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
DESTROYED ViewportEventType destroyed

the viewport has been destroyed

<readonly> TYPE :ViewportType

Enum for the viewport types.

Type:
Properties:
Name Type Default Description
DEFAULT ViewportType default

the default viewport

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,
  type: api.viewports.TYPE.DEFAULT,
  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 CameraApi

the camera api

lights LightApi

the light api

ViewportDefinition

Properties:
Name Type Description
container HTMLElement

the domElement in which to put the viewer

type ViewportType

the type of the viewport

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

ViewportType

Viewport type, see TYPE for values

Type:
  • String
ShapeDiver 3D Viewer, Copyright © 2015-2019 ShapeDiver GmbH. Documentation generated by JSDoc 3.5.5 on Wed Jul 3rd 2019 using the DocStrap template.