Skip to content

Light

Introduction

vtkLight is a virtual light for 3D rendering. It provides methods to locate and point the light, turn it on and off, and set its brightness and color. In addition to the basic infinite distance point light source attributes, you also can specify the light attenuation values and cone angle. These attributes are only used if the light is a positional light. The default is a directional light (e.g. infinite point light source).

Lights have a type that describes how the light should move with respect to the camera. A Headlight is always located at the current camera position and shines on the camera’s focal point. A CameraLight also moves with the camera, but may not be coincident to it. CameraLights are defined in a normalized coordinate space where the camera is located at (0, 0, 1), the camera is looking at (0, 0, 0), and up is (0, 1, 0). Finally, a SceneLight is part of the scene itself and does not move with the camera. (Renderers are responsible for moving the light based on its type.)

Lights have a transformation matrix that describes the space in which they are positioned. A light’s world space position and focal point are defined by their local position and focal point, transformed by their transformation matrix (if it exists).

Methods

extend

Method use to decorate a given object (publicAPI+model) with vtkLight characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesILightInitialValuesNo(default: {})

getAttenuationValues

getAttenuationValuesByReference

getColor

Get the color of the light.

getColorByReference

Get the color of the light.

getConeAngle

Get the lighting cone angle of a positional light in degrees. This is the angle between the axis of the cone and a ray along the edge of the cone. A value of 90 (or more) indicates that you want no spot lighting effects just a positional light.

getConeFalloff

Get the lighting falloff angle of a positional light in degrees. This is the angle that sets how much the cone will be extended to smooth the border. A value of 0 indicates that the spot light will have a completely sharp edge (this does not mean completely sharp lighting, just that the border will be sharp).

getDirection

Set the position and focal point of a light based on elevation and azimuth. The light is moved so it is shining from the given angle. Angles are given in degrees. If the light is a positional light, it is made directional instead.

getExponent

Get the exponent of the cosine used in positional lighting.

getFocalPoint

Get the focal point.

getFocalPointByReference

Get the focal point.

getIntensity

Get the brightness of the light

getLightType

Get the type of the light.

getPosition

Get the position of the light.

getPositionByReference

Get the position of the light.

getPositional

Get if positional lighting is on or off.

getTransformedFocalPoint

Get the focal point of the light, modified by the transformation matrix (if it exists).

getTransformedPosition

Get the position of the light, modified by the transformation matrix (if it exists).

lightTypeIsCameraLight

Check if the type of the light is CameraLight.

lightTypeIsHeadLight

Check if the type of the light is HeadLight.

lightTypeIsSceneLight

Check if the type of the light is SceneLight.

newInstance

Method use to create a new instance of vtkLight with the focal point at the origin and its position set to [0, 0, 1]. The light is a SceneLight, its color is white, intensity=1, the light is turned on, positional lighting is off, coneAngle=30, coneFalloff=5, AttenuationValues=[1, 0, 0], exponent=1 and the transformMatrix is null.

ArgumentTypeRequiredDescription
initialValuesILightInitialValuesNofor pre-setting some of its content

setAttenuationValues

Set the quadratic attenuation constants.

ArgumentTypeRequiredDescription
aNumberYes
bNumberYes
cNumberYes

setAttenuationValuesFrom

Set the quadratic attenuation constants from an array.

ArgumentTypeRequiredDescription
attenuationValuesArray[Number]YesThe quadratic attenuation.

setColor

Set the color of the object. Has the side effect of setting the ambient diffuse and specular colors as well. This is basically a quick overall color setting method.

ArgumentTypeRequiredDescription
colorRGBColorYesDefines the RGB color array..

setColor

Set the color of the object. Has the side effect of setting the ambient diffuse and specular colors as well. This is basically a quick overall color setting method.

ArgumentTypeRequiredDescription
rNumberYesDefines the red component (between 0 and 1).
gNumberYesDefines the green component (between 0 and 1).
bNumberYesDefines the blue component (between 0 and 1).

setColorFrom

Set the color of the object. Has the side effect of setting the ambient diffuse and specular colors as well. This is basically a quick overall color setting method.

ArgumentTypeRequiredDescription
colorRGBColorYesDefines the RGB color array..

setColorFrom

Set the color of the object. Has the side effect of setting the ambient diffuse and specular colors as well. This is basically a quick overall color setting method.

ArgumentTypeRequiredDescription
rNumberYesDefines the red component (between 0 and 1).
gNumberYesDefines the green component (between 0 and 1).
bNumberYesDefines the blue component (between 0 and 1).

setConeAngle

Set the lighting cone angle of a positional light in degrees. This is the angle between the axis of the cone and a ray along the edge of the cone. A value of 90 (or more) indicates that you want no spot lighting effects just a positional light.

ArgumentTypeRequiredDescription
coneAngleNumberYesThe cone angle.

setConeFalloff

Set the lighting falloff angle of a positional light in degrees. This is the angle that sets how much the cone will be extended to smooth the border. A value of 0 indicates that the spot light will have a completely sharp edge (this does not mean completely sharp lighting, just that the border will be sharp).

ArgumentTypeRequiredDescription
coneFalloffNumberYesThe cone falloff angle.

setDirection

Set the direction vector of the light from X, Y, and Z values

ArgumentTypeRequiredDescription
directionVector3Yes

setDirection

Set the direction vector of the light from X, Y, and Z values

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setDirectionAngle

Set the position and focal point of a light based on elevation and azimuth. The light is moved so it is shining from the given angle. Angles are given in degrees. If the light is a positional light, it is made directional instead.

ArgumentTypeRequiredDescription
elevationNumberYes
azimuthNumberYes

setExponent

Set the exponent of the cosine used in positional lighting.

ArgumentTypeRequiredDescription
exponentNumberYesThe exponent of the cosine.

setFocalPoint

Set the focal point.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setFocalPointFrom

Set the focal point from an array

ArgumentTypeRequiredDescription
focalPointVector3YesThe focal point array.

setIntensity

Set the brightness of the light (from one to zero).

ArgumentTypeRequiredDescription
intensityNumberYes

setLightType

Set the type of the light to lightType

ArgumentTypeRequiredDescription
lightTypeLIGHT_TYPESYesThe light type.

setLightTypeToCameraLight

Set the type of the light is CameraLight.

setLightTypeToHeadLight

Set the the type of the light is HeadLight.

setLightTypeToSceneLight

Set the the type of the light is SceneLight.

setPosition

Set the position of the light.

ArgumentTypeRequiredDescription
xNumberYesThe x coordinate.
yNumberYesThe y coordinate.
zNumberYesThe z coordinate.

setPositionFrom

Set the position of the light.

ArgumentTypeRequiredDescription
positionVector3YesThe position coordinate of the light.

setPositional

Turn positional lighting on or off.

ArgumentTypeRequiredDescription
positionalBooleanYesThe positional value.

setShadowAttenuation

Set the shadow intensity By default a light will be completely blocked when in shadow by setting this value to less than 1.0 you can control how much light is attenuated when in shadow.

ArgumentTypeRequiredDescription
shadowAttenuationNumberYesThe shadow attenuation value.

setSwitch

Turn the light on or off.

ArgumentTypeRequiredDescription
switchValueBooleanYesThe switch value.

setTransformMatrix

Set the light's transformation matrix.

ArgumentTypeRequiredDescription
transformMatrixmat4YesThe transform matrix.