From b74ba4cab2c59ac8b3f13972d30b5fbb5d7bae92 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Fri, 30 May 2025 15:34:49 +0200 Subject: [PATCH] [ts] Port to 4.3 fixes (WIP) --- spine-ts/spine-canvas/src/SkeletonRenderer.ts | 1 - spine-ts/spine-core/src/Animation.ts | 4 +--- spine-ts/spine-core/src/BonePose.ts | 10 +++++----- spine-ts/spine-core/src/IkConstraint.ts | 6 +++--- spine-ts/spine-core/src/SkeletonJson.ts | 3 ++- spine-ts/spine-core/src/TransformConstraintData.ts | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/spine-ts/spine-canvas/src/SkeletonRenderer.ts b/spine-ts/spine-canvas/src/SkeletonRenderer.ts index 076a446f3..af5a2dc85 100644 --- a/spine-ts/spine-canvas/src/SkeletonRenderer.ts +++ b/spine-ts/spine-canvas/src/SkeletonRenderer.ts @@ -123,7 +123,6 @@ export class SkeletonRenderer { let attachment = pose.attachment; let texture: HTMLImageElement; - let region: TextureAtlasRegion; if (attachment instanceof RegionAttachment) { let regionAttachment = attachment; vertices = this.computeRegionVertices(slot, regionAttachment, false); diff --git a/spine-ts/spine-core/src/Animation.ts b/spine-ts/spine-core/src/Animation.ts index f10ebe926..d9371fd3c 100644 --- a/spine-ts/spine-core/src/Animation.ts +++ b/spine-ts/spine-core/src/Animation.ts @@ -669,13 +669,11 @@ export class TranslateYTimeline extends BoneTimeline1 { /** Changes a bone's local {@link BoneLocal.scaleX} and {@link BoneLocal.scaleY}. */ export class ScaleTimeline extends BoneTimeline2 { - boneIndex = 0; - constructor (frameCount: number, bezierCount: number, boneIndex: number) { super(frameCount, bezierCount, boneIndex, Property.scaleX, Property.scaleY); } - protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend,direction: MixDirection) { + protected apply1 (pose: BoneLocal, setup: BoneLocal, time: number, alpha:number, blend: MixBlend, direction: MixDirection) { let frames = this.frames; if (time < frames[0]) { switch (blend) { diff --git a/spine-ts/spine-core/src/BonePose.ts b/spine-ts/spine-core/src/BonePose.ts index eeb67b8fc..158f878dd 100644 --- a/spine-ts/spine-core/src/BonePose.ts +++ b/spine-ts/spine-core/src/BonePose.ts @@ -63,7 +63,7 @@ export class BonePose extends BoneLocal implements Update { /** Called by {@link Skeleton#updateCache()} to compute the world transform, if needed. */ public update (skeleton: Skeleton, physics: Physics): void { - if (this.world != skeleton._update) this.updateWorldTransform(skeleton); + if (this.world !== skeleton._update) this.updateWorldTransform(skeleton); } /** Computes the world transform using the parent bone's applied pose and this pose. Child bones are not updated. @@ -71,17 +71,17 @@ export class BonePose extends BoneLocal implements Update { * See World transforms in the Spine * Runtimes Guide. */ updateWorldTransform (skeleton: Skeleton): void { - if (this.local == skeleton._update) + if (this.local === skeleton._update) this.updateLocalTransform(skeleton); else this.world = skeleton._update; - const rotation = this.rotation; + let rotation = this.rotation; const scaleX = this.scaleX; const scaleY = this.scaleY; const shearX = this.shearX; const shearY = this.shearY; - if (this.bone.parent == null) { // Root bone. + if (!this.bone.parent) { // Root bone. const sx = skeleton.scaleX, sy = skeleton.scaleY; const rx = (rotation + shearX) * MathUtils.degRad; const ry = (rotation + 90 + shearY) * MathUtils.degRad; @@ -152,7 +152,7 @@ export class BonePose extends BoneLocal implements Update { } case Inherit.NoScale: case Inherit.NoScaleOrReflection: { - this.rotation *= MathUtils.degRad; + rotation *= MathUtils.degRad; const cos = Math.cos(rotation), sin = Math.sin(rotation); let za = (pa * cos + pb * sin) / skeleton.scaleX; let zc = (pc * cos + pd * sin) / skeleton.scaleY; diff --git a/spine-ts/spine-core/src/IkConstraint.ts b/spine-ts/spine-core/src/IkConstraint.ts index 6f7e5f0a4..f050f547c 100644 --- a/spine-ts/spine-core/src/IkConstraint.ts +++ b/spine-ts/spine-core/src/IkConstraint.ts @@ -68,8 +68,8 @@ export class IkConstraint extends Constraint(); + offsets = [0, 0, 0, 0, 0, 0]; /** An offset added to the constrained bone X translation. */ offsetX = 0;