Browse Source

[ts] Temporarily use Physics.update everywhere

Mario Zechner 1 year ago
parent
commit
4598da9a21

+ 1 - 1
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;
 	}

+ 7 - 6
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);

+ 3 - 2
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();
 	}

+ 5 - 5
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;

+ 2 - 1
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();
 	}