BoxHelper.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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"><a href="Object3D.html">Object3D</a></span>, color : <span class="param-type">number | <a href="Color.html">Color</a> | 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">
  41. <strong>object</strong>
  42. </td>
  43. <td class="description last">
  44. <p>The 3D object to show the world-axis-aligned bounding box.</p>
  45. </td>
  46. </tr>
  47. <tr>
  48. <td class="name">
  49. <strong>color</strong>
  50. </td>
  51. <td class="description last">
  52. <p>The box's color.</p>
  53. <p>Default is <code>0xffff00</code>.</p>
  54. </td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Properties</h2>
  61. <div class="member">
  62. <h3 class="name" id="object" translate="no">.<a href="#object">object</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  63. <div class="description">
  64. <p>The 3D object being visualized.</p>
  65. </div>
  66. </div>
  67. <h2 class="subsection-title">Methods</h2>
  68. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>Frees the GPU-related resources allocated by this instance. Call this
  72. method whenever this instance is no longer used in your app.</p>
  73. </div>
  74. </div>
  75. <h3 class="name name-method" id="setFromObject" translate="no">.<a href="#setFromObject">setFromObject</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : <a href="BoxHelper.html">BoxHelper</a></span> </h3>
  76. <div class="method">
  77. <div class="description">
  78. <p>Updates the wireframe box for the passed object.</p>
  79. </div>
  80. <table class="params">
  81. <tbody>
  82. <tr>
  83. <td class="name">
  84. <strong>object</strong>
  85. </td>
  86. <td class="description last">
  87. <p>The 3D object to create the helper for.</p>
  88. </td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. <dl class="details">
  93. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  94. </dl>
  95. </div>
  96. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  97. <div class="method">
  98. <div class="description">
  99. <p>Updates the helper's geometry to match the dimensions of the object,
  100. including any children.</p>
  101. </div>
  102. </div>
  103. <h2 class="subsection-title">Source</h2>
  104. <p>
  105. <a href="https://github.com/mrdoob/three.js/blob/master/src/helpers/BoxHelper.js" translate="no" target="_blank" rel="noopener">src/helpers/BoxHelper.js</a>
  106. </p>
  107. </article>
  108. </section>
  109. <script src="../scripts/linenumber.js"></script>
  110. <script src="../scripts/page.js"></script>
  111. </body>
  112. </html>
粤ICP备19079148号