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.

Interface: ApiViewportsInterface

api.viewports

ShapeDiver Viewer - Viewport API

The viewports interface is part of the global API.

It allows to

  • get viewport apis
  • create and destroy viewports

Methods

create(viewportDefinition)

Creates a new viewport

Parameters:
Name Type Description
viewportDefinition ViewportDefinition

definition of the viewport

Returns:
Type Description
ViewportApi

the api of the new viewport

destroy(runtimeId)

Destroys an existing viewport

Parameters:
Name Type Description
runtimeId String

the runtimeId of the viewport

Returns:
Type Description
boolean

true if there was a viewport to remove

get(runtimeId)

Get api for existing viewports

Parameters:
Name Type Description
runtimeId String

the runtimeId of the viewport, or undefined to return an object containing apis for all viewports

Returns:
Type Description
ViewportApi

the api of the viewport with the given runtimeId, or an array containing apis for all viewports

Members

<readonly> EVENTTYPE :ViewportEventType

Enum for the viewport api events.

Type:
Properties:
Name Type Default Description
CREATED ViewportEventType created

a viewport has been created

DESTROYED ViewportEventType destroyed

the viewport has been destroyed

Type Definitions

ViewportApi

// container for the viewport, typically this is a <div>
var _container = document.getElementById('sdv-container-viewport');
let viewportApi = api.viewports.create({
  container: _container,
  runtimeID: 'defaultViewport'
});

// to get the camera definition
viewportApi.camera.get();

// get a screenshot of the current viewport
viewportApi.getScreenshot();

// if there is only one default viewport
// api.scene.camera.get();
// and
// api.scene.getScreenshot();
// would do exactly the same

The api for a specific viewport. If there is only one viewport api.scene can be used instead. Due to the implementation being identical to api.scene but only viewport specific, the documentation is omitted. Please see api.scene instead.

The viewportApi has a camera api (viewportApi.camera) and a lights api (viewportApi.lights) that have the same methods as the corresponding apis in api.scene. The specific documentation is omitted. Please see api.scene.camera or api.scene.lights.

Properties:
Name Type Description
camera module:CameraApiDefault~CameraApi

the camera api

lights module:LightApiDefault~LightApi

the light api

ViewportDefinition

Properties:
Name Type Description
container HTMLElement

the domElement in which to put the viewer

runtimeId String

a unique runtimeId, if the id is not unique, a new one will be created

ViewportEventType

Viewport event type, see EVENTTYPE for values

Type:
  • String
ShapeDiver 3D Viewer, Copyright © 2015-2019 ShapeDiver GmbH. Documentation generated by JSDoc 3.6.6 on Thu Apr 29th 2021 using the DocStrap template.