i have array of text, i want to display multiple text in scene. For this i am loading the font again and again for each value in array.
for(let i=0 ;i<texts.length-1;i++){
loader.load( '/js/fonts/helvetiker_regular.typeface.json', function ( font ) {
shape_text = font.generateShapes( texts[i], 8 );
geometry_text = new THREE.ShapeBufferGeometry( shape_text );
geometry_text.computeBoundingBox();
xMid = - 0.5 * ( geometry_text.boundingBox.max.x - geometry_text.boundingBox.min.x );
geometry_text.translate( xMid, 0, 0 );
text.push( new THREE.Mesh( geometry_text, mat));
scene.add( text[text.length-1] );
});
}
It is bit slower to load font each time. I tried to save font to some variable but returns undefined. Is there any better way to do this.