Skip to content

Commit c466bb3

Browse files
authored
Merge pull request #18396 from Mugen87/dev32
Docs: Clarify Box2/3 descriptions and code example.
2 parents 2d47b40 + 7e69e64 commit c466bb3

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

docs/api/en/math/Box2.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<h1>[name]</h1>
1212

1313
<p class="desc">
14-
Represents a box in 2D space.
14+
Represents an axis-aligned bounding box (AABB) in 2D space.
1515
</p>
1616

1717

docs/api/en/math/Box3.html

+14-16
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,30 @@
1111
<h1>[name]</h1>
1212

1313
<p class="desc">
14-
Represents a box or cube in 3D space. The main purpose of this is to represent
15-
the world-axis-aligned bounding boxes for objects.
14+
Represents an axis-aligned bounding box (AABB) in 3D space.
1615
</p>
1716

18-
17+
1918
<h2>Example</h2>
2019

2120
<code>
22-
// Creating the object whose bounding box we want to compute
23-
var sphereObject = new THREE.Mesh(
24-
new THREE.SphereGeometry(),
25-
new THREE.MeshBasicMaterial( 0xff0000 )
21+
var box = new THREE.Box3();
22+
23+
var mesh = new THREE.Mesh(
24+
new THREE.SphereBufferGeometry(),
25+
new THREE.MeshBasicMaterial()
2626
);
27-
// Creating the actual bounding box with Box3
28-
sphereObject.geometry.computeBoundingBox();
29-
var box = sphereObject.geometry.boundingBox.clone();
27+
28+
// ensure the bounding box is computed for its geometry
29+
// this should be done only once (assuming static geometries)
30+
mesh.geometry.computeBoundingBox();
3031

3132
// ...
32-
33-
// In the animation loop, to keep the bounding box updated after move/rotate/scale operations
34-
sphereObject.updateMatrixWorld( true );
35-
box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
36-
</code>
3733

34+
// in the animation loop, compute the current bounding box with the world matrix
35+
box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );
36+
</code>
3837

39-
4038
<h2>Constructor</h2>
4139

4240

docs/api/zh/math/Box3.html

+12-11
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@ <h1>[name]</h1>
1717
<h2>示例</h2>
1818

1919
<code>
20-
// Creating the object whose bounding box we want to compute
21-
var sphereObject = new THREE.Mesh(
22-
new THREE.SphereGeometry(),
23-
new THREE.MeshBasicMaterial( 0xff0000 )
20+
var box = new THREE.Box3();
21+
22+
var mesh = new THREE.Mesh(
23+
new THREE.SphereBufferGeometry(),
24+
new THREE.MeshBasicMaterial()
2425
);
25-
// Creating the actual bounding box with Box3
26-
sphereObject.geometry.computeBoundingBox();
27-
var box = sphereObject.geometry.boundingBox.clone();
26+
27+
// ensure the bounding box is computed for its geometry
28+
// this should be done only once (assuming static geometries)
29+
mesh.geometry.computeBoundingBox();
2830

2931
// ...
30-
31-
// In the animation loop, to keep the bounding box updated after move/rotate/scale operations
32-
sphereObject.updateMatrixWorld( true );
33-
box.copy( sphereObject.geometry.boundingBox ).applyMatrix4( sphereObject.matrixWorld );
32+
33+
// in the animation loop, compute the current bounding box with the world matrix
34+
box.copy( mesh.geometry.boundingBox ).applyMatrix4( mesh.matrixWorld );
3435
</code>
3536

3637
<h2>构造器(Constructor)</h2>

0 commit comments

Comments
 (0)