[page:Object3D] →
Light
Abstract base class for lights.
Constructor
Light( [page:Integer hex] )
[page:Integer hex] — Numeric value of the RGB component of the color.
This creates a light with color.
Properties
[property:Color color]
Color of the light.
Source:src/lights/Light.js
[page:Object3D] → [page:Light] →
AmbientLight
OObject3D -> Light ->
This light's color gets applied to all the objects in the scene globally.
Example
var light = new THREE.AmbientLight( 0x404040 ); // soft white light
scene.add( light );
Constructor
AreaLight( [page:Integer hex], [page:Float intensity])
[page:Integer hex] — Numeric value of the RGB component of the color.
[page:Float intensity] — Numeric value of the light's strength/intensity.
AreaLight( hex, intensity)
This creates a arealight with color.
Properties
[property:Vector3 right]
.right
Sets or gets an unit vector that indicates the right
side of the light. This is calculated in local space.
[property:Vector3 normal]
Sets or gets an unit vectorSets or gets an unit vector that indicates the right side of the light. This is calculated in local space.
[property:number height]
Sets or gets the height of the illuminating plane.
[property:number width]
Sets or gets the width of the illuminating plane.
[property:Float intensity]
Light's intensity.
Default — *1.0*.
[property:number constantAttenuation]
Sets or gets the attention of the light in constant space. This is independant of the distance of the light.
[property:number linearAttenuation]
Sets or gets the attention of the light in linear space. This increases the attenuation linearly with the distance from the light.
[property:number quadraticAttenuation]
Sets or gets the attention of the light in linear space. This increases the attenuation quadratic with the distance from the light.
Source:src/lights/AreaLight.js
[page:Object3D] → [page:Light] →
DirectionalLight
Object3D -> Light ->
Affects objects using
[page:MeshLambertMaterial] or [page:MeshPhongMaterial].
Example
// White directional light at half intensity shining from the top.
var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
directionalLight.position.set( 0, 1, 0 );
scene.add( directionalLight );
Constructor
DirectionalLight([page:Integer hex], [page:Float intensity])
[page:Integer hex] -- Numeric value of the RGB component of the color.
[page:Float intensity] -- Numeric value of the light's strength/intensity.
DirectionalLight(hex, intensity)
Creates a light that shines from a specific direction
not from a specific position.
This light will behave as though it is infinitely far away and
the rays produced from it are all parallel.
The best analogy would be a light source that acts like the sun:
the sun is so far away that all sunlight hitting objects comes from
the same angle.
Properties
[property:Object3D target]
Target used for shadow camera orientation.
[property:Float intensity]
Light's intensity.
Default — *1.0*.
[property:Boolean onlyShadow]
If set to *true* light will only cast shadow but not contribute
any lighting (as if *intensity* was 0 but cheaper to compute).
Default — *false*.
[property:Float shadowCameraNear]
Orthographic shadow camera frustum parameter.
Default — *50*.
[property:Float shadowCameraFar]
Orthographic shadow camera frustum parameter.
Default — *5000*.
[property:Float shadowCameraLeft]
Orthographic shadow camera frustum parameter.
Default — *-500*.
[property:Float shadowCameraRight]
Orthographic shadow camera frustum parameter.
Default — *500*.
[property:Float shadowCameraTop]
Orthographic shadow camera frustum parameter.
Default — *500*.
[property:Float shadowCameraBottom]
Orthographic shadow camera frustum parameter.
Default — *-500*.
[property:Boolean shadowCameraVisible]
Show debug shadow camera frustum.
Default — *false*.
[property:Float shadowBias]
Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.
Default — *0*.
[property:Float shadowDarkness]
Darkness of shadow casted by this light (from *0* to *1*).
Default — *0.5*.
[property:Integer shadowMapWidth]
Shadow map texture width in pixels.
Default — *512*.
[property:Integer shadowMapHeight]
Shadow map texture height in pixels.
Default — *512*.
[property:Boolean shadowCascade]
**Experimental** If true, use a series of shadow maps in a cascade. This can give better z-depth resolution for a directional light.
Default — *false*.
[property:Integer shadowCascadeCount]
Number of shadow maps to allocate in a cascade (one after another).
Default — *2*.
[property:Vector3 shadowCascadeOffset]
A relative position to real camera where virtual shadow cameras are attached. A magic vector; scene and light orientation dependent.
Default — *Three.Vector3( 0, 0, -1000 )*.
[property:Array shadowCascadeBias]
An array of shadowMapBias values for the corresponding shadow map in the cascade, near to far.
Default — [ 0, 0, 0 ].
[property:Array shadowCascadeWidth]
An array of shadowMapWidth values for the corresponding shadow map in the cascade, near to far.
Default — [ 512, 512, 512 ].
[property:Array shadowCascadeHeight]
An array of shadowMapHeight values for the corresponding shadow map in the cascade, near to far.
Default — [ 512, 512, 512 ].
[property:Array shadowCascadeNearZ]
An array of shadowMapNear values for the corresponding shadow map in the cascade, near to far. These typically start with -1.0 (near plane) and match with the previous shadowCascadeFarZ array value.
Default — [ -1.000, 0.990, 0.998 ].
[property:Array shadowCascadeFarZ]
An array of shadowMapFar values for the corresponding shadow map in the cascade, near to far. These typically match with the next shadowCascadeNearZ array value, ending in 1.0.
Default — [ 0.990, 0.998, 1.000 ].
[property:Array shadowCascadeArray]
Array of size shadowCascadeCount of [page:DirectionalLight THREE.DirectionalLight] objects. This holds the series of separate shadow maps in a cascade, near to far. Created internally.
[property:Vector2 shadowMapSize]
The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering.
[property:OrthographicCamera shadowCamera]
The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings.
[property:Matrix4 shadowMatrix]
Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering.
[property:WebGLRenderTarget shadowMap]
The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
Methods
Source:src/lights/DirectionalLight.js
Object3D -> Light ->
[page:Object3D] → [page:Light] →
HemisphereLight
A light source positioned directly above the scene.
Constructor
HemisphereLight([page:Integer skyColorHex], [page:Integer groundColorHex], [page:Float intensity])
HemisphereLight(skyColorHex, groundColorHex, intensity)
[page:Integer skyColorHex] — Numeric value of the RGB sky color.
[page:Integer groundColorHex] — Numeric value of the RGB ground color.
[page:Float intensity] — Numeric value of the light's strength/intensity.
Properties
[property:Float groundColor]
Light's ground color.
[property:Float intensity]
Light's intensity.
Default — *1.0*.
Methods
Source:src/lights/HemisphereLight.js
[page:Object3D] → [page:Light] →
PointLight
Object3D -> Light ->
Affects objects using
[page:MeshLambertMaterial] or [page:MeshPhongMaterial].
Example
var light = new THREE.PointLight( 0xff0000, 1, 100 );
light.position.set( 50, 50, 50 );
scene.add( light );
Constructor
PointLight([page:Integer hex], [page:Float intensity], [page:Number distance])
[page:Integer hex] — Numeric value of the RGB component of the color.
[page:Float intensity] — Numeric value of the light's strength/intensity.
[page:Number distance] -- The distance of the light where the intensity is 0. When distance is 0, then the distance is endless.
PointLight(hex, intensity, distance)
Creates a light at a specific position in the scene.
The light shines in all directions (roughly similar to a light bulb.)
Properties
[property:Float intensity]
Light's intensity.
Default - *1.0*.
[property:Float distance]
If non-zero, light will attenuate linearly from maximum intensity at light *position* down to zero at *distance*.
Default — *0.0*.
Methods
Source:src/lights/PointLight.js
[page:Object3D] → [page:Light] →
Object3D -> Light ->
SpotLight
A point light that can cast shadow in one direction.
Affects objects using
[page:MeshLambertMaterial] or [page:MeshPhongMaterial].
Example
// white spotlight shining from the side, casting shadow
var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 100, 1000, 100 );
spotLight.castShadow = true;
spotLight.shadowMapWidth = 1024;
spotLight.shadowMapHeight = 1024;
spotLight.shadowCameraNear = 500;
spotLight.shadowCameraFar = 4000;
spotLight.shadowCameraFov = 30;
scene.add( spotLight );
Constructor
SpotLight([page:Integer hex], [page:Float intensity],
[page:todo distance], [page:todo angle], [page:todo exponent])
SpotLight(hex, intensity, distance, angle, exponent)
[page:Integer hex] — Numeric value of the RGB component of the color.
[page:Float intensity] — Numeric value of the light's strength/intensity.
distance -- Maximum distance from origin where light will shine whose intensity is attenuated linearly based on distance from origin.
angle -- Maximum angle of light dispersion from its direction whose upper bound is Math.PI/2.
exponent -- todo
todo
Properties
[property:Object3D target]
Spotlight focus points at target.position.
Default position — *(0,0,0)*.
[property:Float intensity]
Light's intensity.
Default — *1.0*.
[property:Float distance]
If non-zero, light will attenuate linearly from maximum intensity at light *position* down to zero at *distance*.
Default — *0.0*.
[property:Float angle]
Maximum extent of the spotlight, in radians, from its direction. Should be no more than *Math.PI/2*.
Default — *Math.PI/3*.
[property:Float exponent]
Rapidity of the falloff of light from its target direction.
Default — *10.0*.
[property:Boolean castShadow]
If set to *true* light will cast dynamic shadows. *Warning*: This is expensive and requires tweaking to get shadows looking right.
Default — *false*.
[property:Boolean onlyShadow]
If set to *true* light will only cast shadow but not contribute any lighting (as if *intensity* was 0 but cheaper to compute).
Default — *false*.
[property:Float shadowCameraNear]
Perspective shadow camera frustum near parameter.
Default — *50*.
[property:Float shadowCameraFar]
Perspective shadow camera frustum far parameter.
Default — *5000*.
[property:Float shadowCameraFov]
Perspective shadow camera frustum field of view parameter.
Default — *50*.
[property:Boolean shadowCameraVisible]
Show debug shadow camera frustum.
Default — *false*.
[property:Float shadowBias]
Shadow map bias, how much to add or subtract from the normalized depth when deciding whether a surface is in shadow.
Default — *0*.
[property:Float shadowDarkness]
Darkness of shadow casted by this light (from *0* to *1*).
Default — *0.5*.
[property:Integer shadowMapWidth]
Shadow map texture width in pixels.
Default — *512*.
[property:Integer shadowMapHeight]
Shadow map texture height in pixels.
Default — *512*.
[property:Vector2 shadowMapSize]
The shadowMapWidth and shadowMapHeight stored in a [page:Vector2 THREE.Vector2]. Set internally during rendering.
[property:PerspectiveCamera shadowCamera]
The shadow's view of the world. Computed internally during rendering from the shadowCamera* settings.
[property:Matrix4 shadowMatrix]
Model to shadow camera space, to compute location and depth in shadow map. Computed internally during rendering.
[property:WebGLRenderTarget shadowMap]
The depth map generated using the shadowCamera; a location beyond a pixel's depth is in shadow. Computed internally during rendering.
Methods
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]