BoxHelper.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Object3D] &rarr; [page:Line] &rarr; [page:LineSegments] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Helper object to graphically show the world-axis-aligned bounding box
  14. around an object. The actual bounding box is handled with [page:Box3],
  15. this is just a visual helper for debugging. It can be automatically
  16. resized with the [page:BoxHelper.update] method when the object it's
  17. created from is transformed. Note that the object must have a
  18. [page:BufferGeometry] for this to work, so it won't work with [page:Sprite Sprites].
  19. </p>
  20. <h2>Code Example</h2>
  21. <code>
  22. const sphere = new THREE.SphereGeometry();
  23. const object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) );
  24. const box = new THREE.BoxHelper( object, 0xffff00 );
  25. scene.add( box );
  26. </code>
  27. <h2>Examples</h2>
  28. <p>
  29. [example:webgl_helpers WebGL / helpers]<br />
  30. [example:webgl_loader_nrrd WebGL / loader / nrrd]<br />
  31. [example:webgl_buffergeometry_drawrange WebGL / buffergeometry / drawrange]
  32. </p>
  33. <h2>Constructor</h2>
  34. <h3>[name]( [param:Object3D object], [param:Color color] )</h3>
  35. <p>
  36. [page:Object3D object] -- (optional) the object3D to show the
  37. world-axis-aligned boundingbox.<br />
  38. [page:Color color] -- (optional) hexadecimal value that defines the box's
  39. color. Default is 0xffff00.<br /><br />
  40. Creates a new wireframe box that bounds the passed object. Internally this
  41. uses [page:Box3.setFromObject] to calculate the dimensions. Note that this
  42. includes any children.
  43. </p>
  44. <h2>Properties</h2>
  45. <p>See the base [page:LineSegments] class for common properties.</p>
  46. <h2>Methods</h2>
  47. <p>See the base [page:LineSegments] class for common methods.</p>
  48. <h3>[method:undefined update]()</h3>
  49. <p>
  50. Updates the helper's geometry to match the dimensions of the object,
  51. including any children. See [page:Box3.setFromObject].
  52. </p>
  53. <h3>[method:this setFromObject]( [param:Object3D object] )</h3>
  54. <p>
  55. [page:Object3D object] - [page:Object3D] to create the helper of.<br /><br />
  56. Updates the wireframe box for the passed object.
  57. </p>
  58. <h3>[method:undefined dispose]()</h3>
  59. <p>
  60. Frees the GPU-related resources allocated by this instance. Call this
  61. method whenever this instance is no longer used in your app.
  62. </p>
  63. <h2>Source</h2>
  64. <p>
  65. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  66. </p>
  67. </body>
  68. </html>