@rings-webgpu/core 1.0.36 → 1.0.37

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.
@@ -0,0 +1,176 @@
1
+ import { RenderNode } from "./RenderNode";
2
+ import { GSplatMaterial } from "../../materials/GSplatMaterial";
3
+ import { View3D } from "../../core/View3D";
4
+ import { RendererPassState } from "../../gfx/renderJob/passRenderer/state/RendererPassState";
5
+ import { ClusterLightingBuffer } from "../../gfx/renderJob/passRenderer/cluster/ClusterLightingBuffer";
6
+ import { PassType } from "../../gfx/renderJob/passRenderer/state/PassType";
7
+ import { Uint8ArrayTexture } from "../../textures/Uint8ArrayTexture";
8
+ import { Uint32ArrayTexture } from "../../textures/Uint32ArrayTexture";
9
+ import { R32UintTexture } from "../../textures/R32UintTexture";
10
+ import { Float16ArrayTexture } from "../../textures/Float16ArrayTexture";
11
+ import { Vector2 } from "../../math/Vector2";
12
+ import { BoundingBox } from "../../core/bound/BoundingBox";
13
+ /**
14
+ * Single splat data structure for streaming
15
+ */
16
+ export type SplatData = {
17
+ position: [number, number, number];
18
+ rotation?: [number, number, number, number];
19
+ scale?: [number, number, number];
20
+ opacity?: number;
21
+ sh?: {
22
+ order: number;
23
+ coeffs: Float32Array;
24
+ };
25
+ };
26
+ /**
27
+ * Gaussian Splat Stream Renderer Component
28
+ */
29
+ export declare class GSplatStreamRenderer extends RenderNode {
30
+ totalCount: number;
31
+ size: Vector2;
32
+ worldBoundBox: BoundingBox;
33
+ splatColor: Uint8ArrayTexture;
34
+ transformA: Uint32ArrayTexture;
35
+ transformB: Float16ArrayTexture;
36
+ texParams: Float32Array;
37
+ splatOrder: R32UintTexture;
38
+ gsplatMaterial: GSplatMaterial;
39
+ private _colorData;
40
+ private _transformAData;
41
+ private _transformBData;
42
+ private _orderData;
43
+ private _positions;
44
+ private _worldPositions;
45
+ private _splatSetFlags;
46
+ private _validCount;
47
+ private _sortWorker;
48
+ private _lastSentTime;
49
+ private _minIntervalMs;
50
+ private _centersSent;
51
+ private _lastViewMatrixHash;
52
+ private _lastCameraSpeed;
53
+ private _adaptiveSorting;
54
+ private _lastPixelCullParams;
55
+ private _texturesInitialized;
56
+ private _minPixelCoverage;
57
+ private _maxPixelCoverage;
58
+ private _maxPixelCullDistance;
59
+ private _batchSize;
60
+ instanceCount: number;
61
+ private _pendingUpdates;
62
+ private _autoFlushThreshold;
63
+ private _frameCount;
64
+ constructor();
65
+ /**
66
+ * Initialize renderer with total splat count
67
+ * Pre-allocates all GPU resources with zero-initialized data
68
+ * @param totalCount Total number of splats that will be streamed
69
+ * @param batchSize Splats per draw call (default: 128)
70
+ */
71
+ initCount(totalCount: number, batchSize?: number): void;
72
+ /**
73
+ * Set data for a single splat at the given index
74
+ * Updates CPU buffers and marks for GPU update
75
+ * @param index Splat index (0 to count-1)
76
+ * @param data Splat data (position is required, others optional)
77
+ */
78
+ setSplatData(index: number, data: SplatData): void;
79
+ /**
80
+ * Update transform data for a single splat
81
+ */
82
+ private updateTransformData;
83
+ /**
84
+ * Flush pending updates to GPU
85
+ * Updates GPU textures with all pending changes
86
+ */
87
+ flushUpdates(): void;
88
+ /**
89
+ * Set auto-flush threshold
90
+ * @param threshold Number of pending updates before auto-flush (default: 100)
91
+ */
92
+ setAutoFlushThreshold(threshold: number): void;
93
+ /**
94
+ * Get current streaming statistics
95
+ */
96
+ getStreamingStats(): {
97
+ totalCount: number;
98
+ validCount: number;
99
+ pendingUpdates: number;
100
+ progress: number;
101
+ };
102
+ /**
103
+ * Update splat sorting before rendering
104
+ * Uses the same logic as GSplatRenderer for reliable sorting
105
+ */
106
+ onBeforeUpdate(view?: View3D): void;
107
+ /**
108
+ * Update world space positions when transform changes
109
+ */
110
+ private updateWorldPositions;
111
+ private updatePendingWorldPositions;
112
+ /**
113
+ * Schedule Web Worker-based sorting task
114
+ * Uses the same logic as GSplatRenderer for consistency
115
+ */
116
+ private scheduleOrder;
117
+ /**
118
+ * Create Web Worker for sorting
119
+ * Uses the exact same logic as GSplatRenderer for consistency
120
+ */
121
+ private createSortWorker;
122
+ /**
123
+ * Set visibility boost factor
124
+ */
125
+ setVisBoost(v: number): void;
126
+ setCount(c: number): void;
127
+ private _updateTexParams;
128
+ /**
129
+ * Set sort throttle interval (milliseconds)
130
+ */
131
+ setSortThrottle(ms: number): void;
132
+ /**
133
+ * Enable/disable adaptive sorting
134
+ */
135
+ setAdaptiveSorting(enabled: boolean): void;
136
+ /**
137
+ * Set pixel coverage culling thresholds
138
+ */
139
+ setPixelCulling(minPixels: number, maxPixels?: number, maxPixelCullDistance?: number): void;
140
+ /**
141
+ * Get current pixel culling settings
142
+ */
143
+ getPixelCullingStats(): {
144
+ minPixels: number;
145
+ maxPixels: number;
146
+ maxPixelCullDistance: number;
147
+ maxEnabled: boolean;
148
+ distanceEnabled: boolean;
149
+ };
150
+ /**
151
+ * Get batching statistics
152
+ */
153
+ getBatchingStats(): {
154
+ enabled: boolean;
155
+ batchSize: number;
156
+ instanceCount: number;
157
+ splatCount: number;
158
+ reduction: number;
159
+ };
160
+ /**
161
+ * Calculate texture size for given splat count
162
+ */
163
+ private evalTextureSize;
164
+ /**
165
+ * Update node before rendering
166
+ */
167
+ nodeUpdate(view: View3D, passType: PassType, renderPassState: RendererPassState, clusterLightingBuffer?: ClusterLightingBuffer): void;
168
+ /**
169
+ * Render pass
170
+ */
171
+ renderPass(view: View3D, passType: PassType, renderContext: any): void;
172
+ /**
173
+ * Clean up resources
174
+ */
175
+ destroy(force?: boolean): void;
176
+ }
@@ -183,6 +183,7 @@ export * from "./components/lights/SpotLight";
183
183
  export * from "./components/post/PostProcessingComponent";
184
184
  export * from "./components/renderer/FatLineRenderer";
185
185
  export * from "./components/renderer/GSplatRenderer";
186
+ export * from "./components/renderer/GSplatStreamRenderer";
186
187
  export * from "./components/renderer/GlobalIlluminationComponent";
187
188
  export * from "./components/renderer/InstanceDrawComponent";
188
189
  export * from "./components/renderer/MeshFilter";
@@ -380,8 +381,10 @@ export * from "./loader/FileLoader";
380
381
  export * from "./loader/LoaderBase";
381
382
  export * from "./loader/LoaderFunctions";
382
383
  export * from "./loader/LoaderManager";
384
+ export * from "./loader/StreamLoader";
383
385
  export * from "./loader/parser/3dgs/GaussianSplatAsset";
384
386
  export * from "./loader/parser/3dgs/GaussianSplatParser";
387
+ export * from "./loader/parser/3dgs/StreamingGaussianSplatParser";
385
388
  export * from "./loader/parser/3dgs/loaders/FormatDetector";
386
389
  export * from "./loader/parser/AtlasParser";
387
390
  export * from "./loader/parser/B3DMParser";
@@ -434,6 +437,7 @@ export * from "./loader/parser/las/LASTypes";
434
437
  export * from "./loader/parser/las/LASUtils";
435
438
  export * from "./loader/parser/ply/PlyLoader";
436
439
  export * from "./loader/parser/ply/PlyParser";
440
+ export * from "./loader/parser/ply/PlyStreamParser";
437
441
  export * from "./loader/parser/ply/PlyTypes";
438
442
  export * from "./loader/parser/ply/PlyUtils";
439
443
  export * from "./loader/parser/pnts/PNTSLoader";
@@ -0,0 +1,26 @@
1
+ import { LoaderBase } from "./LoaderBase";
2
+ import { LoaderFunctions } from "./LoaderFunctions";
3
+ import { ParserBase } from "./parser/ParserBase";
4
+ import { Parser } from "../util/Global";
5
+ /**
6
+ * Stream loader result with cancel capability
7
+ */
8
+ export interface StreamLoadResult<T extends ParserBase> {
9
+ parser: T;
10
+ cancel: () => void;
11
+ }
12
+ /**
13
+ * Stream loader for progressive resource loading
14
+ * Supports streaming data as it arrives, enabling progressive rendering
15
+ */
16
+ export declare class StreamLoader extends LoaderBase {
17
+ /**
18
+ * Load resource with streaming support
19
+ * @param url Resource URL
20
+ * @param parserClass Parser class that supports streaming
21
+ * @param loaderFunctions Optional loader callbacks
22
+ * @param userData Optional user data
23
+ * @returns Promise that resolves when initial data is ready (header parsed), includes cancel method
24
+ */
25
+ loadStream<T extends ParserBase>(url: string, parserClass: Parser<T>, loaderFunctions?: LoaderFunctions, userData?: any): Promise<StreamLoadResult<T>>;
26
+ }
@@ -0,0 +1,53 @@
1
+ import { ParserBase } from "../ParserBase";
2
+ import { ParserFormat } from "../ParserFormat";
3
+ /**
4
+ * Streaming Gaussian Splat Parser
5
+ *
6
+ * Supports progressive loading and rendering of Gaussian Splat files.
7
+ * Parses header first, then streams vertex data as it arrives.
8
+ */
9
+ export declare class StreamingGaussianSplatParser extends ParserBase {
10
+ static format: ParserFormat;
11
+ private _streamParser;
12
+ private _streamingRenderer;
13
+ private _rendererObject;
14
+ private _chunksPerBatch;
15
+ private _headerParsed;
16
+ private _onHeaderParsed;
17
+ private _cancelled;
18
+ /**
19
+ * Initialize streaming parser
20
+ * @param contentLength Total content length (if known)
21
+ * @param onHeaderParsed Optional callback when header is parsed (parser is ready)
22
+ */
23
+ initStream(contentLength: number, onHeaderParsed?: () => void): Promise<void>;
24
+ /**
25
+ * Process incoming data chunk
26
+ * @param chunk Data chunk
27
+ * @param receivedLength Total bytes received so far
28
+ * @param contentLength Total content length (if known)
29
+ */
30
+ processChunk(chunk: Uint8Array, receivedLength: number, contentLength: number): Promise<void>;
31
+ /**
32
+ * Cancel streaming loading
33
+ * Stops processing new chunks and cleans up resources
34
+ */
35
+ cancel(): void;
36
+ /**
37
+ * Check if loading is cancelled
38
+ */
39
+ isCancelled(): boolean;
40
+ /**
41
+ * Finalize streaming parsing
42
+ */
43
+ finalizeStream(): Promise<void>;
44
+ /**
45
+ * Get parsing progress
46
+ */
47
+ getProgress(): {
48
+ processed: number;
49
+ total: number;
50
+ percentage: number;
51
+ };
52
+ verification(): boolean;
53
+ }
@@ -0,0 +1,66 @@
1
+ import { PlyHeader } from './PlyTypes';
2
+ import { SplatData } from '../../../components/renderer/GSplatStreamRenderer';
3
+ /**
4
+ * Streaming PLY parser for Gaussian Splatting
5
+ *
6
+ * Handles incremental parsing of PLY binary data as chunks arrive.
7
+ * Maintains state to handle partial vertex data at chunk boundaries.
8
+ */
9
+ export declare class PlyStreamParser {
10
+ private _header;
11
+ private _headerBuffer;
12
+ private _headerLength;
13
+ private _headerParsed;
14
+ private _dataBuffer;
15
+ private _dataOffset;
16
+ private _processedVertices;
17
+ private _vertexStride;
18
+ private _propOffsets;
19
+ private _properties;
20
+ private _onHeaderParsed;
21
+ private _onSplatParsed;
22
+ private _batchSize;
23
+ private _cancelled;
24
+ constructor(onHeaderParsed: (header: PlyHeader) => void, onSplatParsed: (splatData: SplatData, index: number) => void, batchSize?: number);
25
+ /**
26
+ * Process incoming data chunk
27
+ */
28
+ processChunk(chunk: Uint8Array): void;
29
+ /**
30
+ * Cancel parsing
31
+ * Stops processing new chunks
32
+ */
33
+ cancel(): void;
34
+ /**
35
+ * Check if parsing is cancelled
36
+ */
37
+ isCancelled(): boolean;
38
+ /**
39
+ * Process header chunk
40
+ */
41
+ private _processHeaderChunk;
42
+ /**
43
+ * Parse PLY header from buffer
44
+ */
45
+ private _parseHeader;
46
+ /**
47
+ * Initialize data parsing structures
48
+ */
49
+ private _initializeDataParsing;
50
+ /**
51
+ * Process data chunk
52
+ */
53
+ private _processDataChunk;
54
+ /**
55
+ * Parse vertices from current data buffer
56
+ */
57
+ private _parseVertices;
58
+ /**
59
+ * Get current parsing progress
60
+ */
61
+ getProgress(): {
62
+ processed: number;
63
+ total: number;
64
+ percentage: number;
65
+ };
66
+ }
@@ -6,3 +6,4 @@
6
6
  export * from './PlyTypes';
7
7
  export * from './PlyUtils';
8
8
  export * from './PlyLoader';
9
+ export * from './PlyStreamParser';
@@ -24,4 +24,5 @@ export declare class GSplatMaterial extends Material {
24
24
  * @param maxPixelCullDistance Only cull oversized splats within this distance, 0 = always cull
25
25
  */
26
26
  setPixelCulling(minPixels: number, maxPixels: number, maxPixelCullDistance?: number, batchSize?: number): void;
27
+ setTexParams(texParams: Float32Array): void;
27
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rings-webgpu/core",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "Rings webgpu Engine",
5
5
  "main": "index.js",
6
6
  "exports": {