From 4598da9a2198419dff4810f22064bf98ab01dce6 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 26 Nov 2023 12:58:14 +0100 Subject: [PATCH] [ts] Temporarily use Physics.update everywhere --- spine-ts/spine-core/src/AnimationState.ts | 2 +- spine-ts/spine-phaser/src/SpineGameObject.ts | 13 +++++++------ spine-ts/spine-pixi/src/Spine.ts | 5 +++-- spine-ts/spine-player/src/Player.ts | 10 +++++----- spine-ts/spine-threejs/src/SkeletonMesh.ts | 3 ++- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/spine-ts/spine-core/src/AnimationState.ts b/spine-ts/spine-core/src/AnimationState.ts index 20c7c1b20..6ad716c6c 100644 --- a/spine-ts/spine-core/src/AnimationState.ts +++ b/spine-ts/spine-core/src/AnimationState.ts @@ -945,7 +945,7 @@ export class TrackEntry { } set mixDuration (mixDuration: number) { - this.mixDuration = mixDuration; + this._mixDuration = mixDuration; if (this.previous != null && this.delay <= 0) this.delay += this.previous.getTrackComplete() - mixDuration; this.delay = this.delay; } diff --git a/spine-ts/spine-phaser/src/SpineGameObject.ts b/spine-ts/spine-phaser/src/SpineGameObject.ts index e05ea0e61..55659fdc5 100644 --- a/spine-ts/spine-phaser/src/SpineGameObject.ts +++ b/spine-ts/spine-phaser/src/SpineGameObject.ts @@ -44,6 +44,7 @@ import { AnimationStateData, Bone, MathUtils, + Physics, Skeleton, Skin, Vector2, @@ -75,7 +76,7 @@ export class SetupPoseBoundsProvider implements SpineGameObjectBoundsProvider { // reconstruct that state. const skeleton = new Skeleton(gameObject.skeleton.data); skeleton.setToSetupPose(); - skeleton.updateWorldTransform(); + skeleton.updateWorldTransform(Physics.update); const bounds = skeleton.getBoundsRect(); return bounds.width == Number.NEGATIVE_INFINITY ? { x: 0, y: 0, width: 0, height: 0 } @@ -125,7 +126,7 @@ export class SkinsAndAnimationBoundsProvider const animation = this.animation != null ? data.findAnimation(this.animation!) : null; if (animation == null) { - skeleton.updateWorldTransform(); + skeleton.updateWorldTransform(Physics.update); const bounds = skeleton.getBoundsRect(); return bounds.width == Number.NEGATIVE_INFINITY ? { x: 0, y: 0, width: 0, height: 0 } @@ -141,7 +142,7 @@ export class SkinsAndAnimationBoundsProvider for (let i = 0; i < steps; i++) { animationState.update(i > 0 ? this.timeStep : 0); animationState.apply(skeleton); - skeleton.updateWorldTransform(); + skeleton.updateWorldTransform(Physics.update); const bounds = skeleton.getBoundsRect(); minX = Math.min(minX, bounds.x); @@ -218,7 +219,7 @@ export class SpineGameObject extends DepthMixin( this.skeleton = this.plugin.createSkeleton(dataKey, atlasKey); this.animationStateData = new AnimationStateData(this.skeleton.data); this.animationState = new AnimationState(this.animationStateData); - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); this.updateSize(); } @@ -283,7 +284,7 @@ export class SpineGameObject extends DepthMixin( this.animationState.update(delta / 1000); this.animationState.apply(this.skeleton); this.beforeUpdateWorldTransforms(this); - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); this.afterUpdateWorldTransforms(this); } @@ -387,7 +388,7 @@ export class SpineGameObject extends DepthMixin( skeleton.scaleY = transform.scaleY; let root = skeleton.getRootBone()!; root.rotation = -MathUtils.radiansToDegrees * transform.rotationNormalized; - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); context.save(); skeletonRenderer.draw(skeleton); diff --git a/spine-ts/spine-pixi/src/Spine.ts b/spine-ts/spine-pixi/src/Spine.ts index 71f3215a3..d4f07decb 100644 --- a/spine-ts/spine-pixi/src/Spine.ts +++ b/spine-ts/spine-pixi/src/Spine.ts @@ -35,6 +35,7 @@ import { ClippingAttachment, Color, MeshAttachment, + Physics, RegionAttachment, Skeleton, SkeletonBinary, @@ -123,7 +124,7 @@ export class Spine extends Container { this.autoUpdate = options?.autoUpdate ?? true; this.slotMeshFactory = options?.slotMeshFactory ?? ((): ISlotMesh => new SlotMesh()); this.skeleton.setToSetupPose(); - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); } public update (deltaSeconds: number): void { @@ -149,7 +150,7 @@ export class Spine extends Container { // if I ever create the linked spines, this will be useful. this.state.apply(this.skeleton); - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); this.updateGeometry(); this.sortChildren(); } diff --git a/spine-ts/spine-player/src/Player.ts b/spine-ts/spine-player/src/Player.ts index 050d70775..5fa3dcc58 100644 --- a/spine-ts/spine-player/src/Player.ts +++ b/spine-ts/spine-player/src/Player.ts @@ -27,7 +27,7 @@ * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -import { Animation, AnimationState, AnimationStateData, AtlasAttachmentLoader, Bone, Color, Disposable, Downloader, MathUtils, MixBlend, MixDirection, Skeleton, SkeletonBinary, SkeletonData, SkeletonJson, StringMap, TextureAtlas, TextureFilter, TimeKeeper, TrackEntry, Vector2 } from "@esotericsoftware/spine-core" +import { Animation, AnimationState, AnimationStateData, AtlasAttachmentLoader, Bone, Color, Disposable, Downloader, MathUtils, MixBlend, MixDirection, Physics, Skeleton, SkeletonBinary, SkeletonData, SkeletonJson, StringMap, TextureAtlas, TextureFilter, TimeKeeper, TrackEntry, Vector2 } from "@esotericsoftware/spine-core" import { AssetManager, GLTexture, Input, LoadingScreen, ManagedWebGLRenderingContext, ResizeMode, SceneRenderer, Vector3 } from "@esotericsoftware/spine-webgl" export interface SpinePlayerConfig { @@ -370,7 +370,7 @@ export class SpinePlayer implements Disposable { let time = animationDuration * percentage; this.animationState!.update(time - this.playTime); this.animationState!.apply(this.skeleton!); - this.skeleton!.updateWorldTransform(); + this.skeleton!.updateWorldTransform(Physics.update); this.playTime = time; }; @@ -542,7 +542,7 @@ export class SpinePlayer implements Disposable { } else { entry = this.animationState.setEmptyAnimation(0); entry.trackEnd = 100000000; - this.skeleton.updateWorldTransform(); + this.skeleton.updateWorldTransform(Physics.update); this.setViewport(entry.animation!); this.pause(); } @@ -769,7 +769,7 @@ export class SpinePlayer implements Disposable { for (let i = 0; i < steps; i++, time += stepTime) { animation.apply(this.skeleton!, time, time, false, [], 1, MixBlend.setup, MixDirection.mixIn); - this.skeleton!.updateWorldTransform(); + this.skeleton!.updateWorldTransform(Physics.update); this.skeleton!.getBounds(offset, size); if (!isNaN(offset.x) && !isNaN(offset.y) && !isNaN(size.x) && !isNaN(size.y)) { @@ -817,7 +817,7 @@ export class SpinePlayer implements Disposable { if (!this.paused) { this.animationState!.update(playDelta); this.animationState!.apply(skeleton); - skeleton.updateWorldTransform(); + skeleton.updateWorldTransform(Physics.update); if (config.showControls) { this.playTime += playDelta; diff --git a/spine-ts/spine-threejs/src/SkeletonMesh.ts b/spine-ts/spine-threejs/src/SkeletonMesh.ts index 694174851..1b622062c 100644 --- a/spine-ts/spine-threejs/src/SkeletonMesh.ts +++ b/spine-ts/spine-threejs/src/SkeletonMesh.ts @@ -35,6 +35,7 @@ import { Color, MeshAttachment, NumberArrayLike, + Physics, RegionAttachment, Skeleton, SkeletonClipping, @@ -137,7 +138,7 @@ export class SkeletonMesh extends THREE.Object3D { state.update(deltaTime); state.apply(skeleton); - skeleton.updateWorldTransform(); + skeleton.updateWorldTransform(Physics.update); this.updateGeometry(); }