UNPKG

s2maps-gpu

Version:

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

92 lines (91 loc) 3.98 kB
import Workflow, { Feature } from './workflow.js'; import type Context from '../context/context.js'; import type { PointData } from 'workers/worker.spec.js'; import type { TileGL as Tile } from 'source/tile.spec.js'; import type { BBox, ColorArray, LayerDefinitionBase, PointDefinition, PointStyle, PointWorkflowLayerGuide } from 'style/style.spec.js'; import type { PointFeature as PointFeatureSpec, PointSource, PointWorkflow as PointWorkflowSpec, PointWorkflowUniforms } from './workflow.spec.js'; /** Point Feature is a standalone point render storage unit that can be drawn to the GPU */ export declare class PointFeature extends Feature implements PointFeatureSpec { workflow: PointWorkflow; source: PointSource; layerGuide: PointWorkflowLayerGuide; tile: Tile; count: number; offset: number; featureCode: number[]; parent?: Tile | undefined; bounds?: BBox | undefined; type: "point"; color?: ColorArray; radius?: number; stroke?: ColorArray; strokeWidth?: number; opacity?: number; /** * @param workflow - the point workflow * @param source - the point source * @param layerGuide - layer guide for this feature * @param tile - the tile that the feature is drawn on * @param count - the number of points * @param offset - the offset of the points * @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: PointWorkflow, source: PointSource, layerGuide: PointWorkflowLayerGuide, tile: Tile, count: number, offset: number, 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): PointFeature; /** * Set the attributes of the feature if the context is webgl1 * @param color - the color * @param radius - the radius * @param stroke - the stroke * @param strokeWidth - the stroke width * @param opacity - the opacity */ setWebGL1Attributes(color?: ColorArray, radius?: number, stroke?: ColorArray, strokeWidth?: number, opacity?: number): void; } /** Point Workflow */ export default class PointWorkflow extends Workflow implements PointWorkflowSpec { #private; label: "point"; extentBuffer?: WebGLBuffer; layerGuides: Map<number, PointWorkflowLayerGuide>; uniforms: { [key in PointWorkflowUniforms]: WebGLUniformLocation; }; /** @param context - the WebGL(1|2) context */ constructor(context: Context); /** * Build the source raster data into raster features * @param pointData - the point data * @param tile - the tile we are building the features for */ buildSource(pointData: PointData, tile: Tile): void; /** * Build the layer definition for this workflow * @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 point feature */ buildLayerDefinition(layerBase: LayerDefinitionBase, layer: PointStyle): PointDefinition; /** Use this workflow as the current shaders for the GPU */ use(): void; /** * Draw the point feature * @param feature - the point feature * @param _interactive - whether or not the feature is interactive */ draw(feature: PointFeatureSpec, _interactive?: boolean): void; }