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) • 4.18 kB
TypeScript
import type { BBox } from 'gis-tools/index.js';
import type { HeatmapData } from 'workers/worker.spec.js';
import type { TileGPU as Tile } from 'source/tile.spec.js';
import type { WebGPUContext } from '../context/index.js';
import type { HeatmapDefinition, HeatmapStyle, HeatmapWorkflowLayerGuideGPU, LayerDefinitionBase } from 'style/style.spec.js';
import type { HeatmapFeature as HeatmapFeatureSpec, HeatmapSource, HeatmapWorkflow as HeatmapWorkflowSpec } from './workflow.spec.js';
/** Heatmap Feature is a standalone heatmap render storage unit that can be drawn to the GPU */
export declare class HeatmapFeature implements HeatmapFeatureSpec {
#private;
workflow: HeatmapWorkflow;
source: HeatmapSource;
layerGuide: HeatmapWorkflowLayerGuideGPU;
tile: Tile;
count: number;
offset: number;
featureCode: number[];
heatmapBoundsBuffer: GPUBuffer;
featureCodeBuffer: GPUBuffer;
parent?: Tile | undefined;
type: "heatmap";
bindGroup: GPUBindGroup;
heatmapBindGroup: GPUBindGroup;
/**
* @param workflow - the heatmap workflow
* @param source - the heatmap source
* @param layerGuide - layer guide for this feature
* @param tile - the tile this feature is drawn on
* @param count - the number of points
* @param offset - the offset of the points
* @param featureCode - the encoded feature code
* @param heatmapBoundsBuffer - the bounds of the heatmap
* @param featureCodeBuffer - the encoded feature code that tells the GPU how to compute it's properties
* @param parent - the parent tile if applicable
*/
constructor(workflow: HeatmapWorkflow, source: HeatmapSource, layerGuide: HeatmapWorkflowLayerGuideGPU, tile: Tile, count: number, offset: number, featureCode: number[], heatmapBoundsBuffer: GPUBuffer, featureCodeBuffer: GPUBuffer, parent?: Tile | undefined);
/** Draw the feature to the GPU */
draw(): void;
/** Destroy and cleanup the feature */
destroy(): void;
/**
* Duplicate this feature
* @param tile - the tile this 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;
}
/** Heatmap Workflow */
export default class HeatmapWorkflow implements HeatmapWorkflowSpec {
#private;
context: WebGPUContext;
layerGuides: Map<number, HeatmapWorkflowLayerGuideGPU>;
pipeline: GPURenderPipeline;
module: GPUShaderModule;
texturePipeline: GPURenderPipeline;
heatmapBindGroupLayout: GPUBindGroupLayout;
heatmapTextureBindGroupLayout: GPUBindGroupLayout;
/** @param context - The WebGPU context */
constructor(context: WebGPUContext);
/** Setup the workflow */
setup(): Promise<void>;
/** Resize the workflow's associated render targets and textures */
resize(): void;
/** Destroy and cleanup the workflow */
destroy(): 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 feature
*/
buildLayerDefinition(layerBase: LayerDefinitionBase, layer: HeatmapStyle): HeatmapDefinition;
/**
* Build the source heatmap data into heatmap features
* @param heatmapData - the input heatmap data
* @param tile - the tile we are building the features for
*/
buildSource(heatmapData: HeatmapData, tile: Tile): void;
/**
* Draw the features to an early render target that will be an input texture for the screen workflow
* @param features - the heatmap features to draw
* @returns the resulting combination of associated features
*/
textureDraw(features: HeatmapFeatureSpec[]): HeatmapFeatureSpec[] | undefined;
/**
* Draw a screen quad with the heatmap feature's properties describing the heatmap's texture inputs
* @param feature - heatmap feature
*/
draw(feature: HeatmapFeatureSpec): void;
}