s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
94 lines (93 loc) • 4.08 kB
TypeScript
import type { BBox } from 'gis-tools/index.js';
import type { PointData } from 'workers/worker.spec.js';
import type { TileGPU as Tile } from 'source/tile.spec.js';
import type { WebGPUContext } from '../context/index.js';
import type { LayerDefinitionBase, PointDefinition, PointStyle, PointWorkflowLayerGuideGPU } from 'style/style.spec.js';
import type { PointFeature as PointFeatureSpec, PointSource, PointWorkflow as PointWorkflowSpec } from './workflow.spec.js';
/** Point Feature is a standalone point render storage unit that can be drawn to the GPU */
export declare class PointFeature implements PointFeatureSpec {
#private;
workflow: PointWorkflow;
source: PointSource;
layerGuide: PointWorkflowLayerGuideGPU;
tile: Tile;
count: number;
offset: number;
featureCode: number[];
pointBoundsBuffer: GPUBuffer;
pointInteractiveBuffer: GPUBuffer;
featureCodeBuffer: GPUBuffer;
parent?: Tile | undefined;
type: "point";
bindGroup: GPUBindGroup;
pointBindGroup: GPUBindGroup;
pointInteractiveBindGroup: GPUBindGroup;
/**
* @param workflow - the point workflow
* @param source - the point 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 pointBoundsBuffer - the bounds of the points
* @param pointInteractiveBuffer - the interactive buffer
* @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: PointWorkflow, source: PointSource, layerGuide: PointWorkflowLayerGuideGPU, tile: Tile, count: number, offset: number, featureCode: number[], pointBoundsBuffer: GPUBuffer, pointInteractiveBuffer: GPUBuffer, featureCodeBuffer: GPUBuffer, parent?: Tile | undefined);
/** Draw the feature to the GPU */
draw(): void;
/** Compute the feature's interactivity with the mouse */
compute(): 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): PointFeature;
}
/** Point Workflow */
export default class PointWorkflow implements PointWorkflowSpec {
#private;
context: WebGPUContext;
layerGuides: Map<number, PointWorkflowLayerGuideGPU>;
pipeline: GPURenderPipeline;
interactivePipeline: GPUComputePipeline;
pointInteractiveBindGroupLayout: GPUBindGroupLayout;
pointBindGroupLayout: GPUBindGroupLayout;
module: GPUShaderModule;
/** @param context - The WebGPU context */
constructor(context: WebGPUContext);
/** Setup the workflow */
setup(): Promise<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: PointStyle): PointDefinition;
/**
* Build the source point data into point features
* @param pointData - the input point data
* @param tile - the tile we are building the features for
*/
buildSource(pointData: PointData, tile: Tile): void;
/**
* Draw a point feature to the GPU
* @param feature - point feature guide
*/
draw(feature: PointFeatureSpec): void;
/**
* Compute the interactive features that interact with the mouse
* @param feature - point feature guide
*/
computeInteractive(feature: PointFeatureSpec): void;
}