UNPKG

s2maps-gpu

Version:

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

79 lines (78 loc) 3.51 kB
import type { HillshadeData } from 'workers/worker.spec.js'; import type { TileGPU as Tile } from 'source/tile.spec.js'; import type { WebGPUContext } from '../context/index.js'; import type { HillshadeDefinition, HillshadeStyle, HillshadeWorkflowLayerGuideGPU, LayerDefinitionBase } from 'style/style.spec.js'; import type { HillshadeFeature as HillshadeFeatureSpec, HillshadeWorkflow as HillshadeWorkflowSpec, RasterSource } from './workflow.spec.js'; /** Hillshade Feature is a standalone hillshade render storage unit that can be drawn to the GPU */ export declare class HilllshadeFeature implements HillshadeFeatureSpec { #private; layerGuide: HillshadeWorkflowLayerGuideGPU; workflow: HillshadeWorkflowSpec; tile: Tile; source: RasterSource; featureCode: number[]; hillshadeFadeBuffer: GPUBuffer; featureCodeBuffer: GPUBuffer; fadeStartTime: number; parent?: Tile | undefined; type: "hillshade"; sourceName: string; fadeDuration: number; bindGroup: GPUBindGroup; hillshadeBindGroup: GPUBindGroup; /** * @param layerGuide - the layer guide for this feature * @param workflow - the hillshade workflow * @param tile - the tile this feature is drawn on * @param source - the hillshade source * @param featureCode - the encoded feature code * @param hillshadeFadeBuffer - 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: HillshadeWorkflowLayerGuideGPU, workflow: HillshadeWorkflowSpec, tile: Tile, source: RasterSource, featureCode: number[], hillshadeFadeBuffer: GPUBuffer, featureCodeBuffer: GPUBuffer, fadeStartTime?: number, parent?: Tile | undefined); /** Draw the feature to the GPU */ draw(): void; /** Destroy the feature */ destroy(): void; /** * Duplicate this 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): HilllshadeFeature; } /** Hillshade Workflow */ export default class HillshadeWorkflow implements HillshadeWorkflowSpec { #private; context: WebGPUContext; layerGuides: Map<number, HillshadeWorkflowLayerGuideGPU>; pipeline: GPURenderPipeline; hillshadeBindGroupLayout: 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: HillshadeStyle): HillshadeDefinition; /** * Build the source hillshade data into hillshade features * @param hillshadeData - the input hillshade data * @param tile - the tile we are building the features for */ buildSource(hillshadeData: HillshadeData, tile: Tile): void; /** * Draw a screen quad with the hillshade feature's properties * @param feature - hillshade feature */ draw(feature: HillshadeFeatureSpec): void; }