|
@@ -28,32 +28,10 @@
|
|
|
|
|
|
|
|
|
<code>
|
|
|
- // 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)
|
|
|
- sphereObject.geometry.computeBoundingBox();
|
|
|
- var BBox = new THREE.Box3(
|
|
|
- sphereObject.geometry.boundingBox.min,
|
|
|
- sphereObject.geometry.boundingBox.max
|
|
|
- );
|
|
|
-
|
|
|
- // Moving the sphere
|
|
|
- sphereObject.position.set( 7, 7, 7 );
|
|
|
-
|
|
|
- // Updating both the bounding box and the helper
|
|
|
- // (to repeat each time the object is moved, rotated or scaled)
|
|
|
- BBox.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
|
|
|
- helper.update();
|
|
|
+ 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 );
|
|
|
</code>
|
|
|
|
|
|
|