@inweb/viewer-visualize
    Preparing search index...

    Class Viewer

    3D viewer powered by VisualizeJS library.

    Hierarchy

    Implements

    Index

    Constructors

    • Parameters

      • Optionalclient: Client

        The Client instance that is used to load model reference files from the Open Cloud Server. Do not specify Client if you need a standalone viewer instance to view VSFX files from the web or from local computer.

      • params: {
            crossOrigin?: string;
            enableAutoUpdate?: boolean;
            markupType?: MarkupType;
            visualizeJsUrl?: string;
        } = {}

        An object containing viewer configuration parameters.

        • OptionalcrossOrigin?: string

          The crossorigin content attribute on Visalize.js script element. One of the following values: "", anonymous or use-credentials.

        • OptionalenableAutoUpdate?: boolean

          Enable auto-update of the viewer after any changes. If the auto-update is disabled, you need to register an update event handler and update the VisualizeJS viewer and active dragger manually. Default is true.

        • OptionalmarkupType?: MarkupType

          The type of the markup core: Visualize (deprecated) or Konva. Default is Konva.

        • OptionalvisualizeJsUrl?: string

          VisualizeJS library URL. Set this URL to use your own library instance, or specify undefined or blank to use the default URL defined by Viewer.visualize library you are using.

      Returns Viewer

    Properties

    canvas: HTMLCanvasElement

    HTMLCanvasElement for the viewer used to operate on. Defined only while the viewer is initialized.

    canvasEvents: string[]

    List of canvas events, such as mouse events or pointer events or touch events that the viewer should listen and redirect to the draggers and components.

    By default, the following events are redirected:

    • click
    • contextmenu
    • dblclick
    • mousedown
    • mouseleave
    • mousemove
    • mouseup
    • pointercancel
    • pointerdown
    • pointerleave
    • pointermove
    • pointerup
    • touchcancel
    • touchend
    • touchmove
    • touchstart
    • wheel
    client: Client

    The Client instance that is used to load model reference files from the Open Cloud Server.

    Accessors

    • get components(): string[]

      List of names of available components.

      Returns string[]

    • get draggers(): string[]

      List of names of available draggers.

      The following draggers are available by default:

      • Pan
      • Orbit
      • Zoom
      • MeasureLine
      • CuttingPlaneXAxis
      • CuttingPlaneYAxis
      • CuttingPlaneZAxis
      • Walk

      For a quick reference on how to implement your own dragger, see IDragger.

      Returns string[]

    • get markup(): IMarkup

      2D markup core instance used to create markups.

      Returns IMarkup

    • get visualizeJs(): any

      Returns VisualizeJS module instance.

      Returns any

    • get visualizeJsUrl(): string

      VisualizeJS library URL. Use configure() to change library URL.

      Returns string

    Methods

    • Registers a new listener for the event type.

      Type Parameters

      • T extends (keyof ViewerEventMap) | (keyof CanvasEventMap) | "optionschange"

      Parameters

      Returns this

    • Adds an empty Visualize markup entity to the overlay.

      Parameters

      • entityName: string

      Returns any

    • Cancels asynchronous file loading started by open().

      Fires:

      Returns this

    • Unloads an open file, clears the canvas and markups, deactivates the active dragger.

      Fires:

      Returns this

    • Clears the overlay view.

      Returns void

    • Removes all cutting planes.

      Returns void

    • Deprecated since 25.11. Use markup.colorizeAllMarkup() instead.

      Parameters

      • r: number = 255
      • g: number = 0
      • b: number = 0

      Returns void

    • Deprecated since 25.11. Use markup.colorizeSelectedMarkups() instead.

      Parameters

      • r: number = 255
      • g: number = 0
      • b: number = 0

      Returns void

    • Changes the viewer parameters.

      Parameters

      • params: { crossOrigin?: string; visualizeJsUrl?: string }

        An object containing new parameters.

        • OptionalcrossOrigin?: string

          The crossorigin content attribute on Visalize.js script element. One of the following values: "", anonymous or use-credentials.

        • OptionalvisualizeJsUrl?: string

          VisualizeJS library URL. Set this URL to use your own library instance or specify undefined or blank to use the default URL defined by Viewer.visualize library you are using.

      Returns this

    • Saves the viewer state at the viewpoint.

      To save a viewpoint to the server for a specific file, use the File.saveViewpoint().

      Returns IViewpoint

    • Unloads an open file, clears the canvas and markups, and releases resources allocated by this viewer instance. Call this method before release the Viewer instance.

      Returns this

    • Sets the viewer state to the specified viewpoint.

      To get a list of available viewpoints from the server for a specific file, use the File.getViewpoints().

      Parameters

      Returns void

    • Fires the event. Alias to emitEvent().

      Parameters

      • type: string | object

        The type of event that gets fired.

      • ...args: any[]

        The event properties.

      Returns boolean

    • Fires the event. Calls each of the listeners registered for the event type event.type, in the order they were registered.

      Type Parameters

      • T extends (keyof ViewerEventMap) | (keyof CanvasEventMap) | "optionschange"

      Parameters

      Returns boolean

    • Executes the command denoted by the given command. If the command is not found, tries to set active dragger with the specified name.

      The following commands are available by default:

      • applyModelTransform
      • autoTransformAllModelsToCentralPoint
      • clearMarkup
      • clearSelected
      • clearSlices
      • createPreview
      • explode
      • getDefaultViewPositions
      • getModels
      • getSelected
      • hideSelected
      • isolateSelected
      • regenerateAll
      • resetView
      • selectModel
      • setActiveDragger
      • setDefaultViewPosition
      • setMarkupColor
      • setSelected
      • showAll
      • zoomToExtents
      • zoomToObjects
      • zoomToSelected

      To register custom command use the commands.registerCommand.

      Parameters

      • id: string

        Command ID or dragger name.

      • ...args: any[]

        Parameters passed to the command handler function.

      Returns any

      Returns the result of the command handler function or new active dragger instance. Returns undefined if neither the command nor the dragger exists.

    • Breaks the model into its component objects. To collect objects back use index 0.

      Fires:

      Parameters

      • index: number = 0

        Explode index. Range is 0 to 100.

      Returns void

    • Returns the component reference, or null if there is no component with the specified name.

      Parameters

      • name: string

      Returns IComponent

    • Deprecated since 25.11. Use markup.getMarkupColor() instead.

      Returns { b: number; g: number; r: number }

    • Returns the scaling factors for each axis in world space.

      Returns { x: number; y: number; z: number }

    • Returns a list of original handles for the selected objects.

      Returns string[]

    • Loads the VisualizeJS module and initializes it with the specified canvas. Call dispose() to release allocated resources.

      Fires:

      Parameters

      • canvas: HTMLCanvasElement

        HTMLCanvasElement for VisualizeJS.

      • OptionalonProgress: (event: ProgressEvent) => void

        A callback function that handles events measuring progress of loading of the VisualizeJS library.

      Returns Promise<Viewer>

    • Returns true if current opened model is 3D model.

      Returns boolean

    • Returns true if VisualizeJS module has been loaded and initialized.

      Returns boolean

    • Removes the listener from an event type. Alias to removeEventListener().

      Parameters

      • type: string

        The type of the event that gets removed.

      • listener: (event: any) => void

        The listener function that gets removed.

      Returns this

    • Registers a new listener for the event type. Alias to addEventListener()

      Parameters

      • type: string

        The type of event to listen to.

      • listener: (event: any) => void

        The function that gets called when the event is fired.

      Returns this

    • Loads a file from Open Cloud Server into the viewer.

      The file geometry data on the server must be converted to VSFX format.

      To open a large file, enable partial streaming mode before opening (see example below).

      This method requires a Client instance to be specified when creating the viewer to load model reference files from the Open Cloud Server. For a standalone viewer instance use openVsfFile() or openVsfxFile().

      If there was an active dragger before opening the file, it will be deactivated. After opening the file, you must manually activate the required dragger.

      Fires:

      Parameters

      • file: Model | File | Assembly

        File, assembly or specific model to load. If a File instance with multiple models is specified, the default model will be loaded. If there is no default model, first availiable model will be loaded.

      Returns Promise<Viewer>

      viewer.options.enableStreamingMode = true;
      viewer.options.enablePartialMode = true;
      await viewer.open(file);
    • Loads a VSF file into the viewer.

      This method does not support streaming or partial streaming mode.

      If there was an active dragger before opening the file, it will be deactivated. After opening the file, you must manually activate the required dragger.

      Fires:

      Parameters

      • buffer: ArrayBuffer | Uint8Array<ArrayBufferLike>

        Binary data buffer to load.

      Returns this

    • Loads a VSFX file into the viewer.

      This method does not support streaming or partial streaming mode.

      If there was an active dragger before opening the file, it will be deactivated. After opening the file, you must manually activate the required dragger.

      Fires:

      Parameters

      • buffer: ArrayBuffer | Uint8Array<ArrayBufferLike>

        Binary data buffer to load.

      Returns this

    • Deprecated since 25.12. Use draggers.registerDragger instead.

      Parameters

      • name: string
      • dragger: typeof Dragger

      Returns void

    • If type is specified, removes all registered listeners for type, otherwise removes all registered listeners.

      Type Parameters

      • T extends (keyof ViewerEventMap) | (keyof CanvasEventMap) | "optionschange"

      Parameters

      • Optionaltype: T

        The type of the listener that gets removed.

      Returns this

    • Removes the listener for the event type.

      Type Parameters

      • T extends (keyof ViewerEventMap) | (keyof CanvasEventMap) | "optionschange"

      Parameters

      Returns this

    • Transforms position from screen space into world space.

      Parameters

      • position: { x: number; y: number }

        Screen position in pixels.

      Returns { x: number; y: number; z: number }

    • Changes the active dragger. The viewer must be initialized before activating the dragger, otherwise an exception will be thrown.

      Fires:

      Parameters

      • name: string = ""

        Dragger name. Can be one of the draggers list or an ampty string to deactivate the current dragger.

      Returns IDragger

      Returns the new active dragger reference or null if there is no dragger with the given name.

    • Deprecated since 25.11. Use markup.setMarkupColor() instead.

      Parameters

      • r: number = 255
      • g: number = 0
      • b: number = 0

      Returns void

    • Selects the objects by original handles.

      Fires:

      Parameters

      • Optionalhandles: string[]

        The list of original handles.

      Returns void

    • Creates an overlay view. Overlay view is used to draw cutting planes and markups.

      Returns void

    • Updates the viewer.

      Do nothing if the auto-update mode is disabled in the constructor. In this case, register an update event handler and update the Visualize viewer and active dragger manually.

      Fires:

      Parameters

      • force: boolean = false

        If true updates the viewer immidietly. Otherwise updates on next animation frame. Default is false.

      Returns void

    • Updates the viewer asynchronously without locking the user interface. Used to update the viewer after changes that require a long rendering time.

      Do nothing if the auto-update mode is disabled in the constructor. In this case, register an update event handler and update the VisualizeJS viewer and active dragger manually.

      Fires:

      Parameters

      • maxScheduleUpdateTimeInMs: number = 50

        Maximum time for one update, default 30 ms.

      • maxScheduleUpdateCount: number = 50

        Maximum count of scheduled updates.

      Returns Promise<void>

    • Returns VisualizeJS module instance.

      Returns any

    • Returns VisualizeJS Viewer instance.

      Returns any

    • Transforms position from world space into screen space.

      Parameters

      • position: { x: number; y: number; z: number }

        Position in world space coordinates.

      Returns { x: number; y: number }