Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of combineMorphs #1553

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

0b5vr
Copy link
Contributor

@0b5vr 0b5vr commented Dec 10, 2024

This PR tries to improve the initial stutter when combineMorphs is used after the loading.

cloning many morph attributes takes many CPU resources
@0b5vr 0b5vr added the performance Performance issue label Dec 10, 2024
@0b5vr 0b5vr added this to the next milestone Dec 10, 2024
@0b5vr 0b5vr requested a review from ke456-png December 10, 2024 09:04
@0b5vr 0b5vr self-assigned this Dec 10, 2024
// prevent cloning morph attributes
const originalMorphAttributes = mesh.geometry.morphAttributes;
mesh.geometry.morphAttributes = {};

const geometry = mesh.geometry.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, cloning takes many CPU resources if the model has many morph attributes. the L121 prevents cloning morph attributes.

Comment on lines +27 to +33
// 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];
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty straightforward improvement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant