SpotLight.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 distance from origin where light will shine whose intensity
  56. is attenuated linearly based on distance from origin. <br />
  57. [page:Radians angle] - Maximum angle of light dispersion from its direction whose upper
  58. bound is Math.PI/2.<br />
  59. [page:Float penumbra] - Percent of the spotlight cone that is attenuated due to penumbra.
  60. Takes values between zero and 1. Default is zero.<br />
  61. [page:Float decay] - The amount the light dims along the distance of the light.<br /><br />
  62. Creates a new [name].
  63. </p>
  64. <h2>Properties</h2>
  65. See the base [page:Light Light] class for common properties.
  66. <h3>[property:Float angle]</h3>
  67. <p>
  68. Maximum extent of the spotlight, in radians, from its direction. Should be no more than
  69. *Math.PI/2*. The default is *Math.PI/3*.
  70. </p>
  71. <h3>[property:Boolean castShadow]</h3>
  72. <p>
  73. If set to *true* light will cast dynamic shadows. *Warning*: This is expensive and
  74. requires tweaking to get shadows looking right. See the [page:SpotLightShadow] for details.
  75. The default is *false*.
  76. </p>
  77. <h3>[property:Float decay]</h3>
  78. <p>
  79. The amount the light dims along the distance of the light.<br />
  80. In [page:WebGLRenderer.physicallyCorrectLights physically correct] mode, decay = 2 leads to
  81. physically realistic light falloff. The default is *1*.
  82. </p>
  83. <h3>[property:Float distance]</h3>
  84. <p>
  85. If non-zero, light will attenuate linearly from maximum intensity at the light's
  86. position down to zero at this distance from the light. Default is *0.0*.
  87. </p>
  88. <h3>[property:Boolean isSpotLight]</h3>
  89. <p>
  90. Used to check whether this or derived classes are spot lights. Default is *true*.<br /><br />
  91. You should not change this, as it used internally for optimisation.
  92. </p>
  93. <h3>[property:Float penumbra]</h3>
  94. <p>
  95. Percent of the spotlight cone that is attenuated due to penumbra. Takes values between
  96. zero and 1. The default is *0.0*.
  97. </p>
  98. <h3>[property:Vector3 position]</h3>
  99. <p>
  100. This is set equal to [page:Object3D.DefaultUp] (0, 1, 0), so that the light shines from the top down.
  101. </p>
  102. <h3>[property:Float power]</h3>
  103. <p>
  104. The light's power.<br />
  105. In [page:WebGLRenderer.physicallyCorrectLights physically correct] mode, the luminous
  106. power of the light measured in lumens. Default is *4Math.PI*. <br /><br />
  107. This is directly related to the [page:.intensity intensity] in the ratio
  108. <code>
  109. power = intensity * &pi;
  110. </code>
  111. and changing this will also change the intensity.
  112. </p>
  113. <h3>[property:SpotLightShadow shadow]</h3>
  114. <p>
  115. A [page:SpotLightShadow] used to calculate shadows for this light.
  116. </p>
  117. <h3>[property:Object3D target]</h3>
  118. <p>
  119. The Spotlight points from its [page:.position position] to target.position. The default
  120. position of the target is *(0, 0, 0)*.<br />
  121. *Note*: For the target's position to be changed to anything other than the default,
  122. it must be added to the [page:Scene scene] using
  123. <code>
  124. scene.add( light.target );
  125. </code>
  126. This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
  127. updated each frame.<br /><br />
  128. It is also possible to set the target to be another object in the scene (anything with a
  129. [page:Object3D.position position] property), like so:
  130. <code>
  131. var targetObject = new THREE.Object3D();
  132. scene.add(targetObject);
  133. light.target = targetObject;
  134. </code>
  135. The spotlight will now track the target object.
  136. </p>
  137. <h2>Methods</h2>
  138. See the base [page:Light Light] class for common methods.
  139. <h3>[method:SpotLight copy]( [param:SpotLight source] )</h3>
  140. <p>
  141. Copies value of all the properties from the [page:SpotLight source] to this
  142. SpotLight.
  143. </p>
  144. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  145. </body>
  146. </html>