Browse Source

Docs: Clarify Box2/3 descriptions and code example.

Mugen87 5 years ago
parent
commit
7e69e645b3
3 changed files with 27 additions and 28 deletions
  1. 1 1
      docs/api/en/math/Box2.html
  2. 14 16
      docs/api/en/math/Box3.html
  3. 12 11
      docs/api/zh/math/Box3.html

+ 1 - 1
docs/api/en/math/Box2.html

@@ -11,7 +11,7 @@
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
 		<p class="desc">
 		<p class="desc">
-			Represents a box in 2D space.
+			Represents an axis-aligned bounding box (AABB) in 2D space.
 		</p>
 		</p>
 
 
 
 

+ 14 - 16
docs/api/en/math/Box3.html

@@ -11,32 +11,30 @@
 		<h1>[name]</h1>
 		<h1>[name]</h1>
 
 
 		<p class="desc">
 		<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>
 		</p>
 
 
-		
+
 		<h2>Example</h2>
 		<h2>Example</h2>
 
 
 		<code>
 		<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>
 		<h2>Constructor</h2>
 
 
 
 

+ 12 - 11
docs/api/zh/math/Box3.html

@@ -17,20 +17,21 @@
 		<h2>示例</h2>
 		<h2>示例</h2>
 
 
 		<code>
 		<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 );
+
+		// in the animation loop, compute the current bounding box with the world matrix
+		box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );
 		</code>
 		</code>
 
 
 		<h2>构造器(Constructor)</h2>
 		<h2>构造器(Constructor)</h2>