refactor: visible bounding box on server only
This commit is contained in:
parent
40f690e4a1
commit
063688b5a6
|
@ -185,25 +185,27 @@ export class Visible extends decorate(Trait) {
|
|||
if (this.shouldSynchronizePosition()) {
|
||||
this.synchronizePosition();
|
||||
}
|
||||
if (this.scheduledBoundingBoxUpdate) {
|
||||
// Collect all bounding boxes.
|
||||
const visibleBoundingBoxes = this.entity.invokeHookFlat(
|
||||
'visibleBoundingBoxes'
|
||||
);
|
||||
if (0 === visibleBoundingBoxes.length) {
|
||||
this.visibleBoundingBox = [0, 0, 0, 0];
|
||||
}
|
||||
else {
|
||||
let unifiedBoundingBox = [0, 0, 0, 0];
|
||||
for (let i = 0; i < visibleBoundingBoxes.length; ++i) {
|
||||
const visibleBoundingBox = visibleBoundingBoxes[i];
|
||||
unifiedBoundingBox = Rectangle.united(
|
||||
unifiedBoundingBox,
|
||||
visibleBoundingBox,
|
||||
);
|
||||
if (AVOCADO_SERVER) {
|
||||
if (this.scheduledBoundingBoxUpdate) {
|
||||
// Collect all bounding boxes.
|
||||
const visibleBoundingBoxes = this.entity.invokeHookFlat(
|
||||
'visibleBoundingBoxes'
|
||||
);
|
||||
if (0 === visibleBoundingBoxes.length) {
|
||||
this.visibleBoundingBox = [0, 0, 0, 0];
|
||||
}
|
||||
else {
|
||||
let unifiedBoundingBox = [0, 0, 0, 0];
|
||||
for (let i = 0; i < visibleBoundingBoxes.length; ++i) {
|
||||
const visibleBoundingBox = visibleBoundingBoxes[i];
|
||||
unifiedBoundingBox = Rectangle.united(
|
||||
unifiedBoundingBox,
|
||||
visibleBoundingBox,
|
||||
);
|
||||
}
|
||||
this.visibleBoundingBox = unifiedBoundingBox;
|
||||
this.scheduledBoundingBoxUpdate = false;
|
||||
}
|
||||
this.visibleBoundingBox = unifiedBoundingBox;
|
||||
this.scheduledBoundingBoxUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user