rayzee 7.8.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rayzee.es.js CHANGED
@@ -149,8 +149,8 @@ var Ln = M(.7548776662466927), Rn = M(.5698402909980532), zn = /* @__PURE__ */ G
149
149
  let i = B(r).bitAnd(B(63)), a = M(n).add(M(t).mul(7)), o = N(ne(a.mul(Ln).add(.5)).mul(128)), s = N(ne(a.mul(Rn).add(.5)).mul(128)), c = N(e.x).add(o).bitAnd(N(127)), l = N(e.y).add(s).bitAnd(N(127)), u = N(i).bitAnd(N(7)), d = N(i).shiftRight(N(3));
150
150
  return P(u.mul(N(128)).add(c), d.mul(N(128)).add(l));
151
151
  }, Gn = (e, t, n, r) => {
152
- let i = Wn(e, t, n, r);
153
- return In.load(i).xy;
152
+ let i = Wn(e, t, n, r), a = In.load(i).xy, o = M(B(r).shiftRight(B(6))), s = ne(H(Ln, Rn).mul(o));
153
+ return ne(a.add(s));
154
154
  }, Kn = /* @__PURE__ */ G("\n fn haltonScrambled( index: i32, base: i32, scramble: u32 ) -> f32 {\n\n var result = 0.0f;\n var f = 1.0f;\n var i = index + 1;\n var s = scramble;\n var iter = 0;\n\n while ( i > 0 && iter < 32 ) {\n\n iter += 1;\n f /= f32( base );\n\n // Additive permutation per digit: (digit + s_k) mod base\n // Guaranteed bijection within [0, base) for any s_k\n var digit = i % base;\n digit = ( digit + i32( s % u32( base ) ) ) % base;\n result += f * f32( digit );\n i /= base;\n\n // Evolve scramble per digit position for position-dependent permutations\n s = s * 747796405u + 2891336453u;\n\n }\n\n return result;\n\n }\n"), qn = /* @__PURE__ */ G("\n fn owen_scrambled_sobol( index: u32, dimension: u32, seed: u32 ) -> f32 {\n\n var result = 0u;\n for ( var i = 0; i < 32; i++ ) {\n\n if ( ( index & ( 1u << u32( i ) ) ) != 0u ) {\n\n result ^= getSobolDirectionVector( i );\n\n }\n\n }\n\n // Mix dimension into seed for inter-dimensional decorrelation\n // (Van der Corput base is shared; Owen scrambling with distinct seeds\n // produces decorrelated sequences across dimensions)\n let dimSeed = seed ^ ( dimension * 0x9e3779b9u + 0x6a09e667u );\n result = owen_scramble( result, dimSeed );\n return f32( result ) / 4294967296.0f;\n\n }\n", [zn, /* @__PURE__ */ G("\n fn owen_scramble( x: u32, seed: u32 ) -> u32 {\n\n var v = x;\n v ^= v * 0x3d20adeau;\n v += seed;\n v *= ( seed >> 16u ) | 1u;\n v ^= v >> 15u;\n v *= 0x5851f42du;\n v ^= v >> 12u;\n v *= 0x4c957f2du;\n v ^= v >> 18u;\n return v;\n\n }\n")]), Jn = (e, t, n, r, i, a, o, s) => {
155
155
  let c = L(a.notEqual(N(-1)), a, Mn), l = W(0).toVar();
156
156
  return p(c.equal(N(0)), () => {
@@ -429,7 +429,8 @@ var Ln = M(.7548776662466927), Rn = M(.5698402909980532), zn = /* @__PURE__ */ G
429
429
  ANIMATION_FINISHED: "engine:animationFinished",
430
430
  VIDEO_RENDER_PROGRESS: "engine:videoRenderProgress",
431
431
  VIDEO_RENDER_COMPLETE: "engine:videoRenderComplete",
432
- DISPOSE: "engine:dispose"
432
+ DISPOSE: "engine:dispose",
433
+ DEVICE_LOST: "engine:deviceLost"
433
434
  }, nr = null;
434
435
  function rr(e) {
435
436
  nr = e;
@@ -1819,9 +1820,10 @@ var gi = class {
1819
1820
  t && e && t.envTex && (t.envTex.value = e), e && !e._isGeneratedProcedural && this.uniforms.set("hasSun", 0);
1820
1821
  }
1821
1822
  async setEnvironmentMap(e) {
1822
- this.scene.environment = e, this.setEnvironmentTexture(e), e ? await this.buildEnvironmentCDF() : (this._updateCDFTexture(), this.uniforms.set("envTotalSum", 0), this.uniforms.set("envCompensationDelta", 0), this.uniforms.set("useEnvMapIS", 0));
1823
- let t = this.callbacks.getSceneTextureNodes?.();
1824
- t && e && t.envTex && (t.envTex.value = e), e && !e._isGeneratedProcedural && this.uniforms.set("hasSun", 0), this._notifyReset();
1823
+ let t = this.environmentTexture;
1824
+ e && t && t !== e && t !== this._envPlaceholder && t !== this._previousHDRI && t.dispose?.(), this.scene.environment = e, this.setEnvironmentTexture(e), e ? await this.buildEnvironmentCDF() : (this._updateCDFTexture(), this.uniforms.set("envTotalSum", 0), this.uniforms.set("envCompensationDelta", 0), this.uniforms.set("useEnvMapIS", 0));
1825
+ let n = this.callbacks.getSceneTextureNodes?.();
1826
+ n && e && n.envTex && (n.envTex.value = e), e && !e._isGeneratedProcedural && this.uniforms.set("hasSun", 0), this._notifyReset();
1825
1827
  }
1826
1828
  async generateGradientTexture() {
1827
1829
  this.simpleSkyRenderer ||= new _i(512, 256);
@@ -3616,7 +3618,7 @@ var Yo = /* @__PURE__ */ f(([e, t]) => {
3616
3618
  }
3617
3619
  return this.stats.timeMs = performance.now() - n, this.stats;
3618
3620
  }
3619
- }, is = "" + new URL("assets/BVHWorker-CNJ0UBQz.js", import.meta.url).href, as = {
3621
+ }, is = "" + new URL("assets/BVHWorker-CiVdFrwe.js", import.meta.url).href, as = {
3620
3622
  FLOATS_PER_TRIANGLE: 32,
3621
3623
  POSITION_A_OFFSET: 0,
3622
3624
  POSITION_B_OFFSET: 4,
@@ -4285,7 +4287,7 @@ var Yo = /* @__PURE__ */ f(([e, t]) => {
4285
4287
  }
4286
4288
  }
4287
4289
  }
4288
- }, hs = "" + new URL("assets/BVHSubtreeWorker-D9GImjGj.js", import.meta.url).href, gs = 32, _s = 5e4, vs = 8;
4290
+ }, hs = "" + new URL("assets/BVHSubtreeWorker-sNzvxn66.js", import.meta.url).href, gs = 32, _s = 5e4, vs = 8;
4289
4291
  function ys(e, t, n, r) {
4290
4292
  let i = e.byteLength / (gs * 4), a = Math.min(navigator.hardwareConcurrency || 4, vs), o = Math.ceil(Math.log2(a * 2.5 + 1));
4291
4293
  return console.log(`[ParallelBVH] Parallel build: ${i.toLocaleString()} triangles, ${a} workers, parallelDepth=${o}`), new Promise((s, c) => {
@@ -4867,9 +4869,6 @@ var Cs = 16, ws = class {
4867
4869
  case "worker-direct":
4868
4870
  o = await this.processWithWorkerDirect(r);
4869
4871
  break;
4870
- case "worker-chunked":
4871
- o = await this.processWithWorkerChunked(r, a.chunkSize);
4872
- break;
4873
4872
  case "main-batch":
4874
4873
  o = await this.processOnMainThreadBatch(r, a.batchSize);
4875
4874
  break;
@@ -4887,10 +4886,7 @@ var Cs = 16, ws = class {
4887
4886
  }
4888
4887
  selectProcessingStrategy(e) {
4889
4888
  let t = e.reduce((e, t) => e + (t.image?.width || 0) * (t.image?.height || 0), 0), n = t * 4;
4890
- return this.capabilities.workers && n > jr.MAX_TEXTURE_MEMORY ? {
4891
- method: "worker-chunked",
4892
- chunkSize: Math.max(1, Math.floor(e.length / 4))
4893
- } : this.capabilities.workers && t > 2097152 ? { method: "worker-direct" } : t > 524288 ? {
4889
+ return this.capabilities.workers && n > jr.MAX_TEXTURE_MEMORY ? { method: "main-streaming" } : this.capabilities.workers && t > 2097152 ? { method: "worker-direct" } : t > 524288 ? {
4894
4890
  method: "main-batch",
4895
4891
  batchSize: Math.min(4, e.length)
4896
4892
  } : e.length > 8 ? { method: "main-streaming" } : { method: "main-sync" };
@@ -4930,7 +4926,8 @@ var Cs = 16, ws = class {
4930
4926
  if (!n?.image) continue;
4931
4927
  let e = n.flipY !== !1;
4932
4928
  try {
4933
- if (typeof createImageBitmap < "u" && n.image instanceof HTMLImageElement) {
4929
+ let r = n.image;
4930
+ if (typeof createImageBitmap < "u" && (r instanceof HTMLImageElement || typeof ImageBitmap < "u" && r instanceof ImageBitmap || typeof HTMLCanvasElement < "u" && r instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && r instanceof OffscreenCanvas)) {
4934
4931
  let r = await createImageBitmap(n.image, { imageOrientation: e ? "flipY" : "none" });
4935
4932
  t.push({
4936
4933
  bitmap: r,
@@ -4955,14 +4952,6 @@ var Cs = 16, ws = class {
4955
4952
  }
4956
4953
  return t;
4957
4954
  }
4958
- async processWithWorkerChunked(e, t) {
4959
- let n = [];
4960
- for (let r = 0; r < e.length; r += t) {
4961
- let i = e.slice(r, r + t), a = await this.processWithWorkerDirect(i);
4962
- n.push(a);
4963
- }
4964
- return this.combineTextureResults(n);
4965
- }
4966
4955
  async processOnMainThreadBatch(e, t) {
4967
4956
  let n = e.filter((e) => e?.image);
4968
4957
  if (n.length === 0) return this.createFallbackTexture();
@@ -5353,9 +5342,6 @@ var Cs = 16, ws = class {
5353
5342
  ]), 1, 1, 1);
5354
5343
  return e.minFilter = J, e.magFilter = J, e.format = It, e.type = $t, e.needsUpdate = !0, e.generateMipmaps = !1, e;
5355
5344
  }
5356
- combineTextureResults(e) {
5357
- return e[0];
5358
- }
5359
5345
  dispose() {
5360
5346
  this.canvasPool.dispose(), this.bufferPool.dispose(), this.textureCache.dispose();
5361
5347
  }
@@ -5390,14 +5376,23 @@ var Ns = 128, Ps = class {
5390
5376
  return this._vectorPool.vec2[e % this._vectorPool.vec2.length];
5391
5377
  }
5392
5378
  extract(e) {
5393
- return this.resetArrays(), this._triangleCapacity = 1024, this.triangleData = new Float32Array(this._triangleCapacity * Z.FLOATS_PER_TRIANGLE), this.currentTriangleIndex = 0, this.traverseObject(e), this.logStats(), this.getExtractedData();
5379
+ this.resetArrays();
5380
+ let t = this._countTriangles(e);
5381
+ return this._triangleCapacity = Math.max(1024, t), this.triangleData = new Float32Array(this._triangleCapacity * Z.FLOATS_PER_TRIANGLE), this.currentTriangleIndex = 0, this.traverseObject(e), this.logStats(), this.getExtractedData();
5382
+ }
5383
+ _countTriangles(e) {
5384
+ let t = 0;
5385
+ if (e.isMesh && e.geometry && e.material) {
5386
+ let n = e.geometry.index, r = e.geometry.attributes.position;
5387
+ n ? t += Math.ceil(n.count / 3) : r && (t += Math.ceil(r.count / 3));
5388
+ }
5389
+ if (e.children) for (let n of e.children) t += this._countTriangles(n);
5390
+ return t;
5394
5391
  }
5395
5392
  _ensureCapacity(e) {
5396
5393
  if (e <= this._triangleCapacity) return;
5397
- let t = this._triangleCapacity;
5398
- for (; t < e;) t *= 2;
5399
- let n = new Float32Array(t * Z.FLOATS_PER_TRIANGLE);
5400
- n.set(this.triangleData), this.triangleData = n, this._triangleCapacity = t;
5394
+ let t = new Float32Array(e * Z.FLOATS_PER_TRIANGLE);
5395
+ t.set(this.triangleData), this.triangleData = t, this._triangleCapacity = e;
5401
5396
  }
5402
5397
  traverseObject(e) {
5403
5398
  if (e.isMesh ? this.processMesh(e) : e.isDirectionalLight ? this.directionalLights.push(e) : e.isCamera && this.cameras.push(e), e.children) for (let t of e.children) this.traverseObject(t);
@@ -6137,7 +6132,11 @@ var Rs = class {
6137
6132
  enabled: this.bvhBuilder.enableReinsertionOptimization,
6138
6133
  batchSizeRatio: this.bvhBuilder.reinsertionBatchSizeRatio,
6139
6134
  maxIterations: this.bvhBuilder.reinsertionMaxIterations
6140
- }
6135
+ },
6136
+ maxLeafSize: this.bvhBuilder.maxLeafSize,
6137
+ numBins: this.bvhBuilder.numBins,
6138
+ maxBins: this.bvhBuilder.maxBins,
6139
+ minBins: this.bvhBuilder.minBins
6141
6140
  }, c = a.length + o.length, l = this._buildBLASesWithPool(a, s, (e) => {
6142
6141
  ar({
6143
6142
  status: `Building BLAS ${e + o.length}/${c}...`,
@@ -6225,7 +6224,11 @@ var Rs = class {
6225
6224
  reportProgress: !1,
6226
6225
  sharedReorderBuffer: null,
6227
6226
  treeletOptimization: f,
6228
- reinsertionOptimization: t.reinsertionOptimization
6227
+ reinsertionOptimization: t.reinsertionOptimization,
6228
+ maxLeafSize: t.maxLeafSize,
6229
+ numBins: t.numBins,
6230
+ maxBins: t.maxBins,
6231
+ minBins: t.minBins
6229
6232
  }, [l.buffer]);
6230
6233
  }, f = (e, t) => {
6231
6234
  let r = t.data;
@@ -7287,12 +7290,16 @@ var Qs = 4, $s = class extends $n {
7287
7290
  }, tc = {
7288
7291
  DIST_TRI_BARY: 0,
7289
7292
  NORMAL_MAT: 1
7290
- }, nc = 0, rc = (e, t) => t === 0 ? e : e.add(t * nc), ic = class {
7293
+ }, nc = 0, rc = (e, t) => t === 0 ? e : e.add(t * nc);
7294
+ function ic(e, t) {
7295
+ t && e?._attributes?.delete?.(t);
7296
+ }
7297
+ var ac = class {
7291
7298
  static requiredCapacity(e) {
7292
7299
  return Math.ceil(e * 1.25);
7293
7300
  }
7294
- constructor(e = 0) {
7295
- this.capacity = 0, this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, e > 0 && this.allocate(e);
7301
+ constructor(e = 0, t = null) {
7302
+ this.capacity = 0, this._renderer = t, this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, e > 0 && this.allocate(e);
7296
7303
  }
7297
7304
  allocate(e) {
7298
7305
  this.dispose();
@@ -7320,14 +7327,14 @@ var Qs = 4, $s = class extends $n {
7320
7327
  return Math.ceil(e * 1.25) <= this.capacity && this.capacity > 0 ? !1 : (this.allocate(e), !0);
7321
7328
  }
7322
7329
  dispose() {
7323
- this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, this.capacity = 0;
7330
+ ic(this._renderer, this._attrs.ray), ic(this._renderer, this._attrs.rng), ic(this._renderer, this._attrs.hit), this._attrs = {}, this.rayBuffer = null, this.rngBuffer = null, this.hitBuffer = null, this.capacity = 0;
7324
7331
  }
7325
- }, ac = (e, t) => e.element(rc(t, ec.ORIGIN_META)).xyz, oc = (e, t) => e.element(rc(t, ec.DIR_FLAGS)).xyz, sc = (e, t) => ee(e.element(rc(t, ec.DIR_FLAGS)).w), cc = (e, t) => e.element(rc(t, ec.THROUGHPUT_PDF)).xyz, lc = (e, t) => e.element(rc(t, ec.THROUGHPUT_PDF)).w, uc = (e, t) => e.element(rc(t, ec.RADIANCE_ALPHA)), dc = (e) => B(e).mul(1), fc = (e, t, n, r, i) => e.element(dc(t)).assign(Re(pe(H(n.x, n.y)), pe(H(n.z, r)), me(H(i.x, i.y)), me(H(i.z, 0)))), pc = (e, t) => e.element(dc(t)), mc = (e) => {
7332
+ }, oc = (e, t) => e.element(rc(t, ec.ORIGIN_META)).xyz, sc = (e, t) => e.element(rc(t, ec.DIR_FLAGS)).xyz, cc = (e, t) => ee(e.element(rc(t, ec.DIR_FLAGS)).w), lc = (e, t) => e.element(rc(t, ec.THROUGHPUT_PDF)).xyz, uc = (e, t) => e.element(rc(t, ec.THROUGHPUT_PDF)).w, dc = (e, t) => e.element(rc(t, ec.RADIANCE_ALPHA)), fc = (e) => B(e).mul(1), pc = (e, t, n, r, i) => e.element(fc(t)).assign(Re(pe(H(n.x, n.y)), pe(H(n.z, r)), me(H(i.x, i.y)), me(H(i.z, 0)))), mc = (e, t) => e.element(fc(t)), hc = (e) => {
7326
7333
  let t = Pe(e.x), n = Pe(e.y);
7327
7334
  return W(U(t.x, t.y, n.x).mul(.5).add(.5), n.y);
7328
- }, hc = (e) => U(Fe(e.z), Fe(e.w).x), gc = (e, t, n, r, i) => e.element(rc(t, ec.ORIGIN_META)).assign(W(n, Me(B(r).bitOr(B(i).shiftLeft(8))))), _c = (e, t, n, r) => e.element(rc(t, ec.DIR_FLAGS)).assign(W(n, Me(r))), vc = (e, t, n, r) => e.element(rc(t, ec.THROUGHPUT_PDF)).assign(W(n, r)), yc = (e, t, n) => e.element(rc(t, ec.RADIANCE_ALPHA)).assign(n), bc = (e, t) => e.element(rc(t, tc.DIST_TRI_BARY)).x, xc = (e, t) => ee(e.element(rc(t, tc.DIST_TRI_BARY)).y), Sc = (e, t) => e.element(rc(t, tc.DIST_TRI_BARY)).zw, Cc = (e, t) => e.element(rc(t, tc.NORMAL_MAT)).xyz, wc = (e, t) => B(ee(e.element(rc(t, tc.NORMAL_MAT)).w).bitAnd(65535)), Tc = (e, t, n, r, i, a, o, s, c) => {
7335
+ }, gc = (e) => U(Fe(e.z), Fe(e.w).x), _c = (e, t, n, r, i) => e.element(rc(t, ec.ORIGIN_META)).assign(W(n, Me(B(r).bitOr(B(i).shiftLeft(8))))), vc = (e, t, n, r) => e.element(rc(t, ec.DIR_FLAGS)).assign(W(n, Me(r))), yc = (e, t, n, r) => e.element(rc(t, ec.THROUGHPUT_PDF)).assign(W(n, r)), bc = (e, t, n) => e.element(rc(t, ec.RADIANCE_ALPHA)).assign(n), xc = (e, t) => e.element(rc(t, tc.DIST_TRI_BARY)).x, Sc = (e, t) => ee(e.element(rc(t, tc.DIST_TRI_BARY)).y), Cc = (e, t) => e.element(rc(t, tc.DIST_TRI_BARY)).zw, wc = (e, t) => e.element(rc(t, tc.NORMAL_MAT)).xyz, Tc = (e, t) => B(ee(e.element(rc(t, tc.NORMAL_MAT)).w).bitAnd(65535)), Ec = (e, t, n, r, i, a, o, s, c) => {
7329
7336
  e.element(rc(t, tc.DIST_TRI_BARY)).assign(W(n, Me(r), i, a)), e.element(rc(t, tc.NORMAL_MAT)).assign(W(o, Me(s.bitOr(c.shiftLeft(16)))));
7330
- }, Ec = (e, t) => {
7337
+ }, Dc = (e, t) => {
7331
7338
  let n = e.element(rc(t, ec.MEDIUM_STACK)), r = ee(n.x);
7332
7339
  return {
7333
7340
  stackDepth: r.bitAnd(255),
@@ -7337,17 +7344,17 @@ var Qs = 4, $s = class extends $n {
7337
7344
  ior2: n.z,
7338
7345
  ior3: n.w
7339
7346
  };
7340
- }, Dc = (e, t, n, r, i, a, o, s = B(0)) => e.element(rc(t, ec.MEDIUM_STACK)).assign(W(Me(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), Oc = (e, t) => e.element(rc(t, ec.MEDIUM_SIGMA_A)).xyz, kc = (e, t, n) => e.element(rc(t, ec.MEDIUM_SIGMA_A)).assign(W(n, 0)), Ac = (e, t) => N(ee(e.element(rc(t, ec.ORIGIN_META)).w).bitAnd(255)), jc = (e, t) => N(ee(e.element(rc(t, ec.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), Mc = (e, t) => {
7347
+ }, Oc = (e, t, n, r, i, a, o, s = B(0)) => e.element(rc(t, ec.MEDIUM_STACK)).assign(W(Me(n.bitOr(r.shiftLeft(8)).bitOr(s.shiftLeft(16))), i, a, o)), kc = (e, t) => e.element(rc(t, ec.MEDIUM_SIGMA_A)).xyz, Ac = (e, t, n) => e.element(rc(t, ec.MEDIUM_SIGMA_A)).assign(W(n, 0)), jc = (e, t) => N(ee(e.element(rc(t, ec.ORIGIN_META)).w).bitAnd(255)), Mc = (e, t) => N(ee(e.element(rc(t, ec.ORIGIN_META)).w).shiftRight(8).bitAnd(255)), Nc = (e, t) => {
7341
7348
  let n = e.element(rc(t, ec.SSS_SIGMA_S));
7342
7349
  return {
7343
7350
  sigmaS: n.xyz,
7344
7351
  g: n.w
7345
7352
  };
7346
- }, Nc = (e, t, n, r) => e.element(rc(t, ec.SSS_SIGMA_S)).assign(W(n, r)), Pc = {
7353
+ }, Pc = (e, t, n, r) => e.element(rc(t, ec.SSS_SIGMA_S)).assign(W(n, r)), Fc = {
7347
7354
  ACTIVE_RAY_COUNT: 0,
7348
7355
  ENTERING_COUNT: 1,
7349
7356
  COUNT: 2
7350
- }, Fc = {
7357
+ }, Ic = {
7351
7358
  BOUNCE_MASK: 255,
7352
7359
  ACTIVE: 256,
7353
7360
  SPECULAR: 512,
@@ -7357,12 +7364,12 @@ var Qs = 4, $s = class extends $n {
7357
7364
  HAS_HIT_OPAQUE: 65536,
7358
7365
  AUX_LOCKED: 1 << 17,
7359
7366
  REDIRECTED: 1 << 18
7360
- }, Ic = class {
7361
- constructor(e = 0) {
7362
- this.capacity = 0, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.pingPong = 0, e > 0 && this.allocate(e);
7367
+ }, Lc = class {
7368
+ constructor(e = 0, t = null) {
7369
+ this._renderer = t, this.capacity = 0, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.pingPong = 0, e > 0 && this.allocate(e);
7363
7370
  }
7364
7371
  allocate(e) {
7365
- this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(Pc.COUNT), 1), this.counters = we(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = we(this._bounceCountsAttr, "uint");
7372
+ this.dispose(), this.capacity = e, this._countersAttr = new o(new Uint32Array(Fc.COUNT), 1), this.counters = we(this._countersAttr, "uint").toAtomic(), this.MAX_BOUNCE_SNAPSHOTS = 32, this._bounceCountsAttr = new o(new Uint32Array(this.MAX_BOUNCE_SNAPSHOTS), 1), this.bounceCounts = we(this._bounceCountsAttr, "uint");
7366
7373
  let t = new o(new Uint32Array(e), 1), n = new o(new Uint32Array(e), 1);
7367
7374
  this._attrA = t, this._attrB = n, this.activeIndices = {
7368
7375
  a: we(t, "uint"),
@@ -7373,7 +7380,7 @@ var Qs = 4, $s = class extends $n {
7373
7380
  };
7374
7381
  let r = new o(new Uint32Array(e), 1);
7375
7382
  this._sortAttr = r, this.sortedIndices = we(r, "uint"), this.sortedIndicesRO = we(r, "uint").toReadOnly(), this._sortGlobalHistAttr = new o(new Uint32Array(256), 1), this.sortGlobalHistogram = we(this._sortGlobalHistAttr, "uint").toAtomic(), this.pingPong = 0;
7376
- let i = Pc.COUNT * 4 + e * 4 * 3;
7383
+ let i = Fc.COUNT * 4 + e * 4 * 3;
7377
7384
  console.log(`QueueManager: Allocated capacity=${e}, total=${(i / (1024 * 1024)).toFixed(1)} MB`);
7378
7385
  }
7379
7386
  resize(e) {
@@ -7416,14 +7423,14 @@ var Qs = 4, $s = class extends $n {
7416
7423
  this.pingPong = 0;
7417
7424
  }
7418
7425
  dispose() {
7419
- this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.capacity = 0;
7426
+ ic(this._renderer, this._countersAttr), ic(this._renderer, this._bounceCountsAttr), ic(this._renderer, this._attrA), ic(this._renderer, this._attrB), ic(this._renderer, this._sortAttr), ic(this._renderer, this._sortGlobalHistAttr), this._countersAttr = this._bounceCountsAttr = null, this._attrA = this._attrB = this._sortAttr = this._sortGlobalHistAttr = null, this.counters = null, this.activeIndices = null, this.activeIndicesRO = null, this.sortedIndices = null, this.sortedIndicesRO = null, this.sortGlobalHistogram = null, this.capacity = 0;
7420
7427
  }
7421
- }, Lc = {
7428
+ }, Rc = {
7422
7429
  [It]: 4,
7423
7430
  [Lt]: 3,
7424
7431
  [Rt]: 2,
7425
7432
  [Vt]: 1
7426
- }, Rc = {
7433
+ }, zc = {
7427
7434
  [ct]: 4,
7428
7435
  [dt]: 2,
7429
7436
  [$t]: 1,
@@ -7433,23 +7440,23 @@ var Qs = 4, $s = class extends $n {
7433
7440
  [en]: 4,
7434
7441
  [ft]: 4
7435
7442
  };
7436
- function zc(e) {
7437
- return (Lc[e.format] ?? 4) * (Rc[e.type] ?? 4);
7438
- }
7439
7443
  function Bc(e) {
7440
- return e?.array?.byteLength || 0;
7444
+ return (Rc[e.format] ?? 4) * (zc[e.type] ?? 4);
7441
7445
  }
7442
7446
  function Vc(e) {
7447
+ return e?.array?.byteLength || 0;
7448
+ }
7449
+ function Hc(e) {
7443
7450
  if (!e) return 0;
7444
7451
  if (e.isRenderTarget) {
7445
7452
  let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
7446
- for (let e of t) e && (a += n * r * i * zc(e));
7453
+ for (let e of t) e && (a += n * r * i * Bc(e));
7447
7454
  return a;
7448
7455
  }
7449
7456
  let t = e.image || {}, n = t.width ?? e.width ?? 0, r = t.height ?? e.height ?? 0, i = t.depth ?? 1;
7450
- return n * r * i * zc(e);
7457
+ return n * r * i * Bc(e);
7451
7458
  }
7452
- var Hc = class {
7459
+ var Uc = class {
7453
7460
  constructor(e = null) {
7454
7461
  this._providers = [], this._renderer = e, this.current = 0, this.peak = 0, this.byCategory = {};
7455
7462
  }
@@ -7495,10 +7502,10 @@ var Hc = class {
7495
7502
  _residentTextureBytes(e) {
7496
7503
  if (e.isRenderTarget) {
7497
7504
  let t = e.textures?.length ? e.textures : [e.texture], n = e.width || 0, r = e.height || 0, i = e.depth || 1, a = 0;
7498
- for (let e of t) e && this._isResident(e) && (a += n * r * i * zc(e));
7505
+ for (let e of t) e && this._isResident(e) && (a += n * r * i * Bc(e));
7499
7506
  return a;
7500
7507
  }
7501
- return this._isResident(e) ? Vc(e) : 0;
7508
+ return this._isResident(e) ? Hc(e) : 0;
7502
7509
  }
7503
7510
  resetPeak() {
7504
7511
  this.peak = this.current;
@@ -7507,7 +7514,7 @@ var Hc = class {
7507
7514
  let e = (e) => (e / 1048576).toFixed(1), t = Object.entries(this.byCategory).map(([t, n]) => `${t}=${e(n)}`);
7508
7515
  return `VRAM current=${e(this.current)}MB peak=${e(this.peak)}MB [${t.join(" ")}]`;
7509
7516
  }
7510
- }, Uc = {
7517
+ }, Wc = {
7511
7518
  generate: [
7512
7519
  16,
7513
7520
  16,
@@ -7548,10 +7555,10 @@ var Hc = class {
7548
7555
  16,
7549
7556
  1
7550
7557
  ]
7551
- }, Wc = class {
7558
+ }, Gc = class {
7552
7559
  constructor(e) {
7553
7560
  this.renderer = e, this.kernels = /* @__PURE__ */ new Map(), this.workgroupSizes = /* @__PURE__ */ new Map(), this.timing = /* @__PURE__ */ new Map(), this.profiling = !1, this.profile = /* @__PURE__ */ new Map();
7554
- for (let [e, t] of Object.entries(Uc)) this.workgroupSizes.set(e, t);
7561
+ for (let [e, t] of Object.entries(Wc)) this.workgroupSizes.set(e, t);
7555
7562
  }
7556
7563
  register(e, t) {
7557
7564
  this.kernels.set(e, t), this.timing.set(e, {
@@ -7645,7 +7652,7 @@ var Hc = class {
7645
7652
  dispose() {
7646
7653
  this.kernels.clear(), this.timing.clear(), this.profile.clear();
7647
7654
  }
7648
- }, Gc = 32, Kc = 512, qc = 4, Jc = 8, Yc = 1e8, Xc = () => y("int", Gc).toVar(), Zc = G("\n fn RayTriangleGeometry( rayOrigin: vec3f, rayDir: vec3f, pA: vec3f, pB: vec3f, pC: vec3f, closestHitDst: f32, woopParams: vec4f ) -> vec4f {\n\n // Returns vec4(t, u, v, hit) where hit > 0.5 means intersection.\n // woopParams: (Sx, Sy, Sz, bitcast<f32>(packed kx|ky<<2|kz<<4))\n var result = vec4f( 1e20f, 0.0f, 0.0f, 0.0f );\n\n let Sx = woopParams.x;\n let Sy = woopParams.y;\n let Sz = woopParams.z;\n // Packed as regular f32 (values 0–42), not bitcast — avoids subnormal FTZ on Apple GPUs.\n let packed = i32( woopParams.w );\n let kx = packed & 3;\n let ky = ( packed >> 2 ) & 3;\n let kz = ( packed >> 4 ) & 3;\n\n let A = pA - rayOrigin;\n let B = pB - rayOrigin;\n let C = pC - rayOrigin;\n\n let Akz = A[ kz ];\n let Bkz = B[ kz ];\n let Ckz = C[ kz ];\n\n let Ax = A[ kx ] - Sx * Akz;\n let Ay = A[ ky ] - Sy * Akz;\n let Bx = B[ kx ] - Sx * Bkz;\n let By = B[ ky ] - Sy * Bkz;\n let Cx = C[ kx ] - Sx * Ckz;\n let Cy = C[ ky ] - Sy * Ckz;\n\n // Edge function tests — all three must share sign (or be exactly zero) for hit.\n let U = Cx * By - Cy * Bx;\n let V = Ax * Cy - Ay * Cx;\n let W = Bx * Ay - By * Ax;\n\n let neg = U < 0.0f || V < 0.0f || W < 0.0f;\n let pos = U > 0.0f || V > 0.0f || W > 0.0f;\n if ( !( neg && pos ) ) {\n\n let det = U + V + W;\n if ( det != 0.0f ) {\n\n let T = U * ( Sz * Akz ) + V * ( Sz * Bkz ) + W * ( Sz * Ckz );\n\n // Sign-aware bounds check on t (multiply both sides by sign(det) once).\n let detSign = select( -1.0f, 1.0f, det > 0.0f );\n let tSigned = T * detSign;\n let detAbs = abs( det );\n\n if ( tSigned > 0.0f && tSigned < closestHitDst * detAbs ) {\n\n // Match Möller-Trumbore convention: u = weight of B, v = weight of C.\n // In Woop's edge functions, U → weight of A, V → weight of B, W → weight of C.\n let invDet = 1.0f / det;\n result = vec4f( T * invDet, V * invDet, W * invDet, 1.0f );\n\n }\n\n }\n\n }\n\n return result;\n\n }\n"), Qc = G("\n fn computeWoopRayParams( rayDir: vec3f ) -> vec4f {\n\n let absDir = abs( rayDir );\n\n // kz = argmax(|dir|)\n var kz: i32 = 0;\n if ( absDir.y >= absDir.x ) { kz = 1; }\n if ( absDir.z >= absDir[ u32( kz ) ] ) { kz = 2; }\n\n var kx: i32 = ( kz + 1 ) % 3;\n var ky: i32 = ( kx + 1 ) % 3;\n\n // Preserve triangle winding when the dominant axis component is negative.\n if ( rayDir[ u32( kz ) ] < 0.0f ) {\n let tmp = kx;\n kx = ky;\n ky = tmp;\n }\n\n let dz = rayDir[ u32( kz ) ];\n let Sx = rayDir[ u32( kx ) ] / dz;\n let Sy = rayDir[ u32( ky ) ] / dz;\n let Sz = 1.0f / dz;\n\n let packed = kx | ( ky << 2 ) | ( kz << 4 );\n return vec4f( Sx, Sy, Sz, f32( packed ) );\n\n }\n"), $c = G("\n fn fastRayAABBDst( rayOrigin: vec3f, invDir: vec3f, boxMin: vec3f, boxMax: vec3f ) -> f32 {\n\n let t1 = ( boxMin - rayOrigin ) * invDir;\n let t2 = ( boxMax - rayOrigin ) * invDir;\n\n let tmin = min( t1, t2 );\n let tmax = max( t1, t2 );\n\n let tNear = max( max( tmin.x, tmin.y ), tmin.z );\n let tFar = min( min( tmax.x, tmax.y ), tmax.z ) * 1.00000024f; // Robust traversal: 2 ULP padding (Ize 2013)\n\n let isHit = tNear <= tFar && tFar > 0.0f;\n return select( 1e20f, max( tNear, 0.0f ), isHit );\n\n }\n"), el = f(([e, t, n, r]) => {
7655
+ }, Kc = 32, qc = 512, Jc = 4, Yc = 8, Xc = 1e8, Zc = () => y("int", Kc).toVar(), Qc = G("\n fn RayTriangleGeometry( rayOrigin: vec3f, rayDir: vec3f, pA: vec3f, pB: vec3f, pC: vec3f, closestHitDst: f32, woopParams: vec4f ) -> vec4f {\n\n // Returns vec4(t, u, v, hit) where hit > 0.5 means intersection.\n // woopParams: (Sx, Sy, Sz, bitcast<f32>(packed kx|ky<<2|kz<<4))\n var result = vec4f( 1e20f, 0.0f, 0.0f, 0.0f );\n\n let Sx = woopParams.x;\n let Sy = woopParams.y;\n let Sz = woopParams.z;\n // Packed as regular f32 (values 0–42), not bitcast — avoids subnormal FTZ on Apple GPUs.\n let packed = i32( woopParams.w );\n let kx = packed & 3;\n let ky = ( packed >> 2 ) & 3;\n let kz = ( packed >> 4 ) & 3;\n\n let A = pA - rayOrigin;\n let B = pB - rayOrigin;\n let C = pC - rayOrigin;\n\n let Akz = A[ kz ];\n let Bkz = B[ kz ];\n let Ckz = C[ kz ];\n\n let Ax = A[ kx ] - Sx * Akz;\n let Ay = A[ ky ] - Sy * Akz;\n let Bx = B[ kx ] - Sx * Bkz;\n let By = B[ ky ] - Sy * Bkz;\n let Cx = C[ kx ] - Sx * Ckz;\n let Cy = C[ ky ] - Sy * Ckz;\n\n // Edge function tests — all three must share sign (or be exactly zero) for hit.\n let U = Cx * By - Cy * Bx;\n let V = Ax * Cy - Ay * Cx;\n let W = Bx * Ay - By * Ax;\n\n let neg = U < 0.0f || V < 0.0f || W < 0.0f;\n let pos = U > 0.0f || V > 0.0f || W > 0.0f;\n if ( !( neg && pos ) ) {\n\n let det = U + V + W;\n if ( det != 0.0f ) {\n\n let T = U * ( Sz * Akz ) + V * ( Sz * Bkz ) + W * ( Sz * Ckz );\n\n // Sign-aware bounds check on t (multiply both sides by sign(det) once).\n let detSign = select( -1.0f, 1.0f, det > 0.0f );\n let tSigned = T * detSign;\n let detAbs = abs( det );\n\n if ( tSigned > 0.0f && tSigned < closestHitDst * detAbs ) {\n\n // Match Möller-Trumbore convention: u = weight of B, v = weight of C.\n // In Woop's edge functions, U → weight of A, V → weight of B, W → weight of C.\n let invDet = 1.0f / det;\n result = vec4f( T * invDet, V * invDet, W * invDet, 1.0f );\n\n }\n\n }\n\n }\n\n return result;\n\n }\n"), $c = G("\n fn computeWoopRayParams( rayDir: vec3f ) -> vec4f {\n\n let absDir = abs( rayDir );\n\n // kz = argmax(|dir|)\n var kz: i32 = 0;\n if ( absDir.y >= absDir.x ) { kz = 1; }\n if ( absDir.z >= absDir[ u32( kz ) ] ) { kz = 2; }\n\n var kx: i32 = ( kz + 1 ) % 3;\n var ky: i32 = ( kx + 1 ) % 3;\n\n // Preserve triangle winding when the dominant axis component is negative.\n if ( rayDir[ u32( kz ) ] < 0.0f ) {\n let tmp = kx;\n kx = ky;\n ky = tmp;\n }\n\n let dz = rayDir[ u32( kz ) ];\n let Sx = rayDir[ u32( kx ) ] / dz;\n let Sy = rayDir[ u32( ky ) ] / dz;\n let Sz = 1.0f / dz;\n\n let packed = kx | ( ky << 2 ) | ( kz << 4 );\n return vec4f( Sx, Sy, Sz, f32( packed ) );\n\n }\n"), el = G("\n fn fastRayAABBDst( rayOrigin: vec3f, invDir: vec3f, boxMin: vec3f, boxMax: vec3f ) -> f32 {\n\n let t1 = ( boxMin - rayOrigin ) * invDir;\n let t2 = ( boxMax - rayOrigin ) * invDir;\n\n let tmin = min( t1, t2 );\n let tmax = max( t1, t2 );\n\n let tNear = max( max( tmin.x, tmin.y ), tmin.z );\n let tFar = min( min( tmax.x, tmax.y ), tmax.z ) * 1.00000024f; // Robust traversal: 2 ULP padding (Ize 2013)\n\n let isHit = tNear <= tFar && tFar > 0.0f;\n return select( 1e20f, max( tNear, 0.0f ), isHit );\n\n }\n"), tl = f(([e, t, n, r]) => {
7649
7656
  let i = r ?? T(!1), a = Ci({
7650
7657
  didHit: !1,
7651
7658
  dst: M(0x56bc75e2d63100000),
@@ -7656,12 +7663,12 @@ var Hc = class {
7656
7663
  meshIndex: N(-1),
7657
7664
  boxTests: N(0),
7658
7665
  triTests: N(0)
7659
- }).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = Xc(), u = N(1).toVar();
7666
+ }).toVar(), o = N(-1).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = Zc(), u = N(1).toVar();
7660
7667
  l.element(N(0)).assign(N(0));
7661
- let f = ue(U(1), ye(e.direction), fe(e.direction, U(0))), h = ue(U(1).div(e.direction), U(Yc).mul(f), ae(_(e.direction), U(1e-8))).toVar(), g = e.origin, v = e.direction, y = Qc({ rayDir: v }).toVar(), b = N(0).toVar();
7662
- return m(u.greaterThan(N(0)).and(b.lessThan(N(Kc))), () => {
7668
+ let f = ue(U(1), ye(e.direction), fe(e.direction, U(0))), h = ue(U(1).div(e.direction), U(Xc).mul(f), ae(_(e.direction), U(1e-8))).toVar(), g = e.origin, v = e.direction, y = $c({ rayDir: v }).toVar(), b = N(0).toVar();
7669
+ return m(u.greaterThan(N(0)).and(b.lessThan(N(qc))), () => {
7663
7670
  b.addAssign(1), u.subAssign(1);
7664
- let e = l.element(u).toVar(), r = $(t, e, N(0), N(qc));
7671
+ let e = l.element(u).toVar(), r = $(t, e, N(0), N(Jc));
7665
7672
  a.boxTests.addAssign(1), p(r.w.lessThan(0), () => {
7666
7673
  p(r.w.greaterThan(M(-1.5)), () => {
7667
7674
  let e = N(r.x).toVar(), t = N(r.y).toVar();
@@ -7670,7 +7677,7 @@ var Hc = class {
7670
7677
  end: t
7671
7678
  }, ({ i: t }) => {
7672
7679
  a.triTests.addAssign(1);
7673
- let r = e.add(t).toVar(), l = $(n, r, N(0), N(Jc)).xyz, u = $(n, r, N(1), N(Jc)).xyz, d = $(n, r, N(2), N(Jc)).xyz, f = Zc({
7680
+ let r = e.add(t).toVar(), l = $(n, r, N(0), N(Yc)).xyz, u = $(n, r, N(1), N(Yc)).xyz, d = $(n, r, N(2), N(Yc)).xyz, f = Qc({
7674
7681
  rayOrigin: g,
7675
7682
  rayDir: v,
7676
7683
  pA: l,
@@ -7680,7 +7687,7 @@ var Hc = class {
7680
7687
  woopParams: y
7681
7688
  });
7682
7689
  p(f.w.greaterThan(.5), () => {
7683
- let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(Jc)).xyz, d = $(n, r, N(4), N(Jc)).xyz, m = $(n, r, N(5), N(Jc)), h = m.xyz, g = N(m.w).toVar(), _ = M(1).sub(t).sub(l), y = v.dot(I(u.mul(_).add(d.mul(t)).add(h.mul(l))));
7690
+ let e = f.x, t = f.y, l = f.z, u = $(n, r, N(3), N(Yc)).xyz, d = $(n, r, N(4), N(Yc)).xyz, m = $(n, r, N(5), N(Yc)), h = m.xyz, g = N(m.w).toVar(), _ = M(1).sub(t).sub(l), y = v.dot(I(u.mul(_).add(d.mul(t)).add(h.mul(l))));
7684
7691
  p(i.or(g.equal(N(2))).or(g.equal(N(0)).and(y.lessThan(-1e-4))).or(g.equal(N(1)).and(y.greaterThan(1e-4))), () => {
7685
7692
  a.didHit.assign(!0), a.dst.assign(e), o.assign(r), s.assign(t), c.assign(l);
7686
7693
  });
@@ -7689,17 +7696,17 @@ var Hc = class {
7689
7696
  d();
7690
7697
  });
7691
7698
  }).Else(() => {
7692
- p(r.z.greaterThan(.5).and(u.lessThan(N(Gc))), () => {
7699
+ p(r.z.greaterThan(.5).and(u.lessThan(N(Kc))), () => {
7693
7700
  l.element(u).assign(N(r.x)), u.addAssign(1);
7694
7701
  });
7695
7702
  });
7696
7703
  }).Else(() => {
7697
- let n = $(t, e, N(1), N(qc)), i = $(t, e, N(2), N(qc)), o = $(t, e, N(3), N(qc)), s = N(r.w).toVar(), c = N(n.w).toVar(), d = $c({
7704
+ let n = $(t, e, N(1), N(Jc)), i = $(t, e, N(2), N(Jc)), o = $(t, e, N(3), N(Jc)), s = N(r.w).toVar(), c = N(n.w).toVar(), d = el({
7698
7705
  rayOrigin: g,
7699
7706
  invDir: h,
7700
7707
  boxMin: r.xyz,
7701
7708
  boxMax: n.xyz
7702
- }).toVar(), f = $c({
7709
+ }).toVar(), f = el({
7703
7710
  rayOrigin: g,
7704
7711
  invDir: h,
7705
7712
  boxMin: i.xyz,
@@ -7707,21 +7714,21 @@ var Hc = class {
7707
7714
  }).toVar();
7708
7715
  p(le(d, f).lessThan(a.dst), () => {
7709
7716
  let e = d.lessThan(f);
7710
- p(L(e, f, d).lessThan(a.dst).and(u.lessThan(N(Gc))), () => {
7717
+ p(L(e, f, d).lessThan(a.dst).and(u.lessThan(N(Kc))), () => {
7711
7718
  l.element(u).assign(L(e, c, s)), u.addAssign(1);
7712
- }), p(u.lessThan(N(Gc)), () => {
7719
+ }), p(u.lessThan(N(Kc)), () => {
7713
7720
  l.element(u).assign(L(e, s, c)), u.addAssign(1);
7714
7721
  });
7715
7722
  });
7716
7723
  });
7717
7724
  }), p(a.didHit, () => {
7718
7725
  a.hitPoint.assign(e.origin.add(e.direction.mul(a.dst)));
7719
- let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(Jc)).xyz, i = $(n, o, N(4), N(Jc)).xyz, l = $(n, o, N(5), N(Jc)).xyz;
7726
+ let t = M(1).sub(s).sub(c), r = $(n, o, N(3), N(Yc)).xyz, i = $(n, o, N(4), N(Yc)).xyz, l = $(n, o, N(5), N(Yc)).xyz;
7720
7727
  a.normal.assign(I(r.mul(t).add(i.mul(s)).add(l.mul(c))));
7721
- let u = $(n, o, N(6), N(Jc)), d = $(n, o, N(7), N(Jc));
7728
+ let u = $(n, o, N(6), N(Yc)), d = $(n, o, N(7), N(Yc));
7722
7729
  a.uv.assign(u.xy.mul(t).add(u.zw.mul(s)).add(d.xy.mul(c))), a.materialIndex.assign(N(d.z)), a.meshIndex.assign(N(d.w)), a.triangleIndex.assign(o);
7723
7730
  }), a;
7724
- }), tl = f(([e, t, n, r]) => {
7731
+ }), nl = f(([e, t, n, r]) => {
7725
7732
  let i = Ci({
7726
7733
  didHit: !1,
7727
7734
  dst: r,
@@ -7732,12 +7739,12 @@ var Hc = class {
7732
7739
  meshIndex: N(-1),
7733
7740
  boxTests: N(0),
7734
7741
  triTests: N(0)
7735
- }).toVar(), a = Xc(), o = N(1).toVar();
7742
+ }).toVar(), a = Zc(), o = N(1).toVar();
7736
7743
  a.element(N(0)).assign(N(0));
7737
- let s = ue(U(1), ye(e.direction), fe(e.direction, U(0))), c = ue(U(1).div(e.direction), U(Yc).mul(s), ae(_(e.direction), U(1e-8))).toVar(), l = Qc({ rayDir: e.direction }).toVar(), u = N(0).toVar();
7738
- return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(Kc))), () => {
7744
+ let s = ue(U(1), ye(e.direction), fe(e.direction, U(0))), c = ue(U(1).div(e.direction), U(Xc).mul(s), ae(_(e.direction), U(1e-8))).toVar(), l = $c({ rayDir: e.direction }).toVar(), u = N(0).toVar();
7745
+ return m(o.greaterThan(N(0)).and(i.didHit.not()).and(u.lessThan(N(qc))), () => {
7739
7746
  u.addAssign(1), o.subAssign(1);
7740
- let r = a.element(o).toVar(), s = $(t, r, N(0), N(qc));
7747
+ let r = a.element(o).toVar(), s = $(t, r, N(0), N(Jc));
7741
7748
  p(s.w.lessThan(0), () => {
7742
7749
  p(s.w.greaterThan(M(-1.5)), () => {
7743
7750
  let t = N(s.x).toVar(), r = N(s.y).toVar();
@@ -7745,7 +7752,7 @@ var Hc = class {
7745
7752
  start: N(0),
7746
7753
  end: r
7747
7754
  }, ({ i: r }) => {
7748
- let a = t.add(r).toVar(), o = $(n, a, N(0), N(Jc)).xyz, s = $(n, a, N(1), N(Jc)).xyz, c = $(n, a, N(2), N(Jc)).xyz, u = Zc({
7755
+ let a = t.add(r).toVar(), o = $(n, a, N(0), N(Yc)).xyz, s = $(n, a, N(1), N(Yc)).xyz, c = $(n, a, N(2), N(Yc)).xyz, u = Qc({
7749
7756
  rayOrigin: e.origin,
7750
7757
  rayDir: e.direction,
7751
7758
  pA: o,
@@ -7755,22 +7762,22 @@ var Hc = class {
7755
7762
  woopParams: l
7756
7763
  });
7757
7764
  p(u.w.greaterThan(.5), () => {
7758
- let t = $(n, a, N(7), N(Jc));
7765
+ let t = $(n, a, N(7), N(Yc));
7759
7766
  i.didHit.assign(!0), i.dst.assign(u.x), i.materialIndex.assign(N(t.z)), i.meshIndex.assign(N(t.w)), i.hitPoint.assign(e.origin.add(e.direction.mul(u.x))), i.uv.assign(H(u.y, u.z)), i.triangleIndex.assign(a), d();
7760
7767
  });
7761
7768
  });
7762
7769
  }).Else(() => {
7763
- p(s.z.greaterThan(.5).and(o.lessThan(N(Gc))), () => {
7770
+ p(s.z.greaterThan(.5).and(o.lessThan(N(Kc))), () => {
7764
7771
  a.element(o).assign(N(s.x)), o.addAssign(1);
7765
7772
  });
7766
7773
  });
7767
7774
  }).Else(() => {
7768
- let n = $(t, r, N(1), N(qc)), l = $(t, r, N(2), N(qc)), u = $(t, r, N(3), N(qc)), d = N(s.w).toVar(), f = N(n.w).toVar(), m = $c({
7775
+ let n = $(t, r, N(1), N(Jc)), l = $(t, r, N(2), N(Jc)), u = $(t, r, N(3), N(Jc)), d = N(s.w).toVar(), f = N(n.w).toVar(), m = el({
7769
7776
  rayOrigin: e.origin,
7770
7777
  invDir: c,
7771
7778
  boxMin: s.xyz,
7772
7779
  boxMax: n.xyz
7773
- }).toVar(), h = $c({
7780
+ }).toVar(), h = el({
7774
7781
  rayOrigin: e.origin,
7775
7782
  invDir: c,
7776
7783
  boxMin: l.xyz,
@@ -7778,15 +7785,15 @@ var Hc = class {
7778
7785
  }).toVar();
7779
7786
  p(le(m, h).lessThan(i.dst), () => {
7780
7787
  let e = m.lessThan(h);
7781
- p(L(e, h, m).lessThan(i.dst).and(o.lessThan(N(Gc))), () => {
7788
+ p(L(e, h, m).lessThan(i.dst).and(o.lessThan(N(Kc))), () => {
7782
7789
  a.element(o).assign(L(e, f, d)), o.addAssign(1);
7783
- }), p(o.lessThan(N(Gc)), () => {
7790
+ }), p(o.lessThan(N(Kc)), () => {
7784
7791
  a.element(o).assign(L(e, d, f)), o.addAssign(1);
7785
7792
  });
7786
7793
  });
7787
7794
  });
7788
7795
  }), i;
7789
- }), nl = f(([e, t, n, r, i, a, o, s, c, l, u]) => {
7796
+ }), rl = f(([e, t, n, r, i, a, o, s, c, l, u]) => {
7790
7797
  let d = U(e.xy, 1), f = r.mul(W(d, 1)), m = I(ce(n[0].xyz, n[1].xyz, n[2].xyz).mul(f.xyz.div(f.w))).toVar(), h = U(n[3]).toVar(), g = h.toVar(), _ = m.toVar();
7791
7798
  return p(i.and(a.greaterThan(0)).and(o.lessThan(64)).and(s.greaterThan(.001)), () => {
7792
7799
  let e = a.div(o).mul(.001).mul(c).mul(l), r = Un(t), i = r.x.mul(u.max(.01)), d = r.y, f = I(U(n[0])), p = I(U(n[1])), v = f.mul(i).add(p.mul(d)).mul(e);
@@ -7796,7 +7803,7 @@ var Hc = class {
7796
7803
  direction: _
7797
7804
  });
7798
7805
  });
7799
- function rl(e) {
7806
+ function il(e) {
7800
7807
  let { rayBufferRW: t, rngBufferRW: n, gBufferRW: r, resolution: i, frame: a, cameraWorldMatrix: o, cameraProjectionMatrixInverse: s, enableDOF: c, focalLength: l, aperture: u, focusDistance: d, sceneScale: m, apertureScale: h, anamorphicRatio: g, renderWidth: _, renderHeight: v, transmissiveBounces: y, transparentBackground: b, auxGBufferEnabled: x } = e, S = x.greaterThan(B(0));
7801
7808
  return f(() => {
7802
7809
  let e = N(K.x).mul(16).add(N(oe.x)), f = N(K.y).mul(16).add(N(oe.y));
@@ -7807,51 +7814,51 @@ function rl(e) {
7807
7814
  pixelCoord: _,
7808
7815
  rayIndex: N(0),
7809
7816
  frame: a
7810
- }).toVar() }).toVar(), T = Xn(_, N(0), N(1), w, i, a).toVar(), E = H(2).div(i), D = T.sub(.5).mul(E), O = C.add(D), k = yi.wrap(nl(O, w, o, s, c, l, u, d, m, h, g));
7811
- gc(t, x, k.origin, N(0), N(0)), _c(t, x, k.direction, B(Fc.ACTIVE)), vc(t, x, W(1, 1, 1, 0).xyz, M(0)), yc(t, x, W(U(0), L(b, M(1), M(0)))), p(S, () => {
7812
- fc(r, B(v), U(0, 0, 1), M(1), U(0));
7813
- }), Dc(t, x, B(0), B(y), M(1), M(1), M(1)), n.element(x).assign(w);
7817
+ }).toVar() }).toVar(), T = Xn(_, N(1), N(1), w, i, a).toVar(), E = H(2).div(i), D = T.sub(.5).mul(E), O = C.add(D), k = yi.wrap(rl(O, w, o, s, c, l, u, d, m, h, g));
7818
+ _c(t, x, k.origin, N(0), N(0)), vc(t, x, k.direction, B(Ic.ACTIVE)), yc(t, x, W(1, 1, 1, 0).xyz, M(0)), bc(t, x, W(U(0), L(b, M(1), M(0)))), p(S, () => {
7819
+ pc(r, B(v), U(0, 0, 1), M(1), U(0));
7820
+ }), Oc(t, x, B(0), B(y), M(1), M(1), M(1)), n.element(x).assign(w);
7814
7821
  });
7815
7822
  });
7816
7823
  }
7817
7824
  //#endregion
7818
7825
  //#region src/TSL/ExtendKernel.js
7819
- function il(e) {
7826
+ function al(e) {
7820
7827
  let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, rayBufferRO: i, hitBufferRW: a, activeIndicesRO: o, counters: s, maxRayCount: c } = e;
7821
7828
  return f(() => {
7822
- let e = re, r = s ? S(s.element(B(Pc.ENTERING_COUNT))) : c;
7829
+ let e = re, r = s ? S(s.element(B(Fc.ENTERING_COUNT))) : c;
7823
7830
  p(e.greaterThanEqual(r), () => {
7824
7831
  h();
7825
7832
  });
7826
7833
  let l = o.element(e), u = yi({
7827
- origin: ac(i, l).toVar(),
7828
- direction: oc(i, l).toVar()
7829
- }), d = Ec(i, l).stackDepth.greaterThan(B(0)), f = Ci.wrap(el(u, t, n, d)).toVar();
7830
- Tc(a, l, f.dst, B(f.triangleIndex), f.uv.x, f.uv.y, f.normal, B(f.materialIndex), B(f.meshIndex));
7834
+ origin: oc(i, l).toVar(),
7835
+ direction: sc(i, l).toVar()
7836
+ }), d = Dc(i, l).stackDepth.greaterThan(B(0)), f = Ci.wrap(tl(u, t, n, d)).toVar();
7837
+ Ec(a, l, f.dst, B(f.triangleIndex), f.uv.x, f.uv.y, f.normal, B(f.materialIndex), B(f.meshIndex));
7831
7838
  });
7832
7839
  }
7833
7840
  //#endregion
7834
7841
  //#region src/TSL/Environment.js
7835
- var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, environmentMatrix: mat4x4f ) -> vec2f {\n let d = normalize( ( environmentMatrix * vec4f( direction, 0.0f ) ).xyz );\n var uv = vec2f( atan2( d.z, d.x ), acos( d.y ) );\n uv = uv / vec2f( 6.28318530717958647692f, 3.14159265358979323846f );\n uv.x = uv.x + 0.5f;\n uv.y = 1.0f - uv.y;\n return uv;\n }\n"), ol = /* @__PURE__ */ G("\n fn equirectUvToDirection( uv: vec2f, environmentMatrix: mat4x4f ) -> vec3f {\n let adjustedUv = vec2f( uv.x - 0.5f, 1.0f - uv.y );\n let theta = adjustedUv.x * 6.28318530717958647692f;\n let phi = adjustedUv.y * 3.14159265358979323846f;\n let sinPhi = sin( phi );\n let localDir = vec3f( sinPhi * cos( theta ), cos( phi ), sinPhi * sin( theta ) );\n return normalize( ( transpose( environmentMatrix ) * vec4f( localDir, 0.0f ) ).xyz );\n }\n"), sl = f(([e, t, n, r, i, a]) => {
7842
+ var ol = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, environmentMatrix: mat4x4f ) -> vec2f {\n let d = normalize( ( environmentMatrix * vec4f( direction, 0.0f ) ).xyz );\n var uv = vec2f( atan2( d.z, d.x ), acos( d.y ) );\n uv = uv / vec2f( 6.28318530717958647692f, 3.14159265358979323846f );\n uv.x = uv.x + 0.5f;\n uv.y = 1.0f - uv.y;\n return uv;\n }\n"), sl = /* @__PURE__ */ G("\n fn equirectUvToDirection( uv: vec2f, environmentMatrix: mat4x4f ) -> vec3f {\n let adjustedUv = vec2f( uv.x - 0.5f, 1.0f - uv.y );\n let theta = adjustedUv.x * 6.28318530717958647692f;\n let phi = adjustedUv.y * 3.14159265358979323846f;\n let sinPhi = sin( phi );\n let localDir = vec3f( sinPhi * cos( theta ), cos( phi ), sinPhi * sin( theta ) );\n return normalize( ( transpose( environmentMatrix ) * vec4f( localDir, 0.0f ) ).xyz );\n }\n"), cl = f(([e, t, n, r, i, a]) => {
7836
7843
  let o = W(0).toVar();
7837
7844
  return p(r.equal(0), () => {
7838
7845
  o.assign(W(0));
7839
7846
  }).Else(() => {
7840
- let s = al({
7847
+ let s = ol({
7841
7848
  direction: t,
7842
7849
  environmentMatrix: n
7843
7850
  }).toVar(), c = Ae(e, s, 0).rgb.toVar(), l = be(s.y.mul(Math.PI)).toVar(), u = A(c, Hi).mul(l), d = F(M(0), u.sub(i)).div(r), f = l.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(l)), M(0)), p = M(a.x).mul(M(a.y)).mul(d).mul(f);
7844
7851
  o.assign(W(c, p));
7845
7852
  }), o;
7846
- }), cl = f(([e, t, n, r, i, a, o, s, c]) => {
7847
- let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = ue(t.load(P(l, f)).x, t.load(P(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = H(ue(ue(D, O, w), ue(k, j, w), T).toVar(), h).toVar(), re = ol({
7853
+ }), ll = f(([e, t, n, r, i, a, o, s, c]) => {
7854
+ let l = N(o.x).toVar(), u = o.y, d = E(s.x.mul(u.sub(1)), 0, u.sub(1)), f = N(te(d)), p = le(f.add(1), N(u).sub(1)), m = ne(d), h = ue(t.load(P(l, f)).x, t.load(P(l, p)).x, m).toVar(), g = o.x, _ = o.y, v = E(s.y.mul(g.sub(1)), 0, g.sub(1)), y = E(h.mul(_.sub(1)), 0, _.sub(1)), b = N(te(v)), x = N(te(y)), S = le(b.add(1), N(g).sub(1)), C = le(x.add(1), N(_).sub(1)), w = ne(v), T = ne(y), D = t.load(P(b, x)).x, O = t.load(P(S, x)).x, k = t.load(P(b, C)).x, j = t.load(P(S, C)).x, ee = H(ue(ue(D, O, w), ue(k, j, w), T).toVar(), h).toVar(), re = sl({
7848
7855
  uv: ee,
7849
7856
  environmentMatrix: n
7850
7857
  }).toVar(), ie = Ae(e, ee, 0).rgb.mul(r).toVar();
7851
7858
  c.assign(ie);
7852
7859
  let ae = be(ee.y.mul(Math.PI)).toVar(), oe = A(ie.div(r), Hi).mul(ae), se = F(M(0), oe.sub(a)).div(i), ce = ae.greaterThan(0).select(M(1).div(M(2 * Math.PI * Math.PI).mul(ae)), M(0));
7853
7860
  return W(re, M(o.x).mul(M(o.y)).mul(se).mul(ce));
7854
- }), ll = /* @__PURE__ */ G("\n fn sampleEnvironment(\n tex: texture_2d<f32>,\n samp: sampler,\n direction: vec3f,\n environmentMatrix: mat4x4f,\n environmentIntensity: f32,\n enableEnvironmentLight: f32\n ) -> vec4f {\n if ( enableEnvironmentLight < 0.5 ) { return vec4f( 0.0 ); }\n let uv = equirectDirectionToUv( direction, environmentMatrix );\n let texSample = textureSampleLevel( tex, samp, uv, 0.0 );\n return texSample * environmentIntensity;\n }\n", [al]), ul = f(([e, t, n, r]) => {
7861
+ }), ul = /* @__PURE__ */ G("\n fn sampleEnvironment(\n tex: texture_2d<f32>,\n samp: sampler,\n direction: vec3f,\n environmentMatrix: mat4x4f,\n environmentIntensity: f32,\n enableEnvironmentLight: f32\n ) -> vec4f {\n if ( enableEnvironmentLight < 0.5 ) { return vec4f( 0.0 ); }\n let uv = equirectDirectionToUv( direction, environmentMatrix );\n let texSample = textureSampleLevel( tex, samp, uv, 0.0 );\n return texSample * environmentIntensity;\n }\n", [ol]), dl = f(([e, t, n, r]) => {
7855
7862
  let i = t.toConst(), a = e.toVar();
7856
7863
  a.y.subAssign(r);
7857
7864
  let o = n.mul(n).toConst(), s = a.dot(i).toConst(), c = a.dot(a).sub(o).toConst(), l = s.mul(s).sub(c).toConst(), u = t.toVar();
@@ -7866,13 +7873,13 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7866
7873
  u.assign(a.add(i.mul(le(t, r))).div(n));
7867
7874
  });
7868
7875
  }), u;
7869
- }), dl = f(([e, t, n, r, i, a]) => {
7876
+ }), fl = f(([e, t, n, r, i, a]) => {
7870
7877
  let o = t.toVar();
7871
7878
  return p(n, () => {
7872
7879
  let n = U(e.x, e.y.sub(a), e.z);
7873
- o.assign(ul(n, t, r, i));
7880
+ o.assign(dl(n, t, r, i));
7874
7881
  }), o;
7875
- }), fl = f(([e, t]) => {
7882
+ }), pl = f(([e, t]) => {
7876
7883
  let n = U(0).toVar();
7877
7884
  return p(e.roughness.greaterThan(.98).and(e.metalness.lessThan(.02)).and(e.transmission.equal(0)).and(e.clearcoat.equal(0)).and(e.iridescence.equal(0)), () => {
7878
7885
  n.assign(e.color.rgb.mul(M(1).sub(e.metalness)).mul(Ii));
@@ -7896,24 +7903,24 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7896
7903
  n.assign(d);
7897
7904
  });
7898
7905
  }), n;
7899
- }), pl = f(([e, t, n, r]) => fl(r, Di.wrap($i(n, e, t)))), ml = f(([e, t]) => {
7906
+ }), ml = f(([e, t, n, r]) => pl(r, Di.wrap($i(n, e, t)))), hl = f(([e, t]) => {
7900
7907
  let n = E(ue(_a(t.ior).mul(t.specularColor), t.color.rgb, t.metalness).mul(t.specularIntensity), U(0), U(1)).toVar(), r = va(e.NoH, t.roughness), i = xa(e.NoV, e.NoL, t.roughness), a = pa(e.VoH, n), o = r.mul(i).mul(a).div(F(M(4).mul(e.NoV).mul(e.NoL), Ri)), s = Oi.wrap(Sa(n, e.NoV, t.roughness)), c = o.mul(s.compensation), l = U(1).sub(s.E_total).mul(M(1).sub(t.metalness)).mul(t.color.rgb).div(Fi).add(c), u = F(t.clearcoatRoughness, Bi), d = va(e.NoH, u), f = xa(e.NoV, e.NoL, u), p = fa(e.VoH, M(.04)), m = d.mul(f).mul(p).div(F(M(4).mul(e.NoV).mul(e.NoL), Ri)), h = M(1).sub(t.clearcoat.mul(p).mul(M(2).sub(p)));
7901
7908
  return l.mul(h).add(U(m).mul(t.clearcoat));
7902
- }), hl = 2 * Fi, gl = f(([e, t]) => {
7909
+ }), gl = 2 * Fi, _l = f(([e, t]) => {
7903
7910
  let n = M(1).toVar();
7904
7911
  return p(t.lessThan(M(Fi).sub(.001)).and(e.greaterThan(0)), () => {
7905
7912
  let r = t.mul(.5).toVar(), i = ke(r).toVar(), a = Se(F(M(1).sub(e.mul(e)), 0)).div(F(e, 1e-4)), o = L(r.greaterThan(.05), M(1).div(F(i.sub(r), 1e-6)), M(3).div(F(r.mul(r).mul(r), 1e-9)));
7906
7913
  n.assign(F(i.sub(a).mul(o), 0));
7907
7914
  }), n;
7908
- }), _l = f(([e]) => {
7915
+ }), vl = f(([e]) => {
7909
7916
  let t = L(e.normalize.greaterThan(.5), M(1).div(F(e.area, 1e-10)), M(1));
7910
7917
  return e.color.mul(e.intensity).mul(Ii).mul(t);
7911
- }), vl = f(([e, t, n, r]) => {
7918
+ }), yl = f(([e, t, n, r]) => {
7912
7919
  let i = T(!1).toVar(), a = U(0, 1, 0).toVar(), o = U(0).toVar(), s = M(0).toVar(), c = M(0).toVar(), l = N(2).toVar();
7913
7920
  return p(e.area.greaterThan(0), () => {
7914
7921
  let u = U(0).toVar(), d = M(-1).toVar();
7915
7922
  p(e.shape.greaterThan(.5), () => {
7916
- let t = Se(n.x).toVar(), r = M(hl).mul(n.y).toVar();
7923
+ let t = Se(n.x).toVar(), r = M(gl).mul(n.y).toVar();
7917
7924
  u.assign(e.position.add(e.u.mul(t.mul(D(r)))).add(e.v.mul(t.mul(be(r)))));
7918
7925
  }).Else(() => {
7919
7926
  let r = $o(t, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2), n).toVar();
@@ -7926,7 +7933,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7926
7933
  let f = u.sub(t).toVar(), m = A(f, f).toVar();
7927
7934
  p(m.greaterThanEqual(1e-10), () => {
7928
7935
  let t = Se(m).toVar(), n = f.div(t).toVar(), u = A(n.negate(), e.normal).toVar();
7929
- l.assign(N(1)), s.assign(t), a.assign(n), o.assign(_l(e).mul(gl(u, e.spread)));
7936
+ l.assign(N(1)), s.assign(t), a.assign(n), o.assign(vl(e).mul(_l(u, e.spread)));
7930
7937
  let p = m.div(F(e.area.mul(F(u, .001)), 1e-10)), h = L(d.greaterThan(0), d, p);
7931
7938
  c.assign(h.mul(r)), i.assign(u.greaterThan(0));
7932
7939
  });
@@ -7938,7 +7945,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7938
7945
  pdf: c,
7939
7946
  lightType: l
7940
7947
  });
7941
- }), yl = f(([e, t, n]) => {
7948
+ }), bl = f(([e, t, n]) => {
7942
7949
  let r = T(!1).toVar(), i = U(0, 1, 0).toVar(), a = U(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(3).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
7943
7950
  return p(u.greaterThanEqual(1e-20), () => {
7944
7951
  let t = Se(u).toVar(), c = l.div(t).toVar(), d = A(c.negate(), e.direction).toVar(), f = D(e.angle).toVar();
@@ -7962,7 +7969,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7962
7969
  pdf: s,
7963
7970
  lightType: c
7964
7971
  });
7965
- }), bl = f(([e, t, n]) => {
7972
+ }), xl = f(([e, t, n]) => {
7966
7973
  let r = T(!1).toVar(), i = U(0, 1, 0).toVar(), a = U(0).toVar(), o = M(0).toVar(), s = M(0).toVar(), c = N(2).toVar(), l = e.position.sub(t).toVar(), u = A(l, l).toVar();
7967
7974
  return p(u.greaterThanEqual(1e-20), () => {
7968
7975
  let t = Se(u).toVar(), d = l.div(t), f = Vo({
@@ -7979,10 +7986,10 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7979
7986
  pdf: s,
7980
7987
  lightType: c
7981
7988
  });
7982
- }), xl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, h]) => {
7989
+ }), Sl = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, h]) => {
7983
7990
  let g = T(!1).toVar(), v = U(0, 1, 0).toVar(), y = U(0).toVar(), b = M(0).toVar(), x = M(0).toVar(), S = N(2).toVar(), C = s.add(l).add(d).add(h).toVar();
7984
7991
  return p(C.greaterThan(N(0)), () => {
7985
- let w = M(0).toVar(), E = N(0).toVar(), k = N(-1).toVar(), A = N(-1).toVar(), j = M(0).toVar();
7992
+ let w = M(0).toVar(), E = N(-1).toVar(), k = N(-1).toVar(), A = M(0).toVar();
7986
7993
  p(s.greaterThan(N(0)), () => {
7987
7994
  m({
7988
7995
  start: N(0),
@@ -7990,11 +7997,11 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
7990
7997
  type: "int",
7991
7998
  condition: "<"
7992
7999
  }, ({ i: e }) => {
7993
- p(E.lessThan(N(16)), () => {
8000
+ p(e.lessThan(N(16)), () => {
7994
8001
  let r = Eo(Ao.wrap(Io(o, e)), t, n, i).toVar();
7995
8002
  w.addAssign(r), p(r.greaterThan(0).and(Y(a).mul(w).lessThan(r)), () => {
7996
- k.assign(0), A.assign(e), j.assign(r);
7997
- }), E.addAssign(1);
8003
+ E.assign(0), k.assign(e), A.assign(r);
8004
+ });
7998
8005
  });
7999
8006
  });
8000
8007
  }), p(l.greaterThan(N(0)), () => {
@@ -8004,11 +8011,11 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8004
8011
  type: "int",
8005
8012
  condition: "<"
8006
8013
  }, ({ i: r }) => {
8007
- p(E.lessThan(N(16)), () => {
8014
+ p(r.lessThan(N(16)), () => {
8008
8015
  let i = jo.wrap(Lo(c, r)), o = L(i.intensity.greaterThan(0), Do(i, e, t, n), M(0)).toVar();
8009
8016
  w.addAssign(o), p(o.greaterThan(0).and(Y(a).mul(w).lessThan(o)), () => {
8010
- k.assign(1), A.assign(r), j.assign(o);
8011
- }), E.addAssign(1);
8017
+ E.assign(1), k.assign(r), A.assign(o);
8018
+ });
8012
8019
  });
8013
8020
  });
8014
8021
  }), p(d.greaterThan(N(0)), () => {
@@ -8018,11 +8025,11 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8018
8025
  type: "int",
8019
8026
  condition: "<"
8020
8027
  }, ({ i: r }) => {
8021
- p(E.lessThan(N(16)), () => {
8028
+ p(r.lessThan(N(16)), () => {
8022
8029
  let i = Oo(Mo.wrap(Ro(u, r)), e, t, n).toVar();
8023
8030
  w.addAssign(i), p(i.greaterThan(0).and(Y(a).mul(w).lessThan(i)), () => {
8024
- k.assign(2), A.assign(r), j.assign(i);
8025
- }), E.addAssign(1);
8031
+ E.assign(2), k.assign(r), A.assign(i);
8032
+ });
8026
8033
  });
8027
8034
  });
8028
8035
  }), p(h.greaterThan(N(0)), () => {
@@ -8032,11 +8039,11 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8032
8039
  type: "int",
8033
8040
  condition: "<"
8034
8041
  }, ({ i: r }) => {
8035
- p(E.lessThan(N(16)), () => {
8042
+ p(r.lessThan(N(16)), () => {
8036
8043
  let i = ko(No.wrap(zo(f, r)), e, t, n).toVar();
8037
8044
  w.addAssign(i), p(i.greaterThan(0).and(Y(a).mul(w).lessThan(i)), () => {
8038
- k.assign(3), A.assign(r), j.assign(i);
8039
- }), E.addAssign(1);
8045
+ E.assign(3), k.assign(r), A.assign(i);
8046
+ });
8040
8047
  });
8041
8048
  });
8042
8049
  }), p(w.lessThanEqual(0), () => {
@@ -8055,7 +8062,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8055
8062
  p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(l))), () => {
8056
8063
  let o = jo.wrap(Lo(c, t.sub(m)));
8057
8064
  p(o.intensity.greaterThan(0), () => {
8058
- let t = H(r.y, Y(a)).toVar(), s = Po.wrap(vl(o, e, t, n));
8065
+ let t = H(r.y, Y(a)).toVar(), s = Po.wrap(yl(o, e, t, n));
8059
8066
  g.assign(s.valid), v.assign(s.direction), y.assign(s.emission), b.assign(s.distance), x.assign(s.pdf), S.assign(s.lightType), i.assign(T(!0));
8060
8067
  });
8061
8068
  }), m.addAssign(l);
@@ -8063,7 +8070,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8063
8070
  p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(d))), () => {
8064
8071
  let r = Mo.wrap(Ro(u, t.sub(m)));
8065
8072
  p(r.intensity.greaterThan(0), () => {
8066
- let t = Po.wrap(bl(r, e, n));
8073
+ let t = Po.wrap(xl(r, e, n));
8067
8074
  g.assign(t.valid), v.assign(t.direction), y.assign(t.emission), b.assign(t.distance), x.assign(t.pdf), S.assign(t.lightType), i.assign(T(!0));
8068
8075
  });
8069
8076
  }), m.addAssign(d);
@@ -8071,31 +8078,31 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8071
8078
  p(i.not().and(t.greaterThanEqual(m)).and(t.lessThan(m.add(h))), () => {
8072
8079
  let r = No.wrap(zo(f, t.sub(m)));
8073
8080
  p(r.intensity.greaterThan(0), () => {
8074
- let t = Po.wrap(yl(r, e, n));
8081
+ let t = Po.wrap(bl(r, e, n));
8075
8082
  g.assign(t.valid), v.assign(t.direction), y.assign(t.emission), b.assign(t.distance), x.assign(t.pdf), S.assign(t.lightType), i.assign(T(!0));
8076
8083
  });
8077
8084
  });
8078
8085
  });
8079
8086
  }).Else(() => {
8080
- let t = j.div(F(w, 1e-10)).toVar();
8081
- p(k.equal(N(0)).and(A.greaterThanEqual(N(0))), () => {
8082
- let n = Ao.wrap(Io(o, A)), i = I(n.direction).toVar(), s = M(1).toVar();
8087
+ let t = A.div(F(w, 1e-10)).toVar();
8088
+ p(E.equal(N(0)).and(k.greaterThanEqual(N(0))), () => {
8089
+ let n = Ao.wrap(Io(o, k)), i = I(n.direction).toVar(), s = M(1).toVar();
8083
8090
  p(n.angle.greaterThan(0), () => {
8084
- let e = D(n.angle.mul(.5)).toVar(), t = ue(e, M(1), r.y).toVar(), o = Se(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(hl).mul(Y(a)).toVar(), l = I(n.direction).toVar(), u = I(O(L(_(l.x).greaterThan(.9), U(0, 1, 0), U(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
8091
+ let e = D(n.angle.mul(.5)).toVar(), t = ue(e, M(1), r.y).toVar(), o = Se(F(M(0), M(1).sub(t.mul(t)))).toVar(), c = M(gl).mul(Y(a)).toVar(), l = I(n.direction).toVar(), u = I(O(L(_(l.x).greaterThan(.9), U(0, 1, 0), U(1, 0, 0)), l)).toVar(), d = O(l, u).toVar();
8085
8092
  i.assign(I(l.mul(t).add(u.mul(D(c)).add(d.mul(be(c))).mul(o))));
8086
- let f = M(hl).mul(F(M(1).sub(e), 1e-10));
8093
+ let f = M(gl).mul(F(M(1).sub(e), 1e-10));
8087
8094
  s.assign(M(1).div(f));
8088
8095
  });
8089
8096
  let c = Ko(n, e);
8090
8097
  v.assign(i), y.assign(n.color.mul(n.intensity).mul(c)), b.assign(1e6), x.assign(s.mul(t)), S.assign(N(0)), g.assign(T(!0));
8091
- }), p(k.equal(N(1)).and(A.greaterThanEqual(N(0))), () => {
8092
- let n = jo.wrap(Lo(c, A)), i = H(r.y, Y(a)).toVar(), o = Po.wrap(vl(n, e, i, t));
8098
+ }), p(E.equal(N(1)).and(k.greaterThanEqual(N(0))), () => {
8099
+ let n = jo.wrap(Lo(c, k)), i = H(r.y, Y(a)).toVar(), o = Po.wrap(yl(n, e, i, t));
8093
8100
  g.assign(o.valid), v.assign(o.direction), y.assign(o.emission), b.assign(o.distance), x.assign(o.pdf), S.assign(o.lightType);
8094
- }), p(k.equal(N(2)).and(A.greaterThanEqual(N(0))), () => {
8095
- let n = Mo.wrap(Ro(u, A)), r = Po.wrap(bl(n, e, t));
8101
+ }), p(E.equal(N(2)).and(k.greaterThanEqual(N(0))), () => {
8102
+ let n = Mo.wrap(Ro(u, k)), r = Po.wrap(xl(n, e, t));
8096
8103
  g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
8097
- }), p(k.equal(N(3)).and(A.greaterThanEqual(N(0))), () => {
8098
- let n = No.wrap(zo(f, A)), r = Po.wrap(yl(n, e, t));
8104
+ }), p(E.equal(N(3)).and(k.greaterThanEqual(N(0))), () => {
8105
+ let n = No.wrap(zo(f, k)), r = Po.wrap(bl(n, e, t));
8099
8106
  g.assign(r.valid), v.assign(r.direction), y.assign(r.emission), b.assign(r.distance), x.assign(r.pdf), S.assign(r.lightType);
8100
8107
  });
8101
8108
  });
@@ -8107,7 +8114,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8107
8114
  pdf: x,
8108
8115
  lightType: S
8109
8116
  });
8110
- }), Sl = f(([e, t]) => {
8117
+ }), Cl = f(([e, t]) => {
8111
8118
  let n = t.NoV, r = t.NoL.toVar(), i = t.NoH, a = M(1).sub(e.metalness).mul(M(1).sub(e.transmission)).toVar(), o = M(1).sub(a.mul(M(1).sub(e.metalness))).toVar(), s = a.add(o).toVar(), c = M(0).toVar();
8112
8119
  return p(s.greaterThan(0), () => {
8113
8120
  let t = M(1).div(F(s, 1e-10)).toVar();
@@ -8118,8 +8125,8 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8118
8125
  c.addAssign(o.mul(Ca(i, n, t)));
8119
8126
  });
8120
8127
  }), F(c, 1e-8);
8121
- }), Cl = f(([e, t, n, r]) => Sl(r, Di.wrap($i(n, e, t)))), wl = f(([e, t, n, r, i, a, o, s, c, l, u, d]) => {
8122
- let f = M(0).toVar(), h = N(0).toVar();
8128
+ }), wl = f(([e, t, n, r]) => Cl(r, Di.wrap($i(n, e, t)))), Tl = f(([e, t, n, r, i, a, o, s, c, l, u, d]) => {
8129
+ let f = M(0).toVar();
8123
8130
  return p(a.greaterThan(N(0)), () => {
8124
8131
  m({
8125
8132
  start: N(0),
@@ -8127,9 +8134,9 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8127
8134
  type: "int",
8128
8135
  condition: "<"
8129
8136
  }, ({ i: e }) => {
8130
- p(h.lessThan(N(16)), () => {
8137
+ p(e.lessThan(N(16)), () => {
8131
8138
  let a = Ao.wrap(Io(i, e));
8132
- f.addAssign(Eo(a, t, n, r)), h.addAssign(1);
8139
+ f.addAssign(Eo(a, t, n, r));
8133
8140
  });
8134
8141
  });
8135
8142
  }), p(s.greaterThan(N(0)), () => {
@@ -8139,9 +8146,9 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8139
8146
  type: "int",
8140
8147
  condition: "<"
8141
8148
  }, ({ i: r }) => {
8142
- p(h.lessThan(N(16)), () => {
8149
+ p(r.lessThan(N(16)), () => {
8143
8150
  let i = jo.wrap(Lo(o, r));
8144
- f.addAssign(L(i.intensity.greaterThan(0), Do(i, e, t, n), M(0))), h.addAssign(1);
8151
+ f.addAssign(L(i.intensity.greaterThan(0), Do(i, e, t, n), M(0)));
8145
8152
  });
8146
8153
  });
8147
8154
  }), p(l.greaterThan(N(0)), () => {
@@ -8151,9 +8158,9 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8151
8158
  type: "int",
8152
8159
  condition: "<"
8153
8160
  }, ({ i: r }) => {
8154
- p(h.lessThan(N(16)), () => {
8161
+ p(r.lessThan(N(16)), () => {
8155
8162
  let i = Mo.wrap(Ro(c, r));
8156
- f.addAssign(Oo(i, e, t, n)), h.addAssign(1);
8163
+ f.addAssign(Oo(i, e, t, n));
8157
8164
  });
8158
8165
  });
8159
8166
  }), p(d.greaterThan(N(0)), () => {
@@ -8163,14 +8170,14 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8163
8170
  type: "int",
8164
8171
  condition: "<"
8165
8172
  }, ({ i: r }) => {
8166
- p(h.lessThan(N(16)), () => {
8173
+ p(r.lessThan(N(16)), () => {
8167
8174
  let i = No.wrap(zo(u, r));
8168
- f.addAssign(ko(i, e, t, n)), h.addAssign(1);
8175
+ f.addAssign(ko(i, e, t, n));
8169
8176
  });
8170
8177
  });
8171
8178
  }), f;
8172
- }), Tl = f(([e, t, n, r, i, a, o, s, c, l, u, d, h, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee, te]) => {
8173
- let ne = U(0).toVar(), re = U(0).toVar(), P = e.add(t.mul(.001)).toVar(), ie = f(([e, t, n]) => wo(e, t, n, tl, b, x, S));
8179
+ }), El = f(([e, t, n, r, i, a, o, s, c, l, u, d, h, g, _, v, y, b, x, S, C, w, E, D, O, k, j, ee, te]) => {
8180
+ let ne = U(0).toVar(), re = U(0).toVar(), P = e.add(t.mul(.001)).toVar(), ie = f(([e, t, n]) => wo(e, t, n, nl, b, x, S));
8174
8181
  return p(n.emissiveIntensity.lessThanEqual(10), () => {
8175
8182
  let f = U(1).toVar(), b = Pi.wrap(ia(n.roughness, n.metalness, s, f)), x = b.useBRDFSampling.toVar(), S = b.useLightSampling.toVar(), ae = b.brdfWeight.toVar(), oe = b.lightWeight.toVar(), se = u.add(h).add(_).add(y).toVar(), ce = M(.001).mul(M(1).add(M(s).mul(.5))).toVar(), ue = se.greaterThan(N(0)).toVar(), de = M(0).toVar();
8176
8183
  p(S.and(ue), () => {
@@ -8188,7 +8195,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8188
8195
  }).ElseIf(ue, () => {
8189
8196
  me.assign(T(!0));
8190
8197
  }), p(me, () => {
8191
- let e = H(fe, Y(c)).toVar(), i = Po.wrap(xl(P, t, n, e, s, c, l, u, d, h, g, _, v, y));
8198
+ let e = H(fe, Y(c)).toVar(), i = Po.wrap(Sl(P, t, n, e, s, c, l, u, d, h, g, _, v, y));
8192
8199
  p(i.valid.and(i.pdf.greaterThan(0)), () => {
8193
8200
  let e = F(M(0), A(t, i.direction)).toVar(), a = i.emission.x.add(i.emission.y).add(i.emission.z);
8194
8201
  p(e.greaterThan(0).and(a.mul(e).greaterThan(ce)).and(Bo({
@@ -8197,7 +8204,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8197
8204
  })), () => {
8198
8205
  let a = le(i.distance.sub(.001), M(1e3)), o = ie(P, i.direction, a);
8199
8206
  p(o.greaterThan(0).or(te), () => {
8200
- let a = Di.wrap($i(t, r, i.direction)), s = fl(n, a), c = Sl(n, a).toVar(), l = M(1).toVar();
8207
+ let a = Di.wrap($i(t, r, i.direction)), s = pl(n, a), c = Cl(n, a).toVar(), l = M(1).toVar();
8201
8208
  p(c.greaterThan(0).and(x), () => {
8202
8209
  let e = i.pdf.mul(oe), t = c.mul(ae);
8203
8210
  p(i.lightType.equal(N(1)), () => {
@@ -8247,10 +8254,10 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8247
8254
  p(f.greaterThan(0).or(te), () => {
8248
8255
  let m = F(M(0), A(i, e.normal).negate()).toVar();
8249
8256
  p(m.greaterThan(0), () => {
8250
- let i = c.mul(c), b = Qo(P, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2)).toVar(), x = i.div(F(e.area.mul(m), Ri)), S = L(e.shape.lessThan(.5).and(b.greaterThan(1e-5)), M(1).div(F(b, 1e-10)), x).toVar(), C = Do(e, P, t, n), w = wl(P, t, n, s, l, u, d, h, g, _, v, y).toVar(), T = L(w.greaterThan(0), C.div(F(w, 1e-10)), M(1).div(F(M(se), 1))), E = S.mul(T).toVar(), D = Xi({
8257
+ let i = c.mul(c), b = Qo(P, e.position.sub(e.u).sub(e.v), e.u.mul(2), e.v.mul(2)).toVar(), x = i.div(F(e.area.mul(m), Ri)), S = L(e.shape.lessThan(.5).and(b.greaterThan(1e-5)), M(1).div(F(b, 1e-10)), x).toVar(), C = Do(e, P, t, n), w = Tl(P, t, n, s, l, u, d, h, g, _, v, y).toVar(), T = L(w.greaterThan(0), C.div(F(w, 1e-10)), M(1).div(F(M(se), 1))), E = S.mul(T).toVar(), D = Xi({
8251
8258
  pdf1: a.mul(ae),
8252
8259
  pdf2: E.mul(oe)
8253
- }).toVar(), O = _l(e).mul(gl(m, e.spread)).mul(o).mul(r).mul(D).div(F(a, 1e-10)).mul(de).div(F(ae, 1e-10));
8260
+ }).toVar(), O = vl(e).mul(_l(m, e.spread)).mul(o).mul(r).mul(D).div(F(a, 1e-10)).mul(de).div(F(ae, 1e-10));
8254
8261
  ne.addAssign(O.mul(f)), p(te, () => {
8255
8262
  re.addAssign(O);
8256
8263
  });
@@ -8262,7 +8269,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8262
8269
  });
8263
8270
  });
8264
8271
  }), p(ee, () => {
8265
- let e = H(Y(c).toVar(), Y(c).toVar()).toVar(), i = U(0).toVar(), a = cl(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
8272
+ let e = H(Y(c).toVar(), Y(c).toVar()).toVar(), i = U(0).toVar(), a = ll(C, D, E, w, O, k, j, e, i).toVar(), o = a.xyz.toVar(), s = a.w.toVar();
8266
8273
  p(s.greaterThan(0), () => {
8267
8274
  let e = F(M(0), A(t, o)).toVar();
8268
8275
  p(e.greaterThan(0).and(Bo({
@@ -8271,7 +8278,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8271
8278
  })), () => {
8272
8279
  let a = ie(P, o, M(1e3));
8273
8280
  p(a.greaterThan(0).or(te), () => {
8274
- let c = Di.wrap($i(t, r, o)), l = fl(n, c), u = Sl(n, c).toVar(), d = L(u.greaterThan(0), Zi({
8281
+ let c = Di.wrap($i(t, r, o)), l = pl(n, c), u = Cl(n, c).toVar(), d = L(u.greaterThan(0), Zi({
8275
8282
  pdf1: s,
8276
8283
  pdf2: u
8277
8284
  }), M(1)).toVar(), f = i.mul(l).mul(e).mul(d).div(F(s, 1e-10));
@@ -8286,17 +8293,17 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8286
8293
  shadowed: ne,
8287
8294
  unoccluded: re
8288
8295
  });
8289
- }), El = f(([e, t, n, r, i, a]) => {
8296
+ }), Dl = f(([e, t, n, r, i, a]) => {
8290
8297
  let o = L(a, r, M(1).div(r)).toVar(), s = e.add(t.mul(o)).toVar(), c = A(s, s).toVar(), l = L(c.greaterThan(Ri), s.div(Se(c)), n).toVar();
8291
8298
  p(A(l, n).lessThan(0), () => {
8292
8299
  l.assign(l.negate());
8293
8300
  });
8294
8301
  let u = _(A(e, l)), d = _(A(t, l)).toVar(), f = _(A(n, l)).toVar(), m = va(f, i), h = u.add(d.mul(o)).toVar(), g = h.mul(h), v = d.mul(o).mul(o).div(F(g, Ri));
8295
8302
  return m.mul(f).mul(v);
8296
- }), Dl = f(([e, t, n, r]) => {
8303
+ }), Ol = f(([e, t, n, r]) => {
8297
8304
  let i = e.add(t).toVar(), a = A(i, i).toVar();
8298
8305
  return Ca(F(A(n, L(a.greaterThan(Ri), i.div(Se(a)), n)), 0), F(A(n, e), 0), r);
8299
- }), Ol = f(([e]) => {
8306
+ }), kl = f(([e]) => {
8300
8307
  let t = e.specularImportance.toVar(), n = t.greaterThan(.001).toVar(), r = e.diffuseImportance.toVar(), i = r.greaterThan(.001).toVar(), a = e.transmissionImportance.toVar(), o = a.greaterThan(.001).toVar(), s = e.clearcoatImportance.toVar(), c = s.greaterThan(.001).toVar(), l = t.add(r).add(a).add(s).toVar();
8301
8308
  return p(l.lessThan(.001), () => {
8302
8309
  t.assign(0), r.assign(1), a.assign(0), s.assign(0), l.assign(1), n.assign(T(!1)), i.assign(T(!0)), o.assign(T(!1)), c.assign(T(!1));
@@ -8316,7 +8323,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8316
8323
  useTransmission: o,
8317
8324
  useClearcoat: c
8318
8325
  });
8319
- }), kl = f(([e, t]) => {
8326
+ }), Al = f(([e, t]) => {
8320
8327
  let n = N(2).toVar(), r = M(0).toVar(), i = T(!1).toVar();
8321
8328
  return p(e.useSpecular.and(i.not()), () => {
8322
8329
  r.addAssign(e.specularWeight), p(t.lessThan(r), () => {
@@ -8333,37 +8340,37 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8333
8340
  }), p(e.useClearcoat.and(i.not()), () => {
8334
8341
  n.assign(4);
8335
8342
  }), n;
8336
- }), Al = f(([e]) => F(e, 0).mul(Ii)), jl = f(([e, t, n, r, i, a, o, s]) => {
8343
+ }), jl = f(([e]) => F(e, 0).mul(Ii)), Ml = f(([e, t, n, r, i, a, o, s]) => {
8337
8344
  let c = U(0).toVar(), l = U(0).toVar(), u = M(0).toVar(), d = M(0).toVar(), f = M(0).toVar();
8338
8345
  return p(s.diffuseImportance.greaterThanEqual(0).and(s.specularImportance.greaterThanEqual(0)).and(s.transmissionImportance.greaterThanEqual(0)).and(s.clearcoatImportance.greaterThanEqual(0)).not(), () => {
8339
8346
  let e = H(Y(o).toVar(), Y(o).toVar());
8340
8347
  c.assign(Aa(t, e)), l.assign(n.color.xyz), u.assign(1), d.assign(1);
8341
8348
  }).Else(() => {
8342
- let m = Ni.wrap(Ol(s).toVar()), h = Y(o).toVar(), g = H(Y(o).toVar(), Y(o).toVar()).toVar(), v = kl(m, h).toVar(), y = U(0).toVar(), b = M(0).toVar(), x = U(0).toVar();
8343
- p(v.equal(N(1)), () => {
8344
- y.assign(r), b.assign(i), x.assign(a);
8345
- }).ElseIf(v.equal(N(2)), () => {
8346
- y.assign(Aa(t, g)), b.assign(Al(F(A(t, y), 0))), x.assign(pl(e, y, t, n));
8347
- }).ElseIf(v.equal(N(3)), () => {
8349
+ let m = Ni.wrap(kl(s).toVar()), h = Y(o).toVar(), g = H(Y(o).toVar(), Y(o).toVar()).toVar(), _ = Al(m, h).toVar(), v = U(0).toVar(), y = M(0).toVar(), b = U(0).toVar(), x = U(1).toVar();
8350
+ p(_.equal(N(1)), () => {
8351
+ v.assign(r), y.assign(i), b.assign(a);
8352
+ }).ElseIf(_.equal(N(2)), () => {
8353
+ v.assign(Aa(t, g)), y.assign(jl(F(A(t, v), 0))), b.assign(ml(e, v, t, n));
8354
+ }).ElseIf(_.equal(N(3)), () => {
8348
8355
  let r = A(e, t).greaterThan(0), i = Ha.wrap(Ja(e, t, n.ior, n.roughness, r, n.dispersion, g, o, M(0)).toVar());
8349
- y.assign(i.direction), b.assign(i.pdf), x.assign(pl(e, y, t, n));
8356
+ v.assign(i.direction), y.assign(i.pdf), x.assign(i.colorWeight);
8350
8357
  }).Else(() => {
8351
- y.assign(r), b.assign(i), x.assign(a);
8358
+ v.assign(r), y.assign(i), b.assign(a);
8352
8359
  });
8353
- let S = A(t, y).toVar(), C = F(S, 0).toVar(), w = _(S), T = M(0).toVar();
8360
+ let S = F(A(t, v), 0).toVar(), C = M(0).toVar();
8354
8361
  p(m.useSpecular, () => {
8355
- let r = Ca(F(A(t, I(e.add(y))), .001), F(A(t, e), .001), n.roughness);
8356
- T.addAssign(m.specularWeight.mul(r));
8362
+ let r = Ca(F(A(t, I(e.add(v))), .001), F(A(t, e), .001), n.roughness);
8363
+ C.addAssign(m.specularWeight.mul(r));
8357
8364
  }), p(m.useDiffuse, () => {
8358
- T.addAssign(m.diffuseWeight.mul(Al(C)));
8365
+ C.addAssign(m.diffuseWeight.mul(jl(S)));
8359
8366
  }), p(m.useTransmission.and(n.transmission.greaterThan(0)), () => {
8360
8367
  let r = A(e, t).greaterThan(0);
8361
- T.addAssign(m.transmissionWeight.mul(El(e, y, t, n.ior, n.roughness, r)));
8368
+ C.addAssign(m.transmissionWeight.mul(Dl(e, v, t, n.ior, n.roughness, r)));
8362
8369
  }), p(m.useClearcoat.and(n.clearcoat.greaterThan(0)), () => {
8363
- T.addAssign(m.clearcoatWeight.mul(Dl(e, y, t, n.clearcoatRoughness)));
8364
- }), b.assign(F(b, Vi)), T.assign(F(T, Vi));
8365
- let E = b.div(T).toVar(), D = L(v.equal(N(3)), w, C);
8366
- c.assign(y), l.assign(x.mul(D).mul(E).div(b)), u.assign(E), d.assign(b), f.assign(T);
8370
+ C.addAssign(m.clearcoatWeight.mul(Ol(e, v, t, n.clearcoatRoughness)));
8371
+ }), y.assign(F(y, Vi)), C.assign(F(C, Vi));
8372
+ let w = y.div(C).toVar(), T = b.mul(S).mul(w).div(y), E = n.color.xyz.mul(x).mul(w);
8373
+ c.assign(v), l.assign(L(_.equal(N(3)), E, T)), u.assign(w), d.assign(y), f.assign(C);
8367
8374
  }), Fo({
8368
8375
  direction: c,
8369
8376
  throughput: l,
@@ -8371,7 +8378,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8371
8378
  pdf: d,
8372
8379
  combinedPdf: f
8373
8380
  });
8374
- }), Ml = f(([e, t, n, r, i, a, o, s, c, l]) => {
8381
+ }), Nl = f(([e, t, n, r, i, a, o, s, c, l]) => {
8375
8382
  let u = U(0).toVar(), d = U(0).toVar(), f = M(0).toVar(), m = s.toVar();
8376
8383
  p(o.not(), () => {
8377
8384
  p(c, () => {
@@ -8400,7 +8407,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8400
8407
  xi: g
8401
8408
  }));
8402
8409
  let r = E(A(t, u), 0, 1);
8403
- f.assign(r.mul(Ii)), d.assign(pl(e, u, t, n));
8410
+ f.assign(r.mul(Ii)), d.assign(ml(e, u, t, n));
8404
8411
  }).ElseIf(h.lessThan(y), () => {
8405
8412
  let i = Qi({ N: t }), a = ja({
8406
8413
  V: i.transpose().mul(e),
@@ -8409,7 +8416,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8409
8416
  });
8410
8417
  _.assign(i.mul(a));
8411
8418
  let o = E(A(t, _), .001, 1);
8412
- u.assign(ge(e.negate(), _)), f.assign(Ca(o, S, n.roughness)), d.assign(pl(e, u, t, n));
8419
+ u.assign(ge(e.negate(), _)), f.assign(Ca(o, S, n.roughness)), d.assign(ml(e, u, t, n));
8413
8420
  }).ElseIf(h.lessThan(b), () => {
8414
8421
  _.assign(Oa({
8415
8422
  N: t,
@@ -8423,9 +8430,9 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8423
8430
  u.assign(ka({
8424
8431
  N: t,
8425
8432
  xi: r
8426
- })), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Ii)), d.assign(pl(e, u, t, n));
8433
+ })), o.assign(E(A(t, u), 0, 1)), f.assign(o.mul(Ii)), d.assign(ml(e, u, t, n));
8427
8434
  }).Else(() => {
8428
- f.assign(ya(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, Vi)), d.assign(pl(e, u, t, n));
8435
+ f.assign(ya(i, n.sheenRoughness).mul(i).div(M(4).mul(a))), f.assign(F(f, Vi)), d.assign(ml(e, u, t, n));
8429
8436
  });
8430
8437
  }).ElseIf(h.lessThan(x), () => {
8431
8438
  let i = E(n.clearcoatRoughness, Bi, 1);
@@ -8435,16 +8442,16 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8435
8442
  Xi: r
8436
8443
  }));
8437
8444
  let a = E(A(t, _), 0, 1);
8438
- u.assign(ge(e.negate(), _)), f.assign(Ca(a, S, i)), f.assign(F(f, Vi)), d.assign(pl(e, u, t, n));
8445
+ u.assign(ge(e.negate(), _)), f.assign(Ca(a, S, i)), f.assign(F(f, Vi)), d.assign(ml(e, u, t, n));
8439
8446
  }).Else(() => {
8440
8447
  let a = A(e, t).greaterThan(0), o = Ha.wrap(Ja(e, t, n.ior, n.roughness, a, n.dispersion, r, i, M(0)));
8441
- u.assign(o.direction), f.assign(F(o.pdf, Vi)), d.assign(pl(e, u, t, n));
8448
+ u.assign(o.direction), f.assign(F(o.pdf, Vi)), d.assign(ml(e, u, t, n));
8442
8449
  }), f.assign(F(f, Vi)), wi({
8443
8450
  direction: u,
8444
8451
  value: d,
8445
8452
  pdf: f
8446
8453
  });
8447
- }), Nl = /* @__PURE__ */ G("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [ea, na]), Pl = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), Fl = f(([e, t, n, r, i, a, o]) => {
8454
+ }), Pl = /* @__PURE__ */ G("\n fn regularizePathContribution( contribution: vec3f, pathLength: f32, fireflyThreshold: f32, frame: i32 ) -> vec3f {\n let threshold = calculateFireflyThreshold( fireflyThreshold, i32( pathLength ), frame );\n return applySoftSuppressionRGB( contribution, threshold, 0.5f );\n }\n", [ea, na]), Fl = /* @__PURE__ */ G("\n fn computeNDCDepth( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), Il = f(([e, t, n, r, i, a, o]) => {
8448
8455
  let s = M(1).toVar();
8449
8456
  return p(e.greaterThanEqual(N(3)), () => {
8450
8457
  let c = F(F(F(t.x, t.y), t.z), 0).toVar();
@@ -8495,11 +8502,11 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8495
8502
  });
8496
8503
  });
8497
8504
  }), s;
8498
- }), Il = wn({
8505
+ }), Ll = wn({
8499
8506
  brdf: "vec3",
8500
8507
  L: "vec3",
8501
8508
  pdf: "float"
8502
- }), Ll = f(([e, t, n, r, i]) => {
8509
+ }), Rl = f(([e, t, n, r, i]) => {
8503
8510
  let a = t.normal, o = e.direction.negate(), s = F(n.clearcoatRoughness, Bi), c = F(n.roughness, Bi), l = M(1).sub(c).mul(M(.5).add(M(.5).mul(n.metalness))).toVar(), u = n.clearcoat.mul(M(1).sub(s)).toVar(), d = M(1).sub(l).mul(M(1).sub(n.metalness)).toVar(), f = l.add(u).add(d);
8504
8511
  l.divAssign(f), u.divAssign(f), d.divAssign(f);
8505
8512
  let m = Y(i), h = U(0).toVar(), g = U(0).toVar();
@@ -8522,22 +8529,22 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8522
8529
  })), g.assign(I(o.add(h)));
8523
8530
  });
8524
8531
  let _ = Di.wrap($i(a, o, h)), v = va(_.NoH, s).mul(_.NoH).div(M(4).mul(_.VoH)).mul(u), y = va(_.NoH, c).mul(_.NoH).div(M(4).mul(_.VoH)).mul(l), b = _.NoL.div(Fi).mul(d), x = F(v.add(y).add(b), .001);
8525
- return Il({
8526
- brdf: ml(_, n),
8532
+ return Ll({
8533
+ brdf: hl(_, n),
8527
8534
  L: h,
8528
8535
  pdf: x
8529
8536
  });
8530
- }), Rl = 32, zl = 16, Bl = 5, Vl = 8, Hl = wn({
8537
+ }), zl = 32, Bl = 16, Vl = 5, Hl = 8, Ul = wn({
8531
8538
  hitPoint: "vec3",
8532
8539
  uv: "vec2",
8533
8540
  normal: "vec3",
8534
8541
  height: "float"
8535
- }), Ul = f(([e, t, n, r, i]) => {
8536
- let a = t.hitPoint.toVar(), o = t.uv.toVar(), s = t.normal.toVar(), c = M(0).toVar(), l = t.triangleIndex, u = $(n, l, N(0), N(Vl)).xyz.toVar(), d = $(n, l, N(1), N(Vl)).xyz, f = $(n, l, N(2), N(Vl)).xyz, h = $(n, l, N(6), N(Vl)).toVar(), g = $(n, l, N(7), N(Vl)), v = h.xy.toVar(), y = h.zw, b = g.xy, x = d.sub(u).toVar(), S = f.sub(u).toVar(), C = y.sub(v).toVar(), w = b.sub(v).toVar(), T = C.x.mul(w.y).sub(w.x.mul(C.y)).toVar();
8542
+ }), Wl = f(([e, t, n, r, i]) => {
8543
+ let a = t.hitPoint.toVar(), o = t.uv.toVar(), s = t.normal.toVar(), c = M(0).toVar(), l = t.triangleIndex, u = $(n, l, N(0), N(Hl)).xyz.toVar(), d = $(n, l, N(1), N(Hl)).xyz, f = $(n, l, N(2), N(Hl)).xyz, h = $(n, l, N(6), N(Hl)).toVar(), g = $(n, l, N(7), N(Hl)), v = h.xy.toVar(), y = h.zw, b = g.xy, x = d.sub(u).toVar(), S = f.sub(u).toVar(), C = y.sub(v).toVar(), w = b.sub(v).toVar(), T = C.x.mul(w.y).sub(w.x.mul(C.y)).toVar();
8537
8544
  return p(_(T).greaterThan(1e-8), () => {
8538
8545
  let n = M(1).div(T), l = x.mul(w.y).sub(S.mul(C.y)).mul(n).toVar(), u = S.mul(C.x).sub(x.mul(w.x)).mul(n).toVar(), d = t.normal.toVar(), f = r.displacementScale.div(M(10)), h = e.direction, g = A(h, d).toVar(), v = h.sub(d.mul(g)).toVar(), y = A(l, l), b = A(l, u), E = A(u, u), D = y.mul(E).sub(b.mul(b)).toVar();
8539
8546
  p(_(D).greaterThan(1e-10), () => {
8540
- let e = M(1).div(D), n = A(v, l), x = A(v, u), S = H(E.mul(n).sub(b.mul(x)).mul(e), y.mul(x).sub(b.mul(n)).mul(e)).toVar(), C = g.toVar(), w = F(_(C), .001), T = f.div(w).toVar(), O = N(i.equal(N(0)).select(N(Rl), N(zl))).toVar(), k = T.negate().toVar(), j = T.sub(k).div(M(O)).toVar(), ee = k.toVar(), te = k.toVar(), ne = N(0).toVar();
8547
+ let e = M(1).div(D), n = A(v, l), x = A(v, u), S = H(E.mul(n).sub(b.mul(x)).mul(e), y.mul(x).sub(b.mul(n)).mul(e)).toVar(), C = g.toVar(), w = F(_(C), .001), T = f.div(w).toVar(), O = N(i.equal(N(0)).select(N(zl), N(Bl))).toVar(), k = T.negate().toVar(), j = T.sub(k).div(M(O)).toVar(), ee = k.toVar(), te = k.toVar(), ne = N(0).toVar();
8541
8548
  m({
8542
8549
  start: N(0),
8543
8550
  end: O,
@@ -8556,7 +8563,7 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8556
8563
  let e = ee.toVar(), n = te.toVar();
8557
8564
  m({
8558
8565
  start: N(0),
8559
- end: N(Bl),
8566
+ end: N(Vl),
8560
8567
  type: "int",
8561
8568
  condition: "<"
8562
8569
  }, () => {
@@ -8571,13 +8578,13 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8571
8578
  a.assign(_), o.assign(g), s.assign(A), c.assign(y);
8572
8579
  });
8573
8580
  });
8574
- }), Hl({
8581
+ }), Ul({
8575
8582
  hitPoint: a,
8576
8583
  uv: o,
8577
8584
  normal: s,
8578
8585
  height: c
8579
8586
  });
8580
- }), Wl = wn({
8587
+ }), Gl = wn({
8581
8588
  position: "vec3",
8582
8589
  normal: "vec3",
8583
8590
  emission: "vec3",
@@ -8587,40 +8594,40 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8587
8594
  area: "float",
8588
8595
  cosThetaLight: "float",
8589
8596
  valid: "bool"
8590
- }), Gl = wn({
8597
+ }), Kl = wn({
8591
8598
  contribution: "vec3",
8592
8599
  hasEmissive: "bool",
8593
8600
  emissionOnly: "vec3",
8594
8601
  distance: "float"
8595
- }), Kl = f(([e, t, n, r]) => {
8602
+ }), ql = f(([e, t, n, r]) => {
8596
8603
  let i = Se(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
8597
8604
  return e.mul(a).add(t.mul(o)).add(n.mul(s));
8598
- }), ql = f(([e, t, n]) => ie(O(t.sub(e), n.sub(e))).mul(.5)), Jl = f(([e, t, n, r]) => {
8605
+ }), Jl = f(([e, t, n]) => ie(O(t.sub(e), n.sub(e))).mul(.5)), Yl = f(([e, t, n, r]) => {
8599
8606
  let i = I(e.sub(r)), a = I(t.sub(r)), o = I(n.sub(r)), s = _(A(i, O(a, o))), c = M(1).add(A(a, o)).add(A(i, o)).add(A(i, a));
8600
8607
  return F(M(2).mul(b(s, F(c, M(1e-10)))), M(0));
8601
- }), Yl = f(([e, t, n, r]) => {
8608
+ }), Xl = f(([e, t, n, r]) => {
8602
8609
  let i = t.sub(e), a = n.sub(e), o = n.sub(t), s = F(A(i, i), F(A(a, a), A(o, o))), c = O(i, a), l = A(c, c), u = T(!1).toVar();
8603
8610
  return p(l.greaterThan(1e-20), () => {
8604
8611
  let t = A(c, r.sub(e)), n = t.mul(t).div(l);
8605
8612
  u.assign(s.greaterThan(n));
8606
8613
  }), u;
8607
- }), Xl = wn({
8614
+ }), Zl = wn({
8608
8615
  direction: "vec3",
8609
8616
  position: "vec3",
8610
8617
  solidAngle: "float",
8611
8618
  valid: "bool"
8612
- }), Zl = f(([e]) => {
8619
+ }), Ql = f(([e]) => {
8613
8620
  let t = ie(e);
8614
8621
  return L(t.greaterThan(1e-10), e.div(t), U(0));
8615
- }), Ql = f(([e, t, n, r, i]) => {
8616
- let a = Xl({
8622
+ }), $l = f(([e, t, n, r, i]) => {
8623
+ let a = Zl({
8617
8624
  direction: U(0),
8618
8625
  position: U(0),
8619
8626
  solidAngle: M(0),
8620
8627
  valid: !1
8621
- }).toVar(), o = I(e.sub(r)), s = I(t.sub(r)), c = I(n.sub(r)), l = Jl(e, t, n, r);
8628
+ }).toVar(), o = I(e.sub(r)), s = I(t.sub(r)), c = I(n.sub(r)), l = Yl(e, t, n, r);
8622
8629
  return a.solidAngle.assign(l), p(l.greaterThan(1e-7), () => {
8623
- let u = E(A(Zl(O(o, s)), Zl(O(o, c))), -1, 1), d = Se(F(M(1).sub(u.mul(u)), 0)), f = v(u), m = i.x.mul(l).sub(f), h = be(m), g = D(m), y = E(A(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(L(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = Zl(c.sub(o.mul(T))), j = Se(F(M(1).sub(w.mul(w)), 0)), ee = I(o.mul(w).add(k.mul(j))), te = A(ee, s), ne = M(1).sub(i.y.mul(M(1).sub(te))), re = Se(F(M(1).sub(ne.mul(ne)), 0)), N = Zl(ee.sub(s.mul(te))), P = I(s.mul(ne).add(N.mul(re))), ie = I(O(t.sub(e), n.sub(e))), ae = A(ie, P);
8630
+ let u = E(A(Ql(O(o, s)), Ql(O(o, c))), -1, 1), d = Se(F(M(1).sub(u.mul(u)), 0)), f = v(u), m = i.x.mul(l).sub(f), h = be(m), g = D(m), y = E(A(o, s), -1, 1), b = g.sub(u), x = h.add(d.mul(y)), S = x.mul(g).sub(b.mul(h)).mul(u).sub(x), C = x.mul(h).add(b.mul(g)).mul(d), w = E(L(_(C).greaterThan(1e-10), S.div(C), M(1)), -1, 1), T = A(c, o), k = Ql(c.sub(o.mul(T))), j = Se(F(M(1).sub(w.mul(w)), 0)), ee = I(o.mul(w).add(k.mul(j))), te = A(ee, s), ne = M(1).sub(i.y.mul(M(1).sub(te))), re = Se(F(M(1).sub(ne.mul(ne)), 0)), N = Ql(ee.sub(s.mul(te))), P = I(s.mul(ne).add(N.mul(re))), ie = I(O(t.sub(e), n.sub(e))), ae = A(ie, P);
8624
8631
  p(_(ae).greaterThan(1e-10), () => {
8625
8632
  let t = A(ie, e.sub(r)).div(ae);
8626
8633
  p(t.greaterThan(0), () => {
@@ -8628,15 +8635,15 @@ var al = /* @__PURE__ */ G("\n fn equirectDirectionToUv( direction: vec3f, envir
8628
8635
  });
8629
8636
  });
8630
8637
  }), a;
8631
- }), $l = f(([e, t, n, r]) => {
8638
+ }), eu = f(([e, t, n, r]) => {
8632
8639
  let i = n.sub(t), a = r.sub(t), o = e.sub(t), s = A(i, i), c = A(i, a), l = A(a, a), u = A(o, i), d = A(o, a), f = M(1).div(F(s.mul(l).sub(c.mul(c)), M(1e-10))), p = l.mul(u).sub(c.mul(d)).mul(f), m = s.mul(d).sub(c.mul(u)).mul(f);
8633
8640
  return U(M(1).sub(p).sub(m), p, m);
8634
- }), eu = f(([e, t, n, r]) => {
8641
+ }), tu = f(([e, t, n, r]) => {
8635
8642
  let i = Se(r.x), a = M(1).sub(i), o = r.y.mul(i), s = M(1).sub(a).sub(o);
8636
8643
  return I(e.mul(a).add(t.mul(o)).add(n.mul(s)));
8637
8644
  });
8638
8645
  f(([e]) => e.emissiveIntensity.greaterThan(0).and(ie(e.emissive).greaterThan(0)));
8639
- var tu = 8, nu = 2, ru = wn({
8646
+ var nu = 8, ru = 2, iu = wn({
8640
8647
  v0: "vec3",
8641
8648
  v1: "vec3",
8642
8649
  v2: "vec3",
@@ -8644,9 +8651,9 @@ var tu = 8, nu = 2, ru = wn({
8644
8651
  n1: "vec3",
8645
8652
  n2: "vec3",
8646
8653
  materialIndex: "int"
8647
- }), iu = f(([e, t]) => {
8648
- let n = $(t, e, N(0), N(tu)), r = $(t, e, N(1), N(tu)), i = $(t, e, N(2), N(tu)), a = $(t, e, N(3), N(tu)), o = $(t, e, N(4), N(tu)), s = $(t, e, N(5), N(tu)), c = $(t, e, N(7), N(tu));
8649
- return ru({
8654
+ }), au = f(([e, t]) => {
8655
+ let n = $(t, e, N(0), N(nu)), r = $(t, e, N(1), N(nu)), i = $(t, e, N(2), N(nu)), a = $(t, e, N(3), N(nu)), o = $(t, e, N(4), N(nu)), s = $(t, e, N(5), N(nu)), c = $(t, e, N(7), N(nu));
8656
+ return iu({
8650
8657
  v0: n.xyz,
8651
8658
  v1: r.xyz,
8652
8659
  v2: i.xyz,
@@ -8655,27 +8662,27 @@ var tu = 8, nu = 2, ru = wn({
8655
8662
  n2: s.xyz,
8656
8663
  materialIndex: N(c.z)
8657
8664
  });
8658
- }), au = f(([e, t, n, r, i, a, o]) => {
8659
- let s = ru.wrap(iu(e, i)), c = ql(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(Wi.EMISSIVE_ROUGHNESS), Ui), u = $(a, s.materialIndex, N(Wi.IOR_TRANSMISSION), Ui), d = F(l.x.mul(.2126).add(l.y.mul(.7152)).add(l.z.mul(.0722)).mul(u.a).mul(c), M(1e-10)).div(F(o, M(1e-10))), f = M(0).toVar();
8660
- return p(Yl(s.v0, s.v1, s.v2, r), () => {
8661
- let e = Jl(s.v0, s.v1, s.v2, r);
8665
+ }), ou = f(([e, t, n, r, i, a, o]) => {
8666
+ let s = iu.wrap(au(e, i)), c = Jl(s.v0, s.v1, s.v2), l = $(a, s.materialIndex, N(Wi.EMISSIVE_ROUGHNESS), Ui), u = $(a, s.materialIndex, N(Wi.IOR_TRANSMISSION), Ui), d = F(l.x.mul(.2126).add(l.y.mul(.7152)).add(l.z.mul(.0722)).mul(u.a).mul(c), M(1e-10)).div(F(o, M(1e-10))), f = M(0).toVar();
8667
+ return p(Xl(s.v0, s.v1, s.v2, r), () => {
8668
+ let e = Yl(s.v0, s.v1, s.v2, r);
8662
8669
  f.assign(d.div(F(e, M(1e-10))));
8663
8670
  }).Else(() => {
8664
8671
  let e = I(O(s.v1.sub(s.v0), s.v2.sub(s.v0))), r = F(A(n.negate(), e), .001), i = t.mul(t), a = d.div(c);
8665
8672
  f.assign(a.mul(i).div(r));
8666
8673
  }), F(f, Vi);
8667
- }), ou = f(([e, t, n, r]) => {
8674
+ }), su = f(([e, t, n, r]) => {
8668
8675
  let i = N(0).toVar(), a = n.sub(1).toVar();
8669
8676
  return m(i.lessThan(a), () => {
8670
- let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(nu)))).b;
8677
+ let n = i.add(a).div(2).toVar(), o = e.element(t.add(n.mul(N(ru)))).b;
8671
8678
  p(o.lessThan(r), () => {
8672
8679
  i.assign(n.add(1));
8673
8680
  }).Else(() => {
8674
8681
  a.assign(n);
8675
8682
  });
8676
8683
  }), i;
8677
- }), su = f(([e, t, n, r, i, a, o, s]) => {
8678
- let c = Wl({
8684
+ }), cu = f(([e, t, n, r, i, a, o, s]) => {
8685
+ let c = Gl({
8679
8686
  position: U(0),
8680
8687
  normal: U(0),
8681
8688
  emission: U(0),
@@ -8687,40 +8694,40 @@ var tu = 8, nu = 2, ru = wn({
8687
8694
  valid: !1
8688
8695
  }).toVar();
8689
8696
  return p(a.greaterThan(N(0)), () => {
8690
- let l = ou(r, i, a, Y(n)).toVar(), u = i.add(l.mul(N(nu))), d = r.element(u), f = r.element(u.add(1)), m = N(d.r), h = F(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = ru.wrap(iu(m, s)), y = H(Y(n).toVar(), Y(n).toVar()), b = I(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
8691
- p(Yl(v.v0, v.v1, v.v2, e), () => {
8692
- let n = Xl.wrap(Ql(v.v0, v.v1, v.v2, e, y));
8697
+ let l = su(r, i, a, Y(n)).toVar(), u = i.add(l.mul(N(ru))), d = r.element(u), f = r.element(u.add(1)), m = N(d.r), h = F(d.g, M(1e-10)), g = f.xyz, _ = f.w, v = iu.wrap(au(m, s)), y = H(Y(n).toVar(), Y(n).toVar()), b = I(O(v.v1.sub(v.v0), v.v2.sub(v.v0)));
8698
+ p(Xl(v.v0, v.v1, v.v2, e), () => {
8699
+ let n = Zl.wrap($l(v.v0, v.v1, v.v2, e, y));
8693
8700
  p(n.valid.and(n.solidAngle.greaterThan(1e-7)), () => {
8694
8701
  let r = n.direction, i = n.position, a = A(r, t), s = A(r, b.negate());
8695
8702
  p(a.greaterThan(0).and(s.greaterThan(0)), () => {
8696
- let t = $l(i, v.v0, v.v1, v.v2), a = I(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), l = ie(i.sub(e)), u = h.div(F(o, M(1e-10))).div(n.solidAngle);
8703
+ let t = eu(i, v.v0, v.v1, v.v2), a = I(v.n0.mul(t.x).add(v.n1.mul(t.y)).add(v.n2.mul(t.z))), l = ie(i.sub(e)), u = h.div(F(o, M(1e-10))).div(n.solidAngle);
8697
8704
  c.position.assign(i), c.normal.assign(a), c.emission.assign(g), c.direction.assign(r), c.distance.assign(l), c.pdf.assign(F(u, Vi)), c.area.assign(_), c.cosThetaLight.assign(s), c.valid.assign(!0);
8698
8705
  });
8699
8706
  });
8700
8707
  }).Else(() => {
8701
- let n = Kl(v.v0, v.v1, v.v2, y), r = eu(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), s = Se(a), l = i.div(s), u = A(l, t), d = A(l, r.negate());
8708
+ let n = ql(v.v0, v.v1, v.v2, y), r = tu(v.n0, v.n1, v.n2, y), i = n.sub(e), a = A(i, i), s = Se(a), l = i.div(s), u = A(l, t), d = A(l, r.negate());
8702
8709
  p(u.greaterThan(0).and(d.greaterThan(0)), () => {
8703
8710
  let e = h.div(F(o, M(1e-10)).mul(_)).mul(a).div(d);
8704
8711
  c.position.assign(n), c.normal.assign(r), c.emission.assign(g), c.direction.assign(l), c.distance.assign(s), c.pdf.assign(F(e, Vi)), c.area.assign(_), c.cosThetaLight.assign(d), c.valid.assign(!0);
8705
8712
  });
8706
8713
  });
8707
8714
  }), c;
8708
- }), cu = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m]) => {
8709
- let h = Gl({
8715
+ }), lu = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m]) => {
8716
+ let h = Kl({
8710
8717
  contribution: U(0),
8711
8718
  hasEmissive: !1,
8712
8719
  emissionOnly: U(0),
8713
8720
  distance: M(0)
8714
8721
  }).toVar();
8715
8722
  return p(i.greaterThan(N(1)).and(r.roughness.greaterThan(.9)).and(r.metalness.lessThan(.1)).not(), () => {
8716
- let i = Wl.wrap(su(e, t, a, s, c, l, u, d));
8723
+ let i = Gl.wrap(cu(e, t, a, s, c, l, u, d));
8717
8724
  p(i.valid.and(i.pdf.greaterThan(0)), () => {
8718
8725
  h.hasEmissive.assign(!0), h.emissionOnly.assign(i.emission), h.distance.assign(i.distance);
8719
8726
  let a = F(M(0), A(t, i.direction));
8720
8727
  p(a.greaterThan(0), () => {
8721
8728
  let s = m(e, t, r), c = e.add(s), l = i.distance.sub(.001), u = f(c, i.direction, l);
8722
8729
  p(u.greaterThan(0), () => {
8723
- let e = Di.wrap($i(t, n, i.direction)), s = fl(r, e), c = Sl(r, e), l = L(c.greaterThan(0), Xi({
8730
+ let e = Di.wrap($i(t, n, i.direction)), s = pl(r, e), c = Cl(r, e), l = L(c.greaterThan(0), Xi({
8724
8731
  pdf1: i.pdf,
8725
8732
  pdf2: c
8726
8733
  }), M(1));
@@ -8729,11 +8736,11 @@ var tu = 8, nu = 2, ru = wn({
8729
8736
  });
8730
8737
  });
8731
8738
  }), h;
8732
- }), lu = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => Gl.wrap(cu(e, t, n, r, i, a, o, s, c, l, u, d, f, p)).contribution), uu = 4, du = 2, fu = 32, pu = f(([e, t, n, r]) => L(t.greaterThan(r), M(1), t.mul(r).add(e.mul(n)))), mu = f(([e, t, n, r]) => L(t.greaterThan(r), M(0), e.mul(r).sub(t.mul(n)))), hu = f(([e, t, n, r, i, a]) => {
8733
- let o = e.add(n).mul(.5), s = ie(n.sub(e)), c = a.sub(o), l = F(A(c, c), M(1e-12)), u = F(l, s.mul(.5)), d = A(r, c.div(Se(l))), f = Se(F(M(1).sub(d.mul(d)), M(0))), p = s.mul(s).mul(.25), m = E(p.div(l), M(0), M(1)), h = L(l.lessThan(p), M(-1), Se(F(M(1).sub(m), M(0)))), g = Se(F(M(1).sub(h.mul(h)), M(0))), _ = Se(F(M(1).sub(i.mul(i)), M(0))), v = pu(f, d, _, i), y = pu(mu(f, d, _, i), v, g, h);
8739
+ }), uu = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, p]) => Kl.wrap(lu(e, t, n, r, i, a, o, s, c, l, u, d, f, p)).contribution), du = 4, fu = 2, pu = 32, mu = f(([e, t, n, r]) => L(t.greaterThan(r), M(1), t.mul(r).add(e.mul(n)))), hu = f(([e, t, n, r]) => L(t.greaterThan(r), M(0), e.mul(r).sub(t.mul(n)))), gu = f(([e, t, n, r, i, a]) => {
8740
+ let o = e.add(n).mul(.5), s = ie(n.sub(e)), c = a.sub(o), l = F(A(c, c), M(1e-12)), u = F(l, s.mul(.5)), d = A(r, c.div(Se(l))), f = Se(F(M(1).sub(d.mul(d)), M(0))), p = s.mul(s).mul(.25), m = E(p.div(l), M(0), M(1)), h = L(l.lessThan(p), M(-1), Se(F(M(1).sub(m), M(0)))), g = Se(F(M(1).sub(h.mul(h)), M(0))), _ = Se(F(M(1).sub(i.mul(i)), M(0))), v = mu(f, d, _, i), y = mu(hu(f, d, _, i), v, g, h);
8734
8741
  return F(L(y.greaterThan(M(0)), t.mul(y).div(u), M(0)), M(0));
8735
- }), gu = f(([e, t, n, r, i, a, o]) => {
8736
- let s = Wl({
8742
+ }), _u = f(([e, t, n, r, i, a, o]) => {
8743
+ let s = Gl({
8737
8744
  position: U(0),
8738
8745
  normal: U(0),
8739
8746
  emission: U(0),
@@ -8744,12 +8751,12 @@ var tu = 8, nu = 2, ru = wn({
8744
8751
  cosThetaLight: M(0),
8745
8752
  valid: !1
8746
8753
  }).toVar(), c = M(1).toVar(), l = N(0).toVar(), u = T(!1).toVar();
8747
- return m(fu, () => {
8748
- let t = l.mul(N(uu)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
8754
+ return m(pu, () => {
8755
+ let t = l.mul(N(du)), i = r.element(t.add(N(1))), a = r.element(t.add(N(2)));
8749
8756
  p(i.w.greaterThan(.5), () => {
8750
8757
  u.assign(T(!0)), d();
8751
8758
  });
8752
- let o = N(a.x), s = N(a.y), f = o.mul(N(uu)), m = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(uu)), _ = r.element(g), v = r.element(g.add(N(1))), y = r.element(f.add(N(3))), b = r.element(g.add(N(3))), x = hu(m.xyz, m.w, h.xyz, y.xyz, y.w, e), S = hu(_.xyz, _.w, v.xyz, b.xyz, b.w, e), C = x.add(S);
8759
+ let o = N(a.x), s = N(a.y), f = o.mul(N(du)), m = r.element(f), h = r.element(f.add(N(1))), g = s.mul(N(du)), _ = r.element(g), v = r.element(g.add(N(1))), y = r.element(f.add(N(3))), b = r.element(g.add(N(3))), x = gu(m.xyz, m.w, h.xyz, y.xyz, y.w, e), S = gu(_.xyz, _.w, v.xyz, b.xyz, b.w, e), C = x.add(S);
8753
8760
  p(C.lessThanEqual(M(0)), () => {
8754
8761
  l.assign(o);
8755
8762
  }).Else(() => {
@@ -8761,44 +8768,44 @@ var tu = 8, nu = 2, ru = wn({
8761
8768
  });
8762
8769
  });
8763
8770
  }), p(u, () => {
8764
- let u = l.mul(N(uu)), f = r.element(u), h = r.element(u.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = Y(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
8771
+ let u = l.mul(N(du)), f = r.element(u), h = r.element(u.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = Y(n).mul(v), b = M(0).toVar(), x = g.add(_.sub(N(1))).toVar(), S = M(1e-10).toVar();
8765
8772
  m({
8766
8773
  start: N(0),
8767
8774
  end: _
8768
8775
  }, ({ i: e }) => {
8769
- let t = g.add(e), n = a.add(t.mul(N(du))), r = F(i.element(n).g, M(0));
8776
+ let t = g.add(e), n = a.add(t.mul(N(fu))), r = F(i.element(n).g, M(0));
8770
8777
  b.addAssign(r), p(b.greaterThanEqual(y).and(r.greaterThan(M(0))), () => {
8771
8778
  x.assign(t), S.assign(r), d();
8772
8779
  });
8773
8780
  }), c.mulAssign(S.div(v));
8774
- let C = a.add(x.mul(N(du))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = ru.wrap(iu(E, o)), ee = H(Y(n).toVar(), Y(n).toVar()), te = I(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
8775
- p(Yl(j.v0, j.v1, j.v2, e), () => {
8776
- let n = Xl.wrap(Ql(j.v0, j.v1, j.v2, e, ee));
8781
+ let C = a.add(x.mul(N(fu))), w = i.element(C), T = i.element(C.add(N(1))), E = N(w.r), D = T.xyz, k = T.w, j = iu.wrap(au(E, o)), ee = H(Y(n).toVar(), Y(n).toVar()), te = I(O(j.v1.sub(j.v0), j.v2.sub(j.v0)));
8782
+ p(Xl(j.v0, j.v1, j.v2, e), () => {
8783
+ let n = Zl.wrap($l(j.v0, j.v1, j.v2, e, ee));
8777
8784
  p(n.valid.and(n.solidAngle.greaterThan(M(1e-7))), () => {
8778
8785
  let r = n.direction, i = n.position, a = A(r, t), o = A(r, te.negate());
8779
8786
  p(a.greaterThan(M(0)).and(o.greaterThan(M(0))), () => {
8780
- let t = $l(i, j.v0, j.v1, j.v2), a = I(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ie(i.sub(e)), u = c.div(F(n.solidAngle, M(1e-10)));
8787
+ let t = eu(i, j.v0, j.v1, j.v2), a = I(j.n0.mul(t.x).add(j.n1.mul(t.y)).add(j.n2.mul(t.z))), l = ie(i.sub(e)), u = c.div(F(n.solidAngle, M(1e-10)));
8781
8788
  s.position.assign(i), s.normal.assign(a), s.emission.assign(D), s.direction.assign(r), s.distance.assign(l), s.pdf.assign(F(u, Vi)), s.area.assign(k), s.cosThetaLight.assign(o), s.valid.assign(!0);
8782
8789
  });
8783
8790
  });
8784
8791
  }).Else(() => {
8785
- let n = Kl(j.v0, j.v1, j.v2, ee), r = eu(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = Se(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
8792
+ let n = ql(j.v0, j.v1, j.v2, ee), r = tu(j.n0, j.n1, j.n2, ee), i = n.sub(e), a = A(i, i), o = Se(a), l = i.div(o), u = A(l, t), d = A(l, r.negate());
8786
8793
  p(u.greaterThan(M(0)).and(d.greaterThan(M(0))), () => {
8787
8794
  let e = c.div(F(k, M(1e-10))).mul(a).div(d);
8788
8795
  s.position.assign(n), s.normal.assign(r), s.emission.assign(D), s.direction.assign(l), s.distance.assign(o), s.pdf.assign(F(e, Vi)), s.area.assign(k), s.cosThetaLight.assign(d), s.valid.assign(!0);
8789
8796
  });
8790
8797
  });
8791
8798
  }), s;
8792
- }), _u = f(([e, t, n, r, i, a, o, s]) => {
8799
+ }), vu = f(([e, t, n, r, i, a, o, s]) => {
8793
8800
  let c = M(0).toVar(), l = N(e).toVar(), u = i.element(o.add(l.shiftRight(N(2)))), f = l.bitAnd(N(3)), h = L(f.equal(N(0)), u.x, L(f.equal(N(1)), u.y, L(f.equal(N(2)), u.z, u.w))).toVar();
8794
8801
  return p(h.greaterThanEqual(M(0)), () => {
8795
8802
  let e = N(h).toVar(), o = M(1).toVar(), u = N(0).toVar(), f = N(0).toVar(), g = T(!1).toVar();
8796
- m(fu, () => {
8797
- let t = u.mul(N(uu));
8803
+ m(pu, () => {
8804
+ let t = u.mul(N(du));
8798
8805
  p(i.element(t.add(N(1))).w.greaterThan(.5), () => {
8799
8806
  g.assign(T(!0)), d();
8800
8807
  });
8801
- let n = i.element(t.add(N(2))), a = N(n.x), s = N(n.y), c = a.mul(N(uu)), l = i.element(c), m = i.element(c.add(N(1))), h = i.element(c.add(N(3))), _ = s.mul(N(uu)), v = i.element(_), y = i.element(_.add(N(1))), b = i.element(_.add(N(3))), x = hu(l.xyz, l.w, m.xyz, h.xyz, h.w, r), S = hu(v.xyz, v.w, y.xyz, b.xyz, b.w, r), C = x.add(S), w = e.shiftRight(f).bitAnd(N(1)).equal(N(1));
8808
+ let n = i.element(t.add(N(2))), a = N(n.x), s = N(n.y), c = a.mul(N(du)), l = i.element(c), m = i.element(c.add(N(1))), h = i.element(c.add(N(3))), _ = s.mul(N(du)), v = i.element(_), y = i.element(_.add(N(1))), b = i.element(_.add(N(3))), x = gu(l.xyz, l.w, m.xyz, h.xyz, h.w, r), S = gu(v.xyz, v.w, y.xyz, b.xyz, b.w, r), C = x.add(S), w = e.shiftRight(f).bitAnd(N(1)).equal(N(1));
8802
8809
  p(C.lessThanEqual(M(0)), () => {
8803
8810
  p(w, () => {
8804
8811
  o.assign(M(0)), u.assign(s);
@@ -8814,28 +8821,28 @@ var tu = 8, nu = 2, ru = wn({
8814
8821
  });
8815
8822
  }), f.addAssign(N(1));
8816
8823
  }), p(g.and(o.greaterThan(M(0))), () => {
8817
- let e = u.mul(N(uu)), f = i.element(e), h = i.element(e.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = M(0).toVar();
8824
+ let e = u.mul(N(du)), f = i.element(e), h = i.element(e.add(N(2))), g = N(h.x), _ = N(h.y), v = F(f.w, M(1e-10)), y = M(0).toVar();
8818
8825
  m({
8819
8826
  start: N(0),
8820
8827
  end: _
8821
8828
  }, ({ i: e }) => {
8822
- let t = g.add(e), n = i.element(a.add(t.mul(N(du))));
8829
+ let t = g.add(e), n = i.element(a.add(t.mul(N(fu))));
8823
8830
  p(N(n.r).equal(l), () => {
8824
8831
  y.assign(F(n.g, M(0))), d();
8825
8832
  });
8826
8833
  }), o.mulAssign(y.div(v));
8827
- let b = ru.wrap(iu(l, s));
8828
- p(Yl(b.v0, b.v1, b.v2, r), () => {
8829
- let e = Jl(b.v0, b.v1, b.v2, r);
8834
+ let b = iu.wrap(au(l, s));
8835
+ p(Xl(b.v0, b.v1, b.v2, r), () => {
8836
+ let e = Yl(b.v0, b.v1, b.v2, r);
8830
8837
  c.assign(o.div(F(e, M(1e-10))));
8831
8838
  }).Else(() => {
8832
- let e = I(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = F(A(n.negate(), e), M(.001)), i = ql(b.v0, b.v1, b.v2), a = t.mul(t), s = o.div(F(i, M(1e-10)));
8839
+ let e = I(O(b.v1.sub(b.v0), b.v2.sub(b.v0))), r = F(A(n.negate(), e), M(.001)), i = Jl(b.v0, b.v1, b.v2), a = t.mul(t), s = o.div(F(i, M(1e-10)));
8833
8840
  c.assign(s.mul(a).div(r));
8834
8841
  });
8835
8842
  });
8836
8843
  }), F(c, Vi);
8837
- }), vu = 0x8ac7230489e80000, yu = 1e-4, bu = 1e-4, xu = .001;
8838
- function Su(e) {
8844
+ }), yu = 0x8ac7230489e80000, bu = 1e-4, xu = 1e-4, Su = .001;
8845
+ function Cu(e) {
8839
8846
  let { bvhBuffer: t, triangleBuffer: n, materialBuffer: r, envCDFTexture: i, lightBuffer: a, rayBufferRW: o, rngBufferRW: s, hitBufferRO: c, gBufferRW: l, counters: u, activeIndicesRO: d, envTexture: g, environmentIntensity: _, envMatrix: v, enableEnvironmentLight: y, useEnvMapIS: b, groundProjectionEnabled: x, groundProjectionRadius: C, groundProjectionHeight: w, groundProjectionLevel: D, enableGroundCatcher: O, groundCatcherHeight: k, envTotalSum: ee, envCompensationDelta: te, envResolution: ne, directionalLightsBuffer: P, numDirectionalLights: ae, areaLightsBuffer: oe, numAreaLights: ce, pointLightsBuffer: le, numPointLights: ue, spotLightsBuffer: de, numSpotLights: fe, maxBounceCount: pe, maxSubsurfaceSteps: me, currentBounce: he, transparentBackground: ge, backgroundIntensity: _e, backgroundColor: ye, backgroundBlurriness: be, backgroundBlurSamples: xe, showBackground: Se, globalIlluminationIntensity: Ce, cameraProjectionMatrix: we, cameraViewMatrix: Te, fireflyThreshold: Ee, frame: De, resolution: Oe, emissiveTriangleCount: ke, emissiveVec4Offset: Ae, emissiveTotalPower: R, emissiveBoost: je, totalTriangleCount: z, enableEmissiveTriangleSampling: Me, lightBVHNodeCount: V, reverseMapVec4Offset: Ne, maxRayCount: Pe, auxGBufferEnabled: Fe } = e, Ie = Fe.greaterThan(B(0)), Le = a !== void 0, Re = (e, t, n, r) => {
8840
8847
  let i = I(e).toVar(), a = F(n, N(1)).toVar(), o = U(0).toVar();
8841
8848
  return m({
@@ -8845,7 +8852,7 @@ function Su(e) {
8845
8852
  condition: "<"
8846
8853
  }, () => {
8847
8854
  let e = Xo(i, t, H(Y(r).toVar(), Y(r).toVar())).toVar();
8848
- o.addAssign(ll({
8855
+ o.addAssign(ul({
8849
8856
  tex: g,
8850
8857
  samp: ve(g),
8851
8858
  direction: e,
@@ -8856,30 +8863,30 @@ function Su(e) {
8856
8863
  }), o.div(M(a));
8857
8864
  };
8858
8865
  return f(() => {
8859
- let e = re, m = u ? S(u.element(B(Pc.ENTERING_COUNT))) : Pe;
8866
+ let e = re, m = u ? S(u.element(B(Fc.ENTERING_COUNT))) : Pe;
8860
8867
  p(e.greaterThanEqual(m), () => {
8861
8868
  h();
8862
8869
  });
8863
- let z = d.element(e), Fe = sc(o, z).toVar();
8864
- p(Fe.bitAnd(B(Fc.ACTIVE)).equal(B(0)), () => {
8870
+ let z = d.element(e), Fe = cc(o, z).toVar();
8871
+ p(Fe.bitAnd(B(Ic.ACTIVE)).equal(B(0)), () => {
8865
8872
  h();
8866
8873
  });
8867
- let G = Fe.bitAnd(B(Fc.REDIRECTED)).equal(B(0)).toVar(), ze = ac(o, z).toVar(), Be = oc(o, z).toVar(), K = cc(o, z).toVar(), Ve = uc(o, z).toVar(), He = z, Ue = s.element(z).toVar(), We = bc(c, z).toVar(), Ge = Cc(c, z).toVar(), Ke = Sc(c, z).toVar(), qe = wc(c, z).toVar(), Je = xc(c, z).toVar(), Ye = Ac(o, z).toVar(), Xe = N(he).toVar(), Ze = jc(o, z).toVar();
8874
+ let G = Fe.bitAnd(B(Ic.REDIRECTED)).equal(B(0)).toVar(), ze = oc(o, z).toVar(), Be = sc(o, z).toVar(), K = lc(o, z).toVar(), Ve = dc(o, z).toVar(), He = z, Ue = s.element(z).toVar(), We = xc(c, z).toVar(), Ge = wc(c, z).toVar(), Ke = Cc(c, z).toVar(), qe = Tc(c, z).toVar(), Je = Sc(c, z).toVar(), Ye = jc(o, z).toVar(), Xe = N(he).toVar(), Ze = Mc(o, z).toVar();
8868
8875
  p(O.and(Xe.equal(0)), () => {
8869
8876
  let e = Be.y.toVar();
8870
8877
  p(e.abs().greaterThan(M(Ri)), () => {
8871
8878
  let a = k.sub(ze.y).div(e).toVar();
8872
- p(a.greaterThan(M(yu)).and(a.lessThan(We)), () => {
8873
- let e = ze.add(Be.mul(a)).toVar(), c = U(0, 1, 0), u = Be.negate().toVar(), d = bi.wrap(sa()).toVar(), f = Aa(c, H(Y(Ue).toVar(), Y(Ue).toVar())).toVar(), m = f.y.mul(Ii).toVar(), b = U(Ii), S = Si.wrap(Tl(e, c, d, u, f, m, b, Xe, Ue, P, ae, oe, ce, le, ue, de, fe, t, n, r, g, _, v, i, ee, te, ne, y, T(!0))).toVar(), O = F(A(S.shadowed, Hi), M(0)), k = F(A(S.unoccluded, Hi), M(0)).toVar(), j = E(O.div(F(k, M(bu))), 0, 1).toVar();
8874
- p(k.lessThan(M(xu)), () => {
8879
+ p(a.greaterThan(M(bu)).and(a.lessThan(We)), () => {
8880
+ let e = ze.add(Be.mul(a)).toVar(), c = U(0, 1, 0), u = Be.negate().toVar(), d = bi.wrap(sa()).toVar(), f = Aa(c, H(Y(Ue).toVar(), Y(Ue).toVar())).toVar(), m = f.y.mul(Ii).toVar(), b = U(Ii), S = Si.wrap(El(e, c, d, u, f, m, b, Xe, Ue, P, ae, oe, ce, le, ue, de, fe, t, n, r, g, _, v, i, ee, te, ne, y, T(!0))).toVar(), O = F(A(S.shadowed, Hi), M(0)), k = F(A(S.unoccluded, Hi), M(0)).toVar(), j = E(O.div(F(k, M(xu))), 0, 1).toVar();
8881
+ p(k.lessThan(M(Su)), () => {
8875
8882
  j.assign(1);
8876
8883
  });
8877
- let re = dl(ze, Be, x, C, w, D).toVar(), N = U(0).toVar();
8884
+ let re = fl(ze, Be, x, C, w, D).toVar(), N = U(0).toVar();
8878
8885
  p(Se, () => {
8879
8886
  p(be.greaterThan(0), () => {
8880
8887
  N.assign(Re(re, be.mul(1.3), xe, Ue));
8881
8888
  }).Else(() => {
8882
- N.assign(ll({
8889
+ N.assign(ul({
8883
8890
  tex: g,
8884
8891
  samp: ve(g),
8885
8892
  direction: re,
@@ -8891,26 +8898,26 @@ function Su(e) {
8891
8898
  });
8892
8899
  let ie = L(Se, N.mul(_e), ye), se = L(ge, U(0), ie.mul(j)), I = L(ge, M(1).sub(j), M(1));
8893
8900
  p(Ie, () => {
8894
- fc(l, He, c, Pl({
8901
+ pc(l, He, c, Fl({
8895
8902
  worldPos: e,
8896
8903
  cameraProjectionMatrix: we,
8897
8904
  cameraViewMatrix: Te
8898
8905
  }), U(1));
8899
- }), yc(o, z, W(se, I)), _c(o, z, Be, Fe.bitAnd(B(~Fc.ACTIVE))), s.element(z).assign(Ue), h();
8906
+ }), bc(o, z, W(se, I)), vc(o, z, Be, Fe.bitAnd(B(~Ic.ACTIVE))), s.element(z).assign(Ue), h();
8900
8907
  });
8901
8908
  });
8902
- }), p(We.greaterThan(vu), () => {
8909
+ }), p(We.greaterThan(yu), () => {
8903
8910
  let e = G.and(Se), t = G.not().and(y);
8904
8911
  p(e.or(t), () => {
8905
8912
  let e = Be.toVar();
8906
8913
  p(G, () => {
8907
- e.assign(dl(ze, Be, x, C, w, D));
8914
+ e.assign(fl(ze, Be, x, C, w, D));
8908
8915
  });
8909
8916
  let t = U(0).toVar();
8910
8917
  p(G.and(be.greaterThan(0)), () => {
8911
8918
  t.assign(Re(e, be.mul(1.3), xe, Ue));
8912
8919
  }).Else(() => {
8913
- t.assign(ll({
8920
+ t.assign(ul({
8914
8921
  tex: g,
8915
8922
  samp: ve(g),
8916
8923
  direction: e,
@@ -8921,9 +8928,9 @@ function Su(e) {
8921
8928
  });
8922
8929
  let n = M(1).toVar();
8923
8930
  p(G.not().and(b), () => {
8924
- let e = lc(o, z);
8931
+ let e = uc(o, z);
8925
8932
  p(e.greaterThan(0), () => {
8926
- let t = sl(g, Be, v, ee, te, ne).w;
8933
+ let t = cl(g, Be, v, ee, te, ne).w;
8927
8934
  p(t.greaterThan(0), () => {
8928
8935
  n.assign(Zi({
8929
8936
  pdf1: e,
@@ -8933,16 +8940,16 @@ function Su(e) {
8933
8940
  });
8934
8941
  });
8935
8942
  let r = L(G.not(), Ce, M(1)), i = L(G, _e, n.mul(r)), a = L(G, M(0), M(Xe));
8936
- Ve.assign(W(Ve.xyz.add(Nl(K.mul(t).mul(i), a, Ee, N(De))), Ve.w));
8943
+ Ve.assign(W(Ve.xyz.add(Pl(K.mul(t).mul(i), a, Ee, N(De))), Ve.w));
8937
8944
  }), p(G.and(Se.not()).and(ge.not()), () => {
8938
8945
  Ve.assign(W(Ve.xyz.add(K.mul(ye)), Ve.w));
8939
- }), p(ge.and(Fe.bitAnd(B(Fc.HAS_HIT_OPAQUE)).equal(B(0))), () => {
8946
+ }), p(ge.and(Fe.bitAnd(B(Ic.HAS_HIT_OPAQUE)).equal(B(0))), () => {
8940
8947
  Ve.w.assign(0);
8941
- }), yc(o, z, Ve), _c(o, z, Be, Fe.bitAnd(B(~Fc.ACTIVE))), h();
8948
+ }), bc(o, z, Ve), vc(o, z, Be, Fe.bitAnd(B(~Ic.ACTIVE))), h();
8942
8949
  });
8943
- let Qe = ze.add(Be.mul(We)).toVar(), $e = I(Ge).toVar(), et = Ec(o, z), tt = N(et.stackDepth).toVar(), nt = et.ior1.toVar(), rt = et.ior2.toVar(), it = et.ior3.toVar(), at = N(et.transTraversals).toVar(), ot = M(et.wavelength).toVar();
8950
+ let Qe = ze.add(Be.mul(We)).toVar(), $e = I(Ge).toVar(), et = Dc(o, z), tt = N(et.stackDepth).toVar(), nt = et.ior1.toVar(), rt = et.ior2.toVar(), it = et.ior3.toVar(), at = N(et.transTraversals).toVar(), ot = M(et.wavelength).toVar();
8944
8951
  p(tt.greaterThan(0), () => {
8945
- let e = Oc(o, z).toVar(), t = Mc(o, z), n = t.sigmaS.toVar(), r = t.g.toVar();
8952
+ let e = kc(o, z).toVar(), t = Nc(o, z), n = t.sigmaS.toVar(), r = t.g.toVar();
8946
8953
  p(F(F(n.x, n.y), n.z).lessThanEqual(0), () => {
8947
8954
  K.mulAssign(j(e.mul(We).negate()));
8948
8955
  }).Else(() => {
@@ -8952,8 +8959,8 @@ function Su(e) {
8952
8959
  Ze.addAssign(1);
8953
8960
  let a = E(F(F(K.x, K.y), K.z), .02, 1).toVar();
8954
8961
  p(Ze.greaterThanEqual(me).or(Y(Ue).greaterThan(a)).toVar(), () => {
8955
- yc(o, z, Ve), _c(o, z, Be, Fe.bitAnd(B(~Fc.ACTIVE))), s.element(z).assign(Ue), h();
8956
- }), K.divAssign(a), Fe.assign(Fe.bitOr(B(Fc.REDIRECTED))), gc(o, z, t, Ye, Ze), _c(o, z, n, Fe), vc(o, z, K, lc(o, z)), yc(o, z, Ve), s.element(z).assign(Ue), h();
8962
+ bc(o, z, Ve), vc(o, z, Be, Fe.bitAnd(B(~Ic.ACTIVE))), s.element(z).assign(Ue), h();
8963
+ }), K.divAssign(a), Fe.assign(Fe.bitOr(B(Ic.REDIRECTED))), _c(o, z, t, Ye, Ze), vc(o, z, n, Fe), yc(o, z, K, uc(o, z)), bc(o, z, Ve), s.element(z).assign(Ue), h();
8957
8964
  });
8958
8965
  });
8959
8966
  });
@@ -8973,7 +8980,7 @@ function Su(e) {
8973
8980
  triangleIndex: N(Je),
8974
8981
  boxTests: N(0),
8975
8982
  triTests: N(0)
8976
- }), r = Hl.wrap(Ul(e, t, n, q, Xe)).toVar();
8983
+ }), r = Ul.wrap(Wl(e, t, n, q, Xe)).toVar();
8977
8984
  st.assign(r.uv), ct.assign(r.normal), Qe.assign(r.hitPoint);
8978
8985
  });
8979
8986
  let lt = ki.wrap(vo(q, st, $e)).toVar();
@@ -8984,12 +8991,12 @@ function Su(e) {
8984
8991
  }).Else(() => {
8985
8992
  $e.assign(lt.normal);
8986
8993
  }), p(Xe.equal(0).and(Ie), () => {
8987
- let e = Pl({
8994
+ let e = Fl({
8988
8995
  worldPos: Qe,
8989
8996
  cameraProjectionMatrix: we,
8990
8997
  cameraViewMatrix: Te
8991
8998
  });
8992
- fc(l, He, U(0, 0, 1), e, U(0));
8999
+ pc(l, He, U(0, 0, 1), e, U(0));
8993
9000
  });
8994
9001
  let dt = M(1).toVar(), ft = M(1).toVar();
8995
9002
  p(tt.equal(1), () => {
@@ -9013,7 +9020,7 @@ function Su(e) {
9013
9020
  rt.assign(q.ior);
9014
9021
  }), p(tt.equal(3), () => {
9015
9022
  it.assign(q.ior);
9016
- }), kc(o, z, L(q.attenuationDistance.greaterThan(0), se(F(q.attenuationColor, U(.001))).negate().div(q.attenuationDistance), U(0))), Nc(o, z, U(0), M(0));
9023
+ }), Ac(o, z, L(q.attenuationDistance.greaterThan(0), se(F(q.attenuationColor, U(.001))).negate().div(q.attenuationDistance), U(0))), Pc(o, z, U(0), M(0));
9017
9024
  });
9018
9025
  }).Else(() => {
9019
9026
  p(tt.greaterThan(0), () => {
@@ -9031,7 +9038,7 @@ function Su(e) {
9031
9038
  it.assign(q.ior);
9032
9039
  });
9033
9040
  let e = Na.wrap(La(q.subsurfaceColor, q.subsurfaceRadius, q.subsurfaceRadiusScale)).toVar();
9034
- kc(o, z, e.sigmaT.sub(e.sigmaS)), Nc(o, z, e.sigmaS, E(q.subsurfaceAnisotropy, -.99, .99));
9041
+ Ac(o, z, e.sigmaT.sub(e.sigmaS)), Pc(o, z, e.sigmaS, E(q.subsurfaceAnisotropy, -.99, .99));
9035
9042
  });
9036
9043
  }).Else(() => {
9037
9044
  p(tt.greaterThan(0), () => {
@@ -9043,36 +9050,36 @@ function Su(e) {
9043
9050
  }), K.mulAssign(pt.throughput);
9044
9051
  let e = L(pt.entering, $e, $e.negate()), t = L(pt.didReflect, e, Be), n = Qe.add(t.mul(.001));
9045
9052
  p(pt.isAlphaSkip.not(), () => {
9046
- Fe.assign(Fe.bitOr(B(Fc.REDIRECTED)));
9047
- }), gc(o, z, n, Ye, Ze), _c(o, z, pt.direction, Fe), vc(o, z, K, lc(o, z)), yc(o, z, Ve), Dc(o, z, B(tt), B(at), nt, rt, it, B(ot.add(.5))), s.element(z).assign(Ue), h();
9048
- }), Fe.assign(Fe.bitOr(B(Fc.HAS_HIT_OPAQUE | Fc.REDIRECTED)));
9053
+ Fe.assign(Fe.bitOr(B(Ic.REDIRECTED)));
9054
+ }), _c(o, z, n, Ye, Ze), vc(o, z, pt.direction, Fe), yc(o, z, K, uc(o, z)), bc(o, z, Ve), Oc(o, z, B(tt), B(at), nt, rt, it, B(ot.add(.5))), s.element(z).assign(Ue), h();
9055
+ }), Fe.assign(Fe.bitOr(B(Ic.HAS_HIT_OPAQUE | Ic.REDIRECTED)));
9049
9056
  let mt = lt.emissive.toVar();
9050
9057
  p(ie(mt).greaterThan(0), () => {
9051
9058
  let e = L(G.not(), Ce, M(1)), t = M(1).toVar();
9052
9059
  Le && p(Me.equal(N(1)).and(ke.greaterThan(N(0))).and(Xe.greaterThan(0)), () => {
9053
- let e = lc(o, z);
9060
+ let e = uc(o, z);
9054
9061
  p(e.greaterThan(0), () => {
9055
9062
  let i = M(0).toVar();
9056
9063
  p(V.greaterThan(N(0)), () => {
9057
- i.assign(_u(N(Je), We, Be, ze, a, Ae, Ne, n));
9064
+ i.assign(vu(N(Je), We, Be, ze, a, Ae, Ne, n));
9058
9065
  }).Else(() => {
9059
- i.assign(au(N(Je), We, Be, ze, n, r, R));
9066
+ i.assign(ou(N(Je), We, Be, ze, n, r, R));
9060
9067
  }), t.assign(Xi({
9061
9068
  pdf1: e,
9062
9069
  pdf2: i
9063
9070
  }));
9064
9071
  });
9065
- }), Ve.assign(W(Ve.xyz.add(Nl(mt.mul(K).mul(e).mul(t), M(Xe), Ee, N(De))), Ve.w));
9072
+ }), Ve.assign(W(Ve.xyz.add(Pl(mt.mul(K).mul(e).mul(t), M(Xe), Ee, N(De))), Ve.w));
9066
9073
  });
9067
9074
  let ht = Be.negate().toVar();
9068
9075
  p(A($e, ht).lessThan(0), () => {
9069
9076
  $e.assign($e.negate());
9070
- }), p(Fe.bitAnd(B(Fc.AUX_LOCKED)).equal(B(0)).and(Ie), () => {
9071
- let e = mc(pc(l, He)).w;
9072
- fc(l, He, $e, e, ut.xyz);
9077
+ }), p(Fe.bitAnd(B(Ic.AUX_LOCKED)).equal(B(0)).and(Ie), () => {
9078
+ let e = hc(mc(l, He)).w;
9079
+ pc(l, He, $e, e, ut.xyz);
9073
9080
  let t = q.metalness.greaterThan(.7).and(q.roughness.lessThan(.3)), n = q.transmission.greaterThan(.5);
9074
9081
  p(t.or(n).not(), () => {
9075
- Fe.assign(Fe.bitOr(B(Fc.AUX_LOCKED)));
9082
+ Fe.assign(Fe.bitOr(B(Ic.AUX_LOCKED)));
9076
9083
  });
9077
9084
  });
9078
9085
  let gt = Ai.wrap(ra(q.metalness, q.roughness, q.transmission, q.clearcoat, q.emissive, q.subsurface)).toVar(), _t = N(Oe.x).toVar(), vt = Yn(H(M(N(He).mod(_t)).add(.5), M(N(He).div(_t)).add(.5)), N(0), Xe, Ue, N(-1), Oe, De).toVar(), yt = Ti({
@@ -9110,67 +9117,67 @@ function Su(e) {
9110
9117
  triangleIndex: N(0),
9111
9118
  boxTests: N(0),
9112
9119
  triTests: N(0)
9113
- }), n = Il.wrap(Ll(e, t, q, vt, Ue));
9120
+ }), n = Ll.wrap(Rl(e, t, q, vt, Ue));
9114
9121
  xt.assign(n.L), St.assign(n.brdf), Ct.assign(n.pdf);
9115
9122
  }).Else(() => {
9116
- let e = wi.wrap(Ml(ht, $e, q, vt, Ue, gt, !1, yt, !1, bt));
9123
+ let e = wi.wrap(Nl(ht, $e, q, vt, Ue, gt, !1, yt, !1, bt));
9117
9124
  xt.assign(e.direction), St.assign(e.value), Ct.assign(e.pdf);
9118
9125
  });
9119
- let wt = Si.wrap(Tl(Qe, $e, q, ht, xt, Ct, St, Xe, Ue, P, ae, oe, ce, le, ue, de, fe, t, n, r, g, _, v, i, ee, te, ne, y, T(!1))).shadowed.toVar(), Tt = L(Xe.greaterThan(0), Ce, M(1));
9120
- Ve.assign(W(Ve.xyz.add(Nl(K.mul(wt).mul(Tt), M(Xe), Ee, N(De))), Ve.w)), Le && p(Me.equal(N(1)).and(ke.greaterThan(N(0))), () => {
9121
- let e = f(([e, i, a]) => wo(e, i, a, tl, t, n, r));
9126
+ let wt = Si.wrap(El(Qe, $e, q, ht, xt, Ct, St, Xe, Ue, P, ae, oe, ce, le, ue, de, fe, t, n, r, g, _, v, i, ee, te, ne, y, T(!1))).shadowed.toVar(), Tt = L(Xe.greaterThan(0), Ce, M(1));
9127
+ Ve.assign(W(Ve.xyz.add(Pl(K.mul(wt).mul(Tt), M(Xe), Ee, N(De))), Ve.w)), Le && p(Me.equal(N(1)).and(ke.greaterThan(N(0))), () => {
9128
+ let e = f(([e, i, a]) => wo(e, i, a, nl, t, n, r));
9122
9129
  p(V.greaterThan(N(0)), () => {
9123
- let t = Wl.wrap(gu(Qe, $e, Ue, a, a, Ae, n));
9130
+ let t = Gl.wrap(_u(Qe, $e, Ue, a, a, Ae, n));
9124
9131
  p(Xe.greaterThan(N(1)).and(q.roughness.greaterThan(.9)).and(q.metalness.lessThan(.1)).not().and(t.valid).and(t.pdf.greaterThan(0)), () => {
9125
9132
  let n = F(M(0), A($e, t.direction));
9126
9133
  p(n.greaterThan(0), () => {
9127
9134
  let r = To(Qe, $e, q), i = Qe.add(r), a = t.distance.sub(.001), o = e(i, t.direction, a);
9128
9135
  p(o.greaterThan(0), () => {
9129
- let e = pl(ht, t.direction, $e, q), r = Cl(ht, t.direction, $e, q), i = L(r.greaterThan(0), Xi({
9136
+ let e = ml(ht, t.direction, $e, q), r = wl(ht, t.direction, $e, q), i = L(r.greaterThan(0), Xi({
9130
9137
  pdf1: t.pdf,
9131
9138
  pdf2: r
9132
9139
  }), M(1)), a = t.emission.mul(e).mul(n).div(t.pdf).mul(o).mul(je).mul(i);
9133
- Ve.assign(W(Ve.xyz.add(Nl(a.mul(K).mul(Tt), M(Xe), Ee, N(De))), Ve.w));
9140
+ Ve.assign(W(Ve.xyz.add(Pl(a.mul(K).mul(Tt), M(Xe), Ee, N(De))), Ve.w));
9134
9141
  });
9135
9142
  });
9136
9143
  });
9137
9144
  }).Else(() => {
9138
- let t = lu(Qe, $e, ht, q, Xe, Ue, je, a, Ae, ke, R, n, e, To);
9139
- Ve.assign(W(Ve.xyz.add(Nl(t.mul(K).mul(Tt), M(Xe), Ee, N(De))), Ve.w));
9145
+ let t = uu(Qe, $e, ht, q, Xe, Ue, je, a, Ae, ke, R, n, e, To);
9146
+ Ve.assign(W(Ve.xyz.add(Pl(t.mul(K).mul(Tt), M(Xe), Ee, N(De))), Ve.w));
9140
9147
  });
9141
9148
  });
9142
- let Et = Ei.wrap(Da(q, Xe, gt)).toVar(), Dt = Fo.wrap(jl(ht, $e, q, xt, Ct, St, Ue, Et)).toVar(), Ot = Dt.direction.toVar(), kt = F(Dt.combinedPdf, .001).toVar();
9149
+ let Et = Ei.wrap(Da(q, Xe, gt)).toVar(), Dt = Fo.wrap(Ml(ht, $e, q, xt, Ct, St, Ue, Et)).toVar(), Ot = Dt.direction.toVar(), kt = F(Dt.combinedPdf, .001).toVar();
9143
9150
  K.mulAssign(Dt.throughput);
9144
- let At = Fl(Xe, K, gt, Ot, Ue, y, b).toVar();
9151
+ let At = Il(Xe, K, gt, Ot, Ue, y, b).toVar();
9145
9152
  p(At.lessThanEqual(0), () => {
9146
- yc(o, z, Ve), _c(o, z, Be, Fe.bitAnd(B(~Fc.ACTIVE))), s.element(z).assign(Ue), h();
9153
+ bc(o, z, Ve), vc(o, z, Be, Fe.bitAnd(B(~Ic.ACTIVE))), s.element(z).assign(Ue), h();
9147
9154
  }), K.divAssign(At), p(Ye.greaterThanEqual(pe), () => {
9148
- yc(o, z, Ve), _c(o, z, Be, Fe.bitAnd(B(~Fc.ACTIVE))), s.element(z).assign(Ue), h();
9149
- }), gc(o, z, Qe.add($e.mul(.001)), Ye.add(1), Ze), _c(o, z, Ot, Fe), vc(o, z, K, kt), yc(o, z, Ve), Dc(o, z, B(tt), B(at), nt, rt, it, B(ot.add(.5))), s.element(z).assign(Ue);
9155
+ bc(o, z, Ve), vc(o, z, Be, Fe.bitAnd(B(~Ic.ACTIVE))), s.element(z).assign(Ue), h();
9156
+ }), _c(o, z, Qe.add($e.mul(.001)), Ye.add(1), Ze), vc(o, z, Ot, Fe), yc(o, z, K, kt), bc(o, z, Ve), Oc(o, z, B(tt), B(at), nt, rt, it, B(ot.add(.5))), s.element(z).assign(Ue);
9150
9157
  });
9151
9158
  }
9152
9159
  //#endregion
9153
9160
  //#region src/TSL/CompactKernel.js
9154
- function Cu(e) {
9161
+ function wu(e) {
9155
9162
  let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
9156
9163
  return f(() => {
9157
- let e = re, o = i ? S(i.element(B(Pc.ENTERING_COUNT))) : a;
9164
+ let e = re, o = i ? S(i.element(B(Fc.ENTERING_COUNT))) : a;
9158
9165
  p(e.greaterThanEqual(o), () => {
9159
9166
  h();
9160
9167
  });
9161
9168
  let s = n.element(e);
9162
- p(sc(t, s).bitAnd(B(Fc.ACTIVE)).notEqual(B(0)), () => {
9163
- let e = x(i.element(B(Pc.ACTIVE_RAY_COUNT)), B(1));
9169
+ p(cc(t, s).bitAnd(B(Ic.ACTIVE)).notEqual(B(0)), () => {
9170
+ let e = x(i.element(B(Fc.ACTIVE_RAY_COUNT)), B(1));
9164
9171
  r.element(e).assign(s);
9165
9172
  });
9166
9173
  });
9167
9174
  }
9168
- function wu(e) {
9175
+ function Tu(e) {
9169
9176
  let { rayBufferRO: t, activeIndicesReadRO: n, activeIndicesWriteRW: r, counters: i, currentActiveCount: a } = e;
9170
9177
  return f(() => {
9171
- let e = re, o = i ? S(i.element(B(Pc.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = sc(t, c), u = s.and(l.bitAnd(B(Fc.ACTIVE)).notEqual(B(0))), d = L(u, B(1), B(0)), f = Oe(d).toVar(), m = Ee(d).toVar(), h = Oe(B(1)).toVar(), g = B(0).toVar();
9178
+ let e = re, o = i ? S(i.element(B(Fc.ENTERING_COUNT))) : a, s = e.lessThan(o), c = n.element(e), l = cc(t, c), u = s.and(l.bitAnd(B(Ic.ACTIVE)).notEqual(B(0))), d = L(u, B(1), B(0)), f = Oe(d).toVar(), m = Ee(d).toVar(), h = Oe(B(1)).toVar(), g = B(0).toVar();
9172
9179
  p(h.equal(B(0)), () => {
9173
- g.assign(x(i.element(B(Pc.ACTIVE_RAY_COUNT)), m));
9180
+ g.assign(x(i.element(B(Fc.ACTIVE_RAY_COUNT)), m));
9174
9181
  });
9175
9182
  let _ = De(g, B(0)).toVar();
9176
9183
  p(u, () => {
@@ -9178,16 +9185,16 @@ function wu(e) {
9178
9185
  });
9179
9186
  });
9180
9187
  }
9181
- var Tu = /* @__PURE__ */ G("\n fn nanInfToRed( c: vec3f ) -> vec3f {\n let isNan = c.x != c.x || c.y != c.y || c.z != c.z;\n let isInf = abs( c.x ) > 1e30f || abs( c.y ) > 1e30f || abs( c.z ) > 1e30f;\n if ( isNan || isInf ) { return vec3f( 1.0f, 0.0f, 0.0f ); }\n return vec3f( 0.0f );\n }\n");
9182
- function Eu(e) {
9188
+ var Eu = /* @__PURE__ */ G("\n fn nanInfToRed( c: vec3f ) -> vec3f {\n let isNan = c.x != c.x || c.y != c.y || c.z != c.z;\n let isInf = abs( c.x ) > 1e30f || abs( c.y ) > 1e30f || abs( c.z ) > 1e30f;\n if ( isNan || isInf ) { return vec3f( 1.0f, 0.0f, 0.0f ); }\n return vec3f( 0.0f );\n }\n");
9189
+ function Du(e) {
9183
9190
  let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, transparentBackground: m, prevAccumTexture: h, prevAlbedoTexture: g, renderWidth: _, renderHeight: v, visMode: y, auxGBufferEnabled: b } = e, x = b.greaterThan(B(0));
9184
9191
  return f(() => {
9185
9192
  let e = N(K.x).mul(16).add(N(oe.x)), f = N(K.y).mul(16).add(N(oe.y));
9186
9193
  p(e.lessThan(_).and(f.lessThan(v)), () => {
9187
- let _ = B(f.mul(N(o.x)).add(e)), v = uc(t, _), b = v.xyz.toVar(), S = L(m, v.w, M(1)).toVar(), C = W(0).toVar(), w = W(0).xyz.toVar();
9194
+ let _ = B(f.mul(N(o.x)).add(e)), v = dc(t, _), b = v.xyz.toVar(), S = L(m, v.w, M(1)).toVar(), C = W(0).toVar(), w = W(0).xyz.toVar();
9188
9195
  p(x, () => {
9189
- let e = pc(n, _);
9190
- C.assign(mc(e)), w.assign(W(hc(e), 0).xyz);
9196
+ let e = mc(n, _);
9197
+ C.assign(hc(e)), w.assign(W(gc(e), 0).xyz);
9191
9198
  });
9192
9199
  let T = H(M(e).add(.5), M(f).add(.5)).div(o);
9193
9200
  p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(y.notEqual(N(11))), () => {
@@ -9198,7 +9205,7 @@ function Eu(e) {
9198
9205
  S.assign(ue(e.w, v.w, u));
9199
9206
  });
9200
9207
  }), p(y.equal(N(11)), () => {
9201
- b.assign(Tu(b));
9208
+ b.assign(Eu(b));
9202
9209
  });
9203
9210
  let E = Le(B(e), B(f));
9204
9211
  z(r, E, W(b, S)).toWriteOnly(), p(x, () => {
@@ -9209,11 +9216,11 @@ function Eu(e) {
9209
9216
  }
9210
9217
  //#endregion
9211
9218
  //#region src/TSL/Debugger.js
9212
- var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), Ou = /* @__PURE__ */ G("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), ku = /* @__PURE__ */ G("\n fn computeNDCDepthLocal( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), Au = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g]) => {
9219
+ var Ou = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n return vec3f( 1.0f - depth );\n }\n"), ku = /* @__PURE__ */ G("\n fn visualizeNormal( normal: vec3f ) -> vec3f {\n return normal * 0.5f + 0.5f;\n }\n"), Au = /* @__PURE__ */ G("\n fn computeNDCDepthLocal( worldPos: vec3f, cameraProjectionMatrix: mat4x4f, cameraViewMatrix: mat4x4f ) -> f32 {\n let clipPos = cameraProjectionMatrix * cameraViewMatrix * vec4f( worldPos, 1.0f );\n let ndcDepth = clipPos.z / clipPos.w * 0.5f + 0.5f;\n return clamp( ndcDepth, 0.0f, 1.0f );\n }\n"), ju = f(([e, t, n, r, i, a, o, s, c, l, u, d, f, m, h, g]) => {
9213
9220
  let _ = W(1, 0, 1, 1).toVar(), v = yi({
9214
9221
  origin: e,
9215
9222
  direction: t
9216
- }), y = Ci.wrap(el(v, n, r).toVar());
9223
+ }), y = Ci.wrap(tl(v, n, r).toVar());
9217
9224
  return p(l.equal(N(7)), () => {
9218
9225
  let e = M(y.triTests).div(u);
9219
9226
  _.assign(L(e.lessThan(1), W(U(e), 1), W(1, 0, 0, 1)));
@@ -9222,7 +9229,7 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9222
9229
  _.assign(L(e.lessThan(1), W(U(e), 1), W(1, 0, 0, 1)));
9223
9230
  }), p(l.equal(N(10)), () => {
9224
9231
  p(c, () => {
9225
- let e = ll({
9232
+ let e = ul({
9226
9233
  tex: a,
9227
9234
  samp: ve(a),
9228
9235
  direction: t,
@@ -9270,18 +9277,18 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9270
9277
  _.assign(W(.5, .5, 1, 1));
9271
9278
  }).Else(() => {
9272
9279
  let e = bi.wrap(oa(y.materialIndex, i)).toVar(), t = I(ki.wrap(vo(e, y.uv, y.normal)).toVar().normal);
9273
- _.assign(W(Ou({ normal: t }), 1));
9280
+ _.assign(W(ku({ normal: t }), 1));
9274
9281
  });
9275
9282
  }), p(l.equal(N(2)), () => {
9276
9283
  p(y.didHit.not(), () => {
9277
9284
  _.assign(W(U(1), 1));
9278
9285
  }).Else(() => {
9279
- let e = ku({
9286
+ let e = Au({
9280
9287
  worldPos: y.hitPoint,
9281
9288
  cameraProjectionMatrix: m,
9282
9289
  cameraViewMatrix: h
9283
9290
  });
9284
- _.assign(W(Du({ depth: e }), 1));
9291
+ _.assign(W(Ou({ depth: e }), 1));
9285
9292
  });
9286
9293
  }), p(l.equal(N(3)), () => {
9287
9294
  p(y.didHit.not(), () => {
@@ -9300,10 +9307,10 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9300
9307
  }).toVar(), h = yi({
9301
9308
  origin: y.hitPoint.add(u.mul(.001)),
9302
9309
  direction: m
9303
- }), v = Ci.wrap(el(h, n, r).toVar()), b = U(0).toVar();
9310
+ }), v = Ci.wrap(tl(h, n, r).toVar()), b = U(0).toVar();
9304
9311
  p(v.didHit.not(), () => {
9305
9312
  p(c, () => {
9306
- b.assign(ll({
9313
+ b.assign(ul({
9307
9314
  tex: a,
9308
9315
  samp: ve(a),
9309
9316
  direction: m,
@@ -9315,7 +9322,7 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9315
9322
  }).Else(() => {
9316
9323
  let e = bi.wrap(oa(v.materialIndex, i)).toVar(), t = ki.wrap(vo(e, v.uv, v.normal)).toVar();
9317
9324
  b.assign(t.emissive), p(c, () => {
9318
- let e = I(t.normal).toVar(), n = ll({
9325
+ let e = I(t.normal).toVar(), n = ul({
9319
9326
  tex: a,
9320
9327
  samp: ve(a),
9321
9328
  direction: e,
@@ -9331,7 +9338,7 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9331
9338
  });
9332
9339
  }), p(l.equal(N(6)), () => {
9333
9340
  p(y.didHit, () => {
9334
- let e = y.normal.toVar(), n = I(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r = ll({
9341
+ let e = y.normal.toVar(), n = I(t.sub(e.mul(A(t, e).mul(2)))).toVar(), r = ul({
9335
9342
  tex: a,
9336
9343
  samp: ve(a),
9337
9344
  direction: n,
@@ -9341,7 +9348,7 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9341
9348
  }).xyz, i = r.div(r.add(1));
9342
9349
  _.assign(W(i, 1));
9343
9350
  }).Else(() => {
9344
- let e = ll({
9351
+ let e = ul({
9345
9352
  tex: a,
9346
9353
  samp: ve(a),
9347
9354
  direction: t,
@@ -9353,41 +9360,41 @@ var Du = /* @__PURE__ */ G("\n fn visualizeDepth( depth: f32 ) -> vec3f {\n ret
9353
9360
  });
9354
9361
  }), _;
9355
9362
  });
9356
- function ju(e) {
9363
+ function Mu(e) {
9357
9364
  let { writeColorTex: t, writeNDTex: n, writeAlbedoTex: r, resolution: i, renderWidth: a, renderHeight: o, cameraWorldMatrix: s, cameraProjectionMatrixInverse: c, cameraProjectionMatrix: l, cameraViewMatrix: u, enableDOF: d, focalLength: m, aperture: h, focusDistance: g, sceneScale: _, apertureScale: v, anamorphicRatio: y, bvhBuffer: b, triangleBuffer: x, materialBuffer: S, envTexture: C, environmentMatrix: w, environmentIntensity: T, enableEnvironmentLight: E, visMode: D, debugVisScale: O, frame: k } = e;
9358
9365
  return f(() => {
9359
9366
  let e = N(K.x).mul(16).add(N(oe.x)), f = N(K.y).mul(16).add(N(oe.y));
9360
9367
  p(e.lessThan(a).and(f.lessThan(o)), () => {
9361
9368
  let a = H(M(e).add(.5), M(f).add(.5)), o = Bn({ state: B(f.mul(N(i.x)).add(e)).add(B(1)) }).toVar(), A = a.div(i).mul(2).sub(1).toVar();
9362
9369
  A.y.assign(A.y.negate());
9363
- let j = yi.wrap(nl(A, o, s, c, d, m, h, g, _, v, y)), ee = W(1, 0, 1, 1).toVar();
9370
+ let j = yi.wrap(rl(A, o, s, c, d, m, h, g, _, v, y)), ee = W(1, 0, 1, 1).toVar();
9364
9371
  p(D.equal(N(9)), () => {
9365
9372
  let e = Xn(a, N(0), N(1), o, i, k);
9366
9373
  ee.assign(W(e, 1, 1));
9367
9374
  }).Else(() => {
9368
- ee.assign(Au(j.origin, j.direction, b, x, S, C, w, T, E, D, O, a, i, l, u, k));
9375
+ ee.assign(ju(j.origin, j.direction, b, x, S, C, w, T, E, D, O, a, i, l, u, k));
9369
9376
  });
9370
9377
  let te = Le(B(e), B(f));
9371
9378
  z(t, te, ee).toWriteOnly(), z(n, te, W(.5, .5, 1, 1)).toWriteOnly(), z(r, te, W(ee.xyz, 1)).toWriteOnly();
9372
9379
  });
9373
9380
  });
9374
9381
  }
9375
- function Mu({ sortGlobalHistogram: e, bins: t = 256 }) {
9382
+ function Nu({ sortGlobalHistogram: e, bins: t = 256 }) {
9376
9383
  return f(() => {
9377
9384
  p(re.lessThan(B(t)), () => {
9378
9385
  C(e.element(re), B(0));
9379
9386
  });
9380
9387
  });
9381
9388
  }
9382
- function Nu({ hitBufferRO: e, activeIndicesReadRO: t, sortGlobalHistogram: n, counters: r, bins: i = 256 }) {
9389
+ function Pu({ hitBufferRO: e, activeIndicesReadRO: t, sortGlobalHistogram: n, counters: r, bins: i = 256 }) {
9383
9390
  return f(() => {
9384
9391
  let a = re, o = oe.x, s = Dn("uint", i);
9385
9392
  p(o.lessThan(B(i)), () => {
9386
9393
  C(s.element(o), B(0));
9387
9394
  }), Be();
9388
- let c = S(r.element(B(Pc.ENTERING_COUNT)));
9395
+ let c = S(r.element(B(Fc.ENTERING_COUNT)));
9389
9396
  p(a.lessThan(c), () => {
9390
- let n = B(wc(e, t.element(a))).clamp(B(0), B(i - 1));
9397
+ let n = B(Tc(e, t.element(a))).clamp(B(0), B(i - 1));
9391
9398
  x(s.element(n), B(1));
9392
9399
  }), Be(), p(o.lessThan(B(i)), () => {
9393
9400
  let e = S(s.element(o));
@@ -9397,7 +9404,7 @@ function Nu({ hitBufferRO: e, activeIndicesReadRO: t, sortGlobalHistogram: n, co
9397
9404
  });
9398
9405
  });
9399
9406
  }
9400
- function Pu({ sortGlobalHistogram: e, bins: t = 256 }) {
9407
+ function Fu({ sortGlobalHistogram: e, bins: t = 256 }) {
9401
9408
  return f(() => {
9402
9409
  p(re.equal(B(0)), () => {
9403
9410
  let n = B(0).toVar();
@@ -9412,20 +9419,20 @@ function Pu({ sortGlobalHistogram: e, bins: t = 256 }) {
9412
9419
  });
9413
9420
  });
9414
9421
  }
9415
- function Fu({ hitBufferRO: e, activeIndicesReadRO: t, sortedIndicesRW: n, sortGlobalHistogram: r, counters: i, bins: a = 256 }) {
9422
+ function Iu({ hitBufferRO: e, activeIndicesReadRO: t, sortedIndicesRW: n, sortGlobalHistogram: r, counters: i, bins: a = 256 }) {
9416
9423
  return f(() => {
9417
- let o = re, s = S(i.element(B(Pc.ENTERING_COUNT)));
9424
+ let o = re, s = S(i.element(B(Fc.ENTERING_COUNT)));
9418
9425
  p(o.lessThan(s), () => {
9419
- let i = t.element(o), s = B(wc(e, i)).clamp(B(0), B(a - 1)), c = x(r.element(s), B(1));
9426
+ let i = t.element(o), s = B(Tc(e, i)).clamp(B(0), B(a - 1)), c = x(r.element(s), B(1));
9420
9427
  n.element(c).assign(i);
9421
9428
  });
9422
9429
  });
9423
9430
  }
9424
9431
  //#endregion
9425
9432
  //#region src/Stages/PathTracer.js
9426
- var Iu = class extends $s {
9433
+ var Lu = class extends $s {
9427
9434
  constructor(e, t, n, r = {}) {
9428
- super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new Hc(this.renderer), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
9435
+ super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._useDynamicDispatch = !0, this._sortMaterials = !1, this._useSubgroupCompact = !1, this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackPending = !1, this._readbackEveryNFrames = 4, this._readbackFrameCounter = 0, this._readbackGeneration = 0, this._bounceEarlyExitThreshold = 100, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this.vramTracker = new Uc(this.renderer), this._registerVRAMProviders(), console.log("PathTracer: initialized (wavefront)");
9429
9436
  }
9430
9437
  _registerVRAMProviders() {
9431
9438
  let e = this.vramTracker;
@@ -9558,7 +9565,7 @@ var Iu = class extends $s {
9558
9565
  let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
9559
9566
  if (n === e && r === t || !(this.materialData?.materialCount > 0)) return;
9560
9567
  this._lastBounceCounts = null, this._lastBounceCountsBudget = -1, this._readbackFrameCounter = 0, this._readbackGeneration++;
9561
- let i = ic.requiredCapacity(n * r);
9568
+ let i = ac.requiredCapacity(n * r);
9562
9569
  !this._packedBuffers || i > this._packedBuffers.capacity ? (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels()) : this._resizeWavefrontInPlace(n, r);
9563
9570
  }
9564
9571
  _resizeWavefrontInPlace(e, t) {
@@ -9573,15 +9580,15 @@ var Iu = class extends $s {
9573
9580
  let e = this.shaderBuilder.getSceneTextureNodes();
9574
9581
  if (!e) return;
9575
9582
  let t = this.storageTextures.renderWidth, n = this.storageTextures.renderHeight, r = t * n;
9576
- this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(r / 1e3))), this._packedBuffers ? this._packedBuffers.resize(r) : this._packedBuffers = new ic(r);
9577
- let i = ic.requiredCapacity(r) * 1;
9578
- this._gBufferAttr = new o(new Uint32Array(i * 4), 4);
9583
+ this._bounceEarlyExitThreshold !== -1 && (this._bounceEarlyExitThreshold = Math.max(100, Math.floor(r / 1e3))), this._packedBuffers ? this._packedBuffers.resize(r) : this._packedBuffers = new ac(r, this.renderer);
9584
+ let i = ac.requiredCapacity(r) * 1;
9585
+ ic(this.renderer, this._gBufferAttr), this._gBufferAttr = new o(new Uint32Array(i * 4), 4);
9579
9586
  let a = we(this._gBufferAttr, "uvec4"), s = we(this._gBufferAttr, "uvec4").toReadOnly();
9580
- this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new Ic(this._packedBuffers.capacity), this._kernelManager ||= new Wc(this.renderer);
9587
+ this._queueManager ? this._queueManager.resize(this._packedBuffers.capacity) : this._queueManager = new Lc(this._packedBuffers.capacity, this.renderer), this._kernelManager ||= new Gc(this.renderer);
9581
9588
  let c = this._packedBuffers, l = this._queueManager;
9582
9589
  this._wfRenderWidth.value = t, this._wfRenderHeight.value = n, this._wfMaxRayCount.value = r;
9583
9590
  let u = this.shaderBuilder.prevColorTexNode, d = this.shaderBuilder.prevAlbedoTexNode, m = this.storageTextures.getWriteTextures(), g = l.getCounters(), _ = f(() => {
9584
- C(g.element(B(Pc.ACTIVE_RAY_COUNT)), B(0));
9591
+ C(g.element(B(Fc.ACTIVE_RAY_COUNT)), B(0));
9585
9592
  });
9586
9593
  this._kernelManager.register("resetCounters", _().compute([
9587
9594
  1,
@@ -9593,7 +9600,7 @@ var Iu = class extends $s {
9593
9600
  1
9594
9601
  ]));
9595
9602
  let v = f(() => {
9596
- C(g.element(B(Pc.ACTIVE_RAY_COUNT)), B(0));
9603
+ C(g.element(B(Fc.ACTIVE_RAY_COUNT)), B(0));
9597
9604
  });
9598
9605
  this._kernelManager.register("resetActiveCounter", v().compute([
9599
9606
  1,
@@ -9605,8 +9612,8 @@ var Iu = class extends $s {
9605
9612
  1
9606
9613
  ]));
9607
9614
  let y = l.getBounceCounts(), b = this._wfCurrentBounce, x = f(() => {
9608
- let e = S(g.element(B(Pc.ACTIVE_RAY_COUNT))), t = B(b).clamp(B(0), B(l.MAX_BOUNCE_SNAPSHOTS - 1));
9609
- y.element(t).assign(e), C(g.element(B(Pc.ENTERING_COUNT)), e);
9615
+ let e = S(g.element(B(Fc.ACTIVE_RAY_COUNT))), t = B(b).clamp(B(0), B(l.MAX_BOUNCE_SNAPSHOTS - 1));
9616
+ y.element(t).assign(e), C(g.element(B(Fc.ENTERING_COUNT)), e);
9610
9617
  });
9611
9618
  this._kernelManager.register("snapshotBounceCount", x().compute([
9612
9619
  1,
@@ -9620,7 +9627,7 @@ var Iu = class extends $s {
9620
9627
  let w = l.activeIndices.a, T = f(() => {
9621
9628
  let e = re;
9622
9629
  w.element(e).assign(e), p(e.equal(B(0)), () => {
9623
- C(g.element(B(Pc.ACTIVE_RAY_COUNT)), this._wfMaxRayCount), C(g.element(B(Pc.ENTERING_COUNT)), this._wfMaxRayCount);
9630
+ C(g.element(B(Fc.ACTIVE_RAY_COUNT)), this._wfMaxRayCount), C(g.element(B(Fc.ENTERING_COUNT)), this._wfMaxRayCount);
9624
9631
  });
9625
9632
  });
9626
9633
  this._kernelManager.register("initActiveIndices", T().compute([
@@ -9632,7 +9639,7 @@ var Iu = class extends $s {
9632
9639
  1,
9633
9640
  1
9634
9641
  ]));
9635
- let E = rl({
9642
+ let E = il({
9636
9643
  rayBufferRW: c.rayBuffer.rw,
9637
9644
  rngBufferRW: c.rngBuffer.rw,
9638
9645
  gBufferRW: a,
@@ -9671,7 +9678,7 @@ var Iu = class extends $s {
9671
9678
  srgbBuckets: te,
9672
9679
  linearBuckets: ne
9673
9680
  }, this._sortMaterials = (X.wavefrontSortMaterials ?? !1) && (this.materialData?.materialCount ?? 0) > 8;
9674
- let P = il({
9681
+ let P = al({
9675
9682
  bvhBuffer: D,
9676
9683
  triangleBuffer: O,
9677
9684
  materialBuffer: k,
@@ -9691,7 +9698,7 @@ var Iu = class extends $s {
9691
9698
  1
9692
9699
  ])), this._sortMaterials) {
9693
9700
  let e = l.getSortGlobalHistogram(), t = Math.min(256, this.materialData?.materialCount ?? 256);
9694
- this._kernelManager.register("resetGlobalHist", Mu({
9701
+ this._kernelManager.register("resetGlobalHist", Nu({
9695
9702
  sortGlobalHistogram: e,
9696
9703
  bins: t
9697
9704
  })().compute([
@@ -9702,7 +9709,7 @@ var Iu = class extends $s {
9702
9709
  256,
9703
9710
  1,
9704
9711
  1
9705
- ])), this._kernelManager.register("globalHist", Nu({
9712
+ ])), this._kernelManager.register("globalHist", Pu({
9706
9713
  hitBufferRO: c.hitBuffer.ro,
9707
9714
  activeIndicesReadRO: l.getActiveReadRO(),
9708
9715
  sortGlobalHistogram: e,
@@ -9716,7 +9723,7 @@ var Iu = class extends $s {
9716
9723
  256,
9717
9724
  1,
9718
9725
  1
9719
- ])), this._kernelManager.register("globalPrefix", Pu({
9726
+ ])), this._kernelManager.register("globalPrefix", Fu({
9720
9727
  sortGlobalHistogram: e,
9721
9728
  bins: t
9722
9729
  })().compute([
@@ -9727,7 +9734,7 @@ var Iu = class extends $s {
9727
9734
  1,
9728
9735
  1,
9729
9736
  1
9730
- ])), this._kernelManager.register("globalScatter", Fu({
9737
+ ])), this._kernelManager.register("globalScatter", Iu({
9731
9738
  hitBufferRO: c.hitBuffer.ro,
9732
9739
  activeIndicesReadRO: l.getActiveReadRO(),
9733
9740
  sortedIndicesRW: l.getSortedRW(),
@@ -9744,7 +9751,7 @@ var Iu = class extends $s {
9744
9751
  1
9745
9752
  ]));
9746
9753
  }
9747
- let ie = Su({
9754
+ let ie = Cu({
9748
9755
  gBufferRW: a,
9749
9756
  envCompensationDelta: this.envCompensationDelta,
9750
9757
  bvhBuffer: D,
@@ -9815,7 +9822,7 @@ var Iu = class extends $s {
9815
9822
  ]));
9816
9823
  let ae = this._useSubgroupCompact && (this.renderer.hasFeature ? this.renderer.hasFeature("subgroups") : !1);
9817
9824
  this._compactIsSubgroup = ae;
9818
- let oe = (ae ? wu : Cu)({
9825
+ let oe = (ae ? Tu : wu)({
9819
9826
  rayBufferRO: c.rayBuffer.ro,
9820
9827
  activeIndicesReadRO: l.getActiveReadRO(),
9821
9828
  activeIndicesWriteRW: l.getActiveWrite(),
@@ -9832,7 +9839,7 @@ var Iu = class extends $s {
9832
9839
  1
9833
9840
  ]));
9834
9841
  let se = f(() => {
9835
- C(g.element(B(Pc.ENTERING_COUNT)), this._wfMaxRayCount);
9842
+ C(g.element(B(Fc.ENTERING_COUNT)), this._wfMaxRayCount);
9836
9843
  });
9837
9844
  this._kernelManager.register("enterFull", se().compute([
9838
9845
  1,
@@ -9845,7 +9852,7 @@ var Iu = class extends $s {
9845
9852
  ]));
9846
9853
  let ce = l.activeIndicesRO.b, F = l.activeIndices.a, le = f(() => {
9847
9854
  let e = re;
9848
- p(e.greaterThanEqual(S(g.element(B(Pc.ACTIVE_RAY_COUNT)))), () => {
9855
+ p(e.greaterThanEqual(S(g.element(B(Fc.ACTIVE_RAY_COUNT)))), () => {
9849
9856
  h();
9850
9857
  }), F.element(e).assign(ce.element(e));
9851
9858
  });
@@ -9858,7 +9865,7 @@ var Iu = class extends $s {
9858
9865
  1,
9859
9866
  1
9860
9867
  ]));
9861
- let ue = Eu({
9868
+ let ue = Du({
9862
9869
  rayBufferRO: c.rayBuffer.ro,
9863
9870
  gBufferRO: s,
9864
9871
  writeColorTex: m.color,
@@ -9887,7 +9894,7 @@ var Iu = class extends $s {
9887
9894
  16,
9888
9895
  1
9889
9896
  ]));
9890
- let de = ju({
9897
+ let de = Mu({
9891
9898
  writeColorTex: m.color,
9892
9899
  writeNDTex: m.normalDepth,
9893
9900
  writeAlbedoTex: m.albedo,
@@ -9945,7 +9952,7 @@ var Iu = class extends $s {
9945
9952
  dispose() {
9946
9953
  super.dispose(), this._packedBuffers?.dispose(), this._queueManager?.dispose(), this._kernelManager?.dispose(), this._gBufferAttr?.dispose?.(), this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._wavefrontReady = !1;
9947
9954
  }
9948
- }, Lu = class extends $n {
9955
+ }, Ru = class extends $n {
9949
9956
  constructor(e, t = {}) {
9950
9957
  super("NormalDepth", {
9951
9958
  ...t,
@@ -9993,14 +10000,14 @@ var Iu = class extends $s {
9993
10000
  let d = U(M(l).add(.5).div(a).mul(2).sub(1), M(u).add(.5).div(o).mul(2).sub(1).negate(), 1), f = i.mul(W(d, 1)), m = I(ce(r[0].xyz, r[1].xyz, r[2].xyz).mul(f.xyz.div(f.w))), h = yi({
9994
10001
  origin: U(r[3]),
9995
10002
  direction: m
9996
- }), g = Ci.wrap(el(h, t, e)), _ = g.normal.mul(.5).add(.5), v = g.dst, y = g.didHit.select(W(_, v), W(0, 0, 0, M(1e6)));
10003
+ }), g = Ci.wrap(tl(h, t, e)), _ = g.normal.mul(.5).add(.5), v = g.dst, y = g.didHit.select(W(_, v), W(0, 0, 0, M(65504)));
9997
10004
  z(s, Le(B(l), B(u)), y).toWriteOnly();
9998
10005
  let b = g.normal.toVar();
9999
10006
  p(g.didHit, () => {
10000
10007
  let e = bi.wrap(oa(g.materialIndex, n)).toVar(), t = ji.wrap(fo(g.uv, e)).toVar(), r = ho(g.normal, e, t).toVar();
10001
10008
  b.assign(go(r, e, t));
10002
10009
  });
10003
- let x = g.didHit.select(W(b.mul(.5).add(.5), v), W(0, 0, 0, M(1e6)));
10010
+ let x = g.didHit.select(W(b.mul(.5).add(.5), v), W(0, 0, 0, M(65504)));
10004
10011
  z(c, Le(B(l), B(u)), x).toWriteOnly();
10005
10012
  });
10006
10013
  })(r, i).compute([
@@ -10047,7 +10054,7 @@ var Iu = class extends $s {
10047
10054
  dispose() {
10048
10055
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
10049
10056
  }
10050
- }, Ru = class extends $n {
10057
+ }, zu = class extends $n {
10051
10058
  constructor(e, t, n = {}) {
10052
10059
  super("MotionVector", {
10053
10060
  ...n,
@@ -10071,7 +10078,7 @@ var Iu = class extends $s {
10071
10078
  let s = N(K.x).mul(16).add(N(oe.x)), c = N(K.y).mul(16).add(N(oe.y));
10072
10079
  p(s.lessThan(N(i)).and(c.lessThan(N(a))), () => {
10073
10080
  let l = R(e, P(s, c)).w, u = H(M(s).add(.5).div(i), M(c).add(.5).div(a)), d = W(0, 0, l, 1).toVar();
10074
- p(l.lessThan(M(1e5)), () => {
10081
+ p(l.lessThan(M(6e4)), () => {
10075
10082
  let e = U(M(s).add(.5).div(i).mul(2).sub(1), M(c).add(.5).div(a).mul(2).sub(1).negate(), 1), o = n.mul(W(e, 1)), f = I(ce(t[0].xyz, t[1].xyz, t[2].xyz).mul(o.xyz.div(o.w))), p = U(t[3]).add(f.mul(l)), m = r.mul(W(p, 1)), h = m.xy.div(m.w), g = H(h.x.mul(.5).add(.5), h.y.mul(-.5).add(.5)), _ = u.sub(g), v = g.x.greaterThanEqual(0).and(g.x.lessThanEqual(1)).and(g.y.greaterThanEqual(0)).and(g.y.lessThanEqual(1));
10076
10083
  d.assign(v.select(W(_, l, 1), W(M(1e3), M(1e3), l, 0)));
10077
10084
  }), z(o, Le(B(s), B(c)), d).toWriteOnly();
@@ -10092,7 +10099,7 @@ var Iu = class extends $s {
10092
10099
  let u = N(K.x).mul(16).add(N(oe.x)), d = N(K.y).mul(16).add(N(oe.y));
10093
10100
  p(u.lessThan(N(s)).and(d.lessThan(N(c))), () => {
10094
10101
  let f = R(e, P(u, d)).w, m = W(0, 0, 0, 0).toVar();
10095
- p(i.lessThan(.5).and(f.lessThan(M(1e5))), () => {
10102
+ p(i.lessThan(.5).and(f.lessThan(M(6e4))), () => {
10096
10103
  let e = U(M(u).add(.5).div(s).mul(2).sub(1), M(d).add(.5).div(c).mul(2).sub(1).negate(), 1), i = n.mul(W(e, 1)), l = I(ce(t[0].xyz, t[1].xyz, t[2].xyz).mul(i.xyz.div(i.w))), p = U(t[3]).add(l.mul(f)), h = H(M(u).add(.5).div(s), M(d).add(.5).div(c)), g = r.mul(W(p, 1)), _ = g.xy.div(g.w), v = H(_.x.mul(.5).add(.5), _.y.mul(-.5).add(.5)), y = v.x.greaterThanEqual(0).and(v.x.lessThanEqual(1)).and(v.y.greaterThanEqual(0)).and(v.y.lessThanEqual(1)), b = h.sub(v), x = U(b.x.div(a).mul(o), b.y.div(a).mul(o), 0);
10097
10104
  m.assign(y.select(W(x, 1), W(0, 0, 0, .5)));
10098
10105
  }), z(l, Le(B(u), B(d)), m).toWriteOnly();
@@ -10159,7 +10166,7 @@ var Iu = class extends $s {
10159
10166
  dispose() {
10160
10167
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
10161
10168
  }
10162
- }, zu = (e) => L(e.equal(e), e, M(0)).clamp(0, 1e7), Bu = (e) => U(zu(e.x), zu(e.y), zu(e.z)), Vu = class extends $n {
10169
+ }, Bu = (e) => L(e.equal(e), e, M(0)).clamp(0, 1e7), Vu = (e) => U(Bu(e.x), Bu(e.y), Bu(e.z)), Hu = class extends $n {
10163
10170
  constructor(e, t = {}) {
10164
10171
  super("ASVGF", {
10165
10172
  ...t,
@@ -10200,7 +10207,7 @@ var Iu = class extends $s {
10200
10207
  let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, o = this._gradientStorageTex, s = this.resW, c = this.resH, l = ze("float", 144), u = ze("float", 144);
10201
10208
  this._gradientNode = f(() => {
10202
10209
  let d = oe.x, f = oe.y, m = f.mul(8).add(d), h = N(K.x).mul(8).sub(2).toVar(), g = N(K.y).mul(8).sub(2).toVar(), v = (i) => {
10203
- let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = R(e, P(d, f)).xyz, m = R(t, P(d, f)).xyz, _ = Yi(Bu(p.div(F(m, U(hr))))).toVar();
10210
+ let a = i.mod(B(12)), o = i.div(B(12)), d = h.add(N(a)).clamp(N(0), N(s).sub(1)), f = g.add(N(o)).clamp(N(0), N(c).sub(1)), p = R(e, P(d, f)).xyz, m = R(t, P(d, f)).xyz, _ = Yi(Vu(p.div(F(m, U(hr))))).toVar();
10204
10211
  l.element(i).assign(_);
10205
10212
  let v = R(n, P(d, f)), y = M(d).sub(v.x.mul(s)), b = M(f).sub(v.y.mul(c)), x = N(y.add(.5)).clamp(N(0), N(s).sub(1)), S = N(b.add(.5)).clamp(N(0), N(c).sub(1)), C = v.w.greaterThan(.5), w = R(r, P(x, S)).xyz, T = C.select(Yi(w), _);
10206
10213
  u.element(i).assign(T);
@@ -10247,7 +10254,7 @@ var Iu = class extends $s {
10247
10254
  return f(() => {
10248
10255
  let f = N(K.x).mul(8).add(N(oe.x)), y = N(K.y).mul(8).add(N(oe.y));
10249
10256
  p(f.lessThan(N(g)).and(y.lessThan(N(v))), () => {
10250
- let b = P(f, y), x = R(t, b).xyz, S = R(n, b).xyz, C = F(S, U(hr)), w = Bu(x.div(C)), T = W(w, 1).toVar(), E = W(x, 1).toVar();
10257
+ let b = P(f, y), x = R(t, b).xyz, S = R(n, b).xyz, C = F(S, U(hr)), w = Vu(x.div(C)), T = W(w, 1).toVar(), E = W(x, 1).toVar();
10251
10258
  p(m.greaterThan(.5).and(h.lessThan(.5)), () => {
10252
10259
  let e = R(r, b), t = e.w.greaterThan(.5), n = M(f).sub(e.x.mul(g)), c = M(y).sub(e.y.mul(v)), m = n.greaterThanEqual(0).and(n.lessThan(M(g))).and(c.greaterThanEqual(0)).and(c.lessThan(M(v)));
10253
10260
  p(t.and(m), () => {
@@ -10256,7 +10263,7 @@ var Iu = class extends $s {
10256
10263
  return i.mul(l).mul(u);
10257
10264
  }, oe = ae(D, k, te), se = ae(O, k, ne), ce = ae(D, ee, re), de = ae(O, ee, ie), I = oe.add(se).add(ce).add(de);
10258
10265
  p(I.greaterThan(M(.01)), () => {
10259
- let e = R(o, P(D, k)), t = R(o, P(O, k)), n = R(o, P(D, ee)), r = R(o, P(O, ee)), i = M(1).div(I), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(de)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(de)).mul(i), f = R(s, b).x.mul(d).clamp(0, 1), p = Bu(ue(a, w, ue(F(M(1).div(c.add(1)), u), M(1), f))), m = le(c.add(1), l);
10266
+ let e = R(o, P(D, k)), t = R(o, P(O, k)), n = R(o, P(D, ee)), r = R(o, P(O, ee)), i = M(1).div(I), a = e.xyz.mul(oe).add(t.xyz.mul(se)).add(n.xyz.mul(ce)).add(r.xyz.mul(de)).mul(i), c = e.w.mul(oe).add(t.w.mul(se)).add(n.w.mul(ce)).add(r.w.mul(de)).mul(i), f = R(s, b).x.mul(d).clamp(0, 1), p = Vu(ue(a, w, ue(F(M(1).div(c.add(1)), u), M(1), f))), m = le(c.add(1), l);
10260
10267
  T.assign(W(p, m)), E.assign(W(p.mul(C), 1));
10261
10268
  });
10262
10269
  });
@@ -10368,7 +10375,7 @@ var Iu = class extends $s {
10368
10375
  dispose() {
10369
10376
  this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._demodulatedRT?.dispose(), this._outputRT?.dispose(), this._gradientRT?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._albedoTexNode?.dispose(), this._motionTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._prevNormalDepthTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._gradientReadTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
10370
10377
  }
10371
- }, Hu = (e) => L(e.equal(e), e, M(0)).clamp(0, 1e7), Uu = /* @__PURE__ */ G("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), Wu = class extends $n {
10378
+ }, Uu = (e) => L(e.equal(e), e, M(0)).clamp(0, 1e7), Wu = /* @__PURE__ */ G("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), Gu = class extends $n {
10372
10379
  constructor(e, t = {}) {
10373
10380
  super("VarianceEstimation", {
10374
10381
  ...t,
@@ -10394,9 +10401,9 @@ var Iu = class extends $s {
10394
10401
  let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, o = this.resH, s = ze("float", 100);
10395
10402
  return f(() => {
10396
10403
  let c = oe.x, l = oe.y, u = l.mul(8).add(c), d = N(K.x).mul(8).sub(1), f = N(K.y).mul(8).sub(1), m = u.mod(10), h = u.div(10), g = R(n, P(d.add(N(m)).clamp(N(0), N(a).sub(1)), f.add(N(h)).clamp(N(0), N(o).sub(1)))).xyz;
10397
- s.element(u).assign(Hu(Yi(g))), p(u.lessThan(B(36)), () => {
10404
+ s.element(u).assign(Uu(Yi(g))), p(u.lessThan(B(36)), () => {
10398
10405
  let e = u.add(B(64)), t = e.mod(10), r = e.div(10), i = R(n, P(d.add(N(t)).clamp(N(0), N(a).sub(1)), f.add(N(r)).clamp(N(0), N(o).sub(1)))).xyz;
10399
- s.element(e).assign(Hu(Yi(i)));
10406
+ s.element(e).assign(Uu(Yi(i)));
10400
10407
  }), Be();
10401
10408
  let _ = N(K.x).mul(8).add(N(c)), v = N(K.y).mul(8).add(N(l));
10402
10409
  p(_.lessThan(N(a)).and(v.lessThan(N(o))), () => {
@@ -10407,7 +10414,7 @@ var Iu = class extends $s {
10407
10414
  }
10408
10415
  n.divAssign(9), a.divAssign(9);
10409
10416
  let o = F(a.sub(n.mul(n)), M(0)), u = s.element(l.add(1).mul(10).add(c.add(1))), d = R(t, P(_, v));
10410
- z(e, Le(B(_), B(v)), Uu(u, d.x, d.y, r, o, i)).toWriteOnly();
10417
+ z(e, Le(B(_), B(v)), Wu(u, d.x, d.y, r, o, i)).toWriteOnly();
10411
10418
  });
10412
10419
  })().compute([
10413
10420
  this._dispatchX,
@@ -10453,7 +10460,7 @@ var Iu = class extends $s {
10453
10460
  dispose() {
10454
10461
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
10455
10462
  }
10456
- }, Gu = /* @__PURE__ */ G("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Ku = class extends $n {
10463
+ }, Ku = /* @__PURE__ */ G("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), phiNorm );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), qu = class extends $n {
10457
10464
  constructor(e, t = {}) {
10458
10465
  super("BilateralFiltering", {
10459
10466
  ...t,
@@ -10505,7 +10512,7 @@ var Iu = class extends $s {
10505
10512
  p(f.lessThan(N(h)).and(v.lessThan(N(g))), () => {
10506
10513
  let p = P(f, v), y = R(t, p).xyz, b = R(n, p), x = R(r, p).xyz.mul(2).sub(1), S = b.w, C = Yi(y), w = F(R(i, p).xyz, U(hr)), T = F(Yi(w), M(hr)).toVar(), E = R(a, p), D = ue(E.z, F(E.z, E.w), u), O = l.mul(Se(F(D, M(0)))).div(T).add(M(1e-4)), k = U(0).toVar(), A = M(0).toVar();
10507
10514
  for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
10508
- let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = R(t, P(p, m)).xyz, w = R(n, P(p, m)), T = R(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D = Gu(C, Yi(b), x, T, S, E, y, b, M(u), O, s, c, o);
10515
+ let a = i - 2, l = e - 2, u = _[e * 5 + i], p = f.add(d.mul(a)).clamp(N(0), N(h).sub(1)), m = v.add(d.mul(l)).clamp(N(0), N(g).sub(1)), b = R(t, P(p, m)).xyz, w = R(n, P(p, m)), T = R(r, P(p, m)).xyz.mul(2).sub(1), E = w.w, D = Ku(C, Yi(b), x, T, S, E, y, b, M(u), O, s, c, o);
10509
10516
  k.addAssign(b.mul(D)), A.addAssign(D);
10510
10517
  }
10511
10518
  let j = k.div(F(A, M(1e-4))), ee = m.equal(N(1)).select(j.mul(w), j);
@@ -10556,7 +10563,7 @@ var Iu = class extends $s {
10556
10563
  dispose() {
10557
10564
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose();
10558
10565
  }
10559
- }, qu = class extends $n {
10566
+ }, Ju = class extends $n {
10560
10567
  constructor(e, t = {}) {
10561
10568
  super("EdgeAwareFiltering", {
10562
10569
  ...t,
@@ -10577,7 +10584,7 @@ var Iu = class extends $s {
10577
10584
  this._computeNode = f(() => {
10578
10585
  let d = N(K.x).mul(16).add(N(oe.x)), f = N(K.y).mul(16).add(N(oe.y));
10579
10586
  p(d.lessThan(N(l)).and(f.lessThan(N(u))), () => {
10580
- let m = P(d, f), h = R(e, m).xyz, g = A(h, Hi), v = 1e5, y = R(t, m), b = y.xyz.mul(2).sub(1), x = y.w, S = Ce(M(v), x).oneMinus(), C = r.sub(c.mul(i)).clamp(0, 1), w = h.toVar(), T = M(1).toVar();
10587
+ let m = P(d, f), h = R(e, m).xyz, g = A(h, Hi), v = 6e4, y = R(t, m), b = y.xyz.mul(2).sub(1), x = y.w, S = Ce(M(v), x).oneMinus(), C = r.sub(c.mul(i)).clamp(0, 1), w = h.toVar(), T = M(1).toVar();
10581
10588
  for (let [n, r] of [
10582
10589
  [1, 0],
10583
10590
  [0, 1],
@@ -10642,7 +10649,7 @@ var Iu = class extends $s {
10642
10649
  dispose() {
10643
10650
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this.outputTarget?.dispose(), this._inputTexNode?.dispose(), this._ndTexNode?.dispose();
10644
10651
  }
10645
- }, Ju = 256, Yu = -8, Xu = 6 - Yu, Zu = Xu / Ju, Qu = 1e4, $u = /* @__PURE__ */ G("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), ed = class extends $n {
10652
+ }, Yu = 256, Xu = -8, Zu = 6 - Xu, Qu = Zu / Yu, $u = 1e4, ed = /* @__PURE__ */ G("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), td = class extends $n {
10646
10653
  constructor(e, t = {}) {
10647
10654
  super("AutoExposure", {
10648
10655
  ...t,
@@ -10658,7 +10665,7 @@ var Iu = class extends $s {
10658
10665
  depthBuffer: !1,
10659
10666
  stencilBuffer: !1
10660
10667
  };
10661
- this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = ct, this._downsampleStorageTex.format = It, this._downsampleStorageTex.minFilter = Tt, this._downsampleStorageTex.magFilter = Tt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = ct, this._reductionStorageTex.format = It, this._reductionStorageTex.minFilter = Tt, this._reductionStorageTex.magFilter = Tt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(Ju, "uint").toAtomic();
10668
+ this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = ct, this._downsampleStorageTex.format = It, this._downsampleStorageTex.minFilter = Tt, this._downsampleStorageTex.magFilter = Tt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = ct, this._reductionStorageTex.format = It, this._reductionStorageTex.minFilter = Tt, this._reductionStorageTex.magFilter = Tt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(Yu, "uint").toAtomic();
10662
10669
  }
10663
10670
  _buildCompute() {
10664
10671
  this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
@@ -10692,7 +10699,7 @@ var Iu = class extends $s {
10692
10699
  for (let i = 0; i < 16; i++) {
10693
10700
  let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = R(e, P(N(o), N(s))), l = c.x, u = c.y;
10694
10701
  p(u.greaterThan(0), () => {
10695
- let e = B(l.div(u).sub(M(Yu)).div(M(Xu)).mul(M(Ju)).floor().clamp(0, M(Ju - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M(Qu)));
10702
+ let e = B(l.div(u).sub(M(Xu)).div(M(Zu)).mul(M(Yu)).floor().clamp(0, M(Yu - 1))), r = M(o).add(.5).div(M(64)), i = M(s).add(.5).div(M(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(M($u)));
10696
10703
  x(t.element(e), d);
10697
10704
  });
10698
10705
  }
@@ -10710,14 +10717,14 @@ var Iu = class extends $s {
10710
10717
  let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
10711
10718
  this._histogramAnalyzeNode = f(() => {
10712
10719
  let i = M(0).toVar();
10713
- m(Ju, ({ i: t }) => {
10720
+ m(Yu, ({ i: t }) => {
10714
10721
  i.addAssign(M(S(e.element(t))));
10715
10722
  });
10716
10723
  let a = i.mul(n), o = i.mul(r), s = M(0).toVar(), c = M(0).toVar(), l = M(0).toVar(), u = M(0).toVar();
10717
- m(Ju, ({ i: t }) => {
10724
+ m(Yu, ({ i: t }) => {
10718
10725
  let n = M(S(e.element(t)));
10719
10726
  u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
10720
- let e = M(Yu).add(M(t).add(.5).mul(M(Zu)));
10727
+ let e = M(Xu).add(M(t).add(.5).mul(M(Qu)));
10721
10728
  c.addAssign(e.mul(n)), l.addAssign(n);
10722
10729
  });
10723
10730
  });
@@ -10732,7 +10739,7 @@ var Iu = class extends $s {
10732
10739
  _buildAdaptationCompute() {
10733
10740
  let e = this._reductionReadTexNode, t = this._adaptationResult, n = this.keyValueU, r = this.minExposureU, i = this.maxExposureU, a = this.adaptSpeedBrightU, o = this.adaptSpeedDarkU, s = this.deltaTimeU, c = this.isFirstFrameU, l = this.previousExposureU;
10734
10741
  this._adaptationComputeNode = f(() => {
10735
- let u = R(e, P(N(0), N(0))).x, d = $u(u, l, n, r, i, a, o, s, c);
10742
+ let u = R(e, P(N(0), N(0))).x, d = ed(u, l, n, r, i, a, o, s, c);
10736
10743
  t.element(B(0)).assign(d);
10737
10744
  })().compute(1, [
10738
10745
  1,
@@ -10799,7 +10806,7 @@ var Iu = class extends $s {
10799
10806
  };
10800
10807
  //#endregion
10801
10808
  //#region src/TSL/SSRC.js
10802
- function td({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: m, framesSinceReset: h }) {
10809
+ function nd({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode: r, readPrevNDTexNode: i, writeCacheTex: a, writePrevNDTex: o, resW: s, resH: c, temporalAlpha: l, phiNormal: u, phiDepth: d, maxHistory: m, framesSinceReset: h }) {
10803
10810
  return f(() => {
10804
10811
  let f = N(K.x).mul(8).add(N(oe.x)), g = N(K.y).mul(8).add(N(oe.y));
10805
10812
  p(f.lessThan(N(s)).and(g.lessThan(N(c))), () => {
@@ -10821,7 +10828,7 @@ function td({ colorTexNode: e, ndTexNode: t, motionTexNode: n, readCacheTexNode:
10821
10828
  });
10822
10829
  });
10823
10830
  }
10824
- function nd({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
10831
+ function rd({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r, resW: i, resH: a, spatialRadius: o, spatialWeight: s, phiNormal: c, phiDepth: l }) {
10825
10832
  let u = [
10826
10833
  [1, 0],
10827
10834
  [-1, 0],
@@ -10847,7 +10854,7 @@ function nd({ colorTexNode: e, ndTexNode: t, readCacheTexNode: n, outputTex: r,
10847
10854
  }
10848
10855
  //#endregion
10849
10856
  //#region src/Stages/SSRC.js
10850
- var rd = class extends $n {
10857
+ var id = class extends $n {
10851
10858
  constructor(e, t = {}) {
10852
10859
  super("SSRC", {
10853
10860
  ...t,
@@ -10932,12 +10939,12 @@ var rd = class extends $n {
10932
10939
  phiNormal: this.phiNormal,
10933
10940
  phiDepth: this.phiDepth,
10934
10941
  maxHistory: this.maxHistory
10935
- }, t = td({
10942
+ }, t = nd({
10936
10943
  ...e,
10937
10944
  writeCacheTex: this._cacheTexA,
10938
10945
  writePrevNDTex: this._prevNDTexA,
10939
10946
  framesSinceReset: this._framesSinceReset
10940
- }), n = td({
10947
+ }), n = nd({
10941
10948
  ...e,
10942
10949
  writeCacheTex: this._cacheTexB,
10943
10950
  writePrevNDTex: this._prevNDTexB,
@@ -10951,7 +10958,7 @@ var rd = class extends $n {
10951
10958
  8,
10952
10959
  1
10953
10960
  ];
10954
- this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = nd({
10961
+ this._pass1NodeA = t().compute(r, i), this._pass1NodeB = n().compute(r, i), this._pass2Node = rd({
10955
10962
  colorTexNode: this._colorTexNode,
10956
10963
  ndTexNode: this._ndTexNode,
10957
10964
  readCacheTexNode: this._readPass1CacheTexNode,
@@ -10964,7 +10971,7 @@ var rd = class extends $n {
10964
10971
  phiDepth: this.phiDepth
10965
10972
  })().compute(r, i);
10966
10973
  }
10967
- }, id = class extends $n {
10974
+ }, ad = class extends $n {
10968
10975
  constructor(n, r = {}) {
10969
10976
  super("Compositor", {
10970
10977
  ...r,
@@ -10990,7 +10997,7 @@ var rd = class extends $n {
10990
10997
  dispose() {
10991
10998
  this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this.compositorQuad = null;
10992
10999
  }
10993
- }, ad = class {
11000
+ }, od = class {
10994
11001
  constructor() {
10995
11002
  this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
10996
11003
  frame: 0,
@@ -11112,7 +11119,7 @@ var rd = class extends $n {
11112
11119
  dispose() {
11113
11120
  this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
11114
11121
  }
11115
- }, od = class extends q {
11122
+ }, sd = class extends q {
11116
11123
  constructor() {
11117
11124
  super(), this._onceCallbacks = /* @__PURE__ */ new Map();
11118
11125
  }
@@ -11150,9 +11157,9 @@ var rd = class extends $n {
11150
11157
  eventNames() {
11151
11158
  return this._listeners ? Object.keys(this._listeners) : [];
11152
11159
  }
11153
- }, sd = class {
11160
+ }, cd = class {
11154
11161
  constructor(e, t, n) {
11155
- this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new ad(), this.eventBus = new od(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
11162
+ this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new od(), this.eventBus = new sd(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
11156
11163
  enabled: !1,
11157
11164
  logSkipped: !1,
11158
11165
  timings: /* @__PURE__ */ new Map(),
@@ -11284,7 +11291,7 @@ var rd = class extends $n {
11284
11291
  let e = this.getInfo();
11285
11292
  console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
11286
11293
  }
11287
- }, cd = class {
11294
+ }, ld = class {
11288
11295
  constructor() {
11289
11296
  this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
11290
11297
  }
@@ -11306,7 +11313,7 @@ var rd = class extends $n {
11306
11313
  resumeFromPause() {
11307
11314
  this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
11308
11315
  }
11309
- }, ld = class extends q {
11316
+ }, ud = class extends q {
11310
11317
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
11311
11318
  super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new zt(), this.focusMode = !1, this.focusPointIndicator = null, this.afPointPlacementMode = !1, this.handleAFPointClick = this.handleAFPointClick.bind(this), this.selectedObject = null, this.selectMode = !1, this.clickTimeout = null, this.mouseDownPosition = null, this.dragThreshold = 5, this.handleFocusClick = this.handleFocusClick.bind(this), this.handleSelectClick = this.handleSelectClick.bind(this), this.handleSelectDoubleClick = this.handleSelectDoubleClick.bind(this), this.handleMouseDown = this.handleMouseDown.bind(this), this.handleMouseUp = this.handleMouseUp.bind(this), this.handleContextMenu = this.handleContextMenu.bind(this), this.handleContextPointerDown = this.handleContextPointerDown.bind(this), this.handleContextPointerUp = this.handleContextPointerUp.bind(this), this.contextPointerDownPosition = null, this.canvas.addEventListener("pointerdown", this.handleContextPointerDown), this.canvas.addEventListener("pointerup", this.handleContextPointerUp), this.canvas.addEventListener("contextmenu", this.handleContextMenu), this._overlayManager = null, this._transformManager = null, this._appDispatch = null, this._orbitControls = null;
11312
11319
  }
@@ -11527,18 +11534,18 @@ var rd = class extends $n {
11527
11534
  dispose() {
11528
11535
  this.canvas.removeEventListener("click", this.handleAFPointClick), this.canvas.removeEventListener("click", this.handleFocusClick), this.canvas.removeEventListener("mousedown", this.handleMouseDown), this.canvas.removeEventListener("mouseup", this.handleMouseUp), this.canvas.removeEventListener("click", this.handleSelectClick), this.canvas.removeEventListener("dblclick", this.handleSelectDoubleClick), this.canvas.removeEventListener("contextmenu", this.handleContextMenu), this.canvas.removeEventListener("pointerdown", this.handleContextPointerDown), this.canvas.removeEventListener("pointerup", this.handleContextPointerUp), this.clickTimeout &&= (clearTimeout(this.clickTimeout), null), this.mouseDownPosition = null, this.contextPointerDownPosition = null, this.focusPointIndicator &&= (this.scene.remove(this.focusPointIndicator), null), this.canvas.style.cursor = "auto", this.scene = null, this.camera = null, this.canvas = null, this.assetLoader = null, this.pathTracer = null, this.floorPlane = null, this.raycaster = null;
11529
11536
  }
11530
- }, ud = {
11537
+ }, dd = {
11531
11538
  STRING: "string",
11532
11539
  NUMBER: "number",
11533
11540
  WORD: "word",
11534
11541
  LBRACKET: "[",
11535
11542
  RBRACKET: "]"
11536
- }, dd = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", fd = (e) => e >= "0" && e <= "9", pd = (e, t, n) => !!(fd(e) || e === "." && fd(t) || (e === "-" || e === "+") && (fd(t) || t === "." && fd(n)));
11537
- function md(e) {
11543
+ }, fd = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", pd = (e) => e >= "0" && e <= "9", md = (e, t, n) => !!(pd(e) || e === "." && pd(t) || (e === "-" || e === "+") && (pd(t) || t === "." && pd(n)));
11544
+ function hd(e) {
11538
11545
  let t = [], n = e.length, r = 0;
11539
11546
  for (; r < n;) {
11540
11547
  let i = e[r];
11541
- if (dd(i)) {
11548
+ if (fd(i)) {
11542
11549
  r++;
11543
11550
  continue;
11544
11551
  }
@@ -11547,11 +11554,11 @@ function md(e) {
11547
11554
  continue;
11548
11555
  }
11549
11556
  if (i === "[") {
11550
- t.push({ type: ud.LBRACKET }), r++;
11557
+ t.push({ type: dd.LBRACKET }), r++;
11551
11558
  continue;
11552
11559
  }
11553
11560
  if (i === "]") {
11554
- t.push({ type: ud.RBRACKET }), r++;
11561
+ t.push({ type: dd.RBRACKET }), r++;
11555
11562
  continue;
11556
11563
  }
11557
11564
  if (i === "\"") {
@@ -11560,12 +11567,12 @@ function md(e) {
11560
11567
  for (; r < n && e[r] !== "\"";) r++;
11561
11568
  if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
11562
11569
  t.push({
11563
- type: ud.STRING,
11570
+ type: dd.STRING,
11564
11571
  value: e.slice(i, r)
11565
11572
  }), r++;
11566
11573
  continue;
11567
11574
  }
11568
- if (pd(i, e[r + 1], e[r + 2])) {
11575
+ if (md(i, e[r + 1], e[r + 2])) {
11569
11576
  let i = r;
11570
11577
  for (r++; r < n;) {
11571
11578
  let t = e[r];
@@ -11575,16 +11582,16 @@ function md(e) {
11575
11582
  let a = e.slice(i, r), o = Number(a);
11576
11583
  if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
11577
11584
  t.push({
11578
- type: ud.NUMBER,
11585
+ type: dd.NUMBER,
11579
11586
  value: o
11580
11587
  });
11581
11588
  continue;
11582
11589
  }
11583
11590
  {
11584
11591
  let i = r;
11585
- for (; r < n && !dd(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
11592
+ for (; r < n && !fd(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
11586
11593
  t.push({
11587
- type: ud.WORD,
11594
+ type: dd.WORD,
11588
11595
  value: e.slice(i, r)
11589
11596
  });
11590
11597
  }
@@ -11593,7 +11600,7 @@ function md(e) {
11593
11600
  }
11594
11601
  //#endregion
11595
11602
  //#region src/Processor/PBRT/PBRTMath.js
11596
- function hd() {
11603
+ function gd() {
11597
11604
  return [
11598
11605
  1,
11599
11606
  0,
@@ -11613,7 +11620,7 @@ function hd() {
11613
11620
  1
11614
11621
  ];
11615
11622
  }
11616
- function gd(e, t) {
11623
+ function _d(e, t) {
11617
11624
  let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], k = t[11], A = t[12], j = t[13], M = t[14], ee = t[15];
11618
11625
  return [
11619
11626
  n * v + o * y + u * b + m * x,
@@ -11634,7 +11641,7 @@ function gd(e, t) {
11634
11641
  a * A + l * j + p * M + _ * ee
11635
11642
  ];
11636
11643
  }
11637
- function _d(e, t, n) {
11644
+ function vd(e, t, n) {
11638
11645
  return [
11639
11646
  1,
11640
11647
  0,
@@ -11654,7 +11661,7 @@ function _d(e, t, n) {
11654
11661
  1
11655
11662
  ];
11656
11663
  }
11657
- function vd(e, t, n) {
11664
+ function yd(e, t, n) {
11658
11665
  return [
11659
11666
  e,
11660
11667
  0,
@@ -11674,7 +11681,7 @@ function vd(e, t, n) {
11674
11681
  1
11675
11682
  ];
11676
11683
  }
11677
- function yd(e, t, n, r) {
11684
+ function bd(e, t, n, r) {
11678
11685
  let i = Math.hypot(t, n, r) || 1;
11679
11686
  t /= i, n /= i, r /= i;
11680
11687
  let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
@@ -11697,21 +11704,21 @@ function yd(e, t, n, r) {
11697
11704
  1
11698
11705
  ];
11699
11706
  }
11700
- function bd(e, t) {
11707
+ function xd(e, t) {
11701
11708
  return [
11702
11709
  e[0] - t[0],
11703
11710
  e[1] - t[1],
11704
11711
  e[2] - t[2]
11705
11712
  ];
11706
11713
  }
11707
- function xd(e, t) {
11714
+ function Sd(e, t) {
11708
11715
  return [
11709
11716
  e[1] * t[2] - e[2] * t[1],
11710
11717
  e[2] * t[0] - e[0] * t[2],
11711
11718
  e[0] * t[1] - e[1] * t[0]
11712
11719
  ];
11713
11720
  }
11714
- function Sd(e) {
11721
+ function Cd(e) {
11715
11722
  let t = Math.hypot(e[0], e[1], e[2]) || 1;
11716
11723
  return [
11717
11724
  e[0] / t,
@@ -11719,8 +11726,8 @@ function Sd(e) {
11719
11726
  e[2] / t
11720
11727
  ];
11721
11728
  }
11722
- function Cd(e, t, n) {
11723
- let r = Sd(bd(t, e)), i = Sd(xd(Sd(n), r)), a = xd(r, i);
11729
+ function wd(e, t, n) {
11730
+ let r = Cd(xd(t, e)), i = Cd(Sd(Cd(n), r)), a = Sd(r, i);
11724
11731
  return [
11725
11732
  i[0],
11726
11733
  i[1],
@@ -11740,9 +11747,9 @@ function Cd(e, t, n) {
11740
11747
  1
11741
11748
  ];
11742
11749
  }
11743
- function wd(e) {
11750
+ function Td(e) {
11744
11751
  let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
11745
- if (x === 0) return hd();
11752
+ if (x === 0) return gd();
11746
11753
  let S = 1 / x;
11747
11754
  return [
11748
11755
  _ * S,
@@ -11765,7 +11772,7 @@ function wd(e) {
11765
11772
  }
11766
11773
  //#endregion
11767
11774
  //#region src/Processor/PBRT/PBRTParser.js
11768
- var Td = class {
11775
+ var Ed = class {
11769
11776
  constructor(e = {}) {
11770
11777
  this.resolveInclude = e.resolveInclude || (() => {
11771
11778
  throw Error("PBRTParser: Include used but no resolveInclude provided");
@@ -11779,14 +11786,14 @@ var Td = class {
11779
11786
  instances: [],
11780
11787
  objects: /* @__PURE__ */ new Map(),
11781
11788
  warnings: []
11782
- }, this.ctm = hd(), this.state = {
11789
+ }, this.ctm = gd(), this.state = {
11783
11790
  material: null,
11784
11791
  areaLight: null,
11785
11792
  reverseOrientation: !1
11786
11793
  }, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.objectBeginCTM = null, this.dirStack = [""], this.tokens = [], this.pos = 0, this._warnedUnknown = /* @__PURE__ */ new Set();
11787
11794
  }
11788
11795
  parse(e, t = "") {
11789
- return this.dirStack = [t], this._run(md(e)), this.ir;
11796
+ return this.dirStack = [t], this._run(hd(e)), this.ir;
11790
11797
  }
11791
11798
  _peek() {
11792
11799
  return this.tokens[this.pos];
@@ -11796,12 +11803,12 @@ var Td = class {
11796
11803
  }
11797
11804
  _expectNumber(e) {
11798
11805
  let t = this._next();
11799
- if (!t || t.type !== ud.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
11806
+ if (!t || t.type !== dd.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
11800
11807
  return t.value;
11801
11808
  }
11802
11809
  _expectString(e) {
11803
11810
  let t = this._next();
11804
- if (!t || t.type !== ud.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
11811
+ if (!t || t.type !== dd.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
11805
11812
  return t.value;
11806
11813
  }
11807
11814
  _readNumbers(e) {
@@ -11810,17 +11817,17 @@ var Td = class {
11810
11817
  return t;
11811
11818
  }
11812
11819
  _readBracketedOrBareNumbers(e) {
11813
- if (this._peek() && this._peek().type === ud.LBRACKET) {
11820
+ if (this._peek() && this._peek().type === dd.LBRACKET) {
11814
11821
  this._next();
11815
11822
  let e = [];
11816
- for (; this._peek() && this._peek().type !== ud.RBRACKET;) e.push(this._expectNumber("transform element"));
11823
+ for (; this._peek() && this._peek().type !== dd.RBRACKET;) e.push(this._expectNumber("transform element"));
11817
11824
  return this._next(), e;
11818
11825
  }
11819
11826
  return this._readNumbers(e);
11820
11827
  }
11821
11828
  _parseParams() {
11822
11829
  let e = {};
11823
- for (; this._peek() && this._peek().type === ud.STRING;) {
11830
+ for (; this._peek() && this._peek().type === dd.STRING;) {
11824
11831
  let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
11825
11832
  e[r] = {
11826
11833
  type: n,
@@ -11831,23 +11838,23 @@ var Td = class {
11831
11838
  }
11832
11839
  _parseParamValue() {
11833
11840
  let e = [];
11834
- if (this._peek() && this._peek().type === ud.LBRACKET) {
11835
- for (this._next(); this._peek() && this._peek().type !== ud.RBRACKET;) e.push(this._coerceValueToken(this._next()));
11841
+ if (this._peek() && this._peek().type === dd.LBRACKET) {
11842
+ for (this._next(); this._peek() && this._peek().type !== dd.RBRACKET;) e.push(this._coerceValueToken(this._next()));
11836
11843
  this._next();
11837
11844
  } else e.push(this._coerceValueToken(this._next()));
11838
11845
  return e;
11839
11846
  }
11840
11847
  _coerceValueToken(e) {
11841
11848
  if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
11842
- if (e.type === ud.NUMBER || e.type === ud.STRING) return e.value;
11843
- if (e.type === ud.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
11849
+ if (e.type === dd.NUMBER || e.type === dd.STRING) return e.value;
11850
+ if (e.type === dd.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
11844
11851
  throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
11845
11852
  }
11846
11853
  _run(e) {
11847
11854
  let t = this.tokens, n = this.pos;
11848
11855
  for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
11849
11856
  let e = this._next();
11850
- if (e.type !== ud.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
11857
+ if (e.type !== dd.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
11851
11858
  this._directive(e.value);
11852
11859
  }
11853
11860
  this.tokens = t, this.pos = n;
@@ -11855,25 +11862,25 @@ var Td = class {
11855
11862
  _directive(e) {
11856
11863
  switch (e) {
11857
11864
  case "Identity":
11858
- this.ctm = hd();
11865
+ this.ctm = gd();
11859
11866
  break;
11860
11867
  case "Translate": {
11861
11868
  let [e, t, n] = this._readNumbers(3);
11862
- this.ctm = gd(this.ctm, _d(e, t, n));
11869
+ this.ctm = _d(this.ctm, vd(e, t, n));
11863
11870
  break;
11864
11871
  }
11865
11872
  case "Scale": {
11866
11873
  let [e, t, n] = this._readNumbers(3);
11867
- this.ctm = gd(this.ctm, vd(e, t, n));
11874
+ this.ctm = _d(this.ctm, yd(e, t, n));
11868
11875
  break;
11869
11876
  }
11870
11877
  case "Rotate": {
11871
11878
  let [e, t, n, r] = this._readNumbers(4);
11872
- this.ctm = gd(this.ctm, yd(e, t, n, r));
11879
+ this.ctm = _d(this.ctm, bd(e, t, n, r));
11873
11880
  break;
11874
11881
  }
11875
11882
  case "LookAt": {
11876
- let e = this._readNumbers(9), t = Cd([
11883
+ let e = this._readNumbers(9), t = wd([
11877
11884
  e[0],
11878
11885
  e[1],
11879
11886
  e[2]
@@ -11886,7 +11893,7 @@ var Td = class {
11886
11893
  e[7],
11887
11894
  e[8]
11888
11895
  ]);
11889
- this.ctm = gd(this.ctm, wd(t));
11896
+ this.ctm = _d(this.ctm, Td(t));
11890
11897
  break;
11891
11898
  }
11892
11899
  case "Transform":
@@ -11894,7 +11901,7 @@ var Td = class {
11894
11901
  break;
11895
11902
  case "ConcatTransform": {
11896
11903
  let e = this._readBracketedOrBareNumbers(16);
11897
- this.ctm = gd(this.ctm, e);
11904
+ this.ctm = _d(this.ctm, e);
11898
11905
  break;
11899
11906
  }
11900
11907
  case "CoordinateSystem":
@@ -11910,7 +11917,7 @@ var Td = class {
11910
11917
  this.ir.camera = {
11911
11918
  type: e,
11912
11919
  params: t,
11913
- cameraToWorld: wd(this.ctm)
11920
+ cameraToWorld: Td(this.ctm)
11914
11921
  };
11915
11922
  break;
11916
11923
  }
@@ -11934,7 +11941,7 @@ var Td = class {
11934
11941
  this._skipTypeAndParams();
11935
11942
  break;
11936
11943
  case "WorldBegin":
11937
- this.ctm = hd(), this.state = {
11944
+ this.ctm = gd(), this.state = {
11938
11945
  material: null,
11939
11946
  areaLight: null,
11940
11947
  reverseOrientation: !1
@@ -11979,7 +11986,7 @@ var Td = class {
11979
11986
  this._readNumbers(2);
11980
11987
  break;
11981
11988
  case "MediumInterface":
11982
- this._peek() && this._peek().type === ud.STRING && this._next(), this._peek() && this._peek().type === ud.STRING && this._next();
11989
+ this._peek() && this._peek().type === dd.STRING && this._next(), this._peek() && this._peek().type === dd.STRING && this._next();
11983
11990
  break;
11984
11991
  case "MakeNamedMedium":
11985
11992
  this._skipNamedAndParams();
@@ -12087,7 +12094,7 @@ var Td = class {
12087
12094
  }
12088
12095
  }
12089
12096
  _emitShape(e) {
12090
- this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = gd(wd(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
12097
+ this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = _d(Td(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
12091
12098
  }
12092
12099
  _include(e) {
12093
12100
  let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
@@ -12096,13 +12103,13 @@ var Td = class {
12096
12103
  return;
12097
12104
  }
12098
12105
  let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
12099
- this.dirStack.push(n), this._run(md(t)), this.dirStack.pop();
12106
+ this.dirStack.push(n), this._run(hd(t)), this.dirStack.pop();
12100
12107
  }
12101
12108
  _skipTypeAndParams() {
12102
- this._peek() && this._peek().type === ud.STRING && this._next(), this._parseParams();
12109
+ this._peek() && this._peek().type === dd.STRING && this._next(), this._parseParams();
12103
12110
  }
12104
12111
  _skipNamedAndParams() {
12105
- this._peek() && this._peek().type === ud.STRING && this._next(), this._parseParams();
12112
+ this._peek() && this._peek().type === dd.STRING && this._next(), this._parseParams();
12106
12113
  }
12107
12114
  _num(e, t) {
12108
12115
  return e && e.value.length ? e.value[0] : t;
@@ -12116,7 +12123,7 @@ var Td = class {
12116
12123
  _warnUnknown(e) {
12117
12124
  this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
12118
12125
  }
12119
- }, Ed = {
12126
+ }, Dd = {
12120
12127
  au: [
12121
12128
  1,
12122
12129
  .78,
@@ -12172,12 +12179,12 @@ var Td = class {
12172
12179
  .9,
12173
12180
  .9
12174
12181
  ]
12175
- }, Dd = [
12182
+ }, Od = [
12176
12183
  .92,
12177
12184
  .92,
12178
12185
  .92
12179
12186
  ];
12180
- function Od(e) {
12187
+ function kd(e) {
12181
12188
  let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
12182
12189
  t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
12183
12190
  let a = (e) => Math.max(0, Math.min(255, e)) / 255;
@@ -12187,15 +12194,15 @@ function Od(e) {
12187
12194
  a(i) ** 2.2
12188
12195
  ];
12189
12196
  }
12190
- function kd(e, t, n) {
12197
+ function Ad(e, t, n) {
12191
12198
  let r = e[t];
12192
12199
  return r && typeof r.value[0] == "number" ? r.value[0] : n;
12193
12200
  }
12194
- function Ad(e, t, n) {
12201
+ function jd(e, t, n) {
12195
12202
  let r = e[t];
12196
12203
  return r && typeof r.value[0] == "string" ? r.value[0] : n;
12197
12204
  }
12198
- async function jd(e, t, n, r = null) {
12205
+ async function Md(e, t, n, r = null) {
12199
12206
  let i = e[t];
12200
12207
  if (!i) return {
12201
12208
  rgb: r,
@@ -12234,14 +12241,14 @@ async function jd(e, t, n, r = null) {
12234
12241
  };
12235
12242
  }
12236
12243
  if (i.type === "blackbody") return {
12237
- rgb: Od(i.value[0]),
12244
+ rgb: kd(i.value[0]),
12238
12245
  texture: null
12239
12246
  };
12240
12247
  if (i.type === "spectrum") {
12241
12248
  if (typeof i.value[0] == "string") {
12242
- let e = Md(i.value[0]);
12243
- return e && Ed[e] ? {
12244
- rgb: Ed[e].slice(),
12249
+ let e = Nd(i.value[0]);
12250
+ return e && Dd[e] ? {
12251
+ rgb: Dd[e].slice(),
12245
12252
  texture: null
12246
12253
  } : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
12247
12254
  rgb: [
@@ -12269,18 +12276,18 @@ async function jd(e, t, n, r = null) {
12269
12276
  texture: null
12270
12277
  };
12271
12278
  }
12272
- function Md(e) {
12279
+ function Nd(e) {
12273
12280
  let t = e.toLowerCase().match(/metal-([a-z]+)/);
12274
12281
  if (t) return t[1];
12275
- for (let t of Object.keys(Ed)) if (e.toLowerCase().includes(t)) return t;
12282
+ for (let t of Object.keys(Dd)) if (e.toLowerCase().includes(t)) return t;
12276
12283
  return null;
12277
12284
  }
12278
- function Nd(e, t) {
12285
+ function Pd(e, t) {
12279
12286
  if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
12280
- let n = kd(e, "uroughness", null), r = kd(e, "vroughness", null);
12287
+ let n = Ad(e, "uroughness", null), r = Ad(e, "vroughness", null);
12281
12288
  return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
12282
12289
  }
12283
- async function Pd(e, t) {
12290
+ async function Fd(e, t) {
12284
12291
  let n = e?.type || "diffuse", r = e?.params || {}, i = new Ct({
12285
12292
  side: at,
12286
12293
  roughness: 1,
@@ -12292,7 +12299,7 @@ async function Pd(e, t) {
12292
12299
  };
12293
12300
  switch (n) {
12294
12301
  case "diffuse":
12295
- o(await jd(r, "reflectance", t, [
12302
+ o(await Md(r, "reflectance", t, [
12296
12303
  .5,
12297
12304
  .5,
12298
12305
  .5
@@ -12300,14 +12307,14 @@ async function Pd(e, t) {
12300
12307
  break;
12301
12308
  case "conductor":
12302
12309
  case "metal": {
12303
- let e = await jd(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
12310
+ let e = await Md(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
12304
12311
  if (e.rgb || e.texture) o(e);
12305
12312
  else if (n && s && !c) {
12306
- let e = (await jd(r, "eta", t, [
12313
+ let e = (await Md(r, "eta", t, [
12307
12314
  .2,
12308
12315
  .92,
12309
12316
  1.1
12310
- ])).rgb, n = (await jd(r, "k", t, [
12317
+ ])).rgb, n = (await Md(r, "k", t, [
12311
12318
  3.9,
12312
12319
  2.45,
12313
12320
  2.14
@@ -12317,28 +12324,28 @@ async function Pd(e, t) {
12317
12324
  i(e[1], n[1]),
12318
12325
  i(e[2], n[2])
12319
12326
  ]);
12320
- } else a(n ? (await jd(r, "eta", t, Dd)).rgb || Dd : Ed.cu);
12321
- i.metalness = 1, i.roughness = Nd(r, .1);
12327
+ } else a(n ? (await Md(r, "eta", t, Od)).rgb || Od : Dd.cu);
12328
+ i.metalness = 1, i.roughness = Pd(r, .1);
12322
12329
  break;
12323
12330
  }
12324
12331
  case "dielectric":
12325
12332
  case "thindielectric":
12326
- i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = kd(r, "eta", 1.5), i.roughness = Nd(r, 0), i.thickness = n === "thindielectric" ? 0 : kd(r, "thickness", 0);
12333
+ i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = Ad(r, "eta", 1.5), i.roughness = Pd(r, 0), i.thickness = n === "thindielectric" ? 0 : Ad(r, "thickness", 0);
12327
12334
  break;
12328
12335
  case "coateddiffuse":
12329
- o(await jd(r, "reflectance", t, [
12336
+ o(await Md(r, "reflectance", t, [
12330
12337
  .5,
12331
12338
  .5,
12332
12339
  .5
12333
- ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = Nd(r, 0);
12340
+ ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = Pd(r, 0);
12334
12341
  break;
12335
12342
  case "diffusetransmission": {
12336
- let e = await jd(r, "transmittance", t, [
12343
+ let e = await Md(r, "transmittance", t, [
12337
12344
  .25,
12338
12345
  .25,
12339
12346
  .25
12340
12347
  ]);
12341
- o(await jd(r, "reflectance", t, [
12348
+ o(await Md(r, "reflectance", t, [
12342
12349
  .25,
12343
12350
  .25,
12344
12351
  .25
@@ -12351,9 +12358,9 @@ async function Pd(e, t) {
12351
12358
  i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
12352
12359
  break;
12353
12360
  case "mix": {
12354
- let e = r.materials?.value || [], n = Math.max(0, Math.min(1, kd(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
12361
+ let e = r.materials?.value || [], n = Math.max(0, Math.min(1, Ad(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
12355
12362
  if (a && o) {
12356
- let [e, r] = await Promise.all([Pd(a, t), Pd(o, t)]), s = (e, t) => e * (1 - n) + t * n;
12363
+ let [e, r] = await Promise.all([Fd(a, t), Fd(o, t)]), s = (e, t) => e * (1 - n) + t * n;
12357
12364
  i.color.lerpColors(e.color, r.color, n), i.roughness = s(e.roughness, r.roughness), i.metalness = s(e.metalness, r.metalness), i.ior = s(e.ior ?? 1.5, r.ior ?? 1.5), i.transmission = s(e.transmission ?? 0, r.transmission ?? 0), i.thickness = s(e.thickness ?? 0, r.thickness ?? 0), i.clearcoat = s(e.clearcoat ?? 0, r.clearcoat ?? 0), i.clearcoatRoughness = s(e.clearcoatRoughness ?? 0, r.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, r.emissive, n), i.emissiveIntensity = s(e.emissiveIntensity ?? 0, r.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : r.map) || null;
12358
12365
  break;
12359
12366
  }
@@ -12363,7 +12370,7 @@ async function Pd(e, t) {
12363
12370
  case "subsurface":
12364
12371
  case "hair":
12365
12372
  case "measured":
12366
- t.warn(`material "${n}" not supported — using diffuse approximation`), a((await jd(r, "reflectance", t, [
12373
+ t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Md(r, "reflectance", t, [
12367
12374
  .5,
12368
12375
  .5,
12369
12376
  .5
@@ -12377,7 +12384,7 @@ async function Pd(e, t) {
12377
12384
  }
12378
12385
  //#endregion
12379
12386
  //#region src/Processor/PBRT/PBRTSceneBuilder.js
12380
- var Fd = [
12387
+ var Id = [
12381
12388
  1,
12382
12389
  0,
12383
12390
  0,
@@ -12394,7 +12401,7 @@ var Fd = [
12394
12401
  0,
12395
12402
  0,
12396
12403
  1
12397
- ], Id = class {
12404
+ ], Ld = class {
12398
12405
  constructor(e = {}) {
12399
12406
  this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map();
12400
12407
  }
@@ -12430,7 +12437,7 @@ var Fd = [
12430
12437
  continue;
12431
12438
  }
12432
12439
  for (let e of i) {
12433
- let i = gd(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
12440
+ let i = _d(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
12434
12441
  a && t.add(a);
12435
12442
  }
12436
12443
  }
@@ -12442,7 +12449,7 @@ var Fd = [
12442
12449
  i.map && !a && (this.warn(`${n} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), o = i.clone(), o.map = null);
12443
12450
  let s = new xt(r, o);
12444
12451
  s.name = n;
12445
- let c = this.convertHandedness ? gd(Fd, t) : t;
12452
+ let c = this.convertHandedness ? _d(Id, t) : t;
12446
12453
  new bt().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
12447
12454
  let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new rn()) : new rn();
12448
12455
  return this.report.push({
@@ -12497,7 +12504,7 @@ var Fd = [
12497
12504
  return i.setAttribute("position", new st(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
12498
12505
  }
12499
12506
  async _plyMesh(e) {
12500
- let t = Ad(e, "filename", null);
12507
+ let t = jd(e, "filename", null);
12501
12508
  if (!t) return this.warn("plymesh missing filename"), null;
12502
12509
  try {
12503
12510
  let e = await this.resolvePLY(t);
@@ -12507,10 +12514,10 @@ var Fd = [
12507
12514
  }
12508
12515
  }
12509
12516
  _sphere(e) {
12510
- return new qt(kd(e, "radius", 1), 48, 32);
12517
+ return new qt(Ad(e, "radius", 1), 48, 32);
12511
12518
  }
12512
12519
  _disk(e) {
12513
- let t = kd(e, "radius", 1), n = kd(e, "innerradius", 0), r = kd(e, "height", 0), i = [], a = [];
12520
+ let t = Ad(e, "radius", 1), n = Ad(e, "innerradius", 0), r = Ad(e, "height", 0), i = [], a = [];
12514
12521
  for (let e = 0; e < 48; e++) {
12515
12522
  let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
12516
12523
  i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
@@ -12525,15 +12532,15 @@ var Fd = [
12525
12532
  resolveNamedTexture: (e) => this._resolveNamedTexture(e),
12526
12533
  namedMaterials: this.ir.namedMaterials,
12527
12534
  warn: (e) => this.warn(e)
12528
- }, r = await Pd(e.material, n);
12535
+ }, r = await Fd(e.material, n);
12529
12536
  return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
12530
12537
  }
12531
12538
  async _applyAreaLight(e, t, n) {
12532
- let r = await jd(t.params, "L", n, [
12539
+ let r = await Md(t.params, "L", n, [
12533
12540
  1,
12534
12541
  1,
12535
12542
  1
12536
- ]), i = kd(t.params, "scale", 1), a = r.rgb || [
12543
+ ]), i = Ad(t.params, "scale", 1), a = r.rgb || [
12537
12544
  1,
12538
12545
  1,
12539
12546
  1
@@ -12545,7 +12552,7 @@ var Fd = [
12545
12552
  let t = this.ir.namedTextures.get(e), n = null;
12546
12553
  if (!t) this.warn(`named texture "${e}" not defined`);
12547
12554
  else if (t.class === "imagemap") {
12548
- let r = Ad(t.params, "filename", null);
12555
+ let r = jd(t.params, "filename", null);
12549
12556
  if (r) try {
12550
12557
  let t = await this.resolveImage(r);
12551
12558
  t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
@@ -12633,7 +12640,7 @@ var Fd = [
12633
12640
  return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
12634
12641
  }
12635
12642
  _verticalFov(e, t) {
12636
- let n = kd(e, "fov", 90);
12643
+ let n = Ad(e, "fov", 90);
12637
12644
  if (t >= 1) return n;
12638
12645
  let r = n * Math.PI / 180;
12639
12646
  return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
@@ -12641,7 +12648,7 @@ var Fd = [
12641
12648
  async _buildEnvironment(e) {
12642
12649
  let t = e.find((e) => e.type === "infinite");
12643
12650
  if (!t) return null;
12644
- let n = kd(t.params, "scale", 1), r = Ad(t.params, "filename", null);
12651
+ let n = Ad(t.params, "scale", 1), r = jd(t.params, "filename", null);
12645
12652
  if (r) try {
12646
12653
  let e = await this.resolveEnvironment(r);
12647
12654
  if (e) return e.mapping = ot, { texture: e };
@@ -12649,7 +12656,7 @@ var Fd = [
12649
12656
  } catch (e) {
12650
12657
  this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
12651
12658
  }
12652
- let i = ((await jd(t.params, "L", {
12659
+ let i = ((await Md(t.params, "L", {
12653
12660
  resolveNamedTexture: async () => null,
12654
12661
  warn: (e) => this.warn(e)
12655
12662
  }, [
@@ -12668,20 +12675,20 @@ var Fd = [
12668
12675
  _reportUnsupportedLights(e) {
12669
12676
  for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
12670
12677
  }
12671
- }, Ld = new TextDecoder();
12672
- function Rd(e) {
12678
+ }, Rd = new TextDecoder();
12679
+ function zd(e) {
12673
12680
  let t = e.replace(/\\/g, "/").split("/"), n = [];
12674
12681
  for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
12675
12682
  return n.join("/");
12676
12683
  }
12677
- function zd(e, t) {
12678
- return !e || t.startsWith("/") ? Rd(t) : Rd(`${e}/${t}`);
12684
+ function Bd(e, t) {
12685
+ return !e || t.startsWith("/") ? zd(t) : zd(`${e}/${t}`);
12679
12686
  }
12680
- var Bd = class {
12687
+ var Vd = class {
12681
12688
  constructor(e) {
12682
12689
  this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
12683
12690
  for (let t in e) {
12684
- let n = Rd(t).toLowerCase(), r = {
12691
+ let n = zd(t).toLowerCase(), r = {
12685
12692
  norm: n,
12686
12693
  bytes: e[t]
12687
12694
  };
@@ -12691,13 +12698,13 @@ var Bd = class {
12691
12698
  }
12692
12699
  }
12693
12700
  find(e) {
12694
- let t = Rd(e).toLowerCase();
12701
+ let t = zd(e).toLowerCase();
12695
12702
  if (this.byPath.has(t)) return this.byPath.get(t).bytes;
12696
12703
  let n = this.byBase.get(t.split("/").pop());
12697
12704
  return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
12698
12705
  }
12699
12706
  };
12700
- function Vd(e) {
12707
+ function Hd(e) {
12701
12708
  let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
12702
12709
  if (t.length === 0) return null;
12703
12710
  let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
@@ -12706,17 +12713,17 @@ function Vd(e) {
12706
12713
  return n === r ? e.length - t.length : n - r;
12707
12714
  }), r[0];
12708
12715
  }
12709
- async function Hd(e) {
12710
- let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new Bd(t), s = e.entryPath || Vd(t);
12716
+ async function Ud(e) {
12717
+ let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new Vd(t), s = e.entryPath || Hd(t);
12711
12718
  if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
12712
12719
  let c = o.find(s);
12713
12720
  if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
12714
- let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new Td({ resolveInclude: (e, t) => {
12715
- let n = o.find(zd(t, e)) || o.find(e);
12716
- return n ? Ld.decode(n) : null;
12717
- } }).parse(Ld.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
12721
+ let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new Ed({ resolveInclude: (e, t) => {
12722
+ let n = o.find(Bd(t, e)) || o.find(e);
12723
+ return n ? Rd.decode(n) : null;
12724
+ } }).parse(Rd.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
12718
12725
  return {
12719
- ...await new Id({
12726
+ ...await new Ld({
12720
12727
  convertHandedness: a,
12721
12728
  resolvePLY: async (e) => {
12722
12729
  let t = o.find(e);
@@ -12736,7 +12743,7 @@ async function Hd(e) {
12736
12743
  }
12737
12744
  //#endregion
12738
12745
  //#region src/Processor/AssetLoader.js
12739
- var Ud = {
12746
+ var Wd = {
12740
12747
  glb: {
12741
12748
  type: "model",
12742
12749
  name: "GLB (GLTF Binary)"
@@ -12801,7 +12808,7 @@ var Ud = {
12801
12808
  type: "archive",
12802
12809
  name: "ZIP Archive"
12803
12810
  }
12804
- }, Wd = class extends q {
12811
+ }, Gd = class extends q {
12805
12812
  constructor(e, t, n) {
12806
12813
  super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this._externalModel = null, this.floorPlane = null, this.sceneScale = 1, this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null;
12807
12814
  }
@@ -12812,7 +12819,7 @@ var Ud = {
12812
12819
  this.renderer = e;
12813
12820
  }
12814
12821
  getFileFormat(e) {
12815
- return Ud[e.split(".").pop().toLowerCase()] || null;
12822
+ return Wd[e.split(".").pop().toLowerCase()] || null;
12816
12823
  }
12817
12824
  readFileAsArrayBuffer(e) {
12818
12825
  return new Promise((t, n) => {
@@ -12938,7 +12945,7 @@ var Ud = {
12938
12945
  }
12939
12946
  async loadEnvironmentByExtension(e, t) {
12940
12947
  let n;
12941
- return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new cn().setDataType(ct)) : this.loaderCache.exr || (this.loaderCache.exr = new dn().setDataType(ct))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Zt()), n = await this.loaderCache.texture.loadAsync(e)), n.mapping = ot, n.minFilter = J, n.magFilter = J, n;
12948
+ return t === "hdr" || t === "exr" ? n = await (t === "hdr" ? this.loaderCache.hdr || (this.loaderCache.hdr = new cn().setDataType(ct)) : this.loaderCache.exr || (this.loaderCache.exr = new dn().setDataType(ct))).loadAsync(e) : (this.loaderCache.texture || (this.loaderCache.texture = new Zt()), n = await this.loaderCache.texture.loadAsync(e), n.colorSpace = Wt), n.mapping = ot, n.minFilter = J, n.magFilter = J, n;
12942
12949
  }
12943
12950
  applyEnvironmentToScene(e) {
12944
12951
  this.scene.background = e, this.scene.environment = e;
@@ -12946,7 +12953,7 @@ var Ud = {
12946
12953
  async loadArchiveFromFile(e, t) {
12947
12954
  try {
12948
12955
  let n = await this.readFileAsArrayBuffer(e), r = hn(new Uint8Array(n));
12949
- return Vd(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
12956
+ return Hd(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
12950
12957
  } catch (e) {
12951
12958
  throw console.error("Error loading ZIP archive:", e), e;
12952
12959
  }
@@ -12960,7 +12967,7 @@ var Ud = {
12960
12967
  let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
12961
12968
  this.loaderCache.ply = new e();
12962
12969
  }
12963
- let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await Hd({
12970
+ let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await Ud({
12964
12971
  vfs: e,
12965
12972
  plyParser: (e) => this.loaderCache.ply.parse(e),
12966
12973
  imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
@@ -13059,7 +13066,7 @@ var Ud = {
13059
13066
  }
13060
13067
  for (let t in e) {
13061
13068
  let n = t.split(".").pop().toLowerCase();
13062
- if (Ud[n] && Ud[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
13069
+ if (Wd[n] && Wd[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
13063
13070
  }
13064
13071
  throw Error("No supported model files found in the ZIP archive");
13065
13072
  }
@@ -13585,10 +13592,10 @@ var Ud = {
13585
13592
  getSupportedFormats(e = null) {
13586
13593
  if (e) {
13587
13594
  let t = {};
13588
- for (let [n, r] of Object.entries(Ud)) r.type === e && (t[n] = r);
13595
+ for (let [n, r] of Object.entries(Wd)) r.type === e && (t[n] = r);
13589
13596
  return t;
13590
13597
  }
13591
- return Ud;
13598
+ return Wd;
13592
13599
  }
13593
13600
  dispose() {
13594
13601
  for (let e in this.loaderCache) {
@@ -13600,7 +13607,7 @@ var Ud = {
13600
13607
  removeAllEventListeners() {
13601
13608
  this._listeners = void 0;
13602
13609
  }
13603
- }, Gd = {
13610
+ }, Kd = {
13604
13611
  maxBounces: {
13605
13612
  uniform: "maxBounces",
13606
13613
  reset: !0
@@ -13739,10 +13746,10 @@ var Ud = {
13739
13746
  },
13740
13747
  renderMode: { handler: "handleRenderMode" },
13741
13748
  environmentRotation: { handler: "handleEnvironmentRotation" }
13742
- }, Kd = {
13749
+ }, qd = {
13743
13750
  bounces: "maxBounces",
13744
13751
  debugMode: "visMode"
13745
- }, qd = class extends q {
13752
+ }, Jd = class extends q {
13746
13753
  constructor(e = X) {
13747
13754
  super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
13748
13755
  }
@@ -13788,7 +13795,7 @@ var Ud = {
13788
13795
  let i = this._values.get(e);
13789
13796
  if (i === t) return;
13790
13797
  this._values.set(e, t);
13791
- let a = Gd[e];
13798
+ let a = Kd[e];
13792
13799
  a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
13793
13800
  type: tr.SETTING_CHANGED,
13794
13801
  key: e,
@@ -13802,7 +13809,7 @@ var Ud = {
13802
13809
  let e = this._values.get(r);
13803
13810
  if (e === i) continue;
13804
13811
  this._values.set(r, i);
13805
- let a = Gd[r];
13812
+ let a = Kd[r];
13806
13813
  a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (n = !0), t || this.dispatchEvent({
13807
13814
  type: tr.SETTING_CHANGED,
13808
13815
  key: r,
@@ -13820,7 +13827,7 @@ var Ud = {
13820
13827
  }
13821
13828
  applyAll() {
13822
13829
  for (let [e, t] of this._values) {
13823
- let n = Gd[e];
13830
+ let n = Kd[e];
13824
13831
  n && this._applyRoute(n, t, void 0);
13825
13832
  }
13826
13833
  }
@@ -13828,10 +13835,10 @@ var Ud = {
13828
13835
  e.uniform ? (this._pathTracer?.setUniform(e.uniform, t), e.after && this._pathTracer?.[e.after]?.()) : e.handler ? this._handlers[e.handler]?.(t, n) : e.delegate && this._delegates[e.delegate]?.updateParam?.(e.param, t);
13829
13836
  }
13830
13837
  _initDefaults(e) {
13831
- for (let t of Object.keys(Gd)) t in e && this._values.set(t, e[t]);
13832
- for (let [t, n] of Object.entries(Kd)) t in e && this._values.set(n, e[t]);
13838
+ for (let t of Object.keys(Kd)) t in e && this._values.set(t, e[t]);
13839
+ for (let [t, n] of Object.entries(qd)) t in e && this._values.set(n, e[t]);
13833
13840
  }
13834
- }, Jd = class extends q {
13841
+ }, Yd = class extends q {
13835
13842
  constructor(e) {
13836
13843
  super();
13837
13844
  let t = e.clientWidth, n = e.clientHeight;
@@ -13952,7 +13959,7 @@ var Ud = {
13952
13959
  dispose() {
13953
13960
  this.controls?.dispose();
13954
13961
  }
13955
- }, Yd = class extends q {
13962
+ }, Xd = class extends q {
13956
13963
  constructor(e, t, n, r = {}) {
13957
13964
  super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
13958
13965
  }
@@ -14111,14 +14118,14 @@ var Ud = {
14111
14118
  ], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
14112
14119
  return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
14113
14120
  }
14114
- }, Xd = class {
14121
+ }, Zd = class {
14115
14122
  constructor(e, t = {}) {
14116
14123
  this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
14117
14124
  }
14118
14125
  async loadLibrary(e, { size: t = 256 } = {}) {
14119
14126
  if (!Array.isArray(e) || e.length === 0) return [];
14120
14127
  this._size = t;
14121
- let n = await Promise.all(e.map((e) => Zd(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
14128
+ let n = await Promise.all(e.map((e) => Qd(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
14122
14129
  s.width = r, s.height = i;
14123
14130
  let c = s.getContext("2d", { willReadFrequently: !0 });
14124
14131
  for (let e = 0; e < a; e++) {
@@ -14147,7 +14154,7 @@ var Ud = {
14147
14154
  o.userData.gobo = {
14148
14155
  name: e.name,
14149
14156
  index: e.index,
14150
- intensity: Qd(r),
14157
+ intensity: $d(r),
14151
14158
  inverted: !!i,
14152
14159
  scale: Math.max(1e-4, a)
14153
14160
  };
@@ -14189,28 +14196,28 @@ var Ud = {
14189
14196
  return t && t.isSpotLight ? t : null;
14190
14197
  }
14191
14198
  };
14192
- function Zd(e) {
14199
+ function Qd(e) {
14193
14200
  return new Promise((t, n) => {
14194
14201
  let r = new Image();
14195
14202
  r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
14196
14203
  });
14197
14204
  }
14198
- function Qd(e) {
14205
+ function $d(e) {
14199
14206
  return Math.max(0, Math.min(1, e));
14200
14207
  }
14201
14208
  //#endregion
14202
14209
  //#region src/Processor/IESParser.js
14203
- function $d(e, t = "ies") {
14210
+ function ef(e, t = "ies") {
14204
14211
  let n = e.search(/TILT\s*=/i);
14205
14212
  if (n < 0) throw Error(`IES (${t}): missing TILT line`);
14206
14213
  let r = e.indexOf("\n", n);
14207
14214
  if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
14208
14215
  let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
14209
14216
  if (a === "INCLUDE") {
14210
- let e = rf(o), t = 2 + 2 * Number(e[1]);
14211
- o = af(o, t);
14217
+ let e = af(o), t = 2 + 2 * Number(e[1]);
14218
+ o = of(o, t);
14212
14219
  }
14213
- let s = rf(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
14220
+ let s = af(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
14214
14221
  l(), l(), l(), l();
14215
14222
  let g = l();
14216
14223
  if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
@@ -14236,18 +14243,18 @@ function $d(e, t = "ies") {
14236
14243
  name: t
14237
14244
  };
14238
14245
  }
14239
- function ef(e, t, n) {
14246
+ function tf(e, t, n) {
14240
14247
  let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
14241
14248
  if (s <= 0) return r;
14242
14249
  let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
14243
14250
  for (let e = 0; e < n; e++) {
14244
- let f = (e + .5) / n * c, p = of(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
14251
+ let f = (e + .5) / n * c, p = sf(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
14245
14252
  for (let n = 0; n < t; n++) {
14246
14253
  let i;
14247
- if (d) i = sf(o[p][0], o[m][0], g);
14254
+ if (d) i = cf(o[p][0], o[m][0], g);
14248
14255
  else {
14249
- let e = u + (n + .5) / t * (l - u), r = of(a, e), s = Math.min(r + 1, a.length - 1), c = a[s] - a[r], d = c > 0 ? (e - a[r]) / c : 0, f = o[p][r], h = o[p][s], _ = o[m][r], v = o[m][s];
14250
- i = sf(sf(f, h, d), sf(_, v, d), g);
14256
+ let e = u + (n + .5) / t * (l - u), r = sf(a, e), s = Math.min(r + 1, a.length - 1), c = a[s] - a[r], d = c > 0 ? (e - a[r]) / c : 0, f = o[p][r], h = o[p][s], _ = o[m][r], v = o[m][s];
14257
+ i = cf(cf(f, h, d), cf(_, v, d), g);
14251
14258
  }
14252
14259
  let c = Math.min(1, Math.max(0, i / s));
14253
14260
  r[e * t + n] = Math.round(c * 255);
@@ -14255,7 +14262,7 @@ function ef(e, t, n) {
14255
14262
  }
14256
14263
  return r;
14257
14264
  }
14258
- function tf(e, t = .1) {
14265
+ function nf(e, t = .1) {
14259
14266
  let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
14260
14267
  if (a <= 0 || !n?.length) return o;
14261
14268
  let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
@@ -14270,7 +14277,7 @@ function tf(e, t = .1) {
14270
14277
  let d = l * Math.PI / 180;
14271
14278
  return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
14272
14279
  }
14273
- function nf(e, t, n = .7) {
14280
+ function rf(e, t, n = .7) {
14274
14281
  let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
14275
14282
  if (o <= 0 || !r?.length || t <= 0) return 0;
14276
14283
  let s = o * n, c = i.length, l = 0;
@@ -14283,15 +14290,15 @@ function nf(e, t, n = .7) {
14283
14290
  let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
14284
14291
  return Math.min(Math.max(d, 0), 1);
14285
14292
  }
14286
- function rf(e) {
14293
+ function af(e) {
14287
14294
  return e.split(/\s+/).filter((e) => e.length > 0);
14288
14295
  }
14289
- function af(e, t) {
14296
+ function of(e, t) {
14290
14297
  let n = /\S+/g, r = 0;
14291
14298
  for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
14292
14299
  return "";
14293
14300
  }
14294
- function of(e, t) {
14301
+ function sf(e, t) {
14295
14302
  if (t <= e[0]) return 0;
14296
14303
  if (t >= e[e.length - 1]) return e.length - 1;
14297
14304
  let n = 0, r = e.length - 1;
@@ -14301,12 +14308,12 @@ function of(e, t) {
14301
14308
  }
14302
14309
  return n;
14303
14310
  }
14304
- function sf(e, t, n) {
14311
+ function cf(e, t, n) {
14305
14312
  return e + (t - e) * n;
14306
14313
  }
14307
14314
  //#endregion
14308
14315
  //#region src/managers/IESManager.js
14309
- var cf = class {
14316
+ var lf = class {
14310
14317
  constructor(e, t = {}) {
14311
14318
  this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
14312
14319
  }
@@ -14317,11 +14324,11 @@ var cf = class {
14317
14324
  try {
14318
14325
  let r = await fetch(e.url);
14319
14326
  if (!r.ok) throw Error(`HTTP ${r.status}`);
14320
- let i = $d(await r.text(), e.name);
14327
+ let i = ef(await r.text(), e.name);
14321
14328
  return {
14322
14329
  it: e,
14323
14330
  profile: i,
14324
- grid: ef(i, t, n)
14331
+ grid: tf(i, t, n)
14325
14332
  };
14326
14333
  } catch (t) {
14327
14334
  return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
@@ -14335,14 +14342,14 @@ var cf = class {
14335
14342
  let r = t[e];
14336
14343
  o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
14337
14344
  }
14338
- let i = r[e].profile, c = tf(i);
14345
+ let i = r[e].profile, c = nf(i);
14339
14346
  s.push({
14340
14347
  name: r[e].it.name,
14341
14348
  index: e,
14342
14349
  maxCandela: i.maxCandela,
14343
14350
  photometricType: i.photometricType,
14344
14351
  suggestedAngle: c,
14345
- suggestedPenumbra: nf(i, c),
14352
+ suggestedPenumbra: rf(i, c),
14346
14353
  lumens: i.lumens
14347
14354
  });
14348
14355
  }
@@ -14375,7 +14382,7 @@ var cf = class {
14375
14382
  l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
14376
14383
  name: e.name,
14377
14384
  index: e.index,
14378
- intensity: lf(n),
14385
+ intensity: uf(n),
14379
14386
  fixtureLumens: l
14380
14387
  }, r && (Number.isFinite(e.suggestedAngle) && (i.angle = e.suggestedAngle, o = e.suggestedAngle), Number.isFinite(e.suggestedPenumbra) && (i.penumbra = e.suggestedPenumbra, s = e.suggestedPenumbra), i.decay = 2, c = 2);
14381
14388
  }
@@ -14398,44 +14405,44 @@ var cf = class {
14398
14405
  return t && t.isSpotLight ? t : null;
14399
14406
  }
14400
14407
  };
14401
- function lf(e) {
14408
+ function uf(e) {
14402
14409
  return Math.max(0, Math.min(1, e));
14403
14410
  }
14404
14411
  //#endregion
14405
14412
  //#region src/Processor/ToneMapCPU.js
14406
- var uf = (e) => Math.min(Math.max(e, 0), 1);
14407
- function df(e, t, n, r, i) {
14408
- i[0] = uf(e), i[1] = uf(t), i[2] = uf(n);
14409
- }
14413
+ var df = (e) => Math.min(Math.max(e, 0), 1);
14410
14414
  function ff(e, t, n, r, i) {
14411
- i[0] = uf(e * r), i[1] = uf(t * r), i[2] = uf(n * r);
14415
+ i[0] = df(e), i[1] = df(t), i[2] = df(n);
14412
14416
  }
14413
14417
  function pf(e, t, n, r, i) {
14414
- e *= r, t *= r, n *= r, i[0] = uf(e / (e + 1)), i[1] = uf(t / (t + 1)), i[2] = uf(n / (n + 1));
14418
+ i[0] = df(e * r), i[1] = df(t * r), i[2] = df(n * r);
14415
14419
  }
14416
14420
  function mf(e, t, n, r, i) {
14421
+ e *= r, t *= r, n *= r, i[0] = df(e / (e + 1)), i[1] = df(t / (t + 1)), i[2] = df(n / (n + 1));
14422
+ }
14423
+ function hf(e, t, n, r, i) {
14417
14424
  e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
14418
14425
  let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
14419
14426
  i[0] = a(e), i[1] = a(t), i[2] = a(n);
14420
14427
  }
14421
- function hf(e, t, n, r, i) {
14428
+ function gf(e, t, n, r, i) {
14422
14429
  e = e * r / .6, t = t * r / .6, n = n * r / .6;
14423
14430
  let a = .59719 * e + .35458 * t + .04823 * n, o = .076 * e + .90834 * t + .01566 * n, s = .0284 * e + .13383 * t + .83777 * n, c = (e) => (e * (e + .0245786) - 90537e-9) / (e * (.983729 * e + .432951) + .238081);
14424
- a = c(a), o = c(o), s = c(s), i[0] = uf(1.60475 * a - .53108 * o - .07367 * s), i[1] = uf(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = uf(-.00327 * a - .07276 * o + 1.07602 * s);
14431
+ a = c(a), o = c(o), s = c(s), i[0] = df(1.60475 * a - .53108 * o - .07367 * s), i[1] = df(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = df(-.00327 * a - .07276 * o + 1.07602 * s);
14425
14432
  }
14426
- function gf(e, t, n, r, i) {
14433
+ function _f(e, t, n, r, i) {
14427
14434
  e *= r, t *= r, n *= r;
14428
14435
  let a = .6274 * e + .3293 * t + .0433 * n, o = .0691 * e + .9195 * t + .0113 * n, s = .0164 * e + .088 * t + .8956 * n, c = .856627153315983 * a + .0951212405381588 * o + .0482516061458583 * s, l = .137318972929847 * a + .761241990602591 * o + .101439036467562 * s, u = .11189821299995 * a + .0767994186031903 * o + .811302368396859 * s, d = -12.47393, f = 4.026069 - d;
14429
- c = uf((Math.log2(Math.max(c, 1e-10)) - d) / f), l = uf((Math.log2(Math.max(l, 1e-10)) - d) / f), u = uf((Math.log2(Math.max(u, 1e-10)) - d) / f);
14436
+ c = df((Math.log2(Math.max(c, 1e-10)) - d) / f), l = df((Math.log2(Math.max(l, 1e-10)) - d) / f), u = df((Math.log2(Math.max(u, 1e-10)) - d) / f);
14430
14437
  let p = (e) => {
14431
14438
  let t = e * e, n = t * t;
14432
14439
  return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
14433
14440
  };
14434
14441
  c = p(c), l = p(l), u = p(u);
14435
14442
  let m = 1.1271005818144368 * c - .11060664309660323 * l - .016493938717834573 * u, h = -.1413297634984383 * c + 1.157823702216272 * l - .016493938717834257 * u, g = -.14132976349843826 * c - .11060664309660294 * l + 1.2519364065950405 * u;
14436
- m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = uf(1.6605 * m - .5876 * h - .0728 * g), i[1] = uf(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = uf(-.0182 * m - .1006 * h + 1.1187 * g);
14443
+ m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = df(1.6605 * m - .5876 * h - .0728 * g), i[1] = df(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = df(-.0182 * m - .1006 * h + 1.1187 * g);
14437
14444
  }
14438
- function _f(e, t, n, r, i) {
14445
+ function vf(e, t, n, r, i) {
14439
14446
  let a = .76;
14440
14447
  e *= r, t *= r, n *= r;
14441
14448
  let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
@@ -14450,43 +14457,43 @@ function _f(e, t, n, r, i) {
14450
14457
  let f = 1 - 1 / (.15 * (c - u) + 1);
14451
14458
  i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
14452
14459
  }
14453
- var vf = new Map([
14454
- [Ot, df],
14455
- [mt, ff],
14456
- [Ht, pf],
14457
- [Xe, mf],
14458
- [Ve, hf],
14459
- [Ue, gf],
14460
- [Et, _f]
14461
- ]), yf = 1 / 2.2;
14462
- function bf(e) {
14460
+ var yf = new Map([
14461
+ [Ot, ff],
14462
+ [mt, pf],
14463
+ [Ht, mf],
14464
+ [Xe, hf],
14465
+ [Ve, gf],
14466
+ [Ue, _f],
14467
+ [Et, vf]
14468
+ ]), bf = 1 / 2.2;
14469
+ function xf(e) {
14463
14470
  return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
14464
14471
  }
14465
- var xf = .2126, Sf = .7152, Cf = .0722;
14466
- function wf(e, t) {
14472
+ var Sf = .2126, Cf = .7152, wf = .0722;
14473
+ function Tf(e, t) {
14467
14474
  if (t === 1) return;
14468
- let n = e[0] * xf + e[1] * Sf + e[2] * Cf;
14475
+ let n = e[0] * Sf + e[1] * Cf + e[2] * wf;
14469
14476
  e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
14470
14477
  }
14471
14478
  //#endregion
14472
14479
  //#region src/Passes/OIDNDenoiser.js
14473
- var Tf = null, Ef = null;
14474
- async function Df() {
14475
- if (!Tf) {
14480
+ var Ef = null, Df = null;
14481
+ async function Of() {
14482
+ if (!Ef) {
14476
14483
  let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
14477
- Tf = e.initUNetFromURL, Ef = t.engine;
14484
+ Ef = e.initUNetFromURL, Df = t.engine;
14478
14485
  }
14479
- return Tf;
14486
+ return Ef;
14480
14487
  }
14481
- function Of() {
14482
- if (Ef) try {
14483
- let e = Ef();
14488
+ function kf() {
14489
+ if (Df) try {
14490
+ let e = Df();
14484
14491
  e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
14485
14492
  } catch (e) {
14486
14493
  console.warn("OIDNDenoiser: failed to clear cached TFJS backend", e);
14487
14494
  }
14488
14495
  }
14489
- var kf = new Float32Array(3), Af = {
14496
+ var Af = new Float32Array(3), jf = {
14490
14497
  QUALITY_MODELS: {
14491
14498
  fast: "rt_hdr_alb_nrm_small",
14492
14499
  balance: "rt_hdr_alb_nrm",
@@ -14498,7 +14505,7 @@ var kf = new Float32Array(3), Af = {
14498
14505
  debugGbufferMaps: !0,
14499
14506
  tileSize: 256
14500
14507
  }
14501
- }, jf = class extends q {
14508
+ }, Mf = class extends q {
14502
14509
  constructor(e, t, n, r, i = {}) {
14503
14510
  if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
14504
14511
  this.renderer = t, this.scene = n, this.camera = r, this.input = t.domElement, this.output = e, this.extractGBufferData = i.extractGBufferData || null, this.getMRTRenderTarget = i.getMRTRenderTarget || null, this.backendParamsGetter = i.backendParams || null, this.getGPUTextures = i.getGPUTextures || null, this.getExposure = i.getExposure || (() => 1), this.getToneMapping = i.getToneMapping || (() => Ve), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
@@ -14509,13 +14516,13 @@ var kf = new Float32Array(3), Af = {
14509
14516
  width: 0,
14510
14517
  height: 0
14511
14518
  }, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
14512
- ...Af.DEFAULT_OPTIONS,
14519
+ ...jf.DEFAULT_OPTIONS,
14513
14520
  ...i
14514
14521
  }, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
14515
14522
  isDenoising: !1,
14516
14523
  isLoading: !1,
14517
14524
  abortController: null
14518
- }, this._pendingStagingBuffers = /* @__PURE__ */ new Set(), this._pendingTileBlits = [], this.currentTZAUrl = null, this.unet = null, this._initialize().catch((e) => {
14525
+ }, this._pendingStagingBuffers = /* @__PURE__ */ new Set(), this._pendingTileBlits = [], this.currentTZAUrl = null, this.unet = null, this._pendingStart = !1, this._initialize().catch((e) => {
14519
14526
  console.error("Failed to initialize OIDNDenoiser:", e), this.dispatchEvent({
14520
14527
  type: "error",
14521
14528
  error: e
@@ -14562,7 +14569,7 @@ var kf = new Float32Array(3), Af = {
14562
14569
  let e = this.backendParamsGetter();
14563
14570
  this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
14564
14571
  }
14565
- this.unet = await (await Df())(e, t, {
14572
+ this.unet = await (await Of())(e, t, {
14566
14573
  aux: !0,
14567
14574
  hdr: !0,
14568
14575
  maxTileSize: this.tileSize
@@ -14573,22 +14580,23 @@ var kf = new Float32Array(3), Af = {
14573
14580
  error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`)
14574
14581
  });
14575
14582
  } finally {
14576
- this.state.isLoading = !1;
14583
+ this.state.isLoading = !1, this._pendingStart && this.unet && this.enabled && (this._pendingStart = !1, this.start());
14577
14584
  }
14578
14585
  }
14579
14586
  _generateTzaUrl() {
14580
- let { oidnWeightsBaseUrl: e } = Zs(), { QUALITY_MODELS: t } = Af;
14587
+ let { oidnWeightsBaseUrl: e } = Zs(), { QUALITY_MODELS: t } = jf;
14581
14588
  return `${e}${t[this.quality] || t.balance}.tza`;
14582
14589
  }
14583
14590
  async updateConfiguration(e) {
14584
14591
  Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, await this._setupUNetDenoiser());
14585
14592
  }
14586
14593
  async updateQuality(e) {
14587
- if (!Object.prototype.hasOwnProperty.call(Af.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Af.QUALITY_MODELS).join(", ")}`);
14594
+ if (!Object.prototype.hasOwnProperty.call(jf.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(jf.QUALITY_MODELS).join(", ")}`);
14588
14595
  await this.updateConfiguration({ oidnQuality: e });
14589
14596
  }
14590
14597
  async start() {
14591
- if (!this.enabled || this.state.isDenoising || this.state.isLoading) return !1;
14598
+ if (!this.enabled || this.state.isDenoising) return !1;
14599
+ if (this.state.isLoading) return this._pendingStart = !0, !1;
14592
14600
  this.dispatchEvent({ type: "start" });
14593
14601
  let e = performance.now(), t = await this.execute();
14594
14602
  if (t) {
@@ -14768,10 +14776,10 @@ var kf = new Float32Array(3), Af = {
14768
14776
  }
14769
14777
  r.queue.submit([d.finish()]);
14770
14778
  let f = u.mapAsync(GPUMapMode.READ).then(() => {
14771
- let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = vf.get(this.getToneMapping()) || vf.get(Ve), d = this._cachedAlpha, f = this._cachedAlphaWidth;
14779
+ let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = yf.get(this.getToneMapping()) || yf.get(Ve), d = this._cachedAlpha, f = this._cachedAlphaWidth;
14772
14780
  for (let i = 0, a = e.length; i < a; i += 4) {
14773
14781
  let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
14774
- if (c !== 1 && (kf[0] = a, kf[1] = s, kf[2] = u, wf(kf, c), a = kf[0], s = kf[1], u = kf[2]), l(a, s, u, 1, kf), t.data[i] = bf(kf[0]) * 255 + .5 | 0, t.data[i + 1] = bf(kf[1]) * 255 + .5 | 0, t.data[i + 2] = bf(kf[2]) * 255 + .5 | 0, d) {
14782
+ if (c !== 1 && (Af[0] = a, Af[1] = s, Af[2] = u, Tf(Af, c), a = Af[0], s = Af[1], u = Af[2]), l(a, s, u, 1, Af), t.data[i] = xf(Af[0]) * 255 + .5 | 0, t.data[i + 1] = xf(Af[1]) * 255 + .5 | 0, t.data[i + 2] = xf(Af[2]) * 255 + .5 | 0, d) {
14775
14783
  let e = (i >> 2) % o, r = (i >> 2) / o | 0;
14776
14784
  t.data[i + 3] = d[(n.y + r) * f + n.x + e];
14777
14785
  } else t.data[i + 3] = 255;
@@ -14809,10 +14817,10 @@ var kf = new Float32Array(3), Af = {
14809
14817
  try {
14810
14818
  let o = r.createCommandEncoder({ label: "oidn-readback" });
14811
14819
  o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
14812
- let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = vf.get(this.getToneMapping()) || vf.get(Ve), f = this._cachedAlpha;
14820
+ let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = yf.get(this.getToneMapping()) || yf.get(Ve), f = this._cachedAlpha;
14813
14821
  for (let e = 0, t = s.length; e < t; e += 4) {
14814
14822
  let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
14815
- u !== 1 && (kf[0] = t, kf[1] = n, kf[2] = r, wf(kf, u), t = kf[0], n = kf[1], r = kf[2]), d(t, n, r, 1, kf), c.data[e] = bf(kf[0]) * 255 + .5 | 0, c.data[e + 1] = bf(kf[1]) * 255 + .5 | 0, c.data[e + 2] = bf(kf[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
14823
+ u !== 1 && (Af[0] = t, Af[1] = n, Af[2] = r, Tf(Af, u), t = Af[0], n = Af[1], r = Af[2]), d(t, n, r, 1, Af), c.data[e] = xf(Af[0]) * 255 + .5 | 0, c.data[e + 1] = xf(Af[1]) * 255 + .5 | 0, c.data[e + 2] = xf(Af[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
14816
14824
  }
14817
14825
  a.unmap(), this.ctx.putImageData(c, 0, 0);
14818
14826
  } finally {
@@ -14820,7 +14828,7 @@ var kf = new Float32Array(3), Af = {
14820
14828
  }
14821
14829
  }
14822
14830
  abort() {
14823
- !this.enabled || !this.state.isDenoising || (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }), console.log("Denoising aborted"));
14831
+ this._pendingStart = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this._destroyPendingStagingBuffers(), this.input.style.opacity = "1", this.state.isDenoising = !1, this.dispatchEvent({ type: "end" }), console.log("Denoising aborted"));
14824
14832
  }
14825
14833
  setSize(e, t) {
14826
14834
  if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
@@ -14833,9 +14841,9 @@ var kf = new Float32Array(3), Af = {
14833
14841
  this._pendingStagingBuffers.clear();
14834
14842
  }
14835
14843
  dispose() {
14836
- this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), Of(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
14844
+ this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), kf(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), console.log("OIDNDenoiser disposed");
14837
14845
  }
14838
- }, Mf = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, Nf = {
14846
+ }, Nf = "" + new URL("assets/AIUpscalerWorker-AXN-lKWN.js", import.meta.url).href, Pf = {
14839
14847
  fast: {
14840
14848
  2: "2x-spanx2-ch48.onnx",
14841
14849
  4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
@@ -14849,17 +14857,17 @@ var kf = new Float32Array(3), Af = {
14849
14857
  4: "4xNomos2_hq_mosr_fp32.onnx"
14850
14858
  }
14851
14859
  };
14852
- function Pf() {
14860
+ function Ff() {
14853
14861
  let { upscalerModelBaseUrl: e } = Zs(), t = {};
14854
- for (let n in Nf) {
14862
+ for (let n in Pf) {
14855
14863
  t[n] = {};
14856
- for (let r in Nf[n]) t[n][r] = e + Nf[n][r];
14864
+ for (let r in Pf[n]) t[n][r] = e + Pf[n][r];
14857
14865
  }
14858
14866
  return t;
14859
14867
  }
14860
- var Ff = {
14868
+ var If = {
14861
14869
  get QUALITY_PRESETS() {
14862
- return Pf();
14870
+ return Ff();
14863
14871
  },
14864
14872
  TILE_SIZE: 512,
14865
14873
  TILE_OVERLAP: 16,
@@ -14870,17 +14878,17 @@ var Ff = {
14870
14878
  }],
14871
14879
  graphOptimizationLevel: "all"
14872
14880
  }
14873
- }, If = class extends q {
14881
+ }, Lf = class extends q {
14874
14882
  constructor(e, t, n = {}) {
14875
14883
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
14876
- this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Ve), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || Ff.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
14884
+ this.renderer = t, this.input = t.domElement, this.output = e, this.getSourceCanvas = n.getSourceCanvas || null, this.getGPUTextures = n.getGPUTextures || null, this.getExposure = n.getExposure || (() => 1), this.getToneMapping = n.getToneMapping || (() => Ve), this.getSaturation = n.getSaturation || (() => 1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.tileSize = n.tileSize || If.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
14877
14885
  isUpscaling: !1,
14878
14886
  isLoading: !1,
14879
14887
  abortController: null
14880
14888
  }, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Set(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0;
14881
14889
  }
14882
14890
  async _ensureSession() {
14883
- let e = Ff.QUALITY_PRESETS[this.quality];
14891
+ let e = If.QUALITY_PRESETS[this.quality];
14884
14892
  if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
14885
14893
  let t = e[this.scaleFactor];
14886
14894
  if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
@@ -14891,10 +14899,10 @@ var Ff = {
14891
14899
  });
14892
14900
  try {
14893
14901
  if (!this._worker) try {
14894
- this._worker = new Worker(Mf, { type: "module" });
14902
+ this._worker = new Worker(Nf, { type: "module" });
14895
14903
  } catch (e) {
14896
14904
  if (e.name !== "SecurityError") throw e;
14897
- this._worker = await Hr(Mf);
14905
+ this._worker = await Hr(Nf);
14898
14906
  }
14899
14907
  await new Promise((e, n) => {
14900
14908
  let r = (t) => {
@@ -14903,7 +14911,7 @@ var Ff = {
14903
14911
  this._worker.addEventListener("message", r), this._worker.postMessage({
14904
14912
  type: "load",
14905
14913
  url: t,
14906
- sessionOptions: Ff.SESSION_OPTIONS,
14914
+ sessionOptions: If.SESSION_OPTIONS,
14907
14915
  ortRuntimeUrl: i,
14908
14916
  ortWasmPaths: a,
14909
14917
  cacheNamespace: o
@@ -14973,8 +14981,8 @@ var Ff = {
14973
14981
  willReadFrequently: !0,
14974
14982
  alpha: !0
14975
14983
  });
14976
- this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = vf.get(this.getToneMapping()) || vf.get(Ve), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
14977
- let o = Ff.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
14984
+ this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = yf.get(this.getToneMapping()) || yf.get(Ve), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
14985
+ let o = If.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
14978
14986
  for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
14979
14987
  if (e.aborted) throw new DOMException("Aborted", "AbortError");
14980
14988
  let l = Math.min(u * c, Math.max(0, n - s)), p = Math.min(o * c, Math.max(0, r - s)), m = Math.min(s, n - l), h = Math.min(s, r - p), g = this._extractTile(t, l, p, m, h), _ = await this._inferTile(g, m, h), v = l * i, y = p * i, b = m * i, x = h * i, S = this._tensorToImageData(_, b, x, v, y);
@@ -15047,7 +15055,7 @@ var Ff = {
15047
15055
  let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
15048
15056
  if (s) {
15049
15057
  let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
15050
- n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, wf(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +yf, l[c + d] = this._tmOut[1] ** +yf, l[2 * c + d] = this._tmOut[2] ** +yf;
15058
+ n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, Tf(this._tmOut, n), r = this._tmOut[0], i = this._tmOut[1], o = this._tmOut[2]), e(r, i, o, 1, this._tmOut), l[d] = this._tmOut[0] ** +bf, l[c + d] = this._tmOut[1] ** +bf, l[2 * c + d] = this._tmOut[2] ** +bf;
15051
15059
  } else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
15052
15060
  }
15053
15061
  return l;
@@ -15105,10 +15113,10 @@ var Ff = {
15105
15113
  this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
15106
15114
  let t = this._backupCanvas.getContext("2d");
15107
15115
  if (e.isHDR) {
15108
- let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = vf.get(this.getToneMapping()) || vf.get(Ve), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
15116
+ let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = yf.get(this.getToneMapping()) || yf.get(Ve), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
15109
15117
  for (let e = 0, t = r * i; e < t; e++) {
15110
15118
  let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
15111
- l !== 1 && (u[0] = r, u[1] = i, u[2] = a, wf(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +yf * 255 + .5 | 0, o[t + 1] = u[1] ** +yf * 255 + .5 | 0, o[t + 2] = u[2] ** +yf * 255 + .5 | 0, o[t + 3] = 255;
15119
+ l !== 1 && (u[0] = r, u[1] = i, u[2] = a, Tf(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +bf * 255 + .5 | 0, o[t + 1] = u[1] ** +bf * 255 + .5 | 0, o[t + 2] = u[2] ** +bf * 255 + .5 | 0, o[t + 3] = 255;
15112
15120
  }
15113
15121
  t.putImageData(a, 0, 0);
15114
15122
  } else t.putImageData(e, 0, 0);
@@ -15120,7 +15128,7 @@ var Ff = {
15120
15128
  this.hdr = !!e;
15121
15129
  }
15122
15130
  setQuality(e) {
15123
- if (!Ff.QUALITY_PRESETS[e]) {
15131
+ if (!If.QUALITY_PRESETS[e]) {
15124
15132
  console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
15125
15133
  return;
15126
15134
  }
@@ -15143,7 +15151,7 @@ var Ff = {
15143
15151
  async dispose() {
15144
15152
  this.abort(), this._cleanupPendingWorkerHandlers(), this._worker &&= (this._worker.postMessage({ type: "dispose" }), this._worker.terminate(), null), this._currentModelUrl = null, this._backupCanvas = null, this._upscaledAlpha = null, this.state.abortController = null, this._hdrStagingBuffer?.destroy(), this._hdrStagingBuffer = null, this._hdrStagingWidth = 0, this._hdrStagingHeight = 0, console.log("AIUpscaler disposed");
15145
15153
  }
15146
- }, Lf = class extends q {
15154
+ }, Rf = class extends q {
15147
15155
  constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
15148
15156
  super(), this.renderer = e, this.mainCanvas = t, this.denoiserCanvas = this._createDenoiserCanvas(t), this.scene = n, this.camera = r, this.pipeline = a, this._stages = i, this._getExposure = o, this._getSaturation = s, this._getTransparentBg = c, this.denoiser = null, this.upscaler = null, this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
15149
15157
  }
@@ -15164,7 +15172,7 @@ var Ff = {
15164
15172
  setupDenoiser() {
15165
15173
  if (!this.denoiserCanvas) return;
15166
15174
  let e = this._stages.pathTracer;
15167
- this.denoiser = new jf(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
15175
+ this.denoiser = new Mf(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
15168
15176
  ...X,
15169
15177
  backendParams: () => ({
15170
15178
  device: this.renderer.backend.device,
@@ -15189,7 +15197,7 @@ var Ff = {
15189
15197
  setupUpscaler() {
15190
15198
  if (!this.denoiserCanvas) return;
15191
15199
  let e = this._stages.pathTracer;
15192
- this.upscaler = new If(this.denoiserCanvas, this.renderer, {
15200
+ this.upscaler = new Lf(this.denoiserCanvas, this.renderer, {
15193
15201
  scaleFactor: X.upscalerScale || 2,
15194
15202
  quality: X.upscalerQuality || "fast",
15195
15203
  getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
@@ -15342,7 +15350,7 @@ var Ff = {
15342
15350
  let t = _r[e];
15343
15351
  t && (this._stages.asvgf?.updateParameters(t), this._stages.bilateralFilter?.updateParameters(t), this._stages.variance && t.varianceBoost !== void 0 && (this._stages.variance.varianceBoost.value = t.varianceBoost));
15344
15352
  }
15345
- }, Rf = class {
15353
+ }, zf = class {
15346
15354
  constructor() {
15347
15355
  this.layer = "hud", this.visible = !1, this._tileBounds = null, this._imageWidth = 1, this._imageHeight = 1, this.enabled = !0, this._borderColor = "rgba(255, 0, 0, 0.6)", this._borderWidthRatio = 1 / 540, this._borderWidthMin = 1.5, this._borderWidthMax = 4;
15348
15356
  }
@@ -15366,7 +15374,7 @@ var Ff = {
15366
15374
  dispose() {
15367
15375
  this.visible = !1;
15368
15376
  }
15369
- }, zf = class {
15377
+ }, Bf = class {
15370
15378
  constructor(n, r, i) {
15371
15379
  this.layer = "scene", this.visible = !0, this._outlineNode = _n(r, i, {
15372
15380
  selectedObjects: [],
@@ -15400,7 +15408,7 @@ var Ff = {
15400
15408
  dispose() {
15401
15409
  this.visible = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
15402
15410
  }
15403
- }, Bf = class {
15411
+ }, Vf = class {
15404
15412
  constructor(e, t) {
15405
15413
  this.renderer = e, this.camera = t, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = document.createElement("canvas"), this._hudCanvas.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;", this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null;
15406
15414
  }
@@ -15415,11 +15423,11 @@ var Ff = {
15415
15423
  }
15416
15424
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
15417
15425
  this.setHelperScene(e);
15418
- let s = new Rf();
15426
+ let s = new zf();
15419
15427
  this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
15420
15428
  s.setRenderSize(e.width, e.height);
15421
15429
  }), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
15422
- let c = new zf(this.renderer, t, this.camera);
15430
+ let c = new Bf(this.renderer, t, this.camera);
15423
15431
  this.register("outline", c);
15424
15432
  }
15425
15433
  _wireDenoiserTileEvents(e, t) {
@@ -15486,7 +15494,7 @@ var Ff = {
15486
15494
  for (let e of this._helpers.values()) e.dispose?.();
15487
15495
  this._helpers.clear(), this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
15488
15496
  }
15489
- }, Vf = class extends q {
15497
+ }, Hf = class extends q {
15490
15498
  constructor() {
15491
15499
  super(), this.mixer = null, this.timer = new Qt(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new rn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
15492
15500
  }
@@ -15586,7 +15594,7 @@ var Ff = {
15586
15594
  dispose() {
15587
15595
  this.mixer &&= (this.mixer.stopAllAction(), this.mixer.uncacheRoot(this._mixerRoot), null), this.actions = [], this.isPlaying = !1, this.timer.reset(), this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._skinnedCache = null, this._clipsCache = null;
15588
15596
  }
15589
- }, Hf = class {
15597
+ }, Uf = class {
15590
15598
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
15591
15599
  this._app = r, this._orbitControls = n, this._camera = e, this._controls = new vn(e, t), this._gizmoScene = new Gt(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._tempVec = new rn(), this._normalMatrix = new yt(), this._refitInFlight = !1, this._baselineComputed = !1, this._onDraggingChanged = this._onDraggingChanged.bind(this), this._onObjectChange = this._onObjectChange.bind(this), this._controls.addEventListener("dragging-changed", this._onDraggingChanged), this._controls.addEventListener("objectChange", this._onObjectChange);
15592
15600
  }
@@ -15697,15 +15705,15 @@ var Ff = {
15697
15705
  dispose() {
15698
15706
  this._controls.removeEventListener("dragging-changed", this._onDraggingChanged), this._controls.removeEventListener("objectChange", this._onObjectChange), this.detach(), this._gizmoScene.remove(this._controls.getHelper()), this._controls.dispose(), this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._normalBuffer = null, this._skinnedCache = null, this._normalCache = null, this._baselineComputed = !1, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
15699
15707
  }
15700
- }, Uf = /* @__PURE__ */ new WeakMap(), Wf = class extends q {
15708
+ }, Wf = /* @__PURE__ */ new WeakMap(), Gf = class extends q {
15701
15709
  constructor(e, t = {}) {
15702
15710
  super();
15703
15711
  try {
15704
- Uf.get(e)?.dispose();
15712
+ Wf.get(e)?.dispose();
15705
15713
  } catch (e) {
15706
15714
  console.warn("PathTracerApp: prior canvas owner dispose failed", e);
15707
15715
  }
15708
- Uf.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new qd(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Vf(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new cd(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1;
15716
+ Wf.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Jd(X), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = X.maxTextureSize, this.pipeline = null, this.stages = {}, this.cameraManager = null, this.lightManager = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Hf(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this.pathTracerEnabled = !0, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this.completion = new ld(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1;
15709
15717
  }
15710
15718
  _addTrackedListener(e, t, n) {
15711
15719
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -15726,46 +15734,55 @@ var Ff = {
15726
15734
  return await this._initRenderer(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), this._initManagers(), this._wireEvents(), this.stages.pathTracer.setTriangleData(new Float32Array(32), 0), this.stages.pathTracer.setBVHData(new Float32Array(16)), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, console.log("WebGPU Path Tracer App initialized"), this;
15727
15735
  }
15728
15736
  animate() {
15729
- if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
15730
- this.dispatchEvent({ type: tr.FRAME });
15731
- return;
15732
- }
15733
- if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
15734
- let e = this.animationManager.update();
15735
- e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => console.error("Animation refit error:", e)).finally(() => {
15736
- this._animRefitInFlight = !1;
15737
- }));
15738
- }
15739
- if (this.needsReset &&= (this.reset(!0), !1), this.cameraManager.camera.updateMatrixWorld(), !this.pathTracerEnabled) {
15740
- this.renderer.render(this.meshScene, this.cameraManager.camera), this._renderHelperOverlay();
15741
- return;
15742
- }
15743
- if (!this.pauseRendering) {
15744
- if (this.cameraManager.updateAutoFocus(), this.stages.pathTracer?.isReady) {
15745
- if (this.stages.pathTracer.isComplete && this.completion.renderCompleteDispatched) {
15746
- this._needsDisplayRefresh && (this._needsDisplayRefresh = !1, this.stages.compositor.render(this.pipeline.context), this._renderHelperOverlay()), this.stopAnimation();
15747
- return;
15737
+ if (!this._deviceLost) {
15738
+ if (this.animationManagerId = requestAnimationFrame(() => this.animate()), this._loadingInProgress || this._sdf?.isProcessing) {
15739
+ this.dispatchEvent({ type: tr.FRAME });
15740
+ return;
15741
+ }
15742
+ if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
15743
+ let e = this.animationManager.update();
15744
+ e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => console.error("Animation refit error:", e)).finally(() => {
15745
+ this._animRefitInFlight = !1;
15746
+ }));
15747
+ }
15748
+ if (this.needsReset &&= (this.reset(!0), !1), this.cameraManager.camera.updateMatrixWorld(), !this.pathTracerEnabled) {
15749
+ this.renderer.render(this.meshScene, this.cameraManager.camera), this._renderHelperOverlay();
15750
+ return;
15751
+ }
15752
+ if (!this.pauseRendering) {
15753
+ if (this.cameraManager.updateAutoFocus(), this.stages.pathTracer?.isReady) {
15754
+ if (this.stages.pathTracer.isComplete && this.completion.renderCompleteDispatched) {
15755
+ this._needsDisplayRefresh && (this._needsDisplayRefresh = !1, this.stages.compositor.render(this.pipeline.context), this._renderHelperOverlay()), this.stopAnimation();
15756
+ return;
15757
+ }
15758
+ this.pipeline.render(), this.stages.pathTracer.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
15759
+ let e = this.stages.pathTracer?.vramTracker, t = this.stages.pathTracer?.frameCount ?? 0;
15760
+ e && (t <= 1 || t % 30 == 0) && e.measure(), or({
15761
+ timeElapsed: this.completion.timeElapsed,
15762
+ samples: sr(this.stages.pathTracer),
15763
+ memoryUsed: e?.current ?? 0,
15764
+ memoryPeak: e?.peak ?? 0
15765
+ }), this.completion.isTimeLimitReached(this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (this.stages.pathTracer.isComplete = !0), this.stages.pathTracer.isComplete && this.completion.markComplete() && (this.denoisingManager.onRenderComplete({
15766
+ isStillComplete: () => this.completion.renderCompleteDispatched,
15767
+ context: this.pipeline?.context
15768
+ }), this.dispatchEvent({ type: "RenderComplete" }), this.dispatchEvent({ type: tr.RENDER_COMPLETE }));
15748
15769
  }
15749
- this.pipeline.render(), this.stages.pathTracer.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
15750
- let e = this.stages.pathTracer?.vramTracker, t = this.stages.pathTracer?.frameCount ?? 0;
15751
- e && (t <= 1 || t % 30 == 0) && e.measure(), or({
15752
- timeElapsed: this.completion.timeElapsed,
15753
- samples: sr(this.stages.pathTracer),
15754
- memoryUsed: e?.current ?? 0,
15755
- memoryPeak: e?.peak ?? 0
15756
- }), this.completion.isTimeLimitReached(this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (this.stages.pathTracer.isComplete = !0), this.stages.pathTracer.isComplete && this.completion.markComplete() && (this.denoisingManager.onRenderComplete({
15757
- isStillComplete: () => this.completion.renderCompleteDispatched,
15758
- context: this.pipeline?.context
15759
- }), this.dispatchEvent({ type: "RenderComplete" }), this.dispatchEvent({ type: tr.RENDER_COMPLETE }));
15770
+ this._renderHelperOverlay(), this.dispatchEvent({ type: tr.FRAME });
15760
15771
  }
15761
- this._renderHelperOverlay(), this.dispatchEvent({ type: tr.FRAME });
15762
15772
  }
15763
15773
  }
15764
15774
  stopAnimation() {
15765
15775
  this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
15766
15776
  }
15777
+ _handleDeviceLost(e) {
15778
+ this._deviceLost || (this._deviceLost = !0, console.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
15779
+ type: tr.DEVICE_LOST,
15780
+ reason: e?.reason,
15781
+ message: e?.message
15782
+ }));
15783
+ }
15767
15784
  wake() {
15768
- !this.animationManagerId && this.isInitialized && !this._paused && this.animate();
15785
+ this._deviceLost || !this.animationManagerId && this.isInitialized && !this._paused && this.animate();
15769
15786
  }
15770
15787
  pause() {
15771
15788
  this._paused = !0, this.stopAnimation();
@@ -16043,35 +16060,39 @@ var Ff = {
16043
16060
  maxColorAttachmentBytesPerSample: 128,
16044
16061
  maxStorageBuffersPerShaderStage: Math.min(t.maxStorageBuffersPerShaderStage, 10)
16045
16062
  }
16046
- }), await this.renderer.init(), r.setLTC(an.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = Ve, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
16063
+ }), await this.renderer.init();
16064
+ let n = this.renderer.backend?.device;
16065
+ n?.lost && (n.lost.then((e) => {
16066
+ this._disposed || this._handleDeviceLost(e);
16067
+ }), n.onuncapturederror = (e) => console.error("WebGPU uncaptured error:", e.error)), r.setLTC(an.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = Ve, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
16047
16068
  }
16048
16069
  _initCameraManager() {
16049
- this.cameraManager = new Jd(this.canvas);
16070
+ this.cameraManager = new Yd(this.canvas);
16050
16071
  }
16051
16072
  _initScenes() {
16052
16073
  this.scene = new Gt(), this.meshScene = new Gt(), this._sceneHelpers = new An();
16053
16074
  }
16054
16075
  _initAssetPipeline() {
16055
- this._sdf = new Vs(), this.assetLoader = new Wd(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
16076
+ this._sdf = new Vs(), this.assetLoader = new Gd(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
16056
16077
  this.needsReset = !0, this.wake();
16057
16078
  });
16058
16079
  }
16059
16080
  _initPipeline() {
16060
16081
  this._createStages();
16061
16082
  let { clientWidth: e, clientHeight: t } = this.canvas;
16062
- this.pipeline = new sd(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
16083
+ this.pipeline = new cd(this.renderer, e || 1, t || 1), this.pipeline.addStage(this.stages.pathTracer), this.pipeline.addStage(this.stages.normalDepth), this.pipeline.addStage(this.stages.motionVector), this.pipeline.addStage(this.stages.ssrc), this.pipeline.addStage(this.stages.asvgf), this.pipeline.addStage(this.stages.variance), this.pipeline.addStage(this.stages.bilateralFilter), this.pipeline.addStage(this.stages.edgeFilter), this.pipeline.addStage(this.stages.autoExposure), this.pipeline.addStage(this.stages.compositor);
16063
16084
  let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
16064
16085
  this.pipeline.setSize(n, r);
16065
16086
  }
16066
16087
  _initManagers() {
16067
- this.interactionManager = new ld({
16088
+ this.interactionManager = new ud({
16068
16089
  scene: this.meshScene,
16069
16090
  camera: this.cameraManager.camera,
16070
16091
  canvas: this.canvas,
16071
16092
  assetLoader: this.assetLoader,
16072
16093
  pathTracer: null,
16073
16094
  floorPlane: this.assetLoader.floorPlane
16074
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Yd(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Xd(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new cf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new Hf({
16095
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Xd(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Zd(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new lf(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), this._setupOverlayManager(), this.transformManager = new Uf({
16075
16096
  camera: this.cameraManager.camera,
16076
16097
  canvas: this.canvas,
16077
16098
  orbitControls: this.cameraManager.controls,
@@ -16141,10 +16162,10 @@ var Ff = {
16141
16162
  this.transformManager?.setMeshData(this._sdf.meshes);
16142
16163
  }
16143
16164
  _createStages() {
16144
- this.stages.pathTracer = new Iu(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new Lu(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new Ru(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new rd(this.renderer, { enabled: !1 }), this.stages.asvgf = new Vu(this.renderer, { enabled: !1 }), this.stages.variance = new Wu(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new Ku(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new qu(this.renderer, { enabled: !1 }), this.stages.autoExposure = new ed(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new id(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
16165
+ this.stages.pathTracer = new Lu(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new Ru(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new zu(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.ssrc = new id(this.renderer, { enabled: !1 }), this.stages.asvgf = new Hu(this.renderer, { enabled: !1 }), this.stages.variance = new Gu(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new qu(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new Ju(this.renderer, { enabled: !1 }), this.stages.autoExposure = new td(this.renderer, { enabled: X.autoExposure ?? !1 }), this.stages.compositor = new ad(this.renderer, { saturation: this.settings.get("saturation") ?? X.saturation });
16145
16166
  }
16146
16167
  _setupDenoisingManager() {
16147
- this.denoisingManager = new Lf({
16168
+ this.denoisingManager = new Rf({
16148
16169
  renderer: this.renderer,
16149
16170
  mainCanvas: this.canvas,
16150
16171
  scene: this.scene,
@@ -16188,7 +16209,7 @@ var Ff = {
16188
16209
  this.scene.updateMatrixWorld(), this.overlayManager?.render(), this.transformManager?.render(this.renderer);
16189
16210
  }
16190
16211
  _setupOverlayManager() {
16191
- this.overlayManager = new Bf(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
16212
+ this.overlayManager = new Vf(this.renderer, this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
16192
16213
  helperScene: this._sceneHelpers,
16193
16214
  meshScene: this.meshScene,
16194
16215
  pipeline: this.pipeline,
@@ -16204,7 +16225,7 @@ var Ff = {
16204
16225
  _forwardEvents(e, t) {
16205
16226
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
16206
16227
  }
16207
- }, Gf = class {
16228
+ }, Kf = class {
16208
16229
  constructor(e) {
16209
16230
  this._app = e, this._cancelled = !1, this._rendering = !1;
16210
16231
  }
@@ -16302,6 +16323,6 @@ var Ff = {
16302
16323
  }
16303
16324
  };
16304
16325
  //#endregion
16305
- export { Sr as AF_DEFAULTS, _r as ASVGF_QUALITY_PRESETS, xr as AUTO_FOCUS_MODES, Vf as AnimationManager, Cr as BVH_LEAF_MARKERS, br as CAMERA_PRESETS, vr as CAMERA_RANGES, Jd as CameraManager, Or as DEFAULT_TEXTURE_MATRIX, Lf as DenoisingManager, X as ENGINE_DEFAULTS, tr as EngineEvents, Xd as GoboManager, cf as IESManager, Ar as INTERACTIVE_RENDER_CONFIG, ld as InteractionManager, Yd as LightManager, jr as MEMORY_CONSTANTS, Bf as OverlayManager, kr as PRODUCTION_RENDER_CONFIG, Wf as PathTracerApp, ad as PipelineContext, sd as RenderPipeline, qd as RenderSettings, $n as RenderStage, yr as SKY_PRESETS, Qn as StageExecutionMode, wr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, Hf as TransformManager, Hc as VRAMTracker, Gf as VideoRenderManager, Bc as bufferBytes, Xs as configureAssets, Zs as getAssetConfig, Vc as textureBytes };
16326
+ export { Sr as AF_DEFAULTS, _r as ASVGF_QUALITY_PRESETS, xr as AUTO_FOCUS_MODES, Hf as AnimationManager, Cr as BVH_LEAF_MARKERS, br as CAMERA_PRESETS, vr as CAMERA_RANGES, Yd as CameraManager, Or as DEFAULT_TEXTURE_MATRIX, Rf as DenoisingManager, X as ENGINE_DEFAULTS, tr as EngineEvents, Zd as GoboManager, lf as IESManager, Ar as INTERACTIVE_RENDER_CONFIG, ud as InteractionManager, Xd as LightManager, jr as MEMORY_CONSTANTS, Vf as OverlayManager, kr as PRODUCTION_RENDER_CONFIG, Gf as PathTracerApp, od as PipelineContext, cd as RenderPipeline, Jd as RenderSettings, $n as RenderStage, yr as SKY_PRESETS, Qn as StageExecutionMode, wr as TEXTURE_CONSTANTS, Z as TRIANGLE_DATA_LAYOUT, Uf as TransformManager, Uc as VRAMTracker, Kf as VideoRenderManager, Vc as bufferBytes, Xs as configureAssets, Zs as getAssetConfig, Hc as textureBytes };
16306
16327
 
16307
16328
  //# sourceMappingURL=rayzee.es.js.map