setFromObject to align with the object, not the world

Hi,

Is there a way for the setFromObject to align a box with the object itself, not with the world.

we compute the the box like that:

    box = new THREE.Box3();
    box.setFromObject(object);
    // w.r.t object
    var worldToLocal = new THREE.Matrix4();
    worldToLocal.getInverse(object.matrixWorld);
    box.applyMatrix4(worldToLocal);

Here is what the resultant box currently look like
current

Here is what it should look like if it was aligned with the object
setfromobject

You can rotate and align the object along the axis, then call .setFromObject(), getting the desired box and then set the rotation of the object back.

1 Like

This issue was already discussed at github.

2 Likes