import { Cognite3DViewer } from '../../../api'; import { DisposedDelegate } from '../../../utilities'; import { Texture, Color } from 'three'; import { OverlayInfo, DefaultOverlay3DContentType, OverlayCollection, Overlay3D } from '../../../3d-overlays'; import { Cognite3DViewerToolBase } from '../Cognite3DViewerToolBase'; /** * Events related to overlays */ export type OverlayToolEvent = 'hover' | 'click' | 'disposed'; /** * Type for handlers of overlay events */ export type OverlayEventHandler = (event: { targetOverlay: Overlay3D; htmlTextOverlay: HTMLElement; mousePosition: { offsetX: number; offsetY: number; }; }) => void; /** * Parameters for instantiating the Overlay3DTool */ export type Overlay3DToolParameters = { /** * Max point markers size in pixels. Different platforms has limitations for this value. * On Android and MacOS in Chrome maximum is 64. Windows in Chrome and MacOS Safari desktops can support up to 500. * Default is 64. */ maxPointSize?: number; /** * Sets default overlay color for newly added labels. */ defaultOverlayColor: Color; }; /** * Parameters for instantiating the OverlayCollection. */ export type OverlayCollectionOptions = { /** * Sets default overlay color for newly added overlays. * Default is yellow. * */ defaultOverlayColor?: Color; /** * Sets default texture for all overlays of this OverlayCollection. * Must be a square texture, recommended size is at least `maxPointSize` for * not pixelated overlays. */ overlayTexture?: Texture; /** * Sets default mask for all overlays of this OverlayCollection, * denoting where overlay color should be placed compared to texture color. * Must be a square texture with the same size as `overlayTexture`. * Texture should be monochrome. Internally, R channel is used for * denoting pixels that should be colored by texture and not by overlay color. */ overlayTextureMask?: Texture; }; /** * Tool for adding and interacting with 2D overlays positioned at points in */ export declare class Overlay3DTool extends Cognite3DViewerToolBase { private readonly _viewer; private readonly _defaultOverlayColor; private _overlayCollections; private _isVisible; private readonly _textOverlay; private readonly _events; constructor(viewer: Cognite3DViewer, toolParameters?: Overlay3DToolParameters); /** * Creates new OverlayCollection. * @param overlays Array of overlays to add. * @returns Overlay group containing it's id. */ createOverlayCollection(overlays?: OverlayInfo[], options?: OverlayCollectionOptions): OverlayCollection; /** * Removes overlays that were added with addOverlays method. * @param overlayCollection Id of the overlay group to remove. */ removeOverlayCollection(overlayCollection: OverlayCollection): void; /** * Gets all added overlay collections. */ getCollections(): OverlayCollection[]; /** * Sets whether overlays are visible. */ setVisible(visible: boolean): void; /** * Gets whether overlays are visible. */ getVisible(): boolean; /** * Sets whether text overlay is visible. * Default is false. */ setTextOverlayVisible(visible: boolean): void; /** * Gets whether text overlay is visible. */ getTextOverlayVisible(): boolean; /** * Removes all overlays. */ clear(): void; /** * Subscribes to overlay events. * @param event event to subscribe to. * @param eventHandler */ on(event: 'hover', eventHandler: OverlayEventHandler): void; on(event: 'click', eventHandler: OverlayEventHandler): void; on(event: 'disposed', eventHandler: DisposedDelegate): void; off(event: 'hover', eventHandler: OverlayEventHandler): void; off(event: 'click', eventHandler: OverlayEventHandler): void; off(event: 'disposed', eventHandler: DisposedDelegate): void; /** * Dispose of resources used by this tool */ dispose(): void; private readonly onPointerMove; private readonly onMouseClick; private intersectPointsMarkers; }