SpotLight.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SpotLight - 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="Light.html">Light</a> → </p>
  13. <h1 translate="no">SpotLight</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This light gets emitted from a single point in one direction, along a cone
  17. that increases in size the further from the light it gets.</p>
  18. <p>This light can cast shadows - see the <a href="SpotLightShadow.html">SpotLightShadow</a> for details.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">// white spotlight shining from the side, modulated by a texture
  21. const spotLight = new THREE.SpotLight( 0xffffff );
  22. spotLight.position.set( 100, 1000, 100 );
  23. spotLight.map = new THREE.TextureLoader().load( url );
  24. spotLight.castShadow = true;
  25. spotLight.shadow.mapSize.width = 1024;
  26. spotLight.shadow.mapSize.height = 1024;
  27. spotLight.shadow.camera.near = 500;
  28. spotLight.shadow.camera.far = 4000;
  29. spotLight.shadow.camera.fov = 30;s
  30. </code></pre></div>
  31. </header>
  32. <article>
  33. <div class="container-overview">
  34. <h2>Constructor</h2>
  35. <h3 class="name name-method" id="SpotLight" translate="no">new <a href="#SpotLight">SpotLight</a><span class="signature">( color : <span class="param-type">number | <a href="Color.html">Color</a> | string</span>, intensity : <span class="param-type">number</span>, distance : <span class="param-type">number</span>, angle : <span class="param-type">number</span>, penumbra : <span class="param-type">number</span>, decay : <span class="param-type">number</span> )</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Constructs a new spot light.</p>
  39. </div>
  40. <table class="params">
  41. <tbody>
  42. <tr>
  43. <td class="name">
  44. <strong>color</strong>
  45. </td>
  46. <td class="description last">
  47. <p>The light's color.</p>
  48. <p>Default is <code>0xffffff</code>.</p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="name">
  53. <strong>intensity</strong>
  54. </td>
  55. <td class="description last">
  56. <p>The light's strength/intensity measured in candela (cd).</p>
  57. <p>Default is <code>1</code>.</p>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="name">
  62. <strong>distance</strong>
  63. </td>
  64. <td class="description last">
  65. <p>Maximum range of the light. <code>0</code> means no limit.</p>
  66. <p>Default is <code>0</code>.</p>
  67. </td>
  68. </tr>
  69. <tr>
  70. <td class="name">
  71. <strong>angle</strong>
  72. </td>
  73. <td class="description last">
  74. <p>Maximum angle of light dispersion from its direction whose upper bound is <code>Math.PI/2</code>.</p>
  75. <p>Default is <code>Math.PI/3</code>.</p>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td class="name">
  80. <strong>penumbra</strong>
  81. </td>
  82. <td class="description last">
  83. <p>Percent of the spotlight cone that is attenuated due to penumbra. Value range is <code>[0,1]</code>.</p>
  84. <p>Default is <code>0</code>.</p>
  85. </td>
  86. </tr>
  87. <tr>
  88. <td class="name">
  89. <strong>decay</strong>
  90. </td>
  91. <td class="description last">
  92. <p>The amount the light dims along the distance of the light.</p>
  93. <p>Default is <code>2</code>.</p>
  94. </td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </div>
  99. </div>
  100. <h2 class="subsection-title">Properties</h2>
  101. <div class="member">
  102. <h3 class="name" id="angle" translate="no">.<a href="#angle">angle</a><span class="type-signature"> : number</span> </h3>
  103. <div class="description">
  104. <p>Maximum angle of light dispersion from its direction whose upper bound is <code>Math.PI/2</code>.</p>
  105. <p>Default is <code>Math.PI/3</code>.</p>
  106. </div>
  107. </div>
  108. <div class="member">
  109. <h3 class="name" id="decay" translate="no">.<a href="#decay">decay</a><span class="type-signature"> : number</span> </h3>
  110. <div class="description">
  111. <p>The amount the light dims along the distance of the light. In context of
  112. physically-correct rendering the default value should not be changed.</p>
  113. <p>Default is <code>2</code>.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="distance" translate="no">.<a href="#distance">distance</a><span class="type-signature"> : number</span> </h3>
  118. <div class="description">
  119. <p>Maximum range of the light. <code>0</code> means no limit.</p>
  120. <p>Default is <code>0</code>.</p>
  121. </div>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="isSpotLight" translate="no">.<a href="#isSpotLight">isSpotLight</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  125. <div class="description">
  126. <p>This flag can be used for type testing.</p>
  127. <p>Default is <code>true</code>.</p>
  128. </div>
  129. </div>
  130. <div class="member">
  131. <h3 class="name" id="map" translate="no">.<a href="#map">map</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  132. <div class="description">
  133. <p>A texture used to modulate the color of the light. The spot light
  134. color is mixed with the RGB value of this texture, with a ratio
  135. corresponding to its alpha value. The cookie-like masking effect is
  136. reproduced using pixel values (0, 0, 0, 1-cookie_value).</p>
  137. <p><em>Warning</em>: This property is disabled if <a href="Object3D.html#castShadow">Object3D#castShadow</a> is set to <code>false</code>.</p>
  138. <p>Default is <code>null</code>.</p>
  139. </div>
  140. </div>
  141. <div class="member">
  142. <h3 class="name" id="penumbra" translate="no">.<a href="#penumbra">penumbra</a><span class="type-signature"> : number</span> </h3>
  143. <div class="description">
  144. <p>Percent of the spotlight cone that is attenuated due to penumbra.
  145. Value range is <code>[0,1]</code>.</p>
  146. <p>Default is <code>0</code>.</p>
  147. </div>
  148. </div>
  149. <div class="member">
  150. <h3 class="name" id="power" translate="no">.<a href="#power">power</a><span class="type-signature"> : number</span> </h3>
  151. <div class="description">
  152. <p>The light's power. Power is the luminous power of the light measured in lumens (lm).
  153. Changing the power will also change the light's intensity.</p>
  154. </div>
  155. </div>
  156. <div class="member">
  157. <h3 class="name" id="shadow" translate="no">.<a href="#shadow">shadow</a><span class="type-signature"> : <a href="SpotLightShadow.html">SpotLightShadow</a></span> </h3>
  158. <div class="description">
  159. <p>This property holds the light's shadow configuration.</p>
  160. </div>
  161. </div>
  162. <div class="member">
  163. <h3 class="name" id="target" translate="no">.<a href="#target">target</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  164. <div class="description">
  165. <p>The spot light points from its position to the
  166. target's position.</p>
  167. <p>For the target's position to be changed to anything other
  168. than the default, it must be added to the scene.</p>
  169. <p>It is also possible to set the target to be another 3D object
  170. in the scene. The light will now track the target object.</p>
  171. </div>
  172. </div>
  173. <h2 class="subsection-title">Source</h2>
  174. <p>
  175. <a href="https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLight.js" translate="no" target="_blank" rel="noopener">src/lights/SpotLight.js</a>
  176. </p>
  177. </article>
  178. </section>
  179. <script src="../scripts/linenumber.js"></script>
  180. <script src="../scripts/page.js"></script>
  181. </body>
  182. </html>
粤ICP备19079148号