Interface MapViewInterface

Base interface for 3D views.

The view provides a layer mechanism to plug in modules that add 3D objects to the view. Layers can define events that are called on various occasions, e.g., when the user changes the current location or moves the mouse. Layers are responsible for managing the Three.JS objects below their scene node. To simplify user input handling, meshes added to the scene can define handlers for events like clicks, mouse over, mouse out, dragging, etc.

This interface provides a mechanism to render-on-demand, i.e., only when scene contents changed. Whenever the scene or objects are modified (e.g. by a layer), a call to invalidateScene causes the scene to be rendered. invalidateScene can be called repeatedly, however rendering will only occur at a fixed rate.

For tweening, the view provides the methods watchTween and forgetTween. As long as tweens are watched by the view, the rendering loop will stay active. To use this mechanism, call watchTween when you start it and forgetTween when it completes.

interface MapViewInterface {
    hideOverlappingPois: boolean;
    onZoom: Signal<ZoomHandler>;
    scene: Scene;
    addToScene(layer: SceneLayerInterface): void;
    centerOn(position: Vector3, frustumDepth?: number): void;
    closeContextMenu(): void;
    createSceneGroup(): Object3D<Object3DEventMap>;
    createWatchedTween<T>(object: T, group?: false | Group): Tween<T>;
    forgetTween(tween: Tween<unknown>): void;
    getCamera(): Camera;
    getDefaultViewport(): ViewportInterface;
    getLastMousePosition(): MouseEventCoordinatesInterface;
    getLocationMarkerLayer(): SceneLayerInterface;
    getObjectsUnderCursor(pos: MouseEventCoordinatesInterface): Intersection<Object3D<Object3DEventMap>>[];
    getPoiLayer(): SceneLayerInterface;
    getPositionOnGroundPlane(x: number, y: number, z: number, viewport?: ViewportInterface): Vector3;
    getRouteLayer(): SceneLayerInterface;
    getScreenshot(mimeType?: string, quality?: number): ScreenshotDataInterface;
    invalidateScene(callback?: (() => void)): void;
    unprojectEvent(event: MouseEvent, z?: number): Vector3;
    unprojectScreenCoordinates(x: number, y: number, z?: number, viewport?: ViewportInterface): Vector3;
    watchTween(tween: Tween<unknown>): void;
}

Hierarchy (view full)

Properties

hideOverlappingPois: boolean

Whether to hide POIs that would overlap others. True by default.

Signal that is emitted after the zoom has changed

scene: Scene

Object that contains items that will be rendered in the view. For more information ThreeJS.Scene

Methods

  • Adds a scene layer to the 3D view. Note: see the example on how to add a custom data layer in the 'Developer Guide' section.

    Parameters

    Returns void

  • Center all viewports on the specified location

    Parameters

    • position: Vector3

      Position to center view on

    • OptionalfrustumDepth: number

      Adjust the frustum size of orthographic cameras so that far - near = frustumDepth

    Returns void

  • Create a tween that is added to the watch list when started and removed from the watch list when it completes or when it is stopped.

    As long as at least one tween is watched, the view will render at a fixed frame rate.

    Type Parameters

    • T

    Parameters

    • object: T

      The object to tween. This is passed on to the Tween constructor.

    • Optionalgroup: false | Group

      The tween group. This is passed on to the Tween constructor.

    Returns Tween<T>

    The tween with onStart(), onStop() and onComplete() callbacks installed.

  • Remove a tween from the watch list. Call this from tween's

    onComplete()
    and

    onStop()
    methods.

    Parameters

    • tween: Tween<unknown>

      Tween to remove

    Returns void

  • Returns Camera

    The camera used to render the view

    If there are multiple viewports, this shall return the camera for the default one

  • Find 3D objects under the mouse cursor.

    Parameters

    Returns Intersection<Object3D<Object3DEventMap>>[]

    Intersections with mouse cursor

    This method is viewport-aware and takes care of the extra transformation.

  • Get 3D position of specified screen coordinates assuming a ground plane at given height

    Parameters

    • x: number

      Screen X coordinate

    • y: number

      Screen Y coordinate

    • z: number

      Z coordinate of ground plane. Can be undefined.

    • Optionalviewport: ViewportInterface

      Viewport to use (optional)

    Returns Vector3

    3D position of mouse or gesture event on the plane (or null)

    This method is viewport-aware and takes care of the extra transformation.

    Unprojects the screen coordinates and intersects the ray with a plane with normal (0,0,1) at specified height in order to get the 3D point coordinates on the plane.

    If z is undefined, the plane is assumed to be 1 unit away from the camera position in the direction the camera is facing.

  • Invalidates the scene so that it is rendered. Call this method whenever things happen that modify the appearance of the scene (e.g. a texture download finishes).

    Parameters

    • Optionalcallback: (() => void)

      callback to be run after scene has been rendered

        • (): void
        • Returns void

    Returns void

  • Unproject screen-space coordinates given as input event.

    Parameters

    • event: MouseEvent

      Hammer.JS event data

    • Optionalz: number

      Z coordinate in screen-space (defaults to 1 if not provided)

    Returns Vector3

    Unprojected coordinates (local coordinates)

    This method is viewport-aware and takes care of the extra transformation.

  • Unproject screen-space coordinates (relative to the viewport, i.e. (0,0) is the upper left corner of the rendering DIV).

    Parameters

    • x: number

      X coordinate in screen-space

    • y: number

      Y coordinate in screen-space

    • Optionalz: number

      Z coordinate in screen-space (defaults to 1 if not provided)

    • Optionalviewport: ViewportInterface

      The viewport to use for unprojection

    Returns Vector3

    Unprojected coordinates (local coordinates)

  • Add a tween to the watch list. Call this when you start a tween. As long as at least one tween is watched, the view will render at a fixed frame rate.

    Parameters

    • tween: Tween<unknown>

      Tween to watch

    Returns void