Class: ViewportApiInterface

ViewportApiInterface~ ViewportApiInterface

Interface for the ViewportApi. The ViewportApi implements all functionality related to 3D.

//@interface ViewportApiInterface

Methods

<abstract> addEventListener(type, callback)

Add a callback to be invoked when a certain event occurs

Parameters:
Name Type Description
type ApiEventType

Type of event to subscribe to

callback EventListenerCallback

Function to be called when the event fires

Returns:
Type Description
APIResponse

APIResponse with an EventListenerToken object. The event listener token can be used to remove the event listener by calling removeEventListener.

<abstract> applyTransformation(matrix)

Applies a 4x4 transformation matrix or an array of transformation matrices to this viewport.

Parameters:
Name Type Description
matrix ApiSceneInterface#Transformation | Array.<ApiSceneInterface#Transformation>

The transformation matrix or an array of matrices

Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type boolean.

<abstract> convertTo2D(position)

Converts the given 3D coordinates into various 2D coordinates

See:
  • ApiSceneInterface#2DCoordinateSummary
Parameters:
Name Type Description
position Point3d

The 3D point to convert

Returns:
Type Description
ApiSceneInterface#2DCoordinateSummary

A summary of the different 2D coordinates

<abstract> getContainer()

Returns the container in which the viewer is.

Returns:
Type Description
HTMLElement

the container of the viewer

| Object

<abstract> getScreenshot()

Deprecated:
  • This method is deprecated, please use getScreenshotAsync instead. Get screenshot as a png data URI. Returns a screenshot of the viewer canvas without any control elements as a data URI using the png image format.
Returns:
Type Description
String

Data URI representing the png screeshot image (data:image/png;base64,...).

<abstract> getScreenshotAsync()

Get screenshot as a png data URI. Returns a screenshot of the viewer canvas without any control elements as a data URI using the png image format.

Returns:
Type Description
Promise.<APIResponse>

APIResponse whose data property will be a Data URI representing the png screeshot image (data:image/png;base64,...).

<abstract> getSelected()

Get scene paths of selected objects.

See:
  • ApiSceneInterface#getSelected

<abstract> getSetting(key)

Provides a copy of an individual setting

Parameters:
Name Type Description
key String

name of setting (e.g. 'scene.render.shadows')

Returns:
Type Description
*

a copy of the setting, undefined if not found

<abstract> getSettingDefinitions()

Provides an object describing all available settings

Returns:
Type Description
Object

object describing all available settings, their type, and constraints

<abstract> getSettings( [keys])

Provides a copy of all or multiple settings

See:
Parameters:
Name Type Argument Description
keys Array.<String> <optional>

optional array of keys, keys which don't exist are ignored, if omitted all settings will be returned

Returns:
Type Description
Object

object containing a copy of the settings

<abstract> getTransformation()

Returns the 4x4 transformation matrix or an array of them for this viewport.

Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type matrix or an array of matrices.

<abstract> getViewportRuntimeId()

Get the runtime id used for this API object. The runtime id can optionally be specified as a setting when creating the API object, otherwise a random one will be created.

Returns:
Type Description
String

runtime id used for API instance, should be unique

<abstract> pause()

Pause the rendering.

<abstract> removeEventListener(token)

Remove an event listener

Parameters:
Name Type Description
token EventListenerToken

event listener token for event listener to be removed

Returns:
Type Description
APIResponse

APIResponse with a Boolean data, indicating whether the event listener could be removed.

<abstract> render()

Render the scene.

<abstract> resetTransformation()

Resets the 4x4 transformation matrix or the array of transformation matrices for this viewport.

Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type boolean.

<abstract> resume()

Resume the rendering.

<abstract> setLiveTransformation()

Set a live transformation for this viewport.

See:
  • ApiSceneInterface#setLiveTransformation

<abstract> setTransformation(matrix)

Sets a 4x4 transformation matrix for this viewport.

Parameters:
Name Type Description
matrix ApiSceneInterface#Transformation | Array.<ApiSceneInterface#Transformation>

The transformation matrix or an array of transformation matrices

Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type boolean.

startContinuousRendering()

Starts continously rendering the scene until stopContinuousRendering is called.

<abstract> startExternalDragEvent()

Start an external drag event for an object with a certain path.

See:
  • ApiSceneInterface#startExternalDragEvent

stopContinuousRendering()

Stops continously rendering the scene if startContinuousRendering was called.

<abstract> toggleGeometry()

Show or hide geometry based on its scene path.

See:
  • ApiSceneInterface#toggleGeometry

<abstract> updateSelected()

Update selection status of objects.

See:
  • ApiSceneInterface#updateSelected

<abstract> updateSettingAsync(key, val)

Update an individual setting, if allowed.

See:
Parameters:
Name Type Description
key String

name of setting

val Object

new value of setting

Returns:
Type Description
Promise.<APIResponse>

APIResponse whose data property will be true if setting could be changed, false if not.

<abstract> updateSettingsAsync(settings)

Update a bunch of settings according to the enumerable properties of an object, if allowed.

Parameters:
Name Type Description
settings Object

object whose own properties should be used as settings

Returns:
Type Description
Promise.<APIResponse>

APIResponse whose data property will be set to a copy of the input object, whose property values are replaced by true or false depending on whether the corresponding setting could be updated.

updateShadowMap()

Updates the shadow map if needed. Normally, all updates should be covered.

Members

camera :module:CameraApiInterface~CameraApiInterface

The camera api for the corresponding viewport api.

Type:

lights :module:LightApiInterface~LightApiInterface

The light api for the corresponding viewport api.

Type:
ShapeDiver 3D Viewer, Copyright © 2015-2019 ShapeDiver GmbH. Documentation generated by JSDoc 3.6.5 on Tue Sep 8th 2020 using the DocStrap template.