Align center TextGeometry in each line break

Hello everyone,
I’m a beginner in three.js. be patient please.
I need to align center TextGeometry in each line break . I have modified dat.gui field input for textarea. I need to imitate the behavior of html with the text align center. I need the same geometry, I don’t want to create a new geometry for each line. When a new line is created the text starts on the left.
This is the expected result when user write :
alingCenter
I have created a jsfiddle with this example https://jsfiddle.net/sanprieto/fk355hcp/
I have managed to center the geometry with the method Geometry.center() and
I have calculated the size with .boundingBox max and min,
Is there any way to get it?

Thanks a lot.

2 Likes

I think it’s not possible to achieve this without modifying TextGeometry.

I need the same geometry, I don’t want to create a new geometry for each line.

You could create a geometry for each line, perform the centering and then merge the geometries into a single one. Would this tradeoff be acceptable to you?

2 Likes

Hi Mugen87,
yes is acceptable, thank you for the answer. My idea is that the user will modify the text, so I need that the changes he makes in dat.gui affect the entire text.