Request

Response

    Autodesk.Viewing

    Methods

    setCamera(camera)

    Set or unset the current camera used for navigation. Normally set via the constructor.

    Parameters

    camera*the current camera object.
    * Required

    getCamera()

    Returns

    typedescription
    Camera
    • the current camera object.

    setScreenViewport(viewport)

    Set the current canvas viewport in screen coordinates. Invoked internally on canvas resize.

    Parameters

    viewport*
    object
    Rectangle with properties left, top, width, height.
    * Required

    getScreenViewport()

    Get the current canvas viewport in screen coordinates.

    Returns

    typedescription
    object with properties left, top, width, height.

    setView(from, to, up)

    Sets the current view to the given LookAt, while keeping other camera properties as is. Jumps to the new location, without camera path animation.

    Parameters

    from*The desired camera position in world space.
    to*The desired camera target in world space.
    upThe desired camera up direction in world space.
    * Required

    orientCameraUp(force)

    Orient the camera’s up direction with the current world up direction

    Parameters

    force*
    boolean
    if true, will orient camera up direction regardless of navigation lock
    * Required

    getPivotPoint()

    Returns

    typedescription
    Vector3 the world space position of the pivot point for orbit navigation.

    setPivotPoint(pivot)

    Sets the Vector3 world space position of the pivot point for orbit navigation.

    Parameters

    pivot*the new pivot position.
    * Required

    getPosition()

    Returns

    typedescription
    Vector3 the world space position of the camera.

    setPosition(pos)

    Sets the Vector3 world space position of camera.

    Parameters

    pos*the new camera position.
    * Required

    setTarget(target)

    Sets the Vector3 world space position towards which the camera should be pointing.

    Parameters

    target*the new camera look at point.
    * Required

    getTarget()

    Returns

    typedescription
    Vector3 the world space position towards which the camera is pointing.

    getEyeVector()

    Get the current camera view vector. This vector is not normalized and its length is the distance between the camera position and the camera look at point.

    Returns

    typedescription
    Vector3 the current camera view vector in world space.

    getEyeToCenterOfBoundsVec(bounds)

    Get a vector from the camera location to the center of the input bounding box.

    Parameters

    bounds*Bounding box.
    * Required

    Returns

    typedescription
    Vector3
    • The vector from the camera location to the center of the input bounds.

    getFovMin()

    Returns

    typedescription
    number the minimum allowed vertical field of view in degrees.

    getFovMax()

    Returns

    typedescription
    number the maximum allowed vertical field of view in degrees.

    setZoomInLimitFactor(factor)

    Limits zoom in to show 1/factor-th of the entire 2D page. Applies only on 2D vectorized models.

    Parameters

    factor*
    number
    * Required

    getZoomInLimitFactor()

    Returns

    typedescription
    number the current limit when zooming into 2D vectorized models.

    setZoomOutLimitFactor(factor)

    Limits zoom out to a multiplier of the model’s bounding box dimensions. Applies only on 2D vectorized models.

    Parameters

    factor*
    number
    * Required

    getZoomOutLimitFactor()

    Returns

    typedescription
    number the current limit when zooming out 2D vectorized models.

    isPointVisible(point)

    Returns true if the point is visible.

    Parameters

    point*The point in world coordinates.
    * Required

    Returns

    typedescription
    boolean
    • True if the point is within the camera’s frustum.

    setVerticalFov(fov, adjustPosition)

    Set the current vertical field of view.

    Parameters

    fov*
    number
    the new field of view in degrees (value is clamped to the minimum and maximum field of view values).
    adjustPosition*
    boolean
    If true, the camera position will be modified to keep either the world space area of the view at the pivot point unchanged (if it is set and visible) or the world space area of view at the camera look at point unchanged.
    * Required

    applyRotation(point, angle, pivot, viewVec)

    Applies a rotation on a single point

    Parameters

    point*Point to rotate
    angle*
    number
    Angle of rotation (in radians)
    pivot*Pivot of rotation
    viewVec*Front vector
    * Required

    getSignedAngle(v1, v2, viewVec)

    Computes a signed angle between two vectors

    Parameters

    v1*Vector #1
    v2*Vector #2
    viewVec*Front vector
    * Required

    Returns

    typedescription
    number Signed angle between two vectors

    computeFit(oldpos, oldcoi, fov, bounds, aspect)

    Compute camera position and look at point which will fit the given bounding box in the view frustum at the given field of view angle.

    Parameters

    oldpos*existing camera position
    oldcoi*existing camera look at point
    fov*
    number
    field of view (in degrees) to use for fit calculation in degrees
    bounds*bounding box to fit
    aspect*
    number
    optional aspect ratio of window, horizontal/vertical
    * Required

    Returns

    typedescription
    object Object with properties “position” and “target”.

    computeOrthogonalUp(pos, coi)

    Compute a vector which is orthogonal to the given view and aligned with the world up direction.

    Parameters

    pos*view position
    coi*center of interest (view look at point)
    * Required

    Returns

    typedescription
    Vector3 up direction orthogonal to the given view

    fitBounds(immediate, bounds, reorient, force)

    Causes the current camera position to be changed in order to fit the given bounds into the current view frustum.

    Parameters

    immediate*
    boolean
    if false the camera position will animate to the new location.
    bounds*bounding box to fit
    reorient*
    boolean
    if true the camera up direction will be reoriented with the world up.
    force*
    boolean
    if true will perform regardless of gotoview enabled or not.
    * Required

    Returns

    typedescription
    object Object with properties “position” and “target”.

    updateCamera()

    Update the current camera projection matrix and orient the camera to the current look at point. Invoked internally prior to rendering a new frame with the current camera.

    setConstraints2D(viewRegion, maxPixelPerUnit)

    Applies zooming and panning restrictions when viewing 2D models. Invoke without parameters to clear any previous setting.

    Parameters

    viewRegionin world space. If specified, navigation is restricted so that this region always spans >= half of the screen extent in x and y.
    maxPixelPerUnit
    number
    Restrict zoom-In, so that a single unit in world-space never exceeds maxPixelPerUnit on screen.