Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Viewer

The Viewer manages the Views it contains and handles user interaction (navigation and picking).

A Viewer can have multiple Views. You can add a view with the addView. The Viewer owns and manages the View, and you delete the view by using the deleteViewAt function.

The Viewer handles the interaction with the user, both navigation (pan/rotate/zoom/walk) and selection/picking.

You can trigger a redraw of the 3D view(s) with the requestRedraw function.

Examples of the different highlight modes (See ViewerOptions.highlightMode)

alt text

Hierarchy

  • Viewer

Index

Accessors

Readonly pixelScaleFactor

pixelScaleFactor: number

The current pixel scale factor ( > 1 for 'retina'/'high-dpi') screen.

Readonly viewCount

viewCount: number

The number of views in the Viewer

Methods

addView

  • Adds a view to the viewer.

    This functions creates a view, adds it to the viewer and returns the newly created view.

    You need at least one view in a viewer in order to display a model.

    Returns View

deleteAllViews

  • deleteAllViews(): void
  • Deletes all views from the viewer.

    Returns void

deleteViewAt

  • deleteViewAt(viewIndex: number): void
  • Deletes the view at the given index.

    The index must be zero-based and between 0 and viewCount - 1

    Parameters

    • viewIndex: number

    Returns void

enableMouseButtonTracking

  • enableMouseButtonTracking(enable: boolean): void
  • Mouse tracking needs to be enabled to use the NavigationConfig.leftAndRightMouseButtons setting.

    However, for the mouse tracking to work, the browser context menu needs to be disabled.

    Here is one example on how to do this:

    // Disable context menu - Required for enableMouseButtonTracking
    canvas.addEventListener("contextmenu", (event) => { event.preventDefault()});
    
    // Enable mouse tracking (so we can use leftAndRightMouseButtons)
    viewer.enableMouseButtonTracking(true);
    
    // Ceetron style navigation
    const navConfig = view.navigation.config;
    navConfig.leftMouseButton.noModifier =cee.NavigationType.PAN;
    navConfig.rightMouseButton.noModifier =cee.NavigationType.ROTATE;
    navConfig.leftAndRightMouseButtons.noModifier =cee.NavigationType.WALK;
    navConfig.wheelOrPinch = cee.NavigationType.WALK;

    Parameters

    • enable: boolean

    Returns void

enableNavigationHandling

  • enableNavigationHandling(enable: boolean): void
  • Sets the handler function to be called whenever the mouse navigation type changes.

    Parameters

    • enable: boolean

    Returns void

flyCameraTo

  • flyCameraTo(cameraPos: Vec3, viewDir: Vec3, upVec: Vec3, fov: number, animDuration: number): void
  • Flies the camera from the current position to the specified new position

    Parameters

    • cameraPos: Vec3
    • viewDir: Vec3
    • upVec: Vec3
    • fov: number
    • animDuration: number

    Returns void

getViewArray

  • getViewArray(): ReadonlyArray<View>
  • Returns a read only array with all views in the viewer

    Returns ReadonlyArray<View>

getViewAt

  • getViewAt(viewIndex: number): View
  • Returns the view at the given index.

    The index must be zero-based and between 0 and viewCount - 1

    Parameters

    • viewIndex: number

    Returns View

rayFromMouseCoordinate

  • rayFromMouseCoordinate(view: View, clientX: number, clientY: number): Ray
  • Get a ray from the clientX and clientY coordinate (from e.g. a MouseEvent)

    Parameters

    • view: View
    • clientX: number
    • clientY: number

    Returns Ray

requestRedraw

  • requestRedraw(): void
  • Notifies that this viewer needs a redraw. This will schedule a redraw on the next timer event.

    Use this method to force a redraw if you have changed something that does not update the viewer. This is not usually needed.

    Returns void

resizeViewer

  • resizeViewer(canvasWidth: number, canvasHeight: number): void
  • Sets the size of the canvas. This should normally be set to the size of the associated HTMLCanvasElement.

    Parameters

    • canvasWidth: number
    • canvasHeight: number

    Returns void

rubberBandZoom

  • rubberBandZoom(view: View, clientX: number, clientY: number, width: number, height: number): void
  • Zooms in or out in the view by the given rubber band rectangle.

    clientX and clientY are the Top Left corner of the rectangle, specified in client coordinates (HTML window coordinates) (from e.g. a MouseEvent.clientX/Y)

    Parameters

    • view: View
    • clientX: number
    • clientY: number
    • width: number
    • height: number

    Returns void

setActiveMouseNavigationsChangedHandler

  • Sets the handler function to be called whenever the mouse navigation type changes.

    Parameters

    Returns void

setColorLegendClickHandler

  • Sets the handler function to be called whenever the user clicks on a color legend.

    The handler function will be passed the id of the scalar result.

    Parameters

    Returns void

setPickHandler

  • Sets the handler function to be called whenever the user does a "clean click" in the 3D view.

    No picking is performed before the given handler is invoked, so the behavior of the click is entirely up to the user.

    See PickHandler for more info.

    Parameters

    Returns void

setShowDebugWindow

  • setShowDebugWindow(show: boolean): void
  • Specifies if the debug overlay info window should be shown or not

    Parameters

    • show: boolean

    Returns void

Generated using TypeDoc