ShadowMapViewer.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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">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">Light</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"><code>light</code></td>
  44. <td class="description last"><p>The shadow casting light.</p></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="enabled" translate="no">.<a href="#enabled">enabled</a><span class="type-signature"> : boolean</span> </h3>
  53. <div class="description">
  54. <p>Whether to display the shadow map viewer or not.<br/>Default is <code>true</code>.</p>
  55. </div>
  56. </div>
  57. <div class="member">
  58. <h3 class="name" id="position" translate="no">.<a href="#position">position</a><span class="type-signature"> : Object</span> </h3>
  59. <div class="description">
  60. <p>The position of the viewer. When changing this property, make sure
  61. to call <a href="ShadowMapViewer.html#update">ShadowMapViewer#update</a>.<br/>Default is <code>true</code>.</p>
  62. </div>
  63. </div>
  64. <div class="member">
  65. <h3 class="name" id="size" translate="no">.<a href="#size">size</a><span class="type-signature"> : Object</span> </h3>
  66. <div class="description">
  67. <p>The size of the viewer. When changing this property, make sure
  68. to call <a href="ShadowMapViewer.html#update">ShadowMapViewer#update</a>.<br/>Default is <code>true</code>.</p>
  69. </div>
  70. </div>
  71. <h2 class="subsection-title">Methods</h2>
  72. <h3 class="name name-method" id="render" translate="no">.<a href="#render">render</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer</span> )</span> </h3>
  73. <div class="method">
  74. <div class="description">
  75. <p>Renders the viewer. This method must be called in the app's animation loop.</p>
  76. </div>
  77. <table class="params">
  78. <tbody>
  79. <tr>
  80. <td class="name"><code>renderer</code></td>
  81. <td class="description last"><p>The renderer.</p></td>
  82. </tr>
  83. </tbody>
  84. </table>
  85. </div>
  86. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  87. <div class="method">
  88. <div class="description">
  89. <p>Updates the viewer.</p>
  90. </div>
  91. </div>
  92. <h3 class="name name-method" id="updateForWindowResize" translate="no">.<a href="#updateForWindowResize">updateForWindowResize</a><span class="signature">()</span> </h3>
  93. <div class="method">
  94. <div class="description">
  95. <p>Resizes the viewer. This method should be called whenever the app's
  96. window is resized.</p>
  97. </div>
  98. </div>
  99. <h2 class="subsection-title">Source</h2>
  100. <p>
  101. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/ShadowMapViewer.js" target="_blank" rel="noopener" translate="no">examples/jsm/utils/ShadowMapViewer.js</a>
  102. </p>
  103. </article>
  104. </section>
  105. <script src="../scripts/linenumber.js"></script>
  106. <script src="../scripts/page.js"></script>
  107. </body>
  108. </html>
粤ICP备19079148号