Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions docs/api/en/helpers/BoxHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<h1>[name]</h1>

<p class="desc">
Helper object to show the world-axis-aligned bounding box around an object.

Helper object to graphically show the world-axis-aligned bounding box around an object. The actual bounding box is handled with [page:Box3], this is just a visual helper for debugging.
It can be automatically resized with the [page:BoxHelper.update] method when the object it's created from is transformed.
Note that the object must have a [page:Geometry] or [page:BufferGeometry] for this to work,
so it won't work with [page:Sprite Sprites].
</p>
Expand All @@ -28,10 +28,25 @@ <h2>Example</h2>


<code>
var sphere = new THREE.SphereGeometry();
var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) );
var box = new THREE.BoxHelper( object, 0xffff00 );
scene.add( box );
// Creating the object whose bounding box we want to compute
var sphereGeom = new THREE.SphereGeometry();
var sphereObject = new THREE.Mesh( sphereGeom, new THREE.MeshBasicMaterial( 0xff0000 ) );

// Creating the helper and displaying it in the scene
var helper = new THREE.BoxHelper( sphereObject, 0xffff00 );
scene.add( helper );

// Creating the actual bounding box (on which we can test intersection with other Box3 objects)
var box3 = new THREE.Box3();
// Shape and position the box after the object
box3.setFromObject( sphere );

// Let's move the sphere
sphereObject.position.set( 7, 7, 7 );

// Whenever the object is moved or rotated or scaled, we update both the bounding box and the helper
helper.update();
box3.setFromObject( sphereObject );
</code>


Expand Down
3 changes: 1 addition & 2 deletions docs/api/en/math/Box3.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ <h1>[name]</h1>

<p class="desc">
Represents a box or cube in 3D space. The main purpose of this is to represent
the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes]
for objects.
the world-axis-aligned bounding boxes for objects, which are used for fast collision detection.
</p>


Expand Down