H3DU.LightSource
H3DU.LightSource([params], [ambient], [diffuse], [specular])
Specifies parameters for light sources.
NOTE: The default shader program assumes that all colors specified in this object are in companded sRGB.
Parameters
params
(Type: Object | Array.<number>) (optional)
An object as described in "setParams". Using this parameter as described in the "position" property is deprecated since version 2.0.ambient
(Type: Array.<number>) (optional)
See "ambient" property. This parameter is deprecated.diffuse
(Type: Array.<number>) (optional)
See "diffuse" property. This parameter is deprecated.specular
(Type: Array.<number>) (optional)
See "specular" property. This parameter is deprecated.
Members
- ambient
A 4-element vector giving an additional color to multiply with the ambient color of each object, in the red, green, and blue components respectively. - diffuse
A 4-element vector giving an additional color to multiply with the diffuse or albedo color (base color) of each object, in the red, green, and blue components respectively. - position
Light position. - radius
Radius of the light source. - specular
A 3-element vector giving the color of the light when it causes a specular reflection, in the red, green, and blue components respectively.
Methods
- setParams
Sets parameters for this material object.
H3DU.LightSource#ambient
A 4-element vector giving an additional color to multiply with the ambient color of each object, in the red, green, and blue components respectively. The default is (0,0,0,1), or black.
NOTE: This property is not used in the default shader program.
Default Value: "[0,0,0,1]"
H3DU.LightSource#diffuse
A 4-element vector giving an additional color to multiply with the diffuse or albedo color (base color) of each object, in the red, green, and blue components respectively. See also H3DU.PbrMaterial#albedo. Each component ranges from 0 to 1. The default is (1,1,1,1), or white.
Default Value: "[1,1,1,1]"
H3DU.LightSource#position
Light position. An array of four numbers, where the first three numbers are the X, Y, and Z components and the fourth number is the W component.
- If W is 0, then X, Y, and Z specify a vector in world space; the light will shine the brightest on surfaces that face the light in this vector's direction from the origin (0, 0, 0).
- If W is 1, then X, Y, and Z specify the position of the light in world space; the light will shine brightest, and in every direction, at the given position.
Default Value: "[0,0,1,0]"
H3DU.LightSource#radius
Radius of the light source. If 0, the light's intensity doesn't change with distance.
Default Value: 0
H3DU.LightSource#specular
A 3-element vector giving the color of the light when it causes a specular reflection, in the red, green, and blue components respectively. Each component ranges from 0 to 1. A specular reflection is a reflection in the opposite direction from the direction the light reaches the object in, like a mirror. Specular reflections can cause shiny highlights depending on the viewing angle. The default is (1,1,1), or white.
NOTE: The default shader uses this only for H3DU.Material, not for H3DU.PbrMaterial.
Default Value: "[1,1,1]"
H3DU.LightSource#setParams(params)
Sets parameters for this material object.
Parameters
params
(Type: Object)
An object whose keys have the possibilities given below, and whose values are those allowed for each key.position
- Light position. (See H3DU.LightSource#position.)ambient
- Not used in the default shader program.diffuse
- A color vector or string giving an additional color to multiply with the diffusion color of each object (which is also called "albedo"). The default is (1, 1, 1, 1) for light index 0 and (0, 0, 0, 0) otherwise.specular
- A color vector or string giving the color of specular highlights caused by the light. The default is (1, 1, 1) for light index 0 and (0, 0, 0) otherwise.radius
- Radius of the light source. If 0, the light's intensity doesn't change with distance.
Return Value
This object. (Type: H3DU.LightSource)