rayzee 11.6.0 → 11.8.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 (72) hide show
  1. package/README.md +26 -14
  2. package/dist/{ArchiveImporter-iofnC8zB.js → ArchiveImporter-_sJm5uaK.js} +1923 -1243
  3. package/dist/{BidirectionalIntegrator-CqAilt2I.js → BidirectionalIntegrator-Dzt4Z97x.js} +290 -289
  4. package/dist/{ColorManagement-oeEk7oSu.js → ColorManagement-30MfpHwQ.js} +1 -1
  5. package/dist/{EngineIssues-CIZnXHsF.js → EngineIssues-xljoXM0E.js} +18 -8
  6. package/dist/{NeuralRetouch-DFI4pOjO.js → NeuralRetouch-BKQCsmEs.js} +2 -2
  7. package/dist/{NeuralSuperRes-ChCiiilS.js → NeuralSuperRes-C4ymq68e.js} +2 -2
  8. package/dist/{PathTracer-BX4sJLx7.js → PathTracer-C_to_i40.js} +3158 -3102
  9. package/dist/{PhysicalSky-Biv39eTA.js → PhysicalSky-bMHbm_7H.js} +1 -1
  10. package/dist/{RayzeeRenderer-D8XRKU3A.js → RayzeeRenderer-B_aB6VTJ.js} +370 -372
  11. package/dist/SceneMetadata-CSmlJW4c.js +183 -0
  12. package/dist/{ToneMapGPU-sAs8wdgI.js → ToneMapGPU-4GPwoG_c.js} +13 -6
  13. package/dist/addons/archives.es.js +1 -1
  14. package/dist/addons/bidirectional.es.js +1 -1
  15. package/dist/addons/color.es.js +1 -1
  16. package/dist/addons/physical-sky.es.js +1 -1
  17. package/dist/addons/storage.es.js +1 -1
  18. package/dist/{openStorage-Fe9BoS1_.js → openStorage-B085D9FR.js} +1 -1
  19. package/dist/rayzee-core.es.js +5 -5
  20. package/dist/rayzee.es.js +917 -1624
  21. package/dist/rayzee.umd.js +113 -156
  22. package/dist/{sceneCachePolicy-W5PLbzuR.js → sceneCachePolicy-D_uBSbQF.js} +2 -2
  23. package/package.json +1 -1
  24. package/src/EngineIssues.js +20 -6
  25. package/src/Passes/AIUpscaler.js +4 -0
  26. package/src/Passes/OIDNDenoiser.js +17 -17
  27. package/src/PathTracerApp.js +16 -18
  28. package/src/Pipeline/BindingAudit.js +2 -3
  29. package/src/Pipeline/PipelineContext.js +0 -1
  30. package/src/Pipeline/RenderPipeline.js +1 -2
  31. package/src/Pipeline/RenderStage.js +1 -1
  32. package/src/Processor/ArchiveImporter.js +23 -6
  33. package/src/Processor/AssetLoader.js +15 -0
  34. package/src/Processor/LightSerializer.js +6 -2
  35. package/src/Processor/PBRT/PBRTMaterials.js +2 -1
  36. package/src/Processor/PBRT/PBRTSceneBuilder.js +1 -1
  37. package/src/Processor/PackedRayBuffer.js +2 -2
  38. package/src/Processor/PlatformImageLoader.js +9 -0
  39. package/src/Processor/StorageTexturePool.js +1 -1
  40. package/src/Processor/TextureCreator.js +44 -4
  41. package/src/Processor/ToneMapCPU.js +34 -5
  42. package/src/Processor/ToneMapGPU.js +15 -9
  43. package/src/Processor/USD/USDScene.js +981 -17
  44. package/src/RayzeeRenderer.js +82 -27
  45. package/src/Stages/AutoExposure.js +21 -8
  46. package/src/Stages/Compositor.js +39 -1
  47. package/src/Stages/DenoiserSettings.js +5 -81
  48. package/src/Stages/LocalExposure.js +44 -18
  49. package/src/Stages/MotionVector.js +21 -215
  50. package/src/Stages/NormalDepth.js +12 -8
  51. package/src/Stages/PathTracer.js +26 -2
  52. package/src/Stages/PathTracerStage.js +13 -18
  53. package/src/TSL/CameraRay.js +12 -1
  54. package/src/TSL/DebugKernel.js +3 -2
  55. package/src/TSL/FinalWriteKernel.js +6 -9
  56. package/src/TSL/GenerateKernel.js +6 -2
  57. package/src/TSL/LightSplatKernel.js +7 -4
  58. package/src/TSL/LightsCore.js +6 -2
  59. package/src/TSL/LightsSampling.js +45 -12
  60. package/src/TSL/SceneResources.js +11 -0
  61. package/src/TSL/ShadeKernel.js +4 -5
  62. package/src/index.js +1 -1
  63. package/src/integrators/BidirectionalIntegrator.js +1 -0
  64. package/src/managers/CameraManager.js +9 -0
  65. package/src/managers/DenoisingManager.js +79 -187
  66. package/src/managers/InteractionManager.js +6 -0
  67. package/src/managers/UniformManager.js +3 -1
  68. package/dist/SceneMetadata-D2Sh-0e-.js +0 -110
  69. package/src/Stages/ASVGF.js +0 -932
  70. package/src/Stages/BilateralFilter.js +0 -486
  71. package/src/Stages/EdgeFilter.js +0 -545
  72. package/src/Stages/Variance.js +0 -443
@@ -1,31 +1,31 @@
1
1
  import { dt as e } from "./SolarLimb-bZE6y63S.js";
2
- import { At as t, Dt as n, Et as r, ct as i, gt as a, i as o, jt as s, kt as c, lt as l, n as u, r as d, ut as f, vt as p, yt as m } from "./PathTracer-BX4sJLx7.js";
2
+ import { Mt as t, Nt as n, Ot as r, bt as i, dt as a, ft as o, i as s, jt as c, kt as l, lt as u, n as d, r as f, ut as p, vt as ee, xt as m } from "./PathTracer-C_to_i40.js";
3
3
  import { n as h, t as g } from "./EngineEvents-CLckhYbL.js";
4
- import { $ as ee, C as te, G as _, M as ne, Q as re, T as v, W as ie, at as y, d as ae, et as oe, f as se, l as ce, nt as le, ot as ue, r as de, rt as fe, tt as pe, u as me, v as he, x as b } from "./sceneCachePolicy-W5PLbzuR.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-D_uBSbQF.js";
5
5
  import { i as x, r as S } from "./Logger-dDDGj9Av.js";
6
- import { f as ge, r as _e } from "./BufferLayout-xPRH9jYD.js";
7
- import { i as ve, n as C, t as ye } from "./EngineIssues-CIZnXHsF.js";
8
- import { n as be, r as xe } from "./shared-BGBcSxBQ.js";
9
- import { a as Se } from "./WorkingMatrix-C6y233hT.js";
10
- import { i as w, r as Ce, t as T } from "./ActiveColor-YvuQq44O.js";
11
- import { n as E, r as we } from "./AssetConfig-DSEntE65.js";
12
- import { d as Te, l as Ee, m as De, p as Oe, t as ke, u as D } from "./ViewTransforms-CYN7bq2w.js";
13
- import { i as O, n as Ae, r as je } from "./identity-C1cLD1C0.js";
14
- import { a as Me, i as Ne, t as Pe } from "./SceneMetadata-D2Sh-0e-.js";
15
- import { t as Fe } from "./ToneMapGPU-sAs8wdgI.js";
16
- import { LinearSRGBColorSpace as Ie, MeshBasicNodeMaterial as Le, QuadMesh as Re, RectAreaLightNode as ze, SRGBColorSpace as Be, TextureNode as Ve, WebGPURenderer as He } from "three/webgpu";
17
- import { Fn as Ue, If as We, cubeTexture as Ge, dot as Ke, float as k, int as A, mix as j, screenUV as qe, select as M, storage as Je, texture as Ye, uint as Xe, uniform as N, uv as P, vec3 as F, vec4 as Ze } from "three/tsl";
18
- import { Box3 as Qe, BufferGeometry as $e, CircleGeometry as et, Color as I, DataTexture as tt, DirectionalLight as nt, DirectionalLightHelper as rt, EquirectangularReflectionMapping as it, EventDispatcher as L, FloatType as at, LinearFilter as ot, LinearSRGBColorSpace as st, LoaderUtils as R, LoadingManager as ct, MathUtils as z, Mesh as lt, MeshPhysicalMaterial as ut, NoBlending as dt, NoToneMapping as ft, Object3D as B, OrthographicCamera as pt, PerspectiveCamera as mt, PointLight as ht, PointLightHelper as gt, REVISION as _t, RGBAFormat as vt, RectAreaLight as V, SRGBColorSpace as H, Scene as yt, SpotLight as bt, SpotLightHelper as xt, TextureLoader as St, UnsignedByteType as Ct, Vector2 as wt, Vector3 as U } from "three";
19
- import { RectAreaLightTexturesLib as Tt } from "three/addons/lights/RectAreaLightTexturesLib.js";
20
- import { RectAreaLightHelper as Et } from "three/addons/helpers/RectAreaLightHelper.js";
21
- import { GLTFLoader as Dt } from "three/addons/loaders/GLTFLoader.js";
22
- import { HDRLoader as Ot } from "three/addons/loaders/HDRLoader.js";
23
- import { createMeshesFromMultiMaterialMesh as kt } from "three/addons/utils/SceneUtils.js";
24
- import { clone as At } from "three/addons/utils/SkeletonUtils.js";
6
+ import { f as _e, r as ve } from "./BufferLayout-xPRH9jYD.js";
7
+ import { i as ye, n as C, t as be } from "./EngineIssues-xljoXM0E.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-CSmlJW4c.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";
25
25
  //#region src/SceneHelpers.js
26
- var jt = class {
26
+ var Mt = class {
27
27
  constructor() {
28
- this.scene = new yt(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
28
+ this.scene = new H(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
29
29
  }
30
30
  add(e) {
31
31
  if (this._helpers.has(e.uuid)) return this._helpers.get(e.uuid);
@@ -63,22 +63,31 @@ var jt = class {
63
63
  this.clear();
64
64
  }
65
65
  _createHelper(e) {
66
- return e.isRectAreaLight ? new Et(e) : e.isPointLight ? new gt(e, .5) : e.isSpotLight ? new xt(e) : e.isDirectionalLight ? new rt(e, .5) : null;
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;
67
67
  }
68
- }, Mt = class extends t {
68
+ }, Nt = class extends t {
69
69
  constructor(e, t = {}) {
70
70
  super("Compositor", {
71
71
  ...t,
72
- executionMode: s.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 Ve(), this._displayGain = null, this.compositorMaterial = new Le(), this.compositorMaterial.blending = dt, this._buildColorNode(), this.compositorQuad = new Re(this.compositorMaterial);
72
+ executionMode: n.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);
74
74
  }
75
75
  _buildColorNode() {
76
- let t = this._sourceTexNode.sample(P()), n = this._displayGain ? t.xyz.mul(this._displayGain(t.xyz, qe)) : t.xyz, r = j(F(Ke(n, e)), n, this.saturation), i = M(this._transparentBackground, t.w, 1);
77
- this.compositorMaterial.colorNode = Ze(r, i), this.compositorMaterial.needsUpdate = !0;
76
+ let t = this._sourceTexNode.sample(P()), n = this._displayGain ? this._displayGain(t.xyz, Ze) : null;
77
+ if (this._backdropExposure !== null) {
78
+ let e = n ?? k(1), r = e.add(this._backdropGain.sub(e).mul(t.w.clamp(0, 1).oneMinus()));
79
+ n = M(this._holdBackdrop.greaterThan(A(0)), r, e);
80
+ }
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;
78
83
  }
79
84
  setDisplayGain(e) {
80
85
  e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
81
86
  }
87
+ setBackdropExposure(e) {
88
+ let t = e === null != (this._backdropExposure === null);
89
+ this._backdropExposure = e, t && this._buildColorNode();
90
+ }
82
91
  resolveLightTexture(e) {
83
92
  return this.resolveLightSource(e)?.texture ?? null;
84
93
  }
@@ -96,17 +105,17 @@ var jt = class {
96
105
  let t = this._pathTracer?.getConvergenceDebugSource?.();
97
106
  if (!t) return !1;
98
107
  if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
99
- this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Ve();
100
- let n = Ue(() => {
101
- let n = Ke(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 = Xe(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Je(t.m2, "float").toReadOnly().element(o).toVar(), c = Je(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(), m = f.div(p.max(k(1e-6))).toVar(), h = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), g = h.toVar(), ee = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
102
- return We(m.greaterThanEqual(k(1)).or(ee.not()), () => {
103
- let e = j(F(1, .8, .1), F(1, .1, .05), m.sub(1).div(3).clamp(0, 1));
104
- g.assign(j(h, e, .85));
105
- }), We(c.equal(Xe(1)).and(u), () => {
106
- g.assign(j(h, F(.1, .45, 1), .55));
107
- }), g;
108
+ this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Ge();
109
+ 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));
111
+ return Je(ee.greaterThanEqual(k(1)).or(g.not()), () => {
112
+ let e = j(F(1, .8, .1), F(1, .1, .05), ee.sub(1).div(3).clamp(0, 1));
113
+ h.assign(j(m, e, .85));
114
+ }), Je(c.equal(et(1)).and(u), () => {
115
+ h.assign(j(m, F(.1, .45, 1), .55));
116
+ }), h;
108
117
  });
109
- return this._debugMaterial = new Le(), this._debugMaterial.colorNode = Ze(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = dt, this._debugQuad = new Re(this._debugMaterial), !0;
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;
110
119
  }
111
120
  render(e) {
112
121
  if (!this.enabled) return;
@@ -114,13 +123,19 @@ var jt = class {
114
123
  let t = e.getTexture("pathtracer:color");
115
124
  if (t) {
116
125
  this._debugTexNode.value = t;
117
- let e = this.renderer.toneMapping !== ft;
126
+ let e = this.renderer.toneMapping !== gt;
118
127
  this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
119
128
  return;
120
129
  }
121
130
  }
122
131
  let t = this.resolveLightTexture(e);
123
- t && (this._sourceTexNode.value = t, this.renderer.setRenderTarget(null), this.compositorQuad.render(this.renderer));
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 = a(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
136
+ }
137
+ this._sourceTexNode.value = t, this.renderer.setRenderTarget(null), this.compositorQuad.render(this.renderer);
138
+ }
124
139
  }
125
140
  setConvergenceOverlay(e) {
126
141
  this._convergenceOverlay = !!e;
@@ -134,13 +149,12 @@ var jt = class {
134
149
  dispose() {
135
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;
136
151
  }
137
- }, Nt = class {
152
+ }, Pt = class {
138
153
  constructor() {
139
154
  this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
140
155
  frame: 0,
141
156
  accumulatedFrames: 0,
142
157
  renderMode: 0,
143
- interactionMode: !1,
144
158
  isComplete: !1,
145
159
  tileInfo: null,
146
160
  currentTile: 0,
@@ -254,7 +268,7 @@ var jt = class {
254
268
  dispose() {
255
269
  this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
256
270
  }
257
- }, Pt = class extends L {
271
+ }, Ft = class extends L {
258
272
  constructor() {
259
273
  super(), this._onceCallbacks = /* @__PURE__ */ new Map();
260
274
  }
@@ -292,15 +306,15 @@ var jt = class {
292
306
  eventNames() {
293
307
  return this._listeners ? Object.keys(this._listeners) : [];
294
308
  }
295
- }, Ft = !1, It = [], Lt = /* @__PURE__ */ new WeakMap();
309
+ }, It = !1, W = [], Lt = /* @__PURE__ */ new WeakMap();
296
310
  function Rt(e) {
297
- Ft = !!e;
311
+ It = !!e;
298
312
  }
299
313
  function zt() {
300
- return It.slice();
314
+ return W.slice();
301
315
  }
302
316
  function Bt() {
303
- It.length = 0;
317
+ W.length = 0;
304
318
  }
305
319
  function Vt(e) {
306
320
  let t = [];
@@ -309,7 +323,7 @@ function Vt(e) {
309
323
  }
310
324
  var Ht = (e) => !e || !e.image || !(e.image.width > 0);
311
325
  function Ut(e, t, n) {
312
- if (!Ft) {
326
+ if (!It) {
313
327
  n();
314
328
  return;
315
329
  }
@@ -338,7 +352,7 @@ function Wt(e, t) {
338
352
  if (Ht(t)) return;
339
353
  t.isStorageTexture !== !0 && n.push(r);
340
354
  }
341
- t.phase = "done", n.length !== 0 && It.push({
355
+ t.phase = "done", n.length !== 0 && W.push({
342
356
  stage: e.name,
343
357
  nodes: n,
344
358
  unboundAtCompile: t.unboundAtCompile.slice(),
@@ -358,7 +372,7 @@ var Gt = class {
358
372
  }));
359
373
  }
360
374
  constructor(e, t, n, { issues: r = null } = {}) {
361
- this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Nt(), this.eventBus = new Pt(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
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 = {
362
376
  enabled: !1,
363
377
  logSkipped: !1,
364
378
  timings: /* @__PURE__ */ new Map(),
@@ -515,7 +529,7 @@ var Gt = class {
515
529
  resumeFromPause() {
516
530
  this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
517
531
  }
518
- }, Jt = 864e5, W = Object.freeze({
532
+ }, Jt = 864e5, G = Object.freeze({
519
533
  IMMUTABLE: "immutable",
520
534
  REVALIDATE: "revalidate",
521
535
  NETWORK: "network"
@@ -523,8 +537,8 @@ var Gt = class {
523
537
  loaded: e,
524
538
  total: t,
525
539
  lengthComputable: t > 0 && e <= t
526
- }), G = (e, t) => e.headers?.get?.(t) ?? null, Xt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
527
- function K(e) {
540
+ }), K = (e, t) => e.headers?.get?.(t) ?? null, Xt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
541
+ function q(e) {
528
542
  try {
529
543
  let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
530
544
  return decodeURIComponent(t.split("/").pop()) || "download";
@@ -533,7 +547,7 @@ function K(e) {
533
547
  }
534
548
  }
535
549
  async function Zt(e, { onProgress: t, signal: n }) {
536
- let r = Number(G(e, "content-length")) || 0, i = G(e, "content-type") ?? "";
550
+ let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
537
551
  if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
538
552
  let a = e.body.getReader(), o = [], s = 0;
539
553
  for (;;) {
@@ -547,20 +561,20 @@ async function Zt(e, { onProgress: t, signal: n }) {
547
561
  var Qt = (e, t, n) => new File([e], t, {
548
562
  type: n || e.type,
549
563
  lastModified: e.lastModified ?? Date.now()
550
- }), $t = () => {}, q = class {
564
+ }), $t = () => {}, J = class {
551
565
  constructor(e) {
552
566
  this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
553
567
  }
554
568
  get _area() {
555
- return this._storage?.area(xe.DOWNLOADS) ?? null;
569
+ return this._storage?.area(Se.DOWNLOADS) ?? null;
556
570
  }
557
- async fetch(e, { key: t = e, name: n = K(e), policy: r = W.REVALIDATE, maxAgeMs: i = Jt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
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 = {} } = {}) {
558
572
  let c = this._area;
559
- if (c && r !== W.NETWORK) {
573
+ if (c && r !== G.NETWORK) {
560
574
  let o = await c.open(t);
561
575
  if (o) {
562
576
  let c = await o.file("data");
563
- if (c) return r === W.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Yt(c.size, c.size)), {
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)), {
564
578
  file: Qt(c, n, o.extra.contentType),
565
579
  release: () => o.release(),
566
580
  fromCache: !0
@@ -585,10 +599,10 @@ var Qt = (e, t, n) => new File([e], t, {
585
599
  signal: i
586
600
  });
587
601
  if (!s.ok) throw Error(`HTTP ${s.status} fetching ${e}`);
588
- let c = Number(G(s, "content-length")) || 0, l = {
602
+ let c = Number(K(s, "content-length")) || 0, l = {
589
603
  url: e,
590
- contentType: G(s, "content-type") ?? "",
591
- lastModified: G(s, "last-modified"),
604
+ contentType: K(s, "content-type") ?? "",
605
+ lastModified: K(s, "last-modified"),
592
606
  contentLength: c || null,
593
607
  checkedAt: Date.now()
594
608
  }, u = o && s.body ? await this._area.create(t, {
@@ -637,7 +651,7 @@ var Qt = (e, t, n) => new File([e], t, {
637
651
  headers: t
638
652
  });
639
653
  if (n.body?.cancel().catch(() => {}), n.ok) {
640
- let e = G(n, "last-modified"), t = n.status === 206 ? Number(G(n, "content-range")?.match(/\/(\d+)$/)?.[1]) || null : Number(G(n, "content-length")) || null;
654
+ let e = K(n, "last-modified"), t = n.status === 206 ? Number(K(n, "content-range")?.match(/\/(\d+)$/)?.[1]) || null : Number(K(n, "content-length")) || null;
641
655
  a = !!(e && r.lastModified && e !== r.lastModified || t && r.contentLength && t !== r.contentLength);
642
656
  }
643
657
  } catch {}
@@ -658,10 +672,10 @@ var Qt = (e, t, n) => new File([e], t, {
658
672
  }
659
673
  };
660
674
  function en(e, t, n) {
661
- return new q(t).fetch(e, n);
675
+ return new J(t).fetch(e, n);
662
676
  }
663
677
  function tn() {
664
- return new q(be(E().cacheNamespace));
678
+ return new J(xe(E().cacheNamespace));
665
679
  }
666
680
  async function nn(e, { downloads: t = tn(), ...n } = {}) {
667
681
  if (!t._storage || !/^https?:/i.test(e)) return {
@@ -901,7 +915,7 @@ var rn = {
901
915
  },
902
916
  maxTextureSize: { reset: !1 },
903
917
  areaLightIntensityScale: { reset: !1 }
904
- }, J = Object.freeze({
918
+ }, Y = Object.freeze({
905
919
  DEFAULT: "default",
906
920
  HOST: "host",
907
921
  SCENE_METADATA: "scene-metadata",
@@ -920,15 +934,15 @@ var rn = {
920
934
  reset: r
921
935
  });
922
936
  let i = t === void 0 ? this._defaults[e] : t;
923
- !this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, J.DEFAULT));
937
+ !this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
924
938
  }
925
939
  _buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
926
- let a = new wt(), o = (t, n) => {
927
- a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(z.DEG2RAD), e.pathTracer?.setUniform(t, a);
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);
928
942
  };
929
943
  return {
930
944
  handleCameraProjection: (t) => {
931
- e.pathTracer?.setUniform("cameraProjection", ie[t] ?? ie.perspective), i?.(t);
945
+ e.pathTracer?.setUniform("cameraProjection", ae[t] ?? ae.perspective), i?.(t);
932
946
  },
933
947
  handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
934
948
  handlePanoramaLonRange: (e) => o("panoLonRange", e),
@@ -978,7 +992,7 @@ var rn = {
978
992
  }
979
993
  };
980
994
  }
981
- set(e, t, { reset: n, silent: r, source: i = J.HOST } = {}) {
995
+ set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
982
996
  let a = this._applyOne(e, t, i);
983
997
  a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
984
998
  type: g.SETTING_CHANGED,
@@ -987,7 +1001,7 @@ var rn = {
987
1001
  prev: a.prev
988
1002
  }));
989
1003
  }
990
- setMany(e, { silent: t, reset: n, source: r = J.HOST } = {}) {
1004
+ setMany(e, { silent: t, reset: n, source: r = Y.HOST } = {}) {
991
1005
  let i = !1;
992
1006
  for (let [n, a] of Object.entries(e)) {
993
1007
  let e = this._applyOne(n, a, r);
@@ -1023,7 +1037,7 @@ var rn = {
1023
1037
  let e = {};
1024
1038
  for (let [t, n] of this._values) e[t] = {
1025
1039
  value: n,
1026
- source: this._sources.get(t) ?? J.DEFAULT,
1040
+ source: this._sources.get(t) ?? Y.DEFAULT,
1027
1041
  routed: this._routes.has(t)
1028
1042
  };
1029
1043
  return e;
@@ -1034,7 +1048,7 @@ var rn = {
1034
1048
  serialize() {
1035
1049
  let e = {};
1036
1050
  for (let [t, n] of this._values) {
1037
- if (this._sources.get(t) !== J.HOST || !this._routes.has(t)) continue;
1051
+ if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
1038
1052
  let r = m(n);
1039
1053
  r !== void 0 && (e[t] = r);
1040
1054
  }
@@ -1042,7 +1056,7 @@ var rn = {
1042
1056
  }
1043
1057
  restore(e) {
1044
1058
  let t = {}, n = [];
1045
- for (let [r, i] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = p(i) : n.push(r);
1059
+ for (let [r, a] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = i(a) : n.push(r);
1046
1060
  return this.setMany(t), n;
1047
1061
  }
1048
1062
  applyAll() {
@@ -1055,12 +1069,12 @@ var rn = {
1055
1069
  e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
1056
1070
  }
1057
1071
  _initDefaults(e) {
1058
- for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, J.DEFAULT));
1072
+ for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
1059
1073
  }
1060
1074
  }, on = class {
1061
1075
  constructor({ issues: e = null } = {}) {
1062
- this._issues = e, this._renderer = null, this._offRegistry = Oe(() => {
1063
- this._renderer && De(this._renderer);
1076
+ this._issues = e, this._renderer = null, this._offRegistry = ke(() => {
1077
+ this._renderer && Oe(this._renderer);
1064
1078
  });
1065
1079
  }
1066
1080
  get hasConfig() {
@@ -1077,11 +1091,11 @@ var rn = {
1077
1091
  }
1078
1092
  attachRenderer(e) {
1079
1093
  this._renderer = e;
1080
- let t = De(e);
1081
- return e.outputColorSpace = H, t;
1094
+ let t = Oe(e);
1095
+ return e.outputColorSpace = V, t;
1082
1096
  }
1083
1097
  listViews() {
1084
- return Te();
1098
+ return Ee();
1085
1099
  }
1086
1100
  get activeView() {
1087
1101
  return null;
@@ -1093,7 +1107,7 @@ var rn = {
1093
1107
  return this._renderer && (this._renderer.toneMapping = e), t;
1094
1108
  }
1095
1109
  _publishWorkingMatrix() {
1096
- Se(null, T);
1110
+ Ce(null, T);
1097
1111
  }
1098
1112
  loadConfig() {
1099
1113
  let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
@@ -1121,83 +1135,16 @@ var rn = {
1121
1135
  activeView: null,
1122
1136
  context: null,
1123
1137
  exportSpace: null,
1124
- views: Te(),
1125
- registryVersion: Ee(),
1138
+ views: Ee(),
1139
+ registryVersion: De(),
1126
1140
  bakeError: e?.error ?? null
1127
1141
  };
1128
1142
  }
1129
1143
  dispose() {
1130
- this._offRegistry?.(), this._renderer = null, this._issues = null, Ce() === this && (Se(null), w(null));
1144
+ this._offRegistry?.(), this._renderer = null, this._issues = null, we() === this && (Ce(null), w(null));
1131
1145
  }
1132
- }, sn = [
1133
- [/\.jpe?g(\?|#|$)/i, "image/jpeg"],
1134
- [/\.webp(\?|#|$)/i, "image/webp"],
1135
- [/\.avif(\?|#|$)/i, "image/avif"]
1136
- ];
1146
+ }, sn = "KHR_materials_diffuse_transmission";
1137
1147
  function cn(e) {
1138
- return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : sn.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
1139
- }
1140
- function ln(e) {
1141
- for (let t = 8; t + 12 <= e.length;) {
1142
- let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
1143
- if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
1144
- t = r;
1145
- }
1146
- return e;
1147
- }
1148
- function un({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
1149
- let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
1150
- r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
1151
- let o = new tt(a, t, n, vt, Ct);
1152
- return o.needsUpdate = !0, o;
1153
- }
1154
- function dn(e, t) {
1155
- return b().decodeImage(t === "image/png" ? ln(e) : e, t);
1156
- }
1157
- async function fn(e) {
1158
- let t = await fetch(e);
1159
- if (!t.ok) throw Error(`HTTP ${t.status}`);
1160
- return new Uint8Array(await t.arrayBuffer());
1161
- }
1162
- function pn(e, t) {
1163
- return t.bufferView === void 0 ? fn(e.options.manager.resolveURL(R.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
1164
- }
1165
- var mn = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
1166
- function hn(e, t, n) {
1167
- if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
1168
- let r = pn(e, e.json.images[t]).then((e) => new Promise((t, r) => {
1169
- n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
1170
- }));
1171
- return e.sourceCache[t] = r, r;
1172
- }
1173
- async function gn(e, t = cn({ uri: e })) {
1174
- let n = un(await dn(await fn(e), t));
1175
- return n.flipY = !0, n;
1176
- }
1177
- function _n(e, t = null) {
1178
- return e.loadImageSource = function(e, n) {
1179
- if (mn(this, n)) return hn(this, e, n);
1180
- let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
1181
- return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
1182
- }, { name: "RAYZEE_missing_image_decoder" };
1183
- }
1184
- function vn(e, t = null) {
1185
- return e.loadImageSource = function(e, n) {
1186
- if (mn(this, n)) return hn(this, e, n);
1187
- if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
1188
- let r = this.json.images[e], i = cn(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = pn(this, r).then((e) => dn(e, i)).then((e) => {
1189
- let t = un(e, { shared: !0 });
1190
- return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
1191
- }).catch((e) => {
1192
- throw t?.(a, e), e;
1193
- });
1194
- return this.sourceCache[e] = o, o;
1195
- }, { name: "RAYZEE_platform_images" };
1196
- }
1197
- //#endregion
1198
- //#region src/Processor/GLTFDiffuseTransmission.js
1199
- var yn = "KHR_materials_diffuse_transmission";
1200
- function bn(e) {
1201
1148
  let t = (t, n, r, i) => {
1202
1149
  let a = {};
1203
1150
  return e.assignTexture(a, n, r, i).then(() => {
@@ -1205,7 +1152,7 @@ function bn(e) {
1205
1152
  });
1206
1153
  };
1207
1154
  return {
1208
- name: yn,
1155
+ name: sn,
1209
1156
  afterRoot(n) {
1210
1157
  let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
1211
1158
  for (let o of n.scenes ?? []) o.traverse((n) => {
@@ -1213,7 +1160,7 @@ function bn(e) {
1213
1160
  for (let n of o) {
1214
1161
  if (i.has(n)) continue;
1215
1162
  i.add(n);
1216
- let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[yn];
1163
+ let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[sn];
1217
1164
  if (!s) continue;
1218
1165
  n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
1219
1166
  let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
@@ -1221,7 +1168,7 @@ function bn(e) {
1221
1168
  1,
1222
1169
  1
1223
1170
  ];
1224
- n.diffuseTransmissionColor = new I().setRGB(c, l, u, st), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, H));
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));
1225
1172
  }
1226
1173
  });
1227
1174
  return Promise.all(a);
@@ -1230,20 +1177,20 @@ function bn(e) {
1230
1177
  }
1231
1178
  //#endregion
1232
1179
  //#region src/Processor/GLTFDecoders.js
1233
- var xn = "KHR_draco_mesh_compression", Sn = "KHR_texture_basisu", Cn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], wn = new TextDecoder();
1234
- function Tn(e) {
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) {
1235
1182
  if (typeof e == "string") return e;
1236
1183
  if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
1237
1184
  let t = new DataView(e);
1238
- if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return wn.decode(e);
1185
+ if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return fn.decode(e);
1239
1186
  let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
1240
- return wn.decode(new Uint8Array(e, 20, n));
1187
+ return fn.decode(new Uint8Array(e, 20, n));
1241
1188
  }
1242
- async function En(e, t, n) {
1189
+ async function mn(e, t, n) {
1243
1190
  let { dracoDecoderPath: r, ktx2TranscoderPath: i } = E(), [a, o, s] = await Promise.all([
1244
- t.includes(xn) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
1245
- t.includes(Sn) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
1246
- Cn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
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
1247
1194
  ]);
1248
1195
  if (a) {
1249
1196
  let t = new a.DRACOLoader();
@@ -1262,15 +1209,15 @@ async function En(e, t, n) {
1262
1209
  }
1263
1210
  s && e.setMeshoptDecoder(s.MeshoptDecoder);
1264
1211
  }
1265
- function Dn(e, t) {
1212
+ function hn(e, t) {
1266
1213
  let n = e.parse.bind(e);
1267
1214
  return e.parse = (r, i, a, o) => {
1268
- En(e, Tn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
1215
+ mn(e, pn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
1269
1216
  }, e;
1270
1217
  }
1271
1218
  //#endregion
1272
1219
  //#region src/Processor/AssetLoader.js
1273
- var On = S("assets"), kn = {
1220
+ var gn = S("assets"), _n = {
1274
1221
  glb: {
1275
1222
  type: "model",
1276
1223
  name: "GLB (GLTF Binary)"
@@ -1299,45 +1246,52 @@ var On = S("assets"), kn = {
1299
1246
  type: "image",
1300
1247
  name: "WebP"
1301
1248
  }
1302
- }, Y = {
1249
+ }, X = {
1303
1250
  addOn: "rayzee/addons/archives",
1304
1251
  install: "assetLoader.setArchiveImporter()"
1305
- }, X = {
1252
+ }, Z = {
1306
1253
  addOn: "rayzee/addons/formats",
1307
1254
  install: "assetLoader.registerFormat()"
1308
- }, An = {
1309
- zip: Y,
1310
- gz: Y,
1311
- tgz: Y,
1312
- tar: Y,
1313
- fbx: X,
1314
- obj: X,
1315
- stl: X,
1316
- ply: X,
1317
- dae: X,
1318
- "3mf": X,
1319
- usd: X,
1320
- usda: X,
1321
- usdc: X,
1322
- usdz: X,
1323
- exr: X
1255
+ }, vn = {
1256
+ zip: X,
1257
+ gz: X,
1258
+ tgz: X,
1259
+ tar: X,
1260
+ fbx: Z,
1261
+ obj: Z,
1262
+ stl: Z,
1263
+ ply: Z,
1264
+ dae: Z,
1265
+ "3mf": Z,
1266
+ usd: Z,
1267
+ usda: Z,
1268
+ usdc: Z,
1269
+ usdz: Z,
1270
+ exr: Z
1324
1271
  };
1325
- function jn(e) {
1326
- let t = new $e();
1272
+ function yn(e) {
1273
+ let t = new rt();
1327
1274
  for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
1328
1275
  e.index && t.setIndex(e.index);
1329
1276
  for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
1330
1277
  return t;
1331
1278
  }
1332
- var Mn = 683;
1333
- function Nn(e, t, n, r) {
1279
+ var bn = {
1280
+ name: "RAYZEE_camera_clip",
1281
+ afterRoot(e) {
1282
+ for (let t of e.scenes) t.traverse((e) => {
1283
+ e.isCamera && e.near > 0 && (e.userData.clipStart = e.near);
1284
+ });
1285
+ }
1286
+ }, xn = 683;
1287
+ function Sn(e, t, n, r) {
1334
1288
  if (!(r.normalize ?? !0)) return Math.PI;
1335
1289
  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);
1336
1290
  return Number.isFinite(o) ? o : Math.PI;
1337
1291
  }
1338
- var Pn = class e extends L {
1292
+ var Cn = class e extends L {
1339
1293
  constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
1340
- 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 ct(), 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) => {
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) => {
1341
1295
  this._loadCancelled || this._issues?.record(C.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
1342
1296
  };
1343
1297
  }
@@ -1357,7 +1311,7 @@ var Pn = class e extends L {
1357
1311
  downloads: this.downloads,
1358
1312
  key: i,
1359
1313
  policy: a,
1360
- name: K(t),
1314
+ name: q(t),
1361
1315
  signal: o.signal,
1362
1316
  onProgress: this._downloadProgress(n, r)
1363
1317
  });
@@ -1374,7 +1328,7 @@ var Pn = class e extends L {
1374
1328
  return t ? `${e}::${t}` : null;
1375
1329
  }
1376
1330
  get downloads() {
1377
- return this._downloads?._storage !== this.storage && (this._downloads = new q(this.storage)), this._downloads;
1331
+ return this._downloads?._storage !== this.storage && (this._downloads = new J(this.storage)), this._downloads;
1378
1332
  }
1379
1333
  _isCancellation(e) {
1380
1334
  return this._loadCancelled || e?.name === "AbortError" || e?.code === "LOAD_CANCELLED";
@@ -1411,7 +1365,7 @@ var Pn = class e extends L {
1411
1365
  _adoptExternalObject(e) {
1412
1366
  let t;
1413
1367
  try {
1414
- t = At(e);
1368
+ t = jt(e);
1415
1369
  } catch (t) {
1416
1370
  throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
1417
1371
  }
@@ -1445,10 +1399,10 @@ var Pn = class e extends L {
1445
1399
  }
1446
1400
  getFileFormat(e) {
1447
1401
  let t = e.split(".").pop().toLowerCase();
1448
- return kn[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
1402
+ return _n[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
1449
1403
  }
1450
1404
  formatError(e) {
1451
- let t = An[e.split(".").pop().toLowerCase()];
1405
+ let t = vn[e.split(".").pop().toLowerCase()];
1452
1406
  return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
1453
1407
  }
1454
1408
  async inspectArchive(e) {
@@ -1499,7 +1453,7 @@ var Pn = class e extends L {
1499
1453
  }
1500
1454
  async loadFolder(e, t = {}) {
1501
1455
  let n = await this._archiveImporter();
1502
- if (!n) throw Error(`${e.name}: folders are read by ${Y.addOn} — install it with ${Y.install}`);
1456
+ if (!n) throw Error(`${e.name}: folders are read by ${X.addOn} — install it with ${X.install}`);
1503
1457
  y({
1504
1458
  isLoading: !0,
1505
1459
  status: `Loading ${e.name}...`,
@@ -1516,7 +1470,7 @@ var Pn = class e extends L {
1516
1470
  }
1517
1471
  }
1518
1472
  async loadAssetFromUrl(t, n = {}) {
1519
- let { filename: r = K(t), cacheKey: i = t, cachePolicy: a, ...o } = n;
1473
+ let { filename: r = q(t), cacheKey: i = t, cachePolicy: a, ...o } = n;
1520
1474
  if (!this.getFileFormat(r)) throw this.formatError(r);
1521
1475
  this._loadCancelled = !1;
1522
1476
  let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
@@ -1552,7 +1506,7 @@ var Pn = class e extends L {
1552
1506
  }
1553
1507
  }
1554
1508
  async loadModelFromFile(e, t) {
1555
- let n = this.storage ? this._keyed("file", O(await Ae(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);
1509
+ 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);
1556
1510
  return this._sourceKey = n, i;
1557
1511
  }
1558
1512
  async _loadModelFileByExtension(e, t) {
@@ -1599,7 +1553,7 @@ var Pn = class e extends L {
1599
1553
  };
1600
1554
  try {
1601
1555
  let r = await this.loadEnvironment(n);
1602
- return he(r, O(await Ae(e))), this.dispatchEvent({
1556
+ return he(r, O(await je(e))), this.dispatchEvent({
1603
1557
  type: "load",
1604
1558
  texture: r,
1605
1559
  filename: t
@@ -1658,21 +1612,21 @@ var Pn = class e extends L {
1658
1612
  }
1659
1613
  async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
1660
1614
  let i = this._formats.get(n);
1661
- if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new Ot(this._loadingManager).setDataType(at)), !r && An[n]) throw this.formatError(`environment.${n}`);
1615
+ 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}`);
1662
1616
  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;
1663
1617
  try {
1664
- r ? l = await r.loadAsync(s.url, c) : b().decodeImage ? (l = await gn(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = H) : (this.loaderCache.texture || (this.loaderCache.texture = new St(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = H);
1618
+ 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);
1665
1619
  } finally {
1666
1620
  s.release();
1667
1621
  }
1668
- return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && Fn(l, this.maxEnvironmentWidth), l.mapping = it, l.minFilter = ot, l.magFilter = ot, l;
1622
+ return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && wn(l, this.maxEnvironmentWidth), l.mapping = st, l.minFilter = lt, l.magFilter = lt, l;
1669
1623
  }
1670
1624
  applyEnvironmentToScene(e) {
1671
1625
  this.scene.background = e, this.scene.environment = e;
1672
1626
  }
1673
1627
  async createGLTFLoader() {
1674
- let e = Dn(new Dt(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
1675
- return b().decodeImage ? e.register((e) => vn(e, t)) : te() || e.register((e) => _n(e, t)), e.register((e) => bn(e)), e;
1628
+ let e = hn(new Ot(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
1629
+ 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;
1676
1630
  }
1677
1631
  _reportImageFailure(e, t) {
1678
1632
  try {
@@ -1707,9 +1661,9 @@ var Pn = class e extends L {
1707
1661
  canCancel: i,
1708
1662
  loadedBytes: 0,
1709
1663
  totalBytes: 0
1710
- }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(R.extractUrlBase(t));
1664
+ }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
1711
1665
  let e = await v(() => 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 = Pe(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
1666
+ 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({
1713
1667
  type: "load",
1714
1668
  model: e.scene,
1715
1669
  filename: t.split("/").pop()
@@ -1738,7 +1692,7 @@ var Pn = class e extends L {
1738
1692
  canCancel: i,
1739
1693
  loadedBytes: 0,
1740
1694
  totalBytes: 0
1741
- }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(R.extractUrlBase(t));
1695
+ }), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
1742
1696
  let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
1743
1697
  return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
1744
1698
  root: e.scene,
@@ -1756,7 +1710,7 @@ var Pn = class e extends L {
1756
1710
  return n.name = e.name || t, this._processAndParent(n), { root: n };
1757
1711
  }
1758
1712
  removeModelRoot(e) {
1759
- e && (e.userData.__rayzeeExternal ? (re(e), e.parent?.remove(e)) : ee(e));
1713
+ e && (e.userData.__rayzeeExternal ? (ie(e), e.parent?.remove(e)) : te(e));
1760
1714
  }
1761
1715
  async loadGLBFromArrayBuffer(e, t = "model.glb") {
1762
1716
  let n = await this.createGLTFLoader();
@@ -1767,7 +1721,7 @@ var Pn = class e extends L {
1767
1721
  progress: 5
1768
1722
  }), await new Promise((e) => setTimeout(e, 0));
1769
1723
  let r = await v(() => n.parseAsync(e, ""));
1770
- return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Pe(r), y({
1724
+ return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r), y({
1771
1725
  isLoading: !0,
1772
1726
  status: "Processing Data...",
1773
1727
  progress: 10
@@ -1800,20 +1754,20 @@ var Pn = class e extends L {
1800
1754
  }), n;
1801
1755
  }
1802
1756
  async onModelLoad(e) {
1803
- let t = new l("onModelLoad");
1757
+ let t = new p("onModelLoad");
1804
1758
  t.start("Camera extraction");
1805
1759
  let n = this.extractCamerasFromModel(e);
1806
1760
  t.end("Camera extraction"), t.start("Camera setup");
1807
- let r = new Qe().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
1761
+ let r = new nt().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
1808
1762
  this.controls?.target.copy(i);
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), u = Math.PI / 6, d = new U(Math.cos(u) * c, c / Math.sqrt(2), Math.sin(u) * c);
1810
- if (this.camera.position.copy(d.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) {
1763
+ 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);
1764
+ 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) {
1811
1765
  let e = r.min.y;
1812
1766
  this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
1813
1767
  }
1814
1768
  t.start("Process model objects"), this.processModelObjects(e), t.end("Process model objects"), t.start("Scene add"), this.scene.add(e), t.end("Scene add");
1815
- let f = o;
1816
- return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, f), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
1769
+ let d = o;
1770
+ return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, d), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
1817
1771
  type: "modelProcessed",
1818
1772
  model: e,
1819
1773
  cameras: n,
@@ -1821,13 +1775,13 @@ var Pn = class e extends L {
1821
1775
  center: i,
1822
1776
  size: a,
1823
1777
  maxDim: o,
1824
- sceneScale: f
1778
+ sceneScale: d
1825
1779
  }
1826
1780
  }), this.dispatchEvent({ type: "SceneRebuild" }), {
1827
1781
  center: i,
1828
1782
  size: a,
1829
1783
  maxDim: o,
1830
- sceneScale: f
1784
+ sceneScale: d
1831
1785
  };
1832
1786
  }
1833
1787
  extractCamerasFromModel(e) {
@@ -1843,10 +1797,10 @@ var Pn = class e extends L {
1843
1797
  let t = [], n = [];
1844
1798
  e.traverse((e) => {
1845
1799
  let r = e.userData;
1846
- e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Nn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / Mn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= Mn, r.__luxConverted = !0);
1800
+ 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);
1847
1801
  let i = e.name.startsWith("RectAreaLightPlaceholder");
1848
1802
  if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
1849
- let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Nn(e, r.width, r.height, r), a = new V(new I(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
1803
+ 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);
1850
1804
  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);
1851
1805
  }
1852
1806
  e.isMesh && Array.isArray(e.material) && t.push(e);
@@ -1857,8 +1811,8 @@ var Pn = class e extends L {
1857
1811
  let r = e.userData.__rayzeeExternal === !0;
1858
1812
  for (let e of t) {
1859
1813
  if (!e.parent) continue;
1860
- console.log("Found multi-material mesh:", e.name), r && (e.geometry = jn(e.geometry));
1861
- let t = kt(e);
1814
+ console.log("Found multi-material mesh:", e.name), r && (e.geometry = yn(e.geometry));
1815
+ let t = At(e);
1862
1816
  for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
1863
1817
  e.parent.add(t), e.parent.remove(e);
1864
1818
  }
@@ -1867,7 +1821,7 @@ var Pn = class e extends L {
1867
1821
  this.sceneScale = t;
1868
1822
  }
1869
1823
  createFloorPlane() {
1870
- this.floorPlane = new lt(new et(), new ut({
1824
+ this.floorPlane = new pt(new it(), new mt({
1871
1825
  transparent: !1,
1872
1826
  color: 3158064,
1873
1827
  roughness: 1,
@@ -1890,7 +1844,7 @@ var Pn = class e extends L {
1890
1844
  }
1891
1845
  getSupportedFormats(e = null) {
1892
1846
  let t = {
1893
- ...kn,
1847
+ ..._n,
1894
1848
  ...this._archiveFormats
1895
1849
  };
1896
1850
  for (let [e, { type: n, name: r }] of this._formats) t[e] = {
@@ -1915,7 +1869,7 @@ var Pn = class e extends L {
1915
1869
  this._listeners = void 0;
1916
1870
  }
1917
1871
  };
1918
- function Fn(e, t) {
1872
+ function wn(e, t) {
1919
1873
  let { data: n, width: r, height: i } = e.image ?? {};
1920
1874
  if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
1921
1875
  let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
@@ -1936,17 +1890,17 @@ function Fn(e, t) {
1936
1890
  data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
1937
1891
  width: o,
1938
1892
  height: s
1939
- }, e.needsUpdate = !0, On.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
1893
+ }, e.needsUpdate = !0, gn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
1940
1894
  }
1941
1895
  //#endregion
1942
1896
  //#region src/HeadlessCanvas.js
1943
- var In = {
1897
+ var Tn = {
1944
1898
  addEventListener() {},
1945
1899
  removeEventListener() {},
1946
1900
  dispatchEvent() {
1947
1901
  return !0;
1948
1902
  }
1949
- }, Ln = class {
1903
+ }, En = class {
1950
1904
  constructor(e) {
1951
1905
  this.canvas = e, this._configuration = null, this._texture = null;
1952
1906
  }
@@ -1974,12 +1928,12 @@ var In = {
1974
1928
  return this._texture;
1975
1929
  }
1976
1930
  };
1977
- function Rn(e = 1, t = 1) {
1931
+ function Dn(e = 1, t = 1) {
1978
1932
  let n = {
1979
- ...In,
1933
+ ...Tn,
1980
1934
  defaultView: null
1981
1935
  }, r = {
1982
- ...In,
1936
+ ...Tn,
1983
1937
  isHeadlessCanvas: !0,
1984
1938
  width: e,
1985
1939
  height: t,
@@ -2006,12 +1960,12 @@ function Rn(e = 1, t = 1) {
2006
1960
  hasPointerCapture: () => !1,
2007
1961
  focus() {},
2008
1962
  getContext: (e) => e === "webgpu" ? i : null
2009
- }, i = new Ln(r);
1963
+ }, i = new En(r);
2010
1964
  return r;
2011
1965
  }
2012
1966
  //#endregion
2013
1967
  //#region src/managers/ViewCamera.js
2014
- var zn = class extends mt {
1968
+ var On = class extends vt {
2015
1969
  constructor(e, t, n, r) {
2016
1970
  super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
2017
1971
  }
@@ -2035,17 +1989,17 @@ var zn = class extends mt {
2035
1989
  return -this.orthoHalfHeight * this.aspect;
2036
1990
  }
2037
1991
  updateProjectionMatrix() {
2038
- this.orthographic ? pt.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
1992
+ this.orthographic ? _t.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
2039
1993
  }
2040
1994
  copy(e, t) {
2041
1995
  return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
2042
1996
  }
2043
- }, Bn = "__rayzeeUserLight", Vn = {
2044
- DirectionalLight: nt,
2045
- PointLight: ht,
2046
- SpotLight: bt,
2047
- RectAreaLight: V
2048
- }, Hn = class extends L {
1997
+ }, kn = "__rayzeeUserLight", An = {
1998
+ DirectionalLight: at,
1999
+ PointLight: yt,
2000
+ SpotLight: St,
2001
+ RectAreaLight: B
2002
+ }, jn = class extends L {
2049
2003
  constructor(e, t, n, r = {}) {
2050
2004
  super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
2051
2005
  }
@@ -2093,14 +2047,14 @@ var zn = class extends mt {
2093
2047
  }[e];
2094
2048
  if (!t) return null;
2095
2049
  let n;
2096
- if (e === "DirectionalLight") n = new nt(t.color, t.intensity), n.position.fromArray(t.position);
2097
- else if (e === "PointLight") n = new ht(t.color, t.intensity), n.position.fromArray(t.position);
2050
+ if (e === "DirectionalLight") n = new at(t.color, t.intensity), n.position.fromArray(t.position);
2051
+ else if (e === "PointLight") n = new yt(t.color, t.intensity), n.position.fromArray(t.position);
2098
2052
  else if (e === "SpotLight") {
2099
- n = new bt(t.color, t.intensity), n.position.fromArray(t.position), n.angle = z.degToRad(t.angle);
2100
- let e = new B();
2053
+ n = new St(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
2054
+ let e = new z();
2101
2055
  this.scene.add(e), n.target = e;
2102
- } else e === "RectAreaLight" && (n = new V(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");
2103
- n.userData[Bn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
2056
+ } 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");
2057
+ n.userData[kn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
2104
2058
  let r = this.scene.getObjectsByProperty("isLight", !0).length;
2105
2059
  return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
2106
2060
  }
@@ -2126,7 +2080,7 @@ var zn = class extends mt {
2126
2080
  this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
2127
2081
  }
2128
2082
  transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
2129
- this._removeAllLights(t ? (e) => !e.userData?.[Bn] : void 0);
2083
+ this._removeAllLights(t ? (e) => !e.userData?.[kn] : void 0);
2130
2084
  let n = e.getObjectsByProperty("isLight", !0);
2131
2085
  if (!n || n.length === 0) {
2132
2086
  this.updateLights();
@@ -2135,7 +2089,7 @@ var zn = class extends mt {
2135
2089
  for (let e of n) {
2136
2090
  let t = e.clone();
2137
2091
  if (e.updateWorldMatrix(!0, !1), e.getWorldPosition(t.position), e.getWorldQuaternion(t.quaternion), e.getWorldScale(t.scale), t.isRectAreaLight && (t.width *= t.scale.x, t.height *= t.scale.y, t.scale.set(1, 1, 1)), (e.isSpotLight || e.isDirectionalLight) && e.target) {
2138
- let n = new B();
2092
+ let n = new z();
2139
2093
  e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
2140
2094
  }
2141
2095
  this.scene.add(t);
@@ -2180,14 +2134,14 @@ var zn = class extends mt {
2180
2134
  this.sceneHelpers?.clear(), this._removeAllLights();
2181
2135
  let t = [];
2182
2136
  for (let n of e ?? []) {
2183
- let e = Vn[n.type];
2137
+ let e = An[n.type];
2184
2138
  if (!e) continue;
2185
2139
  let r = new e();
2186
2140
  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 ?? [
2187
2141
  1,
2188
2142
  1,
2189
2143
  1
2190
- ]), r.userData = p(n.userData) ?? {};
2144
+ ]), r.userData = i(n.userData) ?? {};
2191
2145
  for (let e of [
2192
2146
  "angle",
2193
2147
  "penumbra",
@@ -2197,7 +2151,7 @@ var zn = class extends mt {
2197
2151
  "height"
2198
2152
  ]) typeof n[e] == "number" && (r[e] = n[e]);
2199
2153
  if (n.target) {
2200
- let e = new B();
2154
+ let e = new z();
2201
2155
  e.position.fromArray(n.target), this.scene.add(e), r.target = e;
2202
2156
  }
2203
2157
  this.scene.add(r), t.push(r);
@@ -2237,7 +2191,7 @@ var zn = class extends mt {
2237
2191
  }
2238
2192
  _buildDescriptor(e) {
2239
2193
  let t = 0;
2240
- e.type === "SpotLight" && e.angle !== void 0 ? t = z.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = z.radToDeg(e.userData?.angle ?? 0));
2194
+ e.type === "SpotLight" && e.angle !== void 0 ? t = R.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = R.radToDeg(e.userData?.angle ?? 0));
2241
2195
  let n = {
2242
2196
  uuid: e.uuid,
2243
2197
  name: e.name,
@@ -2256,7 +2210,7 @@ var zn = class extends mt {
2256
2210
  exposure: e.userData?.exposure ?? 0
2257
2211
  };
2258
2212
  if (e.type === "RectAreaLight") {
2259
- n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = z.radToDeg(e.userData?.spread ?? Math.PI);
2213
+ n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = R.radToDeg(e.userData?.spread ?? Math.PI);
2260
2214
  let t = e.userData?.shape;
2261
2215
  n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
2262
2216
  let r = e.getWorldDirection(e.position.clone());
@@ -2272,11 +2226,11 @@ var zn = class extends mt {
2272
2226
  ], 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);
2273
2227
  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;
2274
2228
  }
2275
- }, Z = ({ element: e, pbrtEntry: t } = {}) => ({
2229
+ }, Mn = ({ element: e, pbrtEntry: t } = {}) => ({
2276
2230
  ...e === void 0 ? {} : { element: e },
2277
2231
  ...t === void 0 ? {} : { pbrtEntry: t }
2278
- }), Q = /* @__PURE__ */ new WeakMap(), Un = 3e4, Wn = new Set([...Object.values(g), ...Object.values(h)]), Gn = /* @__PURE__ */ new Set();
2279
- async function Kn(e, t) {
2232
+ }), Q = /* @__PURE__ */ new WeakMap(), Nn = 3e4, Pn = new Set([...Object.values(g), ...Object.values(h)]), Fn = /* @__PURE__ */ new Set();
2233
+ async function In(e, t) {
2280
2234
  if (!t || typeof self < "u") return e.init();
2281
2235
  globalThis.self = {
2282
2236
  requestAnimationFrame: () => 0,
@@ -2289,36 +2243,57 @@ async function Kn(e, t) {
2289
2243
  }
2290
2244
  }
2291
2245
  var $ = S("engine");
2292
- function qn() {
2246
+ function Ln() {
2293
2247
  let e = new Float32Array(16);
2294
- return new Uint32Array(e.buffer)[3] = _e.TRIANGLE_LEAF, e;
2248
+ return new Uint32Array(e.buffer)[3] = ve.TRIANGLE_LEAF, e;
2295
2249
  }
2296
- function Jn(e, t) {
2250
+ function Rn(e, t) {
2297
2251
  e.lost.then((e) => {
2298
2252
  t.app && t.app._handleDeviceLost(e);
2299
2253
  });
2300
2254
  }
2301
- var Yn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
2302
- function Xn(e) {
2255
+ var zn = [
2256
+ "core-features-and-limits",
2257
+ "depth-clip-control",
2258
+ "depth32float-stencil8",
2259
+ "texture-compression-bc",
2260
+ "texture-compression-bc-sliced-3d",
2261
+ "texture-compression-etc2",
2262
+ "texture-compression-astc",
2263
+ "texture-compression-astc-sliced-3d",
2264
+ "timestamp-query",
2265
+ "indirect-first-instance",
2266
+ "shader-f16",
2267
+ "rg11b10ufloat-renderable",
2268
+ "bgra8unorm-storage",
2269
+ "float32-filterable",
2270
+ "float32-blendable",
2271
+ "clip-distances",
2272
+ "dual-source-blending",
2273
+ "subgroups",
2274
+ "texture-formats-tier1",
2275
+ "texture-formats-tier2"
2276
+ ], Bn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
2277
+ function Vn(e) {
2303
2278
  let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
2304
2279
  return {
2305
2280
  vendor: t.vendor ?? "",
2306
2281
  architecture: t.architecture ?? "",
2307
2282
  device: t.device ?? "",
2308
2283
  description: t.description ?? "",
2309
- isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Yn.test(n)
2284
+ isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Bn.test(n)
2310
2285
  };
2311
2286
  }
2312
- var Zn = class extends L {
2287
+ var Hn = class extends L {
2313
2288
  constructor(e, t = {}) {
2314
- super(), this._headless = t.headless === !0 || !e, e ??= Rn();
2289
+ super(), this._headless = t.headless === !0 || !e, e ??= Dn();
2315
2290
  try {
2316
2291
  Q.get(e)?.dispose();
2317
2292
  } catch (e) {
2318
2293
  $.warn("prior canvas owner dispose failed", e);
2319
2294
  }
2320
2295
  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`.");
2321
- this._issues = new ve({
2296
+ this._issues = new ye({
2322
2297
  strict: t.strict === !0,
2323
2298
  onIssue: (e) => this.dispatchEvent({
2324
2299
  type: g.ISSUE,
@@ -2343,18 +2318,18 @@ var Zn = class extends L {
2343
2318
  }
2344
2319
  async init() {
2345
2320
  let e = this._initStorage();
2346
- 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(ge.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(qn()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
2321
+ 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;
2347
2322
  }
2348
2323
  async setStorageOpener(e) {
2349
2324
  this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
2350
2325
  }
2351
2326
  async _initStorage() {
2352
- let e = this._storageOption ?? (this._issues.strict && !we("storage") ? !1 : E().storage);
2327
+ let e = this._storageOption ?? (this._issues.strict && !Te("storage") ? !1 : E().storage);
2353
2328
  if (e !== !1) {
2354
2329
  if (e && typeof e == "object") this.storage = e;
2355
2330
  else {
2356
2331
  if (!this._storageOpener) {
2357
- (this._storageOption !== void 0 || we("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
2332
+ (this._storageOption !== void 0 || Te("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
2358
2333
  return;
2359
2334
  }
2360
2335
  let { storage: e, reason: t, release: n } = await this._storageOpener(E().cacheNamespace);
@@ -2386,7 +2361,7 @@ var Zn = class extends L {
2386
2361
  });
2387
2362
  }
2388
2363
  addEventListener(e, t) {
2389
- !Wn.has(e) && !Gn.has(e) && (Gn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
2364
+ !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);
2390
2365
  }
2391
2366
  animate() {
2392
2367
  if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
@@ -2475,26 +2450,27 @@ var Zn = class extends L {
2475
2450
  t && this.stages.pathTracer?.noteViewChanged(), this._beforeReset(e || t), this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("pipeline:historyReset")), this._afterReset(), this.completion.reset(), this.wake(), this.dispatchEvent({ type: g.RENDER_RESET });
2476
2451
  }
2477
2452
  dispose() {
2478
- if (!this._disposed) {
2479
- 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) {
2480
- this.meshScene.environment?.dispose(), this.meshScene.environment = null;
2481
- for (let e of [...this.meshScene.children]) ee(e);
2482
- this.meshScene.clear(), this.meshScene = null;
2483
- }
2484
- this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
2485
- try {
2486
- let e = Ye().value, t = Ge().value;
2487
- e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
2488
- } catch (e) {
2489
- $.warn("failed to clear TSL texture singleton listeners", e);
2490
- }
2491
- this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), oe(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
2453
+ if (this._disposed) return;
2454
+ 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) {
2455
+ this.meshScene.environment?.dispose(), this.meshScene.environment = null;
2456
+ for (let e of [...this.meshScene.children]) te(e);
2457
+ this.meshScene.clear(), this.meshScene = null;
2458
+ }
2459
+ this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
2460
+ try {
2461
+ let e = $e().value, t = Ye().value;
2462
+ e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
2463
+ } catch (e) {
2464
+ $.warn("failed to clear TSL texture singleton listeners", e);
2492
2465
  }
2466
+ this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas);
2467
+ let e = this._gpuDevice;
2468
+ 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;
2493
2469
  }
2494
2470
  unloadScene() {
2495
2471
  if (this.isInitialized) {
2496
2472
  if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
2497
- this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(ge.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(qn()), 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 }));
2473
+ 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 }));
2498
2474
  }
2499
2475
  }
2500
2476
  async loadModel(e, t = {}) {
@@ -2539,7 +2515,7 @@ var Zn = class extends L {
2539
2515
  }
2540
2516
  async loadFile(e, t = {}) {
2541
2517
  if (t = this._sceneBudgets(t), typeof e == "string") {
2542
- let n = t.filename ?? K(e), r = this.assetLoader?.getFileFormat(n);
2518
+ let n = t.filename ?? q(e), r = this.assetLoader?.getFileFormat(n);
2543
2519
  if (!r) throw this.assetLoader.formatError(n);
2544
2520
  if (r.type === "environment" || r.type === "image") return this.loadEnvironment(e);
2545
2521
  await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromUrl(e, {
@@ -2553,24 +2529,24 @@ var Zn = class extends L {
2553
2529
  url: e,
2554
2530
  filename: n,
2555
2531
  cacheKey: t.cacheKey ?? null,
2556
- ...Z(t)
2532
+ ...Mn(t)
2557
2533
  });
2558
2534
  return;
2559
2535
  }
2560
2536
  if (Ne(e)) {
2561
- let n = Me(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
2537
+ let n = Fe(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
2562
2538
  if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
2563
2539
  await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
2564
2540
  type: g.MODEL_LOADED,
2565
2541
  filename: n.name
2566
2542
  }, async () => {
2567
- let e = await je(n);
2543
+ let e = await Me(n);
2568
2544
  return {
2569
2545
  kind: "local-folder",
2570
2546
  folder: e,
2571
2547
  key: O(e),
2572
2548
  ...n.flat ? { flat: !0 } : {},
2573
- ...Z(t)
2549
+ ...Mn(t)
2574
2550
  };
2575
2551
  }), this._sceneSourceInput = n;
2576
2552
  return;
@@ -2578,7 +2554,7 @@ var Zn = class extends L {
2578
2554
  let n = this.assetLoader?.getFileFormat(e?.name || "");
2579
2555
  if (!n) throw this.assetLoader.formatError(e?.name || "");
2580
2556
  if (n.type !== "environment" && n.type !== "image") {
2581
- let n = Ae(e).catch(() => ({
2557
+ let n = je(e).catch(() => ({
2582
2558
  name: e.name,
2583
2559
  size: e.size,
2584
2560
  lastModified: e.lastModified ?? 0,
@@ -2593,7 +2569,7 @@ var Zn = class extends L {
2593
2569
  kind: "local-file",
2594
2570
  file: e,
2595
2571
  key: e.sample ? O(e) : null,
2596
- ...Z(t)
2572
+ ...Mn(t)
2597
2573
  };
2598
2574
  }), this._sceneSourceInput = e;
2599
2575
  return;
@@ -2649,11 +2625,11 @@ var Zn = class extends L {
2649
2625
  }
2650
2626
  async _loadWithSceneRebuild(e, t, n = null) {
2651
2627
  if (this._loadingInProgress) throw this._busyError("PathTracerApp");
2652
- this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? ce : 0);
2628
+ this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? le : 0);
2653
2629
  try {
2654
2630
  await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }), this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced();
2655
2631
  } catch (e) {
2656
- throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? le() : e?.code !== "LOAD_IN_PROGRESS" && y({
2632
+ throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? b() : e?.code !== "LOAD_IN_PROGRESS" && y({
2657
2633
  status: `Error: ${e?.message ?? e}`,
2658
2634
  failed: !0,
2659
2635
  progress: 100
@@ -2693,7 +2669,7 @@ var Zn = class extends L {
2693
2669
  };
2694
2670
  n.intensity !== void 0 && (r.environmentIntensity = n.intensity, r.backgroundIntensity = n.intensity), n.rotation !== void 0 && (r.environmentRotation = n.rotation), this.settings.setMany(r, {
2695
2671
  reset: !1,
2696
- source: J.SCENE_METADATA
2672
+ source: Y.SCENE_METADATA
2697
2673
  }), this.scene && (this.scene.background = e), this.dispatchEvent({
2698
2674
  type: g.SCENE_METADATA_APPLIED,
2699
2675
  metadata: t,
@@ -2710,7 +2686,7 @@ var Zn = class extends L {
2710
2686
  source: e[t].source
2711
2687
  }])), this.settings.setMany(t, {
2712
2688
  reset: !1,
2713
- source: J.SCENE_METADATA
2689
+ source: Y.SCENE_METADATA
2714
2690
  }), this.dispatchEvent({
2715
2691
  type: g.SCENE_METADATA_APPLIED,
2716
2692
  metadata: this.sceneMetadata,
@@ -2722,7 +2698,7 @@ var Zn = class extends L {
2722
2698
  if (!e) return;
2723
2699
  this._unlitRestore = null;
2724
2700
  let t = this.settings.getEffective();
2725
- for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source === J.SCENE_METADATA && this.settings.set(n, r, {
2701
+ for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source === Y.SCENE_METADATA && this.settings.set(n, r, {
2726
2702
  reset: !1,
2727
2703
  source: i
2728
2704
  });
@@ -2734,7 +2710,7 @@ var Zn = class extends L {
2734
2710
  }
2735
2711
  async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
2736
2712
  this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
2737
- let n = new l("", {
2713
+ let n = new p("", {
2738
2714
  namespace: "scene",
2739
2715
  level: "info"
2740
2716
  }), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
@@ -2762,7 +2738,7 @@ var Zn = class extends L {
2762
2738
  let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
2763
2739
  this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
2764
2740
  }
2765
- return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), le(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
2741
+ 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;
2766
2742
  }
2767
2743
  _sceneSummaryParts() {
2768
2744
  let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
@@ -2848,16 +2824,16 @@ var Zn = class extends L {
2848
2824
  }
2849
2825
  _sceneBudgets(e) {
2850
2826
  return this._memorySpill === !1 || !this.storage ? e : {
2851
- maxTriangles: ae,
2827
+ maxTriangles: oe,
2852
2828
  maxPlacements: me,
2853
2829
  ...e
2854
2830
  };
2855
2831
  }
2856
2832
  _planSpill() {
2857
2833
  let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
2858
- this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? ce : 0);
2834
+ this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? le : 0);
2859
2835
  let t = e ? this.meshScene?.environment : null, n = t?.image;
2860
- return n && Fn(t, ce), 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;
2836
+ 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;
2861
2837
  }
2862
2838
  _progressiveSpill() {
2863
2839
  let e = this._spillPlan ?? this._planSpill();
@@ -2879,7 +2855,7 @@ var Zn = class extends L {
2879
2855
  _scheduleRespill() {
2880
2856
  this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
2881
2857
  this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
2882
- }, Un), this._respillTimer.unref?.());
2858
+ }, Nn), this._respillTimer.unref?.());
2883
2859
  }
2884
2860
  async ensureSceneResident() {
2885
2861
  this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
@@ -2914,34 +2890,34 @@ var Zn = class extends L {
2914
2890
  return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
2915
2891
  }
2916
2892
  setReservedRenderResolution(e, { allowLower: t = !1 } = {}) {
2917
- let i = t ? e : Math.max(e, n);
2893
+ let n = t ? e : Math.max(e, l);
2918
2894
  if (!this.renderer) return this._pendingReservedRenderSize = {
2919
2895
  requestedPx: e,
2920
2896
  allowLower: t
2921
- }, Math.max(256, Math.min(r, Math.floor(i) || 256));
2922
- let a = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, o = se(this._hostMemoryGB), s = o.gb >= 8 && a >= 1024 * 1024 * 1024 ? r : 2048, l = c(Math.min(i, s));
2923
- 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` + (o.assumed && o.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
2897
+ }, Math.max(256, Math.min(r, Math.floor(n) || 256));
2898
+ let i = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, a = ce(this._hostMemoryGB), o = a.gb >= 8 && i >= 1024 * 1024 * 1024 ? r : 2048, s = c(Math.min(n, o));
2899
+ if (s < Math.floor(e) && this._issues.warn(C.RENDER_RESERVE_CAPPED, `reserved render size ${x.n(e)}px was capped to ${x.n(s)}px by this device's limits — renders above ${x.n(s)}px will be declined` + (a.assumed && a.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
2924
2900
  requested: e,
2925
- applied: l,
2926
- deviceMemoryGB: o.gb,
2927
- assumed: o.assumed,
2928
- maxStorageBufferBindingSize: a
2929
- }), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? l) !== l) {
2901
+ applied: s,
2902
+ deviceMemoryGB: a.gb,
2903
+ assumed: a.assumed,
2904
+ maxStorageBufferBindingSize: i
2905
+ }), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? s) !== s) {
2930
2906
  let e = this.pauseRendering;
2931
2907
  this.pauseRendering = !0;
2932
2908
  try {
2933
2909
  let e = this.renderer.domElement;
2934
- (e.width > l || e.height > l) && this.renderer.setSize(Math.min(e.width, l), Math.min(e.height, l), !1);
2910
+ (e.width > s || e.height > s) && this.renderer.setSize(Math.min(e.width, s), Math.min(e.height, s), !1);
2935
2911
  for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
2936
2912
  } finally {
2937
2913
  this.pauseRendering = e;
2938
2914
  }
2939
2915
  this.reset(), this.dispatchEvent({
2940
2916
  type: g.RESERVED_RENDER_SIZE_CHANGED,
2941
- size: l
2917
+ size: s
2942
2918
  });
2943
2919
  }
2944
- return l;
2920
+ return s;
2945
2921
  }
2946
2922
  _applyPendingReservedRenderSize() {
2947
2923
  let e = this._pendingReservedRenderSize;
@@ -2954,13 +2930,13 @@ var Zn = class extends L {
2954
2930
  });
2955
2931
  }
2956
2932
  getReservedRenderResolution() {
2957
- return n;
2933
+ return l;
2958
2934
  }
2959
2935
  _isRenderSizeSupported(e, t) {
2960
- return e > n || t > n ? (this._issues.record(C.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${n}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
2936
+ return e > l || t > l ? (this._issues.record(C.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${l}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
2961
2937
  width: e,
2962
2938
  height: t,
2963
- reserve: n
2939
+ reserve: l
2964
2940
  }), !1) : !0;
2965
2941
  }
2966
2942
  onResize() {
@@ -3112,7 +3088,7 @@ var Zn = class extends L {
3112
3088
  let e = this.stages.pathTracer, t = this.color?.status();
3113
3089
  return m({
3114
3090
  engine: de,
3115
- three: _t,
3091
+ three: xt,
3116
3092
  adapter: this.adapterInfo ?? null,
3117
3093
  mode: {
3118
3094
  headless: this._headless,
@@ -3173,50 +3149,55 @@ var Zn = class extends L {
3173
3149
  if (e !== "linear" && e !== "srgb" && !this.color?.hasConfig) throw Error(`renderToBuffer: colorSpace must be 'linear' or 'srgb' without a colour config loaded, got "${e}"`);
3174
3150
  let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
3175
3151
  if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
3176
- let { width: a, height: s } = r;
3152
+ let { width: a, height: c } = r, l = !!this.settings.get("transparentBackground");
3177
3153
  if (e === "srgb") {
3178
- let r = n === "display" ? this._displaySource(i) : null, c = {
3154
+ let r = n === "display" ? this._displaySource(i) : null, u = {
3179
3155
  exposure: this.renderer.toneMappingExposure,
3180
3156
  toneMapping: this.renderer.toneMapping,
3181
3157
  saturation: this.settings.get("saturation") ?? 1,
3182
- preserveAlpha: t,
3158
+ preserveAlpha: t && l,
3183
3159
  gain: this._displayGain()
3184
- }, l = await this._toneMapOnGPU(r?.texture ?? null, i, a, s, c), u = !l && c.gain ? await c.gain.cpu() : null;
3160
+ }, d = await this._toneMapOnGPU(r?.texture ?? null, i, a, c, u), f = !d && u.gain?.cpu ? await u.gain.cpu() : null, p = u.gain?.backdrop ?? 0;
3185
3161
  return {
3186
- data: l ?? f(r ? await this._readTexture(r.texture, a, s) : await o(this.renderer, i, a, s), {
3187
- ...c,
3188
- pixelGain: u && {
3189
- fn: u,
3162
+ data: d ?? o(r ? await this._readTexture(r.texture, a, c) : await s(this.renderer, i, a, c), {
3163
+ ...u,
3164
+ pixelGain: f || p ? {
3165
+ fn: f,
3190
3166
  width: a,
3191
- height: s
3192
- }
3167
+ height: c,
3168
+ backdrop: p
3169
+ } : null
3193
3170
  }),
3194
3171
  width: a,
3195
- height: s,
3172
+ height: c,
3196
3173
  colorSpace: e,
3197
3174
  source: r?.source ?? "accumulation",
3198
- toneMappedOn: l ? "gpu" : "cpu"
3175
+ toneMappedOn: d ? "gpu" : "cpu"
3199
3176
  };
3200
3177
  }
3201
- let { data: c, source: l } = n === "display" ? await this._readDisplaySource(i, a, s) : {
3202
- data: await o(this.renderer, i, a, s),
3178
+ let { data: u, source: d } = n === "display" ? await this._readDisplaySource(i, a, c) : {
3179
+ data: await s(this.renderer, i, a, c),
3203
3180
  source: "accumulation"
3204
3181
  };
3182
+ if (!l) {
3183
+ let e = u instanceof Uint16Array ? 15360 : 1;
3184
+ for (let t = 3; t < u.length; t += 4) u[t] = e;
3185
+ }
3205
3186
  if (e === "linear") return {
3206
- data: c,
3187
+ data: u,
3207
3188
  width: a,
3208
- height: s,
3189
+ height: c,
3209
3190
  colorSpace: e,
3210
3191
  workingSpace: this.color?.workingSpace ?? null,
3211
- source: l
3192
+ source: d
3212
3193
  };
3213
- let { rgba: u, colorSpace: d } = this.color.exportPixels(c, e);
3194
+ let { rgba: f, colorSpace: p } = this.color.exportPixels(u, e);
3214
3195
  return {
3215
- data: u,
3196
+ data: f,
3216
3197
  width: a,
3217
- height: s,
3218
- colorSpace: d,
3219
- source: l
3198
+ height: c,
3199
+ colorSpace: p,
3200
+ source: d
3220
3201
  };
3221
3202
  }
3222
3203
  async _toneMapOnGPU(e, t, n, r, i) {
@@ -3224,9 +3205,9 @@ var Zn = class extends L {
3224
3205
  if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
3225
3206
  try {
3226
3207
  let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
3227
- return s ? (this._readbackToneMapper ??= new Fe(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");
3208
+ 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");
3228
3209
  } catch (e) {
3229
- if (e instanceof ye) throw e;
3210
+ if (e instanceof be) throw e;
3230
3211
  return this._toneMapFallback("the GPU pass threw", e);
3231
3212
  } finally {
3232
3213
  this._readbackToneMapper?.release(), e && this._textureReadback?.release();
@@ -3364,7 +3345,7 @@ var Zn = class extends L {
3364
3345
  }
3365
3346
  getSceneMinY() {
3366
3347
  if (!this.meshScene) return 0;
3367
- let e = new Qe().setFromObject(this.meshScene);
3348
+ let e = new nt().setFromObject(this.meshScene);
3368
3349
  return Number.isFinite(e.min.y) ? e.min.y : 0;
3369
3350
  }
3370
3351
  getMaterialProperty(e, t) {
@@ -3374,7 +3355,7 @@ var Zn = class extends L {
3374
3355
  return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
3375
3356
  }
3376
3357
  setMaterialProperty(e, t, n) {
3377
- if (this._sdf?.spilled && a.has(t)) {
3358
+ if (this._sdf?.spilled && ee.has(t)) {
3378
3359
  this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
3379
3360
  return;
3380
3361
  }
@@ -3437,12 +3418,12 @@ var Zn = class extends L {
3437
3418
  data: await this._readTexture(r.texture, t, n),
3438
3419
  source: r.source
3439
3420
  } : {
3440
- data: await o(this.renderer, e, t, n),
3421
+ data: await s(this.renderer, e, t, n),
3441
3422
  source: "accumulation"
3442
3423
  };
3443
3424
  }
3444
3425
  _readbackPass() {
3445
- return this._textureReadback ??= new d(this.renderer);
3426
+ return this._textureReadback ??= new f(this.renderer);
3446
3427
  }
3447
3428
  _readTexture(e, t, n) {
3448
3429
  return this._readbackPass().read(e, t, n);
@@ -3453,10 +3434,10 @@ var Zn = class extends L {
3453
3434
  n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
3454
3435
  let r = n.__rayzeeOriginalColorSpace;
3455
3436
  if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
3456
- else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? Be : Ie, n.__rayzeeColorSpaceChoice = t;
3437
+ else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? We : Be, n.__rayzeeColorSpaceChoice = t;
3457
3438
  else {
3458
3439
  if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
3459
- n.ocioColorSpace = t, e.colorSpace = Be;
3440
+ n.ocioColorSpace = t, e.colorSpace = We;
3460
3441
  }
3461
3442
  e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
3462
3443
  }
@@ -3486,14 +3467,18 @@ var Zn = class extends L {
3486
3467
  async rebuildMaterials(e) {
3487
3468
  await this.ensureSceneResident();
3488
3469
  let t = this.stages.pathTracer;
3489
- await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && ne(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
3470
+ 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();
3490
3471
  }
3491
3472
  async _initRenderer() {
3492
- if (fe((e) => this.dispatchEvent(e)), typeof navigator > "u" || !navigator.gpu) throw Error("WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
3493
- let e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
3494
- if (!e) throw Error("Failed to get WebGPU adapter");
3495
- this.adapterInfo = Xn(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}`));
3496
- let t = e.limits, n = { maxColorAttachmentBytesPerSample: 128 };
3473
+ 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)");
3474
+ let e = null, t;
3475
+ try {
3476
+ e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
3477
+ } catch (e) {
3478
+ t = e;
3479
+ }
3480
+ 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}`));
3481
+ let n = e.limits, r = { maxColorAttachmentBytesPerSample: 128 };
3497
3482
  for (let e of [
3498
3483
  "maxBufferSize",
3499
3484
  "maxStorageBufferBindingSize",
@@ -3507,26 +3492,39 @@ var Zn = class extends L {
3507
3492
  "maxComputeWorkgroupSizeY",
3508
3493
  "maxComputeWorkgroupSizeZ"
3509
3494
  ]) {
3510
- let r = t[e];
3511
- r !== void 0 && (n[e] = r);
3495
+ let t = n[e];
3496
+ t !== void 0 && (r[e] = t);
3512
3497
  }
3513
- if (n.maxStorageBuffersPerShaderStage = Math.min(t.maxStorageBuffersPerShaderStage, 10), this.renderer = new He({
3498
+ r.maxStorageBuffersPerShaderStage = Math.min(n.maxStorageBuffersPerShaderStage, 10);
3499
+ let i;
3500
+ try {
3501
+ i = await e.requestDevice({
3502
+ requiredFeatures: zn.filter((t) => e.features.has(t)),
3503
+ requiredLimits: r
3504
+ });
3505
+ } catch (e) {
3506
+ this._issues.fail(C.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
3507
+ }
3508
+ this.renderer = new Ke({
3514
3509
  canvas: this.canvas,
3515
3510
  alpha: !0,
3516
- powerPreference: "high-performance",
3517
- requiredLimits: n
3518
- }), await Kn(this.renderer, this._headless), !this.renderer.backend?.isWebGPUBackend) throw Error("WebGPU backend unavailable — three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.");
3519
- let r = this.renderer.backend?.device;
3520
- r?.lost && (this._gpuDevice = r, this._deviceLostHolder = { app: this }, Jn(r, this._deviceLostHolder), r.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), ze.setLTC(Tt.init()), this.renderer.outputColorSpace = Be, this.renderer.toneMapping = ke, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
3511
+ device: i
3512
+ });
3513
+ try {
3514
+ await In(this.renderer, this._headless);
3515
+ } catch (e) {
3516
+ throw i.destroy(), e;
3517
+ }
3518
+ 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);
3521
3519
  }
3522
3520
  _initScenes() {
3523
- this.scene = new yt(), this.meshScene = new yt(), this._sceneHelpers = new jt();
3521
+ this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Mt();
3524
3522
  }
3525
3523
  _initAssetPipeline() {
3526
- this._sdf = new i({
3524
+ this._sdf = new u({
3527
3525
  issues: this._issues,
3528
3526
  ...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
3529
- }), this.assetLoader = new Pn(this.meshScene, this.camera, null, {
3527
+ }), this.assetLoader = new Cn(this.meshScene, this.camera, null, {
3530
3528
  issues: this._issues,
3531
3529
  areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
3532
3530
  }), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
@@ -3541,7 +3539,7 @@ var Zn = class extends L {
3541
3539
  this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
3542
3540
  }
3543
3541
  async _initManagers() {
3544
- this.lightManager = new Hn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
3542
+ this.lightManager = new jn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
3545
3543
  onReset: () => this.reset(),
3546
3544
  onLightRemoved: (e) => this._lightRemoved(e)
3547
3545
  }), 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();
@@ -3552,7 +3550,7 @@ var Zn = class extends L {
3552
3550
  if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
3553
3551
  else if (e.texture) {
3554
3552
  let e = this.meshScene.environment;
3555
- e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), le();
3553
+ e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), b();
3556
3554
  }
3557
3555
  this.pauseRendering = !1, this.reset();
3558
3556
  }
@@ -3562,10 +3560,10 @@ var Zn = class extends L {
3562
3560
  }));
3563
3561
  }
3564
3562
  _createStages() {
3565
- this.stages.pathTracer = new u(this.renderer, this.scene, this.camera, {
3563
+ this.stages.pathTracer = new d(this.renderer, this.scene, this.camera, {
3566
3564
  hostMemoryGB: this._hostMemoryGB,
3567
3565
  sortMaterials: this.settings.get("wavefrontSortMaterials")
3568
- }), this._extraStages = this._createExtraStages(), this.stages.compositor = new Mt(this.renderer, {
3566
+ }), this._extraStages = this._createExtraStages(), this.stages.compositor = new Nt(this.renderer, {
3569
3567
  saturation: this.settings.get("saturation") ?? _.saturation,
3570
3568
  pathTracer: this.stages.pathTracer,
3571
3569
  displaySources: this._displaySources()
@@ -3581,7 +3579,7 @@ var Zn = class extends L {
3581
3579
  if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
3582
3580
  }
3583
3581
  _createCamera() {
3584
- let e = new zn(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
3582
+ let e = new On(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
3585
3583
  return e.position.set(0, 0, 5), e;
3586
3584
  }
3587
3585
  _createExtraStages() {
@@ -3651,4 +3649,4 @@ var Zn = class extends L {
3651
3649
  _disposeExtensions() {}
3652
3650
  };
3653
3651
  //#endregion
3654
- export { Nt as _, an as a, q as c, K as d, tn as f, Rt as g, zt as h, zn as i, nn as l, Bt as m, Xn as n, J as o, Gt as p, Hn as r, W as s, Zn as t, en as u };
3652
+ 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 };