@rings-webgpu/core 1.0.3 → 1.0.4
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 +462 -209
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +2243 -284
- package/dist/rings.umd.js +460 -207
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +2258 -283
- package/package.json +2 -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$j = (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$j([
|
|
2227
2227
|
NonSerialize
|
|
2228
2228
|
], _Struct.prototype, "__refection");
|
|
2229
|
-
__decorateClass$
|
|
2229
|
+
__decorateClass$j([
|
|
2230
2230
|
NonSerialize
|
|
2231
2231
|
], _Struct.prototype, "__size");
|
|
2232
2232
|
let Struct = _Struct;
|
|
@@ -11833,6 +11833,21 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
11833
11833
|
target.transformDir(fromDirection, toDirection);
|
|
11834
11834
|
return target;
|
|
11835
11835
|
}
|
|
11836
|
+
/**
|
|
11837
|
+
* Create a matrix from an array of 16 numbers
|
|
11838
|
+
* @param array Array of 16 numbers
|
|
11839
|
+
* @returns Matrix4 result
|
|
11840
|
+
*/
|
|
11841
|
+
static fromArray(array) {
|
|
11842
|
+
if (array.length !== 16) {
|
|
11843
|
+
throw new Error("Array must contain exactly 16 elements");
|
|
11844
|
+
}
|
|
11845
|
+
const matrix = new Matrix4();
|
|
11846
|
+
for (let i = 0; i < 16; i++) {
|
|
11847
|
+
matrix.rawData[i] = array[i];
|
|
11848
|
+
}
|
|
11849
|
+
return matrix;
|
|
11850
|
+
}
|
|
11836
11851
|
/**
|
|
11837
11852
|
* Generate a matrix (rotate degrees with x,y,z as the center axis)
|
|
11838
11853
|
* @param x x on the central axis
|
|
@@ -16482,9 +16497,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
16482
16497
|
}
|
|
16483
16498
|
}
|
|
16484
16499
|
|
|
16485
|
-
var __getOwnPropDesc$
|
|
16486
|
-
var __decorateClass$
|
|
16487
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
16500
|
+
var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
|
|
16501
|
+
var __decorateClass$i = (decorators, target, key, kind) => {
|
|
16502
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
|
|
16488
16503
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16489
16504
|
if (decorator = decorators[i])
|
|
16490
16505
|
result = (decorator(result)) || result;
|
|
@@ -16749,7 +16764,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
16749
16764
|
super.destroy(force);
|
|
16750
16765
|
}
|
|
16751
16766
|
};
|
|
16752
|
-
exports.Object3D = __decorateClass$
|
|
16767
|
+
exports.Object3D = __decorateClass$i([
|
|
16753
16768
|
DecorateObject3D
|
|
16754
16769
|
], exports.Object3D);
|
|
16755
16770
|
function DecorateObject3D(ctor, _) {
|
|
@@ -23527,9 +23542,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
23527
23542
|
}
|
|
23528
23543
|
|
|
23529
23544
|
var __defProp$1 = Object.defineProperty;
|
|
23530
|
-
var __getOwnPropDesc$
|
|
23531
|
-
var __decorateClass$
|
|
23532
|
-
var result = __getOwnPropDesc$
|
|
23545
|
+
var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
|
|
23546
|
+
var __decorateClass$h = (decorators, target, key, kind) => {
|
|
23547
|
+
var result = __getOwnPropDesc$h(target, key) ;
|
|
23533
23548
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
23534
23549
|
if (decorator = decorators[i])
|
|
23535
23550
|
result = (decorator(target, key, result) ) || result;
|
|
@@ -24114,20 +24129,20 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
24114
24129
|
this._combineShaderRefection = void 0;
|
|
24115
24130
|
}
|
|
24116
24131
|
}
|
|
24117
|
-
__decorateClass$
|
|
24132
|
+
__decorateClass$h([
|
|
24118
24133
|
EditorInspector
|
|
24119
24134
|
], RenderNode.prototype, "materials");
|
|
24120
|
-
__decorateClass$
|
|
24135
|
+
__decorateClass$h([
|
|
24121
24136
|
EditorInspector
|
|
24122
24137
|
], RenderNode.prototype, "castShadow");
|
|
24123
|
-
__decorateClass$
|
|
24138
|
+
__decorateClass$h([
|
|
24124
24139
|
EditorInspector
|
|
24125
24140
|
], RenderNode.prototype, "castGI");
|
|
24126
24141
|
|
|
24127
24142
|
var __defProp = Object.defineProperty;
|
|
24128
|
-
var __getOwnPropDesc$
|
|
24129
|
-
var __decorateClass$
|
|
24130
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
24143
|
+
var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
|
|
24144
|
+
var __decorateClass$g = (decorators, target, key, kind) => {
|
|
24145
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
|
|
24131
24146
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
24132
24147
|
if (decorator = decorators[i])
|
|
24133
24148
|
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
@@ -24236,13 +24251,13 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
24236
24251
|
super.destroy(force);
|
|
24237
24252
|
}
|
|
24238
24253
|
};
|
|
24239
|
-
__decorateClass$
|
|
24254
|
+
__decorateClass$g([
|
|
24240
24255
|
EditorInspector
|
|
24241
24256
|
], exports.MeshRenderer.prototype, "geometry", 1);
|
|
24242
|
-
__decorateClass$
|
|
24257
|
+
__decorateClass$g([
|
|
24243
24258
|
EditorInspector
|
|
24244
24259
|
], exports.MeshRenderer.prototype, "material", 1);
|
|
24245
|
-
exports.MeshRenderer = __decorateClass$
|
|
24260
|
+
exports.MeshRenderer = __decorateClass$g([
|
|
24246
24261
|
RegisterComponent(exports.MeshRenderer, "MeshRenderer")
|
|
24247
24262
|
], exports.MeshRenderer);
|
|
24248
24263
|
|
|
@@ -25891,9 +25906,9 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
25891
25906
|
}
|
|
25892
25907
|
}
|
|
25893
25908
|
|
|
25894
|
-
var __getOwnPropDesc$
|
|
25895
|
-
var __decorateClass$
|
|
25896
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
25909
|
+
var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
|
|
25910
|
+
var __decorateClass$f = (decorators, target, key, kind) => {
|
|
25911
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
|
|
25897
25912
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
25898
25913
|
if (decorator = decorators[i])
|
|
25899
25914
|
result = (decorator(result)) || result;
|
|
@@ -25917,7 +25932,7 @@ fn SH9(dir: vec3<f32>, coefficients: array<vec4f, 9>) -> vec4<f32> {
|
|
|
25917
25932
|
this.setUniformFloat(`height`, 100);
|
|
25918
25933
|
}
|
|
25919
25934
|
};
|
|
25920
|
-
exports.QuadShader = __decorateClass$
|
|
25935
|
+
exports.QuadShader = __decorateClass$f([
|
|
25921
25936
|
RegisterShader(exports.QuadShader, "QuadShader")
|
|
25922
25937
|
], exports.QuadShader);
|
|
25923
25938
|
|
|
@@ -31327,6 +31342,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
31327
31342
|
parser.userData = userData;
|
|
31328
31343
|
parser.baseUrl = this.baseUrl;
|
|
31329
31344
|
parser.initUrl = url;
|
|
31345
|
+
parser.loaderFunctions = loaderFunctions;
|
|
31330
31346
|
await parser.parseBuffer(data);
|
|
31331
31347
|
if (parser.verification()) {
|
|
31332
31348
|
succ(parser);
|
|
@@ -33190,9 +33206,9 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
33190
33206
|
}
|
|
33191
33207
|
}
|
|
33192
33208
|
|
|
33193
|
-
var __getOwnPropDesc$
|
|
33194
|
-
var __decorateClass$
|
|
33195
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
33209
|
+
var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
|
|
33210
|
+
var __decorateClass$e = (decorators, target, key, kind) => {
|
|
33211
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
|
|
33196
33212
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
33197
33213
|
if (decorator = decorators[i])
|
|
33198
33214
|
result = (decorator(result)) || result;
|
|
@@ -33234,13 +33250,13 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
33234
33250
|
debug() {
|
|
33235
33251
|
}
|
|
33236
33252
|
};
|
|
33237
|
-
exports.DirectLight = __decorateClass$
|
|
33253
|
+
exports.DirectLight = __decorateClass$e([
|
|
33238
33254
|
RegisterComponent(exports.DirectLight, "DirectLight")
|
|
33239
33255
|
], exports.DirectLight);
|
|
33240
33256
|
|
|
33241
|
-
var __getOwnPropDesc$
|
|
33242
|
-
var __decorateClass$
|
|
33243
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
33257
|
+
var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
|
|
33258
|
+
var __decorateClass$d = (decorators, target, key, kind) => {
|
|
33259
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
|
|
33244
33260
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
33245
33261
|
if (decorator = decorators[i])
|
|
33246
33262
|
result = (decorator(result)) || result;
|
|
@@ -33298,13 +33314,13 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
33298
33314
|
debugDraw(show) {
|
|
33299
33315
|
}
|
|
33300
33316
|
};
|
|
33301
|
-
exports.PointLight = __decorateClass$
|
|
33317
|
+
exports.PointLight = __decorateClass$d([
|
|
33302
33318
|
RegisterComponent(exports.PointLight, "PointLight")
|
|
33303
33319
|
], exports.PointLight);
|
|
33304
33320
|
|
|
33305
|
-
var __getOwnPropDesc$
|
|
33306
|
-
var __decorateClass$
|
|
33307
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
33321
|
+
var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
|
|
33322
|
+
var __decorateClass$c = (decorators, target, key, kind) => {
|
|
33323
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
|
|
33308
33324
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
33309
33325
|
if (decorator = decorators[i])
|
|
33310
33326
|
result = (decorator(result)) || result;
|
|
@@ -33369,7 +33385,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
33369
33385
|
debugDraw(show) {
|
|
33370
33386
|
}
|
|
33371
33387
|
};
|
|
33372
|
-
exports.SpotLight = __decorateClass$
|
|
33388
|
+
exports.SpotLight = __decorateClass$c([
|
|
33373
33389
|
RegisterComponent(exports.SpotLight, "SpotLight")
|
|
33374
33390
|
], exports.SpotLight);
|
|
33375
33391
|
|
|
@@ -38014,6 +38030,826 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
38014
38030
|
}
|
|
38015
38031
|
}
|
|
38016
38032
|
|
|
38033
|
+
// DEFLATE is a complex format; to read this code, you should probably check the RFC first:
|
|
38034
|
+
// https://tools.ietf.org/html/rfc1951
|
|
38035
|
+
// You may also wish to take a look at the guide I made about this program:
|
|
38036
|
+
// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
|
|
38037
|
+
// Some of the following code is similar to that of UZIP.js:
|
|
38038
|
+
// https://github.com/photopea/UZIP.js
|
|
38039
|
+
// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
|
|
38040
|
+
// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
|
|
38041
|
+
// is better for memory in most engines (I *think*).
|
|
38042
|
+
|
|
38043
|
+
// aliases for shorter compressed code (most minifers don't do this)
|
|
38044
|
+
var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
|
|
38045
|
+
// fixed length extra bits
|
|
38046
|
+
var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);
|
|
38047
|
+
// fixed distance extra bits
|
|
38048
|
+
var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);
|
|
38049
|
+
// code length index map
|
|
38050
|
+
var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
|
|
38051
|
+
// get base, reverse index map from extra bits
|
|
38052
|
+
var freb = function (eb, start) {
|
|
38053
|
+
var b = new u16(31);
|
|
38054
|
+
for (var i = 0; i < 31; ++i) {
|
|
38055
|
+
b[i] = start += 1 << eb[i - 1];
|
|
38056
|
+
}
|
|
38057
|
+
// numbers here are at max 18 bits
|
|
38058
|
+
var r = new i32(b[30]);
|
|
38059
|
+
for (var i = 1; i < 30; ++i) {
|
|
38060
|
+
for (var j = b[i]; j < b[i + 1]; ++j) {
|
|
38061
|
+
r[j] = ((j - b[i]) << 5) | i;
|
|
38062
|
+
}
|
|
38063
|
+
}
|
|
38064
|
+
return { b: b, r: r };
|
|
38065
|
+
};
|
|
38066
|
+
var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
|
|
38067
|
+
// we can ignore the fact that the other numbers are wrong; they never happen anyway
|
|
38068
|
+
fl[28] = 258, revfl[258] = 28;
|
|
38069
|
+
var _b = freb(fdeb, 0), fd = _b.b;
|
|
38070
|
+
// map of value to reverse (assuming 16 bits)
|
|
38071
|
+
var rev = new u16(32768);
|
|
38072
|
+
for (var i = 0; i < 32768; ++i) {
|
|
38073
|
+
// reverse table algorithm from SO
|
|
38074
|
+
var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);
|
|
38075
|
+
x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
|
|
38076
|
+
x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
|
|
38077
|
+
rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;
|
|
38078
|
+
}
|
|
38079
|
+
// create huffman tree from u8 "map": index -> code length for code index
|
|
38080
|
+
// mb (max bits) must be at most 15
|
|
38081
|
+
// TODO: optimize/split up?
|
|
38082
|
+
var hMap = (function (cd, mb, r) {
|
|
38083
|
+
var s = cd.length;
|
|
38084
|
+
// index
|
|
38085
|
+
var i = 0;
|
|
38086
|
+
// u16 "map": index -> # of codes with bit length = index
|
|
38087
|
+
var l = new u16(mb);
|
|
38088
|
+
// length of cd must be 288 (total # of codes)
|
|
38089
|
+
for (; i < s; ++i) {
|
|
38090
|
+
if (cd[i])
|
|
38091
|
+
++l[cd[i] - 1];
|
|
38092
|
+
}
|
|
38093
|
+
// u16 "map": index -> minimum code for bit length = index
|
|
38094
|
+
var le = new u16(mb);
|
|
38095
|
+
for (i = 1; i < mb; ++i) {
|
|
38096
|
+
le[i] = (le[i - 1] + l[i - 1]) << 1;
|
|
38097
|
+
}
|
|
38098
|
+
var co;
|
|
38099
|
+
if (r) {
|
|
38100
|
+
// u16 "map": index -> number of actual bits, symbol for code
|
|
38101
|
+
co = new u16(1 << mb);
|
|
38102
|
+
// bits to remove for reverser
|
|
38103
|
+
var rvb = 15 - mb;
|
|
38104
|
+
for (i = 0; i < s; ++i) {
|
|
38105
|
+
// ignore 0 lengths
|
|
38106
|
+
if (cd[i]) {
|
|
38107
|
+
// num encoding both symbol and bits read
|
|
38108
|
+
var sv = (i << 4) | cd[i];
|
|
38109
|
+
// free bits
|
|
38110
|
+
var r_1 = mb - cd[i];
|
|
38111
|
+
// start value
|
|
38112
|
+
var v = le[cd[i] - 1]++ << r_1;
|
|
38113
|
+
// m is end value
|
|
38114
|
+
for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
|
|
38115
|
+
// every 16 bit value starting with the code yields the same result
|
|
38116
|
+
co[rev[v] >> rvb] = sv;
|
|
38117
|
+
}
|
|
38118
|
+
}
|
|
38119
|
+
}
|
|
38120
|
+
}
|
|
38121
|
+
else {
|
|
38122
|
+
co = new u16(s);
|
|
38123
|
+
for (i = 0; i < s; ++i) {
|
|
38124
|
+
if (cd[i]) {
|
|
38125
|
+
co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);
|
|
38126
|
+
}
|
|
38127
|
+
}
|
|
38128
|
+
}
|
|
38129
|
+
return co;
|
|
38130
|
+
});
|
|
38131
|
+
// fixed length tree
|
|
38132
|
+
var flt = new u8(288);
|
|
38133
|
+
for (var i = 0; i < 144; ++i)
|
|
38134
|
+
flt[i] = 8;
|
|
38135
|
+
for (var i = 144; i < 256; ++i)
|
|
38136
|
+
flt[i] = 9;
|
|
38137
|
+
for (var i = 256; i < 280; ++i)
|
|
38138
|
+
flt[i] = 7;
|
|
38139
|
+
for (var i = 280; i < 288; ++i)
|
|
38140
|
+
flt[i] = 8;
|
|
38141
|
+
// fixed distance tree
|
|
38142
|
+
var fdt = new u8(32);
|
|
38143
|
+
for (var i = 0; i < 32; ++i)
|
|
38144
|
+
fdt[i] = 5;
|
|
38145
|
+
// fixed length map
|
|
38146
|
+
var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
|
|
38147
|
+
// fixed distance map
|
|
38148
|
+
var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
|
|
38149
|
+
// find max of array
|
|
38150
|
+
var max = function (a) {
|
|
38151
|
+
var m = a[0];
|
|
38152
|
+
for (var i = 1; i < a.length; ++i) {
|
|
38153
|
+
if (a[i] > m)
|
|
38154
|
+
m = a[i];
|
|
38155
|
+
}
|
|
38156
|
+
return m;
|
|
38157
|
+
};
|
|
38158
|
+
// read d, starting at bit p and mask with m
|
|
38159
|
+
var bits = function (d, p, m) {
|
|
38160
|
+
var o = (p / 8) | 0;
|
|
38161
|
+
return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
|
|
38162
|
+
};
|
|
38163
|
+
// read d, starting at bit p continuing for at least 16 bits
|
|
38164
|
+
var bits16 = function (d, p) {
|
|
38165
|
+
var o = (p / 8) | 0;
|
|
38166
|
+
return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
|
|
38167
|
+
};
|
|
38168
|
+
// get end of byte
|
|
38169
|
+
var shft = function (p) { return ((p + 7) / 8) | 0; };
|
|
38170
|
+
// typed array slice - allows garbage collector to free original reference,
|
|
38171
|
+
// while being more compatible than .slice
|
|
38172
|
+
var slc = function (v, s, e) {
|
|
38173
|
+
if (s == null || s < 0)
|
|
38174
|
+
s = 0;
|
|
38175
|
+
if (e == null || e > v.length)
|
|
38176
|
+
e = v.length;
|
|
38177
|
+
// can't use .constructor in case user-supplied
|
|
38178
|
+
return new u8(v.subarray(s, e));
|
|
38179
|
+
};
|
|
38180
|
+
// error codes
|
|
38181
|
+
var ec = [
|
|
38182
|
+
'unexpected EOF',
|
|
38183
|
+
'invalid block type',
|
|
38184
|
+
'invalid length/literal',
|
|
38185
|
+
'invalid distance',
|
|
38186
|
+
'stream finished',
|
|
38187
|
+
'no stream handler',
|
|
38188
|
+
,
|
|
38189
|
+
'no callback',
|
|
38190
|
+
'invalid UTF-8 data',
|
|
38191
|
+
'extra field too long',
|
|
38192
|
+
'date not in range 1980-2099',
|
|
38193
|
+
'filename too long',
|
|
38194
|
+
'stream finishing',
|
|
38195
|
+
'invalid zip data'
|
|
38196
|
+
// determined by unknown compression method
|
|
38197
|
+
];
|
|
38198
|
+
var err = function (ind, msg, nt) {
|
|
38199
|
+
var e = new Error(msg || ec[ind]);
|
|
38200
|
+
e.code = ind;
|
|
38201
|
+
if (Error.captureStackTrace)
|
|
38202
|
+
Error.captureStackTrace(e, err);
|
|
38203
|
+
if (!nt)
|
|
38204
|
+
throw e;
|
|
38205
|
+
return e;
|
|
38206
|
+
};
|
|
38207
|
+
// expands raw DEFLATE data
|
|
38208
|
+
var inflt = function (dat, st, buf, dict) {
|
|
38209
|
+
// source length dict length
|
|
38210
|
+
var sl = dat.length, dl = dict ? dict.length : 0;
|
|
38211
|
+
if (!sl || st.f && !st.l)
|
|
38212
|
+
return buf || new u8(0);
|
|
38213
|
+
var noBuf = !buf;
|
|
38214
|
+
// have to estimate size
|
|
38215
|
+
var resize = noBuf || st.i != 2;
|
|
38216
|
+
// no state
|
|
38217
|
+
var noSt = st.i;
|
|
38218
|
+
// Assumes roughly 33% compression ratio average
|
|
38219
|
+
if (noBuf)
|
|
38220
|
+
buf = new u8(sl * 3);
|
|
38221
|
+
// ensure buffer can fit at least l elements
|
|
38222
|
+
var cbuf = function (l) {
|
|
38223
|
+
var bl = buf.length;
|
|
38224
|
+
// need to increase size to fit
|
|
38225
|
+
if (l > bl) {
|
|
38226
|
+
// Double or set to necessary, whichever is greater
|
|
38227
|
+
var nbuf = new u8(Math.max(bl * 2, l));
|
|
38228
|
+
nbuf.set(buf);
|
|
38229
|
+
buf = nbuf;
|
|
38230
|
+
}
|
|
38231
|
+
};
|
|
38232
|
+
// last chunk bitpos bytes
|
|
38233
|
+
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
|
|
38234
|
+
// total bits
|
|
38235
|
+
var tbts = sl * 8;
|
|
38236
|
+
do {
|
|
38237
|
+
if (!lm) {
|
|
38238
|
+
// BFINAL - this is only 1 when last chunk is next
|
|
38239
|
+
final = bits(dat, pos, 1);
|
|
38240
|
+
// type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
|
|
38241
|
+
var type = bits(dat, pos + 1, 3);
|
|
38242
|
+
pos += 3;
|
|
38243
|
+
if (!type) {
|
|
38244
|
+
// go to end of byte boundary
|
|
38245
|
+
var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
|
|
38246
|
+
if (t > sl) {
|
|
38247
|
+
if (noSt)
|
|
38248
|
+
err(0);
|
|
38249
|
+
break;
|
|
38250
|
+
}
|
|
38251
|
+
// ensure size
|
|
38252
|
+
if (resize)
|
|
38253
|
+
cbuf(bt + l);
|
|
38254
|
+
// Copy over uncompressed data
|
|
38255
|
+
buf.set(dat.subarray(s, t), bt);
|
|
38256
|
+
// Get new bitpos, update byte count
|
|
38257
|
+
st.b = bt += l, st.p = pos = t * 8, st.f = final;
|
|
38258
|
+
continue;
|
|
38259
|
+
}
|
|
38260
|
+
else if (type == 1)
|
|
38261
|
+
lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
|
|
38262
|
+
else if (type == 2) {
|
|
38263
|
+
// literal lengths
|
|
38264
|
+
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
|
|
38265
|
+
var tl = hLit + bits(dat, pos + 5, 31) + 1;
|
|
38266
|
+
pos += 14;
|
|
38267
|
+
// length+distance tree
|
|
38268
|
+
var ldt = new u8(tl);
|
|
38269
|
+
// code length tree
|
|
38270
|
+
var clt = new u8(19);
|
|
38271
|
+
for (var i = 0; i < hcLen; ++i) {
|
|
38272
|
+
// use index map to get real code
|
|
38273
|
+
clt[clim[i]] = bits(dat, pos + i * 3, 7);
|
|
38274
|
+
}
|
|
38275
|
+
pos += hcLen * 3;
|
|
38276
|
+
// code lengths bits
|
|
38277
|
+
var clb = max(clt), clbmsk = (1 << clb) - 1;
|
|
38278
|
+
// code lengths map
|
|
38279
|
+
var clm = hMap(clt, clb, 1);
|
|
38280
|
+
for (var i = 0; i < tl;) {
|
|
38281
|
+
var r = clm[bits(dat, pos, clbmsk)];
|
|
38282
|
+
// bits read
|
|
38283
|
+
pos += r & 15;
|
|
38284
|
+
// symbol
|
|
38285
|
+
var s = r >> 4;
|
|
38286
|
+
// code length to copy
|
|
38287
|
+
if (s < 16) {
|
|
38288
|
+
ldt[i++] = s;
|
|
38289
|
+
}
|
|
38290
|
+
else {
|
|
38291
|
+
// copy count
|
|
38292
|
+
var c = 0, n = 0;
|
|
38293
|
+
if (s == 16)
|
|
38294
|
+
n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
|
|
38295
|
+
else if (s == 17)
|
|
38296
|
+
n = 3 + bits(dat, pos, 7), pos += 3;
|
|
38297
|
+
else if (s == 18)
|
|
38298
|
+
n = 11 + bits(dat, pos, 127), pos += 7;
|
|
38299
|
+
while (n--)
|
|
38300
|
+
ldt[i++] = c;
|
|
38301
|
+
}
|
|
38302
|
+
}
|
|
38303
|
+
// length tree distance tree
|
|
38304
|
+
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
|
|
38305
|
+
// max length bits
|
|
38306
|
+
lbt = max(lt);
|
|
38307
|
+
// max dist bits
|
|
38308
|
+
dbt = max(dt);
|
|
38309
|
+
lm = hMap(lt, lbt, 1);
|
|
38310
|
+
dm = hMap(dt, dbt, 1);
|
|
38311
|
+
}
|
|
38312
|
+
else
|
|
38313
|
+
err(1);
|
|
38314
|
+
if (pos > tbts) {
|
|
38315
|
+
if (noSt)
|
|
38316
|
+
err(0);
|
|
38317
|
+
break;
|
|
38318
|
+
}
|
|
38319
|
+
}
|
|
38320
|
+
// Make sure the buffer can hold this + the largest possible addition
|
|
38321
|
+
// Maximum chunk size (practically, theoretically infinite) is 2^17
|
|
38322
|
+
if (resize)
|
|
38323
|
+
cbuf(bt + 131072);
|
|
38324
|
+
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
|
|
38325
|
+
var lpos = pos;
|
|
38326
|
+
for (;; lpos = pos) {
|
|
38327
|
+
// bits read, code
|
|
38328
|
+
var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
|
|
38329
|
+
pos += c & 15;
|
|
38330
|
+
if (pos > tbts) {
|
|
38331
|
+
if (noSt)
|
|
38332
|
+
err(0);
|
|
38333
|
+
break;
|
|
38334
|
+
}
|
|
38335
|
+
if (!c)
|
|
38336
|
+
err(2);
|
|
38337
|
+
if (sym < 256)
|
|
38338
|
+
buf[bt++] = sym;
|
|
38339
|
+
else if (sym == 256) {
|
|
38340
|
+
lpos = pos, lm = null;
|
|
38341
|
+
break;
|
|
38342
|
+
}
|
|
38343
|
+
else {
|
|
38344
|
+
var add = sym - 254;
|
|
38345
|
+
// no extra bits needed if less
|
|
38346
|
+
if (sym > 264) {
|
|
38347
|
+
// index
|
|
38348
|
+
var i = sym - 257, b = fleb[i];
|
|
38349
|
+
add = bits(dat, pos, (1 << b) - 1) + fl[i];
|
|
38350
|
+
pos += b;
|
|
38351
|
+
}
|
|
38352
|
+
// dist
|
|
38353
|
+
var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
|
|
38354
|
+
if (!d)
|
|
38355
|
+
err(3);
|
|
38356
|
+
pos += d & 15;
|
|
38357
|
+
var dt = fd[dsym];
|
|
38358
|
+
if (dsym > 3) {
|
|
38359
|
+
var b = fdeb[dsym];
|
|
38360
|
+
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
|
|
38361
|
+
}
|
|
38362
|
+
if (pos > tbts) {
|
|
38363
|
+
if (noSt)
|
|
38364
|
+
err(0);
|
|
38365
|
+
break;
|
|
38366
|
+
}
|
|
38367
|
+
if (resize)
|
|
38368
|
+
cbuf(bt + 131072);
|
|
38369
|
+
var end = bt + add;
|
|
38370
|
+
if (bt < dt) {
|
|
38371
|
+
var shift = dl - dt, dend = Math.min(dt, end);
|
|
38372
|
+
if (shift + bt < 0)
|
|
38373
|
+
err(3);
|
|
38374
|
+
for (; bt < dend; ++bt)
|
|
38375
|
+
buf[bt] = dict[shift + bt];
|
|
38376
|
+
}
|
|
38377
|
+
for (; bt < end; ++bt)
|
|
38378
|
+
buf[bt] = buf[bt - dt];
|
|
38379
|
+
}
|
|
38380
|
+
}
|
|
38381
|
+
st.l = lm, st.p = lpos, st.b = bt, st.f = final;
|
|
38382
|
+
if (lm)
|
|
38383
|
+
final = 1, st.m = lbt, st.d = dm, st.n = dbt;
|
|
38384
|
+
} while (!final);
|
|
38385
|
+
// don't reallocate for streams or user buffers
|
|
38386
|
+
return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
|
|
38387
|
+
};
|
|
38388
|
+
// empty
|
|
38389
|
+
var et = /*#__PURE__*/ new u8(0);
|
|
38390
|
+
// read 2 bytes
|
|
38391
|
+
var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
|
|
38392
|
+
// read 4 bytes
|
|
38393
|
+
var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
|
|
38394
|
+
var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
|
|
38395
|
+
/**
|
|
38396
|
+
* Expands DEFLATE data with no wrapper
|
|
38397
|
+
* @param data The data to decompress
|
|
38398
|
+
* @param opts The decompression options
|
|
38399
|
+
* @returns The decompressed version of the data
|
|
38400
|
+
*/
|
|
38401
|
+
function inflateSync(data, opts) {
|
|
38402
|
+
return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
38403
|
+
}
|
|
38404
|
+
// text decoder
|
|
38405
|
+
var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
|
|
38406
|
+
// text decoder stream
|
|
38407
|
+
var tds = 0;
|
|
38408
|
+
try {
|
|
38409
|
+
td.decode(et, { stream: true });
|
|
38410
|
+
tds = 1;
|
|
38411
|
+
}
|
|
38412
|
+
catch (e) { }
|
|
38413
|
+
// decode UTF8
|
|
38414
|
+
var dutf8 = function (d) {
|
|
38415
|
+
for (var r = '', i = 0;;) {
|
|
38416
|
+
var c = d[i++];
|
|
38417
|
+
var eb = (c > 127) + (c > 223) + (c > 239);
|
|
38418
|
+
if (i + eb > d.length)
|
|
38419
|
+
return { s: r, r: slc(d, i - 1) };
|
|
38420
|
+
if (!eb)
|
|
38421
|
+
r += String.fromCharCode(c);
|
|
38422
|
+
else if (eb == 3) {
|
|
38423
|
+
c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
|
|
38424
|
+
r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
|
|
38425
|
+
}
|
|
38426
|
+
else if (eb & 1)
|
|
38427
|
+
r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
|
|
38428
|
+
else
|
|
38429
|
+
r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
|
|
38430
|
+
}
|
|
38431
|
+
};
|
|
38432
|
+
/**
|
|
38433
|
+
* Converts a Uint8Array to a string
|
|
38434
|
+
* @param dat The data to decode to string
|
|
38435
|
+
* @param latin1 Whether or not to interpret the data as Latin-1. This should
|
|
38436
|
+
* not need to be true unless encoding to binary string.
|
|
38437
|
+
* @returns The original UTF-8/Latin-1 string
|
|
38438
|
+
*/
|
|
38439
|
+
function strFromU8(dat, latin1) {
|
|
38440
|
+
if (latin1) {
|
|
38441
|
+
var r = '';
|
|
38442
|
+
for (var i = 0; i < dat.length; i += 16384)
|
|
38443
|
+
r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
|
|
38444
|
+
return r;
|
|
38445
|
+
}
|
|
38446
|
+
else if (td) {
|
|
38447
|
+
return td.decode(dat);
|
|
38448
|
+
}
|
|
38449
|
+
else {
|
|
38450
|
+
var _a = dutf8(dat), s = _a.s, r = _a.r;
|
|
38451
|
+
if (r.length)
|
|
38452
|
+
err(8);
|
|
38453
|
+
return s;
|
|
38454
|
+
}
|
|
38455
|
+
}
|
|
38456
|
+
// skip local zip header
|
|
38457
|
+
var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
|
|
38458
|
+
// read zip header
|
|
38459
|
+
var zh = function (d, b, z) {
|
|
38460
|
+
var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
|
|
38461
|
+
var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
|
|
38462
|
+
return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
|
|
38463
|
+
};
|
|
38464
|
+
// read zip64 extra field
|
|
38465
|
+
var z64e = function (d, b) {
|
|
38466
|
+
for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
|
|
38467
|
+
;
|
|
38468
|
+
return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
|
|
38469
|
+
};
|
|
38470
|
+
/**
|
|
38471
|
+
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
|
|
38472
|
+
* performance with more than one file.
|
|
38473
|
+
* @param data The raw compressed ZIP file
|
|
38474
|
+
* @param opts The ZIP extraction options
|
|
38475
|
+
* @returns The decompressed files
|
|
38476
|
+
*/
|
|
38477
|
+
function unzipSync(data, opts) {
|
|
38478
|
+
var files = {};
|
|
38479
|
+
var e = data.length - 22;
|
|
38480
|
+
for (; b4(data, e) != 0x6054B50; --e) {
|
|
38481
|
+
if (!e || data.length - e > 65558)
|
|
38482
|
+
err(13);
|
|
38483
|
+
}
|
|
38484
|
+
var c = b2(data, e + 8);
|
|
38485
|
+
if (!c)
|
|
38486
|
+
return {};
|
|
38487
|
+
var o = b4(data, e + 16);
|
|
38488
|
+
var z = o == 4294967295 || c == 65535;
|
|
38489
|
+
if (z) {
|
|
38490
|
+
var ze = b4(data, e - 12);
|
|
38491
|
+
z = b4(data, ze) == 0x6064B50;
|
|
38492
|
+
if (z) {
|
|
38493
|
+
c = b4(data, ze + 32);
|
|
38494
|
+
o = b4(data, ze + 48);
|
|
38495
|
+
}
|
|
38496
|
+
}
|
|
38497
|
+
for (var i = 0; i < c; ++i) {
|
|
38498
|
+
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
|
|
38499
|
+
o = no;
|
|
38500
|
+
{
|
|
38501
|
+
if (!c_2)
|
|
38502
|
+
files[fn] = slc(data, b, b + sc);
|
|
38503
|
+
else if (c_2 == 8)
|
|
38504
|
+
files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
|
|
38505
|
+
else
|
|
38506
|
+
err(14, 'unknown compression type ' + c_2);
|
|
38507
|
+
}
|
|
38508
|
+
}
|
|
38509
|
+
return files;
|
|
38510
|
+
}
|
|
38511
|
+
|
|
38512
|
+
class UnLitMaterial extends Material {
|
|
38513
|
+
/**
|
|
38514
|
+
* @constructor
|
|
38515
|
+
*/
|
|
38516
|
+
constructor() {
|
|
38517
|
+
super();
|
|
38518
|
+
this.shader = new exports.UnLitShader();
|
|
38519
|
+
this.baseMap = Engine3D.res.whiteTexture;
|
|
38520
|
+
}
|
|
38521
|
+
set baseMap(texture) {
|
|
38522
|
+
this.shader.setTexture(`baseMap`, texture);
|
|
38523
|
+
}
|
|
38524
|
+
get baseMap() {
|
|
38525
|
+
return this.shader.getTexture(`baseMap`);
|
|
38526
|
+
}
|
|
38527
|
+
/**
|
|
38528
|
+
* set base color (tint color)
|
|
38529
|
+
*/
|
|
38530
|
+
set baseColor(color) {
|
|
38531
|
+
this.shader.setUniformColor(`baseColor`, color);
|
|
38532
|
+
}
|
|
38533
|
+
/**
|
|
38534
|
+
* get base color (tint color)
|
|
38535
|
+
*/
|
|
38536
|
+
get baseColor() {
|
|
38537
|
+
return this.shader.getUniformColor("baseColor");
|
|
38538
|
+
}
|
|
38539
|
+
/**
|
|
38540
|
+
* set environment texture, usually referring to cubemap
|
|
38541
|
+
*/
|
|
38542
|
+
set envMap(texture) {
|
|
38543
|
+
}
|
|
38544
|
+
/**
|
|
38545
|
+
* @internal
|
|
38546
|
+
* set shadow map
|
|
38547
|
+
*/
|
|
38548
|
+
set shadowMap(texture) {
|
|
38549
|
+
}
|
|
38550
|
+
}
|
|
38551
|
+
|
|
38552
|
+
class SphereGeometry extends GeometryBase {
|
|
38553
|
+
shape_vertices = [];
|
|
38554
|
+
shape_indices = [];
|
|
38555
|
+
radius;
|
|
38556
|
+
widthSegments;
|
|
38557
|
+
heightSegments;
|
|
38558
|
+
phiStart;
|
|
38559
|
+
phiLength;
|
|
38560
|
+
thetaStart;
|
|
38561
|
+
thetaLength;
|
|
38562
|
+
/**
|
|
38563
|
+
* 球体几何体
|
|
38564
|
+
* @constructor
|
|
38565
|
+
* @param radius 球体半径
|
|
38566
|
+
* @param widthSegments 定义水平分段数
|
|
38567
|
+
* @param heightSegments 定义垂直分段数
|
|
38568
|
+
* @param phiStart 球体赤道线起始点的弧度
|
|
38569
|
+
* @param phiLength 球体赤道线的弧长
|
|
38570
|
+
* @param thetaStart 球体经线起始点的弧度
|
|
38571
|
+
* @param thetaLength 球体经线的弧长
|
|
38572
|
+
*/
|
|
38573
|
+
constructor(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
|
|
38574
|
+
super();
|
|
38575
|
+
this.radius = radius;
|
|
38576
|
+
this.widthSegments = widthSegments;
|
|
38577
|
+
this.heightSegments = heightSegments;
|
|
38578
|
+
this.phiStart = phiStart;
|
|
38579
|
+
this.phiLength = phiLength;
|
|
38580
|
+
this.thetaStart = thetaStart;
|
|
38581
|
+
this.thetaLength = thetaLength;
|
|
38582
|
+
this.buildGeometry();
|
|
38583
|
+
}
|
|
38584
|
+
buildGeometry() {
|
|
38585
|
+
var i, j, triIndex = 0;
|
|
38586
|
+
let _segmentsH = this.heightSegments;
|
|
38587
|
+
let _segmentsW = this.widthSegments;
|
|
38588
|
+
let _radius = this.radius;
|
|
38589
|
+
var vertexCount = (_segmentsH + 1) * (_segmentsW + 1);
|
|
38590
|
+
let position_arr = new Float32Array(vertexCount * 3);
|
|
38591
|
+
let normal_arr = new Float32Array(vertexCount * 3);
|
|
38592
|
+
let uv_arr = new Float32Array(vertexCount * 2);
|
|
38593
|
+
let indice_arr = new Uint16Array(_segmentsW * _segmentsH * 2 * 3);
|
|
38594
|
+
let pi = 0;
|
|
38595
|
+
let ni = 0;
|
|
38596
|
+
let ui = 0;
|
|
38597
|
+
for (j = 0; j <= _segmentsH; ++j) {
|
|
38598
|
+
var horAngle = Math.PI * j / _segmentsH;
|
|
38599
|
+
var y = _radius * Math.cos(horAngle);
|
|
38600
|
+
var ringRadius = _radius * Math.sin(horAngle);
|
|
38601
|
+
for (i = 0; i <= _segmentsW; ++i) {
|
|
38602
|
+
var verAngle = 2 * Math.PI * i / _segmentsW;
|
|
38603
|
+
var x = ringRadius * Math.cos(verAngle);
|
|
38604
|
+
var z = ringRadius * Math.sin(verAngle);
|
|
38605
|
+
var normLen = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
38606
|
+
position_arr[pi++] = x;
|
|
38607
|
+
position_arr[pi++] = y;
|
|
38608
|
+
position_arr[pi++] = z;
|
|
38609
|
+
normal_arr[ni++] = x * normLen;
|
|
38610
|
+
normal_arr[ni++] = y * normLen;
|
|
38611
|
+
normal_arr[ni++] = z * normLen;
|
|
38612
|
+
uv_arr[ui++] = i / _segmentsW;
|
|
38613
|
+
uv_arr[ui++] = j / _segmentsH;
|
|
38614
|
+
if (i > 0 && j > 0) {
|
|
38615
|
+
var a = (_segmentsW + 1) * j + i;
|
|
38616
|
+
var b = (_segmentsW + 1) * j + i - 1;
|
|
38617
|
+
var c = (_segmentsW + 1) * (j - 1) + i - 1;
|
|
38618
|
+
var d = (_segmentsW + 1) * (j - 1) + i;
|
|
38619
|
+
if (j == _segmentsH) {
|
|
38620
|
+
indice_arr[triIndex++] = a;
|
|
38621
|
+
indice_arr[triIndex++] = c;
|
|
38622
|
+
indice_arr[triIndex++] = d;
|
|
38623
|
+
} else if (j == 1) {
|
|
38624
|
+
indice_arr[triIndex++] = a;
|
|
38625
|
+
indice_arr[triIndex++] = b;
|
|
38626
|
+
indice_arr[triIndex++] = c;
|
|
38627
|
+
} else {
|
|
38628
|
+
indice_arr[triIndex++] = a;
|
|
38629
|
+
indice_arr[triIndex++] = b;
|
|
38630
|
+
indice_arr[triIndex++] = c;
|
|
38631
|
+
indice_arr[triIndex++] = a;
|
|
38632
|
+
indice_arr[triIndex++] = c;
|
|
38633
|
+
indice_arr[triIndex++] = d;
|
|
38634
|
+
}
|
|
38635
|
+
}
|
|
38636
|
+
}
|
|
38637
|
+
}
|
|
38638
|
+
this.setIndices(indice_arr);
|
|
38639
|
+
this.setAttribute(VertexAttributeName.position, position_arr);
|
|
38640
|
+
this.setAttribute(VertexAttributeName.normal, normal_arr);
|
|
38641
|
+
this.setAttribute(VertexAttributeName.uv, uv_arr);
|
|
38642
|
+
this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
|
|
38643
|
+
this.addSubGeometry({
|
|
38644
|
+
indexStart: 0,
|
|
38645
|
+
indexCount: indice_arr.length,
|
|
38646
|
+
vertexStart: 0,
|
|
38647
|
+
vertexCount: 0,
|
|
38648
|
+
firstStart: 0,
|
|
38649
|
+
index: 0,
|
|
38650
|
+
topology: 0
|
|
38651
|
+
});
|
|
38652
|
+
this.bounds = new BoundingBox(
|
|
38653
|
+
Vector3.ZERO,
|
|
38654
|
+
new Vector3(this.radius * 2, this.radius * 2, this.radius * 2)
|
|
38655
|
+
);
|
|
38656
|
+
}
|
|
38657
|
+
}
|
|
38658
|
+
|
|
38659
|
+
class WayPoint3D extends exports.Object3D {
|
|
38660
|
+
static register3DRepresentation = null;
|
|
38661
|
+
positionIndex = -1;
|
|
38662
|
+
positionValid = false;
|
|
38663
|
+
marker;
|
|
38664
|
+
constructor(placemark) {
|
|
38665
|
+
super();
|
|
38666
|
+
this.parsePlacemark(placemark);
|
|
38667
|
+
this.setup3DRepresentation();
|
|
38668
|
+
}
|
|
38669
|
+
parsePlacemark(placemark) {
|
|
38670
|
+
if (!placemark.slamPositionInfo) {
|
|
38671
|
+
console.warn("WayPoint3D: slamPositionInfo is not found");
|
|
38672
|
+
return;
|
|
38673
|
+
}
|
|
38674
|
+
const slamPosition = placemark.slamPositionInfo.slamPosition.split(",").map(Number);
|
|
38675
|
+
this.localPosition = new Vector3(slamPosition[0], slamPosition[1], slamPosition[2]);
|
|
38676
|
+
this.positionIndex = Number(placemark.slamPositionInfo.slamPositionIndex);
|
|
38677
|
+
this.positionValid = placemark.slamPositionInfo.slamPositionValid === "1";
|
|
38678
|
+
}
|
|
38679
|
+
setup3DRepresentation() {
|
|
38680
|
+
if (this.marker) {
|
|
38681
|
+
this.removeChild(this.marker);
|
|
38682
|
+
this.marker = null;
|
|
38683
|
+
}
|
|
38684
|
+
if (WayPoint3D.register3DRepresentation) {
|
|
38685
|
+
this.marker = WayPoint3D.register3DRepresentation(this);
|
|
38686
|
+
if (this.marker) {
|
|
38687
|
+
this.addChild(this.marker);
|
|
38688
|
+
}
|
|
38689
|
+
} else {
|
|
38690
|
+
this.marker = new exports.Object3D();
|
|
38691
|
+
const markerRenderer = this.marker.addComponent(exports.MeshRenderer);
|
|
38692
|
+
markerRenderer.geometry = new SphereGeometry(0.1, 32, 16);
|
|
38693
|
+
markerRenderer.material = new LitMaterial();
|
|
38694
|
+
markerRenderer.material.baseColor = this.positionValid ? new Color(0, 1, 0, 1) : new Color(1, 0, 0, 1);
|
|
38695
|
+
this.addChild(this.marker);
|
|
38696
|
+
this.marker.name = "WayPoint3DMarker";
|
|
38697
|
+
}
|
|
38698
|
+
}
|
|
38699
|
+
}
|
|
38700
|
+
|
|
38701
|
+
class WayLines3D extends exports.Object3D {
|
|
38702
|
+
static register3DRepresentation = null;
|
|
38703
|
+
line;
|
|
38704
|
+
constructor(wayLineFile) {
|
|
38705
|
+
super();
|
|
38706
|
+
this.parseWayLineFile(wayLineFile);
|
|
38707
|
+
this.setup3DRepresentation();
|
|
38708
|
+
}
|
|
38709
|
+
parseWayLineFile(wayLineFile) {
|
|
38710
|
+
for (const placemark of wayLineFile.Folder.Placemark) {
|
|
38711
|
+
const wayPoint3D = new WayPoint3D(placemark);
|
|
38712
|
+
this.addChild(wayPoint3D);
|
|
38713
|
+
}
|
|
38714
|
+
this.entityChildren = this.entityChildren.sort((a, b) => {
|
|
38715
|
+
return a.positionIndex - b.positionIndex;
|
|
38716
|
+
});
|
|
38717
|
+
}
|
|
38718
|
+
setup3DRepresentation() {
|
|
38719
|
+
if (this.line) {
|
|
38720
|
+
this.removeChild(this.line);
|
|
38721
|
+
this.line = null;
|
|
38722
|
+
}
|
|
38723
|
+
if (WayLines3D.register3DRepresentation) {
|
|
38724
|
+
this.line = WayLines3D.register3DRepresentation(this);
|
|
38725
|
+
if (this.line) {
|
|
38726
|
+
this.addChild(this.line);
|
|
38727
|
+
}
|
|
38728
|
+
} else {
|
|
38729
|
+
this.line = this.createMultiLine(this.entityChildren.map((child) => child.localPosition), new Color(1, 1, 1, 1));
|
|
38730
|
+
this.addChild(this.line);
|
|
38731
|
+
this.line.name = "WayLines3DLine";
|
|
38732
|
+
}
|
|
38733
|
+
}
|
|
38734
|
+
createMultiLine(positions, color) {
|
|
38735
|
+
if (positions.length < 2) {
|
|
38736
|
+
return null;
|
|
38737
|
+
}
|
|
38738
|
+
const lineGeometry = new GeometryBase();
|
|
38739
|
+
const vertices = new Float32Array(positions.length * 3);
|
|
38740
|
+
for (let i = 0; i < positions.length; i++) {
|
|
38741
|
+
vertices[i * 3] = positions[i].x;
|
|
38742
|
+
vertices[i * 3 + 1] = positions[i].y;
|
|
38743
|
+
vertices[i * 3 + 2] = positions[i].z;
|
|
38744
|
+
}
|
|
38745
|
+
const indices = new Uint16Array((positions.length - 1) * 2);
|
|
38746
|
+
for (let i = 0; i < positions.length - 1; i++) {
|
|
38747
|
+
indices[i * 2] = i;
|
|
38748
|
+
indices[i * 2 + 1] = i + 1;
|
|
38749
|
+
}
|
|
38750
|
+
lineGeometry.setIndices(indices);
|
|
38751
|
+
lineGeometry.setAttribute(VertexAttributeName.position, vertices);
|
|
38752
|
+
lineGeometry.addSubGeometry({
|
|
38753
|
+
indexStart: 0,
|
|
38754
|
+
indexCount: indices.length,
|
|
38755
|
+
vertexStart: 0,
|
|
38756
|
+
vertexCount: 0,
|
|
38757
|
+
firstStart: 0,
|
|
38758
|
+
index: 0,
|
|
38759
|
+
topology: 0
|
|
38760
|
+
});
|
|
38761
|
+
const lineObject = new exports.Object3D();
|
|
38762
|
+
const lineRenderer = lineObject.addComponent(exports.MeshRenderer);
|
|
38763
|
+
const material = new UnLitMaterial();
|
|
38764
|
+
material.topology = "line-list";
|
|
38765
|
+
material.baseColor = color;
|
|
38766
|
+
material.blendMode = BlendMode.ADD;
|
|
38767
|
+
material.castReflection = false;
|
|
38768
|
+
lineRenderer.geometry = lineGeometry;
|
|
38769
|
+
lineRenderer.material = material;
|
|
38770
|
+
return lineObject;
|
|
38771
|
+
}
|
|
38772
|
+
}
|
|
38773
|
+
|
|
38774
|
+
class KMZParser extends ParserBase {
|
|
38775
|
+
static format = ParserFormat.BIN;
|
|
38776
|
+
parseBuffer(buffer) {
|
|
38777
|
+
try {
|
|
38778
|
+
const kmzObj = {
|
|
38779
|
+
template: null,
|
|
38780
|
+
waylines: null
|
|
38781
|
+
};
|
|
38782
|
+
const zip = unzipSync(new Uint8Array(buffer));
|
|
38783
|
+
for (const path in zip) {
|
|
38784
|
+
const fileData = zip[path];
|
|
38785
|
+
const domParser = new DOMParser();
|
|
38786
|
+
const xmlDoc = domParser.parseFromString(strFromU8(fileData), "application/xml");
|
|
38787
|
+
const obj = {};
|
|
38788
|
+
this.parseNode(xmlDoc, obj);
|
|
38789
|
+
const objName = path.replace("wpmz/", "").split(".")[0];
|
|
38790
|
+
Object.assign(kmzObj, {
|
|
38791
|
+
[objName]: obj["#document"].kml.Document
|
|
38792
|
+
});
|
|
38793
|
+
}
|
|
38794
|
+
const wayline3D = new WayLines3D(kmzObj.waylines);
|
|
38795
|
+
this.data = wayline3D;
|
|
38796
|
+
} catch (error) {
|
|
38797
|
+
this.parserError(`KMZ parsing failed: ${error}`, -1);
|
|
38798
|
+
}
|
|
38799
|
+
}
|
|
38800
|
+
parseNode(xml, obj) {
|
|
38801
|
+
const arrayLikeName = ["Placemark", "actionGroup", "action"];
|
|
38802
|
+
const attr = xml.nodeName.replace("wpml:", "");
|
|
38803
|
+
if (!xml.childNodes.length) {
|
|
38804
|
+
obj[attr] = void 0;
|
|
38805
|
+
} else {
|
|
38806
|
+
let textValue = null;
|
|
38807
|
+
let hasElementChildren = false;
|
|
38808
|
+
for (let i = 0; i < xml.childNodes.length; ++i) {
|
|
38809
|
+
const childNode = xml.childNodes[i];
|
|
38810
|
+
if (childNode.nodeType == Node.TEXT_NODE) {
|
|
38811
|
+
const text = childNode.nodeValue?.trim();
|
|
38812
|
+
if (text && text.length > 0) {
|
|
38813
|
+
textValue = text;
|
|
38814
|
+
}
|
|
38815
|
+
} else if (childNode.nodeType == Node.ELEMENT_NODE) {
|
|
38816
|
+
hasElementChildren = true;
|
|
38817
|
+
}
|
|
38818
|
+
}
|
|
38819
|
+
if (textValue && !hasElementChildren) {
|
|
38820
|
+
obj[attr] = textValue;
|
|
38821
|
+
} else if (hasElementChildren) {
|
|
38822
|
+
if (arrayLikeName.includes(attr)) {
|
|
38823
|
+
if (obj[attr]?.length) {
|
|
38824
|
+
obj[attr].push({});
|
|
38825
|
+
} else {
|
|
38826
|
+
obj[attr] = [{}];
|
|
38827
|
+
}
|
|
38828
|
+
} else {
|
|
38829
|
+
obj[attr] = {};
|
|
38830
|
+
}
|
|
38831
|
+
for (let i = 0; i < xml.childNodes.length; ++i) {
|
|
38832
|
+
const childNode = xml.childNodes[i];
|
|
38833
|
+
if (childNode.nodeType == Node.ELEMENT_NODE) {
|
|
38834
|
+
this.parseNode(
|
|
38835
|
+
childNode,
|
|
38836
|
+
!Array.isArray(obj[attr]) ? obj[attr] : obj[attr].at(-1)
|
|
38837
|
+
);
|
|
38838
|
+
}
|
|
38839
|
+
}
|
|
38840
|
+
} else {
|
|
38841
|
+
obj[attr] = void 0;
|
|
38842
|
+
}
|
|
38843
|
+
}
|
|
38844
|
+
}
|
|
38845
|
+
verification() {
|
|
38846
|
+
if (this.data) {
|
|
38847
|
+
return true;
|
|
38848
|
+
}
|
|
38849
|
+
throw new Error("verify failed.");
|
|
38850
|
+
}
|
|
38851
|
+
}
|
|
38852
|
+
|
|
38017
38853
|
class Res {
|
|
38018
38854
|
_texturePool;
|
|
38019
38855
|
_materialPool;
|
|
@@ -38243,6 +39079,11 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
38243
39079
|
let parser = await loader.load(url, AtlasParser, loaderFunctions, url);
|
|
38244
39080
|
return parser.data;
|
|
38245
39081
|
}
|
|
39082
|
+
async loadKMZ(url, loaderFunctions) {
|
|
39083
|
+
let loader = new FileLoader();
|
|
39084
|
+
let parser = await loader.load(url, KMZParser, loaderFunctions);
|
|
39085
|
+
return parser.data;
|
|
39086
|
+
}
|
|
38246
39087
|
normalTexture;
|
|
38247
39088
|
maskTexture;
|
|
38248
39089
|
whiteTexture;
|
|
@@ -38436,7 +39277,7 @@ fn CsMain( @builtin(workgroup_id) workgroup_id : vec3<u32> , @builtin(global_inv
|
|
|
38436
39277
|
}
|
|
38437
39278
|
}
|
|
38438
39279
|
|
|
38439
|
-
const version = "1.0.
|
|
39280
|
+
const version = "1.0.4";
|
|
38440
39281
|
|
|
38441
39282
|
class Engine3D {
|
|
38442
39283
|
/**
|
|
@@ -41745,6 +42586,267 @@ fn CsMain(@builtin(workgroup_id) workgroup_id: vec3<u32>, @builtin(global_invoca
|
|
|
41745
42586
|
`
|
|
41746
42587
|
);
|
|
41747
42588
|
|
|
42589
|
+
const GSplat_VS = (
|
|
42590
|
+
/* wgsl */
|
|
42591
|
+
`
|
|
42592
|
+
#include "GlobalUniform"
|
|
42593
|
+
|
|
42594
|
+
struct VSOut {
|
|
42595
|
+
@location(auto) vColor : vec4f,
|
|
42596
|
+
@location(auto) vTexCoord : vec2f,
|
|
42597
|
+
@builtin(position) member : vec4f
|
|
42598
|
+
};
|
|
42599
|
+
|
|
42600
|
+
// ===== SPLAT CORE VS (from PlayCanvas shader-generator-gsplat.js) =====
|
|
42601
|
+
|
|
42602
|
+
// Uniforms (mapped to WebGPU bindings)
|
|
42603
|
+
// matrix_model, matrix_view, matrix_projection -> GlobalUniform + MaterialUniform
|
|
42604
|
+
// viewport -> calculated from globalUniform.windowWidth/Height
|
|
42605
|
+
// tex_params -> materialUniform.tex_params
|
|
42606
|
+
|
|
42607
|
+
@group(1) @binding(0) var splatColor : texture_2d<f32>;
|
|
42608
|
+
@group(1) @binding(1) var transformA : texture_2d<u32>;
|
|
42609
|
+
@group(1) @binding(2) var transformB : texture_2d<f32>;
|
|
42610
|
+
@group(1) @binding(4) var splatOrder : texture_2d<u32>;
|
|
42611
|
+
|
|
42612
|
+
struct MaterialUniform {
|
|
42613
|
+
tex_params: vec4f, // numSplats, textureWidth, validCount, visBoost
|
|
42614
|
+
modelMatrix: mat4x4<f32>,
|
|
42615
|
+
};
|
|
42616
|
+
@group(1) @binding(3) var<uniform> materialUniform : MaterialUniform;
|
|
42617
|
+
|
|
42618
|
+
// Global variables (like PlayCanvas)
|
|
42619
|
+
var<private> orderId: u32;
|
|
42620
|
+
var<private> splatId: u32;
|
|
42621
|
+
var<private> splatUV: vec2<i32>;
|
|
42622
|
+
var<private> tA: vec4<u32>;
|
|
42623
|
+
|
|
42624
|
+
// Helper: decode 16-bit half float
|
|
42625
|
+
fn unpackHalf(h: u32) -> f32 {
|
|
42626
|
+
let s = (h >> 15u) & 0x1u;
|
|
42627
|
+
let e = (h >> 10u) & 0x1fu;
|
|
42628
|
+
let m = h & 0x3ffu;
|
|
42629
|
+
let sign = select(1.0, -1.0, s == 1u);
|
|
42630
|
+
if (e == 0u) {
|
|
42631
|
+
if (m == 0u) { return 0.0; }
|
|
42632
|
+
return sign * (f32(m) * exp2(-24.0));
|
|
42633
|
+
} else if (e == 31u) {
|
|
42634
|
+
return sign * 65504.0;
|
|
42635
|
+
} else {
|
|
42636
|
+
return sign * (1.0 + f32(m) / 1024.0) * exp2(f32(i32(e) - 15));
|
|
42637
|
+
}
|
|
42638
|
+
}
|
|
42639
|
+
|
|
42640
|
+
// === calcSplatUV() - returns bool ===
|
|
42641
|
+
fn calcSplatUV(instance_id: u32) -> bool {
|
|
42642
|
+
let numSplats = u32(materialUniform.tex_params.x);
|
|
42643
|
+
let textureWidth = u32(materialUniform.tex_params.y);
|
|
42644
|
+
|
|
42645
|
+
// calculate splat index
|
|
42646
|
+
orderId = instance_id;
|
|
42647
|
+
|
|
42648
|
+
if (orderId >= numSplats) {
|
|
42649
|
+
return false;
|
|
42650
|
+
}
|
|
42651
|
+
|
|
42652
|
+
let orderUV = vec2<i32>(
|
|
42653
|
+
i32(orderId % textureWidth),
|
|
42654
|
+
i32(orderId / textureWidth)
|
|
42655
|
+
);
|
|
42656
|
+
|
|
42657
|
+
// calculate splatUV
|
|
42658
|
+
splatId = textureLoad(splatOrder, orderUV, 0).r;
|
|
42659
|
+
splatUV = vec2<i32>(
|
|
42660
|
+
i32(splatId % textureWidth),
|
|
42661
|
+
i32(splatId / textureWidth)
|
|
42662
|
+
);
|
|
42663
|
+
|
|
42664
|
+
return true;
|
|
42665
|
+
}
|
|
42666
|
+
|
|
42667
|
+
// === getCenter() - returns vec3 ===
|
|
42668
|
+
fn getCenter() -> vec3f {
|
|
42669
|
+
tA = textureLoad(transformA, splatUV, 0);
|
|
42670
|
+
return vec3f(bitcast<f32>(tA.x), bitcast<f32>(tA.y), bitcast<f32>(tA.z));
|
|
42671
|
+
}
|
|
42672
|
+
|
|
42673
|
+
// Struct to return covA and covB
|
|
42674
|
+
struct CovarianceData {
|
|
42675
|
+
covA: vec3f,
|
|
42676
|
+
covB: vec3f,
|
|
42677
|
+
};
|
|
42678
|
+
|
|
42679
|
+
// === getCovariance() - returns struct ===
|
|
42680
|
+
fn getCovariance() -> CovarianceData {
|
|
42681
|
+
let tB = textureLoad(transformB, splatUV, 0);
|
|
42682
|
+
|
|
42683
|
+
// unpackHalf2x16 equivalent
|
|
42684
|
+
let h1 = tA.w & 0xFFFFu;
|
|
42685
|
+
let h2 = (tA.w >> 16u) & 0xFFFFu;
|
|
42686
|
+
let tCx = unpackHalf(h1);
|
|
42687
|
+
let tCy = unpackHalf(h2);
|
|
42688
|
+
|
|
42689
|
+
var result: CovarianceData;
|
|
42690
|
+
result.covA = tB.xyz;
|
|
42691
|
+
result.covB = vec3f(tCx, tCy, tB.w);
|
|
42692
|
+
|
|
42693
|
+
return result;
|
|
42694
|
+
}
|
|
42695
|
+
|
|
42696
|
+
// === calcV1V2() - returns vec4 ===
|
|
42697
|
+
fn calcV1V2(splat_cam: vec3f, covA: vec3f, covB: vec3f, W: mat3x3f, viewport: vec2f, projMat: mat4x4f) -> vec4f {
|
|
42698
|
+
let Vrk = mat3x3f(
|
|
42699
|
+
vec3f(covA.x, covA.y, covA.z),
|
|
42700
|
+
vec3f(covA.y, covB.x, covB.y),
|
|
42701
|
+
vec3f(covA.z, covB.y, covB.z)
|
|
42702
|
+
);
|
|
42703
|
+
|
|
42704
|
+
let focal = viewport.x * abs(projMat[0][0]);
|
|
42705
|
+
|
|
42706
|
+
let J1 = focal / abs(splat_cam.z);
|
|
42707
|
+
let J2 = -J1 / abs(splat_cam.z) * splat_cam.xy;
|
|
42708
|
+
let J = mat3x3f(
|
|
42709
|
+
vec3f(J1, 0.0, J2.x),
|
|
42710
|
+
vec3f(0.0, J1, J2.y),
|
|
42711
|
+
vec3f(0.0, 0.0, 0.0)
|
|
42712
|
+
);
|
|
42713
|
+
|
|
42714
|
+
let T = W * J;
|
|
42715
|
+
let cov = transpose(T) * Vrk * T;
|
|
42716
|
+
|
|
42717
|
+
let diagonal1 = cov[0][0] + 0.3;
|
|
42718
|
+
let offDiagonal = cov[0][1];
|
|
42719
|
+
let diagonal2 = cov[1][1] + 0.3;
|
|
42720
|
+
|
|
42721
|
+
let mid = 0.5 * (diagonal1 + diagonal2);
|
|
42722
|
+
let radius = length(vec2f((diagonal1 - diagonal2) / 2.0, offDiagonal));
|
|
42723
|
+
let lambda1 = mid + radius;
|
|
42724
|
+
let lambda2 = max(mid - radius, 0.1);
|
|
42725
|
+
let diagonalVector = normalize(vec2f(offDiagonal, lambda1 - diagonal1));
|
|
42726
|
+
|
|
42727
|
+
let v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;
|
|
42728
|
+
let v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2f(diagonalVector.y, -diagonalVector.x);
|
|
42729
|
+
|
|
42730
|
+
return vec4f(v1, v2);
|
|
42731
|
+
}
|
|
42732
|
+
|
|
42733
|
+
// ===== SPLAT MAIN VS (from PlayCanvas gsplat-material.js) =====
|
|
42734
|
+
|
|
42735
|
+
@vertex
|
|
42736
|
+
fn VertMain(
|
|
42737
|
+
@builtin(vertex_index) vid : u32,
|
|
42738
|
+
@builtin(instance_index) iid : u32
|
|
42739
|
+
) -> VSOut {
|
|
42740
|
+
var o: VSOut;
|
|
42741
|
+
let discardVec = vec4f(0.0, 0.0, 2.0, 1.0);
|
|
42742
|
+
|
|
42743
|
+
// Vertex position array (PlayCanvas uses attribute vec3 with x,y in [-1,1])
|
|
42744
|
+
let vertex_position = array<vec2f, 4>(
|
|
42745
|
+
vec2f(-2.0, -2.0),
|
|
42746
|
+
vec2f( 2.0, -2.0),
|
|
42747
|
+
vec2f(-2.0, 2.0),
|
|
42748
|
+
vec2f( 2.0, 2.0)
|
|
42749
|
+
);
|
|
42750
|
+
let vertex_pos = vertex_position[vid & 3u];
|
|
42751
|
+
|
|
42752
|
+
// calculate splat uv
|
|
42753
|
+
if (!calcSplatUV(iid)) {
|
|
42754
|
+
o.member = discardVec;
|
|
42755
|
+
o.vColor = vec4f(0.0);
|
|
42756
|
+
o.vTexCoord = vec2f(0.0);
|
|
42757
|
+
return o;
|
|
42758
|
+
}
|
|
42759
|
+
|
|
42760
|
+
// get center
|
|
42761
|
+
let center = getCenter();
|
|
42762
|
+
|
|
42763
|
+
// handle transforms
|
|
42764
|
+
let matrix_view = globalUniform.viewMat;
|
|
42765
|
+
let matrix_projection = globalUniform.projMat;
|
|
42766
|
+
let matrix_model = materialUniform.modelMatrix;
|
|
42767
|
+
|
|
42768
|
+
let model_view = matrix_view * matrix_model;
|
|
42769
|
+
let splat_cam = model_view * vec4f(center, 1.0);
|
|
42770
|
+
let splat_proj = matrix_projection * splat_cam;
|
|
42771
|
+
|
|
42772
|
+
// cull behind camera (WebGPU: NDC z in [0,1], cull if z/w < 0)
|
|
42773
|
+
if (splat_proj.z < 0.0) {
|
|
42774
|
+
o.member = discardVec;
|
|
42775
|
+
o.vColor = vec4f(0.0);
|
|
42776
|
+
o.vTexCoord = vec2f(0.0);
|
|
42777
|
+
return o;
|
|
42778
|
+
}
|
|
42779
|
+
|
|
42780
|
+
// get covariance
|
|
42781
|
+
let cov_data = getCovariance();
|
|
42782
|
+
|
|
42783
|
+
let viewport = vec2f(globalUniform.windowWidth, globalUniform.windowHeight);
|
|
42784
|
+
let v1v2 = calcV1V2(splat_cam.xyz, cov_data.covA, cov_data.covB, transpose(mat3x3f(model_view[0].xyz, model_view[1].xyz, model_view[2].xyz)), viewport, matrix_projection);
|
|
42785
|
+
|
|
42786
|
+
// get color
|
|
42787
|
+
let color = textureLoad(splatColor, splatUV, 0);
|
|
42788
|
+
|
|
42789
|
+
// calculate scale based on alpha
|
|
42790
|
+
let scale = min(1.0, sqrt(-log(1.0 / 255.0 / color.a)) / 2.0);
|
|
42791
|
+
|
|
42792
|
+
// apply visBoost (size multiplier)
|
|
42793
|
+
let visBoost = materialUniform.tex_params.w;
|
|
42794
|
+
var v1v2_scaled = v1v2 * scale * visBoost;
|
|
42795
|
+
|
|
42796
|
+
// early out tiny splats
|
|
42797
|
+
if (dot(v1v2_scaled.xy, v1v2_scaled.xy) < 4.0 && dot(v1v2_scaled.zw, v1v2_scaled.zw) < 4.0) {
|
|
42798
|
+
o.member = discardVec;
|
|
42799
|
+
o.vColor = vec4f(0.0);
|
|
42800
|
+
o.vTexCoord = vec2f(0.0);
|
|
42801
|
+
return o;
|
|
42802
|
+
}
|
|
42803
|
+
|
|
42804
|
+
// gl_Position = splat_proj + vec4((vertex_position.x * v1v2.xy + vertex_position.y * v1v2.zw) / viewport * splat_proj.w, 0, 0);
|
|
42805
|
+
o.member = splat_proj + vec4f((vertex_pos.x * v1v2_scaled.xy + vertex_pos.y * v1v2_scaled.zw) / viewport * splat_proj.w, 0.0, 0.0);
|
|
42806
|
+
|
|
42807
|
+
// texCoord = vertex_position.xy * scale / 2.0;
|
|
42808
|
+
o.vTexCoord = vertex_pos * scale / 2.0;
|
|
42809
|
+
|
|
42810
|
+
o.vColor = color;
|
|
42811
|
+
|
|
42812
|
+
return o;
|
|
42813
|
+
}
|
|
42814
|
+
`
|
|
42815
|
+
);
|
|
42816
|
+
const GSplat_FS = (
|
|
42817
|
+
/* wgsl */
|
|
42818
|
+
`
|
|
42819
|
+
#include "FragmentOutput"
|
|
42820
|
+
|
|
42821
|
+
// === evalSplat() - like PlayCanvas splatCoreFS ===
|
|
42822
|
+
fn evalSplat(texCoord: vec2f, color: vec4f) -> vec4f {
|
|
42823
|
+
let A = dot(texCoord, texCoord);
|
|
42824
|
+
if (A > 1.0) {
|
|
42825
|
+
discard;
|
|
42826
|
+
}
|
|
42827
|
+
|
|
42828
|
+
let B = exp(-A * 4.0) * color.a;
|
|
42829
|
+
if (B < 1.0 / 255.0) {
|
|
42830
|
+
discard;
|
|
42831
|
+
}
|
|
42832
|
+
|
|
42833
|
+
// TONEMAP_ENABLED branch not implemented (would call toneMap() and gammaCorrectOutput())
|
|
42834
|
+
return vec4f(color.rgb, B);
|
|
42835
|
+
}
|
|
42836
|
+
|
|
42837
|
+
// === main() - like PlayCanvas splatMainFS ===
|
|
42838
|
+
@fragment
|
|
42839
|
+
fn FragMain(@location(auto) vColor: vec4f, @location(auto) vTexCoord: vec2f) -> FragmentOutput {
|
|
42840
|
+
let result = evalSplat(vTexCoord, vColor);
|
|
42841
|
+
|
|
42842
|
+
var o: FragmentOutput;
|
|
42843
|
+
o.color = result;
|
|
42844
|
+
o.gBuffer = vec4f(0.0);
|
|
42845
|
+
return o;
|
|
42846
|
+
}
|
|
42847
|
+
`
|
|
42848
|
+
);
|
|
42849
|
+
|
|
41748
42850
|
let GlassShader = (
|
|
41749
42851
|
/*wgsl */
|
|
41750
42852
|
`
|
|
@@ -42949,9 +44051,9 @@ fn frag(){
|
|
|
42949
44051
|
}
|
|
42950
44052
|
}
|
|
42951
44053
|
|
|
42952
|
-
var __getOwnPropDesc$
|
|
42953
|
-
var __decorateClass$
|
|
42954
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
44054
|
+
var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
|
|
44055
|
+
var __decorateClass$b = (decorators, target, key, kind) => {
|
|
44056
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
|
|
42955
44057
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
42956
44058
|
if (decorator = decorators[i])
|
|
42957
44059
|
result = (decorator(result)) || result;
|
|
@@ -42975,7 +44077,7 @@ fn frag(){
|
|
|
42975
44077
|
shaderState.depthCompare = GPUCompareFunction.less;
|
|
42976
44078
|
}
|
|
42977
44079
|
};
|
|
42978
|
-
exports.SkyShader = __decorateClass$
|
|
44080
|
+
exports.SkyShader = __decorateClass$b([
|
|
42979
44081
|
RegisterShader(exports.SkyShader, "SkyShader")
|
|
42980
44082
|
], exports.SkyShader);
|
|
42981
44083
|
|
|
@@ -43020,113 +44122,6 @@ fn frag(){
|
|
|
43020
44122
|
}
|
|
43021
44123
|
}
|
|
43022
44124
|
|
|
43023
|
-
class SphereGeometry extends GeometryBase {
|
|
43024
|
-
shape_vertices = [];
|
|
43025
|
-
shape_indices = [];
|
|
43026
|
-
radius;
|
|
43027
|
-
widthSegments;
|
|
43028
|
-
heightSegments;
|
|
43029
|
-
phiStart;
|
|
43030
|
-
phiLength;
|
|
43031
|
-
thetaStart;
|
|
43032
|
-
thetaLength;
|
|
43033
|
-
/**
|
|
43034
|
-
* 球体几何体
|
|
43035
|
-
* @constructor
|
|
43036
|
-
* @param radius 球体半径
|
|
43037
|
-
* @param widthSegments 定义水平分段数
|
|
43038
|
-
* @param heightSegments 定义垂直分段数
|
|
43039
|
-
* @param phiStart 球体赤道线起始点的弧度
|
|
43040
|
-
* @param phiLength 球体赤道线的弧长
|
|
43041
|
-
* @param thetaStart 球体经线起始点的弧度
|
|
43042
|
-
* @param thetaLength 球体经线的弧长
|
|
43043
|
-
*/
|
|
43044
|
-
constructor(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
|
|
43045
|
-
super();
|
|
43046
|
-
this.radius = radius;
|
|
43047
|
-
this.widthSegments = widthSegments;
|
|
43048
|
-
this.heightSegments = heightSegments;
|
|
43049
|
-
this.phiStart = phiStart;
|
|
43050
|
-
this.phiLength = phiLength;
|
|
43051
|
-
this.thetaStart = thetaStart;
|
|
43052
|
-
this.thetaLength = thetaLength;
|
|
43053
|
-
this.buildGeometry();
|
|
43054
|
-
}
|
|
43055
|
-
buildGeometry() {
|
|
43056
|
-
var i, j, triIndex = 0;
|
|
43057
|
-
let _segmentsH = this.heightSegments;
|
|
43058
|
-
let _segmentsW = this.widthSegments;
|
|
43059
|
-
let _radius = this.radius;
|
|
43060
|
-
var vertexCount = (_segmentsH + 1) * (_segmentsW + 1);
|
|
43061
|
-
let position_arr = new Float32Array(vertexCount * 3);
|
|
43062
|
-
let normal_arr = new Float32Array(vertexCount * 3);
|
|
43063
|
-
let uv_arr = new Float32Array(vertexCount * 2);
|
|
43064
|
-
let indice_arr = new Uint16Array(_segmentsW * _segmentsH * 2 * 3);
|
|
43065
|
-
let pi = 0;
|
|
43066
|
-
let ni = 0;
|
|
43067
|
-
let ui = 0;
|
|
43068
|
-
for (j = 0; j <= _segmentsH; ++j) {
|
|
43069
|
-
var horAngle = Math.PI * j / _segmentsH;
|
|
43070
|
-
var y = _radius * Math.cos(horAngle);
|
|
43071
|
-
var ringRadius = _radius * Math.sin(horAngle);
|
|
43072
|
-
for (i = 0; i <= _segmentsW; ++i) {
|
|
43073
|
-
var verAngle = 2 * Math.PI * i / _segmentsW;
|
|
43074
|
-
var x = ringRadius * Math.cos(verAngle);
|
|
43075
|
-
var z = ringRadius * Math.sin(verAngle);
|
|
43076
|
-
var normLen = 1 / Math.sqrt(x * x + y * y + z * z);
|
|
43077
|
-
position_arr[pi++] = x;
|
|
43078
|
-
position_arr[pi++] = y;
|
|
43079
|
-
position_arr[pi++] = z;
|
|
43080
|
-
normal_arr[ni++] = x * normLen;
|
|
43081
|
-
normal_arr[ni++] = y * normLen;
|
|
43082
|
-
normal_arr[ni++] = z * normLen;
|
|
43083
|
-
uv_arr[ui++] = i / _segmentsW;
|
|
43084
|
-
uv_arr[ui++] = j / _segmentsH;
|
|
43085
|
-
if (i > 0 && j > 0) {
|
|
43086
|
-
var a = (_segmentsW + 1) * j + i;
|
|
43087
|
-
var b = (_segmentsW + 1) * j + i - 1;
|
|
43088
|
-
var c = (_segmentsW + 1) * (j - 1) + i - 1;
|
|
43089
|
-
var d = (_segmentsW + 1) * (j - 1) + i;
|
|
43090
|
-
if (j == _segmentsH) {
|
|
43091
|
-
indice_arr[triIndex++] = a;
|
|
43092
|
-
indice_arr[triIndex++] = c;
|
|
43093
|
-
indice_arr[triIndex++] = d;
|
|
43094
|
-
} else if (j == 1) {
|
|
43095
|
-
indice_arr[triIndex++] = a;
|
|
43096
|
-
indice_arr[triIndex++] = b;
|
|
43097
|
-
indice_arr[triIndex++] = c;
|
|
43098
|
-
} else {
|
|
43099
|
-
indice_arr[triIndex++] = a;
|
|
43100
|
-
indice_arr[triIndex++] = b;
|
|
43101
|
-
indice_arr[triIndex++] = c;
|
|
43102
|
-
indice_arr[triIndex++] = a;
|
|
43103
|
-
indice_arr[triIndex++] = c;
|
|
43104
|
-
indice_arr[triIndex++] = d;
|
|
43105
|
-
}
|
|
43106
|
-
}
|
|
43107
|
-
}
|
|
43108
|
-
}
|
|
43109
|
-
this.setIndices(indice_arr);
|
|
43110
|
-
this.setAttribute(VertexAttributeName.position, position_arr);
|
|
43111
|
-
this.setAttribute(VertexAttributeName.normal, normal_arr);
|
|
43112
|
-
this.setAttribute(VertexAttributeName.uv, uv_arr);
|
|
43113
|
-
this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
|
|
43114
|
-
this.addSubGeometry({
|
|
43115
|
-
indexStart: 0,
|
|
43116
|
-
indexCount: indice_arr.length,
|
|
43117
|
-
vertexStart: 0,
|
|
43118
|
-
vertexCount: 0,
|
|
43119
|
-
firstStart: 0,
|
|
43120
|
-
index: 0,
|
|
43121
|
-
topology: 0
|
|
43122
|
-
});
|
|
43123
|
-
this.bounds = new BoundingBox(
|
|
43124
|
-
Vector3.ZERO,
|
|
43125
|
-
new Vector3(this.radius * 2, this.radius * 2, this.radius * 2)
|
|
43126
|
-
);
|
|
43127
|
-
}
|
|
43128
|
-
}
|
|
43129
|
-
|
|
43130
44125
|
class Reflection extends RenderNode {
|
|
43131
44126
|
gid = 0;
|
|
43132
44127
|
needUpdate = true;
|
|
@@ -43880,9 +44875,9 @@ fn frag(){
|
|
|
43880
44875
|
}
|
|
43881
44876
|
}
|
|
43882
44877
|
|
|
43883
|
-
var __getOwnPropDesc$
|
|
43884
|
-
var __decorateClass$
|
|
43885
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
44878
|
+
var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
|
|
44879
|
+
var __decorateClass$a = (decorators, target, key, kind) => {
|
|
44880
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
|
|
43886
44881
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
43887
44882
|
if (decorator = decorators[i])
|
|
43888
44883
|
result = (decorator(result)) || result;
|
|
@@ -44086,7 +45081,7 @@ fn frag(){
|
|
|
44086
45081
|
this._currentClipState.weight = 1;
|
|
44087
45082
|
}
|
|
44088
45083
|
};
|
|
44089
|
-
exports.SkeletonAnimationComponent = __decorateClass$
|
|
45084
|
+
exports.SkeletonAnimationComponent = __decorateClass$a([
|
|
44090
45085
|
RegisterComponent(exports.SkeletonAnimationComponent, "SkeletonAnimationComponent")
|
|
44091
45086
|
], exports.SkeletonAnimationComponent);
|
|
44092
45087
|
class SkeletonAnimationCrossFadeState {
|
|
@@ -44122,9 +45117,9 @@ fn frag(){
|
|
|
44122
45117
|
}
|
|
44123
45118
|
}
|
|
44124
45119
|
|
|
44125
|
-
var __getOwnPropDesc$
|
|
44126
|
-
var __decorateClass$
|
|
44127
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
45120
|
+
var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
|
|
45121
|
+
var __decorateClass$9 = (decorators, target, key, kind) => {
|
|
45122
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
|
|
44128
45123
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
44129
45124
|
if (decorator = decorators[i])
|
|
44130
45125
|
result = (decorator(result)) || result;
|
|
@@ -44535,7 +45530,7 @@ fn frag(){
|
|
|
44535
45530
|
return dst;
|
|
44536
45531
|
}
|
|
44537
45532
|
};
|
|
44538
|
-
exports.AnimatorComponent = __decorateClass$
|
|
45533
|
+
exports.AnimatorComponent = __decorateClass$9([
|
|
44539
45534
|
RegisterComponent(exports.AnimatorComponent, "AnimatorComponent")
|
|
44540
45535
|
], exports.AnimatorComponent);
|
|
44541
45536
|
class PropertyAnimationClipState {
|
|
@@ -45292,9 +46287,9 @@ fn frag(){
|
|
|
45292
46287
|
}
|
|
45293
46288
|
}
|
|
45294
46289
|
|
|
45295
|
-
var __getOwnPropDesc$
|
|
45296
|
-
var __decorateClass$
|
|
45297
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
46290
|
+
var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
|
|
46291
|
+
var __decorateClass$8 = (decorators, target, key, kind) => {
|
|
46292
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
|
|
45298
46293
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
45299
46294
|
if (decorator = decorators[i])
|
|
45300
46295
|
result = (decorator(result)) || result;
|
|
@@ -45443,7 +46438,7 @@ fn frag(){
|
|
|
45443
46438
|
super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
|
|
45444
46439
|
}
|
|
45445
46440
|
};
|
|
45446
|
-
exports.SkinnedMeshRenderer2 = __decorateClass$
|
|
46441
|
+
exports.SkinnedMeshRenderer2 = __decorateClass$8([
|
|
45447
46442
|
RegisterComponent(exports.SkinnedMeshRenderer2, "SkinnedMeshRenderer2")
|
|
45448
46443
|
], exports.SkinnedMeshRenderer2);
|
|
45449
46444
|
|
|
@@ -50573,9 +51568,9 @@ fn frag(){
|
|
|
50573
51568
|
}
|
|
50574
51569
|
}
|
|
50575
51570
|
|
|
50576
|
-
var __getOwnPropDesc$
|
|
50577
|
-
var __decorateClass$
|
|
50578
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
51571
|
+
var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
|
|
51572
|
+
var __decorateClass$7 = (decorators, target, key, kind) => {
|
|
51573
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
|
|
50579
51574
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
50580
51575
|
if (decorator = decorators[i])
|
|
50581
51576
|
result = (decorator(result)) || result;
|
|
@@ -50652,10 +51647,802 @@ fn frag(){
|
|
|
50652
51647
|
debugDraw(show) {
|
|
50653
51648
|
}
|
|
50654
51649
|
};
|
|
50655
|
-
exports.Light = __decorateClass$
|
|
51650
|
+
exports.Light = __decorateClass$7([
|
|
50656
51651
|
RegisterComponent(exports.Light, "Light")
|
|
50657
51652
|
], exports.Light);
|
|
50658
51653
|
|
|
51654
|
+
class GSplatMaterial extends Material {
|
|
51655
|
+
constructor() {
|
|
51656
|
+
super();
|
|
51657
|
+
ShaderLib.register("gsplat_vs_dc", GSplat_VS);
|
|
51658
|
+
ShaderLib.register("gsplat_fs_dc", GSplat_FS);
|
|
51659
|
+
const pass = new RenderShaderPass("gsplat_vs_dc", "gsplat_fs_dc");
|
|
51660
|
+
pass.passType = PassType.COLOR;
|
|
51661
|
+
pass.setShaderEntry("VertMain", "FragMain");
|
|
51662
|
+
pass.topology = GPUPrimitiveTopology.triangle_strip;
|
|
51663
|
+
pass.depthWriteEnabled = false;
|
|
51664
|
+
pass.cullMode = "none";
|
|
51665
|
+
pass.shaderState.transparent = true;
|
|
51666
|
+
pass.shaderState.blendMode = BlendMode.NORMAL;
|
|
51667
|
+
pass.shaderState.writeMasks = [15, 15];
|
|
51668
|
+
const shader = new Shader();
|
|
51669
|
+
shader.addRenderPass(pass);
|
|
51670
|
+
this.shader = shader;
|
|
51671
|
+
}
|
|
51672
|
+
setSplatTextures(splatColor, transformA, transformB, texParams, splatOrder) {
|
|
51673
|
+
const pass = this.shader.getDefaultColorShader();
|
|
51674
|
+
pass.setTexture("splatColor", splatColor);
|
|
51675
|
+
pass.setTexture("transformA", transformA);
|
|
51676
|
+
pass.setTexture("transformB", transformB);
|
|
51677
|
+
pass.setUniformArray("tex_params", texParams);
|
|
51678
|
+
if (splatOrder) {
|
|
51679
|
+
pass.setTexture("splatOrder", splatOrder);
|
|
51680
|
+
}
|
|
51681
|
+
}
|
|
51682
|
+
/**
|
|
51683
|
+
* Set the model matrix for transforming splats to world space
|
|
51684
|
+
*/
|
|
51685
|
+
setTransformMatrix(matrix) {
|
|
51686
|
+
const pass = this.shader.getDefaultColorShader();
|
|
51687
|
+
pass.setUniform("modelMatrix", matrix.rawData);
|
|
51688
|
+
}
|
|
51689
|
+
}
|
|
51690
|
+
|
|
51691
|
+
class Uint32ArrayTexture extends Texture {
|
|
51692
|
+
_dataBuffer;
|
|
51693
|
+
create(width, height, data) {
|
|
51694
|
+
let device = webGPUContext.device;
|
|
51695
|
+
const bytesPerRow = width * 4 * 4;
|
|
51696
|
+
this.format = GPUTextureFormat.rgba32uint;
|
|
51697
|
+
const mipmapCount = 1;
|
|
51698
|
+
this.createTextureDescriptor(width, height, mipmapCount, this.format);
|
|
51699
|
+
const textureDataBuffer = this._dataBuffer = device.createBuffer({
|
|
51700
|
+
size: data.byteLength,
|
|
51701
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
|
|
51702
|
+
});
|
|
51703
|
+
device.queue.writeBuffer(textureDataBuffer, 0, data.buffer);
|
|
51704
|
+
const encoder = device.createCommandEncoder();
|
|
51705
|
+
encoder.copyBufferToTexture(
|
|
51706
|
+
{ buffer: textureDataBuffer, bytesPerRow },
|
|
51707
|
+
{ texture: this.getGPUTexture() },
|
|
51708
|
+
{ width, height, depthOrArrayLayers: 1 }
|
|
51709
|
+
);
|
|
51710
|
+
device.queue.submit([encoder.finish()]);
|
|
51711
|
+
this.samplerBindingLayout.type = `non-filtering`;
|
|
51712
|
+
this.textureBindingLayout.sampleType = `uint`;
|
|
51713
|
+
this.gpuSampler = device.createSampler({});
|
|
51714
|
+
return this;
|
|
51715
|
+
}
|
|
51716
|
+
updateTexture(width, height, data) {
|
|
51717
|
+
let device = webGPUContext.device;
|
|
51718
|
+
const bytesPerRow = width * 4 * 4;
|
|
51719
|
+
const staging = device.createBuffer({
|
|
51720
|
+
size: data.byteLength,
|
|
51721
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
|
|
51722
|
+
});
|
|
51723
|
+
device.queue.writeBuffer(staging, 0, data.buffer);
|
|
51724
|
+
const encoder = device.createCommandEncoder();
|
|
51725
|
+
encoder.copyBufferToTexture(
|
|
51726
|
+
{ buffer: staging, bytesPerRow },
|
|
51727
|
+
{ texture: this.getGPUTexture() },
|
|
51728
|
+
{ width, height, depthOrArrayLayers: 1 }
|
|
51729
|
+
);
|
|
51730
|
+
device.queue.submit([encoder.finish()]);
|
|
51731
|
+
}
|
|
51732
|
+
}
|
|
51733
|
+
|
|
51734
|
+
class Float16ArrayTexture extends Texture {
|
|
51735
|
+
uint16Array;
|
|
51736
|
+
floatArray;
|
|
51737
|
+
_dataBuffer;
|
|
51738
|
+
/**
|
|
51739
|
+
* 使用数字数组填充纹理,格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
|
|
51740
|
+
* @param width 纹理宽度
|
|
51741
|
+
* @param height 纹理高度
|
|
51742
|
+
* @param numbers 每个像素的颜色值数组
|
|
51743
|
+
* @param useMipmap 是否生成Mipmap
|
|
51744
|
+
* @returns 返回纹理实例
|
|
51745
|
+
*/
|
|
51746
|
+
create(width, height, numbers = null, mipmap = true) {
|
|
51747
|
+
if (numbers == null) {
|
|
51748
|
+
numbers = [];
|
|
51749
|
+
for (let i = 0, c = width * height * 4; i < c; i++) {
|
|
51750
|
+
numbers[i] = 0;
|
|
51751
|
+
}
|
|
51752
|
+
}
|
|
51753
|
+
this.updateTexture(width, height, numbers, mipmap);
|
|
51754
|
+
return this;
|
|
51755
|
+
}
|
|
51756
|
+
/**
|
|
51757
|
+
* 更新纹理内容
|
|
51758
|
+
* @param width 纹理宽度
|
|
51759
|
+
* @param height 纹理高度
|
|
51760
|
+
* @param numbers 像素数据数组
|
|
51761
|
+
* @param mipmap 是否生成Mipmap
|
|
51762
|
+
*/
|
|
51763
|
+
updateTexture(width, height, numbers, mipmap = true) {
|
|
51764
|
+
if (width != this.width || height != this.height) {
|
|
51765
|
+
this._dataBuffer && this._dataBuffer.destroy();
|
|
51766
|
+
this._dataBuffer = null;
|
|
51767
|
+
this.gpuTexture && this.gpuTexture.destroy();
|
|
51768
|
+
this.gpuTexture = null;
|
|
51769
|
+
}
|
|
51770
|
+
this.floatArray = numbers;
|
|
51771
|
+
let device = webGPUContext.device;
|
|
51772
|
+
const bytesPerRow = width * 4 * 2;
|
|
51773
|
+
this.format = GPUTextureFormat.rgba16float;
|
|
51774
|
+
this.mipmapCount = Math.floor(mipmap ? Math.log2(width) : 1);
|
|
51775
|
+
this.createTextureDescriptor(width, height, this.mipmapCount, this.format);
|
|
51776
|
+
if (!this.uint16Array || this.uint16Array.length != numbers.length) {
|
|
51777
|
+
this.uint16Array = new Uint16Array(numbers.length);
|
|
51778
|
+
}
|
|
51779
|
+
let uint16Array = this.uint16Array;
|
|
51780
|
+
for (let i = 0, c = uint16Array.length; i < c; i++) {
|
|
51781
|
+
uint16Array[i] = toHalfFloat(numbers[i]);
|
|
51782
|
+
}
|
|
51783
|
+
const textureDataBuffer = this._dataBuffer = device.createBuffer({
|
|
51784
|
+
size: uint16Array.byteLength,
|
|
51785
|
+
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
|
|
51786
|
+
});
|
|
51787
|
+
device.queue.writeBuffer(textureDataBuffer, 0, uint16Array);
|
|
51788
|
+
const commandEncoder = GPUContext.beginCommandEncoder();
|
|
51789
|
+
commandEncoder.copyBufferToTexture(
|
|
51790
|
+
{
|
|
51791
|
+
buffer: textureDataBuffer,
|
|
51792
|
+
bytesPerRow
|
|
51793
|
+
},
|
|
51794
|
+
{
|
|
51795
|
+
texture: this.getGPUTexture()
|
|
51796
|
+
},
|
|
51797
|
+
{
|
|
51798
|
+
width,
|
|
51799
|
+
height,
|
|
51800
|
+
depthOrArrayLayers: 1
|
|
51801
|
+
}
|
|
51802
|
+
);
|
|
51803
|
+
if (!this.useMipmap) {
|
|
51804
|
+
this.samplerBindingLayout.type = `filtering`;
|
|
51805
|
+
this.textureBindingLayout.sampleType = `float`;
|
|
51806
|
+
}
|
|
51807
|
+
GPUContext.endCommandEncoder(commandEncoder);
|
|
51808
|
+
this.gpuSampler = device.createSampler(this);
|
|
51809
|
+
this.gpuTexture = this.getGPUTexture();
|
|
51810
|
+
if (this.mipmapCount > 1) TextureMipmapGenerator.webGPUGenerateMipmap(this);
|
|
51811
|
+
}
|
|
51812
|
+
}
|
|
51813
|
+
|
|
51814
|
+
var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
|
|
51815
|
+
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
51816
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
|
|
51817
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
51818
|
+
if (decorator = decorators[i])
|
|
51819
|
+
result = (decorator(result)) || result;
|
|
51820
|
+
return result;
|
|
51821
|
+
};
|
|
51822
|
+
exports.GSplatRenderer = class GSplatRenderer extends RenderNode {
|
|
51823
|
+
// Splat count and texture dimensions
|
|
51824
|
+
count = 0;
|
|
51825
|
+
size = new Vector2();
|
|
51826
|
+
// GPU textures for splat data
|
|
51827
|
+
splatColor;
|
|
51828
|
+
transformA;
|
|
51829
|
+
transformB;
|
|
51830
|
+
texParams;
|
|
51831
|
+
// [numSplats, texWidth, validCount, visBoost]
|
|
51832
|
+
splatOrder;
|
|
51833
|
+
// Material and geometry
|
|
51834
|
+
gsplatMaterial;
|
|
51835
|
+
// CPU-side data for sorting
|
|
51836
|
+
_positions;
|
|
51837
|
+
// xyz per splat (local space)
|
|
51838
|
+
_worldPositions;
|
|
51839
|
+
// xyz per splat (world space, cached)
|
|
51840
|
+
_orderData;
|
|
51841
|
+
// RGBA32U backing: size.x * size.y * 4
|
|
51842
|
+
// Web Worker for sorting
|
|
51843
|
+
_sortWorker;
|
|
51844
|
+
_lastSentTime = 0;
|
|
51845
|
+
_minIntervalMs = 0;
|
|
51846
|
+
// No throttle for immediate sorting
|
|
51847
|
+
_centersSent = false;
|
|
51848
|
+
_lastViewMatrixHash = 0;
|
|
51849
|
+
// Mapping support (optional subset rendering)
|
|
51850
|
+
_mapping = null;
|
|
51851
|
+
_fullCount = 0;
|
|
51852
|
+
// Original total count
|
|
51853
|
+
constructor() {
|
|
51854
|
+
super();
|
|
51855
|
+
}
|
|
51856
|
+
/**
|
|
51857
|
+
* Initialize from Gaussian Splat asset
|
|
51858
|
+
*/
|
|
51859
|
+
initAsset(asset) {
|
|
51860
|
+
this.count = asset.count;
|
|
51861
|
+
this._fullCount = asset.count;
|
|
51862
|
+
this.size = this.evalTextureSize(asset.count);
|
|
51863
|
+
this.buildColor(asset);
|
|
51864
|
+
this.buildTransform(asset);
|
|
51865
|
+
this.texParams = new Float32Array([this.count, this.size.x, this.count, 1]);
|
|
51866
|
+
this._positions = asset.position;
|
|
51867
|
+
const total = this.size.x * this.size.y;
|
|
51868
|
+
this._orderData = new Uint32Array(total * 4);
|
|
51869
|
+
for (let i = 0; i < total; i++) {
|
|
51870
|
+
const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
|
|
51871
|
+
const base = i * 4;
|
|
51872
|
+
this._orderData[base + 0] = src;
|
|
51873
|
+
this._orderData[base + 1] = 0;
|
|
51874
|
+
this._orderData[base + 2] = 0;
|
|
51875
|
+
this._orderData[base + 3] = 0;
|
|
51876
|
+
}
|
|
51877
|
+
this.splatOrder = new Uint32ArrayTexture().create(this.size.x, this.size.y, this._orderData);
|
|
51878
|
+
this.splatOrder.name = "splatOrder";
|
|
51879
|
+
this.splatOrder.minFilter = "nearest";
|
|
51880
|
+
this.splatOrder.magFilter = "nearest";
|
|
51881
|
+
this.splatOrder.addressModeU = "clamp-to-edge";
|
|
51882
|
+
this.splatOrder.addressModeV = "clamp-to-edge";
|
|
51883
|
+
this.gsplatMaterial = new GSplatMaterial();
|
|
51884
|
+
this.geometry = new PlaneGeometry(1, 1, 1, 1);
|
|
51885
|
+
this.materials = [this.gsplatMaterial];
|
|
51886
|
+
}
|
|
51887
|
+
/**
|
|
51888
|
+
* Update splat sorting before rendering
|
|
51889
|
+
* This runs every frame to ensure correct depth ordering for alpha blending
|
|
51890
|
+
*/
|
|
51891
|
+
onBeforeUpdate(view) {
|
|
51892
|
+
if (this.count > 0 && view?.camera?.viewMatrix) {
|
|
51893
|
+
this.scheduleOrder(view.camera.viewMatrix);
|
|
51894
|
+
}
|
|
51895
|
+
}
|
|
51896
|
+
/**
|
|
51897
|
+
* Set rendering subset mapping
|
|
51898
|
+
* Pass null/undefined to cancel mapping
|
|
51899
|
+
*/
|
|
51900
|
+
setMapping(mapping) {
|
|
51901
|
+
this._mapping = mapping && mapping.length > 0 ? mapping : null;
|
|
51902
|
+
this.count = this._mapping ? this._mapping.length : this._fullCount;
|
|
51903
|
+
this.texParams[0] = this.count;
|
|
51904
|
+
this.texParams[2] = Math.min(this.texParams[0], this.count);
|
|
51905
|
+
const total = this.size.x * this.size.y;
|
|
51906
|
+
for (let i = 0; i < total; i++) {
|
|
51907
|
+
const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
|
|
51908
|
+
const base = i * 4;
|
|
51909
|
+
this._orderData[base + 0] = src;
|
|
51910
|
+
this._orderData[base + 1] = 0;
|
|
51911
|
+
this._orderData[base + 2] = 0;
|
|
51912
|
+
this._orderData[base + 3] = 0;
|
|
51913
|
+
}
|
|
51914
|
+
this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
|
|
51915
|
+
if (this._sortWorker) {
|
|
51916
|
+
const worldPos = this._worldPositions || this._positions;
|
|
51917
|
+
const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
|
|
51918
|
+
if (this._mapping) {
|
|
51919
|
+
for (let i = 0; i < this._mapping.length; ++i) {
|
|
51920
|
+
const src = this._mapping[i] * 3;
|
|
51921
|
+
const dst = i * 3;
|
|
51922
|
+
centers[dst + 0] = worldPos[src + 0];
|
|
51923
|
+
centers[dst + 1] = worldPos[src + 1];
|
|
51924
|
+
centers[dst + 2] = worldPos[src + 2];
|
|
51925
|
+
}
|
|
51926
|
+
}
|
|
51927
|
+
this._sortWorker.postMessage(
|
|
51928
|
+
{
|
|
51929
|
+
type: "centers",
|
|
51930
|
+
centers: centers.buffer,
|
|
51931
|
+
mapping: this._mapping ? this._mapping : null
|
|
51932
|
+
},
|
|
51933
|
+
[centers.buffer]
|
|
51934
|
+
);
|
|
51935
|
+
this._centersSent = true;
|
|
51936
|
+
} else {
|
|
51937
|
+
this._centersSent = false;
|
|
51938
|
+
}
|
|
51939
|
+
}
|
|
51940
|
+
/**
|
|
51941
|
+
* Set visibility boost factor (material uniform tex_params.w)
|
|
51942
|
+
*/
|
|
51943
|
+
setVisBoost(v) {
|
|
51944
|
+
this.texParams[3] = Math.max(0, v);
|
|
51945
|
+
}
|
|
51946
|
+
/**
|
|
51947
|
+
* Set sort throttle interval (milliseconds)
|
|
51948
|
+
*/
|
|
51949
|
+
setSortThrottle(ms) {
|
|
51950
|
+
this._minIntervalMs = Math.max(0, ms | 0);
|
|
51951
|
+
}
|
|
51952
|
+
/**
|
|
51953
|
+
* Calculate texture size for given splat count
|
|
51954
|
+
*/
|
|
51955
|
+
evalTextureSize(count) {
|
|
51956
|
+
let w = Math.ceil(Math.sqrt(count));
|
|
51957
|
+
const align = 64;
|
|
51958
|
+
w = Math.ceil(w / align) * align;
|
|
51959
|
+
const h = Math.ceil(count / w);
|
|
51960
|
+
return new Vector2(w, h);
|
|
51961
|
+
}
|
|
51962
|
+
/**
|
|
51963
|
+
* Build color texture from asset
|
|
51964
|
+
*/
|
|
51965
|
+
buildColor(asset) {
|
|
51966
|
+
const w = this.size.x | 0;
|
|
51967
|
+
const h = this.size.y | 0;
|
|
51968
|
+
const data = new Uint8Array(w * h * 4);
|
|
51969
|
+
const SH_C0 = 0.28209479177387814;
|
|
51970
|
+
const count = asset.count;
|
|
51971
|
+
const coeffs = asset.sh?.coeffs;
|
|
51972
|
+
const coeffsPerColor = coeffs ? coeffs.length / (3 * count) : 1;
|
|
51973
|
+
for (let i = 0; i < count; i++) {
|
|
51974
|
+
let r = 0.5, g = 0.5, b = 0.5;
|
|
51975
|
+
if (coeffs && coeffsPerColor >= 1) {
|
|
51976
|
+
const baseIndex = i * coeffsPerColor * 3;
|
|
51977
|
+
r = 0.5 + coeffs[baseIndex + 0] * SH_C0;
|
|
51978
|
+
g = 0.5 + coeffs[baseIndex + coeffsPerColor + 0] * SH_C0;
|
|
51979
|
+
b = 0.5 + coeffs[baseIndex + 2 * coeffsPerColor + 0] * SH_C0;
|
|
51980
|
+
}
|
|
51981
|
+
const a = asset.opacity ? 1 / (1 + Math.exp(-asset.opacity[i])) : 1;
|
|
51982
|
+
const idx = i * 4;
|
|
51983
|
+
data[idx + 0] = Math.max(0, Math.min(255, Math.floor(r * 255)));
|
|
51984
|
+
data[idx + 1] = Math.max(0, Math.min(255, Math.floor(g * 255)));
|
|
51985
|
+
data[idx + 2] = Math.max(0, Math.min(255, Math.floor(b * 255)));
|
|
51986
|
+
data[idx + 3] = Math.max(0, Math.min(255, Math.floor(a * 255)));
|
|
51987
|
+
}
|
|
51988
|
+
this.splatColor = new Uint8ArrayTexture().create(w, h, data, false);
|
|
51989
|
+
this.splatColor.name = "splatColor";
|
|
51990
|
+
this.splatColor.minFilter = "nearest";
|
|
51991
|
+
this.splatColor.magFilter = "nearest";
|
|
51992
|
+
this.splatColor.mipmapFilter = "nearest";
|
|
51993
|
+
this.splatColor.addressModeU = "clamp-to-edge";
|
|
51994
|
+
this.splatColor.addressModeV = "clamp-to-edge";
|
|
51995
|
+
}
|
|
51996
|
+
/**
|
|
51997
|
+
* Build transform textures from asset
|
|
51998
|
+
*/
|
|
51999
|
+
buildTransform(asset) {
|
|
52000
|
+
const w = this.size.x | 0;
|
|
52001
|
+
const h = this.size.y | 0;
|
|
52002
|
+
const count = asset.count;
|
|
52003
|
+
const tA = new Uint32Array(w * h * 4);
|
|
52004
|
+
const tB = new Array(w * h * 4).fill(0);
|
|
52005
|
+
const fb = new ArrayBuffer(4);
|
|
52006
|
+
const f32 = new Float32Array(fb);
|
|
52007
|
+
const u32 = new Uint32Array(fb);
|
|
52008
|
+
const setFloatBits = (v) => {
|
|
52009
|
+
f32[0] = v;
|
|
52010
|
+
return u32[0];
|
|
52011
|
+
};
|
|
52012
|
+
const pos = asset.position;
|
|
52013
|
+
const rot = asset.rotation;
|
|
52014
|
+
const scl = asset.scale;
|
|
52015
|
+
let maxScale = 0;
|
|
52016
|
+
let minScale = Infinity;
|
|
52017
|
+
let maxCov = 0;
|
|
52018
|
+
for (let i = 0; i < count; i++) {
|
|
52019
|
+
const idx = i * 4;
|
|
52020
|
+
const x = pos[i * 3 + 0];
|
|
52021
|
+
const y = pos[i * 3 + 1];
|
|
52022
|
+
const z = pos[i * 3 + 2];
|
|
52023
|
+
tA[idx + 0] = setFloatBits(x);
|
|
52024
|
+
tA[idx + 1] = setFloatBits(y);
|
|
52025
|
+
tA[idx + 2] = setFloatBits(z);
|
|
52026
|
+
let qx = 0, qy = 0, qz = 0, qw = 1;
|
|
52027
|
+
if (rot) {
|
|
52028
|
+
qx = rot[i * 4 + 0];
|
|
52029
|
+
qy = rot[i * 4 + 1];
|
|
52030
|
+
qz = rot[i * 4 + 2];
|
|
52031
|
+
qw = rot[i * 4 + 3];
|
|
52032
|
+
const inv = 1 / Math.hypot(qx, qy, qz, qw);
|
|
52033
|
+
qx *= inv;
|
|
52034
|
+
qy *= inv;
|
|
52035
|
+
qz *= inv;
|
|
52036
|
+
qw *= inv;
|
|
52037
|
+
}
|
|
52038
|
+
let sx = 1, sy = 1, sz = 1;
|
|
52039
|
+
if (scl) {
|
|
52040
|
+
sx = Math.exp(scl[i * 3 + 0]);
|
|
52041
|
+
sy = Math.exp(scl[i * 3 + 1]);
|
|
52042
|
+
sz = Math.exp(scl[i * 3 + 2]);
|
|
52043
|
+
maxScale = Math.max(maxScale, sx, sy, sz);
|
|
52044
|
+
minScale = Math.min(minScale, sx, sy, sz);
|
|
52045
|
+
}
|
|
52046
|
+
const xx = qx * qx, yy = qy * qy, zz = qz * qz;
|
|
52047
|
+
const xy = qx * qy, xz = qx * qz, yz = qy * qz;
|
|
52048
|
+
const wx = qw * qx, wy = qw * qy, wz = qw * qz;
|
|
52049
|
+
const m00 = 1 - 2 * (yy + zz);
|
|
52050
|
+
const m01 = 2 * (xy + wz);
|
|
52051
|
+
const m02 = 2 * (xz - wy);
|
|
52052
|
+
const m10 = 2 * (xy - wz);
|
|
52053
|
+
const m11 = 1 - 2 * (xx + zz);
|
|
52054
|
+
const m12 = 2 * (yz + wx);
|
|
52055
|
+
const m20 = 2 * (xz + wy);
|
|
52056
|
+
const m21 = 2 * (yz - wx);
|
|
52057
|
+
const m22 = 1 - 2 * (xx + yy);
|
|
52058
|
+
const r00 = m00 * sx, r01 = m01 * sx, r02 = m02 * sx;
|
|
52059
|
+
const r10 = m10 * sy, r11 = m11 * sy, r12 = m12 * sy;
|
|
52060
|
+
const r20 = m20 * sz, r21 = m21 * sz, r22 = m22 * sz;
|
|
52061
|
+
const cAx = r00 * r00 + r10 * r10 + r20 * r20;
|
|
52062
|
+
const cAy = r00 * r01 + r10 * r11 + r20 * r21;
|
|
52063
|
+
const cAz = r00 * r02 + r10 * r12 + r20 * r22;
|
|
52064
|
+
const cBx = r01 * r01 + r11 * r11 + r21 * r21;
|
|
52065
|
+
const cBy = r01 * r02 + r11 * r12 + r21 * r22;
|
|
52066
|
+
const cBz = r02 * r02 + r12 * r12 + r22 * r22;
|
|
52067
|
+
maxCov = Math.max(
|
|
52068
|
+
maxCov,
|
|
52069
|
+
Math.abs(cAx),
|
|
52070
|
+
Math.abs(cAy),
|
|
52071
|
+
Math.abs(cAz),
|
|
52072
|
+
Math.abs(cBx),
|
|
52073
|
+
Math.abs(cBy),
|
|
52074
|
+
Math.abs(cBz)
|
|
52075
|
+
);
|
|
52076
|
+
const bidx = idx;
|
|
52077
|
+
tB[bidx + 0] = cAx;
|
|
52078
|
+
tB[bidx + 1] = cAy;
|
|
52079
|
+
tB[bidx + 2] = cAz;
|
|
52080
|
+
tB[bidx + 3] = cBz;
|
|
52081
|
+
const hx = toHalfFloat(cBx) & 65535;
|
|
52082
|
+
const hy = toHalfFloat(cBy) & 65535;
|
|
52083
|
+
tA[idx + 3] = hx | hy << 16;
|
|
52084
|
+
}
|
|
52085
|
+
console.group("🔍 GSplat Data Statistics");
|
|
52086
|
+
console.log("Splat count:", count);
|
|
52087
|
+
console.log("Scale range:", minScale.toFixed(4), "~", maxScale.toFixed(4));
|
|
52088
|
+
console.log("Max covariance:", maxCov.toFixed(4));
|
|
52089
|
+
if (maxScale > 50) {
|
|
52090
|
+
console.error("❌ CRITICAL: Scale values are too large! This causes spikes.");
|
|
52091
|
+
console.log("💡 Try reducing visBoost or clamping scale values");
|
|
52092
|
+
} else if (maxScale > 20) {
|
|
52093
|
+
console.warn("⚠️ WARNING: Scale values are large. May cause rendering issues.");
|
|
52094
|
+
} else {
|
|
52095
|
+
console.log("✅ Scale values look normal");
|
|
52096
|
+
}
|
|
52097
|
+
if (maxCov > 100) {
|
|
52098
|
+
console.error("❌ CRITICAL: Covariance values are too large!");
|
|
52099
|
+
} else if (maxCov > 50) {
|
|
52100
|
+
console.warn("⚠️ WARNING: Covariance values are large.");
|
|
52101
|
+
} else {
|
|
52102
|
+
console.log("✅ Covariance values look normal");
|
|
52103
|
+
}
|
|
52104
|
+
console.groupEnd();
|
|
52105
|
+
this.transformA = new Uint32ArrayTexture().create(w, h, tA);
|
|
52106
|
+
this.transformA.name = "transformA";
|
|
52107
|
+
this.transformA.minFilter = "nearest";
|
|
52108
|
+
this.transformA.magFilter = "nearest";
|
|
52109
|
+
this.transformA.addressModeU = "clamp-to-edge";
|
|
52110
|
+
this.transformA.addressModeV = "clamp-to-edge";
|
|
52111
|
+
this.transformB = new Float16ArrayTexture().create(w, h, tB, false);
|
|
52112
|
+
this.transformB.name = "transformB";
|
|
52113
|
+
this.transformB.minFilter = "nearest";
|
|
52114
|
+
this.transformB.magFilter = "nearest";
|
|
52115
|
+
this.transformB.mipmapFilter = "nearest";
|
|
52116
|
+
this.transformB.addressModeU = "clamp-to-edge";
|
|
52117
|
+
this.transformB.addressModeV = "clamp-to-edge";
|
|
52118
|
+
}
|
|
52119
|
+
/**
|
|
52120
|
+
* Update world space positions when transform changes
|
|
52121
|
+
*/
|
|
52122
|
+
updateWorldPositions() {
|
|
52123
|
+
if (!this._positions) return;
|
|
52124
|
+
const worldMatrix = this.object3D.transform.worldMatrix;
|
|
52125
|
+
const localPos = this._positions;
|
|
52126
|
+
const count = this._fullCount;
|
|
52127
|
+
if (!this._worldPositions) {
|
|
52128
|
+
this._worldPositions = new Float32Array(localPos.length);
|
|
52129
|
+
}
|
|
52130
|
+
const m = worldMatrix.rawData;
|
|
52131
|
+
for (let i = 0; i < count; i++) {
|
|
52132
|
+
const idx = i * 3;
|
|
52133
|
+
const x = localPos[idx + 0];
|
|
52134
|
+
const y = localPos[idx + 1];
|
|
52135
|
+
const z = localPos[idx + 2];
|
|
52136
|
+
this._worldPositions[idx + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
52137
|
+
this._worldPositions[idx + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
52138
|
+
this._worldPositions[idx + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
52139
|
+
}
|
|
52140
|
+
this._centersSent = false;
|
|
52141
|
+
}
|
|
52142
|
+
/**
|
|
52143
|
+
* Schedule Web Worker-based sorting task
|
|
52144
|
+
*/
|
|
52145
|
+
scheduleOrder(viewMatrix) {
|
|
52146
|
+
if (this.count === 0) return;
|
|
52147
|
+
const transformChanged = this.object3D.transform.localChange;
|
|
52148
|
+
if (transformChanged || !this._worldPositions) {
|
|
52149
|
+
this.updateWorldPositions();
|
|
52150
|
+
}
|
|
52151
|
+
const r = viewMatrix.rawData;
|
|
52152
|
+
const vx = r[2], vy = r[6], vz = r[10];
|
|
52153
|
+
const px = -(r[0] * r[12] + r[1] * r[13] + r[2] * r[14]);
|
|
52154
|
+
const py = -(r[4] * r[12] + r[5] * r[13] + r[6] * r[14]);
|
|
52155
|
+
const pz = -(r[8] * r[12] + r[9] * r[13] + r[10] * r[14]);
|
|
52156
|
+
const posHash = Math.floor(px * 1e3) ^ Math.floor(py * 1e3) ^ Math.floor(pz * 1e3);
|
|
52157
|
+
const dirHash = Math.floor(vx * 1e3) ^ Math.floor(vy * 1e3) ^ Math.floor(vz * 1e3);
|
|
52158
|
+
const hash = posHash ^ dirHash;
|
|
52159
|
+
if (hash === this._lastViewMatrixHash && !transformChanged) {
|
|
52160
|
+
return;
|
|
52161
|
+
}
|
|
52162
|
+
this._lastViewMatrixHash = hash;
|
|
52163
|
+
const now = performance.now();
|
|
52164
|
+
if (now - this._lastSentTime < this._minIntervalMs) return;
|
|
52165
|
+
this._lastSentTime = now;
|
|
52166
|
+
if (!this._sortWorker) {
|
|
52167
|
+
this._sortWorker = this.createSortWorker();
|
|
52168
|
+
this._sortWorker.onmessage = (ev) => {
|
|
52169
|
+
const newOrder = ev.data.order;
|
|
52170
|
+
const oldOrder = this._orderData.buffer;
|
|
52171
|
+
this._sortWorker.postMessage({
|
|
52172
|
+
order: oldOrder
|
|
52173
|
+
}, [oldOrder]);
|
|
52174
|
+
const indices = new Uint32Array(newOrder);
|
|
52175
|
+
const total = this.size.x * this.size.y;
|
|
52176
|
+
const count = this.count;
|
|
52177
|
+
this._orderData = new Uint32Array(total * 4);
|
|
52178
|
+
for (let i = 0; i < total; i++) {
|
|
52179
|
+
const src = i < count ? indices[i] : count > 0 ? count - 1 : 0;
|
|
52180
|
+
const base = i * 4;
|
|
52181
|
+
this._orderData[base + 0] = src;
|
|
52182
|
+
this._orderData[base + 1] = 0;
|
|
52183
|
+
this._orderData[base + 2] = 0;
|
|
52184
|
+
this._orderData[base + 3] = 0;
|
|
52185
|
+
}
|
|
52186
|
+
this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
|
|
52187
|
+
const valid = Math.max(0, Math.min(this.count, ev.data.count | 0));
|
|
52188
|
+
this.texParams[2] = valid;
|
|
52189
|
+
};
|
|
52190
|
+
const worldPos = this._worldPositions || this._positions;
|
|
52191
|
+
const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
|
|
52192
|
+
if (this._mapping) {
|
|
52193
|
+
for (let i = 0; i < this._mapping.length; ++i) {
|
|
52194
|
+
const src = this._mapping[i] * 3;
|
|
52195
|
+
const dst = i * 3;
|
|
52196
|
+
centers[dst + 0] = worldPos[src + 0];
|
|
52197
|
+
centers[dst + 1] = worldPos[src + 1];
|
|
52198
|
+
centers[dst + 2] = worldPos[src + 2];
|
|
52199
|
+
}
|
|
52200
|
+
}
|
|
52201
|
+
const orderBuffer = new Uint32Array(this.count);
|
|
52202
|
+
for (let i = 0; i < this.count; i++) {
|
|
52203
|
+
orderBuffer[i] = i;
|
|
52204
|
+
}
|
|
52205
|
+
this._sortWorker.postMessage({
|
|
52206
|
+
order: orderBuffer.buffer,
|
|
52207
|
+
centers: centers.buffer,
|
|
52208
|
+
mapping: this._mapping
|
|
52209
|
+
}, [orderBuffer.buffer, centers.buffer]);
|
|
52210
|
+
this._centersSent = true;
|
|
52211
|
+
}
|
|
52212
|
+
if (!this._centersSent && this._sortWorker) {
|
|
52213
|
+
const worldPos = this._worldPositions || this._positions;
|
|
52214
|
+
const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
|
|
52215
|
+
if (this._mapping) {
|
|
52216
|
+
for (let i = 0; i < this._mapping.length; ++i) {
|
|
52217
|
+
const src = this._mapping[i] * 3;
|
|
52218
|
+
const dst = i * 3;
|
|
52219
|
+
centers[dst + 0] = worldPos[src + 0];
|
|
52220
|
+
centers[dst + 1] = worldPos[src + 1];
|
|
52221
|
+
centers[dst + 2] = worldPos[src + 2];
|
|
52222
|
+
}
|
|
52223
|
+
}
|
|
52224
|
+
this._sortWorker.postMessage({
|
|
52225
|
+
type: "centers",
|
|
52226
|
+
centers: centers.buffer,
|
|
52227
|
+
mapping: this._mapping ? this._mapping : null
|
|
52228
|
+
}, [centers.buffer]);
|
|
52229
|
+
this._centersSent = true;
|
|
52230
|
+
}
|
|
52231
|
+
this._sortWorker.postMessage({
|
|
52232
|
+
cameraPosition: { x: px, y: py, z: pz },
|
|
52233
|
+
cameraDirection: { x: -vx, y: -vy, z: -vz }
|
|
52234
|
+
});
|
|
52235
|
+
}
|
|
52236
|
+
/**
|
|
52237
|
+
* Create Web Worker for sorting
|
|
52238
|
+
*/
|
|
52239
|
+
createSortWorker() {
|
|
52240
|
+
function SortWorker() {
|
|
52241
|
+
const compareBits = 16;
|
|
52242
|
+
const bucketCount = 2 ** compareBits + 1;
|
|
52243
|
+
let order;
|
|
52244
|
+
let centers;
|
|
52245
|
+
let mapping;
|
|
52246
|
+
let cameraPosition;
|
|
52247
|
+
let cameraDirection;
|
|
52248
|
+
let forceUpdate = false;
|
|
52249
|
+
const lastCameraPosition = { x: 0, y: 0, z: 0 };
|
|
52250
|
+
const lastCameraDirection = { x: 0, y: 0, z: 0 };
|
|
52251
|
+
const boundMin = { x: 0, y: 0, z: 0 };
|
|
52252
|
+
const boundMax = { x: 0, y: 0, z: 0 };
|
|
52253
|
+
let distances;
|
|
52254
|
+
let countBuffer;
|
|
52255
|
+
const binarySearch = (m, n, compare_fn) => {
|
|
52256
|
+
while (m <= n) {
|
|
52257
|
+
const k = n + m >> 1;
|
|
52258
|
+
const cmp = compare_fn(k);
|
|
52259
|
+
if (cmp > 0) {
|
|
52260
|
+
m = k + 1;
|
|
52261
|
+
} else if (cmp < 0) {
|
|
52262
|
+
n = k - 1;
|
|
52263
|
+
} else {
|
|
52264
|
+
return k;
|
|
52265
|
+
}
|
|
52266
|
+
}
|
|
52267
|
+
return ~m;
|
|
52268
|
+
};
|
|
52269
|
+
const update = () => {
|
|
52270
|
+
if (!order || !centers || !cameraPosition || !cameraDirection) return;
|
|
52271
|
+
const px = cameraPosition.x;
|
|
52272
|
+
const py = cameraPosition.y;
|
|
52273
|
+
const pz = cameraPosition.z;
|
|
52274
|
+
const dx = cameraDirection.x;
|
|
52275
|
+
const dy = cameraDirection.y;
|
|
52276
|
+
const dz = cameraDirection.z;
|
|
52277
|
+
const epsilon = 1e-3;
|
|
52278
|
+
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) {
|
|
52279
|
+
return;
|
|
52280
|
+
}
|
|
52281
|
+
forceUpdate = false;
|
|
52282
|
+
lastCameraPosition.x = px;
|
|
52283
|
+
lastCameraPosition.y = py;
|
|
52284
|
+
lastCameraPosition.z = pz;
|
|
52285
|
+
lastCameraDirection.x = dx;
|
|
52286
|
+
lastCameraDirection.y = dy;
|
|
52287
|
+
lastCameraDirection.z = dz;
|
|
52288
|
+
const numVertices = centers.length / 3;
|
|
52289
|
+
if (distances?.length !== numVertices) {
|
|
52290
|
+
distances = new Uint32Array(numVertices);
|
|
52291
|
+
}
|
|
52292
|
+
let minDist;
|
|
52293
|
+
let maxDist;
|
|
52294
|
+
for (let i = 0; i < 8; ++i) {
|
|
52295
|
+
const x = (i & 1 ? boundMin.x : boundMax.x) - px;
|
|
52296
|
+
const y = (i & 2 ? boundMin.y : boundMax.y) - py;
|
|
52297
|
+
const z = (i & 4 ? boundMin.z : boundMax.z) - pz;
|
|
52298
|
+
const d = x * dx + y * dy + z * dz;
|
|
52299
|
+
if (i === 0) {
|
|
52300
|
+
minDist = maxDist = d;
|
|
52301
|
+
} else {
|
|
52302
|
+
minDist = Math.min(minDist, d);
|
|
52303
|
+
maxDist = Math.max(maxDist, d);
|
|
52304
|
+
}
|
|
52305
|
+
}
|
|
52306
|
+
if (!countBuffer) {
|
|
52307
|
+
countBuffer = new Uint32Array(bucketCount);
|
|
52308
|
+
} else {
|
|
52309
|
+
countBuffer.fill(0);
|
|
52310
|
+
}
|
|
52311
|
+
const range = maxDist - minDist;
|
|
52312
|
+
const divider = range < 1e-6 ? 0 : 1 / range * 2 ** compareBits;
|
|
52313
|
+
for (let i = 0; i < numVertices; ++i) {
|
|
52314
|
+
const istride = i * 3;
|
|
52315
|
+
const x = centers[istride + 0] - px;
|
|
52316
|
+
const y = centers[istride + 1] - py;
|
|
52317
|
+
const z = centers[istride + 2] - pz;
|
|
52318
|
+
const d = x * dx + y * dy + z * dz;
|
|
52319
|
+
const sortKey = Math.floor((d - minDist) * divider);
|
|
52320
|
+
distances[i] = sortKey;
|
|
52321
|
+
countBuffer[sortKey]++;
|
|
52322
|
+
}
|
|
52323
|
+
for (let i = 1; i < bucketCount; i++) {
|
|
52324
|
+
countBuffer[i] += countBuffer[i - 1];
|
|
52325
|
+
}
|
|
52326
|
+
for (let i = 0; i < numVertices; i++) {
|
|
52327
|
+
const distance = distances[i];
|
|
52328
|
+
const destIndex = --countBuffer[distance];
|
|
52329
|
+
order[destIndex] = i;
|
|
52330
|
+
}
|
|
52331
|
+
const dist = (i) => distances[order[i]] / divider + minDist;
|
|
52332
|
+
const findZero = () => {
|
|
52333
|
+
const result = binarySearch(0, numVertices - 1, (i) => -dist(i));
|
|
52334
|
+
return Math.min(numVertices, Math.abs(result));
|
|
52335
|
+
};
|
|
52336
|
+
const count = dist(numVertices - 1) >= 0 ? findZero() : numVertices;
|
|
52337
|
+
if (mapping) {
|
|
52338
|
+
for (let i = 0; i < numVertices; ++i) {
|
|
52339
|
+
order[i] = mapping[order[i]];
|
|
52340
|
+
}
|
|
52341
|
+
}
|
|
52342
|
+
self.postMessage({
|
|
52343
|
+
order: order.buffer,
|
|
52344
|
+
count
|
|
52345
|
+
}, [order.buffer]);
|
|
52346
|
+
order = null;
|
|
52347
|
+
};
|
|
52348
|
+
self.onmessage = (message) => {
|
|
52349
|
+
if (message.data.order) {
|
|
52350
|
+
order = new Uint32Array(message.data.order);
|
|
52351
|
+
}
|
|
52352
|
+
if (message.data.centers) {
|
|
52353
|
+
centers = new Float32Array(message.data.centers);
|
|
52354
|
+
boundMin.x = boundMax.x = centers[0];
|
|
52355
|
+
boundMin.y = boundMax.y = centers[1];
|
|
52356
|
+
boundMin.z = boundMax.z = centers[2];
|
|
52357
|
+
const numVertices = centers.length / 3;
|
|
52358
|
+
for (let i = 1; i < numVertices; ++i) {
|
|
52359
|
+
const x = centers[i * 3 + 0];
|
|
52360
|
+
const y = centers[i * 3 + 1];
|
|
52361
|
+
const z = centers[i * 3 + 2];
|
|
52362
|
+
boundMin.x = Math.min(boundMin.x, x);
|
|
52363
|
+
boundMin.y = Math.min(boundMin.y, y);
|
|
52364
|
+
boundMin.z = Math.min(boundMin.z, z);
|
|
52365
|
+
boundMax.x = Math.max(boundMax.x, x);
|
|
52366
|
+
boundMax.y = Math.max(boundMax.y, y);
|
|
52367
|
+
boundMax.z = Math.max(boundMax.z, z);
|
|
52368
|
+
}
|
|
52369
|
+
forceUpdate = true;
|
|
52370
|
+
}
|
|
52371
|
+
if (message.data.hasOwnProperty("mapping")) {
|
|
52372
|
+
mapping = message.data.mapping ? new Uint32Array(message.data.mapping) : null;
|
|
52373
|
+
forceUpdate = true;
|
|
52374
|
+
}
|
|
52375
|
+
if (message.data.cameraPosition) cameraPosition = message.data.cameraPosition;
|
|
52376
|
+
if (message.data.cameraDirection) cameraDirection = message.data.cameraDirection;
|
|
52377
|
+
update();
|
|
52378
|
+
};
|
|
52379
|
+
}
|
|
52380
|
+
const code = `(${SortWorker.toString()})()`;
|
|
52381
|
+
const blob = new Blob([code], { type: "application/javascript" });
|
|
52382
|
+
const url = URL.createObjectURL(blob);
|
|
52383
|
+
return new Worker(url);
|
|
52384
|
+
}
|
|
52385
|
+
/**
|
|
52386
|
+
* Update node before rendering
|
|
52387
|
+
*/
|
|
52388
|
+
nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
|
|
52389
|
+
const worldMatrix = this.object3D.transform.worldMatrix;
|
|
52390
|
+
this.gsplatMaterial.setTransformMatrix(worldMatrix);
|
|
52391
|
+
this.gsplatMaterial.setSplatTextures(
|
|
52392
|
+
this.splatColor,
|
|
52393
|
+
this.transformA,
|
|
52394
|
+
this.transformB,
|
|
52395
|
+
this.texParams,
|
|
52396
|
+
this.splatOrder
|
|
52397
|
+
);
|
|
52398
|
+
super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
|
|
52399
|
+
}
|
|
52400
|
+
/**
|
|
52401
|
+
* Render pass
|
|
52402
|
+
*/
|
|
52403
|
+
renderPass2(view, passType, rendererPassState, clusterLightingBuffer, encoder, useBundle = false) {
|
|
52404
|
+
for (let mat of this.materials) {
|
|
52405
|
+
const passes = mat.getPass(passType);
|
|
52406
|
+
if (!passes || passes.length === 0) continue;
|
|
52407
|
+
for (const pass of passes) {
|
|
52408
|
+
if (!pass.pipeline) continue;
|
|
52409
|
+
pass.apply(this.geometry, rendererPassState);
|
|
52410
|
+
GPUContext.bindPipeline(encoder, pass);
|
|
52411
|
+
GPUContext.draw(encoder, 4, this.count, 0, 0);
|
|
52412
|
+
}
|
|
52413
|
+
}
|
|
52414
|
+
}
|
|
52415
|
+
/**
|
|
52416
|
+
* Render pass (fallback)
|
|
52417
|
+
*/
|
|
52418
|
+
renderPass(view, passType, renderContext) {
|
|
52419
|
+
const encoder = renderContext.encoder;
|
|
52420
|
+
for (let mat of this.materials) {
|
|
52421
|
+
const passes = mat.getPass(passType);
|
|
52422
|
+
if (!passes || passes.length === 0) continue;
|
|
52423
|
+
for (const pass of passes) {
|
|
52424
|
+
if (!pass.pipeline) continue;
|
|
52425
|
+
pass.apply(this.geometry, renderContext.rendererPassState || renderContext);
|
|
52426
|
+
GPUContext.bindPipeline(encoder, pass);
|
|
52427
|
+
GPUContext.draw(encoder, 4, this.count, 0, 0);
|
|
52428
|
+
}
|
|
52429
|
+
}
|
|
52430
|
+
}
|
|
52431
|
+
/**
|
|
52432
|
+
* Clean up resources
|
|
52433
|
+
*/
|
|
52434
|
+
destroy(force) {
|
|
52435
|
+
if (this._sortWorker) {
|
|
52436
|
+
this._sortWorker.terminate();
|
|
52437
|
+
this._sortWorker = null;
|
|
52438
|
+
}
|
|
52439
|
+
super.destroy(force);
|
|
52440
|
+
}
|
|
52441
|
+
};
|
|
52442
|
+
exports.GSplatRenderer = __decorateClass$6([
|
|
52443
|
+
RegisterComponent(exports.GSplatRenderer, "GSplatRenderer")
|
|
52444
|
+
], exports.GSplatRenderer);
|
|
52445
|
+
|
|
50659
52446
|
class Probe extends exports.Object3D {
|
|
50660
52447
|
index = 0;
|
|
50661
52448
|
drawCallFrame = -1;
|
|
@@ -55911,6 +57698,298 @@ fn frag(){
|
|
|
55911
57698
|
}
|
|
55912
57699
|
}
|
|
55913
57700
|
|
|
57701
|
+
function computeAABBFromPositions(position) {
|
|
57702
|
+
const min = [Infinity, Infinity, Infinity];
|
|
57703
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
57704
|
+
for (let i = 0; i < position.length; i += 3) {
|
|
57705
|
+
const x = position[i + 0];
|
|
57706
|
+
const y = position[i + 1];
|
|
57707
|
+
const z = position[i + 2];
|
|
57708
|
+
if (x < min[0]) min[0] = x;
|
|
57709
|
+
if (y < min[1]) min[1] = y;
|
|
57710
|
+
if (z < min[2]) min[2] = z;
|
|
57711
|
+
if (x > max[0]) max[0] = x;
|
|
57712
|
+
if (y > max[1]) max[1] = y;
|
|
57713
|
+
if (z > max[2]) max[2] = z;
|
|
57714
|
+
}
|
|
57715
|
+
return { min, max };
|
|
57716
|
+
}
|
|
57717
|
+
|
|
57718
|
+
var GSplatFormat = /* @__PURE__ */ ((GSplatFormat2) => {
|
|
57719
|
+
GSplatFormat2["PLY"] = "ply";
|
|
57720
|
+
GSplatFormat2["SPLAT"] = "splat";
|
|
57721
|
+
GSplatFormat2["KSPLAT"] = "ksplat";
|
|
57722
|
+
GSplatFormat2["UNKNOWN"] = "unknown";
|
|
57723
|
+
return GSplatFormat2;
|
|
57724
|
+
})(GSplatFormat || {});
|
|
57725
|
+
function detectGSplatFormat(buffer) {
|
|
57726
|
+
if (buffer.byteLength < 16) {
|
|
57727
|
+
return "unknown" /* UNKNOWN */;
|
|
57728
|
+
}
|
|
57729
|
+
const headerBytes = new Uint8Array(buffer, 0, Math.min(512, buffer.byteLength));
|
|
57730
|
+
const headerText = new TextDecoder("utf-8").decode(headerBytes);
|
|
57731
|
+
if (headerText.startsWith("ply")) {
|
|
57732
|
+
return "ply" /* PLY */;
|
|
57733
|
+
}
|
|
57734
|
+
return "unknown" /* UNKNOWN */;
|
|
57735
|
+
}
|
|
57736
|
+
|
|
57737
|
+
function byteSizeOfType(t) {
|
|
57738
|
+
switch (t) {
|
|
57739
|
+
case "char":
|
|
57740
|
+
case "uchar":
|
|
57741
|
+
case "uint8":
|
|
57742
|
+
case "int8":
|
|
57743
|
+
return 1;
|
|
57744
|
+
case "short":
|
|
57745
|
+
case "ushort":
|
|
57746
|
+
case "int16":
|
|
57747
|
+
case "uint16":
|
|
57748
|
+
return 2;
|
|
57749
|
+
case "int":
|
|
57750
|
+
case "uint":
|
|
57751
|
+
case "int32":
|
|
57752
|
+
case "uint32":
|
|
57753
|
+
case "float":
|
|
57754
|
+
case "float32":
|
|
57755
|
+
return 4;
|
|
57756
|
+
case "double":
|
|
57757
|
+
case "float64":
|
|
57758
|
+
return 8;
|
|
57759
|
+
default:
|
|
57760
|
+
return 4;
|
|
57761
|
+
}
|
|
57762
|
+
}
|
|
57763
|
+
function readByType(view, offset, type) {
|
|
57764
|
+
switch (type) {
|
|
57765
|
+
case "char":
|
|
57766
|
+
case "int8":
|
|
57767
|
+
return view.getInt8(offset);
|
|
57768
|
+
case "uchar":
|
|
57769
|
+
case "uint8":
|
|
57770
|
+
return view.getUint8(offset);
|
|
57771
|
+
case "short":
|
|
57772
|
+
case "int16":
|
|
57773
|
+
return view.getInt16(offset, true);
|
|
57774
|
+
case "ushort":
|
|
57775
|
+
case "uint16":
|
|
57776
|
+
return view.getUint16(offset, true);
|
|
57777
|
+
case "int":
|
|
57778
|
+
case "int32":
|
|
57779
|
+
return view.getInt32(offset, true);
|
|
57780
|
+
case "uint":
|
|
57781
|
+
case "uint32":
|
|
57782
|
+
return view.getUint32(offset, true);
|
|
57783
|
+
case "double":
|
|
57784
|
+
case "float64":
|
|
57785
|
+
return view.getFloat64(offset, true);
|
|
57786
|
+
case "float":
|
|
57787
|
+
case "float32":
|
|
57788
|
+
default:
|
|
57789
|
+
return view.getFloat32(offset, true);
|
|
57790
|
+
}
|
|
57791
|
+
}
|
|
57792
|
+
function inferSHOrder(coeffsPerColor) {
|
|
57793
|
+
const root = Math.round(Math.sqrt(coeffsPerColor));
|
|
57794
|
+
return Math.max(0, root - 1);
|
|
57795
|
+
}
|
|
57796
|
+
|
|
57797
|
+
function parsePlyHeader(buffer) {
|
|
57798
|
+
const ascii = new TextDecoder("utf-8").decode(
|
|
57799
|
+
new Uint8Array(buffer, 0, Math.min(4096, buffer.byteLength))
|
|
57800
|
+
);
|
|
57801
|
+
if (!ascii.startsWith("ply")) {
|
|
57802
|
+
throw new Error("PLY: Unsupported format. Expecting PLY file.");
|
|
57803
|
+
}
|
|
57804
|
+
const headerEnd = ascii.indexOf("end_header\n");
|
|
57805
|
+
if (headerEnd < 0) {
|
|
57806
|
+
throw new Error("PLY: Invalid PLY header");
|
|
57807
|
+
}
|
|
57808
|
+
const headerText = ascii.substring(0, headerEnd + "end_header\n".length);
|
|
57809
|
+
const lines = headerText.split(/\r?\n/);
|
|
57810
|
+
let format = "";
|
|
57811
|
+
let vertexCount = 0;
|
|
57812
|
+
const properties = [];
|
|
57813
|
+
let inVertexElement = false;
|
|
57814
|
+
for (const line of lines) {
|
|
57815
|
+
if (line.startsWith("format ")) {
|
|
57816
|
+
format = line.split(/\s+/)[1];
|
|
57817
|
+
} else if (line.startsWith("element ")) {
|
|
57818
|
+
const toks = line.split(/\s+/);
|
|
57819
|
+
inVertexElement = toks[1] === "vertex";
|
|
57820
|
+
if (inVertexElement) vertexCount = parseInt(toks[2]);
|
|
57821
|
+
} else if (inVertexElement && line.startsWith("property ")) {
|
|
57822
|
+
const toks = line.split(/\s+/);
|
|
57823
|
+
const type = toks[1];
|
|
57824
|
+
const name = toks[2];
|
|
57825
|
+
properties.push({ name, type });
|
|
57826
|
+
}
|
|
57827
|
+
}
|
|
57828
|
+
if (format !== "binary_little_endian") {
|
|
57829
|
+
throw new Error("PLY: Only binary_little_endian PLY is supported");
|
|
57830
|
+
}
|
|
57831
|
+
return {
|
|
57832
|
+
format,
|
|
57833
|
+
vertexCount,
|
|
57834
|
+
properties,
|
|
57835
|
+
headerByteLength: headerText.length
|
|
57836
|
+
};
|
|
57837
|
+
}
|
|
57838
|
+
function parsePlyGaussianSplat(buffer) {
|
|
57839
|
+
const header = parsePlyHeader(buffer);
|
|
57840
|
+
const { vertexCount, properties, headerByteLength } = header;
|
|
57841
|
+
const payload = new DataView(buffer, headerByteLength);
|
|
57842
|
+
const has = (n) => properties.find((p) => p.name === n) != null;
|
|
57843
|
+
const propIndex = (n) => properties.findIndex((p) => p.name === n);
|
|
57844
|
+
const position = new Float32Array(vertexCount * 3);
|
|
57845
|
+
const scale = has("scale_0") ? new Float32Array(vertexCount * 3) : void 0;
|
|
57846
|
+
const rotation = has("rot_0") ? new Float32Array(vertexCount * 4) : void 0;
|
|
57847
|
+
const opacity = has("opacity") ? new Float32Array(vertexCount) : void 0;
|
|
57848
|
+
const dcIdx = [propIndex("f_dc_0"), propIndex("f_dc_1"), propIndex("f_dc_2")];
|
|
57849
|
+
const restIndices = [];
|
|
57850
|
+
for (let i = 0; i < properties.length; i++) {
|
|
57851
|
+
if (properties[i].name.startsWith("f_rest_")) restIndices.push(i);
|
|
57852
|
+
}
|
|
57853
|
+
const hasSH = dcIdx[0] >= 0 && dcIdx[1] >= 0 && dcIdx[2] >= 0;
|
|
57854
|
+
let shCoeffs = void 0;
|
|
57855
|
+
let shOrder = 0;
|
|
57856
|
+
if (hasSH) {
|
|
57857
|
+
const coeffsPerColor = 1 + restIndices.length / 3;
|
|
57858
|
+
shOrder = inferSHOrder(coeffsPerColor);
|
|
57859
|
+
shCoeffs = new Float32Array(vertexCount * coeffsPerColor * 3);
|
|
57860
|
+
}
|
|
57861
|
+
const propOffsets = [];
|
|
57862
|
+
let stride = 0;
|
|
57863
|
+
for (const p of properties) {
|
|
57864
|
+
propOffsets.push(stride);
|
|
57865
|
+
stride += byteSizeOfType(p.type);
|
|
57866
|
+
}
|
|
57867
|
+
let base = 0;
|
|
57868
|
+
for (let v = 0; v < vertexCount; v++) {
|
|
57869
|
+
const vOffset = base;
|
|
57870
|
+
const ix = propIndex("x");
|
|
57871
|
+
const iy = propIndex("y");
|
|
57872
|
+
const iz = propIndex("z");
|
|
57873
|
+
if (ix < 0 || iy < 0 || iz < 0) {
|
|
57874
|
+
throw new Error("PLY: Missing x/y/z for vertex");
|
|
57875
|
+
}
|
|
57876
|
+
position[v * 3 + 0] = readByType(payload, vOffset + propOffsets[ix], properties[ix].type);
|
|
57877
|
+
position[v * 3 + 1] = readByType(payload, vOffset + propOffsets[iy], properties[iy].type);
|
|
57878
|
+
position[v * 3 + 2] = readByType(payload, vOffset + propOffsets[iz], properties[iz].type);
|
|
57879
|
+
if (scale) {
|
|
57880
|
+
const s0 = propIndex("scale_0");
|
|
57881
|
+
const s1 = propIndex("scale_1");
|
|
57882
|
+
const s2 = propIndex("scale_2");
|
|
57883
|
+
scale[v * 3 + 0] = readByType(payload, vOffset + propOffsets[s0], properties[s0].type);
|
|
57884
|
+
scale[v * 3 + 1] = readByType(payload, vOffset + propOffsets[s1], properties[s1].type);
|
|
57885
|
+
scale[v * 3 + 2] = readByType(payload, vOffset + propOffsets[s2], properties[s2].type);
|
|
57886
|
+
}
|
|
57887
|
+
if (rotation) {
|
|
57888
|
+
const r0 = propIndex("rot_0");
|
|
57889
|
+
const r1 = propIndex("rot_1");
|
|
57890
|
+
const r2 = propIndex("rot_2");
|
|
57891
|
+
const r3 = propIndex("rot_3");
|
|
57892
|
+
rotation[v * 4 + 0] = readByType(payload, vOffset + propOffsets[r0], properties[r0].type);
|
|
57893
|
+
rotation[v * 4 + 1] = readByType(payload, vOffset + propOffsets[r1], properties[r1].type);
|
|
57894
|
+
rotation[v * 4 + 2] = readByType(payload, vOffset + propOffsets[r2], properties[r2].type);
|
|
57895
|
+
rotation[v * 4 + 3] = readByType(payload, vOffset + propOffsets[r3], properties[r3].type);
|
|
57896
|
+
}
|
|
57897
|
+
if (opacity) {
|
|
57898
|
+
const oi = propIndex("opacity");
|
|
57899
|
+
opacity[v] = readByType(payload, vOffset + propOffsets[oi], properties[oi].type);
|
|
57900
|
+
}
|
|
57901
|
+
if (hasSH && shCoeffs) {
|
|
57902
|
+
const coeffsPerColor = 1 + restIndices.length / 3;
|
|
57903
|
+
const baseIndex = v * coeffsPerColor * 3;
|
|
57904
|
+
shCoeffs[baseIndex + 0] = readByType(
|
|
57905
|
+
payload,
|
|
57906
|
+
vOffset + propOffsets[dcIdx[0]],
|
|
57907
|
+
properties[dcIdx[0]].type
|
|
57908
|
+
);
|
|
57909
|
+
shCoeffs[baseIndex + coeffsPerColor + 0] = readByType(
|
|
57910
|
+
payload,
|
|
57911
|
+
vOffset + propOffsets[dcIdx[1]],
|
|
57912
|
+
properties[dcIdx[1]].type
|
|
57913
|
+
);
|
|
57914
|
+
shCoeffs[baseIndex + 2 * coeffsPerColor + 0] = readByType(
|
|
57915
|
+
payload,
|
|
57916
|
+
vOffset + propOffsets[dcIdx[2]],
|
|
57917
|
+
properties[dcIdx[2]].type
|
|
57918
|
+
);
|
|
57919
|
+
let rPtr = 1;
|
|
57920
|
+
let gPtr = 1;
|
|
57921
|
+
let bPtr = 1;
|
|
57922
|
+
for (let i = 0; i < restIndices.length; i += 3) {
|
|
57923
|
+
const ri = restIndices[i + 0];
|
|
57924
|
+
const gi = restIndices[i + 1];
|
|
57925
|
+
const bi = restIndices[i + 2];
|
|
57926
|
+
shCoeffs[baseIndex + rPtr] = readByType(
|
|
57927
|
+
payload,
|
|
57928
|
+
vOffset + propOffsets[ri],
|
|
57929
|
+
properties[ri].type
|
|
57930
|
+
);
|
|
57931
|
+
shCoeffs[baseIndex + coeffsPerColor + gPtr] = readByType(
|
|
57932
|
+
payload,
|
|
57933
|
+
vOffset + propOffsets[gi],
|
|
57934
|
+
properties[gi].type
|
|
57935
|
+
);
|
|
57936
|
+
shCoeffs[baseIndex + 2 * coeffsPerColor + bPtr] = readByType(
|
|
57937
|
+
payload,
|
|
57938
|
+
vOffset + propOffsets[bi],
|
|
57939
|
+
properties[bi].type
|
|
57940
|
+
);
|
|
57941
|
+
rPtr++;
|
|
57942
|
+
gPtr++;
|
|
57943
|
+
bPtr++;
|
|
57944
|
+
}
|
|
57945
|
+
}
|
|
57946
|
+
base += stride;
|
|
57947
|
+
}
|
|
57948
|
+
return {
|
|
57949
|
+
vertexCount,
|
|
57950
|
+
position,
|
|
57951
|
+
scale,
|
|
57952
|
+
rotation,
|
|
57953
|
+
opacity,
|
|
57954
|
+
sh: hasSH && shCoeffs ? { order: shOrder, coeffs: shCoeffs } : void 0
|
|
57955
|
+
};
|
|
57956
|
+
}
|
|
57957
|
+
|
|
57958
|
+
class GaussianSplatParser extends ParserBase {
|
|
57959
|
+
static format = ParserFormat.BIN;
|
|
57960
|
+
async parseBuffer(buffer) {
|
|
57961
|
+
const format = detectGSplatFormat(buffer);
|
|
57962
|
+
let asset;
|
|
57963
|
+
switch (format) {
|
|
57964
|
+
case GSplatFormat.PLY: {
|
|
57965
|
+
const plyData = parsePlyGaussianSplat(buffer);
|
|
57966
|
+
asset = {
|
|
57967
|
+
count: plyData.vertexCount,
|
|
57968
|
+
position: plyData.position,
|
|
57969
|
+
rotation: plyData.rotation,
|
|
57970
|
+
scale: plyData.scale,
|
|
57971
|
+
opacity: plyData.opacity,
|
|
57972
|
+
sh: plyData.sh
|
|
57973
|
+
};
|
|
57974
|
+
asset.bbox = computeAABBFromPositions(plyData.position);
|
|
57975
|
+
break;
|
|
57976
|
+
}
|
|
57977
|
+
case GSplatFormat.SPLAT:
|
|
57978
|
+
throw new Error("SPLAT format is not yet supported");
|
|
57979
|
+
case GSplatFormat.KSPLAT:
|
|
57980
|
+
throw new Error("KSPLAT format is not yet supported");
|
|
57981
|
+
case GSplatFormat.UNKNOWN:
|
|
57982
|
+
default:
|
|
57983
|
+
throw new Error("Unknown or unsupported Gaussian Splatting file format");
|
|
57984
|
+
}
|
|
57985
|
+
this.data = asset;
|
|
57986
|
+
return asset;
|
|
57987
|
+
}
|
|
57988
|
+
verification() {
|
|
57989
|
+
return !!this.data && this.data.count > 0;
|
|
57990
|
+
}
|
|
57991
|
+
}
|
|
57992
|
+
|
|
55914
57993
|
var GeoType = /* @__PURE__ */ ((GeoType2) => {
|
|
55915
57994
|
GeoType2["Point"] = "Point";
|
|
55916
57995
|
GeoType2["LineString"] = "LineString";
|
|
@@ -57702,46 +59781,6 @@ fn frag(){
|
|
|
57702
59781
|
function registerMaterial(name, cls) {
|
|
57703
59782
|
}
|
|
57704
59783
|
|
|
57705
|
-
class UnLitMaterial extends Material {
|
|
57706
|
-
/**
|
|
57707
|
-
* @constructor
|
|
57708
|
-
*/
|
|
57709
|
-
constructor() {
|
|
57710
|
-
super();
|
|
57711
|
-
this.shader = new exports.UnLitShader();
|
|
57712
|
-
this.baseMap = Engine3D.res.whiteTexture;
|
|
57713
|
-
}
|
|
57714
|
-
set baseMap(texture) {
|
|
57715
|
-
this.shader.setTexture(`baseMap`, texture);
|
|
57716
|
-
}
|
|
57717
|
-
get baseMap() {
|
|
57718
|
-
return this.shader.getTexture(`baseMap`);
|
|
57719
|
-
}
|
|
57720
|
-
/**
|
|
57721
|
-
* set base color (tint color)
|
|
57722
|
-
*/
|
|
57723
|
-
set baseColor(color) {
|
|
57724
|
-
this.shader.setUniformColor(`baseColor`, color);
|
|
57725
|
-
}
|
|
57726
|
-
/**
|
|
57727
|
-
* get base color (tint color)
|
|
57728
|
-
*/
|
|
57729
|
-
get baseColor() {
|
|
57730
|
-
return this.shader.getUniformColor("baseColor");
|
|
57731
|
-
}
|
|
57732
|
-
/**
|
|
57733
|
-
* set environment texture, usually referring to cubemap
|
|
57734
|
-
*/
|
|
57735
|
-
set envMap(texture) {
|
|
57736
|
-
}
|
|
57737
|
-
/**
|
|
57738
|
-
* @internal
|
|
57739
|
-
* set shadow map
|
|
57740
|
-
*/
|
|
57741
|
-
set shadowMap(texture) {
|
|
57742
|
-
}
|
|
57743
|
-
}
|
|
57744
|
-
|
|
57745
59784
|
class UnLitTexArrayMaterial extends Material {
|
|
57746
59785
|
/**
|
|
57747
59786
|
* @constructor
|
|
@@ -62018,86 +64057,6 @@ fn frag(){
|
|
|
62018
64057
|
}
|
|
62019
64058
|
}
|
|
62020
64059
|
|
|
62021
|
-
class Float16ArrayTexture extends Texture {
|
|
62022
|
-
uint16Array;
|
|
62023
|
-
floatArray;
|
|
62024
|
-
_dataBuffer;
|
|
62025
|
-
/**
|
|
62026
|
-
* 使用数字数组填充纹理,格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
|
|
62027
|
-
* @param width 纹理宽度
|
|
62028
|
-
* @param height 纹理高度
|
|
62029
|
-
* @param numbers 每个像素的颜色值数组
|
|
62030
|
-
* @param useMipmap 是否生成Mipmap
|
|
62031
|
-
* @returns 返回纹理实例
|
|
62032
|
-
*/
|
|
62033
|
-
create(width, height, numbers = null, mipmap = true) {
|
|
62034
|
-
if (numbers == null) {
|
|
62035
|
-
numbers = [];
|
|
62036
|
-
for (let i = 0, c = width * height * 4; i < c; i++) {
|
|
62037
|
-
numbers[i] = 0;
|
|
62038
|
-
}
|
|
62039
|
-
}
|
|
62040
|
-
this.updateTexture(width, height, numbers, mipmap);
|
|
62041
|
-
return this;
|
|
62042
|
-
}
|
|
62043
|
-
/**
|
|
62044
|
-
* 更新纹理内容
|
|
62045
|
-
* @param width 纹理宽度
|
|
62046
|
-
* @param height 纹理高度
|
|
62047
|
-
* @param numbers 像素数据数组
|
|
62048
|
-
* @param mipmap 是否生成Mipmap
|
|
62049
|
-
*/
|
|
62050
|
-
updateTexture(width, height, numbers, mipmap = true) {
|
|
62051
|
-
if (width != this.width || height != this.height) {
|
|
62052
|
-
this._dataBuffer && this._dataBuffer.destroy();
|
|
62053
|
-
this._dataBuffer = null;
|
|
62054
|
-
this.gpuTexture && this.gpuTexture.destroy();
|
|
62055
|
-
this.gpuTexture = null;
|
|
62056
|
-
}
|
|
62057
|
-
this.floatArray = numbers;
|
|
62058
|
-
let device = webGPUContext.device;
|
|
62059
|
-
const bytesPerRow = width * 4 * 2;
|
|
62060
|
-
this.format = GPUTextureFormat.rgba16float;
|
|
62061
|
-
this.mipmapCount = Math.floor(mipmap ? Math.log2(width) : 1);
|
|
62062
|
-
this.createTextureDescriptor(width, height, this.mipmapCount, this.format);
|
|
62063
|
-
if (!this.uint16Array || this.uint16Array.length != numbers.length) {
|
|
62064
|
-
this.uint16Array = new Uint16Array(numbers.length);
|
|
62065
|
-
}
|
|
62066
|
-
let uint16Array = this.uint16Array;
|
|
62067
|
-
for (let i = 0, c = uint16Array.length; i < c; i++) {
|
|
62068
|
-
uint16Array[i] = toHalfFloat(numbers[i]);
|
|
62069
|
-
}
|
|
62070
|
-
const textureDataBuffer = this._dataBuffer = device.createBuffer({
|
|
62071
|
-
size: uint16Array.byteLength,
|
|
62072
|
-
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
|
|
62073
|
-
});
|
|
62074
|
-
device.queue.writeBuffer(textureDataBuffer, 0, uint16Array);
|
|
62075
|
-
const commandEncoder = GPUContext.beginCommandEncoder();
|
|
62076
|
-
commandEncoder.copyBufferToTexture(
|
|
62077
|
-
{
|
|
62078
|
-
buffer: textureDataBuffer,
|
|
62079
|
-
bytesPerRow
|
|
62080
|
-
},
|
|
62081
|
-
{
|
|
62082
|
-
texture: this.getGPUTexture()
|
|
62083
|
-
},
|
|
62084
|
-
{
|
|
62085
|
-
width,
|
|
62086
|
-
height,
|
|
62087
|
-
depthOrArrayLayers: 1
|
|
62088
|
-
}
|
|
62089
|
-
);
|
|
62090
|
-
if (!this.useMipmap) {
|
|
62091
|
-
this.samplerBindingLayout.type = `filtering`;
|
|
62092
|
-
this.textureBindingLayout.sampleType = `float`;
|
|
62093
|
-
}
|
|
62094
|
-
GPUContext.endCommandEncoder(commandEncoder);
|
|
62095
|
-
this.gpuSampler = device.createSampler(this);
|
|
62096
|
-
this.gpuTexture = this.getGPUTexture();
|
|
62097
|
-
if (this.mipmapCount > 1) TextureMipmapGenerator.webGPUGenerateMipmap(this);
|
|
62098
|
-
}
|
|
62099
|
-
}
|
|
62100
|
-
|
|
62101
64060
|
class Float32ArrayTexture extends Texture {
|
|
62102
64061
|
create(width, height, data, filtering = true) {
|
|
62103
64062
|
let device = webGPUContext.device;
|
|
@@ -63734,6 +65693,10 @@ fn frag(){
|
|
|
63734
65693
|
exports.GPUTextureFormat = GPUTextureFormat;
|
|
63735
65694
|
exports.GPUVertexFormat = GPUVertexFormat;
|
|
63736
65695
|
exports.GPUVertexStepMode = GPUVertexStepMode;
|
|
65696
|
+
exports.GSplatFormat = GSplatFormat;
|
|
65697
|
+
exports.GSplatMaterial = GSplatMaterial;
|
|
65698
|
+
exports.GSplat_FS = GSplat_FS;
|
|
65699
|
+
exports.GSplat_VS = GSplat_VS;
|
|
63737
65700
|
exports.GTAOPost = GTAOPost;
|
|
63738
65701
|
exports.GTAO_cs = GTAO_cs;
|
|
63739
65702
|
exports.GUIAtlasTexture = GUIAtlasTexture;
|
|
@@ -63752,6 +65715,7 @@ fn frag(){
|
|
|
63752
65715
|
exports.GUISpace = GUISpace;
|
|
63753
65716
|
exports.GUISprite = GUISprite;
|
|
63754
65717
|
exports.GUITexture = GUITexture;
|
|
65718
|
+
exports.GaussianSplatParser = GaussianSplatParser;
|
|
63755
65719
|
exports.GenerayRandomDir = GenerayRandomDir;
|
|
63756
65720
|
exports.GeoJsonParser = GeoJsonParser;
|
|
63757
65721
|
exports.GeoJsonUtil = GeoJsonUtil;
|
|
@@ -63820,6 +65784,7 @@ fn frag(){
|
|
|
63820
65784
|
exports.KHR_materials_emissive_strength = KHR_materials_emissive_strength;
|
|
63821
65785
|
exports.KHR_materials_ior = KHR_materials_ior;
|
|
63822
65786
|
exports.KHR_materials_unlit = KHR_materials_unlit;
|
|
65787
|
+
exports.KMZParser = KMZParser;
|
|
63823
65788
|
exports.KV = KV;
|
|
63824
65789
|
exports.KelvinUtil = KelvinUtil;
|
|
63825
65790
|
exports.KeyCode = KeyCode;
|
|
@@ -64145,6 +66110,7 @@ fn frag(){
|
|
|
64145
66110
|
exports.UITransform = UITransform;
|
|
64146
66111
|
exports.UUID = UUID;
|
|
64147
66112
|
exports.UV = UV;
|
|
66113
|
+
exports.Uint32ArrayTexture = Uint32ArrayTexture;
|
|
64148
66114
|
exports.Uint8ArrayTexture = Uint8ArrayTexture;
|
|
64149
66115
|
exports.UnLit = UnLit;
|
|
64150
66116
|
exports.UnLitMaterial = UnLitMaterial;
|
|
@@ -64179,6 +66145,8 @@ fn frag(){
|
|
|
64179
66145
|
exports.ViewQuad = ViewQuad;
|
|
64180
66146
|
exports.VirtualTexture = VirtualTexture;
|
|
64181
66147
|
exports.WGSLTranslator = WGSLTranslator;
|
|
66148
|
+
exports.WayLines3D = WayLines3D;
|
|
66149
|
+
exports.WayPoint3D = WayPoint3D;
|
|
64182
66150
|
exports.WebGPUDescriptorCreator = WebGPUDescriptorCreator;
|
|
64183
66151
|
exports.WorldMatrixUniform = WorldMatrixUniform;
|
|
64184
66152
|
exports.WorldPanel = WorldPanel;
|
|
@@ -64193,17 +66161,20 @@ fn frag(){
|
|
|
64193
66161
|
exports.arrayToString = arrayToString;
|
|
64194
66162
|
exports.blendComponent = blendComponent;
|
|
64195
66163
|
exports.buildCurves = buildCurves;
|
|
66164
|
+
exports.byteSizeOfType = byteSizeOfType;
|
|
64196
66165
|
exports.calculateCurveRangesValue = calculateCurveRangesValue;
|
|
64197
66166
|
exports.calculateMinMax = calculateMinMax;
|
|
64198
66167
|
exports.castPointShadowMap_vert = castPointShadowMap_vert;
|
|
64199
66168
|
exports.clamp = clamp;
|
|
64200
66169
|
exports.clampRepeat = clampRepeat;
|
|
66170
|
+
exports.computeAABBFromPositions = computeAABBFromPositions;
|
|
64201
66171
|
exports.cos = cos;
|
|
64202
66172
|
exports.crossProduct = crossProduct;
|
|
64203
66173
|
exports.cubicPolynomialRoot = cubicPolynomialRoot;
|
|
64204
66174
|
exports.cubicPolynomialRootsGeneric = cubicPolynomialRootsGeneric;
|
|
64205
66175
|
exports.curvesSupportProcedural = curvesSupportProcedural;
|
|
64206
66176
|
exports.deg2Rad = deg2Rad;
|
|
66177
|
+
exports.detectGSplatFormat = detectGSplatFormat;
|
|
64207
66178
|
exports.directionShadowCastMap_frag = directionShadowCastMap_frag;
|
|
64208
66179
|
exports.dot = dot;
|
|
64209
66180
|
exports.doubleIntegrateSegment = doubleIntegrateSegment;
|
|
@@ -64223,6 +66194,7 @@ fn frag(){
|
|
|
64223
66194
|
exports.grad2 = grad2;
|
|
64224
66195
|
exports.grad3 = grad3;
|
|
64225
66196
|
exports.grad4 = grad4;
|
|
66197
|
+
exports.inferSHOrder = inferSHOrder;
|
|
64226
66198
|
exports.integrateSegment = integrateSegment;
|
|
64227
66199
|
exports.irradianceDataReader = irradianceDataReader;
|
|
64228
66200
|
exports.kPI = kPI;
|
|
@@ -64246,6 +66218,8 @@ fn frag(){
|
|
|
64246
66218
|
exports.normalizedToWord = normalizedToWord;
|
|
64247
66219
|
exports.outlinePostData = outlinePostData;
|
|
64248
66220
|
exports.outlinePostManager = outlinePostManager;
|
|
66221
|
+
exports.parsePlyGaussianSplat = parsePlyGaussianSplat;
|
|
66222
|
+
exports.parsePlyHeader = parsePlyHeader;
|
|
64249
66223
|
exports.perm = perm;
|
|
64250
66224
|
exports.post = post;
|
|
64251
66225
|
exports.quadraticPolynomialRootsGeneric = quadraticPolynomialRootsGeneric;
|
|
@@ -64264,6 +66238,7 @@ fn frag(){
|
|
|
64264
66238
|
exports.randomUnitVector2 = randomUnitVector2;
|
|
64265
66239
|
exports.rangedRandomFloat = rangedRandomFloat;
|
|
64266
66240
|
exports.rangedRandomInt = rangedRandomInt;
|
|
66241
|
+
exports.readByType = readByType;
|
|
64267
66242
|
exports.readMagicBytes = readMagicBytes;
|
|
64268
66243
|
exports.registerMaterial = registerMaterial;
|
|
64269
66244
|
exports.repeat = repeat;
|