1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:LineSegments] →
- <h1>[name]</h1>
- <p class="desc">
- Helper object to show the world-axis-aligned bounding box around an object.
- It can be used in synergy with [page:Box3] items in order to easily compute the [link:https://en.wikipedia.org/wiki/Minimum_bounding_box Minimum Bounding Boxes] for objects, and use them for fast collision detection. See [page:Box3.intersect].
- 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>
- <h2>Example</h2>
- <div>[example:webgl_helpers WebGL / helpers]</div>
- <div>[example:webgl_loader_nrrd WebGL / loader / nrrd]</div>
- <div>[example:webgl_buffergeometry_drawcalls advanced / buffergeometry / drawcalls]</div>
- <code>
- // Creating the object whose bounding box we want to compute
- var sphereGeom = new THREE.SphereGeometry();
- var sphereObject = new THREE.Mesh( sphereGeom, new THREE.MeshBasicMaterial( 0xff0000 ) );
- // Creating the helper and displaying it in the scene
- var helper = new THREE.BoxHelper( sphereObject, 0xffff00 );
- scene.add( helper );
- // Creating the actual bounding box (on which we can test intersection with other Box3 objects)
- var box3 = new THREE.Box3();
- // Shape and position the box after the helper
- box3.setFromObject( helper );
- // Let's move the sphere
- sphereObject.position.set( 7, 7, 7 );
- // Whenever the object is moved or rotated or scaled:
- helper.update();
- box3.setFromObject( helper );
- </code>
- <h2>Constructor</h2>
- <h3>[name]( [param:Object3D object], [param:Color color] )</h3>
- <p>
- [page:Object3D object] -- (optional) the object3D to show the world-axis-aligned boundingbox.<br />
- [page:Color color] -- (optional) hexadecimal value that defines the box's color. Default is 0xffff00.<br /><br />
- Creates a new wireframe box that bounds the passed object. Internally this uses [page:Box3.setFromObject]
- to calculate the dimensions. Note that this includes any children.
- </p>
- <h2>Properties</h2>
- <p>See the base [page:LineSegments] class for common properties.</p>
- <h2>Methods</h2>
- <p>See the base [page:LineSegments] class for common methods.</p>
- <h3>[method:null update]()</h3>
- <p>
- Updates the helper's geometry to match the dimensions
- of the object, including any children. See [page:Box3.setFromObject].
- </p>
- <h3>[method:BoxHelper setFromObject]( [param:Object3D object] )</h3>
- <p>
- [page:Object3D object] - [page:Object3D] to create the helper of.<br /><br />
- Updates the wireframe box for the passed object.
- </p>
- <h2>Source</h2>
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
- </html>
|