s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
135 lines (134 loc) • 5.27 kB
TypeScript
import type { Context as WebGLContext } from 'gl/context/index.js';
import type { WebGPUContext } from 'gpu/context/index.js';
import type { BBox, Face, S2CellId } from 'gis-tools/index.js';
import type { Corners, FaceST, SharedContext, SharedFeatures, SharedMaskSource, TileGL, TileGPU, TileBase as TileSpec } from './tile.spec.js';
import type { InteractiveObject, SourceFlushMessage, TileFlushMessage } from 'workers/worker.spec.js';
import type { LayerDefinition, Projection } from 'style/style.spec.js';
import type { Projector, TileInView, TmpWMID } from 'ui/camera/projector/index.js';
/**
* Create a new Tile given the approprate projection, context and ID.
* @param projection - the projection type (WM or S2)
* @param context - the GPU or WebGL context
* @param tileInfo - the tile identifier
* @returns the new Tile object
*/
export declare function createTile(projection: Projection, context: WebGPUContext | WebGLContext, tileInfo: TileInView): TileGL & TileGPU;
/** Base Tile Class that all Tiles inherit from. */
declare class Tile<C extends SharedContext, F extends SharedFeatures, M extends SharedMaskSource> implements TileSpec<C, F, M> {
#private;
id: S2CellId;
face: Face;
i: number;
j: number;
zoom: number;
division: number;
tmpMaskID: number;
mask: M;
bbox: BBox;
readonly featureGuides: F[];
context: C;
interactiveGuide: Map<number, InteractiveObject>;
uniforms: Float32Array<ArrayBuffer>;
bottomTop: Float32Array<ArrayBuffer>;
state: 'loading' | 'loaded' | 'deleted';
type: 'S2' | 'WM';
faceST: FaceST;
matrix: Float32Array;
layersLoaded: Set<number>;
layersToBeLoaded?: Set<number>;
wrappedID?: TmpWMID;
dependents: Array<Tile<C, F, M>>;
/**
* @param context - the GPU or WebGL context
* @param id - the tile ID
*/
constructor(context: C, id: S2CellId);
/**
* inject references to featureGuide from each parentTile. Sometimes if we zoom really fast, we inject
* a parents' parent or deeper, so we need to reflect that in the tile property.
* @param parent - parent tile to inject
* @param layers - the effected layers to modify
*/
injectParentTile(parent: TileSpec<C, F, M>, layers: LayerDefinition[]): void;
/**
* inject references to featureGuide from a wrapped tile
* @param wrapped - the wrapped tile
*/
injectWrappedTile(wrapped: TileSpec<C, F, M>): void;
/**
* set the screen positions of the mask
* @param _ - the projector (not needed here)
*/
setScreenPositions(_: Projector): void;
/**
* get an interactive feature's properties if it exists
* @param id - the id of the feature
* @returns the interactive object
*/
getInteractiveFeature(id: number): undefined | InteractiveObject;
/**
* add features to the tile
* @param features - the features to add
*/
addFeatures(features: F[]): void;
/**
* Flush message that was sent from the Source or Tile Workers letting this tile know the source and layer's state
* @param msg - input flush messge
*/
flush(msg: SourceFlushMessage | TileFlushMessage): void;
/** cleanup after itself. When a tile is deleted, it's adventageous to cleanup GPU cache. */
delete(): void;
/**
* Delete a layer
* @param index - the index of the layer
*/
deleteLayer(index: number): void;
/**
* Reorder layers
* @param layerChanges - a map of layerIndex to new layerIndex
*/
reorderLayers(layerChanges: Record<number, number>): void;
/**
* remove all sources that match the input sourceNames
* @param sourceNames - the names of the sources
*/
deleteSources(sourceNames: string[]): void;
/**
* Inject interactive data. we don't parse the interactiveData immediately to save time
* @param interactiveGuide - the interactive guide
* @param interactiveData - the interactive data
*/
injectInteractiveData(interactiveGuide: Uint32Array, interactiveData: Uint8Array): void;
}
/** S2 Geometry Projection Tile */
export declare class S2Tile<C extends SharedContext, F extends SharedFeatures, M extends SharedMaskSource> extends Tile<C, F, M> {
#private;
type: "S2";
corners?: Corners;
/**
* @param context - the context to use (GPU or WebGL)
* @param tileInfo - Information about the tile
*/
constructor(context: C, tileInfo: TileInView);
/**
* given a matrix, compute the corners screen positions
* @param projector - the camera's current view
*/
setScreenPositions(projector: Projector): void;
}
/** Web Mercator Projection Tile */
export declare class WMTile<C extends SharedContext, F extends SharedFeatures, M extends SharedMaskSource> extends Tile<C, F, M> {
type: "WM";
matrix: Float32Array;
/**
* @param context - a GPU context or WebGL context
* @param tileInfo - Information about the tile
*/
constructor(context: C, tileInfo: TileInView);
/**
* given a basic ortho matrix, adjust by the tile's offset and scale
* @param projector - the camera's current view
*/
setScreenPositions(projector: Projector): void;
}
export {};