WebGLMorphtargets: Allow changing number of morph targets #20845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding a new morph target attribute to a mesh after it has been rendered at least once with a material with
morphTargets
set totrue
results in the following error during rendering:The line at error is shown below (with context, from the chrome web tools source viewer):
Based on my understanding of the code, this is because
influences
is populated once the first time that the geometry is rendered (i.e., wheninfluences === undefined
). When a new morph target is added, theninfluences.length
no longer matchesobjectInfluences.length
causing an issue during the iteration of:My proposal is, for simplicity's sake, to simply recreate the influence list when there's been a change in the length. It could be reasonable to add / remove elements from the list as well, but that seems to needlessly complicate things in my personal opinion.
Unfortunately, there doesn't seem to me to be any way to reset the influences list short of creating an entirely new geometry and replacing the old one. I'm still working on trying to find a workaround.