Dynamic Morph Target

Version: 7.33.0

Background

Currently (7.33.0) there is no way to update vertex data in a MorphTarget after being added to a MorphTargetManager and rendered. Because in synchronize(), the only method that uploads MorphTarget data to gpu, it only checks the texture size to update, not data inside eash MorphTarget.

Proposal

Add a MorphTargetManager#forceUpdate method that rebuilds the texture data, and upload it to GPU via RawTexture2DArray#update, to avoid disposal and recreation of GPU resources. When underlying data being updated, user should know it, and choose to update the texture or not.

Example here:

Alternatives

  1. Dispose the MorphTargetManager and recreate it, resulting in disposal and recreation of GPU resources, might hurt performance in some cases.
  2. Add a dirty check in MorphTargetManager, when a MorphTarget being updated, mark the MorphTargetManager as dirty, and check it in MorphTargetManager#synchronize(), this would cause extra rendering overhead, making performance of existing static morph target worse.
  3. Add a DynamicMorphTargetManager extends MorphTargetManager, with dirty checks above.
2 Likes