API Docs for:
Show:

LS.Components.Light Class

Module: LS

Light contains all the info about the light (type: SPOT, OMNI, DIRECTIONAL, attenuations, shadows, etc)

Constructor

LS.Components.Light

(
  • object
)

Parameters:

  • object Object

    to configure from

Methods

applyTransformMatrix

(
  • matrix
  • center
  • property_name
)
Mat4

apply a transformation to a given light property, this is done in a function to allow more complex gizmos

Parameters:

  • matrix Mat4

    transformation in matrix form

  • center Vec3

    �?

  • property_name String

    "target" or "position"

Returns:

Mat4:

mat4

computeLightIntensity

() Number

Computes the max amount of light this object can produce (taking into account every color channel)

Returns:

Number:

intensity

computeLightRadius

() Number

Computes the light radius according to the attenuation

Returns:

Number:

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:

Number:

distance

generateShadowmap

() Object

Generates the shadowmap for this light

Returns:

Object:

render_settings

getFront

(
  • output
)
Vec3

returns a copy of the front vector (in global coordinates)

Parameters:

  • output Vec3

    optional

Returns:

Vec3:

the front vector

getGlobalMatrix

(
  • output
)
Mat4

It returns the global matrix

Parameters:

  • output Mat4

    [optional]

Returns:

Mat4:

mat4

getLightCamera

() Camera

Returns the camera that will match the light orientation (taking into account fov, etc), useful for shadowmaps

Returns:

Camera:

the camera

getPosition

(
  • output
)
Vec3

returns a copy of the light position (in global coordinates), if you want local you can access the position property

Parameters:

  • output Vec3

    optional

Returns:

Vec3:

the position

getQuery

(
  • instance
  • render_settings
)
ShaderQuery

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 RenderInstance

    the render instance where this light will be applied

  • render_settings Object

    info about how the scene will be rendered

Returns:

ShaderQuery:

the macros

getTarget

(
  • output
)
Vec3

returns a copy of the light target (in global coordinates), if you want local you can access the target property

Parameters:

  • output Vec3

    optional

Returns:

Vec3:

the target

getTransformMatrix

(
  • element
  • output
)
Mat4

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:

mat4

getUp

(
  • output
)
Vec3

returns a copy of the light up vector (in global coordinates), if you want local you can access the up property

Parameters:

  • output Vec3

    optional

Returns:

Vec3:

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 Object

    info 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]