You are reading the documentation for the version 2 of the ShapeDiver viewer API. Free support for this viewer version will be discontinued on June 1st, 2024.

Please refer to the version 3 documentation here. See also the migration guide from version 2 to version 3 here.

Class: LightApi

api.scene.lights

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
id String

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
name LightSceneType

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
lights Array.<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
DEFAULT LightSceneType default

default light scene

DEFAULT_LEGACY LightSceneType default_legacy

default legacy light scene

TEST LightSceneType test

test light scene

<readonly> TYPE :LightType

Enum for light types.

Type:
Properties:
Name Type Default Description
AMBIENT LightType 0

ambient light

DIRECTIONAL LightType 1

directional light

SPOT LightType 2

spot light, potentially falling off

Type Definitions

LightDefinition

Light definition

Type:
  • Object
Properties:
Name Type Argument Default Description
id Number <optional>

Unique id of the light object. When adding a new light, do not set this property.

type LightType <optional>
TYPE.DIRECTIONAL

Type of light. Default is a directional light.

color Color <optional>
'white'

[r,g,b,a] array of numbers between 0-255, alpha value will be ignored, defaults to white.

intensity Number <optional>
1.0

Intensity of the light between 0 and Infinity. This example explains the influence of this parameter.

shadows Boolean <optional>
false

If set to true light will cast dynamic shadows. Currently this is supported for directional lights only.

position Point3d <optional>

For spotlights, position of the light. Defaults to target - direction.

target Point3d <optional>

For spotlights, target of the light. Defaults to center of scene bounding box.

direction Point3d <optional>
{x:1,y:-1,z:1}

For directional lights, direction of the light.

distance Number <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.

angle Number <optional>
Math.PI/3

For spotlights, maximum extent of the spotlight, in radians, from its direction. Should be no more than Math.PI/2.

penumbra Number <optional>
0

For spotlights, percent of the spotlight cone that is attenuated due to penumbra. Takes values between zero and 1.

decay Number <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
ShapeDiver 3D Viewer, Copyright © 2015-2019 ShapeDiver GmbH. Documentation generated by JSDoc 3.5.5 on Wed Jul 3rd 2019 using the DocStrap template.