rayzee 7.22.5 → 7.22.7

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
@@ -1244,7 +1244,7 @@ var di = class {
1244
1244
  let r = V(t, n);
1245
1245
  return this._uniforms.set(e, r), r;
1246
1246
  }, r = (e, t) => (this._booleans.add(e), n(e, +!!t, "int"));
1247
- n("frame", 0, "uint"), n("seedFrame", 0, "uint"), n("maxBounces", Y.bounces, "int"), n("maxSamples", Y.maxSamples, "int"), n("transmissiveBounces", Y.transmissiveBounces, "int"), n("maxSubsurfaceSteps", Y.maxSubsurfaceSteps, "int"), n("maxTransparentBounces", Y.maxTransparentBounces, "int"), n("visMode", Y.debugMode, "int"), n("debugVisScale", Y.debugVisScale, "float"), r("useAdaptiveSampling", Y.useAdaptiveSampling), n("noiseThreshold", Y.noiseThreshold, "float"), n("adaptiveMinSamples", Y.adaptiveMinSamples, "int"), n("adaptiveStopFraction", Y.adaptiveStopFraction, "float"), r("usePixelFreeze", Y.usePixelFreeze), n("pixelFreezeThreshold", Y.pixelFreezeThreshold, "float"), n("pixelFreezeStability", Y.pixelFreezeStability, "int"), r("convergenceOverlay", Y.convergenceOverlay), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("environmentIntensity", Y.environmentIntensity, "float"), n("backgroundIntensity", Y.backgroundIntensity, "float"), n("backgroundColor", new et(0, 0, 0), "color"), n("backgroundBlurriness", Y.backgroundBlurriness, "float"), n("backgroundBlurSamples", Y.backgroundBlurSamples, "int"), r("showBackground", Y.showBackground), r("transparentBackground", Y.transparentBackground), r("enableEnvironment", Y.enableEnvironment), n("environmentMatrix", new St(), "mat4"), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new on(1, 1), "vec2"), r("groundProjectionEnabled", Y.groundProjectionEnabled), n("groundProjectionRadius", Y.groundProjectionRadius, "float"), n("groundProjectionHeight", Y.groundProjectionHeight, "float"), n("groundProjectionLevel", Y.groundProjectionLevel, "float"), r("enableGroundCatcher", Y.enableGroundCatcher), n("groundCatcherHeight", Y.groundCatcherHeight, "float"), n("sunDirection", new sn(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", Y.globalIlluminationIntensity, "float"), n("exposure", Y.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
1247
+ n("frame", 0, "uint"), n("seedFrame", 0, "uint"), n("maxBounces", Y.bounces, "int"), n("maxSamples", Y.maxSamples, "int"), n("transmissiveBounces", Y.transmissiveBounces, "int"), n("maxSubsurfaceSteps", Y.maxSubsurfaceSteps, "int"), n("maxTransparentBounces", Y.maxTransparentBounces, "int"), n("visMode", Y.debugMode, "int"), n("debugVisScale", Y.debugVisScale, "float"), r("useAdaptiveSampling", Y.useAdaptiveSampling), n("noiseThreshold", Y.noiseThreshold, "float"), n("adaptiveMinSamples", Y.adaptiveMinSamples, "int"), n("adaptiveStopFraction", Y.adaptiveStopFraction, "float"), r("usePixelFreeze", Y.usePixelFreeze), n("pixelFreezeThreshold", Y.pixelFreezeThreshold, "float"), n("pixelFreezeStability", Y.pixelFreezeStability, "int"), r("convergenceOverlay", Y.convergenceOverlay), r("enableAccumulation", !0), n("accumulationAlpha", 0, "float"), r("cameraIsMoving", !1), r("hasPreviousAccumulated", !1), n("auxAccumulationAlpha", 1, "float"), r("hasPreviousAux", !1), n("environmentIntensity", Y.environmentIntensity, "float"), n("backgroundIntensity", Y.backgroundIntensity, "float"), n("backgroundColor", new et(0, 0, 0), "color"), n("backgroundBlurriness", Y.backgroundBlurriness, "float"), n("backgroundBlurSamples", Y.backgroundBlurSamples, "int"), r("showBackground", Y.showBackground), r("transparentBackground", Y.transparentBackground), r("enableEnvironment", Y.enableEnvironment), n("environmentMatrix", new St(), "mat4"), n("envTotalSum", 0, "float"), n("envCompensationDelta", 0, "float"), n("envResolution", new on(1, 1), "vec2"), r("groundProjectionEnabled", Y.groundProjectionEnabled), n("groundProjectionRadius", Y.groundProjectionRadius, "float"), n("groundProjectionHeight", Y.groundProjectionHeight, "float"), n("groundProjectionLevel", Y.groundProjectionLevel, "float"), r("enableGroundCatcher", Y.enableGroundCatcher), n("groundCatcherHeight", Y.groundCatcherHeight, "float"), n("sunDirection", new sn(0, 1, 0), "vec3"), n("sunAngularSize", .0087, "float"), r("hasSun", !1), n("globalIlluminationIntensity", Y.globalIlluminationIntensity, "float"), n("exposure", Y.exposure, "float"), n("numDirectionalLights", 0, "int"), n("numAreaLights", 0, "int"), n("numPointLights", 0, "int"), n("numSpotLights", 0, "int"), this._lightBuffers = {
1248
1248
  directional: Pe(new Float32Array(192), "float"),
1249
1249
  area: Pe(new Float32Array(256), "float"),
1250
1250
  point: Pe(new Float32Array(144), "float"),
@@ -10468,47 +10468,47 @@ function Hd(e) {
10468
10468
  }
10469
10469
  var Ud = /* @__PURE__ */ K("\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");
10470
10470
  function Wd(e) {
10471
- 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, prevNormalDepthTexture: _, renderWidth: v, chunkRowBase: y, chunkRows: b, visMode: x, auxGBufferEnabled: S, cleanAuxNormalEnabled: C, m2BufferRW: w, useAdaptiveSampling: T, noiseThreshold: E, adaptiveMinSamples: D, usePixelFreeze: O, pixelFreezeThreshold: k, streakBufferRW: A, frozenMaskRO: ee, convergenceOverlay: te } = e, ne = S.greaterThan(B(0)), re = C.greaterThan(B(0)), ie = T.greaterThan(N(0)), M = O.greaterThan(N(0)), P = ie.or(M).or(te.greaterThan(N(0)));
10471
+ let { rayBufferRO: t, gBufferRO: n, writeColorTex: r, writeNDTex: i, writeAlbedoTex: a, resolution: o, frame: s, enableAccumulation: c, hasPreviousAccumulated: l, accumulationAlpha: u, cameraIsMoving: d, hasPreviousAux: m, auxAccumulationAlpha: h, transparentBackground: g, prevAccumTexture: _, prevAlbedoTexture: v, prevNormalDepthTexture: y, renderWidth: b, chunkRowBase: x, chunkRows: S, visMode: C, auxGBufferEnabled: w, cleanAuxNormalEnabled: T, m2BufferRW: E, useAdaptiveSampling: D, noiseThreshold: O, adaptiveMinSamples: k, usePixelFreeze: A, pixelFreezeThreshold: ee, streakBufferRW: te, frozenMaskRO: ne, convergenceOverlay: re } = e, ie = w.greaterThan(B(0)), M = T.greaterThan(B(0)), P = D.greaterThan(N(0)), oe = A.greaterThan(N(0)), ce = P.or(oe).or(re.greaterThan(N(0)));
10472
10472
  return f(() => {
10473
10473
  let e = N(Ve.x).mul(16).add(N(se.x)), f = N(Ve.y).mul(16).add(N(se.y));
10474
- p(e.lessThan(v).and(f.lessThan(b)), () => {
10475
- let b = f.add(y), S = B(f.mul(v).add(e)), C = B(b.mul(v).add(e)), T = wl(t, S), O = T.xyz.toVar(), te = R(m, T.w, j(1)).toVar(), oe = M.and(s.greaterThan(B(0))).and(ee.element(C).equal(B(1))).toVar(), se = G(0).toVar(), ce = G(0).xyz.toVar();
10476
- p(ne, () => {
10477
- let e = Dl(n, S);
10478
- se.assign(Ol(e)), ce.assign(G(kl(e), 0).xyz);
10474
+ p(e.lessThan(b).and(f.lessThan(S)), () => {
10475
+ let S = f.add(x), w = B(f.mul(b).add(e)), T = B(S.mul(b).add(e)), D = wl(t, w), A = D.xyz.toVar(), re = R(g, D.w, j(1)).toVar(), se = oe.and(s.greaterThan(B(0))).and(ne.element(T).equal(B(1))).toVar(), le = G(0).toVar(), ue = G(0).xyz.toVar();
10476
+ p(ie, () => {
10477
+ let e = Dl(n, w);
10478
+ le.assign(Ol(e)), ue.assign(G(kl(e), 0).xyz);
10479
10479
  });
10480
- let le = U(j(e).add(.5), j(b).add(.5)).div(o);
10481
- p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(x.notEqual(N(11))), () => {
10482
- let e = Ae(h, le, 0).toVar();
10483
- O.assign(R(oe, e.xyz, I(e.xyz, T.xyz, u))), p(ne, () => {
10484
- ce.assign(I(Ae(g, le, 0).xyz, ce, u)), p(re, () => {
10485
- let e = Ae(_, le, 0).xyz.mul(2).sub(1), t = se.xyz.mul(2).sub(1).toVar(), n = I(e, t, u).toVar(), r = ae(n), i = R(r.greaterThan(1e-4), n.div(r), t);
10486
- se.assign(G(i.mul(.5).add(.5), se.w));
10480
+ let F = U(j(e).add(.5), j(S).add(.5)).div(o);
10481
+ p(c.and(d.not()).and(s.greaterThan(B(0))).and(l).and(C.notEqual(N(11))), () => {
10482
+ let e = Ae(_, F, 0).toVar();
10483
+ A.assign(R(se, e.xyz, I(e.xyz, D.xyz, u))), p(ie.and(m), () => {
10484
+ ue.assign(I(Ae(v, F, 0).xyz, ue, h)), p(M, () => {
10485
+ let e = Ae(y, F, 0).xyz.mul(2).sub(1), t = le.xyz.mul(2).sub(1).toVar(), n = I(e, t, h).toVar(), r = ae(n), i = R(r.greaterThan(1e-4), n.div(r), t);
10486
+ le.assign(G(i.mul(.5).add(.5), le.w));
10487
10487
  });
10488
- }), p(m, () => {
10489
- te.assign(R(oe, e.w, I(e.w, T.w, u)));
10488
+ }), p(g, () => {
10489
+ re.assign(R(se, e.w, I(e.w, D.w, u)));
10490
10490
  });
10491
- }), p(P, () => {
10492
- let e = Oa(T.xyz), t = I(w.element(C).toVar(), e.mul(e), u).toVar();
10493
- w.element(C).assign(t);
10494
- let n = Oa(O).toVar(), r = t.sub(n.mul(n)).max(j(0)).div(j(s).add(1)).sqrt().toVar(), i = r.div(n.add(j(1e-4))), a = R(n.lessThan(j(1)), n.sqrt(), n), o = r.div(a.add(j(1e-4))).lessThan(E);
10495
- p(ie.or(M), () => {
10496
- let e = ie.and(s.greaterThanEqual(B(D))).and(o), t = A.element(C).toVar(), r = t.bitAnd(B(1073741823)).toVar(), a = r.toVar(), c = T.w.greaterThan(j(.5)), l = t.bitAnd(B(1073741824)).notEqual(B(0)), u = R(s.equal(B(0)), R(c, B(1073741824), B(0)), R(c.or(l), B(1073741824), B(0))).toVar();
10497
- p(M, () => {
10491
+ }), p(ce, () => {
10492
+ let e = Oa(D.xyz), t = I(E.element(T).toVar(), e.mul(e), u).toVar();
10493
+ E.element(T).assign(t);
10494
+ let n = Oa(A).toVar(), r = t.sub(n.mul(n)).max(j(0)).div(j(s).add(1)).sqrt().toVar(), i = r.div(n.add(j(1e-4))), a = R(n.lessThan(j(1)), n.sqrt(), n), o = r.div(a.add(j(1e-4))).lessThan(O);
10495
+ p(P.or(oe), () => {
10496
+ let e = P.and(s.greaterThanEqual(B(k))).and(o), t = te.element(T).toVar(), r = t.bitAnd(B(1073741823)).toVar(), a = r.toVar(), c = D.w.greaterThan(j(.5)), l = t.bitAnd(B(1073741824)).notEqual(B(0)), u = R(s.equal(B(0)), R(c, B(1073741824), B(0)), R(c.or(l), B(1073741824), B(0))).toVar();
10497
+ p(oe, () => {
10498
10498
  p(s.equal(B(0)), () => {
10499
10499
  a.assign(B(0));
10500
- }), p(oe.not().and(s.greaterThan(B(0))), () => {
10501
- let e = s.greaterThanEqual(B(D)).and(i.lessThan(k)).and(n.greaterThan(j(0)));
10500
+ }), p(se.not().and(s.greaterThan(B(0))), () => {
10501
+ let e = s.greaterThanEqual(B(k)).and(i.lessThan(ee)).and(n.greaterThan(j(0)));
10502
10502
  a.assign(R(e, r.add(B(1)), B(0)));
10503
10503
  });
10504
- }), A.element(C).assign(a.bitOr(R(e, B(2147483648), B(0))).bitOr(u));
10504
+ }), te.element(T).assign(a.bitOr(R(e, B(2147483648), B(0))).bitOr(u));
10505
10505
  });
10506
- }), p(x.equal(N(11)), () => {
10507
- O.assign(Ud(O));
10506
+ }), p(C.equal(N(11)), () => {
10507
+ A.assign(Ud(A));
10508
10508
  });
10509
- let ue = Le(B(e), B(b));
10510
- Me(r, ue, G(O, te)).toWriteOnly(), p(ne, () => {
10511
- Me(i, ue, se).toWriteOnly(), Me(a, ue, G(ce, 1)).toWriteOnly();
10509
+ let de = Le(B(e), B(S));
10510
+ Me(r, de, G(A, re)).toWriteOnly(), p(ie, () => {
10511
+ Me(i, de, le).toWriteOnly(), Me(a, de, G(ue, 1)).toWriteOnly();
10512
10512
  });
10513
10513
  });
10514
10514
  });
@@ -10746,7 +10746,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
10746
10746
  "compactCopyback"
10747
10747
  ], rf = class extends dl {
10748
10748
  constructor(e, t, n, r = {}) {
10749
- super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = V(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = 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._curveSizingValid = !1, this._bounceEarlyExitThreshold = 100, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._geometryPixelCount = 0, this._convergedReadbackPending = !1, this._lastActivePixelCount = 0, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this._wfChunkRowBase = V(0, "int"), this._wfChunkRows = V(0, "int"), this._wfIsFirstChunk = V(1, "uint"), this._pathBudget = 0, this._pathBudgetOverride = 0, this._chunkRows = 0, this._numChunks = 1, this.vramTracker = new uu(this.renderer), this._registerVRAMProviders(), ef.debug("initialized (wavefront)");
10749
+ super(e, t, n, r), this.name = "PathTracer", this._packedBuffers = null, this._queueManager = null, this._kernelManager = null, this._gBufferAttr = null, this._m2Attr = null, this._streakAttr = null, this._frozenMaskAttr = null, this._convDebugSource = null, this._dilateFrozenUniform = V(1, "int"), this._wavefrontReady = !1, this._auxGBufferEnabled = !1, this._auxGBufferUniform = V(0, "uint"), this._cleanAuxNormalEnabled = !1, this._cleanAuxNormalUniform = V(0, "uint"), this._auxSamples = 0, this._auxSeedPending = !1, 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._curveSizingValid = !1, this._bounceEarlyExitThreshold = 100, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._geometryPixelCount = 0, this._convergedReadbackPending = !1, this._lastActivePixelCount = 0, this._wfRenderWidth = V(1920, "int"), this._wfRenderHeight = V(1080, "int"), this._wfMaxRayCount = V(0, "uint"), this._wfCurrentBounce = V(0, "int"), this._wfChunkRowBase = V(0, "int"), this._wfChunkRows = V(0, "int"), this._wfIsFirstChunk = V(1, "uint"), this._pathBudget = 0, this._pathBudgetOverride = 0, this._chunkRows = 0, this._numChunks = 1, this.vramTracker = new uu(this.renderer), this._registerVRAMProviders(), ef.debug("initialized (wavefront)");
10750
10750
  }
10751
10751
  _registerVRAMProviders() {
10752
10752
  let e = this.vramTracker;
@@ -10798,58 +10798,61 @@ var ef = ai("wavefront"), tf = 256, nf = [
10798
10798
  }
10799
10799
  render(e) {
10800
10800
  if (!this.isReady || !this._wavefrontReady || this._lightBufferRealloc && (this._kernelManager && this._kernelManager.dispose(), this._wavefrontReady = !1, this._buildWavefrontKernels(), !this._wavefrontReady)) return;
10801
- if (this.isComplete || this.frameCount >= this.completionThreshold || this._isConvergedComplete()) {
10801
+ if (this.isComplete || this.frameCount >= this.completionThreshold || this._isConvergedComplete()) if (this._auxSeedPending) this.isComplete = !1;
10802
+ else {
10802
10803
  this.isComplete ||= !0;
10803
10804
  return;
10804
10805
  }
10805
10806
  this.performanceMonitor?.start();
10806
10807
  let t = this.frameCount, n = this.renderMode.value, r = null;
10807
- n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this.cameraChanged && (this._curveSizingValid = !1, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0), this._updateAccumulationUniforms(t, n), this.frame.value = t, this.seedFrame.value = this._seedTick++, this._setWfDispatch();
10808
- let i = this.storageTextures.getReadTextures();
10809
- this.shaderBuilder.prevColorTexNode && (this.shaderBuilder.prevColorTexNode.value = i.color, this.shaderBuilder.prevAlbedoTexNode.value = i.albedo, this.shaderBuilder.prevNormalDepthTexNode.value = i.normalDepth), this._refreshWfTextureNodes();
10810
- let a = this._kernelManager;
10808
+ n === 1 && t === 0 && (r = this.maxBounces.value, this.maxBounces.value = 1), this._handleResize(), this.manageASVGFForRenderMode(n), e && e.setState("tileRenderingComplete", !0), this.cameraChanged = this._updateCameraUniforms(), this.cameraOptimizer?.updateInteractionMode(this.cameraChanged), this.cameraChanged && (this._curveSizingValid = !1, this._readbackGeneration++, this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0), this._updateAccumulationUniforms(t, n);
10809
+ let i = this._updateAuxAccumulationUniforms(t);
10810
+ this.frame.value = t, this.seedFrame.value = this._seedTick++, this._setWfDispatch();
10811
+ let a = this.storageTextures.getReadTextures();
10812
+ this.shaderBuilder.prevColorTexNode && (this.shaderBuilder.prevColorTexNode.value = a.color, this.shaderBuilder.prevAlbedoTexNode.value = a.albedo, this.shaderBuilder.prevNormalDepthTexNode.value = a.normalDepth), this._refreshWfTextureNodes();
10813
+ let o = this._kernelManager;
10811
10814
  if ((this.visMode?.value | 0) > 0 && this.visMode.value !== 11) {
10812
- a.dispatch("debug"), this.storageTextures.copyToReadTargets(this.renderer);
10815
+ o.dispatch("debug"), this.storageTextures.copyToReadTargets(this.renderer);
10813
10816
  let t = this.storageTextures.getReadTextures();
10814
10817
  e && this._publishTexturesToContext(e, t), this._emitStateEvents(), this.cameraOptimizer?.isInInteractionMode() || this.frameCount++, r !== null && (this.maxBounces.value = r), this.performanceMonitor?.end();
10815
10818
  return;
10816
10819
  }
10817
- let o = this.maxBounces.value, s = o + this.transmissiveBounces.value + this.maxSubsurfaceSteps.value, c = this._wfRenderHeight.value, l = this._chunkRows, u = this._numChunks <= 1, d = this._lastBounceCounts, f = u && d ? o <= this._lastBounceCountsBudget ? s + 1 : this._lastBounceCountsBudget : 0;
10818
- for (let e = 0, n = 0; n < c; n += l, e++) {
10819
- let r = Math.min(l, c - n), i = this._setChunk(n, r, e), o = this.usePixelFreeze.value > 0, p = u && o && this._curveSizingValid && this._lastActivePixelCount > 0 ? this._lastActivePixelCount : i;
10820
- if (o) {
10821
- let e = Math.min(i, Math.ceil(p * 1.5) + 1024);
10822
- a.setDispatchForCount("generateList", e), a.dispatch("resetFrameCounters"), a.dispatch("buildActivePixels"), a.dispatch("seedEnter"), a.dispatch("generateList");
10823
- } else a.dispatch("generate"), a.dispatch("initActiveIndices");
10824
- e === 0 && t > 0 && this.useAdaptiveSampling.value > 0 && this._willReadCountersThisFrame() && a.dispatch("countConvergedDilated");
10825
- for (let e = 0; e <= s; e++) {
10820
+ let s = this.maxBounces.value, c = s + this.transmissiveBounces.value + this.maxSubsurfaceSteps.value, l = this._wfRenderHeight.value, u = this._chunkRows, d = this._numChunks <= 1, f = this._lastBounceCounts, p = d && f ? s <= this._lastBounceCountsBudget ? c + 1 : this._lastBounceCountsBudget : 0;
10821
+ for (let e = 0, n = 0; n < l; n += u, e++) {
10822
+ let r = Math.min(u, l - n), i = this._setChunk(n, r, e), a = this.usePixelFreeze.value > 0 && !this._auxSeedPending, s = d && a && this._curveSizingValid && this._lastActivePixelCount > 0 ? this._lastActivePixelCount : i;
10823
+ if (a) {
10824
+ let e = Math.min(i, Math.ceil(s * 1.5) + 1024);
10825
+ o.setDispatchForCount("generateList", e), o.dispatch("resetFrameCounters"), o.dispatch("buildActivePixels"), o.dispatch("seedEnter"), o.dispatch("generateList");
10826
+ } else o.dispatch("generate"), o.dispatch("initActiveIndices");
10827
+ e === 0 && t > 0 && this.useAdaptiveSampling.value > 0 && this._willReadCountersThisFrame() && o.dispatch("countConvergedDilated");
10828
+ for (let e = 0; e <= c; e++) {
10826
10829
  this._wfCurrentBounce.value = e;
10827
10830
  let t = this._useDynamicDispatch;
10828
10831
  if (t) {
10829
10832
  let t = i;
10830
- if (u && e > 0 && this._curveSizingValid) {
10833
+ if (d && e > 0 && this._curveSizingValid) {
10831
10834
  let n = e - 1, r;
10832
- n < f && d[n] !== void 0 ? r = d[n] : f > 0 && (r = d[f - 1]), t = r > 0 ? r : i;
10833
- } else e === 0 && o && (t = p);
10835
+ n < p && f[n] !== void 0 ? r = f[n] : p > 0 && (r = f[p - 1]), t = r > 0 ? r : i;
10836
+ } else e === 0 && a && (t = s);
10834
10837
  let n = Math.min(i, Math.ceil(t * 1.5) + 1024);
10835
- for (let e of nf) a.setDispatchForCount(e, n);
10838
+ for (let e of nf) o.setDispatchForCount(e, n);
10836
10839
  } else {
10837
- a.dispatch("enterFull");
10838
- for (let e of nf) a.setDispatchForCount(e, i);
10840
+ o.dispatch("enterFull");
10841
+ for (let e of nf) o.setDispatchForCount(e, i);
10839
10842
  }
10840
- if (a.dispatch("extend"), this._sortMaterials && (a.dispatch("resetGlobalHist"), a.dispatch("globalHist"), a.dispatch("globalPrefix"), a.dispatch("globalScatter")), a.dispatch("shade"), a.dispatch("compact"), t ? a.dispatch("compactCopyback") : a.dispatch("snapshotBounceCount"), e < f && e < s && d[e] !== void 0 && d[e] <= this._bounceEarlyExitThreshold) break;
10843
+ if (o.dispatch("extend"), this._sortMaterials && (o.dispatch("resetGlobalHist"), o.dispatch("globalHist"), o.dispatch("globalPrefix"), o.dispatch("globalScatter")), o.dispatch("shade"), o.dispatch("compact"), t ? o.dispatch("compactCopyback") : o.dispatch("snapshotBounceCount"), e < p && e < c && f[e] !== void 0 && f[e] <= this._bounceEarlyExitThreshold) break;
10841
10844
  }
10842
- a.dispatch("finalWrite");
10845
+ o.dispatch("finalWrite");
10843
10846
  }
10844
10847
  this._maybeReadbackCounters(), this.storageTextures.copyToReadTargets(this.renderer, this._auxGBufferEnabled);
10845
- let p = this.storageTextures.getReadTextures();
10846
- e && this._publishTexturesToContext(e, p), this._emitStateEvents(), this.cameraOptimizer?.isInInteractionMode() || this.frameCount++, r !== null && (this.maxBounces.value = r), this.performanceMonitor?.end();
10848
+ let m = this.storageTextures.getReadTextures();
10849
+ e && this._publishTexturesToContext(e, m), this._emitStateEvents(), this.cameraOptimizer?.isInInteractionMode() || this.frameCount++, this._auxGBufferEnabled && (this._auxSamples = i ? this._auxSamples + 1 : 1), this._auxSeedPending = !1, r !== null && (this.maxBounces.value = r), this.performanceMonitor?.end();
10847
10850
  }
10848
10851
  _isConvergedComplete() {
10849
10852
  return this.useAdaptiveSampling.value > 0 && this.frameCount >= this.adaptiveMinSamples.value && this._convergedFraction >= this.adaptiveStopFraction.value && this._convergedGeometryFraction >= this.adaptiveStopFraction.value;
10850
10853
  }
10851
10854
  reset() {
10852
- super.reset(), this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0;
10855
+ super.reset(), this._convergedFraction = 0, this._convergedGeometryFraction = 0, this._lastActivePixelCount = 0, this._auxSamples = 0, this._auxSeedPending = !1;
10853
10856
  }
10854
10857
  getConvergenceDebugSource() {
10855
10858
  return !this._m2Attr || !this._frozenMaskAttr ? null : (this._convDebugSource?.m2 === this._m2Attr && this._convDebugSource.frozenMask === this._frozenMaskAttr || (this._convDebugSource = {
@@ -10880,10 +10883,17 @@ var ef = ai("wavefront"), tf = 256, nf = [
10880
10883
  super._handleResize(), this._rebuildKernelsIfResized(e, t);
10881
10884
  }
10882
10885
  setAuxGBufferEnabled(e) {
10883
- e = !!e, this._auxGBufferEnabled !== e && (this._auxGBufferEnabled = e, this._auxGBufferUniform.value = +!!e, this.reset());
10886
+ e = !!e, this._auxGBufferEnabled !== e && (this._auxGBufferEnabled = e, this._auxGBufferUniform.value = +!!e, this.restartAuxAccumulation());
10884
10887
  }
10885
10888
  setCleanAuxNormal(e) {
10886
- e = !!e, this._cleanAuxNormalEnabled !== e && (this._cleanAuxNormalEnabled = e, this._cleanAuxNormalUniform.value = +!!e, this.reset());
10889
+ e = !!e, this._cleanAuxNormalEnabled !== e && (this._cleanAuxNormalEnabled = e, this._cleanAuxNormalUniform.value = +!!e, this.restartAuxAccumulation());
10890
+ }
10891
+ restartAuxAccumulation() {
10892
+ this._auxSamples = 0, this._auxSeedPending = this._auxGBufferEnabled;
10893
+ }
10894
+ _updateAuxAccumulationUniforms(e) {
10895
+ let t = this.accumulationEnabled && !this.cameraIsMoving.value && e > 0 && this.hasPreviousAccumulated.value > 0 && this.visMode.value !== 11, n = this._auxGBufferEnabled && t && !this._auxSeedPending && this._auxSamples > 0;
10896
+ return this.hasPreviousAux.value = +!!n, this.auxAccumulationAlpha.value = n ? 1 / (this._auxSamples + 1) : 1, n;
10887
10897
  }
10888
10898
  setSize(e, t) {
10889
10899
  let n = this.storageTextures.renderWidth, r = this.storageTextures.renderHeight;
@@ -11374,6 +11384,8 @@ var ef = ai("wavefront"), tf = 256, nf = [
11374
11384
  enableAccumulation: this.enableAccumulation,
11375
11385
  hasPreviousAccumulated: this.hasPreviousAccumulated,
11376
11386
  accumulationAlpha: this.accumulationAlpha,
11387
+ hasPreviousAux: this.hasPreviousAux,
11388
+ auxAccumulationAlpha: this.auxAccumulationAlpha,
11377
11389
  cameraIsMoving: this.cameraIsMoving,
11378
11390
  transparentBackground: this.transparentBackground,
11379
11391
  prevAccumTexture: b,
@@ -12120,7 +12132,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12120
12132
  dispose() {
12121
12133
  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(), this._srcAlphaTexNode?.dispose();
12122
12134
  }
12123
- }, hf = 6e4, gf = (e) => R(e.equal(e), e, j(0)).clamp(0, 1e7), _f = (e) => W(gf(e.x), gf(e.y), gf(e.z)), vf = [
12135
+ }, hf = 6e4, gf = (e) => R(e.equal(e), e, j(0)).clamp(0, 1e7), _f = (e) => W(gf(e.x), gf(e.y), gf(e.z)), vf = 4, yf = [
12124
12136
  1 / 256,
12125
12137
  4 / 256,
12126
12138
  6 / 256,
@@ -12146,12 +12158,12 @@ var ef = ai("wavefront"), tf = 256, nf = [
12146
12158
  6 / 256,
12147
12159
  4 / 256,
12148
12160
  1 / 256
12149
- ], yf = class extends cr {
12161
+ ], bf = class extends cr {
12150
12162
  constructor(e, t = {}) {
12151
12163
  super("EdgeAwareFiltering", {
12152
12164
  ...t,
12153
12165
  executionMode: sr.PER_CYCLE
12154
- }), this.renderer = e, this.filterStrength = V(t.filterStrength ?? 1), this.phiLuminance = V(t.phiLuminance ?? 4), this.phiNormal = V(t.phiNormal ?? 64), this.phiDepth = V(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = V(1, "int"), this.isLastIterationU = V(0, "int"), this.isFirstIterationU = V(1, "int"), this.resW = V(t.width || 1), this.resH = V(t.height || 1), this._colorTexNode = new c(), this._ndTexNode = new c(), this._snTexNode = new c(), this._albedoTexNode = new c(), this._varTexNode = new c(), this._readTexNode = new c();
12166
+ }), this.renderer = e, this.filterStrength = V(t.filterStrength ?? 1), this.phiLuminance = V(t.phiLuminance ?? 1), this.phiNormal = V(t.phiNormal ?? 64), this.phiDepth = V(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = V(1, "int"), this.isLastIterationU = V(0, "int"), this.isFirstIterationU = V(1, "int"), this.varianceHistoryU = V(0, "int"), this.resW = V(t.width || 1), this.resH = V(t.height || 1), this._colorTexNode = new c(), this._ndTexNode = new c(), this._snTexNode = new c(), this._albedoTexNode = new c(), this._varTexNode = new c(), this._readTexNode = new c();
12155
12167
  let n = t.width || 1, r = t.height || 1;
12156
12168
  this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new qe(new on(0, 0), new on(0, 0)), this.outputTarget = new i(n, r, {
12157
12169
  type: dt,
@@ -12188,20 +12200,20 @@ var ef = ai("wavefront"), tf = 256, nf = [
12188
12200
  ]);
12189
12201
  }
12190
12202
  _buildAtrous(e) {
12191
- let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, o = this._varTexNode, s = this.filterStrength, c = this.phiLuminance, l = this.phiNormal, u = this.phiDepth, d = this.stepSizeU, m = this.isLastIterationU, h = this.isFirstIterationU, g = this.resW, _ = this.resH;
12203
+ let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, o = this._varTexNode, s = this.filterStrength, c = this.phiLuminance, l = this.phiNormal, u = this.phiDepth, d = this.stepSizeU, m = this.isLastIterationU, h = this.isFirstIterationU, g = this.varianceHistoryU, _ = this.resW, v = this.resH;
12192
12204
  return f(() => {
12193
- let f = N(Ve.x).mul(16).add(N(se.x)), v = N(Ve.y).mul(16).add(N(se.y));
12194
- p(f.lessThan(N(g)).and(v.lessThan(N(_))), () => {
12195
- let p = P(f, v), y = z(t, p), b = y.xyz, x = Oa(b), S = z(r, p).w, C = z(i, p).xyz.mul(2).sub(1), w = S.lessThan(j(hf)), T = R(w, j(1), j(0)), E = z(a, p).xyz, D = R(w, F(E, W(Tr)), W(1)), O = F(Oa(D), j(Tr)), k = h.equal(N(1)), ee = (e) => {
12205
+ let f = N(Ve.x).mul(16).add(N(se.x)), y = N(Ve.y).mul(16).add(N(se.y));
12206
+ p(f.lessThan(N(_)).and(y.lessThan(N(v))), () => {
12207
+ let p = P(f, y), b = z(t, p), x = b.xyz, S = Oa(x), C = z(r, p).w, w = z(i, p).xyz.mul(2).sub(1), T = C.lessThan(j(hf)), E = R(T, j(1), j(0)), D = z(a, p).xyz, O = R(T, F(D, W(Tr)), W(1)), k = F(Oa(O), j(Tr)), ee = h.equal(N(1)), te = g.lessThan(N(vf)), ne = (e) => {
12196
12208
  let t = z(o, e);
12197
- return F(t.z, t.w);
12198
- }, te = k.select(ee(p), y.w.mul(y.w)).toVar(), ne = c.mul(Ce(F(te, j(0)))).div(O).add(j(1e-4)), re = W(0).toVar(), ie = j(0).toVar(), M = j(0).toVar();
12209
+ return R(te, F(t.z, t.w), t.z);
12210
+ }, re = ee.select(ne(p), b.w.mul(b.w)).toVar(), ie = c.mul(Ce(F(re, j(0)))).div(k).add(j(1e-4)), M = W(0).toVar(), ae = j(0).toVar(), oe = j(0).toVar();
12199
12211
  for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
12200
- let a = n - 2, o = e - 2, s = vf[e * 5 + n], c = P(f.add(d.mul(a)).clamp(N(0), N(g).sub(1)), v.add(d.mul(o)).clamp(N(0), N(_).sub(1))), p = z(t, c), m = p.xyz, h = Oa(m), y = z(r, c).w, b = z(i, c).xyz.mul(2).sub(1), w = R(y.lessThan(j(hf)), j(1), j(0)), E = x.sub(h).abs().div(ne).negate().exp(), D = ge(A(C, b).clamp(0, 1), l), O = S.sub(y).abs().div(F(S.mul(u), j(.001))).negate().exp(), te = T.mul(w), ae = T.oneMinus().mul(w.oneMinus()), oe = te.add(ae), se = I(j(1), D.mul(O), te), ce = j(s).mul(E).mul(se).mul(oe), le = k.select(ee(c), p.w.mul(p.w));
12201
- re.addAssign(m.mul(ce)), ie.addAssign(ce), M.addAssign(ce.mul(ce).mul(F(le, j(0))));
12212
+ let a = n - 2, o = e - 2, s = yf[e * 5 + n], c = P(f.add(d.mul(a)).clamp(N(0), N(_).sub(1)), y.add(d.mul(o)).clamp(N(0), N(v).sub(1))), p = z(t, c), m = p.xyz, h = Oa(m), g = z(r, c).w, b = z(i, c).xyz.mul(2).sub(1), x = R(g.lessThan(j(hf)), j(1), j(0)), T = S.sub(h).abs().div(ie).negate().exp(), D = ge(A(w, b).clamp(0, 1), l), O = C.sub(g).abs().div(F(C.mul(u), j(.001))).negate().exp(), k = E.mul(x), te = E.oneMinus().mul(x.oneMinus()), re = k.add(te), se = I(j(1), D.mul(O), k), ce = j(s).mul(T).mul(se).mul(re), le = ee.select(ne(c), p.w.mul(p.w));
12213
+ M.addAssign(m.mul(ce)), ae.addAssign(ce), oe.addAssign(ce.mul(ce).mul(F(le, j(0))));
12202
12214
  }
12203
- let ae = re.div(F(ie, j(1e-4))), oe = M.div(F(ie.mul(ie), j(1e-8))), se = m.equal(N(1)), ce = z(n, p).xyz, le = I(ce, ae.mul(D), s), ue = se.select(le, ae), de = se.select(z(n, p).w, Ce(F(oe, j(0))));
12204
- Me(e, Le(B(f), B(v)), G(ue, de)).toWriteOnly();
12215
+ let se = M.div(F(ae, j(1e-4))), ce = oe.div(F(ae.mul(ae), j(1e-8))), le = m.equal(N(1)), ue = z(n, p).xyz, de = I(ue, se.mul(O), s), fe = le.select(de, se), L = le.select(z(n, p).w, Ce(F(ce, j(0))));
12216
+ Me(e, Le(B(f), B(y)), G(fe, L)).toWriteOnly();
12205
12217
  });
12206
12218
  })().compute([
12207
12219
  this._dispatchX,
@@ -12225,7 +12237,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12225
12237
  return;
12226
12238
  }
12227
12239
  let o = t.image;
12228
- o && o.width > 0 && o.height > 0 && (o.width !== this.outputTarget.width || o.height !== this.outputTarget.height) && this.setSize(o.width, o.height), this._colorTexNode.value = t, this._ndTexNode.value = n, this._snTexNode.value = r, this._albedoTexNode.value = i, this._varTexNode.value = a, this._compiled ||= (this.renderer.compute(this._computeDemod), this.renderer.compute(this._computeAtrousA), this.renderer.compute(this._computeAtrousB), !0), this.renderer.compute(this._computeDemod);
12240
+ o && o.width > 0 && o.height > 0 && (o.width !== this.outputTarget.width || o.height !== this.outputTarget.height) && this.setSize(o.width, o.height), this.varianceHistoryU.value = e.getState("accumulatedFrames") ?? 0, this._colorTexNode.value = t, this._ndTexNode.value = n, this._snTexNode.value = r, this._albedoTexNode.value = i, this._varTexNode.value = a, this._compiled ||= (this.renderer.compute(this._computeDemod), this.renderer.compute(this._computeAtrousA), this.renderer.compute(this._computeAtrousB), !0), this.renderer.compute(this._computeDemod);
12229
12241
  let s = this._demodTex, c = this._computeAtrousA, l = this._computeAtrousB;
12230
12242
  for (let e = 0; e < this.iterations; e++) {
12231
12243
  this.stepSizeU.value = 1 << e, this.isLastIterationU.value = +(e === this.iterations - 1), this.isFirstIterationU.value = +(e === 0), this._readTexNode.value = s, this.renderer.compute(c), s = c === this._computeAtrousA ? this._storageTexA : this._storageTexB;
@@ -12259,7 +12271,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12259
12271
  dispose() {
12260
12272
  this._computeDemod?.dispose(), this._computeAtrousA?.dispose(), this._computeAtrousB?.dispose(), this._demodTex?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this.outputTarget?.dispose(), this._colorTexNode?.dispose(), this._ndTexNode?.dispose(), this._snTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varTexNode?.dispose(), this._readTexNode?.dispose();
12261
12273
  }
12262
- }, bf = 256, xf = -8, Sf = 6 - xf, Cf = Sf / bf, wf = 1e4, Tf = /* @__PURE__ */ K("\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"), Ef = class extends cr {
12274
+ }, xf = 256, Sf = -8, Cf = 6 - Sf, wf = Cf / xf, Tf = 1e4, Ef = /* @__PURE__ */ K("\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"), Df = class extends cr {
12263
12275
  constructor(e, t = {}) {
12264
12276
  super("AutoExposure", {
12265
12277
  ...t,
@@ -12275,7 +12287,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12275
12287
  depthBuffer: !1,
12276
12288
  stencilBuffer: !1
12277
12289
  };
12278
- this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = dt, this._downsampleStorageTex.format = zt, this._downsampleStorageTex.minFilter = Dt, this._downsampleStorageTex.magFilter = Dt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = dt, this._reductionStorageTex.format = zt, this._reductionStorageTex.minFilter = Dt, this._reductionStorageTex.magFilter = Dt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(bf, "uint").toAtomic();
12290
+ this._downsampleTarget = new i(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new s(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = dt, this._downsampleStorageTex.format = zt, this._downsampleStorageTex.minFilter = Dt, this._downsampleStorageTex.magFilter = Dt, this._reductionStorageTex = new s(1, 1), this._reductionStorageTex.type = dt, this._reductionStorageTex.format = zt, this._reductionStorageTex.minFilter = Dt, this._reductionStorageTex.magFilter = Dt, this._reductionReadTarget = new i(1, 1, e), this._adaptationResult = w(1, "vec4"), this._readbackBuffer = new n(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = w(xf, "uint").toAtomic();
12279
12291
  }
12280
12292
  _buildCompute() {
12281
12293
  this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
@@ -12309,7 +12321,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12309
12321
  for (let i = 0; i < 16; i++) {
12310
12322
  let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = z(e, P(N(o), N(s))), l = c.x, u = c.y;
12311
12323
  p(u.greaterThan(0), () => {
12312
- let e = B(l.div(u).sub(j(xf)).div(j(Sf)).mul(j(bf)).floor().clamp(0, j(bf - 1))), r = j(o).add(.5).div(j(64)), i = j(s).add(.5).div(j(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(j(wf)));
12324
+ let e = B(l.div(u).sub(j(Sf)).div(j(Cf)).mul(j(xf)).floor().clamp(0, j(xf - 1))), r = j(o).add(.5).div(j(64)), i = j(s).add(.5).div(j(64)), a = r.sub(.5), c = i.sub(.5), d = B(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(j(Tf)));
12313
12325
  x(t.element(e), d);
12314
12326
  });
12315
12327
  }
@@ -12327,14 +12339,14 @@ var ef = ai("wavefront"), tf = 256, nf = [
12327
12339
  let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
12328
12340
  this._histogramAnalyzeNode = f(() => {
12329
12341
  let i = j(0).toVar();
12330
- m(bf, ({ i: t }) => {
12342
+ m(xf, ({ i: t }) => {
12331
12343
  i.addAssign(j(S(e.element(t))));
12332
12344
  });
12333
12345
  let a = i.mul(n), o = i.mul(r), s = j(0).toVar(), c = j(0).toVar(), l = j(0).toVar(), u = j(0).toVar();
12334
- m(bf, ({ i: t }) => {
12346
+ m(xf, ({ i: t }) => {
12335
12347
  let n = j(S(e.element(t)));
12336
12348
  u.assign(s), s.addAssign(n), p(u.lessThan(o).and(s.greaterThan(a)), () => {
12337
- let e = j(xf).add(j(t).add(.5).mul(j(Cf)));
12349
+ let e = j(Sf).add(j(t).add(.5).mul(j(wf)));
12338
12350
  c.addAssign(e.mul(n)), l.addAssign(n);
12339
12351
  });
12340
12352
  });
@@ -12349,7 +12361,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12349
12361
  _buildAdaptationCompute() {
12350
12362
  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;
12351
12363
  this._adaptationComputeNode = f(() => {
12352
- let u = z(e, P(N(0), N(0))).x, d = Tf(u, l, n, r, i, a, o, s, c);
12364
+ let u = z(e, P(N(0), N(0))).x, d = Ef(u, l, n, r, i, a, o, s, c);
12353
12365
  t.element(B(0)).assign(d);
12354
12366
  })().compute(1, [
12355
12367
  1,
@@ -12413,7 +12425,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12413
12425
  dispose() {
12414
12426
  this._downsampleComputeNode?.dispose(), this._histogramComputeNode?.dispose(), this._histogramAnalyzeNode?.dispose(), this._adaptationComputeNode?.dispose(), this._downsampleTarget?.dispose(), this._downsampleStorageTex?.dispose(), this._reductionStorageTex?.dispose(), this._reductionReadTarget?.dispose(), this._readbackBuffer?.dispose(), this._inputTexNode?.dispose(), this._reductionReadTexNode?.dispose();
12415
12427
  }
12416
- }, Df = class extends cr {
12428
+ }, Of = class extends cr {
12417
12429
  constructor(n, r = {}) {
12418
12430
  super("Compositor", {
12419
12431
  ...r,
@@ -12467,7 +12479,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12467
12479
  dispose() {
12468
12480
  this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
12469
12481
  }
12470
- }, Of = class {
12482
+ }, kf = class {
12471
12483
  constructor() {
12472
12484
  this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
12473
12485
  frame: 0,
@@ -12589,7 +12601,7 @@ var ef = ai("wavefront"), tf = 256, nf = [
12589
12601
  dispose() {
12590
12602
  this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
12591
12603
  }
12592
- }, kf = class extends lt {
12604
+ }, Af = class extends lt {
12593
12605
  constructor() {
12594
12606
  super(), this._onceCallbacks = /* @__PURE__ */ new Map();
12595
12607
  }
@@ -12627,38 +12639,38 @@ var ef = ai("wavefront"), tf = 256, nf = [
12627
12639
  eventNames() {
12628
12640
  return this._listeners ? Object.keys(this._listeners) : [];
12629
12641
  }
12630
- }, Af = !1, jf = [], Mf = /* @__PURE__ */ new WeakMap();
12631
- function Nf(e) {
12632
- Af = !!e;
12633
- }
12634
- function Pf() {
12635
- return jf.slice();
12642
+ }, jf = !1, Mf = [], Nf = /* @__PURE__ */ new WeakMap();
12643
+ function Pf(e) {
12644
+ jf = !!e;
12636
12645
  }
12637
12646
  function Ff() {
12638
- jf.length = 0;
12647
+ return Mf.slice();
12648
+ }
12649
+ function If() {
12650
+ Mf.length = 0;
12639
12651
  }
12640
- function If(e) {
12652
+ function Lf(e) {
12641
12653
  let t = [];
12642
12654
  for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
12643
12655
  return t;
12644
12656
  }
12645
- var Lf = (e) => !e || !e.image || !(e.image.width > 0);
12646
- function Rf(e, t, n) {
12647
- if (!Af) {
12657
+ var Rf = (e) => !e || !e.image || !(e.image.width > 0);
12658
+ function zf(e, t, n) {
12659
+ if (!jf) {
12648
12660
  n();
12649
12661
  return;
12650
12662
  }
12651
- let r = Mf.get(e);
12663
+ let r = Nf.get(e);
12652
12664
  if (r || (r = {
12653
12665
  phase: "pending",
12654
12666
  unboundAtCompile: []
12655
- }, Mf.set(e, r)), r.phase !== "pending") {
12656
- n(), r.phase === "watch" && zf(e, r);
12667
+ }, Nf.set(e, r)), r.phase !== "pending") {
12668
+ n(), r.phase === "watch" && Bf(e, r);
12657
12669
  return;
12658
12670
  }
12659
12671
  let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
12660
12672
  t.compute = function(...t) {
12661
- return r.phase === "pending" && (r.unboundAtCompile = If(e).filter((t) => Lf(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
12673
+ return r.phase === "pending" && (r.unboundAtCompile = Lf(e).filter((t) => Rf(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
12662
12674
  };
12663
12675
  try {
12664
12676
  n();
@@ -12666,14 +12678,14 @@ function Rf(e, t, n) {
12666
12678
  i ? t.compute = a : delete t.compute;
12667
12679
  }
12668
12680
  }
12669
- function zf(e, t) {
12681
+ function Bf(e, t) {
12670
12682
  let n = [];
12671
12683
  for (let r of t.unboundAtCompile) {
12672
12684
  let t = e[r]?.value;
12673
- if (Lf(t)) return;
12685
+ if (Rf(t)) return;
12674
12686
  t.isStorageTexture !== !0 && n.push(r);
12675
12687
  }
12676
- t.phase = "done", n.length !== 0 && jf.push({
12688
+ t.phase = "done", n.length !== 0 && Mf.push({
12677
12689
  stage: e.name,
12678
12690
  nodes: n,
12679
12691
  unboundAtCompile: t.unboundAtCompile.slice(),
@@ -12682,9 +12694,9 @@ function zf(e, t) {
12682
12694
  }
12683
12695
  //#endregion
12684
12696
  //#region src/Pipeline/RenderPipeline.js
12685
- var Bf = class {
12697
+ var Vf = class {
12686
12698
  constructor(e, t, n) {
12687
- this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new Of(), this.eventBus = new kf(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
12699
+ this.renderer = e, this.width = t, this.height = n, this.stages = [], this.context = new kf(), this.eventBus = new Af(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
12688
12700
  enabled: !1,
12689
12701
  logSkipped: !1,
12690
12702
  timings: /* @__PURE__ */ new Map(),
@@ -12718,7 +12730,7 @@ var Bf = class {
12718
12730
  }
12719
12731
  try {
12720
12732
  let n = this.stats.enabled ? performance.now() : 0;
12721
- if (Rf(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
12733
+ if (zf(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
12722
12734
  let e = performance.now() - n;
12723
12735
  this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
12724
12736
  let r = this.stats.timings.get(t.name);
@@ -12816,7 +12828,7 @@ var Bf = class {
12816
12828
  let e = this.getInfo();
12817
12829
  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();
12818
12830
  }
12819
- }, Vf = class {
12831
+ }, Hf = class {
12820
12832
  constructor() {
12821
12833
  this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1;
12822
12834
  }
@@ -12838,7 +12850,7 @@ var Bf = class {
12838
12850
  resumeFromPause() {
12839
12851
  this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
12840
12852
  }
12841
- }, Hf = class extends lt {
12853
+ }, Uf = class extends lt {
12842
12854
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
12843
12855
  super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Ht(), 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, this._helperScene = null;
12844
12856
  }
@@ -13074,18 +13086,18 @@ var Bf = class {
13074
13086
  dispose() {
13075
13087
  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;
13076
13088
  }
13077
- }, Uf = {
13089
+ }, Wf = {
13078
13090
  STRING: "string",
13079
13091
  NUMBER: "number",
13080
13092
  WORD: "word",
13081
13093
  LBRACKET: "[",
13082
13094
  RBRACKET: "]"
13083
- }, Wf = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Gf = (e) => e >= "0" && e <= "9", Kf = (e, t, n) => !!(Gf(e) || e === "." && Gf(t) || (e === "-" || e === "+") && (Gf(t) || t === "." && Gf(n)));
13084
- function qf(e) {
13095
+ }, Gf = (e) => e === " " || e === " " || e === "\n" || e === "\r" || e === "\f", Kf = (e) => e >= "0" && e <= "9", qf = (e, t, n) => !!(Kf(e) || e === "." && Kf(t) || (e === "-" || e === "+") && (Kf(t) || t === "." && Kf(n)));
13096
+ function Jf(e) {
13085
13097
  let t = [], n = e.length, r = 0;
13086
13098
  for (; r < n;) {
13087
13099
  let i = e[r];
13088
- if (Wf(i)) {
13100
+ if (Gf(i)) {
13089
13101
  r++;
13090
13102
  continue;
13091
13103
  }
@@ -13094,11 +13106,11 @@ function qf(e) {
13094
13106
  continue;
13095
13107
  }
13096
13108
  if (i === "[") {
13097
- t.push({ type: Uf.LBRACKET }), r++;
13109
+ t.push({ type: Wf.LBRACKET }), r++;
13098
13110
  continue;
13099
13111
  }
13100
13112
  if (i === "]") {
13101
- t.push({ type: Uf.RBRACKET }), r++;
13113
+ t.push({ type: Wf.RBRACKET }), r++;
13102
13114
  continue;
13103
13115
  }
13104
13116
  if (i === "\"") {
@@ -13107,12 +13119,12 @@ function qf(e) {
13107
13119
  for (; r < n && e[r] !== "\"";) r++;
13108
13120
  if (r >= n) throw Error("PBRT tokenizer: unterminated string literal");
13109
13121
  t.push({
13110
- type: Uf.STRING,
13122
+ type: Wf.STRING,
13111
13123
  value: e.slice(i, r)
13112
13124
  }), r++;
13113
13125
  continue;
13114
13126
  }
13115
- if (Kf(i, e[r + 1], e[r + 2])) {
13127
+ if (qf(i, e[r + 1], e[r + 2])) {
13116
13128
  let i = r;
13117
13129
  for (r++; r < n;) {
13118
13130
  let t = e[r];
@@ -13122,16 +13134,16 @@ function qf(e) {
13122
13134
  let a = e.slice(i, r), o = Number(a);
13123
13135
  if (Number.isNaN(o)) throw Error(`PBRT tokenizer: invalid number "${a}"`);
13124
13136
  t.push({
13125
- type: Uf.NUMBER,
13137
+ type: Wf.NUMBER,
13126
13138
  value: o
13127
13139
  });
13128
13140
  continue;
13129
13141
  }
13130
13142
  {
13131
13143
  let i = r;
13132
- for (; r < n && !Wf(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
13144
+ for (; r < n && !Gf(e[r]) && e[r] !== "\"" && e[r] !== "[" && e[r] !== "]" && e[r] !== "#";) r++;
13133
13145
  t.push({
13134
- type: Uf.WORD,
13146
+ type: Wf.WORD,
13135
13147
  value: e.slice(i, r)
13136
13148
  });
13137
13149
  }
@@ -13140,7 +13152,7 @@ function qf(e) {
13140
13152
  }
13141
13153
  //#endregion
13142
13154
  //#region src/Processor/PBRT/PBRTMath.js
13143
- function Jf() {
13155
+ function Yf() {
13144
13156
  return [
13145
13157
  1,
13146
13158
  0,
@@ -13160,7 +13172,7 @@ function Jf() {
13160
13172
  1
13161
13173
  ];
13162
13174
  }
13163
- function Yf(e, t) {
13175
+ function Xf(e, t) {
13164
13176
  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], ee = t[13], te = t[14], j = t[15];
13165
13177
  return [
13166
13178
  n * v + o * y + u * b + m * x,
@@ -13181,7 +13193,7 @@ function Yf(e, t) {
13181
13193
  a * A + l * ee + p * te + _ * j
13182
13194
  ];
13183
13195
  }
13184
- function Xf(e, t, n) {
13196
+ function Zf(e, t, n) {
13185
13197
  return [
13186
13198
  1,
13187
13199
  0,
@@ -13201,7 +13213,7 @@ function Xf(e, t, n) {
13201
13213
  1
13202
13214
  ];
13203
13215
  }
13204
- function Zf(e, t, n) {
13216
+ function Qf(e, t, n) {
13205
13217
  return [
13206
13218
  e,
13207
13219
  0,
@@ -13221,7 +13233,7 @@ function Zf(e, t, n) {
13221
13233
  1
13222
13234
  ];
13223
13235
  }
13224
- function Qf(e, t, n, r) {
13236
+ function $f(e, t, n, r) {
13225
13237
  let i = Math.hypot(t, n, r) || 1;
13226
13238
  t /= i, n /= i, r /= i;
13227
13239
  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;
@@ -13244,21 +13256,21 @@ function Qf(e, t, n, r) {
13244
13256
  1
13245
13257
  ];
13246
13258
  }
13247
- function $f(e, t) {
13259
+ function ep(e, t) {
13248
13260
  return [
13249
13261
  e[0] - t[0],
13250
13262
  e[1] - t[1],
13251
13263
  e[2] - t[2]
13252
13264
  ];
13253
13265
  }
13254
- function ep(e, t) {
13266
+ function tp(e, t) {
13255
13267
  return [
13256
13268
  e[1] * t[2] - e[2] * t[1],
13257
13269
  e[2] * t[0] - e[0] * t[2],
13258
13270
  e[0] * t[1] - e[1] * t[0]
13259
13271
  ];
13260
13272
  }
13261
- function tp(e) {
13273
+ function np(e) {
13262
13274
  let t = Math.hypot(e[0], e[1], e[2]) || 1;
13263
13275
  return [
13264
13276
  e[0] / t,
@@ -13266,8 +13278,8 @@ function tp(e) {
13266
13278
  e[2] / t
13267
13279
  ];
13268
13280
  }
13269
- function np(e, t, n) {
13270
- let r = tp($f(t, e)), i = tp(ep(tp(n), r)), a = ep(r, i);
13281
+ function rp(e, t, n) {
13282
+ let r = np(ep(t, e)), i = np(tp(np(n), r)), a = tp(r, i);
13271
13283
  return [
13272
13284
  i[0],
13273
13285
  i[1],
@@ -13287,9 +13299,9 @@ function np(e, t, n) {
13287
13299
  1
13288
13300
  ];
13289
13301
  }
13290
- function rp(e) {
13302
+ function ip(e) {
13291
13303
  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;
13292
- if (x === 0) return Jf();
13304
+ if (x === 0) return Yf();
13293
13305
  let S = 1 / x;
13294
13306
  return [
13295
13307
  _ * S,
@@ -13312,7 +13324,7 @@ function rp(e) {
13312
13324
  }
13313
13325
  //#endregion
13314
13326
  //#region src/Processor/PBRT/PBRTParser.js
13315
- var ip = class {
13327
+ var ap = class {
13316
13328
  constructor(e = {}) {
13317
13329
  this.resolveInclude = e.resolveInclude || (() => {
13318
13330
  throw Error("PBRTParser: Include used but no resolveInclude provided");
@@ -13326,14 +13338,14 @@ var ip = class {
13326
13338
  instances: [],
13327
13339
  objects: /* @__PURE__ */ new Map(),
13328
13340
  warnings: []
13329
- }, this.ctm = Jf(), this.state = {
13341
+ }, this.ctm = Yf(), this.state = {
13330
13342
  material: null,
13331
13343
  areaLight: null,
13332
13344
  reverseOrientation: !1
13333
13345
  }, 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();
13334
13346
  }
13335
13347
  parse(e, t = "") {
13336
- return this.dirStack = [t], this._run(qf(e)), this.ir;
13348
+ return this.dirStack = [t], this._run(Jf(e)), this.ir;
13337
13349
  }
13338
13350
  _peek() {
13339
13351
  return this.tokens[this.pos];
@@ -13343,12 +13355,12 @@ var ip = class {
13343
13355
  }
13344
13356
  _expectNumber(e) {
13345
13357
  let t = this._next();
13346
- if (!t || t.type !== Uf.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
13358
+ if (!t || t.type !== Wf.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
13347
13359
  return t.value;
13348
13360
  }
13349
13361
  _expectString(e) {
13350
13362
  let t = this._next();
13351
- if (!t || t.type !== Uf.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
13363
+ if (!t || t.type !== Wf.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
13352
13364
  return t.value;
13353
13365
  }
13354
13366
  _readNumbers(e) {
@@ -13357,17 +13369,17 @@ var ip = class {
13357
13369
  return t;
13358
13370
  }
13359
13371
  _readBracketedOrBareNumbers(e) {
13360
- if (this._peek() && this._peek().type === Uf.LBRACKET) {
13372
+ if (this._peek() && this._peek().type === Wf.LBRACKET) {
13361
13373
  this._next();
13362
13374
  let e = [];
13363
- for (; this._peek() && this._peek().type !== Uf.RBRACKET;) e.push(this._expectNumber("transform element"));
13375
+ for (; this._peek() && this._peek().type !== Wf.RBRACKET;) e.push(this._expectNumber("transform element"));
13364
13376
  return this._next(), e;
13365
13377
  }
13366
13378
  return this._readNumbers(e);
13367
13379
  }
13368
13380
  _parseParams() {
13369
13381
  let e = {};
13370
- for (; this._peek() && this._peek().type === Uf.STRING;) {
13382
+ for (; this._peek() && this._peek().type === Wf.STRING;) {
13371
13383
  let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
13372
13384
  e[r] = {
13373
13385
  type: n,
@@ -13378,23 +13390,23 @@ var ip = class {
13378
13390
  }
13379
13391
  _parseParamValue() {
13380
13392
  let e = [];
13381
- if (this._peek() && this._peek().type === Uf.LBRACKET) {
13382
- for (this._next(); this._peek() && this._peek().type !== Uf.RBRACKET;) e.push(this._coerceValueToken(this._next()));
13393
+ if (this._peek() && this._peek().type === Wf.LBRACKET) {
13394
+ for (this._next(); this._peek() && this._peek().type !== Wf.RBRACKET;) e.push(this._coerceValueToken(this._next()));
13383
13395
  this._next();
13384
13396
  } else e.push(this._coerceValueToken(this._next()));
13385
13397
  return e;
13386
13398
  }
13387
13399
  _coerceValueToken(e) {
13388
13400
  if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
13389
- if (e.type === Uf.NUMBER || e.type === Uf.STRING) return e.value;
13390
- if (e.type === Uf.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
13401
+ if (e.type === Wf.NUMBER || e.type === Wf.STRING) return e.value;
13402
+ if (e.type === Wf.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
13391
13403
  throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
13392
13404
  }
13393
13405
  _run(e) {
13394
13406
  let t = this.tokens, n = this.pos;
13395
13407
  for (this.tokens = e, this.pos = 0; this.pos < this.tokens.length;) {
13396
13408
  let e = this._next();
13397
- if (e.type !== Uf.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
13409
+ if (e.type !== Wf.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
13398
13410
  this._directive(e.value);
13399
13411
  }
13400
13412
  this.tokens = t, this.pos = n;
@@ -13402,25 +13414,25 @@ var ip = class {
13402
13414
  _directive(e) {
13403
13415
  switch (e) {
13404
13416
  case "Identity":
13405
- this.ctm = Jf();
13417
+ this.ctm = Yf();
13406
13418
  break;
13407
13419
  case "Translate": {
13408
13420
  let [e, t, n] = this._readNumbers(3);
13409
- this.ctm = Yf(this.ctm, Xf(e, t, n));
13421
+ this.ctm = Xf(this.ctm, Zf(e, t, n));
13410
13422
  break;
13411
13423
  }
13412
13424
  case "Scale": {
13413
13425
  let [e, t, n] = this._readNumbers(3);
13414
- this.ctm = Yf(this.ctm, Zf(e, t, n));
13426
+ this.ctm = Xf(this.ctm, Qf(e, t, n));
13415
13427
  break;
13416
13428
  }
13417
13429
  case "Rotate": {
13418
13430
  let [e, t, n, r] = this._readNumbers(4);
13419
- this.ctm = Yf(this.ctm, Qf(e, t, n, r));
13431
+ this.ctm = Xf(this.ctm, $f(e, t, n, r));
13420
13432
  break;
13421
13433
  }
13422
13434
  case "LookAt": {
13423
- let e = this._readNumbers(9), t = np([
13435
+ let e = this._readNumbers(9), t = rp([
13424
13436
  e[0],
13425
13437
  e[1],
13426
13438
  e[2]
@@ -13433,7 +13445,7 @@ var ip = class {
13433
13445
  e[7],
13434
13446
  e[8]
13435
13447
  ]);
13436
- this.ctm = Yf(this.ctm, rp(t));
13448
+ this.ctm = Xf(this.ctm, ip(t));
13437
13449
  break;
13438
13450
  }
13439
13451
  case "Transform":
@@ -13441,7 +13453,7 @@ var ip = class {
13441
13453
  break;
13442
13454
  case "ConcatTransform": {
13443
13455
  let e = this._readBracketedOrBareNumbers(16);
13444
- this.ctm = Yf(this.ctm, e);
13456
+ this.ctm = Xf(this.ctm, e);
13445
13457
  break;
13446
13458
  }
13447
13459
  case "CoordinateSystem":
@@ -13457,7 +13469,7 @@ var ip = class {
13457
13469
  this.ir.camera = {
13458
13470
  type: e,
13459
13471
  params: t,
13460
- cameraToWorld: rp(this.ctm)
13472
+ cameraToWorld: ip(this.ctm)
13461
13473
  };
13462
13474
  break;
13463
13475
  }
@@ -13481,7 +13493,7 @@ var ip = class {
13481
13493
  this._skipTypeAndParams();
13482
13494
  break;
13483
13495
  case "WorldBegin":
13484
- this.ctm = Jf(), this.state = {
13496
+ this.ctm = Yf(), this.state = {
13485
13497
  material: null,
13486
13498
  areaLight: null,
13487
13499
  reverseOrientation: !1
@@ -13526,7 +13538,7 @@ var ip = class {
13526
13538
  this._readNumbers(2);
13527
13539
  break;
13528
13540
  case "MediumInterface":
13529
- this._peek() && this._peek().type === Uf.STRING && this._next(), this._peek() && this._peek().type === Uf.STRING && this._next();
13541
+ this._peek() && this._peek().type === Wf.STRING && this._next(), this._peek() && this._peek().type === Wf.STRING && this._next();
13530
13542
  break;
13531
13543
  case "MakeNamedMedium":
13532
13544
  this._skipNamedAndParams();
@@ -13634,7 +13646,7 @@ var ip = class {
13634
13646
  }
13635
13647
  }
13636
13648
  _emitShape(e) {
13637
- this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = Yf(rp(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
13649
+ this.currentObject === null ? this.ir.shapes.push(e) : (e.relativeCTM = Xf(ip(this.objectBeginCTM), e.ctm), this.ir.objects.get(this.currentObject).push(e));
13638
13650
  }
13639
13651
  _include(e) {
13640
13652
  let t = this.resolveInclude(e, this.dirStack[this.dirStack.length - 1]);
@@ -13643,13 +13655,13 @@ var ip = class {
13643
13655
  return;
13644
13656
  }
13645
13657
  let n = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
13646
- this.dirStack.push(n), this._run(qf(t)), this.dirStack.pop();
13658
+ this.dirStack.push(n), this._run(Jf(t)), this.dirStack.pop();
13647
13659
  }
13648
13660
  _skipTypeAndParams() {
13649
- this._peek() && this._peek().type === Uf.STRING && this._next(), this._parseParams();
13661
+ this._peek() && this._peek().type === Wf.STRING && this._next(), this._parseParams();
13650
13662
  }
13651
13663
  _skipNamedAndParams() {
13652
- this._peek() && this._peek().type === Uf.STRING && this._next(), this._parseParams();
13664
+ this._peek() && this._peek().type === Wf.STRING && this._next(), this._parseParams();
13653
13665
  }
13654
13666
  _num(e, t) {
13655
13667
  return e && e.value.length ? e.value[0] : t;
@@ -13663,7 +13675,7 @@ var ip = class {
13663
13675
  _warnUnknown(e) {
13664
13676
  this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
13665
13677
  }
13666
- }, ap = {
13678
+ }, op = {
13667
13679
  au: [
13668
13680
  1,
13669
13681
  .78,
@@ -13719,12 +13731,12 @@ var ip = class {
13719
13731
  .9,
13720
13732
  .9
13721
13733
  ]
13722
- }, op = [
13734
+ }, sp = [
13723
13735
  .92,
13724
13736
  .92,
13725
13737
  .92
13726
13738
  ];
13727
- function sp(e) {
13739
+ function cp(e) {
13728
13740
  let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
13729
13741
  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;
13730
13742
  let a = (e) => Math.max(0, Math.min(255, e)) / 255;
@@ -13734,15 +13746,15 @@ function sp(e) {
13734
13746
  a(i) ** 2.2
13735
13747
  ];
13736
13748
  }
13737
- function cp(e, t, n) {
13749
+ function lp(e, t, n) {
13738
13750
  let r = e[t];
13739
13751
  return r && typeof r.value[0] == "number" ? r.value[0] : n;
13740
13752
  }
13741
- function lp(e, t, n) {
13753
+ function up(e, t, n) {
13742
13754
  let r = e[t];
13743
13755
  return r && typeof r.value[0] == "string" ? r.value[0] : n;
13744
13756
  }
13745
- async function up(e, t, n, r = null) {
13757
+ async function dp(e, t, n, r = null) {
13746
13758
  let i = e[t];
13747
13759
  if (!i) return {
13748
13760
  rgb: r,
@@ -13781,14 +13793,14 @@ async function up(e, t, n, r = null) {
13781
13793
  };
13782
13794
  }
13783
13795
  if (i.type === "blackbody") return {
13784
- rgb: sp(i.value[0]),
13796
+ rgb: cp(i.value[0]),
13785
13797
  texture: null
13786
13798
  };
13787
13799
  if (i.type === "spectrum") {
13788
13800
  if (typeof i.value[0] == "string") {
13789
- let e = dp(i.value[0]);
13790
- return e && ap[e] ? {
13791
- rgb: ap[e].slice(),
13801
+ let e = fp(i.value[0]);
13802
+ return e && op[e] ? {
13803
+ rgb: op[e].slice(),
13792
13804
  texture: null
13793
13805
  } : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
13794
13806
  rgb: [
@@ -13816,18 +13828,18 @@ async function up(e, t, n, r = null) {
13816
13828
  texture: null
13817
13829
  };
13818
13830
  }
13819
- function dp(e) {
13831
+ function fp(e) {
13820
13832
  let t = e.toLowerCase().match(/metal-([a-z]+)/);
13821
13833
  if (t) return t[1];
13822
- for (let t of Object.keys(ap)) if (e.toLowerCase().includes(t)) return t;
13834
+ for (let t of Object.keys(op)) if (e.toLowerCase().includes(t)) return t;
13823
13835
  return null;
13824
13836
  }
13825
- function fp(e, t) {
13837
+ function pp(e, t) {
13826
13838
  if (e.roughness && typeof e.roughness.value[0] == "number") return e.roughness.value[0];
13827
- let n = cp(e, "uroughness", null), r = cp(e, "vroughness", null);
13839
+ let n = lp(e, "uroughness", null), r = lp(e, "vroughness", null);
13828
13840
  return n !== null && r !== null ? (n + r) / 2 : n === null ? t : n;
13829
13841
  }
13830
- async function pp(e, t) {
13842
+ async function mp(e, t) {
13831
13843
  let n = e?.type || "diffuse", r = e?.params || {}, i = new Tt({
13832
13844
  side: st,
13833
13845
  roughness: 1,
@@ -13839,7 +13851,7 @@ async function pp(e, t) {
13839
13851
  };
13840
13852
  switch (n) {
13841
13853
  case "diffuse":
13842
- o(await up(r, "reflectance", t, [
13854
+ o(await dp(r, "reflectance", t, [
13843
13855
  .5,
13844
13856
  .5,
13845
13857
  .5
@@ -13847,14 +13859,14 @@ async function pp(e, t) {
13847
13859
  break;
13848
13860
  case "conductor":
13849
13861
  case "metal": {
13850
- let e = await up(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
13862
+ let e = await dp(r, "reflectance", t, null), n = r.eta, s = r.k, c = n && n.type === "spectrum" && typeof n.value[0] == "string";
13851
13863
  if (e.rgb || e.texture) o(e);
13852
13864
  else if (n && s && !c) {
13853
- let e = (await up(r, "eta", t, [
13865
+ let e = (await dp(r, "eta", t, [
13854
13866
  .2,
13855
13867
  .92,
13856
13868
  1.1
13857
- ])).rgb, n = (await up(r, "k", t, [
13869
+ ])).rgb, n = (await dp(r, "k", t, [
13858
13870
  3.9,
13859
13871
  2.45,
13860
13872
  2.14
@@ -13864,28 +13876,28 @@ async function pp(e, t) {
13864
13876
  i(e[1], n[1]),
13865
13877
  i(e[2], n[2])
13866
13878
  ]);
13867
- } else a(n ? (await up(r, "eta", t, op)).rgb || op : ap.cu);
13868
- i.metalness = 1, i.roughness = fp(r, .1);
13879
+ } else a(n ? (await dp(r, "eta", t, sp)).rgb || sp : op.cu);
13880
+ i.metalness = 1, i.roughness = pp(r, .1);
13869
13881
  break;
13870
13882
  }
13871
13883
  case "dielectric":
13872
13884
  case "thindielectric":
13873
- i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = cp(r, "eta", 1.5), i.roughness = fp(r, 0), i.thickness = n === "thindielectric" ? 0 : cp(r, "thickness", 0);
13885
+ i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = lp(r, "eta", 1.5), i.roughness = pp(r, 0), i.thickness = n === "thindielectric" ? 0 : lp(r, "thickness", 0);
13874
13886
  break;
13875
13887
  case "coateddiffuse":
13876
- o(await up(r, "reflectance", t, [
13888
+ o(await dp(r, "reflectance", t, [
13877
13889
  .5,
13878
13890
  .5,
13879
13891
  .5
13880
- ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = fp(r, 0);
13892
+ ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = pp(r, 0);
13881
13893
  break;
13882
13894
  case "diffusetransmission": {
13883
- let e = await up(r, "transmittance", t, [
13895
+ let e = await dp(r, "transmittance", t, [
13884
13896
  .25,
13885
13897
  .25,
13886
13898
  .25
13887
13899
  ]);
13888
- o(await up(r, "reflectance", t, [
13900
+ o(await dp(r, "reflectance", t, [
13889
13901
  .25,
13890
13902
  .25,
13891
13903
  .25
@@ -13898,9 +13910,9 @@ async function pp(e, t) {
13898
13910
  i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
13899
13911
  break;
13900
13912
  case "mix": {
13901
- let e = r.materials?.value || [], n = Math.max(0, Math.min(1, cp(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
13913
+ let e = r.materials?.value || [], n = Math.max(0, Math.min(1, lp(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
13902
13914
  if (a && o) {
13903
- let [e, r] = await Promise.all([pp(a, t), pp(o, t)]), s = (e, t) => e * (1 - n) + t * n;
13915
+ let [e, r] = await Promise.all([mp(a, t), mp(o, t)]), s = (e, t) => e * (1 - n) + t * n;
13904
13916
  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;
13905
13917
  break;
13906
13918
  }
@@ -13910,7 +13922,7 @@ async function pp(e, t) {
13910
13922
  case "subsurface":
13911
13923
  case "hair":
13912
13924
  case "measured":
13913
- t.warn(`material "${n}" not supported — using diffuse approximation`), a((await up(r, "reflectance", t, [
13925
+ t.warn(`material "${n}" not supported — using diffuse approximation`), a((await dp(r, "reflectance", t, [
13914
13926
  .5,
13915
13927
  .5,
13916
13928
  .5
@@ -13924,7 +13936,7 @@ async function pp(e, t) {
13924
13936
  }
13925
13937
  //#endregion
13926
13938
  //#region src/Processor/PBRT/PBRTSceneBuilder.js
13927
- var mp = [
13939
+ var hp = [
13928
13940
  1,
13929
13941
  0,
13930
13942
  0,
@@ -13941,7 +13953,7 @@ var mp = [
13941
13953
  0,
13942
13954
  0,
13943
13955
  1
13944
- ], hp = class {
13956
+ ], gp = class {
13945
13957
  constructor(e = {}) {
13946
13958
  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();
13947
13959
  }
@@ -13977,7 +13989,7 @@ var mp = [
13977
13989
  continue;
13978
13990
  }
13979
13991
  for (let e of i) {
13980
- let i = Yf(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
13992
+ let i = Xf(r.ctm, e.relativeCTM || e.ctm), a = await this._buildShapeMesh(e, i, `instance_${n++}`);
13981
13993
  a && t.add(a);
13982
13994
  }
13983
13995
  }
@@ -13989,7 +14001,7 @@ var mp = [
13989
14001
  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);
13990
14002
  let s = new Ct(r, o);
13991
14003
  s.name = n;
13992
- let c = this.convertHandedness ? Yf(mp, t) : t;
14004
+ let c = this.convertHandedness ? Xf(hp, t) : t;
13993
14005
  new St().fromArray(c).decompose(s.position, s.quaternion, s.scale), s.updateMatrix(), r.computeBoundingBox();
13994
14006
  let l = r.boundingBox ? r.boundingBox.clone().applyMatrix4(s.matrix).getSize(new sn()) : new sn();
13995
14007
  return this.report.push({
@@ -14044,7 +14056,7 @@ var mp = [
14044
14056
  return i.setAttribute("position", new ut(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
14045
14057
  }
14046
14058
  async _plyMesh(e) {
14047
- let t = lp(e, "filename", null);
14059
+ let t = up(e, "filename", null);
14048
14060
  if (!t) return this.warn("plymesh missing filename"), null;
14049
14061
  try {
14050
14062
  let e = await this.resolvePLY(t);
@@ -14054,10 +14066,10 @@ var mp = [
14054
14066
  }
14055
14067
  }
14056
14068
  _sphere(e) {
14057
- return new Xt(cp(e, "radius", 1), 48, 32);
14069
+ return new Xt(lp(e, "radius", 1), 48, 32);
14058
14070
  }
14059
14071
  _disk(e) {
14060
- let t = cp(e, "radius", 1), n = cp(e, "innerradius", 0), r = cp(e, "height", 0), i = [], a = [];
14072
+ let t = lp(e, "radius", 1), n = lp(e, "innerradius", 0), r = lp(e, "height", 0), i = [], a = [];
14061
14073
  for (let e = 0; e < 48; e++) {
14062
14074
  let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
14063
14075
  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);
@@ -14072,15 +14084,15 @@ var mp = [
14072
14084
  resolveNamedTexture: (e) => this._resolveNamedTexture(e),
14073
14085
  namedMaterials: this.ir.namedMaterials,
14074
14086
  warn: (e) => this.warn(e)
14075
- }, r = await pp(e.material, n);
14087
+ }, r = await mp(e.material, n);
14076
14088
  return e.areaLight && await this._applyAreaLight(r, e.areaLight, n), t.set(e.areaLight, r), r;
14077
14089
  }
14078
14090
  async _applyAreaLight(e, t, n) {
14079
- let r = await up(t.params, "L", n, [
14091
+ let r = await dp(t.params, "L", n, [
14080
14092
  1,
14081
14093
  1,
14082
14094
  1
14083
- ]), i = cp(t.params, "scale", 1), a = r.rgb || [
14095
+ ]), i = lp(t.params, "scale", 1), a = r.rgb || [
14084
14096
  1,
14085
14097
  1,
14086
14098
  1
@@ -14092,7 +14104,7 @@ var mp = [
14092
14104
  let t = this.ir.namedTextures.get(e), n = null;
14093
14105
  if (!t) this.warn(`named texture "${e}" not defined`);
14094
14106
  else if (t.class === "imagemap") {
14095
- let r = lp(t.params, "filename", null);
14107
+ let r = up(t.params, "filename", null);
14096
14108
  if (r) try {
14097
14109
  let t = await this.resolveImage(r);
14098
14110
  t ? n = { texture: t } : this.warn(`image not found for texture "${e}": ${r}`);
@@ -14180,7 +14192,7 @@ var mp = [
14180
14192
  return c.name = "PBRT Camera", c.up.copy(a.normalize()), c.position.copy(r), c.lookAt(o), c.updateMatrixWorld(!0), c;
14181
14193
  }
14182
14194
  _verticalFov(e, t) {
14183
- let n = cp(e, "fov", 90);
14195
+ let n = lp(e, "fov", 90);
14184
14196
  if (t >= 1) return n;
14185
14197
  let r = n * Math.PI / 180;
14186
14198
  return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
@@ -14188,7 +14200,7 @@ var mp = [
14188
14200
  async _buildEnvironment(e) {
14189
14201
  let t = e.find((e) => e.type === "infinite");
14190
14202
  if (!t) return null;
14191
- let n = cp(t.params, "scale", 1), r = lp(t.params, "filename", null);
14203
+ let n = lp(t.params, "scale", 1), r = up(t.params, "filename", null);
14192
14204
  if (r) try {
14193
14205
  let e = await this.resolveEnvironment(r);
14194
14206
  if (e) return e.mapping = ct, { texture: e };
@@ -14196,7 +14208,7 @@ var mp = [
14196
14208
  } catch (e) {
14197
14209
  this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
14198
14210
  }
14199
- let i = ((await up(t.params, "L", {
14211
+ let i = ((await dp(t.params, "L", {
14200
14212
  resolveNamedTexture: async () => null,
14201
14213
  warn: (e) => this.warn(e)
14202
14214
  }, [
@@ -14215,20 +14227,20 @@ var mp = [
14215
14227
  _reportUnsupportedLights(e) {
14216
14228
  for (let t of e) t.type !== "infinite" && this.warn(`light "${t.type}" not supported (only infinite lights and emissive area lights are mapped)`);
14217
14229
  }
14218
- }, gp = new TextDecoder();
14219
- function _p(e) {
14230
+ }, _p = new TextDecoder();
14231
+ function vp(e) {
14220
14232
  let t = e.replace(/\\/g, "/").split("/"), n = [];
14221
14233
  for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
14222
14234
  return n.join("/");
14223
14235
  }
14224
- function vp(e, t) {
14225
- return !e || t.startsWith("/") ? _p(t) : _p(`${e}/${t}`);
14236
+ function yp(e, t) {
14237
+ return !e || t.startsWith("/") ? vp(t) : vp(`${e}/${t}`);
14226
14238
  }
14227
- var yp = class {
14239
+ var bp = class {
14228
14240
  constructor(e) {
14229
14241
  this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
14230
14242
  for (let t in e) {
14231
- let n = _p(t).toLowerCase(), r = {
14243
+ let n = vp(t).toLowerCase(), r = {
14232
14244
  norm: n,
14233
14245
  bytes: e[t]
14234
14246
  };
@@ -14238,13 +14250,13 @@ var yp = class {
14238
14250
  }
14239
14251
  }
14240
14252
  find(e) {
14241
- let t = _p(e).toLowerCase();
14253
+ let t = vp(e).toLowerCase();
14242
14254
  if (this.byPath.has(t)) return this.byPath.get(t).bytes;
14243
14255
  let n = this.byBase.get(t.split("/").pop());
14244
14256
  return n ? (n.find((e) => e.norm.endsWith("/" + t)) || n[0]).bytes : null;
14245
14257
  }
14246
14258
  };
14247
- function bp(e) {
14259
+ function xp(e) {
14248
14260
  let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
14249
14261
  if (t.length === 0) return null;
14250
14262
  let n = t.filter((e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), r = n.length ? n : t;
@@ -14253,17 +14265,17 @@ function bp(e) {
14253
14265
  return n === r ? e.length - t.length : n - r;
14254
14266
  }), r[0];
14255
14267
  }
14256
- async function xp(e) {
14257
- let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new yp(t), s = e.entryPath || bp(t);
14268
+ async function Sp(e) {
14269
+ let { vfs: t, plyParser: n, imageFromBytes: r, envFromBytes: i, convertHandedness: a } = e, o = new bp(t), s = e.entryPath || xp(t);
14258
14270
  if (!s) throw Error("PBRT loader: no .pbrt file found in archive");
14259
14271
  let c = o.find(s);
14260
14272
  if (!c) throw Error(`PBRT loader: entry "${s}" not readable`);
14261
- let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new ip({ resolveInclude: (e, t) => {
14262
- let n = o.find(vp(t, e)) || o.find(e);
14263
- return n ? gp.decode(n) : null;
14264
- } }).parse(gp.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
14273
+ let l = s.includes("/") ? s.slice(0, s.lastIndexOf("/")) : "", u = new ap({ resolveInclude: (e, t) => {
14274
+ let n = o.find(yp(t, e)) || o.find(e);
14275
+ return n ? _p.decode(n) : null;
14276
+ } }).parse(_p.decode(c), l), d = (e) => e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
14265
14277
  return {
14266
- ...await new hp({
14278
+ ...await new gp({
14267
14279
  convertHandedness: a,
14268
14280
  resolvePLY: async (e) => {
14269
14281
  let t = o.find(e);
@@ -14283,7 +14295,7 @@ async function xp(e) {
14283
14295
  }
14284
14296
  //#endregion
14285
14297
  //#region src/Processor/AssetLoader.js
14286
- var Sp = {
14298
+ var Cp = {
14287
14299
  glb: {
14288
14300
  type: "model",
14289
14301
  name: "GLB (GLTF Binary)"
@@ -14348,7 +14360,7 @@ var Sp = {
14348
14360
  type: "archive",
14349
14361
  name: "ZIP Archive"
14350
14362
  }
14351
- }, Cp = class e extends lt {
14363
+ }, wp = class e extends lt {
14352
14364
  constructor(e, t, n) {
14353
14365
  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, this._loadingManager = new _t(), this._loadCancelled = !1;
14354
14366
  }
@@ -14394,7 +14406,7 @@ var Sp = {
14394
14406
  this.renderer = e;
14395
14407
  }
14396
14408
  getFileFormat(e) {
14397
- return Sp[e.split(".").pop().toLowerCase()] || null;
14409
+ return Cp[e.split(".").pop().toLowerCase()] || null;
14398
14410
  }
14399
14411
  readFileAsArrayBuffer(e) {
14400
14412
  return new Promise((t, n) => {
@@ -14529,7 +14541,7 @@ var Sp = {
14529
14541
  async loadArchiveFromFile(e, t) {
14530
14542
  try {
14531
14543
  let n = await this.readFileAsArrayBuffer(e), r = vn(new Uint8Array(n));
14532
- return bp(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
14544
+ return xp(r) ? await this.loadPBRTFromZip(r, t) : await this.processObjMtlPairsInZip(r, t) || await this.findAndLoadModelFromZip(r, t);
14533
14545
  } catch (e) {
14534
14546
  throw console.error("Error loading ZIP archive:", e), e;
14535
14547
  }
@@ -14543,7 +14555,7 @@ var Sp = {
14543
14555
  let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
14544
14556
  this.loaderCache.ply = new e();
14545
14557
  }
14546
- let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await xp({
14558
+ let { group: n, environment: r, report: i, warnings: a, entryPath: o } = await Sp({
14547
14559
  vfs: e,
14548
14560
  plyParser: (e) => this.loaderCache.ply.parse(e),
14549
14561
  imageFromBytes: (e, t) => this._pbrtTextureFromBytes(e, t),
@@ -14642,7 +14654,7 @@ var Sp = {
14642
14654
  }
14643
14655
  for (let t in e) {
14644
14656
  let n = t.split(".").pop().toLowerCase();
14645
- if (Sp[n] && Sp[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
14657
+ if (Cp[n] && Cp[n].type === "model") return console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e);
14646
14658
  }
14647
14659
  throw Error("No supported model files found in the ZIP archive");
14648
14660
  }
@@ -15202,10 +15214,10 @@ var Sp = {
15202
15214
  getSupportedFormats(e = null) {
15203
15215
  if (e) {
15204
15216
  let t = {};
15205
- for (let [n, r] of Object.entries(Sp)) r.type === e && (t[n] = r);
15217
+ for (let [n, r] of Object.entries(Cp)) r.type === e && (t[n] = r);
15206
15218
  return t;
15207
15219
  }
15208
- return Sp;
15220
+ return Cp;
15209
15221
  }
15210
15222
  dispose() {
15211
15223
  for (let e in this.loaderCache) {
@@ -15217,7 +15229,7 @@ var Sp = {
15217
15229
  removeAllEventListeners() {
15218
15230
  this._listeners = void 0;
15219
15231
  }
15220
- }, wp = {
15232
+ }, Tp = {
15221
15233
  maxBounces: {
15222
15234
  uniform: "maxBounces",
15223
15235
  reset: !0
@@ -15408,10 +15420,10 @@ var Sp = {
15408
15420
  },
15409
15421
  renderMode: { handler: "handleRenderMode" },
15410
15422
  environmentRotation: { handler: "handleEnvironmentRotation" }
15411
- }, Tp = {
15423
+ }, Ep = {
15412
15424
  bounces: "maxBounces",
15413
15425
  debugMode: "visMode"
15414
- }, Ep = class extends lt {
15426
+ }, Dp = class extends lt {
15415
15427
  constructor(e = Y) {
15416
15428
  super(), this._values = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._delegates = {}, this._initDefaults(e);
15417
15429
  }
@@ -15469,7 +15481,7 @@ var Sp = {
15469
15481
  let i = this._values.get(e);
15470
15482
  if (i === t) return;
15471
15483
  this._values.set(e, t);
15472
- let a = wp[e];
15484
+ let a = Tp[e];
15473
15485
  a && (this._applyRoute(a, t, i), (n === void 0 ? a.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
15474
15486
  type: ur.SETTING_CHANGED,
15475
15487
  key: e,
@@ -15483,7 +15495,7 @@ var Sp = {
15483
15495
  let e = this._values.get(n);
15484
15496
  if (e === i) continue;
15485
15497
  this._values.set(n, i);
15486
- let a = wp[n];
15498
+ let a = Tp[n];
15487
15499
  a && (this._applyRoute(a, i, e), (a.reset ?? !0) && (r = !0), t || this.dispatchEvent({
15488
15500
  type: ur.SETTING_CHANGED,
15489
15501
  key: n,
@@ -15501,7 +15513,7 @@ var Sp = {
15501
15513
  }
15502
15514
  applyAll() {
15503
15515
  for (let [e, t] of this._values) {
15504
- let n = wp[e];
15516
+ let n = Tp[e];
15505
15517
  n && this._applyRoute(n, t, void 0);
15506
15518
  }
15507
15519
  }
@@ -15509,10 +15521,10 @@ var Sp = {
15509
15521
  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);
15510
15522
  }
15511
15523
  _initDefaults(e) {
15512
- for (let t of Object.keys(wp)) t in e && this._values.set(t, e[t]);
15513
- for (let [t, n] of Object.entries(Tp)) t in e && this._values.set(n, e[t]);
15524
+ for (let t of Object.keys(Tp)) t in e && this._values.set(t, e[t]);
15525
+ for (let [t, n] of Object.entries(Ep)) t in e && this._values.set(n, e[t]);
15514
15526
  }
15515
- }, Dp = class extends lt {
15527
+ }, Op = class extends lt {
15516
15528
  constructor(e) {
15517
15529
  super();
15518
15530
  let t = e.clientWidth, n = e.clientHeight;
@@ -15678,7 +15690,7 @@ var Sp = {
15678
15690
  dispose() {
15679
15691
  this.controls?.dispose();
15680
15692
  }
15681
- }, Op = class extends lt {
15693
+ }, kp = class extends lt {
15682
15694
  constructor(e, t, n, r = {}) {
15683
15695
  super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null;
15684
15696
  }
@@ -15838,14 +15850,14 @@ var Sp = {
15838
15850
  ], 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);
15839
15851
  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;
15840
15852
  }
15841
- }, kp = class {
15853
+ }, Ap = class {
15842
15854
  constructor(e, t = {}) {
15843
15855
  this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._size = 256;
15844
15856
  }
15845
15857
  async loadLibrary(e, { size: t = 256 } = {}) {
15846
15858
  if (!Array.isArray(e) || e.length === 0) return [];
15847
15859
  this._size = t;
15848
- let n = await Promise.all(e.map((e) => Ap(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
15860
+ let n = await Promise.all(e.map((e) => jp(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
15849
15861
  s.width = r, s.height = i;
15850
15862
  let c = s.getContext("2d", { willReadFrequently: !0 });
15851
15863
  for (let e = 0; e < a; e++) {
@@ -15874,7 +15886,7 @@ var Sp = {
15874
15886
  o.userData.gobo = {
15875
15887
  name: e.name,
15876
15888
  index: e.index,
15877
- intensity: jp(r),
15889
+ intensity: Mp(r),
15878
15890
  inverted: !!i,
15879
15891
  scale: Math.max(1e-4, a)
15880
15892
  };
@@ -15916,28 +15928,28 @@ var Sp = {
15916
15928
  return t && t.isSpotLight ? t : null;
15917
15929
  }
15918
15930
  };
15919
- function Ap(e) {
15931
+ function jp(e) {
15920
15932
  return new Promise((t, n) => {
15921
15933
  let r = new Image();
15922
15934
  r.crossOrigin = "anonymous", r.onload = () => t(r), r.onerror = () => n(/* @__PURE__ */ Error(`Failed to load gobo image: ${e}`)), r.src = e;
15923
15935
  });
15924
15936
  }
15925
- function jp(e) {
15937
+ function Mp(e) {
15926
15938
  return Math.max(0, Math.min(1, e));
15927
15939
  }
15928
15940
  //#endregion
15929
15941
  //#region src/Processor/IESParser.js
15930
- function Mp(e, t = "ies") {
15942
+ function Np(e, t = "ies") {
15931
15943
  let n = e.search(/TILT\s*=/i);
15932
15944
  if (n < 0) throw Error(`IES (${t}): missing TILT line`);
15933
15945
  let r = e.indexOf("\n", n);
15934
15946
  if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
15935
15947
  let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
15936
15948
  if (a === "INCLUDE") {
15937
- let e = Ip(o), t = 2 + 2 * Number(e[1]);
15938
- o = Lp(o, t);
15949
+ let e = Lp(o), t = 2 + 2 * Number(e[1]);
15950
+ o = Rp(o, t);
15939
15951
  }
15940
- let s = Ip(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
15952
+ let s = Lp(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
15941
15953
  l(), l(), l(), l();
15942
15954
  let g = l();
15943
15955
  if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
@@ -15963,18 +15975,18 @@ function Mp(e, t = "ies") {
15963
15975
  name: t
15964
15976
  };
15965
15977
  }
15966
- function Np(e, t, n) {
15978
+ function Pp(e, t, n) {
15967
15979
  let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s } = e;
15968
15980
  if (s <= 0) return r;
15969
15981
  let c = i[i.length - 1], l = a[a.length - 1], u = a[0], d = a.length === 1 || l === u;
15970
15982
  for (let e = 0; e < n; e++) {
15971
- let f = (e + .5) / n * c, p = Rp(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
15983
+ let f = (e + .5) / n * c, p = zp(i, f), m = Math.min(p + 1, i.length - 1), h = i[m] - i[p], g = h > 0 ? (f - i[p]) / h : 0;
15972
15984
  for (let n = 0; n < t; n++) {
15973
15985
  let i;
15974
- if (d) i = zp(o[p][0], o[m][0], g);
15986
+ if (d) i = Bp(o[p][0], o[m][0], g);
15975
15987
  else {
15976
- let e = u + (n + .5) / t * (l - u), r = Rp(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];
15977
- i = zp(zp(f, h, d), zp(_, v, d), g);
15988
+ let e = u + (n + .5) / t * (l - u), r = zp(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];
15989
+ i = Bp(Bp(f, h, d), Bp(_, v, d), g);
15978
15990
  }
15979
15991
  let c = Math.min(1, Math.max(0, i / s));
15980
15992
  r[e * t + n] = Math.round(c * 255);
@@ -15982,7 +15994,7 @@ function Np(e, t, n) {
15982
15994
  }
15983
15995
  return r;
15984
15996
  }
15985
- function Pp(e, t = .1) {
15997
+ function Fp(e, t = .1) {
15986
15998
  let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
15987
15999
  if (a <= 0 || !n?.length) return o;
15988
16000
  let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
@@ -15997,7 +16009,7 @@ function Pp(e, t = .1) {
15997
16009
  let d = l * Math.PI / 180;
15998
16010
  return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
15999
16011
  }
16000
- function Fp(e, t, n = .7) {
16012
+ function Ip(e, t, n = .7) {
16001
16013
  let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
16002
16014
  if (o <= 0 || !r?.length || t <= 0) return 0;
16003
16015
  let s = o * n, c = i.length, l = 0;
@@ -16010,15 +16022,15 @@ function Fp(e, t, n = .7) {
16010
16022
  let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
16011
16023
  return Math.min(Math.max(d, 0), 1);
16012
16024
  }
16013
- function Ip(e) {
16025
+ function Lp(e) {
16014
16026
  return e.split(/\s+/).filter((e) => e.length > 0);
16015
16027
  }
16016
- function Lp(e, t) {
16028
+ function Rp(e, t) {
16017
16029
  let n = /\S+/g, r = 0;
16018
16030
  for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
16019
16031
  return "";
16020
16032
  }
16021
- function Rp(e, t) {
16033
+ function zp(e, t) {
16022
16034
  if (t <= e[0]) return 0;
16023
16035
  if (t >= e[e.length - 1]) return e.length - 1;
16024
16036
  let n = 0, r = e.length - 1;
@@ -16028,12 +16040,12 @@ function Rp(e, t) {
16028
16040
  }
16029
16041
  return n;
16030
16042
  }
16031
- function zp(e, t, n) {
16043
+ function Bp(e, t, n) {
16032
16044
  return e + (t - e) * n;
16033
16045
  }
16034
16046
  //#endregion
16035
16047
  //#region src/managers/IESManager.js
16036
- var Bp = class {
16048
+ var Vp = class {
16037
16049
  constructor(e, t = {}) {
16038
16050
  this.pathTracer = e, this._onReset = t.onReset || null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
16039
16051
  }
@@ -16044,11 +16056,11 @@ var Bp = class {
16044
16056
  try {
16045
16057
  let r = await fetch(e.url);
16046
16058
  if (!r.ok) throw Error(`HTTP ${r.status}`);
16047
- let i = Mp(await r.text(), e.name);
16059
+ let i = Np(await r.text(), e.name);
16048
16060
  return {
16049
16061
  it: e,
16050
16062
  profile: i,
16051
- grid: Np(i, t, n)
16063
+ grid: Pp(i, t, n)
16052
16064
  };
16053
16065
  } catch (t) {
16054
16066
  return console.warn(`IESManager: failed to load "${e.name}": ${t.message}`), null;
@@ -16062,14 +16074,14 @@ var Bp = class {
16062
16074
  let r = t[e];
16063
16075
  o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
16064
16076
  }
16065
- let i = r[e].profile, c = Pp(i);
16077
+ let i = r[e].profile, c = Fp(i);
16066
16078
  s.push({
16067
16079
  name: r[e].it.name,
16068
16080
  index: e,
16069
16081
  maxCandela: i.maxCandela,
16070
16082
  photometricType: i.photometricType,
16071
16083
  suggestedAngle: c,
16072
- suggestedPenumbra: Fp(i, c),
16084
+ suggestedPenumbra: Ip(i, c),
16073
16085
  lumens: i.lumens
16074
16086
  });
16075
16087
  }
@@ -16102,7 +16114,7 @@ var Bp = class {
16102
16114
  l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
16103
16115
  name: e.name,
16104
16116
  index: e.index,
16105
- intensity: Vp(n),
16117
+ intensity: Hp(n),
16106
16118
  fixtureLumens: l
16107
16119
  }, 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);
16108
16120
  }
@@ -16125,44 +16137,44 @@ var Bp = class {
16125
16137
  return t && t.isSpotLight ? t : null;
16126
16138
  }
16127
16139
  };
16128
- function Vp(e) {
16140
+ function Hp(e) {
16129
16141
  return Math.max(0, Math.min(1, e));
16130
16142
  }
16131
16143
  //#endregion
16132
16144
  //#region src/Processor/ToneMapCPU.js
16133
- var Hp = (e) => Math.min(Math.max(e, 0), 1);
16134
- function Up(e, t, n, r, i) {
16135
- i[0] = Hp(e), i[1] = Hp(t), i[2] = Hp(n);
16136
- }
16145
+ var Up = (e) => Math.min(Math.max(e, 0), 1);
16137
16146
  function Wp(e, t, n, r, i) {
16138
- i[0] = Hp(e * r), i[1] = Hp(t * r), i[2] = Hp(n * r);
16147
+ i[0] = Up(e), i[1] = Up(t), i[2] = Up(n);
16139
16148
  }
16140
16149
  function Gp(e, t, n, r, i) {
16141
- e *= r, t *= r, n *= r, i[0] = Hp(e / (e + 1)), i[1] = Hp(t / (t + 1)), i[2] = Hp(n / (n + 1));
16150
+ i[0] = Up(e * r), i[1] = Up(t * r), i[2] = Up(n * r);
16142
16151
  }
16143
16152
  function Kp(e, t, n, r, i) {
16153
+ e *= r, t *= r, n *= r, i[0] = Up(e / (e + 1)), i[1] = Up(t / (t + 1)), i[2] = Up(n / (n + 1));
16154
+ }
16155
+ function qp(e, t, n, r, i) {
16144
16156
  e = Math.max(e * r - .004, 0), t = Math.max(t * r - .004, 0), n = Math.max(n * r - .004, 0);
16145
16157
  let a = (e) => (e * (6.2 * e + .5) / (e * (6.2 * e + 1.7) + .06)) ** 2.2;
16146
16158
  i[0] = a(e), i[1] = a(t), i[2] = a(n);
16147
16159
  }
16148
- function qp(e, t, n, r, i) {
16160
+ function Jp(e, t, n, r, i) {
16149
16161
  e = e * r / .6, t = t * r / .6, n = n * r / .6;
16150
16162
  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);
16151
- a = c(a), o = c(o), s = c(s), i[0] = Hp(1.60475 * a - .53108 * o - .07367 * s), i[1] = Hp(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Hp(-.00327 * a - .07276 * o + 1.07602 * s);
16163
+ a = c(a), o = c(o), s = c(s), i[0] = Up(1.60475 * a - .53108 * o - .07367 * s), i[1] = Up(-.10208 * a + 1.10813 * o - .00605 * s), i[2] = Up(-.00327 * a - .07276 * o + 1.07602 * s);
16152
16164
  }
16153
- function Jp(e, t, n, r, i) {
16165
+ function Yp(e, t, n, r, i) {
16154
16166
  e *= r, t *= r, n *= r;
16155
16167
  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;
16156
- c = Hp((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Hp((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Hp((Math.log2(Math.max(u, 1e-10)) - d) / f);
16168
+ c = Up((Math.log2(Math.max(c, 1e-10)) - d) / f), l = Up((Math.log2(Math.max(l, 1e-10)) - d) / f), u = Up((Math.log2(Math.max(u, 1e-10)) - d) / f);
16157
16169
  let p = (e) => {
16158
16170
  let t = e * e, n = t * t;
16159
16171
  return 15.5 * n * t - 40.14 * n * e + 31.96 * n - 6.868 * t * e + .4298 * t + .1191 * e - .00232;
16160
16172
  };
16161
16173
  c = p(c), l = p(l), u = p(u);
16162
16174
  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;
16163
- m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Hp(1.6605 * m - .5876 * h - .0728 * g), i[1] = Hp(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Hp(-.0182 * m - .1006 * h + 1.1187 * g);
16175
+ m = Math.max(0, m) ** 2.2, h = Math.max(0, h) ** 2.2, g = Math.max(0, g) ** 2.2, i[0] = Up(1.6605 * m - .5876 * h - .0728 * g), i[1] = Up(-.1246 * m + 1.1329 * h - .0083 * g), i[2] = Up(-.0182 * m - .1006 * h + 1.1187 * g);
16164
16176
  }
16165
- function Yp(e, t, n, r, i) {
16177
+ function Xp(e, t, n, r, i) {
16166
16178
  let a = .76;
16167
16179
  e *= r, t *= r, n *= r;
16168
16180
  let o = Math.min(e, Math.min(t, n)), s = o < .08 ? o - 6.25 * o * o : .04;
@@ -16177,43 +16189,43 @@ function Yp(e, t, n, r, i) {
16177
16189
  let f = 1 - 1 / (.15 * (c - u) + 1);
16178
16190
  i[0] = e + (u - e) * f, i[1] = t + (u - t) * f, i[2] = n + (u - n) * f;
16179
16191
  }
16180
- var Xp = new Map([
16181
- [At, Up],
16182
- [J, Wp],
16183
- [Gt, Gp],
16184
- [Ze, Kp],
16185
- [He, qp],
16186
- [We, Jp],
16187
- [Ot, Yp]
16188
- ]), Zp = 1 / 2.2;
16189
- function Qp(e) {
16192
+ var Zp = new Map([
16193
+ [At, Wp],
16194
+ [J, Gp],
16195
+ [Gt, Kp],
16196
+ [Ze, qp],
16197
+ [He, Jp],
16198
+ [We, Yp],
16199
+ [Ot, Xp]
16200
+ ]), Qp = 1 / 2.2;
16201
+ function $p(e) {
16190
16202
  return e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055;
16191
16203
  }
16192
- var $p = .2126, em = .7152, tm = .0722;
16193
- function nm(e, t) {
16204
+ var em = .2126, tm = .7152, nm = .0722;
16205
+ function rm(e, t) {
16194
16206
  if (t === 1) return;
16195
- let n = e[0] * $p + e[1] * em + e[2] * tm;
16207
+ let n = e[0] * em + e[1] * tm + e[2] * nm;
16196
16208
  e[0] = n + (e[0] - n) * t, e[1] = n + (e[1] - n) * t, e[2] = n + (e[2] - n) * t;
16197
16209
  }
16198
16210
  //#endregion
16199
16211
  //#region src/Passes/OIDNDenoiser.js
16200
- var rm = ai("oidn"), im = null, am = null;
16201
- async function om() {
16202
- if (!im) {
16212
+ var im = ai("oidn"), am = null, om = null;
16213
+ async function sm() {
16214
+ if (!am) {
16203
16215
  let [e, t] = await Promise.all([import("oidn-web"), import("@tensorflow/tfjs-core")]);
16204
- im = e.initUNetFromURL, am = t.engine;
16216
+ am = e.initUNetFromURL, om = t.engine;
16205
16217
  }
16206
- return im;
16218
+ return am;
16207
16219
  }
16208
- function sm() {
16209
- if (am) try {
16210
- let e = am();
16220
+ function cm() {
16221
+ if (om) try {
16222
+ let e = om();
16211
16223
  e?.registryFactory && "webgpu-oidn" in e.registryFactory && e.removeBackend("webgpu-oidn");
16212
16224
  } catch (e) {
16213
- rm.warn("failed to clear cached TFJS backend", e);
16225
+ im.warn("failed to clear cached TFJS backend", e);
16214
16226
  }
16215
16227
  }
16216
- var cm = new Float32Array(3), lm = {
16228
+ var lm = new Float32Array(3), um = {
16217
16229
  QUALITY_MODELS: {
16218
16230
  fast: "rt_hdr_alb_nrm_small",
16219
16231
  balance: "rt_hdr_alb_nrm",
@@ -16225,7 +16237,7 @@ var cm = new Float32Array(3), lm = {
16225
16237
  debugGbufferMaps: !0,
16226
16238
  tileSize: 256
16227
16239
  }
16228
- }, um = class extends lt {
16240
+ }, dm = class extends lt {
16229
16241
  constructor(e, t, n, r, i = {}) {
16230
16242
  if (super(), !e || !t || !n || !r) throw Error("OIDNDenoiser requires output canvas, renderer, scene, and camera");
16231
16243
  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 || (() => He), this.getSaturation = i.getSaturation || (() => 1), this.getTransparentBackground = i.getTransparentBackground || (() => !1), this.isGPUMode = !!this.backendParamsGetter, this.gpuDevice = null, this._gpuInputBuffers = {
@@ -16236,14 +16248,14 @@ var cm = new Float32Array(3), lm = {
16236
16248
  width: 0,
16237
16249
  height: 0
16238
16250
  }, this._gpuInputPadBuffer = null, this._gpuInputPaddedRowBytes = 0, this._alphaReadbackBuffer = null, this._alphaReadbackMapped = !1, this._cachedAlpha = null, this._cachedAlphaWidth = 0, this.config = {
16239
- ...lm.DEFAULT_OPTIONS,
16251
+ ...um.DEFAULT_OPTIONS,
16240
16252
  ...i
16241
16253
  }, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.debugGbufferMaps = this.config.debugGbufferMaps, this.tileSize = this.config.tileSize, this.state = {
16242
16254
  isDenoising: !1,
16243
16255
  isLoading: !1,
16244
16256
  abortController: null
16245
16257
  }, this._pendingStagingBuffers = /* @__PURE__ */ new Set(), this._pendingTileBlits = [], this.currentTZAUrl = null, this.unet = null, this._pendingStart = !1, this._initialize().catch((e) => {
16246
- rm.error("init failed:", e), this.dispatchEvent({
16258
+ im.error("init failed:", e), this.dispatchEvent({
16247
16259
  type: "error",
16248
16260
  error: e
16249
16261
  });
@@ -16289,13 +16301,13 @@ var cm = new Float32Array(3), lm = {
16289
16301
  let e = this.backendParamsGetter();
16290
16302
  this.gpuDevice = e?.device ?? null, t = e?.device ? e : void 0;
16291
16303
  }
16292
- this.unet = await (await om())(e, t, {
16304
+ this.unet = await (await sm())(e, t, {
16293
16305
  aux: !0,
16294
16306
  hdr: !0,
16295
16307
  maxTileSize: this.tileSize
16296
- }), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }), rm.debug("UNet weights loaded:", e);
16308
+ }), this.currentTZAUrl = e, this.dispatchEvent({ type: "loaded" }), im.debug("UNet weights loaded:", e);
16297
16309
  } catch (e) {
16298
- rm.error("UNet weights failed to load:", e), this.dispatchEvent({
16310
+ im.error("UNet weights failed to load:", e), this.dispatchEvent({
16299
16311
  type: "error",
16300
16312
  error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`)
16301
16313
  });
@@ -16304,14 +16316,14 @@ var cm = new Float32Array(3), lm = {
16304
16316
  }
16305
16317
  }
16306
16318
  _generateTzaUrl() {
16307
- let { oidnWeightsBaseUrl: e } = cl(), { QUALITY_MODELS: t } = lm;
16319
+ let { oidnWeightsBaseUrl: e } = cl(), { QUALITY_MODELS: t } = um;
16308
16320
  return `${e}${t[this.quality] || t.balance}.tza`;
16309
16321
  }
16310
16322
  async updateConfiguration(e) {
16311
16323
  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());
16312
16324
  }
16313
16325
  async updateQuality(e) {
16314
- if (!Object.prototype.hasOwnProperty.call(lm.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(lm.QUALITY_MODELS).join(", ")}`);
16326
+ if (!Object.prototype.hasOwnProperty.call(um.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(um.QUALITY_MODELS).join(", ")}`);
16315
16327
  await this.updateConfiguration({ oidnQuality: e });
16316
16328
  }
16317
16329
  async start() {
@@ -16322,7 +16334,7 @@ var cm = new Float32Array(3), lm = {
16322
16334
  if (t) {
16323
16335
  this.renderer?.resetState?.(), this.input.style.opacity = "0";
16324
16336
  let t = performance.now() - e;
16325
- rm.debug(`denoise complete in ${Q.ms(t)} · quality ${this.quality}`);
16337
+ im.debug(`denoise complete in ${Q.ms(t)} · quality ${this.quality}`);
16326
16338
  }
16327
16339
  return t;
16328
16340
  }
@@ -16332,7 +16344,7 @@ var cm = new Float32Array(3), lm = {
16332
16344
  try {
16333
16345
  return await this._executeUNet(), !0;
16334
16346
  } catch (e) {
16335
- return e.name === "AbortError" ? rm.debug("denoise aborted") : rm.error("denoise error:", e), this.input.style.opacity = "1", !1;
16347
+ return e.name === "AbortError" ? im.debug("denoise aborted") : im.error("denoise error:", e), this.input.style.opacity = "1", !1;
16336
16348
  } finally {
16337
16349
  this.state.isDenoising = !1, this.state.abortController = null, this.dispatchEvent({ type: "end" });
16338
16350
  }
@@ -16342,11 +16354,11 @@ var cm = new Float32Array(3), lm = {
16342
16354
  }
16343
16355
  async _executeUNetGPU() {
16344
16356
  let { width: e, height: t } = this.output;
16345
- if (!this.getGPUTextures) return rm.warn("GPU mode enabled but getGPUTextures not provided"), !1;
16357
+ if (!this.getGPUTextures) return im.warn("GPU mode enabled but getGPUTextures not provided"), !1;
16346
16358
  let n = this.getGPUTextures();
16347
- if (!n?.color) return rm.warn("GPU textures not ready yet"), !1;
16359
+ if (!n?.color) return im.warn("GPU textures not ready yet"), !1;
16348
16360
  let r = this.gpuDevice;
16349
- if (!r) return rm.warn("gpuDevice not available"), !1;
16361
+ if (!r) return im.warn("gpuDevice not available"), !1;
16350
16362
  this._ensureGPUInputBuffers(e, t);
16351
16363
  let i = r.createCommandEncoder({ label: "oidn-tex-to-buf" }), a = e * 16, o = this._gpuInputPaddedRowBytes, s = o > a, c = this._gpuInputPadBuffer, l = (n, r) => {
16352
16364
  if (!s) i.copyTextureToBuffer({
@@ -16496,10 +16508,10 @@ var cm = new Float32Array(3), lm = {
16496
16508
  }
16497
16509
  r.queue.submit([d.finish()]);
16498
16510
  let f = u.mapAsync(GPUMapMode.READ).then(() => {
16499
- let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Xp.get(this.getToneMapping()) || Xp.get(He), d = this._cachedAlpha, f = this._cachedAlphaWidth;
16511
+ let e = new Float32Array(u.getMappedRange()), t = new ImageData(o, s), r = this.getExposure(), c = this.getSaturation(), l = Zp.get(this.getToneMapping()) || Zp.get(He), d = this._cachedAlpha, f = this._cachedAlphaWidth;
16500
16512
  for (let i = 0, a = e.length; i < a; i += 4) {
16501
16513
  let a = e[i] * r, s = e[i + 1] * r, u = e[i + 2] * r;
16502
- if (c !== 1 && (cm[0] = a, cm[1] = s, cm[2] = u, nm(cm, c), a = cm[0], s = cm[1], u = cm[2]), l(a, s, u, 1, cm), t.data[i] = Qp(cm[0]) * 255 + .5 | 0, t.data[i + 1] = Qp(cm[1]) * 255 + .5 | 0, t.data[i + 2] = Qp(cm[2]) * 255 + .5 | 0, d) {
16514
+ if (c !== 1 && (lm[0] = a, lm[1] = s, lm[2] = u, rm(lm, c), a = lm[0], s = lm[1], u = lm[2]), l(a, s, u, 1, lm), t.data[i] = $p(lm[0]) * 255 + .5 | 0, t.data[i + 1] = $p(lm[1]) * 255 + .5 | 0, t.data[i + 2] = $p(lm[2]) * 255 + .5 | 0, d) {
16503
16515
  let e = (i >> 2) % o, r = (i >> 2) / o | 0;
16504
16516
  t.data[i + 3] = d[(n.y + r) * f + n.x + e];
16505
16517
  } else t.data[i + 3] = 255;
@@ -16526,7 +16538,7 @@ var cm = new Float32Array(3), lm = {
16526
16538
  async _displayGPUOutput({ data: e, width: t, height: n }) {
16527
16539
  let r = this.gpuDevice;
16528
16540
  if (!r) {
16529
- rm.error("gpuDevice not available for output readback");
16541
+ im.error("gpuDevice not available for output readback");
16530
16542
  return;
16531
16543
  }
16532
16544
  let i = t * n * 4 * 4, a = r.createBuffer({
@@ -16537,10 +16549,10 @@ var cm = new Float32Array(3), lm = {
16537
16549
  try {
16538
16550
  let o = r.createCommandEncoder({ label: "oidn-readback" });
16539
16551
  o.copyBufferToBuffer(e, 0, a, 0, i), r.queue.submit([o.finish()]), await a.mapAsync(GPUMapMode.READ);
16540
- let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Xp.get(this.getToneMapping()) || Xp.get(He), f = this._cachedAlpha;
16552
+ let s = new Float32Array(a.getMappedRange()), c = new ImageData(t, n), l = this.getExposure(), u = this.getSaturation(), d = Zp.get(this.getToneMapping()) || Zp.get(He), f = this._cachedAlpha;
16541
16553
  for (let e = 0, t = s.length; e < t; e += 4) {
16542
16554
  let t = s[e] * l, n = s[e + 1] * l, r = s[e + 2] * l;
16543
- u !== 1 && (cm[0] = t, cm[1] = n, cm[2] = r, nm(cm, u), t = cm[0], n = cm[1], r = cm[2]), d(t, n, r, 1, cm), c.data[e] = Qp(cm[0]) * 255 + .5 | 0, c.data[e + 1] = Qp(cm[1]) * 255 + .5 | 0, c.data[e + 2] = Qp(cm[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
16555
+ u !== 1 && (lm[0] = t, lm[1] = n, lm[2] = r, rm(lm, u), t = lm[0], n = lm[1], r = lm[2]), d(t, n, r, 1, lm), c.data[e] = $p(lm[0]) * 255 + .5 | 0, c.data[e + 1] = $p(lm[1]) * 255 + .5 | 0, c.data[e + 2] = $p(lm[2]) * 255 + .5 | 0, c.data[e + 3] = f ? f[e >> 2] : 255;
16544
16556
  }
16545
16557
  a.unmap(), this.ctx.putImageData(c, 0, 0);
16546
16558
  } finally {
@@ -16548,12 +16560,12 @@ var cm = new Float32Array(3), lm = {
16548
16560
  }
16549
16561
  }
16550
16562
  abort() {
16551
- 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" }), rm.debug("denoise aborted"));
16563
+ 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" }), im.debug("denoise aborted"));
16552
16564
  }
16553
16565
  setSize(e, t) {
16554
16566
  if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
16555
16567
  this.output.width = e, this.output.height = t, this._setupUNetDenoiser().catch((e) => {
16556
- rm.error("reinitialize after size change failed:", e);
16568
+ im.error("reinitialize after size change failed:", e);
16557
16569
  });
16558
16570
  }
16559
16571
  _destroyPendingStagingBuffers() {
@@ -16561,13 +16573,13 @@ var cm = new Float32Array(3), lm = {
16561
16573
  this._pendingStagingBuffers.clear();
16562
16574
  }
16563
16575
  dispose() {
16564
- this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), sm(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), rm.debug("disposed");
16576
+ this.abort(), this._destroyPendingStagingBuffers(), this.unet?.dispose(), cm(), this._destroyGPUInputBuffers(), this.output?.parentNode && this.output.remove(), this.unet = null, this.ctx = null, this.state.abortController = null, this.removeAllListeners?.(), im.debug("disposed");
16565
16577
  }
16566
- }, dm = "let e={ortRuntimeUrl:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs`,ortWasmPaths:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/`,cacheNamespace:`rayzee`},t=null;async function n(){return t||(t=await import(e.ortRuntimeUrl),t.env.wasm.wasmPaths=e.ortWasmPaths,t.env.logLevel=`error`,t)}function r(){return`${e.cacheNamespace}:ai-upscaler-models`}const i=`models`;let a=null,o=null;function s(){return new Promise((e,t)=>{let n=indexedDB.open(r(),1);n.onupgradeneeded=()=>n.result.createObjectStore(i),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function c(e){try{let t=await s();return await new Promise((n,r)=>{let a=t.transaction(i,`readonly`).objectStore(i).get(e);a.onsuccess=()=>n(a.result||null),a.onerror=()=>r(a.error)})}catch{return null}}async function l(e,t){try{let n=await s();await new Promise((r,a)=>{let o=n.transaction(i,`readwrite`);o.objectStore(i).put(t,e),o.oncomplete=()=>r(),o.onerror=()=>a(o.error)})}catch{}}async function u(e){let t=await c(e);if(t)return console.log(`AI Upscaler Worker: model loaded from cache (${(t.byteLength/1024/1024).toFixed(1)}MB)`),t;let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch model: ${n.status}`);let r=await n.arrayBuffer();return l(e,r.slice(0)),r}async function d(e,t){if(a&&o===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}a&&=(await a.release(),null);let[r,i]=await Promise.all([u(e),n()]);a=await i.InferenceSession.create(r,t),o=e;let s=512;try{let e=await navigator.gpu?.requestAdapter(),t=await e?.requestAdapterInfo?.()||e?.info,n=/apple|swiftshader|llvmpipe/i.test(t?.vendor||``)||/apple|swiftshader/i.test(t?.architecture||``),r=t?.device?.toLowerCase?.()?.includes(`integrated`)||/intel.*iris|intel.*uhd|intel.*hd|amd.*vega|radeon.*graphics/i.test(t?.description||``);s=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${s}`)}catch{}let c=(r.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${c}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:s})}async function f(e,t,r,i){let o=await n(),s=a.inputNames[0],c=a.outputNames[0],l=new o.Tensor(`float32`,e,[1,3,r,t]),u=(await a.run({[s]:l}))[c].data;self.postMessage({type:`inferred`,outputData:u,id:i},[u.buffer])}self.onmessage=async t=>{let{type:n}=t.data;try{n===`load`?(t.data.ortRuntimeUrl&&(e.ortRuntimeUrl=t.data.ortRuntimeUrl),t.data.ortWasmPaths&&(e.ortWasmPaths=t.data.ortWasmPaths),t.data.cacheNamespace&&(e.cacheNamespace=t.data.cacheNamespace),await d(t.data.url,t.data.sessionOptions)):n===`infer`?await f(t.data.tileData,t.data.width,t.data.height,t.data.id):n===`dispose`&&a&&(await a.release(),a=null,o=null)}catch(e){self.postMessage({type:`error`,message:e.message,id:t.data?.id})}};", fm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", dm], { type: "text/javascript;charset=utf-8" });
16567
- function pm(e) {
16578
+ }, fm = "let e={ortRuntimeUrl:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/ort.webgpu.bundle.min.mjs`,ortWasmPaths:`https://cdn.jsdelivr.net/npm/onnxruntime-web@1.24.3/dist/`,cacheNamespace:`rayzee`},t=null;async function n(){return t||(t=await import(e.ortRuntimeUrl),t.env.wasm.wasmPaths=e.ortWasmPaths,t.env.logLevel=`error`,t)}function r(){return`${e.cacheNamespace}:ai-upscaler-models`}const i=`models`;let a=null,o=null;function s(){return new Promise((e,t)=>{let n=indexedDB.open(r(),1);n.onupgradeneeded=()=>n.result.createObjectStore(i),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}async function c(e){try{let t=await s();return await new Promise((n,r)=>{let a=t.transaction(i,`readonly`).objectStore(i).get(e);a.onsuccess=()=>n(a.result||null),a.onerror=()=>r(a.error)})}catch{return null}}async function l(e,t){try{let n=await s();await new Promise((r,a)=>{let o=n.transaction(i,`readwrite`);o.objectStore(i).put(t,e),o.oncomplete=()=>r(),o.onerror=()=>a(o.error)})}catch{}}async function u(e){let t=await c(e);if(t)return console.log(`AI Upscaler Worker: model loaded from cache (${(t.byteLength/1024/1024).toFixed(1)}MB)`),t;let n=await fetch(e);if(!n.ok)throw Error(`Failed to fetch model: ${n.status}`);let r=await n.arrayBuffer();return l(e,r.slice(0)),r}async function d(e,t){if(a&&o===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}a&&=(await a.release(),null);let[r,i]=await Promise.all([u(e),n()]);a=await i.InferenceSession.create(r,t),o=e;let s=512;try{let e=await navigator.gpu?.requestAdapter(),t=await e?.requestAdapterInfo?.()||e?.info,n=/apple|swiftshader|llvmpipe/i.test(t?.vendor||``)||/apple|swiftshader/i.test(t?.architecture||``),r=t?.device?.toLowerCase?.()?.includes(`integrated`)||/intel.*iris|intel.*uhd|intel.*hd|amd.*vega|radeon.*graphics/i.test(t?.description||``);s=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${s}`)}catch{}let c=(r.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${c}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:s})}async function f(e,t,r,i){let o=await n(),s=a.inputNames[0],c=a.outputNames[0],l=new o.Tensor(`float32`,e,[1,3,r,t]),u=(await a.run({[s]:l}))[c].data;self.postMessage({type:`inferred`,outputData:u,id:i},[u.buffer])}self.onmessage=async t=>{let{type:n}=t.data;try{n===`load`?(t.data.ortRuntimeUrl&&(e.ortRuntimeUrl=t.data.ortRuntimeUrl),t.data.ortWasmPaths&&(e.ortWasmPaths=t.data.ortWasmPaths),t.data.cacheNamespace&&(e.cacheNamespace=t.data.cacheNamespace),await d(t.data.url,t.data.sessionOptions)):n===`infer`?await f(t.data.tileData,t.data.width,t.data.height,t.data.id):n===`dispose`&&a&&(await a.release(),a=null,o=null)}catch(e){self.postMessage({type:`error`,message:e.message,id:t.data?.id})}};", pm = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", fm], { type: "text/javascript;charset=utf-8" });
16579
+ function mm(e) {
16568
16580
  let t;
16569
16581
  try {
16570
- if (t = fm && (self.URL || self.webkitURL).createObjectURL(fm), !t) throw "";
16582
+ if (t = pm && (self.URL || self.webkitURL).createObjectURL(pm), !t) throw "";
16571
16583
  let n = new Worker(t, {
16572
16584
  type: "module",
16573
16585
  name: e?.name
@@ -16576,7 +16588,7 @@ function pm(e) {
16576
16588
  (self.URL || self.webkitURL).revokeObjectURL(t);
16577
16589
  }), n;
16578
16590
  } catch {
16579
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(dm), {
16591
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(fm), {
16580
16592
  type: "module",
16581
16593
  name: e?.name
16582
16594
  });
@@ -16584,7 +16596,7 @@ function pm(e) {
16584
16596
  }
16585
16597
  //#endregion
16586
16598
  //#region src/Passes/AIUpscaler.js
16587
- var mm = {
16599
+ var hm = {
16588
16600
  fast: {
16589
16601
  2: "2x-spanx2-ch48.onnx",
16590
16602
  4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
@@ -16598,17 +16610,17 @@ var mm = {
16598
16610
  4: "4xNomos2_hq_mosr_fp32.onnx"
16599
16611
  }
16600
16612
  };
16601
- function hm() {
16613
+ function gm() {
16602
16614
  let { upscalerModelBaseUrl: e } = cl(), t = {};
16603
- for (let n in mm) {
16615
+ for (let n in hm) {
16604
16616
  t[n] = {};
16605
- for (let r in mm[n]) t[n][r] = e + mm[n][r];
16617
+ for (let r in hm[n]) t[n][r] = e + hm[n][r];
16606
16618
  }
16607
16619
  return t;
16608
16620
  }
16609
- var gm = {
16621
+ var _m = {
16610
16622
  get QUALITY_PRESETS() {
16611
- return hm();
16623
+ return gm();
16612
16624
  },
16613
16625
  TILE_SIZE: 512,
16614
16626
  TILE_OVERLAP: 16,
@@ -16619,17 +16631,17 @@ var gm = {
16619
16631
  }],
16620
16632
  graphOptimizationLevel: "all"
16621
16633
  }
16622
- }, _m = class extends lt {
16634
+ }, vm = class extends lt {
16623
16635
  constructor(e, t, n = {}) {
16624
16636
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
16625
- 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 || (() => He), 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 || gm.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
16637
+ 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 || (() => He), 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 || _m.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
16626
16638
  isUpscaling: !1,
16627
16639
  isLoading: !1,
16628
16640
  abortController: null
16629
16641
  }, 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;
16630
16642
  }
16631
16643
  async _ensureSession() {
16632
- let e = gm.QUALITY_PRESETS[this.quality];
16644
+ let e = _m.QUALITY_PRESETS[this.quality];
16633
16645
  if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
16634
16646
  let t = e[this.scaleFactor];
16635
16647
  if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
@@ -16639,14 +16651,14 @@ var gm = {
16639
16651
  message: `Loading ${this.scaleFactor}x upscale model...`
16640
16652
  });
16641
16653
  try {
16642
- this._worker ||= new pm(), await new Promise((e, n) => {
16654
+ this._worker ||= new mm(), await new Promise((e, n) => {
16643
16655
  let r = (t) => {
16644
16656
  t.data.type === "loaded" ? (this._worker.removeEventListener("message", r), t.data.tileSize && !this._tileSizeOverride && (this.tileSize = t.data.tileSize), console.log(`AI Upscaler: ${this.scaleFactor}x model loaded, backend: ${t.data.backend}, tileSize: ${this.tileSize}`), e()) : t.data.type === "error" && (this._worker.removeEventListener("message", r), n(Error(t.data.message)));
16645
16657
  }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o } = cl();
16646
16658
  this._worker.addEventListener("message", r), this._worker.postMessage({
16647
16659
  type: "load",
16648
16660
  url: t,
16649
- sessionOptions: gm.SESSION_OPTIONS,
16661
+ sessionOptions: _m.SESSION_OPTIONS,
16650
16662
  ortRuntimeUrl: i,
16651
16663
  ortWasmPaths: a,
16652
16664
  cacheNamespace: o
@@ -16716,8 +16728,8 @@ var gm = {
16716
16728
  willReadFrequently: !0,
16717
16729
  alpha: !0
16718
16730
  });
16719
- this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Xp.get(this.getToneMapping()) || Xp.get(He), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
16720
- let o = gm.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
16731
+ this._cacheUpscaledAlpha(t, n * i, r * i), t.isHDR && (this._hdrToneMapFn = Zp.get(this.getToneMapping()) || Zp.get(He), this._hdrExposure = this.getExposure(), this._hdrSaturation = this.getSaturation(), this._tmOut = new Float32Array(3));
16732
+ let o = _m.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
16721
16733
  for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
16722
16734
  if (e.aborted) throw new DOMException("Aborted", "AbortError");
16723
16735
  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);
@@ -16790,7 +16802,7 @@ var gm = {
16790
16802
  let u = ((n + e) * o + (t + i)) * 4, d = e * r + i;
16791
16803
  if (s) {
16792
16804
  let e = this._hdrToneMapFn, t = this._hdrExposure, n = this._hdrSaturation, r = a[u] * t, i = a[u + 1] * t, o = a[u + 2] * t;
16793
- n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, nm(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] ** +Zp, l[c + d] = this._tmOut[1] ** +Zp, l[2 * c + d] = this._tmOut[2] ** +Zp;
16805
+ n !== 1 && (this._tmOut[0] = r, this._tmOut[1] = i, this._tmOut[2] = o, rm(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] ** +Qp, l[c + d] = this._tmOut[1] ** +Qp, l[2 * c + d] = this._tmOut[2] ** +Qp;
16794
16806
  } else l[d] = a[u] / 255, l[c + d] = a[u + 1] / 255, l[2 * c + d] = a[u + 2] / 255;
16795
16807
  }
16796
16808
  return l;
@@ -16848,10 +16860,10 @@ var gm = {
16848
16860
  this._backupCanvas = document.createElement("canvas"), this._backupCanvas.width = e.width, this._backupCanvas.height = e.height;
16849
16861
  let t = this._backupCanvas.getContext("2d");
16850
16862
  if (e.isHDR) {
16851
- let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Xp.get(this.getToneMapping()) || Xp.get(He), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
16863
+ let { data: n, width: r, height: i } = e, a = t.createImageData(r, i), o = a.data, s = Zp.get(this.getToneMapping()) || Zp.get(He), c = this.getExposure(), l = this.getSaturation(), u = new Float32Array(3);
16852
16864
  for (let e = 0, t = r * i; e < t; e++) {
16853
16865
  let t = e * 4, r = n[t] * c, i = n[t + 1] * c, a = n[t + 2] * c;
16854
- l !== 1 && (u[0] = r, u[1] = i, u[2] = a, nm(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Zp * 255 + .5 | 0, o[t + 1] = u[1] ** +Zp * 255 + .5 | 0, o[t + 2] = u[2] ** +Zp * 255 + .5 | 0, o[t + 3] = 255;
16866
+ l !== 1 && (u[0] = r, u[1] = i, u[2] = a, rm(u, l), r = u[0], i = u[1], a = u[2]), s(r, i, a, 1, u), o[t] = u[0] ** +Qp * 255 + .5 | 0, o[t + 1] = u[1] ** +Qp * 255 + .5 | 0, o[t + 2] = u[2] ** +Qp * 255 + .5 | 0, o[t + 3] = 255;
16855
16867
  }
16856
16868
  t.putImageData(a, 0, 0);
16857
16869
  } else t.putImageData(e, 0, 0);
@@ -16863,7 +16875,7 @@ var gm = {
16863
16875
  this.hdr = !!e;
16864
16876
  }
16865
16877
  setQuality(e) {
16866
- if (!gm.QUALITY_PRESETS[e]) {
16878
+ if (!_m.QUALITY_PRESETS[e]) {
16867
16879
  console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
16868
16880
  return;
16869
16881
  }
@@ -16886,9 +16898,9 @@ var gm = {
16886
16898
  async dispose() {
16887
16899
  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");
16888
16900
  }
16889
- }, vm = class extends lt {
16901
+ }, ym = class extends lt {
16890
16902
  constructor({ renderer: e, mainCanvas: t, scene: n, camera: r, stages: i, pipeline: a, getExposure: o, getSaturation: s, getTransparentBg: c }) {
16891
- 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;
16903
+ 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._onReset = null, this._onPostProcessRefresh = 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;
16892
16904
  }
16893
16905
  _createDenoiserCanvas(e) {
16894
16906
  let t = e.parentNode;
@@ -16907,7 +16919,7 @@ var gm = {
16907
16919
  setupDenoiser() {
16908
16920
  if (!this.denoiserCanvas) return;
16909
16921
  let e = this._stages.pathTracer;
16910
- this.denoiser = new um(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
16922
+ this.denoiser = new dm(this.denoiserCanvas, this.renderer, this.scene, this.camera, {
16911
16923
  ...Y,
16912
16924
  backendParams: () => ({
16913
16925
  device: this.renderer.backend.device,
@@ -16932,7 +16944,7 @@ var gm = {
16932
16944
  setupUpscaler() {
16933
16945
  if (!this.denoiserCanvas) return;
16934
16946
  let e = this._stages.pathTracer;
16935
- this.upscaler = new _m(this.denoiserCanvas, this.renderer, {
16947
+ this.upscaler = new vm(this.denoiserCanvas, this.renderer, {
16936
16948
  scaleFactor: Y.upscalerScale || 2,
16937
16949
  quality: Y.upscalerQuality || "fast",
16938
16950
  getSourceCanvas: () => this.denoiser?.enabled ? null : this.renderer.domElement,
@@ -17013,6 +17025,9 @@ var gm = {
17013
17025
  setResetCallback(e) {
17014
17026
  this._onReset = e;
17015
17027
  }
17028
+ setPostProcessRefreshCallback(e) {
17029
+ this._onPostProcessRefresh = e;
17030
+ }
17016
17031
  setSettings(e) {
17017
17032
  this._settings = e;
17018
17033
  }
@@ -17032,10 +17047,10 @@ var gm = {
17032
17047
  this._stages.autoExposure?.updateParameters(e);
17033
17048
  }
17034
17049
  setOIDNEnabled(e) {
17035
- this.denoiser && (this.denoiser.enabled = e), this._syncGBufferStages();
17050
+ this.denoiser && (this.denoiser.enabled = e), this._syncGBufferStages(), this._onPostProcessRefresh?.();
17036
17051
  }
17037
17052
  setOIDNQuality(e) {
17038
- this.denoiser?.updateQuality(e), this._stages.pathTracer?.setCleanAuxNormal?.(!!this.denoiser?.enabled && e !== "fast");
17053
+ this.denoiser?.updateQuality(e), this._stages.pathTracer?.setCleanAuxNormal?.(!!this.denoiser?.enabled && e !== "fast"), this._onPostProcessRefresh?.();
17039
17054
  }
17040
17055
  setTileHelperEnabled(e) {
17041
17056
  this._setTileHelper(e);
@@ -17080,7 +17095,7 @@ var gm = {
17080
17095
  let t = kr[e];
17081
17096
  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));
17082
17097
  }
17083
- }, ym = class {
17098
+ }, bm = class {
17084
17099
  constructor() {
17085
17100
  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;
17086
17101
  }
@@ -17104,7 +17119,7 @@ var gm = {
17104
17119
  dispose() {
17105
17120
  this.visible = !1;
17106
17121
  }
17107
- }, bm = class {
17122
+ }, xm = class {
17108
17123
  constructor(n, r) {
17109
17124
  this.layer = "scene", this._enabled = !0, this._outlineNode = bn(n, r, {
17110
17125
  selectedObjects: [],
@@ -17135,11 +17150,11 @@ var gm = {
17135
17150
  this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
17136
17151
  }
17137
17152
  };
17138
- function xm(e = !1) {
17153
+ function Sm(e = !1) {
17139
17154
  let t = document.createElement("canvas");
17140
17155
  return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
17141
17156
  }
17142
- function Sm(e, t = Infinity) {
17157
+ function Cm(e, t = Infinity) {
17143
17158
  let n = e?.getBoundingClientRect();
17144
17159
  if (!n || n.width === 0 || n.height === 0) return null;
17145
17160
  let r = Math.min(window.devicePixelRatio || 1, 2), i = Math.round(n.width * r), a = Math.round(n.height * r), o = t / Math.max(i, a);
@@ -17150,9 +17165,9 @@ function Sm(e, t = Infinity) {
17150
17165
  }
17151
17166
  //#endregion
17152
17167
  //#region src/managers/helpers/ViewOverlayRenderer.js
17153
- var Cm = 4096, wm = class {
17168
+ var wm = 4096, Tm = class {
17154
17169
  constructor() {
17155
- this.canvas = xm(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
17170
+ this.canvas = Sm(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
17156
17171
  }
17157
17172
  async init({ device: e, sizeSource: t }) {
17158
17173
  this._sizeSource = t;
@@ -17169,7 +17184,7 @@ var Cm = 4096, wm = class {
17169
17184
  }
17170
17185
  syncSize() {
17171
17186
  if (!this.renderer) return;
17172
- let e = Sm(this._sizeSource, Cm);
17187
+ let e = Cm(this._sizeSource, wm);
17173
17188
  !e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
17174
17189
  }
17175
17190
  begin() {
@@ -17181,18 +17196,18 @@ var Cm = 4096, wm = class {
17181
17196
  dispose() {
17182
17197
  br(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
17183
17198
  }
17184
- }, Tm = ai("overlay"), Em = (e, t) => e.visible && e.layer === t && e.render, Dm = class {
17199
+ }, Em = ai("overlay"), Dm = (e, t) => e.visible && e.layer === t && e.render, Om = class {
17185
17200
  constructor(e) {
17186
- this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = xm(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
17201
+ this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Sm(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
17187
17202
  }
17188
17203
  async initViewRenderer({ device: e, sizeSource: t }) {
17189
17204
  if (!(!e || !t)) try {
17190
- this._viewOverlay = await new wm().init({
17205
+ this._viewOverlay = await new Tm().init({
17191
17206
  device: e,
17192
17207
  sizeSource: t
17193
17208
  });
17194
17209
  } catch (e) {
17195
- Tm.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
17210
+ Em.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
17196
17211
  }
17197
17212
  }
17198
17213
  setHelperScene(e) {
@@ -17208,11 +17223,11 @@ var Cm = 4096, wm = class {
17208
17223
  }
17209
17224
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
17210
17225
  this.setHelperScene(e);
17211
- let s = new ym();
17226
+ let s = new bm();
17212
17227
  this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener("resolution_changed", (e) => {
17213
17228
  s.setRenderSize(e.width, e.height);
17214
17229
  }), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
17215
- let c = new bm(t, this.camera);
17230
+ let c = new xm(t, this.camera);
17216
17231
  this.register("outline", c);
17217
17232
  }
17218
17233
  _wireDenoiserTileEvents(e, t) {
@@ -17224,7 +17239,7 @@ var Cm = 4096, wm = class {
17224
17239
  }));
17225
17240
  }
17226
17241
  register(e, t) {
17227
- this._helpers.has(e) && (Tm.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
17242
+ this._helpers.has(e) && (Em.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
17228
17243
  }
17229
17244
  unregister(e) {
17230
17245
  let t = this._helpers.get(e);
@@ -17262,16 +17277,16 @@ var Cm = 4096, wm = class {
17262
17277
  }
17263
17278
  _renderSceneLayer(e) {
17264
17279
  this._helperScene?.render(e, this.camera);
17265
- for (let t of this._helpers.values()) Em(t, "scene") && t.render(e, this.camera);
17280
+ for (let t of this._helpers.values()) Dm(t, "scene") && t.render(e, this.camera);
17266
17281
  }
17267
17282
  _hasVisibleSceneOverlay() {
17268
17283
  if (this._helperScene?.isDrawing) return !0;
17269
- for (let e of this._helpers.values()) if (Em(e, "scene")) return !0;
17284
+ for (let e of this._helpers.values()) if (Dm(e, "scene")) return !0;
17270
17285
  return !1;
17271
17286
  }
17272
17287
  refreshHUD() {
17273
17288
  let e = this._hudCanvas, t = this._hudCtx, n = !1;
17274
- for (let e of this._helpers.values()) if (Em(e, "hud")) {
17289
+ for (let e of this._helpers.values()) if (Dm(e, "hud")) {
17275
17290
  n = !0;
17276
17291
  break;
17277
17292
  }
@@ -17280,10 +17295,10 @@ var Cm = 4096, wm = class {
17280
17295
  return;
17281
17296
  }
17282
17297
  e.style.display !== "" && (e.style.display = "");
17283
- let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Sm(e) : null;
17298
+ let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Cm(e) : null;
17284
17299
  if (a) {
17285
17300
  (e.width !== a.width || e.height !== a.height) && (e.width = a.width, e.height = a.height), t.clearRect(0, 0, a.width, a.height), t.save(), t.scale(a.width / r, a.height / i);
17286
- for (let e of this._helpers.values()) Em(e, "hud") && e.render(t, r, i);
17301
+ for (let e of this._helpers.values()) Dm(e, "hud") && e.render(t, r, i);
17287
17302
  t.restore(), e.style.display !== "" && (e.style.display = "");
17288
17303
  }
17289
17304
  }
@@ -17291,7 +17306,7 @@ var Cm = 4096, wm = class {
17291
17306
  for (let e of this._helpers.values()) e.dispose?.();
17292
17307
  this._helpers.clear(), this._viewOverlay?.dispose(), this._viewOverlay = null, this._hudCanvas.parentElement && this._hudCanvas.parentElement.removeChild(this._hudCanvas);
17293
17308
  }
17294
- }, Om = class extends lt {
17309
+ }, km = class extends lt {
17295
17310
  constructor() {
17296
17311
  super(), this.mixer = null, this.timer = new tn(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._posBuffer = null, this._tempVec = new sn(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this.wakeCallback = null;
17297
17312
  }
@@ -17391,7 +17406,7 @@ var Cm = 4096, wm = class {
17391
17406
  dispose() {
17392
17407
  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;
17393
17408
  }
17394
- }, km = new sn(0, 0, -1), Am = class {
17409
+ }, Am = new sn(0, 0, -1), jm = class {
17395
17410
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
17396
17411
  this._app = r, this._orbitControls = n, this._camera = e, this._controls = new xn(e, t), this._gizmoScene = new Jt(), 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 sn(), this._normalMatrix = new xt(), this._refitInFlight = !1, this._baselineComputed = !1, this._tempForward = new sn(), this._lightTargetDistance = null, this._lastLightPosition = null, 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);
17397
17412
  }
@@ -17412,7 +17427,7 @@ var Cm = 4096, wm = class {
17412
17427
  attach(e) {
17413
17428
  if (this._attached !== e && (this._controls.attach(e), this._attached = e, this._lightTargetDistance = null, this._lastLightPosition = null, e.isLight && e.target)) {
17414
17429
  let t = e.target.position.clone().sub(e.position), n = t.length();
17415
- n > 1e-4 ? (e.quaternion.setFromUnitVectors(km, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
17430
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(Am, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1, this._lastLightPosition = e.position.clone();
17416
17431
  }
17417
17432
  }
17418
17433
  detach() {
@@ -17524,7 +17539,7 @@ var Cm = 4096, wm = class {
17524
17539
  dispose() {
17525
17540
  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._tempForward = null, this._lightTargetDistance = null, this._lastLightPosition = null, this._app = null, this._orbitControls = null, this._camera = null, this._controls = null, this._gizmoScene = null;
17526
17541
  }
17527
- }, jm = class {
17542
+ }, Mm = class {
17528
17543
  constructor(e) {
17529
17544
  this.layer = "scene", this._transformManager = e, this._enabled = !0;
17530
17545
  }
@@ -17543,15 +17558,15 @@ var Cm = 4096, wm = class {
17543
17558
  dispose() {
17544
17559
  this._enabled = !1;
17545
17560
  }
17546
- }, Mm = /* @__PURE__ */ new WeakMap(), Nm = ai("engine"), Pm = class extends lt {
17561
+ }, Nm = /* @__PURE__ */ new WeakMap(), Pm = ai("engine"), Fm = class extends lt {
17547
17562
  constructor(e, t = {}) {
17548
17563
  super();
17549
17564
  try {
17550
- Mm.get(e)?.dispose();
17565
+ Nm.get(e)?.dispose();
17551
17566
  } catch (e) {
17552
- Nm.warn("prior canvas owner dispose failed", e);
17567
+ Pm.warn("prior canvas owner dispose failed", e);
17553
17568
  }
17554
- Mm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Ep(Y), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = Y.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = 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 Om(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Vf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
17569
+ Nm.set(e, this), this.canvas = e, this._autoResize = t.autoResize !== !1, this._container = t.container || null, this.settings = new Dp(Y), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this._animRefitInFlight = !1, this._maxTextureSize = Y.maxTextureSize, this.pipeline = null, this._pendingReservedRenderSize = 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 km(), this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Hf(), this._resizeDebounceTimer = null, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null;
17555
17570
  }
17556
17571
  _addTrackedListener(e, t, n) {
17557
17572
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -17564,12 +17579,12 @@ var Cm = 4096, wm = class {
17564
17579
  for (let { target: e, type: t, handler: n } of this._trackedListeners) try {
17565
17580
  e.removeEventListener(t, n);
17566
17581
  } catch (e) {
17567
- Nm.warn("failed to remove listener", t, e);
17582
+ Pm.warn("failed to remove listener", t, e);
17568
17583
  }
17569
17584
  this._trackedListeners.length = 0;
17570
17585
  }
17571
17586
  async init() {
17572
- return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await 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, Nm.debug("WebGPU path tracer app initialized"), this;
17587
+ return await this._initRenderer(), this._applyPendingReservedRenderSize(), this._initCameraManager(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await 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, Pm.debug("WebGPU path tracer app initialized"), this;
17573
17588
  }
17574
17589
  animate() {
17575
17590
  if (!this._deviceLost) {
@@ -17579,7 +17594,7 @@ var Cm = 4096, wm = class {
17579
17594
  }
17580
17595
  if (this.cameraManager.controls && this.cameraManager.controls.update(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
17581
17596
  let e = this.animationManager.update();
17582
- e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => Nm.error("animation refit error:", e)).finally(() => {
17597
+ e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => Pm.error("animation refit error:", e)).finally(() => {
17583
17598
  this._animRefitInFlight = !1;
17584
17599
  }));
17585
17600
  }
@@ -17613,7 +17628,7 @@ var Cm = 4096, wm = class {
17613
17628
  this.animationManagerId &&= (cancelAnimationFrame(this.animationManagerId), null);
17614
17629
  }
17615
17630
  _handleDeviceLost(e) {
17616
- this._deviceLost || (this._deviceLost = !0, Nm.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
17631
+ this._deviceLost || (this._deviceLost = !0, Pm.error(`WebGPU device lost (${e?.reason || "unknown"}): ${e?.message || ""}`), this.stopAnimation(), this.dispatchEvent({
17617
17632
  type: ur.DEVICE_LOST,
17618
17633
  reason: e?.reason,
17619
17634
  message: e?.message
@@ -17629,15 +17644,7 @@ var Cm = 4096, wm = class {
17629
17644
  this._paused = !1, this.animationManagerId || this.animate();
17630
17645
  }
17631
17646
  reset(e = !1) {
17632
- if (this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("asvgf:reset")), this.denoisingManager?.abort(this.canvas), this.denoisingManager?.restoreBaseResolution()) {
17633
- let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
17634
- this.dispatchEvent({
17635
- type: "resolution_changed",
17636
- width: e,
17637
- height: t
17638
- });
17639
- }
17640
- this.completion.reset(), this.wake(), this.dispatchEvent({ type: "RenderReset" }), this.dispatchEvent({ type: ur.RENDER_RESET });
17647
+ this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("asvgf:reset")), this._abortPostProcess(), this.completion.reset(), this.wake(), this.dispatchEvent({ type: "RenderReset" }), this.dispatchEvent({ type: ur.RENDER_RESET });
17641
17648
  }
17642
17649
  dispose() {
17643
17650
  if (!this._disposed) {
@@ -17651,7 +17658,7 @@ var Cm = 4096, wm = class {
17651
17658
  let e = Ae().value, t = k().value;
17652
17659
  e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
17653
17660
  } catch (e) {
17654
- Nm.warn("failed to clear TSL texture singleton listeners", e);
17661
+ Pm.warn("failed to clear TSL texture singleton listeners", e);
17655
17662
  }
17656
17663
  br(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
17657
17664
  }
@@ -17875,7 +17882,7 @@ var Cm = 4096, wm = class {
17875
17882
  if (!e) return;
17876
17883
  this._pendingReservedRenderSize = null;
17877
17884
  let t = this.setReservedRenderResolution(e.requestedPx, { allowLower: e.allowLower });
17878
- t < e.requestedPx && Nm.warn(`reserved render size ${Q.n(e.requestedPx)}px was capped to ${Q.n(t)}px by this device's limits — renders above ${Q.n(t)}px will be declined.`), this.dispatchEvent({
17885
+ t < e.requestedPx && Pm.warn(`reserved render size ${Q.n(e.requestedPx)}px was capped to ${Q.n(t)}px by this device's limits — renders above ${Q.n(t)}px will be declined.`), this.dispatchEvent({
17879
17886
  type: "reserved_render_size_changed",
17880
17887
  size: t
17881
17888
  });
@@ -17884,7 +17891,7 @@ var Cm = 4096, wm = class {
17884
17891
  return Dr;
17885
17892
  }
17886
17893
  _isRenderSizeSupported(e, t) {
17887
- return e > Dr || t > Dr ? (Nm.warn(`render resolution ${e}×${t} exceeds the ${Dr}px reserve (compute storage textures are pre-allocated at ${Dr}px). Ignoring resize — raise the reserve with setReservedRenderResolution( ${Math.max(e, t)} ) first, or use a resolution ≤ ${Dr}.`), !1) : !0;
17894
+ return e > Dr || t > Dr ? (Pm.warn(`render resolution ${e}×${t} exceeds the ${Dr}px reserve (compute storage textures are pre-allocated at ${Dr}px). Ignoring resize — raise the reserve with setReservedRenderResolution( ${Math.max(e, t)} ) first, or use a resolution ≤ ${Dr}.`), !1) : !0;
17888
17895
  }
17889
17896
  onResize() {
17890
17897
  let e = this.canvas.clientWidth, t = this.canvas.clientHeight;
@@ -17934,6 +17941,19 @@ var Cm = 4096, wm = class {
17934
17941
  refreshFrame() {
17935
17942
  this._needsDisplayRefresh = !0, this.wake();
17936
17943
  }
17944
+ _abortPostProcess() {
17945
+ if (this.denoisingManager?.abort(this.canvas), this.denoisingManager?.restoreBaseResolution()) {
17946
+ let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
17947
+ this.dispatchEvent({
17948
+ type: "resolution_changed",
17949
+ width: e,
17950
+ height: t
17951
+ });
17952
+ }
17953
+ }
17954
+ requestPostProcessRefresh() {
17955
+ !this.stages.pathTracer?.isReady || this._deviceLost || (this._abortPostProcess(), this.completion.renderCompleteDispatched = !1, this.wake());
17956
+ }
17937
17957
  setDeterministicMode(e = !0, { pinDispatch: t = !0 } = {}) {
17938
17958
  let n = this.stages.pathTracer;
17939
17959
  if (!n) return !1;
@@ -18055,7 +18075,7 @@ var Cm = 4096, wm = class {
18055
18075
  this._pathTracerEnabled = e, e || this.precompileRaster();
18056
18076
  }
18057
18077
  precompileRaster() {
18058
- return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => Nm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
18078
+ return !this.renderer || !this.meshScene ? Promise.resolve() : (this._rasterPrecompile ??= this.renderer.compileAsync(this.meshScene, this.cameraManager.camera).catch((e) => Pm.warn("raster fallback precompile failed", e)), this._rasterPrecompile);
18059
18079
  }
18060
18080
  get isLoading() {
18061
18081
  return this._loadingInProgress;
@@ -18162,46 +18182,46 @@ var Cm = 4096, wm = class {
18162
18182
  let n = this.renderer.backend?.device;
18163
18183
  n?.lost && (n.lost.then((e) => {
18164
18184
  this._disposed || this._handleDeviceLost(e);
18165
- }), n.onuncapturederror = (e) => Nm.error("WebGPU uncaptured error:", e.error)), r.setLTC(cn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = He, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
18185
+ }), n.onuncapturederror = (e) => Pm.error("WebGPU uncaptured error:", e.error)), r.setLTC(cn.init()), this.renderer.outputColorSpace = a, this.renderer.toneMapping = He, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1);
18166
18186
  }
18167
18187
  _initCameraManager() {
18168
- this.cameraManager = new Dp(this.canvas);
18188
+ this.cameraManager = new Op(this.canvas);
18169
18189
  }
18170
18190
  _initScenes() {
18171
18191
  this.scene = new Jt(), this.meshScene = new Jt(), this._sceneHelpers = new Nn();
18172
18192
  }
18173
18193
  _initAssetPipeline() {
18174
- this._sdf = new Qc(), this.assetLoader = new Cp(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
18194
+ this._sdf = new Qc(), this.assetLoader = new wp(this.meshScene, this.cameraManager.camera, this.cameraManager.controls), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane(), this._addTrackedListener(this.cameraManager.controls, "change", () => {
18175
18195
  this.needsReset = !0, this.wake();
18176
18196
  });
18177
18197
  }
18178
18198
  _initPipeline() {
18179
18199
  this._createStages();
18180
18200
  let { clientWidth: e, clientHeight: t } = this.canvas;
18181
- this.pipeline = new Bf(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.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);
18201
+ this.pipeline = new Vf(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.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);
18182
18202
  let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
18183
18203
  this.pipeline.setSize(n, r);
18184
18204
  }
18185
18205
  async _initManagers() {
18186
- this.interactionManager = new Hf({
18206
+ this.interactionManager = new Uf({
18187
18207
  scene: this.meshScene,
18188
18208
  camera: this.cameraManager.camera,
18189
18209
  canvas: this.canvas,
18190
18210
  assetLoader: this.assetLoader,
18191
18211
  pathTracer: null,
18192
18212
  floorPlane: this.assetLoader.floorPlane
18193
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new Op(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new kp(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Bp(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new Am({
18213
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.lightManager = new kp(this.scene, this._sceneHelpers, this.stages.pathTracer, { onReset: () => this.reset() }), this.goboManager = new Ap(this.stages.pathTracer, { onReset: () => this.reset() }), this.iesManager = new Vp(this.stages.pathTracer, { onReset: () => this.reset() }), this._setupDenoisingManager(), await this._setupOverlayManager(), this.transformManager = new jm({
18194
18214
  camera: this.cameraManager.camera,
18195
18215
  canvas: this.canvas,
18196
18216
  orbitControls: this.cameraManager.controls,
18197
18217
  app: this
18198
- }), this.overlayManager.register("transform", new jm(this.transformManager)), this.interactionManager.setDependencies({
18218
+ }), this.overlayManager.register("transform", new Mm(this.transformManager)), this.interactionManager.setDependencies({
18199
18219
  overlayManager: this.overlayManager,
18200
18220
  transformManager: this.transformManager,
18201
18221
  appDispatch: (e) => this.dispatchEvent(e),
18202
18222
  orbitControls: this.cameraManager.controls,
18203
18223
  helperScene: this._sceneHelpers.scene
18204
- }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
18224
+ }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setPostProcessRefreshCallback(() => this.requestPostProcessRefresh()), this.denoisingManager.setSettings(this.settings), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.callbacks.onAutoExposureReset = () => this.pipeline.eventBus.emit("autoexposure:resetHistory");
18205
18225
  }
18206
18226
  _wireEvents() {
18207
18227
  this._addTrackedListener(this.cameraManager, "CameraSwitched", (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, ur.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
@@ -18267,13 +18287,13 @@ var Cm = 4096, wm = class {
18267
18287
  this.transformManager?.setMeshData(this._sdf.meshes);
18268
18288
  }
18269
18289
  _createStages() {
18270
- this.stages.pathTracer = new rf(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new af(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new of(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.asvgf = new lf(this.renderer, { enabled: !1 }), this.stages.variance = new ff(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new mf(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new yf(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Ef(this.renderer, { enabled: Y.autoExposure ?? !1 }), this.stages.compositor = new Df(this.renderer, {
18290
+ this.stages.pathTracer = new rf(this.renderer, this.scene, this.cameraManager.camera), this.stages.normalDepth = new af(this.renderer, { pathTracer: this.stages.pathTracer }), this.stages.motionVector = new of(this.renderer, this.cameraManager.camera, { pathTracer: this.stages.pathTracer }), this.stages.asvgf = new lf(this.renderer, { enabled: !1 }), this.stages.variance = new ff(this.renderer, { enabled: !1 }), this.stages.bilateralFilter = new mf(this.renderer, { enabled: !1 }), this.stages.edgeFilter = new bf(this.renderer, { enabled: !1 }), this.stages.autoExposure = new Df(this.renderer, { enabled: Y.autoExposure ?? !1 }), this.stages.compositor = new Of(this.renderer, {
18271
18291
  saturation: this.settings.get("saturation") ?? Y.saturation,
18272
18292
  pathTracer: this.stages.pathTracer
18273
18293
  });
18274
18294
  }
18275
18295
  _setupDenoisingManager() {
18276
- this.denoisingManager = new vm({
18296
+ this.denoisingManager = new ym({
18277
18297
  renderer: this.renderer,
18278
18298
  mainCanvas: this.canvas,
18279
18299
  scene: this.scene,
@@ -18316,7 +18336,7 @@ var Cm = 4096, wm = class {
18316
18336
  this.scene.updateMatrixWorld(), this.overlayManager?.render();
18317
18337
  }
18318
18338
  async _setupOverlayManager() {
18319
- this.overlayManager = new Dm(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
18339
+ this.overlayManager = new Om(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
18320
18340
  helperScene: this._sceneHelpers,
18321
18341
  meshScene: this.meshScene,
18322
18342
  pipeline: this.pipeline,
@@ -18347,7 +18367,7 @@ var Cm = 4096, wm = class {
18347
18367
  _forwardEvents(e, t) {
18348
18368
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
18349
18369
  }
18350
- }, Fm = class {
18370
+ }, Im = class {
18351
18371
  constructor(e) {
18352
18372
  this._app = e, this._cancelled = !1, this._rendering = !1;
18353
18373
  }
@@ -18445,4 +18465,4 @@ var Cm = 4096, wm = class {
18445
18465
  }
18446
18466
  };
18447
18467
  //#endregion
18448
- export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, Om as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Dp as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, vm as DenoisingManager, Y as ENGINE_DEFAULTS, ur as EngineEvents, kp as GoboManager, Bp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Hf as InteractionManager, Wr as LOG_LEVELS, Op as LightManager, ii as Logger, Er as MAX_RESERVABLE_RENDER_SIZE, Ur as MEMORY_CONSTANTS, Dm as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Pm as PathTracerApp, Of as PipelineContext, Bf as RenderPipeline, Ep as RenderSettings, cr as RenderStage, jr as SKY_PRESETS, sr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, Am as TransformManager, uu as VRAMTracker, Fm as VideoRenderManager, cu as bufferBytes, Ff as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Pf as getBindingAuditFindings, Nf as setBindingAudit, lu as textureBytes };
18468
+ export { Pr as AF_DEFAULTS, kr as ASVGF_QUALITY_PRESETS, Nr as AUTO_FOCUS_MODES, km as AnimationManager, Fr as BVH_LEAF_MARKERS, Mr as CAMERA_PRESETS, Ar as CAMERA_RANGES, Op as CameraManager, Br as DEFAULT_TEXTURE_MATRIX, ym as DenoisingManager, Y as ENGINE_DEFAULTS, ur as EngineEvents, Ap as GoboManager, Vp as IESManager, Hr as INTERACTIVE_RENDER_CONFIG, Uf as InteractionManager, Wr as LOG_LEVELS, kp as LightManager, ii as Logger, Er as MAX_RESERVABLE_RENDER_SIZE, Ur as MEMORY_CONSTANTS, Om as OverlayManager, Vr as PRODUCTION_RENDER_CONFIG, Fm as PathTracerApp, kf as PipelineContext, Vf as RenderPipeline, Dp as RenderSettings, cr as RenderStage, jr as SKY_PRESETS, sr as StageExecutionMode, Ir as TEXTURE_CONSTANTS, X as TRIANGLE_DATA_LAYOUT, jm as TransformManager, uu as VRAMTracker, Im as VideoRenderManager, cu as bufferBytes, If as clearBindingAuditFindings, sl as configureAssets, ai as createLogger, Q as fmt, cl as getAssetConfig, Ff as getBindingAuditFindings, Pf as setBindingAudit, lu as textureBytes };