Skip to content

Commit

Permalink
[ts][pixi] Fixed regression on rendering setup pose before update sta…
Browse files Browse the repository at this point in the history
…te (removed internal Ticker). Closes #2539.
  • Loading branch information
davidetan committed Jun 16, 2024
1 parent ccac475 commit 28a503a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions spine-ts/spine-pixi/src/Spine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@ export class Spine extends Container {
}
/** When `true`, the Spine AnimationState and the Skeleton will be automatically updated using the {@link Ticker.shared} instance. */
public set autoUpdate (value: boolean) {
if (value) {
Ticker.shared.add(this.internalUpdate, this);
this.autoUpdateWarned = false;
} else {
Ticker.shared.remove(this.internalUpdate, this);
}
if (value) this.autoUpdateWarned = false;
this._autoUpdate = value;
}

Expand Down Expand Up @@ -171,14 +166,14 @@ export class Spine extends Container {

/** If {@link Spine.autoUpdate} is `false`, this method allows to update the AnimationState and the Skeleton with the given delta. */
public update (deltaSeconds: number): void {
if (this.autoUpdate && !this.autoUpdateWarned) {
if (this._autoUpdate && !this.autoUpdateWarned) {
console.warn("You are calling update on a Spine instance that has autoUpdate set to true. This is probably not what you want.");
this.autoUpdateWarned = true;
}
this.internalUpdate(0, deltaSeconds);
this.internalUpdate(deltaSeconds);
}

protected internalUpdate (_deltaFrame: number, deltaSeconds?: number): void {
protected internalUpdate (deltaSeconds?: number): void {
// Because reasons, pixi uses deltaFrames at 60fps. We ignore the default deltaFrames and use the deltaSeconds from pixi ticker.
const delta = deltaSeconds ?? Ticker.shared.deltaMS / 1000;
this.state.update(delta);
Expand All @@ -191,6 +186,7 @@ export class Spine extends Container {

/** Render the meshes based on the current skeleton state, render debug information, then call {@link Container.updateTransform}. */
public override updateTransform (): void {
if (this._autoUpdate) this.internalUpdate();
this.renderMeshes();
this.sortChildren();
this.debug?.renderDebug(this);
Expand Down

0 comments on commit 28a503a

Please sign in to comment.