Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3). The directional light is emitted from everywhere in the given direction. It can cast shadows. Documentation : https://doc.babylonjs.com/babylon101/lights
The friendly name of the light
The direction of the light
The scene the light belongs to
Gets or sets the animation properties override
Gets a list of Animations associated with the node
Automatically compute the projection matrix to best fit (including all the casters) on each frame.
Gets the list of attached behaviors
Callback defining a custom Projection Matrix Builder. This can be used to override the default projection matrix computation.
Diffuse gives the basic color to an object.
In 2d mode (needCube being false), sets the direction used to cast the shadow. Also use as the light direction on spot and directional lights.
Gets or sets a boolean used to define if the node must be serialized
Sets the layer id use to find what meshes are not impacted by the light. Inactive if 0
Sets the meshes not impacted by this light.
Defines the falloff type for this light. This lets overrriding 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.
Gets or sets the id of the node
Sets the layer id use to find what meshes are impacted by the light. Inactive if 0
Sets the only meshes impacted by this light.
List of inspectable custom properties (used by the Inspector)
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.
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.
Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
Gets or sets an object used to store user defined information for the node
Gets or sets the name of the node
Sets a callback that will be raised when the node will be disposed
An event triggered when the mesh is disposed
Callback raised when the node is ready to be used
Gets or sets the parent of the node (without keeping the current position in the scene)
Sets the position the shadow will be casted from. Also use as the light position for both point and spot lights.
sets the light radius used by PBR Materials to simulate soft area lights.
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.
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.
For internal use only. Please do not use.
Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching the current shadow generator.
Specifies a fix frustum size for the shadow generation.
Gets the shadow projection clipping maximum z value.
Sets the shadow projection clipping minimum z value.
Sets the shadow projection scale against the optimal computed one. 0.1 by default which means that the projection window is increase by 10% from the optimal size. This does not impact in fixed frustum size (shadowFrustumSize being set)
Specular produces a highlight color on an object. Note: This is note affecting PBR materials.
Gets or sets a string used to store user defined state for the node
The transformed direction. Direction of the light in world space taking parenting in account.
The transformed position. Position of the light in world space taking parenting in account.
Gets or sets the unique id of the node
Returns directly the latest state of the mesh World matrix. A Matrix is returned.
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.
Falloff gltf: light is falling off as described in the gltf moving to PBR document to enhance interoperability with other engines.
Falloff Physical: light is falling off following the inverse squared distance law.
Falloff Standard: light is falling off like in the standard material to enhance interoperability with other materials.
Each light type uses the default quantity according to its type: point/spot lights use luminous intensity directional lights use illuminance
lux (lm/m^2)
nit (cd/m^2)
candela (lm/sr)
lumen (lm)
If every light affecting the material is in this lightmapMode, material.lightmapTexture adds or multiplies (depends on material.useLightmapAsShadowmap) after every other light calculations.
material.lightmapTexture as only lighting no light calculation from this light only adds dynamic shadows from this light
material.lightmapTexture as only diffuse lighting from this light adds only specular lighting from this light adds dynamic shadows
Light type const id of the directional light.
Light type const id of the hemispheric light.
Light type const id of the point light.
Light type const id of the spot light.
Will start the animation sequence
defines the range frames for animation sequence
defines if the animation should loop (false by default)
defines the speed factor in which to run the animation (1 by default)
defines a function to be executed when the animation ended (undefined by default)
the object created for this animation. If range does not exist, it will return null
Binds the lights information from the scene to the effect for the given mesh.
Light index
The scene where the light belongs to
The effect we are binding the data to
Defines if specular is supported
Specifies whether the light falloff is defined physically or not
Specifies whether the shader is rebuilding in parallel
Specifies if the light will affect the passed mesh.
The mesh to test against the light
true the mesh is affected otherwise, false.
Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
true if the information has been computed, false if it does not need to (no parenting)
Computes the world matrix of the node
defines if the cache version should be invalidated forcing the world matrix to be created from scratch
the world matrix
Creates an animation range for this node
defines the name of the range
defines the starting key
defines the end key
Delete a specific animation range
defines the name of the range to delete
defines if animation frames from the range must be deleted as well
Releases resources associated with this node.
Set to true to not recurse into each children (recurse into each children by default)
Set to true to also dispose referenced materials and textures (false by default)
Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
Returns the ShadowLight absolute position in the World.
the position vector in world space
Get an animation range by name
defines the name of the animation range to look for
null if not found else the requested animation range
Gets the list of all animation ranges defined on this node
an array
Get all child-meshes of this node
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)
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
an array of AbstractMesh
Get all direct children of this node
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
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)
an array of Node
Returns the string "DirectionalLight".
The class name
Gets the maxZ used for shadow according to both the scene and the light.
Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
The camera we are returning the max for
the depth max z
Gets the minZ used for shadow according to both the scene and the light.
Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
The camera we are returning the min for
the depth min z
Return the depth scale used for the shadow map.
the depth scale.
Will return all nodes that have this node as ascendant
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
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
all children nodes of all types
Gets the engine of the node
a Engine
Return the minimum and maximum world vectors of the entire hierarchy under current node
Include bounding info from descendants as well (true by default)
defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
the new bounding vectors
Returns the light rotation in euler definition.
the x y z rotation in local space.
Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
the scaled intensity in intensity mode unit
Gets the scene of the node
a scene
Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
The index of the face we are computed the direction to generate shadow
The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
Returns the Light associated shadow generator if any.
the associated shadow generator.
Returns the integer 1.
The light Type id as a constant defines in Light.LIGHTTYPEID_x
Returns the latest update of the World matrix
a Matrix
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
defines the parent node to inspect
a boolean indicating if this node is a descendant of the given node
Gets a boolean indicating if the node has been disposed
true if the node was disposed
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
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
whether this node (and its parent) is enabled
Is this node ready to be used/rendered
defines if a complete check (including materials and lights) has to be done (false by default)
true if the node is ready
Returns whether or not the shadow generation require a cube texture or a 2d texture.
true if a cube texture needs to be use
Detects if the projection matrix requires to be recomputed this frame.
true if it requires to be recomputed otherwise, false.
Prepares the list of defines specific to the light type.
the list of defines
defines the index of the light for the effect
Serializes the current light into a Serialization object.
the serialized object.
Serialize animation ranges into a JSON compatible object
serialization object
Set the enabled state of this node.
the new enabled state
Sets the shadow projection matrix in parameter to the generated projection matrix.
The materix to updated with the projection information
The transform matrix of the light
The list of mesh to render in the map
The current light
Converts the light information to a readable string for debug purpose.
Supports for multiple levels of logging within scene loading
the human readable light info
Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
The effect to update
The index of the light in the effect to update
The directional light
Add a new node constructor
defines the type name of the node to construct
defines the constructor function
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.
Type according to the types available in Light.LIGHTTYPEID_x
The friendly name of the light
The scene the new light will belong to
the constructor function
Generated using TypeDoc
A directional light is defined by a direction (what a surprise!). The light is emitted from everywhere in the specified direction, and has an infinite range. An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object. Documentation: https://doc.babylonjs.com/babylon101/lights