LS.Components.Light Class
Light contains all the info about the light (type: SPOT, OMNI, DIRECTIONAL, attenuations, shadows, etc)
Constructor
LS.Components.Light
-
object
Parameters:
-
object
Objectto configure from
Item Index
Methods
Methods
applyTransformMatrix
-
matrix
-
center
-
property_name
apply a transformation to a given light property, this is done in a function to allow more complex gizmos
Parameters:
-
matrix
Mat4transformation in matrix form
-
center
Vec3�?
-
property_name
String"target" or "position"
Returns:
mat4
computeLightIntensity
()
Number
Computes the max amount of light this object can produce (taking into account every color channel)
Returns:
intensity
computeLightRadius
()
Number
Computes the light radius according to the attenuation
Returns:
radius
computeShadowmapFar
()
Number
Optimization: instead of using the far plane, we take into account the attenuation to avoid rendering objects where the light will never reach
Returns:
distance
generateShadowmap
()
Object
Generates the shadowmap for this light
Returns:
render_settings
getFront
-
output
returns a copy of the front vector (in global coordinates)
Parameters:
-
output
Vec3optional
Returns:
the front vector
getGlobalMatrix
-
output
It returns the global matrix
Parameters:
-
output
Mat4[optional]
Returns:
mat4
getLightCamera
()
Camera
Returns the camera that will match the light orientation (taking into account fov, etc), useful for shadowmaps
Returns:
the camera
getPosition
-
output
returns a copy of the light position (in global coordinates), if you want local you can access the position property
Parameters:
-
output
Vec3optional
Returns:
the position
getQuery
-
instance
-
render_settings
Collects and returns the shader query of the light (some macros have to be computed now because they depend not only on the light, also on the node or material)
Parameters:
-
instance
RenderInstancethe render instance where this light will be applied
-
render_settings
Objectinfo about how the scene will be rendered
Returns:
the macros
getTarget
-
output
returns a copy of the light target (in global coordinates), if you want local you can access the target property
Parameters:
-
output
Vec3optional
Returns:
the target
getTransformMatrix
-
element
-
output
It returns a matrix in the position of the given light property (target, position), mostly used for gizmos
Parameters:
-
element
String"target" or "position"
-
output
Mat4[optional]
Returns:
mat4
getUp
-
output
returns a copy of the light up vector (in global coordinates), if you want local you can access the up property
Parameters:
-
output
Vec3optional
Returns:
the up vector
prepare
-
render_settings
This method is called by the LS.Renderer when the light needs to be prepared to be used during render (compute light camera, create shadowmaps, prepare macros, etc)
Parameters:
-
render_settings
Objectinfo about how the scene will be rendered
updateVectors
()
updates all the important vectors (target, position, etc) according to the node parent of the light
Properties
angle
Number
Angle for the spot light inner apperture
Default: 45
angle_end
Number
Angle for the spot light outer apperture
Default: 60
attenuation_type
Number
type of attenuation: Light.NO_ATTENUATION, Light.LINEAR_ATTENUATION, Light.RANGE_ATTENUATION
Default: [1,1,1]
cast_shadows
Boolean
If the light cast shadows
Default: false
color
Vec3
The color of the light
Default: [1,1,1]
enabled
Boolean
Enabled
Default: true
far
Number
Far distance
Default: 1000
intensity
Number
The intensity of the light
Default: 1
layers
Number
Layers mask, this layers define which objects are iluminated by this light
Default: true
near
Number
Near distance
Default: 1
position
[x,y,z]
Position of the light in world space
Default: [0,0,0]
target
[x,y,z]
Position where the light is pointing at (in world space)
Default: [0,0,1]
up
[x,y,z]
Up vector (in world coordinates)
Default: [0,1,0]