I make meshes by combining several geometries that all have their own morph animations. I use BufferGeometryUtils.mergeBufferGeometries and that seems to do nothing for my morph information.
So I am looking for more detailed documentation on how the morph info is stored in my object. It looks like a bit is stored in morphAttribute on the geometry, and there are two attributes morphTargetDictionary and morphTargetInfluences on the mesh.
What do they do?
Or maybe from functional to technical: I want to morph a specific set of vertices and normals to new positions. How would I go about building such a morph Animation. Important: I just want to effect this set of vertices. Other vertices must be left untouched as they will be animated by a next morph-what-should-I-call-it.
This last part is vital, the example on the website only seems to touch everything.
The implementation of mergeBufferGeometries assumes that each of ‘M’ BufferGeometry instances being merged has exactly ‘N’ morph targets, and that the 1st morph target of geometry A can be merged with the 1st morph target of geometry B, and so on. All geometries must have the same number of morph targgets. So after merging, it would not be possible to apply the morph target from just one of the original geometries anymore.
You could probably write an alternative version that merges each input geometry’s morph targets with the base positions of the other geometries, so then the final geometry would have N * M morph targets available. This will take more GPU memory, and you’ll only be able to apply 4-8 of those morph targets at a time, but it’s possible.
Is that what you’re asking, or have I misunderstood?
If you can do without merging the geometries, you may find this easier… do you need to merge them? If so, is that because there are too many (e.g. 1000s) to have 1 draw call per mesh? 1000s of morph targets would probably become a problem of its own, if so.
That is very usefull information, I derive from it that I will have to merge the morph data seperately.
But I still need to know how to manually add a morph animation that only effects a given set of vertices. Is that possible? How do I specify which vertices to morph and which to leave alone?
Assuming you have multiple morph targets active at the same time, this will only be possible with the new
geometry.morphTargetsRelative=true option coming in r111. With that enabled, your morph targets should be values you want to have added to the original vertex positions, instead of being the final vertex positions. Just set them to
0, 0, 0 for any vertices you want left alone.