SpotLight.html 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 | Color | 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"><code>color</code></td>
  44. <td class="description last"><p>The light's color.<br/>Default is <code>0xffffff</code>.</p></td>
  45. </tr>
  46. <tr>
  47. <td class="name"><code>intensity</code></td>
  48. <td class="description last"><p>The light's strength/intensity measured in candela (cd).<br/>Default is <code>1</code>.</p></td>
  49. </tr>
  50. <tr>
  51. <td class="name"><code>distance</code></td>
  52. <td class="description last"><p>Maximum range of the light. <code>0</code> means no limit.<br/>Default is <code>0</code>.</p></td>
  53. </tr>
  54. <tr>
  55. <td class="name"><code>angle</code></td>
  56. <td class="description last"><p>Maximum angle of light dispersion from its direction whose upper bound is <code>Math.PI/2</code>.<br/>Default is <code>Math.PI/3</code>.</p></td>
  57. </tr>
  58. <tr>
  59. <td class="name"><code>penumbra</code></td>
  60. <td class="description last"><p>Percent of the spotlight cone that is attenuated due to penumbra. Value range is <code>[0,1]</code>.<br/>Default is <code>0</code>.</p></td>
  61. </tr>
  62. <tr>
  63. <td class="name"><code>decay</code></td>
  64. <td class="description last"><p>The amount the light dims along the distance of the light.<br/>Default is <code>2</code>.</p></td>
  65. </tr>
  66. </tbody>
  67. </table>
  68. </div>
  69. </div>
  70. <h2 class="subsection-title">Properties</h2>
  71. <div class="member">
  72. <h3 class="name" id="angle" translate="no">.<a href="#angle">angle</a><span class="type-signature"> : number</span> </h3>
  73. <div class="description">
  74. <p>Maximum angle of light dispersion from its direction whose upper bound is <code>Math.PI/2</code>.<br/>Default is <code>Math.PI/3</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="decay" translate="no">.<a href="#decay">decay</a><span class="type-signature"> : number</span> </h3>
  79. <div class="description">
  80. <p>The amount the light dims along the distance of the light. In context of
  81. physically-correct rendering the default value should not be changed.<br/>Default is <code>2</code>.</p>
  82. </div>
  83. </div>
  84. <div class="member">
  85. <h3 class="name" id="distance" translate="no">.<a href="#distance">distance</a><span class="type-signature"> : number</span> </h3>
  86. <div class="description">
  87. <p>Maximum range of the light. <code>0</code> means no limit.<br/>Default is <code>0</code>.</p>
  88. </div>
  89. </div>
  90. <div class="member">
  91. <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>
  92. <div class="description">
  93. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  94. </div>
  95. </div>
  96. <div class="member">
  97. <h3 class="name" id="map" translate="no">.<a href="#map">map</a><span class="type-signature"> : <a href="Texture.html">Texture</a></span> </h3>
  98. <div class="description">
  99. <p>A texture used to modulate the color of the light. The spot light
  100. color is mixed with the RGB value of this texture, with a ratio
  101. corresponding to its alpha value. The cookie-like masking effect is
  102. reproduced using pixel values (0, 0, 0, 1-cookie_value).</p>
  103. <p><em>Warning</em>: This property is disabled if <a href="Object3D.html#castShadow">Object3D#castShadow</a> is set to <code>false</code>.<br/>Default is <code>null</code>.</p>
  104. </div>
  105. </div>
  106. <div class="member">
  107. <h3 class="name" id="penumbra" translate="no">.<a href="#penumbra">penumbra</a><span class="type-signature"> : number</span> </h3>
  108. <div class="description">
  109. <p>Percent of the spotlight cone that is attenuated due to penumbra.
  110. Value range is <code>[0,1]</code>.<br/>Default is <code>0</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="power" translate="no">.<a href="#power">power</a><span class="type-signature"> : number</span> </h3>
  115. <div class="description">
  116. <p>The light's power. Power is the luminous power of the light measured in lumens (lm).
  117. Changing the power will also change the light's intensity.</p>
  118. </div>
  119. </div>
  120. <div class="member">
  121. <h3 class="name" id="shadow" translate="no">.<a href="#shadow">shadow</a><span class="type-signature"> : <a href="SpotLightShadow.html">SpotLightShadow</a></span> </h3>
  122. <div class="description">
  123. <p>This property holds the light's shadow configuration.</p>
  124. </div>
  125. </div>
  126. <div class="member">
  127. <h3 class="name" id="target" translate="no">.<a href="#target">target</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  128. <div class="description">
  129. <p>The spot light points from its position to the
  130. target's position.</p>
  131. <p>For the target's position to be changed to anything other
  132. than the default, it must be added to the scene.</p>
  133. <p>It is also possible to set the target to be another 3D object
  134. in the scene. The light will now track the target object.</p>
  135. </div>
  136. </div>
  137. <h2 class="subsection-title">Source</h2>
  138. <p>
  139. <a href="https://github.com/mrdoob/three.js/blob/master/src/lights/SpotLight.js" target="_blank" rel="noopener" translate="no">src/lights/SpotLight.js</a>
  140. </p>
  141. </article>
  142. </section>
  143. <script src="../scripts/linenumber.js"></script>
  144. <script src="../scripts/page.js"></script>
  145. </body>
  146. </html>
粤ICP备19079148号