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