Browse Source

fix box3 example

jotaro-sama 6 years ago
parent
commit
480fd36a21
1 changed files with 7 additions and 13 deletions
  1. 7 13
      docs/api/en/math/Box3.html

+ 7 - 13
docs/api/en/math/Box3.html

@@ -20,25 +20,19 @@
 
 		<code>
 		// Creating the object whose bounding box we want to compute
-		var sphereGeom = new THREE.SphereGeometry();
 		var sphereObject = new THREE.Mesh( 
-			sphereGeom, 
+			new THREE.SphereGeometry(), 
 			new THREE.MeshBasicMaterial( 0xff0000 ) 
 		);
-
 		// Creating the actual bounding box with Box3
 		sphereObject.geometry.computeBoundingBox();
-		var BBox = new THREE.Box3(
-			sphereObject.geometry.boundingBox.min,
-  			sphereObject.geometry.boundingBox.max
-		);
+		var box = sphereObject.geometry.boundingBox.clone();
 
-		// Moving the sphere
-		sphereObject.position.set( 7, 7, 7 );
-
-		// Updating the bounding box
-		// (to repeat each time the object is moved, rotated or scaled) 
-		BBox.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
+		// ...
+		
+		// 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>