Skip to content Skip to sidebar Skip to footer

Threejs: Computing The Bounding Box Of Rotated Text

On my scene I have a text. After I create it I rotate it to fit the right area. However, the bounding box is completely ignoring the rotation. I've made a fiddle here: http://jsfid

Solution 1:

The geometry does not know anything about rotation. You have two options.

The first option is to rotate your geometry by applying a rotation matrix to the geometry, instead of rotating the mesh. For example,

geometry.rotateZ( Math.PI / 2 );

Now you can call geometry.computeBoundingBox() and you should see what you expect.

The second option is to use Box3.setFromObject( object ) to compute the bounding box of the mesh:

var box = new THREE.Box3().setFromObject( object );

This function computes the world-axis-aligned bounding box of an object (including its children), accounting for both the object's, and children's, world transforms.

EDIT: updated to three.js r.95

Post a Comment for "Threejs: Computing The Bounding Box Of Rotated Text"