setText with TextGeometry during runtime?

Thanks for ThreeJS, great stuff, good to learn with the examples. One issue that I face currently is that I cannot change the text at runtime. My code:

var text3dparams = {
    size:           0.3,    // size of the text
    height:     0.05,   // thickness to extrude text
    curveSegments: 2,       // number of points on the curves
    font:           'helvetiker',       // font name
    weight:         'normal',       // font weight (normal, bold)
    style:      'normal',       // font style  (normal, italics)
}
var material = new THREE.MeshBasicMaterial({color: 0xFF5555});
var text3d_volume = new THREE.TextGeometry( "V = 300 m³", text3dparams );
var text3dItemV = new THREE.Mesh(text3d_volume, material); 
scene.add(text3dItemV);

I create a cube and label its edges (but labels are not updating the text values): http://www.echteinfach.tv/3d/quader/

Question is, how can the text be changed at runtime?

I hoped there is something like setText(“new text”); but there is not 🙁

Unfortunately, the text example provided in the source is not using TextGeometry. Other examples I found just add the text but never change it at runtime.

PS: I see only one workaround to remove the 3d text and add it again on every update in render()?

Author: Fantashit

3 thoughts on “setText with TextGeometry during runtime?

  1. I finally did the workaround.

    In var render = function () { …. } I remove the 3d text and set it again with the new text values.

    scene.remove(text3dItemV);
    text3d_volume = new THREE.TextGeometry( 'V = new text', text3dparams );
    text3dItemV = new THREE.Mesh(text3d_volume, material); 
    scene.add(text3dItemV);
    

    But it would be great if a setText() method could be added to the core.

Comments are closed.