SpotLight

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

Core Class

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

Type Parameters

  • T extends TextureV2 | Texture2D = Texture2D

Hierarchy

Constructors

  • Type Parameters

    • T extends TextureV2 | Texture2D = Texture2D

    Parameters

    • color: string | number
    • intensity: number
    • distance: number
    • angle: number
    • penumbra: number
    • decay: number
    • isIESEnabled: boolean
    • textureIES: T
    • iesIntensityScale: number
    • iesTextureResolution: Vector2

    Returns SpotLight<T>

Properties

DefaultUp: Vector3

Every objects in 3D space must have a default up direction.

id: number

Unique number for each object3D instance.

categoryId: string

Reserved attribute

sourceType: string

Record the object rendered as instance or other type.

scene: Nullable<Scene3D>

The scene which this object belong to.

updateDirtyId: number

The number is the frame id which this object is changed or participates change of scene graph. If this value equals to frame id - 1,

name: string

The name of this object, it is empty if useless.

isObject3D: boolean

Used to check type of this or extended instance. This value should not be changed by user.

parent: Nullable<Object3D>

Object's parent node in the scene graph. An object can have at most one parent.

children: Object3D[]

Array with object's children.

See Group| Group for information on manually grouping objects.

This is used by the lookAt method, for example, to determine the orientation of the result. Default is DefaultUp .

worldMatrixUpdateTimestamp: number

Record when this object's world matrix last updated.

transformChanged: boolean

Record whether the object's any attribute| attribute is updated.

visibleChanged: boolean
matrixWorld: Matrix4

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

matrixWorldNeedsUpdate: boolean

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

netVisibility: boolean

Record if the object is really visible in rendering process. If the Object3D has no parent, it would be set by visible ;

localMatrixNeedUpdate: boolean

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

type: string

The type of this Object3D.

isLight: boolean

Check the type whether it belongs to Light. This value should not be changed by user.

color: Color

Color of the light. This value can influence the color of model's surface according to the material. Defaults to a new color set to white, if not passed in the constructor.

intensity: number

The light's intensity, or strength. In physically correct mode, the product of color * intensity is interpreted as luminous intensity measured in candela.

viewMatrix: Matrix4
invViewMatrix: Matrix4
angle: number

Maximum extent of the spotlight, in radians, from its direction. Should be no more than Math.PI/2.

penumbra: number

Percent of the spotlight cone that is attenuated due to penumbra. Takes values between zero and 1.

iesIntensityScale: number

The intensity scale of IES file.

iesTextureResolution: Vector2

Resolution of ies texture.

decay: number

The amount the light dims along the distance of the light In physically correct mode, decay = 2 leads to physically realistic light falloff.

isIESEnabled: boolean
isRotationModeOn: boolean

To support IES, spotLight set isRotationModeOn as true to calculate intensity according to rotation of light.

isSpotLight: boolean

Check the type whether it belongs to PerspectiveCamera. This value should not be changed by user.

defaultDirection: Vector3
direction: Vector3
shadow: SpotShadow<T>
isShadowNeedsUpdate: boolean
userData: Record<keyof any, any>
_uuid: any
uuid: string
_listeners: Map<Symbol, Listener<never>[]>

Accessors

  • get layers(): Layers

    Returns Layers

  • set layers(v: Layers): void

    Parameters

    Returns void

  • get interactionLayers(): Layers | undefined

    Returns Layers | undefined

  • set interactionLayers(v: Layers | undefined): void

    Parameters

    Returns void

  • get groupLayer(): Layers | undefined

    Returns Layers | undefined

  • set groupLayer(v: Layers | undefined): void

    Parameters

    Returns void

  • get position(): Vector3

    Returns Vector3

  • set position(_position: Vector3): void

    A vector representing the object's local position.

    Parameters

    Returns void

  • get rotation(): Euler

    Returns Euler

  • set rotation(rotation: Euler): void

    Object's local rotation, in radians.

    Parameters

    Returns void

  • get quaternion(): Quaternion

    Returns Quaternion

  • set quaternion(_quaternion: Quaternion): void

    Object's local rotation as a Quaternion.

    Parameters

    Returns void

    See Quaternion for more details.

  • get scale(): Vector3

    Returns Vector3

  • set scale(_scale: Vector3): void

    The object's local scale.

    Parameters

    Returns void

  • get matrix(): Matrix4

    The local transform matrix.

    Returns Matrix4

  • set matrix(value: Matrix4): void

    Parameters

    Returns void

  • get visible(): boolean

    Object gets rendered if true.

    Returns boolean

  • set visible(value: boolean): void

    Parameters

    • value: boolean

    Returns void

  • get enabled(): boolean

    Returns boolean

  • set enabled(v: boolean): void

    Parameters

    • v: boolean

    Returns void

  • get textureIES(): Nullable<T>

    Returns Nullable<T>

  • set textureIES(value: Nullable<T>): void

    Parameters

    • value: Nullable<T>

    Returns void

  • get power(): number

    The light's power. In physically correct mode, the luminous power of the light measured in lumens. This is directly related to the intensity in the ratio

    Returns number

  • set power(power: number): void

    Parameters

    • power: number

    Returns void

  • get distance(): number

    When distance is zero, light does not attenuate. When distance is non-zero, light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light.

    Returns number

  • set distance(dis: number): void

    Parameters

    • dis: number

    Returns void

  • get businessTag(): string

    Returns string

  • set businessTag(v: string): void

    Parameters

    • v: string

    Returns void

Methods

  • If the local matrix is changed, use this method to manually refresh data in scene graph.

    Returns void

    It's better to use notifySceneChange() as an alternative.

  • Use this method to manually refresh data in scene graph and draw again. The engine may not notify every change of the scene. If any effect is not changed with the parameters, use this may solve.

    Returns void

  • If there are zero or two negative numbers in xyz, return false, otherwise return true.

    Returns boolean

  • Converts the vector from local space to world space.

    Parameters

    • vector: Vector3

      A vector represents a position in local (object) coordinate.

    Returns Vector3

  • Applies the matrix transform to the object and updates the object's position, rotation and scale.

    Parameters

    • matrix: Matrix4

      A matrix represents the information of transform.

    Returns void

  • Applies the rotation represented by the quaternion to the object.

    Parameters

    • q: Quaternion

      A Quaternion represents the information of rotation.

    Returns this

  • Calls Quaternion.setRotationFromEuler| setRotationFromEuler(euler, true) on the Quaternion.

    Parameters

    • euler: Euler

      Euler angle specifying rotation amount.

    Returns void

  • 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

      Angle in radians.

    Returns this

  • Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent.

    Parameters

    • axis: Vector3

      A normalized vector in object space.

    • angle: number

      Angle in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Rotates the object around x axis in local space.

    Parameters

    • angle: number

      The angle to rotate in radians.

    Returns this

  • Translate an object by distance along an axis in object space. The axis is assumed to be normalized.

    Parameters

    • axis: Vector3

      A normalized vector in object space.

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along x axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along y axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Translates object along z axis in object space by distance units.

    Parameters

    • distance: number

      The distance to translate.

    Returns this

  • Rotates the object to face to a point in world space. This method does not support objects having non-uniformly-scaled parent(s)

    Parameters

    • _x: Vector3

      A vector representing position of target in world space.

    Returns void

  • Rotates the object to face a point in local space.

    Parameters

    • _x: Vector3

      A vector representing position of target in local space.

    Returns void

  • Adds object as child of this object. An arbitrary number of objects may be added. Any current parent on an object passed in here will be removed, since an object can have at most one parent. The scene graph change will be immediately notify by engine after adding nodes.

    Parameters

    • o: Object3D | Object3D[]

      Parameter can be one object or objects array, all of them is added to this object.

    Returns this

  • Remove the specified object form children.

    Parameters

    • object: Object3D

      The object which needs to be removed.

    Returns this

  • Remove all children in specified objects from this objects. Migrate from tools common

    Parameters

    • objects: Object3D[]

      An array of objects which need to be removed.

    Returns this

  • Searches through an object and its children, starting with the object itself, and returns the first with a matching id. Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.

    Parameters

    • id: number

      Unique number of the object instance.

    Returns Object3D

  • Searches through an object and its children, starting with the object itself, and returns the first with a matching name. Note that for most objects the name is an empty string by default. You will have to set it manually to make use of this method.

    Parameters

    • name: string

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

    Returns Object3D

  • Searches through an object and its children, starting with the object itself, and returns the first with a property that matches the value given.

    Parameters

    • name: string

      The property name to search for.

    • value: any

      Value of the given property.

    Returns Object3D

  • Return a vector of the scaling factors applied to the object for each axis in world space.

    Parameters

    • target: Vector3

      the result will be copied into this Vector3.

    Returns Vector3

  • Return a vector representing the direction of object's positive z-axis in world space.

    Parameters

    • target: Vector3

      the result will be copied into this Vector3.

    Returns Vector3

  • Execute the callback on this object and all descendants.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Execute the callback when return is false, stop traverse the object's descendants.

    Parameters

    • callback: (object: Object3D) => boolean

      A function with as first argument an object3D object, return boolean.

    Returns void

  • Execute the callback on this object and all descendants which is visible.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Execute the callback on this object and all ancestors.

    Parameters

    • callback: (object: Object3D) => any

      A function with as first argument an object3D object.

    Returns void

  • Update the matrix local transform.

    Returns void

  • Update the object's and its descendants' matrix of global transform with. If the parameter or matrixWorldNeedsUpdate is true, matrix will not skip updates.

    Parameters

    • force: boolean

      Whether or not force to updates the matrix.

    Returns void

  • Update the object's and its descendants' matrix of global transform with. will update parent or children according to the parameters

    Parameters

    • updateParents: boolean

      update parents.

    • updateChildren: boolean

      update children.

    • force: boolean

      Whether or not force to updates the matrix.

    Returns void

  • Get the whole bounding box of current object cover all children's.

    Parameters

    • localBox: Box3

      If this is not undefined, result will be stored to it.

    Returns Box3

  • Get UUID of this object instance. This value is automatically assigned, so this shouldn't be edited.

    Returns string

  • The name of instance's class.

    Returns string

  • Returns number

  • Copy the data to this light instance from source. This method need override in derived classes to copy extended data.

    Parameters

    • source: SpotLight<T>

      the data source.

    • recursive: boolean

      if true, descendants of the object are also cloned. Default is true.

    Returns this

  • Return a cloned instance of this class and optionally all descendants.

    Parameters

    • recursive: boolean

      if true, descendants of the object are also cloned. Default is true.

    Returns SpotLight<T>

  • Parameters

    • program: WGLProgram
    • index: number

    Returns void

  • Parameters

    • program: WGLProgram

    Returns void

  • Parameters

    • program: WGLProgram
    • lightPrefix: string
    • shadowPrefix: string

    Returns void

  • Parameters

    • isArray: boolean

    Returns
    | "\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n uniform sampler2D spotIES[ NUM_SPOT_LIGHTS ];\n "
    | "\n uniform SpotLight spotLight;\n uniform sampler2D spotLightIES;\n "

  • Returns Texture2D | T

  • Returns void

  • Parameters

    • drawable: Drawable

    Returns boolean

  • Parse the data for this class from string according to serializing format.

    Parameters

    • ctx: Deserializer

      an instance give the method to take the data for attribute.

    Returns void

  • Store the attributes of this class into string as serializing format.

    Parameters

    • ctx: Serializer

      an instance used to store the data of scene objects.

    Returns void

  • Adds a listener to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Only active the listener one times and then off it| it.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Checks if listener is added to an event type.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns boolean

  • Removes a listener from listening list.

    Type Parameters

    • T

    Parameters

    • _type: EventType<T>
    • _listener: Listener<T>

    Returns void

  • Active the event and call the registered listener.

    Parameters

    • type: EventType<never>

    Returns void

  • Type Parameters

    • T

    Parameters

    • type: EventType<T>
    • payload: T

    Returns void

  • Removes all listeners from listening list.

    Returns void