rayzee 11.8.0 → 11.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +18 -6
  2. package/dist/{ArchiveImporter-_sJm5uaK.js → ArchiveImporter-B4Qz5BGT.js} +1549 -1232
  3. package/dist/{BidirectionalIntegrator-Dzt4Z97x.js → BidirectionalIntegrator-ZrCN3uyc.js} +240 -240
  4. package/dist/{BufferLayout-xPRH9jYD.js → BufferLayout-Bzgccg1o.js} +1 -0
  5. package/dist/{ColorManagement-30MfpHwQ.js → ColorManagement-B_HjAiy2.js} +1 -1
  6. package/dist/{EngineIssues-xljoXM0E.js → EngineIssues-CfJiBaNj.js} +1 -0
  7. package/dist/{NeuralRetouch-BKQCsmEs.js → NeuralRetouch-BtzPRZSB.js} +1 -1
  8. package/dist/{NeuralSuperRes-C4ymq68e.js → NeuralSuperRes-B2V-vlHN.js} +1 -1
  9. package/dist/{PathTracer-C_to_i40.js → PathTracer-CuO_bS6Z.js} +3433 -3363
  10. package/dist/{PhysicalSky-bMHbm_7H.js → PhysicalSky-NdPIyVqP.js} +45 -45
  11. package/dist/{RayzeeRenderer-B_aB6VTJ.js → RayzeeRenderer-BOJsV6Sj.js} +13 -8
  12. package/dist/{SceneMetadata-CSmlJW4c.js → SceneMetadata-DiQpoDtm.js} +1 -1
  13. package/dist/{SolarLimb-bZE6y63S.js → SolarLimb-DRYy8tln.js} +184 -172
  14. package/dist/addons/archives.es.js +1 -1
  15. package/dist/addons/bidirectional.es.js +1 -1
  16. package/dist/addons/color.es.js +1 -1
  17. package/dist/addons/physical-sky.es.js +1 -1
  18. package/dist/addons/storage.es.js +1 -1
  19. package/dist/{openStorage-B085D9FR.js → openStorage-CdyVjmps.js} +1 -1
  20. package/dist/rayzee-core.es.js +7 -7
  21. package/dist/rayzee.es.js +567 -559
  22. package/dist/rayzee.umd.js +106 -101
  23. package/dist/{sceneCachePolicy-D_uBSbQF.js → sceneCachePolicy-EwLlPi01.js} +9 -6
  24. package/package.json +1 -1
  25. package/src/EngineDefaults.js +1 -0
  26. package/src/EngineIssues.js +1 -0
  27. package/src/Passes/OIDNTemporalHistory.js +1 -1
  28. package/src/Processor/ArchiveImporter.js +83 -21
  29. package/src/Processor/AssetLoader.js +7 -0
  30. package/src/Processor/BufferLayout.js +3 -3
  31. package/src/Processor/GeometryExtractor.js +12 -4
  32. package/src/Processor/MaterialPacking.js +2 -2
  33. package/src/Processor/PBRT/PBRTMaterials.js +47 -12
  34. package/src/Processor/PBRT/PBRTParser.js +144 -22
  35. package/src/Processor/PBRT/PBRTSceneBuilder.js +287 -67
  36. package/src/Processor/PBRT/PBRTTextureBake.js +191 -9
  37. package/src/Processor/PBRT/index.js +19 -4
  38. package/src/Processor/SceneProcessor.js +42 -26
  39. package/src/RayzeeRenderer.js +4 -2
  40. package/src/Stages/DenoiserSettings.js +0 -4
  41. package/src/Stages/NRD.js +53 -24
  42. package/src/Stages/NormalDepth.js +5 -3
  43. package/src/Stages/PathTracer.js +2 -0
  44. package/src/Stages/PathTracerStage.js +5 -1
  45. package/src/Storage/SceneGraphCodec.js +6 -3
  46. package/src/TSL/BVHTraversal.js +33 -20
  47. package/src/TSL/Common.js +25 -8
  48. package/src/TSL/Displacement.js +66 -113
  49. package/src/TSL/LightsDirect.js +33 -11
  50. package/src/TSL/SceneResources.js +8 -0
  51. package/src/TSL/ShadeKernel.js +2 -2
  52. package/src/TSL/Struct.js +1 -0
  53. package/src/managers/MaterialDataManager.js +11 -0
package/dist/rayzee.es.js CHANGED
@@ -1,26 +1,26 @@
1
- import { t as e } from "./BidirectionalIntegrator-Dzt4Z97x.js";
2
- import { $t as t, Ft as n, Pt as r, Yt as i, en as a, nn as o, rt as s, wt as c } from "./SolarLimb-bZE6y63S.js";
3
- import { _ as l, a as u, c as d, d as f, f as p, g as m, h, i as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T } from "./RayzeeRenderer-B_aB6VTJ.js";
4
- import { $ as E, At as D, B as ee, F as O, H as te, I as ne, J as re, Mt as k, Nt as A, Ot as j, Q as ie, V as ae, W as oe, _t as se, at as ce, bt as le, dt as M, et as ue, gt as de, ht as fe, it as pe, kt as N, mt as me, nt as he, pt as ge, rt as _e, tt as ve, xt as ye, yt as be, z as xe } from "./PathTracer-C_to_i40.js";
1
+ import { t as e } from "./BidirectionalIntegrator-ZrCN3uyc.js";
2
+ import { Ft as t, Pt as n, Xt as r, en as i, rn as a, rt as o, tn as s, wt as c } from "./SolarLimb-DRYy8tln.js";
3
+ import { _ as l, a as u, c as d, d as f, f as p, g as m, h, i as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T } from "./RayzeeRenderer-BOJsV6Sj.js";
4
+ import { $ as E, At as D, B as O, F as k, H as ee, I as te, J as ne, Mt as A, Nt as j, Ot as re, Q as M, V as ie, W as ae, _t as oe, at as se, bt as ce, dt as le, et as N, gt as ue, ht as de, it as fe, kt as pe, mt as me, nt as he, pt as ge, rt as _e, tt as ve, xt as ye, yt as be, z as xe } from "./PathTracer-CuO_bS6Z.js";
5
5
  import { n as Se, t as P } from "./EngineEvents-CLckhYbL.js";
6
- import { D as Ce, G as we, J as Te, K as Ee, O as De, W as Oe, Y as ke, a as Ae, c as je, et as Me, i as Ne, m as Pe, ot as Fe, p as Ie, q as Le, r as Re, tt as ze, x as Be, y as Ve } from "./sceneCachePolicy-D_uBSbQF.js";
6
+ import { D as Ce, G as we, J as Te, K as Ee, O as De, W as Oe, Y as ke, a as Ae, c as je, et as Me, i as Ne, m as Pe, ot as Fe, p as Ie, q as Le, r as Re, tt as ze, x as Be, y as Ve } from "./sceneCachePolicy-EwLlPi01.js";
7
7
  import { i as He, n as Ue, r as We, t as Ge } from "./Logger-dDDGj9Av.js";
8
- import { f as Ke, r as qe } from "./BufferLayout-xPRH9jYD.js";
9
- import { i as Je, n as Ye, r as Xe, t as Ze } from "./EngineIssues-xljoXM0E.js";
8
+ import { f as Ke, r as qe } from "./BufferLayout-Bzgccg1o.js";
9
+ import { i as Je, n as Ye, r as Xe, t as Ze } from "./EngineIssues-CfJiBaNj.js";
10
10
  import { i as Qe, r as $e } from "./shared-BGBcSxBQ.js";
11
11
  import { r as et } from "./WorkingMatrix-C6y233hT.js";
12
12
  import { i as tt, r as nt, t as rt } from "./ActiveColor-YvuQq44O.js";
13
13
  import { n as it, t as at } from "./AssetConfig-DSEntE65.js";
14
14
  import { a as ot, d as st, g as ct, i as lt, l as ut, o as dt, p as ft, r as pt, s as mt, t as ht, u as gt } from "./ViewTransforms-CYN7bq2w.js";
15
15
  import { a as _t, i as vt, n as yt, r as bt } from "./identity-C1cLD1C0.js";
16
- import { l as xt, n as St, s as Ct, t as wt } from "./SceneMetadata-CSmlJW4c.js";
16
+ import { l as xt, n as St, s as Ct, t as wt } from "./SceneMetadata-DiQpoDtm.js";
17
17
  import { t as Tt } from "./ToneMapGPU-4GPwoG_c.js";
18
18
  import { t as Et } from "./FileFormats-sPGJeCRc.js";
19
- import { A as Dt, C as Ot, D as kt, E as At, O as jt, S as Mt, T as Nt, _ as Pt, a as Ft, b as It, c as Lt, d as Rt, f as zt, g as Bt, h as Vt, i as Ht, k as Ut, l as Wt, m as Gt, n as Kt, o as qt, p as Jt, r as Yt, s as Xt, t as Zt, u as Qt, v as $t, w as en, x as tn, y as nn } from "./ColorManagement-30MfpHwQ.js";
20
- import { c as rn, l as an, n as on, o as sn, t as cn } from "./openStorage-B085D9FR.js";
19
+ import { A as Dt, C as Ot, D as kt, E as At, O as jt, S as Mt, T as Nt, _ as Pt, a as Ft, b as It, c as Lt, d as Rt, f as zt, g as Bt, h as Vt, i as Ht, k as Ut, l as Wt, m as Gt, n as Kt, o as qt, p as Jt, r as Yt, s as Xt, t as Zt, u as Qt, v as $t, w as en, x as tn, y as nn } from "./ColorManagement-B_HjAiy2.js";
20
+ import { c as rn, l as an, n as on, o as sn, t as cn } from "./openStorage-CdyVjmps.js";
21
21
  import { n as ln, t as un } from "./ZipReader-gDSWr0I5.js";
22
- import { i as dn, n as fn, r as pn } from "./NeuralSuperRes-C4ymq68e.js";
23
- import { i as mn, n as hn, r as gn } from "./NeuralRetouch-BKQCsmEs.js";
22
+ import { i as dn, n as fn, r as pn } from "./NeuralSuperRes-B2V-vlHN.js";
23
+ import { i as mn, n as hn, r as gn } from "./NeuralRetouch-BtzPRZSB.js";
24
24
  import { ExternalTexture as _n, MeshBasicNodeMaterial as vn, QuadMesh as yn, ReadbackBuffer as bn, RenderTarget as xn, StorageTexture as Sn, TextureNode as Cn, WebGPURenderer as wn } from "three/webgpu";
25
25
  import { Fn as Tn, If as F, Loop as En, Return as Dn, atan as On, atomicAdd as kn, atomicLoad as An, atomicStore as jn, attributeArray as Mn, dot as I, exp as Nn, exp2 as Pn, float as L, floatBitsToUint as Fn, floor as In, fract as Ln, int as R, ivec2 as Rn, localId as z, log2 as zn, max as B, min as Bn, mix as V, normalize as Vn, pow as Hn, round as Un, saturate as H, select as U, smoothstep as Wn, sqrt as Gn, storage as Kn, textureLoad as W, textureStore as G, toneMappingExposure as qn, uint as K, uniform as q, uvec2 as Jn, uvec4 as Yn, vec2 as J, vec3 as Xn, vec4 as Y, workgroupArray as Zn, workgroupBarrier as Qn, workgroupId as X } from "three/tsl";
26
26
  import { ACESFilmicToneMapping as $n, AddEquation as er, AnimationMixer as tr, Box2 as nr, Box3 as rr, ClampToEdgeWrapping as ir, Color as ar, Controls as or, CustomBlending as sr, DataArrayTexture as cr, DataTexture as lr, EventDispatcher as ur, FloatType as dr, HalfFloatType as fr, InterpolateSmooth as pr, LinearFilter as mr, LoopOnce as hr, LoopRepeat as gr, MathUtils as _r, Matrix3 as vr, Matrix4 as yr, Mesh as br, MeshBasicMaterial as xr, NearestFilter as Z, NoColorSpace as Sr, NumberKeyframeTrack as Cr, OneFactor as wr, OrthographicCamera as Tr, PerspectiveCamera as Er, PropertyBinding as Dr, Quaternion as Or, RGBAFormat as kr, Raycaster as Ar, RedIntegerFormat as jr, SRGBColorSpace as Mr, Scene as Nr, SphereGeometry as Pr, Timer as Fr, UnsignedByteType as Ir, UnsignedIntType as Lr, Vector2 as Rr, Vector3 as Q, Vector4 as zr, VectorKeyframeTrack as Br } from "three";
@@ -28,11 +28,11 @@ import { OrbitControls as Vr } from "three/addons/controls/OrbitControls.js";
28
28
  import { outline as Hr } from "three/addons/tsl/display/OutlineNode.js";
29
29
  import { TransformControls as Ur } from "three/addons/controls/TransformControls.js";
30
30
  //#region src/Stages/DenoiserSettings.js
31
- var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
31
+ var Wr = 65504, Gr = 6e4, Kr = Object.freeze([
32
32
  "none",
33
33
  "nrd",
34
34
  "oidn"
35
- ]), Jr = 3, Yr = .1, Xr = {
35
+ ]), qr = 3, Jr = .1, Yr = {
36
36
  maxAccumulatedFrameNum: 30,
37
37
  maxFastAccumulatedFrameNum: 6,
38
38
  maxStabilizedFrameNum: 63,
@@ -56,7 +56,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
56
56
  convergenceP: .8,
57
57
  lobeVolumePercent: .1,
58
58
  handoverFrames: 0
59
- }, Zr = [
59
+ }, Xr = [
60
60
  "maxAccumulatedFrameNum",
61
61
  "maxFastAccumulatedFrameNum",
62
62
  "maxStabilizedFrameNum",
@@ -64,7 +64,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
64
64
  "prepassBlurRadius",
65
65
  "maxBlurRadius",
66
66
  "enableAntiFirefly"
67
- ], Qr = {
67
+ ], Zr = {
68
68
  low: {
69
69
  maxAccumulatedFrameNum: 16,
70
70
  maxFastAccumulatedFrameNum: 4,
@@ -82,7 +82,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
82
82
  prepassBlurRadius: 40,
83
83
  maxBlurRadius: 40
84
84
  }
85
- }, $r = {
85
+ }, Qr = {
86
86
  denoiserStrategy: "none",
87
87
  enableOIDN: !1,
88
88
  oidnQuality: "fast",
@@ -95,14 +95,14 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
95
95
  upscalerHdr: !0,
96
96
  nrdQualityPreset: "medium",
97
97
  nrdDebugMode: 0
98
- }, ei = class extends k {
98
+ }, $r = class extends A {
99
99
  constructor(e, t = {}) {
100
100
  super("NormalDepth", {
101
101
  ...t,
102
- executionMode: A.ALWAYS
102
+ executionMode: j.ALWAYS
103
103
  }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = q(new yr(), "mat4"), this.cameraProjectionMatrixInverse = q(new yr(), "mat4"), this.cameraRay = ve(), this.resolutionWidth = q(t.width || 1), this.resolutionHeight = q(t.height || 1);
104
104
  let n = t.width || 1, r = t.height || 1;
105
- this._outputStorageTex = new Sn(N, N), this._outputStorageTex.type = fr, this._outputStorageTex.format = kr, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new Sn(N, N), this._shadingStorageTex.type = fr, this._shadingStorageTex.format = kr, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new xn(n, r, {
105
+ this._outputStorageTex = new Sn(pe, pe), this._outputStorageTex.type = fr, this._outputStorageTex.format = kr, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new Sn(pe, pe), this._shadingStorageTex.type = fr, this._shadingStorageTex.format = kr, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new xn(n, r, {
106
106
  type: fr,
107
107
  format: kr,
108
108
  minFilter: Z,
@@ -135,40 +135,42 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
135
135
  let t = e.sceneStorageNodes?.();
136
136
  t && (this._triStorageNode = t.triangles, this._bvhStorageNode = t.bvh);
137
137
  }
138
- return t && !this._matStorageNode && (this._matStorageNode = Kn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && te(this._linearBuckets, e.materialData?.linearBuckets), this._lastTriAttr = e.triangleGeoAttr || this._lastTriAttr, this._lastBvhAttr = e.bvhStorageAttr || this._lastBvhAttr, this._lastMatAttr = t || this._lastMatAttr, !!(this._triStorageNode && this._bvhStorageNode && this._matStorageNode);
138
+ return t && !this._matStorageNode && (this._matStorageNode = Kn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && ee(this._linearBuckets, e.materialData?.linearBuckets), this._lastTriAttr = e.triangleGeoAttr || this._lastTriAttr, this._lastBvhAttr = e.bvhStorageAttr || this._lastBvhAttr, this._lastMatAttr = t || this._lastMatAttr, !!(this._triStorageNode && this._bvhStorageNode && this._matStorageNode);
139
139
  }
140
140
  _buildCompute() {
141
- let e = this._triStorageNode, n = this._bvhStorageNode, r = this._matStorageNode;
142
- this._linearBuckets = O(this.pathTracer?.materialData?.linearBuckets);
143
- let s = {
144
- srgbBuckets: O(null),
141
+ let e = this._triStorageNode, t = this._bvhStorageNode, n = this._matStorageNode;
142
+ this._linearBuckets = k(this.pathTracer?.materialData?.linearBuckets);
143
+ let o = {
144
+ srgbBuckets: k(null),
145
145
  linearBuckets: this._linearBuckets,
146
146
  shadowAlbedoMaps: null,
147
147
  goboMaps: null,
148
148
  iesProfiles: null,
149
149
  alphaShadows: null
150
150
  }, l = this.cameraWorldMatrix, u = this.cameraProjectionMatrixInverse, d = this.resolutionWidth, f = this.resolutionHeight, p = this._outputStorageTex, m = this._shadingStorageTex, h = this._leafStorageTex;
151
- this._computeNode = be(Tn(([s, l]) => {
151
+ this._computeNode = be(Tn(([o, l]) => {
152
152
  let u = R(X.x).mul(8).add(R(z.x)), g = R(X.y).mul(8).add(R(z.y));
153
153
  F(u.lessThan(R(d)).and(g.lessThan(R(f))), () => {
154
- let _ = E(J(L(u).add(.5).div(d), L(g).add(.5).div(f)), s, l, this.cameraRay), v = _.direction.toVar(), y = ie(v, this.cameraRay.clipStart, s, this.cameraRay.cameraProjection).toVar(), b = t({
154
+ let _ = E(J(L(u).add(.5).div(d), L(g).add(.5).div(f)), o, l, this.cameraRay), v = _.direction.toVar(), y = M(v, this.cameraRay.clipStart, o, this.cameraRay.cameraProjection).toVar(), b = i({
155
155
  origin: _.origin.add(v.mul(y)),
156
156
  direction: v
157
- }), x = i.wrap(re(b, n, e)), S = x.normal.mul(.5).add(.5), C = Bn(x.dst.add(y), L(65504)), w = x.didHit.select(Y(S, C), Y(0, 0, 0, L(Wr)));
157
+ }), x = r.wrap(ne(b, t, e)), S = x.normal.mul(.5).add(.5), C = Bn(x.dst.add(y), L(65504)), w = x.didHit.select(Y(S, C), Y(0, 0, 0, L(Wr)));
158
158
  G(p, Jn(K(u), K(g)), w).toWriteOnly(), h && G(h, Jn(K(u), K(g)), Yn(K(x.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
159
159
  let T = x.normal.toVar(), D = L(1).toVar();
160
160
  F(x.didHit, () => {
161
- let t = a.wrap(c(x.materialIndex, r)).toVar(), i = o.wrap(ne(x.uv, t)).toVar(), s = Y(0).toVar();
162
- F(t.normalMapIndex.greaterThanEqual(R(0)), () => {
163
- s.assign(oe(e, x.triangleIndex, x.normal, t.normalTransform, n, x.instanceLeaf));
161
+ let r = s.wrap(c(x.materialIndex, n)).toVar(), i = a.wrap(te(x.uv, r)).toVar(), o = Y(0).toVar();
162
+ F(r.normalMapIndex.greaterThanEqual(R(0)), () => {
163
+ o.assign(ae(e, x.triangleIndex, x.normal, r.normalTransform, t, x.instanceLeaf));
164
164
  });
165
- let l = ae(x.normal, t, i, s).toVar();
166
- T.assign(xe(l, t, i)), D.assign(ee(t, i).y.clamp(.05, 1));
165
+ let l = ie(x.normal, r, i, o).toVar();
166
+ T.assign(xe(l, r, i)), D.assign(O(r, i).y.clamp(.05, 1));
167
+ let u = B(r.emissive.x, B(r.emissive.y, r.emissive.z)).mul(r.emissiveIntensity).greaterThan(0);
168
+ D.assign(U(u, D.negate(), D));
167
169
  });
168
- let O = x.didHit.select(Y(T.mul(.5).add(.5), D), Y(0, 0, 0, 1));
169
- G(m, Jn(K(u), K(g)), O).toWriteOnly();
170
+ let k = x.didHit.select(Y(T.mul(.5).add(.5), D), Y(0, 0, 0, 1));
171
+ G(m, Jn(K(u), K(g)), k).toWriteOnly();
170
172
  });
171
- })(l, u), s).compute([
173
+ })(l, u), o).compute([
172
174
  this._dispatchX,
173
175
  this._dispatchY,
174
176
  1
@@ -212,7 +214,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
212
214
  reallocateReservedStorage() {
213
215
  this._computeNode?.dispose(), this._computeNode = null, this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose();
214
216
  let e = () => {
215
- let e = new Sn(N, N);
217
+ let e = new Sn(pe, pe);
216
218
  return e.type = fr, e.format = kr, e.minFilter = Z, e.magFilter = Z, e;
217
219
  };
218
220
  this._outputStorageTex = e(), this._shadingStorageTex = e(), this._leafStorageTex &&= (this._leafStorageTex.dispose(), this._makeLeafStorage()), this._computeBuilt = !1;
@@ -231,20 +233,20 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
231
233
  this._leafRT ? e.setTexture("pathtracer:instanceLeaf", this._leafRT.texture) : e.getTexture("pathtracer:instanceLeaf") && e.removeTexture("pathtracer:instanceLeaf");
232
234
  }
233
235
  _makeLeafStorage() {
234
- let e = new Sn(N, N);
236
+ let e = new Sn(pe, pe);
235
237
  return e.type = Lr, e.format = jr, e.minFilter = Z, e.magFilter = Z, e;
236
238
  }
237
239
  dispose() {
238
240
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._leafStorageTex?.dispose(), this._leafRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
239
241
  }
240
- }, ti = class extends k {
242
+ }, ei = class extends A {
241
243
  constructor(e, t, n = {}) {
242
244
  super("MotionVector", {
243
245
  ...n,
244
- executionMode: A.ALWAYS
246
+ executionMode: j.ALWAYS
245
247
  }), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
246
248
  let r = n.width || 1, i = n.height || 1;
247
- this.prevViewProjectionMatrix = new yr(), this.currentViewProjectionMatrix = new yr(), this.matricesInitialized = !1, this.cameraWorldMatrix = q(new yr(), "mat4"), this.cameraProjectionMatrixInverse = q(new yr(), "mat4"), this.cameraRay = ve(), this.prevVP = q(new yr(), "mat4"), this.resolutionWidth = q(r), this.resolutionHeight = q(i), this._normalDepthTexNode = new Cn(), this._screenSpaceStorageTex = new Sn(N, N), this._screenSpaceStorageTex.type = fr, this._screenSpaceStorageTex.format = kr, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._srcRegion = new nr(new Rr(0, 0), new Rr(0, 0)), this.screenSpaceTarget = new xn(r, i, {
249
+ this.prevViewProjectionMatrix = new yr(), this.currentViewProjectionMatrix = new yr(), this.matricesInitialized = !1, this.cameraWorldMatrix = q(new yr(), "mat4"), this.cameraProjectionMatrixInverse = q(new yr(), "mat4"), this.cameraRay = ve(), this.prevVP = q(new yr(), "mat4"), this.resolutionWidth = q(r), this.resolutionHeight = q(i), this._normalDepthTexNode = new Cn(), this._screenSpaceStorageTex = new Sn(pe, pe), this._screenSpaceStorageTex.type = fr, this._screenSpaceStorageTex.format = kr, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._srcRegion = new nr(new Rr(0, 0), new Rr(0, 0)), this.screenSpaceTarget = new xn(r, i, {
248
250
  type: fr,
249
251
  format: kr,
250
252
  minFilter: Z,
@@ -260,7 +262,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
260
262
  F(s.lessThan(R(i)).and(c.lessThan(R(a))), () => {
261
263
  let l = W(e, Rn(s, c)).w, u = J(L(s).add(.5).div(i), L(c).add(.5).div(a)), d = Y(0, 0, l, 1).toVar();
262
264
  F(l.lessThan(L(6e4)), () => {
263
- let e = ue(u, l, t, n, this.cameraRay), i = r.mul(Y(e, 1)), a = i.xy.div(i.w), o = J(a.x.mul(.5).add(.5), a.y.mul(-.5).add(.5)), s = u.sub(o), c = o.x.greaterThanEqual(0).and(o.x.lessThanEqual(1)).and(o.y.greaterThanEqual(0)).and(o.y.lessThanEqual(1));
265
+ let e = N(u, l, t, n, this.cameraRay), i = r.mul(Y(e, 1)), a = i.xy.div(i.w), o = J(a.x.mul(.5).add(.5), a.y.mul(-.5).add(.5)), s = u.sub(o), c = o.x.greaterThanEqual(0).and(o.x.lessThanEqual(1)).and(o.y.greaterThanEqual(0)).and(o.y.lessThanEqual(1));
264
266
  d.assign(c.select(Y(s, l, 1), Y(L(1e3), L(1e3), l, 0)));
265
267
  }), G(o, Jn(K(s), K(c)), d).toWriteOnly();
266
268
  });
@@ -304,13 +306,13 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
304
306
  }
305
307
  reallocateReservedStorage() {
306
308
  this._screenSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose();
307
- let e = new Sn(N, N);
309
+ let e = new Sn(pe, pe);
308
310
  e.type = fr, e.format = kr, e.minFilter = Z, e.magFilter = Z, this._screenSpaceStorageTex = e, this._buildScreenSpaceCompute();
309
311
  }
310
312
  dispose() {
311
313
  this._screenSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
312
314
  }
313
- }, ni = 1e-6, ri = 1.5 / 255, ii = .01, ai = 3, oi = 2, si = 2, ci = 3, li = 2, ui = 38, di = .1, fi = 4, pi = Math.cos(89 * Math.PI / 180), mi = .5, hi = 16, gi = {
315
+ }, ti = 1e-6, ni = 1.5 / 255, ri = .01, ii = 3, ai = 2, oi = 2, si = 3, ci = 2, li = 38, ui = .1, di = 4, fi = Math.cos(89 * Math.PI / 180), pi = .5, mi = .04, hi = .1 * mi, gi = 16, _i = 16, vi = {
314
316
  pre: {
315
317
  radiusScale: 1,
316
318
  fractionScale: 2
@@ -323,7 +325,7 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
323
325
  radiusScale: 2,
324
326
  fractionScale: .5
325
327
  }
326
- }, _i = .25 * Math.SQRT2, vi = [
328
+ }, yi = .25 * Math.SQRT2, bi = [
327
329
  [
328
330
  -1,
329
331
  0,
@@ -345,58 +347,58 @@ var Wr = 65504, Gr = 6e4, Kr = .01, qr = Object.freeze([
345
347
  1
346
348
  ],
347
349
  [
348
- -_i,
349
- _i,
350
+ -yi,
351
+ yi,
350
352
  .5
351
353
  ],
352
354
  [
353
- _i,
354
- _i,
355
+ yi,
356
+ yi,
355
357
  .5
356
358
  ],
357
359
  [
358
- _i,
359
- -_i,
360
+ yi,
361
+ -yi,
360
362
  .5
361
363
  ],
362
364
  [
363
- -_i,
364
- -_i,
365
+ -yi,
366
+ -yi,
365
367
  .5
366
368
  ]
367
- ], yi = (e, t, n) => Wn(0, 1, L(1).sub(e.mul(t).add(n).abs())), bi = (e, t, n) => {
368
- let r = e.mul(t).add(n).abs().mul(-ai);
369
+ ], xi = (e, t, n) => Wn(0, 1, L(1).sub(e.mul(t).add(n).abs())), Si = (e, t, n) => {
370
+ let r = e.mul(t).add(n).abs().mul(-ii);
369
371
  return L(1).div(r.mul(r).sub(r).add(1));
370
- }, xi = (e) => V(L(1.570796), L(1.395402), H(e)).mul(Gn(H(L(1).sub(e)))), Si = (e, t) => L(1).sub(Pn(e.mul(e).mul(-200))).mul(Hn(H(e), t)), Ci = (e, t) => H(e).mul(Gn(t.div(L(1).sub(t).add(ni)))), wi = (e, t, n, r) => {
371
- let i = B(On(Ci(n, r.mul(V(H(t), L(1), e)))), L(ri));
372
+ }, Ci = (e) => V(L(1.570796), L(1.395402), H(e)).mul(Gn(H(L(1).sub(e)))), wi = (e, t) => L(1).sub(Pn(e.mul(e).mul(-200))).mul(Hn(H(e), t)), Ti = (e, t) => H(e).mul(Gn(t.div(L(1).sub(t).add(ti)))), Ei = (e, t, n, r) => {
373
+ let i = B(On(Ti(n, r.mul(V(H(t), L(1), e)))), L(ni));
372
374
  return L(1).div(i);
373
- }, Ti = (e, t) => {
374
- let n = L(1).div(V(L(ii), L(1), H(e.mul(t))));
375
+ }, Di = (e, t) => {
376
+ let n = L(1).div(V(L(ri), L(1), H(e.mul(t))));
375
377
  return J(n, e.mul(n).negate());
376
- }, Ei = (e, t, n) => {
378
+ }, Oi = (e, t, n) => {
377
379
  let r = L(1).div(V(L(n), L(1), V(e.mul(e), e, H(t))));
378
380
  return J(r, e.mul(r).negate());
379
- }, Di = (e, t) => {
381
+ }, ki = (e, t) => {
380
382
  let n = L(1).div(t);
381
383
  return J(n, e.mul(n).negate());
382
- }, Oi = (e, t, n, r) => {
384
+ }, Ai = (e, t, n, r) => {
383
385
  let i = L(1).div(e.mul(t));
384
386
  return J(i, I(r, n).mul(i).negate());
385
- }, ki = (e) => J(1).sub(J(1).sub(Ln(e.mul(.5)).mul(2)).abs()).min(.99999), Ai = (e) => Xn(I(e, Xn(.25, .5, .25)), I(e, Xn(.5, 0, -.5)), I(e, Xn(-.25, .5, -.25))), ji = (e) => {
387
+ }, ji = (e) => J(1).sub(J(1).sub(Ln(e.mul(.5)).mul(2)).abs()).min(.99999), Mi = (e) => Xn(I(e, Xn(.25, .5, .25)), I(e, Xn(.5, 0, -.5)), I(e, Xn(-.25, .5, -.25))), Ni = (e) => {
386
388
  let t = e.x.sub(e.z);
387
389
  return B(Xn(t.add(e.y), e.x.add(e.z), t.sub(e.y)), Xn(0));
388
- }, Mi = (e, t) => t.add(ni).div(e.add(ni)), Ni = (e, t) => Y(e.xyz.mul(Mi(e.x, t)), e.w), Pi = (e) => Y(Ai(ji(e.xyz)), H(e.w)), Fi = (e, t) => Gn(t.sub(e.mul(e)).abs()), Ii = (e, t) => J(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), Li = (e, t) => U(e.equal(0), Y(0), t);
389
- function Ri(e) {
390
+ }, Pi = (e, t) => t.add(ti).div(e.add(ti)), Fi = (e, t) => Y(e.xyz.mul(Pi(e.x, t)), e.w), Ii = (e) => Y(Mi(Ni(e.xyz)), H(e.w)), Li = (e, t) => Gn(t.sub(e.mul(e)).abs()), Ri = (e, t) => J(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), zi = (e) => e.mul(1 - mi).add(mi), Bi = (e) => B(e.x, B(e.y, e.z)).lessThan(hi), Vi = (e) => e.z.greaterThan(gi - .5), Hi = (e) => e.lessThan(0), Ui = (e) => e.abs().clamp(.05, 1), Wi = (e, t) => U(e.equal(0), Y(0), t);
391
+ function Gi(e) {
390
392
  let t = Math.imul(e | 0, 2654435761) >>> 0;
391
393
  return t ^= t >>> 15, t = Math.imul(t, 2246822507) >>> 0, t ^= t >>> 13, t = Math.imul(t, 3266489909) >>> 0, t ^= t >>> 16, t / 4294967296;
392
394
  }
393
- var zi = class extends k {
395
+ var Ki = class extends A {
394
396
  constructor(e, t = {}) {
395
397
  super("NRD", {
396
398
  ...t,
397
- executionMode: A.PER_CYCLE
399
+ executionMode: j.PER_CYCLE
398
400
  }), this.renderer = e, this.pathTracer = t.pathTracer || null, this.settings = {
399
- ...Xr,
401
+ ...Yr,
400
402
  ...t.settings || {}
401
403
  }, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(B(t.mul(.1).add(3), L(1e-4))).clamp(0, 1) }) ?? null;
402
404
  let n = t.width || 1, r = t.height || 1;
@@ -435,7 +437,7 @@ var zi = class extends k {
435
437
  magFilter: mr,
436
438
  depthBuffer: !1,
437
439
  stencilBuffer: !1
438
- }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / hi), this._dispatchY = Math.ceil(r / hi), this._buildKernels();
440
+ }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / _i), this._dispatchY = Math.ceil(r / _i), this._buildKernels();
439
441
  }
440
442
  _allocStorage() {
441
443
  let e = () => D(fr);
@@ -459,7 +461,7 @@ var zi = class extends k {
459
461
  }
460
462
  updateParameters(e) {
461
463
  if (e) {
462
- for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Xr && (this.settings[t] = e[t]);
464
+ for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Yr && (this.settings[t] = e[t]);
463
465
  this._syncUniforms();
464
466
  }
465
467
  }
@@ -470,7 +472,7 @@ var zi = class extends k {
470
472
  t.fastClampSigmaScale.value = 3 + (e.fastHistoryClampingSigmaScale - 3) * a, t.fireflyMinRelativeScale.value = e.fireflySuppressorMinRelativeScale, t.antiFirefly.value = +!!e.enableAntiFirefly, t.antilag.value.set(e.antilagLuminanceSigmaScale, e.antilagLuminanceSensitivity), t.disocclusionThreshold.value = e.disocclusionThreshold, t.convergence.value.set(e.convergenceS, e.convergenceB, e.convergenceP), t.lobeVolumePercent.value = e.lobeVolumePercent, t.handoverFrames.value = e.handoverFrames > 0 ? e.handoverFrames : 2 * n;
471
473
  }
472
474
  _worldPosAt(e, t, n, r) {
473
- return ue(e, t, n, r, this.cameraRay);
475
+ return N(e, t, n, r, this.cameraRay);
474
476
  }
475
477
  _viewVector(e, t, n) {
476
478
  return U(he(this.cameraRay.cameraProjection), n, Vn(t.sub(e)));
@@ -494,6 +496,9 @@ var zi = class extends k {
494
496
  _handover(e) {
495
497
  return H(e.div(B(this.u.handoverFrames, 1)));
496
498
  }
499
+ _excluded(e, t, n, r) {
500
+ return e.greaterThanEqual(Gr).or(Hi(t)).or(n.and(r.not()));
501
+ }
497
502
  _bilinear(e) {
498
503
  let t = e.mul(J(this.resW, this.resH)).sub(.5), n = In(t), r = H(t.sub(n)), i = R(n.x), a = R(n.y), o = (e, t) => U(e.greaterThanEqual(R(0)).and(t.greaterThanEqual(R(0))).and(e.lessThan(R(this.resW))).and(t.lessThan(R(this.resH))), L(1), L(0));
499
504
  return {
@@ -526,7 +531,7 @@ var zi = class extends k {
526
531
  _sampleHistory(e, t, n, r, i) {
527
532
  let a = Y(0).toVar();
528
533
  return F(i, () => {
529
- let n = H(t).mul(J(this.resW, this.resH)), r = In(n.sub(.5)).add(.5), i = H(n.sub(r)), o = mi, s = i.mul(i.mul(i.mul(-o).add(2 * o)).sub(o)), c = i.mul(i.mul(i.mul(2 - o).sub(3 - o))).add(1), l = i.mul(i.mul(i.mul(-(2 - o)).add(3 - 2 * o)).add(o)), u = i.mul(i.mul(i.mul(o).sub(o))), d = [
534
+ let n = H(t).mul(J(this.resW, this.resH)), r = In(n.sub(.5)).add(.5), i = H(n.sub(r)), o = pi, s = i.mul(i.mul(i.mul(-o).add(2 * o)).sub(o)), c = i.mul(i.mul(i.mul(2 - o).sub(3 - o))).add(1), l = i.mul(i.mul(i.mul(-(2 - o)).add(3 - 2 * o)).add(o)), u = i.mul(i.mul(i.mul(o).sub(o))), d = [
530
535
  s.x,
531
536
  c.x,
532
537
  l.x,
@@ -564,119 +569,122 @@ var zi = class extends k {
564
569
  this._dispatchY,
565
570
  1
566
571
  ], [
567
- hi,
568
- hi,
572
+ _i,
573
+ _i,
569
574
  1
570
575
  ]);
571
576
  }
572
577
  _buildSpatial(e) {
573
- let t = e === "pre", { radiusScale: i, fractionScale: a } = gi[e], o = this.u, c = this._colorTexNode, l = this._albedoTexNode, u = this._ndTexNode, d = this._snTexNode, f = this._nData, p = e === "blur" ? this._nTmpA : this._nTmpB, m = e === "blur" ? this._tmpB : t ? this._tmpA : this._hist, h = this._geomPrev, g = t ? this.rotPre : e === "blur" ? this.rotBlur : this.rotPost, _ = t ? o.prepassBlurRadius : o.maxBlurRadius, v = this.camView, y = this.camPos, b = this.resW, x = this.resH, S = this.inputFrames, C = t ? (e) => {
574
- let t = W(c, e), i = W(l, e);
575
- return Y(Ai(n(t.xyz.div(B(i.xyz, Xn(Kr))))), r(i.w, s).min(1));
576
- } : (e) => W(p, e), w = Tn(([n, r]) => {
577
- let s = R(X.x).mul(hi).add(R(z.x)), c = R(X.y).mul(hi).add(R(z.y));
578
- F(s.lessThan(R(b)).and(c.lessThan(R(x))), () => {
579
- let l = Rn(s, c), p = Jn(K(s), K(c)), w = W(u, l).w.toVar(), T = w.greaterThanEqual(Gr), E = W(d, l).toVar(), D = Vn(E.xyz.mul(2).sub(1)).toVar(), ee = E.w.clamp(.05, 1).toVar(), O = L(Gr).toVar(), te = C(l).toVar();
580
- F(T.not(), () => {
581
- let e = this._pixelUv(s, c), p = this._worldPosAt(e, w, n, r).toVar();
582
- O.assign(v.mul(Y(p, 1)).z.abs()), F(_.greaterThan(0), () => {
583
- let s = I(D, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(O).toVar(), m = S.add(1), h = t ? B(S, L(10)) : W(f, l).y.add(S), w = (t ? L(1).div(h.add(1)) : this._advancedNonLinear(h)).toVar(), T = Si(ee, .5).toVar(), E = O.mul(Yr).add(3), ne = te.w.toVar(), re = H(ne.mul(E).div(c)), k = L(1).sub(this._handover(m)), A = (t ? re.div(m) : re.mul(w)).mul(k), j = o.minBlurRadius.mul(H(L(2).sub(h.div(B(o.maxAccum, 1))))), ie = B(H(Gn(H(A)).mul(i)).mul(_).mul(T), j.mul(T)).toVar(), ae = Oi(o.planeDistSensitivity, c, p, D).toVar(), oe = wi(w, o.lobeAngleFraction, ee, o.lobeVolumePercent).div(a).toVar(), se = Ti(ee, o.roughnessFraction.mul(a)).toVar(), ce = Di(ne, w).toVar(), le = o.minHitDistanceWeight.mul(a).mul(T);
584
- t || (le = le.mul(w)), le = le.toVar();
585
- let M = J(1);
586
- if (!t) {
587
- let e = v.mul(Y(D, 0)).xy;
588
- M = V(J(1).sub(e.abs()), J(1), s), M = M.div(B(M.x, M.y));
578
+ let r = e === "pre", { radiusScale: i, fractionScale: a } = vi[e], s = this.u, c = this._colorTexNode, l = this._albedoTexNode, u = this._ndTexNode, d = this._snTexNode, f = this._nData, p = e === "blur" ? this._nTmpA : this._nTmpB, m = e === "blur" ? this._tmpB : r ? this._tmpA : this._hist, h = this._geomPrev, g = r ? this.rotPre : e === "blur" ? this.rotBlur : this.rotPost, _ = r ? s.prepassBlurRadius : s.maxBlurRadius, v = this.camView, y = this.camPos, b = this.resW, x = this.resH, S = this.inputFrames, C = r ? (e, r) => Y(Mi(t(W(c, e).xyz.div(zi(r.xyz)))), n(r.w, o).min(1)) : (e) => W(p, e), w = Tn(([t, n]) => {
579
+ let o = R(X.x).mul(_i).add(R(z.x)), c = R(X.y).mul(_i).add(R(z.y));
580
+ F(o.lessThan(R(b)).and(c.lessThan(R(x))), () => {
581
+ let p = Rn(o, c), w = Jn(K(o), K(c)), T = W(u, p).w.toVar(), E = T.greaterThanEqual(Gr), D = W(d, p).toVar(), O = Vn(D.xyz.mul(2).sub(1)).toVar(), k = Ui(D.w).toVar(), ee = L(Gr).toVar(), te = r ? W(l, p) : null, ne = (r ? Bi(te) : Vi(W(f, p))).toVar(), A = C(p, te).toVar();
582
+ F(E.not(), () => {
583
+ let e = this._pixelUv(o, c), m = this._worldPosAt(e, T, t, n).toVar();
584
+ ee.assign(v.mul(Y(m, 1)).z.abs()), F(_.greaterThan(0).and(Hi(D.w).not()), () => {
585
+ let o = I(O, this._viewVector(m, y, this.viewVector)).abs().toVar(), c = this._frustumSize(ee).toVar(), h = S.add(1), w = r ? B(S, L(10)) : W(f, p).y.add(S), T = (r ? L(1).div(w.add(1)) : this._advancedNonLinear(w)).toVar(), E = wi(k, .5).toVar(), D = ee.mul(Jr).add(3), te = A.w.toVar(), j = H(te.mul(D).div(c)), re = L(1).sub(this._handover(h)), M = (r ? j.div(h) : j.mul(T)).mul(re), ie = s.minBlurRadius.mul(H(L(2).sub(w.div(B(s.maxAccum, 1))))), ae = B(H(Gn(H(M)).mul(i)).mul(_).mul(E), ie.mul(E)).toVar(), oe = Ai(s.planeDistSensitivity, c, m, O).toVar(), se = Ei(T, s.lobeAngleFraction, k, s.lobeVolumePercent).div(a).toVar(), ce = Di(k, s.roughnessFraction.mul(a)).toVar(), le = ki(te, T).toVar(), N = s.minHitDistanceWeight.mul(a).mul(E);
586
+ r || (N = N.mul(T)), N = N.toVar();
587
+ let ue = J(1);
588
+ if (!r) {
589
+ let e = v.mul(Y(O, 0)).xy;
590
+ ue = V(J(1).sub(e.abs()), J(1), o), ue = ue.div(B(ue.x, ue.y));
589
591
  }
590
- let ue = M.mul(J(L(1).div(b), L(1).div(x))).mul(ie).toVar(), de = L(1).toVar();
591
- for (let t = 0; t < vi.length; t++) {
592
- let i = vi[t], a = e.add(Ii(g, J(i[0], i[1])).mul(ue)), o = ki(a), s = U(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), L(1), L(Math.exp(-.66 * i[2] * i[2]))).toVar(), c = this._uvToCoord(o), l = W(u, c).w, f = this._worldPosAt(o, l, n, r), p = W(d, c), m = xi(I(D, Vn(p.xyz.mul(2).sub(1))));
593
- s.mulAssign(yi(m, oe, L(0))), s.mulAssign(yi(p.w, se.x, se.y)), s.mulAssign(yi(I(D, f), ae.x, ae.y)), s.assign(U(l.greaterThanEqual(Gr), L(0), s));
594
- let h = Li(s, C(c));
595
- s.mulAssign(le.add(bi(h.w, ce.x, ce.y))), de.addAssign(s), te.addAssign(h.mul(s));
592
+ let de = ue.mul(J(L(1).div(b), L(1).div(x))).mul(ae).toVar(), fe = L(1).toVar();
593
+ for (let i = 0; i < bi.length; i++) {
594
+ let a = bi[i], o = e.add(Ri(g, J(a[0], a[1])).mul(de)), s = ji(o), c = U(s.x.notEqual(o.x).or(s.y.notEqual(o.y)), L(1), L(Math.exp(-.66 * a[2] * a[2]))).toVar(), p = this._uvToCoord(s), m = W(u, p).w, h = this._worldPosAt(s, m, t, n), _ = W(d, p), v = Ci(I(O, Vn(_.xyz.mul(2).sub(1))));
595
+ c.mulAssign(xi(v, se, L(0))), c.mulAssign(xi(Ui(_.w), ce.x, ce.y)), c.mulAssign(xi(I(O, h), oe.x, oe.y));
596
+ let y = r ? W(l, p) : null, b = r ? Bi(y) : Vi(W(f, p));
597
+ c.assign(U(this._excluded(m, _.w, b, ne), L(0), c));
598
+ let x = Wi(c, C(p, y));
599
+ c.mulAssign(N.add(Si(x.w, le.x, le.y))), fe.addAssign(c), A.addAssign(x.mul(c));
596
600
  }
597
- te.divAssign(B(de, 1e-6)), t || te.assign(Y(te.xyz, ne));
601
+ A.divAssign(B(fe, 1e-6)), r || A.assign(Y(A.xyz, te));
598
602
  });
599
- }), G(m, p, te).toWriteOnly(), e === "post" && G(h, p, Y(D, O)).toWriteOnly();
603
+ }), G(m, w, A).toWriteOnly(), e === "post" && G(h, w, Y(O, ee)).toWriteOnly();
600
604
  });
601
605
  });
602
606
  return this._dispatchOf(w);
603
607
  }
604
608
  _buildTemporalAccumulation() {
605
- let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._motionTexNode, i = this._nTmpA, a = this._nHist, o = this._nFast, s = this._nInternal, c = this._nGeom, l = this._tmpB, u = this._dataT, d = this.camView, f = this.prevCamView, p = this.camPos, m = this.prevCamPos, h = this.resW, g = this.resH, _ = this.inputFrames, v = this.resetU, y = Tn(([y, b]) => {
606
- let x = R(X.x).mul(hi).add(R(z.x)), S = R(X.y).mul(hi).add(R(z.y));
607
- F(x.lessThan(R(h)).and(S.lessThan(R(g))), () => {
608
- let h = Rn(x, S), g = Jn(K(x), K(S)), C = W(t, h).w, w = W(i, h).toVar();
609
- F(C.greaterThanEqual(Gr), () => {
610
- G(l, g, w).toWriteOnly(), G(u, g, Y(0)).toWriteOnly(), Dn();
609
+ let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._motionTexNode, i = this._nTmpA, a = this._nHist, o = this._nFast, s = this._nInternal, c = this._nGeom, l = this._tmpB, u = this._dataT, d = this._albedoTexNode, f = this.camView, p = this.prevCamView, m = this.camPos, h = this.prevCamPos, g = this.resW, _ = this.resH, v = this.inputFrames, y = this.resetU, b = Tn(([b, x]) => {
610
+ let S = R(X.x).mul(_i).add(R(z.x)), C = R(X.y).mul(_i).add(R(z.y));
611
+ F(S.lessThan(R(g)).and(C.lessThan(R(_))), () => {
612
+ let g = Rn(S, C), _ = Jn(K(S), K(C)), w = W(t, g).w, T = W(i, g).toVar();
613
+ F(w.greaterThanEqual(Gr), () => {
614
+ G(l, _, T).toWriteOnly(), G(u, _, Y(0)).toWriteOnly(), Dn();
611
615
  });
612
- let T = e.maxAccum.mul(L(1).sub(v)).toVar(), E = e.maxFast.mul(L(1).sub(v)).toVar(), D = W(n, h), ee = Vn(D.xyz.mul(2).sub(1)).toVar(), O = D.w.clamp(.05, 1).toVar(), te = this._pixelUv(x, S), ne = this._worldPosAt(te, C, y, b).toVar(), re = d.mul(Y(ne, 1)).z.abs().toVar(), k = I(ee, this._viewVector(ne, p, this.viewVector)).abs().toVar(), A = this._frustumSize(re).toVar(), j = Xn(0).toVar();
613
- j.addAssign(ee.mul(.25));
616
+ let E = e.maxAccum.mul(L(1).sub(y)).toVar(), D = e.maxFast.mul(L(1).sub(y)).toVar(), O = W(n, g), k = Vn(O.xyz.mul(2).sub(1)).toVar(), ee = Ui(O.w).toVar(), te = this._pixelUv(S, C), ne = this._worldPosAt(te, w, b, x).toVar(), A = f.mul(Y(ne, 1)).z.abs().toVar(), j = I(k, this._viewVector(ne, m, this.viewVector)).abs().toVar(), re = this._frustumSize(A).toVar(), M = Xn(0).toVar();
617
+ M.addAssign(k.mul(.25));
614
618
  for (let e = -1; e <= 0; e++) for (let r = -1; r <= 0; r++) {
615
619
  if (r === 0 && e === 0) continue;
616
- let i = this._clampCoord(x.add(r), S.add(e)), a = Vn(W(n, i).xyz.mul(2).sub(1)), o = W(t, i).w.lessThan(Gr);
617
- j.addAssign(U(o, a, ee).mul(.25));
620
+ let i = this._clampCoord(S.add(r), C.add(e)), a = Vn(W(n, i).xyz.mul(2).sub(1)), o = W(t, i).w.lessThan(Gr);
621
+ M.addAssign(U(o, a, k).mul(.25));
618
622
  }
619
- let ie = W(r, h), ae = te.sub(ie.xy).toVar(), oe = f.mul(Y(ne, 1)).z.abs().toVar(), se = this._bilinear(ae), ce = A.mul(H(e.disocclusionThreshold.div(B(k, .05)))).sub(ni).toVar(), le = L(1).sub(v), M = [], ue = [];
623
+ let ie = W(r, g), ae = te.sub(ie.xy).toVar(), oe = p.mul(Y(ne, 1)).z.abs().toVar(), se = this._bilinear(ae), ce = re.mul(H(e.disocclusionThreshold.div(B(j, .05)))).sub(ti).toVar(), le = L(1).sub(y), N = [], ue = [];
620
624
  for (let e = 0; e < 4; e++) {
621
- let t = W(c, se.taps[e]), n = U(I(t.xyz, j).greaterThan(pi), L(1), L(0)), r = U(t.w.sub(oe).abs().lessThanEqual(ce), L(1), L(0)), i = U(t.w.lessThan(Gr), L(1), L(0));
622
- M.push(n.mul(r).mul(i).mul(se.inScreen[e]).mul(le).toVar()), ue.push(W(s, se.taps[e]).x);
625
+ let t = W(c, se.taps[e]), n = U(I(t.xyz, M).greaterThan(fi), L(1), L(0)), r = U(t.w.sub(oe).abs().lessThanEqual(ce), L(1), L(0)), i = U(t.w.lessThan(Gr), L(1), L(0));
626
+ N.push(n.mul(r).mul(i).mul(se.inScreen[e]).mul(le).toVar()), ue.push(W(s, se.taps[e]).x);
623
627
  }
624
- let de = se.customWeights(M).map((e) => e.toVar()), fe = M[0].add(M[1]).add(M[2]).add(M[3]).greaterThan(3.5).toVar(), pe = M[0].add(M[1].mul(2)).add(M[2].mul(4)).add(M[3].mul(8)), N = this._applyCustomWeights(ue, de, L(0)).toVar(), me = I(ee, this._viewVector(ne, m, this.prevViewVector)).abs().add(.001).div(k.add(.001)).toVar();
625
- me.assign(V(L(.1), L(1), H(me.mul(me))));
626
- let he = Gn(H(se.filter(M))).mul(me).toVar();
627
- N.assign(N.mul(V(he, L(1), L(1).div(N.add(1))))), N.assign(Bn(N, T));
628
- let ge = Pi(this._sampleHistory((e) => W(a, e), ae, se, de, fe)).toVar(), _e = B(this._applyCustomWeights(se.taps.map((e) => W(o, e).x), de, L(0)), 0).toVar(), ve = _.add(1), ye = this._handover(ve).toVar(), be = N.mul(L(1).sub(ye)), xe = ve.div(ve.add(be)).toVar(), Se = L(1).div(L(1).add(Si(O, .25).mul(.5).mul(T))), P = Y(V(ge.xyz, w.xyz, xe), V(ge.w, w.w, B(xe, Se))).toVar(), Ce = e.fireflyMinRelativeScale.add(L(ui).div(N.add(1))).toVar(), we = N.mul(e.maxBlurRadius).mul(di).toVar();
629
- we.assign(we.div(we.add(1)).mul(L(1).sub(ye)));
630
- let Te = V(P.x, Bn(P.x, ge.x.mul(Ce)), we);
631
- P.assign(Ni(P, Te));
632
- let Ee = L(1.2).add(L(1).div(N.add(1)));
633
- P.assign(Y(P.xyz, V(P.w, Bn(P.w, ge.w.mul(Ee)), we))), G(l, g, P).toWriteOnly();
634
- let De = Bn(N, E).mul(L(1).sub(ye)), Oe = ve.div(ve.add(De)), ke = V(_e, w.x, Oe).toVar(), Ae = Bn(ke, ge.x.mul(Ce).mul(fi));
635
- ke.assign(V(ke, Ae, we)), G(u, g, Y(ke, N, pe, U(fe, L(1), L(0)))).toWriteOnly();
628
+ let de = se.customWeights(N).map((e) => e.toVar()), fe = N[0].add(N[1]).add(N[2]).add(N[3]).greaterThan(3.5).toVar(), pe = N[0].add(N[1].mul(2)).add(N[2].mul(4)).add(N[3].mul(8)), me = this._applyCustomWeights(ue, de, L(0)).toVar(), he = I(k, this._viewVector(ne, h, this.prevViewVector)).abs().add(.001).div(j.add(.001)).toVar();
629
+ he.assign(V(L(.1), L(1), H(he.mul(he))));
630
+ let ge = Gn(H(se.filter(N))).mul(he).toVar();
631
+ me.assign(me.mul(V(ge, L(1), L(1).div(me.add(1))))), me.assign(Bn(me, E));
632
+ let _e = Ii(this._sampleHistory((e) => W(a, e), ae, se, de, fe)).toVar(), ve = B(this._applyCustomWeights(se.taps.map((e) => W(o, e).x), de, L(0)), 0).toVar(), ye = v.add(1), be = this._handover(ye).toVar(), xe = me.mul(L(1).sub(be)), Se = ye.div(ye.add(xe)).toVar(), P = L(1).div(L(1).add(wi(ee, .25).mul(.5).mul(E))), Ce = Y(V(_e.xyz, T.xyz, Se), V(_e.w, T.w, B(Se, P))).toVar(), we = e.fireflyMinRelativeScale.add(L(li).div(me.add(1))).toVar(), Te = me.mul(e.maxBlurRadius).mul(ui).toVar();
633
+ Te.assign(Te.div(Te.add(1)).mul(L(1).sub(be)));
634
+ let Ee = V(Ce.x, Bn(Ce.x, _e.x.mul(we)), Te);
635
+ Ce.assign(Fi(Ce, Ee));
636
+ let De = L(1.2).add(L(1).div(me.add(1)));
637
+ Ce.assign(Y(Ce.xyz, V(Ce.w, Bn(Ce.w, _e.w.mul(De)), Te))), G(l, _, Ce).toWriteOnly();
638
+ let Oe = Bn(me, D).mul(L(1).sub(be)), ke = ye.div(ye.add(Oe)), Ae = V(ve, T.x, ke).toVar(), je = Bn(Ae, _e.x.mul(we).mul(di));
639
+ Ae.assign(V(Ae, je, Te));
640
+ let Me = U(Bi(W(d, g)), L(gi), L(0));
641
+ G(u, _, Y(Ae, me, pe.add(Me), U(fe, L(1), L(0)))).toWriteOnly();
636
642
  });
637
643
  });
638
- return this._dispatchOf(y);
644
+ return this._dispatchOf(b);
639
645
  }
640
646
  _buildHistoryFix() {
641
647
  let e = this.u, t = this._ndTexNode, n = this._snTexNode, r = this._nTmpB, i = this._nData, a = this._tmpA, o = this._fastHist, s = this.camView, c = this.resW, l = this.resH, u = this.inputFrames, d = Tn(([d, f]) => {
642
- let p = R(X.x).mul(hi).add(R(z.x)), m = R(X.y).mul(hi).add(R(z.y));
648
+ let p = R(X.x).mul(_i).add(R(z.x)), m = R(X.y).mul(_i).add(R(z.y));
643
649
  F(p.lessThan(R(c)).and(m.lessThan(R(l))), () => {
644
650
  let h = Rn(p, m), g = Jn(K(p), K(m)), _ = W(t, h).w;
645
651
  F(_.greaterThanEqual(Gr), () => {
646
652
  let e = W(r, h);
647
653
  G(a, g, e).toWriteOnly(), G(o, g, Y(e.x, 0, 0, 0)).toWriteOnly(), Dn();
648
654
  });
649
- let v = W(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = W(n, h), C = Vn(S.xyz.mul(2).sub(1)).toVar(), w = S.w.clamp(.05, 1).toVar(), T = this._pixelUv(p, m), E = this._worldPosAt(T, _, d, f).toVar(), D = s.mul(Y(E, 1)).z.abs(), ee = this._frustumSize(D).toVar(), O = W(r, h).toVar(), te = L(1).div(b.add(1)).toVar(), ne = D.mul(Yr).add(3), re = H(O.w.mul(ne).div(ee)), k = O.w.toVar(), A = Un(U(b.lessThan(e.historyFixFrameNum), L(1), L(0)).mul(.5).mul(2 / oi).mul(e.historyFixStride).mul(V(L(.25).add(Gn(re).mul(.75)), L(1), te))).toVar();
650
- F(A.notEqual(0), () => {
651
- let a = wi(te, e.lobeAngleFraction, w, e.lobeVolumePercent).toVar(), o = Oi(e.planeDistSensitivity, ee, E, C).toVar(), s = Di(k, te).toVar(), u = Ei(w.mul(w), Gn(e.roughnessFraction), ii).toVar(), p = L(1).add(y).toVar();
652
- O.mulAssign(p);
653
- for (let e = -oi; e <= oi; e++) for (let m = -oi; m <= oi; m++) {
654
- if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === oi * 2) continue;
655
- let h = ki(T.add(J(m, e).mul(A).mul(J(L(1).div(c), L(1).div(l))))), g = this._uvToCoord(h), _ = W(t, g).w, v = this._worldPosAt(h, _, d, f), y = W(n, g), b = bi(xi(I(Vn(y.xyz.mul(2).sub(1)), C)), a, L(0)).toVar();
656
- b.mulAssign(bi(y.w.mul(y.w), u.x, u.y)), b.mulAssign(L(1).add(W(i, g).y)), b.mulAssign(yi(I(C, v), o.x, o.y)), b.assign(U(_.greaterThanEqual(Gr), L(0), b));
657
- let x = Li(b, W(r, g));
658
- b.mulAssign(bi(x.w, s.x, s.y)), p.addAssign(b), O.addAssign(x.mul(b));
655
+ let v = W(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = W(n, h), C = Vn(S.xyz.mul(2).sub(1)).toVar(), w = Ui(S.w).toVar(), T = this._pixelUv(p, m), E = this._worldPosAt(T, _, d, f).toVar(), D = s.mul(Y(E, 1)).z.abs(), O = this._frustumSize(D).toVar(), k = W(r, h).toVar(), ee = L(1).div(b.add(1)).toVar(), te = D.mul(Jr).add(3), ne = H(k.w.mul(te).div(O)), A = k.w.toVar(), j = Un(U(b.lessThan(e.historyFixFrameNum), L(1), L(0)).mul(.5).mul(2 / ai).mul(e.historyFixStride).mul(V(L(.25).add(Gn(ne).mul(.75)), L(1), ee))).toVar(), re = Hi(S.w).toVar();
656
+ F(j.notEqual(0).and(re.not()), () => {
657
+ let a = Ei(ee, e.lobeAngleFraction, w, e.lobeVolumePercent).toVar(), o = Ai(e.planeDistSensitivity, O, E, C).toVar(), s = ki(A, ee).toVar(), u = Oi(w.mul(w), Gn(e.roughnessFraction), ri).toVar(), p = Vi(v).toVar(), m = L(1).add(y).toVar();
658
+ k.mulAssign(m);
659
+ for (let e = -ai; e <= ai; e++) for (let h = -ai; h <= ai; h++) {
660
+ if (h === 0 && e === 0 || Math.abs(h) + Math.abs(e) === ai * 2) continue;
661
+ let g = ji(T.add(J(h, e).mul(j).mul(J(L(1).div(c), L(1).div(l))))), _ = this._uvToCoord(g), v = W(t, _).w, y = this._worldPosAt(g, v, d, f), b = W(n, _), x = Si(Ci(I(Vn(b.xyz.mul(2).sub(1)), C)), a, L(0)).toVar(), S = Ui(b.w);
662
+ x.mulAssign(Si(S.mul(S), u.x, u.y));
663
+ let w = W(i, _);
664
+ x.mulAssign(L(1).add(w.y)), x.mulAssign(xi(I(C, y), o.x, o.y)), x.assign(U(this._excluded(v, b.w, Vi(w), p), L(0), x));
665
+ let E = Wi(x, W(r, _));
666
+ x.mulAssign(Si(E.w, s.x, s.y)), m.addAssign(x), k.addAssign(E.mul(x));
659
667
  }
660
- O.divAssign(B(p, 1e-6));
668
+ k.divAssign(B(m, 1e-6));
661
669
  });
662
- let j = O.x.toVar(), ie = H(y.div(B(e.historyFixFrameNum, ni))), ae = V(j, v.x, ie).toVar();
670
+ let M = k.x.toVar(), ie = H(y.div(B(e.historyFixFrameNum, ti))), ae = V(M, v.x, ie).toVar();
663
671
  G(o, g, Y(ae, 0, 0, 0)).toWriteOnly();
664
- let oe = ae.toVar(), se = ae.mul(ae).toVar(), ce = L(0).toVar(), le = L(0).toVar(), M = (e, n, r) => {
672
+ let oe = ae.toVar(), se = ae.mul(ae).toVar(), ce = L(0).toVar(), le = L(0).toVar(), N = (e, n, r) => {
665
673
  let a = this._clampCoord(p.add(e), m.add(n)), o = W(t, a).w, s = U(o.greaterThanEqual(Gr), ae, W(i, a).x);
666
- Math.abs(e) <= si && Math.abs(n) <= si && (oe.addAssign(s), se.addAssign(s.mul(s))), r && (ce.addAssign(s), le.addAssign(s.mul(s)));
674
+ Math.abs(e) <= oi && Math.abs(n) <= oi && (oe.addAssign(s), se.addAssign(s.mul(s))), r && (ce.addAssign(s), le.addAssign(s.mul(s)));
667
675
  }, ue = e.antiFirefly.greaterThan(.5);
668
- for (let e = -si; e <= si; e++) for (let t = -si; t <= si; t++) t === 0 && e === 0 || M(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
676
+ for (let e = -oi; e <= oi; e++) for (let t = -oi; t <= oi; t++) t === 0 && e === 0 || N(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
669
677
  F(ue, () => {
670
- for (let e = -ci; e <= ci; e++) for (let t = -ci; t <= ci; t++) Math.abs(t) <= si && Math.abs(e) <= si || M(t, e, !0);
678
+ for (let e = -si; e <= si; e++) for (let t = -si; t <= si; t++) Math.abs(t) <= oi && Math.abs(e) <= oi || N(t, e, !0);
671
679
  }), F(ue, () => {
672
- let e = 1 / ((ci * 2 + 1) ** 2 - 9), t = ce.mul(e), n = Fi(t, le.mul(e)).mul(li);
673
- j.assign(V(j.clamp(t.sub(n), t.add(n)), j, x));
680
+ let e = 1 / ((si * 2 + 1) ** 2 - 9), t = ce.mul(e), n = Li(t, le.mul(e)).mul(ci);
681
+ M.assign(V(M.clamp(t.sub(n), t.add(n)), M, x));
674
682
  });
675
683
  {
676
- let t = 1 / (si * 2 + 1) ** 2, n = oe.mul(t), r = Fi(n, se.mul(t)).mul(e.fastClampSigmaScale), i = j.clamp(n.sub(r), n.add(r)), a = U(e.maxFast.lessThan(e.maxAccum), L(1), L(0)), o = V(L(1).div(L(1).add(a.mul(y).mul(2))), L(1), x);
677
- j.assign(V(i, j, o));
684
+ let t = 1 / (oi * 2 + 1) ** 2, n = oe.mul(t), r = Li(n, se.mul(t)).mul(e.fastClampSigmaScale), i = M.clamp(n.sub(r), n.add(r)), a = U(e.maxFast.lessThan(e.maxAccum), L(1), L(0)), o = V(L(1).div(L(1).add(a.mul(y).mul(2))), L(1), x);
685
+ M.assign(V(i, M, o));
678
686
  }
679
- G(a, g, Ni(O, j)).toWriteOnly();
687
+ G(a, g, U(re, k, Fi(k, M))).toWriteOnly();
680
688
  });
681
689
  });
682
690
  return this._dispatchOf(d);
@@ -684,56 +692,56 @@ var zi = class extends k {
684
692
  _buildTemporalStabilization(e) {
685
693
  let t = this.u, n = this._colorTexNode, r = this._albedoTexNode, i = this._ndTexNode, a = this._snTexNode, o = this._motionTexNode, s = this._nHist, c = this._nData, l = this._nStabRead, u = this._internal, d = this._tmpA, f = this.resW, p = this.resH, m = this.inputFrames, h = this.resetU, g = this.debugMode;
686
694
  return Tn(() => {
687
- let _ = R(X.x).mul(hi).add(R(z.x)), v = R(X.y).mul(hi).add(R(z.y));
695
+ let _ = R(X.x).mul(_i).add(R(z.x)), v = R(X.y).mul(_i).add(R(z.y));
688
696
  F(_.lessThan(R(f)).and(v.lessThan(R(p))), () => {
689
697
  let f = Rn(_, v), p = Jn(K(_), K(v)), y = W(i, f).w, b = W(n, f).toVar();
690
698
  F(y.greaterThanEqual(Gr), () => {
691
699
  G(d, p, b).toWriteOnly(), G(e, p, Y(W(s, f).x, 0, 0, 0)).toWriteOnly(), G(u, p, Y(0, 1, 0, 0)).toWriteOnly(), Dn();
692
700
  });
693
- let x = W(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), C = W(o, f), w = S.sub(C.xy).toVar(), T = W(c, f).toVar(), E = T.y.toVar(), D = K(T.z.add(.5)).toVar(), ee = T.w.greaterThan(.5), O = this._bilinear(w), te = [
701
+ let x = W(a, f).w, S = Ui(x), C = this._pixelUv(_, v), w = W(o, f), T = C.sub(w.xy).toVar(), E = W(c, f).toVar(), D = E.y.toVar(), O = K(E.z.add(.5)).toVar(), k = E.w.greaterThan(.5), ee = this._bilinear(T), te = [
694
702
  1,
695
703
  2,
696
704
  4,
697
705
  8
698
- ].map((e) => U(D.bitAnd(K(e)).notEqual(K(0)), L(1), L(0))), ne = O.customWeights(te).map((e) => e.toVar()), re = Gn(H(O.filter(te))).toVar(), k = W(s, f).toVar(), A = k.x.toVar(), j = A.toVar(), ie = A.mul(A).toVar();
706
+ ].map((e) => U(O.bitAnd(K(e)).notEqual(K(0)), L(1), L(0))), ne = ee.customWeights(te).map((e) => e.toVar()), A = Gn(H(ee.filter(te))).toVar(), j = W(s, f).toVar(), re = j.x.toVar(), M = re.toVar(), ie = re.mul(re).toVar();
699
707
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
700
708
  if (t === 0 && e === 0) continue;
701
- let n = this._clampCoord(_.add(t), v.add(e)), r = W(i, n).w, a = U(r.greaterThanEqual(Gr), A, W(s, n).x);
702
- j.addAssign(a), ie.addAssign(a.mul(a));
709
+ let n = this._clampCoord(_.add(t), v.add(e)), r = W(i, n).w, a = U(r.greaterThanEqual(Gr), re, W(s, n).x);
710
+ M.addAssign(a), ie.addAssign(a.mul(a));
703
711
  }
704
- j.divAssign(9), ie.divAssign(9);
705
- let ae = Fi(j, ie).toVar();
706
- F(E.lessThan(t.historyFixFrameNum), () => {
707
- A.assign(Bn(A, j.mul(L(1.2).add(L(1).div(E.add(1))))));
712
+ M.divAssign(9), ie.divAssign(9);
713
+ let ae = Li(M, ie).toVar();
714
+ F(D.lessThan(t.historyFixFrameNum).and(Hi(x).not()), () => {
715
+ re.assign(Bn(re, M.mul(L(1.2).add(L(1).div(D.add(1))))));
708
716
  });
709
- let oe = B(this._sampleHistory((e) => W(l, e), w, O, ne, ee).x, 0).toVar(), se = ae.mul(t.antilag.x), ce = t.antilag.y.mul(4), le = oe.clamp(j.sub(se), j.add(se)), M = oe.sub(le).abs().div(B(oe, le).add(ni)), ue = L(1).div(L(1).add(M.mul(E.mul(re)).div(ce))).toVar(), de = Bn(E, t.historyFixFrameNum);
710
- E.assign(V(de, E, ue));
711
- let fe = m.add(1), pe = this._handover(fe), N = re.mul(L(1).sub(this._advancedNonLinear(E.mul(L(1).sub(pe)).div(fe)))).mul(ue).toVar(), me = L(1).add(N.mul(6)), he = t.stabilizationStrength.mul(L(1).sub(h)), ge = V(A, oe.clamp(j.sub(ae.mul(me)), j.add(ae.mul(me))), Bn(N, he)).toVar();
712
- k.assign(Ni(k, ge)), G(e, p, Y(ge, 0, 0, 0)).toWriteOnly();
713
- let _e = t.maxAccum.mul(L(1).sub(h));
714
- G(u, p, Y(Bn(E.add(1), _e), x, 0, 0)).toWriteOnly();
715
- let ve = W(r, f), ye = Y(ji(k.xyz).mul(B(ve.xyz, Xn(Kr))), b.w).toVar();
717
+ let oe = B(this._sampleHistory((e) => W(l, e), T, ee, ne, k).x, 0).toVar(), se = ae.mul(t.antilag.x), ce = t.antilag.y.mul(4), le = oe.clamp(M.sub(se), M.add(se)), N = oe.sub(le).abs().div(B(oe, le).add(ti)), ue = L(1).div(L(1).add(N.mul(D.mul(A)).div(ce))).toVar(), de = Bn(D, t.historyFixFrameNum);
718
+ D.assign(V(de, D, ue));
719
+ let fe = m.add(1), pe = this._handover(fe), me = A.mul(L(1).sub(this._advancedNonLinear(D.mul(L(1).sub(pe)).div(fe)))).mul(ue).toVar(), he = L(1).add(me.mul(6)), ge = t.stabilizationStrength.mul(L(1).sub(h)), _e = V(re, oe.clamp(M.sub(ae.mul(he)), M.add(ae.mul(he))), Bn(me, ge)).toVar();
720
+ j.assign(Fi(j, _e)), G(e, p, Y(_e, 0, 0, 0)).toWriteOnly();
721
+ let ve = t.maxAccum.mul(L(1).sub(h));
722
+ G(u, p, Y(Bn(D.add(1), ve), S, 0, 0)).toWriteOnly();
723
+ let ye = W(r, f), be = Y(Ni(j.xyz).mul(zi(ye.xyz)), b.w).toVar();
716
724
  F(g.equal(R(1)), () => {
717
- let e = H(E.div(B(t.maxAccum, 1)));
718
- ye.assign(Y(L(1).sub(e), e, .2, 1));
725
+ let e = H(D.div(B(t.maxAccum, 1)));
726
+ be.assign(Y(L(1).sub(e), e, .2, 1));
719
727
  }).ElseIf(g.equal(R(2)), () => {
720
- ye.assign(Y(Xn(k.w), 1));
728
+ be.assign(Y(Xn(j.w), 1));
721
729
  }).ElseIf(g.equal(R(3)), () => {
722
- ye.assign(Y(Xn(x), 1));
730
+ be.assign(Y(Xn(S), 1));
723
731
  }).ElseIf(g.equal(R(4)), () => {
724
- let e = T.x.div(T.x.add(1));
725
- ye.assign(Y(Xn(e), 1));
732
+ let e = E.x.div(E.x.add(1));
733
+ be.assign(Y(Xn(e), 1));
726
734
  }).ElseIf(g.equal(R(5)), () => {
727
- ye.assign(Y(Xn(T.z.div(15)), 1));
728
- }), G(d, p, ye).toWriteOnly();
735
+ be.assign(Y(Xn(L(O.bitAnd(K(15))).div(15)), 1));
736
+ }), G(d, p, be).toWriteOnly();
729
737
  });
730
738
  })().compute([
731
739
  this._dispatchX,
732
740
  this._dispatchY,
733
741
  1
734
742
  ], [
735
- hi,
736
- hi,
743
+ _i,
744
+ _i,
737
745
  1
738
746
  ]);
739
747
  }
@@ -753,7 +761,7 @@ var zi = class extends k {
753
761
  }
754
762
  _updateRotators(e) {
755
763
  let t = (t, n) => {
756
- let r = Ri(e * 3 + n) * Math.PI * 2;
764
+ let r = Gi(e * 3 + n) * Math.PI * 2;
757
765
  t.value.set(Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r));
758
766
  };
759
767
  t(this.rotPre, 0), t(this.rotBlur, 1), t(this.rotPost, 2);
@@ -780,7 +788,7 @@ var zi = class extends k {
780
788
  this._nTmpA.value = this._tmpA, this._nTmpB.value = this._tmpB, this._nHist.value = this._hist, this._nFast.value = this._fastHist, this._nInternal.value = this._internal, this._nGeom.value = this._geomPrev, this._nData.value = this._dataT, this._nStabRead.value = this._stabPing === 0 ? this._stabB : this._stabA, this.renderer.compute(this._kPre), this.renderer.compute(this._kTa), this.renderer.compute(this._kHf), this.renderer.compute(this._kBlur), this.renderer.compute(this._kPost), this.renderer.compute(this._stabPing === 0 ? this._kTsA : this._kTsB), this._srcRegion.max.set(this.outputTarget.width, this.outputTarget.height), this.renderer.copyTextureToTexture(this._tmpA, this.outputTarget.texture, this._srcRegion), e.setTexture("nrd:output", this.outputTarget.texture), this._stabPing = 1 - this._stabPing, this._needsReset = !1, this._needsReset = !1;
781
789
  }
782
790
  setSize(e, t) {
783
- this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / hi), this._dispatchY = Math.ceil(t / hi);
791
+ this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / _i), this._dispatchY = Math.ceil(t / _i);
784
792
  let n = [
785
793
  this._dispatchX,
786
794
  this._dispatchY,
@@ -809,7 +817,7 @@ var zi = class extends k {
809
817
  for (let [e, t] of this._placeholders) e.dispose(), t.dispose();
810
818
  this._placeholders.clear();
811
819
  }
812
- }, Bi = {
820
+ }, qi = {
813
821
  autoExposure: !1,
814
822
  autoExposureMetering: "center",
815
823
  autoExposureStrength: .3,
@@ -818,42 +826,42 @@ var zi = class extends k {
818
826
  autoExposureMaxExposure: 2 ** 8,
819
827
  autoExposureAdaptSpeedBright: 3,
820
828
  autoExposureAdaptSpeedDark: 1
821
- }, Vi = [
829
+ }, Ji = [
822
830
  "average",
823
831
  "center",
824
832
  "spot"
825
- ], Hi = 64, Ui = 8, Wi = 8, Gi = 256, Ki = -16, qi = (12 - Ki) / Gi, Ji = 2 ** -24, Yi = 65536, Xi = 256, Zi = 128, Qi = 1.5, $i = .01, ea = .06, ta = .25, na = 4, ra = .3, ia = 1.5, aa = 3, oa = [
833
+ ], Yi = 64, Xi = 8, Zi = 8, Qi = 256, $i = -16, ea = (12 - $i) / Qi, ta = 2 ** -24, na = 65536, ra = 256, ia = 128, aa = 1.5, oa = .01, sa = .06, ca = .25, la = 4, ua = .3, da = 1.5, fa = 3, pa = [
826
834
  .2126,
827
835
  .7152,
828
836
  .0722
829
- ], sa = .999, ca = {
837
+ ], ma = .999, ha = {
830
838
  transparent: 0,
831
839
  environment: 1,
832
840
  color: 2
833
841
  };
834
- function la(e, t, n, r, i) {
842
+ function ga(e, t, n, r, i) {
835
843
  let a = t - e;
836
844
  if (a === 0 || !(n > 0)) return e;
837
845
  let o = Math.max(a < 0 ? r : i, .001);
838
846
  if (n === Infinity) return t;
839
- let s = Math.min(o * n, Math.abs(a) * (1 - Math.exp(-o * n / Qi)));
847
+ let s = Math.min(o * n, Math.abs(a) * (1 - Math.exp(-o * n / aa)));
840
848
  return e + Math.sign(a) * s;
841
849
  }
842
- function ua(e, t, n) {
850
+ function _a(e, t, n) {
843
851
  let r = Math.abs(e);
844
- return e * (r <= ia ? n : r >= aa ? 1 : n + (1 - n) * (r - ia) / (aa - ia)) + n * (t - e);
852
+ return e * (r <= da ? n : r >= fa ? 1 : n + (1 - n) * (r - da) / (fa - da)) + n * (t - e);
845
853
  }
846
- function da(e, t) {
847
- if (!e) return t.fromArray(oa);
854
+ function va(e, t) {
855
+ if (!e) return t.fromArray(pa);
848
856
  let n = new vr().set(...e).invert().elements;
849
- return t.set(oa[0] * n[0] + oa[1] * n[1] + oa[2] * n[2], oa[0] * n[3] + oa[1] * n[4] + oa[2] * n[5], oa[0] * n[6] + oa[1] * n[7] + oa[2] * n[8]);
857
+ return t.set(pa[0] * n[0] + pa[1] * n[1] + pa[2] * n[2], pa[0] * n[3] + pa[1] * n[4] + pa[2] * n[5], pa[0] * n[6] + pa[1] * n[7] + pa[2] * n[8]);
850
858
  }
851
- var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
859
+ var ya = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, ba = class extends A {
852
860
  constructor(e, t = {}) {
853
861
  super("AutoExposure", {
854
862
  ...t,
855
- executionMode: A.ALWAYS
856
- }), this.renderer = e, this.metering = t.metering ?? Bi.autoExposureMetering, this.meteringPoint = new Rr(.5, .5), this.keyValue = t.keyValue ?? Bi.autoExposureKeyValue, this.minExposure = t.minExposure ?? Bi.autoExposureMinExposure, this.maxExposure = t.maxExposure ?? Bi.autoExposureMaxExposure, this.adaptSpeedBright = t.adaptSpeedBright ?? Bi.autoExposureAdaptSpeedBright, this.adaptSpeedDark = t.adaptSpeedDark ?? Bi.autoExposureAdaptSpeedDark, this.centerWeight = t.centerWeight ?? 8, this.strength = t.strength ?? Bi.autoExposureStrength, this.instant = !1, this.holdSamples = 0, this.onChange = null, this._lowU = q(t.lowPercentile ?? .1), this._highU = q(t.highPercentile ?? .9), this._falloffU = q(new Rr()), this._pointU = q(new Rr(.5, .5)), this._lumWeightsU = q(new Q().fromArray(oa)), this._backdropModeU = q(ca.transparent, "int"), this._widthU = q(1, "int"), this._heightU = q(1, "int"), this._strideU = q(1, "int"), this._gridXU = q(Hi, "int"), this._gridYU = q(Hi, "int"), this._inputNode = new Cn(), this._workingMatrix = void 0, this._histogram = Mn(Gi, "uint").toAtomic(), this._result = Mn(1, "vec4"), this._readback = new bn(16), this._readback.name = "AutoExposure", this._kernels = [this._buildTileKernel(), this._buildResolveKernel()], this._compensation = 1, this._exposureEV = 0, this._targetEV = null, this._viewEV = null, this._roomEV = null, this._clock = 0, this._movingUntil = -1, this._viewMoves = 0, this._landed = null, this._meteredLog2 = null, this._snap = !0, this._lastUpdate = null, this._accumulating = !1, this._emittedEV = null, this._pending = null, this._generation = 0, this._restarts = 0, this._meteredAt = {
863
+ executionMode: j.ALWAYS
864
+ }), this.renderer = e, this.metering = t.metering ?? qi.autoExposureMetering, this.meteringPoint = new Rr(.5, .5), this.keyValue = t.keyValue ?? qi.autoExposureKeyValue, this.minExposure = t.minExposure ?? qi.autoExposureMinExposure, this.maxExposure = t.maxExposure ?? qi.autoExposureMaxExposure, this.adaptSpeedBright = t.adaptSpeedBright ?? qi.autoExposureAdaptSpeedBright, this.adaptSpeedDark = t.adaptSpeedDark ?? qi.autoExposureAdaptSpeedDark, this.centerWeight = t.centerWeight ?? 8, this.strength = t.strength ?? qi.autoExposureStrength, this.instant = !1, this.holdSamples = 0, this.onChange = null, this._lowU = q(t.lowPercentile ?? .1), this._highU = q(t.highPercentile ?? .9), this._falloffU = q(new Rr()), this._pointU = q(new Rr(.5, .5)), this._lumWeightsU = q(new Q().fromArray(pa)), this._backdropModeU = q(ha.transparent, "int"), this._widthU = q(1, "int"), this._heightU = q(1, "int"), this._strideU = q(1, "int"), this._gridXU = q(Yi, "int"), this._gridYU = q(Yi, "int"), this._inputNode = new Cn(), this._workingMatrix = void 0, this._histogram = Mn(Qi, "uint").toAtomic(), this._result = Mn(1, "vec4"), this._readback = new bn(16), this._readback.name = "AutoExposure", this._kernels = [this._buildTileKernel(), this._buildResolveKernel()], this._compensation = 1, this._exposureEV = 0, this._targetEV = null, this._viewEV = null, this._roomEV = null, this._clock = 0, this._movingUntil = -1, this._viewMoves = 0, this._landed = null, this._meteredLog2 = null, this._snap = !0, this._lastUpdate = null, this._accumulating = !1, this._emittedEV = null, this._pending = null, this._generation = 0, this._restarts = 0, this._meteredAt = {
857
865
  restarts: -1,
858
866
  samples: -1
859
867
  }, this._stale = !1, this._disposed = !1;
@@ -861,7 +869,7 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
861
869
  _buildTileKernel() {
862
870
  let e = this._inputNode, t = this._histogram, n = this._widthU, r = this._heightU, i = this._strideU, a = this._gridXU, o = this._gridYU, s = this._lumWeightsU, c = this._falloffU, l = this._pointU, u = this._backdropModeU;
863
871
  return Tn(() => {
864
- let d = z.y.mul(K(Wi)).add(z.x), f = R(X.x), p = R(X.y), m = f.mul(n).div(a).toVar(), h = f.add(R(1)).mul(n).div(a).toVar(), g = p.mul(r).div(o).toVar(), _ = p.add(R(1)).mul(r).div(o).toVar(), v = i.mul(R(Wi)), y = L(0).toVar(), b = L(0).toVar();
872
+ let d = z.y.mul(K(Zi)).add(z.x), f = R(X.x), p = R(X.y), m = f.mul(n).div(a).toVar(), h = f.add(R(1)).mul(n).div(a).toVar(), g = p.mul(r).div(o).toVar(), _ = p.add(R(1)).mul(r).div(o).toVar(), v = i.mul(R(Zi)), y = L(0).toVar(), b = L(0).toVar();
865
873
  En({
866
874
  start: g.add(R(z.y)),
867
875
  end: _,
@@ -878,31 +886,31 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
878
886
  update: v,
879
887
  name: "px"
880
888
  }, ({ px: n }) => {
881
- let r = W(e, Rn(n, t)), i = I(r.xyz, s).toVar(), a = Fn(i).bitAnd(K(2139095040)).notEqual(K(2139095040)), o = r.w.clamp(0, 1), c = U(u.equal(R(ca.environment)), L(1), U(u.equal(R(ca.color)), U(o.greaterThanEqual(sa), L(1), L(0)), o));
889
+ let r = W(e, Rn(n, t)), i = I(r.xyz, s).toVar(), a = Fn(i).bitAnd(K(2139095040)).notEqual(K(2139095040)), o = r.w.clamp(0, 1), c = U(u.equal(R(ha.environment)), L(1), U(u.equal(R(ha.color)), U(o.greaterThanEqual(ma), L(1), L(0)), o));
882
890
  y.addAssign(U(a, i.clamp(0, 1e6), L(0)).mul(c)), b.addAssign(c);
883
891
  });
884
892
  });
885
- let x = Zn("float", Wi * Wi), S = Zn("float", Wi * Wi);
893
+ let x = Zn("float", Zi * Zi), S = Zn("float", Zi * Zi);
886
894
  x.element(d).assign(y), S.element(d).assign(b), Qn();
887
- for (let e = Wi * Wi >> 1; e > 0; e >>= 1) F(d.lessThan(K(e)), () => {
895
+ for (let e = Zi * Zi >> 1; e > 0; e >>= 1) F(d.lessThan(K(e)), () => {
888
896
  x.element(d).addAssign(x.element(d.add(K(e)))), S.element(d).addAssign(S.element(d.add(K(e))));
889
897
  }), Qn();
890
898
  F(d.equal(K(0)), () => {
891
- let e = x.element(K(0)).toVar(), i = S.element(K(0)).toVar(), a = (e) => e.div(v).mul(R(Wi)).add(Bn(e.mod(v), R(Wi))), o = L(a(h.sub(m)).mul(a(_.sub(g))));
892
- F(i.greaterThan(0).and(e.greaterThan(i.mul(Ji))), () => {
893
- let a = K(zn(e.div(i)).sub(Ki).div(qi).floor().clamp(0, Gi - 1)), s = J(L(m.add(h)).div(L(n)), L(g.add(_)).div(L(r))).mul(.5).sub(l), u = K(Nn(I(s.mul(s), c).negate()).mul(i.div(B(o, 1))).mul(Yi).add(.5));
899
+ let e = x.element(K(0)).toVar(), i = S.element(K(0)).toVar(), a = (e) => e.div(v).mul(R(Zi)).add(Bn(e.mod(v), R(Zi))), o = L(a(h.sub(m)).mul(a(_.sub(g))));
900
+ F(i.greaterThan(0).and(e.greaterThan(i.mul(ta))), () => {
901
+ let a = K(zn(e.div(i)).sub($i).div(ea).floor().clamp(0, Qi - 1)), s = J(L(m.add(h)).div(L(n)), L(g.add(_)).div(L(r))).mul(.5).sub(l), u = K(Nn(I(s.mul(s), c).negate()).mul(i.div(B(o, 1))).mul(na).add(.5));
894
902
  F(u.greaterThan(K(0)), () => {
895
903
  kn(t.element(a), u);
896
904
  });
897
905
  });
898
906
  });
899
907
  })().compute([
900
- Hi,
901
- Hi,
908
+ Yi,
909
+ Yi,
902
910
  1
903
911
  ], [
904
- Wi,
905
- Wi,
912
+ Zi,
913
+ Zi,
906
914
  1
907
915
  ]);
908
916
  }
@@ -911,31 +919,31 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
911
919
  return Tn(() => {
912
920
  let i = z.x, a = L(An(e.element(i))).toVar();
913
921
  jn(e.element(i), K(0));
914
- let o = Zn("float", Gi), s = Zn("float", Gi);
922
+ let o = Zn("float", Qi), s = Zn("float", Qi);
915
923
  o.element(i).assign(a), Qn();
916
- for (let e = 1; e < Gi; e <<= 1) {
924
+ for (let e = 1; e < Qi; e <<= 1) {
917
925
  let t = o.element(i).toVar();
918
926
  F(i.greaterThanEqual(K(e)), () => {
919
927
  t.addAssign(o.element(i.sub(K(e))));
920
928
  }), Qn(), o.element(i).assign(t), Qn();
921
929
  }
922
- let c = o.element(K(Gi - 1)).toVar(), l = o.element(i).toVar();
930
+ let c = o.element(K(Qi - 1)).toVar(), l = o.element(i).toVar();
923
931
  Qn();
924
932
  let u = B(Bn(l, c.mul(r)).sub(B(l.sub(a), c.mul(n))), 0);
925
- o.element(i).assign(u), s.element(i).assign(u.mul(L(i).add(.5).mul(qi).add(Ki))), Qn();
926
- for (let e = Gi >> 1; e > 0; e >>= 1) F(i.lessThan(K(e)), () => {
933
+ o.element(i).assign(u), s.element(i).assign(u.mul(L(i).add(.5).mul(ea).add($i))), Qn();
934
+ for (let e = Qi >> 1; e > 0; e >>= 1) F(i.lessThan(K(e)), () => {
927
935
  o.element(i).addAssign(o.element(i.add(K(e)))), s.element(i).addAssign(s.element(i.add(K(e))));
928
936
  }), Qn();
929
937
  F(i.equal(K(0)), () => {
930
938
  let e = o.element(K(0));
931
- t.element(K(0)).assign(Y(s.element(K(0)).div(B(e, 1e-6)), c.div(Yi), e.div(Yi), 1));
939
+ t.element(K(0)).assign(Y(s.element(K(0)).div(B(e, 1e-6)), c.div(na), e.div(na), 1));
932
940
  });
933
941
  })().compute([
934
942
  1,
935
943
  1,
936
944
  1
937
945
  ], [
938
- Gi,
946
+ Qi,
939
947
  1,
940
948
  1
941
949
  ]);
@@ -947,7 +955,7 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
947
955
  if (!this.enabled) return;
948
956
  let t = e.getState("pathtracer:samples") ?? 0;
949
957
  if (this._accumulating = t >= 2, !this._pending) {
950
- let n = this._meteredAt, r = this._stale || this._targetEV === null || n.restarts !== this._restarts || t - n.samples >= fa(t), i = t < this.holdSamples && this._targetEV !== null && !this._stale;
958
+ let n = this._meteredAt, r = this._stale || this._targetEV === null || n.restarts !== this._restarts || t - n.samples >= ya(t), i = t < this.holdSamples && this._targetEV !== null && !this._stale;
951
959
  r && !i && this._meter(e, t);
952
960
  }
953
961
  e.setState("autoexposure:value", this.renderer.toneMappingExposure), e.setState("autoexposure:avgLuminance", this.luminance);
@@ -962,13 +970,13 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
962
970
  if (!n || r < 1 || i < 1 || this._disposed) return null;
963
971
  this._meteredAt.restarts = this._restarts, this._meteredAt.samples = t, this._stale = !1;
964
972
  let a = et();
965
- a !== this._workingMatrix && (this._workingMatrix = a, da(a, this._lumWeightsU.value));
966
- let o = Math.min(Hi, Math.max(1, Math.floor(r / Ui))), s = Math.min(Hi, Math.max(1, Math.floor(i / Ui))), c = r / o * (i / s);
973
+ a !== this._workingMatrix && (this._workingMatrix = a, va(a, this._lumWeightsU.value));
974
+ let o = Math.min(Yi, Math.max(1, Math.floor(r / Xi))), s = Math.min(Yi, Math.max(1, Math.floor(i / Xi))), c = r / o * (i / s);
967
975
  this._gridXU.value = o, this._gridYU.value = s, this._kernels[0].dispatchSize = [
968
976
  o,
969
977
  s,
970
978
  1
971
- ], this._strideU.value = Math.max(1, Math.round(Math.sqrt(c / Xi))), this._widthU.value = r, this._heightU.value = i, this._backdropModeU.value = ca[e.getState("pathtracer:backdrop")] ?? ca.transparent, this._updateMeteringPattern(r / i), this._inputNode.value = n, this.renderer.compute(this._kernels);
979
+ ], this._strideU.value = Math.max(1, Math.round(Math.sqrt(c / ra))), this._widthU.value = r, this._heightU.value = i, this._backdropModeU.value = ha[e.getState("pathtracer:backdrop")] ?? ha.transparent, this._updateMeteringPattern(r / i), this._inputNode.value = n, this.renderer.compute(this._kernels);
972
980
  let l = this._generation, u = {
973
981
  restarts: this._restarts,
974
982
  moves: this._viewMoves
@@ -984,7 +992,7 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
984
992
  let t = this._falloffU.value, n = this._pointU.value;
985
993
  if (this.metering === "average") t.set(0, 0);
986
994
  else if (this.metering === "spot") {
987
- t.set(Zi * e * e, Zi), n.copy(this.meteringPoint);
995
+ t.set(ia * e * e, ia), n.copy(this.meteringPoint);
988
996
  return;
989
997
  } else t.set(this.centerWeight, this.centerWeight);
990
998
  n.set(.5, .5);
@@ -993,25 +1001,25 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
993
1001
  let [n, r, i] = e;
994
1002
  if (!this.enabled || !(r > 0 && i > 0) || !Number.isFinite(n)) return null;
995
1003
  let a = this._viewEV;
996
- this._meteredLog2 = n, this._viewEV = Math.log2(this.keyValue) - n, this._roomEV === null ? this._roomEV = this._viewEV : t?.moves === this._landed?.moves ? this._roomEV += this._viewEV - a : this._movingUntil = this._clock + ra, this._landed = t;
997
- let o = this._aim(), s = this._targetEV === null || Math.abs(o - this._targetEV) > $i;
1004
+ this._meteredLog2 = n, this._viewEV = Math.log2(this.keyValue) - n, this._roomEV === null ? this._roomEV = this._viewEV : t?.moves === this._landed?.moves ? this._roomEV += this._viewEV - a : this._movingUntil = this._clock + ua, this._landed = t;
1005
+ let o = this._aim(), s = this._targetEV === null || Math.abs(o - this._targetEV) > oa;
998
1006
  return this._targetEV = o, (s || this.settling) && this.onChange?.(), n;
999
1007
  }
1000
1008
  update(e = performance.now()) {
1001
- let t = this._lastUpdate === null ? 0 : Math.min((e - this._lastUpdate) / 1e3, ta), n = this.advance(t, this._accumulating);
1009
+ let t = this._lastUpdate === null ? 0 : Math.min((e - this._lastUpdate) / 1e3, ca), n = this.advance(t, this._accumulating);
1002
1010
  return this._lastUpdate = this.settling || this._clock <= this._movingUntil ? e : null, n;
1003
1011
  }
1004
1012
  advance(e, t = !1) {
1005
1013
  if (!this.enabled || this._targetEV === null) return !1;
1006
- e > 0 && e !== Infinity && (this._clock += e, this._clock <= this._movingUntil && (this._roomEV += (this._viewEV - this._roomEV) * (1 - Math.exp(-Math.min(e, ta) / na)), this._targetEV = this._aim()));
1014
+ e > 0 && e !== Infinity && (this._clock += e, this._clock <= this._movingUntil && (this._roomEV += (this._viewEV - this._roomEV) * (1 - Math.exp(-Math.min(e, ca) / la)), this._targetEV = this._aim()));
1007
1015
  let n = this._exposureEV;
1008
- return this._snap || this.instant ? (this._exposureEV = this._targetEV, this._snap = !1) : (this._exposureEV = t ? n + (this._targetEV - n) * (1 - Math.exp(-e / ea)) : la(n, this._targetEV, e, this.adaptSpeedBright, this.adaptSpeedDark), Math.abs(this._targetEV - this._exposureEV) <= $i && (this._exposureEV = this._targetEV)), this._exposureEV === n ? !1 : (this._apply(), !0);
1016
+ return this._snap || this.instant ? (this._exposureEV = this._targetEV, this._snap = !1) : (this._exposureEV = t ? n + (this._targetEV - n) * (1 - Math.exp(-e / sa)) : ga(n, this._targetEV, e, this.adaptSpeedBright, this.adaptSpeedDark), Math.abs(this._targetEV - this._exposureEV) <= oa && (this._exposureEV = this._targetEV)), this._exposureEV === n ? !1 : (this._apply(), !0);
1009
1017
  }
1010
1018
  _inRange(e) {
1011
1019
  return Math.min(Math.max(e, Math.log2(this.minExposure)), Math.log2(this.maxExposure));
1012
1020
  }
1013
1021
  _aim() {
1014
- return this._inRange(ua(this._roomEV, this._viewEV, this.strength));
1022
+ return this._inRange(_a(this._roomEV, this._viewEV, this.strength));
1015
1023
  }
1016
1024
  noteViewChanged() {
1017
1025
  this._viewMoves++;
@@ -1054,7 +1062,7 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
1054
1062
  }
1055
1063
  updateParameters(e) {
1056
1064
  let t = e.metering;
1057
- t !== void 0 && Vi.includes(t) && (this.metering = t), e.meteringPoint && this.meteringPoint.set(e.meteringPoint.x, e.meteringPoint.y);
1065
+ t !== void 0 && Ji.includes(t) && (this.metering = t), e.meteringPoint && this.meteringPoint.set(e.meteringPoint.x, e.meteringPoint.y);
1058
1066
  for (let t of [
1059
1067
  "keyValue",
1060
1068
  "minExposure",
@@ -1077,32 +1085,32 @@ var fa = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, pa = class extends k {
1077
1085
  for (let e of this._kernels) e.dispose();
1078
1086
  this._readback.dispose(), this._inputNode.dispose();
1079
1087
  }
1080
- }, ma = {
1088
+ }, xa = {
1081
1089
  localExposure: !1,
1082
1090
  localExposureHighlightContrast: .6,
1083
1091
  localExposureShadowContrast: 1,
1084
1092
  localExposureDetailStrength: 1
1085
- }, ha = 128, ga = (ha / 2) ** 2, $ = 32, _a = -16, va = 16, ya = -40, ba = 40, xa = 256, Sa = 32, Ca = .6, wa = 50, Ta = Math.log2(.18), Ea = .999, Da = 2 ** -24, Oa = Math.ceil(j / ha), ka = Math.ceil(j / Sa), Aa = [
1093
+ }, Sa = 128, Ca = (Sa / 2) ** 2, $ = 32, wa = -16, Ta = 16, Ea = -40, Da = 40, Oa = 256, ka = 32, Aa = .6, ja = 50, Ma = Math.log2(.18), Na = .999, Pa = 2 ** -24, Fa = Math.ceil(re / Sa), Ia = Math.ceil(re / ka), La = [
1086
1094
  .2126,
1087
1095
  .7152,
1088
1096
  .0722
1089
- ], ja = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, Ma = (e, t, n) => Math.min(Math.max(e, t), n);
1090
- function Na(e, t, n, r, i, a, o) {
1091
- let s = Math.min(Math.log2(Math.max(a, Da)), ba), c = e[6], l = e[7], u = Ma(r * e[2] - .5, 0, c - 1), d = Ma(i * e[3] - .5, 0, l - 1), f = Math.floor(u), p = Math.floor(d), m = Math.min(f + 1, c - 1), h = Math.min(p + 1, l - 1), g = u - f, _ = d - p, v = (e) => n[e * c + f] + (n[e * c + m] - n[e * c + f]) * g, y = v(p) + (v(h) - v(p)) * _, b = e[4], x = e[5], S = Ma(r * e[0] - .5, 0, b - 1), C = Ma(i * e[1] - .5, 0, x - 1), w = Ma((s + e[8] - _a) / (va - _a), 0, 1) * ($ - 1), T = Math.floor(S), E = Math.floor(C), D = Math.floor(w), ee = S - T, O = C - E, te = w - D, ne = 0, re = 0;
1097
+ ], Ra = (e) => e < 16 ? 1 : e < 64 ? 4 : 16, za = (e, t, n) => Math.min(Math.max(e, t), n);
1098
+ function Ba(e, t, n, r, i, a, o) {
1099
+ let s = Math.min(Math.log2(Math.max(a, Pa)), Da), c = e[6], l = e[7], u = za(r * e[2] - .5, 0, c - 1), d = za(i * e[3] - .5, 0, l - 1), f = Math.floor(u), p = Math.floor(d), m = Math.min(f + 1, c - 1), h = Math.min(p + 1, l - 1), g = u - f, _ = d - p, v = (e) => n[e * c + f] + (n[e * c + m] - n[e * c + f]) * g, y = v(p) + (v(h) - v(p)) * _, b = e[4], x = e[5], S = za(r * e[0] - .5, 0, b - 1), C = za(i * e[1] - .5, 0, x - 1), w = za((s + e[8] - wa) / (Ta - wa), 0, 1) * ($ - 1), T = Math.floor(S), E = Math.floor(C), D = Math.floor(w), O = S - T, k = C - E, ee = w - D, te = 0, ne = 0;
1092
1100
  for (let e = 0; e < 8; e++) {
1093
- let n = e & 1, r = e >> 1 & 1, i = e >> 2, a = (n ? ee : 1 - ee) * (r ? O : 1 - O) * (i ? te : 1 - te), o = ((Math.min(E + r, x - 1) * b + Math.min(T + n, b - 1)) * $ + Math.min(D + i, $ - 1)) * 2;
1094
- ne += t[o] * a, re += t[o + 1] * a;
1101
+ let n = e & 1, r = e >> 1 & 1, i = e >> 2, a = (n ? O : 1 - O) * (r ? k : 1 - k) * (i ? ee : 1 - ee), o = ((Math.min(E + r, x - 1) * b + Math.min(T + n, b - 1)) * $ + Math.min(D + i, $ - 1)) * 2;
1102
+ te += t[o] * a, ne += t[o + 1] * a;
1095
1103
  }
1096
- let k = re * ga < .001 ? y : ne / re, A = k + (y - k) * e[12] + o, j = s + o, ie = A > e[13] ? e[9] : e[10];
1097
- return 2 ** (e[13] + (A - e[13]) * ie + (j - A) * e[11] - j);
1104
+ let A = ne * Ca < .001 ? y : te / ne, j = A + (y - A) * e[12] + o, re = s + o, M = j > e[13] ? e[9] : e[10];
1105
+ return 2 ** (e[13] + (j - e[13]) * M + (re - j) * e[11] - re);
1098
1106
  }
1099
- var Pa = `
1107
+ var Va = `
1100
1108
  @group(1) @binding(0) var<storage, read> leGrid: array<vec2<f32>>;
1101
1109
  @group(1) @binding(1) var<storage, read> leBlur: array<f32>;
1102
1110
  @group(1) @binding(2) var<uniform> le: array<vec4<f32>, 4>;
1103
1111
 
1104
1112
  fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1105
- let logL = min( log2( max( dot( linear, vec3<f32>( ${Aa.join(", ")} ) ), ${Da} ) ), ${ba}.0 );
1113
+ let logL = min( log2( max( dot( linear, vec3<f32>( ${La.join(", ")} ) ), ${Pa} ) ), ${Da}.0 );
1106
1114
  let logExposure = log2( exposure );
1107
1115
 
1108
1116
  let bs = vec2<i32>( le[ 1 ].zw );
@@ -1116,7 +1124,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1116
1124
 
1117
1125
  let cs = vec2<i32>( le[ 1 ].xy );
1118
1126
  let gp = clamp( uv * le[ 0 ].xy - 0.5, vec2<f32>( 0.0 ), vec2<f32>( cs - 1 ) );
1119
- let gz = clamp( ( logL + le[ 2 ].x - (${_a}.0) ) / ${va - _a}.0, 0.0, 1.0 ) * ${$ - 1}.0;
1127
+ let gz = clamp( ( logL + le[ 2 ].x - (${wa}.0) ) / ${Ta - wa}.0, 0.0, 1.0 ) * ${$ - 1}.0;
1120
1128
  let g0 = vec3<i32>( vec2<i32>( floor( gp ) ), i32( floor( gz ) ) );
1121
1129
  let gf = vec3<f32>( gp - floor( gp ), gz - floor( gz ) );
1122
1130
  var acc = vec2<f32>( 0.0 );
@@ -1127,18 +1135,18 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1127
1135
  acc += leGrid[ ( c.y * cs.x + c.x ) * ${$} + c.z ] * ( wv.x * wv.y * wv.z );
1128
1136
  }
1129
1137
 
1130
- let bilateral = select( acc.x / acc.y, blurred, acc.y * ${ga}.0 < 1e-3 );
1138
+ let bilateral = select( acc.x / acc.y, blurred, acc.y * ${Ca}.0 < 1e-3 );
1131
1139
  let base = mix( bilateral, blurred, le[ 3 ].x ) + logExposure;
1132
1140
  let y = logL + logExposure;
1133
1141
  let contrast = select( le[ 2 ].z, le[ 2 ].y, base > le[ 3 ].y );
1134
1142
  return exp2( le[ 3 ].y + ( base - le[ 3 ].y ) * contrast + ( y - base ) * le[ 2 ].w - y );
1135
1143
  }
1136
- `, Fa = class extends k {
1144
+ `, Ha = class extends A {
1137
1145
  constructor(e, t = {}) {
1138
1146
  super("LocalExposure", {
1139
1147
  ...t,
1140
- executionMode: A.ALWAYS
1141
- }), this.renderer = e, this.highlightContrast = t.highlightContrast ?? ma.localExposureHighlightContrast, this.shadowContrast = t.shadowContrast ?? ma.localExposureShadowContrast, this.detailStrength = t.detailStrength ?? ma.localExposureDetailStrength, this.onChange = null, this._grid = Mn(Oa * Oa * $, "vec2"), this._blur = Mn(ka * ka, "float"), this._blurSource = Mn(ka * ka, "vec2"), this._blurTmp = Mn(ka * ka, "vec2"), this._inputNode = new Cn(), this._widthU = q(1, "int"), this._heightU = q(1, "int"), this._cellsXU = q(1, "int"), this._blurWU = q(1, "int"), this._blurHU = q(1, "int"), this._radiusU = q(1), this._logExposureU = q(0), this._sceneOnlyU = q(0, "int"), this._p = [
1148
+ executionMode: j.ALWAYS
1149
+ }), this.renderer = e, this.highlightContrast = t.highlightContrast ?? xa.localExposureHighlightContrast, this.shadowContrast = t.shadowContrast ?? xa.localExposureShadowContrast, this.detailStrength = t.detailStrength ?? xa.localExposureDetailStrength, this.onChange = null, this._grid = Mn(Fa * Fa * $, "vec2"), this._blur = Mn(Ia * Ia, "float"), this._blurSource = Mn(Ia * Ia, "vec2"), this._blurTmp = Mn(Ia * Ia, "vec2"), this._inputNode = new Cn(), this._widthU = q(1, "int"), this._heightU = q(1, "int"), this._cellsXU = q(1, "int"), this._blurWU = q(1, "int"), this._blurHU = q(1, "int"), this._radiusU = q(1), this._logExposureU = q(0), this._sceneOnlyU = q(0, "int"), this._p = [
1142
1150
  new zr(),
1143
1151
  new zr(),
1144
1152
  new zr(),
@@ -1154,13 +1162,13 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1154
1162
  }, this._stale = !1, this._paramsBuffer = null, this._disposed = !1;
1155
1163
  }
1156
1164
  _buildGridKernel() {
1157
- let e = this._inputNode, t = this._grid, n = this._widthU, r = this._heightU, i = this._cellsXU, a = this._logExposureU, o = this._sceneOnlyU.greaterThan(R(0)), s = Y(...Aa, 0).xyz;
1165
+ let e = this._inputNode, t = this._grid, n = this._widthU, r = this._heightU, i = this._cellsXU, a = this._logExposureU, o = this._sceneOnlyU.greaterThan(R(0)), s = Y(...La, 0).xyz;
1158
1166
  return Tn(() => {
1159
1167
  let c = z.y.mul(K(16)).add(z.x), l = Zn("uint", $).toAtomic(), u = Zn("uint", $).toAtomic();
1160
1168
  F(c.lessThan(K($)), () => {
1161
1169
  jn(l.element(c), K(0)), jn(u.element(c), K(0));
1162
1170
  }), Qn();
1163
- let d = R(X.x).mul(R(ha)).add(R(z.x).mul(R(8))), f = R(X.y).mul(R(ha)).add(R(z.y).mul(R(8)));
1171
+ let d = R(X.x).mul(R(Sa)).add(R(z.x).mul(R(8))), f = R(X.y).mul(R(Sa)).add(R(z.y).mul(R(8)));
1164
1172
  En({
1165
1173
  start: R(0),
1166
1174
  end: R(8),
@@ -1179,16 +1187,16 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1179
1187
  }, ({ tx: i }) => {
1180
1188
  let c = d.add(i), p = f.add(t);
1181
1189
  F(c.lessThan(n).and(p.lessThan(r)), () => {
1182
- let t = Bn(c.add(R(1)), n.sub(R(1))), i = Bn(p.add(R(1)), r.sub(R(1))), d = W(e, Rn(c, p)).toVar(), f = W(e, Rn(t, p)).toVar(), m = W(e, Rn(c, i)).toVar(), h = W(e, Rn(t, i)).toVar(), g = (e) => U(o.and(e.w.lessThan(Ea)), L(0), L(1)), _ = g(d), v = g(f), y = g(m), b = g(h), x = _.add(v).add(y).add(b).toVar(), S = I(d.xyz, s).mul(_).add(I(f.xyz, s).mul(v)).add(I(m.xyz, s).mul(y)).add(I(h.xyz, s).mul(b)).div(B(x, 1e-6)).toVar(), C = x.mul(.25).toVar();
1190
+ let t = Bn(c.add(R(1)), n.sub(R(1))), i = Bn(p.add(R(1)), r.sub(R(1))), d = W(e, Rn(c, p)).toVar(), f = W(e, Rn(t, p)).toVar(), m = W(e, Rn(c, i)).toVar(), h = W(e, Rn(t, i)).toVar(), g = (e) => U(o.and(e.w.lessThan(Na)), L(0), L(1)), _ = g(d), v = g(f), y = g(m), b = g(h), x = _.add(v).add(y).add(b).toVar(), S = I(d.xyz, s).mul(_).add(I(f.xyz, s).mul(v)).add(I(m.xyz, s).mul(y)).add(I(h.xyz, s).mul(b)).div(B(x, 1e-6)).toVar(), C = x.mul(.25).toVar();
1183
1191
  F(Fn(S).bitAnd(K(2139095040)).notEqual(K(2139095040)).and(x.greaterThan(0)), () => {
1184
- let e = zn(B(S, Da)).clamp(ya, ba).toVar(), t = e.add(a).sub(_a).div(va - _a).clamp(0, 1).mul($ - 1).toVar(), n = K(In(t)).min(K($ - 1)), r = n.add(K(1)).min(K($ - 1)), i = t.sub(In(t)).mul(C), o = L(1).sub(t.sub(In(t))).mul(C), s = e.sub(ya).mul(xa);
1185
- kn(l.element(n), K(s.mul(o).add(.5))), kn(u.element(n), K(o.mul(xa).add(.5))), kn(l.element(r), K(s.mul(i).add(.5))), kn(u.element(r), K(i.mul(xa).add(.5)));
1192
+ let e = zn(B(S, Pa)).clamp(Ea, Da).toVar(), t = e.add(a).sub(wa).div(Ta - wa).clamp(0, 1).mul($ - 1).toVar(), n = K(In(t)).min(K($ - 1)), r = n.add(K(1)).min(K($ - 1)), i = t.sub(In(t)).mul(C), o = L(1).sub(t.sub(In(t))).mul(C), s = e.sub(Ea).mul(Oa);
1193
+ kn(l.element(n), K(s.mul(o).add(.5))), kn(u.element(n), K(o.mul(Oa).add(.5))), kn(l.element(r), K(s.mul(i).add(.5))), kn(u.element(r), K(i.mul(Oa).add(.5)));
1186
1194
  });
1187
1195
  });
1188
1196
  });
1189
1197
  }), Qn(), F(c.lessThan(K($)), () => {
1190
- let e = L(An(u.element(c))).div(xa), n = L(An(l.element(c))).div(xa).add(e.mul(ya)), r = K(X.y).mul(K(i)).add(K(X.x));
1191
- t.element(r.mul(K($)).add(c)).assign(J(n, e).div(ga));
1198
+ let e = L(An(u.element(c))).div(Oa), n = L(An(l.element(c))).div(Oa).add(e.mul(Ea)), r = K(X.y).mul(K(i)).add(K(X.x));
1199
+ t.element(r.mul(K($)).add(c)).assign(J(n, e).div(Ca));
1192
1200
  });
1193
1201
  })().compute([
1194
1202
  1,
@@ -1201,12 +1209,12 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1201
1209
  ]);
1202
1210
  }
1203
1211
  _buildBlurSourceKernel() {
1204
- let e = this._inputNode, t = this._blurSource, n = this._widthU, r = this._heightU, i = this._blurWU, a = this._sceneOnlyU.greaterThan(R(0)), o = Y(...Aa, 0).xyz;
1212
+ let e = this._inputNode, t = this._blurSource, n = this._widthU, r = this._heightU, i = this._blurWU, a = this._sceneOnlyU.greaterThan(R(0)), o = Y(...La, 0).xyz;
1205
1213
  return Tn(() => {
1206
- let s = z.y.mul(K(8)).add(z.x), c = R(X.x).mul(R(Sa)), l = R(X.y).mul(R(Sa)), u = L(0).toVar(), d = L(0).toVar(), f = L(0).toVar();
1214
+ let s = z.y.mul(K(8)).add(z.x), c = R(X.x).mul(R(ka)), l = R(X.y).mul(R(ka)), u = L(0).toVar(), d = L(0).toVar(), f = L(0).toVar();
1207
1215
  En({
1208
1216
  start: R(z.y),
1209
- end: R(Sa),
1217
+ end: R(ka),
1210
1218
  type: "int",
1211
1219
  condition: "<",
1212
1220
  update: 8,
@@ -1214,7 +1222,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1214
1222
  }, ({ by: t }) => {
1215
1223
  En({
1216
1224
  start: R(z.x),
1217
- end: R(Sa),
1225
+ end: R(ka),
1218
1226
  type: "int",
1219
1227
  condition: "<",
1220
1228
  update: 8,
@@ -1222,7 +1230,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1222
1230
  }, ({ bx: i }) => {
1223
1231
  let s = c.add(i), p = l.add(t);
1224
1232
  F(s.lessThan(n).and(p.lessThan(r)), () => {
1225
- let t = W(e, Rn(s, p)).toVar(), n = I(t.xyz, o).toVar(), r = Fn(n).bitAnd(K(2139095040)).notEqual(K(2139095040)), i = U(a.and(t.w.lessThan(Ea)), L(0), L(1));
1233
+ let t = W(e, Rn(s, p)).toVar(), n = I(t.xyz, o).toVar(), r = Fn(n).bitAnd(K(2139095040)).notEqual(K(2139095040)), i = U(a.and(t.w.lessThan(Na)), L(0), L(1));
1226
1234
  u.addAssign(U(r, n.max(0).mul(i), L(0))), d.addAssign(U(r, i, L(0))), f.addAssign(U(r, L(1), L(0)));
1227
1235
  });
1228
1236
  });
@@ -1233,7 +1241,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1233
1241
  p.element(s).addAssign(p.element(s.add(K(e)))), m.element(s).addAssign(m.element(s.add(K(e)))), h.element(s).addAssign(h.element(s.add(K(e))));
1234
1242
  }), Qn();
1235
1243
  F(s.equal(K(0)), () => {
1236
- let e = zn(B(p.element(K(0)).div(B(m.element(K(0)), 1)), Da)).clamp(ya, ba), n = U(a, m.element(K(0)).div(B(h.element(K(0)), 1)), L(1)).toVar();
1244
+ let e = zn(B(p.element(K(0)).div(B(m.element(K(0)), 1)), Pa)).clamp(Ea, Da), n = U(a, m.element(K(0)).div(B(h.element(K(0)), 1)), L(1)).toVar();
1237
1245
  t.element(K(R(X.y).mul(i).add(R(X.x)))).assign(J(e.mul(n), n));
1238
1246
  });
1239
1247
  })().compute([
@@ -1285,14 +1293,14 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1285
1293
  render(e) {
1286
1294
  if (!this.enabled) return;
1287
1295
  let t = e.getState("pathtracer:samples") ?? 0, n = this._builtAt;
1288
- (this._stale || !this._built || n.restarts !== this._restarts || t - n.samples >= ja(t)) && this.build(e);
1296
+ (this._stale || !this._built || n.restarts !== this._restarts || t - n.samples >= Ra(t)) && this.build(e);
1289
1297
  }
1290
1298
  build(e = this.context) {
1291
1299
  let t = e?.getTexture("pathtracer:color"), n = t?.image?.width | 0, r = t?.image?.height | 0;
1292
1300
  if (!t || n < 1 || r < 1 || this._disposed) return !1;
1293
1301
  this._builtAt.restarts = this._restarts, this._builtAt.samples = e.getState("pathtracer:samples") ?? 0, this._stale = !1;
1294
- let i = Math.min(Oa, Math.ceil(n / ha)), a = Math.min(Oa, Math.ceil(r / ha)), o = Math.min(ka, Math.ceil(n / Sa)), s = Math.min(ka, Math.ceil(r / Sa)), c = Math.log2(Math.max(this.renderer.toneMappingExposure, 1e-6));
1295
- return this._inputNode.value = t, this._widthU.value = n, this._heightU.value = r, this._cellsXU.value = i, this._blurWU.value = o, this._blurHU.value = s, this._radiusU.value = Math.max(1, wa / 100 * o), this._logExposureU.value = c, this._sceneOnlyU.value = +(e.getState("pathtracer:backdrop") === "color"), this._kernels[0].dispatchSize = [
1302
+ let i = Math.min(Fa, Math.ceil(n / Sa)), a = Math.min(Fa, Math.ceil(r / Sa)), o = Math.min(Ia, Math.ceil(n / ka)), s = Math.min(Ia, Math.ceil(r / ka)), c = Math.log2(Math.max(this.renderer.toneMappingExposure, 1e-6));
1303
+ return this._inputNode.value = t, this._widthU.value = n, this._heightU.value = r, this._cellsXU.value = i, this._blurWU.value = o, this._blurHU.value = s, this._radiusU.value = Math.max(1, ja / 100 * o), this._logExposureU.value = c, this._sceneOnlyU.value = +(e.getState("pathtracer:backdrop") === "color"), this._kernels[0].dispatchSize = [
1296
1304
  i,
1297
1305
  a,
1298
1306
  1
@@ -1305,10 +1313,10 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1305
1313
  Math.ceil(s / 8),
1306
1314
  1
1307
1315
  ], this.renderer.compute(this._kernels), this._params.set([
1308
- n / ha,
1309
- r / ha,
1310
1316
  n / Sa,
1311
1317
  r / Sa,
1318
+ n / ka,
1319
+ r / ka,
1312
1320
  i,
1313
1321
  a,
1314
1322
  o,
@@ -1318,7 +1326,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1318
1326
  }
1319
1327
  _writeParams() {
1320
1328
  let e = this._params;
1321
- e[9] = this.highlightContrast, e[10] = this.shadowContrast, e[11] = this.detailStrength, e[12] = Ca, e[13] = Ta;
1329
+ e[9] = this.highlightContrast, e[10] = this.shadowContrast, e[11] = this.detailStrength, e[12] = Aa, e[13] = Ma;
1322
1330
  for (let t = 0; t < 4; t++) this._p[t].value.fromArray(e, t * 4);
1323
1331
  this.onChange?.();
1324
1332
  }
@@ -1337,15 +1345,15 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1337
1345
  this.enabled !== e && (this.enabled = e, this._stale = !0, this.onChange?.());
1338
1346
  }
1339
1347
  gainNode(e, t) {
1340
- let n = Kn(this._grid.value, "vec2", Oa * Oa * $).toReadOnly(), r = Kn(this._blur.value, "float", ka * ka).toReadOnly(), [i, a, o, s] = this._p;
1348
+ let n = Kn(this._grid.value, "vec2", Fa * Fa * $).toReadOnly(), r = Kn(this._blur.value, "float", Ia * Ia).toReadOnly(), [i, a, o, s] = this._p;
1341
1349
  return Tn(([e, t]) => {
1342
- let c = zn(B(I(e, Y(...Aa, 0).xyz), Da)).min(ba).toVar(), l = zn(qn).toVar(), u = Rn(a.zw), d = t.mul(i.zw).sub(.5).clamp(J(0), J(u.sub(R(1)))).toVar(), f = Rn(In(d)).toVar(), p = f.add(R(1)).min(u.sub(R(1))).toVar(), m = d.sub(In(d)).toVar(), h = (e, t) => r.element(K(t.mul(u.x).add(e))), g = V(V(h(f.x, f.y), h(p.x, f.y), m.x), V(h(f.x, p.y), h(p.x, p.y), m.x), m.y).toVar(), _ = Rn(a.xy), v = t.mul(i.xy).sub(.5).clamp(J(0), J(_.sub(R(1)))).toVar(), y = c.add(o.x).sub(_a).div(va - _a).clamp(0, 1).mul($ - 1).toVar(), b = R(In(v.x)), x = R(In(v.y)), S = R(In(y)), C = v.x.sub(In(v.x)), w = v.y.sub(In(v.y)), T = y.sub(In(y)), E = J(0).toVar();
1350
+ let c = zn(B(I(e, Y(...La, 0).xyz), Pa)).min(Da).toVar(), l = zn(qn).toVar(), u = Rn(a.zw), d = t.mul(i.zw).sub(.5).clamp(J(0), J(u.sub(R(1)))).toVar(), f = Rn(In(d)).toVar(), p = f.add(R(1)).min(u.sub(R(1))).toVar(), m = d.sub(In(d)).toVar(), h = (e, t) => r.element(K(t.mul(u.x).add(e))), g = V(V(h(f.x, f.y), h(p.x, f.y), m.x), V(h(f.x, p.y), h(p.x, p.y), m.x), m.y).toVar(), _ = Rn(a.xy), v = t.mul(i.xy).sub(.5).clamp(J(0), J(_.sub(R(1)))).toVar(), y = c.add(o.x).sub(wa).div(Ta - wa).clamp(0, 1).mul($ - 1).toVar(), b = R(In(v.x)), x = R(In(v.y)), S = R(In(y)), C = v.x.sub(In(v.x)), w = v.y.sub(In(v.y)), T = y.sub(In(y)), E = J(0).toVar();
1343
1351
  for (let e = 0; e < 8; e++) {
1344
1352
  let t = e & 1, r = e >> 1 & 1, i = e >> 2, a = (t ? C : C.oneMinus()).mul(r ? w : w.oneMinus()).mul(i ? T : T.oneMinus()), o = b.add(R(t)).min(_.x.sub(R(1))), s = x.add(R(r)).min(_.y.sub(R(1))), c = S.add(R(i)).min(R($ - 1));
1345
1353
  E.addAssign(n.element(K(s.mul(_.x).add(o).mul(R($)).add(c))).mul(a));
1346
1354
  }
1347
- let D = V(U(E.y.mul(ga).lessThan(.001), g, E.x.div(E.y)), g, s.x).add(l).toVar(), ee = c.add(l), O = U(D.greaterThan(s.y), o.y, o.z);
1348
- return Pn(s.y.add(D.sub(s.y).mul(O)).add(ee.sub(D).mul(o.w)).sub(ee));
1355
+ let D = V(U(E.y.mul(Ca).lessThan(.001), g, E.x.div(E.y)), g, s.x).add(l).toVar(), O = c.add(l), k = U(D.greaterThan(s.y), o.y, o.z);
1356
+ return Pn(s.y.add(D.sub(s.y).mul(k)).add(O.sub(D).mul(o.w)).sub(O));
1349
1357
  })(e, t);
1350
1358
  }
1351
1359
  toneGain() {
@@ -1360,7 +1368,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1360
1368
  let r = this._params.slice(), i = () => Promise.all([this.renderer.getArrayBufferAsync(this._grid.value), this.renderer.getArrayBufferAsync(this._blur.value)]);
1361
1369
  return {
1362
1370
  key: "local-exposure",
1363
- wgsl: Pa,
1371
+ wgsl: Va,
1364
1372
  device: e.device,
1365
1373
  entries: [
1366
1374
  {
@@ -1378,7 +1386,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1378
1386
  ],
1379
1387
  cpu: async () => {
1380
1388
  let [e, t] = await i(), n = new Float32Array(e), a = new Float32Array(t);
1381
- return (e, t, i, o) => Na(r, n, a, e, t, i, o);
1389
+ return (e, t, i, o) => Ba(r, n, a, e, t, i, o);
1382
1390
  },
1383
1391
  copyTo: async (e) => {
1384
1392
  let [t, n] = await i(), a = [
@@ -1395,7 +1403,7 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1395
1403
  });
1396
1404
  return {
1397
1405
  key: "local-exposure",
1398
- wgsl: Pa,
1406
+ wgsl: Va,
1399
1407
  device: e,
1400
1408
  entries: a.map((e, t) => ({
1401
1409
  binding: t,
@@ -1413,14 +1421,14 @@ fn rayzee_gain( uv: vec2<f32>, linear: vec3<f32>, exposure: f32 ) -> f32 {
1413
1421
  for (let e of this._kernels) e.dispose();
1414
1422
  this._inputNode.dispose(), this._paramsBuffer?.destroy(), this._paramsBuffer = null;
1415
1423
  }
1416
- }, Ia = new Q(), La = new Q();
1417
- function Ra(e, t) {
1418
- return La.subVectors(e, t.position).dot(t.getWorldDirection(Ia));
1424
+ }, Ua = new Q(), Wa = new Q();
1425
+ function Ga(e, t) {
1426
+ return Wa.subVectors(e, t.position).dot(t.getWorldDirection(Ua));
1419
1427
  }
1420
- function za(e, t, n = !1) {
1421
- return n ? e.distance : Ra(e.point, t);
1428
+ function Ka(e, t, n = !1) {
1429
+ return n ? e.distance : Ga(e.point, t);
1422
1430
  }
1423
- var Ba = class extends ur {
1431
+ var qa = class extends ur {
1424
1432
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a, isGeometryOnDisk: o = null }) {
1425
1433
  super(), this.scene = e, this.isGeometryOnDisk = o, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Ar(), 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;
1426
1434
  }
@@ -1454,7 +1462,7 @@ var Ba = class extends ur {
1454
1462
  this.raycaster.setFromCamera(t, this.camera);
1455
1463
  let n = this._intersectScene();
1456
1464
  if (n.length > 0) {
1457
- let e = n[0], t = this.pathTracer?.cameraProjection?.value === Oe.equirectangular, r = za(e, this.camera, t);
1465
+ let e = n[0], t = this.pathTracer?.cameraProjection?.value === Oe.equirectangular, r = Ka(e, this.camera, t);
1458
1466
  this.showFocusPoint(e.point), this.toggleFocusMode(), this.dispatchEvent({
1459
1467
  type: "focusChanged",
1460
1468
  distance: r / this.assetLoader.getSceneScale(),
@@ -1595,7 +1603,7 @@ var Ba = class extends ur {
1595
1603
  }
1596
1604
  _intersectScene() {
1597
1605
  let e = this.camera.userData?.clipStart ?? 0;
1598
- return this.raycaster.near = e > 0 && !this.camera.isOrthographicCamera ? e / Math.max(this.raycaster.ray.direction.dot(this.camera.getWorldDirection(Ia)), 1e-4) : 0, this.isGeometryOnDisk?.() ? [] : this.raycaster.intersectObjects(this.scene.children, !0);
1606
+ return this.raycaster.near = e > 0 && !this.camera.isOrthographicCamera ? e / Math.max(this.raycaster.ray.direction.dot(this.camera.getWorldDirection(Ua)), 1e-4) : 0, this.isGeometryOnDisk?.() ? [] : this.raycaster.intersectObjects(this.scene.children, !0);
1599
1607
  }
1600
1608
  pickSurface(e, t) {
1601
1609
  return this.raycaster.setFromCamera({
@@ -1666,7 +1674,7 @@ var Ba = class extends ur {
1666
1674
  dispose() {
1667
1675
  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;
1668
1676
  }
1669
- }, Va = 8, Ha = 4, Ua = .25, Wa = _r.degToRad(89), Ga = .25, Ka = {
1677
+ }, Ja = 8, Ya = 4, Xa = .25, Za = _r.degToRad(89), Qa = .25, $a = {
1670
1678
  KeyD: [
1671
1679
  1,
1672
1680
  0,
@@ -1717,15 +1725,15 @@ var Ba = class extends ur {
1717
1725
  0,
1718
1726
  -1
1719
1727
  ]
1720
- }, qa = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", Ja = (e) => e.shiftKey ? Ha : e.altKey ? Ua : 1, Ya = { type: "change" }, Xa = { type: "start" }, Za = new Q(), Qa = new Q(), $a = new Q(), eo = new Q(), to = new Or(), no = class extends or {
1728
+ }, eo = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", to = (e) => e.shiftKey ? Ya : e.altKey ? Xa : 1, no = { type: "change" }, ro = { type: "start" }, io = new Q(), ao = new Q(), oo = new Q(), so = new Q(), co = new Or(), lo = class extends or {
1721
1729
  constructor(e, t, n) {
1722
- super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / Va, this._held = /* @__PURE__ */ new Set(), this._factor = 1, this._lastTime = 0, this._drag = null, this._onKeyDown = this._onKeyDown.bind(this), this._onKeyUp = this._onKeyUp.bind(this), this.release = this.release.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), t && this.connect(t);
1730
+ super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / Ja, this._held = /* @__PURE__ */ new Set(), this._factor = 1, this._lastTime = 0, this._drag = null, this._onKeyDown = this._onKeyDown.bind(this), this._onKeyUp = this._onKeyUp.bind(this), this.release = this.release.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), t && this.connect(t);
1723
1731
  }
1724
1732
  get active() {
1725
1733
  return this.enabled && this.orbit.enabled;
1726
1734
  }
1727
1735
  fitSpeed(e) {
1728
- this.speed = (e > 0 ? e : 1) / Va;
1736
+ this.speed = (e > 0 ? e : 1) / Ja;
1729
1737
  }
1730
1738
  connect(e) {
1731
1739
  super.connect(e);
@@ -1745,34 +1753,34 @@ var Ba = class extends ur {
1745
1753
  if (!this._held.size || !this.active) return !1;
1746
1754
  let t = 0, n = 0, r = 0;
1747
1755
  for (let e of this._held) {
1748
- let [i, a, o] = Ka[e];
1756
+ let [i, a, o] = $a[e];
1749
1757
  t += i, n += a, r += o;
1750
1758
  }
1751
1759
  if (!t && !n && !r) return !1;
1752
1760
  let i = this.object;
1753
- return Qa.set(1, 0, 0).applyQuaternion(i.quaternion), Za.crossVectors(i.up, Qa).normalize(), Qa.crossVectors(Za, i.up), $a.set(0, 0, 0).addScaledVector(Qa, t).addScaledVector(Za, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add($a), this.orbit.target.add($a), i.updateMatrixWorld(), this.dispatchEvent(Ya), !0;
1761
+ return ao.set(1, 0, 0).applyQuaternion(i.quaternion), io.crossVectors(i.up, ao).normalize(), ao.crossVectors(io, i.up), oo.set(0, 0, 0).addScaledVector(ao, t).addScaledVector(io, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(oo), this.orbit.target.add(oo), i.updateMatrixWorld(), this.dispatchEvent(no), !0;
1754
1762
  }
1755
1763
  _elapsed() {
1756
- let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, Ga);
1764
+ let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, Qa);
1757
1765
  return this._lastTime = e, t;
1758
1766
  }
1759
1767
  _look(e, t) {
1760
1768
  let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = _r.degToRad(n.fov) / (this.domElement.clientHeight || 1);
1761
- n.quaternion.premultiply(to.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(Za);
1762
- let o = Math.asin(_r.clamp(Za.dot(n.up), -1, 1)), s = _r.clamp(o + t * a, -Wa, Wa);
1763
- n.quaternion.multiply(to.setFromAxisAngle(eo.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(Za), i), this.dispatchEvent(Ya);
1769
+ n.quaternion.premultiply(co.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(io);
1770
+ let o = Math.asin(_r.clamp(io.dot(n.up), -1, 1)), s = _r.clamp(o + t * a, -Za, Za);
1771
+ n.quaternion.multiply(co.setFromAxisAngle(so.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(io), i), this.dispatchEvent(no);
1764
1772
  }
1765
1773
  _onKeyDown(e) {
1766
- if (!(!this.active || e.defaultPrevented || e.target?.closest?.(qa))) {
1774
+ if (!(!this.active || e.defaultPrevented || e.target?.closest?.(eo))) {
1767
1775
  if (e.metaKey || e.ctrlKey) {
1768
1776
  this.release();
1769
1777
  return;
1770
1778
  }
1771
- this._factor = Ja(e), Ka[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(Xa))));
1779
+ this._factor = to(e), $a[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(ro))));
1772
1780
  }
1773
1781
  }
1774
1782
  _onKeyUp(e) {
1775
- this._factor = Ja(e), this._held.delete(e.code);
1783
+ this._factor = to(e), this._held.delete(e.code);
1776
1784
  }
1777
1785
  release() {
1778
1786
  this._held.clear(), this._factor = 1;
@@ -1793,18 +1801,18 @@ var Ba = class extends ur {
1793
1801
  _onPointerUp(e) {
1794
1802
  this._drag?.id === e.pointerId && (this._drag = null, this.domElement.releasePointerCapture?.(e.pointerId));
1795
1803
  }
1796
- }, ro = {
1804
+ }, uo = {
1797
1805
  autoFocusMode: "auto",
1798
1806
  afScreenPoint: {
1799
1807
  x: .5,
1800
1808
  y: .5
1801
1809
  },
1802
1810
  afSmoothingFactor: .15
1803
- }, io = .05, ao = 10, oo = .5, so = Object.freeze(new Q(1, 1, 1)), co = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, lo = class extends ur {
1811
+ }, fo = .05, po = 10, mo = .5, ho = Object.freeze(new Q(1, 1, 1)), go = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, _o = class extends ur {
1804
1812
  constructor(e) {
1805
1813
  super();
1806
1814
  let t = e.clientWidth, n = e.clientHeight;
1807
- this.camera = new g(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Vr(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this._reportedOrthoHeight = null, this._reportOrthoHeight = this._reportOrthoHeight.bind(this), this.controls.addEventListener("change", this._reportOrthoHeight), this.walkControls = new no(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = ro.autoFocusMode, this.afScreenPoint = { ...ro.afScreenPoint }, this.afSmoothingFactor = ro.afSmoothingFactor, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._afSuspended = !1, this._afPick = null, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null, this._applySettings = null;
1815
+ this.camera = new g(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Vr(this.camera, e), this.controls.screenSpacePanning = !0, this.controls.zoomToCursor = !0, this.controls.saveState(), this._reportedOrthoHeight = null, this._reportOrthoHeight = this._reportOrthoHeight.bind(this), this.controls.addEventListener("change", this._reportOrthoHeight), this.walkControls = new lo(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = uo.autoFocusMode, this.afScreenPoint = { ...uo.afScreenPoint }, this.afSmoothingFactor = uo.afSmoothingFactor, this._lastValidFocusDistance = null, this._smoothedFocusDistance = null, this._afPointDirty = !1, this._afSuspended = !1, this._afPick = null, this._defaultCameraState = null, this._onResize = null, this._onReset = null, this._getSettings = null, this._applySettings = null;
1808
1816
  }
1809
1817
  setCameras(e) {
1810
1818
  this.cameras = e, this._userCameraCounter = 0, this.camera.userData.clipStart = 0, this.resetAutoFocus();
@@ -1864,11 +1872,11 @@ var Ba = class extends ur {
1864
1872
  target: this.controls ? this.controls.target.clone() : null
1865
1873
  }), this.currentCameraIndex = e, e === 0 && this._defaultCameraState) {
1866
1874
  let e = this._defaultCameraState;
1867
- this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ?? so), this.camera.fov = e.fov, this.camera.near = e.near, this.camera.far = e.far, this.camera.userData.clipStart = 0, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls && e.target && (this.controls.target.copy(e.target), this.controls.update());
1875
+ this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ?? ho), this.camera.fov = e.fov, this.camera.near = e.near, this.camera.far = e.far, this.camera.userData.clipStart = 0, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls && e.target && (this.controls.target.copy(e.target), this.controls.update());
1868
1876
  } else this._placeAt(this.cameras[e], t);
1869
1877
  this.resetAutoFocus();
1870
1878
  let a = this.cameras[e], o = a?.userData?.__rayzeeEffects;
1871
- this._showOrthographic(o ? o.orthoHeight : co(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
1879
+ this._showOrthographic(o ? o.orthoHeight : go(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
1872
1880
  type: P.CAMERA_SWITCHED,
1873
1881
  cameraIndex: e,
1874
1882
  effects: this._captureEffects(),
@@ -1883,7 +1891,7 @@ var Ba = class extends ur {
1883
1891
  return;
1884
1892
  }
1885
1893
  this._placeAt(e, this._getSettings?.("focusDistance"));
1886
- let t = co(e);
1894
+ let t = go(e);
1887
1895
  this.camera.orthographic && this._setView(!0, t ? t / 2 : this.camera.orthoHalfHeight), this._onReset?.();
1888
1896
  }
1889
1897
  _placeAt(e, t) {
@@ -1913,7 +1921,7 @@ var Ba = class extends ur {
1913
1921
  }
1914
1922
  }
1915
1923
  get orthoHeight() {
1916
- return co(this.camera);
1924
+ return go(this.camera);
1917
1925
  }
1918
1926
  setOrthoHeight(e) {
1919
1927
  e > 0 && (this._setView(this.camera.orthographic, e / 2), this._onReset?.());
@@ -2038,7 +2046,7 @@ var Ba = class extends ur {
2038
2046
  for (let r of e.cameras ?? []) {
2039
2047
  if (r.user) {
2040
2048
  let e = r.orthographic ? new Tr(...r.frustum, r.near, r.far) : new Er(r.fov, r.aspect, r.near, r.far);
2041
- e.name = r.name, e.zoom = r.zoom ?? 1, e.position.fromArray(r.position), e.quaternion.fromArray(r.quaternion), e.scale.fromArray(r.scale), e.updateProjectionMatrix(), e.updateMatrixWorld(!0), e.userData.__rayzeeUserCamera = !0, e.userData.__rayzeeEffects = le(r.effects), r.clipStart > 0 && (e.userData.clipStart = r.clipStart), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new Q().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2049
+ e.name = r.name, e.zoom = r.zoom ?? 1, e.position.fromArray(r.position), e.quaternion.fromArray(r.quaternion), e.scale.fromArray(r.scale), e.updateProjectionMatrix(), e.updateMatrixWorld(!0), e.userData.__rayzeeUserCamera = !0, e.userData.__rayzeeEffects = ce(r.effects), r.clipStart > 0 && (e.userData.clipStart = r.clipStart), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new Q().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2042
2050
  continue;
2043
2051
  }
2044
2052
  let e = this.cameras[r.index];
@@ -2046,7 +2054,7 @@ var Ba = class extends ur {
2046
2054
  t.push(r.name);
2047
2055
  continue;
2048
2056
  }
2049
- n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = le(r.effects));
2057
+ n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = ce(r.effects));
2050
2058
  }
2051
2059
  this._userCameraCounter = this.cameras.filter((e) => e.userData?.__rayzeeUserCamera).length, this.currentCameraIndex = n.get(e.current) ?? 0;
2052
2060
  let r = e.defaultView;
@@ -2109,14 +2117,14 @@ var Ba = class extends ur {
2109
2117
  let c = i;
2110
2118
  if (c?.isReady && c.renderMode?.value === 1 && c.frameCount > 0 && !c.isComplete) return;
2111
2119
  let l = this._pickFocusPoint(c.resetCount), u;
2112
- if (l) u = Ra(l, this.camera), this._lastValidFocusDistance = u;
2120
+ if (l) u = Ga(l, this.camera), this._lastValidFocusDistance = u;
2113
2121
  else if (this._lastValidFocusDistance !== null) u = this._lastValidFocusDistance;
2114
2122
  else {
2115
- let e = this.controls ? Ra(this.controls.target, this.camera) : 0;
2116
- u = e > 0 ? e : ao * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2123
+ let e = this.controls ? Ga(this.controls.target, this.camera) : 0;
2124
+ u = e > 0 ? e : po * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2117
2125
  }
2118
2126
  let d = this._afPointDirty;
2119
- this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > oo ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2127
+ this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > mo ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2120
2128
  let f = r, p = this._smoothedFocusDistance;
2121
2129
  if (d || f === 0 || Math.abs(p - f) / Math.max(f, .001) > .001) {
2122
2130
  a(p);
@@ -2127,7 +2135,7 @@ var Ba = class extends ur {
2127
2135
  worldDistance: p
2128
2136
  });
2129
2137
  let t = Math.abs(p - f) / Math.max(f, .001);
2130
- d ? s?.() : t > io && o?.();
2138
+ d ? s?.() : t > fo && o?.();
2131
2139
  }
2132
2140
  }
2133
2141
  _pickFocusPoint(e) {
@@ -2161,7 +2169,7 @@ var Ba = class extends ur {
2161
2169
  dispose() {
2162
2170
  this.walkControls?.dispose(), this.controls?.removeEventListener("change", this._reportOrthoHeight), this.controls?.dispose();
2163
2171
  }
2164
- }, uo = .001, fo = 2, po = (e, t, n, r) => new e(t, n, r, pr).createInterpolant(), mo = class {
2172
+ }, vo = .001, yo = 2, bo = (e, t, n, r) => new e(t, n, r, pr).createInterpolant(), xo = class {
2165
2173
  constructor(e, t) {
2166
2174
  this._cameraManager = e, this._onChange = t, this.keys = [], this._nextId = 1, this._interpolants = null;
2167
2175
  }
@@ -2171,7 +2179,7 @@ var Ba = class extends ur {
2171
2179
  get duration() {
2172
2180
  return this.keys.length ? this.keys[this.keys.length - 1].time : 0;
2173
2181
  }
2174
- addKey(e = this.keys.length ? this.duration + fo : 0) {
2182
+ addKey(e = this.keys.length ? this.duration + yo : 0) {
2175
2183
  return this.add(this._cameraManager.captureView(), e);
2176
2184
  }
2177
2185
  updateKey(e) {
@@ -2185,13 +2193,13 @@ var Ba = class extends ur {
2185
2193
  let n = {
2186
2194
  id: this._nextId++,
2187
2195
  time: t,
2188
- ...ho(e)
2196
+ ...So(e)
2189
2197
  };
2190
2198
  return this.keys.push(n), this._changed(), n;
2191
2199
  }
2192
2200
  update(e, t) {
2193
2201
  let n = this.get(e);
2194
- n && (Object.assign(n, ho(t)), this._changed());
2202
+ n && (Object.assign(n, So(t)), this._changed());
2195
2203
  }
2196
2204
  setTime(e, t) {
2197
2205
  let n = this.get(e);
@@ -2241,7 +2249,7 @@ var Ba = class extends ur {
2241
2249
  }
2242
2250
  _build() {
2243
2251
  let e = [];
2244
- for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] + uo) : t.time);
2252
+ for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] + vo) : t.time);
2245
2253
  let t = e[0], n = e[e.length - 1], r = this.keys;
2246
2254
  if (r.length > 1) {
2247
2255
  let i = r.length;
@@ -2255,17 +2263,17 @@ var Ba = class extends ur {
2255
2263
  return {
2256
2264
  start: t,
2257
2265
  end: n,
2258
- position: po(Br, ".position", e, i((e) => e.position)),
2259
- target: po(Br, ".target", e, i((e) => e.target)),
2260
- fov: po(Cr, ".fov", e, r.map((e) => e.fov)),
2261
- logHeight: po(Cr, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2266
+ position: bo(Br, ".position", e, i((e) => e.position)),
2267
+ target: bo(Br, ".target", e, i((e) => e.target)),
2268
+ fov: bo(Cr, ".fov", e, r.map((e) => e.fov)),
2269
+ logHeight: bo(Cr, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2262
2270
  };
2263
2271
  }
2264
2272
  _changed() {
2265
2273
  this.keys.sort((e, t) => e.time - t.time), this._interpolants = null, this._onChange?.();
2266
2274
  }
2267
2275
  };
2268
- function ho({ position: e, target: t, fov: n, orthoHeight: r }) {
2276
+ function So({ position: e, target: t, fov: n, orthoHeight: r }) {
2269
2277
  return {
2270
2278
  position: e.clone(),
2271
2279
  target: t.clone(),
@@ -2275,9 +2283,9 @@ function ho({ position: e, target: t, fov: n, orthoHeight: r }) {
2275
2283
  }
2276
2284
  //#endregion
2277
2285
  //#region src/managers/timeline/TimelineManager.js
2278
- var go = class extends ur {
2286
+ var Co = class extends ur {
2279
2287
  constructor({ cameraManager: e, onReset: t }) {
2280
- super(), this._cameraManager = e, this._onReset = t, this.camera = new mo(e, () => this._changed("camera")), this._playback = null, this._timer = new Fr(), typeof document < "u" && this._timer.connect(document);
2288
+ super(), this._cameraManager = e, this._onReset = t, this.camera = new xo(e, () => this._changed("camera")), this._playback = null, this._timer = new Fr(), typeof document < "u" && this._timer.connect(document);
2281
2289
  }
2282
2290
  get duration() {
2283
2291
  return this.camera.duration;
@@ -2330,14 +2338,14 @@ var go = class extends ur {
2330
2338
  track: e
2331
2339
  });
2332
2340
  }
2333
- }, _o = class {
2341
+ }, wo = class {
2334
2342
  constructor(e, t = {}) {
2335
2343
  this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._size = 256;
2336
2344
  }
2337
2345
  async loadLibrary(e, { size: t = 256 } = {}) {
2338
2346
  if (!Array.isArray(e) || e.length === 0) return [];
2339
2347
  this._size = t;
2340
- let n = await Promise.all(e.map((e) => vo(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
2348
+ let n = await Promise.all(e.map((e) => To(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
2341
2349
  s.width = r, s.height = i;
2342
2350
  let c = s.getContext("2d", { willReadFrequently: !0 }), l = performance.now();
2343
2351
  for (let e = 0; e < a; e++) {
@@ -2369,7 +2377,7 @@ var go = class extends ur {
2369
2377
  o.userData.gobo = {
2370
2378
  name: e.name,
2371
2379
  index: e.index,
2372
- intensity: yo(r),
2380
+ intensity: Eo(r),
2373
2381
  inverted: !!i,
2374
2382
  scale: Math.max(1e-4, a)
2375
2383
  };
@@ -2411,7 +2419,7 @@ var go = class extends ur {
2411
2419
  return t && t.isSpotLight ? t : null;
2412
2420
  }
2413
2421
  };
2414
- async function vo(e) {
2422
+ async function To(e) {
2415
2423
  let t = await _(e);
2416
2424
  try {
2417
2425
  return await new Promise((n, r) => {
@@ -2422,22 +2430,22 @@ async function vo(e) {
2422
2430
  t.release();
2423
2431
  }
2424
2432
  }
2425
- function yo(e) {
2433
+ function Eo(e) {
2426
2434
  return Math.max(0, Math.min(1, e));
2427
2435
  }
2428
2436
  //#endregion
2429
2437
  //#region src/Processor/IESParser.js
2430
- function bo(e, t = "ies") {
2438
+ function Do(e, t = "ies") {
2431
2439
  let n = e.search(/TILT\s*=/i);
2432
2440
  if (n < 0) throw Error(`IES (${t}): missing TILT line`);
2433
2441
  let r = e.indexOf("\n", n);
2434
2442
  if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
2435
2443
  let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
2436
2444
  if (a === "INCLUDE") {
2437
- let e = To(o), t = 2 + 2 * Number(e[1]);
2438
- o = Eo(o, t);
2445
+ let e = Mo(o), t = 2 + 2 * Number(e[1]);
2446
+ o = No(o, t);
2439
2447
  }
2440
- let s = To(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
2448
+ let s = Mo(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
2441
2449
  l(), l(), l(), l();
2442
2450
  let g = l();
2443
2451
  if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
@@ -2463,34 +2471,34 @@ function bo(e, t = "ies") {
2463
2471
  name: t
2464
2472
  };
2465
2473
  }
2466
- function xo(e, t, n) {
2474
+ function Oo(e, t, n) {
2467
2475
  if (t === 0 && n === 90) {
2468
2476
  let t = e % 180;
2469
2477
  return t > 90 ? 180 - t : t;
2470
2478
  }
2471
2479
  return t === 0 && n === 180 ? e > 180 ? 360 - e : e : t === 90 && n === 270 ? e >= 90 && e <= 270 ? e : (540 - e) % 360 : e;
2472
2480
  }
2473
- function So(e, t, n) {
2481
+ function ko(e, t, n) {
2474
2482
  let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s, photometricType: c } = e;
2475
2483
  if (s <= 0) return r;
2476
2484
  let l = c === void 0 || c === 1, u = i[0], d = i[i.length - 1], f = a[0], p = a[a.length - 1], m = a.length === 1 || p === f, h = (e, t, n, r) => {
2477
- if (m) return Oo(o[e][0], o[t][0], n);
2485
+ if (m) return Fo(o[e][0], o[t][0], n);
2478
2486
  if (r < f || r > p) return 0;
2479
- let i = Do(a, r), s = Math.min(i + 1, a.length - 1), c = a[s] - a[i], l = c > 0 ? (r - a[i]) / c : 0;
2480
- return Oo(Oo(o[e][i], o[e][s], l), Oo(o[t][i], o[t][s], l), n);
2487
+ let i = Po(a, r), s = Math.min(i + 1, a.length - 1), c = a[s] - a[i], l = c > 0 ? (r - a[i]) / c : 0;
2488
+ return Fo(Fo(o[e][i], o[e][s], l), Fo(o[t][i], o[t][s], l), n);
2481
2489
  };
2482
2490
  for (let e = 0; e < n; e++) {
2483
2491
  let a = (e + .5) / n, o = l ? a * 180 : u + a * (d - u);
2484
2492
  if (o < u || o > d) continue;
2485
- let c = Do(i, o), m = Math.min(c + 1, i.length - 1), g = i[m] - i[c], _ = g > 0 ? (o - i[c]) / g : 0;
2493
+ let c = Po(i, o), m = Math.min(c + 1, i.length - 1), g = i[m] - i[c], _ = g > 0 ? (o - i[c]) / g : 0;
2486
2494
  for (let n = 0; n < t; n++) {
2487
- let i = (n + .5) / t, a = l ? xo(i * 360, f, p) : f + i * (p - f), o = Math.min(1, Math.max(0, h(c, m, _, a) / s));
2495
+ let i = (n + .5) / t, a = l ? Oo(i * 360, f, p) : f + i * (p - f), o = Math.min(1, Math.max(0, h(c, m, _, a) / s));
2488
2496
  r[e * t + n] = Math.round(o * 255);
2489
2497
  }
2490
2498
  }
2491
2499
  return r;
2492
2500
  }
2493
- function Co(e, t = .1) {
2501
+ function Ao(e, t = .1) {
2494
2502
  let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
2495
2503
  if (a <= 0 || !n?.length) return o;
2496
2504
  let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
@@ -2505,7 +2513,7 @@ function Co(e, t = .1) {
2505
2513
  let d = l * Math.PI / 180;
2506
2514
  return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
2507
2515
  }
2508
- function wo(e, t, n = .7) {
2516
+ function jo(e, t, n = .7) {
2509
2517
  let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
2510
2518
  if (o <= 0 || !r?.length || t <= 0) return 0;
2511
2519
  let s = o * n, c = i.length, l = 0;
@@ -2518,15 +2526,15 @@ function wo(e, t, n = .7) {
2518
2526
  let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
2519
2527
  return Math.min(Math.max(d, 0), 1);
2520
2528
  }
2521
- function To(e) {
2529
+ function Mo(e) {
2522
2530
  return e.split(/\s+/).filter((e) => e.length > 0);
2523
2531
  }
2524
- function Eo(e, t) {
2532
+ function No(e, t) {
2525
2533
  let n = /\S+/g, r = 0;
2526
2534
  for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
2527
2535
  return "";
2528
2536
  }
2529
- function Do(e, t) {
2537
+ function Po(e, t) {
2530
2538
  if (t <= e[0]) return 0;
2531
2539
  if (t >= e[e.length - 1]) return e.length - 1;
2532
2540
  let n = 0, r = e.length - 1;
@@ -2536,12 +2544,12 @@ function Do(e, t) {
2536
2544
  }
2537
2545
  return n;
2538
2546
  }
2539
- function Oo(e, t, n) {
2547
+ function Fo(e, t, n) {
2540
2548
  return e + (t - e) * n;
2541
2549
  }
2542
2550
  //#endregion
2543
2551
  //#region src/managers/IESManager.js
2544
- var ko = class {
2552
+ var Io = class {
2545
2553
  constructor(e, t = {}) {
2546
2554
  this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
2547
2555
  }
@@ -2550,11 +2558,11 @@ var ko = class {
2550
2558
  this._gridWidth = t, this._gridHeight = n;
2551
2559
  let r = (await Promise.all(e.map(async (e) => {
2552
2560
  try {
2553
- let { file: r, release: i } = await p().fetch(e.url), a = bo(await r.text().finally(i), e.name);
2561
+ let { file: r, release: i } = await p().fetch(e.url), a = Do(await r.text().finally(i), e.name);
2554
2562
  return {
2555
2563
  it: e,
2556
2564
  profile: a,
2557
- grid: So(a, t, n)
2565
+ grid: ko(a, t, n)
2558
2566
  };
2559
2567
  } catch (t) {
2560
2568
  return this._issues?.warn(Ye.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
@@ -2572,14 +2580,14 @@ var ko = class {
2572
2580
  let r = t[e];
2573
2581
  o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
2574
2582
  }
2575
- let i = r[e].profile, c = Co(i);
2583
+ let i = r[e].profile, c = Ao(i);
2576
2584
  s.push({
2577
2585
  name: r[e].it.name,
2578
2586
  index: e,
2579
2587
  maxCandela: i.maxCandela,
2580
2588
  photometricType: i.photometricType,
2581
2589
  suggestedAngle: c,
2582
- suggestedPenumbra: wo(i, c),
2590
+ suggestedPenumbra: jo(i, c),
2583
2591
  lumens: i.lumens
2584
2592
  });
2585
2593
  }
@@ -2615,7 +2623,7 @@ var ko = class {
2615
2623
  l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
2616
2624
  name: e.name,
2617
2625
  index: e.index,
2618
- intensity: Ao(n),
2626
+ intensity: Lo(n),
2619
2627
  fixtureLumens: l
2620
2628
  }, 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);
2621
2629
  }
@@ -2638,24 +2646,24 @@ var ko = class {
2638
2646
  return t && t.isSpotLight ? t : null;
2639
2647
  }
2640
2648
  };
2641
- function Ao(e) {
2649
+ function Lo(e) {
2642
2650
  return Math.max(0, Math.min(1, e));
2643
2651
  }
2644
2652
  //#endregion
2645
2653
  //#region src/Passes/OIDNDenoiser.js
2646
- var jo = We("oidn"), Mo = 16, No = 16;
2647
- function Po(e, t) {
2648
- let n = (e) => Math.ceil((e + 2 * No) / Mo) * Mo;
2654
+ var Ro = We("oidn"), zo = 16, Bo = 16;
2655
+ function Vo(e, t) {
2656
+ let n = (e) => Math.ceil((e + 2 * Bo) / zo) * zo;
2649
2657
  return {
2650
2658
  width: n(e),
2651
2659
  height: n(t)
2652
2660
  };
2653
2661
  }
2654
- var Fo = null;
2655
- async function Io() {
2656
- return Fo ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, Fo;
2662
+ var Ho = null;
2663
+ async function Uo() {
2664
+ return Ho ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, Ho;
2657
2665
  }
2658
- var Lo = {
2666
+ var Wo = {
2659
2667
  QUALITY_MODELS: {
2660
2668
  fast: {
2661
2669
  model: "rt_hdr_alb_nrm_small",
@@ -2679,9 +2687,9 @@ var Lo = {
2679
2687
  oidnQuality: "fast",
2680
2688
  tileSize: 1024
2681
2689
  }
2682
- }, Ro = .18, zo = 256, Bo = 256, Vo = `
2683
- const WG: u32 = ${zo}u;
2684
- const GROUPS: u32 = ${Bo}u;
2690
+ }, Go = .18, Ko = 256, qo = 256, Jo = `
2691
+ const WG: u32 = ${Ko}u;
2692
+ const GROUPS: u32 = ${qo}u;
2685
2693
 
2686
2694
  @group(0) @binding(0) var<storage, read> col: array<vec4<f32>>;
2687
2695
  @group(0) @binding(1) var<storage, read_write> partials: array<f32>;
@@ -2700,7 +2708,7 @@ fn treeSum( lid: u32 ) {
2700
2708
  }
2701
2709
  }
2702
2710
 
2703
- @compute @workgroup_size(${zo})
2711
+ @compute @workgroup_size(${Ko})
2704
2712
  fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
2705
2713
  @builtin(local_invocation_id) lid: vec3<u32>,
2706
2714
  @builtin(workgroup_id) wid: vec3<u32> ) {
@@ -2724,7 +2732,7 @@ fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
2724
2732
  if ( lid.x == 0u ) { partials[ wid.x ] = sdata[ 0 ]; }
2725
2733
  }
2726
2734
 
2727
- @compute @workgroup_size(${zo})
2735
+ @compute @workgroup_size(${Ko})
2728
2736
  fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
2729
2737
 
2730
2738
  var v = 0.0;
@@ -2734,12 +2742,12 @@ fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
2734
2742
  treeSum( lid.x );
2735
2743
 
2736
2744
  if ( lid.x == 0u ) {
2737
- let scale = ${Ro} / exp2( sdata[ 0 ] / f32( params.x ) );
2745
+ let scale = ${Go} / exp2( sdata[ 0 ] / f32( params.x ) );
2738
2746
  // Mirrors the CPU guard: a non-finite or non-positive scale means no scaling at all.
2739
2747
  scaleOut[ 0 ] = select( 1.0, scale, scale > 0.0 && scale < 3.4e38 );
2740
2748
  }
2741
2749
  }
2742
- `, Ho = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read> scaleBuf: array<f32>;\n\n@compute @workgroup_size(64)\nfn main( @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(num_workgroups) nwg: vec3<u32> ) {\n let i = gid.y * nwg.x * 64u + gid.x;\n if ( i >= arrayLength( &col ) ) { return; }\n let c = col[ i ];\n col[ i ] = vec4<f32>( c.xyz * scaleBuf[ 0 ], c.w );\n}\n", Uo = 64, Wo = 32768, Go = 16, Ko = 32, qo = `
2750
+ `, Yo = "\n@group(0) @binding(0) var<storage, read_write> col: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read> scaleBuf: array<f32>;\n\n@compute @workgroup_size(64)\nfn main( @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(num_workgroups) nwg: vec3<u32> ) {\n let i = gid.y * nwg.x * 64u + gid.x;\n if ( i >= arrayLength( &col ) ) { return; }\n let c = col[ i ];\n col[ i ] = vec4<f32>( c.xyz * scaleBuf[ 0 ], c.w );\n}\n", Xo = 64, Zo = 32768, Qo = 16, $o = 32, es = `
2743
2751
  struct UnpackParams {
2744
2752
  srcWidth: u32,
2745
2753
  tileX: u32,
@@ -2757,7 +2765,7 @@ struct UnpackParams {
2757
2765
  @group(0) @binding(3) var<storage, read> inColor: array<vec4<f32>>;
2758
2766
  @group(0) @binding(4) var dst: texture_storage_2d<rgba16float, write>;
2759
2767
 
2760
- @compute @workgroup_size(${Go}, ${Go})
2768
+ @compute @workgroup_size(${Qo}, ${Qo})
2761
2769
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2762
2770
 
2763
2771
  if ( gid.x >= P.tileW || gid.y >= P.tileH ) { return; }
@@ -2771,7 +2779,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2771
2779
  // survives the denoise.
2772
2780
  textureStore( dst, vec2<u32>( px, py ), vec4<f32>( src[ si ].xyz / scaleBuf[ 0 ], inColor[ si ].w ) );
2773
2781
  }
2774
- `, Jo = 8, Yo = `
2782
+ `, ts = 8, ns = `
2775
2783
  @group(0) @binding(0) var src: texture_2d<f32>;
2776
2784
  @group(0) @binding(1) var<storage, read_write> dst: array<vec4<f32>>;
2777
2785
  @group(0) @binding(2) var<uniform> size: vec4<u32>; // buffer w, h; frame w, h
@@ -2781,15 +2789,15 @@ fn mirror( i: i32, n: i32 ) -> i32 {
2781
2789
  return clamp( select( m, 2 * n - 2 - m, m >= n ), 0, n - 1 );
2782
2790
  }
2783
2791
 
2784
- @compute @workgroup_size(${Jo}, ${Jo})
2792
+ @compute @workgroup_size(${ts}, ${ts})
2785
2793
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2786
2794
 
2787
2795
  if ( gid.x >= size.x || gid.y >= size.y ) { return; }
2788
- let p = vec2<i32>( gid.xy ) - ${No};
2796
+ let p = vec2<i32>( gid.xy ) - ${Bo};
2789
2797
  let s = vec2<i32>( mirror( p.x, i32( size.z ) ), mirror( p.y, i32( size.w ) ) );
2790
2798
  dst[ gid.y * size.x + gid.x ] = textureLoad( src, s, 0 );
2791
2799
  }
2792
- `, Xo = class extends ur {
2800
+ `, rs = class extends ur {
2793
2801
  constructor(e, t = {}) {
2794
2802
  if (super(), !e) throw Error("OIDNDenoiser requires a renderer");
2795
2803
  this.renderer = e, this._renderWidth = e.domElement.width, this._renderHeight = e.domElement.height, this.backendParamsGetter = t.backendParams || null, this.getGPUTextures = t.getGPUTextures || null, this.gpuDevice = null, this._gpuInputBuffers = {
@@ -2803,14 +2811,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2803
2811
  width: 0,
2804
2812
  height: 0
2805
2813
  }, this.config = {
2806
- ...Lo.DEFAULT_OPTIONS,
2814
+ ...Wo.DEFAULT_OPTIONS,
2807
2815
  ...t
2808
2816
  }, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.maxTileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
2809
2817
  isDenoising: !1,
2810
2818
  isLoading: !1,
2811
2819
  abortController: null
2812
2820
  }, this._tilesWritten = 0, this._runId = 0, this._hasOutput = !1, this.lastDenoiseMs = 0, this.currentTZAUrl = null, this.unet = null, this._weights = /* @__PURE__ */ new Map(), this._pendingStart = !1, this._pendingStartContinuous = !1, this._reloadPending = !1, this._initialize().catch((e) => {
2813
- jo.error("init failed:", e), this.dispatchEvent({
2821
+ Ro.error("init failed:", e), this.dispatchEvent({
2814
2822
  type: "error",
2815
2823
  error: e
2816
2824
  });
@@ -2824,7 +2832,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2824
2832
  }
2825
2833
  }
2826
2834
  expectsCleanAux(e = this.quality) {
2827
- let { QUALITY_MODELS: t } = Lo;
2835
+ let { QUALITY_MODELS: t } = Wo;
2828
2836
  return (t[e] || t.balance).cleanAux;
2829
2837
  }
2830
2838
  getRuntimeInfo() {
@@ -2838,8 +2846,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2838
2846
  }
2839
2847
  _resolveTileSize() {
2840
2848
  if (!this._renderWidth || !this._renderHeight) return this.maxTileSize;
2841
- let e = Po(this._renderWidth, this._renderHeight), t = Po(this.maxTileSize, this.maxTileSize);
2842
- return e.width * e.height <= t.width * t.height ? Math.max(e.width, e.height) : Math.max(Mo, Math.floor(this.maxTileSize / Mo) * Mo);
2849
+ let e = Vo(this._renderWidth, this._renderHeight), t = Vo(this.maxTileSize, this.maxTileSize);
2850
+ return e.width * e.height <= t.width * t.height ? Math.max(e.width, e.height) : Math.max(zo, Math.floor(this.maxTileSize / zo) * zo);
2843
2851
  }
2844
2852
  _setupUNetDenoiser() {
2845
2853
  return this.state.isLoading ? (this._reloadPending = !0, Promise.resolve()) : (this._loading = this._loadUNet(), this._loading);
@@ -2853,7 +2861,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2853
2861
  try {
2854
2862
  await this._loadUNetWeights();
2855
2863
  } catch (e) {
2856
- jo.error("UNet weights failed to load:", e), this.dispatchEvent({
2864
+ Ro.error("UNet weights failed to load:", e), this.dispatchEvent({
2857
2865
  type: "error",
2858
2866
  error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`),
2859
2867
  url: this._generateTzaUrl()
@@ -2879,26 +2887,26 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2879
2887
  let e = this.backendParamsGetter();
2880
2888
  this.gpuDevice = e?.device ?? null, n = e?.device ? { device: e.device } : void 0;
2881
2889
  }
2882
- this.unet = await (await Io())(await this._fetchWeights(e), n, {
2890
+ this.unet = await (await Uo())(await this._fetchWeights(e), n, {
2883
2891
  aux: !0,
2884
2892
  hdr: !0,
2885
2893
  maxTileSize: t,
2886
2894
  dynamicTile: !1
2887
- }), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), jo.debug("UNet weights loaded:", e);
2895
+ }), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), Ro.debug("UNet weights loaded:", e);
2888
2896
  }
2889
2897
  _fetchWeights(e) {
2890
2898
  let t = this._weights.get(e);
2891
2899
  return t || (t = p().fetch(e, { policy: C.IMMUTABLE }).then(({ file: e, release: t }) => e.arrayBuffer().finally(t)), t.catch(() => this._weights.delete(e)), this._weights.set(e, t)), t;
2892
2900
  }
2893
2901
  _generateTzaUrl() {
2894
- let { oidnWeightsBaseUrl: e } = it(), { QUALITY_MODELS: t } = Lo;
2902
+ let { oidnWeightsBaseUrl: e } = it(), { QUALITY_MODELS: t } = Wo;
2895
2903
  return `${e}${(t[this.quality] || t.balance).model}.tza`;
2896
2904
  }
2897
2905
  async updateConfiguration(e) {
2898
2906
  Object.keys(e).some((t) => this.config[t] !== e[t]) && (Object.assign(this.config, e), this.quality = this.config.oidnQuality, this.maxTileSize = this.config.tileSize, await this._setupUNetDenoiser());
2899
2907
  }
2900
2908
  async updateQuality(e) {
2901
- if (!Object.prototype.hasOwnProperty.call(Lo.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Lo.QUALITY_MODELS).join(", ")}`);
2909
+ if (!Object.prototype.hasOwnProperty.call(Wo.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(Wo.QUALITY_MODELS).join(", ")}`);
2902
2910
  await this.updateConfiguration({ oidnQuality: e });
2903
2911
  }
2904
2912
  async start({ continuous: e = !1 } = {}) {
@@ -2909,7 +2917,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2909
2917
  continuous: e
2910
2918
  });
2911
2919
  let t = performance.now(), n = await this.execute(e);
2912
- return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, jo.debug(`denoise complete in ${He.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
2920
+ return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Ro.debug(`denoise complete in ${He.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
2913
2921
  }
2914
2922
  async execute(e = !1) {
2915
2923
  let t = ++this._runId;
@@ -2917,7 +2925,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2917
2925
  try {
2918
2926
  return !this.enabled || !this.unet ? !1 : await this._executeUNetGPU(e) !== !1;
2919
2927
  } catch (e) {
2920
- return e.name === "AbortError" ? jo.debug("denoise aborted") : jo.error("denoise error:", e), !1;
2928
+ return e.name === "AbortError" ? Ro.debug("denoise aborted") : Ro.error("denoise error:", e), !1;
2921
2929
  } finally {
2922
2930
  this._runId === t && (this.state.isDenoising = !1, this.state.abortController = null), this.dispatchEvent({
2923
2931
  type: "end",
@@ -2927,13 +2935,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2927
2935
  }
2928
2936
  async _executeUNetGPU(e = !1) {
2929
2937
  let t = this._renderWidth, n = this._renderHeight;
2930
- if (!this.getGPUTextures) return jo.warn("GPU mode enabled but getGPUTextures not provided"), !1;
2938
+ if (!this.getGPUTextures) return Ro.warn("GPU mode enabled but getGPUTextures not provided"), !1;
2931
2939
  let r = this.getGPUTextures({ continuous: e });
2932
- if (!r?.color) return jo.warn("GPU textures not ready yet"), !1;
2940
+ if (!r?.color) return Ro.warn("GPU textures not ready yet"), !1;
2933
2941
  let i = this.gpuDevice;
2934
- if (!i) return jo.warn("gpuDevice not available"), !1;
2942
+ if (!i) return Ro.warn("gpuDevice not available"), !1;
2935
2943
  this._ensureGPUInputBuffers(t, n), this._copyInputs(i, r, t, n);
2936
- let a = Po(t, n);
2944
+ let a = Vo(t, n);
2937
2945
  this._computeInputScale(i, t, n), this._applyColorScale(i, a.width * a.height), !e && !this._hasOutput && this._unpackToTexture(this._gpuInputBuffers.color, {
2938
2946
  x: 0,
2939
2947
  y: 0,
@@ -2952,7 +2960,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2952
2960
  return this._executeWithAbortGPU(s, e);
2953
2961
  }
2954
2962
  _copyInputs(e, t, n, r) {
2955
- let i = Po(n, r), a = e.createCommandEncoder({ label: "oidn-tex-to-buf" }), o = this._beginPack(e, a, i, n, r);
2963
+ let i = Vo(n, r), a = e.createCommandEncoder({ label: "oidn-tex-to-buf" }), o = this._beginPack(e, a, i, n, r);
2956
2964
  for (let n of [
2957
2965
  "color",
2958
2966
  "albedo",
@@ -2973,14 +2981,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2973
2981
  resource: { buffer: this._packParams }
2974
2982
  }
2975
2983
  ]
2976
- })), o.dispatchWorkgroups(Math.ceil(i.width / Jo), Math.ceil(i.height / Jo));
2984
+ })), o.dispatchWorkgroups(Math.ceil(i.width / ts), Math.ceil(i.height / ts));
2977
2985
  o.end(), e.queue.submit([a.finish()]);
2978
2986
  }
2979
2987
  _ensureGPUInputBuffers(e, t) {
2980
2988
  let { width: n, height: r } = this._gpuInputBufferSize;
2981
2989
  if (n === e && r === t && this._gpuInputBuffers.color) return;
2982
2990
  this._destroyGPUInputBuffers();
2983
- let i = this.gpuDevice, a = Po(e, t), o = a.width * a.height * 16, s = GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC;
2991
+ let i = this.gpuDevice, a = Vo(e, t), o = a.width * a.height * 16, s = GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC;
2984
2992
  this._gpuInputBuffers.color = i.createBuffer({
2985
2993
  label: "oidn-in-color",
2986
2994
  size: o,
@@ -3024,7 +3032,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3024
3032
  compute: {
3025
3033
  module: e.createShaderModule({
3026
3034
  label: "oidn-pack",
3027
- code: Yo
3035
+ code: ns
3028
3036
  }),
3029
3037
  entryPoint: "main"
3030
3038
  }
@@ -3082,7 +3090,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3082
3090
  });
3083
3091
  let t = e.createShaderModule({
3084
3092
  label: "oidn-autoexposure",
3085
- code: Vo
3093
+ code: Jo
3086
3094
  }), n = e.createPipelineLayout({ bindGroupLayouts: [this._lumLayout] });
3087
3095
  this._lumReducePipeline = e.createComputePipeline({
3088
3096
  label: "oidn-autoexposure-reduce",
@@ -3106,7 +3114,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3106
3114
  compute: {
3107
3115
  module: e.createShaderModule({
3108
3116
  label: "oidn-color-scale",
3109
- code: Ho
3117
+ code: Yo
3110
3118
  }),
3111
3119
  entryPoint: "main"
3112
3120
  }
@@ -3116,7 +3124,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3116
3124
  compute: {
3117
3125
  module: e.createShaderModule({
3118
3126
  label: "oidn-output-unpack",
3119
- code: qo
3127
+ code: es
3120
3128
  }),
3121
3129
  entryPoint: "main"
3122
3130
  }
@@ -3126,7 +3134,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3126
3134
  size: 4
3127
3135
  }), this._lumPartials = e.createBuffer({
3128
3136
  label: "oidn-autoexposure-partials",
3129
- size: Bo * 4,
3137
+ size: qo * 4,
3130
3138
  usage: GPUBufferUsage.STORAGE
3131
3139
  }), this._lumParams = e.createBuffer({
3132
3140
  label: "oidn-autoexposure-params",
@@ -3171,21 +3179,21 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3171
3179
  e.queue.writeBuffer(this._inputScaleBuffer, 0, new Float32Array([1]));
3172
3180
  return;
3173
3181
  }
3174
- let r = Po(t, n);
3182
+ let r = Vo(t, n);
3175
3183
  e.queue.writeBuffer(this._lumParams, 0, new Uint32Array([
3176
3184
  t * n,
3177
3185
  t,
3178
3186
  r.width,
3179
- No
3187
+ Bo
3180
3188
  ]));
3181
3189
  let i = e.createCommandEncoder({ label: "oidn-autoexposure" }), a = i.beginComputePass({ label: "oidn-autoexposure-reduce" });
3182
- a.setPipeline(this._lumReducePipeline), a.setBindGroup(0, this._lumBindGroup), a.dispatchWorkgroups(Bo, 1, 1), a.end();
3190
+ a.setPipeline(this._lumReducePipeline), a.setBindGroup(0, this._lumBindGroup), a.dispatchWorkgroups(qo, 1, 1), a.end();
3183
3191
  let o = i.beginComputePass({ label: "oidn-autoexposure-finalize" });
3184
3192
  o.setPipeline(this._lumFinalizePipeline), o.setBindGroup(0, this._lumBindGroup), o.dispatchWorkgroups(1, 1, 1), o.end(), e.queue.submit([i.finish()]);
3185
3193
  }
3186
3194
  _applyColorScale(e, t) {
3187
3195
  if (!this._ensureScalePipelines(e)) return;
3188
- let n = Math.ceil(t / Uo), r = Math.min(n, Wo), i = Math.ceil(n / r), a = e.createCommandEncoder({ label: "oidn-color-scale" }), o = a.beginComputePass({ label: "oidn-color-scale" });
3196
+ let n = Math.ceil(t / Xo), r = Math.min(n, Zo), i = Math.ceil(n / r), a = e.createCommandEncoder({ label: "oidn-color-scale" }), o = a.beginComputePass({ label: "oidn-color-scale" });
3189
3197
  o.setPipeline(this._colorScalePipeline), o.setBindGroup(0, this._colorScaleBindGroup), o.dispatchWorkgroups(r, i, 1), o.end(), e.queue.submit([a.finish()]);
3190
3198
  }
3191
3199
  get outputTexture() {
@@ -3230,18 +3238,18 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3230
3238
  if (this._ensureOutputTexture(r, this._renderWidth, this._renderHeight), !this._outGPUTexture) return;
3231
3239
  let c = r.createBuffer({
3232
3240
  label: "oidn-unpack-params",
3233
- size: Ko,
3241
+ size: $o,
3234
3242
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
3235
3243
  });
3236
3244
  try {
3237
- let t = Po(this._gpuInputBufferSize.width, this._gpuInputBufferSize.height).width;
3245
+ let t = Vo(this._gpuInputBufferSize.width, this._gpuInputBufferSize.height).width;
3238
3246
  r.queue.writeBuffer(c, 0, new Uint32Array([
3239
3247
  t,
3240
3248
  i,
3241
3249
  a,
3242
3250
  o,
3243
3251
  s,
3244
- No,
3252
+ Bo,
3245
3253
  0,
3246
3254
  0
3247
3255
  ]));
@@ -3271,7 +3279,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3271
3279
  }
3272
3280
  ]
3273
3281
  }), u = r.createCommandEncoder({ label: "oidn-output-unpack" }), d = u.beginComputePass({ label: "oidn-output-unpack" });
3274
- d.setPipeline(this._unpackPipeline), d.setBindGroup(0, l), d.dispatchWorkgroups(Math.ceil(o / Go), Math.ceil(s / Go), 1), d.end(), r.queue.submit([u.finish()]), n && (this._hasOutput = !0);
3282
+ d.setPipeline(this._unpackPipeline), d.setBindGroup(0, l), d.dispatchWorkgroups(Math.ceil(o / Qo), Math.ceil(s / Qo), 1), d.end(), r.queue.submit([u.finish()]), n && (this._hasOutput = !0);
3275
3283
  } finally {
3276
3284
  c.destroy();
3277
3285
  }
@@ -3303,7 +3311,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3303
3311
  },
3304
3312
  progress: (e, n, r) => {
3305
3313
  if (!e?.data || !r) return;
3306
- let { width: i, height: a } = this._gpuInputBufferSize, o = Math.max(r.x - No, 0), s = Math.max(r.y - No, 0), c = Math.min(r.x + r.width - No, i) - o, l = Math.min(r.y + r.height - No, a) - s;
3314
+ let { width: i, height: a } = this._gpuInputBufferSize, o = Math.max(r.x - Bo, 0), s = Math.max(r.y - Bo, 0), c = Math.min(r.x + r.width - Bo, i) - o, l = Math.min(r.y + r.height - Bo, a) - s;
3307
3315
  if (c <= 0 || l <= 0) return;
3308
3316
  let u = {
3309
3317
  x: o,
@@ -3324,7 +3332,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3324
3332
  }
3325
3333
  _displayGPUOutput({ data: e }) {
3326
3334
  if (!this.gpuDevice) {
3327
- jo.error("gpuDevice not available for the output picture");
3335
+ Ro.error("gpuDevice not available for the output picture");
3328
3336
  return;
3329
3337
  }
3330
3338
  let { width: t, height: n } = this._gpuInputBufferSize;
@@ -3336,7 +3344,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3336
3344
  });
3337
3345
  }
3338
3346
  abort() {
3339
- this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1, jo.debug("denoise aborted"));
3347
+ this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1, Ro.debug("denoise aborted"));
3340
3348
  }
3341
3349
  get hasOutput() {
3342
3350
  return this._hasOutput;
@@ -3347,13 +3355,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3347
3355
  setSize(e, t) {
3348
3356
  if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
3349
3357
  this._renderWidth = e, this._renderHeight = t, this._hasOutput = !1, this.lastDenoiseMs = 0, this._setupUNetDenoiser().catch((e) => {
3350
- jo.error("reinitialize after size change failed:", e);
3358
+ Ro.error("reinitialize after size change failed:", e);
3351
3359
  });
3352
3360
  }
3353
3361
  dispose() {
3354
- this.abort(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._releaseOutputTexture(), this._colorScalePipeline = null, this._lumReducePipeline = null, this._lumFinalizePipeline = null, this._lumLayout = null, this._unpackPipeline = null, this.unet = null, this._weights.clear(), this.state.abortController = null, this.removeAllListeners?.(), jo.debug("disposed");
3362
+ this.abort(), this.unet?.dispose(), this._destroyGPUInputBuffers(), this._releaseOutputTexture(), this._colorScalePipeline = null, this._lumReducePipeline = null, this._lumFinalizePipeline = null, this._lumLayout = null, this._unpackPipeline = null, this.unet = null, this._weights.clear(), this.state.abortController = null, this.removeAllListeners?.(), Ro.debug("disposed");
3355
3363
  }
3356
- }, Zo = Object.freeze({
3364
+ }, is = Object.freeze({
3357
3365
  maxLength: 8,
3358
3366
  smoothLength: 2,
3359
3367
  roughStart: .45,
@@ -3361,7 +3369,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3361
3369
  depthTolerance: .05,
3362
3370
  normalTolerance: .8,
3363
3371
  movedLength: 2
3364
- }), Qo = 8, $o = 304, es = 16, ts = 1, ns = 2, rs = 4, is = 1073741824, as = "\nstruct Params {\n size: vec2<u32>,\n reset: u32,\n flags: u32,\n maxLength: f32,\n smoothLength: f32,\n depthTolerance: f32,\n normalTolerance: f32,\n roughStart: f32,\n roughEnd: f32,\n samples: f32,\n historyScale: f32,\n camWorld: mat4x4<f32>,\n projInv: mat4x4<f32>,\n prevViewProj: mat4x4<f32>,\n prevCamPos: vec4<f32>,\n moved: vec4<u32>,\n movedLength: f32,\n prevCamDir: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> P: Params;\n\nfn finite3( v: vec3<f32> ) -> bool {\n let e = bitcast<vec3<u32>>( v ) & vec3<u32>( 0x7f800000u );\n return all( e != vec3<u32>( 0x7f800000u ) );\n}\n\n// [0,1]-encoded in and out, renormalised like FinalWrite's clean aux.\nfn mixNormal( h: vec3<f32>, c: vec3<f32>, t: f32 ) -> vec3<f32> {\n let m = mix( h * 2.0 - 1.0, c * 2.0 - 1.0, t );\n let l = length( m );\n return select( c, m / l * 0.5 + 0.5, l > 1e-4 );\n}\n", os = as + `
3372
+ }), as = 8, os = 304, ss = 16, cs = 1, ls = 2, us = 4, ds = 1073741824, fs = "\nstruct Params {\n size: vec2<u32>,\n reset: u32,\n flags: u32,\n maxLength: f32,\n smoothLength: f32,\n depthTolerance: f32,\n normalTolerance: f32,\n roughStart: f32,\n roughEnd: f32,\n samples: f32,\n historyScale: f32,\n camWorld: mat4x4<f32>,\n projInv: mat4x4<f32>,\n prevViewProj: mat4x4<f32>,\n prevCamPos: vec4<f32>,\n moved: vec4<u32>,\n movedLength: f32,\n prevCamDir: vec4<f32>,\n};\n\n@group(0) @binding(0) var<uniform> P: Params;\n\nfn finite3( v: vec3<f32> ) -> bool {\n let e = bitcast<vec3<u32>>( v ) & vec3<u32>( 0x7f800000u );\n return all( e != vec3<u32>( 0x7f800000u ) );\n}\n\n// [0,1]-encoded in and out, renormalised like FinalWrite's clean aux.\nfn mixNormal( h: vec3<f32>, c: vec3<f32>, t: f32 ) -> vec3<f32> {\n let m = mix( h * 2.0 - 1.0, c * 2.0 - 1.0, t );\n let l = length( m );\n return select( c, m / l * 0.5 + 0.5, l > 1e-4 );\n}\n", ps = fs + `
3365
3373
  @group(0) @binding(1) var geoCur: texture_2d<f32>;
3366
3374
  @group(0) @binding(2) var geoPrev: texture_2d<f32>;
3367
3375
  @group(0) @binding(3) var<storage, read_write> picked: array<i32>;
@@ -3387,7 +3395,7 @@ fn movedIndex( leaf: u32 ) -> i32 {
3387
3395
 
3388
3396
  }
3389
3397
 
3390
- @compute @workgroup_size(${Qo}, ${Qo})
3398
+ @compute @workgroup_size(${as}, ${as})
3391
3399
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3392
3400
 
3393
3401
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3402,7 +3410,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3402
3410
  let size = vec2<f32>( P.size );
3403
3411
  let uv = ( vec2<f32>( gid.xy ) + 0.5 ) / size;
3404
3412
  // Depth is along the ray: from the camera, or from its image plane when orthographic.
3405
- let ortho = ( P.flags & ${rs}u ) != 0u;
3413
+ let ortho = ( P.flags & ${us}u ) != 0u;
3406
3414
  let ndc = vec2<f32>( uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0 );
3407
3415
  var origin = P.camWorld[ 3 ].xyz;
3408
3416
  var dir: vec3<f32>;
@@ -3426,7 +3434,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3426
3434
  let toPrev = movedToPrev[ u32( m ) ];
3427
3435
  wp = ( toPrev * vec4<f32>( wp, 1.0 ) ).xyz;
3428
3436
  n = normalize( ( toPrev * vec4<f32>( n, 0.0 ) ).xyz );
3429
- movedFlag = ${is};
3437
+ movedFlag = ${ds};
3430
3438
 
3431
3439
  }
3432
3440
 
@@ -3463,7 +3471,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3463
3471
  if ( pick >= 0 ) { atomicAdd( &copies[ u32( pick ) ], 1u ); }
3464
3472
 
3465
3473
  }
3466
- `, ss = as + `
3474
+ `, ms = fs + `
3467
3475
  @group(0) @binding(1) var curColor: texture_2d<f32>;
3468
3476
  @group(0) @binding(2) var curAlbedo: texture_2d<f32>;
3469
3477
  @group(0) @binding(3) var curNormal: texture_2d<f32>;
@@ -3477,7 +3485,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3477
3485
  @group(0) @binding(11) var outAlbedo: texture_storage_2d<rgba32float, write>;
3478
3486
  @group(0) @binding(12) var outNormal: texture_storage_2d<rgba32float, write>;
3479
3487
 
3480
- @compute @workgroup_size(${Qo}, ${Qo})
3488
+ @compute @workgroup_size(${as}, ${as})
3481
3489
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3482
3490
 
3483
3491
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3493,8 +3501,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3493
3501
  var ha = ca.xyz;
3494
3502
  var hn = cn.xyz;
3495
3503
  let raw = picked[ gid.y * P.size.x + gid.x ];
3496
- let movedPx = raw >= 0 && ( raw & ${is} ) != 0;
3497
- let pick = select( raw, raw & ~${is}, raw >= 0 );
3504
+ let movedPx = raw >= 0 && ( raw & ${ds} ) != 0;
3505
+ let pick = select( raw, raw & ~${ds}, raw >= 0 );
3498
3506
 
3499
3507
  if ( pick >= 0 ) {
3500
3508
 
@@ -3508,13 +3516,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3508
3516
  ha = a.xyz;
3509
3517
  hn = textureLoad( histNormal, q, 0 ).xyz;
3510
3518
  len = a.w;
3511
- if ( ( P.flags & ${ns}u ) != 0u ) { len = len / f32( max( copies[ u32( pick ) ], 1u ) ); }
3519
+ if ( ( P.flags & ${ls}u ) != 0u ) { len = len / f32( max( copies[ u32( pick ) ], 1u ) ); }
3512
3520
 
3513
3521
  }
3514
3522
 
3515
3523
  }
3516
3524
 
3517
- let rough = textureLoad( shading, p, 0 ).w;
3525
+ let rough = abs( textureLoad( shading, p, 0 ).w );
3518
3526
  var cap = mix( P.smoothLength, P.maxLength, smoothstep( P.roughStart, P.roughEnd, rough ) );
3519
3527
  if ( movedPx ) { cap = min( cap, P.movedLength ); }
3520
3528
  let newLen = min( len + 1.0, cap );
@@ -3522,11 +3530,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3522
3530
 
3523
3531
  textureStore( outColor, p, vec4<f32>( mix( hc, cur.xyz, t ), cur.w ) );
3524
3532
  textureStore( outAlbedo, p, vec4<f32>( mix( ha, ca.xyz, t ), newLen ) );
3525
- let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${ts}u ) != 0u );
3533
+ let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${cs}u ) != 0u );
3526
3534
  textureStore( outNormal, p, vec4<f32>( n, cn.w ) );
3527
3535
 
3528
3536
  }
3529
- `, cs = as + `
3537
+ `, hs = fs + `
3530
3538
  @group(0) @binding(1) var accColor: texture_2d<f32>;
3531
3539
  @group(0) @binding(2) var accAlbedo: texture_2d<f32>;
3532
3540
  @group(0) @binding(3) var accNormal: texture_2d<f32>;
@@ -3537,7 +3545,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3537
3545
  @group(0) @binding(8) var outAlbedo: texture_storage_2d<rgba32float, write>;
3538
3546
  @group(0) @binding(9) var outNormal: texture_storage_2d<rgba32float, write>;
3539
3547
 
3540
- @compute @workgroup_size(${Qo}, ${Qo})
3548
+ @compute @workgroup_size(${as}, ${as})
3541
3549
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3542
3550
 
3543
3551
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3571,32 +3579,32 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3571
3579
  let t = P.samples / max( k + P.samples, 1e-6 );
3572
3580
  textureStore( outColor, p, vec4<f32>( mix( hc, ac.xyz, t ), ac.w ) );
3573
3581
  textureStore( outAlbedo, p, vec4<f32>( mix( ha, aa.xyz, t ), min( k + P.samples, P.maxLength ) ) );
3574
- let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${ts}u ) != 0u );
3582
+ let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${cs}u ) != 0u );
3575
3583
  textureStore( outNormal, p, vec4<f32>( n, an.w ) );
3576
3584
 
3577
3585
  }
3578
- `, ls = (e) => ({
3586
+ `, gs = (e) => ({
3579
3587
  binding: e,
3580
3588
  visibility: GPUShaderStage.COMPUTE,
3581
3589
  texture: { sampleType: "unfilterable-float" }
3582
- }), us = (e) => ({
3590
+ }), _s = (e) => ({
3583
3591
  binding: e,
3584
3592
  visibility: GPUShaderStage.COMPUTE,
3585
3593
  storageTexture: {
3586
3594
  access: "write-only",
3587
3595
  format: "rgba32float"
3588
3596
  }
3589
- }), ds = (e, t) => ({
3597
+ }), vs = (e, t) => ({
3590
3598
  binding: e,
3591
3599
  visibility: GPUShaderStage.COMPUTE,
3592
3600
  buffer: { type: t }
3593
- }), fs = class {
3601
+ }), ys = class {
3594
3602
  constructor(e) {
3595
3603
  this.device = e, this.settings = {
3596
- ...Zo,
3604
+ ...is,
3597
3605
  cleanAux: !1,
3598
3606
  splitCopies: !0
3599
- }, this.valid = !1, this.width = 0, this.height = 0, this._sets = null, this._current = 0, this._picked = null, this._copies = null, this._paramsBuffer = null, this._pipelines = null, this._movedLeaves = null, this._movedToPrev = null, this._movedCapacity = 0, this._movedCount = 0, this._paramData = new ArrayBuffer($o), this._paramU32 = new Uint32Array(this._paramData), this._paramF32 = new Float32Array(this._paramData), this._prevViewProj = new Float32Array(16), this._prevCamPos = new Float32Array(4), this._prevCamDir = new Float32Array(4);
3607
+ }, this.valid = !1, this.width = 0, this.height = 0, this._sets = null, this._current = 0, this._picked = null, this._copies = null, this._paramsBuffer = null, this._pipelines = null, this._movedLeaves = null, this._movedToPrev = null, this._movedCapacity = 0, this._movedCount = 0, this._paramData = new ArrayBuffer(os), this._paramU32 = new Uint32Array(this._paramData), this._paramF32 = new Float32Array(this._paramData), this._prevViewProj = new Float32Array(16), this._prevCamPos = new Float32Array(4), this._prevCamDir = new Float32Array(4);
3600
3608
  }
3601
3609
  get textures() {
3602
3610
  return this.valid ? this._sets[this._current] : null;
@@ -3704,23 +3712,23 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3704
3712
  }),
3705
3713
  layout: i
3706
3714
  };
3707
- }, n = ds(0, "uniform");
3715
+ }, n = vs(0, "uniform");
3708
3716
  this._pipelines = {
3709
- select: t("oidn-history-select", os, [
3717
+ select: t("oidn-history-select", ps, [
3710
3718
  n,
3711
- ls(1),
3712
- ls(2),
3713
- ds(3, "storage"),
3714
- ds(4, "storage"),
3719
+ gs(1),
3720
+ gs(2),
3721
+ vs(3, "storage"),
3722
+ vs(4, "storage"),
3715
3723
  {
3716
3724
  binding: 5,
3717
3725
  visibility: GPUShaderStage.COMPUTE,
3718
3726
  texture: { sampleType: "uint" }
3719
3727
  },
3720
- ds(6, "read-only-storage"),
3721
- ds(7, "read-only-storage")
3728
+ vs(6, "read-only-storage"),
3729
+ vs(7, "read-only-storage")
3722
3730
  ]),
3723
- blend: t("oidn-history-blend", ss, [
3731
+ blend: t("oidn-history-blend", ms, [
3724
3732
  n,
3725
3733
  ...[
3726
3734
  1,
@@ -3730,14 +3738,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3730
3738
  5,
3731
3739
  6,
3732
3740
  7
3733
- ].map(ls),
3734
- ds(8, "read-only-storage"),
3735
- ds(9, "read-only-storage"),
3736
- us(10),
3737
- us(11),
3738
- us(12)
3741
+ ].map(gs),
3742
+ vs(8, "read-only-storage"),
3743
+ vs(9, "read-only-storage"),
3744
+ _s(10),
3745
+ _s(11),
3746
+ _s(12)
3739
3747
  ]),
3740
- merge: t("oidn-history-merge", cs, [
3748
+ merge: t("oidn-history-merge", hs, [
3741
3749
  n,
3742
3750
  ...[
3743
3751
  1,
@@ -3746,16 +3754,16 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3746
3754
  4,
3747
3755
  5,
3748
3756
  6
3749
- ].map(ls),
3750
- us(7),
3751
- us(8),
3752
- us(9)
3757
+ ].map(gs),
3758
+ _s(7),
3759
+ _s(8),
3760
+ _s(9)
3753
3761
  ])
3754
3762
  }, this._paramsBuffer = e.createBuffer({
3755
3763
  label: "oidn-history-params",
3756
- size: $o,
3764
+ size: os,
3757
3765
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
3758
- }), this._growMoved(es);
3766
+ }), this._growMoved(ss);
3759
3767
  }
3760
3768
  _growMoved(e) {
3761
3769
  this._movedLeaves?.destroy(), this._movedToPrev?.destroy();
@@ -3781,11 +3789,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3781
3789
  a.setPipeline(t), a.setBindGroup(0, this.device.createBindGroup({
3782
3790
  layout: n,
3783
3791
  entries: i
3784
- })), a.dispatchWorkgroups(Math.ceil(this.width / Qo), Math.ceil(this.height / Qo)), a.end();
3792
+ })), a.dispatchWorkgroups(Math.ceil(this.width / as), Math.ceil(this.height / as)), a.end();
3785
3793
  }
3786
3794
  _writeParams(e, t, n, r) {
3787
3795
  let i = this.settings, a = this._paramU32, o = this._paramF32;
3788
- a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ? ts : 0) | (i.splitCopies ? ns : 0) | (e.orthographic ? rs : 0), o[4] = i.maxLength, o[5] = i.smoothLength, o[6] = i.depthTolerance, o[7] = i.normalTolerance, o[8] = i.roughStart, o[9] = i.roughEnd, o[10] = n, o[11] = r, o.set(e.world, 12), o.set(e.projInv, 28), o.set(this._prevViewProj, 44), o.set(this._prevCamPos, 60), a[64] = this._movedCount, o[68] = i.movedLength, o.set(this._prevCamDir, 72), this.device.queue.writeBuffer(this._paramsBuffer, 0, this._paramData);
3796
+ a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ? cs : 0) | (i.splitCopies ? ls : 0) | (e.orthographic ? us : 0), o[4] = i.maxLength, o[5] = i.smoothLength, o[6] = i.depthTolerance, o[7] = i.normalTolerance, o[8] = i.roughStart, o[9] = i.roughEnd, o[10] = n, o[11] = r, o.set(e.world, 12), o.set(e.projInv, 28), o.set(this._prevViewProj, 44), o.set(this._prevCamPos, 60), a[64] = this._movedCount, o[68] = i.movedLength, o.set(this._prevCamDir, 72), this.device.queue.writeBuffer(this._paramsBuffer, 0, this._paramData);
3789
3797
  }
3790
3798
  _rememberCamera(e) {
3791
3799
  this._prevViewProj.set(e.viewProj), this._prevCamPos[0] = e.world[12], this._prevCamPos[1] = e.world[13], this._prevCamPos[2] = e.world[14];
@@ -3795,11 +3803,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3795
3803
  _releaseTextures() {
3796
3804
  this._sets?.forEach((e) => Object.values(e).forEach((e) => e.destroy())), this._picked?.destroy(), this._copies?.destroy(), this._sets = null, this._picked = null, this._copies = null, this.width = 0, this.height = 0, this.valid = !1;
3797
3805
  }
3798
- }, ps = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,ADAPTER_UNAVAILABLE:`adapter.unavailable`,DEVICE_UNAVAILABLE:`device.unavailable`,WEBGPU_UNAVAILABLE:`webgpu.unavailable`,ASSET_UNREACHABLE:`asset.unreachable`,ASSET_AMBIGUOUS_ENTRY:`asset.ambiguous_entry`,ASSET_ARCHIVE_TOO_LARGE:`asset.archive_too_large`,ASSET_ENTRY_TOO_LARGE:`asset.entry_too_large`,TEXTURE_BUILD_FAILED:`texture.build_failed`,TEXTURE_PROCESSING_FALLBACK:`texture.processing_fallback`,TEXTURE_LIMIT_EXCEEDED:`texture.limit_exceeded`,ENVIRONMENT_LOAD_FAILED:`environment.load_failed`,SETTING_UNKNOWN_KEY:`setting.unknown_key`,RENDER_SIZE_DECLINED:`render.size_declined`,STAGE_RENDER_FAILED:`stage.render_failed`,RENDER_RESERVE_CAPPED:`render.reserve_capped`,SCENE_MEMORY_BUDGET:`scene.memory_budget`,EMISSIVE_INSTANCES_COLLAPSED:`emissive.instances_collapsed`,REFIT_SHARED_GEOMETRY:`refit.shared_geometry`,VIEW_TRANSFORM_DISPLAY_MISMATCH:`viewTransform.display_mismatch`,VIEW_TRANSFORM_BAKE_FAILED:`viewTransform.bake_failed`,COLOR_CONFIG_LOAD_FAILED:`color.config_load_failed`,STORAGE_UNAVAILABLE:`storage.unavailable`,STORAGE_QUOTA_EXCEEDED:`storage.quota_exceeded`,STORAGE_WRITE_FAILED:`storage.write_failed`,STORAGE_READ_FAILED:`storage.read_failed`,STORAGE_ENTRY_CORRUPT:`storage.entry_corrupt`,STORAGE_CACHE_MISMATCH:`storage.cache_mismatch`,DENOISER_UNAVAILABLE:`denoiser.unavailable`,OUTPUT_SOURCE_FALLBACK:`output.source_fallback`,OUTPUT_TONEMAP_FALLBACK:`output.tonemap_fallback`,LIGHT_PLACEHOLDER_SKIPPED:`light.placeholder_skipped`,CAPABILITY_MISSING:`capability.missing`});Object.freeze({ERROR:`error`,WARNING:`warning`});const t=new Map;function n(e,t){return e.exclusive||t===`exclusive`&&e.shared>0?!1:(t===`exclusive`?e.exclusive=!0:e.shared++,!0)}function r(e,r,a){let o=t.get(e);o||(o={shared:0,exclusive:!1,queue:[]},t.set(e,o));let s=i(()=>{for(r===`exclusive`?o.exclusive=!1:o.shared--;o.queue.length&&n(o,o.queue[0].mode);)o.queue.shift().grant();!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e)});return o.queue.length===0&&n(o,r)?Promise.resolve(s):a?(!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e),Promise.resolve(null)):new Promise(e=>o.queue.push({mode:r,grant:()=>e(s)}))}function i(e){let t=!1;return()=>{t||(t=!0,e())}}const a=()=>typeof navigator<`u`&&navigator.locks?.request?navigator.locks:null;function o(e,{mode:t=`exclusive`,ifAvailable:n=!1}={}){let o=a();return o?new Promise((r,a)=>{o.request(e,{mode:t,ifAvailable:n},e=>{if(!e){r(null);return}return new Promise(e=>r(i(e)))}).catch(a)}):r(e,t,n)}async function s(){let e=a();if(!e)return new Set(t.keys());let{held:n=[]}=await e.query();return new Set(n.map(e=>e.name))}const c=new TextEncoder;function l(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}async function u(e){let t=typeof e==`string`?c.encode(e):e;return l(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}async function d(e){return(await u(e)).slice(0,32)}var f=class{constructor(){this._handlers=new Map}addEventListener(e,t){this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t)}removeEventListener(e,t){this._handlers.get(e)?.delete(t)}dispatchEvent(e){for(let t of[...this._handlers.get(e.type)??[]])t.call(this,e)}},p=class{constructor(e){this._root=e,this._writers=new Map,this._nextId=1}async _dir(e,t){let n=await this._root;for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n}async openWriter({path:e,name:t,truncate:n=!0,length:r}){let i=await(await(await this._dir(e,!0)).getFileHandle(t,{create:!0})).createSyncAccessHandle();n?i.truncate(0):r!==void 0&&i.getSize()>r&&i.truncate(r);let a=this._nextId++;return this._writers.set(a,{handle:i,end:i.getSize()}),{id:a}}write({id:e,buffer:t,byteOffset:n=0,byteLength:r,at:i}){let a=this._writers.get(e);if(!a)throw Error(`storage: writer ${e} is not open`);let o=new Uint8Array(t,n,r??t.byteLength-n),s=i??a.end,c=0;for(;c<o.length;){let e=a.handle.write(o.subarray(c),{at:s+c});if(e<=0)throw Error(`storage: write made no progress`);c+=e}return a.end=Math.max(a.end,s+o.length),{bytes:o.length}}closeWriter({id:e,abort:t=!1}){let n=this._writers.get(e);if(!n)return{size:0};this._writers.delete(e);try{return t||n.handle.flush(),{size:n.handle.getSize()}}finally{n.handle.close()}}async writeFile({path:e,name:t,buffer:n,byteOffset:r=0,byteLength:i}){let{id:a}=await this.openWriter({path:e,name:t});try{return this.write({id:a,buffer:n,byteOffset:r,byteLength:i}),this.closeWriter({id:a})}catch(e){throw this.closeWriter({id:a,abort:!0}),e}}async readRange({path:e,name:t,offset:n=0,length:r}){let i=await(await this._dir(e,!1)).getFileHandle(t),a=null;try{a=await i.createSyncAccessHandle()}catch(e){if(e.name!==`NoModificationAllowedError`)throw e}if(!a){let e=await i.getFile(),t=r===void 0?e.size:n+r;return{buffer:await e.slice(n,t).arrayBuffer()}}try{let e=a.getSize(),t=Math.max(0,Math.min(r??e-n,e-n)),i=new ArrayBuffer(t);return a.read(i,{at:n}),{buffer:i}}finally{a.close()}}dispose(){for(let e of[...this._writers.keys()])this.closeWriter({id:e,abort:!0})}},m=class{constructor(e){this._ops=new p(e)}async call(e,t){return this._ops[e](t)}dispose(){this._ops.dispose()}};const h=Object.freeze({CACHE:`cache`,USER:`user`,SCRATCH:`scratch`}),g=Object.freeze({DOWNLOADS:`downloads`,ARCHIVES:`archives`,SCENES:`scenes`,CDF:`cdf`,SPILL:`spill`}),_=`meta.json`,v=100*1024**3,y=64*1024**2,b=8*1024**2,x=new TextEncoder;function S(e,{copy:t,transfer:n}){if(typeof e==`string`&&(e=x.encode(e)),e instanceof ArrayBuffer){if(!t||n)return{args:{buffer:e},list:[e]};let r=e.slice(0);return{args:{buffer:r},list:[r]}}if(!ArrayBuffer.isView(e))throw TypeError(`storage: write expects an ArrayBuffer, a typed array, a Blob or a string`);let{buffer:r,byteOffset:i,byteLength:a}=e,o=typeof SharedArrayBuffer<`u`&&r instanceof SharedArrayBuffer;if(!t)return{args:{buffer:r,byteOffset:i,byteLength:a},list:[]};if(o){let e=new Uint8Array(a);return e.set(new Uint8Array(r,i,a)),{args:{buffer:e.buffer},list:[e.buffer]}}if(n&&i===0&&a===r.byteLength)return{args:{buffer:r},list:[r]};let s=r.slice(i,i+a);return{args:{buffer:s},list:[s]}}async function C(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return JSON.parse(await n.text())}catch{return null}}async function*w(e){for await(let[t,n]of e.entries())n.kind===`directory`&&(yield[t,n])}var T=class{constructor(e,t,n,r,i){this.area=e,this.id=t,this.key=n.key,this.meta=n,this._dir=r,this._release=i}get bytes(){return this.meta.bytes}get extra(){return this.meta.extra??{}}async file(t){try{return await(await this._dir.getFileHandle(t)).getFile()}catch(n){return this.area.manager._issue(e.STORAGE_READ_FAILED,`could not read ${this.area.name}/${this.id}/${t}`,{error:n.message}),null}}async json(e){let t=await this.file(e);return t?JSON.parse(await t.text()):null}release(){this._release?.(),this._release=null}},E=class{constructor(e,t,n,r,i,{sizes:a={},append:o=!1}={}){this.area=e,this.id=t,this.key=n,this._info=r,this._release=i,this._writers=new Map,this._sizes={...a},this._append=o,this._done=!1,this._committedBytes=o?Object.values(a).reduce((e,t)=>e+t,0):0}get _transport(){return this.area.manager._transport}get _path(){return[this.area.name,this.id]}async _writer(e){let t=this._writers.get(e);if(!t){let n=this._append&&e in this._sizes,r=n&&(this._info.growable??[]).includes(e)?this._sizes[e]:void 0;t=this._transport.call(`openWriter`,{path:this._path,name:e,truncate:!n,length:r}),this._writers.set(e,t)}return(await t).id}async write(e,t,{at:n,transfer:r=!1}={}){this._assertOpen();let{args:i,list:a}=(typeof Blob<`u`&&t instanceof Blob?null:S(t,{copy:!0,transfer:r}))??S(await t.arrayBuffer(),{copy:!0,transfer:!0}),o=await this._writer(e);return this._transport.call(`write`,{id:o,at:n,...i},a)}async writeFile(e,t){this._assertOpen(),typeof Blob<`u`&&t instanceof Blob&&(t=await t.arrayBuffer());let{args:n,list:r}=S(t,{copy:!0,transfer:!0}),{size:i}=await this._transport.call(`writeFile`,{path:this._path,name:e,...n},r);return this._sizes[e]=i,i}writeJSON(e,t){return this.writeFile(e,JSON.stringify(t))}async writeStream(e,t,{onProgress:n=null,signal:r=null,batchBytes:i=b}={}){let a=t.getReader(),o=[],s=new Uint8Array(i),c=0,l=0,u=async()=>{if(c===0)return;let t=c===i?s:s.slice(0,c);s=new Uint8Array(i),c=0,o.push(this.write(e,t,{transfer:!0})),o.length>=4&&await o.shift()};try{for(;;){if(r?.aborted)throw r.reason??new DOMException(`aborted`,`AbortError`);let{done:e,value:t}=await a.read();if(e)break;let o=0;for(;o<t.length;){let e=Math.min(t.length-o,i-c);s.set(t.subarray(o,o+e),c),c+=e,o+=e,l+=e,c===i&&await u()}n?.(l)}return await u(),await Promise.all(o),l}catch(e){throw a.cancel().catch(()=>{}),await Promise.allSettled(o),e}}async commit(e={}){this._assertOpen(),this._done=!0;try{for(let[e,t]of this._writers){let{size:n}=await this._transport.call(`closeWriter`,{id:(await t).id});this._sizes[e]=n}this._writers.clear();let t=Date.now(),n={v:1,key:this.key,label:this._info.label??``,kind:this.area.kind,files:{...this._sizes},bytes:Object.values(this._sizes).reduce((e,t)=>e+t,0),createdAt:this._info.createdAt??t,lastUsed:t,pinned:this._info.pinned===!0,extra:{...this._info.extra,...e}},r=this._info.growable??[];r.length&&(n.growable=r);let{args:i,list:a}=S(JSON.stringify(n),{copy:!1});return await this._transport.call(`writeFile`,{path:this._path,name:_,...i},a),this.area.kind===h.CACHE&&this.area.manager._countCacheBytes(n.bytes-this._committedBytes),this.area.manager._changed(this.area.name),n}catch(e){throw await this._discard(),this.area.manager._writeFailed(this.area.name,e),e}finally{this._release?.(),this._release=null}}async abort(){if(!this._done){this._done=!0;try{this._append?await this._closeAll(!0):await this._discard()}finally{this._release?.(),this._release=null}}}async _closeAll(e){for(let t of this._writers.values())try{await this._transport.call(`closeWriter`,{id:(await t).id,abort:e})}catch{}this._writers.clear()}async _discard(){await this._closeAll(!0),await this.area._removeDir(this.id)}_assertOpen(){if(this._done)throw Error(`storage: entry ${this.area.name}/${this.id} is already committed or aborted`)}},D=class{constructor(e,t,n){this.manager=e,this.name=t,this.kind=n}_lockName(e){return`${this.manager.namespace}:store:${this.name}:${e}`}async _dir(e=!1){try{return await this.manager._root.getDirectoryHandle(this.name,{create:e})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _entryDir(e,t=!1){let n=await this._dir(t);if(!n)return null;try{return await n.getDirectoryHandle(e,{create:t})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _removeDir(e){let t=await this._dir(!1);if(t)try{await t.removeEntry(e,{recursive:!0})}catch(e){if(e.name!==`NotFoundError`)throw e}}async _validMeta(e,t=null){let n=await C(e,_);if(!n||n.v!==1||typeof n.key!=`string`||t!==null&&n.key!==t)return null;let r=n.growable??[];for(let[t,i]of Object.entries(n.files??{}))try{let n=await(await e.getFileHandle(t)).getFile();if(n.size!==i&&!(r.includes(t)&&n.size>i))return null}catch{return null}return n}async open(t,{wait:n=!1}={}){let r=await d(t),i=await o(this._lockName(r),{mode:`shared`,ifAvailable:!n});if(!i)return null;try{let e=await this._entryDir(r),n=e?await this._validMeta(e,t):null;return n?(Date.now()-n.lastUsed>36e5&&this._touch(r,n),new T(this,r,n,e,i)):(i(),null)}catch(t){return i(),this.manager._issue(e.STORAGE_READ_FAILED,`could not open ${this.name} entry`,{error:t.message}),null}}async has(e){let t=await this.open(e);return t?.release(),!!t}_touch(e,t){let n={...t,lastUsed:Date.now()},{args:r,list:i}=S(JSON.stringify(n),{copy:!1});this.manager._transport.call(`writeFile`,{path:[this.name,e],name:_,...r},i).catch(()=>{}),t.lastUsed=n.lastUsed}async create(t,{label:n=``,pinned:r=!1,expectedBytes:i=0,extra:a={},growable:s=[]}={}){let c=await d(t),l=await o(this._lockName(c),{mode:`exclusive`});try{return i>0&&!await this.manager.ensureSpace(i,this.kind)?(l(),this.manager._issue(e.STORAGE_QUOTA_EXCEEDED,`no room for ${(i/1048576).toFixed(0)} MB in ${this.name}`,{area:this.name,expectedBytes:i}),null):(await this._removeDir(c),await this._entryDir(c,!0),new E(this,c,t,{label:n,pinned:r,extra:a,growable:s},l))}catch(e){return l(),this.manager._writeFailed(this.name,e),null}}async patchMeta(e,t){let n=await d(e),r=await o(this._lockName(n),{mode:`shared`,ifAvailable:!0});if(!r)return!1;try{let r=await this._entryDir(n),i=r?await this._validMeta(r,e):null;if(!i)return!1;let{args:a,list:o}=S(JSON.stringify({...i,...t,v:1,key:e}),{copy:!1});return await this.manager._transport.call(`writeFile`,{path:[this.name,n],name:_,...a},o),!0}finally{r()}}async edit(e){let t=await d(e),n=await o(this._lockName(t),{mode:`exclusive`});try{let r=await this._entryDir(t),i=r?await this._validMeta(r,e):null;if(!i)return n(),null;let a={label:i.label,pinned:i.pinned,extra:i.extra,createdAt:i.createdAt,growable:i.growable};return new E(this,t,e,a,n,{sizes:i.files,append:!0})}catch(e){return n(),this.manager._writeFailed(this.name,e),null}}async remove(e){return this.removeById(await d(e))}async removeById(e){let t=await o(this._lockName(e),{mode:`exclusive`,ifAvailable:!0});if(!t)return!1;try{return await this._removeDir(e),this.manager._changed(this.name),!0}finally{t()}}async list(){let e=await this._dir(!1);if(!e)return[];let t=[];for await(let[n,r]of w(e)){let e=await C(r,_);e?.v===1&&t.push({...e,id:n})}return t}async clear(){let e=0;for(let{id:t}of await this.list())await this.removeById(t)&&e++;return e}async sweep(){let e=await this._dir(!1);if(!e)return 0;let t=await s(),n=0;for await(let[r,i]of w(e))t.has(this._lockName(r))||await this._validMeta(i)||await this.removeById(r)&&n++;return n}},O=class extends f{constructor({root:e,transport:t,namespace:n}){super(),this.namespace=n,this._root=e,this._transport=t,this._areas=new Map,this._budget=null,this._cacheTotal=null;for(let e of Object.values(g))this.defineArea(e,{kind:e===g.SPILL?h.SCRATCH:h.CACHE})}defineArea(e,{kind:t=h.CACHE}={}){let n=this._areas.get(e);if(n){if(n.kind!==t)throw Error(`storage: area \"${e}\" is already defined as ${n.kind}`);return n}let r=new D(this,e,t);return this._areas.set(e,r),r}area(e){let t=this._areas.get(e);if(!t)throw Error(`storage: unknown area \"${e}\"`);return t}get areaNames(){return[...this._areas.keys()]}async estimate(){let e=typeof navigator<`u`?navigator.storage:null;if(!e?.estimate)return{quota:1/0,usage:0};let{quota:t=1/0,usage:n=0}=await e.estimate();return{quota:t,usage:n}}async persisted(){return await globalThis.navigator?.storage?.persisted?.()===!0}async persist(){let e=await globalThis.navigator?.storage?.persist?.()===!0;return this._changed(null),e}async budget(){if(this._budget!==null)return this._budget;let{quota:e}=await this.estimate();return Math.min(e*.3,v)}setBudget(e){this._budget=e===null?null:Math.max(0,e),this._changed(null)}async _cacheBytes(){let e=this._cacheTotal;return(!e||Date.now()-e.at>3e4)&&(e=this._cacheTotal={at:Date.now(),bytes:0,ready:null},e.ready=this._cacheEntries().then(t=>{e.bytes+=t.reduce((e,t)=>e+(t.meta.bytes??0),0)}),e.ready.catch(()=>{this._cacheTotal===e&&(this._cacheTotal=null)})),await e.ready,e.bytes}_countCacheBytes(e){this._cacheTotal&&(this._cacheTotal.bytes+=e)}async _cacheEntries(){let e=[];for(let t of this._areas.values())if(t.kind===h.CACHE)for(let n of await t.list())e.push({area:t,meta:n});return e}async usage(){let{quota:e,usage:t}=await this.estimate(),n={},r=0;for(let e of this._areas.values()){let t=await e.list(),i=t.reduce((e,t)=>e+(t.bytes??0),0);n[e.name]={kind:e.kind,bytes:i,entries:t.length},e.kind===h.CACHE&&(r+=i)}return{quota:e,usage:t,persisted:await this.persisted(),budget:await this.budget(),cacheBytes:r,areas:n}}async collect({freeBytes:e=null}={}){let t=await this._cacheEntries(),n=await this.budget(),r=this._cacheTotal={at:Date.now(),bytes:t.reduce((e,t)=>e+(t.meta.bytes??0),0),ready:null},i=e??Math.max(0,r.bytes-n);if(i<=0)return 0;let a=await s(),o=t.filter(({area:e,meta:t})=>!t.pinned&&!a.has(e._lockName(t.id))).sort((e,t)=>e.meta.lastUsed-t.meta.lastUsed),c=0;for(let{area:e,meta:t}of o){if(c>=i)break;await e.removeById(t.id)&&(c+=t.bytes??0,r.bytes-=t.bytes??0)}return c}async ensureSpace(e,t=h.CACHE){let n=async()=>{let{quota:n,usage:r}=await this.estimate(),i=e+y-(n-r);return t===h.CACHE?{free:i,budget:await this._cacheBytes()+e-await this.budget()}:{free:i,budget:0}},r=await n();return r.free<=0&&r.budget<=0?!0:(await this.collect({freeBytes:Math.max(r.free,r.budget)}),(await n()).free<=0)}async sweep(){let e=0;for(let t of this._areas.values())e+=await t.sweep(),t.kind===h.SCRATCH&&(e+=await t.clear());return e}_changed(e){this.dispatchEvent({type:`change`,area:e})}_issue(e,t,n={}){this.dispatchEvent({type:`issue`,code:e,message:t,detail:n})}_writeFailed(t,n){let r=n?.name===`QuotaExceededError`;this._issue(r?e.STORAGE_QUOTA_EXCEEDED:e.STORAGE_WRITE_FAILED,`${t}: ${n?.message??n}`,{area:t,error:n?.name})}dispose(){this._transport?.dispose(),this._transport=null,this._areas.clear()}};function k({namespace:e,root:t}){let n=new m(t);n.inline=!0;let r=new O({root:t,transport:n,namespace:e});return r.sweep().catch(()=>{}),r}const A=Object.freeze({IMMUTABLE:`immutable`,REVALIDATE:`revalidate`,NETWORK:`network`}),j=(e,t)=>({loaded:e,total:t,lengthComputable:t>0&&e<=t}),M=(e,t)=>e.headers?.get?.(t)??null,N=e=>e.reason??new DOMException(`aborted`,`AbortError`);function P(e){try{let t=new URL(e,globalThis.location?.href??`http://localhost/`).pathname;return decodeURIComponent(t.split(`/`).pop())||`download`}catch{return`download`}}async function F(e,{onProgress:t,signal:n}){let r=Number(M(e,`content-length`))||0,i=M(e,`content-type`)??``;if(!e.body)return new Blob([await e.arrayBuffer()],{type:i});let a=e.body.getReader(),o=[],s=0;for(;;){if(n?.aborted)throw a.cancel().catch(()=>{}),N(n);let{done:e,value:i}=await a.read();if(e)break;o.push(i),s+=i.length,t?.(j(s,r))}return new Blob(o,{type:i})}const I=(e,t,n)=>new File([e],t,{type:n||e.type,lastModified:e.lastModified??Date.now()}),L=()=>{};var R=class{constructor(e){this._storage=e,this._revalidating=new Set}get _area(){return this._storage?.area(g.DOWNLOADS)??null}async fetch(e,{key:t=e,name:n=P(e),policy:r=A.REVALIDATE,maxAgeMs:i=864e5,onProgress:a=null,signal:o=null,fetchOptions:s={}}={}){let c=this._area;if(c&&r!==A.NETWORK){let o=await c.open(t);if(o){let c=await o.file(`data`);if(c)return r===A.REVALIDATE&&Date.now()-(o.extra.checkedAt??0)>=i&&this._revalidate(e,t,n,o.extra,s),a?.(j(c.size,c.size)),{file:I(c,n,o.extra.contentType),release:()=>o.release(),fromCache:!0};o.release()}}return this._download(e,t,n,{onProgress:a,signal:o,fetchOptions:s,cache:!!c})}async has(e){return await this._area?.has(e)===!0}async _download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:o}){if(i?.aborted)throw N(i);let s=await fetch(e,{...a,signal:i});if(!s.ok)throw Error(`HTTP ${s.status} fetching ${e}`);let c=Number(M(s,`content-length`))||0,l={url:e,contentType:M(s,`content-type`)??``,lastModified:M(s,`last-modified`),contentLength:c||null,checkedAt:Date.now()},u=o&&s.body?await this._area.create(t,{label:n,expectedBytes:c}):null;if(!u)return{file:I(await F(s,{onProgress:r,signal:i}),n,l.contentType),release:L,fromCache:!1};try{await u.writeStream(`data`,s.body,{signal:i,onProgress:e=>r?.(j(e,c))}),await u.commit(l)}catch(o){if(await u.abort(),o?.name!==`QuotaExceededError`)throw o;return this._download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:!1})}let d=await this._area.open(t,{wait:!0}),f=d&&await d.file(`data`);if(!f)throw d?.release(),Error(`storage: ${n} vanished right after it was saved`);return{file:I(f,n,l.contentType),release:()=>d.release(),fromCache:!1}}async _revalidate(e,t,n,r,i){if(this._revalidating.has(t))return;this._revalidating.add(t);let a=!1;try{let t=new Headers(i?.headers);t.set(`Range`,`bytes=0-0`);let n=await fetch(e,{...i,headers:t});if(n.body?.cancel().catch(()=>{}),n.ok){let e=M(n,`last-modified`),t=n.status===206?Number(M(n,`content-range`)?.match(/\\/(\\d+)$/)?.[1])||null:Number(M(n,`content-length`))||null;a=!!(e&&r.lastModified&&e!==r.lastModified||t&&r.contentLength&&t!==r.contentLength)}}catch{}try{if(a){let{release:r}=await this._download(e,t,n,{fetchOptions:i,cache:!0});r()}else await this._area.patchMeta(t,{extra:{...r,checkedAt:Date.now()}})}catch{}finally{this._revalidating.delete(t)}}};let z={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`,storage:`auto`},B=null;async function V(){return B||(B=await import(z.ortRuntimeUrl),B.env.wasm.wasmPaths=z.ortWasmPaths,B.env.logLevel=`error`,B)}let H=null,U=null,W=null;function G(){return W??=(async()=>{if(z.storage===!1||!navigator.storage?.getDirectory)return new R(null);try{let e=await(await navigator.storage.getDirectory()).getDirectoryHandle(z.cacheNamespace,{create:!0}),t=k({namespace:z.cacheNamespace,root:e});return await K(t).catch(()=>{}),new R(t)}catch{return new R(null)}})(),W}async function K(e){let t=`${z.cacheNamespace}:ai-upscaler-models`;if(typeof indexedDB>`u`||!indexedDB.databases||!(await indexedDB.databases()).some(e=>e.name===t))return;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onerror=()=>n(r.error),r.onsuccess=()=>{let t=r.result;if(!t.objectStoreNames.contains(`models`)){t.close(),e([]);return}let i=[],a=t.transaction(`models`,`readonly`).objectStore(`models`).openCursor();a.onerror=()=>n(a.error),a.onsuccess=()=>{let n=a.result;if(!n){t.close(),e(i);return}i.push([n.key,n.value]),n.continue()}}}),r=e.area(`downloads`);for(let[e,t]of n){if(typeof e!=`string`||!(t instanceof ArrayBuffer)||await r.has(e))continue;let n=await r.create(e,{label:e.split(`/`).pop(),expectedBytes:t.byteLength});n&&(await n.write(`data`,t,{transfer:!0}),await n.commit({url:e,contentType:`application/octet-stream`,checkedAt:Date.now()}))}await new Promise(e=>{let n=indexedDB.deleteDatabase(t);n.onsuccess=n.onerror=n.onblocked=()=>e()})}async function q(e){let{file:t,release:n,fromCache:r}=await(await G()).fetch(e);try{let e=await t.arrayBuffer();return r&&console.log(`AI Upscaler Worker: model loaded from cache (${(e.byteLength/1024/1024).toFixed(1)}MB)`),e}finally{n()}}async function J(e,t){if(H&&U===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}H&&=(await H.release(),null);let[n,r]=await Promise.all([q(e),V()]);H=await r.InferenceSession.create(n,t),U=e;let i=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||``);i=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${i}`)}catch{}let a=(n.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${a}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:i})}async function Y(e,t,n,r){let i=await V(),a=H.inputNames[0],o=H.outputNames[0],s=new i.Tensor(`float32`,e,[1,3,n,t]),c=(await H.run({[a]:s}))[o].data;self.postMessage({type:`inferred`,outputData:c,id:r},[c.buffer])}self.onmessage=async e=>{let{type:t}=e.data;try{t===`load`?(e.data.ortRuntimeUrl&&(z.ortRuntimeUrl=e.data.ortRuntimeUrl),e.data.ortWasmPaths&&(z.ortWasmPaths=e.data.ortWasmPaths),e.data.cacheNamespace&&(z.cacheNamespace=e.data.cacheNamespace),e.data.storage!==void 0&&(z.storage=e.data.storage),await J(e.data.url,e.data.sessionOptions)):t===`infer`?await Y(e.data.tileData,e.data.width,e.data.height,e.data.id):t===`dispose`&&H&&(await H.release(),H=null,U=null)}catch(t){self.postMessage({type:`error`,message:t.message,id:e.data?.id})}};", ms = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ps], { type: "text/javascript;charset=utf-8" });
3799
- function hs(e) {
3806
+ }, bs = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,ADAPTER_UNAVAILABLE:`adapter.unavailable`,DEVICE_UNAVAILABLE:`device.unavailable`,WEBGPU_UNAVAILABLE:`webgpu.unavailable`,ASSET_UNREACHABLE:`asset.unreachable`,ASSET_AMBIGUOUS_ENTRY:`asset.ambiguous_entry`,ASSET_ARCHIVE_TOO_LARGE:`asset.archive_too_large`,ASSET_ENTRY_TOO_LARGE:`asset.entry_too_large`,ASSET_PARAMETERS_IGNORED:`asset.parameters_ignored`,TEXTURE_BUILD_FAILED:`texture.build_failed`,TEXTURE_PROCESSING_FALLBACK:`texture.processing_fallback`,TEXTURE_LIMIT_EXCEEDED:`texture.limit_exceeded`,ENVIRONMENT_LOAD_FAILED:`environment.load_failed`,SETTING_UNKNOWN_KEY:`setting.unknown_key`,RENDER_SIZE_DECLINED:`render.size_declined`,STAGE_RENDER_FAILED:`stage.render_failed`,RENDER_RESERVE_CAPPED:`render.reserve_capped`,SCENE_MEMORY_BUDGET:`scene.memory_budget`,EMISSIVE_INSTANCES_COLLAPSED:`emissive.instances_collapsed`,REFIT_SHARED_GEOMETRY:`refit.shared_geometry`,VIEW_TRANSFORM_DISPLAY_MISMATCH:`viewTransform.display_mismatch`,VIEW_TRANSFORM_BAKE_FAILED:`viewTransform.bake_failed`,COLOR_CONFIG_LOAD_FAILED:`color.config_load_failed`,STORAGE_UNAVAILABLE:`storage.unavailable`,STORAGE_QUOTA_EXCEEDED:`storage.quota_exceeded`,STORAGE_WRITE_FAILED:`storage.write_failed`,STORAGE_READ_FAILED:`storage.read_failed`,STORAGE_ENTRY_CORRUPT:`storage.entry_corrupt`,STORAGE_CACHE_MISMATCH:`storage.cache_mismatch`,DENOISER_UNAVAILABLE:`denoiser.unavailable`,OUTPUT_SOURCE_FALLBACK:`output.source_fallback`,OUTPUT_TONEMAP_FALLBACK:`output.tonemap_fallback`,LIGHT_PLACEHOLDER_SKIPPED:`light.placeholder_skipped`,CAPABILITY_MISSING:`capability.missing`});Object.freeze({ERROR:`error`,WARNING:`warning`});const t=new Map;function n(e,t){return e.exclusive||t===`exclusive`&&e.shared>0?!1:(t===`exclusive`?e.exclusive=!0:e.shared++,!0)}function r(e,r,a){let o=t.get(e);o||(o={shared:0,exclusive:!1,queue:[]},t.set(e,o));let s=i(()=>{for(r===`exclusive`?o.exclusive=!1:o.shared--;o.queue.length&&n(o,o.queue[0].mode);)o.queue.shift().grant();!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e)});return o.queue.length===0&&n(o,r)?Promise.resolve(s):a?(!o.exclusive&&o.shared===0&&o.queue.length===0&&t.delete(e),Promise.resolve(null)):new Promise(e=>o.queue.push({mode:r,grant:()=>e(s)}))}function i(e){let t=!1;return()=>{t||(t=!0,e())}}const a=()=>typeof navigator<`u`&&navigator.locks?.request?navigator.locks:null;function o(e,{mode:t=`exclusive`,ifAvailable:n=!1}={}){let o=a();return o?new Promise((r,a)=>{o.request(e,{mode:t,ifAvailable:n},e=>{if(!e){r(null);return}return new Promise(e=>r(i(e)))}).catch(a)}):r(e,t,n)}async function s(){let e=a();if(!e)return new Set(t.keys());let{held:n=[]}=await e.query();return new Set(n.map(e=>e.name))}const c=new TextEncoder;function l(e){let t=``;for(let n of e)t+=n.toString(16).padStart(2,`0`);return t}async function u(e){let t=typeof e==`string`?c.encode(e):e;return l(new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)))}async function d(e){return(await u(e)).slice(0,32)}var f=class{constructor(){this._handlers=new Map}addEventListener(e,t){this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t)}removeEventListener(e,t){this._handlers.get(e)?.delete(t)}dispatchEvent(e){for(let t of[...this._handlers.get(e.type)??[]])t.call(this,e)}},p=class{constructor(e){this._root=e,this._writers=new Map,this._nextId=1}async _dir(e,t){let n=await this._root;for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n}async openWriter({path:e,name:t,truncate:n=!0,length:r}){let i=await(await(await this._dir(e,!0)).getFileHandle(t,{create:!0})).createSyncAccessHandle();n?i.truncate(0):r!==void 0&&i.getSize()>r&&i.truncate(r);let a=this._nextId++;return this._writers.set(a,{handle:i,end:i.getSize()}),{id:a}}write({id:e,buffer:t,byteOffset:n=0,byteLength:r,at:i}){let a=this._writers.get(e);if(!a)throw Error(`storage: writer ${e} is not open`);let o=new Uint8Array(t,n,r??t.byteLength-n),s=i??a.end,c=0;for(;c<o.length;){let e=a.handle.write(o.subarray(c),{at:s+c});if(e<=0)throw Error(`storage: write made no progress`);c+=e}return a.end=Math.max(a.end,s+o.length),{bytes:o.length}}closeWriter({id:e,abort:t=!1}){let n=this._writers.get(e);if(!n)return{size:0};this._writers.delete(e);try{return t||n.handle.flush(),{size:n.handle.getSize()}}finally{n.handle.close()}}async writeFile({path:e,name:t,buffer:n,byteOffset:r=0,byteLength:i}){let{id:a}=await this.openWriter({path:e,name:t});try{return this.write({id:a,buffer:n,byteOffset:r,byteLength:i}),this.closeWriter({id:a})}catch(e){throw this.closeWriter({id:a,abort:!0}),e}}async readRange({path:e,name:t,offset:n=0,length:r}){let i=await(await this._dir(e,!1)).getFileHandle(t),a=null;try{a=await i.createSyncAccessHandle()}catch(e){if(e.name!==`NoModificationAllowedError`)throw e}if(!a){let e=await i.getFile(),t=r===void 0?e.size:n+r;return{buffer:await e.slice(n,t).arrayBuffer()}}try{let e=a.getSize(),t=Math.max(0,Math.min(r??e-n,e-n)),i=new ArrayBuffer(t);return a.read(i,{at:n}),{buffer:i}}finally{a.close()}}dispose(){for(let e of[...this._writers.keys()])this.closeWriter({id:e,abort:!0})}},m=class{constructor(e){this._ops=new p(e)}async call(e,t){return this._ops[e](t)}dispose(){this._ops.dispose()}};const h=Object.freeze({CACHE:`cache`,USER:`user`,SCRATCH:`scratch`}),g=Object.freeze({DOWNLOADS:`downloads`,ARCHIVES:`archives`,SCENES:`scenes`,CDF:`cdf`,SPILL:`spill`}),_=`meta.json`,v=100*1024**3,y=64*1024**2,b=8*1024**2,x=new TextEncoder;function S(e,{copy:t,transfer:n}){if(typeof e==`string`&&(e=x.encode(e)),e instanceof ArrayBuffer){if(!t||n)return{args:{buffer:e},list:[e]};let r=e.slice(0);return{args:{buffer:r},list:[r]}}if(!ArrayBuffer.isView(e))throw TypeError(`storage: write expects an ArrayBuffer, a typed array, a Blob or a string`);let{buffer:r,byteOffset:i,byteLength:a}=e,o=typeof SharedArrayBuffer<`u`&&r instanceof SharedArrayBuffer;if(!t)return{args:{buffer:r,byteOffset:i,byteLength:a},list:[]};if(o){let e=new Uint8Array(a);return e.set(new Uint8Array(r,i,a)),{args:{buffer:e.buffer},list:[e.buffer]}}if(n&&i===0&&a===r.byteLength)return{args:{buffer:r},list:[r]};let s=r.slice(i,i+a);return{args:{buffer:s},list:[s]}}async function C(e,t){try{let n=await(await e.getFileHandle(t)).getFile();return JSON.parse(await n.text())}catch{return null}}async function*w(e){for await(let[t,n]of e.entries())n.kind===`directory`&&(yield[t,n])}var T=class{constructor(e,t,n,r,i){this.area=e,this.id=t,this.key=n.key,this.meta=n,this._dir=r,this._release=i}get bytes(){return this.meta.bytes}get extra(){return this.meta.extra??{}}async file(t){try{return await(await this._dir.getFileHandle(t)).getFile()}catch(n){return this.area.manager._issue(e.STORAGE_READ_FAILED,`could not read ${this.area.name}/${this.id}/${t}`,{error:n.message}),null}}async json(e){let t=await this.file(e);return t?JSON.parse(await t.text()):null}release(){this._release?.(),this._release=null}},E=class{constructor(e,t,n,r,i,{sizes:a={},append:o=!1}={}){this.area=e,this.id=t,this.key=n,this._info=r,this._release=i,this._writers=new Map,this._sizes={...a},this._append=o,this._done=!1,this._committedBytes=o?Object.values(a).reduce((e,t)=>e+t,0):0}get _transport(){return this.area.manager._transport}get _path(){return[this.area.name,this.id]}async _writer(e){let t=this._writers.get(e);if(!t){let n=this._append&&e in this._sizes,r=n&&(this._info.growable??[]).includes(e)?this._sizes[e]:void 0;t=this._transport.call(`openWriter`,{path:this._path,name:e,truncate:!n,length:r}),this._writers.set(e,t)}return(await t).id}async write(e,t,{at:n,transfer:r=!1}={}){this._assertOpen();let{args:i,list:a}=(typeof Blob<`u`&&t instanceof Blob?null:S(t,{copy:!0,transfer:r}))??S(await t.arrayBuffer(),{copy:!0,transfer:!0}),o=await this._writer(e);return this._transport.call(`write`,{id:o,at:n,...i},a)}async writeFile(e,t){this._assertOpen(),typeof Blob<`u`&&t instanceof Blob&&(t=await t.arrayBuffer());let{args:n,list:r}=S(t,{copy:!0,transfer:!0}),{size:i}=await this._transport.call(`writeFile`,{path:this._path,name:e,...n},r);return this._sizes[e]=i,i}writeJSON(e,t){return this.writeFile(e,JSON.stringify(t))}async writeStream(e,t,{onProgress:n=null,signal:r=null,batchBytes:i=b}={}){let a=t.getReader(),o=[],s=new Uint8Array(i),c=0,l=0,u=async()=>{if(c===0)return;let t=c===i?s:s.slice(0,c);s=new Uint8Array(i),c=0,o.push(this.write(e,t,{transfer:!0})),o.length>=4&&await o.shift()};try{for(;;){if(r?.aborted)throw r.reason??new DOMException(`aborted`,`AbortError`);let{done:e,value:t}=await a.read();if(e)break;let o=0;for(;o<t.length;){let e=Math.min(t.length-o,i-c);s.set(t.subarray(o,o+e),c),c+=e,o+=e,l+=e,c===i&&await u()}n?.(l)}return await u(),await Promise.all(o),l}catch(e){throw a.cancel().catch(()=>{}),await Promise.allSettled(o),e}}async commit(e={}){this._assertOpen(),this._done=!0;try{for(let[e,t]of this._writers){let{size:n}=await this._transport.call(`closeWriter`,{id:(await t).id});this._sizes[e]=n}this._writers.clear();let t=Date.now(),n={v:1,key:this.key,label:this._info.label??``,kind:this.area.kind,files:{...this._sizes},bytes:Object.values(this._sizes).reduce((e,t)=>e+t,0),createdAt:this._info.createdAt??t,lastUsed:t,pinned:this._info.pinned===!0,extra:{...this._info.extra,...e}},r=this._info.growable??[];r.length&&(n.growable=r);let{args:i,list:a}=S(JSON.stringify(n),{copy:!1});return await this._transport.call(`writeFile`,{path:this._path,name:_,...i},a),this.area.kind===h.CACHE&&this.area.manager._countCacheBytes(n.bytes-this._committedBytes),this.area.manager._changed(this.area.name),n}catch(e){throw await this._discard(),this.area.manager._writeFailed(this.area.name,e),e}finally{this._release?.(),this._release=null}}async abort(){if(!this._done){this._done=!0;try{this._append?await this._closeAll(!0):await this._discard()}finally{this._release?.(),this._release=null}}}async _closeAll(e){for(let t of this._writers.values())try{await this._transport.call(`closeWriter`,{id:(await t).id,abort:e})}catch{}this._writers.clear()}async _discard(){await this._closeAll(!0),await this.area._removeDir(this.id)}_assertOpen(){if(this._done)throw Error(`storage: entry ${this.area.name}/${this.id} is already committed or aborted`)}},D=class{constructor(e,t,n){this.manager=e,this.name=t,this.kind=n}_lockName(e){return`${this.manager.namespace}:store:${this.name}:${e}`}async _dir(e=!1){try{return await this.manager._root.getDirectoryHandle(this.name,{create:e})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _entryDir(e,t=!1){let n=await this._dir(t);if(!n)return null;try{return await n.getDirectoryHandle(e,{create:t})}catch(e){if(e.name===`NotFoundError`)return null;throw e}}async _removeDir(e){let t=await this._dir(!1);if(t)try{await t.removeEntry(e,{recursive:!0})}catch(e){if(e.name!==`NotFoundError`)throw e}}async _validMeta(e,t=null){let n=await C(e,_);if(!n||n.v!==1||typeof n.key!=`string`||t!==null&&n.key!==t)return null;let r=n.growable??[];for(let[t,i]of Object.entries(n.files??{}))try{let n=await(await e.getFileHandle(t)).getFile();if(n.size!==i&&!(r.includes(t)&&n.size>i))return null}catch{return null}return n}async open(t,{wait:n=!1}={}){let r=await d(t),i=await o(this._lockName(r),{mode:`shared`,ifAvailable:!n});if(!i)return null;try{let e=await this._entryDir(r),n=e?await this._validMeta(e,t):null;return n?(Date.now()-n.lastUsed>36e5&&this._touch(r,n),new T(this,r,n,e,i)):(i(),null)}catch(t){return i(),this.manager._issue(e.STORAGE_READ_FAILED,`could not open ${this.name} entry`,{error:t.message}),null}}async has(e){let t=await this.open(e);return t?.release(),!!t}_touch(e,t){let n={...t,lastUsed:Date.now()},{args:r,list:i}=S(JSON.stringify(n),{copy:!1});this.manager._transport.call(`writeFile`,{path:[this.name,e],name:_,...r},i).catch(()=>{}),t.lastUsed=n.lastUsed}async create(t,{label:n=``,pinned:r=!1,expectedBytes:i=0,extra:a={},growable:s=[]}={}){let c=await d(t),l=await o(this._lockName(c),{mode:`exclusive`});try{return i>0&&!await this.manager.ensureSpace(i,this.kind)?(l(),this.manager._issue(e.STORAGE_QUOTA_EXCEEDED,`no room for ${(i/1048576).toFixed(0)} MB in ${this.name}`,{area:this.name,expectedBytes:i}),null):(await this._removeDir(c),await this._entryDir(c,!0),new E(this,c,t,{label:n,pinned:r,extra:a,growable:s},l))}catch(e){return l(),this.manager._writeFailed(this.name,e),null}}async patchMeta(e,t){let n=await d(e),r=await o(this._lockName(n),{mode:`shared`,ifAvailable:!0});if(!r)return!1;try{let r=await this._entryDir(n),i=r?await this._validMeta(r,e):null;if(!i)return!1;let{args:a,list:o}=S(JSON.stringify({...i,...t,v:1,key:e}),{copy:!1});return await this.manager._transport.call(`writeFile`,{path:[this.name,n],name:_,...a},o),!0}finally{r()}}async edit(e){let t=await d(e),n=await o(this._lockName(t),{mode:`exclusive`});try{let r=await this._entryDir(t),i=r?await this._validMeta(r,e):null;if(!i)return n(),null;let a={label:i.label,pinned:i.pinned,extra:i.extra,createdAt:i.createdAt,growable:i.growable};return new E(this,t,e,a,n,{sizes:i.files,append:!0})}catch(e){return n(),this.manager._writeFailed(this.name,e),null}}async remove(e){return this.removeById(await d(e))}async removeById(e){let t=await o(this._lockName(e),{mode:`exclusive`,ifAvailable:!0});if(!t)return!1;try{return await this._removeDir(e),this.manager._changed(this.name),!0}finally{t()}}async list(){let e=await this._dir(!1);if(!e)return[];let t=[];for await(let[n,r]of w(e)){let e=await C(r,_);e?.v===1&&t.push({...e,id:n})}return t}async clear(){let e=0;for(let{id:t}of await this.list())await this.removeById(t)&&e++;return e}async sweep(){let e=await this._dir(!1);if(!e)return 0;let t=await s(),n=0;for await(let[r,i]of w(e))t.has(this._lockName(r))||await this._validMeta(i)||await this.removeById(r)&&n++;return n}},O=class extends f{constructor({root:e,transport:t,namespace:n}){super(),this.namespace=n,this._root=e,this._transport=t,this._areas=new Map,this._budget=null,this._cacheTotal=null;for(let e of Object.values(g))this.defineArea(e,{kind:e===g.SPILL?h.SCRATCH:h.CACHE})}defineArea(e,{kind:t=h.CACHE}={}){let n=this._areas.get(e);if(n){if(n.kind!==t)throw Error(`storage: area \"${e}\" is already defined as ${n.kind}`);return n}let r=new D(this,e,t);return this._areas.set(e,r),r}area(e){let t=this._areas.get(e);if(!t)throw Error(`storage: unknown area \"${e}\"`);return t}get areaNames(){return[...this._areas.keys()]}async estimate(){let e=typeof navigator<`u`?navigator.storage:null;if(!e?.estimate)return{quota:1/0,usage:0};let{quota:t=1/0,usage:n=0}=await e.estimate();return{quota:t,usage:n}}async persisted(){return await globalThis.navigator?.storage?.persisted?.()===!0}async persist(){let e=await globalThis.navigator?.storage?.persist?.()===!0;return this._changed(null),e}async budget(){if(this._budget!==null)return this._budget;let{quota:e}=await this.estimate();return Math.min(e*.3,v)}setBudget(e){this._budget=e===null?null:Math.max(0,e),this._changed(null)}async _cacheBytes(){let e=this._cacheTotal;return(!e||Date.now()-e.at>3e4)&&(e=this._cacheTotal={at:Date.now(),bytes:0,ready:null},e.ready=this._cacheEntries().then(t=>{e.bytes+=t.reduce((e,t)=>e+(t.meta.bytes??0),0)}),e.ready.catch(()=>{this._cacheTotal===e&&(this._cacheTotal=null)})),await e.ready,e.bytes}_countCacheBytes(e){this._cacheTotal&&(this._cacheTotal.bytes+=e)}async _cacheEntries(){let e=[];for(let t of this._areas.values())if(t.kind===h.CACHE)for(let n of await t.list())e.push({area:t,meta:n});return e}async usage(){let{quota:e,usage:t}=await this.estimate(),n={},r=0;for(let e of this._areas.values()){let t=await e.list(),i=t.reduce((e,t)=>e+(t.bytes??0),0);n[e.name]={kind:e.kind,bytes:i,entries:t.length},e.kind===h.CACHE&&(r+=i)}return{quota:e,usage:t,persisted:await this.persisted(),budget:await this.budget(),cacheBytes:r,areas:n}}async collect({freeBytes:e=null}={}){let t=await this._cacheEntries(),n=await this.budget(),r=this._cacheTotal={at:Date.now(),bytes:t.reduce((e,t)=>e+(t.meta.bytes??0),0),ready:null},i=e??Math.max(0,r.bytes-n);if(i<=0)return 0;let a=await s(),o=t.filter(({area:e,meta:t})=>!t.pinned&&!a.has(e._lockName(t.id))).sort((e,t)=>e.meta.lastUsed-t.meta.lastUsed),c=0;for(let{area:e,meta:t}of o){if(c>=i)break;await e.removeById(t.id)&&(c+=t.bytes??0,r.bytes-=t.bytes??0)}return c}async ensureSpace(e,t=h.CACHE){let n=async()=>{let{quota:n,usage:r}=await this.estimate(),i=e+y-(n-r);return t===h.CACHE?{free:i,budget:await this._cacheBytes()+e-await this.budget()}:{free:i,budget:0}},r=await n();return r.free<=0&&r.budget<=0?!0:(await this.collect({freeBytes:Math.max(r.free,r.budget)}),(await n()).free<=0)}async sweep(){let e=0;for(let t of this._areas.values())e+=await t.sweep(),t.kind===h.SCRATCH&&(e+=await t.clear());return e}_changed(e){this.dispatchEvent({type:`change`,area:e})}_issue(e,t,n={}){this.dispatchEvent({type:`issue`,code:e,message:t,detail:n})}_writeFailed(t,n){let r=n?.name===`QuotaExceededError`;this._issue(r?e.STORAGE_QUOTA_EXCEEDED:e.STORAGE_WRITE_FAILED,`${t}: ${n?.message??n}`,{area:t,error:n?.name})}dispose(){this._transport?.dispose(),this._transport=null,this._areas.clear()}};function k({namespace:e,root:t}){let n=new m(t);n.inline=!0;let r=new O({root:t,transport:n,namespace:e});return r.sweep().catch(()=>{}),r}const A=Object.freeze({IMMUTABLE:`immutable`,REVALIDATE:`revalidate`,NETWORK:`network`}),j=(e,t)=>({loaded:e,total:t,lengthComputable:t>0&&e<=t}),M=(e,t)=>e.headers?.get?.(t)??null,N=e=>e.reason??new DOMException(`aborted`,`AbortError`);function P(e){try{let t=new URL(e,globalThis.location?.href??`http://localhost/`).pathname;return decodeURIComponent(t.split(`/`).pop())||`download`}catch{return`download`}}async function F(e,{onProgress:t,signal:n}){let r=Number(M(e,`content-length`))||0,i=M(e,`content-type`)??``;if(!e.body)return new Blob([await e.arrayBuffer()],{type:i});let a=e.body.getReader(),o=[],s=0;for(;;){if(n?.aborted)throw a.cancel().catch(()=>{}),N(n);let{done:e,value:i}=await a.read();if(e)break;o.push(i),s+=i.length,t?.(j(s,r))}return new Blob(o,{type:i})}const I=(e,t,n)=>new File([e],t,{type:n||e.type,lastModified:e.lastModified??Date.now()}),L=()=>{};var R=class{constructor(e){this._storage=e,this._revalidating=new Set}get _area(){return this._storage?.area(g.DOWNLOADS)??null}async fetch(e,{key:t=e,name:n=P(e),policy:r=A.REVALIDATE,maxAgeMs:i=864e5,onProgress:a=null,signal:o=null,fetchOptions:s={}}={}){let c=this._area;if(c&&r!==A.NETWORK){let o=await c.open(t);if(o){let c=await o.file(`data`);if(c)return r===A.REVALIDATE&&Date.now()-(o.extra.checkedAt??0)>=i&&this._revalidate(e,t,n,o.extra,s),a?.(j(c.size,c.size)),{file:I(c,n,o.extra.contentType),release:()=>o.release(),fromCache:!0};o.release()}}return this._download(e,t,n,{onProgress:a,signal:o,fetchOptions:s,cache:!!c})}async has(e){return await this._area?.has(e)===!0}async _download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:o}){if(i?.aborted)throw N(i);let s=await fetch(e,{...a,signal:i});if(!s.ok)throw Error(`HTTP ${s.status} fetching ${e}`);let c=Number(M(s,`content-length`))||0,l={url:e,contentType:M(s,`content-type`)??``,lastModified:M(s,`last-modified`),contentLength:c||null,checkedAt:Date.now()},u=o&&s.body?await this._area.create(t,{label:n,expectedBytes:c}):null;if(!u)return{file:I(await F(s,{onProgress:r,signal:i}),n,l.contentType),release:L,fromCache:!1};try{await u.writeStream(`data`,s.body,{signal:i,onProgress:e=>r?.(j(e,c))}),await u.commit(l)}catch(o){if(await u.abort(),o?.name!==`QuotaExceededError`)throw o;return this._download(e,t,n,{onProgress:r,signal:i,fetchOptions:a,cache:!1})}let d=await this._area.open(t,{wait:!0}),f=d&&await d.file(`data`);if(!f)throw d?.release(),Error(`storage: ${n} vanished right after it was saved`);return{file:I(f,n,l.contentType),release:()=>d.release(),fromCache:!1}}async _revalidate(e,t,n,r,i){if(this._revalidating.has(t))return;this._revalidating.add(t);let a=!1;try{let t=new Headers(i?.headers);t.set(`Range`,`bytes=0-0`);let n=await fetch(e,{...i,headers:t});if(n.body?.cancel().catch(()=>{}),n.ok){let e=M(n,`last-modified`),t=n.status===206?Number(M(n,`content-range`)?.match(/\\/(\\d+)$/)?.[1])||null:Number(M(n,`content-length`))||null;a=!!(e&&r.lastModified&&e!==r.lastModified||t&&r.contentLength&&t!==r.contentLength)}}catch{}try{if(a){let{release:r}=await this._download(e,t,n,{fetchOptions:i,cache:!0});r()}else await this._area.patchMeta(t,{extra:{...r,checkedAt:Date.now()}})}catch{}finally{this._revalidating.delete(t)}}};let z={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`,storage:`auto`},B=null;async function V(){return B||(B=await import(z.ortRuntimeUrl),B.env.wasm.wasmPaths=z.ortWasmPaths,B.env.logLevel=`error`,B)}let H=null,U=null,W=null;function G(){return W??=(async()=>{if(z.storage===!1||!navigator.storage?.getDirectory)return new R(null);try{let e=await(await navigator.storage.getDirectory()).getDirectoryHandle(z.cacheNamespace,{create:!0}),t=k({namespace:z.cacheNamespace,root:e});return await K(t).catch(()=>{}),new R(t)}catch{return new R(null)}})(),W}async function K(e){let t=`${z.cacheNamespace}:ai-upscaler-models`;if(typeof indexedDB>`u`||!indexedDB.databases||!(await indexedDB.databases()).some(e=>e.name===t))return;let n=await new Promise((e,n)=>{let r=indexedDB.open(t);r.onerror=()=>n(r.error),r.onsuccess=()=>{let t=r.result;if(!t.objectStoreNames.contains(`models`)){t.close(),e([]);return}let i=[],a=t.transaction(`models`,`readonly`).objectStore(`models`).openCursor();a.onerror=()=>n(a.error),a.onsuccess=()=>{let n=a.result;if(!n){t.close(),e(i);return}i.push([n.key,n.value]),n.continue()}}}),r=e.area(`downloads`);for(let[e,t]of n){if(typeof e!=`string`||!(t instanceof ArrayBuffer)||await r.has(e))continue;let n=await r.create(e,{label:e.split(`/`).pop(),expectedBytes:t.byteLength});n&&(await n.write(`data`,t,{transfer:!0}),await n.commit({url:e,contentType:`application/octet-stream`,checkedAt:Date.now()}))}await new Promise(e=>{let n=indexedDB.deleteDatabase(t);n.onsuccess=n.onerror=n.onblocked=()=>e()})}async function q(e){let{file:t,release:n,fromCache:r}=await(await G()).fetch(e);try{let e=await t.arrayBuffer();return r&&console.log(`AI Upscaler Worker: model loaded from cache (${(e.byteLength/1024/1024).toFixed(1)}MB)`),e}finally{n()}}async function J(e,t){if(H&&U===e){self.postMessage({type:`loaded`,backend:`webgpu`});return}H&&=(await H.release(),null);let[n,r]=await Promise.all([q(e),V()]);H=await r.InferenceSession.create(n,t),U=e;let i=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||``);i=n?128:r?256:512,console.log(`AI Upscaler Worker: GPU=\"${t?.description||t?.device||`unknown`}\", tileSize=${i}`)}catch{}let a=(n.byteLength/1024/1024).toFixed(1);console.log(`AI Upscaler Worker: model loaded (${a}MB), backend: webgpu`),self.postMessage({type:`loaded`,backend:`webgpu`,tileSize:i})}async function Y(e,t,n,r){let i=await V(),a=H.inputNames[0],o=H.outputNames[0],s=new i.Tensor(`float32`,e,[1,3,n,t]),c=(await H.run({[a]:s}))[o].data;self.postMessage({type:`inferred`,outputData:c,id:r},[c.buffer])}self.onmessage=async e=>{let{type:t}=e.data;try{t===`load`?(e.data.ortRuntimeUrl&&(z.ortRuntimeUrl=e.data.ortRuntimeUrl),e.data.ortWasmPaths&&(z.ortWasmPaths=e.data.ortWasmPaths),e.data.cacheNamespace&&(z.cacheNamespace=e.data.cacheNamespace),e.data.storage!==void 0&&(z.storage=e.data.storage),await J(e.data.url,e.data.sessionOptions)):t===`infer`?await Y(e.data.tileData,e.data.width,e.data.height,e.data.id):t===`dispose`&&H&&(await H.release(),H=null,U=null)}catch(t){self.postMessage({type:`error`,message:t.message,id:e.data?.id})}};", xs = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", bs], { type: "text/javascript;charset=utf-8" });
3807
+ function Ss(e) {
3800
3808
  let t;
3801
3809
  try {
3802
- if (t = ms && (self.URL || self.webkitURL).createObjectURL(ms), !t) throw "";
3810
+ if (t = xs && (self.URL || self.webkitURL).createObjectURL(xs), !t) throw "";
3803
3811
  let n = new Worker(t, {
3804
3812
  type: "module",
3805
3813
  name: e?.name
@@ -3808,7 +3816,7 @@ function hs(e) {
3808
3816
  (self.URL || self.webkitURL).revokeObjectURL(t);
3809
3817
  }), n;
3810
3818
  } catch {
3811
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(ps), {
3819
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(bs), {
3812
3820
  type: "module",
3813
3821
  name: e?.name
3814
3822
  });
@@ -3816,7 +3824,7 @@ function hs(e) {
3816
3824
  }
3817
3825
  //#endregion
3818
3826
  //#region src/Passes/AIUpscaler.js
3819
- var gs = {
3827
+ var Cs = {
3820
3828
  fast: {
3821
3829
  2: "2x-spanx2-ch48.onnx",
3822
3830
  4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
@@ -3830,17 +3838,17 @@ var gs = {
3830
3838
  4: "4xNomos2_hq_mosr_fp32.onnx"
3831
3839
  }
3832
3840
  };
3833
- function _s() {
3841
+ function ws() {
3834
3842
  let { upscalerModelBaseUrl: e } = it(), t = {};
3835
- for (let n in gs) {
3843
+ for (let n in Cs) {
3836
3844
  t[n] = {};
3837
- for (let r in gs[n]) t[n][r] = e + gs[n][r];
3845
+ for (let r in Cs[n]) t[n][r] = e + Cs[n][r];
3838
3846
  }
3839
3847
  return t;
3840
3848
  }
3841
- var vs = {
3849
+ var Ts = {
3842
3850
  get QUALITY_PRESETS() {
3843
- return _s();
3851
+ return ws();
3844
3852
  },
3845
3853
  TILE_SIZE: 512,
3846
3854
  TILE_OVERLAP: 16,
@@ -3851,17 +3859,17 @@ var vs = {
3851
3859
  }],
3852
3860
  graphOptimizationLevel: "all"
3853
3861
  }
3854
- }, ys = class extends ur {
3862
+ }, Es = class extends ur {
3855
3863
  constructor(e, t, n = {}) {
3856
3864
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
3857
- 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 || (() => $n), this.getSaturation = n.getSaturation || (() => 1), this.getDisplayGain = n.getDisplayGain || (() => null), this.getTransparentBackground = n.getTransparentBackground || (() => !1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || vs.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
3865
+ 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 || (() => $n), this.getSaturation = n.getSaturation || (() => 1), this.getDisplayGain = n.getDisplayGain || (() => null), this.getTransparentBackground = n.getTransparentBackground || (() => !1), this.enabled = !1, this.hdr = !1, this.scaleFactor = n.scaleFactor || 2, this.quality = n.quality || "fast", this.refreshInput = n.refreshInput || null, this.tileSize = n.tileSize || Ts.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
3858
3866
  isUpscaling: !1,
3859
3867
  isLoading: !1,
3860
3868
  abortController: null
3861
3869
  }, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Map(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._toneMapper = null;
3862
3870
  }
3863
3871
  async _ensureSession() {
3864
- let e = vs.QUALITY_PRESETS[this.quality];
3872
+ let e = Ts.QUALITY_PRESETS[this.quality];
3865
3873
  if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
3866
3874
  let t = e[this.scaleFactor];
3867
3875
  if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
@@ -3871,14 +3879,14 @@ var vs = {
3871
3879
  message: `Loading ${this.scaleFactor}x upscale model...`
3872
3880
  });
3873
3881
  try {
3874
- this._worker ||= new hs(), await new Promise((e, n) => {
3882
+ this._worker ||= new Ss(), await new Promise((e, n) => {
3875
3883
  let r = (t) => {
3876
3884
  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)));
3877
3885
  }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = it();
3878
3886
  this._worker.addEventListener("message", r), this._worker.postMessage({
3879
3887
  type: "load",
3880
3888
  url: t,
3881
- sessionOptions: vs.SESSION_OPTIONS,
3889
+ sessionOptions: Ts.SESSION_OPTIONS,
3882
3890
  ortRuntimeUrl: i,
3883
3891
  ortWasmPaths: a,
3884
3892
  cacheNamespace: o,
@@ -3953,7 +3961,7 @@ var vs = {
3953
3961
  alpha: !0
3954
3962
  });
3955
3963
  this._cacheUpscaledAlpha(t, n * i, r * i);
3956
- let o = vs.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
3964
+ let o = Ts.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
3957
3965
  for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
3958
3966
  if (e.aborted) throw new DOMException("Aborted", "AbortError");
3959
3967
  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);
@@ -4096,7 +4104,7 @@ var vs = {
4096
4104
  this.hdr = !!e;
4097
4105
  }
4098
4106
  setQuality(e) {
4099
- if (!vs.QUALITY_PRESETS[e]) {
4107
+ if (!Ts.QUALITY_PRESETS[e]) {
4100
4108
  console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
4101
4109
  return;
4102
4110
  }
@@ -4119,9 +4127,9 @@ var vs = {
4119
4127
  async dispose() {
4120
4128
  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._toneMapper?.dispose(), this._toneMapper = null, console.log("AIUpscaler disposed");
4121
4129
  }
4122
- }, bs = We("neural"), xs = 120, Ss = 2, Cs = 1, ws = 0, Ts = 300, Es = 5, Ds = 3, Os = 3, ks = 16, As = (e) => Math.max(0, 1 - e / ks), js = class extends ur {
4130
+ }, Ds = We("neural"), Os = 120, ks = 2, As = 1, js = 0, Ms = 300, Ns = 5, Ps = 3, Fs = 3, Is = 16, Ls = (e) => Math.max(0, 1 - e / Is), Rs = class extends ur {
4123
4131
  constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a, getDisplayGain: o = null, issues: s = null }) {
4124
- super(), this.renderer = e, this._issues = s, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, this._getDisplayGain = o, this.denoiser = null, this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null, this.neuralRendering = !1, this.neuralRenderingSettings = {}, this._retouch = null, this._superResModule = null, this._neuralPostBusy = !1, this._postIsStillComplete = null, this._postRun = null, this._postRedo = null, this._postCancelled = !1, this._finalQuality = $r.oidnQuality, this.finalDenoise = $r.enableOIDN, this.continuousDenoise = $r.continuousDenoise, this.continuousDenoiseInterval = $r.continuousDenoiseInterval, this._lastCadenceAt = -Infinity, this._lastCadenceSamples = 0, this._failedRefreshes = 0, this._cadenceSuspended = !1, this._movingDenoiseMs = [], this._movingHopeless = !1, this._holdWhileMoving = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this.temporalHistory = $r.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new yr(), this._historyCamera = {
4132
+ super(), this.renderer = e, this._issues = s, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, this._getDisplayGain = o, this.denoiser = null, this.upscaler = null, this.upscalerBackend = "esrgan", this._neuralUpscaler = null, this.neuralRendering = !1, this.neuralRenderingSettings = {}, this._retouch = null, this._superResModule = null, this._neuralPostBusy = !1, this._postIsStillComplete = null, this._postRun = null, this._postRedo = null, this._postCancelled = !1, this._finalQuality = Qr.oidnQuality, this.finalDenoise = Qr.enableOIDN, this.continuousDenoise = Qr.continuousDenoise, this.continuousDenoiseInterval = Qr.continuousDenoiseInterval, this._lastCadenceAt = -Infinity, this._lastCadenceSamples = 0, this._failedRefreshes = 0, this._cadenceSuspended = !1, this._movingDenoiseMs = [], this._movingHopeless = !1, this._holdWhileMoving = null, this._onReset = null, this._onPostProcessRefresh = null, this._onDisplayRefresh = null, this.temporalHistory = Qr.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new yr(), this._historyCamera = {
4125
4133
  world: null,
4126
4134
  projInv: null,
4127
4135
  viewProj: null,
@@ -4152,9 +4160,9 @@ var vs = {
4152
4160
  }
4153
4161
  setupDenoiser() {
4154
4162
  let e = this._stages.pathTracer;
4155
- this.denoiser = new Xo(this.renderer, {
4156
- enableOIDN: $r.enableOIDN,
4157
- oidnQuality: $r.oidnQuality,
4163
+ this.denoiser = new rs(this.renderer, {
4164
+ enableOIDN: Qr.enableOIDN,
4165
+ oidnQuality: Qr.oidnQuality,
4158
4166
  backendParams: () => ({
4159
4167
  device: this.renderer.backend.device,
4160
4168
  adapterInfo: null
@@ -4205,9 +4213,9 @@ var vs = {
4205
4213
  setupUpscaler() {
4206
4214
  if (!this.upscalerCanvas) return;
4207
4215
  let e = this._stages.pathTracer;
4208
- this.upscaler = new ys(this.upscalerCanvas, this.renderer, {
4209
- scaleFactor: $r.upscalerScale || 2,
4210
- quality: $r.upscalerQuality || "fast",
4216
+ this.upscaler = new Es(this.upscalerCanvas, this.renderer, {
4217
+ scaleFactor: Qr.upscalerScale || 2,
4218
+ quality: Qr.upscalerQuality || "fast",
4211
4219
  getSourceCanvas: () => this.renderer.domElement,
4212
4220
  refreshInput: () => {
4213
4221
  let e = this.pipeline?.context;
@@ -4223,7 +4231,7 @@ var vs = {
4223
4231
  getSaturation: () => this._getSaturation(),
4224
4232
  getDisplayGain: () => this._getDisplayGain?.() ?? null,
4225
4233
  getTransparentBackground: () => !!this._settings?.get("transparentBackground")
4226
- }), this.upscaler.enabled = $r.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4234
+ }), this.upscaler.enabled = Qr.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4227
4235
  type: P.RESOLUTION_CHANGED,
4228
4236
  width: e.width,
4229
4237
  height: e.height
@@ -4237,7 +4245,7 @@ var vs = {
4237
4245
  }
4238
4246
  setDenoiserStrategy(e, t) {
4239
4247
  let n = this._stages;
4240
- qr.includes(e) || (this._issues?.record(Ye.DENOISER_UNAVAILABLE, `'${e}' is not a live denoiser (${qr.join(", ")}) — none is used`, { strategy: e }), e = "none"), e === "nrd" && this._isPanorama() && (this._issues?.record(Ye.DENOISER_UNAVAILABLE, "NRD cannot run in a panorama — oidn is used", { strategy: e }), e = "oidn"), this._clearDenoiserTextures(), n.nrd && (n.nrd.enabled = e === "nrd"), n.nrd?.enabled && (n.nrd.resetHistory?.(), this._applyNRDPreset(t || "medium")), this.setContinuousDenoise(e === "oidn");
4248
+ Kr.includes(e) || (this._issues?.record(Ye.DENOISER_UNAVAILABLE, `'${e}' is not a live denoiser (${Kr.join(", ")}) — none is used`, { strategy: e }), e = "none"), e === "nrd" && this._isPanorama() && (this._issues?.record(Ye.DENOISER_UNAVAILABLE, "NRD cannot run in a panorama — oidn is used", { strategy: e }), e = "oidn"), this._clearDenoiserTextures(), n.nrd && (n.nrd.enabled = e === "nrd"), n.nrd?.enabled && (n.nrd.resetHistory?.(), this._applyNRDPreset(t || "medium")), this.setContinuousDenoise(e === "oidn");
4241
4249
  }
4242
4250
  setAutoExposureEnabled(e, t) {
4243
4251
  this._stages.autoExposure?.setEnabled(e, t);
@@ -4260,8 +4268,8 @@ var vs = {
4260
4268
  get holdsWhileMoving() {
4261
4269
  if (!this._stages.pathTracer?.viewIsChanging || !this.continuousDenoise || this._cadenceSuspended || !this.denoiser?.enabled || this._movingHopeless) return !1;
4262
4270
  let e = this.movingCostMs, t = this._movingDenoiseMs.length;
4263
- e > Ts * Ds && (this._movingHopeless = !0, this._syncGBufferStages());
4264
- let n = !this._movingHopeless && (t < 2 || e <= Ts);
4271
+ e > Ms * Ps && (this._movingHopeless = !0, this._syncGBufferStages());
4272
+ let n = !this._movingHopeless && (t < 2 || e <= Ms);
4265
4273
  return this._holdWhileMoving = (this._holdWhileMoving === null || this._holdWhileMoving) && n, this._holdWhileMoving;
4266
4274
  }
4267
4275
  skipsTrace() {
@@ -4278,7 +4286,7 @@ var vs = {
4278
4286
  this.pipeline?.context?.removeTexture("oidn:output"), this.denoiser?.invalidateOutput();
4279
4287
  }
4280
4288
  _checkHeldFrameHealthy() {
4281
- !this.denoiser?.hasOutput || this._failedRefreshes < Os || this._unpublishOutput();
4289
+ !this.denoiser?.hasOutput || this._failedRefreshes < Fs || this._unpublishOutput();
4282
4290
  }
4283
4291
  tickContinuousDenoise(e) {
4284
4292
  let t = this.denoiser;
@@ -4288,12 +4296,12 @@ var vs = {
4288
4296
  if (!n) this._holdWhileMoving = null, this._movingDenoiseMs.length = 0;
4289
4297
  else if (!this.holdsWhileMoving) return !1;
4290
4298
  if (t.state.isDenoising || t.state.isLoading || !n && e <= this._lastCadenceSamples) return !1;
4291
- let r = performance.now(), i = n ? ws : this._lastCadenceSamples === 0 ? Cs : Ss, a = Math.max(this.continuousDenoiseInterval, t.lastDenoiseMs * i);
4299
+ let r = performance.now(), i = n ? js : this._lastCadenceSamples === 0 ? As : ks, a = Math.max(this.continuousDenoiseInterval, t.lastDenoiseMs * i);
4292
4300
  if (r - this._lastCadenceAt < a) return !1;
4293
- this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs > xs && (this._cadenceDowngraded = !0);
4301
+ this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs > Os && (this._cadenceDowngraded = !0);
4294
4302
  let o = this._cadenceDowngraded ? this.previewQuality() : this._finalQuality;
4295
4303
  return t.quality !== o && t.updateQuality(o), t.start({ continuous: !0 }).then((e) => {
4296
- this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length > Es && this._movingDenoiseMs.shift());
4304
+ this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length > Ns && this._movingDenoiseMs.shift());
4297
4305
  }), !0;
4298
4306
  }
4299
4307
  previewQuality() {
@@ -4337,7 +4345,7 @@ var vs = {
4337
4345
  r && (this._ensureHistory().merge(r, t.frameCount, this._historyCameraNow(), {
4338
4346
  commit: !0,
4339
4347
  keepHistory: !this._historyDirty && !n,
4340
- historyScale: As(t.frameCount)
4348
+ historyScale: Ls(t.frameCount)
4341
4349
  }), this._historyDirty = !1);
4342
4350
  }
4343
4351
  afterReset() {
@@ -4379,9 +4387,9 @@ var vs = {
4379
4387
  let e = this._stages.pathTracer, t = this._history;
4380
4388
  if (!t?.valid || this._historyDirty || !this.historyActive || e.isComplete || e.resetCount !== this._knownResetCount || t.width !== this._lastRenderWidth || t.height !== this._lastRenderHeight) return null;
4381
4389
  if (e.frameCount <= 1) return t.textures;
4382
- if (e.frameCount >= ks) return null;
4390
+ if (e.frameCount >= Is) return null;
4383
4391
  let n = this._historyInputs();
4384
- return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale: As(e.frameCount) }) : null;
4392
+ return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale: Ls(e.frameCount) }) : null;
4385
4393
  }
4386
4394
  _historyInputs() {
4387
4395
  let e = this._stages.pathTracer, t = this.pipeline?.context, n = this.renderer?.backend;
@@ -4406,7 +4414,7 @@ var vs = {
4406
4414
  return t.world = e.cameraWorldMatrix.value.elements, t.projInv = e.cameraProjectionMatrixInverse.value.elements, t.viewProj = this._viewProj.elements, t.orthographic = e.uniforms?.get("cameraProjection")?.value === Oe.orthographic, t;
4407
4415
  }
4408
4416
  _ensureHistory() {
4409
- return this._history ??= new fs(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
4417
+ return this._history ??= new ys(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
4410
4418
  }
4411
4419
  _releaseHistory() {
4412
4420
  this._history?.dispose(), this._history = null, this._historyDirty = !0, this._movedPlacements.clear();
@@ -4444,15 +4452,15 @@ var vs = {
4444
4452
  return;
4445
4453
  }
4446
4454
  if (!this.pipeline?.context?.getTexture("oidn:output")) {
4447
- bs.warn("neural pass skipped: no denoised picture — it needs OIDN");
4455
+ Ds.warn("neural pass skipped: no denoised picture — it needs OIDN");
4448
4456
  return;
4449
4457
  }
4450
4458
  this._neuralPostBusy = !0, this.dispatchEvent({ type: P.UPSCALING_START });
4451
4459
  try {
4452
- let i = await import("./NeuralSuperRes-C4ymq68e.js").then((e) => e.t);
4460
+ let i = await import("./NeuralSuperRes-B2V-vlHN.js").then((e) => e.t);
4453
4461
  this._superResModule = i;
4454
- let a = n ? await import("./NeuralRetouch-BKQCsmEs.js").then((e) => e.t) : null, o = this.denoiser?._outTexSize, s = (o?.width ?? 0) * (o?.height ?? 0), c = n && s <= a.RETOUCH_MAX_PIXELS;
4455
- if (n && !c && (bs.warn(`Neural rendering skipped: the render is ${(s / 1e6).toFixed(1)} MP, above the ${(a.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !c) {
4462
+ let a = n ? await import("./NeuralRetouch-BtzPRZSB.js").then((e) => e.t) : null, o = this.denoiser?._outTexSize, s = (o?.width ?? 0) * (o?.height ?? 0), c = n && s <= a.RETOUCH_MAX_PIXELS;
4463
+ if (n && !c && (Ds.warn(`Neural rendering skipped: the render is ${(s / 1e6).toFixed(1)} MP, above the ${(a.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !c) {
4456
4464
  r && !this._postCancelled && await this.upscaler.start();
4457
4465
  return;
4458
4466
  }
@@ -4496,7 +4504,7 @@ var vs = {
4496
4504
  height: d.height
4497
4505
  });
4498
4506
  } catch (e) {
4499
- bs.warn("neural pass failed", e);
4507
+ Ds.warn("neural pass failed", e);
4500
4508
  } finally {
4501
4509
  this._neuralPostBusy = !1, this.dispatchEvent({ type: P.UPSCALING_END });
4502
4510
  }
@@ -4649,16 +4657,16 @@ var vs = {
4649
4657
  e && (e.removeTexture("nrd:output"), e.removeTexture("oidn:output"));
4650
4658
  }
4651
4659
  _applyNRDPreset(e) {
4652
- let t = Qr[e];
4660
+ let t = Zr[e];
4653
4661
  if (!t) return;
4654
4662
  let n = {};
4655
- for (let e of Zr) n[e] = Xr[e];
4663
+ for (let e of Xr) n[e] = Yr[e];
4656
4664
  this._stages.nrd?.updateParameters({
4657
4665
  ...n,
4658
4666
  ...t
4659
4667
  });
4660
4668
  }
4661
- }, Ms = class {
4669
+ }, zs = class {
4662
4670
  constructor() {
4663
4671
  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;
4664
4672
  }
@@ -4682,7 +4690,7 @@ var vs = {
4682
4690
  dispose() {
4683
4691
  this.visible = !1;
4684
4692
  }
4685
- }, Ns = class {
4693
+ }, Bs = class {
4686
4694
  constructor(e, t) {
4687
4695
  this.layer = "scene", this._enabled = !0, this._scene = e, this._camera = t, this._build([]);
4688
4696
  }
@@ -4720,11 +4728,11 @@ var vs = {
4720
4728
  this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
4721
4729
  }
4722
4730
  };
4723
- function Ps(e = !1) {
4731
+ function Vs(e = !1) {
4724
4732
  let t = document.createElement("canvas");
4725
4733
  return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
4726
4734
  }
4727
- function Fs(e, t = Infinity) {
4735
+ function Hs(e, t = Infinity) {
4728
4736
  let n = e?.getBoundingClientRect();
4729
4737
  if (!n || n.width === 0 || n.height === 0) return null;
4730
4738
  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);
@@ -4735,9 +4743,9 @@ function Fs(e, t = Infinity) {
4735
4743
  }
4736
4744
  //#endregion
4737
4745
  //#region src/managers/helpers/ViewOverlayRenderer.js
4738
- var Is = 4096, Ls = class {
4746
+ var Us = 4096, Ws = class {
4739
4747
  constructor() {
4740
- this.canvas = Ps(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
4748
+ this.canvas = Vs(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
4741
4749
  }
4742
4750
  async init({ device: e, sizeSource: t }) {
4743
4751
  this._sizeSource = t;
@@ -4754,7 +4762,7 @@ var Is = 4096, Ls = class {
4754
4762
  }
4755
4763
  syncSize() {
4756
4764
  if (!this.renderer) return;
4757
- let e = Fs(this._sizeSource, Is);
4765
+ let e = Hs(this._sizeSource, Us);
4758
4766
  !e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
4759
4767
  }
4760
4768
  begin() {
@@ -4766,18 +4774,18 @@ var Is = 4096, Ls = class {
4766
4774
  dispose() {
4767
4775
  Me(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
4768
4776
  }
4769
- }, Rs = We("overlay"), zs = (e, t) => e.visible && e.layer === t && e.render, Bs = class {
4777
+ }, Gs = We("overlay"), Ks = (e, t) => e.visible && e.layer === t && e.render, qs = class {
4770
4778
  constructor(e) {
4771
- this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Ps(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
4779
+ this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Vs(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
4772
4780
  }
4773
4781
  async initViewRenderer({ device: e, sizeSource: t }) {
4774
4782
  if (!(!e || !t)) try {
4775
- this._viewOverlay = await new Ls().init({
4783
+ this._viewOverlay = await new Ws().init({
4776
4784
  device: e,
4777
4785
  sizeSource: t
4778
4786
  });
4779
4787
  } catch (e) {
4780
- Rs.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
4788
+ Gs.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
4781
4789
  }
4782
4790
  }
4783
4791
  gpuResources() {
@@ -4797,11 +4805,11 @@ var Is = 4096, Ls = class {
4797
4805
  }
4798
4806
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
4799
4807
  this.setHelperScene(e);
4800
- let s = new Ms();
4808
+ let s = new zs();
4801
4809
  this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(P.RESOLUTION_CHANGED, (e) => {
4802
4810
  s.setRenderSize(e.width, e.height);
4803
4811
  }), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
4804
- let c = new Ns(t, this.camera);
4812
+ let c = new Bs(t, this.camera);
4805
4813
  this.register("outline", c);
4806
4814
  }
4807
4815
  _wireDenoiserTileEvents(e, t) {
@@ -4813,7 +4821,7 @@ var Is = 4096, Ls = class {
4813
4821
  }));
4814
4822
  }
4815
4823
  register(e, t) {
4816
- this._helpers.has(e) && (Rs.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
4824
+ this._helpers.has(e) && (Gs.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
4817
4825
  }
4818
4826
  unregister(e) {
4819
4827
  let t = this._helpers.get(e);
@@ -4851,16 +4859,16 @@ var Is = 4096, Ls = class {
4851
4859
  }
4852
4860
  _renderSceneLayer(e) {
4853
4861
  this._helperScene?.render(e, this.camera);
4854
- for (let t of this._helpers.values()) zs(t, "scene") && t.render(e, this.camera);
4862
+ for (let t of this._helpers.values()) Ks(t, "scene") && t.render(e, this.camera);
4855
4863
  }
4856
4864
  _hasVisibleSceneOverlay() {
4857
4865
  if (this._helperScene?.isDrawing) return !0;
4858
- for (let e of this._helpers.values()) if (zs(e, "scene")) return !0;
4866
+ for (let e of this._helpers.values()) if (Ks(e, "scene")) return !0;
4859
4867
  return !1;
4860
4868
  }
4861
4869
  refreshHUD() {
4862
4870
  let e = this._hudCanvas, t = this._hudCtx, n = !1;
4863
- for (let e of this._helpers.values()) if (zs(e, "hud")) {
4871
+ for (let e of this._helpers.values()) if (Ks(e, "hud")) {
4864
4872
  n = !0;
4865
4873
  break;
4866
4874
  }
@@ -4869,10 +4877,10 @@ var Is = 4096, Ls = class {
4869
4877
  return;
4870
4878
  }
4871
4879
  e.style.display !== "" && (e.style.display = "");
4872
- let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Fs(e) : null;
4880
+ let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? Hs(e) : null;
4873
4881
  if (a) {
4874
4882
  (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);
4875
- for (let e of this._helpers.values()) zs(e, "hud") && e.render(t, r, i);
4883
+ for (let e of this._helpers.values()) Ks(e, "hud") && e.render(t, r, i);
4876
4884
  t.restore(), e.style.display !== "" && (e.style.display = "");
4877
4885
  }
4878
4886
  }
@@ -4883,7 +4891,7 @@ var Is = 4096, Ls = class {
4883
4891
  };
4884
4892
  //#endregion
4885
4893
  //#region src/managers/AnimationManager.js
4886
- function Vs(e, t) {
4894
+ function Js(e, t) {
4887
4895
  let n = [...e].filter((t) => {
4888
4896
  for (let n = t.parent; n; n = n.parent) if (e.has(n)) return !1;
4889
4897
  return !0;
@@ -4892,7 +4900,7 @@ function Vs(e, t) {
4892
4900
  for (let e of n) e.traverse?.(() => i++);
4893
4901
  return i + n.length / 2 < r ? n : null;
4894
4902
  }
4895
- var Hs = class extends ur {
4903
+ var Ys = class extends ur {
4896
4904
  constructor() {
4897
4905
  super(), this.mixer = null, this.timer = new Fr(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new Q(), this._skinnedCache = null, this._clipsCache = null, this._savedTimeScale = 1, this.onFinished = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null, this.wakeCallback = null, this.applyPoseCallback = null;
4898
4906
  }
@@ -4946,7 +4954,7 @@ var Hs = class extends ur {
4946
4954
  visibility: i,
4947
4955
  cameras: [...s],
4948
4956
  nodes: a ? null : r,
4949
- roots: a ? null : Vs(r, t)
4957
+ roots: a ? null : Js(r, t)
4950
4958
  };
4951
4959
  }), this._allPlan = null, !this._rigid) return;
4952
4960
  this._slotOf = new Int32Array(this._meshes.length).fill(-1);
@@ -4965,7 +4973,7 @@ var Hs = class extends ur {
4965
4973
  visibility: n,
4966
4974
  cameras: [...t],
4967
4975
  nodes: r,
4968
- roots: r ? Vs(r, this._mixerRoot) : null
4976
+ roots: r ? Js(r, this._mixerRoot) : null
4969
4977
  };
4970
4978
  }
4971
4979
  return this._allPlan;
@@ -5097,19 +5105,19 @@ var Hs = class extends ur {
5097
5105
  dispose() {
5098
5106
  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._meshPositions = null, this._skinnedCache = null, this._clipsCache = null, this._rigid = !1, this._plans = null, this._allPlan = null, this._activeClip = 0, this._slotOf = null, this._lastWorld = null, this._lastVisible = null, this._lastMeshWorld = null, this._lastMorphWeights = null;
5099
5107
  }
5100
- }, Us = new Q(0, 0, -1), Ws = (e) => {
5108
+ }, Xs = new Q(0, 0, -1), Zs = (e) => {
5101
5109
  for (; e.parent;) e = e.parent;
5102
5110
  return e.isScene ? e : null;
5103
- }, Gs = class {
5111
+ }, Qs = class {
5104
5112
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
5105
5113
  this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Ur(e, t), this._gizmoScene = new Nr(), this._gizmoScene.add(this._controls.getHelper()), this._attached = null, this._isDragging = !1, this._meshes = null, this._refitInFlight = !1, this._baselineComputed = !1, this._moved = /* @__PURE__ */ new Set(), this._tempForward = new Q(), 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);
5106
5114
  }
5107
5115
  setMeshData(e) {
5108
5116
  this._meshes = e;
5109
- for (let e of this._moved) Ws(e) || this._moved.delete(e);
5117
+ for (let e of this._moved) Zs(e) || this._moved.delete(e);
5110
5118
  }
5111
5119
  get movedObjects() {
5112
- return [...this._moved].filter((e) => Ws(e));
5120
+ return [...this._moved].filter((e) => Zs(e));
5113
5121
  }
5114
5122
  noteMoved(e) {
5115
5123
  e && !e.isLight && this._moved.add(e);
@@ -5170,7 +5178,7 @@ var Hs = class extends ur {
5170
5178
  }
5171
5179
  _syncLightAim(e) {
5172
5180
  let t = this._tempForward.copy(e.target.position).sub(e.position), n = t.length();
5173
- n > 1e-4 ? (e.quaternion.setFromUnitVectors(Us, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
5181
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(Xs, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
5174
5182
  }
5175
5183
  _recomputeAndRefit() {
5176
5184
  if (!this._meshes || this._refitInFlight || !this._attached) return;
@@ -5206,7 +5214,7 @@ var Hs = class extends ur {
5206
5214
  dispose() {
5207
5215
  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._moved.clear(), 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;
5208
5216
  }
5209
- }, Ks = class {
5217
+ }, $s = class {
5210
5218
  constructor(e) {
5211
5219
  this.layer = "scene", this._transformManager = e, this._enabled = !0;
5212
5220
  }
@@ -5225,8 +5233,8 @@ var Hs = class extends ur {
5225
5233
  dispose() {
5226
5234
  this._enabled = !1;
5227
5235
  }
5228
- }, qs = 1, Js = (e) => typeof e == "string" && /^https?:\/\//.test(e);
5229
- function Ys(e, t) {
5236
+ }, ec = 1, tc = (e) => typeof e == "string" && /^https?:\/\//.test(e);
5237
+ function nc(e, t) {
5230
5238
  let n = [];
5231
5239
  for (; e && e !== t;) {
5232
5240
  let t = e.parent;
@@ -5235,12 +5243,12 @@ function Ys(e, t) {
5235
5243
  }
5236
5244
  return e === t ? n : null;
5237
5245
  }
5238
- function Xs(e, t) {
5246
+ function rc(e, t) {
5239
5247
  let n = e;
5240
5248
  for (let e of t) if (n = n?.children[e], !n) return null;
5241
5249
  return n;
5242
5250
  }
5243
- function Zs(e) {
5251
+ function ic(e) {
5244
5252
  return {
5245
5253
  key: e.assetLoader?.sceneSourceKey ?? null,
5246
5254
  name: e.sceneModel?.name ?? null,
@@ -5248,7 +5256,7 @@ function Zs(e) {
5248
5256
  materials: e.stages.pathTracer?.materialData.materialCount ?? 0
5249
5257
  };
5250
5258
  }
5251
- function Qs(e) {
5259
+ function ac(e) {
5252
5260
  let t = /* @__PURE__ */ new Map();
5253
5261
  for (let n of e.sceneMeshes) {
5254
5262
  let e = n.userData?.materialIndex;
@@ -5256,7 +5264,7 @@ function Qs(e) {
5256
5264
  }
5257
5265
  return t;
5258
5266
  }
5259
- function $s(e) {
5267
+ function oc(e) {
5260
5268
  if (!e) return null;
5261
5269
  let t = e.status(), n = t.activeView, r = t.config?.id ?? n?.configId ?? null;
5262
5270
  return {
@@ -5271,15 +5279,15 @@ function $s(e) {
5271
5279
  context: t.context ?? null
5272
5280
  };
5273
5281
  }
5274
- function ec(e) {
5275
- let t = e.meshScene, n = Qs(e), r = [];
5282
+ function sc(e) {
5283
+ let t = e.meshScene, n = ac(e), r = [];
5276
5284
  return t.traverse((e) => {
5277
- e !== t && e.visible === !1 && r.push(Ys(e, t));
5285
+ e !== t && e.visible === !1 && r.push(nc(e, t));
5278
5286
  }), {
5279
5287
  v: 1,
5280
5288
  engine: Re,
5281
5289
  savedAt: Date.now(),
5282
- scene: Zs(e),
5290
+ scene: ic(e),
5283
5291
  appended: t.children.filter((t) => t !== e.sceneModel && t.userData?.__rayzeeSceneObject).map((e) => ({
5284
5292
  name: e.userData.__rayzeeName ?? e.name,
5285
5293
  url: e.userData.__rayzeeSourceUrl ?? null,
@@ -5287,7 +5295,7 @@ function ec(e) {
5287
5295
  })),
5288
5296
  settings: e.settings.serialize(),
5289
5297
  environment: e.environmentManager?.serialize() ?? null,
5290
- color: $s(e.color),
5298
+ color: oc(e.color),
5291
5299
  lights: e.lightManager.serialize(),
5292
5300
  cameras: e.cameraManager.serialize(),
5293
5301
  timeline: e.timeline?.serialize() ?? null,
@@ -5297,7 +5305,7 @@ function ec(e) {
5297
5305
  })),
5298
5306
  hidden: r,
5299
5307
  moved: (e.transformManager?.movedObjects ?? []).map((e) => ({
5300
- path: Ys(e, t),
5308
+ path: nc(e, t),
5301
5309
  name: e.name,
5302
5310
  position: e.position.toArray(),
5303
5311
  quaternion: e.quaternion.toArray(),
@@ -5305,15 +5313,15 @@ function ec(e) {
5305
5313
  })).filter((e) => e.path)
5306
5314
  };
5307
5315
  }
5308
- function tc(e, t, n) {
5316
+ function cc(e, t, n) {
5309
5317
  let r = e[t];
5310
5318
  r?.copy && (n?.isColor || n?.isVector2 || n?.isVector3) ? r.copy(n) : e[t] = n, e.needsUpdate = !0;
5311
5319
  }
5312
- async function nc(e, t, n, r) {
5320
+ async function lc(e, t, n, r) {
5313
5321
  if (!t) return;
5314
5322
  let i = e.environmentManager;
5315
5323
  if (t.hdri && t.hdri !== i.hdriSource) {
5316
- let i = Js(t.hdri) ? t.hdri : await n({
5324
+ let i = tc(t.hdri) ? t.hdri : await n({
5317
5325
  kind: "environment",
5318
5326
  source: t.hdri
5319
5327
  });
@@ -5325,7 +5333,7 @@ async function nc(e, t, n, r) {
5325
5333
  }
5326
5334
  await i.restore(t);
5327
5335
  }
5328
- async function rc(e, t, n, r) {
5336
+ async function uc(e, t, n, r) {
5329
5337
  let i = e.color;
5330
5338
  if (!t || !i) return;
5331
5339
  let a = i.status(), o = a.activeView, s = !!t.view && !!o && o.display === t.view.display && o.view === t.view.view && (o.look ?? null) === t.view.look, c = a.config?.id ?? null, l = c ?? o?.configId ?? null;
@@ -5350,7 +5358,7 @@ async function rc(e, t, n, r) {
5350
5358
  r("color", e.message, { config: t.config?.id ?? null });
5351
5359
  }
5352
5360
  }
5353
- async function ic(e, t, { resolve: n = async () => null } = {}) {
5361
+ async function dc(e, t, { resolve: n = async () => null } = {}) {
5354
5362
  if (t?.v !== 1) throw Error(`scene state version ${t?.v} is not 1`);
5355
5363
  let r = [], i = (e, t, n = {}) => r.push({
5356
5364
  section: e,
@@ -5371,11 +5379,11 @@ async function ic(e, t, { resolve: n = async () => null } = {}) {
5371
5379
  i("appended", e.message, { name: n.name });
5372
5380
  }
5373
5381
  }
5374
- let a = Zs(e), o = t.scene ?? {}, s = o.meshes === a.meshes && o.materials === a.materials;
5382
+ let a = ic(e), o = t.scene ?? {}, s = o.meshes === a.meshes && o.materials === a.materials;
5375
5383
  s || i("scene", "the loaded scene is not the one saved: objects and materials left as loaded", {
5376
5384
  saved: o,
5377
5385
  now: a
5378
- }), await nc(e, t.environment, n, i), await rc(e, t.color, n, i);
5386
+ }), await lc(e, t.environment, n, i), await uc(e, t.color, n, i);
5379
5387
  let c = e.settings.restore(t.settings);
5380
5388
  c.length && i("settings", "not settings in this engine", { keys: c });
5381
5389
  let l = e.lightManager.restore(t.lights);
@@ -5384,7 +5392,7 @@ async function ic(e, t, { resolve: n = async () => null } = {}) {
5384
5392
  n && e.goboManager?.entries?.length && e.goboManager.setLightGobo(t.uuid, n.name, n), r && e.iesManager?.entries?.length && e.iesManager.setSpotLightProfile(t.uuid, r.name, r.intensity, { applyAutoCone: !1 });
5385
5393
  }
5386
5394
  if (s) {
5387
- let n = Qs(e);
5395
+ let n = ac(e);
5388
5396
  for (let r of t.materials ?? []) {
5389
5397
  let t = n.get(r.index);
5390
5398
  if (!t || (t.name ?? "") !== r.name) {
@@ -5395,17 +5403,17 @@ async function ic(e, t, { resolve: n = async () => null } = {}) {
5395
5403
  continue;
5396
5404
  }
5397
5405
  for (let [n, i] of Object.entries(r.props)) {
5398
- let a = le(i);
5399
- tc(t, n, a), e.setMaterialProperty(r.index, n, a);
5406
+ let a = ce(i);
5407
+ cc(t, n, a), e.setMaterialProperty(r.index, n, a);
5400
5408
  }
5401
5409
  }
5402
- let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) => Xs(r, e)).filter(Boolean));
5410
+ let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) => rc(r, e)).filter(Boolean));
5403
5411
  r.traverse((e) => {
5404
5412
  e !== r && !e.isLight && (e.visible = !a.has(e));
5405
5413
  }), e.updateAllMeshVisibility();
5406
5414
  let o = [];
5407
5415
  for (let n of t.moved ?? []) {
5408
- let t = Xs(r, n.path);
5416
+ let t = rc(r, n.path);
5409
5417
  if (!t || t.name !== n.name) {
5410
5418
  i("moved", "no such object", { name: n.name });
5411
5419
  continue;
@@ -5427,7 +5435,7 @@ async function ic(e, t, { resolve: n = async () => null } = {}) {
5427
5435
  }
5428
5436
  //#endregion
5429
5437
  //#region src/PathTracerApp.js
5430
- var ac = We("engine"), oc = class extends w {
5438
+ var fc = We("engine"), pc = class extends w {
5431
5439
  constructor(e, t = {}) {
5432
5440
  super(e, t), this.setColorManagement(Zt), this.setStorageOpener(cn), this.settings.define("interactionRenderScale", {
5433
5441
  default: .5,
@@ -5435,16 +5443,16 @@ var ac = We("engine"), oc = class extends w {
5435
5443
  this.stages?.pathTracer?.interactionMode && this._requestRenderScale(this._interactionRenderScale());
5436
5444
  },
5437
5445
  reset: !1
5438
- }), this._container = t.container || null, this._animRefitInFlight = !1, this._emittersMoved = !1, this._pendingRenderScale = null, this.cameraManager = null, this.timeline = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Hs();
5446
+ }), this._container = t.container || null, this._animRefitInFlight = !1, this._emittersMoved = !1, this._pendingRenderScale = null, this.cameraManager = null, this.timeline = null, this.goboManager = null, this.iesManager = null, this.denoisingManager = null, this.overlayManager = null, this.interactionManager = null, this.transformManager = null, this.animationManager = new Ys();
5439
5447
  }
5440
5448
  _createCamera() {
5441
- return this.cameraManager = new lo(this.canvas), this.timeline = new go({
5449
+ return this.cameraManager = new _o(this.canvas), this.timeline = new Co({
5442
5450
  cameraManager: this.cameraManager,
5443
5451
  onReset: () => this.reset()
5444
5452
  }), this.cameraManager.camera;
5445
5453
  }
5446
5454
  _initAssetPipeline() {
5447
- super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Et), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-_sJm5uaK.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), Ct);
5455
+ super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Et), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-B4Qz5BGT.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), Ct);
5448
5456
  let e = () => {
5449
5457
  this.needsReset = !0, this.stages.pathTracer?.enterInteractionMode(), this.wake();
5450
5458
  };
@@ -5452,10 +5460,10 @@ var ac = We("engine"), oc = class extends w {
5452
5460
  }
5453
5461
  _createExtraStages() {
5454
5462
  let { renderer: e, stages: t } = this;
5455
- return t.normalDepth = new ei(e, { pathTracer: t.pathTracer }), t.motionVector = new ti(e, this.camera, { pathTracer: t.pathTracer }), t.nrd = new zi(e, {
5463
+ return t.normalDepth = new $r(e, { pathTracer: t.pathTracer }), t.motionVector = new ei(e, this.camera, { pathTracer: t.pathTracer }), t.nrd = new Ki(e, {
5456
5464
  enabled: !1,
5457
5465
  pathTracer: t.pathTracer
5458
- }), t.autoExposure = new pa(e, { enabled: Bi.autoExposure }), t.localExposure = new Fa(e, { enabled: ma.localExposure }), [
5466
+ }), t.autoExposure = new ba(e, { enabled: qi.autoExposure }), t.localExposure = new Ha(e, { enabled: xa.localExposure }), [
5459
5467
  t.normalDepth,
5460
5468
  t.motionVector,
5461
5469
  t.nrd,
@@ -5467,7 +5475,7 @@ var ac = We("engine"), oc = class extends w {
5467
5475
  super._initPipeline(), this.pipeline.eventBus.on("pathtracer:interactionStart", () => this._requestRenderScale(this._interactionRenderScale())), this.pipeline.eventBus.on("pathtracer:interactionEnd", () => this._applyRenderScale(1));
5468
5476
  }
5469
5477
  async _initManagers() {
5470
- await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-bMHbm_7H.js").then((e) => e.n).then((e) => e.PhysicalSky)), this.stages.pathTracer.registerIntegrator(["bidirectional", "vcm"], (t) => new e(t)), this.stages.pathTracer.requestOutput("gBuffer"), this.interactionManager = new Ba({
5478
+ await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-NdPIyVqP.js").then((e) => e.n).then((e) => e.PhysicalSky)), this.stages.pathTracer.registerIntegrator(["bidirectional", "vcm"], (t) => new e(t)), this.stages.pathTracer.requestOutput("gBuffer"), this.interactionManager = new qa({
5471
5479
  scene: this.meshScene,
5472
5480
  camera: this.camera,
5473
5481
  canvas: this.canvas,
@@ -5475,18 +5483,18 @@ var ac = We("engine"), oc = class extends w {
5475
5483
  pathTracer: null,
5476
5484
  floorPlane: this.assetLoader.floorPlane,
5477
5485
  isGeometryOnDisk: () => this.geometryOnDisk
5478
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new _o(this.stages.pathTracer, {
5486
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new wo(this.stages.pathTracer, {
5479
5487
  onReset: () => this.reset(),
5480
5488
  issues: this._issues
5481
- }), this.iesManager = new ko(this.stages.pathTracer, {
5489
+ }), this.iesManager = new Io(this.stages.pathTracer, {
5482
5490
  onReset: () => this.reset(),
5483
5491
  issues: this._issues
5484
- }), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new Gs({
5492
+ }), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new Qs({
5485
5493
  camera: this.camera,
5486
5494
  canvas: this.canvas,
5487
5495
  orbitControls: this.cameraManager.controls,
5488
5496
  app: this
5489
- }), this.overlayManager.register("transform", new Ks(this.transformManager))), this.interactionManager.setDependencies({
5497
+ }), this.overlayManager.register("transform", new $s(this.transformManager))), this.interactionManager.setDependencies({
5490
5498
  overlayManager: this.overlayManager,
5491
5499
  transformManager: this.transformManager,
5492
5500
  appDispatch: (e) => this.dispatchEvent(e),
@@ -5548,7 +5556,7 @@ var ac = We("engine"), oc = class extends w {
5548
5556
  _beginFrame() {
5549
5557
  if (this.timeline.update(), this.cameraManager.updateControls(), this._updateExposure(), this._applyPendingRenderScale(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
5550
5558
  let e = this.animationManager.update();
5551
- e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => ac.error("animation refit error:", e)).finally(() => {
5559
+ e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => fc.error("animation refit error:", e)).finally(() => {
5552
5560
  this._animRefitInFlight = !1;
5553
5561
  }));
5554
5562
  }
@@ -5579,7 +5587,7 @@ var ac = We("engine"), oc = class extends w {
5579
5587
  let { toneMappingExposure: n, toneMapping: r } = this.renderer;
5580
5588
  return {
5581
5589
  ...t,
5582
- backdrop: M(this.settings.get("exposure") ?? 1, n, r)
5590
+ backdrop: le(this.settings.get("exposure") ?? 1, n, r)
5583
5591
  };
5584
5592
  }
5585
5593
  setLocalExposure(e) {
@@ -5687,10 +5695,10 @@ var ac = We("engine"), oc = class extends w {
5687
5695
  return t && this._dispatchCamerasUpdated(), t;
5688
5696
  }
5689
5697
  exportSceneState() {
5690
- return ec(this);
5698
+ return sc(this);
5691
5699
  }
5692
5700
  async importSceneState(e, t) {
5693
- return await ic(this, e, t);
5701
+ return await dc(this, e, t);
5694
5702
  }
5695
5703
  _dispatchCamerasUpdated() {
5696
5704
  this.dispatchEvent({
@@ -5812,7 +5820,7 @@ var ac = We("engine"), oc = class extends w {
5812
5820
  this.transformManager?.setMeshData(this._sdf.meshes);
5813
5821
  }
5814
5822
  _setupDenoisingManager() {
5815
- this.denoisingManager = new js({
5823
+ this.denoisingManager = new Rs({
5816
5824
  renderer: this.renderer,
5817
5825
  mainCanvas: this.canvas,
5818
5826
  stages: {
@@ -5864,7 +5872,7 @@ var ac = We("engine"), oc = class extends w {
5864
5872
  }, n && this.stages.autoExposure?.noteViewChanged());
5865
5873
  }
5866
5874
  async _setupOverlayManager() {
5867
- this.overlayManager = new Bs(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
5875
+ this.overlayManager = new qs(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
5868
5876
  helperScene: this._sceneHelpers,
5869
5877
  meshScene: this.meshScene,
5870
5878
  pipeline: this.pipeline,
@@ -5895,15 +5903,15 @@ var ac = We("engine"), oc = class extends w {
5895
5903
  };
5896
5904
  //#endregion
5897
5905
  //#region src/Headless.js
5898
- async function sc(e) {
5899
- let t = await lc(e);
5906
+ async function mc(e) {
5907
+ let t = await gc(e);
5900
5908
  try {
5901
- return await cc(t, e);
5909
+ return await hc(t, e);
5902
5910
  } finally {
5903
5911
  t.dispose();
5904
5912
  }
5905
5913
  }
5906
- async function cc(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, denoise: i = !1, onProgress: a = void 0 } = {}) {
5914
+ async function hc(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, denoise: i = !1, onProgress: a = void 0 } = {}) {
5907
5915
  let o = e.denoisingManager;
5908
5916
  i && o && !o.finalDenoise && (o.applyOIDNEnabled(!0), o._syncGBufferStages());
5909
5917
  let s = await e.renderFrames(t, {
@@ -5922,8 +5930,8 @@ async function cc(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire
5922
5930
  provenance: e.getProvenance()
5923
5931
  };
5924
5932
  }
5925
- async function lc({ canvas: e, model: t = null, width: n = 1920, height: r = 1080, strict: i = !0, deterministic: a = !0, settings: o = null, storage: s = !1, hostMemoryGB: c = void 0 } = {}) {
5926
- let l = new oc(e ?? null, {
5933
+ async function gc({ canvas: e, model: t = null, width: n = 1920, height: r = 1080, strict: i = !0, deterministic: a = !0, settings: o = null, storage: s = !1, hostMemoryGB: c = void 0 } = {}) {
5934
+ let l = new pc(e ?? null, {
5927
5935
  autoResize: !1,
5928
5936
  strict: i,
5929
5937
  storage: s,
@@ -5937,7 +5945,7 @@ async function lc({ canvas: e, model: t = null, width: n = 1920, height: r = 108
5937
5945
  }
5938
5946
  //#endregion
5939
5947
  //#region src/managers/VideoRenderManager.js
5940
- var uc = class {
5948
+ var _c = class {
5941
5949
  constructor(e) {
5942
5950
  this._app = e, this._cancelled = !1, this._rendering = !1;
5943
5951
  }
@@ -6051,4 +6059,4 @@ var uc = class {
6051
6059
  }
6052
6060
  };
6053
6061
  //#endregion
6054
- export { Ct as ARCHIVE_FORMATS, Bi as AUTO_EXPOSURE_DEFAULTS, ro as AUTO_FOCUS_DEFAULTS, Hs as AnimationManager, qe as BVH_LEAF_MARKERS, lo as CameraManager, mo as CameraTrack, Zt as ColorManagement, zt as DEFAULT_LUT_SIZE, Jt as DEFAULT_MAX_EV, Gt as DEFAULT_MIN_EV, ge as DEFAULT_SUN_PATH, ht as DEFAULT_VIEW, rt as DEFAULT_WORKING_SPACE, $r as DENOISER_DEFAULTS, qr as DENOISER_STRATEGIES, C as DOWNLOAD_POLICY, js as DenoisingManager, d as DownloadCache, $e as ENGINE_AREAS, we as ENGINE_DEFAULTS, P as EngineEvents, Ze as EngineIssueError, _o as GoboManager, ko as IESManager, Ee as INTERACTIVE_RENDER_CONFIG, Ye as ISSUE_CODES, Xe as ISSUE_SEVERITY, Ba as InteractionManager, Je as IssueLog, Se as LEGACY_EVENT_NAMES, ma as LOCAL_EXPOSURE_DEFAULTS, Ge as LOG_LEVELS, S as LightManager, Ue as Logger, Le as MATERIAL_DEFAULTS, Ce as MATERIAL_VALUE_SOURCE, j as MAX_RESERVABLE_RENDER_SIZE, Ne as MAX_SCENE_BYTES, pt as MAX_TABLE_TRANSFORMS, Ae as MemoryLedger, Xr as NRD_DEFAULTS, Jr as NRD_HIT_DIST_A, Yr as NRD_HIT_DIST_B, Zr as NRD_PRESET_KEYS, Qr as NRD_QUALITY_PRESETS, lt as OCIO_VIEW_BASE, Bs as OverlayManager, Te as PRODUCTION_RENDER_CONFIG, oc as PathTracerApp, l as PipelineContext, hn as RETOUCH_DEFAULTS, gn as RETOUCH_MAX_PIXELS, mn as RETOUCH_RANGES, w as RayzeeRenderer, x as RenderPipeline, u as RenderSettings, k as RenderStage, je as SAFE_SCENE_BYTES, qs as SCENE_STATE_VERSION, b as SETTING_SOURCE, me as SKY_DEFAULTS, fn as SR_MAX_INPUT, pn as SR_SCALE, Qe as STORAGE_KIND, A as StageExecutionMode, sn as StorageManager, Ke as TRIANGLE_DATA_LAYOUT, go as TimelineManager, Gs as TransformManager, Re as VERSION, ot as VIEW_TRANSFORMS, _e as VRAMTracker, uc as VideoRenderManager, rn as acquireLock, Vt as addAllOcioViews, Bt as addOcioView, dt as addViewTransform, tn as applyMatrixRGBA8, $t as bakeLut, pe as bufferBytes, Pt as buildOcioView, mt as buildToneMapWGSL, _ as cachedObjectURL, Kt as canvasColorSpaceFor, cc as captureHeadless, v as clearBindingAuditFindings, Ft as clearInputOverrides, at as configureAssets, Ve as configurePlatform, Mt as convertColor, Ot as convertEncodedRGBA8, en as convertPixelsF32, We as createLogger, fe as dayOfYearForMonth, De as deriveAlphaMode, y as describeAdapter, Dt as displayCanvasFit, Ie as estimateSceneBytes, Nt as extractMatrix, wt as extractSceneMetadata, T as fetchFile, yt as fileIdentity, Yt as findNativeLinearSpace, He as fmt, bt as folderIdentity, le as fromPortable, nt as getActiveColorManagement, it as getAssetConfig, h as getBindingAuditFindings, Be as getPlatform, ut as getRegistryVersion, gt as getViewTransform, At as hasColorSpace, an as heldLockNames, vt as identityKey, Ht as isColorManaged, kt as isDataSpace, qt as isDataTexture, jt as linearToSrgb, Xt as listFileRules, Lt as listInputOverrides, st as listViewTransforms, xt as localFolder, nn as makeCpuSampler, It as measureBakeError, f as nameFromUrl, ft as onRegistryChange, lc as openHeadless, on as openStorage, un as openZip, St as parseSceneMetadata, Pe as probeAddressSpace, ln as readZipDirectory, ct as removeViewTransform, sc as renderHeadless, dn as renderUpscaled, Wt as resolveInputSpace, _t as sameIdentity, tt as setActiveColorManagement, m as setBindingAudit, Qt as setInputOverride, Ut as srgbToLinear, de as sunPosition, ce as textureBytes, Rt as textureInputSpace, se as timeForSunElevation, ye as toPortable };
6062
+ export { Ct as ARCHIVE_FORMATS, qi as AUTO_EXPOSURE_DEFAULTS, uo as AUTO_FOCUS_DEFAULTS, Ys as AnimationManager, qe as BVH_LEAF_MARKERS, _o as CameraManager, xo as CameraTrack, Zt as ColorManagement, zt as DEFAULT_LUT_SIZE, Jt as DEFAULT_MAX_EV, Gt as DEFAULT_MIN_EV, ge as DEFAULT_SUN_PATH, ht as DEFAULT_VIEW, rt as DEFAULT_WORKING_SPACE, Qr as DENOISER_DEFAULTS, Kr as DENOISER_STRATEGIES, C as DOWNLOAD_POLICY, Rs as DenoisingManager, d as DownloadCache, $e as ENGINE_AREAS, we as ENGINE_DEFAULTS, P as EngineEvents, Ze as EngineIssueError, wo as GoboManager, Io as IESManager, Ee as INTERACTIVE_RENDER_CONFIG, Ye as ISSUE_CODES, Xe as ISSUE_SEVERITY, qa as InteractionManager, Je as IssueLog, Se as LEGACY_EVENT_NAMES, xa as LOCAL_EXPOSURE_DEFAULTS, Ge as LOG_LEVELS, S as LightManager, Ue as Logger, Le as MATERIAL_DEFAULTS, Ce as MATERIAL_VALUE_SOURCE, re as MAX_RESERVABLE_RENDER_SIZE, Ne as MAX_SCENE_BYTES, pt as MAX_TABLE_TRANSFORMS, Ae as MemoryLedger, Yr as NRD_DEFAULTS, qr as NRD_HIT_DIST_A, Jr as NRD_HIT_DIST_B, Xr as NRD_PRESET_KEYS, Zr as NRD_QUALITY_PRESETS, lt as OCIO_VIEW_BASE, qs as OverlayManager, Te as PRODUCTION_RENDER_CONFIG, pc as PathTracerApp, l as PipelineContext, hn as RETOUCH_DEFAULTS, gn as RETOUCH_MAX_PIXELS, mn as RETOUCH_RANGES, w as RayzeeRenderer, x as RenderPipeline, u as RenderSettings, A as RenderStage, je as SAFE_SCENE_BYTES, ec as SCENE_STATE_VERSION, b as SETTING_SOURCE, me as SKY_DEFAULTS, fn as SR_MAX_INPUT, pn as SR_SCALE, Qe as STORAGE_KIND, j as StageExecutionMode, sn as StorageManager, Ke as TRIANGLE_DATA_LAYOUT, Co as TimelineManager, Qs as TransformManager, Re as VERSION, ot as VIEW_TRANSFORMS, _e as VRAMTracker, _c as VideoRenderManager, rn as acquireLock, Vt as addAllOcioViews, Bt as addOcioView, dt as addViewTransform, tn as applyMatrixRGBA8, $t as bakeLut, fe as bufferBytes, Pt as buildOcioView, mt as buildToneMapWGSL, _ as cachedObjectURL, Kt as canvasColorSpaceFor, hc as captureHeadless, v as clearBindingAuditFindings, Ft as clearInputOverrides, at as configureAssets, Ve as configurePlatform, Mt as convertColor, Ot as convertEncodedRGBA8, en as convertPixelsF32, We as createLogger, de as dayOfYearForMonth, De as deriveAlphaMode, y as describeAdapter, Dt as displayCanvasFit, Ie as estimateSceneBytes, Nt as extractMatrix, wt as extractSceneMetadata, T as fetchFile, yt as fileIdentity, Yt as findNativeLinearSpace, He as fmt, bt as folderIdentity, ce as fromPortable, nt as getActiveColorManagement, it as getAssetConfig, h as getBindingAuditFindings, Be as getPlatform, ut as getRegistryVersion, gt as getViewTransform, At as hasColorSpace, an as heldLockNames, vt as identityKey, Ht as isColorManaged, kt as isDataSpace, qt as isDataTexture, jt as linearToSrgb, Xt as listFileRules, Lt as listInputOverrides, st as listViewTransforms, xt as localFolder, nn as makeCpuSampler, It as measureBakeError, f as nameFromUrl, ft as onRegistryChange, gc as openHeadless, on as openStorage, un as openZip, St as parseSceneMetadata, Pe as probeAddressSpace, ln as readZipDirectory, ct as removeViewTransform, mc as renderHeadless, dn as renderUpscaled, Wt as resolveInputSpace, _t as sameIdentity, tt as setActiveColorManagement, m as setBindingAudit, Qt as setInputOverride, Ut as srgbToLinear, ue as sunPosition, se as textureBytes, Rt as textureInputSpace, oe as timeForSunElevation, ye as toPortable };