From 2af729c2153ac8e81a07a92cfe998c37dda8c014 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Tue, 5 Dec 2023 21:52:06 -0400 Subject: [PATCH] [ts][player] Call skeleton.update for physics, added config.updateWorldTransform. --- spine-ts/spine-player/src/Player.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spine-ts/spine-player/src/Player.ts b/spine-ts/spine-player/src/Player.ts index 5fa3dcc588..166c048c52 100644 --- a/spine-ts/spine-player/src/Player.ts +++ b/spine-ts/spine-player/src/Player.ts @@ -152,6 +152,9 @@ export interface SpinePlayerConfig { /* Optional: Callback at the start of each frame, before the skeleton is posed or drawn. Default: none */ frame?: (player: SpinePlayer, delta: number) => void + /* Optional: Callback to update the skeleton's world transform. Default: player.skeleton.updateWorldTransform(spine.Physics.update) is called */ + updateWorldTransform?: (player: SpinePlayer, delta: number) => void + /* Optional: Callback after the skeleton is posed each frame, before it is drawn. Default: none */ update?: (player: SpinePlayer, delta: number) => void @@ -815,9 +818,13 @@ export class SpinePlayer implements Disposable { // Update animation time and pose the skeleton. if (!this.paused) { + skeleton.update(playDelta); this.animationState!.update(playDelta); this.animationState!.apply(skeleton); - skeleton.updateWorldTransform(Physics.update); + if (config.updateWorldTransform) + config.updateWorldTransform(this, playDelta); + else + skeleton.updateWorldTransform(Physics.update); if (config.showControls) { this.playTime += playDelta;