@rings-webgpu/core 1.0.36 → 1.0.38

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.
@@ -2120,7 +2120,7 @@
2120
2120
  }
2121
2121
 
2122
2122
  var __defProp$2 = Object.defineProperty;
2123
- var __decorateClass$o = (decorators, target, key, kind) => {
2123
+ var __decorateClass$p = (decorators, target, key, kind) => {
2124
2124
  var result = void 0 ;
2125
2125
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
2126
2126
  if (decorator = decorators[i])
@@ -2223,10 +2223,10 @@
2223
2223
  return struct.__size;
2224
2224
  }
2225
2225
  };
2226
- __decorateClass$o([
2226
+ __decorateClass$p([
2227
2227
  NonSerialize
2228
2228
  ], _Struct.prototype, "__refection");
2229
- __decorateClass$o([
2229
+ __decorateClass$p([
2230
2230
  NonSerialize
2231
2231
  ], _Struct.prototype, "__size");
2232
2232
  let Struct = _Struct;
@@ -21972,9 +21972,9 @@ struct InstanceData {
21972
21972
  }
21973
21973
 
21974
21974
  var __defProp$1 = Object.defineProperty;
21975
- var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
21976
- var __decorateClass$n = (decorators, target, key, kind) => {
21977
- var result = __getOwnPropDesc$n(target, key) ;
21975
+ var __getOwnPropDesc$o = Object.getOwnPropertyDescriptor;
21976
+ var __decorateClass$o = (decorators, target, key, kind) => {
21977
+ var result = __getOwnPropDesc$o(target, key) ;
21978
21978
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
21979
21979
  if (decorator = decorators[i])
21980
21980
  result = (decorator(target, key, result) ) || result;
@@ -22572,13 +22572,13 @@ struct InstanceData {
22572
22572
  this._combineShaderRefection = void 0;
22573
22573
  }
22574
22574
  }
22575
- __decorateClass$n([
22575
+ __decorateClass$o([
22576
22576
  EditorInspector
22577
22577
  ], RenderNode.prototype, "materials");
22578
- __decorateClass$n([
22578
+ __decorateClass$o([
22579
22579
  EditorInspector
22580
22580
  ], RenderNode.prototype, "castShadow");
22581
- __decorateClass$n([
22581
+ __decorateClass$o([
22582
22582
  EditorInspector
22583
22583
  ], RenderNode.prototype, "castGI");
22584
22584
 
@@ -23245,9 +23245,9 @@ struct InstanceData {
23245
23245
  }
23246
23246
  }
23247
23247
 
23248
- var __getOwnPropDesc$m = Object.getOwnPropertyDescriptor;
23249
- var __decorateClass$m = (decorators, target, key, kind) => {
23250
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$m(target, key) : target;
23248
+ var __getOwnPropDesc$n = Object.getOwnPropertyDescriptor;
23249
+ var __decorateClass$n = (decorators, target, key, kind) => {
23250
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$n(target, key) : target;
23251
23251
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
23252
23252
  if (decorator = decorators[i])
23253
23253
  result = (decorator(result)) || result;
@@ -23279,7 +23279,7 @@ struct InstanceData {
23279
23279
  pass.setUniform("pixelCull", new Float32Array([2, 0, 0, 0]));
23280
23280
  }
23281
23281
  };
23282
- exports.GSplatShader = __decorateClass$m([
23282
+ exports.GSplatShader = __decorateClass$n([
23283
23283
  RegisterShader(exports.GSplatShader, "GSplatShader")
23284
23284
  ], exports.GSplatShader);
23285
23285
 
@@ -23323,6 +23323,10 @@ struct InstanceData {
23323
23323
  const pass = this.shader.getDefaultColorShader();
23324
23324
  pass.setUniform("pixelCull", this._pixelCullArray);
23325
23325
  }
23326
+ setTexParams(texParams) {
23327
+ const pass = this.shader.getDefaultColorShader();
23328
+ pass.setUniformArray("tex_params", texParams);
23329
+ }
23326
23330
  }
23327
23331
 
23328
23332
  class VertexGPUBuffer extends GPUBufferBase {
@@ -24296,9 +24300,9 @@ struct InstanceData {
24296
24300
  }
24297
24301
  }
24298
24302
 
24299
- var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
24300
- var __decorateClass$l = (decorators, target, key, kind) => {
24301
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target;
24303
+ var __getOwnPropDesc$m = Object.getOwnPropertyDescriptor;
24304
+ var __decorateClass$m = (decorators, target, key, kind) => {
24305
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$m(target, key) : target;
24302
24306
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
24303
24307
  if (decorator = decorators[i])
24304
24308
  result = (decorator(result)) || result;
@@ -25097,7 +25101,7 @@ struct InstanceData {
25097
25101
  super.destroy(force);
25098
25102
  }
25099
25103
  };
25100
- exports.GSplatRenderer = __decorateClass$l([
25104
+ exports.GSplatRenderer = __decorateClass$m([
25101
25105
  RegisterComponent(exports.GSplatRenderer, "GSplatRenderer")
25102
25106
  ], exports.GSplatRenderer);
25103
25107
 
@@ -25236,9 +25240,9 @@ struct InstanceData {
25236
25240
  `
25237
25241
  );
25238
25242
 
25239
- var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
25240
- var __decorateClass$k = (decorators, target, key, kind) => {
25241
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
25243
+ var __getOwnPropDesc$l = Object.getOwnPropertyDescriptor;
25244
+ var __decorateClass$l = (decorators, target, key, kind) => {
25245
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$l(target, key) : target;
25242
25246
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
25243
25247
  if (decorator = decorators[i])
25244
25248
  result = (decorator(result)) || result;
@@ -25270,7 +25274,7 @@ struct InstanceData {
25270
25274
  pass.setUniformArray("pointParams", new Float32Array([0, 0, 0, 128]));
25271
25275
  }
25272
25276
  };
25273
- exports.PointCloudShader = __decorateClass$k([
25277
+ exports.PointCloudShader = __decorateClass$l([
25274
25278
  RegisterShader(exports.PointCloudShader, "PointCloudShader")
25275
25279
  ], exports.PointCloudShader);
25276
25280
 
@@ -25463,9 +25467,9 @@ struct InstanceData {
25463
25467
  }
25464
25468
  }
25465
25469
 
25466
- var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
25467
- var __decorateClass$j = (decorators, target, key, kind) => {
25468
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
25470
+ var __getOwnPropDesc$k = Object.getOwnPropertyDescriptor;
25471
+ var __decorateClass$k = (decorators, target, key, kind) => {
25472
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$k(target, key) : target;
25469
25473
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
25470
25474
  if (decorator = decorators[i])
25471
25475
  result = (decorator(result)) || result;
@@ -25776,7 +25780,7 @@ struct InstanceData {
25776
25780
  super.destroy(force);
25777
25781
  }
25778
25782
  };
25779
- exports.PointCloudRenderer = __decorateClass$j([
25783
+ exports.PointCloudRenderer = __decorateClass$k([
25780
25784
  RegisterComponent(exports.PointCloudRenderer, "PointCloudRenderer")
25781
25785
  ], exports.PointCloudRenderer);
25782
25786
 
@@ -26131,9 +26135,9 @@ struct InstanceData {
26131
26135
  }
26132
26136
  }
26133
26137
 
26134
- var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
26135
- var __decorateClass$i = (decorators, target, key, kind) => {
26136
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
26138
+ var __getOwnPropDesc$j = Object.getOwnPropertyDescriptor;
26139
+ var __decorateClass$j = (decorators, target, key, kind) => {
26140
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target;
26137
26141
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
26138
26142
  if (decorator = decorators[i])
26139
26143
  result = (decorator(result)) || result;
@@ -26408,7 +26412,7 @@ struct InstanceData {
26408
26412
  super.destroy(force);
26409
26413
  }
26410
26414
  };
26411
- exports.Object3D = __decorateClass$i([
26415
+ exports.Object3D = __decorateClass$j([
26412
26416
  DecorateObject3D
26413
26417
  ], exports.Object3D);
26414
26418
  function DecorateObject3D(ctor, _) {
@@ -27774,9 +27778,9 @@ struct InstanceData {
27774
27778
  }
27775
27779
 
27776
27780
  var __defProp = Object.defineProperty;
27777
- var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
27778
- var __decorateClass$h = (decorators, target, key, kind) => {
27779
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
27781
+ var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
27782
+ var __decorateClass$i = (decorators, target, key, kind) => {
27783
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
27780
27784
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
27781
27785
  if (decorator = decorators[i])
27782
27786
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
@@ -27889,13 +27893,13 @@ struct InstanceData {
27889
27893
  super.destroy(force);
27890
27894
  }
27891
27895
  };
27892
- __decorateClass$h([
27896
+ __decorateClass$i([
27893
27897
  EditorInspector
27894
27898
  ], exports.MeshRenderer.prototype, "geometry", 1);
27895
- __decorateClass$h([
27899
+ __decorateClass$i([
27896
27900
  EditorInspector
27897
27901
  ], exports.MeshRenderer.prototype, "material", 1);
27898
- exports.MeshRenderer = __decorateClass$h([
27902
+ exports.MeshRenderer = __decorateClass$i([
27899
27903
  RegisterComponent(exports.MeshRenderer, "MeshRenderer")
27900
27904
  ], exports.MeshRenderer);
27901
27905
 
@@ -28501,9 +28505,9 @@ struct InstanceData {
28501
28505
  }
28502
28506
  }
28503
28507
 
28504
- var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
28505
- var __decorateClass$g = (decorators, target, key, kind) => {
28506
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
28508
+ var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
28509
+ var __decorateClass$h = (decorators, target, key, kind) => {
28510
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
28507
28511
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
28508
28512
  if (decorator = decorators[i])
28509
28513
  result = (decorator(result)) || result;
@@ -28527,7 +28531,7 @@ struct InstanceData {
28527
28531
  this.setUniformFloat(`height`, 100);
28528
28532
  }
28529
28533
  };
28530
- exports.QuadShader = __decorateClass$g([
28534
+ exports.QuadShader = __decorateClass$h([
28531
28535
  RegisterShader(exports.QuadShader, "QuadShader")
28532
28536
  ], exports.QuadShader);
28533
28537
 
@@ -35890,9 +35894,9 @@ else if (typeof exports === 'object')
35890
35894
  }
35891
35895
  }
35892
35896
 
35893
- var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
35894
- var __decorateClass$f = (decorators, target, key, kind) => {
35895
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
35897
+ var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
35898
+ var __decorateClass$g = (decorators, target, key, kind) => {
35899
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
35896
35900
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
35897
35901
  if (decorator = decorators[i])
35898
35902
  result = (decorator(result)) || result;
@@ -35934,13 +35938,13 @@ else if (typeof exports === 'object')
35934
35938
  debug() {
35935
35939
  }
35936
35940
  };
35937
- exports.DirectLight = __decorateClass$f([
35941
+ exports.DirectLight = __decorateClass$g([
35938
35942
  RegisterComponent(exports.DirectLight, "DirectLight")
35939
35943
  ], exports.DirectLight);
35940
35944
 
35941
- var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
35942
- var __decorateClass$e = (decorators, target, key, kind) => {
35943
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
35945
+ var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
35946
+ var __decorateClass$f = (decorators, target, key, kind) => {
35947
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
35944
35948
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
35945
35949
  if (decorator = decorators[i])
35946
35950
  result = (decorator(result)) || result;
@@ -35998,13 +36002,13 @@ else if (typeof exports === 'object')
35998
36002
  debugDraw(show) {
35999
36003
  }
36000
36004
  };
36001
- exports.PointLight = __decorateClass$e([
36005
+ exports.PointLight = __decorateClass$f([
36002
36006
  RegisterComponent(exports.PointLight, "PointLight")
36003
36007
  ], exports.PointLight);
36004
36008
 
36005
- var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
36006
- var __decorateClass$d = (decorators, target, key, kind) => {
36007
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
36009
+ var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
36010
+ var __decorateClass$e = (decorators, target, key, kind) => {
36011
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
36008
36012
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
36009
36013
  if (decorator = decorators[i])
36010
36014
  result = (decorator(result)) || result;
@@ -36069,7 +36073,7 @@ else if (typeof exports === 'object')
36069
36073
  debugDraw(show) {
36070
36074
  }
36071
36075
  };
36072
- exports.SpotLight = __decorateClass$d([
36076
+ exports.SpotLight = __decorateClass$e([
36073
36077
  RegisterComponent(exports.SpotLight, "SpotLight")
36074
36078
  ], exports.SpotLight);
36075
36079
 
@@ -42154,7 +42158,7 @@ else if (typeof exports === 'object')
42154
42158
  }
42155
42159
  }
42156
42160
 
42157
- const version = "1.0.35";
42161
+ const version = "1.0.36";
42158
42162
 
42159
42163
  class Engine3D {
42160
42164
  /**
@@ -46667,9 +46671,9 @@ fn frag(){
46667
46671
  }
46668
46672
  }
46669
46673
 
46670
- var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
46671
- var __decorateClass$c = (decorators, target, key, kind) => {
46672
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
46674
+ var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
46675
+ var __decorateClass$d = (decorators, target, key, kind) => {
46676
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
46673
46677
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
46674
46678
  if (decorator = decorators[i])
46675
46679
  result = (decorator(result)) || result;
@@ -46693,7 +46697,7 @@ fn frag(){
46693
46697
  shaderState.depthCompare = GPUCompareFunction.less;
46694
46698
  }
46695
46699
  };
46696
- exports.SkyShader = __decorateClass$c([
46700
+ exports.SkyShader = __decorateClass$d([
46697
46701
  RegisterShader(exports.SkyShader, "SkyShader")
46698
46702
  ], exports.SkyShader);
46699
46703
 
@@ -47491,9 +47495,9 @@ fn frag(){
47491
47495
  }
47492
47496
  }
47493
47497
 
47494
- var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
47495
- var __decorateClass$b = (decorators, target, key, kind) => {
47496
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
47498
+ var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
47499
+ var __decorateClass$c = (decorators, target, key, kind) => {
47500
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
47497
47501
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
47498
47502
  if (decorator = decorators[i])
47499
47503
  result = (decorator(result)) || result;
@@ -47697,7 +47701,7 @@ fn frag(){
47697
47701
  this._currentClipState.weight = 1;
47698
47702
  }
47699
47703
  };
47700
- exports.SkeletonAnimationComponent = __decorateClass$b([
47704
+ exports.SkeletonAnimationComponent = __decorateClass$c([
47701
47705
  RegisterComponent(exports.SkeletonAnimationComponent, "SkeletonAnimationComponent")
47702
47706
  ], exports.SkeletonAnimationComponent);
47703
47707
  class SkeletonAnimationCrossFadeState {
@@ -47733,9 +47737,9 @@ fn frag(){
47733
47737
  }
47734
47738
  }
47735
47739
 
47736
- var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
47737
- var __decorateClass$a = (decorators, target, key, kind) => {
47738
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
47740
+ var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
47741
+ var __decorateClass$b = (decorators, target, key, kind) => {
47742
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
47739
47743
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
47740
47744
  if (decorator = decorators[i])
47741
47745
  result = (decorator(result)) || result;
@@ -48146,7 +48150,7 @@ fn frag(){
48146
48150
  return dst;
48147
48151
  }
48148
48152
  };
48149
- exports.AnimatorComponent = __decorateClass$a([
48153
+ exports.AnimatorComponent = __decorateClass$b([
48150
48154
  RegisterComponent(exports.AnimatorComponent, "AnimatorComponent")
48151
48155
  ], exports.AnimatorComponent);
48152
48156
  class PropertyAnimationClipState {
@@ -48903,9 +48907,9 @@ fn frag(){
48903
48907
  }
48904
48908
  }
48905
48909
 
48906
- var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
48907
- var __decorateClass$9 = (decorators, target, key, kind) => {
48908
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
48910
+ var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
48911
+ var __decorateClass$a = (decorators, target, key, kind) => {
48912
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
48909
48913
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
48910
48914
  if (decorator = decorators[i])
48911
48915
  result = (decorator(result)) || result;
@@ -49054,7 +49058,7 @@ fn frag(){
49054
49058
  super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
49055
49059
  }
49056
49060
  };
49057
- exports.SkinnedMeshRenderer2 = __decorateClass$9([
49061
+ exports.SkinnedMeshRenderer2 = __decorateClass$a([
49058
49062
  RegisterComponent(exports.SkinnedMeshRenderer2, "SkinnedMeshRenderer2")
49059
49063
  ], exports.SkinnedMeshRenderer2);
49060
49064
 
@@ -54187,9 +54191,9 @@ fn frag(){
54187
54191
  }
54188
54192
  }
54189
54193
 
54190
- var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
54191
- var __decorateClass$8 = (decorators, target, key, kind) => {
54192
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
54194
+ var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
54195
+ var __decorateClass$9 = (decorators, target, key, kind) => {
54196
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
54193
54197
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
54194
54198
  if (decorator = decorators[i])
54195
54199
  result = (decorator(result)) || result;
@@ -54266,13 +54270,13 @@ fn frag(){
54266
54270
  debugDraw(show) {
54267
54271
  }
54268
54272
  };
54269
- exports.Light = __decorateClass$8([
54273
+ exports.Light = __decorateClass$9([
54270
54274
  RegisterComponent(exports.Light, "Light")
54271
54275
  ], exports.Light);
54272
54276
 
54273
- var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
54274
- var __decorateClass$7 = (decorators, target, key, kind) => {
54275
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
54277
+ var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
54278
+ var __decorateClass$8 = (decorators, target, key, kind) => {
54279
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
54276
54280
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
54277
54281
  if (decorator = decorators[i])
54278
54282
  result = (decorator(result)) || result;
@@ -54347,10 +54351,779 @@ fn frag(){
54347
54351
  super.destroy(force);
54348
54352
  }
54349
54353
  };
54350
- exports.FatLineRenderer = __decorateClass$7([
54354
+ exports.FatLineRenderer = __decorateClass$8([
54351
54355
  RegisterComponent(exports.FatLineRenderer, "FatLineRenderer")
54352
54356
  ], exports.FatLineRenderer);
54353
54357
 
54358
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
54359
+ var __decorateClass$7 = (decorators, target, key, kind) => {
54360
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
54361
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
54362
+ if (decorator = decorators[i])
54363
+ result = (decorator(result)) || result;
54364
+ return result;
54365
+ };
54366
+ exports.GSplatStreamRenderer = class GSplatStreamRenderer extends RenderNode {
54367
+ // Splat count and texture dimensions
54368
+ totalCount = 0;
54369
+ size = new Vector2();
54370
+ localBoundBox = new BoundingBox();
54371
+ // public worldBoundBox: BoundingBox = new BoundingBox();
54372
+ get worldBoundBox() {
54373
+ const boundBox = new BoundingBox();
54374
+ boundBox.makeEmpty();
54375
+ const worldMatrix = this.object3D.transform.worldMatrix;
54376
+ const m = worldMatrix.rawData;
54377
+ const localMin = this.localBoundBox.min;
54378
+ const localMax = this.localBoundBox.max;
54379
+ const corners = [
54380
+ [localMin.x, localMin.y, localMin.z],
54381
+ // 0: min, min, min
54382
+ [localMax.x, localMin.y, localMin.z],
54383
+ // 1: max, min, min
54384
+ [localMin.x, localMax.y, localMin.z],
54385
+ // 2: min, max, min
54386
+ [localMax.x, localMax.y, localMin.z],
54387
+ // 3: max, max, min
54388
+ [localMin.x, localMin.y, localMax.z],
54389
+ // 4: min, min, max
54390
+ [localMax.x, localMin.y, localMax.z],
54391
+ // 5: max, min, max
54392
+ [localMin.x, localMax.y, localMax.z],
54393
+ // 6: min, max, max
54394
+ [localMax.x, localMax.y, localMax.z]
54395
+ // 7: max, max, max
54396
+ ];
54397
+ for (const [x, y, z] of corners) {
54398
+ const wx = m[0] * x + m[4] * y + m[8] * z + m[12];
54399
+ const wy = m[1] * x + m[5] * y + m[9] * z + m[13];
54400
+ const wz = m[2] * x + m[6] * y + m[10] * z + m[14];
54401
+ boundBox.expandByPoint(new Vector3(wx, wy, wz));
54402
+ }
54403
+ return boundBox;
54404
+ }
54405
+ // GPU textures for splat data
54406
+ splatColor;
54407
+ transformA;
54408
+ transformB;
54409
+ texParams;
54410
+ // [numSplats, texWidth, validCount, visBoost]
54411
+ splatOrder;
54412
+ // Material and geometry
54413
+ gsplatMaterial;
54414
+ // CPU-side data buffers (pre-allocated)
54415
+ _colorData;
54416
+ // RGBA8: count * 4
54417
+ _transformAData;
54418
+ // RGBA32U: count * 4
54419
+ _transformBData;
54420
+ // RGBA16F: count * 4
54421
+ _orderData;
54422
+ // R32U: size.x * size.y
54423
+ _positions;
54424
+ // xyz per splat (local space)
54425
+ // private _worldPositions: Float32Array; // xyz per splat (world space, cached)
54426
+ // Tracking which splats have been set
54427
+ _splatSetFlags;
54428
+ // Track which indices have data
54429
+ _validCount = 0;
54430
+ // Number of splats with valid data
54431
+ // Web Worker for sorting (same as GSplatRenderer)
54432
+ _sortWorker;
54433
+ _lastSentTime = 0;
54434
+ _minIntervalMs = 16;
54435
+ _centersSent = false;
54436
+ _lastViewMatrixHash = 0;
54437
+ // Adaptive sorting optimization
54438
+ _lastCameraSpeed = 0;
54439
+ _adaptiveSorting = true;
54440
+ _lastPixelCullParams = "";
54441
+ _texturesInitialized = false;
54442
+ // Pixel coverage culling
54443
+ _minPixelCoverage = 4;
54444
+ _maxPixelCoverage = 0;
54445
+ _maxPixelCullDistance = 0;
54446
+ // Batched rendering
54447
+ _batchSize = 128;
54448
+ instanceCount = 0;
54449
+ // Batch update optimization
54450
+ _pendingUpdates = /* @__PURE__ */ new Set();
54451
+ // Indices pending GPU update
54452
+ _autoFlushThreshold = 100;
54453
+ // Auto-flush when this many updates pending
54454
+ _frameCount = 0;
54455
+ constructor() {
54456
+ super();
54457
+ }
54458
+ /**
54459
+ * Initialize renderer with total splat count
54460
+ * Pre-allocates all GPU resources with zero-initialized data
54461
+ * @param totalCount Total number of splats that will be streamed
54462
+ * @param batchSize Splats per draw call (default: 128)
54463
+ */
54464
+ initCount(totalCount, batchSize = 128) {
54465
+ if (totalCount <= 0) {
54466
+ throw new Error("Total count must be greater than 0");
54467
+ }
54468
+ this.totalCount = totalCount;
54469
+ this._batchSize = batchSize;
54470
+ this.size = this.evalTextureSize(totalCount);
54471
+ const w = this.size.x | 0;
54472
+ const h = this.size.y | 0;
54473
+ const total = w * h;
54474
+ this._colorData = new Uint8Array(total * 4);
54475
+ this._colorData.fill(0);
54476
+ this._transformAData = new Uint32Array(total * 4);
54477
+ this._transformAData.fill(0);
54478
+ this._transformBData = new Array(total * 4).fill(0);
54479
+ this._orderData = new Uint32Array(total);
54480
+ for (let i = 0; i < total; i++) {
54481
+ this._orderData[i] = i < totalCount ? i : totalCount > 0 ? totalCount - 1 : 0;
54482
+ }
54483
+ this._positions = new Float32Array(totalCount * 3);
54484
+ this._positions.fill(0);
54485
+ this.localBoundBox.makeEmpty();
54486
+ this._splatSetFlags = new Array(totalCount).fill(false);
54487
+ this._validCount = 0;
54488
+ this.texParams = new Float32Array([this._validCount, this.size.x, 0, 1]);
54489
+ this.splatColor = new Uint8ArrayTexture().create(w, h, this._colorData, false);
54490
+ this.splatColor.name = "splatColor";
54491
+ this.splatColor.minFilter = "nearest";
54492
+ this.splatColor.magFilter = "nearest";
54493
+ this.splatColor.mipmapFilter = "nearest";
54494
+ this.splatColor.addressModeU = "clamp-to-edge";
54495
+ this.splatColor.addressModeV = "clamp-to-edge";
54496
+ this.transformA = new Uint32ArrayTexture().create(w, h, this._transformAData);
54497
+ this.transformA.name = "transformA";
54498
+ this.transformA.minFilter = "nearest";
54499
+ this.transformA.magFilter = "nearest";
54500
+ this.transformA.addressModeU = "clamp-to-edge";
54501
+ this.transformA.addressModeV = "clamp-to-edge";
54502
+ this.transformB = new Float16ArrayTexture().create(w, h, this._transformBData, false);
54503
+ this.transformB.name = "transformB";
54504
+ this.transformB.minFilter = "nearest";
54505
+ this.transformB.magFilter = "nearest";
54506
+ this.transformB.mipmapFilter = "nearest";
54507
+ this.transformB.addressModeU = "clamp-to-edge";
54508
+ this.transformB.addressModeV = "clamp-to-edge";
54509
+ this.splatOrder = new R32UintTexture().create(w, h, this._orderData);
54510
+ this.splatOrder.name = "splatOrder";
54511
+ this.splatOrder.minFilter = "nearest";
54512
+ this.splatOrder.magFilter = "nearest";
54513
+ this.splatOrder.addressModeU = "clamp-to-edge";
54514
+ this.splatOrder.addressModeV = "clamp-to-edge";
54515
+ this.gsplatMaterial = new GSplatMaterial();
54516
+ this.geometry = new GSplatGeometry(this._batchSize);
54517
+ this.materials = [this.gsplatMaterial];
54518
+ this.instanceCount = 0;
54519
+ }
54520
+ /**
54521
+ * Set data for a single splat at the given index
54522
+ * Updates CPU buffers and marks for GPU update
54523
+ * @param index Splat index (0 to count-1)
54524
+ * @param data Splat data (position is required, others optional)
54525
+ */
54526
+ setSplatData(index, data) {
54527
+ if (index < 0 || index >= this.totalCount) {
54528
+ throw new Error(`Index ${index} out of range [0, ${this.totalCount})`);
54529
+ }
54530
+ const wasSet = this._splatSetFlags[index];
54531
+ this._positions[index * 3 + 0] = data.position[0];
54532
+ this._positions[index * 3 + 1] = data.position[1];
54533
+ this._positions[index * 3 + 2] = data.position[2];
54534
+ this.localBoundBox.expandByPoint(new Vector3(data.position[0], data.position[1], data.position[2]));
54535
+ const SH_C0 = 0.28209479177387814;
54536
+ let r = 0.5, g = 0.5, b = 0.5;
54537
+ if (data.sh && data.sh.coeffs && data.sh.coeffs.length >= 3) {
54538
+ r = 0.5 + data.sh.coeffs[0] * SH_C0;
54539
+ g = 0.5 + data.sh.coeffs[1] * SH_C0;
54540
+ b = 0.5 + data.sh.coeffs[2] * SH_C0;
54541
+ }
54542
+ const a = data.opacity !== void 0 ? 1 / (1 + Math.exp(-data.opacity)) : 1;
54543
+ const colorIdx = index * 4;
54544
+ this._colorData[colorIdx + 0] = Math.max(0, Math.min(255, Math.floor(r * 255)));
54545
+ this._colorData[colorIdx + 1] = Math.max(0, Math.min(255, Math.floor(g * 255)));
54546
+ this._colorData[colorIdx + 2] = Math.max(0, Math.min(255, Math.floor(b * 255)));
54547
+ this._colorData[colorIdx + 3] = Math.max(0, Math.min(255, Math.floor(a * 255)));
54548
+ this.updateTransformData(index, data);
54549
+ if (!wasSet) {
54550
+ this._splatSetFlags[index] = true;
54551
+ this._validCount++;
54552
+ this.texParams[2] = this._validCount;
54553
+ }
54554
+ this._pendingUpdates.add(index);
54555
+ }
54556
+ /**
54557
+ * Update transform data for a single splat
54558
+ */
54559
+ updateTransformData(index, data) {
54560
+ const idx = index * 4;
54561
+ const fb = new ArrayBuffer(4);
54562
+ const f32 = new Float32Array(fb);
54563
+ const u32 = new Uint32Array(fb);
54564
+ const setFloatBits = (v) => {
54565
+ f32[0] = v;
54566
+ return u32[0];
54567
+ };
54568
+ const x = data.position[0];
54569
+ const y = data.position[1];
54570
+ const z = data.position[2];
54571
+ this._transformAData[idx + 0] = setFloatBits(x);
54572
+ this._transformAData[idx + 1] = setFloatBits(y);
54573
+ this._transformAData[idx + 2] = setFloatBits(z);
54574
+ let qx = 0, qy = 0, qz = 0, qw = 1;
54575
+ if (data.rotation) {
54576
+ qx = data.rotation[0];
54577
+ qy = data.rotation[1];
54578
+ qz = data.rotation[2];
54579
+ qw = data.rotation[3];
54580
+ const inv = 1 / Math.hypot(qx, qy, qz, qw);
54581
+ qx *= inv;
54582
+ qy *= inv;
54583
+ qz *= inv;
54584
+ qw *= inv;
54585
+ }
54586
+ let sx = 1, sy = 1, sz = 1;
54587
+ if (data.scale) {
54588
+ sx = Math.exp(data.scale[0]);
54589
+ sy = Math.exp(data.scale[1]);
54590
+ sz = Math.exp(data.scale[2]);
54591
+ }
54592
+ const x2 = qx + qx;
54593
+ const y2 = qy + qy;
54594
+ const z2 = qz + qz;
54595
+ const xx = qx * x2;
54596
+ const xy = qx * y2;
54597
+ const xz = qx * z2;
54598
+ const yy = qy * y2;
54599
+ const yz = qy * z2;
54600
+ const zz = qz * z2;
54601
+ const wx = qw * x2;
54602
+ const wy = qw * y2;
54603
+ const wz = qw * z2;
54604
+ const data0 = 1 - (yy + zz);
54605
+ const data1 = xy + wz;
54606
+ const data2 = xz - wy;
54607
+ const data3 = xy - wz;
54608
+ const data4 = 1 - (xx + zz);
54609
+ const data5 = yz + wx;
54610
+ const data6 = xz + wy;
54611
+ const data7 = yz - wx;
54612
+ const data8 = 1 - (xx + yy);
54613
+ const r00 = data0 * sx;
54614
+ const r01 = data1 * sx;
54615
+ const r02 = data2 * sx;
54616
+ const r10 = data3 * sy;
54617
+ const r11 = data4 * sy;
54618
+ const r12 = data5 * sy;
54619
+ const r20 = data6 * sz;
54620
+ const r21 = data7 * sz;
54621
+ const r22 = data8 * sz;
54622
+ const cAx = r00 * r00 + r10 * r10 + r20 * r20;
54623
+ const cAy = r00 * r01 + r10 * r11 + r20 * r21;
54624
+ const cAz = r00 * r02 + r10 * r12 + r20 * r22;
54625
+ const cBx = r01 * r01 + r11 * r11 + r21 * r21;
54626
+ const cBy = r01 * r02 + r11 * r12 + r21 * r22;
54627
+ const cBz = r02 * r02 + r12 * r12 + r22 * r22;
54628
+ const bidx = idx;
54629
+ this._transformBData[bidx + 0] = cAx;
54630
+ this._transformBData[bidx + 1] = cAy;
54631
+ this._transformBData[bidx + 2] = cAz;
54632
+ this._transformBData[bidx + 3] = cBz;
54633
+ const hx = toHalfFloat(cBx) & 65535;
54634
+ const hy = toHalfFloat(cBy) & 65535;
54635
+ this._transformAData[idx + 3] = hx | hy << 16;
54636
+ }
54637
+ /**
54638
+ * Flush pending updates to GPU
54639
+ * Updates GPU textures with all pending changes
54640
+ */
54641
+ flushUpdates() {
54642
+ if (this._pendingUpdates.size === 0) return;
54643
+ const w = this.size.x | 0;
54644
+ const h = this.size.y | 0;
54645
+ this.splatColor.updateTexture(w, h, this._colorData);
54646
+ this.transformA.updateTexture(w, h, this._transformAData);
54647
+ this.transformB.updateTexture(w, h, this._transformBData, false);
54648
+ this.updatePendingWorldPositions();
54649
+ this._pendingUpdates.clear();
54650
+ }
54651
+ /**
54652
+ * Set auto-flush threshold
54653
+ * @param threshold Number of pending updates before auto-flush (default: 100)
54654
+ */
54655
+ setAutoFlushThreshold(threshold) {
54656
+ this._autoFlushThreshold = Math.max(1, threshold);
54657
+ }
54658
+ /**
54659
+ * Get current streaming statistics
54660
+ */
54661
+ getStreamingStats() {
54662
+ return {
54663
+ totalCount: this.totalCount,
54664
+ validCount: this._validCount,
54665
+ pendingUpdates: this._pendingUpdates.size,
54666
+ progress: this.totalCount > 0 ? this._validCount / this.totalCount * 100 : 0
54667
+ };
54668
+ }
54669
+ /**
54670
+ * Update splat sorting before rendering
54671
+ * Uses the same logic as GSplatRenderer for reliable sorting
54672
+ */
54673
+ onBeforeUpdate(view) {
54674
+ if (this._validCount > 0 && view?.camera) {
54675
+ if (view.camera.viewMatrix) {
54676
+ this.scheduleOrder(view.camera.viewMatrix);
54677
+ }
54678
+ }
54679
+ }
54680
+ /**
54681
+ * Update world space positions when transform changes
54682
+ */
54683
+ updateWorldPositions() {
54684
+ if (!this._positions || this._validCount === 0) return;
54685
+ this._centersSent = false;
54686
+ }
54687
+ updatePendingWorldPositions() {
54688
+ if (!this._positions || this._validCount === 0) return;
54689
+ this._centersSent = false;
54690
+ }
54691
+ /**
54692
+ * Schedule Web Worker-based sorting task
54693
+ * Uses the same logic as GSplatRenderer for consistency
54694
+ */
54695
+ scheduleOrder(viewMatrix) {
54696
+ if (this._validCount === 0) return;
54697
+ const transformChanged = this.object3D.transform.localChange;
54698
+ if (transformChanged) {
54699
+ this.updateWorldPositions();
54700
+ }
54701
+ const r = viewMatrix.rawData;
54702
+ const vx = r[2], vy = r[6], vz = r[10];
54703
+ const px = -(r[0] * r[12] + r[1] * r[13] + r[2] * r[14]);
54704
+ const py = -(r[4] * r[12] + r[5] * r[13] + r[6] * r[14]);
54705
+ const pz = -(r[8] * r[12] + r[9] * r[13] + r[10] * r[14]);
54706
+ const now = performance.now();
54707
+ const deltaTime = (now - this._lastSentTime) / 1e3;
54708
+ const posHash = Math.floor(px * 1e3) ^ Math.floor(py * 1e3) ^ Math.floor(pz * 1e3);
54709
+ const dirHash = Math.floor(vx * 1e3) ^ Math.floor(vy * 1e3) ^ Math.floor(vz * 1e3);
54710
+ const hash = posHash ^ dirHash;
54711
+ if (hash === this._lastViewMatrixHash && !transformChanged && this._centersSent) {
54712
+ return;
54713
+ }
54714
+ let effectiveThrottle = this._minIntervalMs;
54715
+ if (this._adaptiveSorting && this._minIntervalMs > 0) {
54716
+ const hashDelta = Math.abs(hash - this._lastViewMatrixHash);
54717
+ const speed = hashDelta / Math.max(deltaTime, 1e-3);
54718
+ if (speed < 1e3) {
54719
+ effectiveThrottle = this._minIntervalMs;
54720
+ } else if (speed < 1e4) {
54721
+ effectiveThrottle = this._minIntervalMs * 0.5;
54722
+ } else {
54723
+ effectiveThrottle = this._minIntervalMs * 0.2;
54724
+ }
54725
+ this._lastCameraSpeed = speed;
54726
+ }
54727
+ if (now - this._lastSentTime < effectiveThrottle) {
54728
+ return;
54729
+ }
54730
+ this._lastViewMatrixHash = hash;
54731
+ this._lastSentTime = now;
54732
+ if (!this._sortWorker) {
54733
+ this._sortWorker = this.createSortWorker();
54734
+ this._sortWorker.onmessage = (ev) => {
54735
+ const newOrder = ev.data.order;
54736
+ const oldOrder = this._orderData.buffer;
54737
+ this._sortWorker.postMessage({
54738
+ order: oldOrder
54739
+ }, [oldOrder]);
54740
+ const indices = new Uint32Array(newOrder);
54741
+ const total = this.size.x * this.size.y;
54742
+ const validCount = Math.min(this._validCount, indices.length);
54743
+ if (!this._orderData || this._orderData.length !== total) {
54744
+ this._orderData = new Uint32Array(total);
54745
+ }
54746
+ this._orderData.set(indices.subarray(0, validCount), 0);
54747
+ if (validCount < total) {
54748
+ const lastIndex = this._validCount > 0 ? this._validCount - 1 : 0;
54749
+ this._orderData.fill(lastIndex, validCount, total);
54750
+ }
54751
+ this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
54752
+ const valid = Math.max(0, Math.min(this._validCount, ev.data.count | 0));
54753
+ this.texParams[2] = valid;
54754
+ this.texParams[0] = valid;
54755
+ this._updateTexParams();
54756
+ const newInstanceCount = Math.ceil(valid / this._batchSize);
54757
+ this.instanceCount = newInstanceCount;
54758
+ };
54759
+ const centers = new Float32Array(this._validCount * 3);
54760
+ let centerIdx = 0;
54761
+ const worldMatrix = this.object3D.transform.worldMatrix;
54762
+ const localPos = this._positions;
54763
+ const m = worldMatrix.rawData;
54764
+ for (let i = 0; i < this._validCount; i++) {
54765
+ if (this._splatSetFlags[i]) {
54766
+ const srcIdx = i * 3;
54767
+ const x = localPos[srcIdx + 0];
54768
+ const y = localPos[srcIdx + 1];
54769
+ const z = localPos[srcIdx + 2];
54770
+ centers[centerIdx * 3 + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54771
+ centers[centerIdx * 3 + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54772
+ centers[centerIdx * 3 + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54773
+ centerIdx++;
54774
+ }
54775
+ }
54776
+ const orderBuffer = new Uint32Array(this.totalCount);
54777
+ for (let i = 0; i < this.totalCount; i++) {
54778
+ orderBuffer[i] = i < this._validCount ? i : this._validCount > 0 ? this._validCount - 1 : 0;
54779
+ }
54780
+ this._sortWorker.postMessage({
54781
+ order: orderBuffer.buffer,
54782
+ centers: centers.buffer
54783
+ }, [orderBuffer.buffer, centers.buffer]);
54784
+ this._centersSent = true;
54785
+ }
54786
+ if (!this._centersSent && this._sortWorker) {
54787
+ const centers = new Float32Array(this._validCount * 3);
54788
+ let centerIdx = 0;
54789
+ const worldMatrix = this.object3D.transform.worldMatrix;
54790
+ const localPos = this._positions;
54791
+ const m = worldMatrix.rawData;
54792
+ for (let i = 0; i < this._validCount; i++) {
54793
+ if (this._splatSetFlags[i]) {
54794
+ const srcIdx = i * 3;
54795
+ const x = localPos[srcIdx + 0];
54796
+ const y = localPos[srcIdx + 1];
54797
+ const z = localPos[srcIdx + 2];
54798
+ centers[centerIdx * 3 + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
54799
+ centers[centerIdx * 3 + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
54800
+ centers[centerIdx * 3 + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
54801
+ centerIdx++;
54802
+ }
54803
+ }
54804
+ this._sortWorker.postMessage({
54805
+ type: "centers",
54806
+ centers: centers.buffer
54807
+ }, [centers.buffer]);
54808
+ this._centersSent = true;
54809
+ }
54810
+ this._sortWorker.postMessage({
54811
+ cameraPosition: { x: px, y: py, z: pz },
54812
+ cameraDirection: { x: -vx, y: -vy, z: -vz }
54813
+ });
54814
+ }
54815
+ /**
54816
+ * Create Web Worker for sorting
54817
+ * Uses the exact same logic as GSplatRenderer for consistency
54818
+ */
54819
+ createSortWorker() {
54820
+ function SortWorker() {
54821
+ const compareBits = 16;
54822
+ const bucketCount = 2 ** compareBits + 1;
54823
+ let order;
54824
+ let centers;
54825
+ let cameraPosition;
54826
+ let cameraDirection;
54827
+ let forceUpdate = false;
54828
+ const lastCameraPosition = { x: 0, y: 0, z: 0 };
54829
+ const lastCameraDirection = { x: 0, y: 0, z: 0 };
54830
+ const boundMin = { x: 0, y: 0, z: 0 };
54831
+ const boundMax = { x: 0, y: 0, z: 0 };
54832
+ let distances;
54833
+ let countBuffer;
54834
+ const binarySearch = (m, n, compare_fn) => {
54835
+ while (m <= n) {
54836
+ const k = n + m >> 1;
54837
+ const cmp = compare_fn(k);
54838
+ if (cmp > 0) {
54839
+ m = k + 1;
54840
+ } else if (cmp < 0) {
54841
+ n = k - 1;
54842
+ } else {
54843
+ return k;
54844
+ }
54845
+ }
54846
+ return ~m;
54847
+ };
54848
+ const update = () => {
54849
+ if (!order || !centers || !cameraPosition || !cameraDirection) return;
54850
+ const px = cameraPosition.x;
54851
+ const py = cameraPosition.y;
54852
+ const pz = cameraPosition.z;
54853
+ const dx = cameraDirection.x;
54854
+ const dy = cameraDirection.y;
54855
+ const dz = cameraDirection.z;
54856
+ const epsilon = 1e-3;
54857
+ if (!forceUpdate && Math.abs(px - lastCameraPosition.x) < epsilon && Math.abs(py - lastCameraPosition.y) < epsilon && Math.abs(pz - lastCameraPosition.z) < epsilon && Math.abs(dx - lastCameraDirection.x) < epsilon && Math.abs(dy - lastCameraDirection.y) < epsilon && Math.abs(dz - lastCameraDirection.z) < epsilon) {
54858
+ return;
54859
+ }
54860
+ forceUpdate = false;
54861
+ lastCameraPosition.x = px;
54862
+ lastCameraPosition.y = py;
54863
+ lastCameraPosition.z = pz;
54864
+ lastCameraDirection.x = dx;
54865
+ lastCameraDirection.y = dy;
54866
+ lastCameraDirection.z = dz;
54867
+ const numVertices = centers.length / 3;
54868
+ if (distances?.length !== numVertices) {
54869
+ distances = new Uint32Array(numVertices);
54870
+ }
54871
+ let minDist;
54872
+ let maxDist;
54873
+ for (let i = 0; i < 8; ++i) {
54874
+ const x = (i & 1 ? boundMin.x : boundMax.x) - px;
54875
+ const y = (i & 2 ? boundMin.y : boundMax.y) - py;
54876
+ const z = (i & 4 ? boundMin.z : boundMax.z) - pz;
54877
+ const d = x * dx + y * dy + z * dz;
54878
+ if (i === 0) {
54879
+ minDist = maxDist = d;
54880
+ } else {
54881
+ minDist = Math.min(minDist, d);
54882
+ maxDist = Math.max(maxDist, d);
54883
+ }
54884
+ }
54885
+ if (!countBuffer) {
54886
+ countBuffer = new Uint32Array(bucketCount);
54887
+ } else {
54888
+ countBuffer.fill(0);
54889
+ }
54890
+ const range = maxDist - minDist;
54891
+ const divider = range < 1e-6 ? 0 : 1 / range * 2 ** compareBits;
54892
+ for (let i = 0; i < numVertices; ++i) {
54893
+ const istride = i * 3;
54894
+ const x = centers[istride + 0] - px;
54895
+ const y = centers[istride + 1] - py;
54896
+ const z = centers[istride + 2] - pz;
54897
+ const d = x * dx + y * dy + z * dz;
54898
+ const sortKey = Math.floor((d - minDist) * divider);
54899
+ distances[i] = sortKey;
54900
+ countBuffer[sortKey]++;
54901
+ }
54902
+ for (let i = 1; i < bucketCount; i++) {
54903
+ countBuffer[i] += countBuffer[i - 1];
54904
+ }
54905
+ for (let i = 0; i < numVertices; i++) {
54906
+ const distance = distances[i];
54907
+ const destIndex = --countBuffer[distance];
54908
+ order[destIndex] = i;
54909
+ }
54910
+ const dist = (i) => distances[order[i]] / divider + minDist;
54911
+ const findZero = () => {
54912
+ const result = binarySearch(0, numVertices - 1, (i) => -dist(i));
54913
+ return Math.min(numVertices, Math.abs(result));
54914
+ };
54915
+ const count = dist(numVertices - 1) >= 0 ? findZero() : numVertices;
54916
+ self.postMessage({
54917
+ order: order.buffer,
54918
+ count
54919
+ }, [order.buffer]);
54920
+ order = null;
54921
+ };
54922
+ self.onmessage = (message) => {
54923
+ if (message.data.order) {
54924
+ order = new Uint32Array(message.data.order);
54925
+ }
54926
+ if (message.data.centers) {
54927
+ centers = new Float32Array(message.data.centers);
54928
+ boundMin.x = boundMax.x = centers[0];
54929
+ boundMin.y = boundMax.y = centers[1];
54930
+ boundMin.z = boundMax.z = centers[2];
54931
+ const numVertices = centers.length / 3;
54932
+ for (let i = 1; i < numVertices; ++i) {
54933
+ const x = centers[i * 3 + 0];
54934
+ const y = centers[i * 3 + 1];
54935
+ const z = centers[i * 3 + 2];
54936
+ boundMin.x = Math.min(boundMin.x, x);
54937
+ boundMin.y = Math.min(boundMin.y, y);
54938
+ boundMin.z = Math.min(boundMin.z, z);
54939
+ boundMax.x = Math.max(boundMax.x, x);
54940
+ boundMax.y = Math.max(boundMax.y, y);
54941
+ boundMax.z = Math.max(boundMax.z, z);
54942
+ }
54943
+ forceUpdate = true;
54944
+ }
54945
+ if (message.data.cameraPosition) cameraPosition = message.data.cameraPosition;
54946
+ if (message.data.cameraDirection) cameraDirection = message.data.cameraDirection;
54947
+ update();
54948
+ };
54949
+ }
54950
+ const code = `(${SortWorker.toString()})()`;
54951
+ const blob = new Blob([code], { type: "application/javascript" });
54952
+ const url = URL.createObjectURL(blob);
54953
+ return new Worker(url);
54954
+ }
54955
+ /**
54956
+ * Set visibility boost factor
54957
+ */
54958
+ setVisBoost(v) {
54959
+ this.texParams[3] = Math.max(0, v);
54960
+ }
54961
+ setCount(c) {
54962
+ this.texParams[0] = Math.max(0, c);
54963
+ }
54964
+ _updateTexParams() {
54965
+ this.gsplatMaterial.setTexParams(this.texParams);
54966
+ }
54967
+ /**
54968
+ * Set sort throttle interval (milliseconds)
54969
+ */
54970
+ setSortThrottle(ms) {
54971
+ this._minIntervalMs = Math.max(0, ms | 0);
54972
+ }
54973
+ /**
54974
+ * Enable/disable adaptive sorting
54975
+ */
54976
+ setAdaptiveSorting(enabled) {
54977
+ this._adaptiveSorting = enabled;
54978
+ }
54979
+ /**
54980
+ * Set pixel coverage culling thresholds
54981
+ */
54982
+ setPixelCulling(minPixels, maxPixels = 0, maxPixelCullDistance = 0) {
54983
+ this._minPixelCoverage = Math.max(0, minPixels);
54984
+ this._maxPixelCoverage = Math.max(0, maxPixels);
54985
+ this._maxPixelCullDistance = Math.max(0, maxPixelCullDistance);
54986
+ }
54987
+ /**
54988
+ * Get current pixel culling settings
54989
+ */
54990
+ getPixelCullingStats() {
54991
+ return {
54992
+ minPixels: this._minPixelCoverage,
54993
+ maxPixels: this._maxPixelCoverage,
54994
+ maxPixelCullDistance: this._maxPixelCullDistance,
54995
+ maxEnabled: this._maxPixelCoverage > 0,
54996
+ distanceEnabled: this._maxPixelCullDistance > 0
54997
+ };
54998
+ }
54999
+ /**
55000
+ * Get batching statistics
55001
+ */
55002
+ getBatchingStats() {
55003
+ return {
55004
+ enabled: true,
55005
+ batchSize: this._batchSize,
55006
+ instanceCount: this.instanceCount,
55007
+ splatCount: this._validCount,
55008
+ reduction: this._validCount > 0 ? (1 - this.instanceCount / this._validCount) * 100 : 0
55009
+ };
55010
+ }
55011
+ /**
55012
+ * Calculate texture size for given splat count
55013
+ */
55014
+ evalTextureSize(count) {
55015
+ let w = Math.ceil(Math.sqrt(count));
55016
+ const align = 64;
55017
+ w = Math.ceil(w / align) * align;
55018
+ const h = Math.ceil(count / w);
55019
+ return new Vector2(w, h);
55020
+ }
55021
+ /**
55022
+ * Update node before rendering
55023
+ */
55024
+ nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
55025
+ if (this._pendingUpdates.size > 0 && this._frameCount >= 60) {
55026
+ this.flushUpdates();
55027
+ }
55028
+ if (this._frameCount >= 60 && this._pendingUpdates.size === 0) {
55029
+ this._frameCount = 0;
55030
+ }
55031
+ this._frameCount++;
55032
+ const worldMatrix = this.object3D.transform.worldMatrix;
55033
+ this.gsplatMaterial.setTransformMatrix(worldMatrix);
55034
+ const currentParams = `${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;
55035
+ if (currentParams !== this._lastPixelCullParams) {
55036
+ this.gsplatMaterial.setPixelCulling(this._minPixelCoverage, this._maxPixelCoverage, this._maxPixelCullDistance, this._batchSize);
55037
+ this._lastPixelCullParams = currentParams;
55038
+ }
55039
+ if (!this._texturesInitialized) {
55040
+ this.gsplatMaterial.setSplatTextures(
55041
+ this.splatColor,
55042
+ this.transformA,
55043
+ this.transformB,
55044
+ this.texParams,
55045
+ this.splatOrder
55046
+ );
55047
+ this._texturesInitialized = true;
55048
+ }
55049
+ super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
55050
+ }
55051
+ /**
55052
+ * Render pass
55053
+ */
55054
+ renderPass(view, passType, renderContext) {
55055
+ const encoder = renderContext.encoder;
55056
+ for (let mat of this.materials) {
55057
+ const passes = mat.getPass(passType);
55058
+ if (!passes || passes.length === 0) continue;
55059
+ for (const pass of passes) {
55060
+ if (!pass.pipeline) continue;
55061
+ pass.apply(this.geometry, renderContext.rendererPassState || renderContext);
55062
+ GPUContext.bindPipeline(encoder, pass);
55063
+ GPUContext.bindGeometryBuffer(encoder, this.geometry);
55064
+ const subGeometry = this.geometry.subGeometries[0];
55065
+ const lodInfo = subGeometry.lodLevels[0];
55066
+ if (this.instanceCount > 0) {
55067
+ GPUContext.drawIndexed(
55068
+ encoder,
55069
+ lodInfo.indexCount,
55070
+ this.instanceCount,
55071
+ lodInfo.indexStart,
55072
+ 0,
55073
+ 0
55074
+ );
55075
+ } else {
55076
+ GPUContext.drawIndexed(
55077
+ encoder,
55078
+ lodInfo.indexCount,
55079
+ 1,
55080
+ lodInfo.indexStart,
55081
+ 0,
55082
+ 0
55083
+ );
55084
+ }
55085
+ }
55086
+ }
55087
+ }
55088
+ /**
55089
+ * Clean up resources
55090
+ */
55091
+ destroy(force) {
55092
+ if (this._sortWorker) {
55093
+ this._sortWorker.terminate();
55094
+ this._sortWorker = null;
55095
+ }
55096
+ if (this.splatColor) {
55097
+ this.splatColor.destroy(force);
55098
+ this.splatColor = null;
55099
+ }
55100
+ if (this.transformA) {
55101
+ this.transformA.destroy(force);
55102
+ this.transformA = null;
55103
+ }
55104
+ if (this.transformB) {
55105
+ this.transformB.destroy(force);
55106
+ this.transformB = null;
55107
+ }
55108
+ if (this.splatOrder) {
55109
+ this.splatOrder.destroy(force);
55110
+ this.splatOrder = null;
55111
+ }
55112
+ this._positions = null;
55113
+ this._orderData = null;
55114
+ this._colorData = null;
55115
+ this._transformAData = null;
55116
+ this._transformBData = null;
55117
+ this.texParams = null;
55118
+ this._splatSetFlags = null;
55119
+ this._pendingUpdates.clear();
55120
+ super.destroy(force);
55121
+ }
55122
+ };
55123
+ exports.GSplatStreamRenderer = __decorateClass$7([
55124
+ RegisterComponent(exports.GSplatStreamRenderer, "GSplatStreamRenderer")
55125
+ ], exports.GSplatStreamRenderer);
55126
+
54354
55127
  class Probe extends exports.Object3D {
54355
55128
  index = 0;
54356
55129
  drawCallFrame = -1;
@@ -59830,6 +60603,127 @@ fn frag(){
59830
60603
  }
59831
60604
  }
59832
60605
 
60606
+ class StreamLoader extends LoaderBase {
60607
+ /**
60608
+ * Load resource with streaming support
60609
+ * @param url Resource URL
60610
+ * @param parserClass Parser class that supports streaming
60611
+ * @param loaderFunctions Optional loader callbacks
60612
+ * @param userData Optional user data
60613
+ * @returns Promise that resolves when initial data is ready (header parsed), includes cancel method
60614
+ */
60615
+ async loadStream(url, parserClass, loaderFunctions, userData) {
60616
+ if (parserClass.format !== ParserFormat.BIN) {
60617
+ throw new Error("StreamLoader only supports BIN format parsers");
60618
+ }
60619
+ return new Promise(async (succ, fail) => {
60620
+ let aborted = false;
60621
+ let reader = null;
60622
+ let abortController = null;
60623
+ const cancel = () => {
60624
+ aborted = true;
60625
+ if (reader) {
60626
+ reader.cancel().catch(() => {
60627
+ });
60628
+ reader.releaseLock();
60629
+ }
60630
+ if (abortController) {
60631
+ abortController.abort();
60632
+ }
60633
+ if (parser && typeof parser.cancel === "function") {
60634
+ parser.cancel();
60635
+ }
60636
+ };
60637
+ let parser = null;
60638
+ try {
60639
+ this.baseUrl = url.substring(0, url.lastIndexOf("/") + 1);
60640
+ this.initUrl = url;
60641
+ abortController = new AbortController();
60642
+ const response = await fetch(url, {
60643
+ headers: loaderFunctions?.headers,
60644
+ signal: abortController.signal
60645
+ });
60646
+ if (!response.ok) {
60647
+ throw new Error(`Request rejected with status ${response.status}`);
60648
+ }
60649
+ reader = response.body.getReader();
60650
+ const contentLength = +response.headers.get("Content-Length") || 0;
60651
+ parser = new parserClass();
60652
+ parser.userData = userData;
60653
+ parser.baseUrl = this.baseUrl;
60654
+ parser.initUrl = url;
60655
+ parser.loaderFunctions = loaderFunctions;
60656
+ if (typeof parser.initStream !== "function") {
60657
+ throw new Error(`Parser ${parserClass.name} does not support streaming. Implement initStream() method.`);
60658
+ }
60659
+ let parserResolved = false;
60660
+ await parser.initStream(contentLength, () => {
60661
+ if (!parserResolved && !aborted && parser && parser.verification()) {
60662
+ parserResolved = true;
60663
+ succ({ parser, cancel });
60664
+ }
60665
+ });
60666
+ let receivedLength = 0;
60667
+ while (!aborted) {
60668
+ const { done, value } = await reader.read();
60669
+ if (done || aborted) {
60670
+ if (!aborted) {
60671
+ if (typeof parser.finalizeStream === "function") {
60672
+ await parser.finalizeStream();
60673
+ }
60674
+ if (!parserResolved && parser) {
60675
+ if (parser.verification()) {
60676
+ parserResolved = true;
60677
+ succ({ parser, cancel });
60678
+ } else {
60679
+ throw new Error("Parser verification failed");
60680
+ }
60681
+ }
60682
+ }
60683
+ break;
60684
+ }
60685
+ if (aborted) break;
60686
+ receivedLength += value.length;
60687
+ if (contentLength > 0 && loaderFunctions?.onProgress && !aborted) {
60688
+ loaderFunctions.onProgress.call(
60689
+ this,
60690
+ receivedLength,
60691
+ contentLength,
60692
+ url,
60693
+ parser
60694
+ );
60695
+ }
60696
+ if (!aborted && typeof parser.processChunk === "function") {
60697
+ await parser.processChunk(value, receivedLength, contentLength);
60698
+ }
60699
+ if (!parserResolved && !aborted && parser && parser.verification()) {
60700
+ parserResolved = true;
60701
+ succ({ parser, cancel });
60702
+ }
60703
+ }
60704
+ if (!aborted && loaderFunctions?.onComplete) {
60705
+ loaderFunctions.onComplete.call(this, url);
60706
+ }
60707
+ } catch (e) {
60708
+ if (aborted) {
60709
+ return;
60710
+ }
60711
+ if (loaderFunctions?.onError) {
60712
+ loaderFunctions.onError(e);
60713
+ }
60714
+ fail(e);
60715
+ } finally {
60716
+ if (reader && !aborted) {
60717
+ try {
60718
+ reader.releaseLock();
60719
+ } catch {
60720
+ }
60721
+ }
60722
+ }
60723
+ });
60724
+ }
60725
+ }
60726
+
59833
60727
  function computeAABBFromPositions(position) {
59834
60728
  const min = [Infinity, Infinity, Infinity];
59835
60729
  const max = [-Infinity, -Infinity, -Infinity];
@@ -61048,6 +61942,314 @@ fn frag(){
61048
61942
  };
61049
61943
  }
61050
61944
 
61945
+ class PlyStreamParser {
61946
+ _header = null;
61947
+ _headerBuffer = new Uint8Array(4096);
61948
+ _headerLength = 0;
61949
+ _headerParsed = false;
61950
+ // Data parsing state
61951
+ _dataBuffer = null;
61952
+ _dataOffset = 0;
61953
+ _processedVertices = 0;
61954
+ _vertexStride = 0;
61955
+ _propOffsets = [];
61956
+ _properties = [];
61957
+ // Callbacks
61958
+ _onHeaderParsed = null;
61959
+ _onSplatParsed = null;
61960
+ _batchSize = 1e3;
61961
+ _cancelled = false;
61962
+ constructor(onHeaderParsed, onSplatParsed, batchSize = 1e3) {
61963
+ this._onHeaderParsed = onHeaderParsed;
61964
+ this._onSplatParsed = onSplatParsed;
61965
+ this._batchSize = batchSize;
61966
+ }
61967
+ /**
61968
+ * Process incoming data chunk
61969
+ */
61970
+ processChunk(chunk) {
61971
+ if (this._cancelled) return;
61972
+ if (!this._headerParsed) {
61973
+ this._processHeaderChunk(chunk);
61974
+ } else {
61975
+ this._processDataChunk(chunk);
61976
+ }
61977
+ }
61978
+ /**
61979
+ * Cancel parsing
61980
+ * Stops processing new chunks
61981
+ */
61982
+ cancel() {
61983
+ this._cancelled = true;
61984
+ }
61985
+ /**
61986
+ * Check if parsing is cancelled
61987
+ */
61988
+ isCancelled() {
61989
+ return this._cancelled;
61990
+ }
61991
+ /**
61992
+ * Process header chunk
61993
+ */
61994
+ _processHeaderChunk(chunk) {
61995
+ const needed = this._headerLength + chunk.length;
61996
+ if (needed > this._headerBuffer.length) {
61997
+ const newBuffer = new Uint8Array(Math.max(needed, this._headerBuffer.length * 2));
61998
+ newBuffer.set(this._headerBuffer.subarray(0, this._headerLength));
61999
+ this._headerBuffer = newBuffer;
62000
+ }
62001
+ this._headerBuffer.set(chunk, this._headerLength);
62002
+ this._headerLength += chunk.length;
62003
+ const headerText = new TextDecoder("utf-8").decode(
62004
+ this._headerBuffer.subarray(0, this._headerLength)
62005
+ );
62006
+ const headerEnd = headerText.indexOf("end_header\n");
62007
+ if (headerEnd >= 0) {
62008
+ const headerEndPos = headerEnd + "end_header\n".length;
62009
+ const headerBuffer = this._headerBuffer.subarray(0, headerEndPos);
62010
+ const headerArrayBuffer = headerBuffer.buffer.slice(headerBuffer.byteOffset, headerBuffer.byteOffset + headerBuffer.byteLength);
62011
+ const header = this._parseHeader(headerArrayBuffer);
62012
+ this._header = header;
62013
+ this._headerParsed = true;
62014
+ this._initializeDataParsing(header);
62015
+ if (this._onHeaderParsed) {
62016
+ this._onHeaderParsed(header);
62017
+ }
62018
+ const chunkStartInHeader = this._headerLength - chunk.length;
62019
+ const remainingStartInChunk = headerEndPos - chunkStartInHeader;
62020
+ if (remainingStartInChunk > 0 && remainingStartInChunk < chunk.length) {
62021
+ const remainingChunk = chunk.subarray(remainingStartInChunk);
62022
+ this._processDataChunk(remainingChunk);
62023
+ } else if (remainingStartInChunk === 0) {
62024
+ this._processDataChunk(chunk);
62025
+ }
62026
+ }
62027
+ }
62028
+ /**
62029
+ * Parse PLY header from buffer
62030
+ */
62031
+ _parseHeader(buffer) {
62032
+ const ascii = new TextDecoder("utf-8").decode(new Uint8Array(buffer));
62033
+ const headerEnd = ascii.indexOf("end_header\n");
62034
+ if (headerEnd < 0) {
62035
+ throw new Error("PLY: Invalid PLY header");
62036
+ }
62037
+ const headerText = ascii.substring(0, headerEnd + "end_header\n".length);
62038
+ const lines = headerText.split(/\r?\n/);
62039
+ let format = "";
62040
+ let vertexCount = 0;
62041
+ let faceCount = 0;
62042
+ const properties = [];
62043
+ const faceProperties = [];
62044
+ const textureFiles = [];
62045
+ let inVertexElement = false;
62046
+ let inFaceElement = false;
62047
+ for (const line of lines) {
62048
+ if (line.startsWith("format ")) {
62049
+ format = line.split(/\s+/)[1];
62050
+ } else if (line.startsWith("comment TextureFile ")) {
62051
+ const texturePath = line.substring("comment TextureFile ".length).trim();
62052
+ if (texturePath) {
62053
+ textureFiles.push(texturePath);
62054
+ }
62055
+ } else if (line.startsWith("element ")) {
62056
+ const toks = line.split(/\s+/);
62057
+ inVertexElement = toks[1] === "vertex";
62058
+ inFaceElement = toks[1] === "face";
62059
+ if (inVertexElement) {
62060
+ vertexCount = parseInt(toks[2]);
62061
+ inFaceElement = false;
62062
+ }
62063
+ if (inFaceElement) {
62064
+ faceCount = parseInt(toks[2]);
62065
+ inVertexElement = false;
62066
+ }
62067
+ } else if (inVertexElement && line.startsWith("property ")) {
62068
+ const toks = line.split(/\s+/);
62069
+ const type = toks[1];
62070
+ const name = toks[2];
62071
+ properties.push({ name, type });
62072
+ } else if (inFaceElement && line.startsWith("property ")) {
62073
+ const toks = line.split(/\s+/);
62074
+ if (toks[1] === "list") {
62075
+ const countType = toks[2];
62076
+ const itemType = toks[3];
62077
+ const name = toks[4];
62078
+ faceProperties.push({ name, type: `list ${countType} ${itemType}` });
62079
+ } else {
62080
+ const type = toks[1];
62081
+ const name = toks[2];
62082
+ faceProperties.push({ name, type });
62083
+ }
62084
+ }
62085
+ }
62086
+ if (format !== "binary_little_endian" && format !== "ascii") {
62087
+ throw new Error(`PLY: Unsupported format: ${format}`);
62088
+ }
62089
+ let splatPropertyCount = 0;
62090
+ let splatPropertyColorCount = 0;
62091
+ for (const property of properties) {
62092
+ if (splatProperties.includes(property.name)) {
62093
+ splatPropertyCount++;
62094
+ }
62095
+ if (splatColorProperties.includes(property.name)) {
62096
+ splatPropertyColorCount++;
62097
+ }
62098
+ }
62099
+ let mode;
62100
+ if (faceCount > 0) {
62101
+ mode = PlyMode.Mesh;
62102
+ } else if (splatPropertyCount === splatProperties.length && splatPropertyColorCount === 3) {
62103
+ mode = PlyMode.Splat;
62104
+ } else {
62105
+ mode = PlyMode.PointCloud;
62106
+ }
62107
+ return {
62108
+ format,
62109
+ vertexCount,
62110
+ faceCount,
62111
+ properties,
62112
+ faceProperties: faceProperties.length > 0 ? faceProperties : void 0,
62113
+ textureFiles,
62114
+ headerByteLength: headerText.length,
62115
+ mode
62116
+ };
62117
+ }
62118
+ /**
62119
+ * Initialize data parsing structures
62120
+ */
62121
+ _initializeDataParsing(header) {
62122
+ this._properties = header.properties;
62123
+ this._propOffsets = [];
62124
+ this._vertexStride = 0;
62125
+ for (const p of this._properties) {
62126
+ this._propOffsets.push(this._vertexStride);
62127
+ this._vertexStride += byteSizeOfType(p.type);
62128
+ }
62129
+ const estimatedSize = header.vertexCount * this._vertexStride;
62130
+ this._dataBuffer = new Uint8Array(Math.min(estimatedSize, 1024 * 1024 * 10));
62131
+ this._dataOffset = 0;
62132
+ this._processedVertices = 0;
62133
+ }
62134
+ /**
62135
+ * Process data chunk
62136
+ */
62137
+ _processDataChunk(chunk) {
62138
+ if (!this._header || !this._dataBuffer) return;
62139
+ const needed = this._dataOffset + chunk.length;
62140
+ if (needed > this._dataBuffer.length) {
62141
+ const newSize = Math.max(needed, this._dataBuffer.length * 2);
62142
+ const newBuffer = new Uint8Array(newSize);
62143
+ newBuffer.set(this._dataBuffer);
62144
+ this._dataBuffer = newBuffer;
62145
+ }
62146
+ this._dataBuffer.set(chunk, this._dataOffset);
62147
+ this._dataOffset += chunk.length;
62148
+ this._parseVertices();
62149
+ }
62150
+ /**
62151
+ * Parse vertices from current data buffer
62152
+ */
62153
+ _parseVertices() {
62154
+ if (!this._header || !this._dataBuffer) return;
62155
+ const payload = new DataView(this._dataBuffer.buffer, this._dataBuffer.byteOffset, this._dataBuffer.byteLength);
62156
+ const vertexCount = this._header.vertexCount;
62157
+ const has = (n) => this._properties.find((p) => p.name === n) != null;
62158
+ const propIndex = (n) => this._properties.findIndex((p) => p.name === n);
62159
+ while (this._processedVertices < vertexCount && !this._cancelled) {
62160
+ const v = this._processedVertices;
62161
+ const vOffset = v * this._vertexStride;
62162
+ if (vOffset + this._vertexStride > this._dataOffset) {
62163
+ break;
62164
+ }
62165
+ if (this._cancelled) {
62166
+ break;
62167
+ }
62168
+ const ix = propIndex("x");
62169
+ const iy = propIndex("y");
62170
+ const iz = propIndex("z");
62171
+ if (ix < 0 || iy < 0 || iz < 0) {
62172
+ throw new Error("PLY: Missing required x/y/z properties for vertex");
62173
+ }
62174
+ const splatData = {
62175
+ position: [
62176
+ readByType(payload, vOffset + this._propOffsets[ix], this._properties[ix].type),
62177
+ readByType(payload, vOffset + this._propOffsets[iy], this._properties[iy].type),
62178
+ readByType(payload, vOffset + this._propOffsets[iz], this._properties[iz].type)
62179
+ ]
62180
+ };
62181
+ if (has("scale_0")) {
62182
+ splatData.scale = [
62183
+ readByType(payload, vOffset + this._propOffsets[propIndex("scale_0")], this._properties[propIndex("scale_0")].type),
62184
+ readByType(payload, vOffset + this._propOffsets[propIndex("scale_1")], this._properties[propIndex("scale_1")].type),
62185
+ readByType(payload, vOffset + this._propOffsets[propIndex("scale_2")], this._properties[propIndex("scale_2")].type)
62186
+ ];
62187
+ }
62188
+ if (has("rot_0")) {
62189
+ const w = readByType(payload, vOffset + this._propOffsets[propIndex("rot_0")], this._properties[propIndex("rot_0")].type);
62190
+ const x = readByType(payload, vOffset + this._propOffsets[propIndex("rot_1")], this._properties[propIndex("rot_1")].type);
62191
+ const y = readByType(payload, vOffset + this._propOffsets[propIndex("rot_2")], this._properties[propIndex("rot_2")].type);
62192
+ const z = readByType(payload, vOffset + this._propOffsets[propIndex("rot_3")], this._properties[propIndex("rot_3")].type);
62193
+ splatData.rotation = [x, y, z, w];
62194
+ }
62195
+ if (has("opacity")) {
62196
+ splatData.opacity = readByType(payload, vOffset + this._propOffsets[propIndex("opacity")], this._properties[propIndex("opacity")].type);
62197
+ }
62198
+ const dcIdx = [propIndex("f_dc_0"), propIndex("f_dc_1"), propIndex("f_dc_2")];
62199
+ if (dcIdx[0] >= 0 && dcIdx[1] >= 0 && dcIdx[2] >= 0) {
62200
+ const restIndices = [];
62201
+ for (let i = 0; i < this._properties.length; i++) {
62202
+ if (this._properties[i].name.startsWith("f_rest_")) restIndices.push(i);
62203
+ }
62204
+ const coeffsPerColor = 1 + restIndices.length / 3;
62205
+ const coeffs = new Float32Array(coeffsPerColor * 3);
62206
+ coeffs[0] = readByType(payload, vOffset + this._propOffsets[dcIdx[0]], this._properties[dcIdx[0]].type);
62207
+ coeffs[coeffsPerColor + 0] = readByType(payload, vOffset + this._propOffsets[dcIdx[1]], this._properties[dcIdx[1]].type);
62208
+ coeffs[2 * coeffsPerColor + 0] = readByType(payload, vOffset + this._propOffsets[dcIdx[2]], this._properties[dcIdx[2]].type);
62209
+ let rPtr = 1;
62210
+ let gPtr = 1;
62211
+ let bPtr = 1;
62212
+ for (let i = 0; i < restIndices.length; i += 3) {
62213
+ const ri = restIndices[i + 0];
62214
+ const gi = restIndices[i + 1];
62215
+ const bi = restIndices[i + 2];
62216
+ coeffs[rPtr] = readByType(payload, vOffset + this._propOffsets[ri], this._properties[ri].type);
62217
+ coeffs[coeffsPerColor + gPtr] = readByType(payload, vOffset + this._propOffsets[gi], this._properties[gi].type);
62218
+ coeffs[2 * coeffsPerColor + bPtr] = readByType(payload, vOffset + this._propOffsets[bi], this._properties[bi].type);
62219
+ rPtr++;
62220
+ gPtr++;
62221
+ bPtr++;
62222
+ }
62223
+ splatData.sh = {
62224
+ order: Math.floor(Math.sqrt(coeffsPerColor)),
62225
+ coeffs
62226
+ };
62227
+ }
62228
+ if (this._onSplatParsed) {
62229
+ this._onSplatParsed(splatData, v);
62230
+ }
62231
+ this._processedVertices++;
62232
+ if (this._processedVertices % this._batchSize === 0) {
62233
+ setTimeout(() => {
62234
+ this._parseVertices();
62235
+ }, 0);
62236
+ return;
62237
+ }
62238
+ }
62239
+ }
62240
+ /**
62241
+ * Get current parsing progress
62242
+ */
62243
+ getProgress() {
62244
+ const total = this._header?.vertexCount || 0;
62245
+ return {
62246
+ processed: this._processedVertices,
62247
+ total,
62248
+ percentage: total > 0 ? this._processedVertices / total * 100 : 0
62249
+ };
62250
+ }
62251
+ }
62252
+
61051
62253
  class GaussianSplatParser extends ParserBase {
61052
62254
  static format = ParserFormat.BIN;
61053
62255
  async parseBuffer(buffer) {
@@ -61083,6 +62285,95 @@ fn frag(){
61083
62285
  }
61084
62286
  }
61085
62287
 
62288
+ class StreamingGaussianSplatParser extends ParserBase {
62289
+ static format = ParserFormat.BIN;
62290
+ _streamParser = null;
62291
+ _streamingRenderer = null;
62292
+ _rendererObject = null;
62293
+ _chunksPerBatch = 1e3;
62294
+ // Number of splats to process per batch
62295
+ _headerParsed = false;
62296
+ _onHeaderParsed = null;
62297
+ _cancelled = false;
62298
+ /**
62299
+ * Initialize streaming parser
62300
+ * @param contentLength Total content length (if known)
62301
+ * @param onHeaderParsed Optional callback when header is parsed (parser is ready)
62302
+ */
62303
+ async initStream(contentLength, onHeaderParsed) {
62304
+ this._onHeaderParsed = onHeaderParsed || null;
62305
+ this._rendererObject = new exports.Object3D();
62306
+ this._rendererObject.name = "StreamingGaussianSplat";
62307
+ this._streamingRenderer = this._rendererObject.addComponent(exports.GSplatStreamRenderer);
62308
+ this._streamParser = new PlyStreamParser(
62309
+ (header) => {
62310
+ if (this._streamingRenderer) {
62311
+ this._streamingRenderer.initCount(header.vertexCount);
62312
+ }
62313
+ if (this._rendererObject) {
62314
+ this.data = this._rendererObject;
62315
+ }
62316
+ this._headerParsed = true;
62317
+ if (this._onHeaderParsed) {
62318
+ this._onHeaderParsed();
62319
+ }
62320
+ },
62321
+ (splatData, index) => {
62322
+ if (this._streamingRenderer) {
62323
+ this._streamingRenderer.setSplatData(index, splatData);
62324
+ }
62325
+ },
62326
+ this._chunksPerBatch
62327
+ );
62328
+ }
62329
+ /**
62330
+ * Process incoming data chunk
62331
+ * @param chunk Data chunk
62332
+ * @param receivedLength Total bytes received so far
62333
+ * @param contentLength Total content length (if known)
62334
+ */
62335
+ async processChunk(chunk, receivedLength, contentLength) {
62336
+ if (this._cancelled || !this._streamParser) return;
62337
+ this._streamParser.processChunk(chunk);
62338
+ }
62339
+ /**
62340
+ * Cancel streaming loading
62341
+ * Stops processing new chunks and cleans up resources
62342
+ */
62343
+ cancel() {
62344
+ this._cancelled = true;
62345
+ if (this._streamParser) {
62346
+ this._streamParser.cancel();
62347
+ }
62348
+ }
62349
+ /**
62350
+ * Check if loading is cancelled
62351
+ */
62352
+ isCancelled() {
62353
+ return this._cancelled;
62354
+ }
62355
+ /**
62356
+ * Finalize streaming parsing
62357
+ */
62358
+ async finalizeStream() {
62359
+ if (this._rendererObject) {
62360
+ this.data = this._rendererObject;
62361
+ }
62362
+ }
62363
+ /**
62364
+ * Get parsing progress
62365
+ */
62366
+ getProgress() {
62367
+ if (this._streamParser) {
62368
+ return this._streamParser.getProgress();
62369
+ }
62370
+ return { processed: 0, total: 0, percentage: 0 };
62371
+ }
62372
+ verification() {
62373
+ return this._headerParsed && !!this.data && !!this._streamingRenderer;
62374
+ }
62375
+ }
62376
+
61086
62377
  var GeoType = /* @__PURE__ */ ((GeoType2) => {
61087
62378
  GeoType2["Point"] = "Point";
61088
62379
  GeoType2["LineString"] = "LineString";
@@ -72110,6 +73401,7 @@ fn frag(){
72110
73401
  exports.PlaneGeometry = PlaneGeometry;
72111
73402
  exports.PlyMode = PlyMode;
72112
73403
  exports.PlyParser = PlyParser;
73404
+ exports.PlyStreamParser = PlyStreamParser;
72113
73405
  exports.PointClassification = PointClassification;
72114
73406
  exports.PointCloudGeometry = PointCloudGeometry;
72115
73407
  exports.PointCloudMaterial = PointCloudMaterial;
@@ -72279,6 +73571,8 @@ fn frag(){
72279
73571
  exports.StandShader = StandShader;
72280
73572
  exports.StatementNode = StatementNode;
72281
73573
  exports.StorageGPUBuffer = StorageGPUBuffer;
73574
+ exports.StreamLoader = StreamLoader;
73575
+ exports.StreamingGaussianSplatParser = StreamingGaussianSplatParser;
72282
73576
  exports.StringUtil = StringUtil;
72283
73577
  exports.Struct = Struct;
72284
73578
  exports.StructStorageGPUBuffer = StructStorageGPUBuffer;