SpotLight.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. SpotLight - A spotlight
  2. -----------------------
  3. .. ...............................................................................
  4. .. rubric:: Constructor
  5. .. ...............................................................................
  6. .. class:: SpotLight( hex, intensity, distance, castShadow )
  7. A point light that can cast shadow in one direction
  8. Part of scene graph
  9. Inherits from :class:`Light` :class:`Object3D`
  10. Affects :class:`MeshLambertMaterial` and :class:`MeshPhongMaterial`
  11. :param integer hex: light color
  12. :param float intensity: light intensity
  13. :param float distance: distance affected by light
  14. :param bool castShadow: shadow casting
  15. .. ...............................................................................
  16. .. rubric:: Attributes
  17. .. ...............................................................................
  18. .. attribute:: SpotLight.color
  19. Light :class:`Color`
  20. .. attribute:: SpotLight.intensity
  21. Light intensity
  22. ``default 1.0``
  23. .. attribute:: SpotLight.position
  24. Position of the light
  25. .. attribute:: SpotLight.distance
  26. If non-zero, light will attenuate linearly from maximum intensity at light ``position`` down to zero at ``distance``
  27. .. ...............................................................................
  28. .. rubric:: Shadow attributes
  29. .. ...............................................................................
  30. .. attribute:: SpotLight.castShadow
  31. If set to `true` light will cast dynamic shadows
  32. Warning: this is expensive and requires tweaking to get shadows looking right.
  33. ``default false``
  34. .. attribute:: SpotLight.onlyShadow
  35. If set to `true` light will only cast shadow but not contribute any lighting (as if intensity was 0 but cheaper to compute)
  36. ``default false``
  37. .. attribute:: SpotLight.target
  38. :class:`Object3D` target used for shadow camera orientation
  39. .. attribute:: SpotLight.shadowCameraNear
  40. Perspective shadow camera frustum ``near``
  41. ``default 50``
  42. .. attribute:: SpotLight.shadowCameraFar
  43. Perspective shadow camera frustum ``far``
  44. ``default 5000``
  45. .. attribute:: SpotLight.shadowCameraFov
  46. Perspective shadow camera frustum ``field-of-view``
  47. ``default 50``
  48. .. attribute:: SpotLight.shadowCameraVisible
  49. Show debug shadow camera frustum
  50. ``default false``
  51. .. attribute:: SpotLight.shadowBias
  52. Shadow map bias
  53. ``default 0``
  54. .. attribute:: SpotLight.shadowDarkness
  55. Darkness of shadow casted by this light (``float`` from 0 to 1)
  56. ``default 0.5``
  57. .. attribute:: SpotLight.shadowMapWidth
  58. Shadow map texture width in pixels
  59. ``default 512``
  60. .. attribute:: SpotLight.shadowMapHeight
  61. Shadow map texture height in pixels
  62. ``default 512``
  63. .. ...............................................................................
  64. .. rubric:: Example
  65. .. ...............................................................................
  66. ::
  67. // white spotlight shining from the side, casting shadow
  68. var spotLight = new THREE.SpotLight( 0xffffff );
  69. spotLight.position.set( 100, 1000, 100 );
  70. spotLight.castShadow = true;
  71. spotLight.shadowMapWidth = 1024;
  72. spotLight.shadowMapHeight = 1024;
  73. spotLight.shadowCameraNear = 500;
  74. spotLight.shadowCameraFar = 4000;
  75. spotLight.shadowCameraFov = 30;
  76. scene.add( spotLight );