BoxHelper.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BoxHelper - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → <a href="Line.html">Line</a> → <a href="LineSegments.html">LineSegments</a> → </p>
  13. <h1 translate="no">BoxHelper</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Helper object to graphically show the world-axis-aligned bounding box
  17. around an object. The actual bounding box is handled with <a href="Box3.html">Box3</a>,
  18. this is just a visual helper for debugging. It can be automatically
  19. resized with <a href="BoxHelper.html#update">BoxHelper#update</a> when the object it's created from
  20. is transformed. Note that the object must have a geometry for this to work,
  21. so it won't work with sprites.</p></div>
  22. <h2>Code Example</h2>
  23. <div translate="no"><pre><code class="language-js">const sphere = new THREE.SphereGeometry();
  24. const object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) );
  25. const box = new THREE.BoxHelper( object, 0xffff00 );
  26. scene.add( box );
  27. </code></pre></div>
  28. </header>
  29. <article>
  30. <div class="container-overview">
  31. <h2>Constructor</h2>
  32. <h3 class="name name-method" id="BoxHelper" translate="no">new <a href="#BoxHelper">BoxHelper</a><span class="signature">( object : <span class="param-type">Object3D</span>, color : <span class="param-type">number | Color | string</span> )</span> </h3>
  33. <div class="method">
  34. <div class="description">
  35. <p>Constructs a new box helper.</p>
  36. </div>
  37. <table class="params">
  38. <tbody>
  39. <tr>
  40. <td class="name"><code>object</code></td>
  41. <td class="description last"><p>The 3D object to show the world-axis-aligned bounding box.</p></td>
  42. </tr>
  43. <tr>
  44. <td class="name"><code>color</code></td>
  45. <td class="description last"><p>The box's color.<br/>Default is <code>0xffff00</code>.</p></td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <h2 class="subsection-title">Properties</h2>
  52. <div class="member">
  53. <h3 class="name" id="object" translate="no">.<a href="#object">object</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  54. <div class="description">
  55. <p>The 3D object being visualized.</p>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Methods</h2>
  59. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  60. <div class="method">
  61. <div class="description">
  62. <p>Frees the GPU-related resources allocated by this instance. Call this
  63. method whenever this instance is no longer used in your app.</p>
  64. </div>
  65. </div>
  66. <h3 class="name name-method" id="setFromObject" translate="no">.<a href="#setFromObject">setFromObject</a><span class="signature">( object : <span class="param-type">Object3D</span> )</span><span class="type-signature"> : <a href="BoxHelper.html">BoxHelper</a></span> </h3>
  67. <div class="method">
  68. <div class="description">
  69. <p>Updates the wireframe box for the passed object.</p>
  70. </div>
  71. <table class="params">
  72. <tbody>
  73. <tr>
  74. <td class="name"><code>object</code></td>
  75. <td class="description last"><p>The 3D object to create the helper for.</p></td>
  76. </tr>
  77. </tbody>
  78. </table>
  79. <dl class="details">
  80. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  81. </dl>
  82. </div>
  83. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  84. <div class="method">
  85. <div class="description">
  86. <p>Updates the helper's geometry to match the dimensions of the object,
  87. including any children.</p>
  88. </div>
  89. </div>
  90. <h2 class="subsection-title">Source</h2>
  91. <p>
  92. <a href="https://github.com/mrdoob/three.js/blob/master/src/helpers/BoxHelper.js" target="_blank" rel="noopener" translate="no">src/helpers/BoxHelper.js</a>
  93. </p>
  94. </article>
  95. </section>
  96. <script src="../scripts/linenumber.js"></script>
  97. <script src="../scripts/page.js"></script>
  98. </body>
  99. </html>
粤ICP备19079148号