I'm making some 3D text using WebGL
, three.js
, and THREE.TextGeometry
. It's working fine so far. I'm able to create a single line of 3D text.
Now I want to create multiline text, like a short paragraph. Preferably, I'd like it to wrap naturally when it reaches the border of a box/rectangle its placed it in. I want a similar behavior that standard HTML
text has when it's inside of a div, wrapping to multiple lines when it reaches the edge of it's parent div.
Here's how I'm creating a single line:
textGeo = new THREE.TextGeometry(
'Hello there. Am I a paragraph? I hope so.',
'size': 30
'height': 2
'font': 'helvetiker'
'weight': 'normal'
'style': 'normal'
bevelThickness: 0.1
bevelSize: 0
bevelEnabled: true
material: 0
extrudeMaterial: 1
)
materialArray = [
new THREE.MeshBasicMaterial( { color: 0xFFFFFF } )
new THREE.MeshBasicMaterial( { color: 0x666666, shading: THREE.SmoothShading } )
]
textMaterial = new THREE.MeshFaceMaterial(materialArray)
textGeo = new THREE.Mesh(textGeo, textMaterial)
textGeo.position.x = -150
textGeo.rotation.y = de2ra(15)
scene.add textGeo
How can I make this multiline? Also, how can I put this inside a square so it wraps? How do I create the square?