Request

Response

    Autodesk.Viewing.Extensions.Snapping
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    Snapper

    new Snapper(viewer, options)

    A tool that lets users attach pointer events to vertices and edges. It supports 2D and 3D models.

    Parameters

    viewer*Viewer instance
    options*
    object
    Configurations for the extension
    * Required

    Methods

    isActive()

    Returns

    typedescription
    boolean true when the tool is active

    activate()

    Starts intercepting pointer events. Invoked automatically by the ToolController.

    deactivate()

    Stops intercepting pointer events. Invoked automatically by the ToolController.

    getSnapResult()

    Returns

    typedescription
    SnapResult The snapping status of the last pointer event performed.

    isSnapped()

    Checks whether the tool’s last update resulted on a snap.

    Returns

    typedescription
    boolean true when the last pointer event got snapped.

    snapping3D(result)

    3D Snapping

    Parameters

    result*
    Result of Hit Test.
    * Required

    extractLineGeometry(edge, geometry)

    Get Edge geometry for the case that the hittest result contained a 3D lines. For this case, we have no Face3, so that faceSnapping and edgeSnapping don’t work.

    Parameters

    edge*
    Object
    {a, b} with vertex indices a,b of lineStart/lineEnd vertex
    geometry*
    GeometryBuffer
    * Required

    Returns

    typedescription
    THREE.Geometry, THREE.BufferGeometry Geometry with simple line

    faceIsCurved(face)

    Checks if the given geometry is curved

    Parameters

    face*
    THREE.BufferGeometry
    The geometry
    * Required

    Returns

    typedescription
    boolean True if the any of the faces composing the geometry is curved

    snapping2D(hitResult, options)

    Snap to a 2D model.

    Parameters

    Expand all
    hitResult*
    object
    a result of a ray intersection.
    options
    object
    Options object.
    enumSegments
    function
    Enumerates all segments within a given bbox in model-space.
    * Required