import { EventDispatcher, Vector3, MOUSE, TOUCH, Vector2, PerspectiveCamera, OrthographicCamera } from 'three'; import { MapControls } from 'three/examples/jsm/controls/MapControls'; import LRU from 'lru-cache'; import { Stats } from '@probe.gl/stats'; declare class OrbitControls extends EventDispatcher { constructor(object: any, domElement: any); object: any; domElement: any; enabled: boolean; target: Vector3; minDistance: number; maxDistance: number; minZoom: number; maxZoom: number; minPolarAngle: number; maxPolarAngle: number; minAzimuthAngle: number; maxAzimuthAngle: number; enableDamping: boolean; dampingFactor: number; enableZoom: boolean; zoomSpeed: number; enableRotate: boolean; rotateSpeed: number; enablePan: boolean; panSpeed: number; screenSpacePanning: boolean; keyPanSpeed: number; autoRotate: boolean; autoRotateSpeed: number; keys: { LEFT: string; UP: string; RIGHT: string; BOTTOM: string; }; mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE; }; touches: { ONE: TOUCH; TWO: TOUCH; }; target0: Vector3; position0: any; zoom0: any; _domElementKeyEvents: any; _listenersAttached: boolean; getPolarAngle: () => number; getAzimuthalAngle: () => number; getDistance: () => any; /** * @private */ private listenToKeyEvents; saveState: () => void; reset: () => void; update: () => boolean; connect: () => void; disconnect: () => void; } type CameraView = { renderMode: RenderMode; lng: number; lat: number; altitude: number; zoom: number; isAnimated?: boolean; interpolationFactor?: number; }; declare const enum RenderMode { GLOBE = "globe", MAP = "map" } type RenderOptions = Partial<{ atmosphereEnabled: boolean; atmosphereColor: number[]; atmosphereStrength: number; shadingEnabled: boolean; }>; type TileIdArray = [x: number, y: number, zoom: number]; /** * The TileId primitive encapsulates basic tile-math operations (retrieve parents, children). It is * built in a way that guarantees that there can only ever be a single instance of any given tile, * which allows the tile-objects to be used like primitives in comparisons, maps, sets and so on. * * A TileId instance can be retrieved using the static methods `TileId.fromString()` and * `TileId.fromXYZ()`. The tileIds are of the format `z/x/y`. */ declare class TileId { readonly id: string; readonly x: number; readonly y: number; readonly zoom: number; private constructor(); get parent(): TileId | null; get children(): TileId[]; atZoom(zoom: number): TileId[]; getAncestors(): TileId[]; getParentAtZoom(zoom: number): TileId | null; getChildrenAtZoom(zoom: number): TileId[]; private static cache; static fromXYZ(x: number, y: number, zoom: number): TileId; static fromString(id: string): TileId; static parseStringId(id: string): TileIdArray; static createStringId(x: number, y: number, zoom: number): string; } type TileType = 'tile' | 'image'; declare const enum TileLoadingState { QUEUED = 0, LOADING = 1, LOADED = 2, ERROR = 3 } interface RenderTile { tileId: TileId; zIndex: number; url: string; urlParameters: Record; loadingState: TileLoadingState; type: TileType; data?: ImageBitmap; debug?: boolean; /** * The distance in zoom-levels to the tile's placeholder, used to compute the loading-priority. * Computed as `tile.tileId.zoom - placeholder.tileId.zoom`, so -1 means we have the children * available to replace this tile and 3 means that the best available replacement is 3 zoomlevels * away. */ placeholderDistance?: number; } interface MarkerProps { id: string; html: string; lng: number; lat: number; onClick?: (id: string) => void; offset?: [number, number]; } interface RendererEventMap { cameraViewChanged: CustomEvent; } declare class Renderer extends EventTarget { readonly container: HTMLElement; private readonly webglRenderer; private readonly scene; private readonly globeCamera; private readonly mapCamera; globeControls: OrbitControls; mapControls: MapControls; private tileManager; private markersById; private renderMode; private rendererSize; private atmosphere; private clock; constructor(container?: HTMLElement); getGlobeControls(): OrbitControls; getRenderMode(): RenderMode; setRenderMode(renderMode: RenderMode): void; resize(width: number, height: number): void; getRendererSize(): Vector2; updateTiles(tiles: RenderTile[]): void; getCamera(): PerspectiveCamera | OrthographicCamera; getCameraView(): CameraView | undefined; updateMapCamera(cameraView: CameraView): void; setMarkers(markerProps: MarkerProps[]): void; destroy(): void; private configureCameras; private configureControls; private animationLoopUpdate; updateGlobeCamera(cameraView: CameraView): void; setRenderOptions(renderOptions: RenderOptions): void; } interface Renderer { addEventListener(type: K, listener: (this: Renderer, ev: RendererEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: Renderer, ev: RendererEventMap[K]) => any, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare class MarkerHtml { readonly id: string; private readonly renderer; private readonly markerEl; private props; private rafId; private globePosition; private mapPosition; constructor(renderer: Renderer, props: MarkerProps); private update; updatePosition(): void; setProps(props: MarkerProps): void; destroy(): void; private handleMarkerClick; } type TileSelectorOptions = { debug: boolean; useOffscreenCanvas: boolean; useWorker: boolean; workerUrl: string; }; /** * The TileSelector is the public interface to the tile selection process. Based on the configration * it will start the actual implementation (`TileSelectorImpl`) in a worker or in the same process. */ declare class TileSelector { private readonly options; private impl?; private camera?; private size; private initialized?; private renderMode; /** * Create the tile-selector frontend with the specified options. * * @param options */ constructor(options?: Partial); /** * Sets the size for the renderer * * @param size */ setSize(size: Vector2): void; /** * Attach a camera to the tile-selector. * * @param camera */ setCamera(camera: PerspectiveCamera | OrthographicCamera): void; /** Retrieve the tiles currently visible for the specified camera. */ getVisibleTiles(): Promise>; /** One-time initialization that is started when retrieving tiles for the first time. */ private initialize; setRenderMode(renderMode: RenderMode): void; destroy(): Promise; } type TileUrlParameters = {}> = { x: number; y: number; zoom: number; } & TUrlParameters; interface LayerProps = {}> { id: string; getUrl: (p: TileUrlParameters) => string; urlParameters: TUrlParameters; zIndex: number; type: TileType; maxZoom: number; minZoom?: number; debug?: boolean; debugMode?: string; } declare const enum LayerDebugMode { OVERLAY = "overlay", REPLACE = "replace" } declare const enum LayerLoadingState { /** The layer is currently loading and cannot render a full set of tiles. */ LOADING = "loading", /** The layer is ready to render a full set of tiles, but not yet the requested set. */ READY = "ready", /** The layer completed loading of all requested tiles */ IDLE = "idle" } type DoneFunction = () => any; type GetPriorityFunction = (handle: Handle) => number; type RequestResult = { done: DoneFunction; } | null; /** RequestScheduler Options */ type RequestSchedulerOptions = { throttleRequests?: boolean; maxRequests?: number; }; /** Used to issue a request, without having them "deeply queued" by the browser. */ declare class RequestScheduler { readonly options: Required; readonly stats: Stats; activeRequestCount: number; /** Tracks the number of active requests and prioritizes/cancels queued requests. */ private requestQueue; private requestMap; private deferredUpdate; constructor(options?: RequestSchedulerOptions); /** * Called by an application that wants to issue a request, without having it deeply queued by the * browser * * When the returned promise resolved, it is OK for the application to issue a request. The * promise resolves to an object that contains a `done` method. When the application's request has * completed (or failed), the application must call the `done` function * * @param handle * @param getPriority Will be called when request "slots" open up, allowing the caller to update * priority or cancel the request highest priority executes first, priority < 0 cancels the * request * @returns A promise * * - Resolves to an object (with a `done` field) when the request can be issued without queueing, * - Resolves to `null` if the request has been cancelled (by the callback return < 0). In this case * the application should not issue the request */ scheduleRequest(handle: Handle, getPriority?: GetPriorityFunction): Promise; isScheduled(handle: Handle): boolean; private _issueRequest; /** We check requests asynchronously, to prevent multiple updates */ private _issueNewRequests; /** Refresh all requests */ private _issueNewRequestsAsync; /** Ensure all requests have updated priorities, and that no longer valid requests are cancelled */ private _updateAllRequests; /** Update a single request by calling the callback */ private _updateRequest; } declare class Layer = {}> { scheduler: RequestScheduler; props: LayerProps; eventTarget: EventTarget; loadingState?: LayerLoadingState; visibleTileIds: Set; visibleMinZoomTileIds: Set; minZoomTileset: Set | null; cache: LRU; responseCache: LRU>; constructor(scheduler: RequestScheduler, props: LayerProps, eventTarget: EventTarget); /** * Updates the list of currently visible tileIds coming from the tile selector. * * @param tileIds Visible tileIds */ setVisibleTileIds(tileIds: Set): void; /** * Updates the layer props. Props will be merged so partial updates are ok for the first level. No * deep merge logic! * * @param props Layer props */ setProps(props: Partial>): void; /** * Returns true if the layer is ready to render a frame with the given parameters. This is the * case when all visible tiles are ready to render. */ canRender(allowDownsampling?: boolean): boolean; /** * Returns the best available list of render tiles to display at the moment. Will be called every * frame. * * @returns List of render tiles */ getRenderTiles(): RenderTile[]; private updateTileProps; /** Gets or creates a RenderTile instance for the specified tileId. */ getRenderTile(tileId: TileId, createIfMissing?: true): RenderTile; getRenderTile(tileId: TileId, createIfMissing?: false): RenderTile | null; /** * Updates the request scheduler queue. For every new tile not already in the cache a request will * be scheduled. */ private updateQueue; private updateLoadingState; /** * Returns the priority for a requested tile depending on the zoom level - lowest levels first * (for now). Will return -1 if the tile is not needed anymore. * * @param renderTile The render tile * @returns Priority number */ private getTilePriority; /** * Returns the url of a tile by calling the provided getUrl function with the layer's current url * parameters * * @param tileId The tileId to get the url for * @returns Url */ private getUrlForTileId; /** * Fetches and sets a render tile's image data. The data property will be set to an ImageBitmap * object. In case of an error the image data will be set to an empty 1x1px sizes ImageBitmap as a * fallback. * * Calls the request scheduler's done() function when when complete. * * @param renderTile The render tile */ private fetch; /** * Creates a derived tileset that contains only tiles at minZoom (default 1) covering at least the * same area as the specified tiles. */ private getMinZoomTileIds; private isFullsize; } type WebGlGlobeProps = Partial<{ layers: LayerProps[]; renderMode: RenderMode; cameraView: Partial; markers: MarkerProps[]; allowDownsampling: boolean; renderOptions: RenderOptions; }>; type TextureUrls = { shading: string; atmosphere: string; }; interface WebGlGlobeEventMap { cameraViewChanged: CustomEvent; layerLoadingStateChanged: CustomEvent<{ layer: LayerProps; state: LayerLoadingState; }>; } declare class WebGlGlobe extends EventTarget { private readonly resizeObserver; private readonly container; private readonly scheduler; private readonly renderer; private readonly tileSelector; private readonly interactionController; private abortController; private layersById; /** * Stores the previously rendered tiles per layer, these tiles will continue to get rendered while * the layer is updating due to a change in parameters. A WeakMap is used here to avoid keeping * the tiles around when the layer has been removed. */ private previousRenderTiles; private tileSelectorIntervalId; private tileUpdateRafId; private props; private static tileSelectorWorkerUrl; private static textureUrls; constructor(container: HTMLElement, props?: WebGlGlobeProps); setProps(props: WebGlGlobeProps): void; start(): void; stop(): void; startAutoSpin(speed?: number): void; stopAutoSpin(): void; setControlsInteractionEnabled(enabled: boolean): void; private setLayers; private setMarkers; private startTileSelectorLoop; private startTileUpdateLoop; private updateRenderTiles; private resize; private attachEventListeners; destroy(): void; static getTileSelectorWorkerUrl(): string; static setTileSelectorWorkerUrl(url: string): void; static getTextureUrls(): TextureUrls; static setTextureUrls(value: TextureUrls): void; } interface WebGlGlobe { addEventListener(type: K, listener: (this: WebGlGlobe, ev: WebGlGlobeEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: WebGlGlobe, ev: WebGlGlobeEventMap[K]) => any, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } export { Layer, LayerDebugMode, LayerLoadingState, MarkerHtml, RenderMode, Renderer, TileSelector, WebGlGlobe }; export type { CameraView, LayerProps, MarkerProps, WebGlGlobeEventMap };