ViewHelper.html 9.8 KB

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