ShadowMesh.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ShadowMesh - 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="Mesh.html">Mesh</a> → </p>
  13. <h1 translate="no">ShadowMesh</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A Shadow Mesh that follows a shadow-casting mesh in the scene,
  17. but is confined to a single plane. This technique can be used as
  18. a very performant alternative to classic shadow mapping. However,
  19. it has serious limitations like:</p>
  20. <ul>
  21. <li>Shadows can only be casted on flat planes.</li>
  22. <li>No soft shadows support.</li>
  23. </ul></div>
  24. <h2>Code Example</h2>
  25. <div translate="no"><pre><code class="language-js">const cubeShadow = new ShadowMesh( cube );
  26. scene.add( cubeShadow );
  27. </code></pre></div>
  28. </header>
  29. <article>
  30. <h2 class="subsection-title">Import</h2>
  31. <p><span translate="no">ShadowMesh</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 { ShadowMesh } from 'three/addons/objects/ShadowMesh.js';</code></pre>
  33. <div class="container-overview">
  34. <h2>Constructor</h2>
  35. <h3 class="name name-method" id="ShadowMesh" translate="no">new <a href="#ShadowMesh">ShadowMesh</a><span class="signature">( mesh : <span class="param-type"><a href="Mesh.html">Mesh</a></span> )</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Constructs a new shadow mesh.</p>
  39. </div>
  40. <table class="params">
  41. <tbody>
  42. <tr>
  43. <td class="name">
  44. <strong>mesh</strong>
  45. </td>
  46. <td class="description last">
  47. <p>The shadow-casting reference mesh.</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="frustumCulled" translate="no">.<a href="#frustumCulled">frustumCulled</a><span class="type-signature"> : boolean</span> </h3>
  57. <div class="description">
  58. <p>Overwritten to disable view-frustum culling by default.</p>
  59. <p>Default is <code>false</code>.</p>
  60. </div>
  61. <dl class="details">
  62. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Mesh.html#frustumCulled">Mesh#frustumCulled</a></dt>
  63. </dl>
  64. </div>
  65. <div class="member">
  66. <h3 class="name" id="isShadowMesh" translate="no">.<a href="#isShadowMesh">isShadowMesh</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  67. <div class="description">
  68. <p>This flag can be used for type testing.</p>
  69. <p>Default is <code>true</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="matrixAutoUpdate" translate="no">.<a href="#matrixAutoUpdate">matrixAutoUpdate</a><span class="type-signature"> : boolean</span> </h3>
  74. <div class="description">
  75. <p>Overwritten to disable automatic matrix update. The local
  76. matrix is computed manually in <a href="ShadowMesh.html#update">ShadowMesh#update</a>.</p>
  77. <p>Default is <code>false</code>.</p>
  78. </div>
  79. <dl class="details">
  80. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Mesh.html#matrixAutoUpdate">Mesh#matrixAutoUpdate</a></dt>
  81. </dl>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="meshMatrix" translate="no">.<a href="#meshMatrix">meshMatrix</a><span class="type-signature"> : <a href="Matrix4.html">Matrix4</a></span> </h3>
  85. <div class="description">
  86. <p>Represent the world matrix of the reference mesh.</p>
  87. </div>
  88. </div>
  89. <h2 class="subsection-title">Methods</h2>
  90. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">( plane : <span class="param-type"><a href="Plane.html">Plane</a></span>, lightPosition4D : <span class="param-type"><a href="Vector4.html">Vector4</a></span> )</span> </h3>
  91. <div class="method">
  92. <div class="description">
  93. <p>Updates the shadow mesh so it follows its shadow-casting reference mesh.</p>
  94. </div>
  95. <table class="params">
  96. <tbody>
  97. <tr>
  98. <td class="name">
  99. <strong>plane</strong>
  100. </td>
  101. <td class="description last">
  102. <p>The plane onto the shadow mesh is projected.</p>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td class="name">
  107. <strong>lightPosition4D</strong>
  108. </td>
  109. <td class="description last">
  110. <p>The light position.</p>
  111. </td>
  112. </tr>
  113. </tbody>
  114. </table>
  115. </div>
  116. <h2 class="subsection-title">Source</h2>
  117. <p>
  118. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/ShadowMesh.js" translate="no" target="_blank" rel="noopener">examples/jsm/objects/ShadowMesh.js</a>
  119. </p>
  120. </article>
  121. </section>
  122. <script src="../scripts/linenumber.js"></script>
  123. <script src="../scripts/page.js"></script>
  124. </body>
  125. </html>
粤ICP备19079148号