Skip to main content

Lights

#Lights Light sources in 3D scenes.

AmbientLight

Parameters

NameTypeDescription
optionObjectoptionalparameter
nametypedefault valuedescription
colorString#ffffffoptionalLight source color, supports hexadecimal.
intensityNumber1optionalThe intensity of light irradiation, the value is a positive number.

Case

//Add ambient light source
let ambientLight = new mapmost.AmbientLight({
color: '#ffffff',
intensity: 1
})
map.addLight(ambientLight)
//Remove ambient light source
map.removeLight(ambientLight)

DirectionalLight

Parameters

NameTypeDescription
optionObjectoptionalparameter
nametypedefault valuedescription
colorString#ffffffoptionalLight source color, supports hexadecimal.
intensityNumber1optionalThe intensity of light irradiation, the value is a positive number.
positionArray[0,0,1]optionalThe starting position of the light source, represented by the array [x, y, z], where x represents the east-west direction, east is positive, y represents the north-south direction, north is positive, z represents the up-down direction, upward is positive; always constitutes the light source direction with the light source target position [0,0,0]. Example [1,1,1] can mean that parallel light shines from the northeast direction at 45°.

Case

//Add directional light source
let directionalLight = new mapmost.DirectionalLight({
color: '#ffffff',
intensity: 1,
position: [0, 0, 1]
})
map.addLight(directionalLight)
//Delete directional light source
map.removeLight(directionalLight)

HemisphereLight

Hemispheric light source is a light source located directly above the scene. The light color gradually changes from the sky color to the ground color.

Parameters

nametypedefault value
optionObjectoptionalparameter
nametypedefault valuedescription
skyColorString#ffffffoptionalThe color of the light emitted from the sky, supports hexadecimal.
groundColorString#ffffffoptionalThe color of light emitted from the ground, supports hexadecimal.
intensityNumber1optionalThe intensity of light irradiation, the value is a positive number.
positionArray[0,0,1]optionalThe direction of the light source gradient, represented by the array [x, y, z]. Among them, x represents the east-west direction, a positive value indicates that skyColor gradually changes from east to west to groundColor, y indicates the north-south direction, a positive value indicates that skyColor gradually changes from north to south to groundColor, z indicates the up-down direction, and a positive value indicates that skyColor gradually changes from top to bottom to groundColor.

Case

//Add hemispheric light source
let hemisphereLight = new mapmost.HemisphereLight({
skyColor: '#ffffff',
groundColor: '#ffffff',
intensity: 1,
position: [0, 0, 1]
})

map.addLight(hemisphereLight)