Skip to content

Commit

Permalink
chore(model): avoid creating unnecessary texture weight tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Feb 1, 2024
1 parent 9026ae6 commit c7bc88b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/lib/model/ModelManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,21 @@ class ModelManager {

const animator = new ModelAnimator(spec.loops, spec.sequences, spec.skinned ? spec.bones : []);

for (const [index, textureWeight] of spec.textureWeights.entries()) {
animator.registerTrack(
{ state: 'textureWeights', index },
textureWeight.weightTrack,
THREE.NumberKeyframeTrack,
(value: number) => value / 0x7fff,
);
const hasTextureWeights =
spec.textureWeights.length > 1 ||
spec.textureWeights[0]?.weightTrack.sequenceKeys.length > 1 ||
spec.textureWeights[0]?.weightTrack.sequenceKeys[0].length > 1 ||
spec.textureWeights[0]?.weightTrack.sequenceKeys[0][0] !== 0x7fff;

if (hasTextureWeights) {
for (const [index, textureWeight] of spec.textureWeights.entries()) {
animator.registerTrack(
{ state: 'textureWeights', index },
textureWeight.weightTrack,
THREE.NumberKeyframeTrack,
(value: number) => value / 0x7fff,
);
}
}

for (const [index, textureTransform] of spec.textureTransforms.entries()) {
Expand Down

0 comments on commit c7bc88b

Please sign in to comment.