Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PointLight

A point light is a light defined by an unique point in world space. The light is emitted in every direction from this point. A good example of a point light is a standard light bulb. Documentation: https://doc.babylonjs.com/babylon101/lights

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene. A PointLight emits the light in every direction. It can cast shadows. If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :

    var pointLight = new PointLight("pl", camera.position, scene);
    

    Documentation : https://doc.babylonjs.com/babylon101/lights

    Parameters

    • name: string

      The light friendly name

    • position: Vector3

      The position of the point light in the scene

    • scene: Scene

      The scene the lights belongs to

    Returns PointLight

Properties

animationsSearch playground for animations

animations: Animation[]

Gets a list of Animations associated with the node

customProjectionMatrixBuilderSearch playground for customProjectionMatrixBuilder

customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void

Callback defining a custom Projection Matrix Builder. This can be used to override the default projection matrix computation.

Type declaration

diffuseSearch playground for diffuse

diffuse: Color3

Diffuse gives the basic color to an object.

falloffTypeSearch playground for falloffType

falloffType: number

Defines the falloff type for this light. This lets overriding how punctual light are falling off base on range or angle. This can be set to any values in Light.FALLOFF_x.

Note: This is only useful for PBR Materials at the moment. This could be extended if required to other types of materials.

idSearch playground for id

id: string

Gets or sets the id of the node

inspectableCustomPropertiesSearch playground for inspectableCustomProperties

inspectableCustomProperties: IInspectable[]

List of inspectable custom properties (used by the Inspector)

see

https://doc.babylonjs.com/how_to/debug_layer#extensibility

intensitySearch playground for intensity

intensity: number

Strength of the light. Note: By default it is define in the framework own unit. Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.

metadataSearch playground for metadata

metadata: any

Gets or sets an object used to store user defined information for the node

nameSearch playground for name

name: string

Gets or sets the name of the node

onDisposeObservableSearch playground for onDisposeObservable

onDisposeObservable: Observable<Node>

An event triggered when the mesh is disposed

onReadySearch playground for onReady

onReady: Nullable<(node: Node) => void>

Callback raised when the node is ready to be used

renderPrioritySearch playground for renderPriority

renderPriority: number

Defines the rendering priority of the lights. It can help in case of fallback or number of lights exceeding the number allowed of the materials.

reservedDataStoreSearch playground for reservedDataStore

reservedDataStore: any

For internal use only. Please do not use.

specularSearch playground for specular

specular: Color3

Specular produces a highlight color on an object. Note: This is not affecting PBR materials.

stateSearch playground for state

state: string

Gets or sets a string used to store user defined state for the node

transformedDirectionSearch playground for transformedDirection

transformedDirection: Vector3

The transformed direction. Direction of the light in world space taking parenting in account.

transformedPositionSearch playground for transformedPosition

transformedPosition: Vector3

The transformed position. Position of the light in world space taking parenting in account.

uniqueIdSearch playground for uniqueId

uniqueId: number

Gets or sets the unique id of the node

Static Readonly FALLOFF_DEFAULTSearch playground for FALLOFF_DEFAULT

FALLOFF_DEFAULT: number

Falloff Default: light is falling off following the material specification: standard material is using standard falloff whereas pbr material can request special falloff per materials.

Static Readonly FALLOFF_GLTFSearch playground for FALLOFF_GLTF

FALLOFF_GLTF: number

Falloff gltf: light is falling off as described in the gltf moving to PBR document to enhance interoperability with other engines.

Static Readonly FALLOFF_PHYSICALSearch playground for FALLOFF_PHYSICAL

FALLOFF_PHYSICAL: number

Falloff Physical: light is falling off following the inverse squared distance law.

Static Readonly FALLOFF_STANDARDSearch playground for FALLOFF_STANDARD

FALLOFF_STANDARD: number

Falloff Standard: light is falling off like in the standard material to enhance interoperability with other materials.

Static Readonly INTENSITYMODE_AUTOMATICSearch playground for INTENSITYMODE_AUTOMATIC

INTENSITYMODE_AUTOMATIC: number

Each light type uses the default quantity according to its type: point/spot lights use luminous intensity directional lights use illuminance

Static Readonly INTENSITYMODE_ILLUMINANCESearch playground for INTENSITYMODE_ILLUMINANCE

INTENSITYMODE_ILLUMINANCE: number

lux (lm/m^2)

Static Readonly INTENSITYMODE_LUMINANCESearch playground for INTENSITYMODE_LUMINANCE

INTENSITYMODE_LUMINANCE: number

nit (cd/m^2)

Static Readonly INTENSITYMODE_LUMINOUSINTENSITYSearch playground for INTENSITYMODE_LUMINOUSINTENSITY

INTENSITYMODE_LUMINOUSINTENSITY: number

candela (lm/sr)

Static Readonly INTENSITYMODE_LUMINOUSPOWERSearch playground for INTENSITYMODE_LUMINOUSPOWER

INTENSITYMODE_LUMINOUSPOWER: number

lumen (lm)

Static Readonly LIGHTMAP_DEFAULTSearch playground for LIGHTMAP_DEFAULT

LIGHTMAP_DEFAULT: number

If every light affecting the material is in this lightmapMode, material.lightmapTexture adds or multiplies (depends on material.useLightmapAsShadowmap) after every other light calculations.

Static Readonly LIGHTMAP_SHADOWSONLYSearch playground for LIGHTMAP_SHADOWSONLY

LIGHTMAP_SHADOWSONLY: number

material.lightmapTexture as only lighting no light calculation from this light only adds dynamic shadows from this light

Static Readonly LIGHTMAP_SPECULARSearch playground for LIGHTMAP_SPECULAR

LIGHTMAP_SPECULAR: number

material.lightmapTexture as only diffuse lighting from this light adds only specular lighting from this light adds dynamic shadows

Static Readonly LIGHTTYPEID_DIRECTIONALLIGHTSearch playground for LIGHTTYPEID_DIRECTIONALLIGHT

LIGHTTYPEID_DIRECTIONALLIGHT: number

Light type const id of the directional light.

Static Readonly LIGHTTYPEID_HEMISPHERICLIGHTSearch playground for LIGHTTYPEID_HEMISPHERICLIGHT

LIGHTTYPEID_HEMISPHERICLIGHT: number

Light type const id of the hemispheric light.

Static Readonly LIGHTTYPEID_POINTLIGHTSearch playground for LIGHTTYPEID_POINTLIGHT

LIGHTTYPEID_POINTLIGHT: number

Light type const id of the point light.

Static Readonly LIGHTTYPEID_SPOTLIGHTSearch playground for LIGHTTYPEID_SPOTLIGHT

LIGHTTYPEID_SPOTLIGHT: number

Light type const id of the spot light.

Accessors

animationPropertiesOverride

behaviors

direction

  • Gets the direction if it has been set. In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback

    Returns Vector3

  • In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback

    Parameters

    Returns any

doNotSerialize

  • get doNotSerialize(): boolean
  • set doNotSerialize(value: boolean): any
  • Gets or sets a boolean used to define if the node must be serialized

    Returns boolean

  • Gets or sets a boolean used to define if the node must be serialized

    Parameters

    • value: boolean

    Returns any

excludeWithLayerMask

  • get excludeWithLayerMask(): number
  • set excludeWithLayerMask(value: number): any
  • Gets the layer id use to find what meshes are not impacted by the light. Inactive if 0

    Returns number

  • Sets the layer id use to find what meshes are not impacted by the light. Inactive if 0

    Parameters

    • value: number

    Returns any

excludedMeshes

  • Gets the meshes not impacted by this light.

    Returns AbstractMesh[]

  • Sets the meshes not impacted by this light.

    Parameters

    Returns any

includeOnlyWithLayerMask

  • get includeOnlyWithLayerMask(): number
  • set includeOnlyWithLayerMask(value: number): any
  • Gets the layer id use to find what meshes are impacted by the light. Inactive if 0

    Returns number

  • Sets the layer id use to find what meshes are impacted by the light. Inactive if 0

    Parameters

    • value: number

    Returns any

includedOnlyMeshes

intensityMode

  • get intensityMode(): number
  • set intensityMode(value: number): any
  • Gets the photometric scale used to interpret the intensity. This is only relevant with PBR Materials where the light intensity can be defined in a physical way.

    Returns number

  • Sets the photometric scale used to interpret the intensity. This is only relevant with PBR Materials where the light intensity can be defined in a physical way.

    Parameters

    • value: number

    Returns any

lightmapMode

  • get lightmapMode(): number
  • set lightmapMode(value: number): any
  • Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)

    Returns number

  • Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)

    Parameters

    • value: number

    Returns any

onClonedObservable

onDispose

  • set onDispose(callback: () => void): any
  • Sets a callback that will be raised when the node will be disposed

    Parameters

    • callback: () => void
        • (): void
        • Returns void

    Returns any

onEnabledStateChangedObservable

  • get onEnabledStateChangedObservable(): Observable<boolean>

parent

position

  • Sets the position the shadow will be casted from. Also use as the light position for both point and spot lights.

    Returns Vector3

  • Sets the position the shadow will be casted from. Also use as the light position for both point and spot lights.

    Parameters

    Returns any

radius

  • get radius(): number
  • set radius(value: number): any
  • Gets the light radius used by PBR Materials to simulate soft area lights.

    Returns number

  • sets the light radius used by PBR Materials to simulate soft area lights.

    Parameters

    • value: number

    Returns any

range

  • get range(): number
  • set range(value: number): any
  • Defines how far from the source the light is impacting in scene units. Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.

    Returns number

  • Defines how far from the source the light is impacting in scene units. Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.

    Parameters

    • value: number

    Returns any

shadowAngle

  • get shadowAngle(): number
  • set shadowAngle(value: number): any
  • Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback This specifies what angle the shadow will use to be created.

    It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.

    Returns number

  • Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback This specifies what angle the shadow will use to be created.

    It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.

    Parameters

    • value: number

    Returns any

shadowEnabled

  • get shadowEnabled(): boolean
  • set shadowEnabled(value: boolean): any
  • Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching the current shadow generator.

    Returns boolean

  • Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching the current shadow generator.

    Parameters

    • value: boolean

    Returns any

shadowMaxZ

  • get shadowMaxZ(): number
  • set shadowMaxZ(value: number): any
  • Sets the shadow projection clipping maximum z value.

    Returns number

  • Gets the shadow projection clipping maximum z value.

    Parameters

    • value: number

    Returns any

shadowMinZ

  • get shadowMinZ(): number
  • set shadowMinZ(value: number): any
  • Gets the shadow projection clipping minimum z value.

    Returns number

  • Sets the shadow projection clipping minimum z value.

    Parameters

    • value: number

    Returns any

worldMatrixFromCache

  • get worldMatrixFromCache(): Matrix
  • Returns directly the latest state of the mesh World matrix. A Matrix is returned.

    Returns Matrix

Methods

_bindLightSearch playground for _bindLight

  • _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows?: boolean): void
  • Binds the lights information from the scene to the effect for the given mesh.

    Parameters

    • lightIndex: number

      Light index

    • scene: Scene

      The scene where the light belongs to

    • effect: Effect

      The effect we are binding the data to

    • useSpecular: boolean

      Defines if specular is supported

    • Optional receiveShadows: boolean

      Defines if the effect (mesh) we bind the light for receives shadows

    Returns void

addBehaviorSearch playground for addBehavior

beginAnimationSearch playground for beginAnimation

  • beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>
  • Will start the animation sequence

    Parameters

    • name: string

      defines the range frames for animation sequence

    • Optional loop: boolean

      defines if the animation should loop (false by default)

    • Optional speedRatio: number

      defines the speed factor in which to run the animation (1 by default)

    • Optional onAnimationEnd: () => void

      defines a function to be executed when the animation ended (undefined by default)

        • (): void
        • Returns void

    Returns Nullable<Animatable>

    the object created for this animation. If range does not exist, it will return null

canAffectMeshSearch playground for canAffectMesh

  • Specifies if the light will affect the passed mesh.

    Parameters

    Returns boolean

    true the mesh is affected otherwise, false.

cloneSearch playground for clone

  • Returns a new Light object, named "name", from the current one.

    Parameters

    • name: string

      The name of the cloned light

    • Optional newParent: Nullable<Node>

      The parent of this light, if it has one

    Returns Nullable<Light>

    the new created light

computeTransformedInformationSearch playground for computeTransformedInformation

  • computeTransformedInformation(): boolean

computeWorldMatrixSearch playground for computeWorldMatrix

  • computeWorldMatrix(force?: boolean): Matrix

createAnimationRangeSearch playground for createAnimationRange

  • createAnimationRange(name: string, from: number, to: number): void
  • Creates an animation range for this node

    Parameters

    • name: string

      defines the name of the range

    • from: number

      defines the starting key

    • to: number

      defines the end key

    Returns void

deleteAnimationRangeSearch playground for deleteAnimationRange

  • deleteAnimationRange(name: string, deleteFrames?: boolean): void
  • Delete a specific animation range

    Parameters

    • name: string

      defines the name of the range to delete

    • Optional deleteFrames: boolean

      defines if animation frames from the range must be deleted as well

    Returns void

disposeSearch playground for dispose

  • dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void
  • Releases resources associated with this node.

    Parameters

    • Optional doNotRecurse: boolean

      Set to true to not recurse into each children (recurse into each children by default)

    • Optional disposeMaterialAndTextures: boolean

      Set to true to also dispose referenced materials and textures (false by default)

    Returns void

forceProjectionMatrixComputeSearch playground for forceProjectionMatrixCompute

  • forceProjectionMatrixCompute(): void

getAbsolutePositionSearch playground for getAbsolutePosition

getAnimationByNameSearch playground for getAnimationByName

getAnimationRangeSearch playground for getAnimationRange

getAnimationRangesSearch playground for getAnimationRanges

getBehaviorByNameSearch playground for getBehaviorByName

getChildMeshesSearch playground for getChildMeshes

  • getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[]
  • Get all child-meshes of this node

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)

    • Optional predicate: (node: Node) => boolean

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns AbstractMesh[]

    an array of AbstractMesh

getChildrenSearch playground for getChildren

  • getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[]
  • Get all direct children of this node

    Parameters

    • Optional predicate: (node: Node) => boolean

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)

    Returns Node[]

    an array of Node

getClassNameSearch playground for getClassName

  • getClassName(): string

getDepthMaxZSearch playground for getDepthMaxZ

  • getDepthMaxZ(activeCamera: Camera): number
  • Gets the maxZ used for shadow according to both the scene and the light.

    Parameters

    • activeCamera: Camera

      The camera we are returning the max for

    Returns number

    the depth max z

getDepthMinZSearch playground for getDepthMinZ

  • getDepthMinZ(activeCamera: Camera): number
  • Gets the minZ used for shadow according to both the scene and the light.

    Parameters

    • activeCamera: Camera

      The camera we are returning the min for

    Returns number

    the depth min z

getDepthScaleSearch playground for getDepthScale

  • getDepthScale(): number

getDescendantsSearch playground for getDescendants

  • getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[]
  • Will return all nodes that have this node as ascendant

    Parameters

    • Optional directDescendantsOnly: boolean

      defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered

    • Optional predicate: (node: Node) => boolean

      defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored

        • (node: Node): boolean
        • Parameters

          Returns boolean

    Returns Node[]

    all children nodes of all types

getEngineSearch playground for getEngine

getHierarchyBoundingVectorsSearch playground for getHierarchyBoundingVectors

  • Return the minimum and maximum world vectors of the entire hierarchy under current node

    Parameters

    • Optional includeDescendants: boolean

      Include bounding info from descendants as well (true by default)

    • Optional predicate: Nullable<(abstractMesh: AbstractMesh) => boolean>

      defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors

    Returns { max: Vector3; min: Vector3 }

    the new bounding vectors

getRotationSearch playground for getRotation

  • Returns the light rotation in euler definition.

    Returns Vector3

    the x y z rotation in local space.

getScaledIntensitySearch playground for getScaledIntensity

  • getScaledIntensity(): number
  • Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.

    Returns number

    the scaled intensity in intensity mode unit

getSceneSearch playground for getScene

getShadowDirectionSearch playground for getShadowDirection

  • getShadowDirection(faceIndex?: number): Vector3
  • Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).

    Parameters

    • Optional faceIndex: number

      The index of the face we are computed the direction to generate shadow

    Returns Vector3

    The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true

getShadowGeneratorSearch playground for getShadowGenerator

getTypeIDSearch playground for getTypeID

  • getTypeID(): number
  • Returns the integer 0.

    Returns number

    The light Type id as a constant defines in Light.LIGHTTYPEID_x

getWorldMatrixSearch playground for getWorldMatrix

isDescendantOfSearch playground for isDescendantOf

  • isDescendantOf(ancestor: Node): boolean
  • Is this node a descendant of the given node? The function will iterate up the hierarchy until the ancestor was found or no more parents defined

    Parameters

    • ancestor: Node

      defines the parent node to inspect

    Returns boolean

    a boolean indicating if this node is a descendant of the given node

isDisposedSearch playground for isDisposed

  • isDisposed(): boolean
  • Gets a boolean indicating if the node has been disposed

    Returns boolean

    true if the node was disposed

isEnabledSearch playground for isEnabled

  • isEnabled(checkAncestors?: boolean): boolean
  • Is this node enabled? If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true

    Parameters

    • Optional checkAncestors: boolean

      indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors

    Returns boolean

    whether this node (and its parent) is enabled

isReadySearch playground for isReady

  • isReady(completeCheck?: boolean): boolean
  • Is this node ready to be used/rendered

    Parameters

    • Optional completeCheck: boolean

      defines if a complete check (including materials and lights) has to be done (false by default)

    Returns boolean

    true if the node is ready

needCubeSearch playground for needCube

  • needCube(): boolean
  • Specifies whether or not the shadowmap should be a cube texture.

    Returns boolean

    true if the shadowmap needs to be a cube texture.

needProjectionMatrixComputeSearch playground for needProjectionMatrixCompute

  • needProjectionMatrixCompute(): boolean

prepareLightSpecificDefinesSearch playground for prepareLightSpecificDefines

  • prepareLightSpecificDefines(defines: any, lightIndex: number): void

removeBehaviorSearch playground for removeBehavior

serializeSearch playground for serialize

  • serialize(): any
  • Serializes the current light into a Serialization object.

    Returns any

    the serialized object.

serializeAnimationRangesSearch playground for serializeAnimationRanges

  • serializeAnimationRanges(): any

setDirectionToTargetSearch playground for setDirectionToTarget

  • Sets the ShadowLight direction toward the passed target.

    Parameters

    • target: Vector3

      The point to target in local space

    Returns Vector3

    the updated ShadowLight direction

setEnabledSearch playground for setEnabled

  • setEnabled(value: boolean): void

setShadowProjectionMatrixSearch playground for setShadowProjectionMatrix

toStringSearch playground for toString

  • toString(fullDetails?: boolean): string
  • Converts the light information to a readable string for debug purpose.

    Parameters

    • Optional fullDetails: boolean

      Supports for multiple levels of logging within scene loading

    Returns string

    the human readable light info

transferTexturesToEffectSearch playground for transferTexturesToEffect

  • transferTexturesToEffect(effect: Effect, lightIndex: string): Light

transferToEffectSearch playground for transferToEffect

  • Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).

    Parameters

    • effect: Effect

      The effect to update

    • lightIndex: string

      The index of the light in the effect to update

    Returns PointLight

    The point light

transferToNodeMaterialEffectSearch playground for transferToNodeMaterialEffect

  • transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this

Static AddNodeConstructorSearch playground for AddNodeConstructor

Static ConstructSearch playground for Construct

  • Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>
  • Returns a node constructor based on type name

    Parameters

    • type: string

      defines the type name

    • name: string

      defines the new node name

    • scene: Scene

      defines the hosting scene

    • Optional options: any

      defines optional options to transmit to constructors

    Returns Nullable<() => Node>

    the new constructor or null

Static GetConstructorFromNameSearch playground for GetConstructorFromName

  • Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3. This new light is named "name" and added to the passed scene.

    Parameters

    • type: number

      Type according to the types available in Light.LIGHTTYPEID_x

    • name: string

      The friendly name of the light

    • scene: Scene

      The scene the new light will belong to

    Returns Nullable<() => Light>

    the constructor function

Static ParseSearch playground for Parse

  • Parses the passed "parsedLight" and returns a new instanced Light from this parsing.

    Parameters

    • parsedLight: any

      The JSON representation of the light

    • scene: Scene

      The scene to create the parsed light in

    Returns Nullable<Light>

    the created light after parsing

Static ParseAnimationRangesSearch playground for ParseAnimationRanges

  • ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void
  • Parse animation range data from a serialization object and store them into a given node

    Parameters

    • node: Node

      defines where to store the animation ranges

    • parsedNode: any

      defines the serialization object to read data from

    • scene: Scene

      defines the hosting scene

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Property
  • Method
  • Static property
  • Static method