Handle multiple instances of TextGeometry

Hi,

I have a JSON object containing multiple words and would like to display them one at a time, updating every second. Which is the best way to do this? Should I update the TextGeometry inside the mesh or should I create a mesh for each word and if so, how do I store these and iterate over them (group, traverse etc)?

Two solutions come in my mind. A simple approach and a more complex (but faster) one:

The idea is to create a mesh per word and manage them in an array. Updating the geometry is not something I would advice since the idea of geometry generators (like TextBufferGeometry) is to create an instance and then just use it. You can use the Object3D.visible property to configure whether a mesh should be rendered or not.

The more complex approach is to create a single mesh and then use BufferGeometry.drawRange to decide what part of the geometry (what words) should be rendered. However, this solution only works if you know the exact range of each word which is probably time-consuming to determine. It will be faster since the geometry buffers only needs to be uploaded a single time.

2 Likes