Class DirectionalLight

Affects objects using MeshLambertMaterial or 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 );

see

src/lights/DirectionalLight.js

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(hex?: number, intensity?: number): DirectionalLight

Parameters

  • hex?: number optional
  • intensity?: number optional

Returns

DirectionalLight

Properties

public castShadow: boolean

If set to true light will cast dynamic shadows. Warning: This is expensive and requires tweaking to get shadows looking right. Default — false.

public children: Object3D[]

Array with object's children.

public color: Color

public eulerOrder: string

Order of axis for Euler angles.

public frustumCulled: boolean

When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible.

public id: number

Unique number of this object instance.

public intensity: number

Light's intensity. Default — 1.0.

public matrix: Matrix4

Local transform.

public matrixAutoUpdate: boolean

When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property.

public matrixWorld: Matrix4

The global transform of the object. If the Object3d has no parent, then it's identical to the local transform.

public matrixWorldNeedsUpdate: boolean

When this is set, it calculates the matrixWorld in that frame and resets this property to false.

public name: string

Optional name of the object (doesn't need to be unique).

public onlyShadow: boolean

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.

public parent: Object3D

Object's parent in the scene graph.

public position: Vector3

Direction of the light is normalized vector from position to (0,0,0). Default — new THREE.Vector3().

public quaternion: Quaternion

Global rotation.

public receiveShadow: boolean

Material gets baked in shadow receiving.

public renderDepth: number

Override depth-sorting order if non null.

public rotation: Euler

Object's local rotation (Euler angles), in radians.

public rotationAutoUpdate: boolean

When this is set, then the rotationMatrix gets calculated every frame.

public scale: Vector3

Object's local scale.

public shadowBias: number

Shadow map bias. Default — 0.

public shadowCamera: Camera

Default — null.

public shadowCameraBottom: number

Orthographic shadow camera frustum parameter. Default — -500.

public shadowCameraFar: number

Orthographic shadow camera frustum parameter. Default — 5000.

public shadowCameraLeft: number

Orthographic shadow camera frustum parameter. Default — -500.

public shadowCameraNear: number

Orthographic shadow camera frustum parameter. Default — 50.

public shadowCameraRight: number

Orthographic shadow camera frustum parameter. Default — 500.

public shadowCameraTop: number

Orthographic shadow camera frustum parameter. Default — 500.

public shadowCameraVisible: boolean

Show debug shadow camera frustum. Default — false.

public shadowCascade: boolean

Default — false.

public shadowCascadeArray: DirectionalLight[]

Default — [ ].

public shadowCascadeBias: Array<number>

Default — [ 0, 0, 0 ].

public shadowCascadeCount: number

Default — 2.

public shadowCascadeFarZ: Array<number>

Default — [ 0.990, 0.998, 1.000 ].

public shadowCascadeHeight: Array<number>

Default — [ 512, 512, 512 ].

public shadowCascadeNearZ: Array<number>

Default — [ -1.000, 0.990, 0.998 ].

public shadowCascadeOffset: Vector3

Three.Vector3( 0, 0, -1000 ).

public shadowCascadeWidth: Array<number>

Default — [ 512, 512, 512 ].

public shadowDarkness: number

Darkness of shadow casted by this light (from 0 to 1). Default — 0.5.

public shadowMap: RenderTarget

Default — null.

public shadowMapHeight: number

Shadow map texture height in pixels. Default — 512.

public shadowMapSize: number

Default — null.

public shadowMapWidth: number

Shadow map texture width in pixels. Default — 512.

public shadowMatrix: Matrix4

Default — null.

public target: Object3D

Target used for shadow camera orientation.

public up: Vector3

Up direction.

public useQuaternion: boolean

Use quaternion instead of Euler angles for specifying local rotation.

public userData: any

An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned.

public visible: boolean

Object gets rendered if true.

Methods

public add(object: Object3D)

Adds object as child of this object.

Parameters

public applyMatrix(matrix: Matrix4)

This updates the position, rotation and scale with the matrix.

Parameters

public clone(): DirectionalLight

Returns

DirectionalLight

public getDescendants(array?: Object3D[]): Object3D[]

Searches whole subgraph recursively to add all objects in the array.

Parameters

  • array?: Object3D[] optional

    optional argument that returns the the array with descendants.

Returns

Object3D[]

public getObjectById(id: string, recursive: boolean): Object3D

Searches through the object's children and returns the first with a matching id, optionally recursive.

Parameters

  • id: string

    Unique number of the object instance

  • recursive: boolean

    Boolean whether to search through the children's children. Default is false.

Returns

Object3D

public getObjectByName(name: string, recursive: boolean): Object3D

Searches through the object's children and returns the first with a matching name, optionally recursive.

Parameters

  • name: string

    String to match to the children's Object3d.name property.

  • recursive: boolean

    Boolean whether to search through the children's children. Default is false.

Returns

Object3D

public localToWorld(vector: Vector3): Vector3

Updates the vector from local space to world space.

Parameters

Returns

Vector3

public lookAt(vector: Vector3)

Rotates object to face point in space.

Parameters

  • vector: Vector3

    A world vector to look at.

public remove(object: Object3D)

Removes object as child of this object.

Parameters

public rotateOnAxis(axis: Vector3, angle: number): Object3D

Rotate an object along an axis in object space. The axis is assumed to be normalized.

Parameters

  • axis: Vector3

    A normalized vector in object space.

  • angle: number

    The angle in radians.

Returns

Object3D

public translateOnAxis(axis: Vector3, distance: number): Object3D

Parameters

  • axis: Vector3

    A normalized vector in object space.

  • distance: number

    The distance to translate.

Returns

Object3D

public translateX(distance: number)

Translates object along x axis by distance.

Parameters

  • distance: number

    Distance.

public translateY(distance: number)

Translates object along y axis by distance.

Parameters

  • distance: number

    Distance.

public translateZ(distance: number)

Translates object along z axis by distance.

Parameters

  • distance: number

    Distance.

public traverse(callback: (object: THREE.Object3D) => any)

Translates object along arbitrary axis by distance.

Parameters

  • callback: (object: THREE.Object3D) => any

public updateMatrix()

Updates local transform.

public updateMatrixWorld(force: boolean)

Updates global transform of the object and its children.

Parameters

  • force: boolean

public worldToLocal(vector: Vector3): Vector3

Updates the vector from world space to local space.

Parameters

Returns

Vector3