[ts][player] Calculates animation viewport using new Skeleton.getBounds that considers clipping.

This commit is contained in:
Davide Tantillo 2024-05-03 10:56:07 +02:00
parent f3097222f9
commit 03f8f67e01

View File

@ -771,10 +771,11 @@ export class SpinePlayer implements Disposable {
let minX = 100000000, maxX = -100000000, minY = 100000000, maxY = -100000000;
let offset = new Vector2(), size = new Vector2();
const tempArray = new Array<number>(2);
for (let i = 0; i < steps; i++, time += stepTime) {
animation.apply(this.skeleton!, time, time, false, [], 1, MixBlend.setup, MixDirection.mixIn);
this.skeleton!.updateWorldTransform(Physics.update);
this.skeleton!.getBounds(offset, size);
this.skeleton!.getBounds(offset, size, tempArray, this.sceneRenderer!.skeletonRenderer.getSkeletonClipping());
if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) {
minX = Math.min(offset.x, minX);