Request

Response

    UI

    Autodesk.Viewing.GuiViewer3D

    Extends Viewer3D

    new GuiViewer3D(container,config)

    Viewer component based on Viewer3D with added UI.

    Parameters

    container*
    HTMLElement
    The viewer container.
    config*
    object
    The initial settings object. See base class for details.
    * Required

    Methods

    activateLayerState(stateName)

    Changes the active layer state. Get a list of all available layerStates and their active status through getLayerStates.

    Parameters

    stateName*
    string
    Name of the layer state to activate.
    * Required

    addPanel(panel)

    Adds a panel to the viewer. The panel will be moved and resized if the viewer is resized and the panel falls outside of the bounds of the viewer.

    Parameters

    panel*The panel to add.
    * Required

    Returns

    TypeDescription
    boolean True if panel was successfully added.

    anyLayerHidden()

    Inherits anyLayerHidden

    Returns true if any layer is hidden.

    Not yet implemented for 3D.

    Returns

    TypeDescription
    boolean true if any layer is hidden

    applyCamera(camera,fit)

    Inherits applyCamera

    Parameters

    camera*
    THREE.Camera
    the camera to apply.
    fit
    boolean
    Do a fit to view after transition.
    * Required

    areAllVisible()

    Inherits areAllVisible

    Returns true if every node is visible.

    Returns

    TypeDescription
    boolean

    clearSelection()

    Inherits clearSelection

    Clears the selection.

    clearThemingColors(model)

    Restore original colors for all themed shapes.

    Parameters

    model
    Autodesk.Viewing.RenderModel
    For multi-model support.

    clientToWorld(clientX,clientY,ignoreTransparent)

    Inherits clientToWorld

    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().

    Parameters

    clientX*
    Number
    X coordinate where 0 is left
    clientY*
    Number
    Y coordinate where 0 is top
    ignoreTransparent
    Boolean
    Ignores transparent materials
    * Required

    Returns

    TypeDescription
    Object|null contains point attribute. 3d models have additional attributes.

    createViewCube()

    Inherits createViewCube

    Create ViewCube.

    displayViewCube(display)

    Inherits displayViewCube

    Display ViewCube.

    Parameters

    display*
    boolean
    Display or hide the ViewCube.
    * Required

    displayViewCubeUI(display)

    Display ViewCube.

    Parameters

    display*
    boolean
    Display or hide the ViewCube with home and info buttons.
    * Required

    explode(scale)

    Inherits explode

    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.
    * Required

    finish()

    Inherits finish

    Unloads any loaded extensions and then uninitializes the viewer.

    fitToView(objectIds,model)

    Inherits fitToView

    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. To enqueue a fitToView() operation, use viewer.getObjectTree()’s callback(s).

    Parameters

    objectIds
    array|int
    array of Ids, or null.
    model
    model
    The model containing the objectIds.

    getActiveNavigationTool()

    Returns the name of the active navigation tool.

    Returns

    TypeDescription
    string
    • The tool’s name.

    See

    • setActiveNavigationTool()

    getAggregateSelection(callback)

    Returns the selected items from all loaded models.

    Parameters

    callback
    function
    Optional callback to receive enumerated pairs of model and dbId for each selected object. If no callback is given, an array of objects is returned.

    Returns

    TypeDescription
    Array.<object> An array of objects with a model and selectionSet properties for each model that has selected items in the scene.

    getBimWalkToolPopup()

    Returns the state of First Person Walk tool popup

    Not applicable to 2D.

    Returns

    TypeDescription
    boolean value is indicating whether first person tool popup is showed or not

    getCamera()

    Inherits getCamera

    Gets the camera so it can be modified by the client.

    Returns

    TypeDescription
    THREE.Camera The active camera.

    getClickConfig(what,where)

    Inherits getClickConfig

    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”).
    * Required

    Returns

    TypeDescription
    array action list for the given entry or null if not found.

    getCutPlanes()

    Inherits getCutPlanes

    Returns a list of active cut planes

    Not applicable to 2D

    Returns

    TypeDescription
    Array.<THREE.Vector4> List of Vector4 plane representation {x:a, y:b, z:c, w:d}

    getDefaultNavigationToolName()

    Returns the default navigation tool

    Returns

    TypeDescription
    Object
    • The default navigation tool.

    getDimensions()

    Inherits getDimensions

    Returns

    TypeDescription
    object Client rectangle bounds.

    getExplodeScale()

    Inherits getExplodeScale

    Returns the explode scale.

    Not applicable to 2D.

    Returns

    TypeDescription
    number
    • A value from 0.0-1.0 indicating how exploded the model is.

    getFirstPersonToolPopup()

    Returns the state of First Person Walk tool popup

    Not applicable to 2D.

    Returns

    TypeDescription
    boolean true if the First Person Walk tool popup appears, false if it does not appear

    getFocalLength()

    Inherits getFocalLength

    Gets the current camera focal length.

    Returns

    TypeDescription
    number
    • the focal length in millimetres.

    getFOV()

    Inherits getFOV

    Gets the current camera vertical field of view.

    Returns

    TypeDescription
    number
    • the field of view in degrees.

    getHiddenModels()

    Inherits getHiddenModels

    Returns

    TypeDescription
    Array.<RenderModel> Returns RenderModel[]

    getHiddenNodes()

    Inherits getHiddenNodes

    Returns an array of the IDs of the currently hidden nodes. When isolation is in place, there are no hidden nodes returned because all nodes that are not isolated are considered hidden.

    Returns

    TypeDescription
    array Array of nodes that are currently hidden, when no isolation is in place.

    getIsolatedNodes()

    Returns an array of the IDs of the currently isolated nodes.

    Not yet implemented for 2D.

    Returns

    TypeDescription
    array Array of nodes that are currently isolated.

    getLayerStates()

    Inherits getLayerStates

    Returns information for each layer state: name, description, active. Activate a state through activateLayerState.

    Returns

    TypeDescription
    array

    getMemoryInfo()

    Inherits getMemoryInfo

    Get the memory stats when using on demand loading.

    Returns

    TypeDescription
    object|null Object containing the total limit and total loaded memory usage for all models. Return null if no model is being loaded on demand.

    getNavigationLock()

    Gets the current state of the navigation lock.

    Returns

    TypeDescription
    boolean True if the navigation controls are currently locked.

    getNavigationLockSettings()

    Gets the current configuration of the navigation lock.

    Returns

    TypeDescription
    object Map of : pairs specifying whether the given action is enabled even when the navigation is locked.

    getObjectTree(onSuccessCallback,onErrorCallback)

    Inherits getObjectTree

    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
    function
    Call this callback once the object tree is loaded.
    onErrorCallback
    function
    Call this callback if the object tree is not found.

    getProperties(dbid,onSuccessCallback,onErrorCallback)

    Inherits getProperties

    Gets the properties for an ID. Once the properties are returned, the method raises a onPropertiesReady event.

    Parameters

    dbid*
    number
    onSuccessCallback
    function
    Call this callback once the properties are found.
    onErrorCallback
    function
    Call this callback if the properties are not found, or another error occurs.
    * Required

    getScreenShot(w,h,cb)

    Inherits getScreenShot

    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. See also getScreenShotBuffer().

    Parameters

    w
    int
    width of the requested image
    h
    int
    height of the requested image
    cb
    function
    callback

    Returns

    TypeDescription
    DOMString screenshot image Blob URL, if no parameters are given

    getScreenShotBuffer(w,h,cb)

    Alternative call to getScreenShot() which internally uses additional steps (more processing) to generate the screenshot.

    Parameters

    w
    int
    width of the requested image
    h
    int
    height of the requested image
    cb
    function
    callback

    getSelection()

    Inherits getSelection

    Returns the current selection.

    Returns

    TypeDescription
    array.<number> Array of the IDs of the currently selected nodes.

    getSelectionCount()

    Returns the number of nodes in the current selection.

    Returns

    TypeDescription
    number Returns the number of nodes in the current selection.

    getSelectionVisibility()

    Returns information about the visibility of the current selection.

    Returns

    TypeDescription
    object {hasVisible:boolean, hasHidden:boolean}

    getState(filter)

    Inherits getState

    Gets the view state as a plain object.

    Parameters

    filter
    object
    Specifies which viewer values to get.

    Returns

    TypeDescription
    object Viewer state.

    getToolbar(create)

    Returns a toolbar.

    Parameters

    create*
    boolean
    If true and the toolbar does not exist, it will be created.
    * Required

    Returns

    TypeDescription
    ToolBar Returns the toolbar.

    hide(node)

    Inherits hide

    Ensures the passed in dbid / ids are hidden.

    Parameters

    node*
    array.<number>|number
    * Required

    hideById(nodeId)

    Inherits hideById

    Parameters

    nodeId*
    number
    * Required

    hideLines(hide)

    Inherits hideLines

    Hides all lines in the scene.

    Parameters

    hide*
    boolean
    * Required

    hideModel(modelId)

    Inherits hideModel

    Temporarily remove a model from the Viewer, but keep loaders, materials, and geometry alive.

    Parameters

    modelId*
    * Required

    Returns

    TypeDescription
    boolean true indicates success, i.e., modelId referred to a visible model that is now hidden

    hidePoints(hide)

    Inherits hidePoints

    Hides all points in the scene.

    Parameters

    hide*
    boolean
    * Required

    initialize()

    Inherits initialize

    Create any DOM and canvas elements, and setup WebGL.

    Returns

    TypeDescription
    number 0 if initialization was successful, Autodesk.Viewing.ErrorCode otherwise.

    initSettings()

    Inherits initSettings

    Initializes all gui settings to their defaults or to the session stored setting This gives session stored settings priority

    isLayerVisible(node)

    Inherits isLayerVisible

    Returns true if the layer is visible.

    Not yet implemented for 3D.

    Parameters

    node*
    Object
    Layer node
    * Required

    Returns

    TypeDescription
    boolean true if the layer is visible

    isNodeVisible(nodeId,model)

    Inherits isNodeVisible

    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.
    modelThe model that contains the specified nodeId.
    * Required

    Returns

    TypeDescription
    boolean

    isolate(node)

    Inherits isolate

    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 BaseViewer#getObjectTree.
    * Required

    isolateById(dbids)

    Inherits isolateById

    Parameters

    dbids*
    array|number
    Either an array or a single integer.
    * Required

    joinLiveReview(sessionId)

    Inherits joinLiveReview

    Join a live review session.

    Parameters

    sessionId
    string
    The live review session id to join.

    leaveLiveReview()

    Inherits leaveLiveReview

    Leave a live review session.

    load(svfURN,sharedPropertyDbPath,onSuccessCallback,onErrorCallback,loadOptions)

    Inherits load

    Parameters

    svfURN*
    string
    The URN or filepath to load.
    sharedPropertyDbPath
    string
    Optional path to shared property database.
    onSuccessCallback
    function
    Method that gets called when initial loading is done and streaming starts.
    onErrorCallback
    function
    Method that gets called when initial loading ends with an error.
    loadOptions
    object
    Optional load options passed to the model loader.
    * Required

    loadModel(url,options,onSuccessCallback,onErrorCallback)

    Inherits loadModel

    Loads a model into the viewer.

    Parameters

    Expand all
    url*
    string
    The url to the model.
    options
    object
    An optional dictionary of options.
    fileLoaderThe file loader to use for this url.
    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.
    onSuccessCallback
    function
    A method that gets called when initial loading is done and streaming starts.
    onErrorCallback
    function
    A method that gets called when loading fails.
    * Required

    localize()

    Inherits localize

    Localize the viewer. This method can be overwritten so that the subclasses can localize any additional elements.

    modelHasTopology()

    Expose if the model has topology information downloaded. Only applicable to 3D models.

    Returns

    TypeDescription
    boolean value - Indicates whether the model has topology information.

    playAnimation(callback)

    Inherits playAnimation

    Play animation if animation data is available as part of model data. If the model data does not contain any animation, this function call is a no op.

    Parameters

    callback
    function
    Callback function that would be invoked at each frame of the animation. The callback function takes a single input value, with value range between 0 and 100, inclusive, with value 100 indicates the animation has finished playing.

    Examples

    Here is an example of callback function.
    function(value) {
        if (value < 100)
            console.log("Animation progress: " + value + "%.");
        else
            console.log("Animation finished.");
    }
    

    registerContextMenuCallback(id,callback)

    Registers a new callback that modifies the context menu. This allows extensions and others to add, remove, or change items in the context menu. Extensions that call registerContextMenuCallback() should call unregisterContextMenuCallback() in their unload().

    Parameters

    id*
    string
    Unique id to identify this callback. Used by unregisterContextMenuCallback().
    callback*
    function
    Will be called before the context menu is displayed.
    * Required

    Examples

    // Here's an example that appends a new context menu item:
    
    viewer.registerContextMenuCallback('MyExtensionName', function (menu, status) {
        if (status.hasSelected) {
            menu.push({
                title: 'My new context menu item with selected objects',
                target: function () {
                    alert('Do something with selected objects');
            });
        } else {
            menu.push({
                title: 'My new context menu item, no selected objects',
                target: function () {
                    alert('Do something else');
            });
        }
    });
    
    Show More

    See

    • Viewer.unregisterContextMenuCallback
    • ObjectContextMenu.buildMenu

    removePanel(panel)

    Removes a panel from the viewer. The panel will no longer be moved and resized if the viewer is resized.

    Parameters

    panel*The panel to remove.
    * Required

    Returns

    TypeDescription
    boolean True if panel was successfully removed.

    resize()

    Inherits resize

    Resizes the viewer.

    resizePanels(options)

    Resizes the panels currently held by the viewer.

    Parameters

    Expand all
    options
    object
    An optional dictionary of options.
    dockingPanels
    array
    A list of panels to resize.
    viewer
    object
    The viewer to use, specify if this method is being used as a callback.
    dimensions
    object
    The area for the panels to occupy.
    width*
    number
    Width.
    height*
    number
    Height.
    * Required

    restoreState(viewerState,filter,immediate)

    Inherits restoreState

    Restores the viewer state from a given object.

    Parameters

    viewerState*
    Object
    filter
    Object
    Similar in structure to viewerState used to filter out values that should not be restored.
    immediate
    boolean
    Whether the new view is applied with (true) or without transition (false).
    * Required

    Returns

    TypeDescription
    boolean True if restore operation was successful.

    search(text,onSuccessCallback,onErrorCallback,attributeNames)

    Inherits search

    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*
    function
    The callback to invoke when search is complete.
    onErrorCallback*
    function
    The callback to invoke when search is complete.
    attributeNames
    Array.<string>
    Restricts search to specific attribute names.
    * Required

    select(dbids,selectionType)

    Inherits select

    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
    You can pass an array of IDs or just a single ID.
    selectionType*
    number
    a member of Autodesk.Viewing.SelectionMode.
    * Required

    setActiveNavigationTool(toolName)

    Swaps the current navigation tool for the tool with the provided name. Will trigger NAVIGATION_MODE_CHANGED event if the mode actually changes.

    Parameters

    toolName
    string
    The name of the tool to activate. By default it will switch to the default tool.

    Returns

    TypeDescription
    boolean
    • True if the tool was set successfully. False otherwise.

    See

    • getActiveNavigationTool()

    setBackgroundColor(red,green,blue,red2,green2,blue2)

    Sets the background color.

    Parameters

    red*
    number
    green*
    number
    blue*
    number
    red2*
    number
    green2*
    number
    blue2*
    number
    * Required

    setBimWalkToolPopup(value)

    Toggles the bimwalk tool popup.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether first person tool popup is showed or not.
    * Required

    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.
    * Required

    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
    
    Show More

    setClickConfig(what,where,newAction)

    Inherits setClickConfig

    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”).
    * Required

    Returns

    TypeDescription
    boolean False if specified entry is not found, otherwise true.

    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.
    * Required

    setContextMenu(contextMenu)

    Inherits setContextMenu

    Sets the object context menu.

    Parameters

    contextMenu
    ObjectContextMenu

    setCutPlanes(planes)

    Inherits setCutPlanes

    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 zero Passing an empty list or null is equivalent to setting zero cut planes
    * Required

    setDefaultContextMenu()

    Activates the default context menu. Contains options Isolate, Hide selected, Show all objects, Focus and Clear selection.

    Returns

    TypeDescription
    boolean Whether the default context menu was successfully set (true) or not (false)

    setDefaultNavigationTool(toolName)

    Sets the default navigation tool. This tool will always sit beneath the navigation tool on the tool stack.

    Parameters

    toolName*
    string
    The name of the new default navigation tool.
    * Required

    setDisplayEdges(show)

    Inherits setDisplayEdges

    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
    * Required

    setEnvMapBackground(value)

    Toggles environment map for background.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether environment map for background is on or off.
    * Required

    setFirstPersonToolPopup(value)

    Toggles first person tool popup.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether first person tool popup is showed or not.
    * Required

    setFocalLength(mm)

    Inherits setFocalLength

    Sets the current cameras focal length.

    Parameters

    mm*
    number
    Focal length in millimetres
    * Required

    setFOV(degrees)

    Inherits setFOV

    Sets the current cameras vertical field of view.

    Parameters

    degrees*
    number
    Field of view in degrees.
    * Required

    setGhosting(value)

    Inherits setGhosting

    Toggles ghosting during search and isolate.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether ghosting is on or off.
    * Required

    setGroundReflection(value)

    Toggles ground reflection.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether reflection is on or off.
    * Required

    setGroundReflectionAlpha(alpha)

    If enabled, set ground reflection alpha. This is reset to default when reflections toggled off.

    Not applicable to 2D

    Parameters

    alpha*
    float
    * Required

    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
    * Required

    setGroundShadow(value)

    Inherits setGroundShadow

    Toggles ground shadow.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    Indicates whether shadow is on or off.
    * Required

    setGroundShadowAlpha(alpha)

    If enabled, set ground shadow alpha

    Not applicable to 2D

    Parameters

    alpha*
    float
    * Required

    setGroundShadowColor(color)

    If enabled, set ground shadow color

    Not applicable to 2D

    Parameters

    color*
    THREE.Color
    * Required

    setLayersPanel(layersPanel)

    Sets the layers panel for display 2d layers.

    Not yet implemented for 3D.

    Parameters

    layersPanel*The layers panel to use, or null.
    * Required

    Returns

    TypeDescription
    boolean True if the panel or null was set successfully, and false otherwise.

    setLayerVisible(nodes,visible,isolate)

    Inherits setLayerVisible

    Set visibility for a single layer, or for all layers.

    Not yet implemented for 3D.

    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
    * Required

    setLightPreset(index)

    Inherits setLightPreset

    Sets the Light Presets (Environments) for the Viewer.

    Not applicable to 2D.

    Sets the preference in the UI

    Parameters

    index*
    Number
    where
    • 0 Simple Grey
    • 1 Sharp Highlights
    • 2 Dark Sky
    • 3 Grey Room
    • 4 Photo Booth
    • 5 Tranquility
    • 6 Infinity Pool
    • 7 Simple White
    • 8 Riverbank
    • 9 Contrast
    • 10 Rim Highlights
    • 11 Cool Light
    • 12 Warm Light
    • 13 Soft Light
    • 14 Grid Light
    • 15 Plaza
    • 16 Snow Field
    * Required

    setModelStructurePanel(modelStructurePanel)

    Sets the model structure panel for displaying the loaded model.

    Parameters

    modelStructurePanel*The model structure panel to use, or null.
    * Required

    Returns

    TypeDescription
    boolean True if the panel, or null, was set successfully; false otherwise.

    setModelUnits(Model)

    Inherits setModelUnits

    Set model units

    Parameters

    Model*
    units
    * Required

    setNavigationLock(value)

    Locks or unlocks navigation controls.

    When navigation is locked, certain operations (for example, orbit, pan, or fit-to-view) are disabled.

    Parameters

    value*
    boolean
    True if the navigation should be locked.
    * Required

    See

    setNavigationLockSettings(settings)

    Updates the configuration of the navigation lock, i.e., which actions are available when navigation is locked.

    The configurable actions are ‘orbit’, ‘pan’, ‘zoom’, ‘roll’, ‘fov’, ‘walk’, or ‘gotoview’. By default, none of the actions are enabled when the navigation is locked.

    Parameters

    settings*
    object
    Map of : pairs specifying whether the given action is enabled even when the navigation is locked.
    * Required

    See

    setOptimizeNavigation(value)

    Toggles whether the navigation should be optimized for performance. If set to true, anti-aliasing and ambient shadows will be off while navigating.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    whether it is on or off
    * Required

    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.
    * Required

    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
    * Required

    setPropertyPanel(propertyPanel)

    Sets the property panel.

    Parameters

    propertyPanel*The property panel to use, or null.
    * Required

    Returns

    TypeDescription
    boolean True if the panel or null was set successfully, and false otherwise.

    setQualityLevel(useSAO,useFXAA)

    Inherits setQualityLevel

    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.
    * Required

    setRenderCache(value)

    Inherits setRenderCache

    Toggles the rendercache feature.

    Not applicable to 2D.

    Parameters

    value*
    boolean
    true if render cache is active, false if render cache is not active.
    * Required

    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
    * Required

    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
    * Required

    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
    * Required

    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.
    * Required

    Examples

    viewer.setSelectionColor(new THREE.Color(0xFF0000), Autodesk.Viewing.SelectionMode.MIXED); // red color
    

    setSelectionMode()

    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.

    setSettingsPanel(settingsPanel)

    Sets the viewer’s settings panel.

    Parameters

    settingsPanel*The settings panel to use, or null.
    * Required

    Returns

    TypeDescription
    boolean True if the panel or null was set successfully, and false otherwise.

    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
    * Required

    setThemingColor(dbId,color,model)

    Inherits setThemingColor

    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.RenderModel
    For multi-model support.
    * Required

    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.
    * Required

    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.)
    * Required

    setViewCube(face)

    Inherits setViewCube

    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/rig ht]".
    * Required

    setViewFromArray(params)

    Sets the view from an array of parameters.

    Parameters

    params*
    array
    View parameters:
    • position-x
    • position-y
    • position-z
    • target-x
    • target-y
    • target-z
    • up-x
    • up-y
    • up-z
    • aspect
    • fov (radians)
    • orthoScale
    • isPerspective (0=perspective, 1=ortho)
    * Required

    setViewFromFile()

    Inherits setViewFromFile

    Sets the view using the default view in the source file.

    setViewFromViewBox(viewbox,name)

    Sets the view from an array representing a view box.

    Not applicable to 3D.

    Parameters

    viewbox*
    array
    View parameters:
    • min-x
    • min-y
    • max-x
    • max-y
    name
    string
    Optional named view name to also set the layer visibility state associated with this view.
    * Required

    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
    * Required

    show(node)

    Inherits show

    Ensures the passed in dbid / ids are shown.

    Parameters

    node*
    Array.<number>|number
    * Required

    showAll()

    Inherits showAll

    Ensures everything is visible. Clears all node isolation (3D) and turns on all layers (2D).

    showModel(modelId)

    Inherits showModel

    Make a previously hidden model visible again.

    Parameters

    modelId*
    * Required

    Returns

    TypeDescription
    boolean true indicates success, i.e., modelId referred to a hidden model that is now visible

    start(url,options,onSuccessCallback,onErrorCallback)

    Inherits start

    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
    function
    Method that gets called when initial loading is done and streaming starts.
    onErrorCallback
    function
    Method that gets called when initial loading ends with an error.

    Returns

    TypeDescription
    number 0 if the viewer has started, an error code (same as that returned by initialize()) otherwise.

    toggleSelect(dbid,selectionType)

    Inherits toggleSelect

    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 OVERLAYED 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
    selectionType*
    number
    a member of Autodesk.Viewing.SelectionMode.
    * Required

    toggleVisibility(node)

    Toggles the visibility of the given node.

    Not yet implemented for 2D.

    Parameters

    node*
    number
    * Required

    trackADPSettingsOptions()

    ADP

    transferModel()

    Inherits transferModel

    Transfer model from this viewer to another one - including state of selection, ghosting, and theming.

    uninitialize()

    Inherits uninitialize

    Removes all created DOM elements and performs any GL uninitialization that is needed.

    unregisterContextMenuCallback(id)

    Unregisters an existing callback that modifies the context menu. Extensions that call registerContextMenuCallback() should call unregisterContextMenuCallback() in their unload().

    Parameters

    id*
    string
    Unique id to identify this callback.
    * Required

    Returns

    TypeDescription
    boolean true if the callback was unregistered successfully.

    See

    • Viewer.registerContextMenuCallback

    updateToolbarButtons()

    Changes visibility of buttons in toolbar to accommodate as many as possible given the available space. Think of it as a media query applied to the viewer canvas only (as opposed to the whole website).

    worldToClient(point)

    Inherits worldToClient

    Calculates the pixel position in client space coordinates of a point in world space. See also clientToWorld().

    Parameters

    point*
    THREE.Vector3
    Point in world space coordinates.
    * Required

    Returns

    TypeDescription
    THREE.Vector3 Point transformed and projected into client space coordinates. Z value is 0.

    Events

    AGGREGATE_SELECTION_CHANGED_EVENT

    Fired when the list of selected objects changes in a multi-model context.

    Properties

    selections
    Array.<object>
    List of objects containing the typical selection properties of Autodesk.Viewing.Viewer3D#SELECTION_CHANGED_EVENT for each model.

    ANIMATION_READY_EVENT

    Fired when animations are successfully initialized.

    CAMERA_CHANGE_EVENT

    Fired when a camera changes.

    Properties

    camera
    object
    Affected camera.

    CUTPLANES_CHANGE_EVENT

    Fired when the cutting planes change.

    Properties

    planes
    Array.<object>
    List of cutplanes.

    ESCAPE_EVENT

    Fired when the ESC key is pressed.

    EXPLODE_CHANGE_EVENT

    Fired whenever the Explode tool is used.

    Properties

    scale
    number
    Scale of the current exploded state.

    EXTENSION_LOADED_EVENT

    Fired when a viewer extension is successfully loaded.

    Properties

    extensionId
    string
    Extension identifier.

    EXTENSION_UNLOADED_EVENT

    Fired when a viewer extension is successfully unloaded.

    Properties

    extensionId
    string
    Extension identifier.

    FINAL_FRAME_RENDERED_CHANGED_EVENT

    Fired when the render frame shown by the Viewer is final or complete (it has no more pending geometry or post processing effects which delay incoming frames), or when the Viewer stops showing final frames.

    Properties

    planes
    array.<object>
    List of cut planes.

    FIT_TO_VIEW_EVENT

    Fired when a fitToView operation is applied.

    Properties

    immediate
    boolean
    True if the change was immediate.
    nodeIdArray
    array.<number>
    List of node IDs fitted. Array is empty when fitting to the whole model.
    model
    object
    Model data.

    FRAGMENTS_LOADED_EVENT

    Fired when fragments are loaded on demand

    Properties

    model
    Model
    The model that loaded the fragment
    getFragIds
    function
    A function used to return the list of fragment ids loaded
    data
    Object
    Data used to generate the fragment ids

    FULLSCREEN_MODE_EVENT

    Fired when the screen mode changes.

    Properties

    mode
    Autodesk.Viewing.ScreenMode
    New screen mode.

    GEOMETRY_LOADED_EVENT

    Fired when the model/drawing finishes loading.

    Properties

    model
    object
    Model data.

    HIDE_EVENT

    Fired when the viewer hides a set of objects.

    Properties

    nodeIdArray
    array.<number>
    List of hidden node IDs.
    model
    object
    Model data.

    ISOLATE_EVENT

    Fired when the viewer isolates a set of objects (i.e., makes everything else invisible or ghosted).

    Properties

    nodeIdArray
    array.<number>
    List of isolated node IDs.
    model
    object
    Model data.

    LAYER_VISIBILITY_CHANGED_EVENT

    Fired when visibility of a 2D layer changes.

    LOAD_MISSING_GEOMETRY

    Fired when something in the view changes that may expose missing geometry.

    Properties

    delay
    boolean
    A flag used to aggregate multiple events during user interactions. Defaults to true.

    MODEL_ROOT_LOADED_EVENT

    Fired when the viewer receives and parses the initial model manifest.

    Properties

    svf
    object
    Parsed SVF/F2D JSON.
    model
    object
    Model data.

    MODEL_UNLOADED_EVENT

    Fired when a model is removed from the viewer.

    Properties

    model
    object
    Model data.

    OBJECT_TREE_CREATED_EVENT

    Fired when the instance tree is successfully created.

    Properties

    svf
    object
    Parsed SVF/F2D JSON.
    model
    object
    Model data.

    OBJECT_TREE_UNAVAILABLE_EVENT

    Fired when there’s an error while parsing the instance tree.

    Properties

    svf
    object
    Parsed SVF/F2D JSON.
    model
    object
    Model data.

    PREF_CHANGED_EVENT

    Fired when a user preference property changes.

    Properties

    name
    string
    Property name.
    value
    object
    New property value.

    PREF_RESET_EVENT

    Fired when a user preference property is reset.

    Properties

    name
    string
    Property name.
    value
    object
    New property value.

    PROGRESS_UPDATE_EVENT

    Fired repeatedly throughout the process of opening a model/drawing.

    Properties

    percent
    number
    Estimated progress.
    state
    number
    Value from Autodesk.Viewing.ProgressState, providing details on the progress state.

    RENDER_OPTION_CHANGED_EVENT

    Fired when rendering options change.

    RENDER_PRESENTED_EVENT

    Fired when the render has presented to the screen.

    RESET_EVENT

    Fired when a model is reset to its initial configuration.

    RESTORE_DEFAULT_SETTINGS_EVENT

    Fired when the user clicks on the UI for restoring default settings. Will get fired after all other Autodesk.Viewing.PREF_CHANGED_EVENT get fired.

    SELECTION_CHANGED_EVENT

    Fired when the list of selected objects changes.

    Properties

    fragIdsArray
    array.<number>
    Fragment IDs of selected objects.
    dbIdArray
    array.<number>
    dbIDs of selected objects.
    nodeArray
    array.<number>
    Same as dbIdArray.
    model
    object
    Model data.

    SHOW_EVENT

    Fired when the viewer shows a set of objects.

    Properties

    nodeIdArray
    array.<number>
    List of shown node IDs.
    model
    object
    Model data.

    TEXTURES_LOADED_EVENT

    Fired when the model/drawing textures finish loading.

    Properties

    model
    object
    Model data.

    TOOL_CHANGE_EVENT

    Fired when a tool is activated or deactivated.

    Properties

    toolName
    string
    Name of a specific mode of a tool.
    tool
    object
    Tool object.
    active
    bool
    Current status of the tool.

    VIEWER_INITIALIZED

    Fired when the viewer is fully initialized.

    VIEWER_RESIZE_EVENT

    Fired when the viewer size changes.

    Properties

    width
    number
    New width of the viewer.
    height
    number
    New height of the viewer.

    VIEWER_STATE_RESTORED_EVENT

    Fired when the viewer state is restored.

    Properties

    value
    bool
    Success of the state restoration.

    VIEWER_UNINITIALIZED

    Fired when the viewer is fully uninitialized.