UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

50 lines (49 loc) 2.52 kB
import CollisionTester from './collisionTester.js'; import VectorWorker from '../vectorWorker.js'; import type ImageStore from '../imageStore.js'; import type { GPUType, GlyphDefinition, GlyphWorkerLayer } from 'style/style.spec.js'; import type { GlyphObject } from './glyph.spec.js'; import type { TileRequest } from 'workers/worker.spec.js'; import type { GlyphWorker as GlyphWorkerSpec, IDGen, VTFeature } from '../process.spec.js'; /** Worker for processing glyph data */ export default class GlyphWorker extends VectorWorker implements GlyphWorkerSpec { #private; collisionTest: CollisionTester; imageStore: ImageStore; featureStore: Map<string, GlyphObject[]>; sourceWorker: MessagePort; tileSize: number; /** * @param idGen - id generator to ensure features don't overlap * @param gpuType - the GPU context of the map renderer (WebGL(1|2) | WebGPU) * @param sourceWorker - the source worker to send requests to * @param imageStore - the image store to pull/request the needed glyphs/icons * @param tileSize - the tile size */ constructor(idGen: IDGen, gpuType: GPUType, sourceWorker: MessagePort, imageStore: ImageStore, tileSize: number); /** * Setup a glyph layer for future processing of vector data * @param glyphLayer - the glyph layer * @returns the layer to process future glyph data */ setupLayer(glyphLayer: GlyphDefinition): GlyphWorkerLayer; /** * Build a Glyph Feature from input vector data * @param tile - the tile request * @param extent - the extent of the tile * @param feature - the input vector tile feature * @param glyphLayer - the glyph worker layer describing how to process the feature * @param mapID - the id of the map to ship the data back to * @param sourceName - the name of the source the data belongs to * @returns true if the feature was built */ buildFeature(tile: TileRequest, extent: number, feature: VTFeature, glyphLayer: GlyphWorkerLayer, mapID: string, sourceName: string): Promise<boolean>; /** * Flush a tile-request to the render thread * @param mapID - id of the map to ship the data back to * @param tile - tile request * @param sourceName - name of the source the data belongs to * @param wait - wait function. We need to wait for a response of missing glyph/icon data beore flushing */ flush(mapID: string, tile: TileRequest, sourceName: string, wait: Promise<void>): Promise<void>; }