scichart-engine 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -0
  3. package/dist/analysis/contours.d.ts +20 -0
  4. package/dist/analysis/fitting.d.ts +24 -0
  5. package/dist/analysis/index.d.ts +12 -0
  6. package/dist/analysis/math.d.ts +32 -0
  7. package/dist/analysis/utils.d.ts +150 -0
  8. package/dist/core/Chart.d.ts +15 -0
  9. package/dist/core/ChartControls.d.ts +30 -0
  10. package/dist/core/ChartLegend.d.ts +35 -0
  11. package/dist/core/ChartStatistics.d.ts +18 -0
  12. package/dist/core/EventEmitter.d.ts +30 -0
  13. package/dist/core/InteractionManager.d.ts +67 -0
  14. package/dist/core/OverlayRenderer.d.ts +67 -0
  15. package/dist/core/Series.d.ts +4 -0
  16. package/dist/core/annotations/AnnotationManager.d.ts +57 -0
  17. package/dist/core/annotations/index.d.ts +5 -0
  18. package/dist/core/annotations/types.d.ts +157 -0
  19. package/dist/core/chart/ChartCore.d.ts +103 -0
  20. package/dist/core/chart/ChartExporter.d.ts +18 -0
  21. package/dist/core/chart/ChartNavigation.d.ts +33 -0
  22. package/dist/core/chart/ChartRenderer.d.ts +53 -0
  23. package/dist/core/chart/ChartScaling.d.ts +26 -0
  24. package/dist/core/chart/ChartSeries.d.ts +4 -0
  25. package/dist/core/chart/ChartSetup.d.ts +64 -0
  26. package/dist/core/chart/ChartUI.d.ts +22 -0
  27. package/dist/core/chart/exporter/SVGExporter.d.ts +6 -0
  28. package/dist/core/chart/exporter/index.d.ts +5 -0
  29. package/dist/core/chart/index.d.ts +14 -0
  30. package/dist/core/chart/plugins/PluginManager.d.ts +13 -0
  31. package/dist/core/chart/plugins/types.d.ts +13 -0
  32. package/dist/core/chart/series/SeriesActions.d.ts +7 -0
  33. package/dist/core/chart/series/SeriesBuffer.d.ts +4 -0
  34. package/dist/core/chart/series/SeriesFit.d.ts +3 -0
  35. package/dist/core/chart/series/index.d.ts +7 -0
  36. package/dist/core/chart/series/types.d.ts +22 -0
  37. package/dist/core/chart/types.d.ts +72 -0
  38. package/dist/core/index.d.ts +9 -0
  39. package/dist/core/series/Series.d.ts +52 -0
  40. package/dist/core/series/SeriesBounds.d.ts +3 -0
  41. package/dist/core/series/SeriesDataUtils.d.ts +7 -0
  42. package/dist/core/series/index.d.ts +6 -0
  43. package/dist/core/tooltip/TooltipManager.d.ts +203 -0
  44. package/dist/core/tooltip/TooltipPositioner.d.ts +83 -0
  45. package/dist/core/tooltip/TooltipRenderer.d.ts +64 -0
  46. package/dist/core/tooltip/index.d.ts +18 -0
  47. package/dist/core/tooltip/templates/AnnotationTemplate.d.ts +18 -0
  48. package/dist/core/tooltip/templates/CrosshairTemplate.d.ts +30 -0
  49. package/dist/core/tooltip/templates/DefaultTemplate.d.ts +30 -0
  50. package/dist/core/tooltip/templates/HeatmapTemplate.d.ts +34 -0
  51. package/dist/core/tooltip/templates/MinimalTemplate.d.ts +26 -0
  52. package/dist/core/tooltip/templates/RangeTemplate.d.ts +18 -0
  53. package/dist/core/tooltip/templates/ScientificTemplate.d.ts +34 -0
  54. package/dist/core/tooltip/templates/index.d.ts +27 -0
  55. package/dist/core/tooltip/themes.d.ts +48 -0
  56. package/dist/core/tooltip/types.d.ts +396 -0
  57. package/dist/examples.d.ts +19 -0
  58. package/dist/gpu/adapter/gpuRenderer.d.ts +135 -0
  59. package/dist/gpu/adapter/index.d.ts +7 -0
  60. package/dist/gpu/adapter/seriesAdapter.d.ts +88 -0
  61. package/dist/gpu/backends/webgl/WebGLBackend.d.ts +42 -0
  62. package/dist/gpu/backends/webgl/index.d.ts +5 -0
  63. package/dist/gpu/backends/webgl/programFactory.d.ts +30 -0
  64. package/dist/gpu/backends/webgl/shaders.d.ts +14 -0
  65. package/dist/gpu/backends/webgpu/MassiveDataRenderer.d.ts +111 -0
  66. package/dist/gpu/backends/webgpu/WebGPUBackend.d.ts +58 -0
  67. package/dist/gpu/backends/webgpu/pipelines/bandPipeline.d.ts +24 -0
  68. package/dist/gpu/backends/webgpu/pipelines/heatmapPipeline.d.ts +28 -0
  69. package/dist/gpu/backends/webgpu/pipelines/index.d.ts +10 -0
  70. package/dist/gpu/backends/webgpu/pipelines/instancedLinePipeline.d.ts +23 -0
  71. package/dist/gpu/backends/webgpu/pipelines/instancedPointPipeline.d.ts +25 -0
  72. package/dist/gpu/backends/webgpu/pipelines/linePipeline.d.ts +23 -0
  73. package/dist/gpu/backends/webgpu/pipelines/pointPipeline.d.ts +28 -0
  74. package/dist/gpu/backends/webgpu/pipelines/trianglePipeline.d.ts +5 -0
  75. package/dist/gpu/backends/webgpu/pipelines/triangleShader.d.ts +1 -0
  76. package/dist/gpu/backends/webgpu/shaders/heatmap.wgsl.d.ts +8 -0
  77. package/dist/gpu/backends/webgpu/shaders/index.d.ts +8 -0
  78. package/dist/gpu/backends/webgpu/shaders/instanced.wgsl.d.ts +16 -0
  79. package/dist/gpu/backends/webgpu/shaders/line.wgsl.d.ts +8 -0
  80. package/dist/gpu/backends/webgpu/shaders/point.wgsl.d.ts +9 -0
  81. package/dist/gpu/benchmark/benchmark.d.ts +74 -0
  82. package/dist/gpu/benchmark/index.d.ts +5 -0
  83. package/dist/gpu/compute/gpuCompute.d.ts +72 -0
  84. package/dist/gpu/compute/index.d.ts +6 -0
  85. package/dist/gpu/compute/shaders.d.ts +9 -0
  86. package/dist/gpu/drawList.d.ts +77 -0
  87. package/dist/gpu/examples/gallery.d.ts +20 -0
  88. package/dist/gpu/examples/index.d.ts +3 -0
  89. package/dist/gpu/examples/webgpu-line-demo.d.ts +8 -0
  90. package/dist/gpu/examples/webgpu-triangle.d.ts +1 -0
  91. package/dist/gpu/frame.d.ts +25 -0
  92. package/dist/gpu/index.d.ts +24 -0
  93. package/dist/gpu/resources/bufferStore.d.ts +40 -0
  94. package/dist/gpu/resources/index.d.ts +9 -0
  95. package/dist/gpu/resources/pipelineCache.d.ts +33 -0
  96. package/dist/gpu/resources/textureStore.d.ts +41 -0
  97. package/dist/gpu/types.d.ts +47 -0
  98. package/dist/index.d.ts +34 -0
  99. package/dist/overlay/CanvasOverlay.d.ts +102 -0
  100. package/dist/overlay/index.d.ts +4 -0
  101. package/dist/react/SciChart.d.ts +60 -0
  102. package/dist/react/index.d.ts +5 -0
  103. package/dist/react/useSciChart.d.ts +56 -0
  104. package/dist/renderer/BarRenderer.d.ts +14 -0
  105. package/dist/renderer/CandlestickRenderer.d.ts +12 -0
  106. package/dist/renderer/HeatmapRenderer.d.ts +15 -0
  107. package/dist/renderer/NativeWebGLRenderer.d.ts +16 -0
  108. package/dist/renderer/RendererInterface.d.ts +70 -0
  109. package/dist/renderer/WebGPURenderer.d.ts +16 -0
  110. package/dist/renderer/index.d.ts +10 -0
  111. package/dist/renderer/native/NativeWebGLRenderer.d.ts +30 -0
  112. package/dist/renderer/native/bufferStore.d.ts +11 -0
  113. package/dist/renderer/native/draw.d.ts +31 -0
  114. package/dist/renderer/native/programFactory.d.ts +3 -0
  115. package/dist/renderer/native/renderFrame.d.ts +3 -0
  116. package/dist/renderer/native/shaderSources.d.ts +6 -0
  117. package/dist/renderer/native/textureStore.d.ts +8 -0
  118. package/dist/renderer/native/types.d.ts +58 -0
  119. package/dist/renderer/native/utils.d.ts +4 -0
  120. package/dist/renderer/shaders.d.ts +77 -0
  121. package/dist/scales/index.d.ts +54 -0
  122. package/dist/scichart-engine.es.js +8408 -0
  123. package/dist/scichart-engine.es.js.map +1 -0
  124. package/dist/scichart-engine.umd.js +871 -0
  125. package/dist/scichart-engine.umd.js.map +1 -0
  126. package/dist/streaming/index.d.ts +7 -0
  127. package/dist/streaming/mock.d.ts +12 -0
  128. package/dist/streaming/types.d.ts +57 -0
  129. package/dist/streaming/utils.d.ts +19 -0
  130. package/dist/streaming/websocket.d.ts +6 -0
  131. package/dist/theme/index.d.ts +123 -0
  132. package/dist/types.d.ts +333 -0
  133. package/dist/workers/downsample.d.ts +34 -0
  134. package/dist/workers/downsample.worker.d.ts +46 -0
  135. package/package.json +59 -0
@@ -0,0 +1,88 @@
1
+ import { DrawList } from '../drawList';
2
+ import { GpuBackend, RGBA } from '../types';
3
+
4
+ /**
5
+ * Series style from the original renderer
6
+ */
7
+ export interface SeriesStyle {
8
+ color?: string | RGBA;
9
+ opacity?: number;
10
+ lineWidth?: number;
11
+ pointSize?: number;
12
+ symbol?: string;
13
+ }
14
+ /**
15
+ * Series render data from the chart system
16
+ */
17
+ export interface SeriesData {
18
+ id: string;
19
+ type: "line" | "scatter" | "line+scatter" | "step" | "step+scatter" | "band" | "bar" | "heatmap";
20
+ visible: boolean;
21
+ /** Main vertex data */
22
+ data: Float32Array;
23
+ /** Style properties */
24
+ style: SeriesStyle;
25
+ /** For step charts */
26
+ stepData?: Float32Array;
27
+ /** Y-axis bounds for multi-axis support */
28
+ yBounds?: {
29
+ min: number;
30
+ max: number;
31
+ };
32
+ /** For heatmaps */
33
+ zBounds?: {
34
+ min: number;
35
+ max: number;
36
+ };
37
+ colormapData?: Uint8Array;
38
+ colormap?: string;
39
+ }
40
+ /**
41
+ * Mutable color tuple for internal use
42
+ */
43
+ type MutableRGBA = [number, number, number, number];
44
+ /**
45
+ * Parse color from various formats to RGBA
46
+ */
47
+ export declare function parseColorToRGBA(color: string | RGBA | undefined): MutableRGBA;
48
+ /**
49
+ * Series Adapter class
50
+ *
51
+ * Manages the conversion of chart series to GPU resources and draw calls.
52
+ */
53
+ export declare class SeriesAdapter {
54
+ private backend;
55
+ private seriesBufferMap;
56
+ private seriesStepBufferMap;
57
+ private seriesTextureMap;
58
+ constructor(backend: GpuBackend);
59
+ /**
60
+ * Get buffer ID for a series
61
+ */
62
+ private getBufferId;
63
+ /**
64
+ * Get step buffer ID for a series
65
+ */
66
+ private getStepBufferId;
67
+ /**
68
+ * Get texture ID for a series
69
+ */
70
+ private getTextureId;
71
+ /**
72
+ * Update series data in GPU buffers
73
+ */
74
+ updateSeries(series: SeriesData): void;
75
+ /**
76
+ * Remove a series from GPU resources
77
+ */
78
+ removeSeries(seriesId: string): void;
79
+ /**
80
+ * Build draw list from series array
81
+ */
82
+ buildDrawList(seriesArray: SeriesData[]): DrawList;
83
+ /**
84
+ * Cleanup all resources
85
+ */
86
+ destroy(): void;
87
+ }
88
+ export {};
@@ -0,0 +1,42 @@
1
+ import { BufferDescriptor, BufferId, GpuBackend, GpuBackendInfo, GpuViewport, Texture1DDescriptor, TextureId } from '../../types';
2
+ import { DrawList } from '../../drawList';
3
+ import { FrameUniforms } from '../../frame';
4
+
5
+ export interface WebGLBackendOptions {
6
+ antialias?: boolean;
7
+ preserveDrawingBuffer?: boolean;
8
+ powerPreference?: "default" | "low-power" | "high-performance";
9
+ }
10
+ export declare class WebGLBackend implements GpuBackend {
11
+ readonly info: GpuBackendInfo;
12
+ private canvas;
13
+ private opts;
14
+ private gl;
15
+ private viewport;
16
+ private dpr;
17
+ private programs;
18
+ private buffers;
19
+ private textures;
20
+ constructor(canvas: HTMLCanvasElement, opts?: WebGLBackendOptions);
21
+ static isSupported(): boolean;
22
+ init(): Promise<void>;
23
+ setViewport(viewport: GpuViewport): void;
24
+ createOrUpdateBuffer(id: BufferId, data: ArrayBufferView, desc?: Partial<BufferDescriptor>): void;
25
+ deleteBuffer(id: BufferId): void;
26
+ createOrUpdateTexture1D(id: TextureId, data: Uint8Array, desc?: Partial<Texture1DDescriptor>): void;
27
+ deleteTexture(id: TextureId): void;
28
+ render(drawList: DrawList, frame: FrameUniforms): void;
29
+ renderWithBounds(drawList: DrawList, frame: FrameUniforms, bounds: {
30
+ xMin: number;
31
+ xMax: number;
32
+ yMin: number;
33
+ yMax: number;
34
+ }): void;
35
+ private renderDrawCall;
36
+ private renderLine;
37
+ private renderPoints;
38
+ private renderBand;
39
+ private renderTriangles;
40
+ private renderHeatmap;
41
+ destroy(): void;
42
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * WebGL Backend Index
3
+ */
4
+ export { WebGLBackend } from './WebGLBackend';
5
+ export type { WebGLBackendOptions } from './WebGLBackend';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * WebGL Program Factory
3
+ *
4
+ * Utilities for compiling and linking WebGL shader programs.
5
+ */
6
+ export interface ShaderProgram {
7
+ program: WebGLProgram;
8
+ attributes: Record<string, number>;
9
+ uniforms: Record<string, WebGLUniformLocation | null>;
10
+ }
11
+ /**
12
+ * Create a shader program from source
13
+ */
14
+ export declare function createProgram(gl: WebGLRenderingContext, vertSource: string, fragSource: string, attributeNames: string[], uniformNames: string[]): ShaderProgram;
15
+ /**
16
+ * All programs used by the WebGL backend
17
+ */
18
+ export interface ProgramBundle {
19
+ line: ShaderProgram;
20
+ point: ShaderProgram;
21
+ heatmap: ShaderProgram;
22
+ }
23
+ /**
24
+ * Create all shader programs
25
+ */
26
+ export declare function createAllPrograms(gl: WebGLRenderingContext): ProgramBundle;
27
+ /**
28
+ * Destroy all programs
29
+ */
30
+ export declare function destroyPrograms(gl: WebGLRenderingContext, bundle: ProgramBundle): void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WebGL Shader Sources
3
+ *
4
+ * GLSL shaders for the WebGL backend.
5
+ * These match the functionality of the WebGPU WGSL shaders.
6
+ */
7
+ export declare const LINE_VERT_GLSL = "\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n}\n";
8
+ export declare const LINE_FRAG_GLSL = "\nprecision highp float;\nuniform vec4 uColor;\n\nvoid main() {\n gl_FragColor = uColor;\n}\n";
9
+ export declare const POINT_VERT_GLSL = "\nprecision highp float;\nattribute vec2 aPosition;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nuniform float uPointSize;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n gl_PointSize = uPointSize;\n}\n";
10
+ export declare const POINT_FRAG_GLSL = "\nprecision highp float;\nuniform vec4 uColor;\nuniform int uSymbol;\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdBox(vec2 p, vec2 b) {\n vec2 d = abs(p) - b;\n return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);\n}\n\nfloat sdTriangle(vec2 p, float r) {\n const float k = sqrt(3.0);\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) p = vec2(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n p.x -= clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfloat sdDiamond(vec2 p, float r) {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfloat sdCross(vec2 p, float r, float thickness) {\n vec2 d = abs(p);\n float s1 = sdBox(d, vec2(r, thickness));\n float s2 = sdBox(d, vec2(thickness, r));\n return min(s1, s2);\n}\n\nfloat sdX(vec2 p, float r, float thickness) {\n float c = cos(0.785398);\n float s = sin(0.785398);\n mat2 m = mat2(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfloat sdStar(vec2 p, float r, float rf) {\n const vec2 k1 = vec2(0.80901699, -0.58778525);\n const vec2 k2 = vec2(-k1.x, k1.y);\n p.x = abs(p.x);\n p -= 2.0 * max(dot(k1, p), 0.0) * k1;\n p -= 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y -= r;\n vec2 ba = rf * vec2(-k1.y, k1.x) - vec2(0, 1);\n float h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\nvoid main() {\n vec2 p = gl_PointCoord - vec2(0.5);\n float d = 0.0;\n\n if (uSymbol == 0) {\n d = sdCircle(p, 0.45);\n } else if (uSymbol == 1) {\n d = sdBox(p, vec2(0.35));\n } else if (uSymbol == 2) {\n d = sdDiamond(p, 0.45);\n } else if (uSymbol == 3) {\n d = sdTriangle(vec2(p.x, p.y + 0.1), 0.4);\n } else if (uSymbol == 4) {\n d = sdTriangle(vec2(p.x, -p.y + 0.1), 0.4);\n } else if (uSymbol == 5) {\n d = sdCross(p, 0.45, 0.15);\n } else if (uSymbol == 6) {\n d = sdX(p, 0.45, 0.15);\n } else if (uSymbol == 7) {\n d = sdStar(p, 0.45, 0.4);\n }\n\n if (d > 0.02) discard;\n\n float alpha = 1.0 - smoothstep(0.0, 0.02, d);\n gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\n}\n";
11
+ export declare const HEATMAP_VERT_GLSL = "\nprecision highp float;\nattribute vec2 aPosition;\nattribute float aValue;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying float vValue;\n\nvoid main() {\n gl_Position = vec4(aPosition * uScale + uTranslate, 0.0, 1.0);\n vValue = aValue;\n}\n";
12
+ export declare const HEATMAP_FRAG_GLSL = "\nprecision highp float;\nvarying float vValue;\nuniform float uMinValue;\nuniform float uMaxValue;\nuniform sampler2D uColormap;\n\nvoid main() {\n float range = uMaxValue - uMinValue;\n float t = (vValue - uMinValue) / (range != 0.0 ? range : 1.0);\n t = clamp(t, 0.0, 1.0);\n gl_FragColor = texture2D(uColormap, vec2(t, 0.5));\n}\n";
13
+ export declare const TRIANGLE_VERT_GLSL = "\nprecision highp float;\nattribute vec2 aPosition;\nattribute vec4 aColor;\nuniform vec2 uScale;\nuniform vec2 uTranslate;\nvarying vec4 vColor;\n\nvoid main() {\n vec2 pos = aPosition * uScale + uTranslate;\n gl_Position = vec4(pos, 0.0, 1.0);\n vColor = aColor;\n}\n";
14
+ export declare const TRIANGLE_FRAG_GLSL = "\nprecision highp float;\nvarying vec4 vColor;\n\nvoid main() {\n gl_FragColor = vColor;\n}\n";
@@ -0,0 +1,111 @@
1
+ /**
2
+ * MassiveDataRenderer - Optimized renderer for 100M+ points
3
+ *
4
+ * Features:
5
+ * - Chunked buffer upload with progress
6
+ * - Batched draw calls to avoid GPU timeout
7
+ * - LOD (Level of Detail) with GPU downsampling
8
+ * - Storage buffers for instanced rendering
9
+ * - Streaming data generation
10
+ */
11
+ export interface MassiveDataConfig {
12
+ maxPointsPerBatch: number;
13
+ chunkSizeBytes: number;
14
+ enableLOD: boolean;
15
+ lodLevels: number;
16
+ onProgress?: (phase: string, progress: number) => void;
17
+ onStats?: (stats: RenderStats) => void;
18
+ }
19
+ export interface RenderStats {
20
+ totalPoints: number;
21
+ renderedPoints: number;
22
+ bufferSizeMB: number;
23
+ uploadTimeMs: number;
24
+ frameTimeMs: number;
25
+ fps: number;
26
+ lodLevel: number;
27
+ batchCount: number;
28
+ }
29
+ export interface LODLevel {
30
+ buffer: any;
31
+ pointCount: number;
32
+ factor: number;
33
+ }
34
+ export declare class MassiveDataRenderer {
35
+ private device;
36
+ private context;
37
+ private format;
38
+ private config;
39
+ private linePipeline;
40
+ private lineBindGroupLayout;
41
+ private uniformBuffer;
42
+ private storageBuffer;
43
+ private bindGroup;
44
+ private totalPoints;
45
+ private lodLevels;
46
+ private currentLOD;
47
+ private lastFrameTime;
48
+ private frameCount;
49
+ private lastFpsTime;
50
+ private currentFps;
51
+ private viewport;
52
+ constructor(device: any, // GPUDevice
53
+ context: any, // GPUCanvasContext
54
+ format: any, // GPUTextureFormat
55
+ config?: Partial<MassiveDataConfig>);
56
+ /**
57
+ * Initialize render pipelines
58
+ */
59
+ init(): Promise<void>;
60
+ /**
61
+ * Set viewport dimensions
62
+ */
63
+ setViewport(width: number, height: number): void;
64
+ /**
65
+ * Upload data with chunked progress
66
+ */
67
+ uploadData(data: Float32Array): Promise<void>;
68
+ /**
69
+ * Build LOD levels using GPU downsampling
70
+ */
71
+ private buildLOD;
72
+ /**
73
+ * Select appropriate LOD level based on visible range
74
+ */
75
+ selectLOD(visibleRange: number, totalRange: number): number;
76
+ /**
77
+ * Render frame with batching
78
+ */
79
+ render(options: {
80
+ bounds: {
81
+ xMin: number;
82
+ xMax: number;
83
+ yMin: number;
84
+ yMax: number;
85
+ };
86
+ color?: [number, number, number, number];
87
+ lineWidth?: number;
88
+ time?: number;
89
+ lodLevel?: number;
90
+ }): void;
91
+ /**
92
+ * Generate streaming sine wave data
93
+ */
94
+ static generateSineWaveData(pointCount: number, onProgress?: (progress: number) => void): Promise<Float32Array>;
95
+ /**
96
+ * Get current stats
97
+ */
98
+ getStats(): RenderStats;
99
+ /**
100
+ * Get available LOD levels
101
+ */
102
+ getLODLevels(): {
103
+ level: number;
104
+ pointCount: number;
105
+ factor: number;
106
+ }[];
107
+ /**
108
+ * Cleanup resources
109
+ */
110
+ destroy(): void;
111
+ }
@@ -0,0 +1,58 @@
1
+ import { BufferDescriptor, BufferId, GpuBackend, GpuBackendInfo, GpuViewport, Texture1DDescriptor, TextureId } from '../../types';
2
+ import { DrawList } from '../../drawList';
3
+ import { FrameUniforms } from '../../frame';
4
+
5
+ export interface WebGPUBackendOptions {
6
+ powerPreference?: "low-power" | "high-performance";
7
+ preferredFormat?: string;
8
+ }
9
+ export declare class WebGPUBackend implements GpuBackend {
10
+ readonly info: GpuBackendInfo;
11
+ private canvas;
12
+ private opts;
13
+ private viewport;
14
+ private adapter;
15
+ private device;
16
+ private context;
17
+ private format;
18
+ private buffers;
19
+ private textures;
20
+ private trianglePipeline;
21
+ private linePipeline;
22
+ private pointPipeline;
23
+ private bandPipeline;
24
+ private heatmapPipeline;
25
+ private heatmapBindGroups;
26
+ constructor(canvas: HTMLCanvasElement, opts?: WebGPUBackendOptions);
27
+ static isSupported(): boolean;
28
+ init(): Promise<void>;
29
+ setViewport(viewport: GpuViewport): void;
30
+ createOrUpdateBuffer(id: BufferId, data: ArrayBufferView, desc?: Partial<BufferDescriptor>): void;
31
+ deleteBuffer(id: BufferId): void;
32
+ createOrUpdateTexture1D(id: TextureId, data: Uint8Array, desc?: Partial<Texture1DDescriptor>): void;
33
+ deleteTexture(id: TextureId): void;
34
+ /**
35
+ * Initialize all pipelines lazily
36
+ */
37
+ private ensurePipelines;
38
+ render(drawList: DrawList, frame: FrameUniforms): void;
39
+ /**
40
+ * Render with explicit bounds (for integration with chart system)
41
+ */
42
+ renderWithBounds(drawList: DrawList, frame: FrameUniforms, bounds: {
43
+ xMin: number;
44
+ xMax: number;
45
+ yMin: number;
46
+ yMax: number;
47
+ }): void;
48
+ /**
49
+ * Render a single draw call
50
+ */
51
+ private renderDrawCall;
52
+ private renderTriangles;
53
+ private renderLine;
54
+ private renderPoints;
55
+ private renderBand;
56
+ private renderHeatmap;
57
+ destroy(): void;
58
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Band Pipeline - WebGPU pipeline for rendering band/area fills
3
+ *
4
+ * Uses triangle-strip topology for efficient area rendering.
5
+ * Reuses the line shader with different primitive topology.
6
+ * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.
7
+ */
8
+ export interface BandPipelineBundle {
9
+ pipeline: any;
10
+ bindGroupLayout: any;
11
+ uniformBuffer: any;
12
+ bindGroup: any;
13
+ vertexStride: number;
14
+ }
15
+ export interface BandUniforms {
16
+ scale: [number, number];
17
+ translate: [number, number];
18
+ color: [number, number, number, number];
19
+ }
20
+ export declare function createBandPipeline(device: any, // GPUDevice
21
+ format: string): BandPipelineBundle;
22
+ export declare function updateBandUniforms(device: any, // GPUDevice
23
+ uniformBuffer: any, // GPUBuffer
24
+ uniforms: BandUniforms): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Heatmap Pipeline - WebGPU pipeline for rendering heatmaps with colormap textures
3
+ *
4
+ * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.
5
+ */
6
+ export interface HeatmapPipelineBundle {
7
+ pipeline: any;
8
+ bindGroupLayout: any;
9
+ uniformBuffer: any;
10
+ sampler: any;
11
+ vertexStride: number;
12
+ }
13
+ export interface HeatmapUniforms {
14
+ scale: [number, number];
15
+ translate: [number, number];
16
+ minValue: number;
17
+ maxValue: number;
18
+ }
19
+ export declare function createHeatmapPipeline(device: any, // GPUDevice
20
+ format: string): HeatmapPipelineBundle;
21
+ export declare function createHeatmapBindGroup(device: any, // GPUDevice
22
+ layout: any, // GPUBindGroupLayout
23
+ uniformBuffer: any, // GPUBuffer
24
+ sampler: any, // GPUSampler
25
+ colormapTexture: any): any;
26
+ export declare function updateHeatmapUniforms(device: any, // GPUDevice
27
+ uniformBuffer: any, // GPUBuffer
28
+ uniforms: HeatmapUniforms): void;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Pipeline Index - Export all WebGPU pipelines
3
+ */
4
+ export { createTrianglePipeline, type TrianglePipelineBundle, } from './trianglePipeline';
5
+ export { createLinePipeline, updateLineUniforms, type LinePipelineBundle, type LineUniforms, } from './linePipeline';
6
+ export { createPointPipeline, updatePointUniforms, SYMBOL_MAP, type PointPipelineBundle, type PointUniforms, } from './pointPipeline';
7
+ export { createHeatmapPipeline, createHeatmapBindGroup, updateHeatmapUniforms, type HeatmapPipelineBundle, type HeatmapUniforms, } from './heatmapPipeline';
8
+ export { createBandPipeline, updateBandUniforms, type BandPipelineBundle, type BandUniforms, } from './bandPipeline';
9
+ export { createInstancedLinePipeline, createInstancedLineBindGroup, updateInstancedLineUniforms, type InstancedLinePipelineBundle, type InstancedLineUniforms, } from './instancedLinePipeline';
10
+ export { createInstancedPointPipeline, createInstancedPointBindGroup, updateInstancedPointUniforms, SYMBOL_TYPE_MAP, type InstancedPointPipelineBundle, type InstancedPointUniforms, } from './instancedPointPipeline';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Instanced Line Pipeline - For rendering large datasets efficiently
3
+ *
4
+ * Uses storage buffers and instancing to render millions of line segments.
5
+ * Each instance represents one line segment between consecutive points.
6
+ */
7
+ export interface InstancedLinePipelineBundle {
8
+ pipeline: any;
9
+ bindGroupLayout: any;
10
+ uniformBuffer: any;
11
+ vertexStride: number;
12
+ }
13
+ export interface InstancedLineUniforms {
14
+ scale: [number, number];
15
+ translate: [number, number];
16
+ color: [number, number, number, number];
17
+ lineWidth: number;
18
+ aspectRatio: number;
19
+ pointCount: number;
20
+ }
21
+ export declare function createInstancedLinePipeline(device: any, format: string): InstancedLinePipelineBundle;
22
+ export declare function createInstancedLineBindGroup(device: any, layout: any, uniformBuffer: any, pointBuffer: any): any;
23
+ export declare function updateInstancedLineUniforms(device: any, uniformBuffer: any, uniforms: InstancedLineUniforms): void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Instanced Point Pipeline - For rendering large scatter datasets
3
+ *
4
+ * Uses storage buffers and instancing to render millions of points.
5
+ */
6
+ export interface InstancedPointPipelineBundle {
7
+ pipeline: any;
8
+ bindGroupLayout: any;
9
+ uniformBuffer: any;
10
+ vertexStride: number;
11
+ }
12
+ export interface InstancedPointUniforms {
13
+ scale: [number, number];
14
+ translate: [number, number];
15
+ color: [number, number, number, number];
16
+ pointSize: number;
17
+ symbolType: number;
18
+ viewportWidth: number;
19
+ viewportHeight: number;
20
+ pointCount: number;
21
+ }
22
+ export declare function createInstancedPointPipeline(device: any, format: string): InstancedPointPipelineBundle;
23
+ export declare function createInstancedPointBindGroup(device: any, layout: any, uniformBuffer: any, pointBuffer: any): any;
24
+ export declare function updateInstancedPointUniforms(device: any, uniformBuffer: any, uniforms: InstancedPointUniforms): void;
25
+ export declare const SYMBOL_TYPE_MAP: Record<string, number>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Line Pipeline - WebGPU pipeline for rendering lines with uniform buffer
3
+ *
4
+ * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types
5
+ * (following the pattern of the original WebGPUBackend.ts)
6
+ */
7
+ export interface LinePipelineBundle {
8
+ pipeline: any;
9
+ bindGroupLayout: any;
10
+ uniformBuffer: any;
11
+ bindGroup: any;
12
+ vertexStride: number;
13
+ }
14
+ export interface LineUniforms {
15
+ scale: [number, number];
16
+ translate: [number, number];
17
+ color: [number, number, number, number];
18
+ }
19
+ export declare function createLinePipeline(device: any, // GPUDevice
20
+ format: string): LinePipelineBundle;
21
+ export declare function updateLineUniforms(device: any, // GPUDevice
22
+ uniformBuffer: any, // GPUBuffer
23
+ uniforms: LineUniforms): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Point Pipeline - WebGPU pipeline for rendering scatter points with SDF symbols
3
+ *
4
+ * Uses instanced rendering where each point is rendered as a quad (2 triangles).
5
+ * Uses `any` types for WebGPU objects to avoid requiring @webgpu/types.
6
+ */
7
+ export interface PointPipelineBundle {
8
+ pipeline: any;
9
+ bindGroupLayout: any;
10
+ uniformBuffer: any;
11
+ bindGroup: any;
12
+ quadBuffer: any;
13
+ vertexStride: number;
14
+ }
15
+ export interface PointUniforms {
16
+ scale: [number, number];
17
+ translate: [number, number];
18
+ color: [number, number, number, number];
19
+ pointSize: number;
20
+ symbol: number;
21
+ viewport: [number, number];
22
+ }
23
+ export declare function createPointPipeline(device: any, // GPUDevice
24
+ format: string): PointPipelineBundle;
25
+ export declare function updatePointUniforms(device: any, // GPUDevice
26
+ uniformBuffer: any, // GPUBuffer
27
+ uniforms: PointUniforms): void;
28
+ export declare const SYMBOL_MAP: Record<string, number>;
@@ -0,0 +1,5 @@
1
+ export interface TrianglePipelineBundle {
2
+ pipeline: any;
3
+ vertexStride: number;
4
+ }
5
+ export declare function createTrianglePipeline(device: any, format: string): TrianglePipelineBundle;
@@ -0,0 +1 @@
1
+ export declare const TRIANGLE_SHADER_WGSL = "\nstruct VSOut {\n @builtin(position) pos: vec4<f32>,\n @location(0) color: vec4<f32>,\n};\n\n@vertex\nfn vs_main(\n @location(0) position: vec2<f32>,\n @location(1) color: vec4<f32>\n) -> VSOut {\n var out: VSOut;\n out.pos = vec4<f32>(position, 0.0, 1.0);\n out.color = color;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOut) -> @location(0) vec4<f32> {\n return in.color;\n}\n";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Heatmap Shader - WGSL for WebGPU
3
+ *
4
+ * Renders heatmap cells with colormap texture lookup.
5
+ * Each vertex has position (x, y) and value (z) for color mapping.
6
+ */
7
+ export declare const HEATMAP_SHADER_WGSL = "\n// Uniform buffer for transforms and value range\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n minValue: f32,\n maxValue: f32,\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\n@group(0) @binding(1)\nvar colormapSampler: sampler;\n\n@group(0) @binding(2)\nvar colormapTexture: texture_1d<f32>;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n @location(1) value: f32,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) value: f32,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.value = in.value;\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n let range = uniforms.maxValue - uniforms.minValue;\n var t: f32;\n if (range != 0.0) {\n t = (in.value - uniforms.minValue) / range;\n } else {\n t = 0.0;\n }\n t = clamp(t, 0.0, 1.0);\n \n return textureSample(colormapTexture, colormapSampler, t);\n}\n";
8
+ export declare const HEATMAP_VERTEX_STRIDE: number;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shader Index - Export all WGSL shaders
3
+ */
4
+ export { TRIANGLE_SHADER_WGSL } from '../pipelines/triangleShader';
5
+ export { LINE_SHADER_WGSL, LINE_VERTEX_STRIDE } from './line.wgsl';
6
+ export { POINT_SHADER_WGSL, POINT_QUAD_SHADER_WGSL, POINT_VERTEX_STRIDE, } from './point.wgsl';
7
+ export { HEATMAP_SHADER_WGSL, HEATMAP_VERTEX_STRIDE, } from './heatmap.wgsl';
8
+ export { INSTANCED_LINE_SHADER_WGSL, INSTANCED_POINT_SHADER_WGSL, INSTANCED_LINE_VERTEX_STRIDE, INSTANCED_POINT_VERTEX_STRIDE, } from './instanced.wgsl';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Instanced Line Shader - For ultra-large datasets
3
+ *
4
+ * Uses instancing to render line segments efficiently.
5
+ * Each instance renders a line segment between two consecutive points.
6
+ */
7
+ export declare const INSTANCED_LINE_SHADER_WGSL = "\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n lineWidth: f32,\n aspectRatio: f32,\n pointCount: u32,\n padding: u32,\n}\n\nstruct Point {\n x: f32,\n y: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n@group(0) @binding(1) var<storage, read> points: array<Point>;\n\nstruct VertexOut {\n @builtin(position) position: vec4<f32>,\n @location(0) @interpolate(flat) segment_index: u32,\n}\n\n@vertex\nfn vs_main(\n @builtin(vertex_index) vertex_index: u32,\n @builtin(instance_index) instance_index: u32\n) -> VertexOut {\n var out: VertexOut;\n out.segment_index = instance_index;\n \n // Skip if beyond point count\n if (instance_index >= uniforms.pointCount - 1u) {\n out.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);\n return out;\n }\n \n // Get the two points for this segment\n let p0 = points[instance_index];\n let p1 = points[instance_index + 1u];\n \n // Transform points to clip space\n let pos0 = vec2<f32>(p0.x * uniforms.scale.x + uniforms.translate.x,\n p0.y * uniforms.scale.y + uniforms.translate.y);\n let pos1 = vec2<f32>(p1.x * uniforms.scale.x + uniforms.translate.x,\n p1.y * uniforms.scale.y + uniforms.translate.y);\n \n // Calculate line direction and perpendicular\n let dir = normalize(pos1 - pos0);\n let perp = vec2<f32>(-dir.y, dir.x);\n \n // Adjust for aspect ratio\n let width = uniforms.lineWidth / 500.0; // Normalized width\n let offset = perp * width;\n \n // Each segment is a quad (2 triangles, 6 vertices)\n // vertex_index: 0,1,2 = first triangle, 3,4,5 = second triangle\n var pos: vec2<f32>;\n \n switch (vertex_index % 6u) {\n case 0u: { pos = pos0 - offset; } // bottom-left of start\n case 1u: { pos = pos0 + offset; } // top-left of start\n case 2u: { pos = pos1 - offset; } // bottom-left of end\n case 3u: { pos = pos1 - offset; } // bottom-left of end\n case 4u: { pos = pos0 + offset; } // top-left of start\n case 5u: { pos = pos1 + offset; } // top-left of end\n default: { pos = pos0; }\n }\n \n out.position = vec4<f32>(pos, 0.0, 1.0);\n return out;\n}\n\n@fragment\nfn fs_main(in: VertexOut) -> @location(0) vec4<f32> {\n return uniforms.color;\n}\n";
8
+ /**
9
+ * Instanced Point Shader - For ultra-large scatter datasets
10
+ *
11
+ * Uses instancing with a quad per point.
12
+ * Supports SDF-based symbols.
13
+ */
14
+ export declare const INSTANCED_POINT_SHADER_WGSL = "\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbolType: i32,\n viewportWidth: f32,\n viewportHeight: f32,\n pointCount: u32,\n padding: vec3<u32>,\n}\n\nstruct Point {\n x: f32,\n y: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n@group(0) @binding(1) var<storage, read> points: array<Point>;\n\nstruct VertexOut {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>,\n}\n\n@vertex\nfn vs_main(\n @builtin(vertex_index) vertex_index: u32,\n @builtin(instance_index) instance_index: u32\n) -> VertexOut {\n var out: VertexOut;\n \n if (instance_index >= uniforms.pointCount) {\n out.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);\n out.uv = vec2<f32>(0.0, 0.0);\n return out;\n }\n \n let pt = points[instance_index];\n \n // Transform point center to clip space\n let center = vec2<f32>(\n pt.x * uniforms.scale.x + uniforms.translate.x,\n pt.y * uniforms.scale.y + uniforms.translate.y\n );\n \n // Calculate point size in clip space\n let sizeX = uniforms.pointSize / uniforms.viewportWidth * 2.0;\n let sizeY = uniforms.pointSize / uniforms.viewportHeight * 2.0;\n \n // Quad vertices (6 for 2 triangles)\n var offset: vec2<f32>;\n var uv: vec2<f32>;\n \n switch (vertex_index % 6u) {\n case 0u: { offset = vec2<f32>(-sizeX, -sizeY); uv = vec2<f32>(-1.0, -1.0); }\n case 1u: { offset = vec2<f32>( sizeX, -sizeY); uv = vec2<f32>( 1.0, -1.0); }\n case 2u: { offset = vec2<f32>(-sizeX, sizeY); uv = vec2<f32>(-1.0, 1.0); }\n case 3u: { offset = vec2<f32>(-sizeX, sizeY); uv = vec2<f32>(-1.0, 1.0); }\n case 4u: { offset = vec2<f32>( sizeX, -sizeY); uv = vec2<f32>( 1.0, -1.0); }\n case 5u: { offset = vec2<f32>( sizeX, sizeY); uv = vec2<f32>( 1.0, 1.0); }\n default: { offset = vec2<f32>(0.0, 0.0); uv = vec2<f32>(0.0, 0.0); }\n }\n \n out.position = vec4<f32>(center + offset, 0.0, 1.0);\n out.uv = uv;\n return out;\n}\n\n// SDF functions\nfn sdCircle(p: vec2<f32>) -> f32 {\n return length(p) - 0.8;\n}\n\nfn sdSquare(p: vec2<f32>) -> f32 {\n let d = abs(p) - vec2<f32>(0.7);\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>) -> f32 {\n return (abs(p.x) + abs(p.y)) - 0.8;\n}\n\n@fragment\nfn fs_main(in: VertexOut) -> @location(0) vec4<f32> {\n var d: f32;\n \n switch (uniforms.symbolType) {\n case 0: { d = sdCircle(in.uv); } // circle\n case 1: { d = sdSquare(in.uv); } // square\n case 2: { d = sdDiamond(in.uv); } // diamond\n default: { d = sdCircle(in.uv); }\n }\n \n if (d > 0.05) {\n discard;\n }\n \n let alpha = 1.0 - smoothstep(0.0, 0.05, d);\n return vec4<f32>(uniforms.color.rgb, uniforms.color.a * alpha);\n}\n";
15
+ export declare const INSTANCED_LINE_VERTEX_STRIDE = 8;
16
+ export declare const INSTANCED_POINT_VERTEX_STRIDE = 8;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Line Shader - WGSL for WebGPU
3
+ *
4
+ * Renders simple line strips with uniform color.
5
+ * Uses uniform buffer for transform (scale + translate).
6
+ */
7
+ export declare const LINE_SHADER_WGSL = "\n// Uniform buffer for transforms and color\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n return out;\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n return uniforms.color;\n}\n";
8
+ export declare const LINE_VERTEX_STRIDE: number;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Point Shader - WGSL for WebGPU
3
+ *
4
+ * Renders scatter points with SDF-based symbols.
5
+ * Supports: circle, square, diamond, triangle, triangleDown, cross, x, star
6
+ */
7
+ export declare const POINT_SHADER_WGSL = "\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32, // 0=circle, 1=square, 2=diamond, 3=triangle, 4=triangleDown, 5=cross, 6=x, 7=star\n _padding: vec2<f32>,\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>,\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) @interpolate(flat) pointSize: f32,\n @location(1) @interpolate(flat) symbol: i32,\n};\n\n@vertex\nfn vs_main(in: VSInput, @builtin(vertex_index) vertexIndex: u32) -> VSOutput {\n var out: VSOutput;\n let transformed = in.position * uniforms.scale + uniforms.translate;\n out.pos = vec4<f32>(transformed, 0.0, 1.0);\n out.pointSize = uniforms.pointSize;\n out.symbol = uniforms.symbol;\n return out;\n}\n\n// SDF functions for symbols\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n // Note: WebGPU doesn't have gl_PointCoord directly\n // Points in WebGPU require rendering quads instead\n // This shader needs instanced rendering with quads for proper point rendering\n // For now, return the color directly\n return uniforms.color;\n}\n";
8
+ export declare const POINT_QUAD_SHADER_WGSL = "\n// Uniform buffer for transforms, color, point properties\nstruct Uniforms {\n scale: vec2<f32>,\n translate: vec2<f32>,\n color: vec4<f32>,\n pointSize: f32,\n symbol: i32,\n viewport: vec2<f32>, // viewport dimensions for proper sizing\n};\n\n@group(0) @binding(0)\nvar<uniform> uniforms: Uniforms;\n\nstruct VSInput {\n @location(0) position: vec2<f32>, // point center position\n @location(1) quadOffset: vec2<f32>, // quad vertex offset (-1 to 1)\n};\n\nstruct VSOutput {\n @builtin(position) pos: vec4<f32>,\n @location(0) uv: vec2<f32>, // -0.5 to 0.5 for SDF\n};\n\n@vertex\nfn vs_main(in: VSInput) -> VSOutput {\n var out: VSOutput;\n \n // Transform point position to NDC\n let transformed = in.position * uniforms.scale + uniforms.translate;\n \n // Calculate point size in NDC\n let pointSizeNDC = vec2<f32>(\n uniforms.pointSize / uniforms.viewport.x * 2.0,\n uniforms.pointSize / uniforms.viewport.y * 2.0\n );\n \n // Apply quad offset\n let offset = in.quadOffset * pointSizeNDC * 0.5;\n \n out.pos = vec4<f32>(transformed + offset, 0.0, 1.0);\n out.uv = in.quadOffset * 0.5; // -0.5 to 0.5\n \n return out;\n}\n\n// SDF functions\nfn sdCircle(p: vec2<f32>, r: f32) -> f32 {\n return length(p) - r;\n}\n\nfn sdBox(p: vec2<f32>, b: vec2<f32>) -> f32 {\n let d = abs(p) - b;\n return length(max(d, vec2<f32>(0.0))) + min(max(d.x, d.y), 0.0);\n}\n\nfn sdDiamond(p: vec2<f32>, r: f32) -> f32 {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfn sdTriangle(p_in: vec2<f32>, r: f32) -> f32 {\n let k = sqrt(3.0);\n var p = p_in;\n p.x = abs(p.x) - r;\n p.y = p.y + r / k;\n if (p.x + k * p.y > 0.0) {\n p = vec2<f32>(p.x - k * p.y, -k * p.x - p.y) / 2.0;\n }\n p.x = p.x - clamp(p.x, -2.0 * r, 0.0);\n return -length(p) * sign(p.y);\n}\n\nfn sdCross(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let d = abs(p);\n let s1 = sdBox(d, vec2<f32>(r, thickness));\n let s2 = sdBox(d, vec2<f32>(thickness, r));\n return min(s1, s2);\n}\n\nfn sdX(p: vec2<f32>, r: f32, thickness: f32) -> f32 {\n let c = cos(0.785398);\n let s = sin(0.785398);\n let m = mat2x2<f32>(c, -s, s, c);\n return sdCross(m * p, r, thickness);\n}\n\nfn sdStar(p_in: vec2<f32>, r: f32, rf: f32) -> f32 {\n let k1 = vec2<f32>(0.80901699, -0.58778525);\n let k2 = vec2<f32>(-k1.x, k1.y);\n var p = p_in;\n p.x = abs(p.x);\n p = p - 2.0 * max(dot(k1, p), 0.0) * k1;\n p = p - 2.0 * max(dot(k2, p), 0.0) * k2;\n p.x = abs(p.x);\n p.y = p.y - r;\n let ba = rf * vec2<f32>(-k1.y, k1.x) - vec2<f32>(0.0, 1.0);\n let h = clamp(dot(p, ba) / dot(ba, ba), 0.0, r);\n return length(p - ba * h) * sign(p.y * ba.x - p.x * ba.y);\n}\n\n@fragment\nfn fs_main(in: VSOutput) -> @location(0) vec4<f32> {\n var d: f32 = 0.0;\n \n if (uniforms.symbol == 0) {\n d = sdCircle(in.uv, 0.45);\n } else if (uniforms.symbol == 1) {\n d = sdBox(in.uv, vec2<f32>(0.35));\n } else if (uniforms.symbol == 2) {\n d = sdDiamond(in.uv, 0.45);\n } else if (uniforms.symbol == 3) {\n d = sdTriangle(vec2<f32>(in.uv.x, in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 4) {\n d = sdTriangle(vec2<f32>(in.uv.x, -in.uv.y + 0.1), 0.4);\n } else if (uniforms.symbol == 5) {\n d = sdCross(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 6) {\n d = sdX(in.uv, 0.45, 0.15);\n } else if (uniforms.symbol == 7) {\n d = sdStar(in.uv, 0.45, 0.4);\n }\n \n if (d > 0.02) {\n discard;\n }\n \n let alpha = 1.0 - smoothstep(0.0, 0.02, d);\n return vec4<f32>(uniforms.color.rgb, uniforms.color.a * alpha);\n}\n";
9
+ export declare const POINT_VERTEX_STRIDE: number;