Viewer3D
new Viewer3D(container, config)
Base class for all viewer implementations. It contains everything that is needed to connect to the Autodesk’s Forge service and display 2D and 3D models. It also includes basic navigation support, context menu and extension APIs.
Parameters
container* HTMLElement | The viewer container. |
config* ViewerConfig | The initial settings object. |
startOnInitialize boolean | Set this to false if you want to defer the run to a later timeby calling run() explicitly. |
theme string | Set this to ‘light-theme’ if you want to use the light ui theme. Themes canbe changed during execution by calling setTheme() and passing the theme’s name. |
Methods
loadExtension(extensionId, options)
Loads the extension with the given id and options. For internal use only.
Parameters
extensionId* string | The string id of the extension. |
options* Object | An optional dictionary of options. |
Returns
type | description |
---|---|
Promise | Resolves with the extension requested. |
getExtension(extensionId)
Returns the loaded extension.
Parameters
extensionId* string | The string id of the extension. |
Returns
type | description |
---|---|
Object | Extension. |
unloadExtension(extensionId)
Unloads the extension with the given id. For internal use only.
Parameters
extensionId* string | The string id of the extension. |
Returns
type | description |
---|---|
boolean | True if the extension was successfully unloaded. |
loadExtensionLocal(extensionId, options)
Loads the extension with the given id and options. For internal use only.
Available from version 2.15
Parameters
extensionId* string | The string id of the extension. |
options* Object | An optional dictionary of options. |
Returns
type | description |
---|---|
Promise | Resolves with the extension requested. |
loadExtensionAsync(extensionId, url, options)
Loads an extension JavaScript file from a URL. It will download the file, parse it and then invoke loadExtension(). Calling this function a second time will not download the file again.
Available from version 2.15
Parameters
extensionId* string | The string id of the extension. |
url* string | The url where the extension’s JavaScript file is hosted. Can be a relative or absolute path. |
options* Object | An optional dictionary of options, same as in loadExtension(). |
Returns
type | description |
---|---|
promise | That resolves with the extension object. |
Examples
viewer.loadExtensionAsync(
'MyExtensionId',
'http://my.site.com/path/MyExtension.js',
{}
).then(function(ext){
ext.doSomething();
}).catch(function(error){
console.error(error);
});
start(url, options, onSuccessCallback, onErrorCallback)
Initializes the viewer and loads any extensions specified in the constructor’s config parameter. If the optional parameters are specified, the start() function will use an optimized initialization sequence that results in faster model load. The parameters are the same as the ones for Viewer3D.loadModel and you do not need to call loadModel subsequently if the model is loaded via the call to start().
Parameters
url string | Optional URN or filepath to load on start. |
options string | Optional path to shared property database. |
onSuccessCallback Autodesk.Viewing.Viewer3D~onLoadModelSuccess | Method that gets called when initial loading is doneand streaming starts. |
onErrorCallback Autodesk.Viewing.Viewer3D~onLoadModelFailure | Method that gets called when initial loading ends with an error. |
Returns
type | description |
---|---|
number | 0 if the viewer has started, an error code (same as that returned by initialize()) otherwise. |
setUp(config)
Loading extensions and initializing canvas interactions. Invoked automatically by Autodesk.Viewing.Viewer3D#start method.
Parameters
config* ViewerConfig | configuration values |
tearDown()
Unloads extensions and the model loaded. Invoked automatically by Autodesk.Viewing.Viewer3D#finish method.
run()
Triggers the Viewer’s render loop. Invoked automatically by Autodesk.Viewing.Viewer3D#start method. Refer to [ViewerConfig.startOnInitialize]`ViewerConfig <#fixMe/>`_ to change start’s method behavior.
localize()
Localize the viewer. This method can be overwritten so that the subclasses can localize any additional elements. Invoked internally during initialization.
uninitialize()
Removes all created DOM elements and performs any GL uninitialization that is needed.
finish()
Unloads any loaded extensions and then uninitializes the viewer.
loadModel(url, options, onSuccessCallback, onErrorCallback)
Loads a model into the viewer. Can be used sequentially to load multiple 3D models into the same scene.
Parameters
url* string | The url to the model. |
options object | Dictionary of options. |
fileLoader Autodesk.Viewing.FileLoader | The file loader to use for this url. Required for unsupported file types. |
loadOptions object | May contain params that are specific for certain loaders/filetypes. |
sharedPropertyDbPath string | Optional path to shared property database. |
ids string | A list of object IDs to load. |
loadAsHidden bool | By default, a new model is instantly shown and triggers viewer refreshes during loading. Setting this option avoids that. The model can then be shown later by calling showModel(). |
modelNameOverride string | Allows host application to override model name used in UI. |
onSuccessCallback Autodesk.Viewing.Viewer3D~onLoadModelSuccess | A method that gets called when model’s metadata loading is doneand geometry streaming starts. |
onErrorCallback Autodesk.Viewing.Viewer3D~onLoadModelFailure | A method that gets called when loading fails. |
loadDocumentNode(avDocument, manifestNode, options)
Parameters
avDocument* Autodesk.Viewing.Document | The Document instance, which owns the model being loaded |
manifestNode* Autodesk.Viewing.BubbleNode | The specific manifest node to load (within the Document) |
options ViewerConfig | Options to pass to {@link Autodesk.Viewing.Viewer3D#loadModel}. Will be initialized internally if not specified. The options object will be augmented by automatically determined load parameters. |
getDimensions()
Returns the dimensions of the WebGL canvas.
Returns
type | description |
---|---|
object | Client rectangle bounds object { width:Number, height: Number } |
resize()
Resizes the viewer. Required when wrapping div changes dimensions due to CSS changes.
getHotkeyManager()
Returns
type | description |
---|---|
Autodesk.Viewing.HotkeyManager | The hotkey manager. |
getCamera()
Gets the camera so it can be modified by the client.
Returns
type | description |
---|---|
THREE.Camera | The active camera. |
getState(filter)
Gets the view state as a plain object. A viewer state contains data for the viewport, selection and isolation,
Parameters
filter object | Specifies which viewer values to get. |
Returns
type | description |
---|---|
object | Viewer state. |
restoreState(viewerState, filter, immediate)
Restores the viewer state from a given object.
Parameters
viewerState* Object | |
filter Object | Similar in structure to viewerState used to filter out valuesthat should not be restored. |
immediate boolean | Whether the new view is applied with (true) or without transition (false). |
Returns
type | description |
---|---|
boolean | True if restore operation was successful. |
setViewFromViewBox(viewbox, name, skipTransition)
Sets the view from an array representing a view box.
Not applicable to 3D.
Parameters
viewbox* Array.<Number> | View parameters:min-xmin-ymax-xmax-y |
name string | Optional named view name to also set the layer visibility stateassociated with this view. |
skipTransition boolean | true to apply instanstly instead of lerping. |
activateLayerState(stateName)
Changes the active layer state. Layes is a feature usually available on 2D models and some 3D models.
Parameters
stateName* string | Name of the layer state to activate. |
getLayerStates()
Returns information for each layer state: name, description, active. Activate a state through Autodesk.Viewing.Viewer3D#activateLayerState.
Returns
type | description |
---|---|
array |
setViewFromFile(model)
Sets the view using the default view in the source file.
Parameters
model Autodesk.Viewing.Model | The model, defaults to the loaded model. |
getProperties(dbid, onSuccessCallback, onErrorCallback)
Gets the properties for an ID.
Parameters
dbid* number | The database identifier. |
onSuccessCallback Callbacks#onPropertiesSuccess | Callback for when the properties are fetched. |
onErrorCallback Callbacks#onGenericError | Callback for when the properties are not found or another error occurs. |
getObjectTree(onSuccessCallback, onErrorCallback)
Gets the viewer model object tree. Once the tree is received it will invoke the specified callback function.
You can use the model object tree to get information about items in the model. The tree is made up of nodes, which correspond to model components such as assemblies or parts.
Parameters
onSuccessCallback Callbacks#onObjectTreeSuccess | Success callback invoked once the object tree is available. |
onErrorCallback Callbacks#onGenericError | Error callback invoked when the object tree is not found available. |
setCanvasClickBehavior(config)
Sets the click behavior on the canvas to follow config. This is used to change the behavior of events such as selection or COI changed.
Parameters
config* object | Parameter object that meets the above layout. |
Examples
{
"click": {
"onObject": [ACTIONS],
"offObject": [ACTIONS]
},
"clickCtrl": {
"onObject": [ACTIONS],
"offObject": [ACTIONS]
},
"clickShift": {
...
},
"clickCtrlShift": {
...
},
"disableSpinner": BOOLEAN
"disableMouseWheel": BOOLEAN,
"disableTwoFingerSwipe": BOOLEAN
}
Actions can be any of the following: - “selectOnly” - “selectToggle” - “deselectAll” - “isolate” - “showAll” - “setCOI” - “focus” - “hide”
search(text, onSuccessCallback, onErrorCallback, attributeNames)
Searches the elements for the given text. When the search is complete, the callback onResultsReturned(idArray) is invoked.
Parameters
text* string | The search term (not case sensitive). |
onSuccessCallback* Callbacks#onSearchSuccess | Invoked when the search results are ready. |
onErrorCallback* Callbacks#onGenericError | Invoke when an error occured during search. |
attributeNames Array.<string> | Restricts search to specific attribute names. |
getIsolatedNodes()
Returns an array of the IDs of the currently isolated nodes.
Not yet implemented for 2D.
Returns
type | description |
---|---|
Array.<number> | Array of nodes that are currently isolated. |
isolate(node, model)
Isolates one of many sub-elements. You can pass in a node or an array of nodes to isolate. Pass in null to reset isolation.
Parameters
node* Array.<number>, number | A node ID or array of node IDs from the model tree {@link BaseViewer#getObjectTree}. |
model Autodesk.Viewing.Model | the model that contains the node id. Defaults to the first loaded model. |
setBackgroundColor(red, green, blue, red2, green2, blue2)
Sets the background colors, which will be used to create a gradient. Values are in the range [0..255]
Parameters
red* number | |
green* number | |
blue* number | |
red2* number | |
green2* number | |
blue2* number |
toggleSelect(dbid, model, selectionType)
Toggles the selection for a given dbid. If it was unselected, it is selected. If it was selected, it is unselected.
Currently three ways of node selection are supported:
Autodesk.Viewing.SelectionMode.MIXED Leaf nodes are selected using the overlayed selection type, and inner nodes are selected using regular selection type.
Autodesk.Viewing.SelectionMode.REGULAR Nodes are tinted with the selection color.
Autodesk.Viewing.SelectionMode.OVERLAYED Nodes are tinted with the selection color and shown on top of the not selected geometry.
Not yet implemented for 2D.
Parameters
dbid* number | |
model Autodesk.Viewing.Model | the model that contains the dbId. Uses the initial model loaded by default. |
selectionType* number | a member of Autodesk.Viewing.SelectionMode. |
select(dbids, model, selectionType)
Selects the array of ids. You can also just pass in a single id instead of an array.
Currently three ways of node selection are supported:
Autodesk.Viewing.SelectionMode.MIXED Leaf nodes are selected using the overlayed selection type, and inner nodes are selected using regular selection type.
Autodesk.Viewing.SelectionMode.REGULAR Nodes are tinted with the selection color.
Autodesk.Viewing.SelectionMode.OVERLAYED Nodes are tinted with the selection color and shown on top of the not selected geometry.
Parameters
dbids* Array.<number>, number | element or array of elements to select. |
model Autodesk.Viewing.Model | the model instance containing the ids. |
selectionType* number | a member of Autodesk.Viewing.SelectionMode. |
clearSelection()
Clears the selection.
getSelectionVisibility()
Returns information about the visibility of the current selection.
Returns
type | description |
---|---|
object | {hasVisible:boolean, hasHidden:boolean} |
getSelectionCount()
Returns the number of nodes in the current selection.
Returns
type | description |
---|---|
number |
setSelectionMode(mode)
Sets selection granularity mode. Supported values are:
Autodesk.Viewing.SelectionMode.LEAF_OBJECT Always select the leaf objects in the hierarchy.
Autodesk.Viewing.SelectionMode.FIRST_OBJECT For a given node, selects the first non-composite (layer, collection, model) on the path from the root to the given node, and all children.
Autodesk.Viewing.SelectionMode.LAST_OBJECT For a given node, selects the nearest ancestor composite node and all children. Selects the input node itself in case there is no composite node in the path to the root node.
Parameters
mode* number | The selection mode. |
getSelection()
Returns the current selection.
Returns
type | description |
---|---|
Array.<number> | Array of the IDs of the currently selected nodes. |
getAggregateSelection(callback)
Returns the selected items from all loaded models.
Parameters
callback function | Optional callback to receive enumerated pairs of model and dbIdfor each selected object. If no callback is given, an array of objects is returned. |
Returns
type | description |
---|---|
Array.<object> | An array of objects with a model and selectionSet properties for each modelthat has selected items in the scene. |
getAggregateIsolation()
Returns the isolated items from all loaded models.
Returns
type | description |
---|---|
Array.<object> | An array of objects with a model and the isolated ids in that model. |
hide(node, model)
Ensures the passed in dbid / ids are hidden.
Parameters
node* Array.<number>, number | An array of dbids or just an id |
model Autodesk.Viewing.Model | The model that contains the dbId. By default uses the initial model loaded into the scene. |
show(node, model)
Ensures the passed in dbid / ids are shown.
Parameters
node* Array.<number>, number | |
model Autodesk.Viewing.Model | The model that contains the dbId. By default uses the initial model loaded into the scene. |
showAll()
Ensures everything is visible. Clears all node isolation (3D) and turns on all layers (2D).
toggleVisibility(dbId, model)
Toggles the visibility of the given node.
Not yet implemented for 2D.
Parameters
dbId* number | the object’s identifier. |
model Autodesk.Viewing.Model | the model that contains the dbId. By default uses the initial model loaded into the scene. |
areAllVisible()
Returns true if every node is visible.
Returns
type | description |
---|---|
boolean |
isNodeVisible(nodeId, model)
Returns true if the specified node is visible. The model argument is required only when in multi-model scenarios.
Parameters
nodeId* number | Geometry node to check if visible. |
model Autodesk.Viewing.Model | The model that contains the specified nodeId . |
Returns
type | description |
---|---|
boolean |
explode(scale)
Explodes the model from the center of gravity.
Not applicable to 2D.
Parameters
scale* number | A value from 0.0-1.0 to indicate how much to explode. |
getExplodeScale()
Returns the explode scale.
Not applicable to 2D.
Returns
type | description |
---|---|
number | A value from 0.0-1.0 indicating how exploded the model is. |
setQualityLevel(useSAO, useFXAA)
Enables or disables the high quality rendering settings.
Not applicable to 2D.
Parameters
useSAO* boolean | True or false to enable screen space ambient occlusion. |
useFXAA* boolean | True or false to enable fast approximate anti-aliasing. |
setGhosting(value)
Toggles ghosting during search and isolate.
Not applicable to 2D.
Parameters
value* boolean | Indicates whether ghosting is on or off. |
setGroundShadow(value)
Toggles ground shadow.
Not applicable to 2D.
Parameters
value* boolean | Indicates whether shadow is on or off. |
setGroundReflection(value)
Toggles ground reflection.
Not applicable to 2D.
Parameters
value* boolean | Indicates whether reflection is on or off. |
setEnvMapBackground(value)
Toggles environment map for background.
Not applicable to 2D.
Parameters
value* boolean | Indicates whether environment map for background is on or off. |
setProgressiveRendering(value)
Toggles whether progressive rendering is used. Warning: turning progressive rendering off will have serious performance implications.
Parameters
value* boolean | whether it is on or off |
setGrayscale(value)
Overrlides line colors in 2D models to render in shades of gray. Applies only to 2D models.
Parameters
value* boolean |
setSwapBlackAndWhite(value)
AutoCAD drawings are commonly displayed with white lines on a black background. Setting reverse swaps (just) these two colors.
Parameters
value* boolean | whether it is on or off |
getFOV()
Gets the current camera vertical field of view.
Returns
type | description |
---|---|
number | the field of view in degrees. |
setFOV(degrees)
Sets the current cameras vertical field of view.
Parameters
degrees* number | Field of view in degrees. |
getFocalLength()
Gets the current camera focal length.
Returns
type | description |
---|---|
number | the focal length in millimetres. |
setFocalLength(mm)
Sets the current cameras focal length.
Parameters
mm* number | Focal length in millimetres |
hideLines(hide)
Hides all lines in the scene.
Parameters
hide* boolean |
hidePoints(hide)
Hides all points in the scene.
Parameters
hide* boolean |
setDisplayEdges(show)
Turns edge topology display on/off (where available)
Parameters
show* boolean | true to turn edge topology display on, false to turn edge topology display off |
applyCamera(camera, fit)
Parameters
camera* THREE.Camera | the camera to apply. |
fit boolean | Do a fit to view after transition. |
fitToView(objectIds, model, immediate)
Fits camera to objects by ID. It fits the entire model if no ID is provided. Operation will fit to the model’s bounding box when its object tree is not available.
Parameters
objectIds Array.<number>, null | array of Ids to fit into the view. Avoid passing this value to fit the entire model. |
model Autodesk.Viewing.Model | The model containing the objectIds . |
immediate boolean | true to avoid the default transition. |
setClickConfig(what, where, newAction)
Modifies a click action configuration entry.
Parameters
what* string | which click config to modify (one of "click", "clickAlt", "clickCtrl", "clickShift", "clickCtrlShift"). |
where* string | hit location selector (one of "onObject", "offObject"). |
newAction* Array.<string> | action list (containing any of "setCOI", "selectOnly", "selectToggle", "deselectAll", "deselectAll", "isolate", "showAll", "hide", "focus"). |
Returns
type | description |
---|---|
boolean | False if specified entry is not found, otherwise true. |
getClickConfig(what, where)
Fetch a click action configuration entry.
Parameters
what* string | which click config to fetch (one of "click", "clickAlt", "clickCtrl", "clickShift", "clickCtrlShift"). |
where* string | hit location selector (one of "onObject", "offObject"). |
Returns
type | description |
---|---|
array | action list for the given entry or null if not found. |
setClickToSetCOI(state, updatePrefs)
Modify the default click behaviour for the viewer.
Parameters
state* boolean | If true the default is to set the center of interest. If false the default is single select. |
updatePrefs boolean | If true, the user preferences will be updated. |
setLightPreset(index)
Sets the Light Presets (Environments) for the Viewer.
Not applicable to 2D.
Sets the preference in the UI
Parameters
index* Number | where0 Simple Grey1 Sharp Highlights2 Dark Sky3 Grey Room4 Photo Booth5 Tranquility6 Infinity Pool7 Simple White8 Riverbank9 Contrast10 Rim Highlights11 Cool Light12 Warm Light13 Soft Light14 Grid Light15 Plaza16 Snow Field |
setUsePivotAlways(value)
Set or unset a view navigation option which requests that orbit controls always orbit around the currently set pivot point.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true to request use of the pivot point. When false some controls may pivot around the center of the view. (Currently applies only to the view-cube orbit controls.) |
setReverseZoomDirection(value)
Set or unset a view navigation option to reverse the default direction for camera dolly (zoom) operations.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true for reverse, false for default |
setReverseHorizontalLookDirection(value)
Set or unset a view navigation option to reverse the default direction for horizontal look operations.
Not applicable to 2D.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true for reverse, false for default |
setReverseVerticalLookDirection(value)
Set or unset a view navigation option to reverse the default direction for vertical look operations.
Not applicable to 2D.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true for reverse, false for default |
setZoomTowardsPivot(value)
Get the state of the view navigation option that requests the default direction for camera dolly (zoom) operations to be towards the camera pivot point.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true for towards the pivot, false for default |
setOrbitPastWorldPoles(value)
Set or unset a view navigation option to allow the orbit controls to move the camera beyond the north and south poles (world up/down direction). In other words, when set the orbit control will allow the camera to rotate into an upside down orientation. When unset orbit navigation should stop when the camera view direction reaches the up/down direction.
Not applicable to 2D.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true to allow orbiting past the poles. |
setUseLeftHandedInput(value)
Set or unset a view navigation option which requests that mouse buttons be reversed from their default assignment. i.e. Left mouse operation becomes right mouse and vice versa.
Sets the preference in the UI
Parameters
value* boolean | value of the option, true to request reversal of mouse button assignments. |
setLayerVisible(nodes, visible, isolate)
Set visibility for a single layer, or for all layers.
Parameters
nodes* Array | An array of layer nodes, or a single layer node, or null for all layers |
visible* boolean | true to show the layer, false to hide it |
isolate boolean | true to isolate the layer |
isLayerVisible(node)
Returns true if the layer is visible.
Parameters
node* Object | Layer node |
Returns
type | description |
---|---|
boolean | true if the layer is visible |
setGroundShadowColor(color)
If enabled, set ground shadow color
Not applicable to 2D
Parameters
color* THREE.Color |
setGroundShadowAlpha(alpha)
If enabled, set ground shadow alpha
Not applicable to 2D
Parameters
alpha* float |
setGroundReflectionColor(color)
If enabled, set ground reflection color. This is reset to default when reflections toggled off.
Not applicable to 2D
Parameters
color* THREE.Color |
setGroundReflectionAlpha(alpha)
If enabled, set ground reflection alpha. This is reset to default when reflections toggled off.
Not applicable to 2D
Parameters
alpha* float |
getCutPlanes()
Returns a list of active cut planes
Not applicable to 2D
Returns
type | description |
---|---|
Array.<THREE.Vector4> | List of Vector4 plane representation {x:a, y:b, z:c, w:d} |
setCutPlanes(planes)
Apply a list of cut planes
Not applicable to 2D
Parameters
planes* Array.<THREE.Vector4> | List of Vector4 plane representation: {x:a, y:b, z:c, w:d}Plane general equation: ax + by + cz + d = 0 where a, b, and c are not all zeroPassing an empty list or null is equivalent to setting zero cut planes |
getScreenShot(w, h, cb, overlayRenderer)
Captures the current screen image as Blob URL Blob URL can be used like a regular image url (e.g., window.open, img.src, etc) If width and height are 0, returns asynchronously and calls the callback with an image as Blob URL with dimensions equal to current canvas dimensions If width and height are given, returns asynchronously and calls the callback with the resized image as Blob URL If no callback is given, displays the image in a new window. Optional overlayRenderer can be supplied, in order to render an overlay on top of the renderer image.
Parameters
w number | width of the requested image |
h number | height of the requested image |
cb function | callback |
overlayRenderer function | overlayRenderer |
Returns
type | description |
---|---|
DOMString | screenshot image Blob URL, if no parameters are given |
worldToClient(point, camera)
Calculates the pixel position in client space coordinates of a point in world space.
See also [clientToWorld()]`Autodesk.Viewing.Viewer3D#clientToWorld </en/docs/viewer/v6/reference/Viewing/Viewer3D/#clientToWorld/>`_.
Parameters
point* THREE.Vector3 | Point in world space coordinates. |
camera* THREE.Camera | Optional camera to use - default is the viewer’s native camera. |
Returns
type | description |
---|---|
THREE.Vector3 | Point transformed and projected into client space coordinates. Z value is 0. |
clientToWorld(clientX, clientY, ignoreTransparent)
Given coordinates in pixel screen space it returns information of the underlying geometry node. Hidden nodes will not be taken into account. Returns null if there is no geometry in the specified location. For 2d models, it will return null outside the paper.
See also [worldToClient()]`Autodesk.Viewing.Viewer3D#worldToClient </en/docs/viewer/v6/reference/Viewing/Viewer3D/#worldToClient/>`_.
Parameters
clientX* Number | X coordinate where 0 is left |
clientY* Number | Y coordinate where 0 is top |
ignoreTransparent Boolean | Ignores transparent materials |
Returns
modelHasTopology()
Expose if the model has topology information downloaded. Only applicable to 3D models.
Returns
type | description |
---|---|
boolean | value - Indicates whether the model has topology information. |
setSelectionColor(color, selectionType)
Changes the color of the selection for a particular selection type.
Autodesk.Viewing.SelectionMode.MIXED Sets the same color for regular and overlayed selection.
Autodesk.Viewing.SelectionMode.REGULAR Sets the color of regular selection.
Autodesk.Viewing.SelectionMode.OVERLAYED Sets the color of overlayed selection.
Parameters
color* THREE.Color | |
selectionType* number | a member of Autodesk.Viewing.SelectionMode. |
Examples
viewer.setSelectionColor(new THREE.Color(0xFF0000), Autodesk.Viewing.SelectionMode.MIXED); // red color
set2dSelectionColor(color)
Changes the color of the selection for 2D drawings.
Parameters
color* THREE.Color |
Examples
viewer.set2dSelectionColor(new THREE.Color(0xFF0000)); // red color
getToolbarPromise()
Interface method for UI workflows, returns a Promise that is meant to resolve with the instance of the toolbar. Headless Viewer will always return a rejected Promise.
Returns
type | description |
---|---|
Promise |
displayViewCube(display)
Display ViewCube.
Parameters
display* boolean | Display or hide the ViewCube. |
displayViewCubeUI(display)
Display ViewCube UI, the buttons around it.
Parameters
display* boolean | Display or hide the ViewCube with home and info buttons. |
setViewCube(face)
Set the face of ViewCube and apply camera transformation according to it.
Parameters
face* string | The face name of ViewCube. The name can contain multiple face names,the format should be "[front/back], [top/bottom], [left/right]" . |
setTheme(name)
Sets the current UI theme of the viewer. Supported values are "light-theme" and "dark-theme", which is the default.
Parameters
name* string | Name of the theme, it will be added to the viewer’s container class list. |
setThemingColor(dbId, color, model, recursive)
Highlight an object with a theming color that is blended with the original object’s material.
Parameters
dbId* number | |
color* THREE.Vector4 | (r, g, b, intensity), all in [0,1]. |
model Autodesk.Viewing.Model | For multi-model support. |
recursive boolean | Should apply theming color recursively to all child nodes. |
clearThemingColors(model)
Restore original colors for all themed shapes.
Parameters
model Autodesk.Viewing.Model | For multi-model support. |
hideModel(modelId)
Temporarily remove a model from the Viewer, but keep loaders, materials, and geometry alive.
Parameters
modelId* |
Returns
type | description |
---|---|
boolean | true indicates success, i.e., modelId referred to a visible model that is now hidden |
showModel(modelId, preserveTools)
Make a previously hidden model visible again.
Parameters
modelId* | |
preserveTools* bool | disable automatic activation of default tool |
Returns
type | description |
---|---|
boolean | true indicates success, i.e., modelId referred to a hidden model that is now visible |
getVisibleModels()
Returns
type | description |
---|---|
Array.<Autodesk.Viewing.Model> |
disableHighlight()
Disables roll-over highlighting.
disableSelection(disable)
disable the selection of a loaded model.
Parameters
disable* boolean | true to disable selection, false to enable selection. |
isHighlightDisabled()
check if the mouse-over highlight is disabled or not
isHighlightPaused()
check if the mouse-over highlight is paused or not
isHighlightActive()
check if the mouse-over highlight is active or not
isSelectionDisabled()
check if the selection of the loaded model is disabled or not
activateExtension(extensionID, mode)
Activates the extension based on the extensionID and mode given. By default it takes the first available mode in getmodes();
Parameters
extensionID* string | The extension id. |
mode string |
deactivateExtension(extensionID)
Dectivates the extension based on the extensionID specified.
Parameters
extensionID* string |
isExtensionActive(extensionID, mode)
Check if the extension is active or not by passing the extensionID.
Parameters
extensionID* string | |
mode* string |
isExtensionLoaded(extensionID)
Check if the extension is loaded or not by passing the extensionID.
Parameters
extensionID* string |
getLoadedExtensions()
Get a list of all the extensions that are currently loaded.
Returns
type | description |
---|---|
Array.<string> |
getExtensionModes(extensionID)
Get a list of all the modes that are available for the given extensionID.
Parameters
extensionID* string |