ShadowMapViewer.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ShadowMapViewer - 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. <h1 translate="no">ShadowMapViewer</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>This is a helper for visualising a given light's shadow map.
  16. It works for shadow casting lights: DirectionalLight and SpotLight.
  17. It renders out the shadow map and displays it on a HUD.</p>
  18. <p>This module can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>. When using <a href="WebGPURenderer.html">WebGPURenderer</a>,
  19. import the class from <code>ShadowMapViewerGPU.js</code>.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">const lightShadowMapViewer = new ShadowMapViewer( light );
  22. lightShadowMapViewer.position.x = 10;
  23. lightShadowMapViewer.position.y = SCREEN_HEIGHT - ( SHADOW_MAP_HEIGHT / 4 ) - 10;
  24. lightShadowMapViewer.size.width = SHADOW_MAP_WIDTH / 4;
  25. lightShadowMapViewer.size.height = SHADOW_MAP_HEIGHT / 4;
  26. lightShadowMapViewer.update();
  27. </code></pre></div>
  28. </header>
  29. <article>
  30. <h2 class="subsection-title">Import</h2>
  31. <p><span translate="no">ShadowMapViewer</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>
  32. <pre><code class="language-js">import { ShadowMapViewer } from 'three/addons/utils/ShadowMapViewer.js';</code></pre>
  33. <div class="container-overview">
  34. <h2>Constructor</h2>
  35. <h3 class="name name-method" id="ShadowMapViewer" translate="no">new <a href="#ShadowMapViewer">ShadowMapViewer</a><span class="signature">( light : <span class="param-type"><a href="Light.html">Light</a></span> )</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Constructs a new shadow map viewer.</p>
  39. </div>
  40. <table class="params">
  41. <tbody>
  42. <tr>
  43. <td class="name">
  44. <strong>light</strong>
  45. </td>
  46. <td class="description last">
  47. <p>The shadow casting light.</p>
  48. </td>
  49. </tr>
  50. </tbody>
  51. </table>
  52. </div>
  53. </div>
  54. <h2 class="subsection-title">Properties</h2>
  55. <div class="member">
  56. <h3 class="name" id="enabled" translate="no">.<a href="#enabled">enabled</a><span class="type-signature"> : boolean</span> </h3>
  57. <div class="description">
  58. <p>Whether to display the shadow map viewer or not.</p>
  59. <p>Default is <code>true</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="position" translate="no">.<a href="#position">position</a><span class="type-signature"> : Object</span> </h3>
  64. <div class="description">
  65. <p>The position of the viewer. When changing this property, make sure
  66. to call <a href="ShadowMapViewer.html#update">ShadowMapViewer#update</a>.</p>
  67. <p>Default is <code>true</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="size" translate="no">.<a href="#size">size</a><span class="type-signature"> : Object</span> </h3>
  72. <div class="description">
  73. <p>The size of the viewer. When changing this property, make sure
  74. to call <a href="ShadowMapViewer.html#update">ShadowMapViewer#update</a>.</p>
  75. <p>Default is <code>true</code>.</p>
  76. </div>
  77. </div>
  78. <h2 class="subsection-title">Methods</h2>
  79. <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></span> )</span> </h3>
  80. <div class="method">
  81. <div class="description">
  82. <p>Renders the viewer. This method must be called in the app's animation loop.</p>
  83. </div>
  84. <table class="params">
  85. <tbody>
  86. <tr>
  87. <td class="name">
  88. <strong>renderer</strong>
  89. </td>
  90. <td class="description last">
  91. <p>The renderer.</p>
  92. </td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. </div>
  97. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  98. <div class="method">
  99. <div class="description">
  100. <p>Updates the viewer.</p>
  101. </div>
  102. </div>
  103. <h3 class="name name-method" id="updateForWindowResize" translate="no">.<a href="#updateForWindowResize">updateForWindowResize</a><span class="signature">()</span> </h3>
  104. <div class="method">
  105. <div class="description">
  106. <p>Resizes the viewer. This method should be called whenever the app's
  107. window is resized.</p>
  108. </div>
  109. </div>
  110. <h2 class="subsection-title">Source</h2>
  111. <p>
  112. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/ShadowMapViewer.js" translate="no" target="_blank" rel="noopener">examples/jsm/utils/ShadowMapViewer.js</a>
  113. </p>
  114. </article>
  115. </section>
  116. <script src="../scripts/linenumber.js"></script>
  117. <script src="../scripts/page.js"></script>
  118. </body>
  119. </html>
粤ICP备19079148号