Creates a new LightComponent instance.
The ComponentSystem that created this Component.
The Entity that this Component is attached to.
The Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Gets whether the light will affect non-lightmapped objects.
Sets whether the light will affect non-lightmapped objects.
Gets whether the light will affect lightmapped objects.
Sets whether the light will affect lightmapped objects.
Gets whether material specularity will be affected by this light.
Sets whether material specularity will be affected by this light. Ignored for lights other than LIGHTTYPE_DIRECTIONAL. Defaults to true.
Gets whether the light will be rendered into lightmaps.
Sets whether the light will be rendered into lightmaps.
Gets the penumbra angle in degrees.
Sets the penumbra angle in degrees, allowing for a soft shadow boundary. Defaults to 0.
Requires bake
to be set to true and the light type is LIGHTTYPE_DIRECTIONAL.
Gets whether the light's direction will contribute to directional lightmaps.
Sets whether the light's direction will contribute to directional lightmaps. The light must
be enabled and bake
set to true. Be aware, that directional lightmap is an approximation
and can only hold single direction per pixel. Intersecting multiple lights with bakeDir=true
may lead to incorrect look of specular/bump-mapping in the area of intersection. The error
is not always visible though, and highly scene-dependent.
Gets the number of samples used to bake this light into the lightmap.
Sets the number of samples used to bake this light into the lightmap. Defaults to 1. Maximum value is 255.
Gets the distribution of subdivision of the camera frustum for individual shadow cascades.
Sets the distribution of subdivision of the camera frustum for individual shadow cascades. Only used if LightComponent#numCascades is larger than 1. Can be a value in range of 0 and 1. Value of 0 represents a linear distribution, value of 1 represents a logarithmic distribution. Defaults to 0.5. Larger value increases the resolution of the shadows in the near distance.
Gets whether the light will cast shadows.
Sets whether the light will cast shadows. Defaults to false.
Gets the angle for spotlight cookie rotation (in degrees).
Sets the angle for spotlight cookie rotation (in degrees).
Gets the texture asset to be used as the cookie for this light.
Sets the texture asset to be used as the cookie for this light. Only spot and omni lights can have cookies. Defaults to null.
Gets the color channels of the cookie texture to use.
Sets the color channels of the cookie texture to use. Can be "r", "g", "b", "a", "rgb".
Gets whether normal spotlight falloff is active when a cookie texture is set.
Sets whether normal spotlight falloff is active when a cookie texture is set. When set to false, a spotlight will work like a pure texture projector (only fading with distance). Default is false.
Gets the cookie texture intensity.
Sets the cookie texture intensity. Defaults to 1.
Gets the enabled state of the component.
Sets the enabled state of the component.
Gets the fall off mode for the light.
Sets the fall off mode for the light. This controls the rate at which a light attenuates from its position. Can be:
Affects omni and spot lights only. Defaults to LIGHTFALLOFF_LINEAR.
Gets the angle at which the spotlight cone starts to fade off.
Sets the angle at which the spotlight cone starts to fade off. The angle is specified in degrees. Affects spot lights only. Defaults to 40.
Gets the brightness of the light.
Sets the brightness of the light. Defaults to 1.
Gets whether the light ever moves.
Sets whether the light ever moves. This is an optimization hint.
Gets the array of layer IDs (Layer#id) to which this light should belong.
Sets the array of layer IDs (Layer#id) to which this light should belong. Don't push/pop/splice or modify this array. If you want to change it, set a new one instead.
Gets the physically-based luminance.
Sets the physically-based luminance. Only used if scene.physicalUnits
is true. Defaults to 0.
Gets the mask to determine which MeshInstances are lit by this light.
Sets the mask to determine which MeshInstances are lit by this light. Defaults to 1.
Gets the normal offset depth bias.
Sets the normal offset depth bias. Valid range is 0 to 1. Defaults to 0.
Gets the number of shadow cascades.
Sets the number of shadow cascades. Can be 1, 2, 3 or 4. Defaults to 1, representing no cascades.
Gets the angle at which the spotlight cone has faded to nothing.
Sets the angle at which the spotlight cone has faded to nothing. The angle is specified in degrees. Affects spot lights only. Defaults to 45.
Gets the size of penumbra for contact hardening shadows.
Sets the size of penumbra for contact hardening shadows. For area lights, acts as a multiplier with the dimensions of the area light. For punctual and directional lights it's the area size of the light. Defaults to 1.
Gets the range of the light.
Sets the range of the light. Affects omni and spot lights only. Defaults to 10.
Get the depth bias for tuning the appearance of the shadow mapping generated by this light.
Set the depth bias for tuning the appearance of the shadow mapping generated by this light. Valid range is 0 to 1. Defaults to 0.05.
Gets the distance from the viewpoint beyond which shadows are no longer rendered.
Sets the distance from the viewpoint beyond which shadows are no longer rendered. Affects directional lights only. Defaults to 40.
Gets the intensity of the shadow darkening.
Sets the intensity of the shadow darkening. 0 having no effect and 1 meaning shadows are entirely black. Defaults to 1.
Gets the size of the texture used for the shadow map.
Sets the size of the texture used for the shadow map. Valid sizes are 64, 128, 256, 512, 1024, 2048. Defaults to 1024.
Gets the type of shadows being rendered by this light.
Sets the type of shadows being rendered by this light. Can be:
Gets the shadow update model.
Sets the shadow update model. This tells the renderer how often shadows must be updated for this light. Can be:
Gets an array of SHADOWUPDATE_ settings per shadow cascade.
Sets an array of SHADOWUPDATE_ settings per shadow cascade. Set to undefined if not used.
Gets the light source shape.
Sets the light source shape. Can be:
Defaults to pc.LIGHTSHAPE_PUNCTUAL.
Gets the type of the light.
Sets the type of the light. Can be:
Defaults to "directional".
Gets the VSM bias value.
Sets the VSM bias value.
Gets the blurring mode for variance shadow maps.
Sets the blurring mode for variance shadow maps. Can be:
Gets the number of samples used for blurring a variance shadow map.
Sets the number of samples used for blurring a variance shadow map. Only uneven numbers work, even are incremented. Minimum value is 1, maximum is 25. Defaults to 11.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
The Light Component enables the Entity to light the scene. There are three types of light: directional, omni and spot. Directional lights are global in that they are considered to be infinitely far away and light the entire scene. Omni and spot lights are local in that they have a position and a range. A spot light is a specialization of an omni light where light is emitted in a cone rather than in all directions. Lights also have the ability to cast shadows to add realism to your scenes.