CameraHelper.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CameraHelper - 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> → <a href="Line.html">Line</a> → <a href="LineSegments.html">LineSegments</a> → </p>
  13. <h1 translate="no">CameraHelper</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This helps with visualizing what a camera contains in its frustum. It
  17. visualizes the frustum of a camera using a line segments.</p>
  18. <p>Based on frustum visualization in <a href="https://github.com/evanw/lightgl.js/blob/master/tests/shadowmap.html" target="_blank" rel="noopener">lightgl.js shadowmap example</a>.</p>
  19. <p><code>CameraHelper</code> must be a child of the scene.</p>
  20. <p>When the camera is transformed or its projection matrix is changed, it's necessary
  21. to call the <code>update()</code> method of the respective helper.</p></div>
  22. <h2>Code Example</h2>
  23. <div translate="no"><pre><code class="language-js">const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
  24. const helper = new THREE.CameraHelper( camera );
  25. scene.add( helper );
  26. </code></pre></div>
  27. </header>
  28. <article>
  29. <div class="container-overview">
  30. <h2>Constructor</h2>
  31. <h3 class="name name-method" id="CameraHelper" translate="no">new <a href="#CameraHelper">CameraHelper</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span> </h3>
  32. <div class="method">
  33. <div class="description">
  34. <p>Constructs a new arrow helper.</p>
  35. </div>
  36. <table class="params">
  37. <tbody>
  38. <tr>
  39. <td class="name">
  40. <strong translate="no">camera</strong>
  41. </td>
  42. <td class="description last">
  43. <p>The camera to visualize.</p>
  44. </td>
  45. </tr>
  46. </tbody>
  47. </table>
  48. </div>
  49. </div>
  50. <h2 class="subsection-title">Properties</h2>
  51. <div class="member">
  52. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  53. <div class="description">
  54. <p>The camera being visualized.</p>
  55. </div>
  56. </div>
  57. <div class="member">
  58. <h3 class="name" id="pointMap" translate="no">.<a href="#pointMap">pointMap</a><span class="type-signature"> : Object.&lt;string, Array.&lt;number>></span> </h3>
  59. <div class="description">
  60. <p>This contains the points used to visualize the camera.</p>
  61. </div>
  62. </div>
  63. <h2 class="subsection-title">Methods</h2>
  64. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  65. <div class="method">
  66. <div class="description">
  67. <p>Frees the GPU-related resources allocated by this instance. Call this
  68. method whenever this instance is no longer used in your app.</p>
  69. </div>
  70. </div>
  71. <h3 class="name name-method" id="setColors" translate="no">.<a href="#setColors">setColors</a><span class="signature">( frustum : <span class="param-type"><a href="Color.html">Color</a></span>, cone : <span class="param-type"><a href="Color.html">Color</a></span>, up : <span class="param-type"><a href="Color.html">Color</a></span>, target : <span class="param-type"><a href="Color.html">Color</a></span>, cross : <span class="param-type"><a href="Color.html">Color</a></span> )</span><span class="type-signature"> : <a href="CameraHelper.html">CameraHelper</a></span> </h3>
  72. <div class="method">
  73. <div class="description">
  74. <p>Defines the colors of the helper.</p>
  75. </div>
  76. <table class="params">
  77. <tbody>
  78. <tr>
  79. <td class="name">
  80. <strong translate="no">frustum</strong>
  81. </td>
  82. <td class="description last">
  83. <p>The frustum line color.</p>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td class="name">
  88. <strong translate="no">cone</strong>
  89. </td>
  90. <td class="description last">
  91. <p>The cone line color.</p>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td class="name">
  96. <strong translate="no">up</strong>
  97. </td>
  98. <td class="description last">
  99. <p>The up line color.</p>
  100. </td>
  101. </tr>
  102. <tr>
  103. <td class="name">
  104. <strong translate="no">target</strong>
  105. </td>
  106. <td class="description last">
  107. <p>The target line color.</p>
  108. </td>
  109. </tr>
  110. <tr>
  111. <td class="name">
  112. <strong translate="no">cross</strong>
  113. </td>
  114. <td class="description last">
  115. <p>The cross line color.</p>
  116. </td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. <dl class="details">
  121. <dt class="tag-returns"><strong>Returns:</strong> A reference to this helper.</dt>
  122. </dl>
  123. </div>
  124. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  125. <div class="method">
  126. <div class="description">
  127. <p>Updates the helper based on the projection matrix of the camera.</p>
  128. </div>
  129. </div>
  130. <h2 class="subsection-title">Source</h2>
  131. <p>
  132. <a href="https://github.com/mrdoob/three.js/blob/master/src/helpers/CameraHelper.js" translate="no" target="_blank" rel="noopener">src/helpers/CameraHelper.js</a>
  133. </p>
  134. </article>
  135. </section>
  136. <script src="../scripts/linenumber.js"></script>
  137. <script src="../scripts/page.js"></script>
  138. </body>
  139. </html>
粤ICP备19079148号