未验证 提交 cdbead98 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16339 from jotaro-sama/dev

Improve docs for Box3 and BoxHelper
......@@ -13,8 +13,8 @@
<h1>[name]</h1>
<p class="desc">
Helper object to show the world-axis-aligned bounding box around an object.
Helper object to graphically show the world-axis-aligned bounding box around an object. The actual bounding box is handled with [page:Box3], this is just a visual helper for debugging.
It can be automatically resized with the [page:BoxHelper.update] method when the object it's created from is transformed.
Note that the object must have a [page:Geometry] or [page:BufferGeometry] for this to work,
so it won't work with [page:Sprite Sprites].
</p>
......@@ -28,10 +28,10 @@
<code>
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 );
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>
......
......@@ -12,11 +12,31 @@
<p class="desc">
Represents a box or cube in 3D space. The main purpose of this is to represent
the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes]
for objects.
the world-axis-aligned bounding boxes for objects.
</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 )
);
// Creating the actual bounding box with Box3
sphereObject.geometry.computeBoundingBox();
var box = sphereObject.geometry.boundingBox.clone();
// ...
// 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>
<h2>Constructor</h2>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册