1
0

ViewHelper.html 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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>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>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. <h2 class="subsection-title">Methods</h2>
  77. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  78. <div class="method">
  79. <div class="description">
  80. <p>Frees the GPU-related resources allocated by this instance. Call this
  81. method whenever this instance is no longer used in your app.</p>
  82. </div>
  83. </div>
  84. <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>
  85. <div class="method">
  86. <div class="description">
  87. <p>This method should be called when a click or pointer event
  88. has happened in the app.</p>
  89. </div>
  90. <table class="params">
  91. <tbody>
  92. <tr>
  93. <td class="name">
  94. <strong>event</strong>
  95. </td>
  96. <td class="description last">
  97. <p>The event to process.</p>
  98. </td>
  99. </tr>
  100. </tbody>
  101. </table>
  102. <dl class="details">
  103. <dt class="tag-returns"><strong>Returns:</strong> Whether an intersection with the helper has been detected or not.</dt>
  104. </dl>
  105. </div>
  106. <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>
  107. <div class="method">
  108. <div class="description">
  109. <p>Renders the helper in a separate view in the bottom-right corner
  110. of the viewport.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name">
  116. <strong>renderer</strong>
  117. </td>
  118. <td class="description last">
  119. <p>The renderer.</p>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. </div>
  125. <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>
  126. <div class="method">
  127. <div class="description">
  128. <p>Sets the label style. Has no effect when the axes are unlabeled.</p>
  129. </div>
  130. <table class="params">
  131. <tbody>
  132. <tr>
  133. <td class="name">
  134. <strong>font</strong>
  135. </td>
  136. <td class="description last">
  137. <p>The label font.</p>
  138. <p>Default is <code>'24px Arial'</code>.</p>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class="name">
  143. <strong>color</strong>
  144. </td>
  145. <td class="description last">
  146. <p>The label color.</p>
  147. <p>Default is <code>'#000000'</code>.</p>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td class="name">
  152. <strong>radius</strong>
  153. </td>
  154. <td class="description last">
  155. <p>The label radius.</p>
  156. <p>Default is <code>14</code>.</p>
  157. </td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. </div>
  162. <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>
  163. <div class="method">
  164. <div class="description">
  165. <p>Sets labels for each axis. By default, they are unlabeled.</p>
  166. </div>
  167. <table class="params">
  168. <tbody>
  169. <tr>
  170. <td class="name">
  171. <strong>labelX</strong>
  172. </td>
  173. <td class="description last">
  174. <p>The label for the x-axis.</p>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td class="name">
  179. <strong>labelY</strong>
  180. </td>
  181. <td class="description last">
  182. <p>The label for the y-axis.</p>
  183. </td>
  184. </tr>
  185. <tr>
  186. <td class="name">
  187. <strong>labelZ</strong>
  188. </td>
  189. <td class="description last">
  190. <p>The label for the z-axis.</p>
  191. </td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. </div>
  196. <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>
  197. <div class="method">
  198. <div class="description">
  199. <p>Updates the helper. This method should be called in the app's animation
  200. loop.</p>
  201. </div>
  202. <table class="params">
  203. <tbody>
  204. <tr>
  205. <td class="name">
  206. <strong>delta</strong>
  207. </td>
  208. <td class="description last">
  209. <p>The delta time in seconds.</p>
  210. </td>
  211. </tr>
  212. </tbody>
  213. </table>
  214. </div>
  215. <h2 class="subsection-title">Source</h2>
  216. <p>
  217. <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>
  218. </p>
  219. </article>
  220. </section>
  221. <script src="../scripts/linenumber.js"></script>
  222. <script src="../scripts/page.js"></script>
  223. </body>
  224. </html>
粤ICP备19079148号