UNPKG

s2maps-gpu

Version:

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

118 lines (117 loc) 4.98 kB
import Workflow, { Feature } from './workflow.js'; import type Context from '../context/context.js'; import type { HeatmapData } from 'workers/worker.spec.js'; import type { TileGL as Tile } from 'source/tile.spec.js'; import type { BBox, HeatmapDefinition, HeatmapStyle, HeatmapWorkflowLayerGuide, LayerDefinitionBase } from 'style/style.spec.js'; import type { HeatmapFeature as HeatmapFeatureSpec, HeatmapSource, HeatmapWorkflow as HeatmapWorkflowSpec, HeatmapWorkflowUniforms } from './workflow.spec.js'; /** Heatmap Feature is a standalone heatmap render storage unit that can be drawn to the GPU */ export declare class HeatmapFeature extends Feature implements HeatmapFeatureSpec { workflow: HeatmapWorkflow; source: HeatmapSource; layerGuide: HeatmapWorkflowLayerGuide; tile: Tile; count: number; offset: number; featureCode: number[]; parent?: Tile | undefined; bounds?: BBox | undefined; type: "heatmap"; radiusLo?: number; opacityLo?: number; intensityLo?: number; radiusHi?: number; opacityHi?: number; intensityHi?: number; /** * @param workflow - the heatmap workflow * @param source - the heatmap 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: HeatmapWorkflow, source: HeatmapSource, layerGuide: HeatmapWorkflowLayerGuide, 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; /** Draw the feature's texture to the GPU */ drawTexture(): 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): HeatmapFeature; /** * Set the webgl1 attributes if the context is webgl1 * Low-High is a system to help WebGL blend between two values on zoom change * @param radiusLo - the low radius * @param opacityLo - the low opacity * @param intensityLo - the low intensity * @param radiusHi - the high radius * @param opacityHi - the high opacity * @param intensityHi - the high intensity */ setWebGL1Attributes(radiusLo?: number, opacityLo?: number, intensityLo?: number, radiusHi?: number, opacityHi?: number, intensityHi?: number): void; } /** Heatmap Workflow */ export default class HeatmapWorkflow extends Workflow implements HeatmapWorkflowSpec { #private; label: "heatmap"; texture: WebGLTexture; nullTextureA: WebGLTexture; nullTextureB: WebGLTexture; framebuffer: WebGLFramebuffer; extentBuffer?: WebGLBuffer; layerGuides: Map<number, HeatmapWorkflowLayerGuide>; uniforms: { [key in HeatmapWorkflowUniforms]: WebGLUniformLocation; }; /** @param context - The WebGL(1|2) context */ constructor(context: Context); /** * Build the heatmap source * @param heatmapData - the heatmap data sent from the tile worker * @param tile - the tile that the features are drawn on */ buildSource(heatmapData: HeatmapData, tile: Tile): void; /** * Build the layer definition * @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: HeatmapStyle): HeatmapDefinition; /** Resize the heatmap FBO */ resize(): void; /** Setup the texture draw workflow */ setupTextureDraw(): void; /** * Draw heatmap feature's textures * @param features - features to draw * @returns the resulting combination of associated features */ textureDraw(features: HeatmapFeatureSpec[]): HeatmapFeatureSpec[] | undefined; /** * Draw feature to early FBO * @param featureGuide - feature to draw */ drawToTexture(featureGuide: HeatmapFeatureSpec): void; /** Use the heatmap workflow */ use(): void; /** * Draw the heatmap feature * @param feature - feature to draw * @param _interactive - whether or not the feature is interactive */ draw(feature: HeatmapFeatureSpec, _interactive?: boolean): void; /** Delete the heatmap workflow */ delete(): void; }