SpotLight.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. <div 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. This light can cast shadows - see the [page:SpotLightShadow].
  16. </div>
  17. <h2>Example</h2>
  18. <iframe src='../examples/webgl_lights_spotlight.html'></iframe>
  19. <div>
  20. [example:webgl_lights_spotlight View in Examples ]
  21. </div>
  22. <h2>Other Examples</h2>
  23. <div>
  24. [example:webgl_interactive_cubes_gpu interactive / cubes / gpu ]<br />
  25. [example:webgl_interactive_draggablecubes interactive / draggablecubes ]<br />
  26. [example:webgl_materials_bumpmap_skin materials / bumpmap / skin ]<br />
  27. [example:webgl_materials_cubemap_dynamic materials / cubemap / dynamic ]<br />
  28. [example:webgl_morphtargets_md2 morphtargets / md2 ]<br />
  29. [example:webgl_shading_physical shading / physical ]<br />
  30. [example:webgl_materials_bumpmap materials / bumpmap]<br/>
  31. [example:webgl_shading_physical shading / physical]<br/>
  32. [example:webgl_shadowmap shadowmap]<br/>
  33. [example:webgl_shadowmap_performance shadowmap / performance]<br/>
  34. [example:webgl_shadowmap_viewer shadowmap / viewer]
  35. </div>
  36. <h2>Code Example</h2>
  37. <code>
  38. // white spotlight shining from the side, casting a shadow
  39. var spotLight = new THREE.SpotLight( 0xffffff );
  40. spotLight.position.set( 100, 1000, 100 );
  41. spotLight.castShadow = true;
  42. spotLight.shadow.mapSize.width = 1024;
  43. spotLight.shadow.mapSize.height = 1024;
  44. spotLight.shadow.camera.near = 500;
  45. spotLight.shadow.camera.far = 4000;
  46. spotLight.shadow.camera.fov = 30;
  47. scene.add( spotLight );
  48. </code>
  49. <h2>Constructor</h2>
  50. <h3>[name]( [page:Integer color], [page:Float intensity], [page:Float distance], [page:Radians angle], [page:Float penumbra], [page:Float decay] )</h3>
  51. <div>
  52. [page:Integer color] - (optional) hexadecimal color of the light. Default is 0xffffff (white).<br />
  53. [page:Float intensity] - (optional) numeric value of the light's strength/intensity. Default is 1.<br /><br />
  54. [page:Float distance] - Maximum distance from origin where light will shine whose intensity
  55. is attenuated linearly based on distance from origin. <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. </div>
  63. <h2>Properties</h2>
  64. See the base [page:Light Light] class for common properties.
  65. <h3>[property:Float angle]</h3>
  66. <div>
  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. </div>
  70. <h3>[property:Boolean castShadow]</h3>
  71. <div>
  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. </div>
  76. <h3>[property:Float decay]</h3>
  77. <div>
  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. </div>
  82. <h3>[property:Float distance]</h3>
  83. <div>
  84. If non-zero, light will attenuate linearly from maximum intensity at the light's
  85. position down to zero at this distance from the light. Default is *0.0*.
  86. </div>
  87. <h3>[property:Boolean isSpotLight]</h3>
  88. <div>
  89. Used to check whether this or derived classes are spot lights. Default is *true*.<br /><br />
  90. You should not change this, as it used internally for optimisation.
  91. </div>
  92. <h3>[property:Float penumbra]</h3>
  93. <div>
  94. Percent of the spotlight cone that is attenuated due to penumbra. Takes values between
  95. zero and 1. The default is *0.0*.
  96. </div>
  97. <h3>[property:Float power]</h3>
  98. <div>
  99. The light's power.<br />
  100. In [page:WebGLRenderer.physicallyCorrectLights physically correct] mode, the luminous
  101. power of the light measured in lumens. Default - *4PI*. <br /><br />
  102. This is directly related to the [page:.intensity intensity] in the ratio
  103. <code>
  104. power = intensity * &Pi;
  105. </code>
  106. and changing this will also change the intensity.
  107. </div>
  108. <h3>[property:SpotLightShadow shadow]</h3>
  109. <div>
  110. A [page:LightShadow] used to calculate shadows for this light.
  111. </div>
  112. <h3>[property:Object3D target]</h3>
  113. <div>
  114. The Spotlight points from its [page:.position position] to target.position. The default
  115. position of the target is *(0, 0, 0)*.<br />
  116. *Note*: For the the target's position to be changed to anything other than the default,
  117. it must be added to the [page:Scene scene] using
  118. <code>
  119. scene.add( light.target );
  120. </code>
  121. This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
  122. updated each frame.<br /><br />
  123. It is also possible to set the target to be another object in the scene (anything with a
  124. [page:Object3D.position position] property), like so:
  125. <code>
  126. var targetObject = new THREE.Object3D();
  127. scene.add(targetObject);
  128. light.target = targetObject;
  129. </code>
  130. The spotlight will now track the target object.
  131. </div>
  132. <h2>Methods</h2>
  133. See the base [page:Light Light] class for common methods.
  134. <h3>[method:SpotLight copy]( [page:SpotLight source] )</h3>
  135. <div>
  136. Copies value of all the properties from the [page:SpotLight source] to this
  137. SpotLight.
  138. </div>
  139. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  140. </body>
  141. </html>