fix: visibleAabb offsets
This commit is contained in:
parent
0e8cb9a924
commit
27afb7de81
|
@ -138,12 +138,16 @@ export class Pictured extends decorate(Trait) {
|
|||
if (!image) {
|
||||
return [0, 0, 0, 0];
|
||||
}
|
||||
const viewPosition = this.offsetFor(key);
|
||||
const size = this.sizeFor(key);
|
||||
const scaledSize = Vector.mul(size, this.entity.rawVisibleScale);
|
||||
const viewPosition = Vector.sub(
|
||||
this.offsetFor(key),
|
||||
Vector.scale(scaledSize, 0.5),
|
||||
);
|
||||
const rectangle = Rectangle.compose(viewPosition, size);
|
||||
const expanded = Rectangle.expand(
|
||||
rectangle,
|
||||
Vector.sub(Vector.mul(size, this.entity.rawVisibleScale), size),
|
||||
Vector.sub(scaledSize, size),
|
||||
);
|
||||
return this._cachedAabbs[key] = expanded;
|
||||
},
|
||||
|
|
|
@ -158,10 +158,9 @@ export class Animated extends decorate(Trait) {
|
|||
if (!this.animationViews) {
|
||||
return;
|
||||
}
|
||||
const rawScale = this._visibleScale;
|
||||
for (const key in this.animationViews) {
|
||||
const animationView = this.animationViews[key];
|
||||
animationView.scale = rawScale;
|
||||
animationView.scale = this.entity.rawVisibleScale;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,12 +187,16 @@ export class Animated extends decorate(Trait) {
|
|||
return [0, 0, 0, 0];
|
||||
}
|
||||
const animation = this.animations[key];
|
||||
const viewPosition = this.offsetFor(key);
|
||||
const size = animation.frameSize;
|
||||
const scaledSize = Vector.mul(size, this.entity.rawVisibleScale);
|
||||
const viewPosition = Vector.sub(
|
||||
this.offsetFor(key),
|
||||
Vector.scale(scaledSize, 0.5),
|
||||
);
|
||||
const rectangle = Rectangle.compose(viewPosition, size);
|
||||
const expanded = Rectangle.expand(
|
||||
rectangle,
|
||||
Vector.sub(Vector.mul(size, this._visibleScale), size),
|
||||
Vector.sub(scaledSize, size),
|
||||
);
|
||||
return this._cachedAabbs[key] = expanded;
|
||||
},
|
||||
|
@ -248,15 +251,8 @@ export class Animated extends decorate(Trait) {
|
|||
}
|
||||
this.loadAnimations();
|
||||
this.loadAnimationImagesIfPossible();
|
||||
if (this.entity.is('visible')) {
|
||||
this._visibleScale = this.entity.rawVisibleScale;
|
||||
}
|
||||
},
|
||||
|
||||
visibleScaleChanged: () => {
|
||||
this._visibleScale = this.entity.rawVisibleScale;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user