gpu-curtains
    Preparing search index...

    Create a spot light, that is emitted from a single point in one direction, along a cone that increases in size the further from the light it gets.

    This light can cast SpotShadow.

    // assuming 'renderer' is a valid Camera renderer

    // this spot light will not cast any shadows
    const spotLight = new SpotLight(renderer, {
    color: new Vec3(1),
    intensity: 1,
    position: new Vec3(5, 2, 3),
    penumbra: 0.5,
    })

    // this spot light will cast shadows
    const spotLightWithShadows = new SpotLight(renderer, {
    color: new Vec3(1),
    intensity: 1,
    position: new Vec3(-10, 10, -5),
    target: new Vec3(0, 0.5, 0),
    shadow: {
    intensity: 1,
    },
    })

    // this spot light will ALSO cast shadows!
    const anotherSpotLightWithShadows = new SpotLight(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 spot light will cast shadows as well...
    const lastSpotLightWithShadows = new SpotLight(renderer, {
    color: new Vec3(1),
    intensity: 1,
    position: new Vec3(10),
    })

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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    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

    target: Vec3

    Options used to create this SpotLight.

    shadow: SpotShadow

    SpotShadow associated with this SpotLight.

    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

    • get parentVisibility(): boolean

      Get whether all this Light parents are visible or not. Should not be used directly.

      Returns boolean

    • set parentVisibility(value: boolean): void

      Set this Light parent visiblity, and update its actualColor property accordingly. Should not be used directly.

      Parameters

      • value: boolean

      Returns void

    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