perf: flat visibleAabb
This commit is contained in:
parent
eb7fdf4f78
commit
7731dca9e7
|
@ -13,13 +13,6 @@ const decorate = compose(
|
|||
StateProperty('isVisible', {
|
||||
track: true,
|
||||
}),
|
||||
Property('visibleAabb', {
|
||||
default: [0, 0, 0, 0],
|
||||
emit: function (...args) {
|
||||
this.entity.emit(...args);
|
||||
},
|
||||
track: true,
|
||||
}),
|
||||
StateProperty('opacity', {
|
||||
track: true,
|
||||
}),
|
||||
|
@ -64,6 +57,7 @@ export class Visible extends decorate(Trait) {
|
|||
this._container.isVisible = this.state.get('isVisible');
|
||||
}
|
||||
this._rawVisibleAabb = [0, 0, 0, 0];
|
||||
this.entity.visibleAabb = [0, 0, 0, 0];
|
||||
this.scheduledBoundingBoxUpdate = true;
|
||||
this.trackPosition = this.params.trackPosition;
|
||||
const scale = this.state.get('visibleScale');
|
||||
|
@ -190,10 +184,11 @@ export class Visible extends decorate(Trait) {
|
|||
}
|
||||
|
||||
translateVisibleAabb() {
|
||||
this.visibleAabb = Rectangle.translated(
|
||||
this.entity.visibleAabb = Rectangle.translated(
|
||||
this._rawVisibleAabb,
|
||||
this.entity.position
|
||||
);
|
||||
this.entity.emit('visibleAabbChanged');
|
||||
}
|
||||
|
||||
tick(elapsed) {
|
||||
|
@ -204,7 +199,7 @@ export class Visible extends decorate(Trait) {
|
|||
'visibleAabbs'
|
||||
);
|
||||
if (0 === visibleAabbs.length) {
|
||||
this.visibleAabb = [0, 0, 0, 0];
|
||||
this._rawVisibleAabb = [0, 0, 0, 0];
|
||||
}
|
||||
else {
|
||||
let unifiedBoundingBox = [0, 0, 0, 0];
|
||||
|
@ -216,9 +211,9 @@ export class Visible extends decorate(Trait) {
|
|||
);
|
||||
}
|
||||
this._rawVisibleAabb = unifiedBoundingBox;
|
||||
this.translateVisibleAabb();
|
||||
this.scheduledBoundingBoxUpdate = false;
|
||||
}
|
||||
this.translateVisibleAabb();
|
||||
this.scheduledBoundingBoxUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user