rayzee 11.11.0 → 11.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/{ArchiveImporter-D5XOC3tN.js → ArchiveImporter-vUowipjh.js} +3 -3
  2. package/dist/{BidirectionalIntegrator-DqG0BEIz.js → BidirectionalIntegrator-DPh6PSYb.js} +2 -2
  3. package/dist/{ColorManagement-B_HjAiy2.js → ColorManagement-3xw0xXRg.js} +859 -374
  4. package/dist/{NeuralRetouch-BkxZPOYq.js → NeuralRetouch-wwAwssFM.js} +1 -1
  5. package/dist/{NeuralSuperRes-a8xDtvXM.js → NeuralSuperRes-DqV4v_gQ.js} +6 -6
  6. package/dist/{PathTracer-C_gliSWI.js → PathTracer-DW-ElMON.js} +1 -1
  7. package/dist/{PhysicalSky-DWK8pS0U.js → PhysicalSky-Ispr77Lf.js} +1 -1
  8. package/dist/{RayzeeRenderer-B4ZehMg_.js → RayzeeRenderer-CPbY683A.js} +349 -289
  9. package/dist/{SceneMetadata-Bb3iwWhh.js → SceneMetadata-BNA22-m3.js} +1 -1
  10. package/dist/addons/archives.es.js +1 -1
  11. package/dist/addons/bidirectional.es.js +1 -1
  12. package/dist/addons/color.es.js +2 -2
  13. package/dist/addons/physical-sky.es.js +1 -1
  14. package/dist/rayzee-core.es.js +4 -4
  15. package/dist/rayzee.es.js +637 -627
  16. package/dist/rayzee.umd.js +9 -9
  17. package/dist/{sceneCachePolicy-BHNKvrHR.js → sceneCachePolicy-BLvdjkVh.js} +1 -1
  18. package/package.json +1 -1
  19. package/src/Color/BakedViews.js +5 -2
  20. package/src/Color/BasicColor.js +27 -0
  21. package/src/Color/ColorManagement.js +255 -11
  22. package/src/Color/Displays.js +149 -7
  23. package/src/Color/OcioRuntime.js +19 -4
  24. package/src/Color/OcioViews.js +251 -37
  25. package/src/Passes/AIUpscaler.js +6 -2
  26. package/src/PathTracerApp.js +2 -0
  27. package/src/RayzeeRenderer.js +54 -9
  28. package/src/Stages/Compositor.js +86 -3
  29. package/src/addons/color.js +2 -2
  30. package/src/index.js +2 -2
  31. package/src/managers/DenoisingManager.js +18 -4
  32. package/src/managers/VideoRenderManager.js +10 -1
  33. package/src/neural/NeuralSuperRes.js +5 -5
@@ -1,29 +1,29 @@
1
1
  import { dt as e } from "./SolarLimb-ZYl-Pwl0.js";
2
- import { At as t, Dt as n, Mt as r, Ot as i, bt as a, dt as o, ft as s, i as c, jt as l, lt as u, n as d, r as f, ut as p, vt as ee, yt as m } from "./PathTracer-C_gliSWI.js";
2
+ import { At as t, Dt as n, Mt as r, Ot as i, bt as a, dt as o, ft as s, i as c, jt as l, lt as u, n as d, r as f, ut as p, vt as ee, yt as m } from "./PathTracer-DW-ElMON.js";
3
3
  import { n as h, t as g } from "./EngineEvents-CLckhYbL.js";
4
- import { $ as te, C as ne, G as _, M as re, Q as ie, T as v, W as ae, at as y, d as oe, et as se, f as ce, l as le, nt as b, ot as ue, r as de, rt as fe, tt as pe, u as me, v as he, x as ge } from "./sceneCachePolicy-BHNKvrHR.js";
5
- import { i as x, r as S } from "./Logger-dDDGj9Av.js";
6
- import { f as _e, r as ve } from "./BufferLayout-BROyMqO1.js";
7
- import { i as ye, n as C, t as be } from "./EngineIssues-CfJiBaNj.js";
8
- import { n as xe, r as Se } from "./shared-BGBcSxBQ.js";
9
- import { a as Ce } from "./WorkingMatrix-C6y233hT.js";
10
- import { i as w, r as we, t as T } from "./ActiveColor-YvuQq44O.js";
11
- import { n as E, r as Te } from "./AssetConfig-DSEntE65.js";
12
- import { d as Ee, l as De, m as Oe, p as ke, t as Ae, u as D } from "./ViewTransforms-CYN7bq2w.js";
13
- import { i as O, n as je, r as Me } from "./identity-C1cLD1C0.js";
14
- import { c as Ne, i as Pe, l as Fe, o as Ie, r as Le, t as Re } from "./SceneMetadata-Bb3iwWhh.js";
15
- import { t as ze } from "./ToneMapGPU-4GPwoG_c.js";
16
- import { LinearSRGBColorSpace as Be, MeshBasicNodeMaterial as Ve, QuadMesh as He, RectAreaLightNode as Ue, SRGBColorSpace as We, TextureNode as Ge, WebGPURenderer as Ke } from "three/webgpu";
17
- import { Fn as qe, If as Je, cubeTexture as Ye, dot as Xe, float as k, int as A, mix as j, screenUV as Ze, select as M, storage as Qe, texture as $e, uint as et, uniform as N, uv as P, vec3 as F, vec4 as tt } from "three/tsl";
18
- import { Box3 as nt, BufferGeometry as rt, CircleGeometry as it, Color as I, DirectionalLight as at, DirectionalLightHelper as ot, EquirectangularReflectionMapping as st, EventDispatcher as L, FloatType as ct, LinearFilter as lt, LinearSRGBColorSpace as ut, LoaderUtils as dt, LoadingManager as ft, MathUtils as R, Mesh as pt, MeshPhysicalMaterial as mt, NoBlending as ht, NoToneMapping as gt, Object3D as z, OrthographicCamera as _t, PerspectiveCamera as vt, PointLight as yt, PointLightHelper as bt, REVISION as xt, RectAreaLight as B, SRGBColorSpace as V, Scene as H, SpotLight as St, SpotLightHelper as Ct, TextureLoader as wt, Vector2 as Tt, Vector3 as U } from "three";
19
- import { RectAreaLightTexturesLib as Et } from "three/addons/lights/RectAreaLightTexturesLib.js";
20
- import { RectAreaLightHelper as Dt } from "three/addons/helpers/RectAreaLightHelper.js";
21
- import { GLTFLoader as Ot } from "three/addons/loaders/GLTFLoader.js";
22
- import { HDRLoader as kt } from "three/addons/loaders/HDRLoader.js";
23
- import { createMeshesFromMultiMaterialMesh as At } from "three/addons/utils/SceneUtils.js";
24
- import { clone as jt } from "three/addons/utils/SkeletonUtils.js";
4
+ import { $ as te, C as ne, G as _, M as re, Q as ie, T as ae, W as oe, at as v, d as se, et as ce, f as le, l as ue, nt as de, ot as fe, r as pe, rt as me, tt as he, u as ge, v as _e, x as ve } from "./sceneCachePolicy-BLvdjkVh.js";
5
+ import { i as y, r as b } from "./Logger-dDDGj9Av.js";
6
+ import { f as ye, r as be } from "./BufferLayout-BROyMqO1.js";
7
+ import { i as xe, n as x, t as Se } from "./EngineIssues-CfJiBaNj.js";
8
+ import { n as Ce, r as we } from "./shared-BGBcSxBQ.js";
9
+ import { a as Te } from "./WorkingMatrix-C6y233hT.js";
10
+ import { i as Ee, r as De, t as S } from "./ActiveColor-YvuQq44O.js";
11
+ import { n as C, r as Oe } from "./AssetConfig-DSEntE65.js";
12
+ import { d as ke, l as Ae, m as je, p as Me, t as Ne, u as w } from "./ViewTransforms-CYN7bq2w.js";
13
+ import { i as T, n as Pe, r as Fe } from "./identity-C1cLD1C0.js";
14
+ import { c as Ie, i as Le, l as Re, o as ze, r as Be, t as Ve } from "./SceneMetadata-BNA22-m3.js";
15
+ import { t as He } from "./ToneMapGPU-4GPwoG_c.js";
16
+ import { LinearSRGBColorSpace as Ue, MeshBasicNodeMaterial as E, QuadMesh as D, RectAreaLightNode as We, SRGBColorSpace as O, TextureNode as Ge, WebGPURenderer as Ke } from "three/webgpu";
17
+ import { Fn as qe, If as Je, cubeTexture as Ye, dot as Xe, float as k, int as A, mix as j, screenUV as Ze, select as M, storage as Qe, texture as $e, toneMappingExposure as et, uint as tt, uniform as N, uv as P, vec3 as F, vec4 as nt } from "three/tsl";
18
+ import { Box3 as rt, BufferGeometry as it, CircleGeometry as at, Color as ot, ColorManagement as st, DirectionalLight as ct, DirectionalLightHelper as lt, EquirectangularReflectionMapping as ut, EventDispatcher as I, FloatType as dt, HalfFloatType as ft, LinearFilter as pt, LinearSRGBColorSpace as mt, LoaderUtils as ht, LoadingManager as gt, MathUtils as L, Mesh as _t, MeshPhysicalMaterial as vt, NoBlending as R, NoToneMapping as yt, Object3D as z, OrthographicCamera as bt, PerspectiveCamera as xt, PointLight as St, PointLightHelper as Ct, REVISION as wt, RectAreaLight as B, SRGBColorSpace as V, Scene as H, SpotLight as Tt, SpotLightHelper as Et, TextureLoader as Dt, Vector2 as Ot, Vector3 as U } from "three";
19
+ import { RectAreaLightTexturesLib as kt } from "three/addons/lights/RectAreaLightTexturesLib.js";
20
+ import { RectAreaLightHelper as At } from "three/addons/helpers/RectAreaLightHelper.js";
21
+ import { GLTFLoader as jt } from "three/addons/loaders/GLTFLoader.js";
22
+ import { HDRLoader as Mt } from "three/addons/loaders/HDRLoader.js";
23
+ import { createMeshesFromMultiMaterialMesh as Nt } from "three/addons/utils/SceneUtils.js";
24
+ import { clone as Pt } from "three/addons/utils/SkeletonUtils.js";
25
25
  //#region src/SceneHelpers.js
26
- var Mt = class {
26
+ var Ft = class {
27
27
  constructor() {
28
28
  this.scene = new H(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
29
29
  }
@@ -63,14 +63,14 @@ var Mt = class {
63
63
  this.clear();
64
64
  }
65
65
  _createHelper(e) {
66
- return e.isRectAreaLight ? new Dt(e) : e.isPointLight ? new bt(e, .5) : e.isSpotLight ? new Ct(e) : e.isDirectionalLight ? new ot(e, .5) : null;
66
+ return e.isRectAreaLight ? new At(e) : e.isPointLight ? new Ct(e, .5) : e.isSpotLight ? new Et(e) : e.isDirectionalLight ? new lt(e, .5) : null;
67
67
  }
68
- }, Nt = class extends l {
68
+ }, It = class extends l {
69
69
  constructor(e, t = {}) {
70
70
  super("Compositor", {
71
71
  ...t,
72
72
  executionMode: r.ALWAYS
73
- }), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new Ge(), this._displayGain = null, this._backdropExposure = null, this._holdBackdrop = N(0, "int"), this._backdropGain = N(1), this.compositorMaterial = new Ve(), this.compositorMaterial.blending = ht, this._buildColorNode(), this.compositorQuad = new He(this.compositorMaterial);
73
+ }), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new Ge(), this._displayGain = null, this._backdropExposure = null, this._holdBackdrop = N(0, "int"), this._backdropGain = N(1), this._canvasTransform = null, this._canvasMaterial = null, this._canvasQuad = null, this.compositorMaterial = new E(), this.compositorMaterial.blending = R, this._buildColorNode(), this.compositorQuad = new D(this.compositorMaterial), this.setCanvasTransform(t.canvasTransform ?? null);
74
74
  }
75
75
  _buildColorNode() {
76
76
  let t = this._sourceTexNode.sample(P()), n = this._displayGain ? this._displayGain(t.xyz, Ze) : null;
@@ -79,7 +79,16 @@ var Mt = class {
79
79
  n = M(this._holdBackdrop.greaterThan(A(0)), r, e);
80
80
  }
81
81
  let r = n ? t.xyz.mul(n) : t.xyz, i = j(F(Xe(r, e)), r, this.saturation), a = M(this._transparentBackground, t.w, 1);
82
- this.compositorMaterial.colorNode = tt(i, a), this.compositorMaterial.needsUpdate = !0;
82
+ this._graded = i, this._alpha = a, this.compositorMaterial.colorNode = nt(i, a), this.compositorMaterial.needsUpdate = !0, this._buildCanvasNode();
83
+ }
84
+ _buildCanvasNode() {
85
+ this._canvasMaterial && (this._canvasMaterial.colorNode = nt(this._canvasTransform(this._graded, et), this._alpha), this._canvasMaterial.needsUpdate = !0);
86
+ }
87
+ setCanvasTransform(e) {
88
+ e !== this._canvasTransform && (this._canvasTransform = e, this._canvasMaterial?.dispose(), this._canvasMaterial = null, this._canvasQuad = null, e && (this._canvasMaterial = new E(), this._canvasMaterial.blending = R, this._canvasQuad = new D(this._canvasMaterial), this._buildCanvasNode()));
89
+ }
90
+ get showsCanvasTransform() {
91
+ return this._canvasQuad !== null;
83
92
  }
84
93
  setDisplayGain(e) {
85
94
  e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
@@ -107,34 +116,49 @@ var Mt = class {
107
116
  if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
108
117
  this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Ge();
109
118
  let n = qe(() => {
110
- let n = Xe(this._debugTexNode.sample(P()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = A(P().x.mul(k(r))).min(r.sub(A(1))).max(A(0)), o = et(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Qe(t.m2, "float").toReadOnly().element(o).toVar(), c = Qe(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(k(0)).div(k(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(A(0)), d = M(n.lessThan(k(1)), n.sqrt(), n).toVar(), f = M(u, l.div(n.add(k(1e-4))), l.div(d.add(k(1e-4)))).toVar(), p = M(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), ee = f.div(p.max(k(1e-6))).toVar(), m = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), h = m.toVar(), g = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
119
+ let n = Xe(this._debugTexNode.sample(P()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = A(P().x.mul(k(r))).min(r.sub(A(1))).max(A(0)), o = tt(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Qe(t.m2, "float").toReadOnly().element(o).toVar(), c = Qe(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(k(0)).div(k(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(A(0)), d = M(n.lessThan(k(1)), n.sqrt(), n).toVar(), f = M(u, l.div(n.add(k(1e-4))), l.div(d.add(k(1e-4)))).toVar(), p = M(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), ee = f.div(p.max(k(1e-6))).toVar(), m = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), h = m.toVar(), g = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
111
120
  return Je(ee.greaterThanEqual(k(1)).or(g.not()), () => {
112
121
  let e = j(F(1, .8, .1), F(1, .1, .05), ee.sub(1).div(3).clamp(0, 1));
113
122
  h.assign(j(m, e, .85));
114
- }), Je(c.equal(et(1)).and(u), () => {
123
+ }), Je(c.equal(tt(1)).and(u), () => {
115
124
  h.assign(j(m, F(.1, .45, 1), .55));
116
125
  }), h;
117
126
  });
118
- return this._debugMaterial = new Ve(), this._debugMaterial.colorNode = tt(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = ht, this._debugQuad = new He(this._debugMaterial), !0;
127
+ return this._debugMaterial = new E(), this._debugMaterial.colorNode = nt(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = R, this._debugQuad = new D(this._debugMaterial), !0;
119
128
  }
120
129
  render(e) {
130
+ this._draw(e, !1);
131
+ }
132
+ renderPicture(e) {
133
+ this._draw(e, !0);
134
+ }
135
+ _draw(e, t) {
121
136
  if (!this.enabled) return;
122
137
  if (this._convergenceOverlay && this._ensureDebugMaterial()) {
123
138
  let t = e.getTexture("pathtracer:color");
124
139
  if (t) {
125
140
  this._debugTexNode.value = t;
126
- let e = this.renderer.toneMapping !== gt;
141
+ let e = this.renderer.toneMapping !== yt;
127
142
  this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
128
143
  return;
129
144
  }
130
145
  }
131
- let t = this.resolveLightTexture(e);
132
- if (t) {
133
- if (this._backdropExposure !== null) {
134
- let t = e.getState("pathtracer:backdrop") === "color";
135
- this._holdBackdrop.value = +!!t, t && (this._backdropGain.value = o(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
136
- }
137
- this._sourceTexNode.value = t, this.renderer.setRenderTarget(null), this.compositorQuad.render(this.renderer);
146
+ let n = this.resolveLightTexture(e);
147
+ if (!n) return;
148
+ if (this._backdropExposure !== null) {
149
+ let t = e.getState("pathtracer:backdrop") === "color";
150
+ this._holdBackdrop.value = +!!t, t && (this._backdropGain.value = o(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
151
+ }
152
+ if (this._sourceTexNode.value = n, this.renderer.setRenderTarget(null), t || !this._canvasQuad) {
153
+ this.compositorQuad.render(this.renderer);
154
+ return;
155
+ }
156
+ let { toneMapping: r, outputColorSpace: i } = this.renderer;
157
+ this.renderer.toneMapping = yt, this.renderer.outputColorSpace = st.workingColorSpace;
158
+ try {
159
+ this._canvasQuad.render(this.renderer);
160
+ } finally {
161
+ this.renderer.toneMapping = r, this.renderer.outputColorSpace = i;
138
162
  }
139
163
  }
140
164
  setConvergenceOverlay(e) {
@@ -147,9 +171,9 @@ var Mt = class {
147
171
  this._transparentBackground.value = +!!e;
148
172
  }
149
173
  dispose() {
150
- this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
174
+ this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._canvasMaterial?.dispose(), this._canvasMaterial = null, this._canvasQuad = null, this._canvasTransform = null, this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
151
175
  }
152
- }, Pt = class {
176
+ }, Lt = class {
153
177
  constructor() {
154
178
  this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
155
179
  frame: 0,
@@ -268,7 +292,7 @@ var Mt = class {
268
292
  dispose() {
269
293
  this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
270
294
  }
271
- }, Ft = class extends L {
295
+ }, Rt = class extends I {
272
296
  constructor() {
273
297
  super(), this._onceCallbacks = /* @__PURE__ */ new Map();
274
298
  }
@@ -306,38 +330,38 @@ var Mt = class {
306
330
  eventNames() {
307
331
  return this._listeners ? Object.keys(this._listeners) : [];
308
332
  }
309
- }, It = !1, W = [], Lt = /* @__PURE__ */ new WeakMap();
310
- function Rt(e) {
311
- It = !!e;
333
+ }, zt = !1, W = [], Bt = /* @__PURE__ */ new WeakMap();
334
+ function Vt(e) {
335
+ zt = !!e;
312
336
  }
313
- function zt() {
337
+ function Ht() {
314
338
  return W.slice();
315
339
  }
316
- function Bt() {
340
+ function Ut() {
317
341
  W.length = 0;
318
342
  }
319
- function Vt(e) {
343
+ function Wt(e) {
320
344
  let t = [];
321
345
  for (let n of Object.keys(e)) e[n]?.isTextureNode === !0 && t.push(n);
322
346
  return t;
323
347
  }
324
- var Ht = (e) => !e || !e.image || !(e.image.width > 0);
325
- function Ut(e, t, n) {
326
- if (!It) {
348
+ var Gt = (e) => !e || !e.image || !(e.image.width > 0);
349
+ function Kt(e, t, n) {
350
+ if (!zt) {
327
351
  n();
328
352
  return;
329
353
  }
330
- let r = Lt.get(e);
354
+ let r = Bt.get(e);
331
355
  if (r || (r = {
332
356
  phase: "pending",
333
357
  unboundAtCompile: []
334
- }, Lt.set(e, r)), r.phase !== "pending") {
335
- n(), r.phase === "watch" && Wt(e, r);
358
+ }, Bt.set(e, r)), r.phase !== "pending") {
359
+ n(), r.phase === "watch" && qt(e, r);
336
360
  return;
337
361
  }
338
362
  let i = Object.prototype.hasOwnProperty.call(t, "compute"), a = t.compute;
339
363
  t.compute = function(...t) {
340
- return r.phase === "pending" && (r.unboundAtCompile = Vt(e).filter((t) => Ht(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
364
+ return r.phase === "pending" && (r.unboundAtCompile = Wt(e).filter((t) => Gt(e[t].value)), r.phase = r.unboundAtCompile.length < 2 ? "done" : "watch"), a.apply(this, t);
341
365
  };
342
366
  try {
343
367
  n();
@@ -345,11 +369,11 @@ function Ut(e, t, n) {
345
369
  i ? t.compute = a : delete t.compute;
346
370
  }
347
371
  }
348
- function Wt(e, t) {
372
+ function qt(e, t) {
349
373
  let n = [];
350
374
  for (let r of t.unboundAtCompile) {
351
375
  let t = e[r]?.value;
352
- if (Ht(t)) return;
376
+ if (Gt(t)) return;
353
377
  t.isStorageTexture !== !0 && n.push(r);
354
378
  }
355
379
  t.phase = "done", n.length !== 0 && W.push({
@@ -361,18 +385,18 @@ function Wt(e, t) {
361
385
  }
362
386
  //#endregion
363
387
  //#region src/Pipeline/RenderPipeline.js
364
- var Gt = class {
388
+ var Jt = class {
365
389
  _reportStageFailure(e, t, n) {
366
390
  console.error(`[Pipeline] Error in stage '${e}' (${t}):`, n);
367
391
  let r = `${e}:${t}`;
368
- this._reportedStageFailures.has(r) || (this._reportedStageFailures.add(r), this._issues?.record(C.STAGE_RENDER_FAILED, `stage "${e}" threw during ${t} — the frame is incomplete`, {
392
+ this._reportedStageFailures.has(r) || (this._reportedStageFailures.add(r), this._issues?.record(x.STAGE_RENDER_FAILED, `stage "${e}" threw during ${t} — the frame is incomplete`, {
369
393
  stage: e,
370
394
  phase: t,
371
395
  cause: String(n?.message ?? n)
372
396
  }));
373
397
  }
374
398
  constructor(e, t, n, { issues: r = null } = {}) {
375
- this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Pt(), this.eventBus = new Ft(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
399
+ this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Lt(), this.eventBus = new Rt(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
376
400
  enabled: !1,
377
401
  logSkipped: !1,
378
402
  timings: /* @__PURE__ */ new Map(),
@@ -406,7 +430,7 @@ var Gt = class {
406
430
  }
407
431
  try {
408
432
  let n = this.stats.enabled ? performance.now() : 0;
409
- if (Ut(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
433
+ if (Kt(t, this.renderer, () => t.render(this.context, e)), this.stats.enabled) {
410
434
  let e = performance.now() - n;
411
435
  this.stats.timings.has(t.name) || this.stats.timings.set(t.name, []);
412
436
  let r = this.stats.timings.get(t.name);
@@ -504,7 +528,7 @@ var Gt = class {
504
528
  let e = this.getInfo();
505
529
  console.group("[Pipeline] Info"), console.log("Stages:", e.stages), console.log("Context Textures:", e.textures), console.log("Context Render Targets:", e.renderTargets), console.log("Context Uniforms:", e.uniforms), console.log("Event Types:", e.events), console.log("State:", e.contextState), console.groupEnd();
506
530
  }
507
- }, Kt = S("engine"), qt = class {
531
+ }, Yt = b("engine"), Xt = class {
508
532
  constructor() {
509
533
  this.timeElapsed = 0, this.lastResetTime = performance.now(), this.renderCompleteDispatched = !1, this.budgetOverrun = !1, this._budgetHeldWarned = !1;
510
534
  }
@@ -512,7 +536,7 @@ var Gt = class {
512
536
  this.timeElapsed = (performance.now() - this.lastResetTime) / 1e3;
513
537
  }
514
538
  isTimeLimitReached(e, t, n) {
515
- return this.budgetOverrun = !1, t !== "time" && t !== "timeOnly" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0, Kt.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
539
+ return this.budgetOverrun = !1, t !== "time" && t !== "timeOnly" || !(n > 0) || this.timeElapsed < n ? !1 : e?.frameCount > 0 ? (this.budgetOverrun = !0, !0) : (this._budgetHeldWarned || (this._budgetHeldWarned = !0, Yt.warn(`render time limit (${n}s) expired before the first sample landed — holding the deadline open to avoid capturing an empty frame`)), !1);
516
540
  }
517
541
  isLimitReached(e, t, n) {
518
542
  return e ? this.isTimeLimitReached(e, t, n) ? !0 : this.stopCondition(e) !== null : !1;
@@ -529,15 +553,15 @@ var Gt = class {
529
553
  resumeFromPause() {
530
554
  this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
531
555
  }
532
- }, Jt = 864e5, G = Object.freeze({
556
+ }, Zt = 864e5, G = Object.freeze({
533
557
  IMMUTABLE: "immutable",
534
558
  REVALIDATE: "revalidate",
535
559
  NETWORK: "network"
536
- }), Yt = (e, t) => ({
560
+ }), Qt = (e, t) => ({
537
561
  loaded: e,
538
562
  total: t,
539
563
  lengthComputable: t > 0 && e <= t
540
- }), K = (e, t) => e.headers?.get?.(t) ?? null, Xt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
564
+ }), K = (e, t) => e.headers?.get?.(t) ?? null, $t = (e) => e.reason ?? new DOMException("aborted", "AbortError");
541
565
  function q(e) {
542
566
  try {
543
567
  let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
@@ -546,36 +570,36 @@ function q(e) {
546
570
  return "download";
547
571
  }
548
572
  }
549
- async function Zt(e, { onProgress: t, signal: n }) {
573
+ async function en(e, { onProgress: t, signal: n }) {
550
574
  let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
551
575
  if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
552
576
  let a = e.body.getReader(), o = [], s = 0;
553
577
  for (;;) {
554
- if (n?.aborted) throw a.cancel().catch(() => {}), Xt(n);
578
+ if (n?.aborted) throw a.cancel().catch(() => {}), $t(n);
555
579
  let { done: e, value: i } = await a.read();
556
580
  if (e) break;
557
- o.push(i), s += i.length, t?.(Yt(s, r));
581
+ o.push(i), s += i.length, t?.(Qt(s, r));
558
582
  }
559
583
  return new Blob(o, { type: i });
560
584
  }
561
- var Qt = (e, t, n) => new File([e], t, {
585
+ var tn = (e, t, n) => new File([e], t, {
562
586
  type: n || e.type,
563
587
  lastModified: e.lastModified ?? Date.now()
564
- }), $t = () => {}, J = class {
588
+ }), nn = () => {}, J = class {
565
589
  constructor(e) {
566
590
  this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
567
591
  }
568
592
  get _area() {
569
- return this._storage?.area(Se.DOWNLOADS) ?? null;
593
+ return this._storage?.area(we.DOWNLOADS) ?? null;
570
594
  }
571
- async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Jt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
595
+ async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Zt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
572
596
  let c = this._area;
573
597
  if (c && r !== G.NETWORK) {
574
598
  let o = await c.open(t);
575
599
  if (o) {
576
600
  let c = await o.file("data");
577
- if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Yt(c.size, c.size)), {
578
- file: Qt(c, n, o.extra.contentType),
601
+ if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Qt(c.size, c.size)), {
602
+ file: tn(c, n, o.extra.contentType),
579
603
  release: () => o.release(),
580
604
  fromCache: !0
581
605
  };
@@ -593,7 +617,7 @@ var Qt = (e, t, n) => new File([e], t, {
593
617
  return await this._area?.has(e) === !0;
594
618
  }
595
619
  async _download(e, t, n, { onProgress: r, signal: i, fetchOptions: a, cache: o }) {
596
- if (i?.aborted) throw Xt(i);
620
+ if (i?.aborted) throw $t(i);
597
621
  let s = await fetch(e, {
598
622
  ...a,
599
623
  signal: i
@@ -610,17 +634,17 @@ var Qt = (e, t, n) => new File([e], t, {
610
634
  expectedBytes: c
611
635
  }) : null;
612
636
  if (!u) return {
613
- file: Qt(await Zt(s, {
637
+ file: tn(await en(s, {
614
638
  onProgress: r,
615
639
  signal: i
616
640
  }), n, l.contentType),
617
- release: $t,
641
+ release: nn,
618
642
  fromCache: !1
619
643
  };
620
644
  try {
621
645
  await u.writeStream("data", s.body, {
622
646
  signal: i,
623
- onProgress: (e) => r?.(Yt(e, c))
647
+ onProgress: (e) => r?.(Qt(e, c))
624
648
  }), await u.commit(l);
625
649
  } catch (o) {
626
650
  if (await u.abort(), o?.name !== "QuotaExceededError") throw o;
@@ -634,7 +658,7 @@ var Qt = (e, t, n) => new File([e], t, {
634
658
  let d = await this._area.open(t, { wait: !0 }), f = d && await d.file("data");
635
659
  if (!f) throw d?.release(), Error(`storage: ${n} vanished right after it was saved`);
636
660
  return {
637
- file: Qt(f, n, l.contentType),
661
+ file: tn(f, n, l.contentType),
638
662
  release: () => d.release(),
639
663
  fromCache: !1
640
664
  };
@@ -671,16 +695,16 @@ var Qt = (e, t, n) => new File([e], t, {
671
695
  }
672
696
  }
673
697
  };
674
- function en(e, t, n) {
698
+ function rn(e, t, n) {
675
699
  return new J(t).fetch(e, n);
676
700
  }
677
- function tn() {
678
- return new J(xe(E().cacheNamespace));
701
+ function an() {
702
+ return new J(Ce(C().cacheNamespace));
679
703
  }
680
- async function nn(e, { downloads: t = tn(), ...n } = {}) {
704
+ async function on(e, { downloads: t = an(), ...n } = {}) {
681
705
  if (!t._storage || !/^https?:/i.test(e)) return {
682
706
  url: e,
683
- release: $t,
707
+ release: nn,
684
708
  cached: !1
685
709
  };
686
710
  let { file: r, release: i } = await t.fetch(e, n), a = URL.createObjectURL(r);
@@ -694,7 +718,7 @@ async function nn(e, { downloads: t = tn(), ...n } = {}) {
694
718
  }
695
719
  //#endregion
696
720
  //#region src/RenderSettings.js
697
- var rn = {
721
+ var sn = {
698
722
  maxBounces: {
699
723
  uniform: "maxBounces",
700
724
  reset: !0
@@ -920,9 +944,9 @@ var rn = {
920
944
  HOST: "host",
921
945
  SCENE_METADATA: "scene-metadata",
922
946
  MODE_PRESET: "mode-preset"
923
- }), an = class extends L {
947
+ }), cn = class extends I {
924
948
  constructor(e = _, { issues: t = null } = {}) {
925
- super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(rn)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
949
+ super(), this._issues = t, this._defaults = e, this._routes = new Map(Object.entries(sn)), this._values = /* @__PURE__ */ new Map(), this._sources = /* @__PURE__ */ new Map(), this._pathTracer = null, this._resetCallback = null, this._handlers = {}, this._initDefaults(e);
926
950
  }
927
951
  bind(e) {
928
952
  this._pathTracer = e.stages.pathTracer, this._resetCallback = e.resetCallback, this._handlers = this._buildHandlers(e);
@@ -937,12 +961,12 @@ var rn = {
937
961
  !this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
938
962
  }
939
963
  _buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
940
- let a = new Tt(), o = (t, n) => {
941
- a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(R.DEG2RAD), e.pathTracer?.setUniform(t, a);
964
+ let a = new Ot(), o = (t, n) => {
965
+ a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(L.DEG2RAD), e.pathTracer?.setUniform(t, a);
942
966
  };
943
967
  return {
944
968
  handleCameraProjection: (t) => {
945
- e.pathTracer?.setUniform("cameraProjection", ae[t] ?? ae.perspective), i?.(t);
969
+ e.pathTracer?.setUniform("cameraProjection", oe[t] ?? oe.perspective), i?.(t);
946
970
  },
947
971
  handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
948
972
  handlePanoramaLonRange: (e) => o("panoLonRange", e),
@@ -951,7 +975,7 @@ var rn = {
951
975
  e.pathTracer?.setUniform("transparentBackground", t), e.compositor?.setTransparentBackground(t);
952
976
  },
953
977
  handleBackgroundColor: (t) => {
954
- let n = t?.isColor ? t : new I(t);
978
+ let n = t?.isColor ? t : new ot(t);
955
979
  e.pathTracer?.setUniform("backgroundColor", n);
956
980
  },
957
981
  handleExposure: (e) => {
@@ -1028,7 +1052,7 @@ var rn = {
1028
1052
  });
1029
1053
  }
1030
1054
  _reportUnknownKey(e) {
1031
- this._issues?.record(C.SETTING_UNKNOWN_KEY, `unknown setting "${e}" — stored but never applied to any stage`, { key: e });
1055
+ this._issues?.record(x.SETTING_UNKNOWN_KEY, `unknown setting "${e}" — stored but never applied to any stage`, { key: e });
1032
1056
  }
1033
1057
  get(e) {
1034
1058
  return this._values.get(e);
@@ -1069,19 +1093,19 @@ var rn = {
1069
1093
  e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
1070
1094
  }
1071
1095
  _initDefaults(e) {
1072
- for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
1096
+ for (let t of Object.keys(sn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
1073
1097
  }
1074
- }, on = class {
1098
+ }, ln = class {
1075
1099
  constructor({ issues: e = null } = {}) {
1076
- this._issues = e, this._renderer = null, this._offRegistry = ke(() => {
1077
- this._renderer && Oe(this._renderer);
1100
+ this._issues = e, this._renderer = null, this._offRegistry = Me(() => {
1101
+ this._renderer && je(this._renderer);
1078
1102
  });
1079
1103
  }
1080
1104
  get hasConfig() {
1081
1105
  return !1;
1082
1106
  }
1083
1107
  get workingSpace() {
1084
- return T;
1108
+ return S;
1085
1109
  }
1086
1110
  get workingSpaceAdopted() {
1087
1111
  return !1;
@@ -1091,41 +1115,53 @@ var rn = {
1091
1115
  }
1092
1116
  attachRenderer(e) {
1093
1117
  this._renderer = e;
1094
- let t = Oe(e);
1118
+ let t = je(e);
1095
1119
  return e.outputColorSpace = V, t;
1096
1120
  }
1097
1121
  listViews() {
1098
- return Ee();
1122
+ return ke();
1099
1123
  }
1100
1124
  get activeView() {
1101
1125
  return null;
1102
1126
  }
1103
1127
  setActiveView(e) {
1104
- let t = D(e);
1128
+ let t = w(e);
1105
1129
  if (!t) throw Error(`no view transform with id ${e}`);
1106
1130
  if (t.outputEncoded) throw Error(`"${t.name}" returns display-encoded colour: it needs rayzee/addons/color`);
1107
1131
  return this._renderer && (this._renderer.toneMapping = e), t;
1108
1132
  }
1109
1133
  _publishWorkingMatrix() {
1110
- Ce(null, T);
1134
+ Te(null, S);
1111
1135
  }
1112
1136
  loadConfig() {
1113
1137
  let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
1114
- return this._issues?.record(C.CAPABILITY_MISSING, e, { capability: "color" }), Promise.reject(Error(e));
1138
+ return this._issues?.record(x.CAPABILITY_MISSING, e, { capability: "color" }), Promise.reject(Error(e));
1115
1139
  }
1116
1140
  unloadConfig() {}
1117
1141
  setWorkingSpace() {}
1142
+ setHdrOutput(e) {
1143
+ e && this._issues?.warn(x.CAPABILITY_MISSING, "HDR on screen needs rayzee/addons/color", { capability: "color" });
1144
+ }
1145
+ get hdrOutput() {
1146
+ return !1;
1147
+ }
1148
+ get canvasTransform() {
1149
+ return null;
1150
+ }
1151
+ get canvasColorSpace() {
1152
+ return "srgb";
1153
+ }
1118
1154
  exportPixels(e) {
1119
1155
  return {
1120
1156
  rgba: e,
1121
- colorSpace: T
1157
+ colorSpace: S
1122
1158
  };
1123
1159
  }
1124
1160
  status() {
1125
- let e = this._renderer ? D(this._renderer.toneMapping) : null;
1161
+ let e = this._renderer ? w(this._renderer.toneMapping) : null;
1126
1162
  return {
1127
1163
  config: null,
1128
- workingSpace: T,
1164
+ workingSpace: S,
1129
1165
  workingSpaceAdopted: !1,
1130
1166
  activeTransform: e ? {
1131
1167
  id: e.id,
@@ -1135,16 +1171,23 @@ var rn = {
1135
1171
  activeView: null,
1136
1172
  context: null,
1137
1173
  exportSpace: null,
1138
- views: Ee(),
1139
- registryVersion: De(),
1140
- bakeError: e?.error ?? null
1174
+ views: ke(),
1175
+ registryVersion: Ae(),
1176
+ bakeError: e?.error ?? null,
1177
+ canvasColorSpace: "srgb",
1178
+ hdr: {
1179
+ on: !1,
1180
+ showing: !1,
1181
+ view: null,
1182
+ reason: null
1183
+ }
1141
1184
  };
1142
1185
  }
1143
1186
  dispose() {
1144
- this._offRegistry?.(), this._renderer = null, this._issues = null, we() === this && (Ce(null), w(null));
1187
+ this._offRegistry?.(), this._renderer = null, this._issues = null, De() === this && (Te(null), Ee(null));
1145
1188
  }
1146
- }, sn = "KHR_materials_diffuse_transmission";
1147
- function cn(e) {
1189
+ }, un = "KHR_materials_diffuse_transmission";
1190
+ function dn(e) {
1148
1191
  let t = (t, n, r, i) => {
1149
1192
  let a = {};
1150
1193
  return e.assignTexture(a, n, r, i).then(() => {
@@ -1152,7 +1195,7 @@ function cn(e) {
1152
1195
  });
1153
1196
  };
1154
1197
  return {
1155
- name: sn,
1198
+ name: un,
1156
1199
  afterRoot(n) {
1157
1200
  let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
1158
1201
  for (let o of n.scenes ?? []) o.traverse((n) => {
@@ -1160,7 +1203,7 @@ function cn(e) {
1160
1203
  for (let n of o) {
1161
1204
  if (i.has(n)) continue;
1162
1205
  i.add(n);
1163
- let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[sn];
1206
+ let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[un];
1164
1207
  if (!s) continue;
1165
1208
  n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
1166
1209
  let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
@@ -1168,7 +1211,7 @@ function cn(e) {
1168
1211
  1,
1169
1212
  1
1170
1213
  ];
1171
- n.diffuseTransmissionColor = new I().setRGB(c, l, u, ut), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, V));
1214
+ n.diffuseTransmissionColor = new ot().setRGB(c, l, u, mt), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, V));
1172
1215
  }
1173
1216
  });
1174
1217
  return Promise.all(a);
@@ -1177,20 +1220,20 @@ function cn(e) {
1177
1220
  }
1178
1221
  //#endregion
1179
1222
  //#region src/Processor/GLTFDecoders.js
1180
- var ln = "KHR_draco_mesh_compression", un = "KHR_texture_basisu", dn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], fn = new TextDecoder();
1181
- function pn(e) {
1223
+ var fn = "KHR_draco_mesh_compression", pn = "KHR_texture_basisu", mn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], hn = new TextDecoder();
1224
+ function gn(e) {
1182
1225
  if (typeof e == "string") return e;
1183
1226
  if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
1184
1227
  let t = new DataView(e);
1185
- if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return fn.decode(e);
1228
+ if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return hn.decode(e);
1186
1229
  let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
1187
- return fn.decode(new Uint8Array(e, 20, n));
1230
+ return hn.decode(new Uint8Array(e, 20, n));
1188
1231
  }
1189
- async function mn(e, t, n) {
1190
- let { dracoDecoderPath: r, ktx2TranscoderPath: i } = E(), [a, o, s] = await Promise.all([
1191
- t.includes(ln) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
1192
- t.includes(un) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
1193
- dn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
1232
+ async function _n(e, t, n) {
1233
+ let { dracoDecoderPath: r, ktx2TranscoderPath: i } = C(), [a, o, s] = await Promise.all([
1234
+ t.includes(fn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
1235
+ t.includes(pn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
1236
+ mn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
1194
1237
  ]);
1195
1238
  if (a) {
1196
1239
  let t = new a.DRACOLoader();
@@ -1209,15 +1252,15 @@ async function mn(e, t, n) {
1209
1252
  }
1210
1253
  s && e.setMeshoptDecoder(s.MeshoptDecoder);
1211
1254
  }
1212
- function hn(e, t) {
1255
+ function vn(e, t) {
1213
1256
  let n = e.parse.bind(e);
1214
1257
  return e.parse = (r, i, a, o) => {
1215
- mn(e, pn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
1258
+ _n(e, gn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
1216
1259
  }, e;
1217
1260
  }
1218
1261
  //#endregion
1219
1262
  //#region src/Processor/AssetLoader.js
1220
- var gn = S("assets"), _n = {
1263
+ var yn = b("assets"), bn = {
1221
1264
  glb: {
1222
1265
  type: "model",
1223
1266
  name: "GLB (GLTF Binary)"
@@ -1252,7 +1295,7 @@ var gn = S("assets"), _n = {
1252
1295
  }, Z = {
1253
1296
  addOn: "rayzee/addons/formats",
1254
1297
  install: "assetLoader.registerFormat()"
1255
- }, vn = {
1298
+ }, xn = {
1256
1299
  zip: X,
1257
1300
  gz: X,
1258
1301
  tgz: X,
@@ -1269,30 +1312,30 @@ var gn = S("assets"), _n = {
1269
1312
  usdz: Z,
1270
1313
  exr: Z
1271
1314
  };
1272
- function yn(e) {
1273
- let t = new rt();
1315
+ function Sn(e) {
1316
+ let t = new it();
1274
1317
  for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
1275
1318
  e.index && t.setIndex(e.index);
1276
1319
  for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
1277
1320
  return t;
1278
1321
  }
1279
- var bn = {
1322
+ var Cn = {
1280
1323
  name: "RAYZEE_camera_clip",
1281
1324
  afterRoot(e) {
1282
1325
  for (let t of e.scenes) t.traverse((e) => {
1283
1326
  e.isCamera && e.near > 0 && (e.userData.clipStart = e.near);
1284
1327
  });
1285
1328
  }
1286
- }, xn = 683;
1287
- function Sn(e, t, n, r) {
1329
+ }, wn = 683;
1330
+ function Tn(e, t, n, r) {
1288
1331
  if (!(r.normalize ?? !0)) return Math.PI;
1289
1332
  let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new U()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
1290
1333
  return Number.isFinite(o) ? o : Math.PI;
1291
1334
  }
1292
- var Cn = class e extends L {
1335
+ var En = class e extends I {
1293
1336
  constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
1294
- super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new ft(), this._loadCancelled = !1, this._urlAbort = null, this.storage = null, this._downloads = null, this._sourceKey = null, this._appended = !1, this.archives = null, this._archiveLoader = null, this._formats = /* @__PURE__ */ new Map(), this._issues = r, this._areaLightIntensityScale = i ?? (() => _.areaLightIntensityScale), this._loadingManager.onError = (e) => {
1295
- this._loadCancelled || this._issues?.record(C.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
1337
+ super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new gt(), this._loadCancelled = !1, this._urlAbort = null, this.storage = null, this._downloads = null, this._sourceKey = null, this._appended = !1, this.archives = null, this._archiveLoader = null, this._formats = /* @__PURE__ */ new Map(), this._issues = r, this._areaLightIntensityScale = i ?? (() => _.areaLightIntensityScale), this._loadingManager.onError = (e) => {
1338
+ this._loadCancelled || this._issues?.record(x.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
1296
1339
  };
1297
1340
  }
1298
1341
  cancelActiveLoad() {
@@ -1307,7 +1350,7 @@ var Cn = class e extends L {
1307
1350
  let o = new AbortController();
1308
1351
  this._urlAbort = o;
1309
1352
  try {
1310
- return await nn(t, {
1353
+ return await on(t, {
1311
1354
  downloads: this.downloads,
1312
1355
  key: i,
1313
1356
  policy: a,
@@ -1340,7 +1383,7 @@ var Cn = class e extends L {
1340
1383
  _downloadProgress(e, t) {
1341
1384
  return (n) => {
1342
1385
  let r = n?.loaded || 0, i = n?.lengthComputable && n.total || 0;
1343
- y({
1386
+ v({
1344
1387
  isLoading: !0,
1345
1388
  status: e,
1346
1389
  loadedBytes: r,
@@ -1351,7 +1394,7 @@ var Cn = class e extends L {
1351
1394
  };
1352
1395
  }
1353
1396
  _downloadComplete(e = "Processing Data...", t = 62) {
1354
- y({
1397
+ v({
1355
1398
  status: e,
1356
1399
  progress: t,
1357
1400
  canCancel: !1,
@@ -1365,7 +1408,7 @@ var Cn = class e extends L {
1365
1408
  _adoptExternalObject(e) {
1366
1409
  let t;
1367
1410
  try {
1368
- t = jt(e);
1411
+ t = Pt(e);
1369
1412
  } catch (t) {
1370
1413
  throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
1371
1414
  }
@@ -1399,10 +1442,10 @@ var Cn = class e extends L {
1399
1442
  }
1400
1443
  getFileFormat(e) {
1401
1444
  let t = e.split(".").pop().toLowerCase();
1402
- return _n[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
1445
+ return bn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
1403
1446
  }
1404
1447
  formatError(e) {
1405
- let t = vn[e.split(".").pop().toLowerCase()];
1448
+ let t = xn[e.split(".").pop().toLowerCase()];
1406
1449
  return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
1407
1450
  }
1408
1451
  async inspectArchive(e) {
@@ -1425,7 +1468,7 @@ var Cn = class e extends L {
1425
1468
  async loadAssetFromFile(e, t = {}) {
1426
1469
  let n = e.name, r = this.getFileFormat(n);
1427
1470
  if (!r) throw this.formatError(n);
1428
- y({
1471
+ v({
1429
1472
  isLoading: !0,
1430
1473
  status: `Loading ${r.name}...`,
1431
1474
  progress: 2
@@ -1457,7 +1500,7 @@ var Cn = class e extends L {
1457
1500
  async loadFolder(e, t = {}) {
1458
1501
  let n = await this._archiveImporter();
1459
1502
  if (!n) throw Error(`${e.name}: folders are read by ${X.addOn} — install it with ${X.install}`);
1460
- y({
1503
+ v({
1461
1504
  isLoading: !0,
1462
1505
  status: `Loading ${e.name}...`,
1463
1506
  progress: 2
@@ -1477,7 +1520,7 @@ var Cn = class e extends L {
1477
1520
  if (!this.getFileFormat(r)) throw this.formatError(r);
1478
1521
  this._loadCancelled = !1;
1479
1522
  let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
1480
- this._urlAbort = l, y({
1523
+ this._urlAbort = l, v({
1481
1524
  isLoading: !0,
1482
1525
  status: c,
1483
1526
  progress: 2,
@@ -1509,7 +1552,7 @@ var Cn = class e extends L {
1509
1552
  }
1510
1553
  }
1511
1554
  async loadModelFromFile(e, t) {
1512
- let n = this.storage ? this._keyed("file", O(await je(e))) : null, r = /\.(usd|usda|usdc)$/i.test(t) ? await this._archiveImporter() : null, i = r ? await r.loadUSDScene({ [t]: e }, t) : await this._loadModelFileByExtension(e, t);
1555
+ let n = this.storage ? this._keyed("file", T(await Pe(e))) : null, r = /\.(usd|usda|usdc)$/i.test(t) ? await this._archiveImporter() : null, i = r ? await r.loadUSDScene({ [t]: e }, t) : await this._loadModelFileByExtension(e, t);
1513
1556
  return this._sourceKey = n, i;
1514
1557
  }
1515
1558
  async _loadModelFileByExtension(e, t) {
@@ -1521,7 +1564,7 @@ var Cn = class e extends L {
1521
1564
  }
1522
1565
  async _loadModelWithFormat(e, t, n) {
1523
1566
  try {
1524
- y({
1567
+ v({
1525
1568
  isLoading: !0,
1526
1569
  status: `Processing ${e.label} Data...`,
1527
1570
  progress: 5
@@ -1530,7 +1573,7 @@ var Cn = class e extends L {
1530
1573
  filename: n,
1531
1574
  cache: this.loaderCache
1532
1575
  });
1533
- return this.releaseTargetModel(), this.targetModel = r, y({
1576
+ return this.releaseTargetModel(), this.targetModel = r, v({
1534
1577
  isLoading: !0,
1535
1578
  status: "Processing Data...",
1536
1579
  progress: 10
@@ -1556,7 +1599,7 @@ var Cn = class e extends L {
1556
1599
  };
1557
1600
  try {
1558
1601
  let r = await this.loadEnvironment(n);
1559
- return he(r, O(await je(e))), this.dispatchEvent({
1602
+ return _e(r, T(await Pe(e))), this.dispatchEvent({
1560
1603
  type: "load",
1561
1604
  texture: r,
1562
1605
  filename: t
@@ -1578,7 +1621,7 @@ var Cn = class e extends L {
1578
1621
  let e = t.split(/[?#]/)[0].split(".").pop().toLowerCase();
1579
1622
  n = await this.loadEnvironmentByExtension(t, e);
1580
1623
  }
1581
- return n.generateMipmaps = !0, e._isNetworkUrl(t) && he(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
1624
+ return n.generateMipmaps = !0, e._isNetworkUrl(t) && _e(n, t), this.applyEnvironmentToScene(n), this.dispatchEvent({
1582
1625
  type: "load",
1583
1626
  texture: n,
1584
1627
  url: t,
@@ -1615,25 +1658,25 @@ var Cn = class e extends L {
1615
1658
  }
1616
1659
  async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
1617
1660
  let i = this._formats.get(n);
1618
- if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new kt(this._loadingManager).setDataType(ct)), !r && vn[n]) throw this.formatError(`environment.${n}`);
1661
+ if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Mt(this._loadingManager).setDataType(dt)), !r && xn[n]) throw this.formatError(`environment.${n}`);
1619
1662
  let a = e._isNetworkUrl(t), o = "Downloading Environment...", s = await this._viaCache(t, o, a), c = s.cached ? void 0 : this._downloadProgress(o, a), l;
1620
1663
  try {
1621
- r ? l = await r.loadAsync(s.url, c) : ge().decodeImage ? (l = await Le(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = V) : (this.loaderCache.texture || (this.loaderCache.texture = new wt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = V);
1664
+ r ? l = await r.loadAsync(s.url, c) : ve().decodeImage ? (l = await Be(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = V) : (this.loaderCache.texture || (this.loaderCache.texture = new Dt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = V);
1622
1665
  } finally {
1623
1666
  s.release();
1624
1667
  }
1625
- return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && wn(l, this.maxEnvironmentWidth), l.mapping = st, l.minFilter = lt, l.magFilter = lt, l;
1668
+ return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && Dn(l, this.maxEnvironmentWidth), l.mapping = ut, l.minFilter = pt, l.magFilter = pt, l;
1626
1669
  }
1627
1670
  applyEnvironmentToScene(e) {
1628
1671
  this.scene.background = e, this.scene.environment = e;
1629
1672
  }
1630
1673
  async createGLTFLoader() {
1631
- let e = hn(new Ot(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
1632
- return ge().decodeImage ? e.register((e) => Ie(e, t)) : ne() || e.register((e) => Pe(e, t)), e.register((e) => cn(e)), e.register(() => bn), e;
1674
+ let e = vn(new jt(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
1675
+ return ve().decodeImage ? e.register((e) => ze(e, t)) : ne() || e.register((e) => Le(e, t)), e.register((e) => dn(e)), e.register(() => Cn), e;
1633
1676
  }
1634
1677
  _reportImageFailure(e, t) {
1635
1678
  try {
1636
- this._issues?.record(C.TEXTURE_BUILD_FAILED, `image ${e} could not be decoded (${t?.message ?? t}) — the surfaces using it render untextured`, {
1679
+ this._issues?.record(x.TEXTURE_BUILD_FAILED, `image ${e} could not be decoded (${t?.message ?? t}) — the surfaces using it render untextured`, {
1637
1680
  image: e,
1638
1681
  cause: String(t?.message ?? t)
1639
1682
  });
@@ -1657,16 +1700,16 @@ var Cn = class e extends L {
1657
1700
  this._loadCancelled = !1;
1658
1701
  let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
1659
1702
  try {
1660
- y({
1703
+ v({
1661
1704
  isLoading: !0,
1662
1705
  status: "Downloading Model...",
1663
1706
  progress: 2,
1664
1707
  canCancel: i,
1665
1708
  loadedBytes: 0,
1666
1709
  totalBytes: 0
1667
- }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
1668
- let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
1669
- return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata = Re(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
1710
+ }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(ht.extractUrlBase(t));
1711
+ let e = await ae(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
1712
+ return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata = Ve(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
1670
1713
  type: "load",
1671
1714
  model: e.scene,
1672
1715
  filename: t.split("/").pop()
@@ -1688,15 +1731,15 @@ var Cn = class e extends L {
1688
1731
  this._loadCancelled = !1;
1689
1732
  let r = await this.createGLTFLoader(), i = e._isNetworkUrl(t), a = null;
1690
1733
  try {
1691
- y({
1734
+ v({
1692
1735
  isLoading: !0,
1693
1736
  status: "Downloading Model...",
1694
1737
  progress: 2,
1695
1738
  canCancel: i,
1696
1739
  loadedBytes: 0,
1697
1740
  totalBytes: 0
1698
- }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
1699
- let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
1741
+ }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(ht.extractUrlBase(t));
1742
+ let e = await ae(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
1700
1743
  return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
1701
1744
  root: e.scene,
1702
1745
  animations: e.animations || []
@@ -1718,13 +1761,13 @@ var Cn = class e extends L {
1718
1761
  async loadGLBFromArrayBuffer(e, t = "model.glb") {
1719
1762
  let n = await this.createGLTFLoader();
1720
1763
  try {
1721
- y({
1764
+ v({
1722
1765
  isLoading: !0,
1723
1766
  status: "Processing GLB Data...",
1724
1767
  progress: 5
1725
1768
  }), await new Promise((e) => setTimeout(e, 0));
1726
- let r = await v(() => n.parseAsync(e, ""));
1727
- return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r), y({
1769
+ let r = await ae(() => n.parseAsync(e, ""));
1770
+ return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Ve(r), v({
1728
1771
  isLoading: !0,
1729
1772
  status: "Processing Data...",
1730
1773
  progress: 10
@@ -1746,7 +1789,7 @@ var Cn = class e extends L {
1746
1789
  async loadObject3D(e, t = "object3d") {
1747
1790
  this.releaseTargetModel();
1748
1791
  let n = this._adoptExternalObject(e);
1749
- return n.name = e.name || t, this.targetModel = n, y({
1792
+ return n.name = e.name || t, this.targetModel = n, v({
1750
1793
  isLoading: !0,
1751
1794
  status: "Processing Data...",
1752
1795
  progress: 10
@@ -1761,7 +1804,7 @@ var Cn = class e extends L {
1761
1804
  t.start("Camera extraction");
1762
1805
  let n = this.extractCamerasFromModel(e);
1763
1806
  t.end("Camera extraction"), t.start("Camera setup");
1764
- let r = new nt().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
1807
+ let r = new rt().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
1765
1808
  this.controls?.target.copy(i);
1766
1809
  let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2), l = Math.PI / 6, u = new U(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
1767
1810
  if (this.camera.position.copy(u.add(i)), this.camera.lookAt(i), this.camera.near = o / 100, this.camera.far = o * 100, this.camera.updateProjectionMatrix(), this.controls && (this.controls.maxDistance = c * 10, this.controls.saveState(), this.controls.update()), t.end("Camera setup"), this.floorPlane) {
@@ -1800,22 +1843,22 @@ var Cn = class e extends L {
1800
1843
  let t = [], n = [];
1801
1844
  e.traverse((e) => {
1802
1845
  let r = e.userData;
1803
- e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Sn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / xn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= xn, r.__luxConverted = !0);
1846
+ e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Tn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / wn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= wn, r.__luxConverted = !0);
1804
1847
  let i = e.name.startsWith("RectAreaLightPlaceholder");
1805
1848
  if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
1806
- let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Sn(e, r.width, r.height, r), a = new B(new I(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
1849
+ let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Tn(e, r.width, r.height, r), a = new B(new ot(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
1807
1850
  a.userData.normalize = t, a.userData.spread = Number.isFinite(r.spread) ? r.spread : Math.PI, a.userData.shape = n, a.userData.__radianceConverted = !0, a.name = r.name, e.add(a);
1808
1851
  }
1809
1852
  e.isMesh && Array.isArray(e.material) && t.push(e);
1810
- }), n.length && this._issues?.record(C.LIGHT_PLACEHOLDER_SKIPPED, `${n.length} area-light placeholder(s) lack userData.name or userData.type 'RectAreaLight' — no light was made for them`, {
1853
+ }), n.length && this._issues?.record(x.LIGHT_PLACEHOLDER_SKIPPED, `${n.length} area-light placeholder(s) lack userData.name or userData.type 'RectAreaLight' — no light was made for them`, {
1811
1854
  count: n.length,
1812
1855
  names: n.slice(0, 10)
1813
1856
  });
1814
1857
  let r = e.userData.__rayzeeExternal === !0;
1815
1858
  for (let e of t) {
1816
1859
  if (!e.parent) continue;
1817
- console.log("Found multi-material mesh:", e.name), r && (e.geometry = yn(e.geometry));
1818
- let t = At(e);
1860
+ console.log("Found multi-material mesh:", e.name), r && (e.geometry = Sn(e.geometry));
1861
+ let t = Nt(e);
1819
1862
  for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
1820
1863
  e.parent.add(t), e.parent.remove(e);
1821
1864
  }
@@ -1824,7 +1867,7 @@ var Cn = class e extends L {
1824
1867
  this.sceneScale = t;
1825
1868
  }
1826
1869
  createFloorPlane() {
1827
- this.floorPlane = new pt(new it(), new mt({
1870
+ this.floorPlane = new _t(new at(), new vt({
1828
1871
  transparent: !1,
1829
1872
  color: 3158064,
1830
1873
  roughness: 1,
@@ -1847,7 +1890,7 @@ var Cn = class e extends L {
1847
1890
  }
1848
1891
  getSupportedFormats(e = null) {
1849
1892
  let t = {
1850
- ..._n,
1893
+ ...bn,
1851
1894
  ...this._archiveFormats
1852
1895
  };
1853
1896
  for (let [e, { type: n, name: r }] of this._formats) t[e] = {
@@ -1872,7 +1915,7 @@ var Cn = class e extends L {
1872
1915
  this._listeners = void 0;
1873
1916
  }
1874
1917
  };
1875
- function wn(e, t) {
1918
+ function Dn(e, t) {
1876
1919
  let { data: n, width: r, height: i } = e.image ?? {};
1877
1920
  if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
1878
1921
  let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
@@ -1893,17 +1936,17 @@ function wn(e, t) {
1893
1936
  data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
1894
1937
  width: o,
1895
1938
  height: s
1896
- }, e.needsUpdate = !0, gn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
1939
+ }, e.needsUpdate = !0, yn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
1897
1940
  }
1898
1941
  //#endregion
1899
1942
  //#region src/HeadlessCanvas.js
1900
- var Tn = {
1943
+ var On = {
1901
1944
  addEventListener() {},
1902
1945
  removeEventListener() {},
1903
1946
  dispatchEvent() {
1904
1947
  return !0;
1905
1948
  }
1906
- }, En = class {
1949
+ }, kn = class {
1907
1950
  constructor(e) {
1908
1951
  this.canvas = e, this._configuration = null, this._texture = null;
1909
1952
  }
@@ -1931,12 +1974,12 @@ var Tn = {
1931
1974
  return this._texture;
1932
1975
  }
1933
1976
  };
1934
- function Dn(e = 1, t = 1) {
1977
+ function An(e = 1, t = 1) {
1935
1978
  let n = {
1936
- ...Tn,
1979
+ ...On,
1937
1980
  defaultView: null
1938
1981
  }, r = {
1939
- ...Tn,
1982
+ ...On,
1940
1983
  isHeadlessCanvas: !0,
1941
1984
  width: e,
1942
1985
  height: t,
@@ -1963,12 +2006,12 @@ function Dn(e = 1, t = 1) {
1963
2006
  hasPointerCapture: () => !1,
1964
2007
  focus() {},
1965
2008
  getContext: (e) => e === "webgpu" ? i : null
1966
- }, i = new En(r);
2009
+ }, i = new kn(r);
1967
2010
  return r;
1968
2011
  }
1969
2012
  //#endregion
1970
2013
  //#region src/managers/ViewCamera.js
1971
- var On = class extends vt {
2014
+ var jn = class extends xt {
1972
2015
  constructor(e, t, n, r) {
1973
2016
  super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
1974
2017
  }
@@ -1992,17 +2035,17 @@ var On = class extends vt {
1992
2035
  return -this.orthoHalfHeight * this.aspect;
1993
2036
  }
1994
2037
  updateProjectionMatrix() {
1995
- this.orthographic ? _t.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
2038
+ this.orthographic ? bt.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
1996
2039
  }
1997
2040
  copy(e, t) {
1998
2041
  return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
1999
2042
  }
2000
- }, kn = "__rayzeeUserLight", An = {
2001
- DirectionalLight: at,
2002
- PointLight: yt,
2003
- SpotLight: St,
2043
+ }, Mn = "__rayzeeUserLight", Nn = {
2044
+ DirectionalLight: ct,
2045
+ PointLight: St,
2046
+ SpotLight: Tt,
2004
2047
  RectAreaLight: B
2005
- }, jn = class extends L {
2048
+ }, Pn = class extends I {
2006
2049
  constructor(e, t, n, r = {}) {
2007
2050
  super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
2008
2051
  }
@@ -2050,14 +2093,14 @@ var On = class extends vt {
2050
2093
  }[e];
2051
2094
  if (!t) return null;
2052
2095
  let n;
2053
- if (e === "DirectionalLight") n = new at(t.color, t.intensity), n.position.fromArray(t.position);
2054
- else if (e === "PointLight") n = new yt(t.color, t.intensity), n.position.fromArray(t.position);
2096
+ if (e === "DirectionalLight") n = new ct(t.color, t.intensity), n.position.fromArray(t.position);
2097
+ else if (e === "PointLight") n = new St(t.color, t.intensity), n.position.fromArray(t.position);
2055
2098
  else if (e === "SpotLight") {
2056
- n = new St(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
2099
+ n = new Tt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = L.degToRad(t.angle);
2057
2100
  let e = new z();
2058
2101
  this.scene.add(e), n.target = e;
2059
2102
  } else e === "RectAreaLight" && (n = new B(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
2060
- n.userData[kn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
2103
+ n.userData[Mn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
2061
2104
  let r = this.scene.getObjectsByProperty("isLight", !0).length;
2062
2105
  return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
2063
2106
  }
@@ -2083,7 +2126,7 @@ var On = class extends vt {
2083
2126
  this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
2084
2127
  }
2085
2128
  transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
2086
- this._removeAllLights(t ? (e) => !e.userData?.[kn] : void 0);
2129
+ this._removeAllLights(t ? (e) => !e.userData?.[Mn] : void 0);
2087
2130
  let n = e.getObjectsByProperty("isLight", !0);
2088
2131
  if (!n || n.length === 0) {
2089
2132
  this.updateLights();
@@ -2137,7 +2180,7 @@ var On = class extends vt {
2137
2180
  this.sceneHelpers?.clear(), this._removeAllLights();
2138
2181
  let t = [];
2139
2182
  for (let n of e ?? []) {
2140
- let e = An[n.type];
2183
+ let e = Nn[n.type];
2141
2184
  if (!e) continue;
2142
2185
  let r = new e();
2143
2186
  r.name = n.name ?? "", r.visible = n.visible !== !1, r.color.setRGB(...n.color), r.intensity = n.intensity, r.position.fromArray(n.position), r.quaternion.fromArray(n.quaternion), r.scale.fromArray(n.scale ?? [
@@ -2194,7 +2237,7 @@ var On = class extends vt {
2194
2237
  }
2195
2238
  _buildDescriptor(e) {
2196
2239
  let t = 0;
2197
- e.type === "SpotLight" && e.angle !== void 0 ? t = R.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = R.radToDeg(e.userData?.angle ?? 0));
2240
+ e.type === "SpotLight" && e.angle !== void 0 ? t = L.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = L.radToDeg(e.userData?.angle ?? 0));
2198
2241
  let n = {
2199
2242
  uuid: e.uuid,
2200
2243
  name: e.name,
@@ -2213,7 +2256,7 @@ var On = class extends vt {
2213
2256
  exposure: e.userData?.exposure ?? 0
2214
2257
  };
2215
2258
  if (e.type === "RectAreaLight") {
2216
- n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = R.radToDeg(e.userData?.spread ?? Math.PI);
2259
+ n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = L.radToDeg(e.userData?.spread ?? Math.PI);
2217
2260
  let t = e.userData?.shape;
2218
2261
  n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
2219
2262
  let r = e.getWorldDirection(e.position.clone());
@@ -2229,11 +2272,11 @@ var On = class extends vt {
2229
2272
  ], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
2230
2273
  return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
2231
2274
  }
2232
- }, Mn = ({ element: e, pbrtEntry: t } = {}) => ({
2275
+ }, Fn = ({ element: e, pbrtEntry: t } = {}) => ({
2233
2276
  ...e === void 0 ? {} : { element: e },
2234
2277
  ...t === void 0 ? {} : { pbrtEntry: t }
2235
- }), Q = /* @__PURE__ */ new WeakMap(), Nn = 3e4, Pn = new Set([...Object.values(g), ...Object.values(h)]), Fn = /* @__PURE__ */ new Set();
2236
- async function In(e, t) {
2278
+ }), Q = /* @__PURE__ */ new WeakMap(), In = 3e4, Ln = new Set([...Object.values(g), ...Object.values(h)]), Rn = /* @__PURE__ */ new Set();
2279
+ async function zn(e, t) {
2237
2280
  if (!t || typeof self < "u") return e.init();
2238
2281
  globalThis.self = {
2239
2282
  requestAnimationFrame: () => 0,
@@ -2245,17 +2288,17 @@ async function In(e, t) {
2245
2288
  delete globalThis.self;
2246
2289
  }
2247
2290
  }
2248
- var $ = S("engine");
2249
- function Ln() {
2291
+ var $ = b("engine");
2292
+ function Bn() {
2250
2293
  let e = new Float32Array(16);
2251
- return new Uint32Array(e.buffer)[3] = ve.TRIANGLE_LEAF, e;
2294
+ return new Uint32Array(e.buffer)[3] = be.TRIANGLE_LEAF, e;
2252
2295
  }
2253
- function Rn(e, t) {
2296
+ function Vn(e, t) {
2254
2297
  e.lost.then((e) => {
2255
2298
  t.app && t.app._handleDeviceLost(e);
2256
2299
  });
2257
2300
  }
2258
- var zn = [
2301
+ var Hn = [
2259
2302
  "core-features-and-limits",
2260
2303
  "depth-clip-control",
2261
2304
  "depth32float-stencil8",
@@ -2276,33 +2319,33 @@ var zn = [
2276
2319
  "subgroups",
2277
2320
  "texture-formats-tier1",
2278
2321
  "texture-formats-tier2"
2279
- ], Bn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
2280
- function Vn(e) {
2322
+ ], Un = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
2323
+ function Wn(e) {
2281
2324
  let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
2282
2325
  return {
2283
2326
  vendor: t.vendor ?? "",
2284
2327
  architecture: t.architecture ?? "",
2285
2328
  device: t.device ?? "",
2286
2329
  description: t.description ?? "",
2287
- isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Bn.test(n)
2330
+ isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Un.test(n)
2288
2331
  };
2289
2332
  }
2290
- var Hn = class extends L {
2333
+ var Gn = class extends I {
2291
2334
  constructor(e, t = {}) {
2292
- super(), this._headless = t.headless === !0 || !e, e ??= Dn();
2335
+ super(), this._headless = t.headless === !0 || !e, e ??= An();
2293
2336
  try {
2294
2337
  Q.get(e)?.dispose();
2295
2338
  } catch (e) {
2296
2339
  $.warn("prior canvas owner dispose failed", e);
2297
2340
  }
2298
2341
  if (Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0 || t.memorySpill === !1 ? t.memorySpill : "auto", this._spillPlan = null, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1, t.profile !== void 0) throw Error("the `profile` option was removed: the engine has one set of defaults. For the old 'physical' profile set `areaLightIntensityScale: 1` and `dofMode: 'physical'` through `settings`.");
2299
- this._issues = new ye({
2342
+ this._issues = new xe({
2300
2343
  strict: t.strict === !0,
2301
2344
  onIssue: (e) => this.dispatchEvent({
2302
2345
  type: g.ISSUE,
2303
2346
  issue: e
2304
2347
  })
2305
- }), this.color = new on({ issues: this._issues }), w(this.color), this.settings = new an(_, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.camera = null, this.lightManager = null, this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new qt(), this._resizeDebounceTimer = null, this._displayWidth = 0, this._displayHeight = 0, this._renderScale = 1, this._renderWidth = 0, this._renderHeight = 0, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
2348
+ }), this.color = new ln({ issues: this._issues }), Ee(this.color), this.settings = new cn(_, { issues: this._issues }), this.renderer = null, this.scene = null, this.meshScene = null, this._sceneHelpers = null, this.assetLoader = null, this._sdf = null, this.pipeline = null, this._pendingReservedRenderSize = null, this.stages = {}, this.camera = null, this.lightManager = null, this.environmentManager = null, this.isInitialized = !1, this.pauseRendering = !1, this._pathTracerEnabled = !0, this._rasterPrecompile = null, this.animationManagerId = null, this.needsReset = !1, this._loadingInProgress = !1, this._needsDisplayRefresh = !1, this._paused = !1, this._emissiveSamplingUserSet = !1, this.completion = new Xt(), this._resizeDebounceTimer = null, this._displayWidth = 0, this._displayHeight = 0, this._renderScale = 1, this._renderWidth = 0, this._renderHeight = 0, this._trackedListeners = [], this._disposed = !1, this._deviceLost = !1, this._gpuDevice = null, this._deviceLostHolder = null, this._deterministic = !1, this._dispatchPinned = !1, this._deterministicRestore = null, this.adapterInfo = null;
2306
2349
  }
2307
2350
  _addTrackedListener(e, t, n) {
2308
2351
  e && (e.addEventListener(t, n), this._trackedListeners.push({
@@ -2321,27 +2364,27 @@ var Hn = class extends L {
2321
2364
  }
2322
2365
  async init() {
2323
2366
  let e = this._initStorage();
2324
- return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
2367
+ return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(ye.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Bn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
2325
2368
  }
2326
2369
  async setStorageOpener(e) {
2327
2370
  this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
2328
2371
  }
2329
2372
  async _initStorage() {
2330
- let e = this._storageOption ?? (this._issues.strict && !Te("storage") ? !1 : E().storage);
2373
+ let e = this._storageOption ?? (this._issues.strict && !Oe("storage") ? !1 : C().storage);
2331
2374
  if (e !== !1) {
2332
2375
  if (e && typeof e == "object") this.storage = e;
2333
2376
  else {
2334
2377
  if (!this._storageOpener) {
2335
- (this._storageOption !== void 0 || Te("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
2378
+ (this._storageOption !== void 0 || Oe("storage")) && this._issues.warn(x.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
2336
2379
  return;
2337
2380
  }
2338
- let { storage: e, reason: t, release: n } = await this._storageOpener(E().cacheNamespace);
2381
+ let { storage: e, reason: t, release: n } = await this._storageOpener(C().cacheNamespace);
2339
2382
  if (this._disposed) {
2340
2383
  n();
2341
2384
  return;
2342
2385
  }
2343
2386
  if (!e) {
2344
- this._issues.warn(C.STORAGE_UNAVAILABLE, `on-disk storage is off: ${t}`, { reason: t });
2387
+ this._issues.warn(x.STORAGE_UNAVAILABLE, `on-disk storage is off: ${t}`, { reason: t });
2345
2388
  return;
2346
2389
  }
2347
2390
  this.storage = e, this._storageRelease = n;
@@ -2364,7 +2407,7 @@ var Hn = class extends L {
2364
2407
  });
2365
2408
  }
2366
2409
  addEventListener(e, t) {
2367
- !Pn.has(e) && !Fn.has(e) && (Fn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
2410
+ !Ln.has(e) && !Rn.has(e) && (Rn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
2368
2411
  }
2369
2412
  animate() {
2370
2413
  if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
@@ -2415,9 +2458,9 @@ var Hn = class extends L {
2415
2458
  let t = this.stages.pathTracer;
2416
2459
  this.pipeline.render(), this._afterTrace(t, e), t.isComplete || this.completion.updateTime(), this._ensureVRAMWiring();
2417
2460
  let n = t.vramTracker, r = t.frameCount ?? 0;
2418
- n && (r <= 1 || r % 30 == 0) && n.measure(), ue({
2461
+ n && (r <= 1 || r % 30 == 0) && n.measure(), fe({
2419
2462
  timeElapsed: this.completion.timeElapsed,
2420
- samples: pe(t),
2463
+ samples: he(t),
2421
2464
  memoryUsed: n?.current ?? 0,
2422
2465
  memoryPeak: n?.peak ?? 0
2423
2466
  }), this.completion.isTimeLimitReached(t, this.settings.get("renderLimitMode"), this.settings.get("renderTimeLimit")) && (t.isComplete = !0);
@@ -2454,7 +2497,7 @@ var Hn = class extends L {
2454
2497
  }
2455
2498
  dispose() {
2456
2499
  if (this._disposed) return;
2457
- if (this._disposed = !0, this.dispatchEvent({ type: g.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), fe(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._textureReadback?.dispose(), this._textureReadback = null, this._readbackToneMapper?.dispose(), this._readbackToneMapper = null, this._disposeExtensions(), this.lightManager?.dispose(), this.pipeline?.dispose(), this._sdf?.dispose(), this._sdf = null, this.assetLoader?.dispose(), this.assetLoader = null, this.meshScene) {
2500
+ if (this._disposed = !0, this.dispatchEvent({ type: g.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), me(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._pictureCopy = null, this._textureReadback?.dispose(), this._textureReadback = null, this._readbackToneMapper?.dispose(), this._readbackToneMapper = null, this._disposeExtensions(), this.lightManager?.dispose(), this.pipeline?.dispose(), this._sdf?.dispose(), this._sdf = null, this.assetLoader?.dispose(), this.assetLoader = null, this.meshScene) {
2458
2501
  this.meshScene.environment?.dispose(), this.meshScene.environment = null;
2459
2502
  for (let e of [...this.meshScene.children]) te(e);
2460
2503
  this.meshScene.clear(), this.meshScene = null;
@@ -2468,12 +2511,12 @@ var Hn = class extends L {
2468
2511
  }
2469
2512
  this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas);
2470
2513
  let e = this._gpuDevice;
2471
- e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(se(this.renderer)).finally(() => e?.destroy()), this.renderer = null, this.stages = {}, this.isInitialized = !1;
2514
+ e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(ce(this.renderer)).finally(() => e?.destroy()), this.renderer = null, this.stages = {}, this.isInitialized = !1;
2472
2515
  }
2473
2516
  unloadScene() {
2474
2517
  if (this.isInitialized) {
2475
2518
  if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
2476
- this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setEmissiveTriangleData?.(new Float32Array(), 0, 0), this.stages.pathTracer.setupMaterial()), this._dropDisplay(), this.reset(), this.dispatchEvent({ type: g.SCENE_UNLOADED }));
2519
+ this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(ye.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Bn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setEmissiveTriangleData?.(new Float32Array(), 0, 0), this.stages.pathTracer.setupMaterial()), this._dropDisplay(), this.reset(), this.dispatchEvent({ type: g.SCENE_UNLOADED }));
2477
2520
  }
2478
2521
  }
2479
2522
  async loadModel(e, t = {}) {
@@ -2532,24 +2575,24 @@ var Hn = class extends L {
2532
2575
  url: e,
2533
2576
  filename: n,
2534
2577
  cacheKey: t.cacheKey ?? null,
2535
- ...Mn(t)
2578
+ ...Fn(t)
2536
2579
  });
2537
2580
  return;
2538
2581
  }
2539
- if (Ne(e)) {
2540
- let n = Fe(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
2582
+ if (Ie(e)) {
2583
+ let n = Re(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
2541
2584
  if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
2542
2585
  await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
2543
2586
  type: g.MODEL_LOADED,
2544
2587
  filename: n.name
2545
2588
  }, async () => {
2546
- let e = await Me(n);
2589
+ let e = await Fe(n);
2547
2590
  return {
2548
2591
  kind: "local-folder",
2549
2592
  folder: e,
2550
- key: O(e),
2593
+ key: T(e),
2551
2594
  ...n.flat ? { flat: !0 } : {},
2552
- ...Mn(t)
2595
+ ...Fn(t)
2553
2596
  };
2554
2597
  }), this._sceneSourceInput = n;
2555
2598
  return;
@@ -2557,7 +2600,7 @@ var Hn = class extends L {
2557
2600
  let n = this.assetLoader?.getFileFormat(e?.name || "");
2558
2601
  if (!n) throw this.assetLoader.formatError(e?.name || "");
2559
2602
  if (n.type !== "environment" && n.type !== "image") {
2560
- let n = je(e).catch(() => ({
2603
+ let n = Pe(e).catch(() => ({
2561
2604
  name: e.name,
2562
2605
  size: e.size,
2563
2606
  lastModified: e.lastModified ?? 0,
@@ -2571,8 +2614,8 @@ var Hn = class extends L {
2571
2614
  return {
2572
2615
  kind: "local-file",
2573
2616
  file: e,
2574
- key: e.sample ? O(e) : null,
2575
- ...Mn(t)
2617
+ key: e.sample ? T(e) : null,
2618
+ ...Fn(t)
2576
2619
  };
2577
2620
  }), this._sceneSourceInput = e;
2578
2621
  return;
@@ -2621,20 +2664,20 @@ var Hn = class extends L {
2621
2664
  return this._sceneSource ?? null;
2622
2665
  }
2623
2666
  get sceneSourceFile() {
2624
- return this._sceneSourceInput && !Ne(this._sceneSourceInput) ? this._sceneSourceInput : null;
2667
+ return this._sceneSourceInput && !Ie(this._sceneSourceInput) ? this._sceneSourceInput : null;
2625
2668
  }
2626
2669
  get sceneSourceFolder() {
2627
- return Ne(this._sceneSourceInput) ? this._sceneSourceInput : null;
2670
+ return Ie(this._sceneSourceInput) ? this._sceneSourceInput : null;
2628
2671
  }
2629
2672
  async _loadWithSceneRebuild(e, t, n = null) {
2630
2673
  if (this._loadingInProgress) throw this._busyError("PathTracerApp");
2631
- this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? le : 0);
2674
+ this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? ue : 0);
2632
2675
  try {
2633
2676
  await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill();
2634
2677
  let r = await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
2635
2678
  this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced(), r && this.assetLoader?.commitPendingGraph(this.sceneModel);
2636
2679
  } catch (e) {
2637
- throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? b() : e?.code !== "LOAD_IN_PROGRESS" && y({
2680
+ throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? de() : e?.code !== "LOAD_IN_PROGRESS" && v({
2638
2681
  status: `Error: ${e?.message ?? e}`,
2639
2682
  failed: !0,
2640
2683
  progress: 100
@@ -2657,7 +2700,7 @@ var Hn = class extends L {
2657
2700
  _beginSceneMetadataEnvironment() {
2658
2701
  this._restoreUnlitSettings();
2659
2702
  let e = this.sceneMetadata?.environment;
2660
- return this._applySceneMetadataEnabled && e?.enabled === !1 ? (this._applyUnlitSettings(), null) : !this._applySceneMetadataEnabled || !e?.sourceFile || !this.stages.pathTracer ? null : (this.stages.pathTracer.environment.beginHDRI(), this._applyingSceneMetadata = !0, this.assetLoader.loadEnvironment(e.sourceFile).catch((t) => (this._issues.record(C.ENVIRONMENT_LOAD_FAILED, `authored environment "${e.sourceFile}" failed to load — lighting falls back to the previous environment`, {
2703
+ return this._applySceneMetadataEnabled && e?.enabled === !1 ? (this._applyUnlitSettings(), null) : !this._applySceneMetadataEnabled || !e?.sourceFile || !this.stages.pathTracer ? null : (this.stages.pathTracer.environment.beginHDRI(), this._applyingSceneMetadata = !0, this.assetLoader.loadEnvironment(e.sourceFile).catch((t) => (this._issues.record(x.ENVIRONMENT_LOAD_FAILED, `authored environment "${e.sourceFile}" failed to load — lighting falls back to the previous environment`, {
2661
2704
  sourceFile: e.sourceFile,
2662
2705
  cause: String(t?.message ?? t)
2663
2706
  }), null)).finally(() => {
@@ -2721,20 +2764,20 @@ var Hn = class extends L {
2721
2764
  }), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
2722
2765
  if (e ? (n.start("Environment fetch + CDF (concurrent)"), a = e.then(async (e) => {
2723
2766
  e && (await this.stages.pathTracer.environment.applyHDRI(e), this._applySceneMetadataSettings(e));
2724
- }).catch((e) => this._issues.record(C.ENVIRONMENT_LOAD_FAILED, "authored environment failed to install — the scene is lit by whatever was already loaded", { cause: String(e?.message ?? e) })).finally(() => n.end("Environment fetch + CDF (concurrent)"))) : i?.image?.data && (n.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = i, a = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => {
2767
+ }).catch((e) => this._issues.record(x.ENVIRONMENT_LOAD_FAILED, "authored environment failed to install — the scene is lit by whatever was already loaded", { cause: String(e?.message ?? e) })).finally(() => n.end("Environment fetch + CDF (concurrent)"))) : i?.image?.data && (n.start("Environment CDF build (worker)"), this.stages.pathTracer.scene.environment = i, a = this.stages.pathTracer.environment.buildEnvironmentCDF().then(() => {
2725
2768
  n.end("Environment CDF build (worker)"), this._applySceneMetadataEnabled && this._applySceneMetadataSettings(i);
2726
2769
  })), n.start("BVH build (SceneProcessor)"), this._sdf.setMaxTextureSize(this.settings.get("maxTextureSize")), await this._sdf.buildBVH(this.meshScene, {
2727
2770
  sceneKey: this.assetLoader?.sceneSourceKey ?? null,
2728
2771
  progressive: this._progressiveSpill()
2729
- }), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), y({
2772
+ }), this.assetLoader?.flushPendingGraph(this._sdf.performanceMetrics.totalProcessingTime), n.end("BVH build (SceneProcessor)"), v({
2730
2773
  status: "Transferring data to GPU...",
2731
2774
  progress: 86
2732
2775
  }), await new Promise((e) => setTimeout(e, 0)), n.start("GPU data transfer"), await this._sdf.uploadChunks(this._chunkUploader()), !this._sdf.uploadToPathTracer(this.stages.pathTracer, this.lightManager, this.meshScene, r(), { keepUserLights: t })) return !1;
2733
2776
  for (let e of [...this._sdf.srgbBucketTextures ?? [], ...this._sdf.linearBucketTextures ?? []]) e && (this.renderer.initTexture(e), await this.stages.pathTracer.drainUploads());
2734
- this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), n.end("GPU data transfer"), y({
2777
+ this.stages.pathTracer._meshRefs = this.stages.pathTracer._collectMeshRefs(this.meshScene), this.stages.pathTracer.setMeshVisibilityData(this.stages.pathTracer._meshRefs), this._refreshEmissiveForVisibility(), n.end("GPU data transfer"), v({
2735
2778
  status: "Compiling shaders...",
2736
2779
  progress: 90
2737
- }), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (y({
2780
+ }), await new Promise((e) => setTimeout(e, 0)), n.start("Material setup (TSL compile)"), this.stages.pathTracer.setupMaterial(), n.end("Material setup (TSL compile)"), this._rasterPrecompile = null, this._pathTracerEnabled || (n.start("Pipeline precompile"), await this.precompileRaster(), n.end("Pipeline precompile")), a && (v({
2738
2781
  status: "Finalizing environment map...",
2739
2782
  progress: 95
2740
2783
  }), await a, this.stages.pathTracer.environment.applyCDFResults());
@@ -2743,16 +2786,16 @@ var Hn = class extends L {
2743
2786
  let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
2744
2787
  this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
2745
2788
  }
2746
- return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), b(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
2789
+ return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), de(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
2747
2790
  }
2748
2791
  _sceneSummaryParts() {
2749
2792
  let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
2750
2793
  return [
2751
- x.count(e.triangleCount, "tri"),
2752
- t ? x.count(t, "mesh", "meshes") : null,
2753
- x.count(e.materialData.materialCount, "material"),
2754
- n ? x.count(n, "map") : null,
2755
- x.count(e.bvhNodeCount, "BVH node")
2794
+ y.count(e.triangleCount, "tri"),
2795
+ t ? y.count(t, "mesh", "meshes") : null,
2796
+ y.count(e.materialData.materialCount, "material"),
2797
+ n ? y.count(n, "map") : null,
2798
+ y.count(e.bvhNodeCount, "BVH node")
2756
2799
  ];
2757
2800
  }
2758
2801
  _tagPrimarySceneObject() {
@@ -2829,16 +2872,16 @@ var Hn = class extends L {
2829
2872
  }
2830
2873
  _sceneBudgets(e) {
2831
2874
  return this._memorySpill === !1 || !this.storage ? e : {
2832
- maxTriangles: oe,
2833
- maxPlacements: me,
2875
+ maxTriangles: se,
2876
+ maxPlacements: ge,
2834
2877
  ...e
2835
2878
  };
2836
2879
  }
2837
2880
  _planSpill() {
2838
2881
  let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
2839
- this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? le : 0);
2882
+ this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? ue : 0);
2840
2883
  let t = e ? this.meshScene?.environment : null, n = t?.image;
2841
- return n && wn(t, le), t && t.image !== n && (t.dispose(), t.needsUpdate = !0), e && this._memorySpill === "auto" && $.info("scene is past the in-memory line: building it through disk"), this._spillPlan = e, e;
2884
+ return n && Dn(t, ue), t && t.image !== n && (t.dispose(), t.needsUpdate = !0), e && this._memorySpill === "auto" && $.info("scene is past the in-memory line: building it through disk"), this._spillPlan = e, e;
2842
2885
  }
2843
2886
  _progressiveSpill() {
2844
2887
  let e = this._spillPlan ?? this._planSpill();
@@ -2852,15 +2895,15 @@ var Hn = class extends L {
2852
2895
  return (t, n, r) => n === "triangles" ? e.createTriangleChunkUploader(t, r) : e.createChunkUploader(t);
2853
2896
  }
2854
2897
  _maybeSpill() {
2855
- !this._sdf?.spilling || !this.storage || (this._sdf.spillAfterLoad().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)), this._sdf.spillToDisk(this.storage).then((e) => e && this.dispatchEvent({
2898
+ !this._sdf?.spilling || !this.storage || (this._sdf.spillAfterLoad().catch((e) => this._issues.warn(x.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)), this._sdf.spillToDisk(this.storage).then((e) => e && this.dispatchEvent({
2856
2899
  type: g.SCENE_SPILLED,
2857
2900
  ...e
2858
- })).catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)));
2901
+ })).catch((e) => this._issues.warn(x.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`)));
2859
2902
  }
2860
2903
  _scheduleRespill() {
2861
2904
  this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
2862
- this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
2863
- }, Nn), this._respillTimer.unref?.());
2905
+ this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(x.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
2906
+ }, In), this._respillTimer.unref?.());
2864
2907
  }
2865
2908
  async ensureSceneResident() {
2866
2909
  this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
@@ -2889,7 +2932,7 @@ var Hn = class extends L {
2889
2932
  }), r;
2890
2933
  }
2891
2934
  updateMeshTransforms(e) {
2892
- if (this._sdf?.needsPageInForMove(e)) return this._sdf.ensureMovable(e).then(() => this.updateMeshTransforms(e)).catch((e) => this._issues.warn(C.STORAGE_READ_FAILED, `reading instance matrices back failed: ${e.message}`)), null;
2935
+ if (this._sdf?.needsPageInForMove(e)) return this._sdf.ensureMovable(e).then(() => this.updateMeshTransforms(e)).catch((e) => this._issues.warn(x.STORAGE_READ_FAILED, `reading instance matrices back failed: ${e.message}`)), null;
2893
2936
  this._notePlacementsMoving(e);
2894
2937
  let t = this._sdf.updateMeshTransforms(e);
2895
2938
  return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
@@ -2900,8 +2943,8 @@ var Hn = class extends L {
2900
2943
  requestedPx: e,
2901
2944
  allowLower: r
2902
2945
  }, Math.max(256, Math.min(n, Math.floor(a) || 256));
2903
- let o = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, s = ce(this._hostMemoryGB), c = s.gb >= 8 && o >= 1024 * 1024 * 1024 ? n : 2048, l = t(Math.min(a, c));
2904
- if (l < Math.floor(e) && this._issues.warn(C.RENDER_RESERVE_CAPPED, `reserved render size ${x.n(e)}px was capped to ${x.n(l)}px by this device's limits — renders above ${x.n(l)}px will be declined` + (s.assumed && s.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
2946
+ let o = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, s = le(this._hostMemoryGB), c = s.gb >= 8 && o >= 1024 * 1024 * 1024 ? n : 2048, l = t(Math.min(a, c));
2947
+ if (l < Math.floor(e) && this._issues.warn(x.RENDER_RESERVE_CAPPED, `reserved render size ${y.n(e)}px was capped to ${y.n(l)}px by this device's limits — renders above ${y.n(l)}px will be declined` + (s.assumed && s.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
2905
2948
  requested: e,
2906
2949
  applied: l,
2907
2950
  deviceMemoryGB: s.gb,
@@ -2938,7 +2981,7 @@ var Hn = class extends L {
2938
2981
  return i;
2939
2982
  }
2940
2983
  _isRenderSizeSupported(e, t) {
2941
- return e > i || t > i ? (this._issues.record(C.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${i}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
2984
+ return e > i || t > i ? (this._issues.record(x.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${i}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
2942
2985
  width: e,
2943
2986
  height: t,
2944
2987
  reserve: i
@@ -3092,8 +3135,8 @@ var Hn = class extends L {
3092
3135
  getProvenance() {
3093
3136
  let e = this.stages.pathTracer, t = this.color?.status();
3094
3137
  return a({
3095
- engine: de,
3096
- three: xt,
3138
+ engine: pe,
3139
+ three: wt,
3097
3140
  adapter: this.adapterInfo ?? null,
3098
3141
  mode: {
3099
3142
  headless: this._headless,
@@ -3135,7 +3178,7 @@ var Hn = class extends L {
3135
3178
  let t = await e.captureAccumulation();
3136
3179
  return {
3137
3180
  v: 1,
3138
- engine: de,
3181
+ engine: pe,
3139
3182
  savedAt: Date.now(),
3140
3183
  samples: t.state.frameCount,
3141
3184
  ...t
@@ -3176,6 +3219,7 @@ var Hn = class extends L {
3176
3219
  width: a,
3177
3220
  height: o,
3178
3221
  colorSpace: e,
3222
+ displayColorSpace: this.color?.canvasColorSpace ?? "srgb",
3179
3223
  source: r?.source ?? "accumulation",
3180
3224
  toneMappedOn: d ? "gpu" : "cpu"
3181
3225
  };
@@ -3210,9 +3254,9 @@ var Hn = class extends L {
3210
3254
  if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
3211
3255
  try {
3212
3256
  let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
3213
- return s ? (this._readbackToneMapper ??= new ze(a.device, "rayzee:readback-tonemap", { input: "texture" }), this._readbackToneMapper.ensureSize(n, r), await this._readbackToneMapper.toRGBA8(s, i)) : this._toneMapFallback("the picture has no GPU texture yet");
3257
+ return s ? (this._readbackToneMapper ??= new He(a.device, "rayzee:readback-tonemap", { input: "texture" }), this._readbackToneMapper.ensureSize(n, r), await this._readbackToneMapper.toRGBA8(s, i)) : this._toneMapFallback("the picture has no GPU texture yet");
3214
3258
  } catch (e) {
3215
- if (e instanceof be) throw e;
3259
+ if (e instanceof Se) throw e;
3216
3260
  return this._toneMapFallback("the GPU pass threw", e);
3217
3261
  } finally {
3218
3262
  this._readbackToneMapper?.release(), e && this._textureReadback?.release();
@@ -3220,7 +3264,7 @@ var Hn = class extends L {
3220
3264
  }
3221
3265
  _toneMapFallback(e, t = null) {
3222
3266
  let n = t ? String(t?.message ?? t) : null, r = `renderToBuffer: tone mapped on the CPU — ${e}${n ? `: ${n}` : ""}`;
3223
- return $.warn(r), this._issues.warn(C.OUTPUT_TONEMAP_FALLBACK, r, {
3267
+ return $.warn(r), this._issues.warn(x.OUTPUT_TONEMAP_FALLBACK, r, {
3224
3268
  reason: e,
3225
3269
  cause: n
3226
3270
  }), null;
@@ -3274,7 +3318,18 @@ var Hn = class extends L {
3274
3318
  };
3275
3319
  }
3276
3320
  getCanvas() {
3277
- return this.renderer?.domElement ? this._displayCanvas() || (this.stages.compositor && this.pipeline?.context && this.stages.compositor.render(this.pipeline.context), this.renderer.domElement) : null;
3321
+ return this.renderer?.domElement ? this._displayCanvas() ?? this._pictureCanvas() : null;
3322
+ }
3323
+ _pictureCanvas() {
3324
+ let e = this.renderer.domElement, t = this.stages.compositor, n = this.pipeline?.context;
3325
+ if (!t || !n || (t.renderPicture(n), !(this.renderer.backend?.parameters?.outputType === ft || t.showsCanvasTransform) || this._headless || typeof document > "u")) return e;
3326
+ let r = e.getContext("webgpu")?.getConfiguration?.()?.colorSpace ?? "srgb", i = this._pictureCopy;
3327
+ (!i || i.colorSpace !== r) && (i = this._pictureCopy = {
3328
+ canvas: document.createElement("canvas"),
3329
+ colorSpace: r
3330
+ }), (i.canvas.width !== e.width || i.canvas.height !== e.height) && (i.canvas.width = e.width, i.canvas.height = e.height);
3331
+ let a = i.canvas.getContext("2d", { colorSpace: r });
3332
+ return a.clearRect(0, 0, e.width, e.height), a.drawImage(e, 0, 0), t.render(n), i.canvas;
3278
3333
  }
3279
3334
  screenshot({ type: e = "image/png", quality: t } = {}) {
3280
3335
  let n = this.getCanvas();
@@ -3350,7 +3405,7 @@ var Hn = class extends L {
3350
3405
  }
3351
3406
  getSceneMinY() {
3352
3407
  if (!this.meshScene) return 0;
3353
- let e = new nt().setFromObject(this.meshScene);
3408
+ let e = new rt().setFromObject(this.meshScene);
3354
3409
  return Number.isFinite(e.min.y) ? e.min.y : 0;
3355
3410
  }
3356
3411
  getMaterialProperty(e, t) {
@@ -3393,7 +3448,7 @@ var Hn = class extends L {
3393
3448
  e(), this._refreshEmissiveForVisibility(), this.reset(), this._scheduleRespill();
3394
3449
  }, n = this._sdf?.whenTLASEditable();
3395
3450
  if (!n) return t();
3396
- n.then(t).catch((e) => this._issues.warn(C.STORAGE_READ_FAILED, `reading the TLAS back failed: ${e.message}`));
3451
+ n.then(t).catch((e) => this._issues.warn(x.STORAGE_READ_FAILED, `reading the TLAS back failed: ${e.message}`));
3397
3452
  }
3398
3453
  getScene() {
3399
3454
  return this.meshScene || this.scene;
@@ -3412,7 +3467,7 @@ var Hn = class extends L {
3412
3467
  return n && n.key !== "pathtracer:color" && n.texture !== e.texture ? {
3413
3468
  texture: n.texture,
3414
3469
  source: n.key.split(":")[0]
3415
- } : (this._denoiserInUse() && this._issues.record(C.OUTPUT_SOURCE_FALLBACK, "renderToBuffer: 'display' was asked for, but no denoiser has published a picture — returned the raw accumulation", {
3470
+ } : (this._denoiserInUse() && this._issues.record(x.OUTPUT_SOURCE_FALLBACK, "renderToBuffer: 'display' was asked for, but no denoiser has published a picture — returned the raw accumulation", {
3416
3471
  requested: "display",
3417
3472
  read: "accumulation"
3418
3473
  }), null);
@@ -3439,20 +3494,24 @@ var Hn = class extends L {
3439
3494
  n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
3440
3495
  let r = n.__rayzeeOriginalColorSpace;
3441
3496
  if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
3442
- else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? We : Be, n.__rayzeeColorSpaceChoice = t;
3497
+ else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? O : Ue, n.__rayzeeColorSpaceChoice = t;
3443
3498
  else {
3444
3499
  if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
3445
- n.ocioColorSpace = t, e.colorSpace = We;
3500
+ n.ocioColorSpace = t, e.colorSpace = O;
3446
3501
  }
3447
3502
  e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
3448
3503
  }
3449
3504
  setColorManagement(e) {
3450
- this.color?.dispose(), this.color = new e({ issues: this._issues }), w(this.color), this.renderer && this.color.attachRenderer(this.renderer);
3505
+ this.color?.dispose(), this.color = new e({ issues: this._issues }), Ee(this.color), this.color.on?.("canvas", () => this._applyCanvasTransform()), this.renderer && this.color.attachRenderer(this.renderer);
3506
+ }
3507
+ _applyCanvasTransform() {
3508
+ let e = this.stages?.compositor;
3509
+ e && (e.setCanvasTransform(this.color?.canvasTransform ?? null), e.showsCanvasTransform || (this._pictureCopy = null), this.animationManagerId ? this._needsDisplayRefresh = !0 : this.pipeline?.context && !this._deviceLost && e.render(this.pipeline.context));
3451
3510
  }
3452
3511
  async loadColorConfig(e = {}) {
3453
3512
  await this._leaveColorWorkingSpace();
3454
- let t = D(this.renderer?.toneMapping), n = await this.color.loadConfig(e);
3455
- return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" && D(this.renderer?.toneMapping) === t) || this.color.workingSpaceAdopted) && this.reset(), n;
3513
+ let t = w(this.renderer?.toneMapping), n = await this.color.loadConfig(e);
3514
+ return this.color.workingSpaceAdopted && await this.applyColorWorkingSpace(), (!(t?.source === "ocio" && w(this.renderer?.toneMapping) === t) || this.color.workingSpaceAdopted) && this.reset(), n;
3456
3515
  }
3457
3516
  async unloadColorConfig() {
3458
3517
  await this._leaveColorWorkingSpace(), this.color.unloadConfig(), this.reset();
@@ -3475,14 +3534,14 @@ var Hn = class extends L {
3475
3534
  await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && re(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
3476
3535
  }
3477
3536
  async _initRenderer() {
3478
- fe((e) => this.dispatchEvent(e)), (typeof navigator > "u" || !navigator.gpu) && this._issues.fail(C.WEBGPU_UNAVAILABLE, "WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
3537
+ me((e) => this.dispatchEvent(e)), (typeof navigator > "u" || !navigator.gpu) && this._issues.fail(x.WEBGPU_UNAVAILABLE, "WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
3479
3538
  let e = null, t;
3480
3539
  try {
3481
3540
  e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
3482
3541
  } catch (e) {
3483
3542
  t = e;
3484
3543
  }
3485
- e || this._issues.fail(C.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo = Vn(e), this.adapterInfo.isSoftware && (this._issues.warn(C.ADAPTER_SOFTWARE, `software GPU adapter "${this.adapterInfo.description || this.adapterInfo.vendor}" — renders are correct but orders of magnitude slower than hardware`, { ...this.adapterInfo }), $.warn(`software GPU adapter — check app.adapterInfo.isSoftware. ${this.adapterInfo.description}`));
3544
+ e || this._issues.fail(x.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo = Wn(e), this.adapterInfo.isSoftware && (this._issues.warn(x.ADAPTER_SOFTWARE, `software GPU adapter "${this.adapterInfo.description || this.adapterInfo.vendor}" — renders are correct but orders of magnitude slower than hardware`, { ...this.adapterInfo }), $.warn(`software GPU adapter — check app.adapterInfo.isSoftware. ${this.adapterInfo.description}`));
3486
3545
  let n = e.limits, r = { maxColorAttachmentBytesPerSample: 128 };
3487
3546
  for (let e of [
3488
3547
  "maxBufferSize",
@@ -3504,11 +3563,11 @@ var Hn = class extends L {
3504
3563
  let i;
3505
3564
  try {
3506
3565
  i = await e.requestDevice({
3507
- requiredFeatures: zn.filter((t) => e.features.has(t)),
3566
+ requiredFeatures: Hn.filter((t) => e.features.has(t)),
3508
3567
  requiredLimits: r
3509
3568
  });
3510
3569
  } catch (e) {
3511
- this._issues.fail(C.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
3570
+ this._issues.fail(x.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
3512
3571
  }
3513
3572
  this.renderer = new Ke({
3514
3573
  canvas: this.canvas,
@@ -3516,20 +3575,20 @@ var Hn = class extends L {
3516
3575
  device: i
3517
3576
  });
3518
3577
  try {
3519
- await In(this.renderer, this._headless);
3578
+ await zn(this.renderer, this._headless);
3520
3579
  } catch (e) {
3521
3580
  throw i.destroy(), e;
3522
3581
  }
3523
- this.renderer.backend?.isWebGPUBackend || (i.destroy(), this._issues.fail(C.WEBGPU_UNAVAILABLE, "three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.")), this._gpuDevice = i, i.lost && (this._deviceLostHolder = { app: this }, Rn(i, this._deviceLostHolder), i.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), Ue.setLTC(Et.init()), this.renderer.outputColorSpace = We, this.renderer.toneMapping = Ae, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
3582
+ this.renderer.backend?.isWebGPUBackend || (i.destroy(), this._issues.fail(x.WEBGPU_UNAVAILABLE, "three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.")), this._gpuDevice = i, i.lost && (this._deviceLostHolder = { app: this }, Vn(i, this._deviceLostHolder), i.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), We.setLTC(kt.init()), this.renderer.outputColorSpace = O, this.renderer.toneMapping = Ne, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
3524
3583
  }
3525
3584
  _initScenes() {
3526
- this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Mt();
3585
+ this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Ft();
3527
3586
  }
3528
3587
  _initAssetPipeline() {
3529
3588
  this._sdf = new u({
3530
3589
  issues: this._issues,
3531
3590
  ...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
3532
- }), this.assetLoader = new Cn(this.meshScene, this.camera, null, {
3591
+ }), this.assetLoader = new En(this.meshScene, this.camera, null, {
3533
3592
  issues: this._issues,
3534
3593
  areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
3535
3594
  }), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
@@ -3537,14 +3596,14 @@ var Hn = class extends L {
3537
3596
  _initPipeline() {
3538
3597
  this._createStages();
3539
3598
  let { clientWidth: e, clientHeight: t } = this.canvas;
3540
- this.pipeline = new Gt(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer);
3599
+ this.pipeline = new Jt(this.renderer, e || 1, t || 1, { issues: this._issues }), this.pipeline.addStage(this.stages.pathTracer);
3541
3600
  for (let e of this._extraStages) this.pipeline.addStage(e);
3542
3601
  this.pipeline.addStage(this.stages.compositor);
3543
3602
  let n = this.canvas.clientWidth || 1, r = this.canvas.clientHeight || 1;
3544
3603
  this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
3545
3604
  }
3546
3605
  async _initManagers() {
3547
- this.lightManager = new jn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
3606
+ this.lightManager = new Pn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
3548
3607
  onReset: () => this.reset(),
3549
3608
  onLightRemoved: (e) => this._lightRemoved(e)
3550
3609
  }), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.issues = this._issues, this.stages.pathTracer.issues = this._issues, this.environmentManager.callbacks.onLightingChanged = () => this.pipeline.eventBus.emit("pipeline:lightingChanged"), this.environmentManager.callbacks.onReset = () => this.reset();
@@ -3555,7 +3614,7 @@ var Hn = class extends L {
3555
3614
  if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }) && this.assetLoader?.commitPendingGraph(e.model);
3556
3615
  else if (e.texture) {
3557
3616
  let e = this.meshScene.environment;
3558
- e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), b();
3617
+ e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), de();
3559
3618
  }
3560
3619
  this.pauseRendering = !1, this.reset();
3561
3620
  }
@@ -3568,10 +3627,11 @@ var Hn = class extends L {
3568
3627
  this.stages.pathTracer = new d(this.renderer, this.scene, this.camera, {
3569
3628
  hostMemoryGB: this._hostMemoryGB,
3570
3629
  sortMaterials: this.settings.get("wavefrontSortMaterials")
3571
- }), this._extraStages = this._createExtraStages(), this.stages.compositor = new Nt(this.renderer, {
3630
+ }), this._extraStages = this._createExtraStages(), this.stages.compositor = new It(this.renderer, {
3572
3631
  saturation: this.settings.get("saturation") ?? _.saturation,
3573
3632
  pathTracer: this.stages.pathTracer,
3574
- displaySources: this._displaySources()
3633
+ displaySources: this._displaySources(),
3634
+ canvasTransform: this.color?.canvasTransform ?? null
3575
3635
  });
3576
3636
  }
3577
3637
  _reconcileCompletion() {
@@ -3584,7 +3644,7 @@ var Hn = class extends L {
3584
3644
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
3585
3645
  }
3586
3646
  _createCamera() {
3587
- let e = new On(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
3647
+ let e = new jn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
3588
3648
  return e.position.set(0, 0, 5), e;
3589
3649
  }
3590
3650
  _createExtraStages() {
@@ -3654,4 +3714,4 @@ var Hn = class extends L {
3654
3714
  _disposeExtensions() {}
3655
3715
  };
3656
3716
  //#endregion
3657
- export { Pt as _, an as a, J as c, q as d, tn as f, Rt as g, zt as h, On as i, nn as l, Bt as m, Vn as n, Y as o, Gt as p, jn as r, G as s, Hn as t, en as u };
3717
+ export { Lt as _, cn as a, J as c, q as d, an as f, Vt as g, Ht as h, jn as i, on as l, Ut as m, Wn as n, Y as o, Jt as p, Pn as r, G as s, Gn as t, rn as u };