@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.
@@ -2113,7 +2113,7 @@ function GetShader(name) {
2113
2113
  }
2114
2114
 
2115
2115
  var __defProp$2 = Object.defineProperty;
2116
- var __decorateClass$i = (decorators, target, key, kind) => {
2116
+ var __decorateClass$j = (decorators, target, key, kind) => {
2117
2117
  var result = void 0 ;
2118
2118
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
2119
2119
  if (decorator = decorators[i])
@@ -2216,10 +2216,10 @@ const _Struct = class _Struct {
2216
2216
  return struct.__size;
2217
2217
  }
2218
2218
  };
2219
- __decorateClass$i([
2219
+ __decorateClass$j([
2220
2220
  NonSerialize
2221
2221
  ], _Struct.prototype, "__refection");
2222
- __decorateClass$i([
2222
+ __decorateClass$j([
2223
2223
  NonSerialize
2224
2224
  ], _Struct.prototype, "__size");
2225
2225
  let Struct = _Struct;
@@ -11826,6 +11826,21 @@ class Matrix4 {
11826
11826
  target.transformDir(fromDirection, toDirection);
11827
11827
  return target;
11828
11828
  }
11829
+ /**
11830
+ * Create a matrix from an array of 16 numbers
11831
+ * @param array Array of 16 numbers
11832
+ * @returns Matrix4 result
11833
+ */
11834
+ static fromArray(array) {
11835
+ if (array.length !== 16) {
11836
+ throw new Error("Array must contain exactly 16 elements");
11837
+ }
11838
+ const matrix = new Matrix4();
11839
+ for (let i = 0; i < 16; i++) {
11840
+ matrix.rawData[i] = array[i];
11841
+ }
11842
+ return matrix;
11843
+ }
11829
11844
  /**
11830
11845
  * Generate a matrix (rotate degrees with x,y,z as the center axis)
11831
11846
  * @param x x on the central axis
@@ -16475,9 +16490,9 @@ class Entity extends CEventDispatcher {
16475
16490
  }
16476
16491
  }
16477
16492
 
16478
- var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
16479
- var __decorateClass$h = (decorators, target, key, kind) => {
16480
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target;
16493
+ var __getOwnPropDesc$i = Object.getOwnPropertyDescriptor;
16494
+ var __decorateClass$i = (decorators, target, key, kind) => {
16495
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target;
16481
16496
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
16482
16497
  if (decorator = decorators[i])
16483
16498
  result = (decorator(result)) || result;
@@ -16742,7 +16757,7 @@ let Object3D = class extends Entity {
16742
16757
  super.destroy(force);
16743
16758
  }
16744
16759
  };
16745
- Object3D = __decorateClass$h([
16760
+ Object3D = __decorateClass$i([
16746
16761
  DecorateObject3D
16747
16762
  ], Object3D);
16748
16763
  function DecorateObject3D(ctor, _) {
@@ -23520,9 +23535,9 @@ class OctreeEntity {
23520
23535
  }
23521
23536
 
23522
23537
  var __defProp$1 = Object.defineProperty;
23523
- var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
23524
- var __decorateClass$g = (decorators, target, key, kind) => {
23525
- var result = __getOwnPropDesc$g(target, key) ;
23538
+ var __getOwnPropDesc$h = Object.getOwnPropertyDescriptor;
23539
+ var __decorateClass$h = (decorators, target, key, kind) => {
23540
+ var result = __getOwnPropDesc$h(target, key) ;
23526
23541
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
23527
23542
  if (decorator = decorators[i])
23528
23543
  result = (decorator(target, key, result) ) || result;
@@ -24107,20 +24122,20 @@ class RenderNode extends ComponentBase {
24107
24122
  this._combineShaderRefection = void 0;
24108
24123
  }
24109
24124
  }
24110
- __decorateClass$g([
24125
+ __decorateClass$h([
24111
24126
  EditorInspector
24112
24127
  ], RenderNode.prototype, "materials");
24113
- __decorateClass$g([
24128
+ __decorateClass$h([
24114
24129
  EditorInspector
24115
24130
  ], RenderNode.prototype, "castShadow");
24116
- __decorateClass$g([
24131
+ __decorateClass$h([
24117
24132
  EditorInspector
24118
24133
  ], RenderNode.prototype, "castGI");
24119
24134
 
24120
24135
  var __defProp = Object.defineProperty;
24121
- var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
24122
- var __decorateClass$f = (decorators, target, key, kind) => {
24123
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
24136
+ var __getOwnPropDesc$g = Object.getOwnPropertyDescriptor;
24137
+ var __decorateClass$g = (decorators, target, key, kind) => {
24138
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target;
24124
24139
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
24125
24140
  if (decorator = decorators[i])
24126
24141
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
@@ -24229,13 +24244,13 @@ let MeshRenderer = class extends RenderNode {
24229
24244
  super.destroy(force);
24230
24245
  }
24231
24246
  };
24232
- __decorateClass$f([
24247
+ __decorateClass$g([
24233
24248
  EditorInspector
24234
24249
  ], MeshRenderer.prototype, "geometry", 1);
24235
- __decorateClass$f([
24250
+ __decorateClass$g([
24236
24251
  EditorInspector
24237
24252
  ], MeshRenderer.prototype, "material", 1);
24238
- MeshRenderer = __decorateClass$f([
24253
+ MeshRenderer = __decorateClass$g([
24239
24254
  RegisterComponent(MeshRenderer, "MeshRenderer")
24240
24255
  ], MeshRenderer);
24241
24256
 
@@ -25884,9 +25899,9 @@ class Shader {
25884
25899
  }
25885
25900
  }
25886
25901
 
25887
- var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
25888
- var __decorateClass$e = (decorators, target, key, kind) => {
25889
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
25902
+ var __getOwnPropDesc$f = Object.getOwnPropertyDescriptor;
25903
+ var __decorateClass$f = (decorators, target, key, kind) => {
25904
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target;
25890
25905
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
25891
25906
  if (decorator = decorators[i])
25892
25907
  result = (decorator(result)) || result;
@@ -25910,7 +25925,7 @@ let QuadShader = class extends Shader {
25910
25925
  this.setUniformFloat(`height`, 100);
25911
25926
  }
25912
25927
  };
25913
- QuadShader = __decorateClass$e([
25928
+ QuadShader = __decorateClass$f([
25914
25929
  RegisterShader(QuadShader, "QuadShader")
25915
25930
  ], QuadShader);
25916
25931
 
@@ -31320,6 +31335,7 @@ class FileLoader extends LoaderBase {
31320
31335
  parser.userData = userData;
31321
31336
  parser.baseUrl = this.baseUrl;
31322
31337
  parser.initUrl = url;
31338
+ parser.loaderFunctions = loaderFunctions;
31323
31339
  await parser.parseBuffer(data);
31324
31340
  if (parser.verification()) {
31325
31341
  succ(parser);
@@ -33183,9 +33199,9 @@ class LightBase extends ComponentBase {
33183
33199
  }
33184
33200
  }
33185
33201
 
33186
- var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
33187
- var __decorateClass$d = (decorators, target, key, kind) => {
33188
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
33202
+ var __getOwnPropDesc$e = Object.getOwnPropertyDescriptor;
33203
+ var __decorateClass$e = (decorators, target, key, kind) => {
33204
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target;
33189
33205
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
33190
33206
  if (decorator = decorators[i])
33191
33207
  result = (decorator(result)) || result;
@@ -33227,13 +33243,13 @@ let DirectLight = class extends LightBase {
33227
33243
  debug() {
33228
33244
  }
33229
33245
  };
33230
- DirectLight = __decorateClass$d([
33246
+ DirectLight = __decorateClass$e([
33231
33247
  RegisterComponent(DirectLight, "DirectLight")
33232
33248
  ], DirectLight);
33233
33249
 
33234
- var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
33235
- var __decorateClass$c = (decorators, target, key, kind) => {
33236
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
33250
+ var __getOwnPropDesc$d = Object.getOwnPropertyDescriptor;
33251
+ var __decorateClass$d = (decorators, target, key, kind) => {
33252
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target;
33237
33253
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
33238
33254
  if (decorator = decorators[i])
33239
33255
  result = (decorator(result)) || result;
@@ -33291,13 +33307,13 @@ let PointLight = class extends LightBase {
33291
33307
  debugDraw(show) {
33292
33308
  }
33293
33309
  };
33294
- PointLight = __decorateClass$c([
33310
+ PointLight = __decorateClass$d([
33295
33311
  RegisterComponent(PointLight, "PointLight")
33296
33312
  ], PointLight);
33297
33313
 
33298
- var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
33299
- var __decorateClass$b = (decorators, target, key, kind) => {
33300
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
33314
+ var __getOwnPropDesc$c = Object.getOwnPropertyDescriptor;
33315
+ var __decorateClass$c = (decorators, target, key, kind) => {
33316
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target;
33301
33317
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
33302
33318
  if (decorator = decorators[i])
33303
33319
  result = (decorator(result)) || result;
@@ -33362,7 +33378,7 @@ let SpotLight = class extends LightBase {
33362
33378
  debugDraw(show) {
33363
33379
  }
33364
33380
  };
33365
- SpotLight = __decorateClass$b([
33381
+ SpotLight = __decorateClass$c([
33366
33382
  RegisterComponent(SpotLight, "SpotLight")
33367
33383
  ], SpotLight);
33368
33384
 
@@ -38007,6 +38023,826 @@ class AtlasParser extends ParserBase {
38007
38023
  }
38008
38024
  }
38009
38025
 
38026
+ // DEFLATE is a complex format; to read this code, you should probably check the RFC first:
38027
+ // https://tools.ietf.org/html/rfc1951
38028
+ // You may also wish to take a look at the guide I made about this program:
38029
+ // https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad
38030
+ // Some of the following code is similar to that of UZIP.js:
38031
+ // https://github.com/photopea/UZIP.js
38032
+ // However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.
38033
+ // Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint
38034
+ // is better for memory in most engines (I *think*).
38035
+
38036
+ // aliases for shorter compressed code (most minifers don't do this)
38037
+ var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;
38038
+ // fixed length extra bits
38039
+ 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]);
38040
+ // fixed distance extra bits
38041
+ 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]);
38042
+ // code length index map
38043
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
38044
+ // get base, reverse index map from extra bits
38045
+ var freb = function (eb, start) {
38046
+ var b = new u16(31);
38047
+ for (var i = 0; i < 31; ++i) {
38048
+ b[i] = start += 1 << eb[i - 1];
38049
+ }
38050
+ // numbers here are at max 18 bits
38051
+ var r = new i32(b[30]);
38052
+ for (var i = 1; i < 30; ++i) {
38053
+ for (var j = b[i]; j < b[i + 1]; ++j) {
38054
+ r[j] = ((j - b[i]) << 5) | i;
38055
+ }
38056
+ }
38057
+ return { b: b, r: r };
38058
+ };
38059
+ var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;
38060
+ // we can ignore the fact that the other numbers are wrong; they never happen anyway
38061
+ fl[28] = 258, revfl[258] = 28;
38062
+ var _b = freb(fdeb, 0), fd = _b.b;
38063
+ // map of value to reverse (assuming 16 bits)
38064
+ var rev = new u16(32768);
38065
+ for (var i = 0; i < 32768; ++i) {
38066
+ // reverse table algorithm from SO
38067
+ var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);
38068
+ x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);
38069
+ x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);
38070
+ rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;
38071
+ }
38072
+ // create huffman tree from u8 "map": index -> code length for code index
38073
+ // mb (max bits) must be at most 15
38074
+ // TODO: optimize/split up?
38075
+ var hMap = (function (cd, mb, r) {
38076
+ var s = cd.length;
38077
+ // index
38078
+ var i = 0;
38079
+ // u16 "map": index -> # of codes with bit length = index
38080
+ var l = new u16(mb);
38081
+ // length of cd must be 288 (total # of codes)
38082
+ for (; i < s; ++i) {
38083
+ if (cd[i])
38084
+ ++l[cd[i] - 1];
38085
+ }
38086
+ // u16 "map": index -> minimum code for bit length = index
38087
+ var le = new u16(mb);
38088
+ for (i = 1; i < mb; ++i) {
38089
+ le[i] = (le[i - 1] + l[i - 1]) << 1;
38090
+ }
38091
+ var co;
38092
+ if (r) {
38093
+ // u16 "map": index -> number of actual bits, symbol for code
38094
+ co = new u16(1 << mb);
38095
+ // bits to remove for reverser
38096
+ var rvb = 15 - mb;
38097
+ for (i = 0; i < s; ++i) {
38098
+ // ignore 0 lengths
38099
+ if (cd[i]) {
38100
+ // num encoding both symbol and bits read
38101
+ var sv = (i << 4) | cd[i];
38102
+ // free bits
38103
+ var r_1 = mb - cd[i];
38104
+ // start value
38105
+ var v = le[cd[i] - 1]++ << r_1;
38106
+ // m is end value
38107
+ for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {
38108
+ // every 16 bit value starting with the code yields the same result
38109
+ co[rev[v] >> rvb] = sv;
38110
+ }
38111
+ }
38112
+ }
38113
+ }
38114
+ else {
38115
+ co = new u16(s);
38116
+ for (i = 0; i < s; ++i) {
38117
+ if (cd[i]) {
38118
+ co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);
38119
+ }
38120
+ }
38121
+ }
38122
+ return co;
38123
+ });
38124
+ // fixed length tree
38125
+ var flt = new u8(288);
38126
+ for (var i = 0; i < 144; ++i)
38127
+ flt[i] = 8;
38128
+ for (var i = 144; i < 256; ++i)
38129
+ flt[i] = 9;
38130
+ for (var i = 256; i < 280; ++i)
38131
+ flt[i] = 7;
38132
+ for (var i = 280; i < 288; ++i)
38133
+ flt[i] = 8;
38134
+ // fixed distance tree
38135
+ var fdt = new u8(32);
38136
+ for (var i = 0; i < 32; ++i)
38137
+ fdt[i] = 5;
38138
+ // fixed length map
38139
+ var flrm = /*#__PURE__*/ hMap(flt, 9, 1);
38140
+ // fixed distance map
38141
+ var fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
38142
+ // find max of array
38143
+ var max = function (a) {
38144
+ var m = a[0];
38145
+ for (var i = 1; i < a.length; ++i) {
38146
+ if (a[i] > m)
38147
+ m = a[i];
38148
+ }
38149
+ return m;
38150
+ };
38151
+ // read d, starting at bit p and mask with m
38152
+ var bits = function (d, p, m) {
38153
+ var o = (p / 8) | 0;
38154
+ return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;
38155
+ };
38156
+ // read d, starting at bit p continuing for at least 16 bits
38157
+ var bits16 = function (d, p) {
38158
+ var o = (p / 8) | 0;
38159
+ return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));
38160
+ };
38161
+ // get end of byte
38162
+ var shft = function (p) { return ((p + 7) / 8) | 0; };
38163
+ // typed array slice - allows garbage collector to free original reference,
38164
+ // while being more compatible than .slice
38165
+ var slc = function (v, s, e) {
38166
+ if (s == null || s < 0)
38167
+ s = 0;
38168
+ if (e == null || e > v.length)
38169
+ e = v.length;
38170
+ // can't use .constructor in case user-supplied
38171
+ return new u8(v.subarray(s, e));
38172
+ };
38173
+ // error codes
38174
+ var ec = [
38175
+ 'unexpected EOF',
38176
+ 'invalid block type',
38177
+ 'invalid length/literal',
38178
+ 'invalid distance',
38179
+ 'stream finished',
38180
+ 'no stream handler',
38181
+ ,
38182
+ 'no callback',
38183
+ 'invalid UTF-8 data',
38184
+ 'extra field too long',
38185
+ 'date not in range 1980-2099',
38186
+ 'filename too long',
38187
+ 'stream finishing',
38188
+ 'invalid zip data'
38189
+ // determined by unknown compression method
38190
+ ];
38191
+ var err = function (ind, msg, nt) {
38192
+ var e = new Error(msg || ec[ind]);
38193
+ e.code = ind;
38194
+ if (Error.captureStackTrace)
38195
+ Error.captureStackTrace(e, err);
38196
+ if (!nt)
38197
+ throw e;
38198
+ return e;
38199
+ };
38200
+ // expands raw DEFLATE data
38201
+ var inflt = function (dat, st, buf, dict) {
38202
+ // source length dict length
38203
+ var sl = dat.length, dl = dict ? dict.length : 0;
38204
+ if (!sl || st.f && !st.l)
38205
+ return buf || new u8(0);
38206
+ var noBuf = !buf;
38207
+ // have to estimate size
38208
+ var resize = noBuf || st.i != 2;
38209
+ // no state
38210
+ var noSt = st.i;
38211
+ // Assumes roughly 33% compression ratio average
38212
+ if (noBuf)
38213
+ buf = new u8(sl * 3);
38214
+ // ensure buffer can fit at least l elements
38215
+ var cbuf = function (l) {
38216
+ var bl = buf.length;
38217
+ // need to increase size to fit
38218
+ if (l > bl) {
38219
+ // Double or set to necessary, whichever is greater
38220
+ var nbuf = new u8(Math.max(bl * 2, l));
38221
+ nbuf.set(buf);
38222
+ buf = nbuf;
38223
+ }
38224
+ };
38225
+ // last chunk bitpos bytes
38226
+ 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;
38227
+ // total bits
38228
+ var tbts = sl * 8;
38229
+ do {
38230
+ if (!lm) {
38231
+ // BFINAL - this is only 1 when last chunk is next
38232
+ final = bits(dat, pos, 1);
38233
+ // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman
38234
+ var type = bits(dat, pos + 1, 3);
38235
+ pos += 3;
38236
+ if (!type) {
38237
+ // go to end of byte boundary
38238
+ var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;
38239
+ if (t > sl) {
38240
+ if (noSt)
38241
+ err(0);
38242
+ break;
38243
+ }
38244
+ // ensure size
38245
+ if (resize)
38246
+ cbuf(bt + l);
38247
+ // Copy over uncompressed data
38248
+ buf.set(dat.subarray(s, t), bt);
38249
+ // Get new bitpos, update byte count
38250
+ st.b = bt += l, st.p = pos = t * 8, st.f = final;
38251
+ continue;
38252
+ }
38253
+ else if (type == 1)
38254
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
38255
+ else if (type == 2) {
38256
+ // literal lengths
38257
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
38258
+ var tl = hLit + bits(dat, pos + 5, 31) + 1;
38259
+ pos += 14;
38260
+ // length+distance tree
38261
+ var ldt = new u8(tl);
38262
+ // code length tree
38263
+ var clt = new u8(19);
38264
+ for (var i = 0; i < hcLen; ++i) {
38265
+ // use index map to get real code
38266
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
38267
+ }
38268
+ pos += hcLen * 3;
38269
+ // code lengths bits
38270
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
38271
+ // code lengths map
38272
+ var clm = hMap(clt, clb, 1);
38273
+ for (var i = 0; i < tl;) {
38274
+ var r = clm[bits(dat, pos, clbmsk)];
38275
+ // bits read
38276
+ pos += r & 15;
38277
+ // symbol
38278
+ var s = r >> 4;
38279
+ // code length to copy
38280
+ if (s < 16) {
38281
+ ldt[i++] = s;
38282
+ }
38283
+ else {
38284
+ // copy count
38285
+ var c = 0, n = 0;
38286
+ if (s == 16)
38287
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
38288
+ else if (s == 17)
38289
+ n = 3 + bits(dat, pos, 7), pos += 3;
38290
+ else if (s == 18)
38291
+ n = 11 + bits(dat, pos, 127), pos += 7;
38292
+ while (n--)
38293
+ ldt[i++] = c;
38294
+ }
38295
+ }
38296
+ // length tree distance tree
38297
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
38298
+ // max length bits
38299
+ lbt = max(lt);
38300
+ // max dist bits
38301
+ dbt = max(dt);
38302
+ lm = hMap(lt, lbt, 1);
38303
+ dm = hMap(dt, dbt, 1);
38304
+ }
38305
+ else
38306
+ err(1);
38307
+ if (pos > tbts) {
38308
+ if (noSt)
38309
+ err(0);
38310
+ break;
38311
+ }
38312
+ }
38313
+ // Make sure the buffer can hold this + the largest possible addition
38314
+ // Maximum chunk size (practically, theoretically infinite) is 2^17
38315
+ if (resize)
38316
+ cbuf(bt + 131072);
38317
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
38318
+ var lpos = pos;
38319
+ for (;; lpos = pos) {
38320
+ // bits read, code
38321
+ var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
38322
+ pos += c & 15;
38323
+ if (pos > tbts) {
38324
+ if (noSt)
38325
+ err(0);
38326
+ break;
38327
+ }
38328
+ if (!c)
38329
+ err(2);
38330
+ if (sym < 256)
38331
+ buf[bt++] = sym;
38332
+ else if (sym == 256) {
38333
+ lpos = pos, lm = null;
38334
+ break;
38335
+ }
38336
+ else {
38337
+ var add = sym - 254;
38338
+ // no extra bits needed if less
38339
+ if (sym > 264) {
38340
+ // index
38341
+ var i = sym - 257, b = fleb[i];
38342
+ add = bits(dat, pos, (1 << b) - 1) + fl[i];
38343
+ pos += b;
38344
+ }
38345
+ // dist
38346
+ var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
38347
+ if (!d)
38348
+ err(3);
38349
+ pos += d & 15;
38350
+ var dt = fd[dsym];
38351
+ if (dsym > 3) {
38352
+ var b = fdeb[dsym];
38353
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
38354
+ }
38355
+ if (pos > tbts) {
38356
+ if (noSt)
38357
+ err(0);
38358
+ break;
38359
+ }
38360
+ if (resize)
38361
+ cbuf(bt + 131072);
38362
+ var end = bt + add;
38363
+ if (bt < dt) {
38364
+ var shift = dl - dt, dend = Math.min(dt, end);
38365
+ if (shift + bt < 0)
38366
+ err(3);
38367
+ for (; bt < dend; ++bt)
38368
+ buf[bt] = dict[shift + bt];
38369
+ }
38370
+ for (; bt < end; ++bt)
38371
+ buf[bt] = buf[bt - dt];
38372
+ }
38373
+ }
38374
+ st.l = lm, st.p = lpos, st.b = bt, st.f = final;
38375
+ if (lm)
38376
+ final = 1, st.m = lbt, st.d = dm, st.n = dbt;
38377
+ } while (!final);
38378
+ // don't reallocate for streams or user buffers
38379
+ return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
38380
+ };
38381
+ // empty
38382
+ var et = /*#__PURE__*/ new u8(0);
38383
+ // read 2 bytes
38384
+ var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };
38385
+ // read 4 bytes
38386
+ var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };
38387
+ var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };
38388
+ /**
38389
+ * Expands DEFLATE data with no wrapper
38390
+ * @param data The data to decompress
38391
+ * @param opts The decompression options
38392
+ * @returns The decompressed version of the data
38393
+ */
38394
+ function inflateSync(data, opts) {
38395
+ return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);
38396
+ }
38397
+ // text decoder
38398
+ var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();
38399
+ // text decoder stream
38400
+ var tds = 0;
38401
+ try {
38402
+ td.decode(et, { stream: true });
38403
+ tds = 1;
38404
+ }
38405
+ catch (e) { }
38406
+ // decode UTF8
38407
+ var dutf8 = function (d) {
38408
+ for (var r = '', i = 0;;) {
38409
+ var c = d[i++];
38410
+ var eb = (c > 127) + (c > 223) + (c > 239);
38411
+ if (i + eb > d.length)
38412
+ return { s: r, r: slc(d, i - 1) };
38413
+ if (!eb)
38414
+ r += String.fromCharCode(c);
38415
+ else if (eb == 3) {
38416
+ c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,
38417
+ r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));
38418
+ }
38419
+ else if (eb & 1)
38420
+ r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));
38421
+ else
38422
+ r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));
38423
+ }
38424
+ };
38425
+ /**
38426
+ * Converts a Uint8Array to a string
38427
+ * @param dat The data to decode to string
38428
+ * @param latin1 Whether or not to interpret the data as Latin-1. This should
38429
+ * not need to be true unless encoding to binary string.
38430
+ * @returns The original UTF-8/Latin-1 string
38431
+ */
38432
+ function strFromU8(dat, latin1) {
38433
+ if (latin1) {
38434
+ var r = '';
38435
+ for (var i = 0; i < dat.length; i += 16384)
38436
+ r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
38437
+ return r;
38438
+ }
38439
+ else if (td) {
38440
+ return td.decode(dat);
38441
+ }
38442
+ else {
38443
+ var _a = dutf8(dat), s = _a.s, r = _a.r;
38444
+ if (r.length)
38445
+ err(8);
38446
+ return s;
38447
+ }
38448
+ }
38449
+ // skip local zip header
38450
+ var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
38451
+ // read zip header
38452
+ var zh = function (d, b, z) {
38453
+ 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);
38454
+ 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];
38455
+ return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
38456
+ };
38457
+ // read zip64 extra field
38458
+ var z64e = function (d, b) {
38459
+ for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
38460
+ ;
38461
+ return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
38462
+ };
38463
+ /**
38464
+ * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
38465
+ * performance with more than one file.
38466
+ * @param data The raw compressed ZIP file
38467
+ * @param opts The ZIP extraction options
38468
+ * @returns The decompressed files
38469
+ */
38470
+ function unzipSync(data, opts) {
38471
+ var files = {};
38472
+ var e = data.length - 22;
38473
+ for (; b4(data, e) != 0x6054B50; --e) {
38474
+ if (!e || data.length - e > 65558)
38475
+ err(13);
38476
+ }
38477
+ var c = b2(data, e + 8);
38478
+ if (!c)
38479
+ return {};
38480
+ var o = b4(data, e + 16);
38481
+ var z = o == 4294967295 || c == 65535;
38482
+ if (z) {
38483
+ var ze = b4(data, e - 12);
38484
+ z = b4(data, ze) == 0x6064B50;
38485
+ if (z) {
38486
+ c = b4(data, ze + 32);
38487
+ o = b4(data, ze + 48);
38488
+ }
38489
+ }
38490
+ for (var i = 0; i < c; ++i) {
38491
+ 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);
38492
+ o = no;
38493
+ {
38494
+ if (!c_2)
38495
+ files[fn] = slc(data, b, b + sc);
38496
+ else if (c_2 == 8)
38497
+ files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });
38498
+ else
38499
+ err(14, 'unknown compression type ' + c_2);
38500
+ }
38501
+ }
38502
+ return files;
38503
+ }
38504
+
38505
+ class UnLitMaterial extends Material {
38506
+ /**
38507
+ * @constructor
38508
+ */
38509
+ constructor() {
38510
+ super();
38511
+ this.shader = new UnLitShader();
38512
+ this.baseMap = Engine3D.res.whiteTexture;
38513
+ }
38514
+ set baseMap(texture) {
38515
+ this.shader.setTexture(`baseMap`, texture);
38516
+ }
38517
+ get baseMap() {
38518
+ return this.shader.getTexture(`baseMap`);
38519
+ }
38520
+ /**
38521
+ * set base color (tint color)
38522
+ */
38523
+ set baseColor(color) {
38524
+ this.shader.setUniformColor(`baseColor`, color);
38525
+ }
38526
+ /**
38527
+ * get base color (tint color)
38528
+ */
38529
+ get baseColor() {
38530
+ return this.shader.getUniformColor("baseColor");
38531
+ }
38532
+ /**
38533
+ * set environment texture, usually referring to cubemap
38534
+ */
38535
+ set envMap(texture) {
38536
+ }
38537
+ /**
38538
+ * @internal
38539
+ * set shadow map
38540
+ */
38541
+ set shadowMap(texture) {
38542
+ }
38543
+ }
38544
+
38545
+ class SphereGeometry extends GeometryBase {
38546
+ shape_vertices = [];
38547
+ shape_indices = [];
38548
+ radius;
38549
+ widthSegments;
38550
+ heightSegments;
38551
+ phiStart;
38552
+ phiLength;
38553
+ thetaStart;
38554
+ thetaLength;
38555
+ /**
38556
+ * 球体几何体
38557
+ * @constructor
38558
+ * @param radius 球体半径
38559
+ * @param widthSegments 定义水平分段数
38560
+ * @param heightSegments 定义垂直分段数
38561
+ * @param phiStart 球体赤道线起始点的弧度
38562
+ * @param phiLength 球体赤道线的弧长
38563
+ * @param thetaStart 球体经线起始点的弧度
38564
+ * @param thetaLength 球体经线的弧长
38565
+ */
38566
+ constructor(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
38567
+ super();
38568
+ this.radius = radius;
38569
+ this.widthSegments = widthSegments;
38570
+ this.heightSegments = heightSegments;
38571
+ this.phiStart = phiStart;
38572
+ this.phiLength = phiLength;
38573
+ this.thetaStart = thetaStart;
38574
+ this.thetaLength = thetaLength;
38575
+ this.buildGeometry();
38576
+ }
38577
+ buildGeometry() {
38578
+ var i, j, triIndex = 0;
38579
+ let _segmentsH = this.heightSegments;
38580
+ let _segmentsW = this.widthSegments;
38581
+ let _radius = this.radius;
38582
+ var vertexCount = (_segmentsH + 1) * (_segmentsW + 1);
38583
+ let position_arr = new Float32Array(vertexCount * 3);
38584
+ let normal_arr = new Float32Array(vertexCount * 3);
38585
+ let uv_arr = new Float32Array(vertexCount * 2);
38586
+ let indice_arr = new Uint16Array(_segmentsW * _segmentsH * 2 * 3);
38587
+ let pi = 0;
38588
+ let ni = 0;
38589
+ let ui = 0;
38590
+ for (j = 0; j <= _segmentsH; ++j) {
38591
+ var horAngle = Math.PI * j / _segmentsH;
38592
+ var y = _radius * Math.cos(horAngle);
38593
+ var ringRadius = _radius * Math.sin(horAngle);
38594
+ for (i = 0; i <= _segmentsW; ++i) {
38595
+ var verAngle = 2 * Math.PI * i / _segmentsW;
38596
+ var x = ringRadius * Math.cos(verAngle);
38597
+ var z = ringRadius * Math.sin(verAngle);
38598
+ var normLen = 1 / Math.sqrt(x * x + y * y + z * z);
38599
+ position_arr[pi++] = x;
38600
+ position_arr[pi++] = y;
38601
+ position_arr[pi++] = z;
38602
+ normal_arr[ni++] = x * normLen;
38603
+ normal_arr[ni++] = y * normLen;
38604
+ normal_arr[ni++] = z * normLen;
38605
+ uv_arr[ui++] = i / _segmentsW;
38606
+ uv_arr[ui++] = j / _segmentsH;
38607
+ if (i > 0 && j > 0) {
38608
+ var a = (_segmentsW + 1) * j + i;
38609
+ var b = (_segmentsW + 1) * j + i - 1;
38610
+ var c = (_segmentsW + 1) * (j - 1) + i - 1;
38611
+ var d = (_segmentsW + 1) * (j - 1) + i;
38612
+ if (j == _segmentsH) {
38613
+ indice_arr[triIndex++] = a;
38614
+ indice_arr[triIndex++] = c;
38615
+ indice_arr[triIndex++] = d;
38616
+ } else if (j == 1) {
38617
+ indice_arr[triIndex++] = a;
38618
+ indice_arr[triIndex++] = b;
38619
+ indice_arr[triIndex++] = c;
38620
+ } else {
38621
+ indice_arr[triIndex++] = a;
38622
+ indice_arr[triIndex++] = b;
38623
+ indice_arr[triIndex++] = c;
38624
+ indice_arr[triIndex++] = a;
38625
+ indice_arr[triIndex++] = c;
38626
+ indice_arr[triIndex++] = d;
38627
+ }
38628
+ }
38629
+ }
38630
+ }
38631
+ this.setIndices(indice_arr);
38632
+ this.setAttribute(VertexAttributeName.position, position_arr);
38633
+ this.setAttribute(VertexAttributeName.normal, normal_arr);
38634
+ this.setAttribute(VertexAttributeName.uv, uv_arr);
38635
+ this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
38636
+ this.addSubGeometry({
38637
+ indexStart: 0,
38638
+ indexCount: indice_arr.length,
38639
+ vertexStart: 0,
38640
+ vertexCount: 0,
38641
+ firstStart: 0,
38642
+ index: 0,
38643
+ topology: 0
38644
+ });
38645
+ this.bounds = new BoundingBox(
38646
+ Vector3.ZERO,
38647
+ new Vector3(this.radius * 2, this.radius * 2, this.radius * 2)
38648
+ );
38649
+ }
38650
+ }
38651
+
38652
+ class WayPoint3D extends Object3D {
38653
+ static register3DRepresentation = null;
38654
+ positionIndex = -1;
38655
+ positionValid = false;
38656
+ marker;
38657
+ constructor(placemark) {
38658
+ super();
38659
+ this.parsePlacemark(placemark);
38660
+ this.setup3DRepresentation();
38661
+ }
38662
+ parsePlacemark(placemark) {
38663
+ if (!placemark.slamPositionInfo) {
38664
+ console.warn("WayPoint3D: slamPositionInfo is not found");
38665
+ return;
38666
+ }
38667
+ const slamPosition = placemark.slamPositionInfo.slamPosition.split(",").map(Number);
38668
+ this.localPosition = new Vector3(slamPosition[0], slamPosition[1], slamPosition[2]);
38669
+ this.positionIndex = Number(placemark.slamPositionInfo.slamPositionIndex);
38670
+ this.positionValid = placemark.slamPositionInfo.slamPositionValid === "1";
38671
+ }
38672
+ setup3DRepresentation() {
38673
+ if (this.marker) {
38674
+ this.removeChild(this.marker);
38675
+ this.marker = null;
38676
+ }
38677
+ if (WayPoint3D.register3DRepresentation) {
38678
+ this.marker = WayPoint3D.register3DRepresentation(this);
38679
+ if (this.marker) {
38680
+ this.addChild(this.marker);
38681
+ }
38682
+ } else {
38683
+ this.marker = new Object3D();
38684
+ const markerRenderer = this.marker.addComponent(MeshRenderer);
38685
+ markerRenderer.geometry = new SphereGeometry(0.1, 32, 16);
38686
+ markerRenderer.material = new LitMaterial();
38687
+ markerRenderer.material.baseColor = this.positionValid ? new Color(0, 1, 0, 1) : new Color(1, 0, 0, 1);
38688
+ this.addChild(this.marker);
38689
+ this.marker.name = "WayPoint3DMarker";
38690
+ }
38691
+ }
38692
+ }
38693
+
38694
+ class WayLines3D extends Object3D {
38695
+ static register3DRepresentation = null;
38696
+ line;
38697
+ constructor(wayLineFile) {
38698
+ super();
38699
+ this.parseWayLineFile(wayLineFile);
38700
+ this.setup3DRepresentation();
38701
+ }
38702
+ parseWayLineFile(wayLineFile) {
38703
+ for (const placemark of wayLineFile.Folder.Placemark) {
38704
+ const wayPoint3D = new WayPoint3D(placemark);
38705
+ this.addChild(wayPoint3D);
38706
+ }
38707
+ this.entityChildren = this.entityChildren.sort((a, b) => {
38708
+ return a.positionIndex - b.positionIndex;
38709
+ });
38710
+ }
38711
+ setup3DRepresentation() {
38712
+ if (this.line) {
38713
+ this.removeChild(this.line);
38714
+ this.line = null;
38715
+ }
38716
+ if (WayLines3D.register3DRepresentation) {
38717
+ this.line = WayLines3D.register3DRepresentation(this);
38718
+ if (this.line) {
38719
+ this.addChild(this.line);
38720
+ }
38721
+ } else {
38722
+ this.line = this.createMultiLine(this.entityChildren.map((child) => child.localPosition), new Color(1, 1, 1, 1));
38723
+ this.addChild(this.line);
38724
+ this.line.name = "WayLines3DLine";
38725
+ }
38726
+ }
38727
+ createMultiLine(positions, color) {
38728
+ if (positions.length < 2) {
38729
+ return null;
38730
+ }
38731
+ const lineGeometry = new GeometryBase();
38732
+ const vertices = new Float32Array(positions.length * 3);
38733
+ for (let i = 0; i < positions.length; i++) {
38734
+ vertices[i * 3] = positions[i].x;
38735
+ vertices[i * 3 + 1] = positions[i].y;
38736
+ vertices[i * 3 + 2] = positions[i].z;
38737
+ }
38738
+ const indices = new Uint16Array((positions.length - 1) * 2);
38739
+ for (let i = 0; i < positions.length - 1; i++) {
38740
+ indices[i * 2] = i;
38741
+ indices[i * 2 + 1] = i + 1;
38742
+ }
38743
+ lineGeometry.setIndices(indices);
38744
+ lineGeometry.setAttribute(VertexAttributeName.position, vertices);
38745
+ lineGeometry.addSubGeometry({
38746
+ indexStart: 0,
38747
+ indexCount: indices.length,
38748
+ vertexStart: 0,
38749
+ vertexCount: 0,
38750
+ firstStart: 0,
38751
+ index: 0,
38752
+ topology: 0
38753
+ });
38754
+ const lineObject = new Object3D();
38755
+ const lineRenderer = lineObject.addComponent(MeshRenderer);
38756
+ const material = new UnLitMaterial();
38757
+ material.topology = "line-list";
38758
+ material.baseColor = color;
38759
+ material.blendMode = BlendMode.ADD;
38760
+ material.castReflection = false;
38761
+ lineRenderer.geometry = lineGeometry;
38762
+ lineRenderer.material = material;
38763
+ return lineObject;
38764
+ }
38765
+ }
38766
+
38767
+ class KMZParser extends ParserBase {
38768
+ static format = ParserFormat.BIN;
38769
+ parseBuffer(buffer) {
38770
+ try {
38771
+ const kmzObj = {
38772
+ template: null,
38773
+ waylines: null
38774
+ };
38775
+ const zip = unzipSync(new Uint8Array(buffer));
38776
+ for (const path in zip) {
38777
+ const fileData = zip[path];
38778
+ const domParser = new DOMParser();
38779
+ const xmlDoc = domParser.parseFromString(strFromU8(fileData), "application/xml");
38780
+ const obj = {};
38781
+ this.parseNode(xmlDoc, obj);
38782
+ const objName = path.replace("wpmz/", "").split(".")[0];
38783
+ Object.assign(kmzObj, {
38784
+ [objName]: obj["#document"].kml.Document
38785
+ });
38786
+ }
38787
+ const wayline3D = new WayLines3D(kmzObj.waylines);
38788
+ this.data = wayline3D;
38789
+ } catch (error) {
38790
+ this.parserError(`KMZ parsing failed: ${error}`, -1);
38791
+ }
38792
+ }
38793
+ parseNode(xml, obj) {
38794
+ const arrayLikeName = ["Placemark", "actionGroup", "action"];
38795
+ const attr = xml.nodeName.replace("wpml:", "");
38796
+ if (!xml.childNodes.length) {
38797
+ obj[attr] = void 0;
38798
+ } else {
38799
+ let textValue = null;
38800
+ let hasElementChildren = false;
38801
+ for (let i = 0; i < xml.childNodes.length; ++i) {
38802
+ const childNode = xml.childNodes[i];
38803
+ if (childNode.nodeType == Node.TEXT_NODE) {
38804
+ const text = childNode.nodeValue?.trim();
38805
+ if (text && text.length > 0) {
38806
+ textValue = text;
38807
+ }
38808
+ } else if (childNode.nodeType == Node.ELEMENT_NODE) {
38809
+ hasElementChildren = true;
38810
+ }
38811
+ }
38812
+ if (textValue && !hasElementChildren) {
38813
+ obj[attr] = textValue;
38814
+ } else if (hasElementChildren) {
38815
+ if (arrayLikeName.includes(attr)) {
38816
+ if (obj[attr]?.length) {
38817
+ obj[attr].push({});
38818
+ } else {
38819
+ obj[attr] = [{}];
38820
+ }
38821
+ } else {
38822
+ obj[attr] = {};
38823
+ }
38824
+ for (let i = 0; i < xml.childNodes.length; ++i) {
38825
+ const childNode = xml.childNodes[i];
38826
+ if (childNode.nodeType == Node.ELEMENT_NODE) {
38827
+ this.parseNode(
38828
+ childNode,
38829
+ !Array.isArray(obj[attr]) ? obj[attr] : obj[attr].at(-1)
38830
+ );
38831
+ }
38832
+ }
38833
+ } else {
38834
+ obj[attr] = void 0;
38835
+ }
38836
+ }
38837
+ }
38838
+ verification() {
38839
+ if (this.data) {
38840
+ return true;
38841
+ }
38842
+ throw new Error("verify failed.");
38843
+ }
38844
+ }
38845
+
38010
38846
  class Res {
38011
38847
  _texturePool;
38012
38848
  _materialPool;
@@ -38236,6 +39072,11 @@ class Res {
38236
39072
  let parser = await loader.load(url, AtlasParser, loaderFunctions, url);
38237
39073
  return parser.data;
38238
39074
  }
39075
+ async loadKMZ(url, loaderFunctions) {
39076
+ let loader = new FileLoader();
39077
+ let parser = await loader.load(url, KMZParser, loaderFunctions);
39078
+ return parser.data;
39079
+ }
38239
39080
  normalTexture;
38240
39081
  maskTexture;
38241
39082
  whiteTexture;
@@ -38429,7 +39270,7 @@ class PostProcessingComponent extends ComponentBase {
38429
39270
  }
38430
39271
  }
38431
39272
 
38432
- const version = "1.0.3";
39273
+ const version = "1.0.4";
38433
39274
 
38434
39275
  class Engine3D {
38435
39276
  /**
@@ -41738,6 +42579,267 @@ let GIProbeShader = (
41738
42579
  `
41739
42580
  );
41740
42581
 
42582
+ const GSplat_VS = (
42583
+ /* wgsl */
42584
+ `
42585
+ #include "GlobalUniform"
42586
+
42587
+ struct VSOut {
42588
+ @location(auto) vColor : vec4f,
42589
+ @location(auto) vTexCoord : vec2f,
42590
+ @builtin(position) member : vec4f
42591
+ };
42592
+
42593
+ // ===== SPLAT CORE VS (from PlayCanvas shader-generator-gsplat.js) =====
42594
+
42595
+ // Uniforms (mapped to WebGPU bindings)
42596
+ // matrix_model, matrix_view, matrix_projection -> GlobalUniform + MaterialUniform
42597
+ // viewport -> calculated from globalUniform.windowWidth/Height
42598
+ // tex_params -> materialUniform.tex_params
42599
+
42600
+ @group(1) @binding(0) var splatColor : texture_2d<f32>;
42601
+ @group(1) @binding(1) var transformA : texture_2d<u32>;
42602
+ @group(1) @binding(2) var transformB : texture_2d<f32>;
42603
+ @group(1) @binding(4) var splatOrder : texture_2d<u32>;
42604
+
42605
+ struct MaterialUniform {
42606
+ tex_params: vec4f, // numSplats, textureWidth, validCount, visBoost
42607
+ modelMatrix: mat4x4<f32>,
42608
+ };
42609
+ @group(1) @binding(3) var<uniform> materialUniform : MaterialUniform;
42610
+
42611
+ // Global variables (like PlayCanvas)
42612
+ var<private> orderId: u32;
42613
+ var<private> splatId: u32;
42614
+ var<private> splatUV: vec2<i32>;
42615
+ var<private> tA: vec4<u32>;
42616
+
42617
+ // Helper: decode 16-bit half float
42618
+ fn unpackHalf(h: u32) -> f32 {
42619
+ let s = (h >> 15u) & 0x1u;
42620
+ let e = (h >> 10u) & 0x1fu;
42621
+ let m = h & 0x3ffu;
42622
+ let sign = select(1.0, -1.0, s == 1u);
42623
+ if (e == 0u) {
42624
+ if (m == 0u) { return 0.0; }
42625
+ return sign * (f32(m) * exp2(-24.0));
42626
+ } else if (e == 31u) {
42627
+ return sign * 65504.0;
42628
+ } else {
42629
+ return sign * (1.0 + f32(m) / 1024.0) * exp2(f32(i32(e) - 15));
42630
+ }
42631
+ }
42632
+
42633
+ // === calcSplatUV() - returns bool ===
42634
+ fn calcSplatUV(instance_id: u32) -> bool {
42635
+ let numSplats = u32(materialUniform.tex_params.x);
42636
+ let textureWidth = u32(materialUniform.tex_params.y);
42637
+
42638
+ // calculate splat index
42639
+ orderId = instance_id;
42640
+
42641
+ if (orderId >= numSplats) {
42642
+ return false;
42643
+ }
42644
+
42645
+ let orderUV = vec2<i32>(
42646
+ i32(orderId % textureWidth),
42647
+ i32(orderId / textureWidth)
42648
+ );
42649
+
42650
+ // calculate splatUV
42651
+ splatId = textureLoad(splatOrder, orderUV, 0).r;
42652
+ splatUV = vec2<i32>(
42653
+ i32(splatId % textureWidth),
42654
+ i32(splatId / textureWidth)
42655
+ );
42656
+
42657
+ return true;
42658
+ }
42659
+
42660
+ // === getCenter() - returns vec3 ===
42661
+ fn getCenter() -> vec3f {
42662
+ tA = textureLoad(transformA, splatUV, 0);
42663
+ return vec3f(bitcast<f32>(tA.x), bitcast<f32>(tA.y), bitcast<f32>(tA.z));
42664
+ }
42665
+
42666
+ // Struct to return covA and covB
42667
+ struct CovarianceData {
42668
+ covA: vec3f,
42669
+ covB: vec3f,
42670
+ };
42671
+
42672
+ // === getCovariance() - returns struct ===
42673
+ fn getCovariance() -> CovarianceData {
42674
+ let tB = textureLoad(transformB, splatUV, 0);
42675
+
42676
+ // unpackHalf2x16 equivalent
42677
+ let h1 = tA.w & 0xFFFFu;
42678
+ let h2 = (tA.w >> 16u) & 0xFFFFu;
42679
+ let tCx = unpackHalf(h1);
42680
+ let tCy = unpackHalf(h2);
42681
+
42682
+ var result: CovarianceData;
42683
+ result.covA = tB.xyz;
42684
+ result.covB = vec3f(tCx, tCy, tB.w);
42685
+
42686
+ return result;
42687
+ }
42688
+
42689
+ // === calcV1V2() - returns vec4 ===
42690
+ fn calcV1V2(splat_cam: vec3f, covA: vec3f, covB: vec3f, W: mat3x3f, viewport: vec2f, projMat: mat4x4f) -> vec4f {
42691
+ let Vrk = mat3x3f(
42692
+ vec3f(covA.x, covA.y, covA.z),
42693
+ vec3f(covA.y, covB.x, covB.y),
42694
+ vec3f(covA.z, covB.y, covB.z)
42695
+ );
42696
+
42697
+ let focal = viewport.x * abs(projMat[0][0]);
42698
+
42699
+ let J1 = focal / abs(splat_cam.z);
42700
+ let J2 = -J1 / abs(splat_cam.z) * splat_cam.xy;
42701
+ let J = mat3x3f(
42702
+ vec3f(J1, 0.0, J2.x),
42703
+ vec3f(0.0, J1, J2.y),
42704
+ vec3f(0.0, 0.0, 0.0)
42705
+ );
42706
+
42707
+ let T = W * J;
42708
+ let cov = transpose(T) * Vrk * T;
42709
+
42710
+ let diagonal1 = cov[0][0] + 0.3;
42711
+ let offDiagonal = cov[0][1];
42712
+ let diagonal2 = cov[1][1] + 0.3;
42713
+
42714
+ let mid = 0.5 * (diagonal1 + diagonal2);
42715
+ let radius = length(vec2f((diagonal1 - diagonal2) / 2.0, offDiagonal));
42716
+ let lambda1 = mid + radius;
42717
+ let lambda2 = max(mid - radius, 0.1);
42718
+ let diagonalVector = normalize(vec2f(offDiagonal, lambda1 - diagonal1));
42719
+
42720
+ let v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;
42721
+ let v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2f(diagonalVector.y, -diagonalVector.x);
42722
+
42723
+ return vec4f(v1, v2);
42724
+ }
42725
+
42726
+ // ===== SPLAT MAIN VS (from PlayCanvas gsplat-material.js) =====
42727
+
42728
+ @vertex
42729
+ fn VertMain(
42730
+ @builtin(vertex_index) vid : u32,
42731
+ @builtin(instance_index) iid : u32
42732
+ ) -> VSOut {
42733
+ var o: VSOut;
42734
+ let discardVec = vec4f(0.0, 0.0, 2.0, 1.0);
42735
+
42736
+ // Vertex position array (PlayCanvas uses attribute vec3 with x,y in [-1,1])
42737
+ let vertex_position = array<vec2f, 4>(
42738
+ vec2f(-2.0, -2.0),
42739
+ vec2f( 2.0, -2.0),
42740
+ vec2f(-2.0, 2.0),
42741
+ vec2f( 2.0, 2.0)
42742
+ );
42743
+ let vertex_pos = vertex_position[vid & 3u];
42744
+
42745
+ // calculate splat uv
42746
+ if (!calcSplatUV(iid)) {
42747
+ o.member = discardVec;
42748
+ o.vColor = vec4f(0.0);
42749
+ o.vTexCoord = vec2f(0.0);
42750
+ return o;
42751
+ }
42752
+
42753
+ // get center
42754
+ let center = getCenter();
42755
+
42756
+ // handle transforms
42757
+ let matrix_view = globalUniform.viewMat;
42758
+ let matrix_projection = globalUniform.projMat;
42759
+ let matrix_model = materialUniform.modelMatrix;
42760
+
42761
+ let model_view = matrix_view * matrix_model;
42762
+ let splat_cam = model_view * vec4f(center, 1.0);
42763
+ let splat_proj = matrix_projection * splat_cam;
42764
+
42765
+ // cull behind camera (WebGPU: NDC z in [0,1], cull if z/w < 0)
42766
+ if (splat_proj.z < 0.0) {
42767
+ o.member = discardVec;
42768
+ o.vColor = vec4f(0.0);
42769
+ o.vTexCoord = vec2f(0.0);
42770
+ return o;
42771
+ }
42772
+
42773
+ // get covariance
42774
+ let cov_data = getCovariance();
42775
+
42776
+ let viewport = vec2f(globalUniform.windowWidth, globalUniform.windowHeight);
42777
+ 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);
42778
+
42779
+ // get color
42780
+ let color = textureLoad(splatColor, splatUV, 0);
42781
+
42782
+ // calculate scale based on alpha
42783
+ let scale = min(1.0, sqrt(-log(1.0 / 255.0 / color.a)) / 2.0);
42784
+
42785
+ // apply visBoost (size multiplier)
42786
+ let visBoost = materialUniform.tex_params.w;
42787
+ var v1v2_scaled = v1v2 * scale * visBoost;
42788
+
42789
+ // early out tiny splats
42790
+ if (dot(v1v2_scaled.xy, v1v2_scaled.xy) < 4.0 && dot(v1v2_scaled.zw, v1v2_scaled.zw) < 4.0) {
42791
+ o.member = discardVec;
42792
+ o.vColor = vec4f(0.0);
42793
+ o.vTexCoord = vec2f(0.0);
42794
+ return o;
42795
+ }
42796
+
42797
+ // gl_Position = splat_proj + vec4((vertex_position.x * v1v2.xy + vertex_position.y * v1v2.zw) / viewport * splat_proj.w, 0, 0);
42798
+ 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);
42799
+
42800
+ // texCoord = vertex_position.xy * scale / 2.0;
42801
+ o.vTexCoord = vertex_pos * scale / 2.0;
42802
+
42803
+ o.vColor = color;
42804
+
42805
+ return o;
42806
+ }
42807
+ `
42808
+ );
42809
+ const GSplat_FS = (
42810
+ /* wgsl */
42811
+ `
42812
+ #include "FragmentOutput"
42813
+
42814
+ // === evalSplat() - like PlayCanvas splatCoreFS ===
42815
+ fn evalSplat(texCoord: vec2f, color: vec4f) -> vec4f {
42816
+ let A = dot(texCoord, texCoord);
42817
+ if (A > 1.0) {
42818
+ discard;
42819
+ }
42820
+
42821
+ let B = exp(-A * 4.0) * color.a;
42822
+ if (B < 1.0 / 255.0) {
42823
+ discard;
42824
+ }
42825
+
42826
+ // TONEMAP_ENABLED branch not implemented (would call toneMap() and gammaCorrectOutput())
42827
+ return vec4f(color.rgb, B);
42828
+ }
42829
+
42830
+ // === main() - like PlayCanvas splatMainFS ===
42831
+ @fragment
42832
+ fn FragMain(@location(auto) vColor: vec4f, @location(auto) vTexCoord: vec2f) -> FragmentOutput {
42833
+ let result = evalSplat(vTexCoord, vColor);
42834
+
42835
+ var o: FragmentOutput;
42836
+ o.color = result;
42837
+ o.gBuffer = vec4f(0.0);
42838
+ return o;
42839
+ }
42840
+ `
42841
+ );
42842
+
41741
42843
  let GlassShader = (
41742
42844
  /*wgsl */
41743
42845
  `
@@ -42942,9 +44044,9 @@ class AtmosphericTexture2D extends VirtualTexture {
42942
44044
  }
42943
44045
  }
42944
44046
 
42945
- var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
42946
- var __decorateClass$a = (decorators, target, key, kind) => {
42947
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
44047
+ var __getOwnPropDesc$b = Object.getOwnPropertyDescriptor;
44048
+ var __decorateClass$b = (decorators, target, key, kind) => {
44049
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target;
42948
44050
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
42949
44051
  if (decorator = decorators[i])
42950
44052
  result = (decorator(result)) || result;
@@ -42968,7 +44070,7 @@ let SkyShader = class extends Shader {
42968
44070
  shaderState.depthCompare = GPUCompareFunction.less;
42969
44071
  }
42970
44072
  };
42971
- SkyShader = __decorateClass$a([
44073
+ SkyShader = __decorateClass$b([
42972
44074
  RegisterShader(SkyShader, "SkyShader")
42973
44075
  ], SkyShader);
42974
44076
 
@@ -43013,113 +44115,6 @@ class SkyMaterial extends Material {
43013
44115
  }
43014
44116
  }
43015
44117
 
43016
- class SphereGeometry extends GeometryBase {
43017
- shape_vertices = [];
43018
- shape_indices = [];
43019
- radius;
43020
- widthSegments;
43021
- heightSegments;
43022
- phiStart;
43023
- phiLength;
43024
- thetaStart;
43025
- thetaLength;
43026
- /**
43027
- * 球体几何体
43028
- * @constructor
43029
- * @param radius 球体半径
43030
- * @param widthSegments 定义水平分段数
43031
- * @param heightSegments 定义垂直分段数
43032
- * @param phiStart 球体赤道线起始点的弧度
43033
- * @param phiLength 球体赤道线的弧长
43034
- * @param thetaStart 球体经线起始点的弧度
43035
- * @param thetaLength 球体经线的弧长
43036
- */
43037
- constructor(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {
43038
- super();
43039
- this.radius = radius;
43040
- this.widthSegments = widthSegments;
43041
- this.heightSegments = heightSegments;
43042
- this.phiStart = phiStart;
43043
- this.phiLength = phiLength;
43044
- this.thetaStart = thetaStart;
43045
- this.thetaLength = thetaLength;
43046
- this.buildGeometry();
43047
- }
43048
- buildGeometry() {
43049
- var i, j, triIndex = 0;
43050
- let _segmentsH = this.heightSegments;
43051
- let _segmentsW = this.widthSegments;
43052
- let _radius = this.radius;
43053
- var vertexCount = (_segmentsH + 1) * (_segmentsW + 1);
43054
- let position_arr = new Float32Array(vertexCount * 3);
43055
- let normal_arr = new Float32Array(vertexCount * 3);
43056
- let uv_arr = new Float32Array(vertexCount * 2);
43057
- let indice_arr = new Uint16Array(_segmentsW * _segmentsH * 2 * 3);
43058
- let pi = 0;
43059
- let ni = 0;
43060
- let ui = 0;
43061
- for (j = 0; j <= _segmentsH; ++j) {
43062
- var horAngle = Math.PI * j / _segmentsH;
43063
- var y = _radius * Math.cos(horAngle);
43064
- var ringRadius = _radius * Math.sin(horAngle);
43065
- for (i = 0; i <= _segmentsW; ++i) {
43066
- var verAngle = 2 * Math.PI * i / _segmentsW;
43067
- var x = ringRadius * Math.cos(verAngle);
43068
- var z = ringRadius * Math.sin(verAngle);
43069
- var normLen = 1 / Math.sqrt(x * x + y * y + z * z);
43070
- position_arr[pi++] = x;
43071
- position_arr[pi++] = y;
43072
- position_arr[pi++] = z;
43073
- normal_arr[ni++] = x * normLen;
43074
- normal_arr[ni++] = y * normLen;
43075
- normal_arr[ni++] = z * normLen;
43076
- uv_arr[ui++] = i / _segmentsW;
43077
- uv_arr[ui++] = j / _segmentsH;
43078
- if (i > 0 && j > 0) {
43079
- var a = (_segmentsW + 1) * j + i;
43080
- var b = (_segmentsW + 1) * j + i - 1;
43081
- var c = (_segmentsW + 1) * (j - 1) + i - 1;
43082
- var d = (_segmentsW + 1) * (j - 1) + i;
43083
- if (j == _segmentsH) {
43084
- indice_arr[triIndex++] = a;
43085
- indice_arr[triIndex++] = c;
43086
- indice_arr[triIndex++] = d;
43087
- } else if (j == 1) {
43088
- indice_arr[triIndex++] = a;
43089
- indice_arr[triIndex++] = b;
43090
- indice_arr[triIndex++] = c;
43091
- } else {
43092
- indice_arr[triIndex++] = a;
43093
- indice_arr[triIndex++] = b;
43094
- indice_arr[triIndex++] = c;
43095
- indice_arr[triIndex++] = a;
43096
- indice_arr[triIndex++] = c;
43097
- indice_arr[triIndex++] = d;
43098
- }
43099
- }
43100
- }
43101
- }
43102
- this.setIndices(indice_arr);
43103
- this.setAttribute(VertexAttributeName.position, position_arr);
43104
- this.setAttribute(VertexAttributeName.normal, normal_arr);
43105
- this.setAttribute(VertexAttributeName.uv, uv_arr);
43106
- this.setAttribute(VertexAttributeName.TEXCOORD_1, uv_arr);
43107
- this.addSubGeometry({
43108
- indexStart: 0,
43109
- indexCount: indice_arr.length,
43110
- vertexStart: 0,
43111
- vertexCount: 0,
43112
- firstStart: 0,
43113
- index: 0,
43114
- topology: 0
43115
- });
43116
- this.bounds = new BoundingBox(
43117
- Vector3.ZERO,
43118
- new Vector3(this.radius * 2, this.radius * 2, this.radius * 2)
43119
- );
43120
- }
43121
- }
43122
-
43123
44118
  class Reflection extends RenderNode {
43124
44119
  gid = 0;
43125
44120
  needUpdate = true;
@@ -43873,9 +44868,9 @@ class SkeletonAnimationClipState {
43873
44868
  }
43874
44869
  }
43875
44870
 
43876
- var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
43877
- var __decorateClass$9 = (decorators, target, key, kind) => {
43878
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
44871
+ var __getOwnPropDesc$a = Object.getOwnPropertyDescriptor;
44872
+ var __decorateClass$a = (decorators, target, key, kind) => {
44873
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target;
43879
44874
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
43880
44875
  if (decorator = decorators[i])
43881
44876
  result = (decorator(result)) || result;
@@ -44079,7 +45074,7 @@ let SkeletonAnimationComponent = class extends ComponentBase {
44079
45074
  this._currentClipState.weight = 1;
44080
45075
  }
44081
45076
  };
44082
- SkeletonAnimationComponent = __decorateClass$9([
45077
+ SkeletonAnimationComponent = __decorateClass$a([
44083
45078
  RegisterComponent(SkeletonAnimationComponent, "SkeletonAnimationComponent")
44084
45079
  ], SkeletonAnimationComponent);
44085
45080
  class SkeletonAnimationCrossFadeState {
@@ -44115,9 +45110,9 @@ class SkeletonAnimationCrossFadeState {
44115
45110
  }
44116
45111
  }
44117
45112
 
44118
- var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
44119
- var __decorateClass$8 = (decorators, target, key, kind) => {
44120
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
45113
+ var __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor;
45114
+ var __decorateClass$9 = (decorators, target, key, kind) => {
45115
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target;
44121
45116
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
44122
45117
  if (decorator = decorators[i])
44123
45118
  result = (decorator(result)) || result;
@@ -44528,7 +45523,7 @@ let AnimatorComponent = class extends ComponentBase {
44528
45523
  return dst;
44529
45524
  }
44530
45525
  };
44531
- AnimatorComponent = __decorateClass$8([
45526
+ AnimatorComponent = __decorateClass$9([
44532
45527
  RegisterComponent(AnimatorComponent, "AnimatorComponent")
44533
45528
  ], AnimatorComponent);
44534
45529
  class PropertyAnimationClipState {
@@ -45285,9 +46280,9 @@ class PropertyAnimation extends ComponentBase {
45285
46280
  }
45286
46281
  }
45287
46282
 
45288
- var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
45289
- var __decorateClass$7 = (decorators, target, key, kind) => {
45290
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
46283
+ var __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor;
46284
+ var __decorateClass$8 = (decorators, target, key, kind) => {
46285
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target;
45291
46286
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
45292
46287
  if (decorator = decorators[i])
45293
46288
  result = (decorator(result)) || result;
@@ -45436,7 +46431,7 @@ let SkinnedMeshRenderer2 = class extends MeshRenderer {
45436
46431
  super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
45437
46432
  }
45438
46433
  };
45439
- SkinnedMeshRenderer2 = __decorateClass$7([
46434
+ SkinnedMeshRenderer2 = __decorateClass$8([
45440
46435
  RegisterComponent(SkinnedMeshRenderer2, "SkinnedMeshRenderer2")
45441
46436
  ], SkinnedMeshRenderer2);
45442
46437
 
@@ -50566,9 +51561,9 @@ class UITextField extends UIRenderAble {
50566
51561
  }
50567
51562
  }
50568
51563
 
50569
- var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
50570
- var __decorateClass$6 = (decorators, target, key, kind) => {
50571
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
51564
+ var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
51565
+ var __decorateClass$7 = (decorators, target, key, kind) => {
51566
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target;
50572
51567
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
50573
51568
  if (decorator = decorators[i])
50574
51569
  result = (decorator(result)) || result;
@@ -50645,10 +51640,802 @@ let Light = class extends LightBase {
50645
51640
  debugDraw(show) {
50646
51641
  }
50647
51642
  };
50648
- Light = __decorateClass$6([
51643
+ Light = __decorateClass$7([
50649
51644
  RegisterComponent(Light, "Light")
50650
51645
  ], Light);
50651
51646
 
51647
+ class GSplatMaterial extends Material {
51648
+ constructor() {
51649
+ super();
51650
+ ShaderLib.register("gsplat_vs_dc", GSplat_VS);
51651
+ ShaderLib.register("gsplat_fs_dc", GSplat_FS);
51652
+ const pass = new RenderShaderPass("gsplat_vs_dc", "gsplat_fs_dc");
51653
+ pass.passType = PassType.COLOR;
51654
+ pass.setShaderEntry("VertMain", "FragMain");
51655
+ pass.topology = GPUPrimitiveTopology.triangle_strip;
51656
+ pass.depthWriteEnabled = false;
51657
+ pass.cullMode = "none";
51658
+ pass.shaderState.transparent = true;
51659
+ pass.shaderState.blendMode = BlendMode.NORMAL;
51660
+ pass.shaderState.writeMasks = [15, 15];
51661
+ const shader = new Shader();
51662
+ shader.addRenderPass(pass);
51663
+ this.shader = shader;
51664
+ }
51665
+ setSplatTextures(splatColor, transformA, transformB, texParams, splatOrder) {
51666
+ const pass = this.shader.getDefaultColorShader();
51667
+ pass.setTexture("splatColor", splatColor);
51668
+ pass.setTexture("transformA", transformA);
51669
+ pass.setTexture("transformB", transformB);
51670
+ pass.setUniformArray("tex_params", texParams);
51671
+ if (splatOrder) {
51672
+ pass.setTexture("splatOrder", splatOrder);
51673
+ }
51674
+ }
51675
+ /**
51676
+ * Set the model matrix for transforming splats to world space
51677
+ */
51678
+ setTransformMatrix(matrix) {
51679
+ const pass = this.shader.getDefaultColorShader();
51680
+ pass.setUniform("modelMatrix", matrix.rawData);
51681
+ }
51682
+ }
51683
+
51684
+ class Uint32ArrayTexture extends Texture {
51685
+ _dataBuffer;
51686
+ create(width, height, data) {
51687
+ let device = webGPUContext.device;
51688
+ const bytesPerRow = width * 4 * 4;
51689
+ this.format = GPUTextureFormat.rgba32uint;
51690
+ const mipmapCount = 1;
51691
+ this.createTextureDescriptor(width, height, mipmapCount, this.format);
51692
+ const textureDataBuffer = this._dataBuffer = device.createBuffer({
51693
+ size: data.byteLength,
51694
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
51695
+ });
51696
+ device.queue.writeBuffer(textureDataBuffer, 0, data.buffer);
51697
+ const encoder = device.createCommandEncoder();
51698
+ encoder.copyBufferToTexture(
51699
+ { buffer: textureDataBuffer, bytesPerRow },
51700
+ { texture: this.getGPUTexture() },
51701
+ { width, height, depthOrArrayLayers: 1 }
51702
+ );
51703
+ device.queue.submit([encoder.finish()]);
51704
+ this.samplerBindingLayout.type = `non-filtering`;
51705
+ this.textureBindingLayout.sampleType = `uint`;
51706
+ this.gpuSampler = device.createSampler({});
51707
+ return this;
51708
+ }
51709
+ updateTexture(width, height, data) {
51710
+ let device = webGPUContext.device;
51711
+ const bytesPerRow = width * 4 * 4;
51712
+ const staging = device.createBuffer({
51713
+ size: data.byteLength,
51714
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
51715
+ });
51716
+ device.queue.writeBuffer(staging, 0, data.buffer);
51717
+ const encoder = device.createCommandEncoder();
51718
+ encoder.copyBufferToTexture(
51719
+ { buffer: staging, bytesPerRow },
51720
+ { texture: this.getGPUTexture() },
51721
+ { width, height, depthOrArrayLayers: 1 }
51722
+ );
51723
+ device.queue.submit([encoder.finish()]);
51724
+ }
51725
+ }
51726
+
51727
+ class Float16ArrayTexture extends Texture {
51728
+ uint16Array;
51729
+ floatArray;
51730
+ _dataBuffer;
51731
+ /**
51732
+ * 使用数字数组填充纹理,格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
51733
+ * @param width 纹理宽度
51734
+ * @param height 纹理高度
51735
+ * @param numbers 每个像素的颜色值数组
51736
+ * @param useMipmap 是否生成Mipmap
51737
+ * @returns 返回纹理实例
51738
+ */
51739
+ create(width, height, numbers = null, mipmap = true) {
51740
+ if (numbers == null) {
51741
+ numbers = [];
51742
+ for (let i = 0, c = width * height * 4; i < c; i++) {
51743
+ numbers[i] = 0;
51744
+ }
51745
+ }
51746
+ this.updateTexture(width, height, numbers, mipmap);
51747
+ return this;
51748
+ }
51749
+ /**
51750
+ * 更新纹理内容
51751
+ * @param width 纹理宽度
51752
+ * @param height 纹理高度
51753
+ * @param numbers 像素数据数组
51754
+ * @param mipmap 是否生成Mipmap
51755
+ */
51756
+ updateTexture(width, height, numbers, mipmap = true) {
51757
+ if (width != this.width || height != this.height) {
51758
+ this._dataBuffer && this._dataBuffer.destroy();
51759
+ this._dataBuffer = null;
51760
+ this.gpuTexture && this.gpuTexture.destroy();
51761
+ this.gpuTexture = null;
51762
+ }
51763
+ this.floatArray = numbers;
51764
+ let device = webGPUContext.device;
51765
+ const bytesPerRow = width * 4 * 2;
51766
+ this.format = GPUTextureFormat.rgba16float;
51767
+ this.mipmapCount = Math.floor(mipmap ? Math.log2(width) : 1);
51768
+ this.createTextureDescriptor(width, height, this.mipmapCount, this.format);
51769
+ if (!this.uint16Array || this.uint16Array.length != numbers.length) {
51770
+ this.uint16Array = new Uint16Array(numbers.length);
51771
+ }
51772
+ let uint16Array = this.uint16Array;
51773
+ for (let i = 0, c = uint16Array.length; i < c; i++) {
51774
+ uint16Array[i] = toHalfFloat(numbers[i]);
51775
+ }
51776
+ const textureDataBuffer = this._dataBuffer = device.createBuffer({
51777
+ size: uint16Array.byteLength,
51778
+ usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
51779
+ });
51780
+ device.queue.writeBuffer(textureDataBuffer, 0, uint16Array);
51781
+ const commandEncoder = GPUContext.beginCommandEncoder();
51782
+ commandEncoder.copyBufferToTexture(
51783
+ {
51784
+ buffer: textureDataBuffer,
51785
+ bytesPerRow
51786
+ },
51787
+ {
51788
+ texture: this.getGPUTexture()
51789
+ },
51790
+ {
51791
+ width,
51792
+ height,
51793
+ depthOrArrayLayers: 1
51794
+ }
51795
+ );
51796
+ if (!this.useMipmap) {
51797
+ this.samplerBindingLayout.type = `filtering`;
51798
+ this.textureBindingLayout.sampleType = `float`;
51799
+ }
51800
+ GPUContext.endCommandEncoder(commandEncoder);
51801
+ this.gpuSampler = device.createSampler(this);
51802
+ this.gpuTexture = this.getGPUTexture();
51803
+ if (this.mipmapCount > 1) TextureMipmapGenerator.webGPUGenerateMipmap(this);
51804
+ }
51805
+ }
51806
+
51807
+ var __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor;
51808
+ var __decorateClass$6 = (decorators, target, key, kind) => {
51809
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target;
51810
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
51811
+ if (decorator = decorators[i])
51812
+ result = (decorator(result)) || result;
51813
+ return result;
51814
+ };
51815
+ let GSplatRenderer = class extends RenderNode {
51816
+ // Splat count and texture dimensions
51817
+ count = 0;
51818
+ size = new Vector2();
51819
+ // GPU textures for splat data
51820
+ splatColor;
51821
+ transformA;
51822
+ transformB;
51823
+ texParams;
51824
+ // [numSplats, texWidth, validCount, visBoost]
51825
+ splatOrder;
51826
+ // Material and geometry
51827
+ gsplatMaterial;
51828
+ // CPU-side data for sorting
51829
+ _positions;
51830
+ // xyz per splat (local space)
51831
+ _worldPositions;
51832
+ // xyz per splat (world space, cached)
51833
+ _orderData;
51834
+ // RGBA32U backing: size.x * size.y * 4
51835
+ // Web Worker for sorting
51836
+ _sortWorker;
51837
+ _lastSentTime = 0;
51838
+ _minIntervalMs = 0;
51839
+ // No throttle for immediate sorting
51840
+ _centersSent = false;
51841
+ _lastViewMatrixHash = 0;
51842
+ // Mapping support (optional subset rendering)
51843
+ _mapping = null;
51844
+ _fullCount = 0;
51845
+ // Original total count
51846
+ constructor() {
51847
+ super();
51848
+ }
51849
+ /**
51850
+ * Initialize from Gaussian Splat asset
51851
+ */
51852
+ initAsset(asset) {
51853
+ this.count = asset.count;
51854
+ this._fullCount = asset.count;
51855
+ this.size = this.evalTextureSize(asset.count);
51856
+ this.buildColor(asset);
51857
+ this.buildTransform(asset);
51858
+ this.texParams = new Float32Array([this.count, this.size.x, this.count, 1]);
51859
+ this._positions = asset.position;
51860
+ const total = this.size.x * this.size.y;
51861
+ this._orderData = new Uint32Array(total * 4);
51862
+ for (let i = 0; i < total; i++) {
51863
+ const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
51864
+ const base = i * 4;
51865
+ this._orderData[base + 0] = src;
51866
+ this._orderData[base + 1] = 0;
51867
+ this._orderData[base + 2] = 0;
51868
+ this._orderData[base + 3] = 0;
51869
+ }
51870
+ this.splatOrder = new Uint32ArrayTexture().create(this.size.x, this.size.y, this._orderData);
51871
+ this.splatOrder.name = "splatOrder";
51872
+ this.splatOrder.minFilter = "nearest";
51873
+ this.splatOrder.magFilter = "nearest";
51874
+ this.splatOrder.addressModeU = "clamp-to-edge";
51875
+ this.splatOrder.addressModeV = "clamp-to-edge";
51876
+ this.gsplatMaterial = new GSplatMaterial();
51877
+ this.geometry = new PlaneGeometry(1, 1, 1, 1);
51878
+ this.materials = [this.gsplatMaterial];
51879
+ }
51880
+ /**
51881
+ * Update splat sorting before rendering
51882
+ * This runs every frame to ensure correct depth ordering for alpha blending
51883
+ */
51884
+ onBeforeUpdate(view) {
51885
+ if (this.count > 0 && view?.camera?.viewMatrix) {
51886
+ this.scheduleOrder(view.camera.viewMatrix);
51887
+ }
51888
+ }
51889
+ /**
51890
+ * Set rendering subset mapping
51891
+ * Pass null/undefined to cancel mapping
51892
+ */
51893
+ setMapping(mapping) {
51894
+ this._mapping = mapping && mapping.length > 0 ? mapping : null;
51895
+ this.count = this._mapping ? this._mapping.length : this._fullCount;
51896
+ this.texParams[0] = this.count;
51897
+ this.texParams[2] = Math.min(this.texParams[0], this.count);
51898
+ const total = this.size.x * this.size.y;
51899
+ for (let i = 0; i < total; i++) {
51900
+ const src = i < this.count ? i : this.count > 0 ? this.count - 1 : 0;
51901
+ const base = i * 4;
51902
+ this._orderData[base + 0] = src;
51903
+ this._orderData[base + 1] = 0;
51904
+ this._orderData[base + 2] = 0;
51905
+ this._orderData[base + 3] = 0;
51906
+ }
51907
+ this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
51908
+ if (this._sortWorker) {
51909
+ const worldPos = this._worldPositions || this._positions;
51910
+ const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
51911
+ if (this._mapping) {
51912
+ for (let i = 0; i < this._mapping.length; ++i) {
51913
+ const src = this._mapping[i] * 3;
51914
+ const dst = i * 3;
51915
+ centers[dst + 0] = worldPos[src + 0];
51916
+ centers[dst + 1] = worldPos[src + 1];
51917
+ centers[dst + 2] = worldPos[src + 2];
51918
+ }
51919
+ }
51920
+ this._sortWorker.postMessage(
51921
+ {
51922
+ type: "centers",
51923
+ centers: centers.buffer,
51924
+ mapping: this._mapping ? this._mapping : null
51925
+ },
51926
+ [centers.buffer]
51927
+ );
51928
+ this._centersSent = true;
51929
+ } else {
51930
+ this._centersSent = false;
51931
+ }
51932
+ }
51933
+ /**
51934
+ * Set visibility boost factor (material uniform tex_params.w)
51935
+ */
51936
+ setVisBoost(v) {
51937
+ this.texParams[3] = Math.max(0, v);
51938
+ }
51939
+ /**
51940
+ * Set sort throttle interval (milliseconds)
51941
+ */
51942
+ setSortThrottle(ms) {
51943
+ this._minIntervalMs = Math.max(0, ms | 0);
51944
+ }
51945
+ /**
51946
+ * Calculate texture size for given splat count
51947
+ */
51948
+ evalTextureSize(count) {
51949
+ let w = Math.ceil(Math.sqrt(count));
51950
+ const align = 64;
51951
+ w = Math.ceil(w / align) * align;
51952
+ const h = Math.ceil(count / w);
51953
+ return new Vector2(w, h);
51954
+ }
51955
+ /**
51956
+ * Build color texture from asset
51957
+ */
51958
+ buildColor(asset) {
51959
+ const w = this.size.x | 0;
51960
+ const h = this.size.y | 0;
51961
+ const data = new Uint8Array(w * h * 4);
51962
+ const SH_C0 = 0.28209479177387814;
51963
+ const count = asset.count;
51964
+ const coeffs = asset.sh?.coeffs;
51965
+ const coeffsPerColor = coeffs ? coeffs.length / (3 * count) : 1;
51966
+ for (let i = 0; i < count; i++) {
51967
+ let r = 0.5, g = 0.5, b = 0.5;
51968
+ if (coeffs && coeffsPerColor >= 1) {
51969
+ const baseIndex = i * coeffsPerColor * 3;
51970
+ r = 0.5 + coeffs[baseIndex + 0] * SH_C0;
51971
+ g = 0.5 + coeffs[baseIndex + coeffsPerColor + 0] * SH_C0;
51972
+ b = 0.5 + coeffs[baseIndex + 2 * coeffsPerColor + 0] * SH_C0;
51973
+ }
51974
+ const a = asset.opacity ? 1 / (1 + Math.exp(-asset.opacity[i])) : 1;
51975
+ const idx = i * 4;
51976
+ data[idx + 0] = Math.max(0, Math.min(255, Math.floor(r * 255)));
51977
+ data[idx + 1] = Math.max(0, Math.min(255, Math.floor(g * 255)));
51978
+ data[idx + 2] = Math.max(0, Math.min(255, Math.floor(b * 255)));
51979
+ data[idx + 3] = Math.max(0, Math.min(255, Math.floor(a * 255)));
51980
+ }
51981
+ this.splatColor = new Uint8ArrayTexture().create(w, h, data, false);
51982
+ this.splatColor.name = "splatColor";
51983
+ this.splatColor.minFilter = "nearest";
51984
+ this.splatColor.magFilter = "nearest";
51985
+ this.splatColor.mipmapFilter = "nearest";
51986
+ this.splatColor.addressModeU = "clamp-to-edge";
51987
+ this.splatColor.addressModeV = "clamp-to-edge";
51988
+ }
51989
+ /**
51990
+ * Build transform textures from asset
51991
+ */
51992
+ buildTransform(asset) {
51993
+ const w = this.size.x | 0;
51994
+ const h = this.size.y | 0;
51995
+ const count = asset.count;
51996
+ const tA = new Uint32Array(w * h * 4);
51997
+ const tB = new Array(w * h * 4).fill(0);
51998
+ const fb = new ArrayBuffer(4);
51999
+ const f32 = new Float32Array(fb);
52000
+ const u32 = new Uint32Array(fb);
52001
+ const setFloatBits = (v) => {
52002
+ f32[0] = v;
52003
+ return u32[0];
52004
+ };
52005
+ const pos = asset.position;
52006
+ const rot = asset.rotation;
52007
+ const scl = asset.scale;
52008
+ let maxScale = 0;
52009
+ let minScale = Infinity;
52010
+ let maxCov = 0;
52011
+ for (let i = 0; i < count; i++) {
52012
+ const idx = i * 4;
52013
+ const x = pos[i * 3 + 0];
52014
+ const y = pos[i * 3 + 1];
52015
+ const z = pos[i * 3 + 2];
52016
+ tA[idx + 0] = setFloatBits(x);
52017
+ tA[idx + 1] = setFloatBits(y);
52018
+ tA[idx + 2] = setFloatBits(z);
52019
+ let qx = 0, qy = 0, qz = 0, qw = 1;
52020
+ if (rot) {
52021
+ qx = rot[i * 4 + 0];
52022
+ qy = rot[i * 4 + 1];
52023
+ qz = rot[i * 4 + 2];
52024
+ qw = rot[i * 4 + 3];
52025
+ const inv = 1 / Math.hypot(qx, qy, qz, qw);
52026
+ qx *= inv;
52027
+ qy *= inv;
52028
+ qz *= inv;
52029
+ qw *= inv;
52030
+ }
52031
+ let sx = 1, sy = 1, sz = 1;
52032
+ if (scl) {
52033
+ sx = Math.exp(scl[i * 3 + 0]);
52034
+ sy = Math.exp(scl[i * 3 + 1]);
52035
+ sz = Math.exp(scl[i * 3 + 2]);
52036
+ maxScale = Math.max(maxScale, sx, sy, sz);
52037
+ minScale = Math.min(minScale, sx, sy, sz);
52038
+ }
52039
+ const xx = qx * qx, yy = qy * qy, zz = qz * qz;
52040
+ const xy = qx * qy, xz = qx * qz, yz = qy * qz;
52041
+ const wx = qw * qx, wy = qw * qy, wz = qw * qz;
52042
+ const m00 = 1 - 2 * (yy + zz);
52043
+ const m01 = 2 * (xy + wz);
52044
+ const m02 = 2 * (xz - wy);
52045
+ const m10 = 2 * (xy - wz);
52046
+ const m11 = 1 - 2 * (xx + zz);
52047
+ const m12 = 2 * (yz + wx);
52048
+ const m20 = 2 * (xz + wy);
52049
+ const m21 = 2 * (yz - wx);
52050
+ const m22 = 1 - 2 * (xx + yy);
52051
+ const r00 = m00 * sx, r01 = m01 * sx, r02 = m02 * sx;
52052
+ const r10 = m10 * sy, r11 = m11 * sy, r12 = m12 * sy;
52053
+ const r20 = m20 * sz, r21 = m21 * sz, r22 = m22 * sz;
52054
+ const cAx = r00 * r00 + r10 * r10 + r20 * r20;
52055
+ const cAy = r00 * r01 + r10 * r11 + r20 * r21;
52056
+ const cAz = r00 * r02 + r10 * r12 + r20 * r22;
52057
+ const cBx = r01 * r01 + r11 * r11 + r21 * r21;
52058
+ const cBy = r01 * r02 + r11 * r12 + r21 * r22;
52059
+ const cBz = r02 * r02 + r12 * r12 + r22 * r22;
52060
+ maxCov = Math.max(
52061
+ maxCov,
52062
+ Math.abs(cAx),
52063
+ Math.abs(cAy),
52064
+ Math.abs(cAz),
52065
+ Math.abs(cBx),
52066
+ Math.abs(cBy),
52067
+ Math.abs(cBz)
52068
+ );
52069
+ const bidx = idx;
52070
+ tB[bidx + 0] = cAx;
52071
+ tB[bidx + 1] = cAy;
52072
+ tB[bidx + 2] = cAz;
52073
+ tB[bidx + 3] = cBz;
52074
+ const hx = toHalfFloat(cBx) & 65535;
52075
+ const hy = toHalfFloat(cBy) & 65535;
52076
+ tA[idx + 3] = hx | hy << 16;
52077
+ }
52078
+ console.group("🔍 GSplat Data Statistics");
52079
+ console.log("Splat count:", count);
52080
+ console.log("Scale range:", minScale.toFixed(4), "~", maxScale.toFixed(4));
52081
+ console.log("Max covariance:", maxCov.toFixed(4));
52082
+ if (maxScale > 50) {
52083
+ console.error("❌ CRITICAL: Scale values are too large! This causes spikes.");
52084
+ console.log("💡 Try reducing visBoost or clamping scale values");
52085
+ } else if (maxScale > 20) {
52086
+ console.warn("⚠️ WARNING: Scale values are large. May cause rendering issues.");
52087
+ } else {
52088
+ console.log("✅ Scale values look normal");
52089
+ }
52090
+ if (maxCov > 100) {
52091
+ console.error("❌ CRITICAL: Covariance values are too large!");
52092
+ } else if (maxCov > 50) {
52093
+ console.warn("⚠️ WARNING: Covariance values are large.");
52094
+ } else {
52095
+ console.log("✅ Covariance values look normal");
52096
+ }
52097
+ console.groupEnd();
52098
+ this.transformA = new Uint32ArrayTexture().create(w, h, tA);
52099
+ this.transformA.name = "transformA";
52100
+ this.transformA.minFilter = "nearest";
52101
+ this.transformA.magFilter = "nearest";
52102
+ this.transformA.addressModeU = "clamp-to-edge";
52103
+ this.transformA.addressModeV = "clamp-to-edge";
52104
+ this.transformB = new Float16ArrayTexture().create(w, h, tB, false);
52105
+ this.transformB.name = "transformB";
52106
+ this.transformB.minFilter = "nearest";
52107
+ this.transformB.magFilter = "nearest";
52108
+ this.transformB.mipmapFilter = "nearest";
52109
+ this.transformB.addressModeU = "clamp-to-edge";
52110
+ this.transformB.addressModeV = "clamp-to-edge";
52111
+ }
52112
+ /**
52113
+ * Update world space positions when transform changes
52114
+ */
52115
+ updateWorldPositions() {
52116
+ if (!this._positions) return;
52117
+ const worldMatrix = this.object3D.transform.worldMatrix;
52118
+ const localPos = this._positions;
52119
+ const count = this._fullCount;
52120
+ if (!this._worldPositions) {
52121
+ this._worldPositions = new Float32Array(localPos.length);
52122
+ }
52123
+ const m = worldMatrix.rawData;
52124
+ for (let i = 0; i < count; i++) {
52125
+ const idx = i * 3;
52126
+ const x = localPos[idx + 0];
52127
+ const y = localPos[idx + 1];
52128
+ const z = localPos[idx + 2];
52129
+ this._worldPositions[idx + 0] = m[0] * x + m[4] * y + m[8] * z + m[12];
52130
+ this._worldPositions[idx + 1] = m[1] * x + m[5] * y + m[9] * z + m[13];
52131
+ this._worldPositions[idx + 2] = m[2] * x + m[6] * y + m[10] * z + m[14];
52132
+ }
52133
+ this._centersSent = false;
52134
+ }
52135
+ /**
52136
+ * Schedule Web Worker-based sorting task
52137
+ */
52138
+ scheduleOrder(viewMatrix) {
52139
+ if (this.count === 0) return;
52140
+ const transformChanged = this.object3D.transform.localChange;
52141
+ if (transformChanged || !this._worldPositions) {
52142
+ this.updateWorldPositions();
52143
+ }
52144
+ const r = viewMatrix.rawData;
52145
+ const vx = r[2], vy = r[6], vz = r[10];
52146
+ const px = -(r[0] * r[12] + r[1] * r[13] + r[2] * r[14]);
52147
+ const py = -(r[4] * r[12] + r[5] * r[13] + r[6] * r[14]);
52148
+ const pz = -(r[8] * r[12] + r[9] * r[13] + r[10] * r[14]);
52149
+ const posHash = Math.floor(px * 1e3) ^ Math.floor(py * 1e3) ^ Math.floor(pz * 1e3);
52150
+ const dirHash = Math.floor(vx * 1e3) ^ Math.floor(vy * 1e3) ^ Math.floor(vz * 1e3);
52151
+ const hash = posHash ^ dirHash;
52152
+ if (hash === this._lastViewMatrixHash && !transformChanged) {
52153
+ return;
52154
+ }
52155
+ this._lastViewMatrixHash = hash;
52156
+ const now = performance.now();
52157
+ if (now - this._lastSentTime < this._minIntervalMs) return;
52158
+ this._lastSentTime = now;
52159
+ if (!this._sortWorker) {
52160
+ this._sortWorker = this.createSortWorker();
52161
+ this._sortWorker.onmessage = (ev) => {
52162
+ const newOrder = ev.data.order;
52163
+ const oldOrder = this._orderData.buffer;
52164
+ this._sortWorker.postMessage({
52165
+ order: oldOrder
52166
+ }, [oldOrder]);
52167
+ const indices = new Uint32Array(newOrder);
52168
+ const total = this.size.x * this.size.y;
52169
+ const count = this.count;
52170
+ this._orderData = new Uint32Array(total * 4);
52171
+ for (let i = 0; i < total; i++) {
52172
+ const src = i < count ? indices[i] : count > 0 ? count - 1 : 0;
52173
+ const base = i * 4;
52174
+ this._orderData[base + 0] = src;
52175
+ this._orderData[base + 1] = 0;
52176
+ this._orderData[base + 2] = 0;
52177
+ this._orderData[base + 3] = 0;
52178
+ }
52179
+ this.splatOrder.updateTexture(this.size.x, this.size.y, this._orderData);
52180
+ const valid = Math.max(0, Math.min(this.count, ev.data.count | 0));
52181
+ this.texParams[2] = valid;
52182
+ };
52183
+ const worldPos = this._worldPositions || this._positions;
52184
+ const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
52185
+ if (this._mapping) {
52186
+ for (let i = 0; i < this._mapping.length; ++i) {
52187
+ const src = this._mapping[i] * 3;
52188
+ const dst = i * 3;
52189
+ centers[dst + 0] = worldPos[src + 0];
52190
+ centers[dst + 1] = worldPos[src + 1];
52191
+ centers[dst + 2] = worldPos[src + 2];
52192
+ }
52193
+ }
52194
+ const orderBuffer = new Uint32Array(this.count);
52195
+ for (let i = 0; i < this.count; i++) {
52196
+ orderBuffer[i] = i;
52197
+ }
52198
+ this._sortWorker.postMessage({
52199
+ order: orderBuffer.buffer,
52200
+ centers: centers.buffer,
52201
+ mapping: this._mapping
52202
+ }, [orderBuffer.buffer, centers.buffer]);
52203
+ this._centersSent = true;
52204
+ }
52205
+ if (!this._centersSent && this._sortWorker) {
52206
+ const worldPos = this._worldPositions || this._positions;
52207
+ const centers = this._mapping ? new Float32Array(this._mapping.length * 3) : new Float32Array(worldPos);
52208
+ if (this._mapping) {
52209
+ for (let i = 0; i < this._mapping.length; ++i) {
52210
+ const src = this._mapping[i] * 3;
52211
+ const dst = i * 3;
52212
+ centers[dst + 0] = worldPos[src + 0];
52213
+ centers[dst + 1] = worldPos[src + 1];
52214
+ centers[dst + 2] = worldPos[src + 2];
52215
+ }
52216
+ }
52217
+ this._sortWorker.postMessage({
52218
+ type: "centers",
52219
+ centers: centers.buffer,
52220
+ mapping: this._mapping ? this._mapping : null
52221
+ }, [centers.buffer]);
52222
+ this._centersSent = true;
52223
+ }
52224
+ this._sortWorker.postMessage({
52225
+ cameraPosition: { x: px, y: py, z: pz },
52226
+ cameraDirection: { x: -vx, y: -vy, z: -vz }
52227
+ });
52228
+ }
52229
+ /**
52230
+ * Create Web Worker for sorting
52231
+ */
52232
+ createSortWorker() {
52233
+ function SortWorker() {
52234
+ const compareBits = 16;
52235
+ const bucketCount = 2 ** compareBits + 1;
52236
+ let order;
52237
+ let centers;
52238
+ let mapping;
52239
+ let cameraPosition;
52240
+ let cameraDirection;
52241
+ let forceUpdate = false;
52242
+ const lastCameraPosition = { x: 0, y: 0, z: 0 };
52243
+ const lastCameraDirection = { x: 0, y: 0, z: 0 };
52244
+ const boundMin = { x: 0, y: 0, z: 0 };
52245
+ const boundMax = { x: 0, y: 0, z: 0 };
52246
+ let distances;
52247
+ let countBuffer;
52248
+ const binarySearch = (m, n, compare_fn) => {
52249
+ while (m <= n) {
52250
+ const k = n + m >> 1;
52251
+ const cmp = compare_fn(k);
52252
+ if (cmp > 0) {
52253
+ m = k + 1;
52254
+ } else if (cmp < 0) {
52255
+ n = k - 1;
52256
+ } else {
52257
+ return k;
52258
+ }
52259
+ }
52260
+ return ~m;
52261
+ };
52262
+ const update = () => {
52263
+ if (!order || !centers || !cameraPosition || !cameraDirection) return;
52264
+ const px = cameraPosition.x;
52265
+ const py = cameraPosition.y;
52266
+ const pz = cameraPosition.z;
52267
+ const dx = cameraDirection.x;
52268
+ const dy = cameraDirection.y;
52269
+ const dz = cameraDirection.z;
52270
+ const epsilon = 1e-3;
52271
+ 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) {
52272
+ return;
52273
+ }
52274
+ forceUpdate = false;
52275
+ lastCameraPosition.x = px;
52276
+ lastCameraPosition.y = py;
52277
+ lastCameraPosition.z = pz;
52278
+ lastCameraDirection.x = dx;
52279
+ lastCameraDirection.y = dy;
52280
+ lastCameraDirection.z = dz;
52281
+ const numVertices = centers.length / 3;
52282
+ if (distances?.length !== numVertices) {
52283
+ distances = new Uint32Array(numVertices);
52284
+ }
52285
+ let minDist;
52286
+ let maxDist;
52287
+ for (let i = 0; i < 8; ++i) {
52288
+ const x = (i & 1 ? boundMin.x : boundMax.x) - px;
52289
+ const y = (i & 2 ? boundMin.y : boundMax.y) - py;
52290
+ const z = (i & 4 ? boundMin.z : boundMax.z) - pz;
52291
+ const d = x * dx + y * dy + z * dz;
52292
+ if (i === 0) {
52293
+ minDist = maxDist = d;
52294
+ } else {
52295
+ minDist = Math.min(minDist, d);
52296
+ maxDist = Math.max(maxDist, d);
52297
+ }
52298
+ }
52299
+ if (!countBuffer) {
52300
+ countBuffer = new Uint32Array(bucketCount);
52301
+ } else {
52302
+ countBuffer.fill(0);
52303
+ }
52304
+ const range = maxDist - minDist;
52305
+ const divider = range < 1e-6 ? 0 : 1 / range * 2 ** compareBits;
52306
+ for (let i = 0; i < numVertices; ++i) {
52307
+ const istride = i * 3;
52308
+ const x = centers[istride + 0] - px;
52309
+ const y = centers[istride + 1] - py;
52310
+ const z = centers[istride + 2] - pz;
52311
+ const d = x * dx + y * dy + z * dz;
52312
+ const sortKey = Math.floor((d - minDist) * divider);
52313
+ distances[i] = sortKey;
52314
+ countBuffer[sortKey]++;
52315
+ }
52316
+ for (let i = 1; i < bucketCount; i++) {
52317
+ countBuffer[i] += countBuffer[i - 1];
52318
+ }
52319
+ for (let i = 0; i < numVertices; i++) {
52320
+ const distance = distances[i];
52321
+ const destIndex = --countBuffer[distance];
52322
+ order[destIndex] = i;
52323
+ }
52324
+ const dist = (i) => distances[order[i]] / divider + minDist;
52325
+ const findZero = () => {
52326
+ const result = binarySearch(0, numVertices - 1, (i) => -dist(i));
52327
+ return Math.min(numVertices, Math.abs(result));
52328
+ };
52329
+ const count = dist(numVertices - 1) >= 0 ? findZero() : numVertices;
52330
+ if (mapping) {
52331
+ for (let i = 0; i < numVertices; ++i) {
52332
+ order[i] = mapping[order[i]];
52333
+ }
52334
+ }
52335
+ self.postMessage({
52336
+ order: order.buffer,
52337
+ count
52338
+ }, [order.buffer]);
52339
+ order = null;
52340
+ };
52341
+ self.onmessage = (message) => {
52342
+ if (message.data.order) {
52343
+ order = new Uint32Array(message.data.order);
52344
+ }
52345
+ if (message.data.centers) {
52346
+ centers = new Float32Array(message.data.centers);
52347
+ boundMin.x = boundMax.x = centers[0];
52348
+ boundMin.y = boundMax.y = centers[1];
52349
+ boundMin.z = boundMax.z = centers[2];
52350
+ const numVertices = centers.length / 3;
52351
+ for (let i = 1; i < numVertices; ++i) {
52352
+ const x = centers[i * 3 + 0];
52353
+ const y = centers[i * 3 + 1];
52354
+ const z = centers[i * 3 + 2];
52355
+ boundMin.x = Math.min(boundMin.x, x);
52356
+ boundMin.y = Math.min(boundMin.y, y);
52357
+ boundMin.z = Math.min(boundMin.z, z);
52358
+ boundMax.x = Math.max(boundMax.x, x);
52359
+ boundMax.y = Math.max(boundMax.y, y);
52360
+ boundMax.z = Math.max(boundMax.z, z);
52361
+ }
52362
+ forceUpdate = true;
52363
+ }
52364
+ if (message.data.hasOwnProperty("mapping")) {
52365
+ mapping = message.data.mapping ? new Uint32Array(message.data.mapping) : null;
52366
+ forceUpdate = true;
52367
+ }
52368
+ if (message.data.cameraPosition) cameraPosition = message.data.cameraPosition;
52369
+ if (message.data.cameraDirection) cameraDirection = message.data.cameraDirection;
52370
+ update();
52371
+ };
52372
+ }
52373
+ const code = `(${SortWorker.toString()})()`;
52374
+ const blob = new Blob([code], { type: "application/javascript" });
52375
+ const url = URL.createObjectURL(blob);
52376
+ return new Worker(url);
52377
+ }
52378
+ /**
52379
+ * Update node before rendering
52380
+ */
52381
+ nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
52382
+ const worldMatrix = this.object3D.transform.worldMatrix;
52383
+ this.gsplatMaterial.setTransformMatrix(worldMatrix);
52384
+ this.gsplatMaterial.setSplatTextures(
52385
+ this.splatColor,
52386
+ this.transformA,
52387
+ this.transformB,
52388
+ this.texParams,
52389
+ this.splatOrder
52390
+ );
52391
+ super.nodeUpdate(view, passType, renderPassState, clusterLightingBuffer);
52392
+ }
52393
+ /**
52394
+ * Render pass
52395
+ */
52396
+ renderPass2(view, passType, rendererPassState, clusterLightingBuffer, encoder, useBundle = false) {
52397
+ for (let mat of this.materials) {
52398
+ const passes = mat.getPass(passType);
52399
+ if (!passes || passes.length === 0) continue;
52400
+ for (const pass of passes) {
52401
+ if (!pass.pipeline) continue;
52402
+ pass.apply(this.geometry, rendererPassState);
52403
+ GPUContext.bindPipeline(encoder, pass);
52404
+ GPUContext.draw(encoder, 4, this.count, 0, 0);
52405
+ }
52406
+ }
52407
+ }
52408
+ /**
52409
+ * Render pass (fallback)
52410
+ */
52411
+ renderPass(view, passType, renderContext) {
52412
+ const encoder = renderContext.encoder;
52413
+ for (let mat of this.materials) {
52414
+ const passes = mat.getPass(passType);
52415
+ if (!passes || passes.length === 0) continue;
52416
+ for (const pass of passes) {
52417
+ if (!pass.pipeline) continue;
52418
+ pass.apply(this.geometry, renderContext.rendererPassState || renderContext);
52419
+ GPUContext.bindPipeline(encoder, pass);
52420
+ GPUContext.draw(encoder, 4, this.count, 0, 0);
52421
+ }
52422
+ }
52423
+ }
52424
+ /**
52425
+ * Clean up resources
52426
+ */
52427
+ destroy(force) {
52428
+ if (this._sortWorker) {
52429
+ this._sortWorker.terminate();
52430
+ this._sortWorker = null;
52431
+ }
52432
+ super.destroy(force);
52433
+ }
52434
+ };
52435
+ GSplatRenderer = __decorateClass$6([
52436
+ RegisterComponent(GSplatRenderer, "GSplatRenderer")
52437
+ ], GSplatRenderer);
52438
+
50652
52439
  class Probe extends Object3D {
50653
52440
  index = 0;
50654
52441
  drawCallFrame = -1;
@@ -55904,6 +57691,298 @@ class LoaderManager extends CEventDispatcher {
55904
57691
  }
55905
57692
  }
55906
57693
 
57694
+ function computeAABBFromPositions(position) {
57695
+ const min = [Infinity, Infinity, Infinity];
57696
+ const max = [-Infinity, -Infinity, -Infinity];
57697
+ for (let i = 0; i < position.length; i += 3) {
57698
+ const x = position[i + 0];
57699
+ const y = position[i + 1];
57700
+ const z = position[i + 2];
57701
+ if (x < min[0]) min[0] = x;
57702
+ if (y < min[1]) min[1] = y;
57703
+ if (z < min[2]) min[2] = z;
57704
+ if (x > max[0]) max[0] = x;
57705
+ if (y > max[1]) max[1] = y;
57706
+ if (z > max[2]) max[2] = z;
57707
+ }
57708
+ return { min, max };
57709
+ }
57710
+
57711
+ var GSplatFormat = /* @__PURE__ */ ((GSplatFormat2) => {
57712
+ GSplatFormat2["PLY"] = "ply";
57713
+ GSplatFormat2["SPLAT"] = "splat";
57714
+ GSplatFormat2["KSPLAT"] = "ksplat";
57715
+ GSplatFormat2["UNKNOWN"] = "unknown";
57716
+ return GSplatFormat2;
57717
+ })(GSplatFormat || {});
57718
+ function detectGSplatFormat(buffer) {
57719
+ if (buffer.byteLength < 16) {
57720
+ return "unknown" /* UNKNOWN */;
57721
+ }
57722
+ const headerBytes = new Uint8Array(buffer, 0, Math.min(512, buffer.byteLength));
57723
+ const headerText = new TextDecoder("utf-8").decode(headerBytes);
57724
+ if (headerText.startsWith("ply")) {
57725
+ return "ply" /* PLY */;
57726
+ }
57727
+ return "unknown" /* UNKNOWN */;
57728
+ }
57729
+
57730
+ function byteSizeOfType(t) {
57731
+ switch (t) {
57732
+ case "char":
57733
+ case "uchar":
57734
+ case "uint8":
57735
+ case "int8":
57736
+ return 1;
57737
+ case "short":
57738
+ case "ushort":
57739
+ case "int16":
57740
+ case "uint16":
57741
+ return 2;
57742
+ case "int":
57743
+ case "uint":
57744
+ case "int32":
57745
+ case "uint32":
57746
+ case "float":
57747
+ case "float32":
57748
+ return 4;
57749
+ case "double":
57750
+ case "float64":
57751
+ return 8;
57752
+ default:
57753
+ return 4;
57754
+ }
57755
+ }
57756
+ function readByType(view, offset, type) {
57757
+ switch (type) {
57758
+ case "char":
57759
+ case "int8":
57760
+ return view.getInt8(offset);
57761
+ case "uchar":
57762
+ case "uint8":
57763
+ return view.getUint8(offset);
57764
+ case "short":
57765
+ case "int16":
57766
+ return view.getInt16(offset, true);
57767
+ case "ushort":
57768
+ case "uint16":
57769
+ return view.getUint16(offset, true);
57770
+ case "int":
57771
+ case "int32":
57772
+ return view.getInt32(offset, true);
57773
+ case "uint":
57774
+ case "uint32":
57775
+ return view.getUint32(offset, true);
57776
+ case "double":
57777
+ case "float64":
57778
+ return view.getFloat64(offset, true);
57779
+ case "float":
57780
+ case "float32":
57781
+ default:
57782
+ return view.getFloat32(offset, true);
57783
+ }
57784
+ }
57785
+ function inferSHOrder(coeffsPerColor) {
57786
+ const root = Math.round(Math.sqrt(coeffsPerColor));
57787
+ return Math.max(0, root - 1);
57788
+ }
57789
+
57790
+ function parsePlyHeader(buffer) {
57791
+ const ascii = new TextDecoder("utf-8").decode(
57792
+ new Uint8Array(buffer, 0, Math.min(4096, buffer.byteLength))
57793
+ );
57794
+ if (!ascii.startsWith("ply")) {
57795
+ throw new Error("PLY: Unsupported format. Expecting PLY file.");
57796
+ }
57797
+ const headerEnd = ascii.indexOf("end_header\n");
57798
+ if (headerEnd < 0) {
57799
+ throw new Error("PLY: Invalid PLY header");
57800
+ }
57801
+ const headerText = ascii.substring(0, headerEnd + "end_header\n".length);
57802
+ const lines = headerText.split(/\r?\n/);
57803
+ let format = "";
57804
+ let vertexCount = 0;
57805
+ const properties = [];
57806
+ let inVertexElement = false;
57807
+ for (const line of lines) {
57808
+ if (line.startsWith("format ")) {
57809
+ format = line.split(/\s+/)[1];
57810
+ } else if (line.startsWith("element ")) {
57811
+ const toks = line.split(/\s+/);
57812
+ inVertexElement = toks[1] === "vertex";
57813
+ if (inVertexElement) vertexCount = parseInt(toks[2]);
57814
+ } else if (inVertexElement && line.startsWith("property ")) {
57815
+ const toks = line.split(/\s+/);
57816
+ const type = toks[1];
57817
+ const name = toks[2];
57818
+ properties.push({ name, type });
57819
+ }
57820
+ }
57821
+ if (format !== "binary_little_endian") {
57822
+ throw new Error("PLY: Only binary_little_endian PLY is supported");
57823
+ }
57824
+ return {
57825
+ format,
57826
+ vertexCount,
57827
+ properties,
57828
+ headerByteLength: headerText.length
57829
+ };
57830
+ }
57831
+ function parsePlyGaussianSplat(buffer) {
57832
+ const header = parsePlyHeader(buffer);
57833
+ const { vertexCount, properties, headerByteLength } = header;
57834
+ const payload = new DataView(buffer, headerByteLength);
57835
+ const has = (n) => properties.find((p) => p.name === n) != null;
57836
+ const propIndex = (n) => properties.findIndex((p) => p.name === n);
57837
+ const position = new Float32Array(vertexCount * 3);
57838
+ const scale = has("scale_0") ? new Float32Array(vertexCount * 3) : void 0;
57839
+ const rotation = has("rot_0") ? new Float32Array(vertexCount * 4) : void 0;
57840
+ const opacity = has("opacity") ? new Float32Array(vertexCount) : void 0;
57841
+ const dcIdx = [propIndex("f_dc_0"), propIndex("f_dc_1"), propIndex("f_dc_2")];
57842
+ const restIndices = [];
57843
+ for (let i = 0; i < properties.length; i++) {
57844
+ if (properties[i].name.startsWith("f_rest_")) restIndices.push(i);
57845
+ }
57846
+ const hasSH = dcIdx[0] >= 0 && dcIdx[1] >= 0 && dcIdx[2] >= 0;
57847
+ let shCoeffs = void 0;
57848
+ let shOrder = 0;
57849
+ if (hasSH) {
57850
+ const coeffsPerColor = 1 + restIndices.length / 3;
57851
+ shOrder = inferSHOrder(coeffsPerColor);
57852
+ shCoeffs = new Float32Array(vertexCount * coeffsPerColor * 3);
57853
+ }
57854
+ const propOffsets = [];
57855
+ let stride = 0;
57856
+ for (const p of properties) {
57857
+ propOffsets.push(stride);
57858
+ stride += byteSizeOfType(p.type);
57859
+ }
57860
+ let base = 0;
57861
+ for (let v = 0; v < vertexCount; v++) {
57862
+ const vOffset = base;
57863
+ const ix = propIndex("x");
57864
+ const iy = propIndex("y");
57865
+ const iz = propIndex("z");
57866
+ if (ix < 0 || iy < 0 || iz < 0) {
57867
+ throw new Error("PLY: Missing x/y/z for vertex");
57868
+ }
57869
+ position[v * 3 + 0] = readByType(payload, vOffset + propOffsets[ix], properties[ix].type);
57870
+ position[v * 3 + 1] = readByType(payload, vOffset + propOffsets[iy], properties[iy].type);
57871
+ position[v * 3 + 2] = readByType(payload, vOffset + propOffsets[iz], properties[iz].type);
57872
+ if (scale) {
57873
+ const s0 = propIndex("scale_0");
57874
+ const s1 = propIndex("scale_1");
57875
+ const s2 = propIndex("scale_2");
57876
+ scale[v * 3 + 0] = readByType(payload, vOffset + propOffsets[s0], properties[s0].type);
57877
+ scale[v * 3 + 1] = readByType(payload, vOffset + propOffsets[s1], properties[s1].type);
57878
+ scale[v * 3 + 2] = readByType(payload, vOffset + propOffsets[s2], properties[s2].type);
57879
+ }
57880
+ if (rotation) {
57881
+ const r0 = propIndex("rot_0");
57882
+ const r1 = propIndex("rot_1");
57883
+ const r2 = propIndex("rot_2");
57884
+ const r3 = propIndex("rot_3");
57885
+ rotation[v * 4 + 0] = readByType(payload, vOffset + propOffsets[r0], properties[r0].type);
57886
+ rotation[v * 4 + 1] = readByType(payload, vOffset + propOffsets[r1], properties[r1].type);
57887
+ rotation[v * 4 + 2] = readByType(payload, vOffset + propOffsets[r2], properties[r2].type);
57888
+ rotation[v * 4 + 3] = readByType(payload, vOffset + propOffsets[r3], properties[r3].type);
57889
+ }
57890
+ if (opacity) {
57891
+ const oi = propIndex("opacity");
57892
+ opacity[v] = readByType(payload, vOffset + propOffsets[oi], properties[oi].type);
57893
+ }
57894
+ if (hasSH && shCoeffs) {
57895
+ const coeffsPerColor = 1 + restIndices.length / 3;
57896
+ const baseIndex = v * coeffsPerColor * 3;
57897
+ shCoeffs[baseIndex + 0] = readByType(
57898
+ payload,
57899
+ vOffset + propOffsets[dcIdx[0]],
57900
+ properties[dcIdx[0]].type
57901
+ );
57902
+ shCoeffs[baseIndex + coeffsPerColor + 0] = readByType(
57903
+ payload,
57904
+ vOffset + propOffsets[dcIdx[1]],
57905
+ properties[dcIdx[1]].type
57906
+ );
57907
+ shCoeffs[baseIndex + 2 * coeffsPerColor + 0] = readByType(
57908
+ payload,
57909
+ vOffset + propOffsets[dcIdx[2]],
57910
+ properties[dcIdx[2]].type
57911
+ );
57912
+ let rPtr = 1;
57913
+ let gPtr = 1;
57914
+ let bPtr = 1;
57915
+ for (let i = 0; i < restIndices.length; i += 3) {
57916
+ const ri = restIndices[i + 0];
57917
+ const gi = restIndices[i + 1];
57918
+ const bi = restIndices[i + 2];
57919
+ shCoeffs[baseIndex + rPtr] = readByType(
57920
+ payload,
57921
+ vOffset + propOffsets[ri],
57922
+ properties[ri].type
57923
+ );
57924
+ shCoeffs[baseIndex + coeffsPerColor + gPtr] = readByType(
57925
+ payload,
57926
+ vOffset + propOffsets[gi],
57927
+ properties[gi].type
57928
+ );
57929
+ shCoeffs[baseIndex + 2 * coeffsPerColor + bPtr] = readByType(
57930
+ payload,
57931
+ vOffset + propOffsets[bi],
57932
+ properties[bi].type
57933
+ );
57934
+ rPtr++;
57935
+ gPtr++;
57936
+ bPtr++;
57937
+ }
57938
+ }
57939
+ base += stride;
57940
+ }
57941
+ return {
57942
+ vertexCount,
57943
+ position,
57944
+ scale,
57945
+ rotation,
57946
+ opacity,
57947
+ sh: hasSH && shCoeffs ? { order: shOrder, coeffs: shCoeffs } : void 0
57948
+ };
57949
+ }
57950
+
57951
+ class GaussianSplatParser extends ParserBase {
57952
+ static format = ParserFormat.BIN;
57953
+ async parseBuffer(buffer) {
57954
+ const format = detectGSplatFormat(buffer);
57955
+ let asset;
57956
+ switch (format) {
57957
+ case GSplatFormat.PLY: {
57958
+ const plyData = parsePlyGaussianSplat(buffer);
57959
+ asset = {
57960
+ count: plyData.vertexCount,
57961
+ position: plyData.position,
57962
+ rotation: plyData.rotation,
57963
+ scale: plyData.scale,
57964
+ opacity: plyData.opacity,
57965
+ sh: plyData.sh
57966
+ };
57967
+ asset.bbox = computeAABBFromPositions(plyData.position);
57968
+ break;
57969
+ }
57970
+ case GSplatFormat.SPLAT:
57971
+ throw new Error("SPLAT format is not yet supported");
57972
+ case GSplatFormat.KSPLAT:
57973
+ throw new Error("KSPLAT format is not yet supported");
57974
+ case GSplatFormat.UNKNOWN:
57975
+ default:
57976
+ throw new Error("Unknown or unsupported Gaussian Splatting file format");
57977
+ }
57978
+ this.data = asset;
57979
+ return asset;
57980
+ }
57981
+ verification() {
57982
+ return !!this.data && this.data.count > 0;
57983
+ }
57984
+ }
57985
+
55907
57986
  var GeoType = /* @__PURE__ */ ((GeoType2) => {
55908
57987
  GeoType2["Point"] = "Point";
55909
57988
  GeoType2["LineString"] = "LineString";
@@ -57695,46 +59774,6 @@ class LambertMaterial extends Material {
57695
59774
  function registerMaterial(name, cls) {
57696
59775
  }
57697
59776
 
57698
- class UnLitMaterial extends Material {
57699
- /**
57700
- * @constructor
57701
- */
57702
- constructor() {
57703
- super();
57704
- this.shader = new UnLitShader();
57705
- this.baseMap = Engine3D.res.whiteTexture;
57706
- }
57707
- set baseMap(texture) {
57708
- this.shader.setTexture(`baseMap`, texture);
57709
- }
57710
- get baseMap() {
57711
- return this.shader.getTexture(`baseMap`);
57712
- }
57713
- /**
57714
- * set base color (tint color)
57715
- */
57716
- set baseColor(color) {
57717
- this.shader.setUniformColor(`baseColor`, color);
57718
- }
57719
- /**
57720
- * get base color (tint color)
57721
- */
57722
- get baseColor() {
57723
- return this.shader.getUniformColor("baseColor");
57724
- }
57725
- /**
57726
- * set environment texture, usually referring to cubemap
57727
- */
57728
- set envMap(texture) {
57729
- }
57730
- /**
57731
- * @internal
57732
- * set shadow map
57733
- */
57734
- set shadowMap(texture) {
57735
- }
57736
- }
57737
-
57738
59777
  class UnLitTexArrayMaterial extends Material {
57739
59778
  /**
57740
59779
  * @constructor
@@ -62011,86 +64050,6 @@ class TriGeometry extends GeometryBase {
62011
64050
  }
62012
64051
  }
62013
64052
 
62014
- class Float16ArrayTexture extends Texture {
62015
- uint16Array;
62016
- floatArray;
62017
- _dataBuffer;
62018
- /**
62019
- * 使用数字数组填充纹理,格式为[红0, 绿0, 蓝0, 透明度0, 红1, 绿1, 蓝1, 透明度1...]
62020
- * @param width 纹理宽度
62021
- * @param height 纹理高度
62022
- * @param numbers 每个像素的颜色值数组
62023
- * @param useMipmap 是否生成Mipmap
62024
- * @returns 返回纹理实例
62025
- */
62026
- create(width, height, numbers = null, mipmap = true) {
62027
- if (numbers == null) {
62028
- numbers = [];
62029
- for (let i = 0, c = width * height * 4; i < c; i++) {
62030
- numbers[i] = 0;
62031
- }
62032
- }
62033
- this.updateTexture(width, height, numbers, mipmap);
62034
- return this;
62035
- }
62036
- /**
62037
- * 更新纹理内容
62038
- * @param width 纹理宽度
62039
- * @param height 纹理高度
62040
- * @param numbers 像素数据数组
62041
- * @param mipmap 是否生成Mipmap
62042
- */
62043
- updateTexture(width, height, numbers, mipmap = true) {
62044
- if (width != this.width || height != this.height) {
62045
- this._dataBuffer && this._dataBuffer.destroy();
62046
- this._dataBuffer = null;
62047
- this.gpuTexture && this.gpuTexture.destroy();
62048
- this.gpuTexture = null;
62049
- }
62050
- this.floatArray = numbers;
62051
- let device = webGPUContext.device;
62052
- const bytesPerRow = width * 4 * 2;
62053
- this.format = GPUTextureFormat.rgba16float;
62054
- this.mipmapCount = Math.floor(mipmap ? Math.log2(width) : 1);
62055
- this.createTextureDescriptor(width, height, this.mipmapCount, this.format);
62056
- if (!this.uint16Array || this.uint16Array.length != numbers.length) {
62057
- this.uint16Array = new Uint16Array(numbers.length);
62058
- }
62059
- let uint16Array = this.uint16Array;
62060
- for (let i = 0, c = uint16Array.length; i < c; i++) {
62061
- uint16Array[i] = toHalfFloat(numbers[i]);
62062
- }
62063
- const textureDataBuffer = this._dataBuffer = device.createBuffer({
62064
- size: uint16Array.byteLength,
62065
- usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC
62066
- });
62067
- device.queue.writeBuffer(textureDataBuffer, 0, uint16Array);
62068
- const commandEncoder = GPUContext.beginCommandEncoder();
62069
- commandEncoder.copyBufferToTexture(
62070
- {
62071
- buffer: textureDataBuffer,
62072
- bytesPerRow
62073
- },
62074
- {
62075
- texture: this.getGPUTexture()
62076
- },
62077
- {
62078
- width,
62079
- height,
62080
- depthOrArrayLayers: 1
62081
- }
62082
- );
62083
- if (!this.useMipmap) {
62084
- this.samplerBindingLayout.type = `filtering`;
62085
- this.textureBindingLayout.sampleType = `float`;
62086
- }
62087
- GPUContext.endCommandEncoder(commandEncoder);
62088
- this.gpuSampler = device.createSampler(this);
62089
- this.gpuTexture = this.getGPUTexture();
62090
- if (this.mipmapCount > 1) TextureMipmapGenerator.webGPUGenerateMipmap(this);
62091
- }
62092
- }
62093
-
62094
64053
  class Float32ArrayTexture extends Texture {
62095
64054
  create(width, height, data, filtering = true) {
62096
64055
  let device = webGPUContext.device;
@@ -63530,4 +65489,4 @@ const __viteBrowserExternal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.def
63530
65489
  __proto__: null
63531
65490
  }, Symbol.toStringTag, { value: 'Module' }));
63532
65491
 
63533
- export { AccelerateDecelerateInterpolator, AccelerateInterpolator, AnimationCurve, AnimationCurveT, AnimationMonitor, AnimatorComponent, AnimatorEventKeyframe, AnticipateInterpolator, AnticipateOvershootInterpolator, ArrayHas, ArrayItemIndex, AtlasParser, AtmosphericComponent, AtmosphericScatteringSky, AtmosphericScatteringSkySetting, AtmosphericScatteringSky_shader, AttributeAnimCurve, AxisObject, B3DMLoader, B3DMLoaderBase, B3DMParseUtil, B3DMParser, BRDFLUT, BRDFLUTGenerate, BRDF_frag, BatchTable, BiMap, BillboardComponent, BillboardType, BitUtil, BitmapTexture2D, BitmapTexture2DArray, BitmapTextureCube, Blend, BlendFactor, BlendMode, BlendShapeData, BlendShapePropertyData, BloomPost, BlurEffectCreatorBlur_cs, BlurEffectCreatorSample_cs, BlurTexture2DBufferCreator, BounceInterpolator, BoundUtil, BoundingBox, BoundingSphere, BoxColliderShape, BoxGeometry, BrdfLut_frag, BsDF_frag, BxDF_frag, BxdfDebug_frag, BytesArray, CEvent, CEventDispatcher, CEventListener, CResizeEvent, CSM, Camera3D, CameraControllerBase, CameraType, CameraUtil, CapsuleColliderShape, CastPointShadowMaterialPass, CastShadowMaterialPass, Clearcoat_frag, ClusterBoundsSource_cs, ClusterConfig, ClusterDebug_frag, ClusterLight, ClusterLightingBuffer, ClusterLightingRender, ClusterLighting_cs, CollectInfo, ColliderComponent, ColliderShape, ColliderShapeType, Color, ColorGradient, ColorLitMaterial, ColorLitShader, ColorPassFragmentOutput, ColorPassRenderer, ColorUtil, ComData, Combine_cs, Common_frag, Common_vert, ComponentBase, ComponentCollect, ComputeGPUBuffer, ComputeShader, Context3D, CubeCamera, CubeMapFaceEnum, CubeSky_Shader, CubicBezierCurve, CubicBezierPath, CubicBezierType, CycleInterpolator, CylinderGeometry, DDGIIrradianceComputePass, DDGIIrradianceGPUBufferReader, DDGIIrradianceVolume, DDGIIrradiance_shader, DDGILightingPass, DDGILighting_shader, DDGIMultiBouncePass, DDGIProbeRenderer, DEGREES_TO_RADIANS, DecelerateInterpolator, Denoising_cs, Depth2DTextureArray, DepthCubeArrayTexture, DepthMaterialPass, DepthOfFieldPost, DepthOfView_cs, DirectLight, DoubleArray, EditorInspector, Engine3D, Entity, EntityBatchCollect, EntityCollect, EnvMap_frag, ErpImage2CubeMap, ErpImage2CubeMapCreateCube_cs, ErpImage2CubeMapRgbe2rgba_cs, ExtrudeGeometry, FASTFLOOR, FXAAPost, FXAAShader, FastMathShader, FeatureTable, FileLoader, FirstPersonCameraController, Float16ArrayTexture, Float32ArrayTexture, FlyCameraController, FontChar, FontInfo, FontPage, FontParser, ForwardRenderJob, FragmentOutput, FragmentVarying, FrameCache, Frustum, FrustumCSM, FrustumCulling_cs, FullQuad_vert_wgsl, GBufferFrame, GBufferPass, GBufferPost, GBufferStand, GBuffer_pass, GILighting, GIProbeMaterial, GIProbeMaterialType, GIProbeShader, GIRenderCompleteEvent, GIRenderStartEvent, GLBChunk, GLBHeader, GLBParser, GLSLLexer, GLSLLexerToken, GLSLPreprocessor, GLSLSyntax, GLTFBinaryExtension, GLTFMaterial, GLTFParser, GLTFSubParser, GLTFSubParserCamera, GLTFSubParserConverter, GLTFSubParserMaterial, GLTFSubParserMesh, GLTFSubParserSkeleton, GLTFSubParserSkin, GLTFType, GLTF_Accessors, GLTF_Info, GLTF_Light, GLTF_Mesh, GLTF_Node, GLTF_Primitives, GLTF_Scene, GPUAddressMode, GPUBlendFactor, GPUBufferBase, GPUBufferType, GPUCompareFunction, GPUContext, GPUCullMode, GPUFilterMode, GPUPrimitiveTopology, GPUTextureFormat, GPUVertexFormat, GPUVertexStepMode, GTAOPost, GTAO_cs, GUIAtlasTexture, GUICanvas, GUIConfig, GUIGeometry, GUIGeometryRebuild, GUIMaterial, GUIPassRenderer, GUIPick, GUIPickHelper, GUIQuad, GUIQuadAttrEnum, GUIRenderer, GUIShader, GUISpace, GUISprite, GUITexture, GenerayRandomDir, GeoJsonParser, GeoJsonUtil, GeoType, GeometryBase, GeometryIndicesBuffer, GeometryUtil, GeometryVertexBuffer, GeometryVertexType, GetComponentClass, GetCountInstanceID, GetRepeat, GetShader, GlassShader, GlobalBindGroup, GlobalBindGroupLayout, GlobalFog, GlobalFog_shader, GlobalIlluminationComponent, GlobalUniform, GlobalUniformGroup, GodRayPost, GodRay_cs, GridObject, HDRTexture, HDRTextureCube, Hair_frag, Hair_shader_op, Hair_shader_tr, HaltonSeq, Horizontal, HoverCameraController, I3DMLoader, I3DMLoaderBase, I3DMParser, IBLEnvMapCreator, IBLEnvMapCreator_cs, IESProfiles, IESProfiles_frag, IKDTreeUserData, ImageType, IndicesGPUBuffer, Inline_vert, InputSystem, InstanceDrawComponent, InstanceUniform, InstancedMesh, Interpolator, InterpolatorEnum, IrradianceDataReaderCompleteEvent, IrradianceVolumeData_frag, Irradiance_frag, IsEditorInspector, IsNonSerialize, Joint, JointPose, JumperInterpolator, KDTreeEntity, KDTreeNode, KDTreeRange, KDTreeSpace, KDTreeUUID, KHR_draco_mesh_compression, KHR_lights_punctual, KHR_materials_clearcoat, KHR_materials_emissive_strength, KHR_materials_ior, KHR_materials_unlit, KV, KelvinUtil, KeyCode, KeyEvent, Keyframe, KeyframeT, LDRTextureCube, LambertMaterial, Lambert_shader, Light, LightBase, LightData, LightEntries, LightType, LightingFunction_frag, Line, LineClassification, LinearInterpolator, LitMaterial, LitSSSShader, LitShader, Lit_shader, LoaderBase, LoaderEvent, LoaderManager, MAX_VALUE, MIN_VALUE, Material, MaterialDataUniformGPUBuffer, MaterialUtilities, MathShader, MathUtil, Matrix3, Matrix4, MatrixBindGroup, MatrixGPUBuffer, MatrixShader, MemoryDO, MemoryInfo, MergeRGBACreator, MergeRGBA_cs, MeshColliderShape, MeshFilter, MeshRenderer, MinMaxAnimationCurves, MinMaxCurve, MinMaxCurveState, MinMaxPolyCurves, MorePassParser, MorePassShader, MorphTargetBlender, MorphTargetData, MorphTargetFrame, MorphTargetTransformKey, MorphTarget_shader, MouseCode, MultiBouncePass_cs, Navi3DAstar, Navi3DConst, Navi3DEdge, Navi3DFunnel, Navi3DMaskType, Navi3DMesh, Navi3DPoint, Navi3DPoint2D, Navi3DPointFat, Navi3DRouter, Navi3DTriangle, NonSerialize, NormalMap_frag, OAnimationEvent, OBJParser, Object3D, Object3DEvent, Object3DTransformTools, Object3DUtil, ObjectAnimClip, OcclusionSystem, Octree, OctreeEntity, OrbitController, OrderMap, Orientation3D, OutLineBlendColor_cs, OutlineCalcOutline_cs, OutlinePass, OutlinePost, OutlinePostData, OutlinePostManager, OutlinePostSlot, Outline_cs, OvershootInterpolator, PBRLItShader, PBRLitSSSShader, ParserBase, ParserFormat, ParticleSystemCurveEvalMode, ParticleSystemRandomnessIds, PassGenerate, PassShader, PassType, PhysicMaterialUniform_frag, PickCompute, PickFire, PickGUIEvent3D, PickResult, Picker_cs, PingPong, PipelinePool, Plane3D, PlaneClassification, PlaneGeometry, PointClassification, PointLight, PointLightShadowRenderer, PointShadowCubeCamera, PointerEvent3D, Polynomial, PolynomialCurve, Polynomials, PoolNode, PostBase, PostProcessingComponent, PostRenderer, PreDepthPassRenderer, PreFilteredEnvironment_cs, PreFilteredEnvironment_cs2, PreIntegratedLut, PreIntegratedLutCompute, PrefabAvatarData, PrefabAvatarParser, PrefabBoneData, PrefabMaterialParser, PrefabMeshData, PrefabMeshParser, PrefabNode, PrefabParser, PrefabStringUtil, PrefabTextureData, PrefabTextureParser, Preprocessor, Probe, ProbeEntries, ProbeGBufferFrame, ProfilerUtil, PropertyAnimClip, PropertyAnimTag, PropertyAnimation, PropertyAnimationClip, PropertyAnimationClipState, PropertyAnimationEvent, PropertyHelp, QuadAABB, QuadGlsl_fs, QuadGlsl_vs, QuadRoot, QuadShader, QuadTree, QuadTreeCell, Quad_depth2dArray_frag_wgsl, Quad_depth2d_frag_wgsl, Quad_depthCube_frag_wgsl, Quad_frag_wgsl, Quad_vert_wgsl, Quaternion, RADIANS_TO_DEGREES, RGBEErrorCode, RGBEHeader, RGBEParser, RTDescriptor, RTFrame, RTResourceConfig, RTResourceMap, Rand, RandomSeed, Ray, RayCastMeshDetail, Reader, Rect, Reference, Reflection, ReflectionCG, ReflectionEntries, ReflectionMaterial, ReflectionRenderer, ReflectionShader, ReflectionShader_shader, RegisterComponent, RegisterShader, RenderContext, RenderLayer, RenderLayerUtil, RenderNode, RenderShaderCollect, RenderShaderCompute, RenderShaderPass, RenderTexture, RendererBase, RendererJob, RendererMap, RendererMask, RendererMaskUtil, RendererPassState, RepeatSE, Res, RotationControlComponents, SHCommon_frag, SN_ArrayConstant, SN_BinaryOperation, SN_Break, SN_CodeBlock, SN_Constant, SN_Continue, SN_Declaration, SN_Discard, SN_DoWhileLoop, SN_Expression, SN_ForLoop, SN_Function, SN_FunctionArgs, SN_FunctionCall, SN_IFBranch, SN_Identifier, SN_IndexOperation, SN_Layout, SN_ParenExpression, SN_Precision, SN_Return, SN_SelectOperation, SN_Struct, SN_TernaryOperation, SN_UnaryOperation, SN_WhileLoop, SSAO_cs, SSGI2_cs, SSGIPost, SSRPost, SSR_BlendColor_cs, SSR_IS_Kernel, SSR_IS_cs, SSR_RayTrace_cs, ScaleControlComponents, Scene3D, Shader, ShaderAttributeInfo, ShaderConverter, ShaderConverterResult, ShaderLib, ShaderPassBase, ShaderReflection, ShaderStage, ShaderState, ShaderUniformInfo, ShaderUtil, ShadingInput, ShadowLightsCollect, ShadowMapPassRenderer, ShadowMapping_frag, Skeleton, SkeletonAnimationClip, SkeletonAnimationClipState, SkeletonAnimationComponent, SkeletonAnimationCompute, SkeletonAnimation_shader, SkeletonBlendComputeArgs, SkeletonPose, SkeletonTransformComputeArgs, SkinnedMeshRenderer, SkinnedMeshRenderer2, SkyGBufferPass, SkyGBuffer_pass, SkyMaterial, SkyRenderer, SkyShader, SolidColorSky, SphereColliderShape, SphereGeometry, SphereReflection, SpotLight, StandShader, StatementNode, StorageGPUBuffer, StringUtil, Struct, StructStorageGPUBuffer, SubGeometry, TAACopyTex_cs, TAAPost, TAASharpTex_cs, TAA_cs, TestComputeLoadBuffer, TextAnchor, TextFieldLayout, TextFieldLine, Texture, TextureCube, TextureCubeFaceData, TextureCubeStdCreator, TextureCubeUtils, TextureMipmapCompute, TextureMipmapGenerator, TextureScaleCompute, ThirdPersonCameraController, TileSet, TileSetChild, TileSetChildContent, TileSetChildContentMetaData, TileSetRoot, TilesRenderer, Time, TokenType, TorusGeometry, TouchData, TrailGeometry, Transform, TransformAxisEnum, TransformControllerBaseComponent, TransformMode, TransformSpaceMode, TranslationControlComponents, TranslatorContext, TriGeometry, Triangle, UIButton, UIButtonTransition, UIComponentBase, UIEvent, UIImage, UIImageGroup, UIInteractive, UIInteractiveStyle, UIPanel, UIRenderAble, UIShadow, UITextField, UITransform, UUID, UV, Uint8ArrayTexture, UnLit, UnLitMaterial, UnLitMaterialUniform_frag, UnLitShader, UnLitTexArrayMaterial, UnLitTexArrayShader, UnLitTextureArray, UnLit_frag, UniformGPUBuffer, UniformNode, UniformType, ValueEnumType, ValueOp, ValueParser, ValueSpread, Vector2, Vector3, Vector3Ex, Vector4, VertexAttribute, VertexAttributeIndexShader, VertexAttributeName, VertexAttributeSize, VertexAttributeStride, VertexAttributes_vert, VertexBufferLayout, VertexFormat, VertexGPUBuffer, Vertical, VideoUniform_frag, View3D, ViewPanel, ViewQuad, VirtualTexture, WGSLTranslator, WebGPUDescriptorCreator, WorldMatrixUniform, WorldPanel, WrapMode, WrapTimeMode, ZCullingCompute, ZPassShader_cs, ZPassShader_fs, ZPassShader_vs, ZSorterUtil, append, arrayToString, blendComponent, buildCurves, calculateCurveRangesValue, calculateMinMax, castPointShadowMap_vert, clamp, clampRepeat, cos, crossProduct, cubicPolynomialRoot, cubicPolynomialRootsGeneric, curvesSupportProcedural, deg2Rad, directionShadowCastMap_frag, dot, doubleIntegrateSegment, downSample, fastInvSqrt, floorfToIntPos, fonts, generateRandom, generateRandom3, getFloatFromInt, getGLTypeFromTypedArray, getGLTypeFromTypedArrayType, getGlobalRandomSeed, getTypedArray, getTypedArrayTypeFromGLType, grad1, grad2, grad3, grad4, integrateSegment, irradianceDataReader, kPI, lerp, lerpByte, lerpColor, lerpVector3, magnitude, makeAloneSprite, makeGUISprite, makeMatrix44, matrixMultiply, matrixRotate, matrixRotateY, mergeFunctions, multiplyMatrices4x4REF, normal_distribution, normalizeFast, normalizeSafe, normalizedToByte, normalizedToWord, outlinePostData, outlinePostManager, perm, post, quadraticPolynomialRootsGeneric, rad2Deg, random01, randomBarycentricCoord, randomPointBetweenEllipsoid, randomPointBetweenSphere, randomPointInsideCube, randomPointInsideEllipsoid, randomPointInsideUnitCircle, randomPointInsideUnitSphere, randomQuaternion, randomQuaternionUniformDistribution, randomSeed, randomUnitVector, randomUnitVector2, rangedRandomFloat, rangedRandomInt, readMagicBytes, registerMaterial, repeat, rotMatrix, rotateVectorByQuat, roundfToIntPos, scale, shadowCastMap_frag, shadowCastMap_vert, simplex, sin, snoise1, snoise2, snoise3, snoise4, sqrMagnitude, sqrtImpl, stencilStateFace, swap, textureCompress, threshold, toHalfFloat, tw, uniform_real_distribution, uniform_real_distribution2, upSample$1 as upSample, webGPUContext, zSorterUtil };
65492
+ export { AccelerateDecelerateInterpolator, AccelerateInterpolator, AnimationCurve, AnimationCurveT, AnimationMonitor, AnimatorComponent, AnimatorEventKeyframe, AnticipateInterpolator, AnticipateOvershootInterpolator, ArrayHas, ArrayItemIndex, AtlasParser, AtmosphericComponent, AtmosphericScatteringSky, AtmosphericScatteringSkySetting, AtmosphericScatteringSky_shader, AttributeAnimCurve, AxisObject, B3DMLoader, B3DMLoaderBase, B3DMParseUtil, B3DMParser, BRDFLUT, BRDFLUTGenerate, BRDF_frag, BatchTable, BiMap, BillboardComponent, BillboardType, BitUtil, BitmapTexture2D, BitmapTexture2DArray, BitmapTextureCube, Blend, BlendFactor, BlendMode, BlendShapeData, BlendShapePropertyData, BloomPost, BlurEffectCreatorBlur_cs, BlurEffectCreatorSample_cs, BlurTexture2DBufferCreator, BounceInterpolator, BoundUtil, BoundingBox, BoundingSphere, BoxColliderShape, BoxGeometry, BrdfLut_frag, BsDF_frag, BxDF_frag, BxdfDebug_frag, BytesArray, CEvent, CEventDispatcher, CEventListener, CResizeEvent, CSM, Camera3D, CameraControllerBase, CameraType, CameraUtil, CapsuleColliderShape, CastPointShadowMaterialPass, CastShadowMaterialPass, Clearcoat_frag, ClusterBoundsSource_cs, ClusterConfig, ClusterDebug_frag, ClusterLight, ClusterLightingBuffer, ClusterLightingRender, ClusterLighting_cs, CollectInfo, ColliderComponent, ColliderShape, ColliderShapeType, Color, ColorGradient, ColorLitMaterial, ColorLitShader, ColorPassFragmentOutput, ColorPassRenderer, ColorUtil, ComData, Combine_cs, Common_frag, Common_vert, ComponentBase, ComponentCollect, ComputeGPUBuffer, ComputeShader, Context3D, CubeCamera, CubeMapFaceEnum, CubeSky_Shader, CubicBezierCurve, CubicBezierPath, CubicBezierType, CycleInterpolator, CylinderGeometry, DDGIIrradianceComputePass, DDGIIrradianceGPUBufferReader, DDGIIrradianceVolume, DDGIIrradiance_shader, DDGILightingPass, DDGILighting_shader, DDGIMultiBouncePass, DDGIProbeRenderer, DEGREES_TO_RADIANS, DecelerateInterpolator, Denoising_cs, Depth2DTextureArray, DepthCubeArrayTexture, DepthMaterialPass, DepthOfFieldPost, DepthOfView_cs, DirectLight, DoubleArray, EditorInspector, Engine3D, Entity, EntityBatchCollect, EntityCollect, EnvMap_frag, ErpImage2CubeMap, ErpImage2CubeMapCreateCube_cs, ErpImage2CubeMapRgbe2rgba_cs, ExtrudeGeometry, FASTFLOOR, FXAAPost, FXAAShader, FastMathShader, FeatureTable, FileLoader, FirstPersonCameraController, Float16ArrayTexture, Float32ArrayTexture, FlyCameraController, FontChar, FontInfo, FontPage, FontParser, ForwardRenderJob, FragmentOutput, FragmentVarying, FrameCache, Frustum, FrustumCSM, FrustumCulling_cs, FullQuad_vert_wgsl, GBufferFrame, GBufferPass, GBufferPost, GBufferStand, GBuffer_pass, GILighting, GIProbeMaterial, GIProbeMaterialType, GIProbeShader, GIRenderCompleteEvent, GIRenderStartEvent, GLBChunk, GLBHeader, GLBParser, GLSLLexer, GLSLLexerToken, GLSLPreprocessor, GLSLSyntax, GLTFBinaryExtension, GLTFMaterial, GLTFParser, GLTFSubParser, GLTFSubParserCamera, GLTFSubParserConverter, GLTFSubParserMaterial, GLTFSubParserMesh, GLTFSubParserSkeleton, GLTFSubParserSkin, GLTFType, GLTF_Accessors, GLTF_Info, GLTF_Light, GLTF_Mesh, GLTF_Node, GLTF_Primitives, GLTF_Scene, GPUAddressMode, GPUBlendFactor, GPUBufferBase, GPUBufferType, GPUCompareFunction, GPUContext, GPUCullMode, GPUFilterMode, GPUPrimitiveTopology, GPUTextureFormat, GPUVertexFormat, GPUVertexStepMode, GSplatFormat, GSplatMaterial, GSplatRenderer, GSplat_FS, GSplat_VS, GTAOPost, GTAO_cs, GUIAtlasTexture, GUICanvas, GUIConfig, GUIGeometry, GUIGeometryRebuild, GUIMaterial, GUIPassRenderer, GUIPick, GUIPickHelper, GUIQuad, GUIQuadAttrEnum, GUIRenderer, GUIShader, GUISpace, GUISprite, GUITexture, GaussianSplatParser, GenerayRandomDir, GeoJsonParser, GeoJsonUtil, GeoType, GeometryBase, GeometryIndicesBuffer, GeometryUtil, GeometryVertexBuffer, GeometryVertexType, GetComponentClass, GetCountInstanceID, GetRepeat, GetShader, GlassShader, GlobalBindGroup, GlobalBindGroupLayout, GlobalFog, GlobalFog_shader, GlobalIlluminationComponent, GlobalUniform, GlobalUniformGroup, GodRayPost, GodRay_cs, GridObject, HDRTexture, HDRTextureCube, Hair_frag, Hair_shader_op, Hair_shader_tr, HaltonSeq, Horizontal, HoverCameraController, I3DMLoader, I3DMLoaderBase, I3DMParser, IBLEnvMapCreator, IBLEnvMapCreator_cs, IESProfiles, IESProfiles_frag, IKDTreeUserData, ImageType, IndicesGPUBuffer, Inline_vert, InputSystem, InstanceDrawComponent, InstanceUniform, InstancedMesh, Interpolator, InterpolatorEnum, IrradianceDataReaderCompleteEvent, IrradianceVolumeData_frag, Irradiance_frag, IsEditorInspector, IsNonSerialize, Joint, JointPose, JumperInterpolator, KDTreeEntity, KDTreeNode, KDTreeRange, KDTreeSpace, KDTreeUUID, KHR_draco_mesh_compression, KHR_lights_punctual, KHR_materials_clearcoat, KHR_materials_emissive_strength, KHR_materials_ior, KHR_materials_unlit, KMZParser, KV, KelvinUtil, KeyCode, KeyEvent, Keyframe, KeyframeT, LDRTextureCube, LambertMaterial, Lambert_shader, Light, LightBase, LightData, LightEntries, LightType, LightingFunction_frag, Line, LineClassification, LinearInterpolator, LitMaterial, LitSSSShader, LitShader, Lit_shader, LoaderBase, LoaderEvent, LoaderManager, MAX_VALUE, MIN_VALUE, Material, MaterialDataUniformGPUBuffer, MaterialUtilities, MathShader, MathUtil, Matrix3, Matrix4, MatrixBindGroup, MatrixGPUBuffer, MatrixShader, MemoryDO, MemoryInfo, MergeRGBACreator, MergeRGBA_cs, MeshColliderShape, MeshFilter, MeshRenderer, MinMaxAnimationCurves, MinMaxCurve, MinMaxCurveState, MinMaxPolyCurves, MorePassParser, MorePassShader, MorphTargetBlender, MorphTargetData, MorphTargetFrame, MorphTargetTransformKey, MorphTarget_shader, MouseCode, MultiBouncePass_cs, Navi3DAstar, Navi3DConst, Navi3DEdge, Navi3DFunnel, Navi3DMaskType, Navi3DMesh, Navi3DPoint, Navi3DPoint2D, Navi3DPointFat, Navi3DRouter, Navi3DTriangle, NonSerialize, NormalMap_frag, OAnimationEvent, OBJParser, Object3D, Object3DEvent, Object3DTransformTools, Object3DUtil, ObjectAnimClip, OcclusionSystem, Octree, OctreeEntity, OrbitController, OrderMap, Orientation3D, OutLineBlendColor_cs, OutlineCalcOutline_cs, OutlinePass, OutlinePost, OutlinePostData, OutlinePostManager, OutlinePostSlot, Outline_cs, OvershootInterpolator, PBRLItShader, PBRLitSSSShader, ParserBase, ParserFormat, ParticleSystemCurveEvalMode, ParticleSystemRandomnessIds, PassGenerate, PassShader, PassType, PhysicMaterialUniform_frag, PickCompute, PickFire, PickGUIEvent3D, PickResult, Picker_cs, PingPong, PipelinePool, Plane3D, PlaneClassification, PlaneGeometry, PointClassification, PointLight, PointLightShadowRenderer, PointShadowCubeCamera, PointerEvent3D, Polynomial, PolynomialCurve, Polynomials, PoolNode, PostBase, PostProcessingComponent, PostRenderer, PreDepthPassRenderer, PreFilteredEnvironment_cs, PreFilteredEnvironment_cs2, PreIntegratedLut, PreIntegratedLutCompute, PrefabAvatarData, PrefabAvatarParser, PrefabBoneData, PrefabMaterialParser, PrefabMeshData, PrefabMeshParser, PrefabNode, PrefabParser, PrefabStringUtil, PrefabTextureData, PrefabTextureParser, Preprocessor, Probe, ProbeEntries, ProbeGBufferFrame, ProfilerUtil, PropertyAnimClip, PropertyAnimTag, PropertyAnimation, PropertyAnimationClip, PropertyAnimationClipState, PropertyAnimationEvent, PropertyHelp, QuadAABB, QuadGlsl_fs, QuadGlsl_vs, QuadRoot, QuadShader, QuadTree, QuadTreeCell, Quad_depth2dArray_frag_wgsl, Quad_depth2d_frag_wgsl, Quad_depthCube_frag_wgsl, Quad_frag_wgsl, Quad_vert_wgsl, Quaternion, RADIANS_TO_DEGREES, RGBEErrorCode, RGBEHeader, RGBEParser, RTDescriptor, RTFrame, RTResourceConfig, RTResourceMap, Rand, RandomSeed, Ray, RayCastMeshDetail, Reader, Rect, Reference, Reflection, ReflectionCG, ReflectionEntries, ReflectionMaterial, ReflectionRenderer, ReflectionShader, ReflectionShader_shader, RegisterComponent, RegisterShader, RenderContext, RenderLayer, RenderLayerUtil, RenderNode, RenderShaderCollect, RenderShaderCompute, RenderShaderPass, RenderTexture, RendererBase, RendererJob, RendererMap, RendererMask, RendererMaskUtil, RendererPassState, RepeatSE, Res, RotationControlComponents, SHCommon_frag, SN_ArrayConstant, SN_BinaryOperation, SN_Break, SN_CodeBlock, SN_Constant, SN_Continue, SN_Declaration, SN_Discard, SN_DoWhileLoop, SN_Expression, SN_ForLoop, SN_Function, SN_FunctionArgs, SN_FunctionCall, SN_IFBranch, SN_Identifier, SN_IndexOperation, SN_Layout, SN_ParenExpression, SN_Precision, SN_Return, SN_SelectOperation, SN_Struct, SN_TernaryOperation, SN_UnaryOperation, SN_WhileLoop, SSAO_cs, SSGI2_cs, SSGIPost, SSRPost, SSR_BlendColor_cs, SSR_IS_Kernel, SSR_IS_cs, SSR_RayTrace_cs, ScaleControlComponents, Scene3D, Shader, ShaderAttributeInfo, ShaderConverter, ShaderConverterResult, ShaderLib, ShaderPassBase, ShaderReflection, ShaderStage, ShaderState, ShaderUniformInfo, ShaderUtil, ShadingInput, ShadowLightsCollect, ShadowMapPassRenderer, ShadowMapping_frag, Skeleton, SkeletonAnimationClip, SkeletonAnimationClipState, SkeletonAnimationComponent, SkeletonAnimationCompute, SkeletonAnimation_shader, SkeletonBlendComputeArgs, SkeletonPose, SkeletonTransformComputeArgs, SkinnedMeshRenderer, SkinnedMeshRenderer2, SkyGBufferPass, SkyGBuffer_pass, SkyMaterial, SkyRenderer, SkyShader, SolidColorSky, SphereColliderShape, SphereGeometry, SphereReflection, SpotLight, StandShader, StatementNode, StorageGPUBuffer, StringUtil, Struct, StructStorageGPUBuffer, SubGeometry, TAACopyTex_cs, TAAPost, TAASharpTex_cs, TAA_cs, TestComputeLoadBuffer, TextAnchor, TextFieldLayout, TextFieldLine, Texture, TextureCube, TextureCubeFaceData, TextureCubeStdCreator, TextureCubeUtils, TextureMipmapCompute, TextureMipmapGenerator, TextureScaleCompute, ThirdPersonCameraController, TileSet, TileSetChild, TileSetChildContent, TileSetChildContentMetaData, TileSetRoot, TilesRenderer, Time, TokenType, TorusGeometry, TouchData, TrailGeometry, Transform, TransformAxisEnum, TransformControllerBaseComponent, TransformMode, TransformSpaceMode, TranslationControlComponents, TranslatorContext, TriGeometry, Triangle, UIButton, UIButtonTransition, UIComponentBase, UIEvent, UIImage, UIImageGroup, UIInteractive, UIInteractiveStyle, UIPanel, UIRenderAble, UIShadow, UITextField, UITransform, UUID, UV, Uint32ArrayTexture, Uint8ArrayTexture, UnLit, UnLitMaterial, UnLitMaterialUniform_frag, UnLitShader, UnLitTexArrayMaterial, UnLitTexArrayShader, UnLitTextureArray, UnLit_frag, UniformGPUBuffer, UniformNode, UniformType, ValueEnumType, ValueOp, ValueParser, ValueSpread, Vector2, Vector3, Vector3Ex, Vector4, VertexAttribute, VertexAttributeIndexShader, VertexAttributeName, VertexAttributeSize, VertexAttributeStride, VertexAttributes_vert, VertexBufferLayout, VertexFormat, VertexGPUBuffer, Vertical, VideoUniform_frag, View3D, ViewPanel, ViewQuad, VirtualTexture, WGSLTranslator, WayLines3D, WayPoint3D, WebGPUDescriptorCreator, WorldMatrixUniform, WorldPanel, WrapMode, WrapTimeMode, ZCullingCompute, ZPassShader_cs, ZPassShader_fs, ZPassShader_vs, ZSorterUtil, append, arrayToString, blendComponent, buildCurves, byteSizeOfType, calculateCurveRangesValue, calculateMinMax, castPointShadowMap_vert, clamp, clampRepeat, computeAABBFromPositions, cos, crossProduct, cubicPolynomialRoot, cubicPolynomialRootsGeneric, curvesSupportProcedural, deg2Rad, detectGSplatFormat, directionShadowCastMap_frag, dot, doubleIntegrateSegment, downSample, fastInvSqrt, floorfToIntPos, fonts, generateRandom, generateRandom3, getFloatFromInt, getGLTypeFromTypedArray, getGLTypeFromTypedArrayType, getGlobalRandomSeed, getTypedArray, getTypedArrayTypeFromGLType, grad1, grad2, grad3, grad4, inferSHOrder, integrateSegment, irradianceDataReader, kPI, lerp, lerpByte, lerpColor, lerpVector3, magnitude, makeAloneSprite, makeGUISprite, makeMatrix44, matrixMultiply, matrixRotate, matrixRotateY, mergeFunctions, multiplyMatrices4x4REF, normal_distribution, normalizeFast, normalizeSafe, normalizedToByte, normalizedToWord, outlinePostData, outlinePostManager, parsePlyGaussianSplat, parsePlyHeader, perm, post, quadraticPolynomialRootsGeneric, rad2Deg, random01, randomBarycentricCoord, randomPointBetweenEllipsoid, randomPointBetweenSphere, randomPointInsideCube, randomPointInsideEllipsoid, randomPointInsideUnitCircle, randomPointInsideUnitSphere, randomQuaternion, randomQuaternionUniformDistribution, randomSeed, randomUnitVector, randomUnitVector2, rangedRandomFloat, rangedRandomInt, readByType, readMagicBytes, registerMaterial, repeat, rotMatrix, rotateVectorByQuat, roundfToIntPos, scale, shadowCastMap_frag, shadowCastMap_vert, simplex, sin, snoise1, snoise2, snoise3, snoise4, sqrMagnitude, sqrtImpl, stencilStateFace, swap, textureCompress, threshold, toHalfFloat, tw, uniform_real_distribution, uniform_real_distribution2, upSample$1 as upSample, webGPUContext, zSorterUtil };