Class: Light

Light() → {Light}

Defines a simple light source that can be a point light, directional light, or spot light

Found in Chapter 8, page 410 of the textbook

Examples: 8.2 Simple Light Shader, 8.6 Directional and Spot Lights, 8.7 Shadow Shaders

Constructor

new Light() → {Light}

Source:
Returns:
a new Light instance
Type
Light

Methods

getColor() → {vec4}

Returns the color of this Light
Source:
Returns:
mColor - [R,G,B,A] color array
Type
vec4

getDirection() → {vec3}

Returns the direction vector of this Light
Source:
Returns:
mDirection - the direction vector
Type
vec3

getDropOff() → {float}

Returns the current drop off value of this Light
Source:
Returns:
mDropOff - current drop off value
Type
float

getFar() → {float}

Returns the far radius in WC space for this Light
Source:
Returns:
mFar - current far radius
Type
float

getInner() → {float}

Returns the inner cone angle of this Light
Source:
Returns:
mInner - current angle in radians
Type
float

getIntensity() → {float}

Returns the intensity level of this Light
Source:
Returns:
mIntensity - the current intensity
Type
float

getLightType() → {eLightType}

Returns what type of light this Light is
Source:
Returns:
mLightType - enum for point, directional, or spotlight
Type
eLightType

getNear() → {float}

Returns the near radius in WC space for this Light
Source:
Returns:
mNear - current near radius
Type
float

getOuter() → {float}

Returns the outer cone angle of this Light
Source:
Returns:
mOuter - current angle in radians
Type
float

getPosition() → {vec3}

Returns the world coordinates of this Light
Source:
Returns:
mPosition - 3D position vector
Type
vec3

isLightCastShadow() → {boolean}

Returns whether or not this Light casts a shadow
Source:
Returns:
mCastShadow - true if a shadow is cast
Type
boolean

isLightOn() → {boolean}

Returns whether this Light is on
Source:
Returns:
true if the light is on
Type
boolean

set2DPosition(p)

Set the 2D world coordinate position for this Light
Parameters:
Name Type Description
p vec2 [X,Y] position
Source:

setColor(c)

Set the color of the light for this Light
Parameters:
Name Type Description
c vec4 [R,G,B,A] color array
Source:

setDirection(d)

Set the direction vector of this Light
Parameters:
Name Type Description
d vec3 direction vector
Source:

setDropOff(d)

Set how quickly does light intensity drops off between inner/outer, Near/Far. A larger Drop off number results in “softer/smoother” transition from full illumination to no illumination
Parameters:
Name Type Description
d float the new drop off value
Source:

setFar(f)

Set the far radius in WC space for this Light. Objects beyond this radius are not illuminated by this Light
Parameters:
Name Type Description
f float the new far radius
Source:

setInner(r)

Set the new inner cone angle of this Light
Parameters:
Name Type Description
r float angle in radians
Source:

setIntensity(i)

Set the intensity level of this Light
Parameters:
Name Type Description
i float the new intensity
Source:

setLightCastShadowTo(on)

Set whether this Light casts a shadow
Parameters:
Name Type Description
on boolean true casts a shadow
Source:

setLightTo(on)

Set whether this Light is on or off
Parameters:
Name Type Description
on boolean true turns this Light on
Source:

setLightType(t)

Set what type of light this Light is
Parameters:
Name Type Description
t eLightType enum for point, directional, or spotlight
Source:

setNear(n)

Set the near radius in WC space for this Light
Parameters:
Name Type Description
n float the new near radius
Source:

setOuter(r)

Set the new outer cone angle of this Light
Parameters:
Name Type Description
r float angle in radians
Source:

setXPos(x)

Set the X world coordinate position of this Light
Parameters:
Name Type Description
x float new X position
Source:

setYPos(y)

Set the Y world coordinate position of this Light
Parameters:
Name Type Description
y float new Y position
Source:

setZPos(z)

Set the Z world coordinate position of this Light
Parameters:
Name Type Description
z float new Z position
Source: