Skip to content

Commit

Permalink
perf: combineMorphs, if there is only one morph target and the weight…
Browse files Browse the repository at this point in the history
… is 1.0, we can use the original as-is
  • Loading branch information
0b5vr committed Dec 10, 2024
1 parent 850c04f commit 2dfda5c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/three-vrm/src/VRMUtils/combineMorphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ function collectMeshes(scene: THREE.Group): Set<THREE.Mesh> {

function combineMorph(
positionAttributes: (THREE.BufferAttribute | THREE.InterleavedBufferAttribute)[],
binds: Iterable<VRMExpressionMorphTargetBind>,
binds: Set<VRMExpressionMorphTargetBind>,
morphTargetsRelative: boolean,
): THREE.BufferAttribute {
): THREE.BufferAttribute | THREE.InterleavedBufferAttribute {
// if there is only one morph target and the weight is 1.0, we can use the original as-is
if (binds.size === 1) {
const bind = binds.values().next().value!;
if (bind.weight === 1.0) {
return positionAttributes[bind.index];
}
}

const newArray = new Float32Array(positionAttributes[0].count * 3);
let weightSum = 0.0;

Expand Down

0 comments on commit 2dfda5c

Please sign in to comment.