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: 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> convertTo2D(position)

Converts the given 3D coordinates into various 2D coordinates

See:
Parameters:
Name Type Description
position Point3d

The 3D point to convert

Returns:
Type Description
ApiSceneInterface#2DCoordinateSummary

A summary of the different 2D coordinates

<abstract> destroy()

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

<abstract> getContainer()

Returns the container in which the viewer is.

Returns:
Type Description
HTMLElement

the container of the viewer

| Object

<abstract> 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.

Returns:
Type Description
String

runtime id used for API instance, should be unique

<abstract> 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.

Returns:
Type Description
String

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

<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> reload()

Destroys the current viewport and reloads it directly afterwars.

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

Members

camera :module:CameraApiInterface~CameraApiInterface

The camera api for the corresponding viewport api.

Type:
ShapeDiver 3D Viewer, Copyright © 2015-2018 ShapeDiver GmbH. Documentation generated by JSDoc 3.5.5 on Sun Dec 16th 2018 using the DocStrap template.