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: ViewportApi

viewportApi

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

Inherited From:
Overrides:
Returns:
Type Description
APIResponse

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

applyTransformation(matrix)

Applies a 4x4 transformation matrix to this viewport.

Parameters:
Name Type Description
matrix ApiSceneInterface#Transformation

The transformation matrix

Inherited From:
Overrides:
Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type boolean.

convertTo2D(position)

Converts the given 3D coordinates into various 2D coordinates

See:
Parameters:
Name Type Description
position Point3d

The 3D point to convert

Inherited From:
Overrides:
Returns:
Type Description
ApiSceneInterface#2DCoordinateSummary

A summary of the different 2D coordinates

destroy()

Destroys the current viewport. This api will be invalid after this operation.

Inherited From:
Overrides:

getContainer()

Returns the container in which the viewer is.

Inherited From:
Overrides:
Returns:
Type Description
HTMLElement

the container of the viewer

| Object

getRuntimeId()

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.

Inherited From:
Overrides:
Returns:
Type Description
String

runtime id used for API instance, should be unique

getScreenshot()

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.

Inherited From:
Overrides:
Returns:
Type Description
String

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

getSelected()

Get scene paths of selected objects.

Returns:
Type Description
Array.<ScenePathType>

Array of scene paths of selected objects.

getSetting(key)

Provides a copy of an individual setting

Parameters:
Name Type Description
key String

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

Inherited From:
Overrides:
Returns:
Type Description
*

a copy of the setting, undefined if not found

getSettingDefinitions()

Provides an object describing all available settings

Inherited From:
Overrides:
Returns:
Type Description
Object

object describing all available settings, their type, and constraints

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

Inherited From:
Overrides:
Returns:
Type Description
Object

object containing a copy of the settings

removeEventListener(token)

Remove an event listener

Parameters:
Name Type Description
token EventListenerToken

event listener token for event listener to be removed

Inherited From:
Overrides:
Returns:
Type Description
APIResponse

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

resetTransformation()

Resets the 4x4 transformation matrix for this viewport.

Inherited From:
Overrides:
Returns:
Type Description
Promise.<APIResponse>

API response with a data array of type boolean.

updateSelected( [select] [, deselect])

Update selection status of objects.

Parameters:
Name Type Argument Description
select Array.<ScenePathType> <optional>

Optional list of scene paths of objects which should be selected (please note that there might be further selected objects after this update, which had already been selected)

deselect Array.<ScenePathType> <optional>

Optional list of scene paths of objects which should be deselected

Returns:
Type Description
Boolean

true if selection status could be set for all specified scene paths, false if at least one error occured.

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

Inherited From:
Overrides:
Returns:
Type Description
Promise.<APIResponse>

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

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

Inherited From:
Overrides:
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.

Members

camera :CameraApi

The camera api.

Type:
Overrides:

lights :LightApi

The light api.

Type:

<inner> _api :ApiInterfaceV2

Type:

<inner> _listeners

To Do:
  • restructure this like original api

<inner> _references :Object

Type:
  • Object

<inner> _threeDManager :module:ThreeDManagerDefault~ThreeDManager

Type:
  • module:ThreeDManagerDefault~ThreeDManager

<inner> _viewportApiHelpers :module:ViewportApiHelpers~ViewportApiHelpers

Type:
  • module:ViewportApiHelpers~ViewportApiHelpers

<inner> _viewportManager :module:ViewportManager~ViewportManager

Type:
  • module:ViewportManager~ViewportManager

<inner, constant> CameraApi :CameraApi

Type:

<inner, constant> LightApi :LightApi

Type:

<inner, constant> THREE_D_MANAGER_CONSTANTS :module:ThreeDManagerConstantsDefault~ThreeDManagerConstants

Type:
  • module:ThreeDManagerConstantsDefault~ThreeDManagerConstants

<inner, constant> ViewportApiInterface :module:ViewportApiInterface~ViewportApiInterface

Type:
ShapeDiver 3D Viewer, Copyright © 2015-2018 ShapeDiver GmbH. Documentation generated by JSDoc 3.5.5 on Thu Mar 7th 2019 using the DocStrap template.