Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Clarify Box2/3 descriptions and code example. #18396

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/en/math/Box2.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h1>[name]</h1>

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


Expand Down
30 changes: 14 additions & 16 deletions docs/api/en/math/Box3.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>


Expand Down
23 changes: 12 additions & 11 deletions docs/api/zh/math/Box3.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ <h1>[name]</h1>
<h2>示例</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 );

// 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>
Expand Down