Create a directional light, that is emitted in a single direction without any attenuation. A common use case for this type of light is to simulate the sun.

This light can cast DirectionalShadow.

// assuming 'renderer' is a valid Camera renderer

// this directional light will not cast any shadows
const directionalLight = new DirectionalLight(renderer, {
color: new Vec3(1),
intensity: 1,
position: new Vec3(5, 2, 3),
})

// this directional light will cast shadows
const directionalLightWithShadows = new DirectionalLight(renderer, {
color: new Vec3(1),
intensity: 1,
position: new Vec3(-10, 10, -5),
shadow: {
intensity: 1,
},
})

// this directional light will ALSO cast shadows!
const anotherDirectionalLightWithShadows = new DirectionalLight(renderer, {
color: new Vec3(1),
intensity: 2,
position: new Vec3(12, 0.5, 5),
target: new Vec3(3),
shadow: {}, // that's enough to start casting shadows
})

// this directional light will cast shadows as well...
const lastDirectionalLightWithShadows = new DirectionalLight(renderer, {
color: new Vec3(1),
intensity: 1,
position: new Vec3(10),
})

// ... because we're telling it here to start casting shadows
lastDirectionalLightWithShadows.shadow.cast()

Hierarchy (View Summary)

Constructors

Properties

target: Vec3

Options used to create this DirectionalLight.

DirectionalShadow associated with this DirectionalLight.

type: string
uuid: string

The universal unique id of this Light

index: number

Index of this Light, i.e. the number of time a Light of this type has been created.

renderer: CameraRenderer

CameraRenderer used by this Light

color: Vec3

Current color of this Light.

rendererBinding: BufferBinding

CameraRenderer corresponding BufferBinding that holds all the bindings to send to the shaders.

userData: Record<string, unknown>

Empty object to store any additional data or custom properties into your Light.

_onBeforeRenderCallback: () => void

function assigned to the onBeforeRender callback

transforms: Object3DTransforms
up: Vec3

Vec3 used by the lookAt method, to determine the orientation of the result. Default to new Vec3(0, 1, 0).

actualPosition: Vec3

Vec3 holding the actual position of this Object3D from its worldMatrix.

children: Object3D[]

Children Object3D in the scene graph, used to compute their own worldMatrix.

object3DIndex: number

Index (order of creation) of this Object3D. Used in the parent / children relation.

matricesNeedUpdate: boolean

Whether at least one of this Object3D matrix needs an update.

Accessors

Methods

  • Callback to execute before updating the Scene matrix stack. This means it is called early and allows to update transformations values before actually setting the Light matrices. The callback won't be called if the renderer is not ready.

    Parameters

    • callback: () => void

      callback to run just before updating the Scene matrix stack.

    Returns this