How To Add A String With Superscript In An Three.textgeometry?
I'm working on a dimensioning tool with Three.js. I would like to write dimensioning of distances over a line between two objects. I want to write 2.455 as shown in the picture.
Solution 1:
The Font
you load must support the characters you want to use.
After a brief inspection, I was able to find "²" in the helvetiker_regular.typeface.json
font file. That does not guarantee that it will include the characters you're looking for. For example, I was unable to find a definition for "⁶" in the same file.
Of course, the easiest workaround is to create normal-scale numbers, then scale/position them into a suberscript position. Three.js also provides methods for combining geometries, so you would make fewer meshes in the process (addressing your "not clean" concern).
Solution 2:
A solution could be the use of the following characters:
⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹
Those are created via ALT characters. link
They should work in Three.js.
Post a Comment for "How To Add A String With Superscript In An Three.textgeometry?"