[ts] Aligned Skeleton updateWorldTransformWith with reference runtime. Close #2695.

This commit is contained in:
Davide Tantillo 2024-11-26 16:16:18 +01:00
parent 8c66239ae5
commit dc2bcb02e1

View File

@ -398,6 +398,20 @@ export class Skeleton {
}
updateWorldTransformWith (physics: Physics, parent: Bone) {
if (!parent) throw new Error("parent cannot be null.");
let bones = this.bones;
for (let i = 1, n = bones.length; i < n; i++) { // Skip root bone.
let bone = bones[i];
bone.ax = bone.x;
bone.ay = bone.y;
bone.arotation = bone.rotation;
bone.ascaleX = bone.scaleX;
bone.ascaleY = bone.scaleY;
bone.ashearX = bone.shearX;
bone.ashearY = bone.shearY;
}
// Apply the parent bone transform to the root bone. The root bone always inherits scale, rotation and reflection.
let rootBone = this.getRootBone();
if (!rootBone) throw new Error("Root bone must not be null.");