player

This module supports the UI for the player.

Methods

(static) addTool(Tool, name) → {Promise}

Add a tool (See Tools and Events)

Parameters:
Name Type Description
Tool Tool
name String

provide a name for the tool to allow removing it.

Returns:
Type
Promise

(static) animateCameraTo(id, duration) → {Promise}

Animate the camera to the position of another.

Parameters:
Name Type Description
id String

the id of the camera to move to.

duration Number

length of the animation (ms), default 300.

Returns:
Type
Promise

(static) createExplode(explodeMode, targetNodeopt, nodeListopt, explodeSizeopt, durationopt) → {Promise}

Create a explode clip for the provide node list

Parameters:
Name Type Attributes Description
explodeMode String

The axises that the explode follow, can be 'xyz', 'xz', 'x' and etc.

targetNode String <optional>

The name of the target node, default is the Objects root.

nodeList Array <optional>

An array of node Id to explode.\

explodeSize Number <optional>

The explode size, default 1.

duration Number <optional>

The duration of the explode clip, default 3000 ms.

Returns:

the promise result includes the dstCameraId, srcCameraId and explodeClipId.

Type
Promise

(static) displayThumbnail(display)

Turn thumbnail display on or off

Parameters:
Name Type Description
display Boolean

Display thumbnail (default true)

(static) exitFullscreen()

Exit fullscreen mode

(static) filterNodesFromCenter(rootNodeopt) → {Array}

return the list of node ids at the center of the screen

Parameters:
Name Type Attributes Description
rootNode String <optional>

Id of root of nodes that will be checked against center

Returns:

list of node ids found.

Type
Array

(static) filterNodesFromPosition(event, rootNodeopt, optionsopt) → {Array}

Given a manipulator event, return the list of node ids at that position. This matches only nodes that have the selectable property.

Parameters:
Name Type Attributes Description
event Event

generated by the manipulator interface. (See Tools and Events)

rootNode String <optional>

Id of root of nodes that will be checked against position

options Object <optional>
Properties
Name Type Attributes Description
nodes Array <optional>

An optional list of node ids to filter against. This can be much more performant as the sceneGraph gets large.

Returns:

list of node ids found.

Type
Array
Example
api.player.addTool({
  click: (ev) => {
    var nodes = api.player.filterNodesFromPosition(ev);
    console.log('Found: ', nodes.map((id) => api.scene.get({id: id, property: 'name'})));
  }
}, 'FindNode');

(static) frameScene(optionalNodeListopt, optionsnullable)

Reposition camera to adjust the frame of the object

Parameters:
Name Type Attributes Description
optionalNodeList Array <optional>

An array of selected node Id

options Object <nullable>
Properties
Name Type Attributes Description
layer String <nullable>

Layer to frame to

cameraId String <nullable>

Id of the camera to frame. Default is the active camera. Framing a non-active camera can be useful for setting it up prior to switching to it or taking a snapshot.

mode String <nullable>

What to frame. Valid values are 'sphere' for bounding sphere, and 'geometry' for precise vertex-level framing

lookAtCenter Boolean <nullable>

Whether to orient camera or simply move it forward/back

padding Number <nullable>

Amount of border around framed view as fraction of view edge to center. This is currently only available with the 'geometry' mode.

(static) getActiveColor()

Return the active color.

(static) getCamera()

Returns the current active camera

(static) getFullscreenBGColor()

Return the fullscreen background color.

(static) getHoverColor()

Return the hover color.

(static) getThree()

Returns an object with the active three.js scene, camera, and renderer. These will not be available immediately, so wait for at least the 'preloaded' event before calling this function.

(static) hideTool(name) → {Promise}

Hide the tool's button. (The tool can still be active when hidden).

Parameters:
Name Type Description
name String

the name of the tool.

Returns:
Type
Promise

(static) isFullscreen()

Check whether were in fullscreen mode.

(static) isLenticularMode()

Check whether we are in Lenticular rendering mode.

(static) isNormalRenderingMode()

(static) isVRMode()

Check whether we are in VR mode.

(static) removeTool(name) → {Promise}

Remove a tool (See Tools and Events)

Parameters:
Name Type Description
name String

The name of the tool to remove

Returns:
Type
Promise

(static) requestFullscreen()

Enable fullscreen mode.

(static) resize()

Trigger a resize event. If you manually resize the player's dom element, use this to force the player to rerender with the updated size.

(static) setActiveColor(color) → {Promise}

Set the active color and timeline color to be used for the player css.

Parameters:
Name Type Description
color Color

a valid css color (ex. '#ff0000'}.

Returns:
Type
Promise

(static) setCameraRadiusConstraint(maxZoom, minZoom)

Will constrain the target of the camera to remain inside the bounding sphere of the scene. The camera will not be allowed to enter the bounding sphere of the scene nor leave bounding sphere defined by arguments setting both maxZoom and minZoom to undefined will disable the constrain, missing one of the argument will use its default value If minZoom is larger than maxZoom, will set both maxZoom and minZoom to the small value of two argument

Parameters:
Name Type Description
maxZoom Number

distance around the center of the scene that defineds outer bounding sphere, default is 5

minZoom Number

distance around the center of the scene that defineds inner bounding sphere, default is 1

(static) setFullscreenBGColor(color) → {Promise}

Set the fullscreen background color to be used for the player css.

Parameters:
Name Type Description
color Color

a valid css color (ex. '#ff0000'}.

Returns:
Type
Promise

(static) setHoverColor(color) → {Promise}

Set the hover color to be used for the player css.

Parameters:
Name Type Description
color Color

a valid css color (ex. '#ff0000'}.

Returns:
Type
Promise

(static) setProgressBar(option)

Set the desired progress bar: default -- the default circle line -- an unobtrisive line across the bottom of the div none -- to allow custom progress bars to be used.

Parameters:
Name Type Description
option String

Desired progress bar, either 'default','line', or 'none'

(static) showTool(name) → {Promise}

Show the tool's button

Parameters:
Name Type Description
name String

the name of the tool.

Returns:
Type
Promise

(static) toggleFullscreen()

Toggle fullscreen mode

(inner) parseExplodeMode(explodeModeopt, nodeTypeopt, explodeSizeopt, durationopt) → {Object}

Auto explode function

Parameters:
Name Type Attributes Description
explodeMode String <optional>

xyz, xy/yz/xz, x/y/z

nodeType String <optional>

The based node type for exploding, default is 'Null', either 'Null' or 'PolyMesh'

explodeSize Number <optional>

explode size, default is 1

duration Number <optional>

duration, default is 3000

Returns:
Type
Object