Skip to content

Commit

Permalink
[ts][player] Call skeleton.update for physics, added config.updateWor…
Browse files Browse the repository at this point in the history
…ldTransform.
  • Loading branch information
NathanSweet committed Dec 6, 2023
1 parent 02911a2 commit 2af729c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion spine-ts/spine-player/src/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2af729c

Please sign in to comment.