SpotLight.rst 2.7 KB

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