rayzee 11.1.1 → 11.2.1

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 (32) hide show
  1. package/README.md +24 -2
  2. package/dist/{ArchiveImporter-CFcggGqi.js → ArchiveImporter-D_x863yu.js} +882 -829
  3. package/dist/{BidirectionalIntegrator-DIPN8lJW.js → BidirectionalIntegrator-DmkxxEOR.js} +226 -226
  4. package/dist/{NeuralRetouch-Doo3a4vY.js → NeuralRetouch-Cr-otSW8.js} +2 -2
  5. package/dist/{NeuralSuperRes-B-rNIU_R.js → NeuralSuperRes-B7E3_M0t.js} +2 -2
  6. package/dist/{PathTracer-D_LmDeLh.js → PathTracer-D6nbknj5.js} +2958 -3000
  7. package/dist/{PhysicalSky-DYffGJ3O.js → PhysicalSky-Dq5VSiCQ.js} +1 -1
  8. package/dist/{RayzeeRenderer-DWx7D714.js → RayzeeRenderer-DbjqO6v-.js} +400 -361
  9. package/dist/SceneMetadata-D2Sh-0e-.js +110 -0
  10. package/dist/addons/archives.es.js +1 -1
  11. package/dist/addons/bidirectional.es.js +1 -1
  12. package/dist/addons/physical-sky.es.js +1 -1
  13. package/dist/addons/storage.es.js +1 -1
  14. package/dist/{identity-DrQsGT2o.js → identity-C1cLD1C0.js} +14 -4
  15. package/dist/{openStorage-DwcBRUj7.js → openStorage-Fe9BoS1_.js} +1 -1
  16. package/dist/rayzee-core.es.js +6 -6
  17. package/dist/rayzee.es.js +827 -827
  18. package/dist/rayzee.umd.js +95 -94
  19. package/dist/{sceneCachePolicy-Bk8sI5PZ.js → sceneCachePolicy-C4-4qwt6.js} +71 -29
  20. package/package.json +1 -1
  21. package/src/Processor/ArchiveImporter.js +130 -96
  22. package/src/Processor/ArchiveReader.js +46 -3
  23. package/src/Processor/AssetLoader.js +26 -1
  24. package/src/Processor/archiveFormats.js +35 -0
  25. package/src/RayzeeRenderer.js +42 -11
  26. package/src/Storage/identity.js +22 -1
  27. package/src/Storage/index.js +1 -1
  28. package/src/TSL/MaterialEvaluation.js +4 -3
  29. package/src/core.js +1 -1
  30. package/src/index.js +2 -2
  31. package/dist/archiveFormats-tnAoUL1j.js +0 -94
  32. /package/dist/{ToneMapGPU-CjU3osDd.js → ToneMapGPU-BOjpul7A.js} +0 -0
package/dist/rayzee.es.js CHANGED
@@ -1,33 +1,33 @@
1
- import { t as e } from "./BidirectionalIntegrator-DIPN8lJW.js";
1
+ import { t as e } from "./BidirectionalIntegrator-DmkxxEOR.js";
2
2
  import { $t as t, Ft as n, Jt as r, Pt as i, Qt as a, jt as o, rt as s, tn as c, wt as l } from "./SolarLimb-CPaeZVwz.js";
3
- import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, r as ee, s as C, t as te, u as w } from "./RayzeeRenderer-DWx7D714.js";
4
- import { $ as ne, At as re, B as T, Bt as E, Ct as ie, Dt as ae, Et as oe, H as se, It as D, K as ce, L as O, Lt as k, N as le, Ot as ue, P as de, Q as A, R as fe, Rt as pe, St as me, Tt as he, Vt as ge, X as _e, Z as ve, bt as ye, dt as be, et as xe, ft as Se, ht as Ce, kt as we, lt as Te, mt as Ee, nt as De, pt as Oe, tt as ke, ut as Ae, xt as je, yt as Me, z as Ne } from "./PathTracer-D_LmDeLh.js";
5
- import { n as Pe, t as j } from "./EngineEvents-Ci8dVWCP.js";
6
- import { E as Fe, T as Ie, a as Le, c as Re, f as ze, i as Be, j as Ve, p as He, r as Ue } from "./sceneCachePolicy-Bk8sI5PZ.js";
7
- import { i as We, n as Ge, r as Ke, t as qe } from "./Logger-dDDGj9Av.js";
8
- import { n as Je, s as Ye } from "./BufferLayout-D_IBo2ci.js";
9
- import { i as Xe, n as Ze, r as Qe, t as $e } from "./EngineIssues-CIZnXHsF.js";
10
- import { i as et, r as tt } from "./shared-BGBcSxBQ.js";
11
- import { i as nt, r as rt, t as it } from "./ActiveColor-YvuQq44O.js";
12
- import { n as at, t as ot } from "./AssetConfig-DSEntE65.js";
13
- import { a as st, d as ct, g as lt, i as ut, l as dt, o as ft, p as pt, r as mt, s as ht, t as gt, u as _t } from "./ViewTransforms-CYN7bq2w.js";
14
- import { i as vt, n as yt, r as bt } from "./identity-DrQsGT2o.js";
15
- import { t as xt } from "./ToneMapGPU-CjU3osDd.js";
16
- import { n as St, r as Ct, t as wt } from "./archiveFormats-tnAoUL1j.js";
17
- import { t as Tt } from "./FileFormats-sPGJeCRc.js";
18
- import { A as Et, C as Dt, D as Ot, E as kt, O as At, S as jt, T as Mt, _ as Nt, a as Pt, b as Ft, c as It, d as Lt, f as Rt, g as zt, h as Bt, i as Vt, k as Ht, l as Ut, m as Wt, n as Gt, o as Kt, p as qt, r as Jt, s as Yt, t as Xt, u as Zt, v as Qt, w as $t, x as en, y as tn } from "./ColorManagement-oeEk7oSu.js";
19
- import { c as nn, l as rn, n as an, o as on, t as sn } from "./openStorage-DwcBRUj7.js";
20
- import { n as cn, t as ln } from "./ZipReader-gDSWr0I5.js";
21
- import { i as un, n as dn, r as fn } from "./NeuralSuperRes-B-rNIU_R.js";
22
- import { i as pn, n as mn, r as hn } from "./NeuralRetouch-Doo3a4vY.js";
23
- import { ExternalTexture as gn, MeshBasicNodeMaterial as _n, QuadMesh as vn, ReadbackBuffer as yn, RenderTarget as bn, StorageTexture as M, TextureNode as N, WebGPURenderer as xn } from "three/webgpu";
24
- import { Fn as Sn, If as P, Loop as Cn, Return as wn, abs as Tn, atan as En, atomicAdd as Dn, atomicLoad as On, atomicStore as kn, attributeArray as An, dot as jn, exp as Mn, exp2 as Nn, float as F, floor as Pn, fract as Fn, int as I, ivec2 as L, localId as R, max as z, min as In, mix as B, normalize as Ln, pow as Rn, round as zn, saturate as V, select as H, smoothstep as Bn, sqrt as Vn, storage as Hn, textureLoad as U, textureStore as W, uint as G, uniform as K, uvec2 as Un, uvec4 as Wn, vec2 as Gn, vec3 as q, vec4 as J, wgslFn as Kn, workgroupArray as qn, workgroupBarrier as Jn, workgroupId as Y } from "three/tsl";
25
- import { ACESFilmicToneMapping as Yn, AddEquation as Xn, AnimationMixer as Zn, Box2 as Qn, Box3 as $n, ClampToEdgeWrapping as er, Color as tr, Controls as nr, CustomBlending as rr, DataArrayTexture as ir, DataTexture as ar, EventDispatcher as or, FloatType as sr, HalfFloatType as cr, InterpolateSmooth as lr, LinearFilter as X, LoopOnce as ur, LoopRepeat as dr, MathUtils as fr, Matrix4 as pr, Mesh as mr, MeshBasicMaterial as hr, NearestFilter as Z, NoColorSpace as gr, NumberKeyframeTrack as _r, OneFactor as vr, OrthographicCamera as yr, PerspectiveCamera as br, PropertyBinding as xr, Quaternion as Sr, RGBAFormat as Q, Raycaster as Cr, RedIntegerFormat as wr, SRGBColorSpace as Tr, Scene as Er, SphereGeometry as Dr, Timer as Or, UnsignedByteType as kr, UnsignedIntType as Ar, Vector2 as jr, Vector3 as $, Vector4 as Mr, VectorKeyframeTrack as Nr } from "three";
26
- import { OrbitControls as Pr } from "three/addons/controls/OrbitControls.js";
27
- import { outline as Fr } from "three/addons/tsl/display/OutlineNode.js";
28
- import { TransformControls as Ir } from "three/addons/controls/TransformControls.js";
3
+ import { _ as u, a as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, r as ee, s as C, t as te, u as w } from "./RayzeeRenderer-DbjqO6v-.js";
4
+ import { $ as ne, B as re, Ct as T, Et as ie, H as ae, It as oe, K as se, L as ce, Lt as E, Mt as le, N as D, Nt as O, P as ue, Pt as de, Q as fe, R as k, St as pe, Tt as me, X as he, Z as ge, _t as _e, dt as ve, et as ye, ft as be, gt as xe, ht as Se, lt as Ce, nt as we, pt as Te, tt as Ee, ut as De, vt as Oe, wt as ke, xt as Ae, yt as je, z as Me } from "./PathTracer-D6nbknj5.js";
5
+ import { n as Ne, t as A } from "./EngineEvents-Ci8dVWCP.js";
6
+ import { M as Pe, N as Fe, R as Ie, _ as Le, a as Re, c as ze, f as Be, i as Ve, p as He, r as Ue, y as We } from "./sceneCachePolicy-C4-4qwt6.js";
7
+ import { i as Ge, n as Ke, r as qe, t as Je } from "./Logger-dDDGj9Av.js";
8
+ import { n as Ye, s as Xe } from "./BufferLayout-D_IBo2ci.js";
9
+ import { i as Ze, n as Qe, r as $e, t as et } from "./EngineIssues-CIZnXHsF.js";
10
+ import { i as tt, r as nt } from "./shared-BGBcSxBQ.js";
11
+ import { i as rt, r as it, t as at } from "./ActiveColor-YvuQq44O.js";
12
+ import { n as ot, t as st } from "./AssetConfig-DSEntE65.js";
13
+ import { a as ct, d as lt, g as ut, i as dt, l as ft, o as pt, p as mt, r as ht, s as gt, t as _t, u as vt } from "./ViewTransforms-CYN7bq2w.js";
14
+ import { a as yt, i as bt, n as xt, r as St } from "./identity-C1cLD1C0.js";
15
+ import { a as Ct, n as wt, r as Tt, t as Et } from "./SceneMetadata-D2Sh-0e-.js";
16
+ import { t as Dt } from "./ToneMapGPU-BOjpul7A.js";
17
+ import { t as Ot } from "./FileFormats-sPGJeCRc.js";
18
+ import { A as kt, C as At, D as jt, E as Mt, O as Nt, S as Pt, T as Ft, _ as It, a as Lt, b as Rt, c as zt, d as Bt, f as Vt, g as Ht, h as Ut, i as Wt, k as Gt, l as Kt, m as qt, n as Jt, o as Yt, p as Xt, r as Zt, s as Qt, t as $t, u as en, v as tn, w as nn, x as rn, y as an } from "./ColorManagement-oeEk7oSu.js";
19
+ import { c as on, l as sn, n as cn, o as ln, t as un } from "./openStorage-Fe9BoS1_.js";
20
+ import { n as dn, t as fn } from "./ZipReader-gDSWr0I5.js";
21
+ import { i as pn, n as mn, r as hn } from "./NeuralSuperRes-B7E3_M0t.js";
22
+ import { i as gn, n as _n, r as vn } from "./NeuralRetouch-Cr-otSW8.js";
23
+ import { ExternalTexture as yn, MeshBasicNodeMaterial as bn, QuadMesh as xn, ReadbackBuffer as Sn, RenderTarget as Cn, StorageTexture as j, TextureNode as M, WebGPURenderer as wn } from "three/webgpu";
24
+ import { Fn as Tn, If as N, Loop as En, Return as Dn, abs as On, atan as kn, atomicAdd as An, atomicLoad as jn, atomicStore as Mn, attributeArray as Nn, dot as Pn, exp as Fn, exp2 as In, float as P, floor as Ln, fract as Rn, int as F, ivec2 as I, localId as L, max as R, min as zn, mix as z, normalize as Bn, pow as Vn, round as Hn, saturate as B, select as V, smoothstep as Un, sqrt as Wn, storage as Gn, textureLoad as H, textureStore as U, uint as W, uniform as G, uvec2 as Kn, uvec4 as qn, vec2 as K, vec3 as q, vec4 as J, wgslFn as Jn, workgroupArray as Yn, workgroupBarrier as Xn, workgroupId as Y } from "three/tsl";
25
+ import { ACESFilmicToneMapping as Zn, AddEquation as Qn, AnimationMixer as $n, Box2 as er, Box3 as tr, ClampToEdgeWrapping as nr, Color as rr, Controls as ir, CustomBlending as ar, DataArrayTexture as or, DataTexture as sr, EventDispatcher as cr, FloatType as lr, HalfFloatType as ur, InterpolateSmooth as dr, LinearFilter as X, LoopOnce as fr, LoopRepeat as pr, MathUtils as mr, Matrix4 as hr, Mesh as gr, MeshBasicMaterial as _r, NearestFilter as Z, NoColorSpace as vr, NumberKeyframeTrack as yr, OneFactor as br, OrthographicCamera as xr, PerspectiveCamera as Sr, PropertyBinding as Cr, Quaternion as wr, RGBAFormat as Q, Raycaster as Tr, RedIntegerFormat as Er, SRGBColorSpace as Dr, Scene as Or, SphereGeometry as kr, Timer as Ar, UnsignedByteType as jr, UnsignedIntType as Mr, Vector2 as Nr, Vector3 as $, Vector4 as Pr, VectorKeyframeTrack as Fr } from "three";
26
+ import { OrbitControls as Ir } from "three/addons/controls/OrbitControls.js";
27
+ import { outline as Lr } from "three/addons/tsl/display/OutlineNode.js";
28
+ import { TransformControls as Rr } from "three/addons/controls/TransformControls.js";
29
29
  //#region src/Stages/DenoiserSettings.js
30
- var Lr = 65504, Rr = 6e4, zr = .01, Br = {
30
+ var zr = 65504, Br = 6e4, Vr = .01, Hr = {
31
31
  low: {
32
32
  temporalAlpha: .1,
33
33
  gradientStrength: .8,
@@ -67,7 +67,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
67
67
  maxAccumFrames: 128,
68
68
  varianceBoost: 1.5
69
69
  }
70
- }, Vr = 3, Hr = .1, Ur = {
70
+ }, Ur = 3, Wr = .1, Gr = {
71
71
  maxAccumulatedFrameNum: 30,
72
72
  maxFastAccumulatedFrameNum: 6,
73
73
  maxStabilizedFrameNum: 63,
@@ -91,7 +91,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
91
91
  convergenceP: .8,
92
92
  lobeVolumePercent: .1,
93
93
  handoverFrames: 0
94
- }, Wr = [
94
+ }, Kr = [
95
95
  "maxAccumulatedFrameNum",
96
96
  "maxFastAccumulatedFrameNum",
97
97
  "maxStabilizedFrameNum",
@@ -99,7 +99,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
99
99
  "prepassBlurRadius",
100
100
  "maxBlurRadius",
101
101
  "enableAntiFirefly"
102
- ], Gr = {
102
+ ], qr = {
103
103
  low: {
104
104
  maxAccumulatedFrameNum: 16,
105
105
  maxFastAccumulatedFrameNum: 4,
@@ -117,7 +117,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
117
117
  prepassBlurRadius: 40,
118
118
  maxBlurRadius: 40
119
119
  }
120
- }, Kr = Br.medium, qr = {
120
+ }, Jr = Hr.medium, Yr = {
121
121
  denoiserStrategy: "none",
122
122
  filterStrength: 1,
123
123
  edgeAtrousIterations: 5,
@@ -135,45 +135,45 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
135
135
  upscalerHdr: !0,
136
136
  enableASVGF: !1,
137
137
  asvgfQualityPreset: "medium",
138
- asvgfTemporalAlpha: Kr.temporalAlpha,
139
- asvgfAtrousIterations: Kr.atrousIterations,
140
- asvgfPhiColor: Kr.phiColor,
141
- asvgfPhiNormal: Kr.phiNormal,
142
- asvgfPhiDepth: Kr.phiDepth,
143
- asvgfPhiLuminance: Kr.phiLuminance,
144
- asvgfVarianceBoost: Kr.varianceBoost,
145
- asvgfMaxAccumFrames: Kr.maxAccumFrames,
146
- asvgfGradientStrength: Kr.gradientStrength,
147
- asvgfGradientSigmaScale: Kr.gradientSigmaScale,
148
- asvgfGradientNoiseFloor: Kr.gradientNoiseFloor,
138
+ asvgfTemporalAlpha: Jr.temporalAlpha,
139
+ asvgfAtrousIterations: Jr.atrousIterations,
140
+ asvgfPhiColor: Jr.phiColor,
141
+ asvgfPhiNormal: Jr.phiNormal,
142
+ asvgfPhiDepth: Jr.phiDepth,
143
+ asvgfPhiLuminance: Jr.phiLuminance,
144
+ asvgfVarianceBoost: Jr.varianceBoost,
145
+ asvgfMaxAccumFrames: Jr.maxAccumFrames,
146
+ asvgfGradientStrength: Jr.gradientStrength,
147
+ asvgfGradientSigmaScale: Jr.gradientSigmaScale,
148
+ asvgfGradientNoiseFloor: Jr.gradientNoiseFloor,
149
149
  asvgfDebugMode: 0,
150
150
  showAsvgfHeatmap: !1,
151
151
  nrdQualityPreset: "medium",
152
152
  nrdDebugMode: 0
153
- }, Jr = class extends E {
153
+ }, Xr = class extends oe {
154
154
  constructor(e, t = {}) {
155
155
  super("NormalDepth", {
156
156
  ...t,
157
- executionMode: ge.ALWAYS
158
- }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = K(new pr(), "mat4"), this.cameraProjectionMatrixInverse = K(new pr(), "mat4"), this.cameraRay = A(), this.resolutionWidth = K(t.width || 1), this.resolutionHeight = K(t.height || 1);
157
+ executionMode: E.ALWAYS
158
+ }), this.renderer = e, this.pathTracer = t.pathTracer, this._dirty = !0, this.cameraWorldMatrix = G(new hr(), "mat4"), this.cameraProjectionMatrixInverse = G(new hr(), "mat4"), this.cameraRay = fe(), this.resolutionWidth = G(t.width || 1), this.resolutionHeight = G(t.height || 1);
159
159
  let n = t.width || 1, r = t.height || 1;
160
- this._outputStorageTex = new M(k, k), this._outputStorageTex.type = cr, this._outputStorageTex.format = Q, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new M(k, k), this._shadingStorageTex.type = cr, this._shadingStorageTex.format = Q, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new bn(n, r, {
161
- type: cr,
160
+ this._outputStorageTex = new j(O, O), this._outputStorageTex.type = ur, this._outputStorageTex.format = Q, this._outputStorageTex.minFilter = Z, this._outputStorageTex.magFilter = Z, this._shadingStorageTex = new j(O, O), this._shadingStorageTex.type = ur, this._shadingStorageTex.format = Q, this._shadingStorageTex.minFilter = Z, this._shadingStorageTex.magFilter = Z, this._shadingRT = new Cn(n, r, {
161
+ type: ur,
162
162
  format: Q,
163
163
  minFilter: Z,
164
164
  magFilter: Z,
165
165
  depthBuffer: !1,
166
166
  stencilBuffer: !1
167
- }), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0));
167
+ }), this._leafStorageTex = null, this._leafRT = null, this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0));
168
168
  let i = {
169
- type: cr,
169
+ type: ur,
170
170
  format: Q,
171
171
  minFilter: Z,
172
172
  magFilter: Z,
173
173
  depthBuffer: !1,
174
174
  stencilBuffer: !1
175
175
  };
176
- this._rtA = new bn(n, r, i), this._rtB = new bn(n, r, i), this._currentIdx = 0, this._hasHistory = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._lastTriAttr = null, this._lastBvhAttr = null, this._lastMatAttr = null, this._computeNode = null, this._computeBuilt = !1, this._linearBuckets = null;
176
+ this._rtA = new Cn(n, r, i), this._rtB = new Cn(n, r, i), this._currentIdx = 0, this._hasHistory = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._lastTriAttr = null, this._lastBvhAttr = null, this._lastMatAttr = null, this._computeNode = null, this._computeBuilt = !1, this._linearBuckets = null;
177
177
  }
178
178
  setupEventListeners() {
179
179
  this.on("camera:moved", () => {
@@ -187,37 +187,37 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
187
187
  if (!e) return !1;
188
188
  let t = e.materialData?.materialStorageAttr, n = e.triangleGeoAttr && e.triangleGeoAttr !== this._lastTriAttr, r = e.bvhStorageAttr && e.bvhStorageAttr !== this._lastBvhAttr, i = t && t !== this._lastMatAttr;
189
189
  return (n || r || i) && (this._computeNode?.dispose?.(), this._computeNode = null, this._computeBuilt = !1, this._triStorageNode = null, this._bvhStorageNode = null, this._matStorageNode = null, this._dirty = !0, this._hasHistory = !1), e.triangleGeoAttr && !this._triStorageNode && (this._triStorageNode = {
190
- geo: Hn(e.triangleGeoAttr, "uvec4", e.triangleGeoAttr.count).toReadOnly(),
191
- shade: Hn(e.triangleShadeAttr, "uvec4", e.triangleShadeAttr.count).toReadOnly()
192
- }), e.bvhStorageAttr && !this._bvhStorageNode && (this._bvhStorageNode = Hn(e.bvhStorageAttr, "vec4", e.bvhStorageAttr.count).toReadOnly()), t && !this._matStorageNode && (this._matStorageNode = Hn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && T(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);
190
+ geo: Gn(e.triangleGeoAttr, "uvec4", e.triangleGeoAttr.count).toReadOnly(),
191
+ shade: Gn(e.triangleShadeAttr, "uvec4", e.triangleShadeAttr.count).toReadOnly()
192
+ }), e.bvhStorageAttr && !this._bvhStorageNode && (this._bvhStorageNode = Gn(e.bvhStorageAttr, "vec4", e.bvhStorageAttr.count).toReadOnly()), t && !this._matStorageNode && (this._matStorageNode = Gn(t, "vec4", t.count).toReadOnly()), this._linearBuckets && re(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);
193
193
  }
194
194
  _buildCompute() {
195
195
  let e = this._triStorageNode, n = this._bvhStorageNode, i = this._matStorageNode;
196
- this._linearBuckets = le(this.pathTracer?.materialData?.linearBuckets);
196
+ this._linearBuckets = D(this.pathTracer?.materialData?.linearBuckets);
197
197
  let o = {
198
- srgbBuckets: le(null),
198
+ srgbBuckets: D(null),
199
199
  linearBuckets: this._linearBuckets,
200
200
  shadowAlbedoMaps: null,
201
201
  goboMaps: null,
202
202
  iesProfiles: null,
203
203
  alphaShadows: null
204
204
  }, s = this.cameraWorldMatrix, u = this.cameraProjectionMatrixInverse, d = this.resolutionWidth, f = this.resolutionHeight, p = this._outputStorageTex, m = this._shadingStorageTex, h = this._leafStorageTex;
205
- this._computeNode = Me(Sn(([o, s]) => {
206
- let u = I(Y.x).mul(8).add(I(R.x)), g = I(Y.y).mul(8).add(I(R.y));
207
- P(u.lessThan(I(d)).and(g.lessThan(I(f))), () => {
208
- let _ = a(_e(Gn(F(u).add(.5).div(d), F(g).add(.5).div(f)), o, s, this.cameraRay)), v = r.wrap(ce(_, n, e)), y = v.normal.mul(.5).add(.5), b = In(v.dst, F(65504)), x = v.didHit.select(J(y, b), J(0, 0, 0, F(Lr)));
209
- W(p, Un(G(u), G(g)), x).toWriteOnly(), h && W(h, Un(G(u), G(g)), Wn(G(v.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
210
- let S = v.normal.toVar(), ee = F(1).toVar();
211
- P(v.didHit, () => {
212
- let r = t.wrap(l(v.materialIndex, i)).toVar(), a = c.wrap(de(v.uv, r)).toVar(), o = J(0).toVar();
213
- P(r.normalMapIndex.greaterThanEqual(I(0)), () => {
214
- o.assign(se(e, v.triangleIndex, v.normal, r.normalTransform, n, v.instanceLeaf));
205
+ this._computeNode = Se(Tn(([o, s]) => {
206
+ let u = F(Y.x).mul(8).add(F(L.x)), g = F(Y.y).mul(8).add(F(L.y));
207
+ N(u.lessThan(F(d)).and(g.lessThan(F(f))), () => {
208
+ let _ = a(he(K(P(u).add(.5).div(d), P(g).add(.5).div(f)), o, s, this.cameraRay)), v = r.wrap(se(_, n, e)), y = v.normal.mul(.5).add(.5), b = zn(v.dst, P(65504)), x = v.didHit.select(J(y, b), J(0, 0, 0, P(zr)));
209
+ U(p, Kn(W(u), W(g)), x).toWriteOnly(), h && U(h, Kn(W(u), W(g)), qn(W(v.instanceLeaf.add(1)), 0, 0, 0)).toWriteOnly();
210
+ let S = v.normal.toVar(), ee = P(1).toVar();
211
+ N(v.didHit, () => {
212
+ let r = t.wrap(l(v.materialIndex, i)).toVar(), a = c.wrap(ue(v.uv, r)).toVar(), o = J(0).toVar();
213
+ N(r.normalMapIndex.greaterThanEqual(F(0)), () => {
214
+ o.assign(ae(e, v.triangleIndex, v.normal, r.normalTransform, n, v.instanceLeaf));
215
215
  });
216
- let s = Ne(v.normal, r, a, o).toVar();
217
- S.assign(O(s, r, a)), ee.assign(fe(r, a).y.clamp(.05, 1));
216
+ let s = Me(v.normal, r, a, o).toVar();
217
+ S.assign(ce(s, r, a)), ee.assign(k(r, a).y.clamp(.05, 1));
218
218
  });
219
219
  let C = v.didHit.select(J(S.mul(.5).add(.5), ee), J(0, 0, 0, 1));
220
- W(m, Un(G(u), G(g)), C).toWriteOnly();
220
+ U(m, Kn(W(u), W(g)), C).toWriteOnly();
221
221
  });
222
222
  })(s, u), o).compute([
223
223
  this._dispatchX,
@@ -263,15 +263,15 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
263
263
  reallocateReservedStorage() {
264
264
  this._computeNode?.dispose(), this._computeNode = null, this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose();
265
265
  let e = () => {
266
- let e = new M(k, k);
267
- return e.type = cr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
266
+ let e = new j(O, O);
267
+ return e.type = ur, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
268
268
  };
269
269
  this._outputStorageTex = e(), this._shadingStorageTex = e(), this._leafStorageTex &&= (this._leafStorageTex.dispose(), this._makeLeafStorage()), this._computeBuilt = !1;
270
270
  }
271
271
  setInstanceLeafOutput(e) {
272
- e = !!e, e !== !!this._leafStorageTex && (this._computeNode?.dispose(), this._computeNode = null, this._computeBuilt = !1, this._dirty = !0, e ? (this._leafStorageTex = this._makeLeafStorage(), this._leafRT = new bn(this._rtA.width, this._rtA.height, {
273
- type: Ar,
274
- format: wr,
272
+ e = !!e, e !== !!this._leafStorageTex && (this._computeNode?.dispose(), this._computeNode = null, this._computeBuilt = !1, this._dirty = !0, e ? (this._leafStorageTex = this._makeLeafStorage(), this._leafRT = new Cn(this._rtA.width, this._rtA.height, {
273
+ type: Mr,
274
+ format: Er,
275
275
  minFilter: Z,
276
276
  magFilter: Z,
277
277
  depthBuffer: !1,
@@ -282,40 +282,40 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
282
282
  this._leafRT ? e.setTexture("pathtracer:instanceLeaf", this._leafRT.texture) : e.getTexture("pathtracer:instanceLeaf") && e.removeTexture("pathtracer:instanceLeaf");
283
283
  }
284
284
  _makeLeafStorage() {
285
- let e = new M(k, k);
286
- return e.type = Ar, e.format = wr, e.minFilter = Z, e.magFilter = Z, e;
285
+ let e = new j(O, O);
286
+ return e.type = Mr, e.format = Er, e.minFilter = Z, e.magFilter = Z, e;
287
287
  }
288
288
  dispose() {
289
289
  this._computeNode?.dispose(), this._outputStorageTex?.dispose(), this._shadingStorageTex?.dispose(), this._shadingRT?.dispose(), this._leafStorageTex?.dispose(), this._leafRT?.dispose(), this._rtA?.dispose(), this._rtB?.dispose();
290
290
  }
291
- }, Yr = class extends E {
291
+ }, Zr = class extends oe {
292
292
  constructor(e, t, n = {}) {
293
293
  super("MotionVector", {
294
294
  ...n,
295
- executionMode: ge.ALWAYS
295
+ executionMode: E.ALWAYS
296
296
  }), this.renderer = e, this.camera = t, this.pathTracer = n.pathTracer || null;
297
297
  let r = n.width || 1, i = n.height || 1;
298
- this.prevViewProjectionMatrix = new pr(), this.currentViewProjectionMatrix = new pr(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = K(new pr(), "mat4"), this.cameraProjectionMatrixInverse = K(new pr(), "mat4"), this.cameraRay = A(), this.prevVP = K(new pr(), "mat4"), this.isFirstFrameU = K(1), this.deltaTime = K(1 / 60), this.velocityScale = K(1), this.resolutionWidth = K(r), this.resolutionHeight = K(i), this._normalDepthTexNode = new N(), this._screenSpaceStorageTex = new M(k, k), this._screenSpaceStorageTex.type = cr, this._screenSpaceStorageTex.format = Q, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._worldSpaceStorageTex = new M(k, k), this._worldSpaceStorageTex.type = cr, this._worldSpaceStorageTex.format = Q, this._worldSpaceStorageTex.minFilter = Z, this._worldSpaceStorageTex.magFilter = Z, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0));
298
+ this.prevViewProjectionMatrix = new hr(), this.currentViewProjectionMatrix = new hr(), this.matricesInitialized = !1, this.isFirstFrame = !0, this.frameCount = 0, this.cameraWorldMatrix = G(new hr(), "mat4"), this.cameraProjectionMatrixInverse = G(new hr(), "mat4"), this.cameraRay = fe(), this.prevVP = G(new hr(), "mat4"), this.isFirstFrameU = G(1), this.deltaTime = G(1 / 60), this.velocityScale = G(1), this.resolutionWidth = G(r), this.resolutionHeight = G(i), this._normalDepthTexNode = new M(), this._screenSpaceStorageTex = new j(O, O), this._screenSpaceStorageTex.type = ur, this._screenSpaceStorageTex.format = Q, this._screenSpaceStorageTex.minFilter = Z, this._screenSpaceStorageTex.magFilter = Z, this._worldSpaceStorageTex = new j(O, O), this._worldSpaceStorageTex.type = ur, this._worldSpaceStorageTex.format = Q, this._worldSpaceStorageTex.minFilter = Z, this._worldSpaceStorageTex.magFilter = Z, this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0));
299
299
  let a = {
300
- type: cr,
300
+ type: ur,
301
301
  format: Q,
302
302
  minFilter: Z,
303
303
  magFilter: Z,
304
304
  depthBuffer: !1,
305
305
  stencilBuffer: !1
306
306
  };
307
- this.screenSpaceTarget = new bn(r, i, a), this.worldSpaceTarget = new bn(r, i, a), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(i / 16), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
307
+ this.screenSpaceTarget = new Cn(r, i, a), this.worldSpaceTarget = new Cn(r, i, a), this._dispatchX = Math.ceil(r / 16), this._dispatchY = Math.ceil(i / 16), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
308
308
  }
309
309
  _buildScreenSpaceCompute() {
310
310
  let e = this._normalDepthTexNode, t = this.cameraWorldMatrix, n = this.cameraProjectionMatrixInverse, r = this.prevVP, i = this.resolutionWidth, a = this.resolutionHeight, o = this._screenSpaceStorageTex;
311
- this._screenSpaceComputeNode = Sn(([t, n]) => {
312
- let s = I(Y.x).mul(16).add(I(R.x)), c = I(Y.y).mul(16).add(I(R.y));
313
- P(s.lessThan(I(i)).and(c.lessThan(I(a))), () => {
314
- let l = U(e, L(s, c)).w, u = Gn(F(s).add(.5).div(i), F(c).add(.5).div(a)), d = J(0, 0, l, 1).toVar();
315
- P(l.lessThan(F(6e4)), () => {
316
- let e = ve(u, l, t, n, this.cameraRay), i = r.mul(J(e, 1)), a = i.xy.div(i.w), o = Gn(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));
317
- d.assign(c.select(J(s, l, 1), J(F(1e3), F(1e3), l, 0)));
318
- }), W(o, Un(G(s), G(c)), d).toWriteOnly();
311
+ this._screenSpaceComputeNode = Tn(([t, n]) => {
312
+ let s = F(Y.x).mul(16).add(F(L.x)), c = F(Y.y).mul(16).add(F(L.y));
313
+ N(s.lessThan(F(i)).and(c.lessThan(F(a))), () => {
314
+ let l = H(e, I(s, c)).w, u = K(P(s).add(.5).div(i), P(c).add(.5).div(a)), d = J(0, 0, l, 1).toVar();
315
+ N(l.lessThan(P(6e4)), () => {
316
+ let e = ge(u, l, t, n, this.cameraRay), i = r.mul(J(e, 1)), a = i.xy.div(i.w), o = K(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));
317
+ d.assign(c.select(J(s, l, 1), J(P(1e3), P(1e3), l, 0)));
318
+ }), U(o, Kn(W(s), W(c)), d).toWriteOnly();
319
319
  });
320
320
  })(t, n).compute([
321
321
  this._dispatchX,
@@ -329,14 +329,14 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
329
329
  }
330
330
  _buildWorldSpaceCompute() {
331
331
  let e = this._normalDepthTexNode, t = this.cameraWorldMatrix, n = this.cameraProjectionMatrixInverse, r = this.prevVP, i = this.isFirstFrameU, a = this.deltaTime, o = this.velocityScale, s = this.resolutionWidth, c = this.resolutionHeight, l = this._worldSpaceStorageTex;
332
- this._worldSpaceComputeNode = Sn(([t, n]) => {
333
- let u = I(Y.x).mul(16).add(I(R.x)), d = I(Y.y).mul(16).add(I(R.y));
334
- P(u.lessThan(I(s)).and(d.lessThan(I(c))), () => {
335
- let f = U(e, L(u, d)).w, p = J(0, 0, 0, 0).toVar();
336
- P(i.lessThan(.5).and(f.lessThan(F(6e4))), () => {
337
- let e = Gn(F(u).add(.5).div(s), F(d).add(.5).div(c)), i = ve(e, f, t, n, this.cameraRay), l = r.mul(J(i, 1)), m = l.xy.div(l.w), h = Gn(m.x.mul(.5).add(.5), m.y.mul(-.5).add(.5)), g = h.x.greaterThanEqual(0).and(h.x.lessThanEqual(1)).and(h.y.greaterThanEqual(0)).and(h.y.lessThanEqual(1)), _ = e.sub(h), v = q(_.x.div(a).mul(o), _.y.div(a).mul(o), 0);
332
+ this._worldSpaceComputeNode = Tn(([t, n]) => {
333
+ let u = F(Y.x).mul(16).add(F(L.x)), d = F(Y.y).mul(16).add(F(L.y));
334
+ N(u.lessThan(F(s)).and(d.lessThan(F(c))), () => {
335
+ let f = H(e, I(u, d)).w, p = J(0, 0, 0, 0).toVar();
336
+ N(i.lessThan(.5).and(f.lessThan(P(6e4))), () => {
337
+ let e = K(P(u).add(.5).div(s), P(d).add(.5).div(c)), i = ge(e, f, t, n, this.cameraRay), l = r.mul(J(i, 1)), m = l.xy.div(l.w), h = K(m.x.mul(.5).add(.5), m.y.mul(-.5).add(.5)), g = h.x.greaterThanEqual(0).and(h.x.lessThanEqual(1)).and(h.y.greaterThanEqual(0)).and(h.y.lessThanEqual(1)), _ = e.sub(h), v = q(_.x.div(a).mul(o), _.y.div(a).mul(o), 0);
338
338
  p.assign(g.select(J(v, 1), J(0, 0, 0, .5)));
339
- }), W(l, Un(G(u), G(d)), p).toWriteOnly();
339
+ }), U(l, Kn(W(u), W(d)), p).toWriteOnly();
340
340
  });
341
341
  })(t, n).compute([
342
342
  this._dispatchX,
@@ -400,83 +400,83 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
400
400
  reallocateReservedStorage() {
401
401
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose();
402
402
  let e = () => {
403
- let e = new M(k, k);
404
- return e.type = cr, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
403
+ let e = new j(O, O);
404
+ return e.type = ur, e.format = Q, e.minFilter = Z, e.magFilter = Z, e;
405
405
  };
406
406
  this._screenSpaceStorageTex = e(), this._worldSpaceStorageTex = e(), this._buildScreenSpaceCompute(), this._buildWorldSpaceCompute();
407
407
  }
408
408
  dispose() {
409
409
  this._screenSpaceComputeNode?.dispose(), this._worldSpaceComputeNode?.dispose(), this._screenSpaceStorageTex?.dispose(), this._worldSpaceStorageTex?.dispose(), this.screenSpaceTarget?.dispose(), this.worldSpaceTarget?.dispose(), this._normalDepthTexNode?.dispose();
410
410
  }
411
- }, Xr = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Zr = (e) => q(Xr(e.x), Xr(e.y), Xr(e.z)), Qr = class extends E {
411
+ }, Qr = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), $r = (e) => q(Qr(e.x), Qr(e.y), Qr(e.z)), ei = class extends oe {
412
412
  constructor(e, t = {}) {
413
413
  super("ASVGF", {
414
414
  ...t,
415
- executionMode: ge.PER_CYCLE
416
- }), this.renderer = e, this.temporalAlpha = K(t.temporalAlpha ?? Br.medium.temporalAlpha), this.gradientStrength = K(t.gradientStrength ?? Br.medium.gradientStrength), this.gradientSigmaScale = K(t.gradientSigmaScale ?? Br.medium.gradientSigmaScale), this.gradientNoiseFloor = K(t.gradientNoiseFloor ?? Br.medium.gradientNoiseFloor), this.maxAccumFrames = K(t.maxAccumFrames ?? Br.medium.maxAccumFrames), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this.temporalEnabledU = K(1), this.forceResetU = K(0), this._colorTexNode = new N(), this._albedoTexNode = new N(), this._motionTexNode = new N(), this._normalDepthTexNode = new N(), this._prevNormalDepthTexNode = new N(), this._readTemporalTexNode = new N(), this._gradientReadTexNode = new N();
415
+ executionMode: E.PER_CYCLE
416
+ }), this.renderer = e, this.temporalAlpha = G(t.temporalAlpha ?? Hr.medium.temporalAlpha), this.gradientStrength = G(t.gradientStrength ?? Hr.medium.gradientStrength), this.gradientSigmaScale = G(t.gradientSigmaScale ?? Hr.medium.gradientSigmaScale), this.gradientNoiseFloor = G(t.gradientNoiseFloor ?? Hr.medium.gradientNoiseFloor), this.maxAccumFrames = G(t.maxAccumFrames ?? Hr.medium.maxAccumFrames), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this.temporalEnabledU = G(1), this.forceResetU = G(0), this._colorTexNode = new M(), this._albedoTexNode = new M(), this._motionTexNode = new M(), this._normalDepthTexNode = new M(), this._prevNormalDepthTexNode = new M(), this._readTemporalTexNode = new M(), this._gradientReadTexNode = new M();
417
417
  let n = t.width || 1, r = t.height || 1;
418
- this._temporalTexA = new M(k, k), this._temporalTexA.type = sr, this._temporalTexA.format = Q, this._temporalTexA.minFilter = X, this._temporalTexA.magFilter = X, this._temporalTexB = new M(k, k), this._temporalTexB.type = sr, this._temporalTexB.format = Q, this._temporalTexB.minFilter = X, this._temporalTexB.magFilter = X, this._outputModulatedTex = new M(k, k), this._outputModulatedTex.type = sr, this._outputModulatedTex.format = Q, this._outputModulatedTex.minFilter = X, this._outputModulatedTex.magFilter = X, this._gradientStorageTex = new M(k, k), this._gradientStorageTex.type = cr, this._gradientStorageTex.format = Q, this._gradientStorageTex.minFilter = X, this._gradientStorageTex.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._demodulatedRT = new bn(n, r, {
419
- type: sr,
418
+ this._temporalTexA = new j(O, O), this._temporalTexA.type = lr, this._temporalTexA.format = Q, this._temporalTexA.minFilter = X, this._temporalTexA.magFilter = X, this._temporalTexB = new j(O, O), this._temporalTexB.type = lr, this._temporalTexB.format = Q, this._temporalTexB.minFilter = X, this._temporalTexB.magFilter = X, this._outputModulatedTex = new j(O, O), this._outputModulatedTex.type = lr, this._outputModulatedTex.format = Q, this._outputModulatedTex.minFilter = X, this._outputModulatedTex.magFilter = X, this._gradientStorageTex = new j(O, O), this._gradientStorageTex.type = ur, this._gradientStorageTex.format = Q, this._gradientStorageTex.minFilter = X, this._gradientStorageTex.magFilter = X, this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0)), this._demodulatedRT = new Cn(n, r, {
419
+ type: lr,
420
420
  format: Q,
421
421
  minFilter: X,
422
422
  magFilter: X,
423
423
  depthBuffer: !1,
424
424
  stencilBuffer: !1
425
- }), this._outputRT = new bn(n, r, {
426
- type: sr,
425
+ }), this._outputRT = new Cn(n, r, {
426
+ type: lr,
427
427
  format: Q,
428
428
  minFilter: X,
429
429
  magFilter: X,
430
430
  depthBuffer: !1,
431
431
  stencilBuffer: !1
432
- }), this._gradientRT = new bn(n, r, {
433
- type: cr,
432
+ }), this._gradientRT = new Cn(n, r, {
433
+ type: ur,
434
434
  format: Q,
435
435
  minFilter: X,
436
436
  magFilter: X,
437
437
  depthBuffer: !1,
438
438
  stencilBuffer: !1
439
- }), this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = K(0, "int"), this._heatmapStorageTex = new M(k, k), this._heatmapStorageTex.type = sr, this._heatmapStorageTex.format = Q, this._heatmapStorageTex.minFilter = Z, this._heatmapStorageTex.magFilter = Z, this.heatmapTarget = new bn(n, r, {
440
- type: sr,
439
+ }), this.currentMoments = 0, this._compiled = !1, this._needsWarmReset = !1, this._dispatchX = Math.ceil(n / 8), this._dispatchY = Math.ceil(r / 8), this._buildGradientCompute(), this._buildTemporalCompute(), this.showHeatmap = !1, this.debugMode = G(0, "int"), this._heatmapStorageTex = new j(O, O), this._heatmapStorageTex.type = lr, this._heatmapStorageTex.format = Q, this._heatmapStorageTex.minFilter = Z, this._heatmapStorageTex.magFilter = Z, this.heatmapTarget = new Cn(n, r, {
440
+ type: lr,
441
441
  format: Q,
442
442
  minFilter: Z,
443
443
  magFilter: Z,
444
444
  depthBuffer: !1,
445
445
  stencilBuffer: !1
446
- }), this._heatmapRawColorTexNode = new N(), this._heatmapColorTexNode = new N(), this._heatmapTemporalTexNode = new N(), this._heatmapNDTexNode = new N(), this._heatmapMotionTexNode = new N(), this._heatmapGradientTexNode = new N(), this._buildHeatmapCompute();
446
+ }), this._heatmapRawColorTexNode = new M(), this._heatmapColorTexNode = new M(), this._heatmapTemporalTexNode = new M(), this._heatmapNDTexNode = new M(), this._heatmapMotionTexNode = new M(), this._heatmapGradientTexNode = new M(), this._buildHeatmapCompute();
447
447
  }
448
448
  _buildGradientCompute() {
449
- let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, s = this._gradientStorageTex, c = this.resW, l = this.resH, u = qn("float", 144), d = qn("float", 144);
450
- this._gradientNode = Sn(() => {
451
- let f = R.x, p = R.y, m = p.mul(8).add(f), h = I(Y.x).mul(8).sub(2).toVar(), g = I(Y.y).mul(8).sub(2).toVar(), _ = (i) => {
452
- let a = i.mod(G(12)), s = i.div(G(12)), f = h.add(I(a)).clamp(I(0), I(c).sub(1)), p = g.add(I(s)).clamp(I(0), I(l).sub(1)), m = U(e, L(f, p)).xyz, _ = U(t, L(f, p)).xyz, v = o(Zr(m.div(z(_, q(zr))))).toVar();
449
+ let e = this._colorTexNode, t = this._albedoTexNode, n = this._motionTexNode, r = this._readTemporalTexNode, i = this.gradientNoiseFloor, a = this.gradientSigmaScale, s = this._gradientStorageTex, c = this.resW, l = this.resH, u = Yn("float", 144), d = Yn("float", 144);
450
+ this._gradientNode = Tn(() => {
451
+ let f = L.x, p = L.y, m = p.mul(8).add(f), h = F(Y.x).mul(8).sub(2).toVar(), g = F(Y.y).mul(8).sub(2).toVar(), _ = (i) => {
452
+ let a = i.mod(W(12)), s = i.div(W(12)), f = h.add(F(a)).clamp(F(0), F(c).sub(1)), p = g.add(F(s)).clamp(F(0), F(l).sub(1)), m = H(e, I(f, p)).xyz, _ = H(t, I(f, p)).xyz, v = o($r(m.div(R(_, q(Vr))))).toVar();
453
453
  u.element(i).assign(v);
454
- let y = U(n, L(f, p)), b = F(f).sub(y.x.mul(c)), x = F(p).sub(y.y.mul(l)), S = I(b.add(.5)).clamp(I(0), I(c).sub(1)), ee = I(x.add(.5)).clamp(I(0), I(l).sub(1)), C = y.w.greaterThan(.5), te = U(r, L(S, ee)).xyz, w = C.select(o(te), v);
454
+ let y = H(n, I(f, p)), b = P(f).sub(y.x.mul(c)), x = P(p).sub(y.y.mul(l)), S = F(b.add(.5)).clamp(F(0), F(c).sub(1)), ee = F(x.add(.5)).clamp(F(0), F(l).sub(1)), C = y.w.greaterThan(.5), te = H(r, I(S, ee)).xyz, w = C.select(o(te), v);
455
455
  d.element(i).assign(w);
456
456
  };
457
457
  _(m);
458
- let v = m.add(G(64));
459
- P(v.lessThan(G(144)), () => {
458
+ let v = m.add(W(64));
459
+ N(v.lessThan(W(144)), () => {
460
460
  _(v);
461
461
  });
462
- let y = m.add(G(128));
463
- P(y.lessThan(G(144)), () => {
462
+ let y = m.add(W(128));
463
+ N(y.lessThan(W(144)), () => {
464
464
  _(y);
465
- }), Jn();
466
- let b = I(Y.x).mul(8).add(I(f)), x = I(Y.y).mul(8).add(I(p));
467
- P(b.lessThan(I(c)).and(x.lessThan(I(l))), () => {
468
- let e = F(0).toVar(), t = F(0).toVar();
465
+ }), Xn();
466
+ let b = F(Y.x).mul(8).add(F(f)), x = F(Y.y).mul(8).add(F(p));
467
+ N(b.lessThan(F(c)).and(x.lessThan(F(l))), () => {
468
+ let e = P(0).toVar(), t = P(0).toVar();
469
469
  for (let n = -2; n <= 2; n++) for (let r = -2; r <= 2; r++) {
470
- let i = p.add(G(2 + n)).mul(G(12)).add(f.add(G(2 + r))), a = u.element(i);
470
+ let i = p.add(W(2 + n)).mul(W(12)).add(f.add(W(2 + r))), a = u.element(i);
471
471
  e.addAssign(a), t.addAssign(a.mul(a));
472
472
  }
473
- let o = e.div(25), m = Vn(z(t.div(25).sub(o.mul(o)), F(0))).mul(a).toVar(), h = F(0).toVar();
473
+ let o = e.div(25), m = Wn(R(t.div(25).sub(o.mul(o)), P(0))).mul(a).toVar(), h = P(0).toVar();
474
474
  for (let e = -2; e <= 2; e++) for (let t = -2; t <= 2; t++) {
475
- let n = p.add(G(2 + e)).mul(G(12)).add(f.add(G(2 + t))), r = u.element(n), a = d.element(n), o = z(z(Tn(r.sub(a)).sub(m), F(0)).div(z(z(r, a), F(.001))).sub(i), F(0)).div(z(F(1).sub(i), F(1e-4)));
475
+ let n = p.add(W(2 + e)).mul(W(12)).add(f.add(W(2 + t))), r = u.element(n), a = d.element(n), o = R(R(On(r.sub(a)).sub(m), P(0)).div(R(R(r, a), P(.001))).sub(i), P(0)).div(R(P(1).sub(i), P(1e-4)));
476
476
  h.addAssign(o.mul(o));
477
477
  }
478
- let g = h.div(25).clamp(0, 1).toVar(), _ = U(n, L(b, x)), v = I(F(b).sub(_.x.mul(c)).add(.5)).clamp(I(0), I(c).sub(1)), y = I(F(x).sub(_.y.mul(l)).add(.5)).clamp(I(0), I(l).sub(1)), S = _.w.greaterThan(.5).select(U(r, L(v, y)).w, F(0)).div(4).clamp(0, 1), ee = g.mul(S);
479
- W(s, Un(G(b), G(x)), J(ee, g, m, 1)).toWriteOnly();
478
+ let g = h.div(25).clamp(0, 1).toVar(), _ = H(n, I(b, x)), v = F(P(b).sub(_.x.mul(c)).add(.5)).clamp(F(0), F(c).sub(1)), y = F(P(x).sub(_.y.mul(l)).add(.5)).clamp(F(0), F(l).sub(1)), S = _.w.greaterThan(.5).select(H(r, I(v, y)).w, P(0)).div(4).clamp(0, 1), ee = g.mul(S);
479
+ U(s, Kn(W(b), W(x)), J(ee, g, m, 1)).toWriteOnly();
480
480
  });
481
481
  })().compute([
482
482
  this._dispatchX,
@@ -493,23 +493,23 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
493
493
  }
494
494
  _buildTemporalForDirection(e) {
495
495
  let t = this._colorTexNode, n = this._albedoTexNode, r = this._motionTexNode, i = this._normalDepthTexNode, a = this._prevNormalDepthTexNode, o = this._readTemporalTexNode, s = this._gradientReadTexNode, c = this._outputModulatedTex, l = this.maxAccumFrames, u = this.temporalAlpha, d = this.gradientStrength, f = this.temporalEnabledU, p = this.forceResetU, m = this.resW, h = this.resH;
496
- return Sn(() => {
497
- let g = I(Y.x).mul(8).add(I(R.x)), _ = I(Y.y).mul(8).add(I(R.y));
498
- P(g.lessThan(I(m)).and(_.lessThan(I(h))), () => {
499
- let v = L(g, _), y = U(t, v), b = y.xyz, x = y.w, S = U(n, v).xyz, ee = z(S, q(zr)), C = Zr(b.div(ee)), te = J(C, 1).toVar(), w = J(b, x).toVar();
500
- P(f.greaterThan(.5).and(p.lessThan(.5)), () => {
501
- let e = U(r, v), t = e.w.greaterThan(.5), n = F(g).sub(e.x.mul(m)), c = F(_).sub(e.y.mul(h)), f = n.greaterThanEqual(0).and(n.lessThan(F(m))).and(c.greaterThanEqual(0)).and(c.lessThan(F(h)));
502
- P(t.and(f), () => {
503
- let e = U(i, v), t = e.xyz.mul(2).sub(1), r = e.w, f = I(n), p = I(c), g = f.add(I(1)), _ = p.add(I(1)), y = n.sub(F(f)), b = c.sub(F(p)), S = f.clamp(I(0), I(m).sub(1)), ne = g.clamp(I(0), I(m).sub(1)), re = p.clamp(I(0), I(h).sub(1)), T = _.clamp(I(0), I(h).sub(1)), E = F(1).sub(y).mul(F(1).sub(b)), ie = y.mul(F(1).sub(b)), ae = F(1).sub(y).mul(b), oe = y.mul(b), se = (e, n, i) => {
504
- let o = U(a, L(e, n)), s = o.xyz.mul(2).sub(1), c = o.w, l = Rn(jn(t, s).clamp(0, 1), F(16)), u = Mn(Tn(r.sub(c)).div(z(r, F(.001))).div(F(.05)).negate());
496
+ return Tn(() => {
497
+ let g = F(Y.x).mul(8).add(F(L.x)), _ = F(Y.y).mul(8).add(F(L.y));
498
+ N(g.lessThan(F(m)).and(_.lessThan(F(h))), () => {
499
+ let v = I(g, _), y = H(t, v), b = y.xyz, x = y.w, S = H(n, v).xyz, ee = R(S, q(Vr)), C = $r(b.div(ee)), te = J(C, 1).toVar(), w = J(b, x).toVar();
500
+ N(f.greaterThan(.5).and(p.lessThan(.5)), () => {
501
+ let e = H(r, v), t = e.w.greaterThan(.5), n = P(g).sub(e.x.mul(m)), c = P(_).sub(e.y.mul(h)), f = n.greaterThanEqual(0).and(n.lessThan(P(m))).and(c.greaterThanEqual(0)).and(c.lessThan(P(h)));
502
+ N(t.and(f), () => {
503
+ let e = H(i, v), t = e.xyz.mul(2).sub(1), r = e.w, f = F(n), p = F(c), g = f.add(F(1)), _ = p.add(F(1)), y = n.sub(P(f)), b = c.sub(P(p)), S = f.clamp(F(0), F(m).sub(1)), ne = g.clamp(F(0), F(m).sub(1)), re = p.clamp(F(0), F(h).sub(1)), T = _.clamp(F(0), F(h).sub(1)), ie = P(1).sub(y).mul(P(1).sub(b)), ae = y.mul(P(1).sub(b)), oe = P(1).sub(y).mul(b), se = y.mul(b), ce = (e, n, i) => {
504
+ let o = H(a, I(e, n)), s = o.xyz.mul(2).sub(1), c = o.w, l = Vn(Pn(t, s).clamp(0, 1), P(16)), u = Fn(On(r.sub(c)).div(R(r, P(.001))).div(P(.05)).negate());
505
505
  return i.mul(l).mul(u);
506
- }, D = se(S, re, E), ce = se(ne, re, ie), O = se(S, T, ae), k = se(ne, T, oe), le = D.add(ce).add(O).add(k);
507
- P(le.greaterThan(F(.01)), () => {
508
- let e = U(o, L(S, re)), t = U(o, L(ne, re)), n = U(o, L(S, T)), r = U(o, L(ne, T)), i = F(1).div(le), a = e.xyz.mul(D).add(t.xyz.mul(ce)).add(n.xyz.mul(O)).add(r.xyz.mul(k)).mul(i), c = e.w.mul(D).add(t.w.mul(ce)).add(n.w.mul(O)).add(r.w.mul(k)).mul(i), f = U(s, v).x.mul(d).clamp(0, 1), p = Zr(B(a, C, B(z(F(1).div(c.add(1)), u), F(1), f))), m = In(c.add(1), l);
506
+ }, E = ce(S, re, ie), le = ce(ne, re, ae), D = ce(S, T, oe), O = ce(ne, T, se), ue = E.add(le).add(D).add(O);
507
+ N(ue.greaterThan(P(.01)), () => {
508
+ let e = H(o, I(S, re)), t = H(o, I(ne, re)), n = H(o, I(S, T)), r = H(o, I(ne, T)), i = P(1).div(ue), a = e.xyz.mul(E).add(t.xyz.mul(le)).add(n.xyz.mul(D)).add(r.xyz.mul(O)).mul(i), c = e.w.mul(E).add(t.w.mul(le)).add(n.w.mul(D)).add(r.w.mul(O)).mul(i), f = H(s, v).x.mul(d).clamp(0, 1), p = $r(z(a, C, z(R(P(1).div(c.add(1)), u), P(1), f))), m = zn(c.add(1), l);
509
509
  te.assign(J(p, m)), w.assign(J(p.mul(ee), x));
510
510
  });
511
511
  });
512
- }), W(e, Un(G(g), G(_)), te).toWriteOnly(), W(c, Un(G(g), G(_)), w).toWriteOnly();
512
+ }), U(e, Kn(W(g), W(_)), te).toWriteOnly(), U(c, Kn(W(g), W(_)), w).toWriteOnly();
513
513
  });
514
514
  })().compute([
515
515
  this._dispatchX,
@@ -523,35 +523,35 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
523
523
  }
524
524
  _buildHeatmapCompute() {
525
525
  let e = this._heatmapRawColorTexNode, t = this._heatmapColorTexNode, n = this._heatmapTemporalTexNode, r = this._heatmapNDTexNode, i = this._heatmapMotionTexNode, a = this._heatmapGradientTexNode, s = this._heatmapStorageTex, c = this.debugMode, l = this.resW, u = this.resH;
526
- this._heatmapComputeNode = Sn(() => {
527
- let d = I(Y.x).mul(8).add(I(R.x)), f = I(Y.y).mul(8).add(I(R.y));
528
- P(d.lessThan(I(l)).and(f.lessThan(I(u))), () => {
529
- let p = L(d, f), m = J(0, 0, 0, 1).toVar();
530
- P(c.equal(I(0)), () => {
531
- let e = U(t, p).xyz;
526
+ this._heatmapComputeNode = Tn(() => {
527
+ let d = F(Y.x).mul(8).add(F(L.x)), f = F(Y.y).mul(8).add(F(L.y));
528
+ N(d.lessThan(F(l)).and(f.lessThan(F(u))), () => {
529
+ let p = I(d, f), m = J(0, 0, 0, 1).toVar();
530
+ N(c.equal(F(0)), () => {
531
+ let e = H(t, p).xyz;
532
532
  m.assign(J(e, 1));
533
- }).ElseIf(c.equal(I(1)), () => {
534
- let t = F(0).toVar(), n = F(0).toVar();
533
+ }).ElseIf(c.equal(F(1)), () => {
534
+ let t = P(0).toVar(), n = P(0).toVar();
535
535
  for (let r = -1; r <= 1; r++) for (let i = -1; i <= 1; i++) {
536
- let a = U(e, L(d.add(i).clamp(I(0), I(l).sub(1)), f.add(r).clamp(I(0), I(u).sub(1)))).xyz, s = o(a);
536
+ let a = H(e, I(d.add(i).clamp(F(0), F(l).sub(1)), f.add(r).clamp(F(0), F(u).sub(1)))).xyz, s = o(a);
537
537
  t.addAssign(s), n.addAssign(s.mul(s));
538
538
  }
539
539
  t.divAssign(9), n.divAssign(9);
540
- let r = z(n.sub(t.mul(t)), F(0)).div(z(t.mul(t), F(1e-4))).mul(10).clamp(0, 1), i = r.sub(.5).mul(4).clamp(0, 1), a = r.mul(4).clamp(0, 1).sub(r.sub(.75).mul(4).clamp(0, 1)), s = F(1).sub(r.sub(.25).mul(4).clamp(0, 1));
540
+ let r = R(n.sub(t.mul(t)), P(0)).div(R(t.mul(t), P(1e-4))).mul(10).clamp(0, 1), i = r.sub(.5).mul(4).clamp(0, 1), a = r.mul(4).clamp(0, 1).sub(r.sub(.75).mul(4).clamp(0, 1)), s = P(1).sub(r.sub(.25).mul(4).clamp(0, 1));
541
541
  m.assign(J(i, a, s, 1));
542
- }).ElseIf(c.equal(I(2)), () => {
543
- let e = U(n, p).w.div(32).clamp(0, 1);
544
- m.assign(J(F(1).sub(e), e, F(.2), 1));
545
- }).ElseIf(c.equal(I(3)), () => {
546
- let e = U(i, p), t = Tn(e.x).mul(100).clamp(0, 1), n = Tn(e.y).mul(100).clamp(0, 1), r = t.add(n).clamp(0, 1);
542
+ }).ElseIf(c.equal(F(2)), () => {
543
+ let e = H(n, p).w.div(32).clamp(0, 1);
544
+ m.assign(J(P(1).sub(e), e, P(.2), 1));
545
+ }).ElseIf(c.equal(F(3)), () => {
546
+ let e = H(i, p), t = On(e.x).mul(100).clamp(0, 1), n = On(e.y).mul(100).clamp(0, 1), r = t.add(n).clamp(0, 1);
547
547
  m.assign(J(t, n, r.mul(.3), 1));
548
- }).ElseIf(c.equal(I(4)), () => {
549
- let e = U(r, p);
548
+ }).ElseIf(c.equal(F(4)), () => {
549
+ let e = H(r, p);
550
550
  m.assign(J(e.xyz, 1));
551
551
  }).Else(() => {
552
- let e = U(a, p).x.mul(5).clamp(0, 1);
553
- m.assign(J(e, e.mul(.5), F(1).sub(e), 1));
554
- }), W(s, Un(G(d), G(f)), m).toWriteOnly();
552
+ let e = H(a, p).x.mul(5).clamp(0, 1);
553
+ m.assign(J(e, e.mul(.5), P(1).sub(e), 1));
554
+ }), U(s, Kn(W(d), W(f)), m).toWriteOnly();
555
555
  });
556
556
  })().compute([
557
557
  this._dispatchX,
@@ -592,10 +592,10 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
592
592
  reallocateReservedStorage() {
593
593
  this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._heatmapComputeNode?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._heatmapStorageTex?.dispose();
594
594
  let e = (e, t) => {
595
- let n = new M(k, k);
595
+ let n = new j(O, O);
596
596
  return n.type = e, n.format = Q, n.minFilter = t, n.magFilter = t, n;
597
597
  };
598
- this._temporalTexA = e(sr, X), this._temporalTexB = e(sr, X), this._outputModulatedTex = e(sr, X), this._gradientStorageTex = e(cr, X), this._heatmapStorageTex = e(sr, Z), this._buildGradientCompute(), this._buildTemporalCompute(), this._buildHeatmapCompute(), this._compiled = !1, this.currentMoments = 0, this._needsWarmReset = !0;
598
+ this._temporalTexA = e(lr, X), this._temporalTexB = e(lr, X), this._outputModulatedTex = e(lr, X), this._gradientStorageTex = e(ur, X), this._heatmapStorageTex = e(lr, Z), this._buildGradientCompute(), this._buildTemporalCompute(), this._buildHeatmapCompute(), this._compiled = !1, this.currentMoments = 0, this._needsWarmReset = !0;
599
599
  }
600
600
  setSize(e, t) {
601
601
  this._demodulatedRT.setSize(e, t), this._demodulatedRT.texture.needsUpdate = !0, this._outputRT.setSize(e, t), this._outputRT.texture.needsUpdate = !0, this._gradientRT.setSize(e, t), this._gradientRT.texture.needsUpdate = !0, this.heatmapTarget.setSize(e, t), this.heatmapTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / 8), this._dispatchY = Math.ceil(t / 8), this._gradientNode.dispatchSize = [
@@ -623,7 +623,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
623
623
  dispose() {
624
624
  this._gradientNode?.dispose(), this._temporalNodeA?.dispose(), this._temporalNodeB?.dispose(), this._temporalTexA?.dispose(), this._temporalTexB?.dispose(), this._outputModulatedTex?.dispose(), this._gradientStorageTex?.dispose(), this._demodulatedRT?.dispose(), this._outputRT?.dispose(), this._gradientRT?.dispose(), this._heatmapComputeNode?.dispose(), this._heatmapStorageTex?.dispose(), this.heatmapTarget?.dispose(), this._colorTexNode?.dispose(), this._albedoTexNode?.dispose(), this._motionTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._prevNormalDepthTexNode?.dispose(), this._readTemporalTexNode?.dispose(), this._gradientReadTexNode?.dispose(), this._heatmapRawColorTexNode?.dispose(), this._heatmapColorTexNode?.dispose(), this._heatmapTemporalTexNode?.dispose(), this._heatmapNDTexNode?.dispose(), this._heatmapMotionTexNode?.dispose(), this._heatmapGradientTexNode?.dispose();
625
625
  }
626
- }, $r = 1e-6, ei = 1.5 / 255, ti = .01, ni = 3, ri = 2, ii = 2, ai = 3, oi = 2, si = 38, ci = .1, li = 4, ui = Math.cos(89 * Math.PI / 180), di = .5, fi = 16, pi = {
626
+ }, 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 = 16, hi = {
627
627
  pre: {
628
628
  radiusScale: 1,
629
629
  fractionScale: 2
@@ -636,7 +636,7 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
636
636
  radiusScale: 2,
637
637
  fractionScale: .5
638
638
  }
639
- }, mi = .25 * Math.SQRT2, hi = [
639
+ }, gi = .25 * Math.SQRT2, _i = [
640
640
  [
641
641
  -1,
642
642
  0,
@@ -658,62 +658,62 @@ var Lr = 65504, Rr = 6e4, zr = .01, Br = {
658
658
  1
659
659
  ],
660
660
  [
661
- -mi,
662
- mi,
661
+ -gi,
662
+ gi,
663
663
  .5
664
664
  ],
665
665
  [
666
- mi,
667
- mi,
666
+ gi,
667
+ gi,
668
668
  .5
669
669
  ],
670
670
  [
671
- mi,
672
- -mi,
671
+ gi,
672
+ -gi,
673
673
  .5
674
674
  ],
675
675
  [
676
- -mi,
677
- -mi,
676
+ -gi,
677
+ -gi,
678
678
  .5
679
679
  ]
680
- ], gi = (e, t, n) => Bn(0, 1, F(1).sub(e.mul(t).add(n).abs())), _i = (e, t, n) => {
681
- let r = e.mul(t).add(n).abs().mul(-ni);
682
- return F(1).div(r.mul(r).sub(r).add(1));
683
- }, vi = (e) => B(F(1.570796), F(1.395402), V(e)).mul(Vn(V(F(1).sub(e)))), yi = (e, t) => F(1).sub(Nn(e.mul(e).mul(-200))).mul(Rn(V(e), t)), bi = (e, t) => V(e).mul(Vn(t.div(F(1).sub(t).add($r)))), xi = (e, t, n, r) => {
684
- let i = z(En(bi(n, r.mul(B(V(t), F(1), e)))), F(ei));
685
- return F(1).div(i);
686
- }, Si = (e, t) => {
687
- let n = F(1).div(B(F(ti), F(1), V(e.mul(t))));
688
- return Gn(n, e.mul(n).negate());
689
- }, Ci = (e, t, n) => {
690
- let r = F(1).div(B(F(n), F(1), B(e.mul(e), e, V(t))));
691
- return Gn(r, e.mul(r).negate());
680
+ ], vi = (e, t, n) => Un(0, 1, P(1).sub(e.mul(t).add(n).abs())), yi = (e, t, n) => {
681
+ let r = e.mul(t).add(n).abs().mul(-ii);
682
+ return P(1).div(r.mul(r).sub(r).add(1));
683
+ }, bi = (e) => z(P(1.570796), P(1.395402), B(e)).mul(Wn(B(P(1).sub(e)))), xi = (e, t) => P(1).sub(In(e.mul(e).mul(-200))).mul(Vn(B(e), t)), Si = (e, t) => B(e).mul(Wn(t.div(P(1).sub(t).add(ti)))), Ci = (e, t, n, r) => {
684
+ let i = R(kn(Si(n, r.mul(z(B(t), P(1), e)))), P(ni));
685
+ return P(1).div(i);
692
686
  }, wi = (e, t) => {
693
- let n = F(1).div(t);
694
- return Gn(n, e.mul(n).negate());
695
- }, Ti = (e, t, n, r) => {
696
- let i = F(1).div(e.mul(t));
697
- return Gn(i, jn(r, n).mul(i).negate());
698
- }, Ei = (e) => Gn(1).sub(Gn(1).sub(Fn(e.mul(.5)).mul(2)).abs()).min(.99999), Di = (e) => q(jn(e, q(.25, .5, .25)), jn(e, q(.5, 0, -.5)), jn(e, q(-.25, .5, -.25))), Oi = (e) => {
687
+ let n = P(1).div(z(P(ri), P(1), B(e.mul(t))));
688
+ return K(n, e.mul(n).negate());
689
+ }, Ti = (e, t, n) => {
690
+ let r = P(1).div(z(P(n), P(1), z(e.mul(e), e, B(t))));
691
+ return K(r, e.mul(r).negate());
692
+ }, Ei = (e, t) => {
693
+ let n = P(1).div(t);
694
+ return K(n, e.mul(n).negate());
695
+ }, Di = (e, t, n, r) => {
696
+ let i = P(1).div(e.mul(t));
697
+ return K(i, Pn(r, n).mul(i).negate());
698
+ }, Oi = (e) => K(1).sub(K(1).sub(Rn(e.mul(.5)).mul(2)).abs()).min(.99999), ki = (e) => q(Pn(e, q(.25, .5, .25)), Pn(e, q(.5, 0, -.5)), Pn(e, q(-.25, .5, -.25))), Ai = (e) => {
699
699
  let t = e.x.sub(e.z);
700
- return z(q(t.add(e.y), e.x.add(e.z), t.sub(e.y)), q(0));
701
- }, ki = (e, t) => t.add($r).div(e.add($r)), Ai = (e, t) => J(e.xyz.mul(ki(e.x, t)), e.w), ji = (e) => J(Di(Oi(e.xyz)), V(e.w)), Mi = (e, t) => Vn(t.sub(e.mul(e)).abs()), Ni = (e, t) => Gn(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), Pi = (e, t) => H(e.equal(0), J(0), t);
702
- function Fi(e) {
700
+ return R(q(t.add(e.y), e.x.add(e.z), t.sub(e.y)), q(0));
701
+ }, ji = (e, t) => t.add(ti).div(e.add(ti)), Mi = (e, t) => J(e.xyz.mul(ji(e.x, t)), e.w), Ni = (e) => J(ki(Ai(e.xyz)), B(e.w)), Pi = (e, t) => Wn(t.sub(e.mul(e)).abs()), Fi = (e, t) => K(e.x.mul(t.x).add(e.y.mul(t.y)), e.z.mul(t.x).add(e.w.mul(t.y))), Ii = (e, t) => V(e.equal(0), J(0), t);
702
+ function Li(e) {
703
703
  let t = Math.imul(e | 0, 2654435761) >>> 0;
704
704
  return t ^= t >>> 15, t = Math.imul(t, 2246822507) >>> 0, t ^= t >>> 13, t = Math.imul(t, 3266489909) >>> 0, t ^= t >>> 16, t / 4294967296;
705
705
  }
706
- var Ii = class extends E {
706
+ var Ri = class extends oe {
707
707
  constructor(e, t = {}) {
708
708
  super("NRD", {
709
709
  ...t,
710
- executionMode: ge.PER_CYCLE
710
+ executionMode: E.PER_CYCLE
711
711
  }), this.renderer = e, this.pathTracer = t.pathTracer || null, this.settings = {
712
- ...Ur,
712
+ ...Gr,
713
713
  ...t.settings || {}
714
- }, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(z(t.mul(.1).add(3), F(1e-4))).clamp(0, 1) }) ?? null;
714
+ }, this._releaseHitDistance = this.pathTracer?.requestOutput?.("hitDistance", { encode: (e, t) => e.div(R(t.mul(.1).add(3), P(1e-4))).clamp(0, 1) }) ?? null;
715
715
  let n = t.width || 1, r = t.height || 1;
716
- this.resW = K(n), this.resH = K(r), this.minRectDimMulUnproject = K(1), this.inputFrames = K(0), this.resetU = K(0), this.debugMode = K(0, "int"), this.rotPre = K(new Mr(1, 0, 0, 1), "vec4"), this.rotBlur = K(new Mr(1, 0, 0, 1), "vec4"), this.rotPost = K(new Mr(1, 0, 0, 1), "vec4"), this.camWorld = K(new pr(), "mat4"), this.camProjInv = K(new pr(), "mat4"), this.camView = K(new pr(), "mat4"), this.prevCamView = K(new pr(), "mat4"), this.camPos = K(new $(), "vec3"), this.prevCamPos = K(new $(), "vec3"), this.viewVector = K(new $(), "vec3"), this.prevViewVector = K(new $(), "vec3"), this.cameraRay = A(), this.u = {};
716
+ this.resW = G(n), this.resH = G(r), this.minRectDimMulUnproject = G(1), this.inputFrames = G(0), this.resetU = G(0), this.debugMode = G(0, "int"), this.rotPre = G(new Pr(1, 0, 0, 1), "vec4"), this.rotBlur = G(new Pr(1, 0, 0, 1), "vec4"), this.rotPost = G(new Pr(1, 0, 0, 1), "vec4"), this.camWorld = G(new hr(), "mat4"), this.camProjInv = G(new hr(), "mat4"), this.camView = G(new hr(), "mat4"), this.prevCamView = G(new hr(), "mat4"), this.camPos = G(new $(), "vec3"), this.prevCamPos = G(new $(), "vec3"), this.viewVector = G(new $(), "vec3"), this.prevViewVector = G(new $(), "vec3"), this.cameraRay = fe(), this.u = {};
717
717
  for (let e of [
718
718
  "maxAccum",
719
719
  "maxFast",
@@ -733,25 +733,25 @@ var Ii = class extends E {
733
733
  "disocclusionThreshold",
734
734
  "lobeVolumePercent",
735
735
  "handoverFrames"
736
- ]) this.u[e] = K(0);
737
- this.u.antilag = K(new jr(), "vec2"), this.u.convergence = K(new $(), "vec3"), this._syncUniforms(), this._colorTexNode = new N(), this._albedoTexNode = new N(), this._ndTexNode = new N(), this._snTexNode = new N(), this._motionTexNode = new N(), this._placeholders = /* @__PURE__ */ new Map();
736
+ ]) this.u[e] = G(0);
737
+ this.u.antilag = G(new Nr(), "vec2"), this.u.convergence = G(new $(), "vec3"), this._syncUniforms(), this._colorTexNode = new M(), this._albedoTexNode = new M(), this._ndTexNode = new M(), this._snTexNode = new M(), this._motionTexNode = new M(), this._placeholders = /* @__PURE__ */ new Map();
738
738
  let i = () => {
739
- let e = new ar(new Float32Array(4), 1, 1, Q, sr);
739
+ let e = new sr(new Float32Array(4), 1, 1, Q, lr);
740
740
  e.needsUpdate = !0;
741
- let t = new N(e);
741
+ let t = new M(e);
742
742
  return this._placeholders.set(t, e), t;
743
743
  };
744
- this._nTmpA = i(), this._nTmpB = i(), this._nHist = i(), this._nFast = i(), this._nInternal = i(), this._nGeom = i(), this._nData = i(), this._nStabRead = i(), this._allocStorage(), this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this.outputTarget = new bn(n, r, {
745
- type: cr,
744
+ this._nTmpA = i(), this._nTmpB = i(), this._nHist = i(), this._nFast = i(), this._nInternal = i(), this._nGeom = i(), this._nData = i(), this._nStabRead = i(), this._allocStorage(), this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0)), this.outputTarget = new Cn(n, r, {
745
+ type: ur,
746
746
  format: Q,
747
747
  minFilter: X,
748
748
  magFilter: X,
749
749
  depthBuffer: !1,
750
750
  stencilBuffer: !1
751
- }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / fi), this._dispatchY = Math.ceil(r / fi), this._buildKernels();
751
+ }), this._compiled = !1, this._needsReset = !0, this._stabPing = 0, this._camInitialized = !1, this._dispatchX = Math.ceil(n / mi), this._dispatchY = Math.ceil(r / mi), this._buildKernels();
752
752
  }
753
753
  _allocStorage() {
754
- let e = () => pe(cr);
754
+ let e = () => de(ur);
755
755
  this._tmpA = e(), this._tmpB = e(), this._hist = e(), this._fastHist = e(), this._internal = e(), this._geomPrev = e(), this._stabA = e(), this._stabB = e(), this._dataT = e();
756
756
  }
757
757
  _disposeStorage() {
@@ -772,7 +772,7 @@ var Ii = class extends E {
772
772
  }
773
773
  updateParameters(e) {
774
774
  if (e) {
775
- for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Ur && (this.settings[t] = e[t]);
775
+ for (let t of Object.keys(e)) t === "debugMode" ? this.debugMode.value = e.debugMode | 0 : t in Gr && (this.settings[t] = e[t]);
776
776
  this._syncUniforms();
777
777
  }
778
778
  }
@@ -783,32 +783,32 @@ var Ii = class extends E {
783
783
  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;
784
784
  }
785
785
  _worldPosAt(e, t, n, r) {
786
- return ve(e, t, n, r, this.cameraRay);
786
+ return ge(e, t, n, r, this.cameraRay);
787
787
  }
788
788
  _viewVector(e, t, n) {
789
- return H(ne(this.cameraRay.cameraProjection), n, Ln(t.sub(e)));
789
+ return V(ne(this.cameraRay.cameraProjection), n, Bn(t.sub(e)));
790
790
  }
791
791
  _frustumSize(e) {
792
- return this.minRectDimMulUnproject.mul(H(ne(this.cameraRay.cameraProjection), F(1), e));
792
+ return this.minRectDimMulUnproject.mul(V(ne(this.cameraRay.cameraProjection), P(1), e));
793
793
  }
794
794
  _pixelUv(e, t) {
795
- return Gn(F(e).add(.5).div(this.resW), F(t).add(.5).div(this.resH));
795
+ return K(P(e).add(.5).div(this.resW), P(t).add(.5).div(this.resH));
796
796
  }
797
797
  _clampCoord(e, t) {
798
- return L(e.clamp(I(0), I(this.resW).sub(1)), t.clamp(I(0), I(this.resH).sub(1)));
798
+ return I(e.clamp(F(0), F(this.resW).sub(1)), t.clamp(F(0), F(this.resH).sub(1)));
799
799
  }
800
800
  _uvToCoord(e) {
801
- return this._clampCoord(I(e.x.mul(this.resW)), I(e.y.mul(this.resH)));
801
+ return this._clampCoord(F(e.x.mul(this.resW)), F(e.y.mul(this.resH)));
802
802
  }
803
803
  _advancedNonLinear(e) {
804
- let t = this.u.convergence, n = V(e.div(F(1).add(this.u.maxAccum.mul(t.z)))), r = t.x.mul(B(t.y, F(1), n));
805
- return F(1).div(F(1).add(r.mul(e)));
804
+ let t = this.u.convergence, n = B(e.div(P(1).add(this.u.maxAccum.mul(t.z)))), r = t.x.mul(z(t.y, P(1), n));
805
+ return P(1).div(P(1).add(r.mul(e)));
806
806
  }
807
807
  _handover(e) {
808
- return V(e.div(z(this.u.handoverFrames, 1)));
808
+ return B(e.div(R(this.u.handoverFrames, 1)));
809
809
  }
810
810
  _bilinear(e) {
811
- let t = e.mul(Gn(this.resW, this.resH)).sub(.5), n = Pn(t), r = V(t.sub(n)), i = I(n.x), a = I(n.y), o = (e, t) => H(e.greaterThanEqual(I(0)).and(t.greaterThanEqual(I(0))).and(e.lessThan(I(this.resW))).and(t.lessThan(I(this.resH))), F(1), F(0));
811
+ let t = e.mul(K(this.resW, this.resH)).sub(.5), n = Ln(t), r = B(t.sub(n)), i = F(n.x), a = F(n.y), o = (e, t) => V(e.greaterThanEqual(F(0)).and(t.greaterThanEqual(F(0))).and(e.lessThan(F(this.resW))).and(t.lessThan(F(this.resH))), P(1), P(0));
812
812
  return {
813
813
  f: r,
814
814
  taps: [
@@ -824,22 +824,22 @@ var Ii = class extends E {
824
824
  o(i.add(1), a.add(1))
825
825
  ],
826
826
  customWeights: (e) => [
827
- e[0].mul(F(1).sub(r.x)).mul(F(1).sub(r.y)),
828
- e[1].mul(r.x).mul(F(1).sub(r.y)),
829
- e[2].mul(F(1).sub(r.x)).mul(r.y),
827
+ e[0].mul(P(1).sub(r.x)).mul(P(1).sub(r.y)),
828
+ e[1].mul(r.x).mul(P(1).sub(r.y)),
829
+ e[2].mul(P(1).sub(r.x)).mul(r.y),
830
830
  e[3].mul(r.x).mul(r.y)
831
831
  ],
832
- filter: (e) => B(B(e[0], e[1], r.x), B(e[2], e[3], r.x), r.y)
832
+ filter: (e) => z(z(e[0], e[1], r.x), z(e[2], e[3], r.x), r.y)
833
833
  };
834
834
  }
835
835
  _applyCustomWeights(e, t, n) {
836
836
  let r = e[0].mul(t[0]).add(e[1].mul(t[1])).add(e[2].mul(t[2])).add(e[3].mul(t[3])), i = t[0].add(t[1]).add(t[2]).add(t[3]);
837
- return H(i.lessThan(1e-4), n, r.div(z(i, 1e-4)));
837
+ return V(i.lessThan(1e-4), n, r.div(R(i, 1e-4)));
838
838
  }
839
839
  _sampleHistory(e, t, n, r, i) {
840
840
  let a = J(0).toVar();
841
- return P(i, () => {
842
- let n = V(t).mul(Gn(this.resW, this.resH)), r = Pn(n.sub(.5)).add(.5), i = V(n.sub(r)), o = di, 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 = [
841
+ return N(i, () => {
842
+ let n = B(t).mul(K(this.resW, this.resH)), r = Ln(n.sub(.5)).add(.5), i = B(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 = [
843
843
  s.x,
844
844
  c.x,
845
845
  l.x,
@@ -849,13 +849,13 @@ var Ii = class extends E {
849
849
  c.y,
850
850
  l.y,
851
851
  u.y
852
- ], p = I(r.x).sub(1), m = I(r.y).sub(1), h = J(0).toVar(), g = F(0).toVar();
852
+ ], p = F(r.x).sub(1), m = F(r.y).sub(1), h = J(0).toVar(), g = P(0).toVar();
853
853
  for (let t = 0; t < 4; t++) for (let n = 0; n < 4; n++) {
854
854
  if ((n === 0 || n === 3) && (t === 0 || t === 3)) continue;
855
855
  let r = d[n].mul(f[t]);
856
856
  h.addAssign(e(this._clampCoord(p.add(n), m.add(t))).mul(r)), g.addAssign(r);
857
857
  }
858
- a.assign(H(g.lessThan(1e-4), J(0), h.div(z(g, 1e-4))));
858
+ a.assign(V(g.lessThan(1e-4), J(0), h.div(R(g, 1e-4))));
859
859
  }).Else(() => {
860
860
  a.assign(this._applyCustomWeights(n.taps.map((t) => e(t)), r, J(0)));
861
861
  }), a;
@@ -877,176 +877,176 @@ var Ii = class extends E {
877
877
  this._dispatchY,
878
878
  1
879
879
  ], [
880
- fi,
881
- fi,
880
+ mi,
881
+ mi,
882
882
  1
883
883
  ]);
884
884
  }
885
885
  _buildSpatial(e) {
886
- let t = e === "pre", { radiusScale: r, fractionScale: a } = pi[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, ee = t ? (e) => {
887
- let t = U(c, e), r = U(l, e);
888
- return J(Di(n(t.xyz.div(z(r.xyz, q(zr))))), i(r.w, s).min(1));
889
- } : (e) => U(p, e), C = Sn(([n, i]) => {
890
- let s = I(Y.x).mul(fi).add(I(R.x)), c = I(Y.y).mul(fi).add(I(R.y));
891
- P(s.lessThan(I(b)).and(c.lessThan(I(x))), () => {
892
- let l = L(s, c), p = Un(G(s), G(c)), C = U(u, l).w.toVar(), te = C.greaterThanEqual(Rr), w = U(d, l).toVar(), ne = Ln(w.xyz.mul(2).sub(1)).toVar(), re = w.w.clamp(.05, 1).toVar(), T = F(Rr).toVar(), E = ee(l).toVar();
893
- P(te.not(), () => {
886
+ let t = e === "pre", { radiusScale: r, fractionScale: a } = hi[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, ee = t ? (e) => {
887
+ let t = H(c, e), r = H(l, e);
888
+ return J(ki(n(t.xyz.div(R(r.xyz, q(Vr))))), i(r.w, s).min(1));
889
+ } : (e) => H(p, e), C = Tn(([n, i]) => {
890
+ let s = F(Y.x).mul(mi).add(F(L.x)), c = F(Y.y).mul(mi).add(F(L.y));
891
+ N(s.lessThan(F(b)).and(c.lessThan(F(x))), () => {
892
+ let l = I(s, c), p = Kn(W(s), W(c)), C = H(u, l).w.toVar(), te = C.greaterThanEqual(Br), w = H(d, l).toVar(), ne = Bn(w.xyz.mul(2).sub(1)).toVar(), re = w.w.clamp(.05, 1).toVar(), T = P(Br).toVar(), ie = ee(l).toVar();
893
+ N(te.not(), () => {
894
894
  let e = this._pixelUv(s, c), p = this._worldPosAt(e, C, n, i).toVar();
895
- T.assign(v.mul(J(p, 1)).z.abs()), P(_.greaterThan(0), () => {
896
- let s = jn(ne, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(T).toVar(), m = S.add(1), h = t ? z(S, F(10)) : U(f, l).y.add(S), C = (t ? F(1).div(h.add(1)) : this._advancedNonLinear(h)).toVar(), te = yi(re, .5).toVar(), w = T.mul(Hr).add(3), ie = E.w.toVar(), ae = V(ie.mul(w).div(c)), oe = F(1).sub(this._handover(m)), se = (t ? ae.div(m) : ae.mul(C)).mul(oe), D = o.minBlurRadius.mul(V(F(2).sub(h.div(z(o.maxAccum, 1))))), ce = z(V(Vn(V(se)).mul(r)).mul(_).mul(te), D.mul(te)).toVar(), O = Ti(o.planeDistSensitivity, c, p, ne).toVar(), k = xi(C, o.lobeAngleFraction, re, o.lobeVolumePercent).div(a).toVar(), le = Si(re, o.roughnessFraction.mul(a)).toVar(), ue = wi(ie, C).toVar(), de = o.minHitDistanceWeight.mul(a).mul(te);
897
- t || (de = de.mul(C)), de = de.toVar();
898
- let A = Gn(1);
895
+ T.assign(v.mul(J(p, 1)).z.abs()), N(_.greaterThan(0), () => {
896
+ let s = Pn(ne, this._viewVector(p, y, this.viewVector)).abs().toVar(), c = this._frustumSize(T).toVar(), m = S.add(1), h = t ? R(S, P(10)) : H(f, l).y.add(S), C = (t ? P(1).div(h.add(1)) : this._advancedNonLinear(h)).toVar(), te = xi(re, .5).toVar(), w = T.mul(Wr).add(3), ae = ie.w.toVar(), oe = B(ae.mul(w).div(c)), se = P(1).sub(this._handover(m)), ce = (t ? oe.div(m) : oe.mul(C)).mul(se), E = o.minBlurRadius.mul(B(P(2).sub(h.div(R(o.maxAccum, 1))))), le = R(B(Wn(B(ce)).mul(r)).mul(_).mul(te), E.mul(te)).toVar(), D = Di(o.planeDistSensitivity, c, p, ne).toVar(), O = Ci(C, o.lobeAngleFraction, re, o.lobeVolumePercent).div(a).toVar(), ue = wi(re, o.roughnessFraction.mul(a)).toVar(), de = Ei(ae, C).toVar(), fe = o.minHitDistanceWeight.mul(a).mul(te);
897
+ t || (fe = fe.mul(C)), fe = fe.toVar();
898
+ let k = K(1);
899
899
  if (!t) {
900
900
  let e = v.mul(J(ne, 0)).xy;
901
- A = B(Gn(1).sub(e.abs()), Gn(1), s), A = A.div(z(A.x, A.y));
901
+ k = z(K(1).sub(e.abs()), K(1), s), k = k.div(R(k.x, k.y));
902
902
  }
903
- let fe = A.mul(Gn(F(1).div(b), F(1).div(x))).mul(ce).toVar(), pe = F(1).toVar();
904
- for (let t = 0; t < hi.length; t++) {
905
- let r = hi[t], a = e.add(Ni(g, Gn(r[0], r[1])).mul(fe)), o = Ei(a), s = H(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), F(1), F(Math.exp(-.66 * r[2] * r[2]))).toVar(), c = this._uvToCoord(o), l = U(u, c).w, f = this._worldPosAt(o, l, n, i), p = U(d, c), m = vi(jn(ne, Ln(p.xyz.mul(2).sub(1))));
906
- s.mulAssign(gi(m, k, F(0))), s.mulAssign(gi(p.w, le.x, le.y)), s.mulAssign(gi(jn(ne, f), O.x, O.y)), s.assign(H(l.greaterThanEqual(Rr), F(0), s));
907
- let h = Pi(s, ee(c));
908
- s.mulAssign(de.add(_i(h.w, ue.x, ue.y))), pe.addAssign(s), E.addAssign(h.mul(s));
903
+ let pe = k.mul(K(P(1).div(b), P(1).div(x))).mul(le).toVar(), me = P(1).toVar();
904
+ for (let t = 0; t < _i.length; t++) {
905
+ let r = _i[t], a = e.add(Fi(g, K(r[0], r[1])).mul(pe)), o = Oi(a), s = V(o.x.notEqual(a.x).or(o.y.notEqual(a.y)), P(1), P(Math.exp(-.66 * r[2] * r[2]))).toVar(), c = this._uvToCoord(o), l = H(u, c).w, f = this._worldPosAt(o, l, n, i), p = H(d, c), m = bi(Pn(ne, Bn(p.xyz.mul(2).sub(1))));
906
+ s.mulAssign(vi(m, O, P(0))), s.mulAssign(vi(p.w, ue.x, ue.y)), s.mulAssign(vi(Pn(ne, f), D.x, D.y)), s.assign(V(l.greaterThanEqual(Br), P(0), s));
907
+ let h = Ii(s, ee(c));
908
+ s.mulAssign(fe.add(yi(h.w, de.x, de.y))), me.addAssign(s), ie.addAssign(h.mul(s));
909
909
  }
910
- E.divAssign(z(pe, 1e-6)), t || E.assign(J(E.xyz, ie));
910
+ ie.divAssign(R(me, 1e-6)), t || ie.assign(J(ie.xyz, ae));
911
911
  });
912
- }), W(m, p, E).toWriteOnly(), e === "post" && W(h, p, J(ne, T)).toWriteOnly();
912
+ }), U(m, p, ie).toWriteOnly(), e === "post" && U(h, p, J(ne, T)).toWriteOnly();
913
913
  });
914
914
  });
915
915
  return this._dispatchOf(C);
916
916
  }
917
917
  _buildTemporalAccumulation() {
918
- 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 = Sn(([y, b]) => {
919
- let x = I(Y.x).mul(fi).add(I(R.x)), S = I(Y.y).mul(fi).add(I(R.y));
920
- P(x.lessThan(I(h)).and(S.lessThan(I(g))), () => {
921
- let h = L(x, S), g = Un(G(x), G(S)), ee = U(t, h).w, C = U(i, h).toVar();
922
- P(ee.greaterThanEqual(Rr), () => {
923
- W(l, g, C).toWriteOnly(), W(u, g, J(0)).toWriteOnly(), wn();
918
+ 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]) => {
919
+ let x = F(Y.x).mul(mi).add(F(L.x)), S = F(Y.y).mul(mi).add(F(L.y));
920
+ N(x.lessThan(F(h)).and(S.lessThan(F(g))), () => {
921
+ let h = I(x, S), g = Kn(W(x), W(S)), ee = H(t, h).w, C = H(i, h).toVar();
922
+ N(ee.greaterThanEqual(Br), () => {
923
+ U(l, g, C).toWriteOnly(), U(u, g, J(0)).toWriteOnly(), Dn();
924
924
  });
925
- let te = e.maxAccum.mul(F(1).sub(v)).toVar(), w = e.maxFast.mul(F(1).sub(v)).toVar(), ne = U(n, h), re = Ln(ne.xyz.mul(2).sub(1)).toVar(), T = ne.w.clamp(.05, 1).toVar(), E = this._pixelUv(x, S), ie = this._worldPosAt(E, ee, y, b).toVar(), ae = d.mul(J(ie, 1)).z.abs().toVar(), oe = jn(re, this._viewVector(ie, p, this.viewVector)).abs().toVar(), se = this._frustumSize(ae).toVar(), D = q(0).toVar();
926
- D.addAssign(re.mul(.25));
925
+ let te = e.maxAccum.mul(P(1).sub(v)).toVar(), w = e.maxFast.mul(P(1).sub(v)).toVar(), ne = H(n, h), re = Bn(ne.xyz.mul(2).sub(1)).toVar(), T = ne.w.clamp(.05, 1).toVar(), ie = this._pixelUv(x, S), ae = this._worldPosAt(ie, ee, y, b).toVar(), oe = d.mul(J(ae, 1)).z.abs().toVar(), se = Pn(re, this._viewVector(ae, p, this.viewVector)).abs().toVar(), ce = this._frustumSize(oe).toVar(), E = q(0).toVar();
926
+ E.addAssign(re.mul(.25));
927
927
  for (let e = -1; e <= 0; e++) for (let r = -1; r <= 0; r++) {
928
928
  if (r === 0 && e === 0) continue;
929
- let i = this._clampCoord(x.add(r), S.add(e)), a = Ln(U(n, i).xyz.mul(2).sub(1)), o = U(t, i).w.lessThan(Rr);
930
- D.addAssign(H(o, a, re).mul(.25));
929
+ let i = this._clampCoord(x.add(r), S.add(e)), a = Bn(H(n, i).xyz.mul(2).sub(1)), o = H(t, i).w.lessThan(Br);
930
+ E.addAssign(V(o, a, re).mul(.25));
931
931
  }
932
- let ce = U(r, h), O = E.sub(ce.xy).toVar(), k = f.mul(J(ie, 1)).z.abs().toVar(), le = this._bilinear(O), ue = se.mul(V(e.disocclusionThreshold.div(z(oe, .05)))).sub($r).toVar(), de = F(1).sub(v), A = [], fe = [];
932
+ let le = H(r, h), D = ie.sub(le.xy).toVar(), O = f.mul(J(ae, 1)).z.abs().toVar(), ue = this._bilinear(D), de = ce.mul(B(e.disocclusionThreshold.div(R(se, .05)))).sub(ti).toVar(), fe = P(1).sub(v), k = [], pe = [];
933
933
  for (let e = 0; e < 4; e++) {
934
- let t = U(c, le.taps[e]), n = H(jn(t.xyz, D).greaterThan(ui), F(1), F(0)), r = H(t.w.sub(k).abs().lessThanEqual(ue), F(1), F(0)), i = H(t.w.lessThan(Rr), F(1), F(0));
935
- A.push(n.mul(r).mul(i).mul(le.inScreen[e]).mul(de).toVar()), fe.push(U(s, le.taps[e]).x);
934
+ let t = H(c, ue.taps[e]), n = V(Pn(t.xyz, E).greaterThan(fi), P(1), P(0)), r = V(t.w.sub(O).abs().lessThanEqual(de), P(1), P(0)), i = V(t.w.lessThan(Br), P(1), P(0));
935
+ k.push(n.mul(r).mul(i).mul(ue.inScreen[e]).mul(fe).toVar()), pe.push(H(s, ue.taps[e]).x);
936
936
  }
937
- let pe = le.customWeights(A).map((e) => e.toVar()), me = A[0].add(A[1]).add(A[2]).add(A[3]).greaterThan(3.5).toVar(), he = A[0].add(A[1].mul(2)).add(A[2].mul(4)).add(A[3].mul(8)), ge = this._applyCustomWeights(fe, pe, F(0)).toVar(), _e = jn(re, this._viewVector(ie, m, this.prevViewVector)).abs().add(.001).div(oe.add(.001)).toVar();
938
- _e.assign(B(F(.1), F(1), V(_e.mul(_e))));
939
- let ve = Vn(V(le.filter(A))).mul(_e).toVar();
940
- ge.assign(ge.mul(B(ve, F(1), F(1).div(ge.add(1))))), ge.assign(In(ge, te));
941
- let ye = ji(this._sampleHistory((e) => U(a, e), O, le, pe, me)).toVar(), be = z(this._applyCustomWeights(le.taps.map((e) => U(o, e).x), pe, F(0)), 0).toVar(), xe = _.add(1), Se = this._handover(xe).toVar(), Ce = ge.mul(F(1).sub(Se)), we = xe.div(xe.add(Ce)).toVar(), Te = F(1).div(F(1).add(yi(T, .25).mul(.5).mul(te))), Ee = J(B(ye.xyz, C.xyz, we), B(ye.w, C.w, z(we, Te))).toVar(), De = e.fireflyMinRelativeScale.add(F(si).div(ge.add(1))).toVar(), Oe = ge.mul(e.maxBlurRadius).mul(ci).toVar();
942
- Oe.assign(Oe.div(Oe.add(1)).mul(F(1).sub(Se)));
943
- let ke = B(Ee.x, In(Ee.x, ye.x.mul(De)), Oe);
944
- Ee.assign(Ai(Ee, ke));
945
- let Ae = F(1.2).add(F(1).div(ge.add(1)));
946
- Ee.assign(J(Ee.xyz, B(Ee.w, In(Ee.w, ye.w.mul(Ae)), Oe))), W(l, g, Ee).toWriteOnly();
947
- let je = In(ge, w).mul(F(1).sub(Se)), Me = xe.div(xe.add(je)), Ne = B(be, C.x, Me).toVar(), Pe = In(Ne, ye.x.mul(De).mul(li));
948
- Ne.assign(B(Ne, Pe, Oe)), W(u, g, J(Ne, ge, he, H(me, F(1), F(0)))).toWriteOnly();
937
+ let me = ue.customWeights(k).map((e) => e.toVar()), he = k[0].add(k[1]).add(k[2]).add(k[3]).greaterThan(3.5).toVar(), ge = k[0].add(k[1].mul(2)).add(k[2].mul(4)).add(k[3].mul(8)), _e = this._applyCustomWeights(pe, me, P(0)).toVar(), ve = Pn(re, this._viewVector(ae, m, this.prevViewVector)).abs().add(.001).div(se.add(.001)).toVar();
938
+ ve.assign(z(P(.1), P(1), B(ve.mul(ve))));
939
+ let ye = Wn(B(ue.filter(k))).mul(ve).toVar();
940
+ _e.assign(_e.mul(z(ye, P(1), P(1).div(_e.add(1))))), _e.assign(zn(_e, te));
941
+ let be = Ni(this._sampleHistory((e) => H(a, e), D, ue, me, he)).toVar(), xe = R(this._applyCustomWeights(ue.taps.map((e) => H(o, e).x), me, P(0)), 0).toVar(), Se = _.add(1), Ce = this._handover(Se).toVar(), we = _e.mul(P(1).sub(Ce)), Te = Se.div(Se.add(we)).toVar(), Ee = P(1).div(P(1).add(xi(T, .25).mul(.5).mul(te))), De = J(z(be.xyz, C.xyz, Te), z(be.w, C.w, R(Te, Ee))).toVar(), Oe = e.fireflyMinRelativeScale.add(P(li).div(_e.add(1))).toVar(), ke = _e.mul(e.maxBlurRadius).mul(ui).toVar();
942
+ ke.assign(ke.div(ke.add(1)).mul(P(1).sub(Ce)));
943
+ let Ae = z(De.x, zn(De.x, be.x.mul(Oe)), ke);
944
+ De.assign(Mi(De, Ae));
945
+ let je = P(1.2).add(P(1).div(_e.add(1)));
946
+ De.assign(J(De.xyz, z(De.w, zn(De.w, be.w.mul(je)), ke))), U(l, g, De).toWriteOnly();
947
+ let Me = zn(_e, w).mul(P(1).sub(Ce)), Ne = Se.div(Se.add(Me)), A = z(xe, C.x, Ne).toVar(), Pe = zn(A, be.x.mul(Oe).mul(di));
948
+ A.assign(z(A, Pe, ke)), U(u, g, J(A, _e, ge, V(he, P(1), P(0)))).toWriteOnly();
949
949
  });
950
950
  });
951
951
  return this._dispatchOf(y);
952
952
  }
953
953
  _buildHistoryFix() {
954
- 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 = Sn(([d, f]) => {
955
- let p = I(Y.x).mul(fi).add(I(R.x)), m = I(Y.y).mul(fi).add(I(R.y));
956
- P(p.lessThan(I(c)).and(m.lessThan(I(l))), () => {
957
- let h = L(p, m), g = Un(G(p), G(m)), _ = U(t, h).w;
958
- P(_.greaterThanEqual(Rr), () => {
959
- let e = U(r, h);
960
- W(a, g, e).toWriteOnly(), W(o, g, J(e.x, 0, 0, 0)).toWriteOnly(), wn();
954
+ 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]) => {
955
+ let p = F(Y.x).mul(mi).add(F(L.x)), m = F(Y.y).mul(mi).add(F(L.y));
956
+ N(p.lessThan(F(c)).and(m.lessThan(F(l))), () => {
957
+ let h = I(p, m), g = Kn(W(p), W(m)), _ = H(t, h).w;
958
+ N(_.greaterThanEqual(Br), () => {
959
+ let e = H(r, h);
960
+ U(a, g, e).toWriteOnly(), U(o, g, J(e.x, 0, 0, 0)).toWriteOnly(), Dn();
961
961
  });
962
- let v = U(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = U(n, h), ee = Ln(S.xyz.mul(2).sub(1)).toVar(), C = S.w.clamp(.05, 1).toVar(), te = this._pixelUv(p, m), w = this._worldPosAt(te, _, d, f).toVar(), ne = s.mul(J(w, 1)).z.abs(), re = this._frustumSize(ne).toVar(), T = U(r, h).toVar(), E = F(1).div(b.add(1)).toVar(), ie = ne.mul(Hr).add(3), ae = V(T.w.mul(ie).div(re)), oe = T.w.toVar(), se = zn(H(b.lessThan(e.historyFixFrameNum), F(1), F(0)).mul(.5).mul(2 / ri).mul(e.historyFixStride).mul(B(F(.25).add(Vn(ae).mul(.75)), F(1), E))).toVar();
963
- P(se.notEqual(0), () => {
964
- let a = xi(E, e.lobeAngleFraction, C, e.lobeVolumePercent).toVar(), o = Ti(e.planeDistSensitivity, re, w, ee).toVar(), s = wi(oe, E).toVar(), u = Ci(C.mul(C), Vn(e.roughnessFraction), ti).toVar(), p = F(1).add(y).toVar();
962
+ let v = H(i, h).toVar(), y = v.y.toVar(), b = y.add(u), x = this._handover(u.add(1)).toVar(), S = H(n, h), ee = Bn(S.xyz.mul(2).sub(1)).toVar(), C = S.w.clamp(.05, 1).toVar(), te = this._pixelUv(p, m), w = this._worldPosAt(te, _, d, f).toVar(), ne = s.mul(J(w, 1)).z.abs(), re = this._frustumSize(ne).toVar(), T = H(r, h).toVar(), ie = P(1).div(b.add(1)).toVar(), ae = ne.mul(Wr).add(3), oe = B(T.w.mul(ae).div(re)), se = T.w.toVar(), ce = Hn(V(b.lessThan(e.historyFixFrameNum), P(1), P(0)).mul(.5).mul(2 / ai).mul(e.historyFixStride).mul(z(P(.25).add(Wn(oe).mul(.75)), P(1), ie))).toVar();
963
+ N(ce.notEqual(0), () => {
964
+ let a = Ci(ie, e.lobeAngleFraction, C, e.lobeVolumePercent).toVar(), o = Di(e.planeDistSensitivity, re, w, ee).toVar(), s = Ei(se, ie).toVar(), u = Ti(C.mul(C), Wn(e.roughnessFraction), ri).toVar(), p = P(1).add(y).toVar();
965
965
  T.mulAssign(p);
966
- for (let e = -ri; e <= ri; e++) for (let m = -ri; m <= ri; m++) {
967
- if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === ri * 2) continue;
968
- let h = Ei(te.add(Gn(m, e).mul(se).mul(Gn(F(1).div(c), F(1).div(l))))), g = this._uvToCoord(h), _ = U(t, g).w, v = this._worldPosAt(h, _, d, f), y = U(n, g), b = _i(vi(jn(Ln(y.xyz.mul(2).sub(1)), ee)), a, F(0)).toVar();
969
- b.mulAssign(_i(y.w.mul(y.w), u.x, u.y)), b.mulAssign(F(1).add(U(i, g).y)), b.mulAssign(gi(jn(ee, v), o.x, o.y)), b.assign(H(_.greaterThanEqual(Rr), F(0), b));
970
- let x = Pi(b, U(r, g));
971
- b.mulAssign(_i(x.w, s.x, s.y)), p.addAssign(b), T.addAssign(x.mul(b));
966
+ for (let e = -ai; e <= ai; e++) for (let m = -ai; m <= ai; m++) {
967
+ if (m === 0 && e === 0 || Math.abs(m) + Math.abs(e) === ai * 2) continue;
968
+ let h = Oi(te.add(K(m, e).mul(ce).mul(K(P(1).div(c), P(1).div(l))))), g = this._uvToCoord(h), _ = H(t, g).w, v = this._worldPosAt(h, _, d, f), y = H(n, g), b = yi(bi(Pn(Bn(y.xyz.mul(2).sub(1)), ee)), a, P(0)).toVar();
969
+ b.mulAssign(yi(y.w.mul(y.w), u.x, u.y)), b.mulAssign(P(1).add(H(i, g).y)), b.mulAssign(vi(Pn(ee, v), o.x, o.y)), b.assign(V(_.greaterThanEqual(Br), P(0), b));
970
+ let x = Ii(b, H(r, g));
971
+ b.mulAssign(yi(x.w, s.x, s.y)), p.addAssign(b), T.addAssign(x.mul(b));
972
972
  }
973
- T.divAssign(z(p, 1e-6));
973
+ T.divAssign(R(p, 1e-6));
974
974
  });
975
- let D = T.x.toVar(), ce = V(y.div(z(e.historyFixFrameNum, $r))), O = B(D, v.x, ce).toVar();
976
- W(o, g, J(O, 0, 0, 0)).toWriteOnly();
977
- let k = O.toVar(), le = O.mul(O).toVar(), ue = F(0).toVar(), de = F(0).toVar(), A = (e, n, r) => {
978
- let a = this._clampCoord(p.add(e), m.add(n)), o = U(t, a).w, s = H(o.greaterThanEqual(Rr), O, U(i, a).x);
979
- Math.abs(e) <= ii && Math.abs(n) <= ii && (k.addAssign(s), le.addAssign(s.mul(s))), r && (ue.addAssign(s), de.addAssign(s.mul(s)));
980
- }, fe = e.antiFirefly.greaterThan(.5);
981
- for (let e = -ii; e <= ii; e++) for (let t = -ii; t <= ii; t++) t === 0 && e === 0 || A(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
982
- P(fe, () => {
983
- for (let e = -ai; e <= ai; e++) for (let t = -ai; t <= ai; t++) Math.abs(t) <= ii && Math.abs(e) <= ii || A(t, e, !0);
984
- }), P(fe, () => {
985
- let e = 1 / ((ai * 2 + 1) ** 2 - 9), t = ue.mul(e), n = Mi(t, de.mul(e)).mul(oi);
986
- D.assign(B(D.clamp(t.sub(n), t.add(n)), D, x));
975
+ let E = T.x.toVar(), le = B(y.div(R(e.historyFixFrameNum, ti))), D = z(E, v.x, le).toVar();
976
+ U(o, g, J(D, 0, 0, 0)).toWriteOnly();
977
+ let O = D.toVar(), ue = D.mul(D).toVar(), de = P(0).toVar(), fe = P(0).toVar(), k = (e, n, r) => {
978
+ let a = this._clampCoord(p.add(e), m.add(n)), o = H(t, a).w, s = V(o.greaterThanEqual(Br), D, H(i, a).x);
979
+ Math.abs(e) <= oi && Math.abs(n) <= oi && (O.addAssign(s), ue.addAssign(s.mul(s))), r && (de.addAssign(s), fe.addAssign(s.mul(s)));
980
+ }, pe = e.antiFirefly.greaterThan(.5);
981
+ for (let e = -oi; e <= oi; e++) for (let t = -oi; t <= oi; t++) t === 0 && e === 0 || k(t, e, Math.abs(t) > 1 || Math.abs(e) > 1);
982
+ N(pe, () => {
983
+ for (let e = -si; e <= si; e++) for (let t = -si; t <= si; t++) Math.abs(t) <= oi && Math.abs(e) <= oi || k(t, e, !0);
984
+ }), N(pe, () => {
985
+ let e = 1 / ((si * 2 + 1) ** 2 - 9), t = de.mul(e), n = Pi(t, fe.mul(e)).mul(ci);
986
+ E.assign(z(E.clamp(t.sub(n), t.add(n)), E, x));
987
987
  });
988
988
  {
989
- let t = 1 / (ii * 2 + 1) ** 2, n = k.mul(t), r = Mi(n, le.mul(t)).mul(e.fastClampSigmaScale), i = D.clamp(n.sub(r), n.add(r)), a = H(e.maxFast.lessThan(e.maxAccum), F(1), F(0)), o = B(F(1).div(F(1).add(a.mul(y).mul(2))), F(1), x);
990
- D.assign(B(i, D, o));
989
+ let t = 1 / (oi * 2 + 1) ** 2, n = O.mul(t), r = Pi(n, ue.mul(t)).mul(e.fastClampSigmaScale), i = E.clamp(n.sub(r), n.add(r)), a = V(e.maxFast.lessThan(e.maxAccum), P(1), P(0)), o = z(P(1).div(P(1).add(a.mul(y).mul(2))), P(1), x);
990
+ E.assign(z(i, E, o));
991
991
  }
992
- W(a, g, Ai(T, D)).toWriteOnly();
992
+ U(a, g, Mi(T, E)).toWriteOnly();
993
993
  });
994
994
  });
995
995
  return this._dispatchOf(d);
996
996
  }
997
997
  _buildTemporalStabilization(e) {
998
998
  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;
999
- return Sn(() => {
1000
- let _ = I(Y.x).mul(fi).add(I(R.x)), v = I(Y.y).mul(fi).add(I(R.y));
1001
- P(_.lessThan(I(f)).and(v.lessThan(I(p))), () => {
1002
- let f = L(_, v), p = Un(G(_), G(v)), y = U(i, f).w, b = U(n, f).toVar();
1003
- P(y.greaterThanEqual(Rr), () => {
1004
- W(d, p, b).toWriteOnly(), W(e, p, J(U(s, f).x, 0, 0, 0)).toWriteOnly(), W(u, p, J(0, 1, 0, 0)).toWriteOnly(), wn();
999
+ return Tn(() => {
1000
+ let _ = F(Y.x).mul(mi).add(F(L.x)), v = F(Y.y).mul(mi).add(F(L.y));
1001
+ N(_.lessThan(F(f)).and(v.lessThan(F(p))), () => {
1002
+ let f = I(_, v), p = Kn(W(_), W(v)), y = H(i, f).w, b = H(n, f).toVar();
1003
+ N(y.greaterThanEqual(Br), () => {
1004
+ U(d, p, b).toWriteOnly(), U(e, p, J(H(s, f).x, 0, 0, 0)).toWriteOnly(), U(u, p, J(0, 1, 0, 0)).toWriteOnly(), Dn();
1005
1005
  });
1006
- let x = U(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), ee = U(o, f), C = S.sub(ee.xy).toVar(), te = U(c, f).toVar(), w = te.y.toVar(), ne = G(te.z.add(.5)).toVar(), re = te.w.greaterThan(.5), T = this._bilinear(C), E = [
1006
+ let x = H(a, f).w.clamp(.05, 1), S = this._pixelUv(_, v), ee = H(o, f), C = S.sub(ee.xy).toVar(), te = H(c, f).toVar(), w = te.y.toVar(), ne = W(te.z.add(.5)).toVar(), re = te.w.greaterThan(.5), T = this._bilinear(C), ie = [
1007
1007
  1,
1008
1008
  2,
1009
1009
  4,
1010
1010
  8
1011
- ].map((e) => H(ne.bitAnd(G(e)).notEqual(G(0)), F(1), F(0))), ie = T.customWeights(E).map((e) => e.toVar()), ae = Vn(V(T.filter(E))).toVar(), oe = U(s, f).toVar(), se = oe.x.toVar(), D = se.toVar(), ce = se.mul(se).toVar();
1011
+ ].map((e) => V(ne.bitAnd(W(e)).notEqual(W(0)), P(1), P(0))), ae = T.customWeights(ie).map((e) => e.toVar()), oe = Wn(B(T.filter(ie))).toVar(), se = H(s, f).toVar(), ce = se.x.toVar(), E = ce.toVar(), le = ce.mul(ce).toVar();
1012
1012
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
1013
1013
  if (t === 0 && e === 0) continue;
1014
- let n = this._clampCoord(_.add(t), v.add(e)), r = U(i, n).w, a = H(r.greaterThanEqual(Rr), se, U(s, n).x);
1015
- D.addAssign(a), ce.addAssign(a.mul(a));
1014
+ let n = this._clampCoord(_.add(t), v.add(e)), r = H(i, n).w, a = V(r.greaterThanEqual(Br), ce, H(s, n).x);
1015
+ E.addAssign(a), le.addAssign(a.mul(a));
1016
1016
  }
1017
- D.divAssign(9), ce.divAssign(9);
1018
- let O = Mi(D, ce).toVar();
1019
- P(w.lessThan(t.historyFixFrameNum), () => {
1020
- se.assign(In(se, D.mul(F(1.2).add(F(1).div(w.add(1))))));
1017
+ E.divAssign(9), le.divAssign(9);
1018
+ let D = Pi(E, le).toVar();
1019
+ N(w.lessThan(t.historyFixFrameNum), () => {
1020
+ ce.assign(zn(ce, E.mul(P(1.2).add(P(1).div(w.add(1))))));
1021
1021
  });
1022
- let k = z(this._sampleHistory((e) => U(l, e), C, T, ie, re).x, 0).toVar(), le = O.mul(t.antilag.x), ue = t.antilag.y.mul(4), de = k.clamp(D.sub(le), D.add(le)), A = k.sub(de).abs().div(z(k, de).add($r)), fe = F(1).div(F(1).add(A.mul(w.mul(ae)).div(ue))).toVar(), pe = In(w, t.historyFixFrameNum);
1023
- w.assign(B(pe, w, fe));
1024
- let me = m.add(1), he = this._handover(me), ge = ae.mul(F(1).sub(this._advancedNonLinear(w.mul(F(1).sub(he)).div(me)))).mul(fe).toVar(), _e = F(1).add(ge.mul(6)), ve = t.stabilizationStrength.mul(F(1).sub(h)), ye = B(se, k.clamp(D.sub(O.mul(_e)), D.add(O.mul(_e))), In(ge, ve)).toVar();
1025
- oe.assign(Ai(oe, ye)), W(e, p, J(ye, 0, 0, 0)).toWriteOnly();
1026
- let be = t.maxAccum.mul(F(1).sub(h));
1027
- W(u, p, J(In(w.add(1), be), x, 0, 0)).toWriteOnly();
1028
- let xe = U(r, f), Se = J(Oi(oe.xyz).mul(z(xe.xyz, q(zr))), b.w).toVar();
1029
- P(g.equal(I(1)), () => {
1030
- let e = V(w.div(z(t.maxAccum, 1)));
1031
- Se.assign(J(F(1).sub(e), e, .2, 1));
1032
- }).ElseIf(g.equal(I(2)), () => {
1033
- Se.assign(J(q(oe.w), 1));
1034
- }).ElseIf(g.equal(I(3)), () => {
1035
- Se.assign(J(q(x), 1));
1036
- }).ElseIf(g.equal(I(4)), () => {
1022
+ let O = R(this._sampleHistory((e) => H(l, e), C, T, ae, re).x, 0).toVar(), ue = D.mul(t.antilag.x), de = t.antilag.y.mul(4), fe = O.clamp(E.sub(ue), E.add(ue)), k = O.sub(fe).abs().div(R(O, fe).add(ti)), pe = P(1).div(P(1).add(k.mul(w.mul(oe)).div(de))).toVar(), me = zn(w, t.historyFixFrameNum);
1023
+ w.assign(z(me, w, pe));
1024
+ let he = m.add(1), ge = this._handover(he), _e = oe.mul(P(1).sub(this._advancedNonLinear(w.mul(P(1).sub(ge)).div(he)))).mul(pe).toVar(), ve = P(1).add(_e.mul(6)), ye = t.stabilizationStrength.mul(P(1).sub(h)), be = z(ce, O.clamp(E.sub(D.mul(ve)), E.add(D.mul(ve))), zn(_e, ye)).toVar();
1025
+ se.assign(Mi(se, be)), U(e, p, J(be, 0, 0, 0)).toWriteOnly();
1026
+ let xe = t.maxAccum.mul(P(1).sub(h));
1027
+ U(u, p, J(zn(w.add(1), xe), x, 0, 0)).toWriteOnly();
1028
+ let Se = H(r, f), Ce = J(Ai(se.xyz).mul(R(Se.xyz, q(Vr))), b.w).toVar();
1029
+ N(g.equal(F(1)), () => {
1030
+ let e = B(w.div(R(t.maxAccum, 1)));
1031
+ Ce.assign(J(P(1).sub(e), e, .2, 1));
1032
+ }).ElseIf(g.equal(F(2)), () => {
1033
+ Ce.assign(J(q(se.w), 1));
1034
+ }).ElseIf(g.equal(F(3)), () => {
1035
+ Ce.assign(J(q(x), 1));
1036
+ }).ElseIf(g.equal(F(4)), () => {
1037
1037
  let e = te.x.div(te.x.add(1));
1038
- Se.assign(J(q(e), 1));
1039
- }).ElseIf(g.equal(I(5)), () => {
1040
- Se.assign(J(q(te.z.div(15)), 1));
1041
- }), W(d, p, Se).toWriteOnly();
1038
+ Ce.assign(J(q(e), 1));
1039
+ }).ElseIf(g.equal(F(5)), () => {
1040
+ Ce.assign(J(q(te.z.div(15)), 1));
1041
+ }), U(d, p, Ce).toWriteOnly();
1042
1042
  });
1043
1043
  })().compute([
1044
1044
  this._dispatchX,
1045
1045
  this._dispatchY,
1046
1046
  1
1047
1047
  ], [
1048
- fi,
1049
- fi,
1048
+ mi,
1049
+ mi,
1050
1050
  1
1051
1051
  ]);
1052
1052
  }
@@ -1066,7 +1066,7 @@ var Ii = class extends E {
1066
1066
  }
1067
1067
  _updateRotators(e) {
1068
1068
  let t = (t, n) => {
1069
- let r = Fi(e * 3 + n) * Math.PI * 2;
1069
+ let r = Li(e * 3 + n) * Math.PI * 2;
1070
1070
  t.value.set(Math.cos(r), Math.sin(r), -Math.sin(r), Math.cos(r));
1071
1071
  };
1072
1072
  t(this.rotPre, 0), t(this.rotBlur, 1), t(this.rotPost, 2);
@@ -1093,7 +1093,7 @@ var Ii = class extends E {
1093
1093
  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;
1094
1094
  }
1095
1095
  setSize(e, t) {
1096
- this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / fi), this._dispatchY = Math.ceil(t / fi);
1096
+ this.outputTarget.setSize(e, t), this.outputTarget.texture.needsUpdate = !0, this.resW.value = e, this.resH.value = t, this._dispatchX = Math.ceil(e / mi), this._dispatchY = Math.ceil(t / mi);
1097
1097
  let n = [
1098
1098
  this._dispatchX,
1099
1099
  this._dispatchY,
@@ -1122,15 +1122,15 @@ var Ii = class extends E {
1122
1122
  for (let [e, t] of this._placeholders) e.dispose(), t.dispose();
1123
1123
  this._placeholders.clear();
1124
1124
  }
1125
- }, Li = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Ri = /* @__PURE__ */ Kn("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), zi = class extends E {
1125
+ }, zi = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Bi = /* @__PURE__ */ Jn("\n fn temporalAccumulate(\n lum: f32,\n prevMean: f32,\n prevMeanSq: f32,\n alpha: f32,\n spatialVariance: f32,\n varianceBoost: f32\n ) -> vec4f {\n\n let newMean = prevMean + ( lum - prevMean ) * alpha;\n let newMeanSq = prevMeanSq + ( lum * lum - prevMeanSq ) * alpha;\n let temporalVariance = max( newMeanSq - newMean * newMean, 0.0 );\n\n return vec4f(\n newMean,\n newMeanSq,\n temporalVariance * varianceBoost,\n spatialVariance * varianceBoost\n );\n\n }\n"), Vi = class extends oe {
1126
1126
  constructor(e, t = {}) {
1127
1127
  super("VarianceEstimation", {
1128
1128
  ...t,
1129
- executionMode: ge.ALWAYS
1130
- }), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = K(t.varianceBoost ?? 1), this.temporalAlpha = K(t.temporalAlpha ?? .1), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._colorTexNode = new N();
1129
+ executionMode: E.ALWAYS
1130
+ }), this.renderer = e, this.inputTextureName = t.inputTextureName || "pathtracer:color", this.varianceBoost = G(t.varianceBoost ?? 1), this.temporalAlpha = G(t.temporalAlpha ?? .1), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._colorTexNode = new M();
1131
1131
  let n = t.width || 1, r = t.height || 1;
1132
- this._storageTexA = new M(k, k), this._storageTexA.type = sr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new M(k, k), this._storageTexB.type = sr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._outputTarget = new bn(n, r, {
1133
- type: sr,
1132
+ this._storageTexA = new j(O, O), this._storageTexA.type = lr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new j(O, O), this._storageTexB.type = lr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0)), this._outputTarget = new Cn(n, r, {
1133
+ type: lr,
1134
1134
  format: Q,
1135
1135
  minFilter: X,
1136
1136
  magFilter: X,
@@ -1142,26 +1142,26 @@ var Ii = class extends E {
1142
1142
  this.on("pathtracer:viewpointChanged", () => this.reset());
1143
1143
  }
1144
1144
  _buildCompute() {
1145
- this._readTexNodeA = new N(), this._readTexNodeB = new N(), this._computeNodeA = this._buildComputeForDirection(this._storageTexA, this._readTexNodeB), this._computeNodeB = this._buildComputeForDirection(this._storageTexB, this._readTexNodeA);
1145
+ this._readTexNodeA = new M(), this._readTexNodeB = new M(), this._computeNodeA = this._buildComputeForDirection(this._storageTexA, this._readTexNodeB), this._computeNodeB = this._buildComputeForDirection(this._storageTexB, this._readTexNodeA);
1146
1146
  }
1147
1147
  _buildComputeForDirection(e, t) {
1148
- let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c = qn("float", 100);
1149
- return Sn(() => {
1150
- let l = R.x, u = R.y, d = u.mul(8).add(l), f = I(Y.x).mul(8).sub(1), p = I(Y.y).mul(8).sub(1), m = d.mod(10), h = d.div(10), g = U(n, L(f.add(I(m)).clamp(I(0), I(a).sub(1)), p.add(I(h)).clamp(I(0), I(s).sub(1)))).xyz;
1151
- c.element(d).assign(Li(o(g))), P(d.lessThan(G(36)), () => {
1152
- let e = d.add(G(64)), t = e.mod(10), r = e.div(10), i = U(n, L(f.add(I(t)).clamp(I(0), I(a).sub(1)), p.add(I(r)).clamp(I(0), I(s).sub(1)))).xyz;
1153
- c.element(e).assign(Li(o(i)));
1154
- }), Jn();
1155
- let _ = I(Y.x).mul(8).add(I(l)), v = I(Y.y).mul(8).add(I(u));
1156
- P(_.lessThan(I(a)).and(v.lessThan(I(s))), () => {
1157
- let n = F(0).toVar(), a = F(0).toVar();
1148
+ let n = this._colorTexNode, r = this.temporalAlpha, i = this.varianceBoost, a = this.resW, s = this.resH, c = Yn("float", 100);
1149
+ return Tn(() => {
1150
+ let l = L.x, u = L.y, d = u.mul(8).add(l), f = F(Y.x).mul(8).sub(1), p = F(Y.y).mul(8).sub(1), m = d.mod(10), h = d.div(10), g = H(n, I(f.add(F(m)).clamp(F(0), F(a).sub(1)), p.add(F(h)).clamp(F(0), F(s).sub(1)))).xyz;
1151
+ c.element(d).assign(zi(o(g))), N(d.lessThan(W(36)), () => {
1152
+ let e = d.add(W(64)), t = e.mod(10), r = e.div(10), i = H(n, I(f.add(F(t)).clamp(F(0), F(a).sub(1)), p.add(F(r)).clamp(F(0), F(s).sub(1)))).xyz;
1153
+ c.element(e).assign(zi(o(i)));
1154
+ }), Xn();
1155
+ let _ = F(Y.x).mul(8).add(F(l)), v = F(Y.y).mul(8).add(F(u));
1156
+ N(_.lessThan(F(a)).and(v.lessThan(F(s))), () => {
1157
+ let n = P(0).toVar(), a = P(0).toVar();
1158
1158
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
1159
1159
  let r = c.element(u.add(1 + e).mul(10).add(l.add(1 + t)));
1160
1160
  n.addAssign(r), a.addAssign(r.mul(r));
1161
1161
  }
1162
1162
  n.divAssign(9), a.divAssign(9);
1163
- let o = z(a.sub(n.mul(n)), F(0)), s = c.element(u.add(1).mul(10).add(l.add(1))), d = U(t, L(_, v));
1164
- W(e, Un(G(_), G(v)), Ri(s, d.x, d.y, r, o, i)).toWriteOnly();
1163
+ let o = R(a.sub(n.mul(n)), P(0)), s = c.element(u.add(1).mul(10).add(l.add(1))), d = H(t, I(_, v));
1164
+ U(e, Kn(W(_), W(v)), Bi(s, d.x, d.y, r, o, i)).toWriteOnly();
1165
1165
  });
1166
1166
  })().compute([
1167
1167
  this._dispatchX,
@@ -1207,23 +1207,23 @@ var Ii = class extends E {
1207
1207
  reallocateReservedStorage() {
1208
1208
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
1209
1209
  let e = () => {
1210
- let e = new M(k, k);
1211
- return e.type = sr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1210
+ let e = new j(O, O);
1211
+ return e.type = lr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1212
1212
  };
1213
1213
  this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
1214
1214
  }
1215
1215
  dispose() {
1216
1216
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._colorTexNode?.dispose(), this._readTexNodeA?.dispose(), this._readTexNodeB?.dispose();
1217
1217
  }
1218
- }, Bi = /* @__PURE__ */ Kn("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n // max(phiNorm, 1e-6): pow(0.0, 0.0) is undefined in WGSL and returned NaN on ~12%\n // of pixels when phiNormal was set to 0.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), max( phiNorm, 1e-6 ) );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Vi = class extends E {
1218
+ }, Hi = /* @__PURE__ */ Jn("\n fn bilateralWeight(\n centerLum: f32, sLum: f32,\n centerNormal: vec3f, sNormal: vec3f,\n centerDepth: f32, sDepth: f32,\n centerColor: vec3f, sColor: vec3f,\n kernelW: f32,\n sigmaL: f32, phiNorm: f32, phiDep: f32, phiCol: f32\n ) -> f32 {\n\n let lumW = exp( -abs( centerLum - sLum ) / sigmaL );\n // clamp dot to [0,1]: miss-ray normals decode to (-1,-1,-1) with\n // dot=3 → pow saturates to +inf → inf*0 = NaN. See project_tsl_pitfalls.\n // max(phiNorm, 1e-6): pow(0.0, 0.0) is undefined in WGSL and returned NaN on ~12%\n // of pixels when phiNormal was set to 0.\n let normW = pow( clamp( dot( centerNormal, sNormal ), 0.0, 1.0 ), max( phiNorm, 1e-6 ) );\n let depW = exp( -abs( centerDepth - sDepth ) / max( centerDepth * phiDep, 0.001 ) );\n let maxDiff = max( max( abs( centerColor.x - sColor.x ),\n abs( centerColor.y - sColor.y ) ),\n abs( centerColor.z - sColor.z ) );\n let avgLum = max( ( centerLum + sLum ) * 0.5, 0.0001 );\n let colW = exp( -( maxDiff / avgLum ) / max( phiCol, 0.0001 ) );\n return kernelW * lumW * normW * depW * colW;\n\n }\n"), Ui = class extends oe {
1219
1219
  constructor(e, t = {}) {
1220
1220
  super("BilateralFiltering", {
1221
1221
  ...t,
1222
- executionMode: ge.ALWAYS
1223
- }), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:demodulated", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.shadingNormalTextureName = t.shadingNormalTextureName || "pathtracer:shadingNormal", this.albedoTextureName = t.albedoTextureName || "pathtracer:albedo", this.varianceTextureName = t.varianceTextureName || "variance:output", this.iterations = t.iterations ?? 4, this.phiColor = K(t.phiColor ?? .5), this.phiNormal = K(t.phiNormal ?? 128), this.phiDepth = K(t.phiDepth ?? .05), this.phiLuminance = K(t.phiLuminance ?? 4), this.spatialVarianceWeight = K(t.spatialVarianceWeight ?? 1), this.stepSizeU = K(1, "int"), this.isLastIterationU = K(0, "int"), this.isFirstIterationU = K(1, "int"), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._readTexNode = new N(), this._normalDepthTexNode = new N(), this._shadingNormalTexNode = new N(), this._albedoTexNode = new N(), this._varianceTexNode = new N(), this._srcAlphaTexNode = new N();
1222
+ executionMode: E.ALWAYS
1223
+ }), this.renderer = e, this.inputTextureName = t.inputTextureName || "asvgf:demodulated", this.normalDepthTextureName = t.normalDepthTextureName || "pathtracer:normalDepth", this.shadingNormalTextureName = t.shadingNormalTextureName || "pathtracer:shadingNormal", this.albedoTextureName = t.albedoTextureName || "pathtracer:albedo", this.varianceTextureName = t.varianceTextureName || "variance:output", this.iterations = t.iterations ?? 4, this.phiColor = G(t.phiColor ?? .5), this.phiNormal = G(t.phiNormal ?? 128), this.phiDepth = G(t.phiDepth ?? .05), this.phiLuminance = G(t.phiLuminance ?? 4), this.spatialVarianceWeight = G(t.spatialVarianceWeight ?? 1), this.stepSizeU = G(1, "int"), this.isLastIterationU = G(0, "int"), this.isFirstIterationU = G(1, "int"), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._readTexNode = new M(), this._normalDepthTexNode = new M(), this._shadingNormalTexNode = new M(), this._albedoTexNode = new M(), this._varianceTexNode = new M(), this._srcAlphaTexNode = new M();
1224
1224
  let n = t.width || 1, r = t.height || 1;
1225
- this._storageTexA = new M(k, k), this._storageTexA.type = cr, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new M(k, k), this._storageTexB.type = cr, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this._outputTarget = new bn(n, r, {
1226
- type: cr,
1225
+ this._storageTexA = new j(O, O), this._storageTexA.type = ur, this._storageTexA.format = Q, this._storageTexA.minFilter = X, this._storageTexA.magFilter = X, this._storageTexB = new j(O, O), this._storageTexB.type = ur, this._storageTexB.format = Q, this._storageTexB.minFilter = X, this._storageTexB.magFilter = X, this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0)), this._outputTarget = new Cn(n, r, {
1226
+ type: ur,
1227
1227
  format: Q,
1228
1228
  minFilter: X,
1229
1229
  magFilter: X,
@@ -1262,19 +1262,19 @@ var Ii = class extends E {
1262
1262
  4 / 256,
1263
1263
  1 / 256
1264
1264
  ];
1265
- return Sn(() => {
1266
- let y = I(Y.x).mul(8).add(I(R.x)), b = I(Y.y).mul(8).add(I(R.y));
1267
- P(y.lessThan(I(g)).and(b.lessThan(I(_))), () => {
1268
- let x = L(y, b), S = U(t, x), ee = S.xyz, C = U(n, x), te = U(r, x).xyz.mul(2).sub(1), w = C.w, ne = o(ee), re = z(U(i, x).xyz, q(zr)), T = z(o(re), F(zr)).toVar(), E = h.equal(I(1)), ie = (e) => {
1269
- let t = U(a, e);
1270
- return B(t.z, z(t.z, t.w), f);
1271
- }, ae = E.select(ie(x), S.w.mul(S.w)).toVar(), oe = d.mul(Vn(z(ae, F(0)))).div(T).add(F(1e-4)), se = q(0).toVar(), D = F(0).toVar(), ce = F(0).toVar();
1265
+ return Tn(() => {
1266
+ let y = F(Y.x).mul(8).add(F(L.x)), b = F(Y.y).mul(8).add(F(L.y));
1267
+ N(y.lessThan(F(g)).and(b.lessThan(F(_))), () => {
1268
+ let x = I(y, b), S = H(t, x), ee = S.xyz, C = H(n, x), te = H(r, x).xyz.mul(2).sub(1), w = C.w, ne = o(ee), re = R(H(i, x).xyz, q(Vr)), T = R(o(re), P(Vr)).toVar(), ie = h.equal(F(1)), ae = (e) => {
1269
+ let t = H(a, e);
1270
+ return z(t.z, R(t.z, t.w), f);
1271
+ }, oe = ie.select(ae(x), S.w.mul(S.w)).toVar(), se = d.mul(Wn(R(oe, P(0)))).div(T).add(P(1e-4)), ce = q(0).toVar(), E = P(0).toVar(), le = P(0).toVar();
1272
1272
  for (let e = 0; e < 5; e++) for (let i = 0; i < 5; i++) {
1273
- let a = i - 2, s = e - 2, d = v[e * 5 + i], f = y.add(p.mul(a)).clamp(I(0), I(g).sub(1)), m = b.add(p.mul(s)).clamp(I(0), I(_).sub(1)), h = U(t, L(f, m)), x = h.xyz, S = U(n, L(f, m)), C = U(r, L(f, m)).xyz.mul(2).sub(1), re = S.w, T = Bi(ne, o(x), te, C, w, re, ee, x, F(d), oe, l, u, c), ae = E.select(ie(L(f, m)), h.w.mul(h.w));
1274
- se.addAssign(x.mul(T)), D.addAssign(T), ce.addAssign(T.mul(T).mul(z(ae, F(0))));
1273
+ let a = i - 2, s = e - 2, d = v[e * 5 + i], f = y.add(p.mul(a)).clamp(F(0), F(g).sub(1)), m = b.add(p.mul(s)).clamp(F(0), F(_).sub(1)), h = H(t, I(f, m)), x = h.xyz, S = H(n, I(f, m)), C = H(r, I(f, m)).xyz.mul(2).sub(1), re = S.w, T = Hi(ne, o(x), te, C, w, re, ee, x, P(d), se, l, u, c), oe = ie.select(ae(I(f, m)), h.w.mul(h.w));
1274
+ ce.addAssign(x.mul(T)), E.addAssign(T), le.addAssign(T.mul(T).mul(R(oe, P(0))));
1275
1275
  }
1276
- let O = se.div(z(D, F(1e-4))), k = ce.div(z(D.mul(D), F(1e-8))), le = m.equal(I(1)), ue = le.select(O.mul(re), O), de = le.select(U(s, x).w, Vn(z(k, F(0))));
1277
- W(e, Un(G(y), G(b)), J(ue, de)).toWriteOnly();
1276
+ let D = ce.div(R(E, P(1e-4))), O = le.div(R(E.mul(E), P(1e-8))), ue = m.equal(F(1)), de = ue.select(D.mul(re), D), fe = ue.select(H(s, x).w, Wn(R(O, P(0))));
1277
+ U(e, Kn(W(y), W(b)), J(de, fe)).toWriteOnly();
1278
1278
  });
1279
1279
  })().compute([
1280
1280
  this._dispatchX,
@@ -1321,15 +1321,15 @@ var Ii = class extends E {
1321
1321
  reallocateReservedStorage() {
1322
1322
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose();
1323
1323
  let e = () => {
1324
- let e = new M(k, k);
1325
- return e.type = cr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1324
+ let e = new j(O, O);
1325
+ return e.type = ur, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1326
1326
  };
1327
1327
  this._storageTexA = e(), this._storageTexB = e(), this._buildCompute(), this._compiled = !1;
1328
1328
  }
1329
1329
  dispose() {
1330
1330
  this._computeNodeA?.dispose(), this._computeNodeB?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this._outputTarget?.dispose(), this._readTexNode?.dispose(), this._normalDepthTexNode?.dispose(), this._shadingNormalTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varianceTexNode?.dispose(), this._srcAlphaTexNode?.dispose();
1331
1331
  }
1332
- }, Hi = 6e4, Ui = (e) => H(e.equal(e), e, F(0)).clamp(0, 1e7), Wi = (e) => q(Ui(e.x), Ui(e.y), Ui(e.z)), Gi = 4, Ki = [
1332
+ }, Wi = 6e4, Gi = (e) => V(e.equal(e), e, P(0)).clamp(0, 1e7), Ki = (e) => q(Gi(e.x), Gi(e.y), Gi(e.z)), qi = 4, Ji = [
1333
1333
  1 / 256,
1334
1334
  4 / 256,
1335
1335
  6 / 256,
@@ -1355,15 +1355,15 @@ var Ii = class extends E {
1355
1355
  6 / 256,
1356
1356
  4 / 256,
1357
1357
  1 / 256
1358
- ], qi = class extends E {
1358
+ ], Yi = class extends oe {
1359
1359
  constructor(e, t = {}) {
1360
1360
  super("EdgeAwareFiltering", {
1361
1361
  ...t,
1362
- executionMode: ge.PER_CYCLE
1363
- }), this.renderer = e, this.filterStrength = K(t.filterStrength ?? 1), this.phiLuminance = K(t.phiLuminance ?? 1), this.phiNormal = K(t.phiNormal ?? 64), this.phiDepth = K(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = K(1, "int"), this.isLastIterationU = K(0, "int"), this.isFirstIterationU = K(1, "int"), this.varianceHistoryU = K(0, "int"), this.resW = K(t.width || 1), this.resH = K(t.height || 1), this._colorTexNode = new N(), this._ndTexNode = new N(), this._snTexNode = new N(), this._albedoTexNode = new N(), this._varTexNode = new N(), this._readTexNode = new N();
1362
+ executionMode: E.PER_CYCLE
1363
+ }), this.renderer = e, this.filterStrength = G(t.filterStrength ?? 1), this.phiLuminance = G(t.phiLuminance ?? 1), this.phiNormal = G(t.phiNormal ?? 64), this.phiDepth = G(t.phiDepth ?? .1), this.iterations = t.atrousIterations ?? t.edgeAtrousIterations ?? 5, this.stepSizeU = G(1, "int"), this.isLastIterationU = G(0, "int"), this.isFirstIterationU = G(1, "int"), this.varianceHistoryU = G(0, "int"), this.resW = G(t.width || 1), this.resH = G(t.height || 1), this._colorTexNode = new M(), this._ndTexNode = new M(), this._snTexNode = new M(), this._albedoTexNode = new M(), this._varTexNode = new M(), this._readTexNode = new M();
1364
1364
  let n = t.width || 1, r = t.height || 1;
1365
- this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new Qn(new jr(0, 0), new jr(0, 0)), this.outputTarget = new bn(n, r, {
1366
- type: sr,
1365
+ this._demodTex = this._makeStorageTex(), this._storageTexA = this._makeStorageTex(), this._storageTexB = this._makeStorageTex(), this._srcRegion = new er(new Nr(0, 0), new Nr(0, 0)), this.outputTarget = new Cn(n, r, {
1366
+ type: lr,
1367
1367
  format: Q,
1368
1368
  minFilter: X,
1369
1369
  magFilter: X,
@@ -1372,19 +1372,19 @@ var Ii = class extends E {
1372
1372
  }), this._compiled = !1, this._dispatchX = Math.ceil(n / 16), this._dispatchY = Math.ceil(r / 16), this._buildCompute();
1373
1373
  }
1374
1374
  _makeStorageTex() {
1375
- let e = new M(k, k);
1376
- return e.type = sr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1375
+ let e = new j(O, O);
1376
+ return e.type = lr, e.format = Q, e.minFilter = X, e.magFilter = X, e;
1377
1377
  }
1378
1378
  _buildCompute() {
1379
1379
  this._computeDemod = this._buildDemod(), this._computeAtrousA = this._buildAtrous(this._storageTexA), this._computeAtrousB = this._buildAtrous(this._storageTexB);
1380
1380
  }
1381
1381
  _buildDemod() {
1382
1382
  let e = this._colorTexNode, t = this._ndTexNode, n = this._albedoTexNode, r = this._demodTex, i = this.resW, a = this.resH;
1383
- return Sn(() => {
1384
- let o = I(Y.x).mul(16).add(I(R.x)), s = I(Y.y).mul(16).add(I(R.y));
1385
- P(o.lessThan(I(i)).and(s.lessThan(I(a))), () => {
1386
- let i = L(o, s), a = U(e, i).xyz, c = U(t, i).w.lessThan(F(Hi)), l = U(n, i).xyz, u = H(c, z(l, q(zr)), q(1)), d = Wi(a.div(u));
1387
- W(r, Un(G(o), G(s)), J(d, 1)).toWriteOnly();
1383
+ return Tn(() => {
1384
+ let o = F(Y.x).mul(16).add(F(L.x)), s = F(Y.y).mul(16).add(F(L.y));
1385
+ N(o.lessThan(F(i)).and(s.lessThan(F(a))), () => {
1386
+ let i = I(o, s), a = H(e, i).xyz, c = H(t, i).w.lessThan(P(Wi)), l = H(n, i).xyz, u = V(c, R(l, q(Vr)), q(1)), d = Ki(a.div(u));
1387
+ U(r, Kn(W(o), W(s)), J(d, 1)).toWriteOnly();
1388
1388
  });
1389
1389
  })().compute([
1390
1390
  this._dispatchX,
@@ -1398,19 +1398,19 @@ var Ii = class extends E {
1398
1398
  }
1399
1399
  _buildAtrous(e) {
1400
1400
  let t = this._readTexNode, n = this._colorTexNode, r = this._ndTexNode, i = this._snTexNode, a = this._albedoTexNode, s = this._varTexNode, c = this.filterStrength, l = this.phiLuminance, u = this.phiNormal, d = this.phiDepth, f = this.stepSizeU, p = this.isLastIterationU, m = this.isFirstIterationU, h = this.varianceHistoryU, g = this.resW, _ = this.resH;
1401
- return Sn(() => {
1402
- let v = I(Y.x).mul(16).add(I(R.x)), y = I(Y.y).mul(16).add(I(R.y));
1403
- P(v.lessThan(I(g)).and(y.lessThan(I(_))), () => {
1404
- let b = L(v, y), x = U(t, b), S = x.xyz, ee = o(S), C = U(r, b).w, te = U(i, b).xyz.mul(2).sub(1), w = C.lessThan(F(Hi)), ne = H(w, F(1), F(0)), re = U(a, b).xyz, T = H(w, z(re, q(zr)), q(1)), E = z(o(T), F(zr)), ie = m.equal(I(1)), ae = h.lessThan(I(Gi)), oe = (e) => {
1405
- let t = U(s, e);
1406
- return H(ae, z(t.z, t.w), t.z);
1407
- }, se = ie.select(oe(b), x.w.mul(x.w)).toVar(), D = l.mul(Vn(z(se, F(0)))).div(E).add(F(1e-4)), ce = q(0).toVar(), O = F(0).toVar(), k = F(0).toVar();
1401
+ return Tn(() => {
1402
+ let v = F(Y.x).mul(16).add(F(L.x)), y = F(Y.y).mul(16).add(F(L.y));
1403
+ N(v.lessThan(F(g)).and(y.lessThan(F(_))), () => {
1404
+ let b = I(v, y), x = H(t, b), S = x.xyz, ee = o(S), C = H(r, b).w, te = H(i, b).xyz.mul(2).sub(1), w = C.lessThan(P(Wi)), ne = V(w, P(1), P(0)), re = H(a, b).xyz, T = V(w, R(re, q(Vr)), q(1)), ie = R(o(T), P(Vr)), ae = m.equal(F(1)), oe = h.lessThan(F(qi)), se = (e) => {
1405
+ let t = H(s, e);
1406
+ return V(oe, R(t.z, t.w), t.z);
1407
+ }, ce = ae.select(se(b), x.w.mul(x.w)).toVar(), E = l.mul(Wn(R(ce, P(0)))).div(ie).add(P(1e-4)), le = q(0).toVar(), D = P(0).toVar(), O = P(0).toVar();
1408
1408
  for (let e = 0; e < 5; e++) for (let n = 0; n < 5; n++) {
1409
- let a = n - 2, s = e - 2, c = Ki[e * 5 + n], l = L(v.add(f.mul(a)).clamp(I(0), I(g).sub(1)), y.add(f.mul(s)).clamp(I(0), I(_).sub(1))), p = U(t, l), m = p.xyz, h = o(m), b = U(r, l).w, x = U(i, l).xyz.mul(2).sub(1), S = H(b.lessThan(F(Hi)), F(1), F(0)), w = ee.sub(h).abs().div(D).negate().exp(), re = Rn(jn(te, x).clamp(0, 1), u), T = C.sub(b).abs().div(z(C.mul(d), F(.001))).negate().exp(), E = ne.mul(S), ae = ne.oneMinus().mul(S.oneMinus()), se = E.add(ae), le = B(F(1), re.mul(T), E), ue = F(c).mul(w).mul(le).mul(se), de = ie.select(oe(l), p.w.mul(p.w));
1410
- ce.addAssign(m.mul(ue)), O.addAssign(ue), k.addAssign(ue.mul(ue).mul(z(de, F(0))));
1409
+ let a = n - 2, s = e - 2, c = Ji[e * 5 + n], l = I(v.add(f.mul(a)).clamp(F(0), F(g).sub(1)), y.add(f.mul(s)).clamp(F(0), F(_).sub(1))), p = H(t, l), m = p.xyz, h = o(m), b = H(r, l).w, x = H(i, l).xyz.mul(2).sub(1), S = V(b.lessThan(P(Wi)), P(1), P(0)), w = ee.sub(h).abs().div(E).negate().exp(), re = Vn(Pn(te, x).clamp(0, 1), u), T = C.sub(b).abs().div(R(C.mul(d), P(.001))).negate().exp(), ie = ne.mul(S), oe = ne.oneMinus().mul(S.oneMinus()), ce = ie.add(oe), ue = z(P(1), re.mul(T), ie), de = P(c).mul(w).mul(ue).mul(ce), fe = ae.select(se(l), p.w.mul(p.w));
1410
+ le.addAssign(m.mul(de)), D.addAssign(de), O.addAssign(de.mul(de).mul(R(fe, P(0))));
1411
1411
  }
1412
- let le = ce.div(z(O, F(1e-4))), ue = k.div(z(O.mul(O), F(1e-8))), de = p.equal(I(1)), A = U(n, b).xyz, fe = B(A, le.mul(T), c), pe = de.select(fe, le), me = de.select(U(n, b).w, Vn(z(ue, F(0))));
1413
- W(e, Un(G(v), G(y)), J(pe, me)).toWriteOnly();
1412
+ let ue = le.div(R(D, P(1e-4))), de = O.div(R(D.mul(D), P(1e-8))), fe = p.equal(F(1)), k = H(n, b).xyz, pe = z(k, ue.mul(T), c), me = fe.select(pe, ue), he = fe.select(H(n, b).w, Wn(R(de, P(0))));
1413
+ U(e, Kn(W(v), W(y)), J(me, he)).toWriteOnly();
1414
1414
  });
1415
1415
  })().compute([
1416
1416
  this._dispatchX,
@@ -1468,45 +1468,45 @@ var Ii = class extends E {
1468
1468
  dispose() {
1469
1469
  this._computeDemod?.dispose(), this._computeAtrousA?.dispose(), this._computeAtrousB?.dispose(), this._demodTex?.dispose(), this._storageTexA?.dispose(), this._storageTexB?.dispose(), this.outputTarget?.dispose(), this._colorTexNode?.dispose(), this._ndTexNode?.dispose(), this._snTexNode?.dispose(), this._albedoTexNode?.dispose(), this._varTexNode?.dispose(), this._readTexNode?.dispose();
1470
1470
  }
1471
- }, Ji = {
1471
+ }, Xi = {
1472
1472
  autoExposure: !1,
1473
1473
  autoExposureKeyValue: .18,
1474
1474
  autoExposureMinExposure: .1,
1475
1475
  autoExposureMaxExposure: 20,
1476
1476
  autoExposureAdaptSpeedBright: 3,
1477
1477
  autoExposureAdaptSpeedDark: .5
1478
- }, Yi = 256, Xi = -8, Zi = 6 - Xi, Qi = Zi / Yi, $i = 1e4, ea = /* @__PURE__ */ Kn("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), ta = class extends E {
1478
+ }, Zi = 256, Qi = -8, $i = 6 - Qi, ea = $i / Zi, ta = 1e4, na = /* @__PURE__ */ Jn("\n fn adaptExposure(\n geoMean: f32,\n prevExposure: f32,\n keyValue: f32,\n minExp: f32,\n maxExp: f32,\n speedBright: f32,\n speedDark: f32,\n dt: f32,\n isFirstFrame: f32\n ) -> vec4f {\n\n let targetExp = clamp( keyValue / max( geoMean, 0.001 ), minExp, maxExp );\n var newExposure = targetExp;\n\n // Temporal smoothing (skip on first frame)\n if ( isFirstFrame < 0.5 ) {\n\n // Asymmetric speed: brighter scenes adapt faster\n let speed = select( speedDark, speedBright, targetExp < prevExposure );\n let alpha = 1.0 - exp( -dt * speed );\n newExposure = mix( prevExposure, targetExp, alpha );\n\n }\n\n return vec4f( newExposure, geoMean, targetExp, 1.0 );\n\n }\n"), ra = class extends oe {
1479
1479
  constructor(e, t = {}) {
1480
1480
  super("AutoExposure", {
1481
1481
  ...t,
1482
- executionMode: ge.ALWAYS
1483
- }), this.renderer = e, this.REDUCTION_SIZE = 64, this.keyValueU = K(t.keyValue ?? Ji.autoExposureKeyValue), this.minExposureU = K(t.minExposure ?? Ji.autoExposureMinExposure), this.maxExposureU = K(t.maxExposure ?? Ji.autoExposureMaxExposure), this.adaptSpeedBrightU = K(t.adaptSpeedBright ?? Ji.autoExposureAdaptSpeedBright), this.adaptSpeedDarkU = K(t.adaptSpeedDark ?? Ji.autoExposureAdaptSpeedDark), this.epsilonU = K(t.epsilon ?? 1e-4), this.deltaTimeU = K(1 / 60), this.isFirstFrameU = K(1), this.previousExposureU = K(t.initialExposure ?? 1), this.lowPercentileU = K(t.lowPercentile ?? .1), this.highPercentileU = K(t.highPercentile ?? .9), this.centerWeightU = K(t.centerWeight ?? 8), this.inputResW = K(1), this.inputResH = K(1), this._inputTexNode = new N(), this._reductionReadTexNode = new N(), this.currentExposure = t.initialExposure ?? 1, this.currentLuminance = .18, this.targetExposure = 1, this.lastTime = performance.now(), this.isFirstFrame = !0, this._pendingReadback = !1, this._readbackGeneration = 0, this._initRenderTargets(), this._buildCompute();
1482
+ executionMode: E.ALWAYS
1483
+ }), this.renderer = e, this.REDUCTION_SIZE = 64, this.keyValueU = G(t.keyValue ?? Xi.autoExposureKeyValue), this.minExposureU = G(t.minExposure ?? Xi.autoExposureMinExposure), this.maxExposureU = G(t.maxExposure ?? Xi.autoExposureMaxExposure), this.adaptSpeedBrightU = G(t.adaptSpeedBright ?? Xi.autoExposureAdaptSpeedBright), this.adaptSpeedDarkU = G(t.adaptSpeedDark ?? Xi.autoExposureAdaptSpeedDark), this.epsilonU = G(t.epsilon ?? 1e-4), this.deltaTimeU = G(1 / 60), this.isFirstFrameU = G(1), this.previousExposureU = G(t.initialExposure ?? 1), this.lowPercentileU = G(t.lowPercentile ?? .1), this.highPercentileU = G(t.highPercentile ?? .9), this.centerWeightU = G(t.centerWeight ?? 8), this.inputResW = G(1), this.inputResH = G(1), this._inputTexNode = new M(), this._reductionReadTexNode = new M(), this.currentExposure = t.initialExposure ?? 1, this.currentLuminance = .18, this.targetExposure = 1, this.lastTime = performance.now(), this.isFirstFrame = !0, this._pendingReadback = !1, this._readbackGeneration = 0, this._initRenderTargets(), this._buildCompute();
1484
1484
  }
1485
1485
  _initRenderTargets() {
1486
1486
  let e = {
1487
- type: sr,
1487
+ type: lr,
1488
1488
  format: Q,
1489
1489
  minFilter: Z,
1490
1490
  magFilter: Z,
1491
1491
  depthBuffer: !1,
1492
1492
  stencilBuffer: !1
1493
1493
  };
1494
- this._downsampleTarget = new bn(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new M(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = sr, this._downsampleStorageTex.format = Q, this._downsampleStorageTex.minFilter = Z, this._downsampleStorageTex.magFilter = Z, this._reductionStorageTex = new M(1, 1), this._reductionStorageTex.type = sr, this._reductionStorageTex.format = Q, this._reductionStorageTex.minFilter = Z, this._reductionStorageTex.magFilter = Z, this._reductionReadTarget = new bn(1, 1, e), this._adaptationResult = An(1, "vec4"), this._readbackBuffer = new yn(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = An(Yi, "uint").toAtomic();
1494
+ this._downsampleTarget = new Cn(this.REDUCTION_SIZE, this.REDUCTION_SIZE, e), this._downsampleStorageTex = new j(this.REDUCTION_SIZE, this.REDUCTION_SIZE), this._downsampleStorageTex.type = lr, this._downsampleStorageTex.format = Q, this._downsampleStorageTex.minFilter = Z, this._downsampleStorageTex.magFilter = Z, this._reductionStorageTex = new j(1, 1), this._reductionStorageTex.type = lr, this._reductionStorageTex.format = Q, this._reductionStorageTex.minFilter = Z, this._reductionStorageTex.magFilter = Z, this._reductionReadTarget = new Cn(1, 1, e), this._adaptationResult = Nn(1, "vec4"), this._readbackBuffer = new Sn(16), this._readbackBuffer.name = "AutoExposureAdaptation", this._histogramBuffer = Nn(Zi, "uint").toAtomic();
1495
1495
  }
1496
1496
  _buildCompute() {
1497
1497
  this._buildDownsampleCompute(), this._buildHistogramCompute(), this._buildHistogramAnalyzeCompute(), this._buildAdaptationCompute();
1498
1498
  }
1499
1499
  _buildDownsampleCompute() {
1500
1500
  let e = this._inputTexNode, t = this._downsampleStorageTex, n = this.epsilonU, r = this.inputResW, i = this.inputResH;
1501
- this._downsampleComputeNode = Sn(() => {
1502
- let a = I(Y.x).mul(8).add(I(R.x)), s = I(Y.y).mul(8).add(I(R.y)), c = r.div(F(64)), l = i.div(F(64)), u = F(a).mul(c), d = F(s).mul(l), f = F(0).toVar(), p = F(0).toVar();
1501
+ this._downsampleComputeNode = Tn(() => {
1502
+ let a = F(Y.x).mul(8).add(F(L.x)), s = F(Y.y).mul(8).add(F(L.y)), c = r.div(P(64)), l = i.div(P(64)), u = P(a).mul(c), d = P(s).mul(l), f = P(0).toVar(), p = P(0).toVar();
1503
1503
  for (let t = 0; t < 4; t++) for (let r = 0; r < 4; r++) {
1504
- let i = o(U(e, L(I(u.add(F((r + .5) / 4).mul(c))), I(d.add(F((t + .5) / 4).mul(l))))).xyz);
1505
- P(i.greaterThan(n), () => {
1504
+ let i = o(H(e, I(F(u.add(P((r + .5) / 4).mul(c))), F(d.add(P((t + .5) / 4).mul(l))))).xyz);
1505
+ N(i.greaterThan(n), () => {
1506
1506
  f.addAssign(i.add(n).log()), p.addAssign(1);
1507
1507
  });
1508
1508
  }
1509
- W(t, Un(G(a), G(s)), J(f, p, 0, 1)).toWriteOnly();
1509
+ U(t, Kn(W(a), W(s)), J(f, p, 0, 1)).toWriteOnly();
1510
1510
  })().compute([
1511
1511
  64 / 8,
1512
1512
  64 / 8,
@@ -1519,14 +1519,14 @@ var Ii = class extends E {
1519
1519
  }
1520
1520
  _buildHistogramCompute() {
1521
1521
  let e = this._downsampleTarget.texture, t = this._histogramBuffer, n = this.centerWeightU;
1522
- this._histogramComputeNode = Sn(() => {
1523
- let r = R.x;
1524
- kn(t.element(r), G(0)), Jn();
1522
+ this._histogramComputeNode = Tn(() => {
1523
+ let r = L.x;
1524
+ Mn(t.element(r), W(0)), Xn();
1525
1525
  for (let i = 0; i < 16; i++) {
1526
- let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = U(e, L(I(o), I(s))), l = c.x, u = c.y;
1527
- P(u.greaterThan(0), () => {
1528
- let e = G(l.div(u).sub(F(Xi)).div(F(Zi)).mul(F(Yi)).floor().clamp(0, F(Yi - 1))), r = F(o).add(.5).div(F(64)), i = F(s).add(.5).div(F(64)), a = r.sub(.5), c = i.sub(.5), d = G(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(F($i)));
1529
- Dn(t.element(e), d);
1526
+ let a = r.mul(16).add(i), o = a.mod(64), s = a.div(64), c = H(e, I(F(o), F(s))), l = c.x, u = c.y;
1527
+ N(u.greaterThan(0), () => {
1528
+ let e = W(l.div(u).sub(P(Qi)).div(P($i)).mul(P(Zi)).floor().clamp(0, P(Zi - 1))), r = P(o).add(.5).div(P(64)), i = P(s).add(.5).div(P(64)), a = r.sub(.5), c = i.sub(.5), d = W(a.mul(a).add(c.mul(c)).mul(n).negate().exp().mul(P(ta)));
1529
+ An(t.element(e), d);
1530
1530
  });
1531
1531
  }
1532
1532
  })().compute([
@@ -1541,21 +1541,21 @@ var Ii = class extends E {
1541
1541
  }
1542
1542
  _buildHistogramAnalyzeCompute() {
1543
1543
  let e = this._histogramBuffer, t = this._reductionStorageTex, n = this.lowPercentileU, r = this.highPercentileU;
1544
- this._histogramAnalyzeNode = Sn(() => {
1545
- let i = F(0).toVar();
1546
- Cn(Yi, ({ i: t }) => {
1547
- i.addAssign(F(On(e.element(t))));
1544
+ this._histogramAnalyzeNode = Tn(() => {
1545
+ let i = P(0).toVar();
1546
+ En(Zi, ({ i: t }) => {
1547
+ i.addAssign(P(jn(e.element(t))));
1548
1548
  });
1549
- let a = i.mul(n), o = i.mul(r), s = F(0).toVar(), c = F(0).toVar(), l = F(0).toVar(), u = F(0).toVar();
1550
- Cn(Yi, ({ i: t }) => {
1551
- let n = F(On(e.element(t)));
1552
- u.assign(s), s.addAssign(n), P(u.lessThan(o).and(s.greaterThan(a)), () => {
1553
- let e = F(Xi).add(F(t).add(.5).mul(F(Qi)));
1549
+ let a = i.mul(n), o = i.mul(r), s = P(0).toVar(), c = P(0).toVar(), l = P(0).toVar(), u = P(0).toVar();
1550
+ En(Zi, ({ i: t }) => {
1551
+ let n = P(jn(e.element(t)));
1552
+ u.assign(s), s.addAssign(n), N(u.lessThan(o).and(s.greaterThan(a)), () => {
1553
+ let e = P(Qi).add(P(t).add(.5).mul(P(ea)));
1554
1554
  c.addAssign(e.mul(n)), l.addAssign(n);
1555
1555
  });
1556
1556
  });
1557
- let d = z(l, F(1)), f = c.div(d), p = f.exp();
1558
- W(t, Un(G(0), G(0)), J(p, i, f, 1)).toWriteOnly();
1557
+ let d = R(l, P(1)), f = c.div(d), p = f.exp();
1558
+ U(t, Kn(W(0), W(0)), J(p, i, f, 1)).toWriteOnly();
1559
1559
  })().compute(1, [
1560
1560
  1,
1561
1561
  1,
@@ -1564,9 +1564,9 @@ var Ii = class extends E {
1564
1564
  }
1565
1565
  _buildAdaptationCompute() {
1566
1566
  let e = this._reductionReadTexNode, t = this._adaptationResult, n = this.keyValueU, r = this.minExposureU, i = this.maxExposureU, a = this.adaptSpeedBrightU, o = this.adaptSpeedDarkU, s = this.deltaTimeU, c = this.isFirstFrameU, l = this.previousExposureU;
1567
- this._adaptationComputeNode = Sn(() => {
1568
- let u = U(e, L(I(0), I(0))).x, d = ea(u, l, n, r, i, a, o, s, c);
1569
- t.element(G(0)).assign(d);
1567
+ this._adaptationComputeNode = Tn(() => {
1568
+ let u = H(e, I(F(0), F(0))).x, d = na(u, l, n, r, i, a, o, s, c);
1569
+ t.element(W(0)).assign(d);
1570
1570
  })().compute(1, [
1571
1571
  1,
1572
1572
  1,
@@ -1627,16 +1627,16 @@ var Ii = class extends E {
1627
1627
  dispose() {
1628
1628
  this._downsampleComputeNode?.dispose(), this._histogramComputeNode?.dispose(), this._histogramAnalyzeNode?.dispose(), this._adaptationComputeNode?.dispose(), this._downsampleTarget?.dispose(), this._downsampleStorageTex?.dispose(), this._reductionStorageTex?.dispose(), this._reductionReadTarget?.dispose(), this._readbackBuffer?.dispose(), this._inputTexNode?.dispose(), this._reductionReadTexNode?.dispose();
1629
1629
  }
1630
- }, na = new $(), ra = new $();
1631
- function ia(e, t) {
1632
- return ra.subVectors(e, t.position).dot(t.getWorldDirection(na));
1630
+ }, ia = new $(), aa = new $();
1631
+ function oa(e, t) {
1632
+ return aa.subVectors(e, t.position).dot(t.getWorldDirection(ia));
1633
1633
  }
1634
- function aa(e, t, n = !1) {
1635
- return n ? e.distance : ia(e.point, t);
1634
+ function sa(e, t, n = !1) {
1635
+ return n ? e.distance : oa(e.point, t);
1636
1636
  }
1637
- var oa = class extends or {
1637
+ var ca = class extends cr {
1638
1638
  constructor({ scene: e, camera: t, canvas: n, assetLoader: r, pathTracer: i, floorPlane: a }) {
1639
- super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Cr(), 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;
1639
+ super(), this.scene = e, this.camera = t, this.canvas = n, this.assetLoader = r, this.pathTracer = i, this.floorPlane = a, this.raycaster = new Tr(), 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;
1640
1640
  }
1641
1641
  setDependencies({ overlayManager: e, transformManager: t, appDispatch: n, orbitControls: r, helperScene: i }) {
1642
1642
  this._overlayManager = e || null, this._transformManager = t || null, this._appDispatch = n || null, this._orbitControls = r || null, this._helperScene = i || null;
@@ -1644,7 +1644,7 @@ var oa = class extends or {
1644
1644
  select(e) {
1645
1645
  let t = this._overlayManager?.getHelper("outline");
1646
1646
  t && t.setSelectedObjects(e ? [e] : []), this.selectedObject = e || null, e ? this._transformManager?.attach(e) : this._transformManager?.detach(), this._appDispatch?.({
1647
- type: j.OBJECT_SELECTED,
1647
+ type: A.OBJECT_SELECTED,
1648
1648
  object: e || null
1649
1649
  });
1650
1650
  }
@@ -1668,7 +1668,7 @@ var oa = class extends or {
1668
1668
  this.raycaster.setFromCamera(t, this.camera);
1669
1669
  let n = this.raycaster.intersectObjects(this.scene.children, !0);
1670
1670
  if (n.length > 0) {
1671
- let e = n[0], t = this.pathTracer?.cameraProjection?.value === he.equirectangular, r = aa(e, this.camera, t);
1671
+ let e = n[0], t = this.pathTracer?.cameraProjection?.value === Ae.equirectangular, r = sa(e, this.camera, t);
1672
1672
  this.showFocusPoint(e.point), this.toggleFocusMode(), this.dispatchEvent({
1673
1673
  type: "focusChanged",
1674
1674
  distance: r / this.assetLoader.getSceneScale(),
@@ -1677,7 +1677,7 @@ var oa = class extends or {
1677
1677
  }
1678
1678
  }
1679
1679
  showFocusPoint(e) {
1680
- this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new mr(new Dr(this.assetLoader.getSceneScale() * .02, 16, 16), new hr({
1680
+ this.focusPointIndicator && this.scene.remove(this.focusPointIndicator), this.focusPointIndicator = new gr(new kr(this.assetLoader.getSceneScale() * .02, 16, 16), new _r({
1681
1681
  color: 65280,
1682
1682
  transparent: !0,
1683
1683
  opacity: .8,
@@ -1840,35 +1840,35 @@ var oa = class extends or {
1840
1840
  wireAppEvents(e) {
1841
1841
  this.addEventListener("objectSelected", (t) => {
1842
1842
  this.select(t.object), e.refreshFrame(), e.dispatchEvent({
1843
- type: j.OBJECT_SELECTED,
1843
+ type: A.OBJECT_SELECTED,
1844
1844
  object: t.object,
1845
1845
  uuid: t.uuid
1846
1846
  });
1847
1847
  }), this.addEventListener("objectDeselected", (t) => {
1848
1848
  this.select(null), e.refreshFrame(), e.dispatchEvent({
1849
- type: j.OBJECT_DESELECTED,
1849
+ type: A.OBJECT_DESELECTED,
1850
1850
  object: t.object,
1851
1851
  uuid: t.uuid
1852
1852
  });
1853
1853
  }), this.addEventListener("selectModeChanged", (t) => {
1854
1854
  e.dispatchEvent({
1855
- type: j.SELECT_MODE_CHANGED,
1855
+ type: A.SELECT_MODE_CHANGED,
1856
1856
  enabled: t.enabled
1857
1857
  });
1858
1858
  }), this.addEventListener("objectDoubleClicked", (t) => {
1859
1859
  this.select(t.object), e.refreshFrame(), e.dispatchEvent({
1860
- type: j.OBJECT_DOUBLE_CLICKED,
1860
+ type: A.OBJECT_DOUBLE_CLICKED,
1861
1861
  object: t.object,
1862
1862
  uuid: t.uuid
1863
1863
  });
1864
1864
  }), this.addEventListener("focusChanged", (t) => {
1865
1865
  e.settings.set("focusDistance", t.worldDistance), e.dispatchEvent({
1866
- type: j.FOCUS_CHANGED,
1866
+ type: A.FOCUS_CHANGED,
1867
1867
  distance: t.distance
1868
1868
  });
1869
1869
  }), this.addEventListener("afPointPlaced", (t) => {
1870
1870
  e.dispatchEvent({
1871
- type: j.AF_POINT_PLACED,
1871
+ type: A.AF_POINT_PLACED,
1872
1872
  point: t.point
1873
1873
  });
1874
1874
  });
@@ -1876,7 +1876,7 @@ var oa = class extends or {
1876
1876
  dispose() {
1877
1877
  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;
1878
1878
  }
1879
- }, sa = 8, ca = 4, la = .25, ua = fr.degToRad(89), da = .25, fa = {
1879
+ }, la = 8, ua = 4, da = .25, fa = mr.degToRad(89), pa = .25, ma = {
1880
1880
  KeyD: [
1881
1881
  1,
1882
1882
  0,
@@ -1927,15 +1927,15 @@ var oa = class extends or {
1927
1927
  0,
1928
1928
  -1
1929
1929
  ]
1930
- }, pa = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", ma = (e) => e.shiftKey ? ca : e.altKey ? la : 1, ha = { type: "change" }, ga = { type: "start" }, _a = new $(), va = new $(), ya = new $(), ba = new $(), xa = new Sr(), Sa = class extends nr {
1930
+ }, ha = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"]), [role=textbox], [role=combobox], [role=listbox], [role=menu], [role=menuitem]", ga = (e) => e.shiftKey ? ua : e.altKey ? da : 1, _a = { type: "change" }, va = { type: "start" }, ya = new $(), ba = new $(), xa = new $(), Sa = new $(), Ca = new wr(), wa = class extends ir {
1931
1931
  constructor(e, t, n) {
1932
- super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / sa, 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);
1932
+ super(e, t), this.orbit = n, this.enabled = !1, this.speed = 1 / la, 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);
1933
1933
  }
1934
1934
  get active() {
1935
1935
  return this.enabled && this.orbit.enabled;
1936
1936
  }
1937
1937
  fitSpeed(e) {
1938
- this.speed = (e > 0 ? e : 1) / sa;
1938
+ this.speed = (e > 0 ? e : 1) / la;
1939
1939
  }
1940
1940
  connect(e) {
1941
1941
  super.connect(e);
@@ -1955,34 +1955,34 @@ var oa = class extends or {
1955
1955
  if (!this._held.size || !this.active) return !1;
1956
1956
  let t = 0, n = 0, r = 0;
1957
1957
  for (let e of this._held) {
1958
- let [i, a, o] = fa[e];
1958
+ let [i, a, o] = ma[e];
1959
1959
  t += i, n += a, r += o;
1960
1960
  }
1961
1961
  if (!t && !n && !r) return !1;
1962
1962
  let i = this.object;
1963
- return va.set(1, 0, 0).applyQuaternion(i.quaternion), _a.crossVectors(i.up, va).normalize(), va.crossVectors(_a, i.up), ya.set(0, 0, 0).addScaledVector(va, t).addScaledVector(_a, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(ya), this.orbit.target.add(ya), i.updateMatrixWorld(), this.dispatchEvent(ha), !0;
1963
+ return ba.set(1, 0, 0).applyQuaternion(i.quaternion), ya.crossVectors(i.up, ba).normalize(), ba.crossVectors(ya, i.up), xa.set(0, 0, 0).addScaledVector(ba, t).addScaledVector(ya, n).addScaledVector(i.up, r).normalize().multiplyScalar(this.speed * this._factor * e), i.position.add(xa), this.orbit.target.add(xa), i.updateMatrixWorld(), this.dispatchEvent(_a), !0;
1964
1964
  }
1965
1965
  _elapsed() {
1966
- let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, da);
1966
+ let e = performance.now(), t = Math.min((e - this._lastTime) / 1e3, pa);
1967
1967
  return this._lastTime = e, t;
1968
1968
  }
1969
1969
  _look(e, t) {
1970
- let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = fr.degToRad(n.fov) / (this.domElement.clientHeight || 1);
1971
- n.quaternion.premultiply(xa.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(_a);
1972
- let o = Math.asin(fr.clamp(_a.dot(n.up), -1, 1)), s = fr.clamp(o + t * a, -ua, ua);
1973
- n.quaternion.multiply(xa.setFromAxisAngle(ba.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(_a), i), this.dispatchEvent(ha);
1970
+ let n = this.object, r = this.orbit.target, i = n.position.distanceTo(r) || 1, a = mr.degToRad(n.fov) / (this.domElement.clientHeight || 1);
1971
+ n.quaternion.premultiply(Ca.setFromAxisAngle(n.up, e * a)), n.getWorldDirection(ya);
1972
+ let o = Math.asin(mr.clamp(ya.dot(n.up), -1, 1)), s = mr.clamp(o + t * a, -fa, fa);
1973
+ n.quaternion.multiply(Ca.setFromAxisAngle(Sa.set(1, 0, 0), s - o)), n.updateMatrixWorld(), r.copy(n.position).addScaledVector(n.getWorldDirection(ya), i), this.dispatchEvent(_a);
1974
1974
  }
1975
1975
  _onKeyDown(e) {
1976
- if (!(!this.active || e.defaultPrevented || e.target?.closest?.(pa))) {
1976
+ if (!(!this.active || e.defaultPrevented || e.target?.closest?.(ha))) {
1977
1977
  if (e.metaKey || e.ctrlKey) {
1978
1978
  this.release();
1979
1979
  return;
1980
1980
  }
1981
- this._factor = ma(e), fa[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(ga))));
1981
+ this._factor = ga(e), ma[e.code] && (e.preventDefault(), !this._held.has(e.code) && (this._held.add(e.code), this._held.size === 1 && (this._lastTime = performance.now(), this.dispatchEvent(va))));
1982
1982
  }
1983
1983
  }
1984
1984
  _onKeyUp(e) {
1985
- this._factor = ma(e), this._held.delete(e.code);
1985
+ this._factor = ga(e), this._held.delete(e.code);
1986
1986
  }
1987
1987
  release() {
1988
1988
  this._held.clear(), this._factor = 1;
@@ -2003,24 +2003,24 @@ var oa = class extends or {
2003
2003
  _onPointerUp(e) {
2004
2004
  this._drag?.id === e.pointerId && (this._drag = null, this.domElement.releasePointerCapture?.(e.pointerId));
2005
2005
  }
2006
- }, Ca = {
2006
+ }, Ta = {
2007
2007
  autoFocusMode: "auto",
2008
2008
  afScreenPoint: {
2009
2009
  x: .5,
2010
2010
  y: .5
2011
2011
  },
2012
2012
  afSmoothingFactor: .15
2013
- }, wa = .05, Ta = 10, Ea = .5, Da = Object.freeze(new $(1, 1, 1)), Oa = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, ka = class extends or {
2013
+ }, Ea = .05, Da = 10, Oa = .5, ka = Object.freeze(new $(1, 1, 1)), Aa = (e) => e?.isOrthographicCamera ? (e.top - e.bottom) / e.zoom : null, ja = class extends cr {
2014
2014
  constructor(e) {
2015
2015
  super();
2016
2016
  let t = e.clientWidth, n = e.clientHeight;
2017
- this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Pr(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 Sa(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = Ca.autoFocusMode, this.afScreenPoint = { ...Ca.afScreenPoint }, this.afSmoothingFactor = Ca.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;
2017
+ this.camera = new _(60, t / n || 1, .01, 1e3), this.camera.position.set(0, 0, 5), this.controls = new Ir(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 wa(this.camera, e, this.controls), this.interactionManager = null, this.cameras = [this.camera], this.currentCameraIndex = 0, this._userCameraCounter = 0, this.autoFocusMode = Ta.autoFocusMode, this.afScreenPoint = { ...Ta.afScreenPoint }, this.afSmoothingFactor = Ta.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;
2018
2018
  }
2019
2019
  setCameras(e) {
2020
2020
  this.cameras = e, this._userCameraCounter = 0, this.resetAutoFocus();
2021
2021
  }
2022
2022
  addCameraFromView(e) {
2023
- let t = this.camera, n = t.orthographic ? new yr(t.left, t.right, t.top, t.bottom, t.near, t.far) : new br(t.fov, t.aspect, t.near, t.far);
2023
+ let t = this.camera, n = t.orthographic ? new xr(t.left, t.right, t.top, t.bottom, t.near, t.far) : new Sr(t.fov, t.aspect, t.near, t.far);
2024
2024
  return n.zoom = t.zoom, n.position.copy(t.position), n.quaternion.copy(t.quaternion), n.scale.copy(t.scale), n.updateMatrixWorld(!0), n.userData.__rayzeeUserCamera = !0, n.userData.__rayzeeEffects = this._captureEffects(), this.controls && (n.userData.__rayzeeOrbitTarget = this.controls.target.clone()), this._userCameraCounter += 1, n.name = e || `View Camera ${this._userCameraCounter}`, this.cameras.push(n), this.cameras.length - 1;
2025
2025
  }
2026
2026
  removeCamera(e) {
@@ -2074,12 +2074,12 @@ var oa = class extends or {
2074
2074
  target: this.controls ? this.controls.target.clone() : null
2075
2075
  }), this.currentCameraIndex = e, e === 0 && this._defaultCameraState) {
2076
2076
  let e = this._defaultCameraState;
2077
- this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ?? Da), this.camera.fov = e.fov, this.camera.near = e.near, this.camera.far = e.far, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls && e.target && (this.controls.target.copy(e.target), this.controls.update());
2077
+ this.camera.position.copy(e.position), this.camera.quaternion.copy(e.quaternion), this.camera.scale.copy(e.scale ?? ka), this.camera.fov = e.fov, this.camera.near = e.near, this.camera.far = e.far, this.camera.updateProjectionMatrix(), this.camera.updateMatrixWorld(!0), this.controls && e.target && (this.controls.target.copy(e.target), this.controls.update());
2078
2078
  } else this._placeAt(this.cameras[e], t);
2079
2079
  this.resetAutoFocus();
2080
2080
  let a = this.cameras[e], o = a?.userData?.__rayzeeEffects;
2081
- this._showOrthographic(o ? o.orthoHeight : Oa(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
2082
- type: j.CAMERA_SWITCHED,
2081
+ this._showOrthographic(o ? o.orthoHeight : Aa(a)), this._applyEffects(o), n?.(), r?.(), this.dispatchEvent({
2082
+ type: A.CAMERA_SWITCHED,
2083
2083
  cameraIndex: e,
2084
2084
  effects: this._captureEffects(),
2085
2085
  fov: this.camera.fov,
@@ -2093,7 +2093,7 @@ var oa = class extends or {
2093
2093
  return;
2094
2094
  }
2095
2095
  this._placeAt(e, this._getSettings?.("focusDistance"));
2096
- let t = Oa(e);
2096
+ let t = Aa(e);
2097
2097
  this.camera.orthographic && this._setView(!0, t ? t / 2 : this.camera.orthoHalfHeight), this._onReset?.();
2098
2098
  }
2099
2099
  _placeAt(e, t) {
@@ -2116,14 +2116,14 @@ var oa = class extends or {
2116
2116
  if (t.orthographic !== n) {
2117
2117
  if (n) this._setView(!0, this._fittedHalfHeight());
2118
2118
  else {
2119
- let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(fr.degToRad(t.fov) / 2);
2119
+ let e = this.controls.target, n = this.orthoHeight / 2 / Math.tan(mr.degToRad(t.fov) / 2);
2120
2120
  t.position.sub(e).setLength(n).add(e), this._setView(!1);
2121
2121
  }
2122
2122
  this.controls.update();
2123
2123
  }
2124
2124
  }
2125
2125
  get orthoHeight() {
2126
- return Oa(this.camera);
2126
+ return Aa(this.camera);
2127
2127
  }
2128
2128
  setOrthoHeight(e) {
2129
2129
  e > 0 && (this._setView(this.camera.orthographic, e / 2), this._onReset?.());
@@ -2136,13 +2136,13 @@ var oa = class extends or {
2136
2136
  n.orthographic = e, n.orthoHalfHeight = t, n.zoom = 1, n.updateProjectionMatrix(), this._reportOrthoHeight();
2137
2137
  }
2138
2138
  _fittedHalfHeight() {
2139
- return this.camera.position.distanceTo(this.controls.target) * Math.tan(fr.degToRad(this.camera.fov) / 2);
2139
+ return this.camera.position.distanceTo(this.controls.target) * Math.tan(mr.degToRad(this.camera.fov) / 2);
2140
2140
  }
2141
2141
  _reportOrthoHeight() {
2142
2142
  if (!this.camera.orthographic) return;
2143
2143
  let e = this.orthoHeight;
2144
2144
  e !== this._reportedOrthoHeight && (this._reportedOrthoHeight = e, this.dispatchEvent({
2145
- type: j.ORTHO_HEIGHT_UPDATED,
2145
+ type: A.ORTHO_HEIGHT_UPDATED,
2146
2146
  height: e
2147
2147
  }));
2148
2148
  }
@@ -2157,7 +2157,7 @@ var oa = class extends or {
2157
2157
  this.walkControls.release();
2158
2158
  let r = this.interactionManager?.pickSurface(0, 0);
2159
2159
  if (!r) return;
2160
- let i = fr.clamp(r.distance, n.minDistance, n.maxDistance);
2160
+ let i = mr.clamp(r.distance, n.minDistance, n.maxDistance);
2161
2161
  n.target.copy(this.camera.position).addScaledVector(this.camera.getWorldDirection(new $()), i), n.update();
2162
2162
  }
2163
2163
  get navigationMode() {
@@ -2213,7 +2213,7 @@ var oa = class extends or {
2213
2213
  let n = {
2214
2214
  index: t,
2215
2215
  name: e.name ?? "",
2216
- effects: je(e.userData?.__rayzeeEffects) ?? null
2216
+ effects: _e(e.userData?.__rayzeeEffects) ?? null
2217
2217
  };
2218
2218
  return t === 0 || !e.userData?.__rayzeeUserCamera ? n : {
2219
2219
  ...n,
@@ -2245,8 +2245,8 @@ var oa = class extends or {
2245
2245
  let n = /* @__PURE__ */ new Map();
2246
2246
  for (let r of e.cameras ?? []) {
2247
2247
  if (r.user) {
2248
- let e = r.orthographic ? new yr(...r.frustum, r.near, r.far) : new br(r.fov, r.aspect, r.near, r.far);
2249
- 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 = ye(r.effects), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new $().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2248
+ let e = r.orthographic ? new xr(...r.frustum, r.near, r.far) : new Sr(r.fov, r.aspect, r.near, r.far);
2249
+ 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 = xe(r.effects), r.orbitTarget && (e.userData.__rayzeeOrbitTarget = new $().fromArray(r.orbitTarget)), n.set(r.index, this.cameras.length), this.cameras.push(e);
2250
2250
  continue;
2251
2251
  }
2252
2252
  let e = this.cameras[r.index];
@@ -2254,13 +2254,13 @@ var oa = class extends or {
2254
2254
  t.push(r.name);
2255
2255
  continue;
2256
2256
  }
2257
- n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = ye(r.effects));
2257
+ n.set(r.index, r.index), r.effects && (e.userData.__rayzeeEffects = xe(r.effects));
2258
2258
  }
2259
2259
  this._userCameraCounter = this.cameras.filter((e) => e.userData?.__rayzeeUserCamera).length, this.currentCameraIndex = n.get(e.current) ?? 0;
2260
2260
  let r = e.defaultView;
2261
2261
  this._defaultCameraState = r ? {
2262
2262
  position: new $().fromArray(r.position),
2263
- quaternion: new Sr().fromArray(r.quaternion),
2263
+ quaternion: new wr().fromArray(r.quaternion),
2264
2264
  scale: new $().fromArray(r.scale),
2265
2265
  fov: r.fov,
2266
2266
  near: r.near,
@@ -2273,7 +2273,7 @@ var oa = class extends or {
2273
2273
  e.position.fromArray(i.position), e.quaternion.fromArray(i.quaternion), e.scale.fromArray(i.scale), e.fov = i.fov, e.near = i.near, e.far = i.far, this._setView(i.orthographic, i.orthoHalfHeight), e.zoom = i.zoom ?? 1, e.updateProjectionMatrix(), e.updateMatrixWorld(!0), this.controls.target.fromArray(i.target), this.controls.update();
2274
2274
  }
2275
2275
  return e.autoFocus && (this.setAutoFocusMode(e.autoFocus.mode), this.setAFScreenPoint(e.autoFocus.point.x, e.autoFocus.point.y)), this.resetAutoFocus(), this._reportOrthoHeight(), this.dispatchEvent({
2276
- type: j.CAMERA_SWITCHED,
2276
+ type: A.CAMERA_SWITCHED,
2277
2277
  cameraIndex: this.currentCameraIndex,
2278
2278
  effects: this._captureEffects(),
2279
2279
  fov: this.camera.fov,
@@ -2309,7 +2309,7 @@ var oa = class extends or {
2309
2309
  if (!t || !this.interactionManager) return;
2310
2310
  let { assetLoader: n, currentFocusDistance: r, pathTracer: i, setFocusDistance: a, softReset: o, hardReset: s } = t;
2311
2311
  if (this.autoFocusMode === "manual") return;
2312
- if (!i?.enableDOF?.value || i.cameraProjection?.value === he.equirectangular) {
2312
+ if (!i?.enableDOF?.value || i.cameraProjection?.value === Ae.equirectangular) {
2313
2313
  this._afSuspended = !0;
2314
2314
  return;
2315
2315
  }
@@ -2317,25 +2317,25 @@ var oa = class extends or {
2317
2317
  let c = i;
2318
2318
  if (c?.isReady && c.renderMode?.value === 1 && c.frameCount > 0 && !c.isComplete) return;
2319
2319
  let l = this._pickFocusPoint(c.resetCount), u;
2320
- if (l) u = ia(l, this.camera), this._lastValidFocusDistance = u;
2320
+ if (l) u = oa(l, this.camera), this._lastValidFocusDistance = u;
2321
2321
  else if (this._lastValidFocusDistance !== null) u = this._lastValidFocusDistance;
2322
2322
  else {
2323
- let e = this.controls ? ia(this.controls.target, this.camera) : 0;
2324
- u = e > 0 ? e : Ta * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2323
+ let e = this.controls ? oa(this.controls.target, this.camera) : 0;
2324
+ u = e > 0 ? e : Da * (n?.getSceneScale() || 1), this._lastValidFocusDistance = u;
2325
2325
  }
2326
2326
  let d = this._afPointDirty;
2327
- this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > Ea ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2327
+ this._afPointDirty = !1, d || this._smoothedFocusDistance === null || this._smoothedFocusDistance === 0 || Math.abs(u - this._smoothedFocusDistance) / this._smoothedFocusDistance > Oa ? this._smoothedFocusDistance = u : this._smoothedFocusDistance += this.afSmoothingFactor * (u - this._smoothedFocusDistance);
2328
2328
  let f = r, p = this._smoothedFocusDistance;
2329
2329
  if (d || f === 0 || Math.abs(p - f) / Math.max(f, .001) > .001) {
2330
2330
  a(p);
2331
2331
  let e = n?.getSceneScale() || 1;
2332
2332
  this.dispatchEvent({
2333
- type: j.AUTO_FOCUS_UPDATED,
2333
+ type: A.AUTO_FOCUS_UPDATED,
2334
2334
  distance: p / e,
2335
2335
  worldDistance: p
2336
2336
  });
2337
2337
  let t = Math.abs(p - f) / Math.max(f, .001);
2338
- d ? s?.() : t > wa && o?.();
2338
+ d ? s?.() : t > Ea && o?.();
2339
2339
  }
2340
2340
  }
2341
2341
  _pickFocusPoint(e) {
@@ -2345,8 +2345,8 @@ var oa = class extends or {
2345
2345
  resetCount: NaN,
2346
2346
  x: NaN,
2347
2347
  y: NaN,
2348
- view: new pr(),
2349
- projection: new pr()
2348
+ view: new hr(),
2349
+ projection: new hr()
2350
2350
  };
2351
2351
  if (this._afPointDirty || e !== i.resetCount || n !== i.x || r !== i.y || !i.view.equals(t.matrixWorld) || !i.projection.equals(t.projectionMatrix)) {
2352
2352
  let a = this.interactionManager.pickSurface(n * 2 - 1, 1 - r * 2);
@@ -2369,7 +2369,7 @@ var oa = class extends or {
2369
2369
  dispose() {
2370
2370
  this.walkControls?.dispose(), this.controls?.removeEventListener("change", this._reportOrthoHeight), this.controls?.dispose();
2371
2371
  }
2372
- }, Aa = .001, ja = 2, Ma = (e, t, n, r) => new e(t, n, r, lr).createInterpolant(), Na = class {
2372
+ }, Ma = .001, Na = 2, Pa = (e, t, n, r) => new e(t, n, r, dr).createInterpolant(), Fa = class {
2373
2373
  constructor(e, t) {
2374
2374
  this._cameraManager = e, this._onChange = t, this.keys = [], this._nextId = 1, this._interpolants = null;
2375
2375
  }
@@ -2379,7 +2379,7 @@ var oa = class extends or {
2379
2379
  get duration() {
2380
2380
  return this.keys.length ? this.keys[this.keys.length - 1].time : 0;
2381
2381
  }
2382
- addKey(e = this.keys.length ? this.duration + ja : 0) {
2382
+ addKey(e = this.keys.length ? this.duration + Na : 0) {
2383
2383
  return this.add(this._cameraManager.captureView(), e);
2384
2384
  }
2385
2385
  updateKey(e) {
@@ -2393,13 +2393,13 @@ var oa = class extends or {
2393
2393
  let n = {
2394
2394
  id: this._nextId++,
2395
2395
  time: t,
2396
- ...Pa(e)
2396
+ ...Ia(e)
2397
2397
  };
2398
2398
  return this.keys.push(n), this._changed(), n;
2399
2399
  }
2400
2400
  update(e, t) {
2401
2401
  let n = this.get(e);
2402
- n && (Object.assign(n, Pa(t)), this._changed());
2402
+ n && (Object.assign(n, Ia(t)), this._changed());
2403
2403
  }
2404
2404
  setTime(e, t) {
2405
2405
  let n = this.get(e);
@@ -2444,12 +2444,12 @@ var oa = class extends or {
2444
2444
  orthoHeight: 0
2445
2445
  }) {
2446
2446
  if (!this.keys.length) return null;
2447
- let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c = fr.clamp(e, o, s);
2447
+ let { position: n, target: r, fov: i, logHeight: a, start: o, end: s } = this._interpolants ??= this._build(), c = mr.clamp(e, o, s);
2448
2448
  return t.position.fromArray(n.evaluate(c)), t.target.fromArray(r.evaluate(c)), t.fov = i.evaluate(c)[0], t.orthoHeight = Math.exp(a.evaluate(c)[0]), t;
2449
2449
  }
2450
2450
  _build() {
2451
2451
  let e = [];
2452
- for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] + Aa) : t.time);
2452
+ for (let t of this.keys) e.push(e.length ? Math.max(t.time, e[e.length - 1] + Ma) : t.time);
2453
2453
  let t = e[0], n = e[e.length - 1], r = this.keys;
2454
2454
  if (r.length > 1) {
2455
2455
  let i = r.length;
@@ -2463,17 +2463,17 @@ var oa = class extends or {
2463
2463
  return {
2464
2464
  start: t,
2465
2465
  end: n,
2466
- position: Ma(Nr, ".position", e, i((e) => e.position)),
2467
- target: Ma(Nr, ".target", e, i((e) => e.target)),
2468
- fov: Ma(_r, ".fov", e, r.map((e) => e.fov)),
2469
- logHeight: Ma(_r, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2466
+ position: Pa(Fr, ".position", e, i((e) => e.position)),
2467
+ target: Pa(Fr, ".target", e, i((e) => e.target)),
2468
+ fov: Pa(yr, ".fov", e, r.map((e) => e.fov)),
2469
+ logHeight: Pa(yr, ".orthoHeight", e, r.map((e) => Math.log(e.orthoHeight)))
2470
2470
  };
2471
2471
  }
2472
2472
  _changed() {
2473
2473
  this.keys.sort((e, t) => e.time - t.time), this._interpolants = null, this._onChange?.();
2474
2474
  }
2475
2475
  };
2476
- function Pa({ position: e, target: t, fov: n, orthoHeight: r }) {
2476
+ function Ia({ position: e, target: t, fov: n, orthoHeight: r }) {
2477
2477
  return {
2478
2478
  position: e.clone(),
2479
2479
  target: t.clone(),
@@ -2483,9 +2483,9 @@ function Pa({ position: e, target: t, fov: n, orthoHeight: r }) {
2483
2483
  }
2484
2484
  //#endregion
2485
2485
  //#region src/managers/timeline/TimelineManager.js
2486
- var Fa = class extends or {
2486
+ var La = class extends cr {
2487
2487
  constructor({ cameraManager: e, onReset: t }) {
2488
- super(), this._cameraManager = e, this._onReset = t, this.camera = new Na(e, () => this._changed("camera")), this._playback = null, this._timer = new Or(), typeof document < "u" && this._timer.connect(document);
2488
+ super(), this._cameraManager = e, this._onReset = t, this.camera = new Fa(e, () => this._changed("camera")), this._playback = null, this._timer = new Ar(), typeof document < "u" && this._timer.connect(document);
2489
2489
  }
2490
2490
  get duration() {
2491
2491
  return this.camera.duration;
@@ -2517,7 +2517,7 @@ var Fa = class extends or {
2517
2517
  let e = this._playback;
2518
2518
  if (!e) return;
2519
2519
  this._timer.update(), e.elapsed += this._timer.getDelta();
2520
- let t = fr.clamp(e.elapsed, 0, this.duration);
2520
+ let t = mr.clamp(e.elapsed, 0, this.duration);
2521
2521
  this.seek(t), t >= this.duration && this.stop();
2522
2522
  }
2523
2523
  serialize() {
@@ -2534,18 +2534,18 @@ var Fa = class extends or {
2534
2534
  }
2535
2535
  _changed(e) {
2536
2536
  this.dispatchEvent({
2537
- type: j.TIMELINE_CHANGED,
2537
+ type: A.TIMELINE_CHANGED,
2538
2538
  track: e
2539
2539
  });
2540
2540
  }
2541
- }, Ia = class {
2541
+ }, Ra = class {
2542
2542
  constructor(e, t = {}) {
2543
2543
  this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._size = 256;
2544
2544
  }
2545
2545
  async loadLibrary(e, { size: t = 256 } = {}) {
2546
2546
  if (!Array.isArray(e) || e.length === 0) return [];
2547
2547
  this._size = t;
2548
- let n = await Promise.all(e.map((e) => La(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
2548
+ let n = await Promise.all(e.map((e) => za(e.url))), r = t, i = t, a = n.length, o = new Uint8Array(r * i * a * 4), s = document.createElement("canvas");
2549
2549
  s.width = r, s.height = i;
2550
2550
  let c = s.getContext("2d", { willReadFrequently: !0 }), l = performance.now();
2551
2551
  for (let e = 0; e < a; e++) {
@@ -2553,8 +2553,8 @@ var Fa = class extends or {
2553
2553
  let t = c.getImageData(0, 0, r, i);
2554
2554
  o.set(t.data, e * r * i * 4), performance.now() - l > 16 && (await new Promise((e) => setTimeout(e, 0)), l = performance.now());
2555
2555
  }
2556
- let u = new ir(o, r, i, a);
2557
- u.minFilter = X, u.magFilter = X, u.format = Q, u.type = kr, u.generateMipmaps = !1, u.needsUpdate = !0;
2556
+ let u = new or(o, r, i, a);
2557
+ u.minFilter = X, u.magFilter = X, u.format = Q, u.type = jr, u.generateMipmaps = !1, u.needsUpdate = !0;
2558
2558
  let d = this.texture;
2559
2559
  return this.texture = u, this.entries = e.map((e, t) => ({
2560
2560
  name: e.name,
@@ -2570,14 +2570,14 @@ var Fa = class extends or {
2570
2570
  if (o.userData = o.userData || {}, t == null) delete o.userData.gobo;
2571
2571
  else {
2572
2572
  let e = this.entries.find((e) => e.name === t);
2573
- if (!e) return this._issues?.record(Ze.ASSET_UNREACHABLE, `no gobo named "${t}" is loaded — the light projects without one`, {
2573
+ if (!e) return this._issues?.record(Qe.ASSET_UNREACHABLE, `no gobo named "${t}" is loaded — the light projects without one`, {
2574
2574
  name: t,
2575
2575
  asset: "gobo"
2576
2576
  }), !1;
2577
2577
  o.userData.gobo = {
2578
2578
  name: e.name,
2579
2579
  index: e.index,
2580
- intensity: Ra(r),
2580
+ intensity: Ba(r),
2581
2581
  inverted: !!i,
2582
2582
  scale: Math.max(1e-4, a)
2583
2583
  };
@@ -2619,7 +2619,7 @@ var Fa = class extends or {
2619
2619
  return t && t.isSpotLight ? t : null;
2620
2620
  }
2621
2621
  };
2622
- async function La(e) {
2622
+ async function za(e) {
2623
2623
  let t = await v(e);
2624
2624
  try {
2625
2625
  return await new Promise((n, r) => {
@@ -2630,22 +2630,22 @@ async function La(e) {
2630
2630
  t.release();
2631
2631
  }
2632
2632
  }
2633
- function Ra(e) {
2633
+ function Ba(e) {
2634
2634
  return Math.max(0, Math.min(1, e));
2635
2635
  }
2636
2636
  //#endregion
2637
2637
  //#region src/Processor/IESParser.js
2638
- function za(e, t = "ies") {
2638
+ function Va(e, t = "ies") {
2639
2639
  let n = e.search(/TILT\s*=/i);
2640
2640
  if (n < 0) throw Error(`IES (${t}): missing TILT line`);
2641
2641
  let r = e.indexOf("\n", n);
2642
2642
  if (r < 0) throw Error(`IES (${t}): truncated TILT line`);
2643
2643
  let i = e.slice(n, r).match(/TILT\s*=\s*(\w+)/i), a = i ? i[1].toUpperCase() : "NONE", o = e.slice(r);
2644
2644
  if (a === "INCLUDE") {
2645
- let e = Wa(o), t = 2 + 2 * Number(e[1]);
2646
- o = Ga(o, t);
2645
+ let e = Ka(o), t = 2 + 2 * Number(e[1]);
2646
+ o = qa(o, t);
2647
2647
  }
2648
- let s = Wa(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
2648
+ let s = Ka(o), c = 0, l = () => Number(s[c++]), u = l(), d = l(), f = l(), p = l(), m = l(), h = l();
2649
2649
  l(), l(), l(), l();
2650
2650
  let g = l();
2651
2651
  if (l(), l(), !Number.isFinite(p) || p <= 0) throw Error(`IES (${t}): invalid vertical angle count ${p}`);
@@ -2671,34 +2671,34 @@ function za(e, t = "ies") {
2671
2671
  name: t
2672
2672
  };
2673
2673
  }
2674
- function Ba(e, t, n) {
2674
+ function Ha(e, t, n) {
2675
2675
  if (t === 0 && n === 90) {
2676
2676
  let t = e % 180;
2677
2677
  return t > 90 ? 180 - t : t;
2678
2678
  }
2679
2679
  return t === 0 && n === 180 ? e > 180 ? 360 - e : e : t === 90 && n === 270 ? e >= 90 && e <= 270 ? e : (540 - e) % 360 : e;
2680
2680
  }
2681
- function Va(e, t, n) {
2681
+ function Ua(e, t, n) {
2682
2682
  let r = new Uint8Array(t * n), { verticalAngles: i, horizontalAngles: a, candela: o, maxCandela: s, photometricType: c } = e;
2683
2683
  if (s <= 0) return r;
2684
2684
  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) => {
2685
- if (m) return qa(o[e][0], o[t][0], n);
2685
+ if (m) return Ya(o[e][0], o[t][0], n);
2686
2686
  if (r < f || r > p) return 0;
2687
- let i = Ka(a, r), s = Math.min(i + 1, a.length - 1), c = a[s] - a[i], l = c > 0 ? (r - a[i]) / c : 0;
2688
- return qa(qa(o[e][i], o[e][s], l), qa(o[t][i], o[t][s], l), n);
2687
+ let i = Ja(a, r), s = Math.min(i + 1, a.length - 1), c = a[s] - a[i], l = c > 0 ? (r - a[i]) / c : 0;
2688
+ return Ya(Ya(o[e][i], o[e][s], l), Ya(o[t][i], o[t][s], l), n);
2689
2689
  };
2690
2690
  for (let e = 0; e < n; e++) {
2691
2691
  let a = (e + .5) / n, o = l ? a * 180 : u + a * (d - u);
2692
2692
  if (o < u || o > d) continue;
2693
- let c = Ka(i, o), m = Math.min(c + 1, i.length - 1), g = i[m] - i[c], _ = g > 0 ? (o - i[c]) / g : 0;
2693
+ let c = Ja(i, o), m = Math.min(c + 1, i.length - 1), g = i[m] - i[c], _ = g > 0 ? (o - i[c]) / g : 0;
2694
2694
  for (let n = 0; n < t; n++) {
2695
- let i = (n + .5) / t, a = l ? Ba(i * 360, f, p) : f + i * (p - f), o = Math.min(1, Math.max(0, h(c, m, _, a) / s));
2695
+ let i = (n + .5) / t, a = l ? Ha(i * 360, f, p) : f + i * (p - f), o = Math.min(1, Math.max(0, h(c, m, _, a) / s));
2696
2696
  r[e * t + n] = Math.round(o * 255);
2697
2697
  }
2698
2698
  }
2699
2699
  return r;
2700
2700
  }
2701
- function Ha(e, t = .1) {
2701
+ function Wa(e, t = .1) {
2702
2702
  let { verticalAngles: n, horizontalAngles: r, candela: i, maxCandela: a } = e, o = Math.PI / 4;
2703
2703
  if (a <= 0 || !n?.length) return o;
2704
2704
  let s = a * t, c = r.length, l = n[n.length - 1], u = !1;
@@ -2713,7 +2713,7 @@ function Ha(e, t = .1) {
2713
2713
  let d = l * Math.PI / 180;
2714
2714
  return Math.min(Math.max(d, 5 * Math.PI / 180), 89 * Math.PI / 180);
2715
2715
  }
2716
- function Ua(e, t, n = .7) {
2716
+ function Ga(e, t, n = .7) {
2717
2717
  let { verticalAngles: r, horizontalAngles: i, candela: a, maxCandela: o } = e;
2718
2718
  if (o <= 0 || !r?.length || t <= 0) return 0;
2719
2719
  let s = o * n, c = i.length, l = 0;
@@ -2726,15 +2726,15 @@ function Ua(e, t, n = .7) {
2726
2726
  let u = t * 180 / Math.PI, d = u > 0 ? 1 - l / u : 0;
2727
2727
  return Math.min(Math.max(d, 0), 1);
2728
2728
  }
2729
- function Wa(e) {
2729
+ function Ka(e) {
2730
2730
  return e.split(/\s+/).filter((e) => e.length > 0);
2731
2731
  }
2732
- function Ga(e, t) {
2732
+ function qa(e, t) {
2733
2733
  let n = /\S+/g, r = 0;
2734
2734
  for (; n.exec(e) !== null;) if (r++, r === t) return e.slice(n.lastIndex);
2735
2735
  return "";
2736
2736
  }
2737
- function Ka(e, t) {
2737
+ function Ja(e, t) {
2738
2738
  if (t <= e[0]) return 0;
2739
2739
  if (t >= e[e.length - 1]) return e.length - 1;
2740
2740
  let n = 0, r = e.length - 1;
@@ -2744,12 +2744,12 @@ function Ka(e, t) {
2744
2744
  }
2745
2745
  return n;
2746
2746
  }
2747
- function qa(e, t, n) {
2747
+ function Ya(e, t, n) {
2748
2748
  return e + (t - e) * n;
2749
2749
  }
2750
2750
  //#endregion
2751
2751
  //#region src/managers/IESManager.js
2752
- var Ja = class {
2752
+ var Xa = class {
2753
2753
  constructor(e, t = {}) {
2754
2754
  this.pathTracer = e, this._onReset = t.onReset || null, this._issues = t.issues ?? null, this.texture = null, this.entries = [], this._gridWidth = 128, this._gridHeight = 128;
2755
2755
  }
@@ -2758,14 +2758,14 @@ var Ja = class {
2758
2758
  this._gridWidth = t, this._gridHeight = n;
2759
2759
  let r = (await Promise.all(e.map(async (e) => {
2760
2760
  try {
2761
- let { file: r, release: i } = await m().fetch(e.url), a = za(await r.text().finally(i), e.name);
2761
+ let { file: r, release: i } = await m().fetch(e.url), a = Va(await r.text().finally(i), e.name);
2762
2762
  return {
2763
2763
  it: e,
2764
2764
  profile: a,
2765
- grid: Va(a, t, n)
2765
+ grid: Ua(a, t, n)
2766
2766
  };
2767
2767
  } catch (t) {
2768
- return this._issues?.warn(Ze.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
2768
+ return this._issues?.warn(Qe.ASSET_UNREACHABLE, `IES profile "${e.name}" could not be loaded: ${t.message}`, {
2769
2769
  url: e.url,
2770
2770
  asset: "ies",
2771
2771
  cause: t.message
@@ -2780,19 +2780,19 @@ var Ja = class {
2780
2780
  let r = t[e];
2781
2781
  o[n + e * 4 + 0] = r, o[n + e * 4 + 1] = r, o[n + e * 4 + 2] = r, o[n + e * 4 + 3] = 255;
2782
2782
  }
2783
- let i = r[e].profile, c = Ha(i);
2783
+ let i = r[e].profile, c = Wa(i);
2784
2784
  s.push({
2785
2785
  name: r[e].it.name,
2786
2786
  index: e,
2787
2787
  maxCandela: i.maxCandela,
2788
2788
  photometricType: i.photometricType,
2789
2789
  suggestedAngle: c,
2790
- suggestedPenumbra: Ua(i, c),
2790
+ suggestedPenumbra: Ga(i, c),
2791
2791
  lumens: i.lumens
2792
2792
  });
2793
2793
  }
2794
- let c = new ir(o, t, n, i);
2795
- c.format = Q, c.type = kr, c.minFilter = X, c.magFilter = X, c.generateMipmaps = !1, c.needsUpdate = !0;
2794
+ let c = new or(o, t, n, i);
2795
+ c.format = Q, c.type = jr, c.minFilter = X, c.magFilter = X, c.generateMipmaps = !1, c.needsUpdate = !0;
2796
2796
  let l = this.texture;
2797
2797
  return this.texture = c, this.entries = s, this.pathTracer.iesProfiles = c, this.pathTracer.shaderBuilder?.updateIESProfiles?.(c), l?.dispose?.(), this.entries.map(({ name: e, index: t }) => ({
2798
2798
  name: e,
@@ -2816,14 +2816,14 @@ var Ja = class {
2816
2816
  if (t == null) delete i.userData.ies;
2817
2817
  else {
2818
2818
  let e = this.entries.find((e) => e.name === t);
2819
- if (!e) return this._issues?.record(Ze.ASSET_UNREACHABLE, `no IES profile named "${t}" is loaded — the light keeps its plain distribution`, {
2819
+ if (!e) return this._issues?.record(Qe.ASSET_UNREACHABLE, `no IES profile named "${t}" is loaded — the light keeps its plain distribution`, {
2820
2820
  name: t,
2821
2821
  asset: "ies"
2822
2822
  }), a;
2823
2823
  l = Number.isFinite(e.lumens) ? e.lumens : null, i.userData.ies = {
2824
2824
  name: e.name,
2825
2825
  index: e.index,
2826
- intensity: Ya(n),
2826
+ intensity: Za(n),
2827
2827
  fixtureLumens: l
2828
2828
  }, 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);
2829
2829
  }
@@ -2846,16 +2846,16 @@ var Ja = class {
2846
2846
  return t && t.isSpotLight ? t : null;
2847
2847
  }
2848
2848
  };
2849
- function Ya(e) {
2849
+ function Za(e) {
2850
2850
  return Math.max(0, Math.min(1, e));
2851
2851
  }
2852
2852
  //#endregion
2853
2853
  //#region src/Passes/OIDNDenoiser.js
2854
- var Xa = Ke("oidn"), Za = 16, Qa = null;
2855
- async function $a() {
2856
- return Qa ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, Qa;
2854
+ var Qa = qe("oidn"), $a = 16, eo = null;
2855
+ async function to() {
2856
+ return eo ||= (await import("oidn-web/dist/oidn.js")).initUNetFromBuffer, eo;
2857
2857
  }
2858
- var eo = {
2858
+ var no = {
2859
2859
  QUALITY_MODELS: {
2860
2860
  fast: {
2861
2861
  model: "rt_hdr_alb_nrm_small",
@@ -2879,9 +2879,9 @@ var eo = {
2879
2879
  oidnQuality: "fast",
2880
2880
  tileSize: 1024
2881
2881
  }
2882
- }, to = .18, no = 256, ro = 256, io = `
2883
- const WG: u32 = ${no}u;
2884
- const GROUPS: u32 = ${ro}u;
2882
+ }, ro = .18, io = 256, ao = 256, oo = `
2883
+ const WG: u32 = ${io}u;
2884
+ const GROUPS: u32 = ${ao}u;
2885
2885
 
2886
2886
  @group(0) @binding(0) var<storage, read> col: array<vec4<f32>>;
2887
2887
  @group(0) @binding(1) var<storage, read_write> partials: array<f32>;
@@ -2900,7 +2900,7 @@ fn treeSum( lid: u32 ) {
2900
2900
  }
2901
2901
  }
2902
2902
 
2903
- @compute @workgroup_size(${no})
2903
+ @compute @workgroup_size(${io})
2904
2904
  fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
2905
2905
  @builtin(local_invocation_id) lid: vec3<u32>,
2906
2906
  @builtin(workgroup_id) wid: vec3<u32> ) {
@@ -2923,7 +2923,7 @@ fn reduce( @builtin(global_invocation_id) gid: vec3<u32>,
2923
2923
  if ( lid.x == 0u ) { partials[ wid.x ] = sdata[ 0 ]; }
2924
2924
  }
2925
2925
 
2926
- @compute @workgroup_size(${no})
2926
+ @compute @workgroup_size(${io})
2927
2927
  fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
2928
2928
 
2929
2929
  var v = 0.0;
@@ -2933,12 +2933,12 @@ fn finalize( @builtin(local_invocation_id) lid: vec3<u32> ) {
2933
2933
  treeSum( lid.x );
2934
2934
 
2935
2935
  if ( lid.x == 0u ) {
2936
- let scale = ${to} / exp2( sdata[ 0 ] / f32( params.x ) );
2936
+ let scale = ${ro} / exp2( sdata[ 0 ] / f32( params.x ) );
2937
2937
  // Mirrors the CPU guard: a non-finite or non-positive scale means no scaling at all.
2938
2938
  scaleOut[ 0 ] = select( 1.0, scale, scale > 0.0 && scale < 3.4e38 );
2939
2939
  }
2940
2940
  }
2941
- `, ao = "\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", oo = 64, so = 32768, co = 16, lo = 32, uo = `
2941
+ `, so = "\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", co = 64, lo = 32768, uo = 16, fo = 32, po = `
2942
2942
  struct UnpackParams {
2943
2943
  srcWidth: u32,
2944
2944
  tileX: u32,
@@ -2956,7 +2956,7 @@ struct UnpackParams {
2956
2956
  @group(0) @binding(3) var<storage, read> inColor: array<vec4<f32>>;
2957
2957
  @group(0) @binding(4) var dst: texture_storage_2d<rgba16float, write>;
2958
2958
 
2959
- @compute @workgroup_size(${co}, ${co})
2959
+ @compute @workgroup_size(${uo}, ${uo})
2960
2960
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2961
2961
 
2962
2962
  if ( gid.x >= P.tileW || gid.y >= P.tileH ) { return; }
@@ -2970,18 +2970,18 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2970
2970
  // survives the denoise.
2971
2971
  textureStore( dst, vec2<u32>( px, py ), vec4<f32>( src[ si ].xyz / scaleBuf[ 0 ], inColor[ si ].w ) );
2972
2972
  }
2973
- `, fo = 8, po = `
2973
+ `, mo = 8, ho = `
2974
2974
  @group(0) @binding(0) var src: texture_2d<f32>;
2975
2975
  @group(0) @binding(1) var<storage, read_write> dst: array<vec4<f32>>;
2976
2976
  @group(0) @binding(2) var<uniform> size: vec2<u32>;
2977
2977
 
2978
- @compute @workgroup_size(${fo}, ${fo})
2978
+ @compute @workgroup_size(${mo}, ${mo})
2979
2979
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2980
2980
 
2981
2981
  if ( gid.x >= size.x || gid.y >= size.y ) { return; }
2982
2982
  dst[ gid.y * size.x + gid.x ] = textureLoad( src, gid.xy, 0 );
2983
2983
  }
2984
- `, mo = class extends or {
2984
+ `, go = class extends cr {
2985
2985
  constructor(e, t = {}) {
2986
2986
  if (super(), !e) throw Error("OIDNDenoiser requires a renderer");
2987
2987
  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 = {
@@ -2995,14 +2995,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
2995
2995
  width: 0,
2996
2996
  height: 0
2997
2997
  }, this.config = {
2998
- ...eo.DEFAULT_OPTIONS,
2998
+ ...no.DEFAULT_OPTIONS,
2999
2999
  ...t
3000
3000
  }, this.enabled = this.config.enableOIDN, this.quality = this.config.oidnQuality, this.maxTileSize = this.config.tileSize, this._activeTileSize = 0, this.state = {
3001
3001
  isDenoising: !1,
3002
3002
  isLoading: !1,
3003
3003
  abortController: null
3004
3004
  }, 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) => {
3005
- Xa.error("init failed:", e), this.dispatchEvent({
3005
+ Qa.error("init failed:", e), this.dispatchEvent({
3006
3006
  type: "error",
3007
3007
  error: e
3008
3008
  });
@@ -3016,7 +3016,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3016
3016
  }
3017
3017
  }
3018
3018
  expectsCleanAux(e = this.quality) {
3019
- let { QUALITY_MODELS: t } = eo;
3019
+ let { QUALITY_MODELS: t } = no;
3020
3020
  return (t[e] || t.balance).cleanAux;
3021
3021
  }
3022
3022
  getRuntimeInfo() {
@@ -3031,8 +3031,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3031
3031
  _resolveTileSize() {
3032
3032
  let e = Math.max(this._renderWidth, this._renderHeight);
3033
3033
  if (!e) return this.maxTileSize;
3034
- let t = Math.ceil(e / Za) * Za;
3035
- return t <= this.maxTileSize ? t : Math.max(Za, Math.floor(this.maxTileSize / Za) * Za);
3034
+ let t = Math.ceil(e / $a) * $a;
3035
+ return t <= this.maxTileSize ? t : Math.max($a, Math.floor(this.maxTileSize / $a) * $a);
3036
3036
  }
3037
3037
  _setupUNetDenoiser() {
3038
3038
  return this.state.isLoading ? (this._reloadPending = !0, Promise.resolve()) : (this._loading = this._loadUNet(), this._loading);
@@ -3046,7 +3046,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3046
3046
  try {
3047
3047
  await this._loadUNetWeights();
3048
3048
  } catch (e) {
3049
- Xa.error("UNet weights failed to load:", e), this.dispatchEvent({
3049
+ Qa.error("UNet weights failed to load:", e), this.dispatchEvent({
3050
3050
  type: "error",
3051
3051
  error: /* @__PURE__ */ Error(`Denoiser loading failed: ${e.message}`),
3052
3052
  url: this._generateTzaUrl()
@@ -3072,26 +3072,26 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3072
3072
  let e = this.backendParamsGetter();
3073
3073
  this.gpuDevice = e?.device ?? null, n = e?.device ? e : void 0;
3074
3074
  }
3075
- this.unet = await (await $a())(await this._fetchWeights(e), n, {
3075
+ this.unet = await (await to())(await this._fetchWeights(e), n, {
3076
3076
  aux: !0,
3077
3077
  hdr: !0,
3078
3078
  maxTileSize: t,
3079
3079
  dynamicTile: !1
3080
- }), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), Xa.debug("UNet weights loaded:", e);
3080
+ }), this.currentTZAUrl = e, this._activeTileSize = t, this.dispatchEvent({ type: "loaded" }), Qa.debug("UNet weights loaded:", e);
3081
3081
  }
3082
3082
  _fetchWeights(e) {
3083
3083
  let t = this._weights.get(e);
3084
3084
  return t || (t = m().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;
3085
3085
  }
3086
3086
  _generateTzaUrl() {
3087
- let { oidnWeightsBaseUrl: e } = at(), { QUALITY_MODELS: t } = eo;
3087
+ let { oidnWeightsBaseUrl: e } = ot(), { QUALITY_MODELS: t } = no;
3088
3088
  return `${e}${(t[this.quality] || t.balance).model}.tza`;
3089
3089
  }
3090
3090
  async updateConfiguration(e) {
3091
3091
  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());
3092
3092
  }
3093
3093
  async updateQuality(e) {
3094
- if (!Object.prototype.hasOwnProperty.call(eo.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(eo.QUALITY_MODELS).join(", ")}`);
3094
+ if (!Object.prototype.hasOwnProperty.call(no.QUALITY_MODELS, e)) throw Error(`Invalid quality setting: ${e}. Must be one of: ${Object.keys(no.QUALITY_MODELS).join(", ")}`);
3095
3095
  await this.updateConfiguration({ oidnQuality: e });
3096
3096
  }
3097
3097
  async start({ continuous: e = !1 } = {}) {
@@ -3102,7 +3102,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3102
3102
  continuous: e
3103
3103
  });
3104
3104
  let t = performance.now(), n = await this.execute(e);
3105
- return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Xa.debug(`denoise complete in ${We.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
3105
+ return n && (this.renderer?.resetState?.(), this.lastDenoiseMs = performance.now() - t, Qa.debug(`denoise complete in ${Ge.ms(this.lastDenoiseMs)} · quality ${this.quality}`)), n;
3106
3106
  }
3107
3107
  async execute(e = !1) {
3108
3108
  if (!this.enabled || !this.unet) return !1;
@@ -3111,7 +3111,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3111
3111
  try {
3112
3112
  return await this._executeUNetGPU(e) !== !1;
3113
3113
  } catch (e) {
3114
- return e.name === "AbortError" ? Xa.debug("denoise aborted") : Xa.error("denoise error:", e), !1;
3114
+ return e.name === "AbortError" ? Qa.debug("denoise aborted") : Qa.error("denoise error:", e), !1;
3115
3115
  } finally {
3116
3116
  this._runId === t && (this.state.isDenoising = !1, this.state.abortController = null), this.dispatchEvent({
3117
3117
  type: "end",
@@ -3121,11 +3121,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3121
3121
  }
3122
3122
  async _executeUNetGPU(e = !1) {
3123
3123
  let t = this._renderWidth, n = this._renderHeight;
3124
- if (!this.getGPUTextures) return Xa.warn("GPU mode enabled but getGPUTextures not provided"), !1;
3124
+ if (!this.getGPUTextures) return Qa.warn("GPU mode enabled but getGPUTextures not provided"), !1;
3125
3125
  let r = this.getGPUTextures({ continuous: e });
3126
- if (!r?.color) return Xa.warn("GPU textures not ready yet"), !1;
3126
+ if (!r?.color) return Qa.warn("GPU textures not ready yet"), !1;
3127
3127
  let i = this.gpuDevice;
3128
- if (!i) return Xa.warn("gpuDevice not available"), !1;
3128
+ if (!i) return Qa.warn("gpuDevice not available"), !1;
3129
3129
  this._ensureGPUInputBuffers(t, n), this._copyInputs(i, r, t, n), this._computeInputScale(i, t * n), this._applyColorScale(i, t * n), !e && !this._hasOutput && this._unpackToTexture(this._gpuInputBuffers.color, t, {
3130
3130
  x: 0,
3131
3131
  y: 0,
@@ -3169,7 +3169,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3169
3169
  resource: { buffer: this._packParams }
3170
3170
  }
3171
3171
  ]
3172
- })), o.dispatchWorkgroups(Math.ceil(n / fo), Math.ceil(r / fo))) : i.copyTextureToBuffer({
3172
+ })), o.dispatchWorkgroups(Math.ceil(n / mo), Math.ceil(r / mo))) : i.copyTextureToBuffer({
3173
3173
  texture: t,
3174
3174
  mipLevel: 0
3175
3175
  }, {
@@ -3233,7 +3233,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3233
3233
  compute: {
3234
3234
  module: e.createShaderModule({
3235
3235
  label: "oidn-pack",
3236
- code: po
3236
+ code: ho
3237
3237
  }),
3238
3238
  entryPoint: "main"
3239
3239
  }
@@ -3286,7 +3286,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3286
3286
  });
3287
3287
  let t = e.createShaderModule({
3288
3288
  label: "oidn-autoexposure",
3289
- code: io
3289
+ code: oo
3290
3290
  }), n = e.createPipelineLayout({ bindGroupLayouts: [this._lumLayout] });
3291
3291
  this._lumReducePipeline = e.createComputePipeline({
3292
3292
  label: "oidn-autoexposure-reduce",
@@ -3310,7 +3310,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3310
3310
  compute: {
3311
3311
  module: e.createShaderModule({
3312
3312
  label: "oidn-color-scale",
3313
- code: ao
3313
+ code: so
3314
3314
  }),
3315
3315
  entryPoint: "main"
3316
3316
  }
@@ -3320,7 +3320,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3320
3320
  compute: {
3321
3321
  module: e.createShaderModule({
3322
3322
  label: "oidn-output-unpack",
3323
- code: uo
3323
+ code: po
3324
3324
  }),
3325
3325
  entryPoint: "main"
3326
3326
  }
@@ -3330,7 +3330,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3330
3330
  size: 4
3331
3331
  }), this._lumPartials = e.createBuffer({
3332
3332
  label: "oidn-autoexposure-partials",
3333
- size: ro * 4,
3333
+ size: ao * 4,
3334
3334
  usage: GPUBufferUsage.STORAGE
3335
3335
  }), this._lumParams = e.createBuffer({
3336
3336
  label: "oidn-autoexposure-params",
@@ -3382,13 +3382,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3382
3382
  0
3383
3383
  ]));
3384
3384
  let n = e.createCommandEncoder({ label: "oidn-autoexposure" }), r = n.beginComputePass({ label: "oidn-autoexposure-reduce" });
3385
- r.setPipeline(this._lumReducePipeline), r.setBindGroup(0, this._lumBindGroup), r.dispatchWorkgroups(ro, 1, 1), r.end();
3385
+ r.setPipeline(this._lumReducePipeline), r.setBindGroup(0, this._lumBindGroup), r.dispatchWorkgroups(ao, 1, 1), r.end();
3386
3386
  let i = n.beginComputePass({ label: "oidn-autoexposure-finalize" });
3387
3387
  i.setPipeline(this._lumFinalizePipeline), i.setBindGroup(0, this._lumBindGroup), i.dispatchWorkgroups(1, 1, 1), i.end(), e.queue.submit([n.finish()]);
3388
3388
  }
3389
3389
  _applyColorScale(e, t) {
3390
3390
  if (!this._ensureScalePipelines(e)) return;
3391
- let n = Math.ceil(t / oo), r = Math.min(n, so), i = Math.ceil(n / r), a = e.createCommandEncoder({ label: "oidn-color-scale" }), o = a.beginComputePass({ label: "oidn-color-scale" });
3391
+ let n = Math.ceil(t / co), r = Math.min(n, lo), i = Math.ceil(n / r), a = e.createCommandEncoder({ label: "oidn-color-scale" }), o = a.beginComputePass({ label: "oidn-color-scale" });
3392
3392
  o.setPipeline(this._colorScalePipeline), o.setBindGroup(0, this._colorScaleBindGroup), o.dispatchWorkgroups(r, i, 1), o.end(), e.queue.submit([a.finish()]);
3393
3393
  }
3394
3394
  get outputTexture() {
@@ -3410,12 +3410,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3410
3410
  format: "rgba16float",
3411
3411
  usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC
3412
3412
  });
3413
- let r = new gn(this._outGPUTexture);
3413
+ let r = new yn(this._outGPUTexture);
3414
3414
  r.name = "oidn:output", r.image = {
3415
3415
  width: t,
3416
3416
  height: n,
3417
3417
  depth: 1
3418
- }, r.type = cr, r.format = Q, r.colorSpace = gr, r.minFilter = Z, r.magFilter = Z, r.wrapS = er, r.wrapT = er, r.generateMipmaps = !1, r.flipY = !1, this._outTexture = r, this._outTexSize = {
3418
+ }, r.type = ur, r.format = Q, r.colorSpace = vr, r.minFilter = Z, r.magFilter = Z, r.wrapS = nr, r.wrapT = nr, r.generateMipmaps = !1, r.flipY = !1, this._outTexture = r, this._outTexSize = {
3419
3419
  width: t,
3420
3420
  height: n
3421
3421
  };
@@ -3433,7 +3433,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3433
3433
  if (this._ensureOutputTexture(i, this._renderWidth, this._renderHeight), !this._outGPUTexture) return;
3434
3434
  let l = i.createBuffer({
3435
3435
  label: "oidn-unpack-params",
3436
- size: lo,
3436
+ size: fo,
3437
3437
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
3438
3438
  });
3439
3439
  try {
@@ -3473,7 +3473,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3473
3473
  }
3474
3474
  ]
3475
3475
  }), u = i.createCommandEncoder({ label: "oidn-output-unpack" }), d = u.beginComputePass({ label: "oidn-output-unpack" });
3476
- d.setPipeline(this._unpackPipeline), d.setBindGroup(0, n), d.dispatchWorkgroups(Math.ceil(s / co), Math.ceil(c / co), 1), d.end(), i.queue.submit([u.finish()]), r && (this._hasOutput = !0);
3476
+ d.setPipeline(this._unpackPipeline), d.setBindGroup(0, n), d.dispatchWorkgroups(Math.ceil(s / uo), Math.ceil(c / uo), 1), d.end(), i.queue.submit([u.finish()]), r && (this._hasOutput = !0);
3477
3477
  } finally {
3478
3478
  l.destroy();
3479
3479
  }
@@ -3522,7 +3522,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3522
3522
  }
3523
3523
  _displayGPUOutput({ data: e, width: t, height: n }) {
3524
3524
  if (!this.gpuDevice) {
3525
- Xa.error("gpuDevice not available for the output picture");
3525
+ Qa.error("gpuDevice not available for the output picture");
3526
3526
  return;
3527
3527
  }
3528
3528
  this._unpackToTexture(e, t, {
@@ -3533,7 +3533,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3533
3533
  });
3534
3534
  }
3535
3535
  abort() {
3536
- this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1, Xa.debug("denoise aborted"));
3536
+ this._pendingStart = !1, this._pendingStartContinuous = !1, !(!this.enabled || !this.state.isDenoising) && (this.state.abortController?.abort(), this.state.isDenoising = !1, Qa.debug("denoise aborted"));
3537
3537
  }
3538
3538
  get hasOutput() {
3539
3539
  return this._hasOutput;
@@ -3544,13 +3544,13 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3544
3544
  setSize(e, t) {
3545
3545
  if (e <= 0 || t <= 0) throw Error(`Invalid dimensions: ${e}x${t}`);
3546
3546
  this._renderWidth = e, this._renderHeight = t, this._hasOutput = !1, this.lastDenoiseMs = 0, this._setupUNetDenoiser().catch((e) => {
3547
- Xa.error("reinitialize after size change failed:", e);
3547
+ Qa.error("reinitialize after size change failed:", e);
3548
3548
  });
3549
3549
  }
3550
3550
  dispose() {
3551
- 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?.(), Xa.debug("disposed");
3551
+ 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?.(), Qa.debug("disposed");
3552
3552
  }
3553
- }, ho = Object.freeze({
3553
+ }, _o = Object.freeze({
3554
3554
  maxLength: 8,
3555
3555
  smoothLength: 2,
3556
3556
  roughStart: .45,
@@ -3558,7 +3558,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3558
3558
  depthTolerance: .05,
3559
3559
  normalTolerance: .8,
3560
3560
  movedLength: 2
3561
- }), go = 8, _o = 304, vo = 16, yo = 1, bo = 2, xo = 4, So = 1073741824, Co = "\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", wo = Co + `
3561
+ }), vo = 8, yo = 304, bo = 16, xo = 1, So = 2, Co = 4, wo = 1073741824, To = "\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", Eo = To + `
3562
3562
  @group(0) @binding(1) var geoCur: texture_2d<f32>;
3563
3563
  @group(0) @binding(2) var geoPrev: texture_2d<f32>;
3564
3564
  @group(0) @binding(3) var<storage, read_write> picked: array<i32>;
@@ -3584,7 +3584,7 @@ fn movedIndex( leaf: u32 ) -> i32 {
3584
3584
 
3585
3585
  }
3586
3586
 
3587
- @compute @workgroup_size(${go}, ${go})
3587
+ @compute @workgroup_size(${vo}, ${vo})
3588
3588
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3589
3589
 
3590
3590
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3594,12 +3594,12 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3594
3594
  var pick = -1;
3595
3595
  var movedFlag = 0;
3596
3596
 
3597
- if ( P.reset == 0u && g.w < ${Rr.toFixed(1)} ) {
3597
+ if ( P.reset == 0u && g.w < ${Br.toFixed(1)} ) {
3598
3598
 
3599
3599
  let size = vec2<f32>( P.size );
3600
3600
  let uv = ( vec2<f32>( gid.xy ) + 0.5 ) / size;
3601
3601
  // Depth is along the ray: from the camera, or from its image plane when orthographic.
3602
- let ortho = ( P.flags & ${xo}u ) != 0u;
3602
+ let ortho = ( P.flags & ${Co}u ) != 0u;
3603
3603
  let ndc = vec2<f32>( uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0 );
3604
3604
  var origin = P.camWorld[ 3 ].xyz;
3605
3605
  var dir: vec3<f32>;
@@ -3623,7 +3623,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3623
3623
  let toPrev = movedToPrev[ u32( m ) ];
3624
3624
  wp = ( toPrev * vec4<f32>( wp, 1.0 ) ).xyz;
3625
3625
  n = normalize( ( toPrev * vec4<f32>( n, 0.0 ) ).xyz );
3626
- movedFlag = ${So};
3626
+ movedFlag = ${wo};
3627
3627
 
3628
3628
  }
3629
3629
 
@@ -3660,7 +3660,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3660
3660
  if ( pick >= 0 ) { atomicAdd( &copies[ u32( pick ) ], 1u ); }
3661
3661
 
3662
3662
  }
3663
- `, To = Co + `
3663
+ `, Do = To + `
3664
3664
  @group(0) @binding(1) var curColor: texture_2d<f32>;
3665
3665
  @group(0) @binding(2) var curAlbedo: texture_2d<f32>;
3666
3666
  @group(0) @binding(3) var curNormal: texture_2d<f32>;
@@ -3674,7 +3674,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3674
3674
  @group(0) @binding(11) var outAlbedo: texture_storage_2d<rgba32float, write>;
3675
3675
  @group(0) @binding(12) var outNormal: texture_storage_2d<rgba32float, write>;
3676
3676
 
3677
- @compute @workgroup_size(${go}, ${go})
3677
+ @compute @workgroup_size(${vo}, ${vo})
3678
3678
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3679
3679
 
3680
3680
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3690,8 +3690,8 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3690
3690
  var ha = ca.xyz;
3691
3691
  var hn = cn.xyz;
3692
3692
  let raw = picked[ gid.y * P.size.x + gid.x ];
3693
- let movedPx = raw >= 0 && ( raw & ${So} ) != 0;
3694
- let pick = select( raw, raw & ~${So}, raw >= 0 );
3693
+ let movedPx = raw >= 0 && ( raw & ${wo} ) != 0;
3694
+ let pick = select( raw, raw & ~${wo}, raw >= 0 );
3695
3695
 
3696
3696
  if ( pick >= 0 ) {
3697
3697
 
@@ -3705,7 +3705,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3705
3705
  ha = a.xyz;
3706
3706
  hn = textureLoad( histNormal, q, 0 ).xyz;
3707
3707
  len = a.w;
3708
- if ( ( P.flags & ${bo}u ) != 0u ) { len = len / f32( max( copies[ u32( pick ) ], 1u ) ); }
3708
+ if ( ( P.flags & ${So}u ) != 0u ) { len = len / f32( max( copies[ u32( pick ) ], 1u ) ); }
3709
3709
 
3710
3710
  }
3711
3711
 
@@ -3719,11 +3719,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3719
3719
 
3720
3720
  textureStore( outColor, p, vec4<f32>( mix( hc, cur.xyz, t ), cur.w ) );
3721
3721
  textureStore( outAlbedo, p, vec4<f32>( mix( ha, ca.xyz, t ), newLen ) );
3722
- let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${yo}u ) != 0u );
3722
+ let n = select( cn.xyz, mixNormal( hn, cn.xyz, t ), ( P.flags & ${xo}u ) != 0u );
3723
3723
  textureStore( outNormal, p, vec4<f32>( n, cn.w ) );
3724
3724
 
3725
3725
  }
3726
- `, Eo = Co + `
3726
+ `, Oo = To + `
3727
3727
  @group(0) @binding(1) var accColor: texture_2d<f32>;
3728
3728
  @group(0) @binding(2) var accAlbedo: texture_2d<f32>;
3729
3729
  @group(0) @binding(3) var accNormal: texture_2d<f32>;
@@ -3734,7 +3734,7 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3734
3734
  @group(0) @binding(8) var outAlbedo: texture_storage_2d<rgba32float, write>;
3735
3735
  @group(0) @binding(9) var outNormal: texture_storage_2d<rgba32float, write>;
3736
3736
 
3737
- @compute @workgroup_size(${go}, ${go})
3737
+ @compute @workgroup_size(${vo}, ${vo})
3738
3738
  fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3739
3739
 
3740
3740
  if ( gid.x >= P.size.x || gid.y >= P.size.y ) { return; }
@@ -3768,32 +3768,32 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3768
3768
  let t = P.samples / max( k + P.samples, 1e-6 );
3769
3769
  textureStore( outColor, p, vec4<f32>( mix( hc, ac.xyz, t ), ac.w ) );
3770
3770
  textureStore( outAlbedo, p, vec4<f32>( mix( ha, aa.xyz, t ), min( k + P.samples, P.maxLength ) ) );
3771
- let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${yo}u ) != 0u );
3771
+ let n = select( an.xyz, mixNormal( hn, an.xyz, t ), ( P.flags & ${xo}u ) != 0u );
3772
3772
  textureStore( outNormal, p, vec4<f32>( n, an.w ) );
3773
3773
 
3774
3774
  }
3775
- `, Do = (e) => ({
3775
+ `, ko = (e) => ({
3776
3776
  binding: e,
3777
3777
  visibility: GPUShaderStage.COMPUTE,
3778
3778
  texture: { sampleType: "unfilterable-float" }
3779
- }), Oo = (e) => ({
3779
+ }), Ao = (e) => ({
3780
3780
  binding: e,
3781
3781
  visibility: GPUShaderStage.COMPUTE,
3782
3782
  storageTexture: {
3783
3783
  access: "write-only",
3784
3784
  format: "rgba32float"
3785
3785
  }
3786
- }), ko = (e, t) => ({
3786
+ }), jo = (e, t) => ({
3787
3787
  binding: e,
3788
3788
  visibility: GPUShaderStage.COMPUTE,
3789
3789
  buffer: { type: t }
3790
- }), Ao = class {
3790
+ }), Mo = class {
3791
3791
  constructor(e) {
3792
3792
  this.device = e, this.settings = {
3793
- ...ho,
3793
+ ..._o,
3794
3794
  cleanAux: !1,
3795
3795
  splitCopies: !0
3796
- }, 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);
3796
+ }, 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(yo), 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);
3797
3797
  }
3798
3798
  get textures() {
3799
3799
  return this.valid ? this._sets[this._current] : null;
@@ -3901,23 +3901,23 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3901
3901
  }),
3902
3902
  layout: i
3903
3903
  };
3904
- }, n = ko(0, "uniform");
3904
+ }, n = jo(0, "uniform");
3905
3905
  this._pipelines = {
3906
- select: t("oidn-history-select", wo, [
3906
+ select: t("oidn-history-select", Eo, [
3907
3907
  n,
3908
- Do(1),
3909
- Do(2),
3910
- ko(3, "storage"),
3911
- ko(4, "storage"),
3908
+ ko(1),
3909
+ ko(2),
3910
+ jo(3, "storage"),
3911
+ jo(4, "storage"),
3912
3912
  {
3913
3913
  binding: 5,
3914
3914
  visibility: GPUShaderStage.COMPUTE,
3915
3915
  texture: { sampleType: "uint" }
3916
3916
  },
3917
- ko(6, "read-only-storage"),
3918
- ko(7, "read-only-storage")
3917
+ jo(6, "read-only-storage"),
3918
+ jo(7, "read-only-storage")
3919
3919
  ]),
3920
- blend: t("oidn-history-blend", To, [
3920
+ blend: t("oidn-history-blend", Do, [
3921
3921
  n,
3922
3922
  ...[
3923
3923
  1,
@@ -3927,14 +3927,14 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3927
3927
  5,
3928
3928
  6,
3929
3929
  7
3930
- ].map(Do),
3931
- ko(8, "read-only-storage"),
3932
- ko(9, "read-only-storage"),
3933
- Oo(10),
3934
- Oo(11),
3935
- Oo(12)
3930
+ ].map(ko),
3931
+ jo(8, "read-only-storage"),
3932
+ jo(9, "read-only-storage"),
3933
+ Ao(10),
3934
+ Ao(11),
3935
+ Ao(12)
3936
3936
  ]),
3937
- merge: t("oidn-history-merge", Eo, [
3937
+ merge: t("oidn-history-merge", Oo, [
3938
3938
  n,
3939
3939
  ...[
3940
3940
  1,
@@ -3943,16 +3943,16 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3943
3943
  4,
3944
3944
  5,
3945
3945
  6
3946
- ].map(Do),
3947
- Oo(7),
3948
- Oo(8),
3949
- Oo(9)
3946
+ ].map(ko),
3947
+ Ao(7),
3948
+ Ao(8),
3949
+ Ao(9)
3950
3950
  ])
3951
3951
  }, this._paramsBuffer = e.createBuffer({
3952
3952
  label: "oidn-history-params",
3953
- size: _o,
3953
+ size: yo,
3954
3954
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
3955
- }), this._growMoved(vo);
3955
+ }), this._growMoved(bo);
3956
3956
  }
3957
3957
  _growMoved(e) {
3958
3958
  this._movedLeaves?.destroy(), this._movedToPrev?.destroy();
@@ -3978,11 +3978,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3978
3978
  a.setPipeline(t), a.setBindGroup(0, this.device.createBindGroup({
3979
3979
  layout: n,
3980
3980
  entries: i
3981
- })), a.dispatchWorkgroups(Math.ceil(this.width / go), Math.ceil(this.height / go)), a.end();
3981
+ })), a.dispatchWorkgroups(Math.ceil(this.width / vo), Math.ceil(this.height / vo)), a.end();
3982
3982
  }
3983
3983
  _writeParams(e, t, n, r) {
3984
3984
  let i = this.settings, a = this._paramU32, o = this._paramF32;
3985
- a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ? yo : 0) | (i.splitCopies ? bo : 0) | (e.orthographic ? xo : 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);
3985
+ a[0] = this.width, a[1] = this.height, a[2] = +!!t, a[3] = (i.cleanAux ? xo : 0) | (i.splitCopies ? So : 0) | (e.orthographic ? Co : 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);
3986
3986
  }
3987
3987
  _rememberCamera(e) {
3988
3988
  this._prevViewProj.set(e.viewProj), this._prevCamPos[0] = e.world[12], this._prevCamPos[1] = e.world[13], this._prevCamPos[2] = e.world[14];
@@ -3992,11 +3992,11 @@ fn main( @builtin(global_invocation_id) gid: vec3<u32> ) {
3992
3992
  _releaseTextures() {
3993
3993
  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;
3994
3994
  }
3995
- }, jo = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,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})}};", Mo = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", jo], { type: "text/javascript;charset=utf-8" });
3996
- function No(e) {
3995
+ }, No = "const e=Object.freeze({ADAPTER_SOFTWARE:`adapter.software`,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})}};", Po = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", No], { type: "text/javascript;charset=utf-8" });
3996
+ function Fo(e) {
3997
3997
  let t;
3998
3998
  try {
3999
- if (t = Mo && (self.URL || self.webkitURL).createObjectURL(Mo), !t) throw "";
3999
+ if (t = Po && (self.URL || self.webkitURL).createObjectURL(Po), !t) throw "";
4000
4000
  let n = new Worker(t, {
4001
4001
  type: "module",
4002
4002
  name: e?.name
@@ -4005,7 +4005,7 @@ function No(e) {
4005
4005
  (self.URL || self.webkitURL).revokeObjectURL(t);
4006
4006
  }), n;
4007
4007
  } catch {
4008
- return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(jo), {
4008
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(No), {
4009
4009
  type: "module",
4010
4010
  name: e?.name
4011
4011
  });
@@ -4013,7 +4013,7 @@ function No(e) {
4013
4013
  }
4014
4014
  //#endregion
4015
4015
  //#region src/Passes/AIUpscaler.js
4016
- var Po = {
4016
+ var Io = {
4017
4017
  fast: {
4018
4018
  2: "2x-spanx2-ch48.onnx",
4019
4019
  4: "4xNomos8k_span_otf_strong_fp32_opset17.onnx"
@@ -4027,17 +4027,17 @@ var Po = {
4027
4027
  4: "4xNomos2_hq_mosr_fp32.onnx"
4028
4028
  }
4029
4029
  };
4030
- function Fo() {
4031
- let { upscalerModelBaseUrl: e } = at(), t = {};
4032
- for (let n in Po) {
4030
+ function Lo() {
4031
+ let { upscalerModelBaseUrl: e } = ot(), t = {};
4032
+ for (let n in Io) {
4033
4033
  t[n] = {};
4034
- for (let r in Po[n]) t[n][r] = e + Po[n][r];
4034
+ for (let r in Io[n]) t[n][r] = e + Io[n][r];
4035
4035
  }
4036
4036
  return t;
4037
4037
  }
4038
- var Io = {
4038
+ var Ro = {
4039
4039
  get QUALITY_PRESETS() {
4040
- return Fo();
4040
+ return Lo();
4041
4041
  },
4042
4042
  TILE_SIZE: 512,
4043
4043
  TILE_OVERLAP: 16,
@@ -4048,17 +4048,17 @@ var Io = {
4048
4048
  }],
4049
4049
  graphOptimizationLevel: "all"
4050
4050
  }
4051
- }, Lo = class extends or {
4051
+ }, zo = class extends cr {
4052
4052
  constructor(e, t, n = {}) {
4053
4053
  if (super(), !e || !t) throw Error("AIUpscaler requires output canvas and renderer");
4054
- 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 || (() => Yn), this.getSaturation = n.getSaturation || (() => 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 || Io.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
4054
+ 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 || (() => Zn), this.getSaturation = n.getSaturation || (() => 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 || Ro.TILE_SIZE, this._tileSizeOverride = !!n.tileSize, this.state = {
4055
4055
  isUpscaling: !1,
4056
4056
  isLoading: !1,
4057
4057
  abortController: null
4058
4058
  }, this._worker = null, this._currentModelUrl = null, this._tileId = 0, this._pendingWorkerHandlers = /* @__PURE__ */ new Set(), this._upscaledAlpha = null, this._upscaledAlphaWidth = 0, this._backupCanvas = null, this._baseWidth = e.width, this._baseHeight = e.height, this._toneMapper = null;
4059
4059
  }
4060
4060
  async _ensureSession() {
4061
- let e = Io.QUALITY_PRESETS[this.quality];
4061
+ let e = Ro.QUALITY_PRESETS[this.quality];
4062
4062
  if (!e) throw Error(`Unknown quality preset: ${this.quality}`);
4063
4063
  let t = e[this.scaleFactor];
4064
4064
  if (!t) throw Error(`No model for ${this.quality}/${this.scaleFactor}x`);
@@ -4068,14 +4068,14 @@ var Io = {
4068
4068
  message: `Loading ${this.scaleFactor}x upscale model...`
4069
4069
  });
4070
4070
  try {
4071
- this._worker ||= new No(), await new Promise((e, n) => {
4071
+ this._worker ||= new Fo(), await new Promise((e, n) => {
4072
4072
  let r = (t) => {
4073
4073
  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)));
4074
- }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = at();
4074
+ }, { ortRuntimeUrl: i, ortWasmPaths: a, cacheNamespace: o, storage: s } = ot();
4075
4075
  this._worker.addEventListener("message", r), this._worker.postMessage({
4076
4076
  type: "load",
4077
4077
  url: t,
4078
- sessionOptions: Io.SESSION_OPTIONS,
4078
+ sessionOptions: Ro.SESSION_OPTIONS,
4079
4079
  ortRuntimeUrl: i,
4080
4080
  ortWasmPaths: a,
4081
4081
  cacheNamespace: o,
@@ -4150,7 +4150,7 @@ var Io = {
4150
4150
  alpha: !0
4151
4151
  });
4152
4152
  this._cacheUpscaledAlpha(t, n * i, r * i);
4153
- let o = Io.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
4153
+ let o = Ro.TILE_OVERLAP, s = this.tileSize, c = s - o * 2, l = Math.ceil(n / c), u = Math.ceil(r / c), d = l * u, f = 0;
4154
4154
  for (let o = 0; o < u; o++) for (let u = 0; u < l; u++) {
4155
4155
  if (e.aborted) throw new DOMException("Aborted", "AbortError");
4156
4156
  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);
@@ -4191,13 +4191,13 @@ var Io = {
4191
4191
  let e = this.getGPUTextures();
4192
4192
  if (!e?.color) throw Error("No GPU color texture available for HDR capture");
4193
4193
  let t = e.color, { width: n, height: r } = t;
4194
- this._toneMapper ??= new xt(this.renderer.backend.device, "aiupscaler-tonemap", {
4194
+ this._toneMapper ??= new Dt(this.renderer.backend.device, "aiupscaler-tonemap", {
4195
4195
  input: "texture",
4196
4196
  output: "planar"
4197
4197
  }), this._toneMapper.ensureSize(n, r);
4198
4198
  let i = await this._toneMapper.toPlanar(t, {
4199
4199
  exposure: this.getExposure(),
4200
- toneMapping: this.getToneMapping() ?? Yn,
4200
+ toneMapping: this.getToneMapping() ?? Zn,
4201
4201
  saturation: this.getSaturation()
4202
4202
  });
4203
4203
  return this._toneMapper.release(), {
@@ -4292,7 +4292,7 @@ var Io = {
4292
4292
  this.hdr = !!e;
4293
4293
  }
4294
4294
  setQuality(e) {
4295
- if (!Io.QUALITY_PRESETS[e]) {
4295
+ if (!Ro.QUALITY_PRESETS[e]) {
4296
4296
  console.warn(`AIUpscaler: Invalid quality "${e}", must be fast/balanced/quality`);
4297
4297
  return;
4298
4298
  }
@@ -4315,9 +4315,9 @@ var Io = {
4315
4315
  async dispose() {
4316
4316
  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");
4317
4317
  }
4318
- }, Ro = Ke("neural"), zo = 120, Bo = 2, Vo = 1, Ho = 0, Uo = 300, Wo = 5, Go = 3, Ko = 3, qo = 16, Jo = (e) => Math.max(0, 1 - e / qo), Yo = class extends or {
4318
+ }, Bo = qe("neural"), Vo = 120, Ho = 2, Uo = 1, Wo = 0, Go = 300, Ko = 5, qo = 3, Jo = 3, Yo = 16, Xo = (e) => Math.max(0, 1 - e / Yo), Zo = class extends cr {
4319
4319
  constructor({ renderer: e, mainCanvas: t, stages: n, pipeline: r, getExposure: i, getSaturation: a, issues: o = null }) {
4320
- super(), this.renderer = e, this._issues = o, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, 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._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 pr(), this._historyCamera = {
4320
+ super(), this.renderer = e, this._issues = o, this.mainCanvas = t, this.upscalerCanvas = this._createUpscalerCanvas(t), this.pipeline = r, this._stages = n, this._getExposure = i, this._getSaturation = a, 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._finalQuality = Yr.oidnQuality, this.finalDenoise = Yr.enableOIDN, this.continuousDenoise = Yr.continuousDenoise, this.continuousDenoiseInterval = Yr.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 = Yr.oidnTemporalHistory, this._history = null, this._historyDirty = !0, this._knownResetCount = 0, this._seenTracedFrames = 0, this._viewProj = new hr(), this._historyCamera = {
4321
4321
  world: null,
4322
4322
  projInv: null,
4323
4323
  viewProj: null,
@@ -4326,7 +4326,7 @@ var Io = {
4326
4326
  count: 0,
4327
4327
  leaves: new Uint32Array(),
4328
4328
  toPrev: new Float32Array()
4329
- }, this._matA = new pr(), this._matB = new pr(), this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._pendingCloseDenoise = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._denoiserErrorHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
4329
+ }, this._matA = new hr(), this._matB = new hr(), this._lastRenderWidth = 0, this._lastRenderHeight = 0, this._pendingStartUpscaler = null, this._pendingCloseDenoise = null, this._denoiserStartHandler = null, this._denoiserEndHandler = null, this._denoiserTileHandler = null, this._denoiserErrorHandler = null, this._upscalerResChangedHandler = null, this._upscalerStartHandler = null, this._upscalerProgressHandler = null, this._upscalerEndHandler = null;
4330
4330
  }
4331
4331
  _createUpscalerCanvas(e) {
4332
4332
  let t = e.parentNode;
@@ -4338,7 +4338,7 @@ var Io = {
4338
4338
  return (this.denoiser?.gpuBytes?.() ?? 0) + (this._history?.gpuBytes?.() ?? 0);
4339
4339
  }
4340
4340
  _recordNoOverlayCanvas(e) {
4341
- this._issues?.record(Ze.DENOISER_UNAVAILABLE, `the ${e} pass needs the render canvas to be in a document, and it is not — skipped`, { pass: e });
4341
+ this._issues?.record(Qe.DENOISER_UNAVAILABLE, `the ${e} pass needs the render canvas to be in a document, and it is not — skipped`, { pass: e });
4342
4342
  }
4343
4343
  setRenderSize(e, t) {
4344
4344
  this._lastRenderWidth = e, this._lastRenderHeight = t, this._cadenceDowngraded = !1, this._holdWhileMoving = null, this._movingDenoiseMs.length = 0, this._movingHopeless = !1, this._historyDirty = !0, this.denoiser?.abort(), this._unpublishOutput(), this.denoiser?.setSize(e, t), this.upscalerCanvas && (this.upscalerCanvas.width !== e || this.upscalerCanvas.height !== t) && (this.upscalerCanvas.width = e, this.upscalerCanvas.height = t), this.upscaler?.setBaseSize(e, t), this._syncGBufferStages();
@@ -4348,9 +4348,9 @@ var Io = {
4348
4348
  }
4349
4349
  setupDenoiser() {
4350
4350
  let e = this._stages.pathTracer;
4351
- this.denoiser = new mo(this.renderer, {
4352
- enableOIDN: qr.enableOIDN,
4353
- oidnQuality: qr.oidnQuality,
4351
+ this.denoiser = new go(this.renderer, {
4352
+ enableOIDN: Yr.enableOIDN,
4353
+ oidnQuality: Yr.oidnQuality,
4354
4354
  backendParams: () => ({
4355
4355
  device: this.renderer.backend.device,
4356
4356
  adapterInfo: null
@@ -4367,11 +4367,11 @@ var Io = {
4367
4367
  };
4368
4368
  }
4369
4369
  }), this._syncOIDNInUse(), this._denoiserStartHandler = (e) => this.dispatchEvent({
4370
- type: j.DENOISING_START,
4370
+ type: A.DENOISING_START,
4371
4371
  continuous: !!e.continuous
4372
4372
  }), this._denoiserEndHandler = (e) => {
4373
4373
  this.denoiser?.hasOutput && this._publishOutput(), this.dispatchEvent({
4374
- type: j.DENOISING_END,
4374
+ type: A.DENOISING_END,
4375
4375
  continuous: !!e.continuous
4376
4376
  });
4377
4377
  }, this._denoiserTileHandler = (e) => {
@@ -4379,7 +4379,7 @@ var Io = {
4379
4379
  this._publishOutput();
4380
4380
  let t = this.pipeline?.context;
4381
4381
  this._stages.compositor && t && this._stages.compositor.render(t);
4382
- }, this._denoiserErrorHandler = (e) => e.url && this._issues?.record(Ze.ASSET_UNREACHABLE, `denoiser weights "${e.url}" could not be loaded — the render is not denoised`, {
4382
+ }, this._denoiserErrorHandler = (e) => e.url && this._issues?.record(Qe.ASSET_UNREACHABLE, `denoiser weights "${e.url}" could not be loaded — the render is not denoised`, {
4383
4383
  url: e.url,
4384
4384
  asset: "oidn-weights",
4385
4385
  cause: String(e.error?.message ?? e.error)
@@ -4388,9 +4388,9 @@ var Io = {
4388
4388
  setupUpscaler() {
4389
4389
  if (!this.upscalerCanvas) return;
4390
4390
  let e = this._stages.pathTracer;
4391
- this.upscaler = new Lo(this.upscalerCanvas, this.renderer, {
4392
- scaleFactor: qr.upscalerScale || 2,
4393
- quality: qr.upscalerQuality || "fast",
4391
+ this.upscaler = new zo(this.upscalerCanvas, this.renderer, {
4392
+ scaleFactor: Yr.upscalerScale || 2,
4393
+ quality: Yr.upscalerQuality || "fast",
4394
4394
  getSourceCanvas: () => this.renderer.domElement,
4395
4395
  refreshInput: () => {
4396
4396
  let e = this.pipeline?.context;
@@ -4404,14 +4404,14 @@ var Io = {
4404
4404
  getExposure: () => this._getEffectiveExposure(),
4405
4405
  getToneMapping: () => this._getToneMapping(),
4406
4406
  getSaturation: () => this._getSaturation()
4407
- }), this.upscaler.enabled = qr.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4408
- type: j.RESOLUTION_CHANGED,
4407
+ }), this.upscaler.enabled = Yr.enableUpscaler || !1, this._upscalerResChangedHandler = (e) => this.dispatchEvent({
4408
+ type: A.RESOLUTION_CHANGED,
4409
4409
  width: e.width,
4410
4410
  height: e.height
4411
- }), this._upscalerStartHandler = () => this.dispatchEvent({ type: j.UPSCALING_START }), this._upscalerProgressHandler = (e) => this.dispatchEvent({
4412
- type: j.UPSCALING_PROGRESS,
4411
+ }), this._upscalerStartHandler = () => this.dispatchEvent({ type: A.UPSCALING_START }), this._upscalerProgressHandler = (e) => this.dispatchEvent({
4412
+ type: A.UPSCALING_PROGRESS,
4413
4413
  progress: e.progress
4414
- }), this._upscalerEndHandler = () => this.dispatchEvent({ type: j.UPSCALING_END }), this.upscaler.addEventListener("resolution_changed", this._upscalerResChangedHandler), this.upscaler.addEventListener("start", this._upscalerStartHandler), this.upscaler.addEventListener("progress", this._upscalerProgressHandler), this.upscaler.addEventListener("end", this._upscalerEndHandler);
4414
+ }), this._upscalerEndHandler = () => this.dispatchEvent({ type: A.UPSCALING_END }), this.upscaler.addEventListener("resolution_changed", this._upscalerResChangedHandler), this.upscaler.addEventListener("start", this._upscalerStartHandler), this.upscaler.addEventListener("progress", this._upscalerProgressHandler), this.upscaler.addEventListener("end", this._upscalerEndHandler);
4415
4415
  }
4416
4416
  get denoiserStrategy() {
4417
4417
  return this.continuousDenoise ? "oidn" : this._stages.asvgf?.enabled ? "asvgf" : this._stages.nrd?.enabled ? "nrd" : this._stages.edgeFilter?.enabled ? "edgeaware" : "none";
@@ -4464,8 +4464,8 @@ var Io = {
4464
4464
  get holdsWhileMoving() {
4465
4465
  if (!this._stages.pathTracer?.viewIsChanging || !this.continuousDenoise || this._cadenceSuspended || !this.denoiser?.enabled || this._movingHopeless) return !1;
4466
4466
  let e = this.movingCostMs, t = this._movingDenoiseMs.length;
4467
- e > Uo * Go && (this._movingHopeless = !0, this._syncGBufferStages());
4468
- let n = !this._movingHopeless && (t < 2 || e <= Uo);
4467
+ e > Go * qo && (this._movingHopeless = !0, this._syncGBufferStages());
4468
+ let n = !this._movingHopeless && (t < 2 || e <= Go);
4469
4469
  return this._holdWhileMoving = (this._holdWhileMoving === null || this._holdWhileMoving) && n, this._holdWhileMoving;
4470
4470
  }
4471
4471
  skipsTrace() {
@@ -4482,7 +4482,7 @@ var Io = {
4482
4482
  this.pipeline?.context?.removeTexture("oidn:output"), this.denoiser?.invalidateOutput();
4483
4483
  }
4484
4484
  _checkHeldFrameHealthy() {
4485
- !this.denoiser?.hasOutput || this._failedRefreshes < Ko || this._unpublishOutput();
4485
+ !this.denoiser?.hasOutput || this._failedRefreshes < Jo || this._unpublishOutput();
4486
4486
  }
4487
4487
  tickContinuousDenoise(e) {
4488
4488
  let t = this.denoiser;
@@ -4492,12 +4492,12 @@ var Io = {
4492
4492
  if (!n) this._holdWhileMoving = null, this._movingDenoiseMs.length = 0;
4493
4493
  else if (!this.holdsWhileMoving) return !1;
4494
4494
  if (t.state.isDenoising || t.state.isLoading || !n && e <= this._lastCadenceSamples) return !1;
4495
- let r = performance.now(), i = n ? Ho : this._lastCadenceSamples === 0 ? Vo : Bo, a = Math.max(this.continuousDenoiseInterval, t.lastDenoiseMs * i);
4495
+ let r = performance.now(), i = n ? Wo : this._lastCadenceSamples === 0 ? Uo : Ho, a = Math.max(this.continuousDenoiseInterval, t.lastDenoiseMs * i);
4496
4496
  if (r - this._lastCadenceAt < a) return !1;
4497
- this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs > zo && (this._cadenceDowngraded = !0);
4497
+ this._lastCadenceAt = r, this._lastCadenceSamples = e, t.lastDenoiseMs > Vo && (this._cadenceDowngraded = !0);
4498
4498
  let o = this._cadenceDowngraded ? this.previewQuality() : this._finalQuality;
4499
4499
  return t.quality !== o && t.updateQuality(o), t.start({ continuous: !0 }).then((e) => {
4500
- this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length > Wo && this._movingDenoiseMs.shift());
4500
+ this._failedRefreshes = e ? 0 : this._failedRefreshes + 1, !(!e || !n) && (this._movingDenoiseMs.push(t.lastDenoiseMs), this._movingDenoiseMs.length > Ko && this._movingDenoiseMs.shift());
4501
4501
  }), !0;
4502
4502
  }
4503
4503
  previewQuality() {
@@ -4524,7 +4524,7 @@ var Io = {
4524
4524
  }
4525
4525
  get historyActive() {
4526
4526
  let e = this._stages.pathTracer;
4527
- return this.historyWanted && !this._cadenceSuspended && !!this._stages.normalDepth?.enabled && e?.uniforms?.get("cameraProjection")?.value !== he.equirectangular && !(e?.visMode?.value > 0);
4527
+ return this.historyWanted && !this._cadenceSuspended && !!this._stages.normalDepth?.enabled && e?.uniforms?.get("cameraProjection")?.value !== Ae.equirectangular && !(e?.visMode?.value > 0);
4528
4528
  }
4529
4529
  beforeReset({ keepHistory: e = !1 } = {}) {
4530
4530
  let t = this._stages.pathTracer;
@@ -4539,7 +4539,7 @@ var Io = {
4539
4539
  r && (this._ensureHistory().merge(r, t.frameCount, this._historyCameraNow(), {
4540
4540
  commit: !0,
4541
4541
  keepHistory: !this._historyDirty && !n,
4542
- historyScale: Jo(t.frameCount)
4542
+ historyScale: Xo(t.frameCount)
4543
4543
  }), this._historyDirty = !1);
4544
4544
  }
4545
4545
  afterReset() {
@@ -4582,9 +4582,9 @@ var Io = {
4582
4582
  let e = this._stages.pathTracer, t = this._history;
4583
4583
  if (!t?.valid || this._historyDirty || !this.historyActive || e.isComplete || e.resetCount !== this._knownResetCount || t.width !== this._lastRenderWidth || t.height !== this._lastRenderHeight) return null;
4584
4584
  if (e.frameCount <= 1) return t.textures;
4585
- if (e.frameCount >= qo) return null;
4585
+ if (e.frameCount >= Yo) return null;
4586
4586
  let n = this._historyInputs();
4587
- return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale: Jo(e.frameCount) }) : null;
4587
+ return n ? t.merge(n, e.frameCount, this._historyCameraNow(), { historyScale: Xo(e.frameCount) }) : null;
4588
4588
  }
4589
4589
  _historyInputs() {
4590
4590
  let e = this._stages.pathTracer, t = this.pipeline?.context, n = this.renderer?.backend;
@@ -4606,10 +4606,10 @@ var Io = {
4606
4606
  let e = this._stages.pathTracer;
4607
4607
  this._viewProj.multiplyMatrices(e.cameraProjectionMatrix.value, e.cameraViewMatrix.value);
4608
4608
  let t = this._historyCamera;
4609
- 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 === he.orthographic, t;
4609
+ 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 === Ae.orthographic, t;
4610
4610
  }
4611
4611
  _ensureHistory() {
4612
- return this._history ??= new Ao(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
4612
+ return this._history ??= new Mo(this.renderer.backend.device), this._history.settings.cleanAux = !!this.denoiser?.expectsCleanAux(this._finalQuality), this._history;
4613
4613
  }
4614
4614
  _releaseHistory() {
4615
4615
  this._history?.dispose(), this._history = null, this._historyDirty = !0, this._movedPlacements.clear();
@@ -4621,7 +4621,7 @@ var Io = {
4621
4621
  _restoreRenderDisplay() {
4622
4622
  let e = this.upscalerCanvas && this.upscalerCanvas.style.display !== "none";
4623
4623
  return this.upscalerCanvas && (this.upscalerCanvas.style.display = "none"), this.mainCanvas && (this.mainCanvas.style.opacity = "1"), e && this._lastRenderWidth && this._lastRenderHeight && this.dispatchEvent({
4624
- type: j.RESOLUTION_CHANGED,
4624
+ type: A.RESOLUTION_CHANGED,
4625
4625
  width: this._lastRenderWidth,
4626
4626
  height: this._lastRenderHeight
4627
4627
  }), !!e;
@@ -4646,15 +4646,15 @@ var Io = {
4646
4646
  return;
4647
4647
  }
4648
4648
  if (!this.pipeline?.context?.getTexture("oidn:output")) {
4649
- Ro.warn("neural pass skipped: no denoised picture — it needs OIDN");
4649
+ Bo.warn("neural pass skipped: no denoised picture — it needs OIDN");
4650
4650
  return;
4651
4651
  }
4652
- this._neuralPostBusy = !0, this.dispatchEvent({ type: j.UPSCALING_START });
4652
+ this._neuralPostBusy = !0, this.dispatchEvent({ type: A.UPSCALING_START });
4653
4653
  try {
4654
- let r = await import("./NeuralSuperRes-B-rNIU_R.js").then((e) => e.t);
4654
+ let r = await import("./NeuralSuperRes-B7E3_M0t.js").then((e) => e.t);
4655
4655
  this._superResModule = r;
4656
- let i = n ? await import("./NeuralRetouch-Doo3a4vY.js").then((e) => e.t) : null, a = this.denoiser?._outTexSize, o = (a?.width ?? 0) * (a?.height ?? 0), s = n && o <= i.RETOUCH_MAX_PIXELS;
4657
- if (n && !s && (Ro.warn(`Neural rendering skipped: the render is ${(o / 1e6).toFixed(1)} MP, above the ${(i.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !s) return;
4656
+ let i = n ? await import("./NeuralRetouch-Cr-otSW8.js").then((e) => e.t) : null, a = this.denoiser?._outTexSize, o = (a?.width ?? 0) * (a?.height ?? 0), s = n && o <= i.RETOUCH_MAX_PIXELS;
4657
+ if (n && !s && (Bo.warn(`Neural rendering skipped: the render is ${(o / 1e6).toFixed(1)} MP, above the ${(i.RETOUCH_MAX_PIXELS / 1e6).toFixed(1)} MP the pass survives.` + (t ? " The upscale still ran." : "")), this._releaseNeuralRetouch()), !t && !s) return;
4658
4658
  let c = {
4659
4659
  exposure: this._getEffectiveExposure(),
4660
4660
  toneMapping: this._getToneMapping(),
@@ -4684,14 +4684,14 @@ var Io = {
4684
4684
  return;
4685
4685
  }
4686
4686
  this.mainCanvas && (this.mainCanvas.style.opacity = "0"), this.dispatchEvent({
4687
- type: j.RESOLUTION_CHANGED,
4687
+ type: A.RESOLUTION_CHANGED,
4688
4688
  width: u.width,
4689
4689
  height: u.height
4690
4690
  });
4691
4691
  } catch (e) {
4692
- Ro.warn("neural pass failed", e);
4692
+ Bo.warn("neural pass failed", e);
4693
4693
  } finally {
4694
- this._neuralPostBusy = !1, this.dispatchEvent({ type: j.UPSCALING_END });
4694
+ this._neuralPostBusy = !1, this.dispatchEvent({ type: A.UPSCALING_END });
4695
4695
  }
4696
4696
  }
4697
4697
  }
@@ -4842,20 +4842,20 @@ var Io = {
4842
4842
  ].forEach((t) => e.removeTexture(t));
4843
4843
  }
4844
4844
  _applyNRDPreset(e) {
4845
- let t = Gr[e];
4845
+ let t = qr[e];
4846
4846
  if (!t) return;
4847
4847
  let n = {};
4848
- for (let e of Wr) n[e] = Ur[e];
4848
+ for (let e of Kr) n[e] = Gr[e];
4849
4849
  this._stages.nrd?.updateParameters({
4850
4850
  ...n,
4851
4851
  ...t
4852
4852
  });
4853
4853
  }
4854
4854
  _applyASVGFPreset(e) {
4855
- let t = Br[e];
4855
+ let t = Hr[e];
4856
4856
  t && (this._stages.asvgf?.updateParameters(t), this._stages.bilateralFilter?.updateParameters(t), this._stages.variance && t.varianceBoost !== void 0 && (this._stages.variance.varianceBoost.value = t.varianceBoost));
4857
4857
  }
4858
- }, Xo = class {
4858
+ }, Qo = class {
4859
4859
  constructor() {
4860
4860
  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;
4861
4861
  }
@@ -4879,18 +4879,18 @@ var Io = {
4879
4879
  dispose() {
4880
4880
  this.visible = !1;
4881
4881
  }
4882
- }, Zo = class {
4882
+ }, $o = class {
4883
4883
  constructor(e, t) {
4884
4884
  this.layer = "scene", this._enabled = !0, this._scene = e, this._camera = t, this._build([]);
4885
4885
  }
4886
4886
  _build(e) {
4887
- this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode = Fr(this._scene, this._camera, {
4887
+ this._orthographic = this._camera.isOrthographicCamera === !0, this._outlineNode = Lr(this._scene, this._camera, {
4888
4888
  selectedObjects: e,
4889
- edgeThickness: K(1),
4890
- edgeGlow: K(0)
4889
+ edgeThickness: G(1),
4890
+ edgeGlow: G(0)
4891
4891
  });
4892
- let t = K(3), n = K(new tr(16777215)), r = K(new tr(1640965)), { visibleEdge: i, hiddenEdge: a } = this._outlineNode, o = i.mul(n).add(a.mul(r)).mul(t), s = o.r.max(o.g).max(o.b).clamp(0, 1);
4893
- this._material = new _n(), this._material.colorNode = J(o, s), this._material.transparent = !0, this._material.blending = rr, this._material.blendEquation = Xn, this._material.blendSrc = vr, this._material.blendDst = vr, this._material.blendEquationAlpha = Xn, this._material.blendSrcAlpha = vr, this._material.blendDstAlpha = vr, this._material.toneMapped = !1, this._material.depthTest = !1, this._material.depthWrite = !1, this._quad = new vn(this._material);
4892
+ let t = G(3), n = G(new rr(16777215)), r = G(new rr(1640965)), { visibleEdge: i, hiddenEdge: a } = this._outlineNode, o = i.mul(n).add(a.mul(r)).mul(t), s = o.r.max(o.g).max(o.b).clamp(0, 1);
4893
+ this._material = new bn(), this._material.colorNode = J(o, s), this._material.transparent = !0, this._material.blending = ar, this._material.blendEquation = Qn, this._material.blendSrc = br, this._material.blendDst = br, this._material.blendEquationAlpha = Qn, this._material.blendSrcAlpha = br, this._material.blendDstAlpha = br, this._material.toneMapped = !1, this._material.depthTest = !1, this._material.depthWrite = !1, this._quad = new xn(this._material);
4894
4894
  }
4895
4895
  setSelectedObjects(e) {
4896
4896
  this._outlineNode.selectedObjects = e;
@@ -4917,11 +4917,11 @@ var Io = {
4917
4917
  this._enabled = !1, this._outlineNode?.dispose(), this._material?.dispose(), this._quad = null;
4918
4918
  }
4919
4919
  };
4920
- function Qo(e = !1) {
4920
+ function es(e = !1) {
4921
4921
  let t = document.createElement("canvas");
4922
4922
  return t.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;" + (e ? "display:none;" : ""), t;
4923
4923
  }
4924
- function $o(e, t = Infinity) {
4924
+ function ts(e, t = Infinity) {
4925
4925
  let n = e?.getBoundingClientRect();
4926
4926
  if (!n || n.width === 0 || n.height === 0) return null;
4927
4927
  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);
@@ -4932,26 +4932,26 @@ function $o(e, t = Infinity) {
4932
4932
  }
4933
4933
  //#endregion
4934
4934
  //#region src/managers/helpers/ViewOverlayRenderer.js
4935
- var es = 4096, ts = class {
4935
+ var ns = 4096, rs = class {
4936
4936
  constructor() {
4937
- this.canvas = Qo(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
4937
+ this.canvas = es(!0), this._visible = !1, this.renderer = null, this._sizeSource = null;
4938
4938
  }
4939
4939
  async init({ device: e, sizeSource: t }) {
4940
4940
  this._sizeSource = t;
4941
- let n = e.onuncapturederror, r = new xn({
4941
+ let n = e.onuncapturederror, r = new wn({
4942
4942
  canvas: this.canvas,
4943
4943
  device: e,
4944
4944
  alpha: !0,
4945
4945
  antialias: (window.devicePixelRatio || 1) < 2
4946
4946
  });
4947
- return await r.init(), e.onuncapturederror = n, r.outputColorSpace = Tr, r.setPixelRatio(1), r.setClearColor(0, 0), r.autoClear = !1, this.renderer = r, this.syncSize(), this;
4947
+ return await r.init(), e.onuncapturederror = n, r.outputColorSpace = Dr, r.setPixelRatio(1), r.setClearColor(0, 0), r.autoClear = !1, this.renderer = r, this.syncSize(), this;
4948
4948
  }
4949
4949
  get isVisible() {
4950
4950
  return this._visible;
4951
4951
  }
4952
4952
  syncSize() {
4953
4953
  if (!this.renderer) return;
4954
- let e = $o(this._sizeSource, es);
4954
+ let e = ts(this._sizeSource, ns);
4955
4955
  !e || e.width === this.canvas.width && e.height === this.canvas.height || this.renderer.setSize(e.width, e.height, !1);
4956
4956
  }
4957
4957
  begin() {
@@ -4961,20 +4961,20 @@ var es = 4096, ts = class {
4961
4961
  this._visible !== e && (this._visible = e, this.canvas.style.display = e ? "" : "none");
4962
4962
  }
4963
4963
  dispose() {
4964
- Ie(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
4964
+ Pe(this.renderer), this.renderer = null, this.canvas.parentElement?.removeChild(this.canvas);
4965
4965
  }
4966
- }, ns = Ke("overlay"), rs = (e, t) => e.visible && e.layer === t && e.render, is = class {
4966
+ }, is = qe("overlay"), as = (e, t) => e.visible && e.layer === t && e.render, os = class {
4967
4967
  constructor(e) {
4968
- this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = Qo(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
4968
+ this.camera = e, this._helpers = /* @__PURE__ */ new Map(), this._hudCanvas = es(), this._hudCtx = this._hudCanvas.getContext("2d"), this._helperScene = null, this._viewOverlay = null;
4969
4969
  }
4970
4970
  async initViewRenderer({ device: e, sizeSource: t }) {
4971
4971
  if (!(!e || !t)) try {
4972
- this._viewOverlay = await new ts().init({
4972
+ this._viewOverlay = await new rs().init({
4973
4973
  device: e,
4974
4974
  sizeSource: t
4975
4975
  });
4976
4976
  } catch (e) {
4977
- ns.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
4977
+ is.error("overlay surface unavailable — light gizmos, transform gizmo and outlines are disabled", e), this._viewOverlay = null;
4978
4978
  }
4979
4979
  }
4980
4980
  gpuResources() {
@@ -4994,11 +4994,11 @@ var es = 4096, ts = class {
4994
4994
  }
4995
4995
  setupDefaultHelpers({ helperScene: e, meshScene: t, pipeline: n, denoisingManager: r, app: i, renderWidth: a, renderHeight: o }) {
4996
4996
  this.setHelperScene(e);
4997
- let s = new Xo();
4998
- this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(j.RESOLUTION_CHANGED, (e) => {
4997
+ let s = new Qo();
4998
+ this.register("tiles", s), s.setRenderSize(a || 1, o || 1), i.addEventListener(A.RESOLUTION_CHANGED, (e) => {
4999
4999
  s.setRenderSize(e.width, e.height);
5000
5000
  }), n.eventBus.on("pipeline:reset", () => s.hide()), this._wireDenoiserTileEvents(s, r);
5001
- let c = new Zo(t, this.camera);
5001
+ let c = new $o(t, this.camera);
5002
5002
  this.register("outline", c);
5003
5003
  }
5004
5004
  _wireDenoiserTileEvents(e, t) {
@@ -5010,7 +5010,7 @@ var es = 4096, ts = class {
5010
5010
  }));
5011
5011
  }
5012
5012
  register(e, t) {
5013
- this._helpers.has(e) && (ns.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
5013
+ this._helpers.has(e) && (is.warn(`helper "${e}" already registered — replacing.`), this._helpers.get(e).dispose?.()), this._helpers.set(e, t);
5014
5014
  }
5015
5015
  unregister(e) {
5016
5016
  let t = this._helpers.get(e);
@@ -5048,16 +5048,16 @@ var es = 4096, ts = class {
5048
5048
  }
5049
5049
  _renderSceneLayer(e) {
5050
5050
  this._helperScene?.render(e, this.camera);
5051
- for (let t of this._helpers.values()) rs(t, "scene") && t.render(e, this.camera);
5051
+ for (let t of this._helpers.values()) as(t, "scene") && t.render(e, this.camera);
5052
5052
  }
5053
5053
  _hasVisibleSceneOverlay() {
5054
5054
  if (this._helperScene?.isDrawing) return !0;
5055
- for (let e of this._helpers.values()) if (rs(e, "scene")) return !0;
5055
+ for (let e of this._helpers.values()) if (as(e, "scene")) return !0;
5056
5056
  return !1;
5057
5057
  }
5058
5058
  refreshHUD() {
5059
5059
  let e = this._hudCanvas, t = this._hudCtx, n = !1;
5060
- for (let e of this._helpers.values()) if (rs(e, "hud")) {
5060
+ for (let e of this._helpers.values()) if (as(e, "hud")) {
5061
5061
  n = !0;
5062
5062
  break;
5063
5063
  }
@@ -5066,10 +5066,10 @@ var es = 4096, ts = class {
5066
5066
  return;
5067
5067
  }
5068
5068
  e.style.display !== "" && (e.style.display = "");
5069
- let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? $o(e) : null;
5069
+ let r = e.clientWidth, i = e.clientHeight, a = r > 0 && i > 0 ? ts(e) : null;
5070
5070
  if (a) {
5071
5071
  (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);
5072
- for (let e of this._helpers.values()) rs(e, "hud") && e.render(t, r, i);
5072
+ for (let e of this._helpers.values()) as(e, "hud") && e.render(t, r, i);
5073
5073
  t.restore(), e.style.display !== "" && (e.style.display = "");
5074
5074
  }
5075
5075
  }
@@ -5080,7 +5080,7 @@ var es = 4096, ts = class {
5080
5080
  };
5081
5081
  //#endregion
5082
5082
  //#region src/managers/AnimationManager.js
5083
- function as(e, t) {
5083
+ function ss(e, t) {
5084
5084
  let n = [...e].filter((t) => {
5085
5085
  for (let n = t.parent; n; n = n.parent) if (e.has(n)) return !1;
5086
5086
  return !0;
@@ -5089,18 +5089,18 @@ function as(e, t) {
5089
5089
  for (let e of n) e.traverse?.(() => i++);
5090
5090
  return i + n.length / 2 < r ? n : null;
5091
5091
  }
5092
- var os = class extends or {
5092
+ var cs = class extends cr {
5093
5093
  constructor() {
5094
- super(), this.mixer = null, this.timer = new Or(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new $(), 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;
5094
+ super(), this.mixer = null, this.timer = new Ar(), this.actions = [], this.isPlaying = !1, this._scene = null, this._mixerRoot = null, this._meshes = null, this._meshTriRanges = null, this._meshPositions = null, this._tempVec = new $(), 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;
5095
5095
  }
5096
5096
  init(e, t, n, r) {
5097
5097
  if (this.dispose(), !r || r.length === 0) return;
5098
- this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new Zn(t);
5098
+ this._scene = e, this._mixerRoot = t, this._meshes = n, this.mixer = new $n(t);
5099
5099
  let i = r.map((e) => this.mixer.clipAction(e)), a = (e, t) => e.name === t || e.getObjectByName(t) !== void 0;
5100
5100
  !i.some((e) => e.getClip().tracks.some((e) => {
5101
5101
  let n = e.name.split(".")[0];
5102
5102
  return a(t, n);
5103
- })) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new Zn(e), this._mixerRoot = e, i = r.map((e) => this.mixer.clipAction(e))), this.actions = i, this._rigid = !n.some((e) => e?.isSkinnedMesh) && !r.some((e) => e.tracks.some((e) => e.name.includes("morphTargetInfluences"))), this._planClips(r), this.mixer.addEventListener("finished", () => {
5103
+ })) && t !== e && (console.log("[AnimationManager] Tracks did not resolve from model root, retrying with scene root"), this.mixer = new $n(e), this._mixerRoot = e, i = r.map((e) => this.mixer.clipAction(e))), this.actions = i, this._rigid = !n.some((e) => e?.isSkinnedMesh) && !r.some((e) => e.tracks.some((e) => e.name.includes("morphTargetInfluences"))), this._planClips(r), this.mixer.addEventListener("finished", () => {
5104
5104
  this.isPlaying = !1, this.timer.reset(), this.onFinished && this.onFinished();
5105
5105
  }), this._meshTriRanges = [], this._skinnedCache = [];
5106
5106
  let o = 0;
@@ -5124,7 +5124,7 @@ var os = class extends or {
5124
5124
  }), this._plans = e.map((e) => {
5125
5125
  let r = /* @__PURE__ */ new Set(), i = !1, a = !1;
5126
5126
  for (let o of e.tracks) {
5127
- let { nodeName: e, propertyName: s } = xr.parseTrackName(o.name), c = e === "" || e === "." ? t : n.get(e);
5127
+ let { nodeName: e, propertyName: s } = Cr.parseTrackName(o.name), c = e === "" || e === "." ? t : n.get(e);
5128
5128
  if (!c) {
5129
5129
  a = !0;
5130
5130
  continue;
@@ -5143,7 +5143,7 @@ var os = class extends or {
5143
5143
  visibility: i,
5144
5144
  cameras: [...s],
5145
5145
  nodes: a ? null : r,
5146
- roots: a ? null : as(r, t)
5146
+ roots: a ? null : ss(r, t)
5147
5147
  };
5148
5148
  }), this._allPlan = null, !this._rigid) return;
5149
5149
  this._slotOf = new Int32Array(this._meshes.length).fill(-1);
@@ -5162,7 +5162,7 @@ var os = class extends or {
5162
5162
  visibility: n,
5163
5163
  cameras: [...t],
5164
5164
  nodes: r,
5165
- roots: r ? as(r, this._mixerRoot) : null
5165
+ roots: r ? ss(r, this._mixerRoot) : null
5166
5166
  };
5167
5167
  }
5168
5168
  return this._allPlan;
@@ -5197,23 +5197,23 @@ var os = class extends or {
5197
5197
  if (!(!this.mixer || this.actions.length === 0)) {
5198
5198
  if (this.mixer.stopAllAction(), e === -1) for (let e of this.actions) e.play();
5199
5199
  else e >= 0 && e < this.actions.length && this.actions[e].play();
5200
- this._activeClip = e, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: j.ANIMATION_STARTED });
5200
+ this._activeClip = e, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: A.ANIMATION_STARTED });
5201
5201
  }
5202
5202
  }
5203
5203
  pause() {
5204
- this.mixer && (this.mixer.timeScale = 0, this.timer.reset(), this.isPlaying = !1, this.dispatchEvent({ type: j.ANIMATION_PAUSED }));
5204
+ this.mixer && (this.mixer.timeScale = 0, this.timer.reset(), this.isPlaying = !1, this.dispatchEvent({ type: A.ANIMATION_PAUSED }));
5205
5205
  }
5206
5206
  resume() {
5207
- this.mixer && (this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: j.ANIMATION_STARTED }));
5207
+ this.mixer && (this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !0, this.wakeCallback?.(), this.dispatchEvent({ type: A.ANIMATION_STARTED }));
5208
5208
  }
5209
5209
  stop() {
5210
- this.mixer && (this.mixer.stopAllAction(), this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !1, this._rigid && (this._mixerRoot.updateMatrixWorld(!0), this._applyRigidPose(-1)), this.dispatchEvent({ type: j.ANIMATION_STOPPED }));
5210
+ this.mixer && (this.mixer.stopAllAction(), this.mixer.timeScale = this._savedTimeScale || 1, this.timer.reset(), this.isPlaying = !1, this._rigid && (this._mixerRoot.updateMatrixWorld(!0), this._applyRigidPose(-1)), this.dispatchEvent({ type: A.ANIMATION_STOPPED }));
5211
5211
  }
5212
5212
  setSpeed(e) {
5213
5213
  this._savedTimeScale = e, this.mixer && this.isPlaying && (this.mixer.timeScale = e);
5214
5214
  }
5215
5215
  setLoop(e) {
5216
- let t = e ? dr : ur;
5216
+ let t = e ? pr : fr;
5217
5217
  for (let n of this.actions) n.setLoop(t), n.clampWhenFinished = !e;
5218
5218
  }
5219
5219
  seekTo(e, t = 0) {
@@ -5294,19 +5294,19 @@ var os = class extends or {
5294
5294
  dispose() {
5295
5295
  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;
5296
5296
  }
5297
- }, ss = new $(0, 0, -1), cs = (e) => {
5297
+ }, ls = new $(0, 0, -1), us = (e) => {
5298
5298
  for (; e.parent;) e = e.parent;
5299
5299
  return e.isScene ? e : null;
5300
- }, ls = class {
5300
+ }, ds = class {
5301
5301
  constructor({ camera: e, canvas: t, orbitControls: n, app: r }) {
5302
- this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Ir(e, t), this._gizmoScene = new Er(), 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 $(), 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);
5302
+ this._app = r, this._orbitControls = n, this._camera = e, this._controls = new Rr(e, t), this._gizmoScene = new Or(), 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 $(), 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);
5303
5303
  }
5304
5304
  setMeshData(e) {
5305
5305
  this._meshes = e;
5306
- for (let e of this._moved) cs(e) || this._moved.delete(e);
5306
+ for (let e of this._moved) us(e) || this._moved.delete(e);
5307
5307
  }
5308
5308
  get movedObjects() {
5309
- return [...this._moved].filter((e) => cs(e));
5309
+ return [...this._moved].filter((e) => us(e));
5310
5310
  }
5311
5311
  noteMoved(e) {
5312
5312
  e && !e.isLight && this._moved.add(e);
@@ -5319,7 +5319,7 @@ var os = class extends or {
5319
5319
  }
5320
5320
  setMode(e) {
5321
5321
  this._controls.setMode(e), this._app?.dispatchEvent({
5322
- type: j.TRANSFORM_MODE_CHANGED,
5322
+ type: A.TRANSFORM_MODE_CHANGED,
5323
5323
  mode: e
5324
5324
  }), this._app?.refreshFrame();
5325
5325
  }
@@ -5341,7 +5341,7 @@ var os = class extends or {
5341
5341
  e.autoClear = !1, e.clearDepth(), e.setRenderTarget(null), e.render(this._gizmoScene, this._camera), e.autoClear = t;
5342
5342
  }
5343
5343
  _onDraggingChanged(e) {
5344
- this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: j.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: j.OBJECT_TRANSFORM_END }));
5344
+ this._isDragging = e.value, this._orbitControls && (this._orbitControls.enabled = !e.value), e.value ? this._app.dispatchEvent({ type: A.OBJECT_TRANSFORM_START }) : (this._attached?.isLight ? this._finalizeLightTransform() : this._recomputeAndRefit(), this._app.dispatchEvent({ type: A.OBJECT_TRANSFORM_END }));
5345
5345
  }
5346
5346
  _onObjectChange() {
5347
5347
  this._app.needsReset = !0, this._app.wake(), this._attached?.isLight && this._syncLightDuringDrag();
@@ -5367,7 +5367,7 @@ var os = class extends or {
5367
5367
  }
5368
5368
  _syncLightAim(e) {
5369
5369
  let t = this._tempForward.copy(e.target.position).sub(e.position), n = t.length();
5370
- n > 1e-4 ? (e.quaternion.setFromUnitVectors(ss, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
5370
+ n > 1e-4 ? (e.quaternion.setFromUnitVectors(ls, t.normalize()), this._lightTargetDistance = n) : this._lightTargetDistance = 1;
5371
5371
  }
5372
5372
  _recomputeAndRefit() {
5373
5373
  if (!this._meshes || this._refitInFlight || !this._attached) return;
@@ -5403,7 +5403,7 @@ var os = class extends or {
5403
5403
  dispose() {
5404
5404
  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;
5405
5405
  }
5406
- }, us = class {
5406
+ }, fs = class {
5407
5407
  constructor(e) {
5408
5408
  this.layer = "scene", this._transformManager = e, this._enabled = !0;
5409
5409
  }
@@ -5422,8 +5422,8 @@ var os = class extends or {
5422
5422
  dispose() {
5423
5423
  this._enabled = !1;
5424
5424
  }
5425
- }, ds = 1, fs = (e) => typeof e == "string" && /^https?:\/\//.test(e);
5426
- function ps(e, t) {
5425
+ }, ps = 1, ms = (e) => typeof e == "string" && /^https?:\/\//.test(e);
5426
+ function hs(e, t) {
5427
5427
  let n = [];
5428
5428
  for (; e && e !== t;) {
5429
5429
  let t = e.parent;
@@ -5432,12 +5432,12 @@ function ps(e, t) {
5432
5432
  }
5433
5433
  return e === t ? n : null;
5434
5434
  }
5435
- function ms(e, t) {
5435
+ function gs(e, t) {
5436
5436
  let n = e;
5437
5437
  for (let e of t) if (n = n?.children[e], !n) return null;
5438
5438
  return n;
5439
5439
  }
5440
- function hs(e) {
5440
+ function _s(e) {
5441
5441
  return {
5442
5442
  key: e.assetLoader?.sceneSourceKey ?? null,
5443
5443
  name: e.sceneModel?.name ?? null,
@@ -5445,7 +5445,7 @@ function hs(e) {
5445
5445
  materials: e.stages.pathTracer?.materialData.materialCount ?? 0
5446
5446
  };
5447
5447
  }
5448
- function gs(e) {
5448
+ function vs(e) {
5449
5449
  let t = /* @__PURE__ */ new Map();
5450
5450
  for (let n of e.sceneMeshes) {
5451
5451
  let e = n.userData?.materialIndex;
@@ -5453,7 +5453,7 @@ function gs(e) {
5453
5453
  }
5454
5454
  return t;
5455
5455
  }
5456
- function _s(e) {
5456
+ function ys(e) {
5457
5457
  if (!e) return null;
5458
5458
  let t = e.status(), n = t.activeView, r = t.config?.id ?? n?.configId ?? null;
5459
5459
  return {
@@ -5468,15 +5468,15 @@ function _s(e) {
5468
5468
  context: t.context ?? null
5469
5469
  };
5470
5470
  }
5471
- function vs(e) {
5472
- let t = e.meshScene, n = gs(e), r = [];
5471
+ function bs(e) {
5472
+ let t = e.meshScene, n = vs(e), r = [];
5473
5473
  return t.traverse((e) => {
5474
- e !== t && e.visible === !1 && r.push(ps(e, t));
5474
+ e !== t && e.visible === !1 && r.push(hs(e, t));
5475
5475
  }), {
5476
5476
  v: 1,
5477
5477
  engine: Ue,
5478
5478
  savedAt: Date.now(),
5479
- scene: hs(e),
5479
+ scene: _s(e),
5480
5480
  appended: t.children.filter((t) => t !== e.sceneModel && t.userData?.__rayzeeSceneObject).map((e) => ({
5481
5481
  name: e.userData.__rayzeeName ?? e.name,
5482
5482
  url: e.userData.__rayzeeSourceUrl ?? null,
@@ -5484,7 +5484,7 @@ function vs(e) {
5484
5484
  })),
5485
5485
  settings: e.settings.serialize(),
5486
5486
  environment: e.environmentManager?.serialize() ?? null,
5487
- color: _s(e.color),
5487
+ color: ys(e.color),
5488
5488
  lights: e.lightManager.serialize(),
5489
5489
  cameras: e.cameraManager.serialize(),
5490
5490
  timeline: e.timeline?.serialize() ?? null,
@@ -5494,7 +5494,7 @@ function vs(e) {
5494
5494
  })),
5495
5495
  hidden: r,
5496
5496
  moved: (e.transformManager?.movedObjects ?? []).map((e) => ({
5497
- path: ps(e, t),
5497
+ path: hs(e, t),
5498
5498
  name: e.name,
5499
5499
  position: e.position.toArray(),
5500
5500
  quaternion: e.quaternion.toArray(),
@@ -5502,15 +5502,15 @@ function vs(e) {
5502
5502
  })).filter((e) => e.path)
5503
5503
  };
5504
5504
  }
5505
- function ys(e, t, n) {
5505
+ function xs(e, t, n) {
5506
5506
  let r = e[t];
5507
5507
  r?.copy && (n?.isColor || n?.isVector2 || n?.isVector3) ? r.copy(n) : e[t] = n, e.needsUpdate = !0;
5508
5508
  }
5509
- async function bs(e, t, n, r) {
5509
+ async function Ss(e, t, n, r) {
5510
5510
  if (!t) return;
5511
5511
  let i = e.environmentManager;
5512
5512
  if (t.hdri && t.hdri !== i.hdriSource) {
5513
- let i = fs(t.hdri) ? t.hdri : await n({
5513
+ let i = ms(t.hdri) ? t.hdri : await n({
5514
5514
  kind: "environment",
5515
5515
  source: t.hdri
5516
5516
  });
@@ -5522,7 +5522,7 @@ async function bs(e, t, n, r) {
5522
5522
  }
5523
5523
  await i.restore(t);
5524
5524
  }
5525
- async function xs(e, t, n, r) {
5525
+ async function Cs(e, t, n, r) {
5526
5526
  let i = e.color;
5527
5527
  if (!t || !i) return;
5528
5528
  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;
@@ -5547,7 +5547,7 @@ async function xs(e, t, n, r) {
5547
5547
  r("color", e.message, { config: t.config?.id ?? null });
5548
5548
  }
5549
5549
  }
5550
- async function Ss(e, t, { resolve: n = async () => null } = {}) {
5550
+ async function ws(e, t, { resolve: n = async () => null } = {}) {
5551
5551
  if (t?.v !== 1) throw Error(`scene state version ${t?.v} is not 1`);
5552
5552
  let r = [], i = (e, t, n = {}) => r.push({
5553
5553
  section: e,
@@ -5568,11 +5568,11 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5568
5568
  i("appended", e.message, { name: n.name });
5569
5569
  }
5570
5570
  }
5571
- let a = hs(e), o = t.scene ?? {}, s = o.meshes === a.meshes && o.materials === a.materials;
5571
+ let a = _s(e), o = t.scene ?? {}, s = o.meshes === a.meshes && o.materials === a.materials;
5572
5572
  s || i("scene", "the loaded scene is not the one saved: objects and materials left as loaded", {
5573
5573
  saved: o,
5574
5574
  now: a
5575
- }), await bs(e, t.environment, n, i), await xs(e, t.color, n, i);
5575
+ }), await Ss(e, t.environment, n, i), await Cs(e, t.color, n, i);
5576
5576
  let c = e.settings.restore(t.settings);
5577
5577
  c.length && i("settings", "not settings in this engine", { keys: c });
5578
5578
  let l = e.lightManager.restore(t.lights);
@@ -5581,7 +5581,7 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5581
5581
  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 });
5582
5582
  }
5583
5583
  if (s) {
5584
- let n = gs(e);
5584
+ let n = vs(e);
5585
5585
  for (let r of t.materials ?? []) {
5586
5586
  let t = n.get(r.index);
5587
5587
  if (!t || (t.name ?? "") !== r.name) {
@@ -5592,17 +5592,17 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5592
5592
  continue;
5593
5593
  }
5594
5594
  for (let [n, i] of Object.entries(r.props)) {
5595
- let a = ye(i);
5596
- ys(t, n, a), e.setMaterialProperty(r.index, n, a);
5595
+ let a = xe(i);
5596
+ xs(t, n, a), e.setMaterialProperty(r.index, n, a);
5597
5597
  }
5598
5598
  }
5599
- let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) => ms(r, e)).filter(Boolean));
5599
+ let r = e.meshScene, a = new Set((t.hidden ?? []).map((e) => gs(r, e)).filter(Boolean));
5600
5600
  r.traverse((e) => {
5601
5601
  e !== r && !e.isLight && (e.visible = !a.has(e));
5602
5602
  }), e.updateAllMeshVisibility();
5603
5603
  let o = [];
5604
5604
  for (let n of t.moved ?? []) {
5605
- let t = ms(r, n.path);
5605
+ let t = gs(r, n.path);
5606
5606
  if (!t || t.name !== n.name) {
5607
5607
  i("moved", "no such object", { name: n.name });
5608
5608
  continue;
@@ -5624,24 +5624,24 @@ async function Ss(e, t, { resolve: n = async () => null } = {}) {
5624
5624
  }
5625
5625
  //#endregion
5626
5626
  //#region src/PathTracerApp.js
5627
- var Cs = Ke("engine"), ws = class extends te {
5627
+ var Ts = qe("engine"), Es = class extends te {
5628
5628
  constructor(e, t = {}) {
5629
- super(e, t), this.setColorManagement(Xt), this.setStorageOpener(sn), this.settings.define("interactionRenderScale", {
5629
+ super(e, t), this.setColorManagement($t), this.setStorageOpener(un), this.settings.define("interactionRenderScale", {
5630
5630
  default: .5,
5631
5631
  apply: () => {
5632
5632
  this.stages?.pathTracer?.interactionMode && this._requestRenderScale(this._interactionRenderScale());
5633
5633
  },
5634
5634
  reset: !1
5635
- }), 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 os();
5635
+ }), 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 cs();
5636
5636
  }
5637
5637
  _createCamera() {
5638
- return this.cameraManager = new ka(this.canvas), this.timeline = new Fa({
5638
+ return this.cameraManager = new ja(this.canvas), this.timeline = new La({
5639
5639
  cameraManager: this.cameraManager,
5640
5640
  onReset: () => this.reset()
5641
5641
  }), this.cameraManager.camera;
5642
5642
  }
5643
5643
  _initAssetPipeline() {
5644
- super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Tt), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-CFcggGqi.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), wt);
5644
+ super._initAssetPipeline(), this.assetLoader.controls = this.cameraManager.controls, this.assetLoader.registerFormat(...Ot), this.assetLoader.setArchiveImporterLoader(() => import("./ArchiveImporter-D_x863yu.js").then((e) => e.r).then((e) => new e.ArchiveImporter(this.assetLoader)), Tt);
5645
5645
  let e = () => {
5646
5646
  this.needsReset = !0, this.stages.pathTracer?.enterInteractionMode(), this.wake();
5647
5647
  };
@@ -5649,10 +5649,10 @@ var Cs = Ke("engine"), ws = class extends te {
5649
5649
  }
5650
5650
  _createExtraStages() {
5651
5651
  let { renderer: e, stages: t } = this;
5652
- return t.normalDepth = new Jr(e, { pathTracer: t.pathTracer }), t.motionVector = new Yr(e, this.camera, { pathTracer: t.pathTracer }), t.asvgf = new Qr(e, { enabled: !1 }), t.nrd = new Ii(e, {
5652
+ return t.normalDepth = new Xr(e, { pathTracer: t.pathTracer }), t.motionVector = new Zr(e, this.camera, { pathTracer: t.pathTracer }), t.asvgf = new ei(e, { enabled: !1 }), t.nrd = new Ri(e, {
5653
5653
  enabled: !1,
5654
5654
  pathTracer: t.pathTracer
5655
- }), t.variance = new zi(e, { enabled: !1 }), t.bilateralFilter = new Vi(e, { enabled: !1 }), t.edgeFilter = new qi(e, { enabled: !1 }), t.autoExposure = new ta(e, { enabled: Ji.autoExposure }), [
5655
+ }), t.variance = new Vi(e, { enabled: !1 }), t.bilateralFilter = new Ui(e, { enabled: !1 }), t.edgeFilter = new Yi(e, { enabled: !1 }), t.autoExposure = new ra(e, { enabled: Xi.autoExposure }), [
5656
5656
  t.normalDepth,
5657
5657
  t.motionVector,
5658
5658
  t.nrd,
@@ -5667,25 +5667,25 @@ var Cs = Ke("engine"), ws = class extends te {
5667
5667
  super._initPipeline(), this.pipeline.eventBus.on("pathtracer:interactionStart", () => this._requestRenderScale(this._interactionRenderScale())), this.pipeline.eventBus.on("pathtracer:interactionEnd", () => this._applyRenderScale(1));
5668
5668
  }
5669
5669
  async _initManagers() {
5670
- await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-DYffGJ3O.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 oa({
5670
+ await super._initManagers(), this.environmentManager.setProceduralSkyLoader(() => import("./PhysicalSky-Dq5VSiCQ.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 ca({
5671
5671
  scene: this.meshScene,
5672
5672
  camera: this.camera,
5673
5673
  canvas: this.canvas,
5674
5674
  assetLoader: this.assetLoader,
5675
5675
  pathTracer: null,
5676
5676
  floorPlane: this.assetLoader.floorPlane
5677
- }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new Ia(this.stages.pathTracer, {
5677
+ }), this.interactionManager.wireAppEvents(this), this.cameraManager.setInteractionManager(this.interactionManager), this.goboManager = new Ra(this.stages.pathTracer, {
5678
5678
  onReset: () => this.reset(),
5679
5679
  issues: this._issues
5680
- }), this.iesManager = new Ja(this.stages.pathTracer, {
5680
+ }), this.iesManager = new Xa(this.stages.pathTracer, {
5681
5681
  onReset: () => this.reset(),
5682
5682
  issues: this._issues
5683
- }), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new ls({
5683
+ }), this._setupDenoisingManager(), this._headless || (await this._setupOverlayManager(), this.transformManager = new ds({
5684
5684
  camera: this.camera,
5685
5685
  canvas: this.canvas,
5686
5686
  orbitControls: this.cameraManager.controls,
5687
5687
  app: this
5688
- }), this.overlayManager.register("transform", new us(this.transformManager))), this.interactionManager.setDependencies({
5688
+ }), this.overlayManager.register("transform", new fs(this.transformManager))), this.interactionManager.setDependencies({
5689
5689
  overlayManager: this.overlayManager,
5690
5690
  transformManager: this.transformManager,
5691
5691
  appDispatch: (e) => this.dispatchEvent(e),
@@ -5694,20 +5694,20 @@ var Cs = Ke("engine"), ws = class extends te {
5694
5694
  }), this.denoisingManager.setOverlayManager(this.overlayManager), this.denoisingManager.setResetCallback(() => this.reset()), this.denoisingManager.setPostProcessRefreshCallback(() => this.requestPostProcessRefresh()), this.denoisingManager.setDisplayRefreshCallback(() => this._presentDisplay()), this.denoisingManager.setSettings(this.settings);
5695
5695
  }
5696
5696
  _wireEvents() {
5697
- this._addTrackedListener(this.cameraManager, j.CAMERA_SWITCHED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, j.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, j.ORTHO_HEIGHT_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.timeline, j.TIMELINE_CHANGED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
5698
- j.DENOISING_START,
5699
- j.DENOISING_END,
5700
- j.UPSCALING_START,
5701
- j.UPSCALING_PROGRESS,
5702
- j.UPSCALING_END,
5703
- j.RESOLUTION_CHANGED
5697
+ this._addTrackedListener(this.cameraManager, A.CAMERA_SWITCHED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, A.AUTO_FOCUS_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.cameraManager, A.ORTHO_HEIGHT_UPDATED, (e) => this.dispatchEvent(e)), this._addTrackedListener(this.timeline, A.TIMELINE_CHANGED, (e) => this.dispatchEvent(e)), this._forwardEvents(this.denoisingManager, [
5698
+ A.DENOISING_START,
5699
+ A.DENOISING_END,
5700
+ A.UPSCALING_START,
5701
+ A.UPSCALING_PROGRESS,
5702
+ A.UPSCALING_END,
5703
+ A.RESOLUTION_CHANGED
5704
5704
  ]), this._setupAutoExposureListener(), this.animationManager.wakeCallback = () => this.wake(), this.animationManager.applyPoseCallback = (e) => this._applyAnimationPose(e), this._forwardEvents(this.animationManager, [
5705
- j.ANIMATION_STARTED,
5706
- j.ANIMATION_PAUSED,
5707
- j.ANIMATION_STOPPED
5708
- ]), this._addTrackedListener(this.animationManager, j.ANIMATION_PAUSED, () => {
5705
+ A.ANIMATION_STARTED,
5706
+ A.ANIMATION_PAUSED,
5707
+ A.ANIMATION_STOPPED
5708
+ ]), this._addTrackedListener(this.animationManager, A.ANIMATION_PAUSED, () => {
5709
5709
  this._animRefitInFlight = !1, this._refreshMovedEmitters();
5710
- }), this._addTrackedListener(this.animationManager, j.ANIMATION_STOPPED, () => {
5710
+ }), this._addTrackedListener(this.animationManager, A.ANIMATION_STOPPED, () => {
5711
5711
  this._animRefitInFlight = !1;
5712
5712
  }), this.cameraManager.initCallbacks({
5713
5713
  onResize: () => this.onResize(),
@@ -5752,7 +5752,7 @@ var Cs = Ke("engine"), ws = class extends te {
5752
5752
  _beginFrame() {
5753
5753
  if (this.timeline.update(), this.cameraManager.updateControls(), this._applyPendingRenderScale(), this.animationManager?.isPlaying && !this._animRefitInFlight) {
5754
5754
  let e = this.animationManager.update();
5755
- e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => Cs.error("animation refit error:", e)).finally(() => {
5755
+ e && (this._animRefitInFlight = !0, this.refitBVH(e).catch((e) => Ts.error("animation refit error:", e)).finally(() => {
5756
5756
  this._animRefitInFlight = !1;
5757
5757
  }));
5758
5758
  }
@@ -5850,14 +5850,14 @@ var Cs = Ke("engine"), ws = class extends te {
5850
5850
  return t && this._dispatchCamerasUpdated(), t;
5851
5851
  }
5852
5852
  exportSceneState() {
5853
- return vs(this);
5853
+ return bs(this);
5854
5854
  }
5855
5855
  async importSceneState(e, t) {
5856
- return await Ss(this, e, t);
5856
+ return await ws(this, e, t);
5857
5857
  }
5858
5858
  _dispatchCamerasUpdated() {
5859
5859
  this.dispatchEvent({
5860
- type: j.CAMERAS_UPDATED,
5860
+ type: A.CAMERAS_UPDATED,
5861
5861
  cameras: this.cameraManager.cameras,
5862
5862
  cameraNames: this.cameraManager.getCameraNames()
5863
5863
  });
@@ -5911,8 +5911,8 @@ var Cs = Ke("engine"), ws = class extends te {
5911
5911
  this._pendingRenderScale = null, !(this._disposed || e === this._renderScale) && (this._renderScale = e, !(!this._displayWidth || !this._displayHeight) && (this._setDisplaySize(this._displayWidth, this._displayHeight), this.pipeline?.setSize(this._scaled(this._displayWidth), this._scaled(this._displayHeight)), this.pipeline?.eventBus.emit("pipeline:historyReset"), this.needsReset = !0));
5912
5912
  }
5913
5913
  configureForMode(e, t = {}) {
5914
- let n = e === "production", r = n ? we : ae;
5915
- this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.settings.setMany(re(r), {
5914
+ let n = e === "production", r = n ? me : T;
5915
+ this.denoisingManager?.setCadenceSuspended(n), this.timeline.stop(), this.cameraManager.controls.enabled = !n, this.settings.setMany(ie(r), {
5916
5916
  silent: !0,
5917
5917
  source: x.MODE_PRESET
5918
5918
  }), this.stages.pathTracer?.setUniform("renderMode", parseInt(r.renderMode)), n && this._applyRenderScale(1), this.stages.pathTracer?.updateCompletionThreshold?.();
@@ -5935,13 +5935,13 @@ var Cs = Ke("engine"), ws = class extends te {
5935
5935
  let e = this.denoisingManager;
5936
5936
  if (await e?.denoiseOnce()) return !0;
5937
5937
  let t = e?.denoiser ? e.denoiser.enabled ? "the denoise did not complete" : "OIDN was off while accumulating — call denoisingManager.setOIDNEnabled( true ) first" : "the denoiser was not built";
5938
- return this._issues.record(Ze.DENOISER_UNAVAILABLE, `final denoise produced no picture: ${t}`, { reason: t }), !1;
5938
+ return this._issues.record(Qe.DENOISER_UNAVAILABLE, `final denoise produced no picture: ${t}`, { reason: t }), !1;
5939
5939
  }
5940
5940
  _abortPostProcess({ keepDisplay: e = !1 } = {}) {
5941
5941
  if (this.denoisingManager?.abort(this.canvas, { keepDisplay: e }), this.denoisingManager?.restoreBaseResolution()) {
5942
5942
  let e = this.denoisingManager._lastRenderWidth, t = this.denoisingManager._lastRenderHeight;
5943
5943
  this.dispatchEvent({
5944
- type: j.RESOLUTION_CHANGED,
5944
+ type: A.RESOLUTION_CHANGED,
5945
5945
  width: e,
5946
5946
  height: t
5947
5947
  });
@@ -5969,13 +5969,13 @@ var Cs = Ke("engine"), ws = class extends te {
5969
5969
  if (e.length > 0) {
5970
5970
  let t = this.sceneModel || this.meshScene;
5971
5971
  this.animationManager.init(this.meshScene, t, this._sdf.meshes, e), this.animationManager.onFinished = () => {
5972
- this._animRefitInFlight = !1, this._refreshMovedEmitters(), this.dispatchEvent({ type: j.ANIMATION_FINISHED });
5972
+ this._animRefitInFlight = !1, this._refreshMovedEmitters(), this.dispatchEvent({ type: A.ANIMATION_FINISHED });
5973
5973
  };
5974
5974
  }
5975
5975
  this.transformManager?.setMeshData(this._sdf.meshes);
5976
5976
  }
5977
5977
  _setupDenoisingManager() {
5978
- this.denoisingManager = new Yo({
5978
+ this.denoisingManager = new Zo({
5979
5979
  renderer: this.renderer,
5980
5980
  mainCanvas: this.canvas,
5981
5981
  stages: {
@@ -6001,14 +6001,14 @@ var Cs = Ke("engine"), ws = class extends te {
6001
6001
  _setupAutoExposureListener() {
6002
6002
  this.stages.autoExposure && this.stages.autoExposure.on("autoexposure:updated", (e) => {
6003
6003
  this.dispatchEvent({
6004
- type: j.AUTO_EXPOSURE_UPDATED,
6004
+ type: A.AUTO_EXPOSURE_UPDATED,
6005
6005
  exposure: e.exposure,
6006
6006
  luminance: e.luminance
6007
6007
  });
6008
6008
  });
6009
6009
  }
6010
6010
  async _setupOverlayManager() {
6011
- this.overlayManager = new is(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
6011
+ this.overlayManager = new os(this.cameraManager.camera), this.overlayManager.setupDefaultHelpers({
6012
6012
  helperScene: this._sceneHelpers,
6013
6013
  meshScene: this.meshScene,
6014
6014
  pipeline: this.pipeline,
@@ -6026,7 +6026,7 @@ var Cs = Ke("engine"), ws = class extends te {
6026
6026
  }
6027
6027
  _recalibrateControlLimits() {
6028
6028
  if (!this.meshScene || !this.cameraManager) return;
6029
- let e = new $n(), t = new $n();
6029
+ let e = new tr(), t = new tr();
6030
6030
  for (let n of this.meshScene.children) n.userData?.__rayzeeSceneObject && (t.setFromObject(n), t.isEmpty() || e.union(t));
6031
6031
  if (e.isEmpty()) return;
6032
6032
  let n = Math.max(e.max.x - e.min.x, e.max.y - e.min.y, e.max.z - e.min.z);
@@ -6039,15 +6039,15 @@ var Cs = Ke("engine"), ws = class extends te {
6039
6039
  };
6040
6040
  //#endregion
6041
6041
  //#region src/Headless.js
6042
- async function Ts(e) {
6043
- let t = await Ds(e);
6042
+ async function Ds(e) {
6043
+ let t = await ks(e);
6044
6044
  try {
6045
- return await Es(t, e);
6045
+ return await Os(t, e);
6046
6046
  } finally {
6047
6047
  t.dispose();
6048
6048
  }
6049
6049
  }
6050
- async function Es(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, denoise: i = !1, onProgress: a = void 0 } = {}) {
6050
+ async function Os(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire: r = !1, denoise: i = !1, onProgress: a = void 0 } = {}) {
6051
6051
  let o = e.denoisingManager;
6052
6052
  i && o && !o.finalDenoise && (o.applyOIDNEnabled(!0), o._syncGBufferStages());
6053
6053
  let s = await e.renderFrames(t, {
@@ -6066,8 +6066,8 @@ async function Es(e, { samples: t = 64, colorSpace: n = "srgb", allowEarlyRetire
6066
6066
  provenance: e.getProvenance()
6067
6067
  };
6068
6068
  }
6069
- async function Ds({ 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 } = {}) {
6070
- let l = new ws(e ?? null, {
6069
+ async function ks({ 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 } = {}) {
6070
+ let l = new Es(e ?? null, {
6071
6071
  autoResize: !1,
6072
6072
  strict: i,
6073
6073
  storage: s,
@@ -6081,12 +6081,12 @@ async function Ds({ canvas: e, model: t = null, width: n = 1920, height: r = 108
6081
6081
  }
6082
6082
  //#endregion
6083
6083
  //#region src/managers/VideoRenderManager.js
6084
- var Os = class {
6084
+ var As = class {
6085
6085
  constructor(e) {
6086
6086
  this._app = e, this._cancelled = !1, this._rendering = !1;
6087
6087
  }
6088
6088
  async renderAnimation(e = {}) {
6089
- let { clipIndex: t = 0, fps: n = 30, speed: r = 1, samplesPerFrame: i = we.maxSamples, enableOIDN: a = !0, timeline: o = null, startFrame: s = 0, onFrame: c, onProgress: l, onComplete: u } = e, d = this._app, f = d.animationManager?.hasAnimations ? d.animationManager.clips[t] : null;
6089
+ let { clipIndex: t = 0, fps: n = 30, speed: r = 1, samplesPerFrame: i = me.maxSamples, enableOIDN: a = !0, timeline: o = null, startFrame: s = 0, onFrame: c, onProgress: l, onComplete: u } = e, d = this._app, f = d.animationManager?.hasAnimations ? d.animationManager.clips[t] : null;
6090
6090
  if (!f && !o?.animates) {
6091
6091
  console.warn(d.animationManager?.hasAnimations ? `VideoRenderManager: Invalid clip index ${t}` : "VideoRenderManager: No animation clips or keyframes"), u?.(!1);
6092
6092
  return;
@@ -6114,7 +6114,7 @@ var Os = class {
6114
6114
  percent: (e + 1) / m * 100
6115
6115
  };
6116
6116
  l?.(u), d.dispatchEvent({
6117
- type: j.VIDEO_RENDER_PROGRESS,
6117
+ type: A.VIDEO_RENDER_PROGRESS,
6118
6118
  ...u
6119
6119
  });
6120
6120
  }
@@ -6124,7 +6124,7 @@ var Os = class {
6124
6124
  this._restoreState(g), this._rendering = !1;
6125
6125
  let e = !this._cancelled;
6126
6126
  u?.(e), d.dispatchEvent({
6127
- type: j.VIDEO_RENDER_COMPLETE,
6127
+ type: A.VIDEO_RENDER_COMPLETE,
6128
6128
  success: e
6129
6129
  });
6130
6130
  }
@@ -6143,26 +6143,26 @@ var Os = class {
6143
6143
  await n;
6144
6144
  continue;
6145
6145
  }
6146
- e.cameraManager.camera.updateMatrixWorld(), e.pipeline.render(), t.frameCount % 4 == 0 && (Ve({ samples: Fe(t) }), await new Promise((e) => setTimeout(e, 0)));
6146
+ e.cameraManager.camera.updateMatrixWorld(), e.pipeline.render(), t.frameCount % 4 == 0 && (Ie({ samples: Fe(t) }), await new Promise((e) => setTimeout(e, 0)));
6147
6147
  }
6148
6148
  }
6149
6149
  _waitForDenoise(e) {
6150
6150
  return new Promise((t) => {
6151
6151
  let n, r = () => {
6152
- e.removeEventListener(j.DENOISING_END, i), clearTimeout(n);
6152
+ e.removeEventListener(A.DENOISING_END, i), clearTimeout(n);
6153
6153
  }, i = () => {
6154
6154
  r(), t();
6155
6155
  };
6156
6156
  n = setTimeout(() => {
6157
6157
  console.warn("VideoRenderManager: Denoise timed out, skipping"), r(), t();
6158
- }, 3e4), e.addEventListener(j.DENOISING_END, i), e.denoisingManager.onRenderComplete({
6158
+ }, 3e4), e.addEventListener(A.DENOISING_END, i), e.denoisingManager.onRenderComplete({
6159
6159
  isStillComplete: () => !this._cancelled,
6160
6160
  context: e.pipeline?.context
6161
6161
  });
6162
6162
  });
6163
6163
  }
6164
6164
  _saveState({ view: e }) {
6165
- let t = this._app, n = t.settings.getEffective(), r = Object.keys(re(we));
6165
+ let t = this._app, n = t.settings.getEffective(), r = Object.keys(ie(me));
6166
6166
  return e && r.push("focusDistance"), {
6167
6167
  view: e ? t.cameraManager.captureView() : null,
6168
6168
  settings: r.map((e) => [e, n[e]]),
@@ -6185,4 +6185,4 @@ var Os = class {
6185
6185
  }
6186
6186
  };
6187
6187
  //#endregion
6188
- export { wt as ARCHIVE_FORMATS, Br as ASVGF_QUALITY_PRESETS, Ji as AUTO_EXPOSURE_DEFAULTS, Ca as AUTO_FOCUS_DEFAULTS, os as AnimationManager, Je as BVH_LEAF_MARKERS, ka as CameraManager, Na as CameraTrack, Xt as ColorManagement, Rt as DEFAULT_LUT_SIZE, qt as DEFAULT_MAX_EV, Wt as DEFAULT_MIN_EV, Te as DEFAULT_SUN_PATH, gt as DEFAULT_VIEW, it as DEFAULT_WORKING_SPACE, qr as DENOISER_DEFAULTS, C as DOWNLOAD_POLICY, Yo as DenoisingManager, f as DownloadCache, tt as ENGINE_AREAS, oe as ENGINE_DEFAULTS, j as EngineEvents, $e as EngineIssueError, Ia as GoboManager, Ja as IESManager, ae as INTERACTIVE_RENDER_CONFIG, Ze as ISSUE_CODES, Qe as ISSUE_SEVERITY, oa as InteractionManager, Xe as IssueLog, Pe as LEGACY_EVENT_NAMES, qe as LOG_LEVELS, ee as LightManager, Ge as Logger, ue as MATERIAL_DEFAULTS, me as MATERIAL_VALUE_SOURCE, D as MAX_RESERVABLE_RENDER_SIZE, Be as MAX_SCENE_BYTES, mt as MAX_TABLE_TRANSFORMS, Le as MemoryLedger, Ur as NRD_DEFAULTS, Vr as NRD_HIT_DIST_A, Hr as NRD_HIT_DIST_B, Wr as NRD_PRESET_KEYS, Gr as NRD_QUALITY_PRESETS, ut as OCIO_VIEW_BASE, is as OverlayManager, we as PRODUCTION_RENDER_CONFIG, ws as PathTracerApp, u as PipelineContext, mn as RETOUCH_DEFAULTS, hn as RETOUCH_MAX_PIXELS, pn as RETOUCH_RANGES, te as RayzeeRenderer, S as RenderPipeline, d as RenderSettings, E as RenderStage, Re as SAFE_SCENE_BYTES, ds as SCENE_STATE_VERSION, x as SETTING_SOURCE, Ae as SKY_DEFAULTS, dn as SR_MAX_INPUT, fn as SR_SCALE, et as STORAGE_KIND, ge as StageExecutionMode, on as StorageManager, Ye as TRIANGLE_DATA_LAYOUT, Fa as TimelineManager, ls as TransformManager, Ue as VERSION, st as VIEW_TRANSFORMS, xe as VRAMTracker, Os as VideoRenderManager, nn as acquireLock, Bt as addAllOcioViews, zt as addOcioView, ft as addViewTransform, en as applyMatrixRGBA8, Qt as bakeLut, ke as bufferBytes, Nt as buildOcioView, ht as buildToneMapWGSL, v as cachedObjectURL, Gt as canvasColorSpaceFor, Es as captureHeadless, y as clearBindingAuditFindings, Pt as clearInputOverrides, ot as configureAssets, Ee as configurePlatform, jt as convertColor, Dt as convertEncodedRGBA8, $t as convertPixelsF32, Ke as createLogger, be as dayOfYearForMonth, ie as deriveAlphaMode, b as describeAdapter, Et as displayCanvasFit, ze as estimateSceneBytes, Mt as extractMatrix, St as extractSceneMetadata, w as fetchFile, yt as fileIdentity, Jt as findNativeLinearSpace, We as fmt, ye as fromPortable, rt as getActiveColorManagement, at as getAssetConfig, g as getBindingAuditFindings, Ce as getPlatform, dt as getRegistryVersion, _t as getViewTransform, kt as hasColorSpace, rn as heldLockNames, bt as identityKey, Vt as isColorManaged, Ot as isDataSpace, Kt as isDataTexture, At as linearToSrgb, Yt as listFileRules, It as listInputOverrides, ct as listViewTransforms, tn as makeCpuSampler, Ft as measureBakeError, p as nameFromUrl, pt as onRegistryChange, Ds as openHeadless, an as openStorage, ln as openZip, Ct as parseSceneMetadata, He as probeAddressSpace, cn as readZipDirectory, lt as removeViewTransform, Ts as renderHeadless, un as renderUpscaled, Ut as resolveInputSpace, vt as sameIdentity, nt as setActiveColorManagement, h as setBindingAudit, Zt as setInputOverride, Ht as srgbToLinear, Se as sunPosition, De as textureBytes, Lt as textureInputSpace, Oe as timeForSunElevation, je as toPortable };
6188
+ export { Tt as ARCHIVE_FORMATS, Hr as ASVGF_QUALITY_PRESETS, Xi as AUTO_EXPOSURE_DEFAULTS, Ta as AUTO_FOCUS_DEFAULTS, cs as AnimationManager, Ye as BVH_LEAF_MARKERS, ja as CameraManager, Fa as CameraTrack, $t as ColorManagement, Vt as DEFAULT_LUT_SIZE, Xt as DEFAULT_MAX_EV, qt as DEFAULT_MIN_EV, Ce as DEFAULT_SUN_PATH, _t as DEFAULT_VIEW, at as DEFAULT_WORKING_SPACE, Yr as DENOISER_DEFAULTS, C as DOWNLOAD_POLICY, Zo as DenoisingManager, f as DownloadCache, nt as ENGINE_AREAS, pe as ENGINE_DEFAULTS, A as EngineEvents, et as EngineIssueError, Ra as GoboManager, Xa as IESManager, T as INTERACTIVE_RENDER_CONFIG, Qe as ISSUE_CODES, $e as ISSUE_SEVERITY, ca as InteractionManager, Ze as IssueLog, Ne as LEGACY_EVENT_NAMES, Je as LOG_LEVELS, ee as LightManager, Ke as Logger, ke as MATERIAL_DEFAULTS, Oe as MATERIAL_VALUE_SOURCE, le as MAX_RESERVABLE_RENDER_SIZE, Ve as MAX_SCENE_BYTES, ht as MAX_TABLE_TRANSFORMS, Re as MemoryLedger, Gr as NRD_DEFAULTS, Ur as NRD_HIT_DIST_A, Wr as NRD_HIT_DIST_B, Kr as NRD_PRESET_KEYS, qr as NRD_QUALITY_PRESETS, dt as OCIO_VIEW_BASE, os as OverlayManager, me as PRODUCTION_RENDER_CONFIG, Es as PathTracerApp, u as PipelineContext, _n as RETOUCH_DEFAULTS, vn as RETOUCH_MAX_PIXELS, gn as RETOUCH_RANGES, te as RayzeeRenderer, S as RenderPipeline, d as RenderSettings, oe as RenderStage, ze as SAFE_SCENE_BYTES, ps as SCENE_STATE_VERSION, x as SETTING_SOURCE, De as SKY_DEFAULTS, mn as SR_MAX_INPUT, hn as SR_SCALE, tt as STORAGE_KIND, E as StageExecutionMode, ln as StorageManager, Xe as TRIANGLE_DATA_LAYOUT, La as TimelineManager, ds as TransformManager, Ue as VERSION, ct as VIEW_TRANSFORMS, ye as VRAMTracker, As as VideoRenderManager, on as acquireLock, Ut as addAllOcioViews, Ht as addOcioView, pt as addViewTransform, rn as applyMatrixRGBA8, tn as bakeLut, Ee as bufferBytes, It as buildOcioView, gt as buildToneMapWGSL, v as cachedObjectURL, Jt as canvasColorSpaceFor, Os as captureHeadless, y as clearBindingAuditFindings, Lt as clearInputOverrides, st as configureAssets, Le as configurePlatform, Pt as convertColor, At as convertEncodedRGBA8, nn as convertPixelsF32, qe as createLogger, ve as dayOfYearForMonth, je as deriveAlphaMode, b as describeAdapter, kt as displayCanvasFit, Be as estimateSceneBytes, Ft as extractMatrix, Et as extractSceneMetadata, w as fetchFile, xt as fileIdentity, Zt as findNativeLinearSpace, Ge as fmt, St as folderIdentity, xe as fromPortable, it as getActiveColorManagement, ot as getAssetConfig, g as getBindingAuditFindings, We as getPlatform, ft as getRegistryVersion, vt as getViewTransform, Mt as hasColorSpace, sn as heldLockNames, bt as identityKey, Wt as isColorManaged, jt as isDataSpace, Yt as isDataTexture, Nt as linearToSrgb, Qt as listFileRules, zt as listInputOverrides, lt as listViewTransforms, Ct as localFolder, an as makeCpuSampler, Rt as measureBakeError, p as nameFromUrl, mt as onRegistryChange, ks as openHeadless, cn as openStorage, fn as openZip, wt as parseSceneMetadata, He as probeAddressSpace, dn as readZipDirectory, ut as removeViewTransform, Ds as renderHeadless, pn as renderUpscaled, Kt as resolveInputSpace, yt as sameIdentity, rt as setActiveColorManagement, h as setBindingAudit, en as setInputOverride, Gt as srgbToLinear, be as sunPosition, we as textureBytes, Bt as textureInputSpace, Te as timeForSunElevation, _e as toPortable };