javascript - How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div? -


i'm making 3d text using webgl, three.js, , three.textgeometry. it's working fine far. i'm able create single line of 3d text.

now want create multiline text, short paragraph. preferably, i'd wrap naturally when reaches border of box/rectangle placed in. want similar behavior standard html text has when it's inside of div, wrapping multiple lines when reaches edge of it's parent div.

here's how i'm creating single line:

 textgeo = new three.textgeometry(     'hello there. paragraph? 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 make multiline? also, how can put inside square wraps? how create square?

one approach might draw text in html , render in 3d scene.

the other approach instantiate text, test how large is, , split multiple textgeometry instances if larger maximum desired width, offset on y-axis height. can dimensions of geometry geometry.boundingbox (after calling geometry.computeboundingbox()) three.box3. bounding boxes have min , max properties vectors representing opposite corner vertices, can dimensions of geometry along given axis calling e.g.:

geometry.boundingbox.max.x - geometry.boundingbox.min.x 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -