Skip to content

Commit

Permalink
chore(model): only create skeleton if model needs skinning
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Jan 30, 2024
1 parent 89ba316 commit ee57a0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/lib/model/ModelAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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[] = [];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/model/ModelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ee57a0c

Please sign in to comment.