UNPKG

s2maps-gpu

Version:

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

114 lines (113 loc) 5.05 kB
import Workflow, { Feature } from './workflow.js'; import type { BBox } from 'gis-tools/index.js'; import type { ColorArray } from 'style/color/index.js'; import type Context from '../context/context.js'; import type { GlyphData } from 'workers/worker.spec.js'; import type { TileGL as Tile } from 'source/tile.spec.js'; import type { GlyphDefinition, GlyphStyle, GlyphWorkflowLayerGuide, LayerDefinitionBase } from 'style/style.spec.js'; import type { GlyphFeature as GlyphFeatureSpec, GlyphFilterWorkflow, GlyphSource, GlyphWorkflow as GlyphWorkflowSpec, GlyphWorkflowUniforms } from './workflow.spec.js'; /** Glyph Feature is a standalone glyph render storage unit that can be drawn to the GPU */ export declare class GlyphFeature extends Feature implements GlyphFeatureSpec { workflow: GlyphWorkflowSpec; source: GlyphSource; tile: Tile; layerGuide: GlyphWorkflowLayerGuide; count: number; offset: number; filterCount: number; filterOffset: number; isPath: boolean; isIcon: boolean; featureCode: number[]; parent?: Tile | undefined; bounds?: BBox | undefined; type: "glyph"; size?: number; fill?: ColorArray; stroke?: ColorArray; strokeWidth?: number; /** * @param workflow - the glyph workflow * @param source - the glyph source * @param tile - the tile that the feature is drawn on * @param layerGuide - layer guide for this feature * @param count - the number of glyphs * @param offset - the offset of the glyphs * @param filterCount - the number of filter glyphs * @param filterOffset - the offset of the filter glyphs * @param isPath - whether or not the glyph is a path or a point * @param isIcon - whether or not the glyph is an icon or a standard glyph * @param featureCode - the encoded feature code that tells the GPU how to compute it's properties * @param parent - the parent tile if applicable * @param bounds - the bounds of the tile if applicable */ constructor(workflow: GlyphWorkflowSpec, source: GlyphSource, tile: Tile, layerGuide: GlyphWorkflowLayerGuide, count: number, offset: number, filterCount: number, filterOffset: number, isPath: boolean, isIcon: boolean, featureCode: number[], parent?: Tile | undefined, bounds?: BBox | undefined); /** * Draw the feature to the GPU * @param interactive - whether or not the feature is interactive */ draw(interactive?: boolean): void; /** * Duplicate this feature * @param tile - the tile that the feature is drawn on * @param parent - the parent tile if applicable * @param bounds - the bounds of the tile if applicable * @returns the duplicated feature */ duplicate(tile: Tile, parent?: Tile, bounds?: BBox): GlyphFeature; /** * Set the attributes of the feature if the context is webgl1 * @param size - size * @param fill - fill * @param stroke - stroke * @param strokeWidth - stroke width */ setWebGL1Attributes(size?: number, fill?: ColorArray, stroke?: ColorArray, strokeWidth?: number): void; } /** Glyph Workflow */ export default class GlyphWorkflow extends Workflow implements GlyphWorkflowSpec { #private; label: "glyph"; stepBuffer?: WebGLBuffer; uvBuffer?: WebGLBuffer; glyphFilterWorkflow: GlyphFilterWorkflow; layerGuides: Map<number, GlyphWorkflowLayerGuide>; uniforms: { [key in GlyphWorkflowUniforms]: WebGLUniformLocation; }; /** @param context - The WebGL(1|2) context */ constructor(context: Context); /** * Inject the glyph filter workflow to share the glyph filter texture * @param glyphFilterWorkflow - The glyph filter workflow */ injectFilter(glyphFilterWorkflow: GlyphFilterWorkflow): void; /** * Build features from the glyph source sent from the Tile Worker * @param glyphData - The glyph data from the Tile Worker * @param tile - The tile that the feature is drawn on */ buildSource(glyphData: GlyphData, tile: Tile): void; /** * Build the layer definition for this workflow given the user input layer * @param layerBase - the common layer attributes * @param layer - the user defined layer attributes * @returns a built layer definition that's ready to describe how to render a feature */ buildLayerDefinition(layerBase: LayerDefinitionBase, layer: GlyphStyle): GlyphDefinition; /** * Compute the glyph filters so that we know which glyphs to render * @param glyphFeatures - the glyph features that need to be computed */ computeFilters(glyphFeatures: GlyphFeatureSpec[]): void; /** Use this workflow as the current shaders for the GPU */ use(): void; /** * Draw the glyph feature * @param feature - the glyph feature guide * @param interactive - whether or not the feature is interactive */ draw(feature: GlyphFeatureSpec, interactive?: boolean): void; /** Delete the glyph workflow */ delete(): void; }