Reputation: 1939
I'd like to use the THREE.BoxHelper to create a bounding box for an Object3D that has children. The motivation is so that I can render a wireframe bounding box for the object, without diagonals on the box's faces. Looking at the source code for BoxHelper, it looks like it doesn't take the object's children into account, which is a problem for my app, since every object has children.
Is there a way to get the BoxHelper to include the object's children? Alternatively, is there a good way to use the BoundingBoxHelper (which does include children), and render it without diagonals?
Upvotes: 3
Views: 5044
Reputation: 104813
If you want create a THREE.BoxHelper
for an object that has children, you can use this pattern:
// box helper
boxHelper = new THREE.BoxHelper( parent );
boxHelper.material.color.set( 0xffffff );
scene.add( boxHelper );
In your render loop, you may have to do this:
boxHelper.update();
three.js r.85
Upvotes: 3