问题
In my scene I have a simple cube:
var test = new THREE.Mesh(new THREE.CubeGeometry(10,10,10), new THREE.MeshBasicMaterial());
scene.add(test);
This cube is getting traversed/scaled through the user with THREE.TransformControls
. What I need is the boundingbox of the cube after these interactions. So I'm doing
test.geometry.computeBoundingBox();
var bb = test.geometry.boundingBox;
bb.translate(test.localToWorld( new THREE.Vector3()));
But I always get a wrong boundingbox! The translation is computed correct, but not the scale. The width and heigth of the boundingbox is always 10 ...
Is this a bug or feature? How do I get the correct boundingbox of my cube?
回答1:
You can compute the world-axis-aligned bounding box of an object (including its children) like so:
var box = new THREE.Box3();
box.setFromObject( object );
Have a look at the source code so you understand what it is doing.
three.js. r.60
来源:https://stackoverflow.com/questions/18461480/three-js-wrong-boundingbox-after-scaling-a-geometry