SelectionBox.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SelectionBox - 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. <h1 translate="no">SelectionBox</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This class can be used to select 3D objects in a scene with a selection box.
  16. It is recommended to visualize the selected area with the help of <a href="SelectionHelper.html">SelectionHelper</a>.</p></div>
  17. <h2>Code Example</h2>
  18. <div translate="no"><pre><code class="language-js">const selectionBox = new SelectionBox( camera, scene );
  19. const selectedObjects = selectionBox.select( startPoint, endPoint );
  20. </code></pre></div>
  21. </header>
  22. <article>
  23. <h2 class="subsection-title">Import</h2>
  24. <p><span translate="no">SelectionBox</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  25. <pre><code class="language-js">import { SelectionBox } from 'three/addons/interactive/SelectionBox.js';</code></pre>
  26. <div class="container-overview">
  27. <h2>Constructor</h2>
  28. <h3 class="name name-method" id="SelectionBox" translate="no">new <a href="#SelectionBox">SelectionBox</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span>, scene : <span class="param-type"><a href="Scene.html">Scene</a></span>, deep : <span class="param-type">number</span> )</span> </h3>
  29. <div class="method">
  30. <div class="description">
  31. <p>Constructs a new selection box.</p>
  32. </div>
  33. <table class="params">
  34. <tbody>
  35. <tr>
  36. <td class="name">
  37. <strong>camera</strong>
  38. </td>
  39. <td class="description last">
  40. <p>The camera the scene is rendered with.</p>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td class="name">
  45. <strong>scene</strong>
  46. </td>
  47. <td class="description last">
  48. <p>The scene.</p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="name">
  53. <strong>deep</strong>
  54. </td>
  55. <td class="description last">
  56. <p>How deep the selection frustum of perspective cameras should extend.</p>
  57. <p>Default is <code>Number.MAX_VALUE</code>.</p>
  58. </td>
  59. </tr>
  60. </tbody>
  61. </table>
  62. </div>
  63. </div>
  64. <h2 class="subsection-title">Properties</h2>
  65. <div class="member">
  66. <h3 class="name" id="batches" translate="no">.<a href="#batches">batches</a><span class="type-signature"> : Object</span> </h3>
  67. <div class="description">
  68. <p>The selected batches of batched meshes.</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  73. <div class="description">
  74. <p>The camera the scene is rendered with.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="collection" translate="no">.<a href="#collection">collection</a><span class="type-signature"> : Array.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  79. <div class="description">
  80. <p>The selected 3D objects.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="deep" translate="no">.<a href="#deep">deep</a><span class="type-signature"> : number</span> </h3>
  85. <div class="description">
  86. <p>How deep the selection frustum of perspective cameras should extend.</p>
  87. <p>Default is <code>Number.MAX_VALUE</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <h3 class="name" id="endPoint" translate="no">.<a href="#endPoint">endPoint</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  92. <div class="description">
  93. <p>The end point of the selection.</p>
  94. </div>
  95. </div>
  96. <div class="member">
  97. <h3 class="name" id="instances" translate="no">.<a href="#instances">instances</a><span class="type-signature"> : Object</span> </h3>
  98. <div class="description">
  99. <p>The selected instance IDs of instanced meshes.</p>
  100. </div>
  101. </div>
  102. <div class="member">
  103. <h3 class="name" id="scene" translate="no">.<a href="#scene">scene</a><span class="type-signature"> : <a href="Scene.html">Scene</a></span> </h3>
  104. <div class="description">
  105. <p>The camera the scene is rendered with.</p>
  106. </div>
  107. </div>
  108. <div class="member">
  109. <h3 class="name" id="startPoint" translate="no">.<a href="#startPoint">startPoint</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  110. <div class="description">
  111. <p>The start point of the selection.</p>
  112. </div>
  113. </div>
  114. <h2 class="subsection-title">Methods</h2>
  115. <h3 class="name name-method" id="select" translate="no">.<a href="#select">select</a><span class="signature">( startPoint : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, endPoint : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : Array.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  116. <div class="method">
  117. <div class="description">
  118. <p>This method selects 3D objects in the scene based on the given start
  119. and end point. If no parameters are provided, the method uses the start
  120. and end values of the respective members.</p>
  121. </div>
  122. <table class="params">
  123. <tbody>
  124. <tr>
  125. <td class="name">
  126. <strong>startPoint</strong>
  127. </td>
  128. <td class="description last">
  129. <p>The start point.</p>
  130. </td>
  131. </tr>
  132. <tr>
  133. <td class="name">
  134. <strong>endPoint</strong>
  135. </td>
  136. <td class="description last">
  137. <p>The end point.</p>
  138. </td>
  139. </tr>
  140. </tbody>
  141. </table>
  142. <dl class="details">
  143. <dt class="tag-returns"><strong>Returns:</strong> The selected 3D objects.</dt>
  144. </dl>
  145. </div>
  146. <h2 class="subsection-title">Source</h2>
  147. <p>
  148. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/interactive/SelectionBox.js" translate="no" target="_blank" rel="noopener">examples/jsm/interactive/SelectionBox.js</a>
  149. </p>
  150. </article>
  151. </section>
  152. <script src="../scripts/linenumber.js"></script>
  153. <script src="../scripts/page.js"></script>
  154. </body>
  155. </html>
粤ICP备19079148号