LightSource

Represents basic light source.

Constructor

new LightSource(nameopt, paramsopt)

Parameters:
NameTypeAttributesDescription
namestring<optional>

Light source name.

paramsILightSourceParams<optional>

Light parameters:

Properties
NameTypeAttributesDescription
positionVec3<optional>

Light source position if it is a point light, otherwise it is a light direction vector.

ambientVec3<optional>

Ambient RGB color.

diffuseVec3<optional>

Diffuse RGB color.

specularVec3<optional>

Specular RGB color.

shininessnumber<optional>

Specular shininess.

Members

(protected) _active :boolean

Light activity.

Type:
  • boolean

(protected) _ambient :Vec3

Ambient color.

Type:

(protected) _diffuse :Vec3

Diffuse color.

Type:

(protected) _name :string

Light name.

Type:
  • string

_position :Vec3

Light position.

Type:

(protected) _renderNode :RenderNode

Render node where light is shines.

(protected) _shininess :number

Shininess.

Type:
  • number

(protected) _specular :Vec3

Specular color.

Type:

directional :boolean

True if the light is directional.

Type:
  • boolean

Methods

addTo(renderNode)

Adds current light to the render node scene.

Parameters:
NameTypeDescription
renderNodeRenderNode

Render node scene.

clone() → {LightSource}

Creates clone of the current light object.

Returns:
Type: 
LightSource

getPosition() → {Vec3}

Returns light source position, or if it is a directional type sets light direction vector.

Returns:
  • Light source position/direction.
Type: 
Vec3

isActive() → {boolean}

Gets light activity.

Returns:
Type: 
boolean

remove()

Removes from render node scene.

setActive(active)

Set light activity. If activity is false the light doesn't shine.

Parameters:
NameTypeDescription
activeboolean

Light activity.

setAmbient()

Set ambient color.

setAmbient3v(rgb)

Set ambient color.

Parameters:
NameTypeDescription
rgbVec3

Ambient color.

setBlack()

Sets light to black.

setDiffuse()

Set diffuse color.

setDiffuse3v(rgb)

Set diffuse color.

Parameters:
NameTypeDescription
rgbVec3

Diffuse color.

setPosition()

Set light source position, or if it is a directional type sets light direction vector.

setPosition3v(position)

Set light source position, or if it is a directional type sets light direction vector.

Parameters:
NameTypeDescription
positionVec3

Light position or direction vector.

setShininess()

Set material shininess.

setSpecular()

Set specular color.

setSpecular3v(rgb)

Set specular color.

Parameters:
NameTypeDescription
rgbVec3

Specular color.