ShapeDiver Viewer - Light API
Methods
-
get()
-
Get light definitions
Returns:
-
Type Description APIResponse APIResponse with a data array of LightDefinition objects. All lights will have the id property set.
-
-
remove(id)
-
Remove a light
Parameters:
Name Type Description idString Id of the light to remove.
Returns:
-
Type Description APIResponse APIResponse with a data array of LightDefinition objects still in the scene. All lights will have the id property set.
-
-
restore(name)
-
Restore a predefined light scene (a default configuration of lights).
This removes all currently configured lights, and restores one of the predefined default light scenes.
Parameters:
Name Type Description nameLightSceneType Name of light scene to restore.
Returns:
-
Type Description APIResponse APIResponse with a data array of LightDefinition objects currently in the scene. All lights will have the id property set.
-
-
update(lights)
-
Add new lights or update existing ones.
Specify the id property of the light definition to update an existing light. Do not specify the id property of the light definition to add a new light.
Parameters:
Name Type Description lightsArray.<LightDefinition> Light definitions to be added (id property not set) or updated (id property set)
Returns:
-
Type Description APIResponse APIResponse with a data array of LightDefinition objects currently in the scene. All lights will have the id property set.
-
Members
-
<readonly> LIGHTSCENE :LightSceneType
-
Enum for default light scenes.
Type:
Properties:
Name Type Default Description DEFAULTLightSceneType default default light scene
DEFAULT_LEGACYLightSceneType default_legacy default legacy light scene
TESTLightSceneType test test light scene
Type Definitions
-
LightDefinition
-
Light definition
Type:
- Object
Properties:
Name Type Argument Default Description idNumber <optional>
Unique id of the light object. When adding a new light, do not set this property.
typeLightType <optional>
TYPE.DIRECTIONAL Type of light. Default is a directional light.
colorColor <optional>
'white' [r,g,b,a] array of numbers between 0-255, alpha value will be ignored, defaults to white.
intensityNumber <optional>
1.0 Intensity of the light between 0 and Infinity. This example explains the influence of this parameter.
shadowsBoolean <optional>
false If set to true light will cast dynamic shadows. Currently this is supported for directional lights only.
positionPoint3d <optional>
For spotlights, position of the light. Defaults to target - direction.
targetPoint3d <optional>
For spotlights, target of the light. Defaults to center of scene bounding box.
directionPoint3d <optional>
{x:1,y:-1,z:1} For directional lights, direction of the light.
distanceNumber <optional>
0 For spotlights, if non-zero, light will attenuate from maximum intensity at the light's position down to zero at this distance from the light. When set to 0, then the light intensity does not decrease with the distance.
angleNumber <optional>
Math.PI/3 For spotlights, maximum extent of the spotlight, in radians, from its direction. Should be no more than Math.PI/2.
penumbraNumber <optional>
0 For spotlights, percent of the spotlight cone that is attenuated due to penumbra. Takes values between zero and 1.
decayNumber <optional>
1 For spotlights, the amount the light dims along the distance of the light. For physically correct lighting, set this to 2.
-
LightSceneType
-
Available light scenes, see LIGHTSCENE for values
Type:
- Integer
-
LightType
-
The light type, see TYPE for values
Type:
- Integer