From 25acb4caf1d6a036c408fa143973b0f6fc5e88d7 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 30 Apr 2024 09:33:43 +0200 Subject: [PATCH] [ts] Port of commit cb48737 (partially - no copy constructor) --- spine-ts/spine-core/src/IkConstraint.ts | 11 ++++++----- spine-ts/spine-core/src/PathConstraint.ts | 2 ++ spine-ts/spine-core/src/PhysicsConstraint.ts | 2 ++ spine-ts/spine-core/src/TransformConstraint.ts | 14 ++++++++------ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/spine-ts/spine-core/src/IkConstraint.ts b/spine-ts/spine-core/src/IkConstraint.ts index 4652d5c52..268af28a6 100644 --- a/spine-ts/spine-core/src/IkConstraint.ts +++ b/spine-ts/spine-core/src/IkConstraint.ts @@ -69,11 +69,6 @@ export class IkConstraint implements Updatable { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; - this.mix = data.mix; - this.softness = data.softness; - this.bendDirection = data.bendDirection; - this.compress = data.compress; - this.stretch = data.stretch; this.bones = new Array(); for (let i = 0; i < data.bones.length; i++) { @@ -83,7 +78,13 @@ export class IkConstraint implements Updatable { } let target = skeleton.findBone(data.target.name); if (!target) throw new Error(`Couldn't find bone ${data.target.name}`); + this.target = target; + this.mix = data.mix; + this.softness = data.softness; + this.bendDirection = data.bendDirection; + this.compress = data.compress; + this.stretch = data.stretch; } isActive () { diff --git a/spine-ts/spine-core/src/PathConstraint.ts b/spine-ts/spine-core/src/PathConstraint.ts index 8ec8e58f0..b535d70e8 100644 --- a/spine-ts/spine-core/src/PathConstraint.ts +++ b/spine-ts/spine-core/src/PathConstraint.ts @@ -75,6 +75,7 @@ export class PathConstraint implements Updatable { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; + this.bones = new Array(); for (let i = 0, n = data.bones.length; i < n; i++) { let bone = skeleton.findBone(data.bones[i].name); @@ -84,6 +85,7 @@ export class PathConstraint implements Updatable { let target = skeleton.findSlot(data.target.name); if (!target) throw new Error(`Couldn't find target bone ${data.target.name}`); this.target = target; + this.position = data.position; this.spacing = data.spacing; this.mixRotate = data.mixRotate; diff --git a/spine-ts/spine-core/src/PhysicsConstraint.ts b/spine-ts/spine-core/src/PhysicsConstraint.ts index 5b34f5c3d..d90493e53 100644 --- a/spine-ts/spine-core/src/PhysicsConstraint.ts +++ b/spine-ts/spine-core/src/PhysicsConstraint.ts @@ -79,7 +79,9 @@ export class PhysicsConstraint implements Updatable { constructor (data: PhysicsConstraintData, skeleton: Skeleton) { this.data = data; this.skeleton = skeleton; + this.bone = skeleton.bones[data.bone.index]; + this.inertia = data.inertia; this.strength = data.strength; this.damping = data.damping; diff --git a/spine-ts/spine-core/src/TransformConstraint.ts b/spine-ts/spine-core/src/TransformConstraint.ts index 040b0213f..bd786a89d 100644 --- a/spine-ts/spine-core/src/TransformConstraint.ts +++ b/spine-ts/spine-core/src/TransformConstraint.ts @@ -58,12 +58,7 @@ export class TransformConstraint implements Updatable { if (!data) throw new Error("data cannot be null."); if (!skeleton) throw new Error("skeleton cannot be null."); this.data = data; - this.mixRotate = data.mixRotate; - this.mixX = data.mixX; - this.mixY = data.mixY; - this.mixScaleX = data.mixScaleX; - this.mixScaleY = data.mixScaleY; - this.mixShearY = data.mixShearY; + this.bones = new Array(); for (let i = 0; i < data.bones.length; i++) { let bone = skeleton.findBone(data.bones[i].name); @@ -73,6 +68,13 @@ export class TransformConstraint implements Updatable { let target = skeleton.findBone(data.target.name); if (!target) throw new Error(`Couldn't find target bone ${data.target.name}.`); this.target = target; + + this.mixRotate = data.mixRotate; + this.mixX = data.mixX; + this.mixY = data.mixY; + this.mixScaleX = data.mixScaleX; + this.mixScaleY = data.mixScaleY; + this.mixShearY = data.mixShearY; } isActive () {