ViewHelper.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ViewHelper - 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> → </p>
  13. <h1 translate="no">ViewHelper</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A special type of helper that visualizes the camera's transformation
  17. in a small viewport area as an axes helper. Such a helper is often wanted
  18. in 3D modeling tools or scene editors like the <a href="https://threejs.org/editor" target="_blank" rel="noopener">three.js editor</a>.</p>
  19. <p>The helper allows to click on the X, Y and Z axes which animates the camera
  20. so it looks along the selected axis.</p></div>
  21. </header>
  22. <article>
  23. <h2 class="subsection-title">Import</h2>
  24. <p><span translate="no">ViewHelper</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 { ViewHelper } from 'three/addons/helpers/ViewHelper.js';</code></pre>
  26. <div class="container-overview">
  27. <h2>Constructor</h2>
  28. <h3 class="name name-method" id="ViewHelper" translate="no">new <a href="#ViewHelper">ViewHelper</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span>, domElement : <span class="param-type">HTMLElement</span> )</span> </h3>
  29. <div class="method">
  30. <div class="description">
  31. <p>Constructs a new view helper.</p>
  32. </div>
  33. <table class="params">
  34. <tbody>
  35. <tr>
  36. <td class="name">
  37. <strong translate="no">camera</strong>
  38. </td>
  39. <td class="description last">
  40. <p>The camera whose transformation should be visualized.</p>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td class="name">
  45. <strong translate="no">domElement</strong>
  46. </td>
  47. <td class="description last">
  48. <p>The DOM element that is used to render the view.</p>
  49. </td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. <h2 class="subsection-title">Properties</h2>
  56. <div class="member">
  57. <h3 class="name" id="animating" translate="no">.<a href="#animating">animating</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  58. <div class="description">
  59. <p>Whether the helper is currently animating or not.</p>
  60. <p>Default is <code>false</code>.</p>
  61. </div>
  62. </div>
  63. <div class="member">
  64. <h3 class="name" id="center" translate="no">.<a href="#center">center</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  65. <div class="description">
  66. <p>The helper's center point.</p>
  67. </div>
  68. </div>
  69. <div class="member">
  70. <h3 class="name" id="isViewHelper" translate="no">.<a href="#isViewHelper">isViewHelper</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  71. <div class="description">
  72. <p>This flag can be used for type testing.</p>
  73. <p>Default is <code>true</code>.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <h3 class="name" id="location" translate="no">.<a href="#location">location</a><span class="type-signature"> : Object</span> </h3>
  78. <div class="description">
  79. <p>Controls the position of the helper in the viewport.
  80. Use <code>top</code>/<code>bottom</code> for vertical positioning and <code>left</code>/<code>right</code> for horizontal.
  81. If <code>left</code> is <code>null</code>, <code>right</code> is used. If <code>top</code> is <code>null</code>, <code>bottom</code> is used.</p>
  82. </div>
  83. </div>
  84. <h2 class="subsection-title">Methods</h2>
  85. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  86. <div class="method">
  87. <div class="description">
  88. <p>Frees the GPU-related resources allocated by this instance. Call this
  89. method whenever this instance is no longer used in your app.</p>
  90. </div>
  91. </div>
  92. <h3 class="name name-method" id="handleClick" translate="no">.<a href="#handleClick">handleClick</a><span class="signature">( event : <span class="param-type">PointerEvent</span> )</span><span class="type-signature"> : boolean</span> </h3>
  93. <div class="method">
  94. <div class="description">
  95. <p>This method should be called when a click or pointer event
  96. has happened in the app.</p>
  97. </div>
  98. <table class="params">
  99. <tbody>
  100. <tr>
  101. <td class="name">
  102. <strong translate="no">event</strong>
  103. </td>
  104. <td class="description last">
  105. <p>The event to process.</p>
  106. </td>
  107. </tr>
  108. </tbody>
  109. </table>
  110. <dl class="details">
  111. <dt class="tag-returns"><strong>Returns:</strong> Whether an intersection with the helper has been detected or not.</dt>
  112. </dl>
  113. </div>
  114. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a> | <a href="WebGPURenderer.html">WebGPURenderer</a></span> )</span> </h3>
  115. <div class="method">
  116. <div class="description">
  117. <p>Renders the helper in a separate view in the viewport.
  118. Position is controlled by the <code>location</code> property.</p>
  119. </div>
  120. <table class="params">
  121. <tbody>
  122. <tr>
  123. <td class="name">
  124. <strong translate="no">renderer</strong>
  125. </td>
  126. <td class="description last">
  127. <p>The renderer.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. </div>
  133. <h3 class="name name-method" id="setLabelStyle" translate="no">.<a href="#setLabelStyle">setLabelStyle</a><span class="signature">( font : <span class="param-type">string</span>, color : <span class="param-type">string</span>, radius : <span class="param-type">number</span> )</span> </h3>
  134. <div class="method">
  135. <div class="description">
  136. <p>Sets the label style. Has no effect when the axes are unlabeled.</p>
  137. </div>
  138. <table class="params">
  139. <tbody>
  140. <tr>
  141. <td class="name">
  142. <strong translate="no">font</strong>
  143. </td>
  144. <td class="description last">
  145. <p>The label font.</p>
  146. <p>Default is <code>'24px Arial'</code>.</p>
  147. </td>
  148. </tr>
  149. <tr>
  150. <td class="name">
  151. <strong translate="no">color</strong>
  152. </td>
  153. <td class="description last">
  154. <p>The label color.</p>
  155. <p>Default is <code>'#000000'</code>.</p>
  156. </td>
  157. </tr>
  158. <tr>
  159. <td class="name">
  160. <strong translate="no">radius</strong>
  161. </td>
  162. <td class="description last">
  163. <p>The label radius.</p>
  164. <p>Default is <code>14</code>.</p>
  165. </td>
  166. </tr>
  167. </tbody>
  168. </table>
  169. </div>
  170. <h3 class="name name-method" id="setLabels" translate="no">.<a href="#setLabels">setLabels</a><span class="signature">( labelX : <span class="param-type">string | undefined</span>, labelY : <span class="param-type">string | undefined</span>, labelZ : <span class="param-type">string | undefined</span> )</span> </h3>
  171. <div class="method">
  172. <div class="description">
  173. <p>Sets labels for each axis. By default, they are unlabeled.</p>
  174. </div>
  175. <table class="params">
  176. <tbody>
  177. <tr>
  178. <td class="name">
  179. <strong translate="no">labelX</strong>
  180. </td>
  181. <td class="description last">
  182. <p>The label for the x-axis.</p>
  183. </td>
  184. </tr>
  185. <tr>
  186. <td class="name">
  187. <strong translate="no">labelY</strong>
  188. </td>
  189. <td class="description last">
  190. <p>The label for the y-axis.</p>
  191. </td>
  192. </tr>
  193. <tr>
  194. <td class="name">
  195. <strong translate="no">labelZ</strong>
  196. </td>
  197. <td class="description last">
  198. <p>The label for the z-axis.</p>
  199. </td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. </div>
  204. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( delta : <span class="param-type">number</span> )</span> </h3>
  205. <div class="method">
  206. <div class="description">
  207. <p>Updates the helper. This method should be called in the app's animation
  208. loop.</p>
  209. </div>
  210. <table class="params">
  211. <tbody>
  212. <tr>
  213. <td class="name">
  214. <strong translate="no">delta</strong>
  215. </td>
  216. <td class="description last">
  217. <p>The delta time in seconds.</p>
  218. </td>
  219. </tr>
  220. </tbody>
  221. </table>
  222. </div>
  223. <h2 class="subsection-title">Source</h2>
  224. <p>
  225. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/helpers/ViewHelper.js" translate="no" target="_blank" rel="noopener">examples/jsm/helpers/ViewHelper.js</a>
  226. </p>
  227. </article>
  228. </section>
  229. <script src="../scripts/linenumber.js"></script>
  230. <script src="../scripts/page.js"></script>
  231. </body>
  232. </html>
粤ICP备19079148号