From f8a125aa8a3d91a5ad2b7186c4b69125210fc8f9 Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Mon, 15 Sep 2025 11:32:57 +0200 Subject: [PATCH] [ts] Port of commit 48355c2, abb4362: PhysicsConstraint fixes. --- spine-ts/spine-core/src/PhysicsConstraint.ts | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/spine-ts/spine-core/src/PhysicsConstraint.ts b/spine-ts/spine-core/src/PhysicsConstraint.ts index c8da7636c..2e38ba645 100644 --- a/spine-ts/spine-core/src/PhysicsConstraint.ts +++ b/spine-ts/spine-core/src/PhysicsConstraint.ts @@ -27,10 +27,10 @@ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -import { BonePose } from "./BonePose.js"; +import type { BonePose } from "./BonePose.js"; import { Constraint } from "./Constraint.js"; import { Physics } from "./Physics.js"; -import { PhysicsConstraintData } from "./PhysicsConstraintData.js"; +import type { PhysicsConstraintData } from "./PhysicsConstraintData.js"; import { PhysicsConstraintPose } from "./PhysicsConstraintPose.js"; import { Skeleton } from "./Skeleton.js"; import { MathUtils } from "./Utils.js"; @@ -125,10 +125,10 @@ export class PhysicsConstraint extends Constraint= t) { - let xs = this.xOffset, ys = this.yOffset; - d = Math.pow(p.damping, 60 * t); + const xs = this.xOffset, ys = this.yOffset; + d = p.damping ** (60 * t); m = t * p.massInverse; e = p.strength; - let w = f * p.wind, g = f * p.gravity; - ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX; - ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY; + const w = f * p.wind, g = f * p.gravity; + const ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX; + const ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY; do { if (x) { this.xVelocity += (ax - this.xOffset * e) * m; @@ -182,7 +182,7 @@ export class PhysicsConstraint extends Constraint qx) dx = qx; else if (dx < -qx) // @@ -207,19 +207,18 @@ export class PhysicsConstraint extends Constraint 0) this.scaleOffset += (dx * c + dy * s) * i / r; } if (a >= t) { - if (d == -1) { - d = Math.pow(p.damping, 60 * t); + if (d === -1) { + d = p.damping ** (60 * t); m = t * p.massInverse; e = p.strength; - const w = f * p.wind, g = f * p.gravity * Skeleton.yDir; - ax = (w * skeleton.windX + g * skeleton.gravityX) * skeleton.scaleX; - ay = (w * skeleton.windY + g * skeleton.gravityY) * skeleton.scaleY; } - let rs = this.rotateOffset, ss = this.scaleOffset, h = l / f + const ax = p.wind * skeleton.windX + p.gravity * skeleton.gravityX; + const ay = (p.wind * skeleton.windY + p.gravity * skeleton.gravityY) * Skeleton.yDir; + const rs = this.rotateOffset, ss = this.scaleOffset, h = l / f; while (true) { a -= t; if (scaleX) { @@ -248,6 +247,7 @@ export class PhysicsConstraint extends Constraint