SpotLight.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Object3D] &rarr; [page:Light] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. This light gets emitted from a single point in one direction, along a cone that increases in size
  15. the further from the light it gets. <br /><br />
  16. This light can cast shadows - see the [page:SpotLightShadow] page for details.
  17. </p>
  18. <h2>Example</h2>
  19. <iframe src='../examples/webgl_lights_spotlight.html'></iframe>
  20. <p>
  21. [example:webgl_lights_spotlight View in Examples ]
  22. </p>
  23. <h2>Other Examples</h2>
  24. <p>
  25. [example:webgl_interactive_cubes_gpu interactive / cubes / gpu ]<br />
  26. [example:webgl_interactive_draggablecubes interactive / draggablecubes ]<br />
  27. [example:webgl_materials_bumpmap_skin materials / bumpmap / skin ]<br />
  28. [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]<br />
  29. [example:webgl_loader_md2 loader / md2 ]<br />
  30. [example:webgl_shading_physical shading / physical ]<br />
  31. [example:webgl_materials_bumpmap materials / bumpmap]<br/>
  32. [example:webgl_shading_physical shading / physical]<br/>
  33. [example:webgl_shadowmap shadowmap]<br/>
  34. [example:webgl_shadowmap_performance shadowmap / performance]<br/>
  35. [example:webgl_shadowmap_viewer shadowmap / viewer]
  36. </p>
  37. <h2>Code Example</h2>
  38. <code>
  39. // white spotlight shining from the side, casting a shadow
  40. var spotLight = new THREE.SpotLight( 0xffffff );
  41. spotLight.position.set( 100, 1000, 100 );
  42. spotLight.castShadow = true;
  43. spotLight.shadow.mapSize.width = 1024;
  44. spotLight.shadow.mapSize.height = 1024;
  45. spotLight.shadow.camera.near = 500;
  46. spotLight.shadow.camera.far = 4000;
  47. spotLight.shadow.camera.fov = 30;
  48. scene.add( spotLight );
  49. </code>
  50. <h2>Constructor</h2>
  51. <h3>[name]( [param:Integer color], [param:Float intensity], [param:Float distance], [param:Radians angle], [param:Float penumbra], [param:Float decay] )</h3>
  52. <p>
  53. [page:Integer color] - (optional) hexadecimal color of the light. Default is 0xffffff (white).<br />
  54. [page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br /><br />
  55. [page:Float distance] - Maximum range of the light. Default is 0 (no limit).<br />
  56. [page:Radians angle] - Maximum angle of light dispersion from its direction whose upper
  57. bound is Math.PI/2.<br />
  58. [page:Float penumbra] - Percent of the spotlight cone that is attenuated due to penumbra.
  59. Takes values between zero and 1. Default is zero.<br />
  60. [page:Float decay] - The amount the light dims along the distance of the light.<br /><br />
  61. Creates a new [name].
  62. </p>
  63. <h2>Properties</h2>
  64. See the base [page:Light Light] class for common properties.
  65. <h3>[property:Float angle]</h3>
  66. <p>
  67. Maximum extent of the spotlight, in radians, from its direction. Should be no more than
  68. *Math.PI/2*. The default is *Math.PI/3*.
  69. </p>
  70. <h3>[property:Boolean castShadow]</h3>
  71. <p>
  72. If set to *true* light will cast dynamic shadows. *Warning*: This is expensive and
  73. requires tweaking to get shadows looking right. See the [page:SpotLightShadow] for details.
  74. The default is *false*.
  75. </p>
  76. <h3>[property:Float decay]</h3>
  77. <p>
  78. The amount the light dims along the distance of the light.<br />
  79. In [page:WebGLRenderer.physicallyCorrectLights physically correct] mode, decay = 2 leads to
  80. physically realistic light falloff. The default is *1*.
  81. </p>
  82. <h3>[property:Float distance]</h3>
  83. <p>
  84. <em>Default mode</em> — When distance is zero, light does not attenuate. When distance is
  85. non-zero, light will attenuate linearly from maximum intensity at the light's position down to
  86. zero at this distance from the light.
  87. </p>
  88. <p>
  89. <em>[page:WebGLRenderer.physicallyCorrectLights Physically correct] mode</em> — When distance
  90. is zero, light will attenuate according to inverse-square law to infinite distance. When
  91. distance is non-zero, light will attenuate according to inverse-square law until near the
  92. distance cutoff, where it will then attenuate quickly and smoothly to 0. Inherently, cutoffs
  93. are not physically correct.
  94. </p>
  95. <p>
  96. Default is *0.0*.
  97. </p>
  98. <h3>[property:Boolean isSpotLight]</h3>
  99. <p>
  100. Used to check whether this or derived classes are spot lights. Default is *true*.<br /><br />
  101. You should not change this, as it used internally for optimisation.
  102. </p>
  103. <h3>[property:Float penumbra]</h3>
  104. <p>
  105. Percent of the spotlight cone that is attenuated due to penumbra. Takes values between
  106. zero and 1. The default is *0.0*.
  107. </p>
  108. <h3>[property:Vector3 position]</h3>
  109. <p>
  110. This is set equal to [page:Object3D.DefaultUp] (0, 1, 0), so that the light shines from the top down.
  111. </p>
  112. <h3>[property:Float power]</h3>
  113. <p>
  114. The light's power.<br />
  115. In [page:WebGLRenderer.physicallyCorrectLights physically correct] mode, the luminous
  116. power of the light measured in lumens. Default is *4Math.PI*. <br /><br />
  117. This is directly related to the [page:.intensity intensity] in the ratio
  118. <code>
  119. power = intensity * &pi;
  120. </code>
  121. and changing this will also change the intensity.
  122. </p>
  123. <h3>[property:SpotLightShadow shadow]</h3>
  124. <p>
  125. A [page:SpotLightShadow] used to calculate shadows for this light.
  126. </p>
  127. <h3>[property:Object3D target]</h3>
  128. <p>
  129. The Spotlight points from its [page:.position position] to target.position. The default
  130. position of the target is *(0, 0, 0)*.<br />
  131. *Note*: For the target's position to be changed to anything other than the default,
  132. it must be added to the [page:Scene scene] using
  133. <code>
  134. scene.add( light.target );
  135. </code>
  136. This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
  137. updated each frame.<br /><br />
  138. It is also possible to set the target to be another object in the scene (anything with a
  139. [page:Object3D.position position] property), like so:
  140. <code>
  141. var targetObject = new THREE.Object3D();
  142. scene.add(targetObject);
  143. light.target = targetObject;
  144. </code>
  145. The spotlight will now track the target object.
  146. </p>
  147. <h2>Methods</h2>
  148. See the base [page:Light Light] class for common methods.
  149. <h3>[method:SpotLight copy]( [param:SpotLight source] )</h3>
  150. <p>
  151. Copies value of all the properties from the [page:SpotLight source] to this
  152. SpotLight.
  153. </p>
  154. <p>
  155. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  156. </p>
  157. </body>
  158. </html>