ShapeDiver 3D Viewer API V1
The API v1 is offered for backwards compatibility with the API of ShapeDiver's 3D viewer v1.
We discourage use of the API v1 for developing new applications.
Methods
-
activateTopView(topViewActive [, force])
-
Toggle the top view mode.
In top view mode the camera is restricted to a top view of the scene. Panning and zooming is still possible, but rotating the camera in any way is impossible.
See:
Parameters:
Name Type Argument Default Description topViewActive
Boolean true: top view mode shall be activated, false: top view mode shall be deactivated
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true: top view mode was changed to given value, false: top view mode was already set to the chosen value, or session settings are different
-
addDraggableShape(id, type, diameter [, color], location)
-
Add a shape which can be dragged by the user.
This function allows you to add a simple shape to the scene which can be dragged by the user. While viewing the scene, the user can drag the object within a plane orthogonal to the current viewing direction.
See:
Parameters:
Name Type Argument Default Description id
String Id of the draggable shape. This can be used to retrieve information about the object or delete it. The caller is responsible for the uniqueness of this id.
type
String Currently supported values are 'box', 'sphere', 'dodecahedron'
diameter
Number Diameter of the draggable object
color
module:ApiInterfaceV1~Color <optional>
red Color of the draggable object, any format understood by this library can be used: https://www.npmjs.com/package/tinycolor2
location
Object The initial location of the object
Properties
Name Type Description x
Number x coordinate
y
Number y coordinate
z
Number z coordinate
Returns:
-
Type Description Boolean true: draggable shape was added successfully, false: error adding draggable shape
-
cameraPath(positions, targets, duration)
-
Tell the viewer camera to follow a given path in a given duration.
This command will prompt the viewer to move its camera on a smooth path interpolating a given set of 3d locations. The camera target is interpolated as well. The most straightforward way to come up with proper input values for predefined paths is to manually move the camera to a desired locations and read the values from the viewer using the getCamera command.
See:
Parameters:
Name Type Description positions
Array.<module:ApiInterfaceV1~Point3d> Array of 3d points defining the camera positions along the path
targets
Array.<module:ApiInterfaceV1~Point3d> Array of 3d points defining the camera targets along the path
duration
Number Duration of the animation in milliseconds
Returns:
-
Type Description Boolean true: the path definition is valid and animation will be run, false: animation will not be run
-
changeEnvMap(name)
-
Set or change the environment map.
The viewer supports predefined environment maps which can be chosen by name. As an alternative the environment map can be influenced directly by passing an array of 6 image URLs defining a cube map. * Please refer to the following example explaining the required alignment of images: https://www.shapediver.com/demos/demo_envmap.html
See:
Parameters:
Name Type Description name
String | Array.<String> The name of the environment map to use, e.g. one of "ocean", "storm", "sky", "mountains", "levelsets", "default", etc. As an alternative an array of 6 image URLs of a cube map can be passed.
Returns:
-
Type Description Boolean true on success, false on error
-
clearMessagingCallback()
-
Clear callback function that previously may have been set.
See:
Returns:
-
Type Description Boolean true on success, false on error (e.g. if no messaging callback was set)
-
clearProcessCallback(token)
-
Clear a callback function which was previously registered using module:ApiInterfaceV1~ApiInterfaceV1#setProcessCallback.
Your subscription to the process messages for a given process token ends automatically once the process ultimately succeeded or failed. You may unsubscribe before that using this function.
See:
Parameters:
Name Type Description token
module:ApiInterfaceV1~ProcessCallbackToken The token which was returned from module:ApiInterfaceV1~ApiInterfaceV1#setProcessCallback
Returns:
-
Type Description Boolean true if callback was unregistered successfully, false otherwise.
-
deregisterPlugin(runtimeId)
-
Deregister a plugin
See:
Parameters:
Name Type Description runtimeId
String runtime id of the plugin to deregister
Returns:
-
Type Description Boolean true in case of success, false otherwise
-
disablePan(bDisable)
-
Disables / enables panning.
See:
Parameters:
Name Type Description bDisable
Boolean true: disable panning, false: enable panning
Returns:
-
Type Description Boolean true if panning toggle was successfully changed, false if it already had the given value or the update failed
-
disableZoom(bDisable)
-
Disables / enables zooming.
See:
Parameters:
Name Type Description bDisable
Boolean true: disable zooming, false: enable zooming
Returns:
-
Type Description Boolean true if zooming toggle was successfully changed, false if it already had the given value or the update failed
-
fadeInViewer()
-
Fade in the viewer (show 3D scene)
Returns:
-
Type Description Boolean true on success
-
-
findTexturedGeometry()
-
Finds the names of geometry outputs which contain meshes which have texture coordinates.
See:
Returns:
-
Type Description Array.<String> Array of names of geometry outputs
-
getApiVersion()
-
Get the version number of the API.
Returns:
-
Type Description String Version number of the API (Major.Minor.Patch)
-
-
getBackgroundColor()
-
Get background color of 3D view.
See:
Returns:
-
Type Description String hex color string including alpha value, i.e. formatted like '#rrggbbaa'
-
getCamera()
-
Get camera position and target.
This information can be used to later return the camera to a specific position using the setCamera command, or to create camera paths using cameraPath.
See:
Returns:
-
Type Description module:ApiInterfaceV1~CameraLocation Location and target of the camera.
-
getDraggableShapePosition(id)
-
Get the current position of a draggable shape.
See:
Parameters:
Name Type Description id
String Id of the draggable shape
Returns:
-
Type Description module:ApiInterfaceV1~Point3d Current location of the draggable shape
-
getExportDefinitions( [plugin])
-
Returns a list of available geometry exports.
Using the ShapeDiver plugin, designers can define several types of geometry exports in their Grasshopper definitions. Currently, geometry can be downloaded using the browser or sent to an email address specified by the designer. This command returns a list of available exports with their types and names. Exports can be triggered using the requestExport command.
See:
Parameters:
Name Type Argument Description plugin
String <optional>
runtime id of plugin to get export definitions for, may be empty in which case export definitions of all plugins will be returned
Returns:
-
Type Description Array.<module:ApiInterfaceV1~ExportDefinition> array of export definitions
-
getGeometryNames( [creatorId])
-
Returns the names of geometry objects in the scene
Parameters:
Name Type Argument Description creatorId
String <optional>
Creator id (typically the runtime id of a plugin) for which to get the names of geometry. If omitted, names for all creators are returned.
Returns:
-
Type Description Object One property for each creator id. The property includes one sub-property per name of geometry, which in turn holds an array of output ids.
-
-
getGeometryPathsByName(name [, creatorId])
-
Given a geometry name, returns the paths for all output ids containing geometry given that name
Parameters:
Name Type Argument Description name
String Geometry name to look for
creatorId
String <optional>
Creator id (typically the runtime id of a plugin) for which to list paths. If omitted, all creators are considered.
Returns:
-
Type Description Array.<String> Array of paths to geometry which has the given name.
-
-
getModelData()
-
Retrieves model specific data defined by the model's data output components.
Retrieves any model data created by ShapeDiver data output Grasshopper components. Values are updated whenever the parameters are changed.
Returns:
-
Type Description Object.<String, module:ApiInterfaceV1~ModelDataItem> The object's property names are the unique ids of the individual data outputs. Their values include the value and name of the data object.
-
-
getParameterDefinitions( [settings])
-
Retrieves the parameter definitions for all parameters known by the viewer application, or a subset.
This prompts the viewer to return an object containing parameter definitions for all parameters currently known by the viewer application. The resulting object will contain one key for each parameter, whose name is the unique parameter id. The content of the parameter definition objects varies depending on the type of the parameter. CAUTION: Parameter ids might not be unique across plugin instances, therefore the returned object might not include all registered parameters. Use module:ApiInterfaceV2~ApiInterfaceV2 to overcome this problem.
Parameters:
Name Type Argument Description settings
Object <optional>
optional properties to search for, works for any setting of parameter
Properties
Name Type Argument Description id
String <optional>
id of parameter
name
String <optional>
name of parameter
plugin
String <optional>
runtime id of plugin the parameter belongs to
type
String <optional>
type of parameter
Returns:
-
Type Description Object.<String, module:ApiInterfaceV1~ParameterDefinition> An object defining all available parameters definitions for the current model.
-
-
getParameterValues()
-
Retrieves current values for all parameters.
Returns an object containing the ids and current values for all parameters currently known by the viewer application. Please note that when a parameter is updated by the user or via the API, this command will immediately begin to return the new parameter value as 'current'. However, it might still take a while until the viewer actually displays the updated geometry.
To get a full overview over the status of the viewer, combine this command with module:ApiInterfaceV1~ApiInterfaceV1#getStatus.
CAUTION: Parameter ids might not be unique across plugin instances, therefore the returned object might not include all registered parameters. Use module:ApiInterfaceV2~ApiInterfaceV2 to overcome this problem.
Returns:
-
Type Description Object An object whose properties define parameter ids and their values.
-
-
getScreenshot()
-
Get screenshot as 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,...).
-
-
getStatus()
-
Returns a code and description of the current status.
Returns:
-
Type Description module:ApiInterfaceV1~ViewerStatusObject Object describing the current status of the viewer
-
-
hideControls()
-
Hides the control panel and its toggle from the viewer window.
See:
Returns:
-
Type Description Boolean true if the control panel was hidden
-
hideFullscreenToggle()
-
Hides the full-screen toggle in the viewer.
See:
Returns:
-
Type Description Boolean true if the full-screen toggle was hidden
-
hideZoomToggle()
-
Hides the zoom toggle in the viewer.
See:
Returns:
-
Type Description Boolean true if the zoom toggle was hidden
-
loadStaticMesh(baseUrl, objFile, mtlFile [, id] [, texturePath] [, sidedNess])
-
Loads a static mesh into the viewer.
Loads a static external mesh into the viewer. The mesh must be stored in a public online location as an OBJ file, with an accompanying MTL file defining material properties. The MTL file may reference texture images to be downloaded.
See:
Parameters:
Name Type Argument Default Description baseUrl
String The base url to use for downloading the .obj and .mtl file
objFile
String Filename of the .obj file to load, will be concatenated with baseUrl
mtlFile
String Filename of the .mtl file to load, will be concatenated with baseUrl
id
String <optional>
Unique id of the statically added mesh, which can be used to reference the mesh later on (show/hide). A unique id will be created if none is provided.
texturePath
String <optional>
baseUrl The base url to use for downloading texture images
sidedNess
String <optional>
'double' The sidedness to use for the mesh ('front', 'back', 'double')
Returns:
-
Type Description Boolean true if the mesh could be added to the scene, false otherwise
-
refreshPlugin(pluginRuntimeId [, token])
-
Refresh the outputs of a plugin by calling its set*ParameterValues function for the current values of its parameters
See:
Parameters:
Name Type Argument Description pluginRuntimeId
String runtime id of the plugin to refresh
token
String <optional>
process token to be used
Returns:
-
Type Description Boolean true if refresh process could be started successfully, false otherwise
-
registerPlugin(plugin)
-
Register a plugin
Loads the plugin and, unless the plugin's setting deferGeometryLoading is true, asks it to display default geometry
See:
Parameters:
Name Type Description plugin
Object The plugin to load
Returns:
-
Type Description String plugin runtime id in case of success, nothing (undefined) on error
-
removeDraggableShape(id)
-
Removes a previously added draggable shape from scene.
See:
Parameters:
Name Type Description id
String The id of the shape to be removed from the scene
Returns:
-
Type Description Boolean true if the shape was found in the scene and successfully removed
-
removeExternalTexture(name, mapNames, true)
-
Remove externally defined texture from a geometry output
See:
Parameters:
Name Type Description name
String Name of the geometry output for which external textures shall be removed
mapNames
Array.<String> Array of map names for which to remove the external texture image. Possible values are 'color', 'alpha', 'bump', 'normal', 'metalness', 'roughness'. A single string can be provided for color textures as a fallback.
true
Boolean if at least one externally defined texture image was removed from a geometry output, false otherwise
-
removeStaticMesh(id)
-
Remove a static mesh from the viewer.
See:
Parameters:
Name Type Description id
String The unique id used to reference the loaded mesh
Returns:
-
Type Description Boolean true if the mesh was found and removed, false otherwise
-
requestExport(id [, beSilent] [, plugin] [, token])
-
Triggers export actions based on the type of the export.
Requests the execution of an export using the current parameter set. The triggered action depends on the type of the export.
- For exports of type 'download', the command will result in a download link to the exported geometry being reported back to the viewer for download, using the file format and file name specified by the designer.
- Exports of type 'email' will prompt the ShapeDiver servers to send an email containing a download link and the current parameter set to the email address specified by the designer. In this case, the user does not get direct access to the exported geometry.
- Exports of type 'shapeways' will be exported directly to ShapeWays, and a link to the ShapeWays model will be reported back to the viewer.
When calling functions like requestExport, which involve several asynchronous operations, the function's return value will only tell you about validity of the parameters which you used to invoke the function. The function will usually return before the process triggered by the function call gets finished. As an example, calling requestExport involves at least one asynchronous request to a backend, etc. If you want to track progress of such a process, register a callback function beforehand using module:ApiInterfaceV1~ApiInterfaceV1#setProcessCallback, making use of the same token that you use when calling this function.
See:
Parameters:
Name Type Argument Default Description id
String | module:ApiInterfaceV1~ExportRequestObject The unique id or name of the export to be triggered
beSilent
Boolean <optional>
false If true, no messages about the export will be displayed to the user.
plugin
String <optional>
Optional plugin runtime id, will be ignored if a module:ApiInterfaceV1~ExportRequestObject is provided for id.
token
String <optional>
The token which identifies the process
Returns:
-
Type Description Boolean true if the export could be triggered
-
requestSceneUpdate()
-
Refresh the outputs of all active plugins by calling their set*ParameterValues function for the current values of their parameters
See:
Returns:
-
Type Description Boolean true if refresh process could be started successfully for all active plugins, false otherwise
-
resetCamera( [tween] [, duration])
-
Reset the camera to its default position.
This command will make the camera move smoothly to its default position.
See:
Parameters:
Name Type Argument Default Description tween
Boolean <optional>
true true: animate movement to new camera position, false: jump to new camera position
duration
Number <optional>
800 Duration of the movement in milliseconds
Returns:
-
Type Description Boolean true if reset of camera could be initiated
-
restrictCamera(component, blnMax, value)
-
Restricts camera movement in x, y or z direction.
Restricts the allowed movement of the camera a axis-parallel planes. As an example, you could prohibit the camera from moving below the xy-plane by setting a lower bound on the z-coordinate.
See:
Parameters:
Name Type Description component
Number 0 for restriction in the x-direction, 1 for y, 2 for z
blnMax
Boolean If true, the value is set as an upper bound, otherwise as a lower bound
value
Number The coordinate used as an upper or lower bound on camera movement
Returns:
-
Type Description Boolean true if the camera movement was successfully restricted
-
restrictPan(component, blnMax, value)
-
Defines upper and lower bounds for camera panning.
Prohibits the panning of the camera target beyond a given axis parallel plane
See:
Parameters:
Name Type Description component
Number 0 for restriction in the x-direction, 1 for y, 2 for z
blnMax
Boolean If true, the value is set as an upper bound, otherwise as a lower bound
value
Number The coordinate used as an upper or lower bound on panning
Returns:
-
Type Description Boolean true if panning was successfully restricted
-
restrictZoom(min, max)
-
Defines minimum and maximum distances for zooming.
Prohibits the camera position from moving too close or too far away from the target.
See:
Parameters:
Name Type Description min
Number Minimum distance for zooming
max
Number Maximum distance for zooming
Returns:
-
Type Description Boolean true if zooming was successfully restricted
-
setAutoRotate(speed)
-
Starts or stops autorotation of the camera around the object.
This command allows to activate autoration of the camera. Pass a boolean to activate/deactivate autorotation. Pass a number to set autorotation speed.
Parameters:
Name Type Description speed
Number | Boolean Speed to be used for autoration of the camera. Typical values between 0 and 10. Setting the speed to 0 or false stops autoration.
Returns:
-
Type Description Boolean true if autorotation was updated
-
-
setAutoRotation(speed)
-
Starts or stops autorotation of the camera around the object.
This command allows to activate autoration of the camera. Pass a boolean to activate/deactivate autorotation. Pass a number to set autorotation speed.
Parameters:
Name Type Description speed
Number | Boolean Speed to be used for autoration of the camera. Typical values between 0 and 10. Setting the speed to 0 or false stops autoration.
Returns:
-
Type Description Boolean true if autorotation was updated
-
-
setAutoRotationSpeed(speed)
-
Sets autorotation speed, use setAutoRotate instead to start/stop autorotation.
Alias for module:ApiInterfaceV1~ApiInterfaceV1#setAutoRotate
See:
Parameters:
Name Type Description speed
Number Speed to be used for autoration of the camera. Typical values between 0 and 10. Setting the speed to 0 stops autoration.
Returns:
-
Type Description Boolean true if autorotation speed could be updated
-
setBackgroundColor(color)
-
Set background color of 3D view.
See:
Parameters:
Name Type Description color
module:ApiInterfaceV2~Color The new background color including alpha, any format understood by this library can be used: https://www.npmjs.com/package/tinycolor2
Returns:
-
Type Description Boolean true if background color and alpha could be updated
-
setBumpAmplitude(bumpAmplitude)
-
Set how much the bump map affects the material. Typical values between 0 and 1. Default is 1.
Parameters:
Name Type Description bumpAmplitude
Number How much the bump map affects the material. Typical values between 0 and 1. Default is 1.
Returns:
-
Type Description Boolean true if bump amplitude could be updated
-
-
setBusyGraphic(url)
-
Set image to display while viewer is busy.
Parameters:
Name Type Description url
String The url of the image to display while the viewer is busy
-
setBusyGraphicPosition(position)
-
Set position of image to display while viewer is busy.
See:
Parameters:
Name Type Description position
String Only supported position: 'center'
-
setButtonColor(color)
-
Changes the color of buttons and toggles in the viewer.
Buttons and toggles in the parameter widget and the viewer will be changed to this color. The toggles will remain gray if unused, but will show the new color when hovered above or activated.
Parameters:
Name Type Description color
module:ApiInterfaceV1~Color The new color for buttons and toggles, any format understood by this library can be used: https://www.npmjs.com/package/tinycolor2
Returns:
-
Type Description Boolean true if color was changed successfully
-
-
setCamera(position, target [, tween] [, duration])
-
Move the camera to a new position.
This command will make the camera move smoothly to a new position.
See:
Parameters:
Name Type Argument Default Description position
module:ApiInterfaceV1~Point3d New 3d position of the camera.
target
module:ApiInterfaceV1~Point3d New 3d target of the camera.
tween
Boolean <optional>
true If true, the camera will move smoothly to the new position within the given duration. If false, the move will be instant.
duration
Number <optional>
800 Duration of the movement in milliseconds
Returns:
-
Type Description Boolean true on success
-
setCommandResultCallback(callback)
-
Allows to define a function to be called whenever a function of the API finishes.
Parameters:
Name Type Description callback
function Function to be called with the following parameters: command name, command result
-
setControlDamping(damping)
-
Sets the damping factor for camera rotation and panning.
Parameters:
Name Type Description damping
Number Damping factor between 0.05 and 0.25
Returns:
-
Type Description Boolean true on success
-
-
setDamping(damping)
-
Sets the damping factor for camera rotation and panning.
Alias for module:ApiInterfaceV1~ApiInterfaceV1#setControlDamping
See:
Parameters:
Name Type Description damping
Number Damping factor between 0.05 and 0.25
Returns:
-
Type Description Boolean true on success
-
setDefaultMaterialColor(color)
-
Set color of default material, used for geometry which does not have a material assigned.
Parameters:
Name Type Description color
module:ApiInterfaceV1~Color color of the default material
Returns:
-
Type Description Boolean true if default color could be updated
-
-
setEdgeColor(color [, force])
-
Define color of visible edges.
Define color for all visible edges. This color is only used if setEdgeColorByObject is set to false and showEdges is set to true.
See:
Parameters:
Name Type Argument Default Description color
module:ApiInterfaceV1~Color The new color used to render visible edges, any format understood by this library can be used: https://www.npmjs.com/package/tinycolor2
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true on success
-
setEdgeColorByObject(byObject [, force])
-
Define how visible edges are colored.
Configure how the color of visible edges is defined. If you set this to true, edges will be colored according to the main color of the object they correspond to. Otherwise, all visible edges will have the color set using setEdgeColor.
See:
Parameters:
Name Type Argument Default Description byObject
Boolean true if edges should be colored according to their parent object
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true on success
-
setExternalTexture(name, mapContainer)
-
Update the default texture images of a geometry output using externally defined texture images
See:
Parameters:
Name Type Description name
String Name of the geometry output for which default texture images shall be overridden
mapContainer
String | Object Object that holds texture image URLs (possibly data-uris) for the different map types. Possible members are 'color', 'alpha', 'bump', 'normal', 'metalness', 'roughness'. A single string can be provided for the color texture image as a fallback.
-
setFOV(angle)
-
Update the camera frustum vertical field of view angle
Parameters:
Name Type Description angle
Number camera frustum vertical field of view angle in degrees, typical values in range [20,50]
-
setIgnoreMouse(ignoreMouse [, force])
-
Ignore all mouse input to the viewer.
If set to true, all mouse input to the 3d viewer window will be ignored. This does not apply to the parameter widget, which will still function normally.
Parameters:
Name Type Argument Default Description ignoreMouse
Boolean true: ignore mouse input, false: enable mouse input
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true on success
-
-
setMessagingCallback(cb)
-
Set a callback function for being notified about the following events.
'CommPluginLoaded' - in general plugin.getShortName() + 'Loaded' - Whenever plugin enters status ACTIVE 'GeometryUpdateDone' - whenever sth new got published to the scene - message SCENE_SUBSCENE_PUBLISHED
See:
Parameters:
Name Type Description cb
function callback to invoke with parameter as described above
Returns:
-
Type Description Boolean true on success, false on error (e.g. if another callback was set before)
-
setParameterValue(id [, value])
-
Tells the viewer to update a given parameter to a new value.
Given the unique id of a parameter of the loaded model as well as a valid new value for this parameter, the viewer will update the model to reflect the new value. The viewer will check if the parameter id and value provided are valid based on its stored parameter information and respond accordingly once this check has been finished.
When calling functions like setParameterValue, which involve several asynchronous operations, the function's return value will only tell you about validity of the parameters which you used to invoke the function. The function will usually return before the process triggered by the function call gets finished. As an example, calling setParameterValue involves at least one asynchronous request to a backend, updating geometry in the 3D viewer, etc. If you want to track progress of such a process, register a callback function beforehand using module:ApiInterfaceV1~ApiInterfaceV1#setProcessCallback, making use of the same token that you use when calling this function.
See:
Parameters:
Name Type Argument Description id
String | module:ApiInterfaceV1~ParameterUpdateObject The unique id or name of the parameter which should be updated, or a module:ApiInterfaceV1~ParameterUpdateObject.
value
String | Number | Boolean <optional>
The new value of the parameter. Used as token in case id is a module:ApiInterfaceV1~ParameterUpdateObject.
Returns:
-
Type Description Boolean true if parameter id and value are valid, false otherwise.
-
setParameterValues(ids [, values])
-
Tells the viewer to update a number of given parameters to new values.
This function allows you to update several or even all parameter values while only causing a single geometry update operation. This might be useful to restore saved settings or if a complex logic requires changes to several parameters based on user input. Please see the setParameterValue command for more detailed info.
See:
Parameters:
Name Type Argument Description ids
Array.<String> | Array.<module:ApiInterfaceV1~ParameterUpdateObject> The unique ids or names of the parameters which should be updated, or an array of module:ApiInterfaceV1~ParameterUpdateObject.
values
Array.<(String|Number|Boolean)> <optional>
The new parameter values. Used as token in case id is an array of module:ApiInterfaceV1~ParameterUpdateObject.
Returns:
-
Type Description Boolean true if all parameter ids and values are valid, false otherwise.
-
setPointSize( [size])
-
Set the size used for displaying point objects
See:
Parameters:
Name Type Argument Default Description size
Number <optional>
1.0 size used for displaying point objects
Returns:
-
Type Description String true in case point size could be set, false on error
The token which identifies the process
callback
module:ApiInterfaceV1~ProcessCallback The callback to invoke for every message related to the given process token
Returns:
-
Type Description module:ApiInterfaceV1~ProcessCallbackToken subscription token which can be used for unsubscribing again, undefined in case of error
-
-
setRotateSpeed(speed)
-
Sets the rotation speed of the camera.
Sets the rotation speed of the camera when using the rotation control of the viewer. Not to be confused with setAutoRotate.
Parameters:
Name Type Description speed
Number Rotation speed, typical values between 0 and 10
Returns:
-
Type Description Boolean true on success
-
-
setRotationSpeed(speed)
-
Sets the rotation speed of the camera.
Alias for module:ApiInterfaceV1~ApiInterfaceV1#setRotateSpeed
See:
Parameters:
Name Type Description speed
Number Rotation speed, typical values between 0 and 10
Returns:
-
Type Description Boolean true on success
-
setToggleAmbientOcclusion(toggle)
-
Toggle ambient occlusion rendering setting.
Parameters:
Name Type Description toggle
Boolean True for turning ambient occlusion ON.
Returns:
-
Type Description Boolean true if ambient occlusion was successfully toggled, false if it wasn't changed
-
-
setToggleCastShadow(path, bCast)
-
Toggle shadow display for the specified object.
See:
Parameters:
Name Type Description path
string The path of the object in the scene in dot notation.
bCast
Boolean If true, shadows are toggled ON, otherwise they are toggled OFF.
Returns:
-
Type Description Boolean true if shadows were toggled successfully
-
setZoomExtentFactor(factor)
-
Sets the factor by which the bounding box of the scene is multiplied before zoom extent is called.
Parameters:
Name Type Description factor
Number Zoom extents factor, typical values between 1 and 5
Returns:
-
Type Description Boolean true on success
-
-
setZoomSpeed(speed)
-
Sets the zoom speed of the camera.
Sets the zoom speed of the camera when using the zoom control of the viewer.
Parameters:
Name Type Description speed
Number Zoom speed, typical values between 0 and 1
Returns:
-
Type Description Boolean true on success
-
-
showControls()
-
Shows the control panel and its toggle in the viewer.
This command activates the display of the control panel and the corresponding toggle in the viewer.
See:
Returns:
-
Type Description Boolean true if the control panel was shown
-
showEdges(show [, force])
-
Choose whether to display feature edges for all objects.
If set to true, lines are displayed to emphasize the objects' feature edges.
See:
Parameters:
Name Type Argument Default Description show
Boolean true: show feature edges, false: hide feature edges
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true if setting was changed, false if setting was already set to the chosen value
-
showFullscreenToggle()
-
Shows the full-screen toggle in the viewer.
See:
Returns:
-
Type Description Boolean true if full screen toggle was shown
-
showGrid( [show] [, force])
-
Choose whether to display the ground plane grid.
Parameters:
Name Type Argument Default Description show
Boolean <optional>
true true: show grid object, false: hide grid object
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true if setting was changed, false if setting was already set to the chosen value
-
-
showGroundPlane( [show] [, force])
-
Choose whether to display the ground plane.
Parameters:
Name Type Argument Default Description show
Boolean <optional>
true true: show ground plane object, false: hide ground plane object
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true if setting was changed, false if setting was already set to the chosen value
-
-
showShadows( [show] [, force])
-
Show or hide (enable or disable) the rendering of shadows.
See:
Parameters:
Name Type Argument Default Description show
Boolean <optional>
true true: enable the rendering of shadows, false: disable the rendering of shadows
force
Boolean <optional>
true true: override session settings, false: keep value that may have been defined in session settings
Returns:
-
Type Description Boolean true if setting was changed, false if setting was already set to the chosen value
-
showStaticMesh(id, show)
-
Show or hide a static mesh.
If set to true, lines are displayed to emphasize the objects' feature edges.
See:
Parameters:
Name Type Description id
String The unique id used to reference the loaded mesh
show
Boolean true: show the static mesh, false: hide the static mesh
Returns:
-
Type Description Boolean true if the mesh was found and its visibility changed, false otherwise
-
showZoomToggle()
-
Shows the zoom toggle in the viewer.
See:
Returns:
-
Type Description Boolean true if zoom toggle was shown
-
toggleDisablePan()
-
Toggle between panning enabled and disabled.
See:
Returns:
-
Type Description Boolean true if panning toggle was successfully changed
-
toggleDisableZoom()
-
Toggle between zooming enabled and disabled.
See:
Returns:
-
Type Description Boolean true if zooming toggle was successfully changed
-
toggleFullscreen( [show])
-
Switch the viewer between fullscreen and normal mode.
See:
Parameters:
Name Type Argument Description show
Boolean <optional>
if no value is provided, switch back and forth between fullscreen and normal mode
Returns:
-
Type Description Boolean true if setting was changed, false if setting was already set to the chosen value
-
toggleSceneBackground( [show])
-
Choose whether the environment map is shown in the background.
See:
Parameters:
Name Type Argument Default Description show
Boolean <optional>
true true: show environment map in background, false: hide environment map
Returns:
-
Type Description Boolean true if setting was changed successfully, false otherwise
-
toggleShadows()
-
Toggle between shadows enabled and disabled.
See:
Returns:
-
Type Description Boolean true if shadow toggle was successfully changed
-
toggleTopView()
-
Toggle between top view enabled and disabled.
See:
Returns:
-
Type Description Boolean true if top view toggle was successfully changed
-
zoomExt( [tween])
-
Zoom to extents of model.
This command will make the camera move smoothly to the extents of the model.
See:
Parameters:
Name Type Argument Default Description tween
Boolean <optional>
true true: animate movement to new camera position, false: jump to new camera position
-
zoomExtents( [tween] [, duration])
-
Zoom to extents of model.
This command will make the camera move smoothly to the extents of the model.
See:
Parameters:
Name Type Argument Default Description tween
Boolean <optional>
true true: animate movement to new camera position, false: jump to new camera position
duration
Number <optional>
800 Duration of the movement in milliseconds
Members
-
<readonly> STATUSCODE :module:ApiInterfaceV1~ViewerStatusCode
-
Enum for reporting viewer state.
Type:
Properties:
Name Type Default Description READY
module:ApiInterfaceV1~ViewerStatusCode 0 Viewer is fully loaded, geometry is being displayed, waiting for next request.
BUSY
module:ApiInterfaceV1~ViewerStatusCode 1 Updated geometry is currently being loaded from server. This may be because of a parameter update or because the initial geometry is still being loaded.
INITIALIZING
module:ApiInterfaceV1~ViewerStatusCode 2 Viewer, or at least one plugin, are still initializing.
ERROR
module:ApiInterfaceV1~ViewerStatusCode 3 There has been a fatal error, the viewer must be reloaded. Error information is included as a message string.
-
<readonly> TYPE :module:ApiInterfaceV1~ParameterType
-
Enum for parameter type.
Type:
Properties:
Name Type Default Description FLOAT
module:ApiInterfaceV1~ParameterType Float floating point number
INT
module:ApiInterfaceV1~ParameterType Int integer number
EVEN
module:ApiInterfaceV1~ParameterType Even even integer number
ODD
module:ApiInterfaceV1~ParameterType Odd odd integer number
STRING
module:ApiInterfaceV1~ParameterType String string with maximum length
COLOR
module:ApiInterfaceV1~ParameterType Color color string, including opacity (10 digits, e.g. 0xffffffaa)
STRINGLIST
module:ApiInterfaceV1~ParameterType StringList choose from a list of strings
BOOL
module:ApiInterfaceV1~ParameterType Bool boolean
TIME
module:ApiInterfaceV1~ParameterType Time date / time
-
<readonly> VISUALIZATION :module:ApiInterfaceV1~ParameterVisualization
-
Enum for parameter visualization.
Type:
Properties:
Name Type Default Description SLIDER
module:ApiInterfaceV1~ParameterVisualization slider currently the only choice for numeric types (Float, Int, Even, Odd)
SEQUENCE
module:ApiInterfaceV1~ParameterVisualization sequence for type StringList
CYCLE
module:ApiInterfaceV1~ParameterVisualization cycle for type StringList
DROPDOWN
module:ApiInterfaceV1~ParameterVisualization dropdown for type StringList
CHECKLIST
module:ApiInterfaceV1~ParameterVisualization checklist for type StringList
CLOCK
module:ApiInterfaceV1~ParameterVisualization clock for type Time
CALENDAR
module:ApiInterfaceV1~ParameterVisualization calendar for type Time