ViewHelper.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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">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">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">Camera</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"><code>camera</code></td>
  37. <td class="description last"><p>The camera whose transformation should be visualized.</p></td>
  38. </tr>
  39. <tr>
  40. <td class="name"><code>domElement</code></td>
  41. <td class="description last"><p>The DOM element that is used to render the view.</p></td>
  42. </tr>
  43. </tbody>
  44. </table>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <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>
  50. <div class="description">
  51. <p>Whether the helper is currently animating or not.<br/>Default is <code>false</code>.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="center" translate="no">.<a href="#center">center</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  56. <div class="description">
  57. <p>The helper's center point.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <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>
  62. <div class="description">
  63. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  64. </div>
  65. </div>
  66. <h2 class="subsection-title">Methods</h2>
  67. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  68. <div class="method">
  69. <div class="description">
  70. <p>Frees the GPU-related resources allocated by this instance. Call this
  71. method whenever this instance is no longer used in your app.</p>
  72. </div>
  73. </div>
  74. <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>
  75. <div class="method">
  76. <div class="description">
  77. <p>This method should be called when a click or pointer event
  78. has happened in the app.</p>
  79. </div>
  80. <table class="params">
  81. <tbody>
  82. <tr>
  83. <td class="name"><code>event</code></td>
  84. <td class="description last"><p>The event to process.</p></td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. <dl class="details">
  89. <dt class="tag-returns"><strong>Returns:</strong> Whether an intersection with the helper has been detected or not.</dt>
  90. </dl>
  91. </div>
  92. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer | WebGPURenderer</span> )</span> </h3>
  93. <div class="method">
  94. <div class="description">
  95. <p>Renders the helper in a separate view in the bottom-right corner
  96. of the viewport.</p>
  97. </div>
  98. <table class="params">
  99. <tbody>
  100. <tr>
  101. <td class="name"><code>renderer</code></td>
  102. <td class="description last"><p>The renderer.</p></td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. </div>
  107. <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>
  108. <div class="method">
  109. <div class="description">
  110. <p>Sets the label style. Has no effect when the axes are unlabeled.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name"><code>font</code></td>
  116. <td class="description last"><p>The label font.<br/>Default is <code>'24px Arial'</code>.</p></td>
  117. </tr>
  118. <tr>
  119. <td class="name"><code>color</code></td>
  120. <td class="description last"><p>The label color.<br/>Default is <code>'#000000'</code>.</p></td>
  121. </tr>
  122. <tr>
  123. <td class="name"><code>radius</code></td>
  124. <td class="description last"><p>The label radius.<br/>Default is <code>14</code>.</p></td>
  125. </tr>
  126. </tbody>
  127. </table>
  128. </div>
  129. <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>
  130. <div class="method">
  131. <div class="description">
  132. <p>Sets labels for each axis. By default, they are unlabeled.</p>
  133. </div>
  134. <table class="params">
  135. <tbody>
  136. <tr>
  137. <td class="name"><code>labelX</code></td>
  138. <td class="description last"><p>The label for the x-axis.</p></td>
  139. </tr>
  140. <tr>
  141. <td class="name"><code>labelY</code></td>
  142. <td class="description last"><p>The label for the y-axis.</p></td>
  143. </tr>
  144. <tr>
  145. <td class="name"><code>labelZ</code></td>
  146. <td class="description last"><p>The label for the z-axis.</p></td>
  147. </tr>
  148. </tbody>
  149. </table>
  150. </div>
  151. <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>
  152. <div class="method">
  153. <div class="description">
  154. <p>Updates the helper. This method should be called in the app's animation
  155. loop.</p>
  156. </div>
  157. <table class="params">
  158. <tbody>
  159. <tr>
  160. <td class="name"><code>delta</code></td>
  161. <td class="description last"><p>The delta time in seconds.</p></td>
  162. </tr>
  163. </tbody>
  164. </table>
  165. </div>
  166. <h2 class="subsection-title">Source</h2>
  167. <p>
  168. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/helpers/ViewHelper.js" target="_blank" rel="noopener" translate="no">examples/jsm/helpers/ViewHelper.js</a>
  169. </p>
  170. </article>
  171. </section>
  172. <script src="../scripts/linenumber.js"></script>
  173. <script src="../scripts/page.js"></script>
  174. </body>
  175. </html>
粤ICP备19079148号