-
Notifications
You must be signed in to change notification settings - Fork 111
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
base: dev
Are you sure you want to change the base?
Conversation
cloning many morph attributes takes many CPU resources
… is 1.0, we can use the original as-is
// prevent cloning morph attributes | ||
const originalMorphAttributes = mesh.geometry.morphAttributes; | ||
mesh.geometry.morphAttributes = {}; | ||
|
||
const geometry = mesh.geometry.clone(); |
There was a problem hiding this comment.
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.
// 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]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty straightforward improvement
This PR tries to improve the initial stutter when combineMorphs is used after the loading.