From ee57a0c3a8f264de15a8e683a86114daddf0180a Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 29 Jan 2024 21:54:37 -0600 Subject: [PATCH] chore(model): only create skeleton if model needs skinning --- src/lib/model/ModelAnimation.ts | 8 +++++++- src/lib/model/ModelManager.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/model/ModelAnimation.ts b/src/lib/model/ModelAnimation.ts index 88531d5..b0adaa7 100644 --- a/src/lib/model/ModelAnimation.ts +++ b/src/lib/model/ModelAnimation.ts @@ -45,7 +45,9 @@ class ModelAnimation extends THREE.Object3D { this.#playingActions.clear(); this.#suspendedActions.clear(); - this.skeleton.dispose(); + if (this.skeleton) { + this.skeleton.dispose(); + } } resume() { @@ -88,6 +90,10 @@ class ModelAnimation extends THREE.Object3D { } #createSkeleton(boneSpecs: BoneSpec[]) { + if (boneSpecs.length === 0) { + return; + } + const bones: THREE.Bone[] = []; const rootBones: THREE.Bone[] = []; diff --git a/src/lib/model/ModelManager.ts b/src/lib/model/ModelManager.ts index 563a9fe..09a6947 100644 --- a/src/lib/model/ModelManager.ts +++ b/src/lib/model/ModelManager.ts @@ -217,7 +217,7 @@ class ModelManager { return null; } - const animator = new ModelAnimator(spec.loops, spec.sequences, spec.bones); + const animator = new ModelAnimator(spec.loops, spec.sequences, spec.skinned ? spec.bones : []); for (const [index, textureWeight] of spec.textureWeights.entries()) { animator.registerTrack(