Experience-Monks / three-bmfont-text

renders BMFont files in ThreeJS with word-wrapping
http://jam3.github.io/three-bmfont-text/test/
MIT License
786 stars 169 forks source link

Merging text geometries is difficult #4

Open kig opened 8 years ago

kig commented 8 years ago

In making the text renderer for https://tabletree.io and http://fhtr.org/textclock I had to do a couple of optimizations to get decent performance. THREE.js objects are pretty heavy, so you'll run into trouble after a few hundred of them. For better performance, you need to merge the text geometries into a single big geometry.

The three-bmfont-text text geometries use vertex indices and are defined as arrays of vec2s. This works a-ok if you don't need to merge geometries. But if you do need to merge geometries, using vec4s for position allows you to position the text verts in 3D (and you get to use the w-coord for random shenanigans.) Additionally, using unindexed vertices makes it a lot simpler to merge two geometries together, for a small bandwidth hit, and a small bufferData speed boost (drawElements has to validate all the element indices).

mattdesl commented 8 years ago

Yup, I was thinking maybe it would be good to have a more generic module that just provides vertex data in flat arrays. It can be optimized to reduce GC etc, and could be generic enough that it doesn't need to depend on ThreeJS.

mister-walter commented 7 years ago

I'm also interested in merging geometries for performance purposes - is there anything I can do to help the PR get merged?