s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
77 lines (76 loc) • 3.39 kB
TypeScript
import type { RasterData } 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, RasterDefinition, RasterStyle, RasterWorkflowLayerGuideGPU } from 'style/style.spec.js';
import type { RasterFeature as RasterFeatureSpec, RasterSource, RasterWorkflow as RasterWorkflowSpec } from './workflow.spec.js';
/** Raster Feature is a standalone raster render storage unit that can be drawn to the GPU */
export declare class RasterFeature implements RasterFeatureSpec {
#private;
layerGuide: RasterWorkflowLayerGuideGPU;
workflow: RasterWorkflowSpec;
tile: Tile;
source: RasterSource;
featureCode: number[];
rasterFadeBuffer: GPUBuffer;
featureCodeBuffer: GPUBuffer;
fadeStartTime: number;
parent?: Tile | undefined;
type: "raster";
bindGroup: GPUBindGroup;
rasterBindGroup: GPUBindGroup;
/**
* @param layerGuide - the layer guide for this feature
* @param workflow - the raster workflow
* @param tile - the tile this feature is drawn on
* @param source - the raster source
* @param featureCode - the encoded feature code that tells the GPU how to compute it's properties
* @param rasterFadeBuffer - the fade buffer
* @param featureCodeBuffer - the feature code buffer
* @param fadeStartTime - the start time of the fade for smooth transitions
* @param parent - the parent tile if applicable
*/
constructor(layerGuide: RasterWorkflowLayerGuideGPU, workflow: RasterWorkflowSpec, tile: Tile, source: RasterSource, featureCode: number[], rasterFadeBuffer: GPUBuffer, featureCodeBuffer: GPUBuffer, fadeStartTime?: number, parent?: Tile | undefined);
/** Draw the feature to the GPU */
draw(): void;
/** Destroy and cleanup the feature */
destroy(): void;
/**
* Duplicate the raster feature
* @param tile - the tile this feature is drawn on
* @param parent - the parent tile if applicable
* @returns the duplicated feature
*/
duplicate(tile: Tile, parent?: Tile): RasterFeature;
}
/** Raster Workflow */
export default class RasterWorkflow implements RasterWorkflowSpec {
#private;
context: WebGPUContext;
layerGuides: Map<number, RasterWorkflowLayerGuideGPU>;
pipeline: GPURenderPipeline;
rasterBindGroupLayout: GPUBindGroupLayout;
/** @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: RasterStyle): RasterDefinition;
/**
* Build the source raster data into raster features
* @param rasterData - the input raster data
* @param tile - the tile we are building the features for
*/
buildSource(rasterData: RasterData, tile: Tile): void;
/**
* Draw a raster feature to the GPU
* @param feature - raster feature guide
*/
draw(feature: RasterFeatureSpec): void;
}