DirectionalLight - A directional light

Constructor

class DirectionalLight(hex, intensity, distance)

A directional light

Part of scene graph

Inherits from Light() Object3D()

Affects MeshLambertMaterial() and MeshPhongMaterial()

Arguments:
  • hex (integer) – light color
  • intensity (float) – light intensity
  • distance (float) – distance affected by light

Attributes

DirectionalLight.color

Light Color()

DirectionalLight.intensity

Light intensity

default 1.0

DirectionalLight.position

Direction of the light is normalized vector from position to (0,0,0).

DirectionalLight.distance

Modulating directional light by distance not implemented in WebGLRenderer()

Shadow attributes

DirectionalLight.castShadow

If set to true light will cast dynamic shadows

Warning: this is expensive and requires tweaking to get shadows looking right.

default false

DirectionalLight.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

DirectionalLight.target

Object3D() target used for shadow camera orientation

DirectionalLight.shadowCameraNear

Orthographic shadow camera frustum parameter

default 50

DirectionalLight.shadowCameraFar

Orthographic shadow camera frustum parameter

default 5000

DirectionalLight.shadowCameraLeft

Orthographic shadow camera frustum parameter

default -500

DirectionalLight.shadowCameraRight

Orthographic shadow camera frustum parameter

default 500

DirectionalLight.shadowCameraTop

Orthographic shadow camera frustum parameter

default 500

DirectionalLight.shadowCameraBottom

Orthographic shadow camera frustum parameter

default -500

DirectionalLight.shadowCameraVisible

Show debug shadow camera frustum

default false

DirectionalLight.shadowBias

Shadow map bias

default 0

DirectionalLight.shadowDarkness

Darkness of shadow casted by this light (float from 0 to 1)

default 0.5

DirectionalLight.shadowMapWidth

Shadow map texture width in pixels

default 512

DirectionalLight.shadowMapHeight

Shadow map texture height in pixels

default 512

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 );

Previous topic

AmbientLight - An ambient light

Next topic

PointLight - A point light

This Page