|
@@ -11,32 +11,30 @@
|
|
|
<h1>[name]</h1>
|
|
|
|
|
|
<p class="desc">
|
|
|
- Represents a box or cube in 3D space. The main purpose of this is to represent
|
|
|
- the world-axis-aligned bounding boxes for objects.
|
|
|
+ Represents an axis-aligned bounding box (AABB) in 3D space.
|
|
|
</p>
|
|
|
|
|
|
-
|
|
|
+
|
|
|
<h2>Example</h2>
|
|
|
|
|
|
<code>
|
|
|
- // Creating the object whose bounding box we want to compute
|
|
|
- var sphereObject = new THREE.Mesh(
|
|
|
- new THREE.SphereGeometry(),
|
|
|
- new THREE.MeshBasicMaterial( 0xff0000 )
|
|
|
+ var box = new THREE.Box3();
|
|
|
+
|
|
|
+ var mesh = new THREE.Mesh(
|
|
|
+ new THREE.SphereBufferGeometry(),
|
|
|
+ new THREE.MeshBasicMaterial()
|
|
|
);
|
|
|
- // Creating the actual bounding box with Box3
|
|
|
- sphereObject.geometry.computeBoundingBox();
|
|
|
- var box = sphereObject.geometry.boundingBox.clone();
|
|
|
+
|
|
|
+ // ensure the bounding box is computed for its geometry
|
|
|
+ // this should be done only once (assuming static geometries)
|
|
|
+ mesh.geometry.computeBoundingBox();
|
|
|
|
|
|
// ...
|
|
|
-
|
|
|
- // In the animation loop, to keep the bounding box updated after move/rotate/scale operations
|
|
|
- sphereObject.updateMatrixWorld( true );
|
|
|
- box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
|
|
|
- </code>
|
|
|
|
|
|
+ // in the animation loop, compute the current bounding box with the world matrix
|
|
|
+ box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );
|
|
|
+ </code>
|
|
|
|
|
|
-
|
|
|
<h2>Constructor</h2>
|
|
|
|
|
|
|