[pixi] Update internals to be more straight forward.

This commit is contained in:
Mario Zechner 2024-06-04 12:24:49 +02:00
parent 62a8216c63
commit e498e96355

View File

@ -177,25 +177,19 @@ export class Spine extends Container {
// Because reasons, pixi uses deltaFrames at 60fps. We ignore the default deltaFrames and use the deltaSeconds from pixi ticker. // 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; const delta = deltaSeconds ?? Ticker.shared.deltaMS / 1000;
this.state.update(delta); this.state.update(delta);
this.state.apply(this.skeleton);
this.skeleton.update(delta); this.skeleton.update(delta);
this.skeleton.updateWorldTransform(Physics.update);
} }
/** Before rendering, apply the state change to the Spine AnimationState and update the skeleton transform, then call the {@link Container.updateTransform}. */ /** Render the meshes based on the current skeleton state, render debug information, then call {@link Container.updateTransform}. */
public override updateTransform (): void { public override updateTransform (): void {
this.updateSpineTransform(); this.renderMeshes();
this.sortChildren();
this.debug?.renderDebug(this); this.debug?.renderDebug(this);
super.updateTransform(); super.updateTransform();
} }
protected updateSpineTransform (): void {
// if I ever create the linked spines, this will be useful.
this.state.apply(this.skeleton);
this.skeleton.updateWorldTransform(Physics.update);
this.updateGeometry();
this.sortChildren();
}
/** Destroy Spine game object elements, then call the {@link Container.destroy} with the given options */ /** Destroy Spine game object elements, then call the {@link Container.destroy} with the given options */
public override destroy (options?: boolean | IDestroyOptions | undefined): void { public override destroy (options?: boolean | IDestroyOptions | undefined): void {
for (const [, mesh] of this.meshesCache) { for (const [, mesh] of this.meshesCache) {
@ -232,7 +226,7 @@ export class Spine extends Container {
private verticesCache: NumberArrayLike = Utils.newFloatArray(1024); private verticesCache: NumberArrayLike = Utils.newFloatArray(1024);
private updateGeometry (): void { private renderMeshes (): void {
this.resetMeshes(); this.resetMeshes();
let triangles: Array<number> | null = null; let triangles: Array<number> | null = null;