ShapeDiver Viewer - Light API
The LightApi implements all functionality related to the lights.
Methods
-
getAllLightScenes()
-
Returns the name of all available light scenes.
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data array of type LightSceneID an array of all stored light scenes
-
getLight(id)
-
Returns the light in the current light scene with this id.
Parameters:
Name Type Description id
LightID unique id of the light to be return from the current light scene
Returns:
-
Type Description APIResponse Api Response with data of type LightDefinition: the definition of the light with the given id
-
-
getLightScene( [id])
-
Return definition of the light scene with the provided id. If no id is provided, it returns the current light scene. Does not change the current light scene.
Parameters:
Name Type Argument Description id
LightSceneID <optional>
id of light scene whose definition should be returned, the definition of the current light scene will be returned if no id is provided
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data of type LightSceneDefinition: definition of light scene on success, falsy if light scene with provided id does not exist
-
removeLight(id)
-
Remove light from the current light scene,
Parameters:
Name Type Description id
LightID unique id of the light to be removed from the current light scene
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data of type boolean: true on success, false if light could not be removed
-
saveLightScene( [id])
-
Save the current light scene either to a new LightSceneID or to the one provided. CAUTION: IDs of predefined light scenes may not be used for saving.
Parameters:
Name Type Argument Description id
LightSceneID <optional>
Unique id to use for saving the current light scene, potentially overwriting the saved definition of an existing light scene. May be empty, in which case a new unique id will be created.
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data array of type LightSceneID unique id which was used for saving the current light scene, falsy on error
-
setLightSceneFromDefinition(scene)
-
Replaces the current light scene with the given lights.
Parameters:
Name Type Description scene
LightSceneDefinition - Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data of type LightSceneID: Unique id of the newly set light scene, falsy if new light scene could not be set
-
setLightSceneFromID(id)
-
Replaces the current light scene with the light scene defined by the given id. Predefined light scenes may be restored using this function. In case the light scene with the given id does not exist, the current light scene will stay untouched.
Parameters:
Name Type Description id
LightSceneID - Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data of type boolean: true if light scene could be set, false if not
-
updateLight(definition)
-
Add a light to the current light scene.
Parameters:
Name Type Description definition
LightDefinition Definition of light to add to the current light scene. May include an id to be used for the new light, which must be unique. A unique id will be automatically created and returned if none is provided.
- Inherited From:
- Overrides:
Returns:
-
Type Description APIResponse Api Response with data of type LightID: Unique id of newly added light in the current light scene, falsy if light could not be added
Members
-
<readonly> LIGHTSCENE :LIGHTSCENE
-
Enum for predefined light scenes.
Type:
- Overrides:
Properties:
Name Type Default Description DEFAULT
LIGHTSCENE default the default light scene
LEGACY
LIGHTSCENE legacy the legacy light scene
-
<readonly> LIGHTTYPE :LIGHTTYPE
-
Enum for supported light types.
Type:
Type Definitions
-
AmbientLightProperties
-
Type:
- Inherited From:
Properties:
Name Type Argument Default Description color
Color <optional>
0xffffff the color of the light
intensity
Number <optional>
0.5 the intensity of the light
-
DirectionalLightProperties
-
Type:
- Inherited From:
Properties:
Name Type Argument Default Description color
Color <optional>
0xffffff the color of the light
intensity
Number <optional>
0.5 the intensity of the light
castShadow
Boolean <optional>
false option to cast shadows from this light
direction
Point3d <optional>
{x: -1, y: 0, z: 1} the direction of the light, will be normalized internally
-
FlashLightProperties
-
Type:
- Inherited From:
Properties:
Name Type Argument Default Description color
Color <optional>
0xffffff the color of the light
intensity
Number <optional>
0.4 the intensity of the light
distance
Number <optional>
0 maximum range of the light; default is 0 (no limit)
angle
Number <optional>
PI/2 maximum angle of light dispersion from its direction whose upper bound is PI/2
penumbra
Number <optional>
5 percent of the spotlight cone that is attenuated due to penumbra; takes values between zero and 1
decay
Number <optional>
5 the amount the light dims along the distance of the light
-
HemisphereLightProperties
-
Type:
-
LightDefinition
-
The definition of a light. Varies per type.
Type:
- Object
- Inherited From:
Properties:
Name Type Description id
LightID the id of the light, if not provided an id unique to the current light scene will be created
type
LIGHTTYPE the type of the light
properties
LightProperties the specific properties of the light
-
LightID
-
The unique ID for a specific light. Each light within a light scene must have a unique ID. When saving light scenes the unique IDs of individual lights will get saved as well, i.e. when restoring light scenes the IDs of the individual lights will be restored as well.
Type:
- String
- Inherited From:
-
LightProperties
-
The properties of a light. When specifying a LightDefinition the type and the properties have to be of same type.
See:
Type:
- Object
- Inherited From:
-
LightSceneDefinition
-
The definition of a light scene.
Type:
- Object
- Inherited From:
Properties:
Name Type Description id
LightSceneID the id of the light scene, if not provided a unique id will be created
lights
Array.<LightDefinition> the lights in the scene
-
LightSceneID
-
The unique ID for a specific light scene. For predefined light scenes see LIGHTSCENE
Type:
- String
- Inherited From:
-
PointLightProperties
-
Type:
- Inherited From:
Properties:
Name Type Argument Default Description color
Color <optional>
0xffffff the color of the light
intensity
Number <optional>
0.5 the intensity of the light
distance
Number <optional>
0 maximum range of the light; default is 0 (no limit)
decay
Number <optional>
2 the amount the light dims along the distance of the light
position
Point3d <optional>
the position of the light; if no position is given, the position is set to the border of the bounding sphere
-
SpotLightProperties
-
Type:
- Inherited From:
Properties:
Name Type Argument Default Description color
Color <optional>
0xffffff the color of the light
intensity
Number <optional>
0.5 the intensity of the light
distance
Number <optional>
0 maximum range of the light; default is 0 (no limit)
angle
Number <optional>
PI/4 maximum angle of light dispersion from its direction whose upper bound is PI/2
penumbra
Number <optional>
0.5 percent of the spotlight cone that is attenuated due to penumbra; takes values between zero and 1
decay
Number <optional>
1 the amount the light dims along the distance of the light
position
Point3d <optional>
the position of the light; if no position is given, the position is set to the border of the bounding sphere
target
Point3d <optional>
the target of the light; if no target is given, the target is set to the center of the scene