rayzee 11.0.0 → 11.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/{ArchiveImporter-BRQvLggb.js → ArchiveImporter-CFcggGqi.js} +1525 -680
  3. package/dist/BidirectionalIntegrator-DIPN8lJW.js +946 -0
  4. package/dist/{NeuralRetouch-BCXylThH.js → NeuralRetouch-Doo3a4vY.js} +1 -1
  5. package/dist/{NeuralSuperRes-sZAeS142.js → NeuralSuperRes-B-rNIU_R.js} +1 -1
  6. package/dist/{PathTracer-CQPW06Mm.js → PathTracer-D_LmDeLh.js} +79 -74
  7. package/dist/{PhysicalSky-BvqCw_dy.js → PhysicalSky-DYffGJ3O.js} +1 -1
  8. package/dist/{RayzeeRenderer-COpwotpU.js → RayzeeRenderer-DWx7D714.js} +3 -3
  9. package/dist/addons/archives.es.js +1 -1
  10. package/dist/addons/bidirectional.es.js +1 -1
  11. package/dist/addons/physical-sky.es.js +1 -1
  12. package/dist/{archiveFormats-BZw7TiDp.js → archiveFormats-tnAoUL1j.js} +28 -9
  13. package/dist/rayzee-core.es.js +4 -4
  14. package/dist/rayzee.es.js +12 -12
  15. package/dist/rayzee.umd.js +43 -43
  16. package/dist/{sceneCachePolicy-BSSsKY98.js → sceneCachePolicy-Bk8sI5PZ.js} +1 -1
  17. package/package.json +1 -1
  18. package/src/PathTracerApp.js +1 -0
  19. package/src/Processor/ArchiveCache.js +19 -6
  20. package/src/Processor/ArchiveImporter.js +9 -3
  21. package/src/Processor/ArchiveReader.js +22 -4
  22. package/src/Processor/PBRT/PBRTMaterials.js +132 -8
  23. package/src/Processor/PBRT/PBRTParser.js +20 -3
  24. package/src/Processor/PBRT/PBRTScattering.js +93 -0
  25. package/src/Processor/PBRT/PBRTSceneBuilder.js +513 -49
  26. package/src/Processor/PBRT/PBRTTextureBake.js +32 -7
  27. package/src/Processor/SceneMetadata.js +30 -5
  28. package/src/RayzeeRenderer.js +3 -2
  29. package/src/Stages/PathTracer.js +3 -5
  30. package/src/TSL/Bidirectional.js +6 -2
  31. package/src/TSL/ConnectKernel.js +31 -11
  32. package/src/TSL/LightSplatKernel.js +22 -7
  33. package/src/TSL/MergeKernel.js +13 -7
  34. package/src/TSL/ShadeKernel.js +51 -30
  35. package/src/integrators/BidirectionalIntegrator.js +6 -1
  36. package/dist/BidirectionalIntegrator-9lZQxFVH.js +0 -934
@@ -1,82 +1,86 @@
1
- import { n as e } from "./BidirectionalIntegrator-9lZQxFVH.js";
2
- import { A as t, g as n, n as r, r as i } from "./sceneCachePolicy-BSSsKY98.js";
1
+ import { n as e } from "./BidirectionalIntegrator-DIPN8lJW.js";
2
+ import { A as t, g as n, n as r, r as i } from "./sceneCachePolicy-Bk8sI5PZ.js";
3
3
  import { n as a, r as o } from "./EngineIssues-CIZnXHsF.js";
4
4
  import { r as s } from "./shared-BGBcSxBQ.js";
5
5
  import { a as c, n as l, r as u } from "./identity-DrQsGT2o.js";
6
- import { n as d, t as f } from "./archiveFormats-BZw7TiDp.js";
6
+ import { n as d, t as f } from "./archiveFormats-tnAoUL1j.js";
7
7
  import { n as p, t as m } from "./ZipReader-gDSWr0I5.js";
8
- import { AnimationClip as h, BooleanKeyframeTrack as g, BufferAttribute as _, BufferGeometry as v, Color as y, DataTexture as b, DirectionalLight as x, DoubleSide as S, EquirectangularReflectionMapping as C, Float32BufferAttribute as w, FloatType as T, FrontSide as E, Group as D, InstancedBufferAttribute as O, InstancedMesh as k, LinearFilter as A, LoadingManager as j, MaterialLoader as M, Matrix4 as N, Mesh as ee, MeshPhysicalMaterial as te, NoColorSpace as ne, NumberKeyframeTrack as re, Object3D as ie, OrthographicCamera as ae, PerspectiveCamera as oe, PointLight as se, Quaternion as ce, QuaternionKeyframeTrack as le, RGBAFormat as P, RepeatWrapping as ue, SRGBColorSpace as F, SphereGeometry as de, SpotLight as fe, Texture as pe, Uint32BufferAttribute as I, Vector3 as L, VectorKeyframeTrack as me } from "three";
8
+ import { AnimationClip as h, BooleanKeyframeTrack as g, BufferAttribute as _, BufferGeometry as v, Color as y, DataTexture as b, DirectionalLight as x, DoubleSide as S, EquirectangularReflectionMapping as C, Float32BufferAttribute as w, FloatType as T, FrontSide as E, Group as D, InstancedBufferAttribute as O, InstancedMesh as k, LinearFilter as A, LoadingManager as j, MaterialLoader as M, Matrix4 as N, Mesh as ee, MeshPhysicalMaterial as te, NoColorSpace as ne, NumberKeyframeTrack as re, Object3D as ie, OrthographicCamera as ae, PerspectiveCamera as oe, PointLight as se, Quaternion as ce, QuaternionKeyframeTrack as le, RGBAFormat as ue, RepeatWrapping as de, SRGBColorSpace as P, SpotLight as fe, Texture as pe, Uint32BufferAttribute as F, Vector3 as I, VectorKeyframeTrack as me } from "three";
9
9
  import { HDRLoader as he } from "three/addons/loaders/HDRLoader.js";
10
- import { Gunzip as ge, strFromU8 as R, zipSync as _e } from "three/addons/libs/fflate.module.js";
11
- import { EXRLoader as ve } from "three/addons/loaders/EXRLoader.js";
10
+ import { Gunzip as ge, strFromU8 as _e, zipSync as ve } from "three/addons/libs/fflate.module.js";
11
+ import { EXRLoader as ye } from "three/addons/loaders/EXRLoader.js";
12
12
  //#region src/Processor/ArchiveReader.js
13
- var z = 512, ye = 4 << 20, be = 15e8, xe = new TextDecoder();
14
- function Se(e) {
13
+ var L = 512, be = 4 << 20, xe = 15e8, Se = new TextDecoder();
14
+ function Ce(e) {
15
15
  return e.length >= 2 && e[0] === 31 && e[1] === 139;
16
16
  }
17
- function Ce(e) {
17
+ function we(e) {
18
18
  return e.length >= 4 && e[0] === 80 && e[1] === 75 && (e[2] === 3 || e[2] === 5 || e[2] === 7);
19
19
  }
20
- function we(e) {
20
+ function Te(e) {
21
21
  return e.length >= 263 && String.fromCharCode(...e.subarray(257, 262)) === "ustar";
22
22
  }
23
- function Te(e) {
24
- return Se(e) ? "gzip" : Ce(e) ? "zip" : we(e) ? "tar" : null;
23
+ function Ee(e) {
24
+ return Ce(e) ? "gzip" : we(e) ? "zip" : Te(e) ? "tar" : null;
25
25
  }
26
- function B(e, t, n) {
26
+ function De(e, t, n) {
27
27
  let r = t, i = t + n;
28
28
  for (; r < i && e[r] !== 0;) r++;
29
- return xe.decode(e.subarray(t, r));
29
+ return Se.decode(e.subarray(t, r));
30
30
  }
31
- function Ee(e, t, n) {
31
+ function Oe(e, t, n) {
32
32
  if (e[t] & 128) {
33
33
  let r = e[t] & 127;
34
34
  for (let i = t + 1; i < t + n; i++) r = r * 256 + e[i];
35
35
  return r;
36
36
  }
37
- let r = B(e, t, n).trim();
37
+ let r = De(e, t, n).trim();
38
38
  if (!r) return 0;
39
39
  let i = parseInt(r, 8);
40
40
  return Number.isFinite(i) ? i : 0;
41
41
  }
42
- function De(e) {
42
+ function ke(e) {
43
43
  let t = [];
44
44
  for (let n of e.replace(/\\/g, "/").split("/")) n === "" || n === "." || (n === ".." ? t.pop() : t.push(n));
45
45
  return t.join("/");
46
46
  }
47
- function Oe(e) {
48
- let t = xe.decode(e).match(/^\d+ path=(.*)$/m);
47
+ function Ae(e) {
48
+ let t = Se.decode(e).match(/^\d+ path=(.*)$/m);
49
49
  return t ? t[1] : null;
50
50
  }
51
- var ke = (e) => e + (z - e % z) % z, Ae = (e) => e === "L" || e === "x" || e === "X";
52
- function je(e) {
53
- let t = B(e, 345, 155), n = B(e, 0, 100);
51
+ var je = (e) => e + (L - e % L) % L, Me = (e) => e === "L" || e === "x" || e === "X";
52
+ function Ne(e) {
53
+ let t = De(e, 345, 155), n = De(e, 0, 100);
54
54
  return {
55
55
  type: String.fromCharCode(e[156] || 48),
56
- size: Ee(e, 124, 12),
56
+ size: Oe(e, 124, 12),
57
57
  name: t ? `${t}/${n}` : n
58
58
  };
59
59
  }
60
- function Me(e, t) {
61
- return e === "5" || e === "g" || e === "K" || t.endsWith("/") || e !== "0" && e !== " " ? null : De(t) || null;
60
+ function Pe(e, t) {
61
+ return e === "5" || e === "g" || e === "K" || t.endsWith("/") || e !== "0" && e !== " " ? null : ke(t) || null;
62
62
  }
63
- function Ne(e) {
64
- for (let t = 0; t < z; t++) if (e[t] !== 0) return !1;
63
+ function Fe(e) {
64
+ for (let t = 0; t < L; t++) if (e[t] !== 0) return !1;
65
65
  return !0;
66
66
  }
67
- var Pe = class {
68
- constructor({ filter: e = null, retain: t = null, byteBudget: n = be, onEntry: r = null } = {}) {
69
- this.filter = e, this.retain = t, this.byteBudget = n, this.onEntry = r, this.entries = Object.create(null), this.listing = [], this.retainedBytes = 0, this.truncated = !1, this.finished = !1, this._header = new Uint8Array(z), this._headerLen = 0, this._state = "header", this._remaining = 0, this._size = 0, this._copied = 0, this._dst = null, this._special = null, this._pendingName = null, this._abs = 0;
67
+ var Ie = class {
68
+ constructor({ filter: e = null, retain: t = null, byteBudget: n = xe, onEntry: r = null, sink: i = null } = {}) {
69
+ this.filter = e, this.sink = i, this._sunk = 0, this.retain = t, this.byteBudget = n, this.onEntry = r, this.entries = Object.create(null), this.listing = [], this.retainedBytes = 0, this.truncated = !1, this.finished = !1, this._header = new Uint8Array(L), this._headerLen = 0, this._state = "header", this._remaining = 0, this._size = 0, this._copied = 0, this._dst = null, this._special = null, this._pendingName = null, this._abs = 0;
70
70
  }
71
71
  push(e) {
72
72
  let t = this._abs;
73
73
  this._abs += e.length;
74
74
  let n = 0;
75
75
  for (; n < e.length && !this.finished;) if (this._state === "header") {
76
- let r = Math.min(z - this._headerLen, e.length - n);
77
- this._header.set(e.subarray(n, n + r), this._headerLen), this._headerLen += r, n += r, this._headerLen === z && (this._headerLen = 0, this._bodyStart = t + n, this._readHeader());
76
+ let r = Math.min(L - this._headerLen, e.length - n);
77
+ this._header.set(e.subarray(n, n + r), this._headerLen), this._headerLen += r, n += r, this._headerLen === L && (this._headerLen = 0, this._bodyStart = t + n, this._readHeader());
78
78
  } else {
79
79
  let t = Math.min(this._remaining, e.length - n);
80
+ if (this.sink && this._indexed && this._sinkLeft > 0) {
81
+ let r = Math.min(t, this._sinkLeft);
82
+ this.sink(e.subarray(n, n + r)), this._sinkLeft -= r;
83
+ }
80
84
  if (this._dst && this._copied < this._size) {
81
85
  let r = Math.min(t, this._size - this._copied);
82
86
  this._dst.set(e.subarray(n, n + r), this._copied), this._copied += r;
@@ -97,7 +101,7 @@ var Pe = class {
97
101
  }
98
102
  _readHeader() {
99
103
  let e = this._header, t = !0;
100
- for (let n = 0; n < z; n++) if (e[n] !== 0) {
104
+ for (let n = 0; n < L; n++) if (e[n] !== 0) {
101
105
  t = !1;
102
106
  break;
103
107
  }
@@ -105,32 +109,32 @@ var Pe = class {
105
109
  this.finished = !0;
106
110
  return;
107
111
  }
108
- let { type: n, size: r, name: i } = je(e), a = this._pendingName ?? i;
109
- if (this._pendingName = null, this._size = r, this._copied = 0, this._remaining = ke(r), this._dst = null, this._special = null, this._indexed = !1, this._state = this._remaining > 0 ? "body" : "header", Ae(n)) {
112
+ let { type: n, size: r, name: i } = Ne(e), a = this._pendingName ?? i;
113
+ if (this._pendingName = null, this._size = r, this._copied = 0, this._remaining = je(r), this._dst = null, this._special = null, this._indexed = !1, this._state = this._remaining > 0 ? "body" : "header", Me(n)) {
110
114
  this._special = n === "L" ? "longname" : "pax", this._dst = new Uint8Array(r);
111
115
  return;
112
116
  }
113
- let o = Me(n, a);
117
+ let o = Pe(n, a);
114
118
  o && (this.listing.push({
115
119
  path: o,
116
120
  size: r
117
- }), this._indexed = this.filter ? this.filter(o, r) : !0, this._indexed && !(this.retain && !this.retain(o, r)) && (this.retainedBytes + r > this.byteBudget ? this.truncated = !0 : (this._dst = new Uint8Array(r), this.retainedBytes += r)), this._remaining === 0 && this._endBody());
121
+ }), this._indexed = this.filter ? this.filter(o, r) : !0, this.sink && this._indexed && (this._sinkStart = this._sunk, this._sinkLeft = r, this._sunk += r), this._indexed && !(this.retain && !this.retain(o, r)) && (this.retainedBytes + r > this.byteBudget ? this.truncated = !0 : (this._dst = new Uint8Array(r), this.retainedBytes += r)), this._remaining === 0 && this._endBody());
118
122
  }
119
123
  _endBody() {
120
124
  if (this._state = "header", this._special === "longname") {
121
- this._pendingName = B(this._dst, 0, this._dst.length), this._dst = null;
125
+ this._pendingName = De(this._dst, 0, this._dst.length), this._dst = null;
122
126
  return;
123
127
  }
124
128
  if (this._special === "pax") {
125
- let e = Oe(this._dst);
129
+ let e = Ae(this._dst);
126
130
  e && (this._pendingName = e), this._dst = null;
127
131
  return;
128
132
  }
129
133
  let e = this.listing[this.listing.length - 1];
130
- this._indexed && e && (e.offset = this._bodyStart, this._indexed = !1), this._dst &&= (this.entries[e.path] = this._dst, this.onEntry?.(e.path, this._dst), null);
134
+ this._indexed && e && (e.offset = this.sink ? this._sinkStart : this._bodyStart, this._indexed = !1), this._dst &&= (this.entries[e.path] = this._dst, this.onEntry?.(e.path, this._dst), null);
131
135
  }
132
136
  };
133
- async function Fe(e, t) {
137
+ async function Le(e, t) {
134
138
  if (typeof DecompressionStream < "u" && typeof e?.stream == "function") {
135
139
  let n = e.stream().pipeThrough(new DecompressionStream("gzip")).getReader();
136
140
  for (;;) {
@@ -143,85 +147,89 @@ async function Fe(e, t) {
143
147
  let n = null, r = new ge((e, r) => {
144
148
  e instanceof Error ? n = e : e && e.length && t(e);
145
149
  });
146
- await Ie(e, (e, t) => {
150
+ await Re(e, (e, t) => {
147
151
  if (r.push(e, t), n) throw n;
148
152
  });
149
153
  }
150
- async function Ie(e, t) {
154
+ async function Re(e, t) {
151
155
  if (e instanceof Uint8Array) {
152
- for (let n = 0; n < e.length; n += ye) {
153
- let r = Math.min(n + ye, e.length);
156
+ for (let n = 0; n < e.length; n += be) {
157
+ let r = Math.min(n + be, e.length);
154
158
  t(e.subarray(n, r), r === e.length);
155
159
  }
156
160
  e.length === 0 && t(e, !0);
157
161
  return;
158
162
  }
159
163
  let n = e.size;
160
- for (let r = 0; r < n; r += ye) {
161
- let i = Math.min(r + ye, n);
164
+ for (let r = 0; r < n; r += be) {
165
+ let i = Math.min(r + be, n);
162
166
  t(new Uint8Array(await e.slice(r, i).arrayBuffer()), i === n);
163
167
  }
164
168
  n === 0 && t(new Uint8Array(), !0);
165
169
  }
166
- async function Le(e, t = {}) {
167
- let { onProgress: n, ...r } = t, i = new Pe(r), a = 0, o = 0;
168
- return await Fe(e, (e) => {
170
+ async function ze(e, t = {}) {
171
+ let { onProgress: n, ...r } = t, i = new Ie(r), a = 0, o = 0;
172
+ return await Le(e, (e) => {
169
173
  i.push(e), a += e.length, n && a >= o && (o = a + (64 << 20), n({
170
174
  entries: i.listing.length,
171
175
  bytes: a
172
176
  }));
173
177
  }), i.end(), i.result();
174
178
  }
175
- var Re = 1 << 20;
176
- async function ze(e, { onProgress: t = null } = {}) {
179
+ var Be = 1 << 20;
180
+ async function Ve(e, { onProgress: t = null } = {}) {
177
181
  let n = e.size, r = [], i = null, a = 0, o = null, s = 0, c = 0, l = async (t, r) => {
178
182
  if (i && t >= a && t + r <= a + i.length) return i.subarray(t - a, t - a + r);
179
- let o = Math.min(n, t + Math.max(r, Re));
183
+ let o = Math.min(n, t + Math.max(r, Be));
180
184
  return i = new Uint8Array(await e.slice(t, o).arrayBuffer()), a = t, i.subarray(0, r);
181
185
  };
182
- for (; s + z <= n;) {
183
- let e = await l(s, z);
184
- if (Ne(e)) break;
185
- let { type: n, size: i, name: a } = je(e), u = o ?? a;
186
+ for (; s + L <= n;) {
187
+ let e = await l(s, L);
188
+ if (Fe(e)) break;
189
+ let { type: n, size: i, name: a } = Ne(e), u = o ?? a;
186
190
  o = null;
187
- let d = s + z;
188
- if (Ae(n)) {
191
+ let d = s + L;
192
+ if (Me(n)) {
189
193
  let e = await l(d, i);
190
- o = n === "L" ? B(e, 0, e.length) : Oe(e);
194
+ o = n === "L" ? De(e, 0, e.length) : Ae(e);
191
195
  } else {
192
- let e = Me(n, u);
196
+ let e = Pe(n, u);
193
197
  e && r.push({
194
198
  path: e,
195
199
  size: i,
196
200
  offset: d
197
201
  });
198
202
  }
199
- s = d + ke(i), t && s >= c && (c = s + (256 << 20), t({
203
+ s = d + je(i), t && s >= c && (c = s + (256 << 20), t({
200
204
  entries: r.length,
201
205
  bytes: s
202
206
  }));
203
207
  }
204
208
  return r;
205
209
  }
206
- function Be() {
207
- let e = new Pe({ retain: () => !1 });
210
+ function He({ filter: e = null, sink: t = null } = {}) {
211
+ let n = new Ie({
212
+ retain: () => !1,
213
+ filter: e,
214
+ sink: t
215
+ });
208
216
  return {
209
- push: (t) => e.push(t),
210
- finish: () => (e.end(), e.listing.filter((e) => e.offset !== void 0))
217
+ push: (e) => n.push(e),
218
+ finish: () => (n.end(), n.listing.filter((e) => e.offset !== void 0))
211
219
  };
212
220
  }
213
- async function Ve(e, t = {}) {
221
+ async function Ue(e, t = {}) {
214
222
  let { index: n = null, headersOnly: r = !1, onProgress: i = null, ...a } = t, o, s, c, l, u = null;
215
223
  if (n || r) {
216
- u = n?.listing ?? await ze(e, { onProgress: i });
224
+ u = n?.listing ?? await Ve(e, { onProgress: i });
217
225
  let { filter: t } = a;
218
226
  s = u.map((e) => !t || t(e.path, e.size) ? { ...e } : {
219
227
  path: e.path,
220
228
  size: e.size
221
229
  }), o = Object.create(null), c = 0, l = !1;
222
230
  } else {
223
- let t = new Pe({ ...a });
224
- await Ie(e, (e) => t.push(e)), t.end(), {entries: o, listing: s, retainedBytes: c, truncated: l} = t.result();
231
+ let t = new Ie({ ...a });
232
+ await Re(e, (e) => t.push(e)), t.end(), {entries: o, listing: s, retainedBytes: c, truncated: l} = t.result();
225
233
  }
226
234
  let d = /* @__PURE__ */ new Map();
227
235
  for (let e of s) e.offset !== void 0 && d.set(e.path, e);
@@ -247,9 +255,9 @@ async function Ve(e, t = {}) {
247
255
  } : null
248
256
  };
249
257
  }
250
- function He(e) {
258
+ function We(e) {
251
259
  let t = (Array.isArray(e) ? e : [e]).filter(Boolean).map((e) => {
252
- let t = De(e);
260
+ let t = ke(e);
253
261
  return {
254
262
  p: t,
255
263
  inside: t + "/"
@@ -263,7 +271,7 @@ function He(e) {
263
271
  return !1;
264
272
  };
265
273
  }
266
- function Ue(e) {
274
+ function Ge(e) {
267
275
  let t = e.filter((e) => e.path.toLowerCase().endsWith(".pbrt")).sort((e, t) => e.path.split("/").length - t.path.split("/").length || e.path.length - t.path.length || (e.path < t.path ? -1 : 1));
268
276
  if (!t.length) return {
269
277
  root: null,
@@ -290,27 +298,37 @@ function Ue(e) {
290
298
  }
291
299
  //#endregion
292
300
  //#region src/Processor/ArchiveCache.js
293
- var We = 1, Ge = 3;
294
- async function Ke(e, t) {
301
+ var Ke = 1, qe = 3;
302
+ async function Je(e, t) {
295
303
  return `${e}:${u(await l(t))}`;
296
304
  }
297
- async function qe(e, { storage: t, label: n = e.name, onProgress: r = null }) {
305
+ async function Ye(e, { storage: t, label: n = e.name, onProgress: r = null, filter: i = null, part: o = null }) {
298
306
  if (!t || typeof DecompressionStream > "u") return null;
299
- let i = t.area(s.ARCHIVES), o = await Ke("gunzip", e), c = await i.open(o), l = !!c;
300
- if (!c) {
301
- let l = await i.create(o, {
307
+ let c = t.area(s.ARCHIVES), l = await Je("gunzip", e), u = l, d = await c.open(l);
308
+ !d && i && (d = await c.open(u = `${l}|${o}`));
309
+ let f = !!d;
310
+ if (!d) {
311
+ let l = await c.create(u, i ? { label: `${n} (${o})` } : {
302
312
  label: n,
303
- expectedBytes: e.size * Ge
313
+ expectedBytes: e.size * qe
304
314
  });
305
315
  if (!l) return null;
306
- let u = Be(), d = new TransformStream({ transform(e, t) {
307
- u.push(e), t.enqueue(e);
308
- } });
316
+ let f = null, p = He(i ? {
317
+ filter: i,
318
+ sink: (e) => f.enqueue(e)
319
+ } : {}), m = new TransformStream({
320
+ start(e) {
321
+ f = e;
322
+ },
323
+ transform(e, t) {
324
+ p.push(e), i || t.enqueue(e);
325
+ }
326
+ });
309
327
  try {
310
- let t = e.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(d), n = await l.writeStream("data.tar", t, { onProgress: r });
328
+ let t = e.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(m), n = await l.writeStream("data.tar", t, { onProgress: r });
311
329
  await l.writeJSON("index.json", {
312
- v: We,
313
- listing: u.finish()
330
+ v: Ke,
331
+ listing: p.finish()
314
332
  }), await l.commit({
315
333
  compressedBytes: e.size,
316
334
  tarBytes: n
@@ -319,30 +337,30 @@ async function qe(e, { storage: t, label: n = e.name, onProgress: r = null }) {
319
337
  if (await l.abort(), e?.name !== "QuotaExceededError") throw e;
320
338
  return t._issue(a.STORAGE_QUOTA_EXCEEDED, `ran out of room unpacking ${n}; reading it in memory instead`, { area: s.ARCHIVES }), null;
321
339
  }
322
- if (c = await i.open(o, { wait: !0 }), !c) return null;
323
- }
324
- let u = await c.file("data.tar"), d = await c.json("index.json");
325
- return !u || d?.v !== We ? (c.release(), null) : {
326
- file: u,
327
- index: d,
328
- release: () => c.release(),
329
- cached: l
340
+ if (d = await c.open(u, { wait: !0 }), !d) return null;
341
+ }
342
+ let p = await d.file("data.tar"), m = await d.json("index.json");
343
+ return !p || m?.v !== Ke ? (d.release(), null) : {
344
+ file: p,
345
+ index: m,
346
+ release: () => d.release(),
347
+ cached: f
330
348
  };
331
349
  }
332
- async function Je(e, t) {
350
+ async function Xe(e, t) {
333
351
  if (!t) return null;
334
- let n = await t.area(s.ARCHIVES).open(await Ke("tarindex", e));
352
+ let n = await t.area(s.ARCHIVES).open(await Je("tarindex", e));
335
353
  if (!n) return null;
336
354
  try {
337
355
  let e = await n.json("index.json");
338
- return e?.v === We ? e : null;
356
+ return e?.v === Ke ? e : null;
339
357
  } finally {
340
358
  n.release();
341
359
  }
342
360
  }
343
- async function Ye(e, t, n) {
361
+ async function Ze(e, t, n) {
344
362
  if (!t || !n) return !1;
345
- let r = await t.area(s.ARCHIVES).create(await Ke("tarindex", e), { label: `${e.name} (index)` });
363
+ let r = await t.area(s.ARCHIVES).create(await Je("tarindex", e), { label: `${e.name} (index)` });
346
364
  if (!r) return !1;
347
365
  try {
348
366
  return await r.writeJSON("index.json", n), await r.commit(), !0;
@@ -350,7 +368,7 @@ async function Ye(e, t, n) {
350
368
  return await r.abort(), !1;
351
369
  }
352
370
  }
353
- var Xe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], Ze = "__rayzeeArchivePath", Qe = "__rayzeeArchiveLoader", $e = 64, et = 32 << 20, tt = 64 << 20, nt = {
371
+ var Qe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], $e = "__rayzeeArchivePath", et = "__rayzeeArchiveLoader", tt = 64, nt = 32 << 20, rt = 64 << 20, it = {
354
372
  Float32Array,
355
373
  Float64Array,
356
374
  Int8Array,
@@ -360,7 +378,7 @@ var Xe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], Ze = "__rayz
360
378
  Uint16Array,
361
379
  Uint32Array,
362
380
  Uint8ClampedArray
363
- }, rt = [
381
+ }, at = [
364
382
  "name",
365
383
  "mapping",
366
384
  "channel",
@@ -376,13 +394,13 @@ var Xe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], Ze = "__rayz
376
394
  "premultiplyAlpha",
377
395
  "unpackAlignment",
378
396
  "colorSpace"
379
- ], it = [
397
+ ], ot = [
380
398
  "intensity",
381
399
  "distance",
382
400
  "decay",
383
401
  "angle",
384
402
  "penumbra"
385
- ], at = [
403
+ ], st = [
386
404
  "name",
387
405
  "visible",
388
406
  "castShadow",
@@ -390,28 +408,28 @@ var Xe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], Ze = "__rayz
390
408
  "frustumCulled",
391
409
  "renderOrder",
392
410
  "matrixAutoUpdate"
393
- ], V = class extends Error {
411
+ ], R = class extends Error {
394
412
  constructor(e) {
395
413
  super(e), this.name = "SceneGraphUnsupported";
396
414
  }
397
415
  };
398
- function ot(e) {
416
+ function ct(e) {
399
417
  return e.isInstancedMesh ? "InstancedMesh" : e.isSkinnedMesh || e.isBatchedMesh ? null : e.isMesh ? "Mesh" : e.isPerspectiveCamera ? "PerspectiveCamera" : e.isOrthographicCamera ? "OrthographicCamera" : e.isDirectionalLight ? "DirectionalLight" : e.isPointLight ? "PointLight" : e.isSpotLight ? "SpotLight" : e.isLight || e.isPoints || e.isLine || e.isSprite || e.isLOD ? null : e.isGroup ? "Group" : e.constructor === ie ? "Object3D" : null;
400
418
  }
401
- function st(e, t) {
419
+ function lt(e, t) {
402
420
  try {
403
421
  let t = JSON.parse(JSON.stringify(e ?? {}));
404
- return delete t[Ze], delete t[Qe], t;
422
+ return delete t[$e], delete t[et], t;
405
423
  } catch {
406
- throw new V(`${t}: userData is not plain JSON`);
424
+ throw new R(`${t}: userData is not plain JSON`);
407
425
  }
408
426
  }
409
- var ct = class {
427
+ var ut = class {
410
428
  constructor() {
411
429
  this.sections = [], this.length = 0;
412
430
  }
413
431
  add(e) {
414
- let t = Math.ceil(this.length / $e) * $e;
432
+ let t = Math.ceil(this.length / tt) * tt;
415
433
  return this.sections.push({
416
434
  offset: t,
417
435
  array: e
@@ -423,8 +441,8 @@ var ct = class {
423
441
  };
424
442
  }
425
443
  };
426
- function lt(e, t, n) {
427
- if (e.isInterleavedBufferAttribute || !ArrayBuffer.isView(e.array)) throw new V(`${n}: interleaved or non-typed attribute`);
444
+ function dt(e, t, n) {
445
+ if (e.isInterleavedBufferAttribute || !ArrayBuffer.isView(e.array)) throw new R(`${n}: interleaved or non-typed attribute`);
428
446
  return {
429
447
  section: t.add(e.array),
430
448
  itemSize: e.itemSize,
@@ -432,44 +450,44 @@ function lt(e, t, n) {
432
450
  name: e.name ?? ""
433
451
  };
434
452
  }
435
- function ut(e, t) {
453
+ function ft(e, t) {
436
454
  let n = `geometry ${e.name || e.uuid}`;
437
- if (Object.keys(e.morphAttributes ?? {}).length) throw new V(`${n}: morph targets`);
455
+ if (Object.keys(e.morphAttributes ?? {}).length) throw new R(`${n}: morph targets`);
438
456
  let r = {};
439
- for (let [i, a] of Object.entries(e.attributes)) r[i] = lt(a, t, n);
457
+ for (let [i, a] of Object.entries(e.attributes)) r[i] = dt(a, t, n);
440
458
  return {
441
459
  uuid: e.uuid,
442
460
  name: e.name,
443
461
  attributes: r,
444
- index: e.index ? lt(e.index, t, n) : null,
462
+ index: e.index ? dt(e.index, t, n) : null,
445
463
  groups: e.groups.map((e) => ({ ...e })),
446
464
  drawRange: { ...e.drawRange },
447
- userData: st(e.userData, n)
465
+ userData: lt(e.userData, n)
448
466
  };
449
467
  }
450
- function dt(e, t) {
468
+ function pt(e, t) {
451
469
  let n = {
452
470
  uuid: e.uuid,
453
- userData: st(e.userData, `texture ${e.uuid}`)
471
+ userData: lt(e.userData, `texture ${e.uuid}`)
454
472
  };
455
- for (let t of rt) n[t] = e[t];
473
+ for (let t of at) n[t] = e[t];
456
474
  for (let t of [
457
475
  "repeat",
458
476
  "offset",
459
477
  "center"
460
478
  ]) n[t] = e[t].toArray();
461
479
  n.rotation = e.rotation;
462
- let r = e.userData?.[Ze];
480
+ let r = e.userData?.[$e];
463
481
  if (r) n.path = r, n.loader = e.userData.__rayzeeArchiveLoader ?? "image";
464
482
  else if (e.isDataTexture && ArrayBuffer.isView(e.image?.data)) n.data = {
465
483
  section: t.add(e.image.data),
466
484
  width: e.image.width,
467
485
  height: e.image.height
468
486
  };
469
- else throw new V(`texture ${e.name || e.uuid}: no archive path and no pixel data to keep`);
487
+ else throw new R(`texture ${e.name || e.uuid}: no archive path and no pixel data to keep`);
470
488
  return n;
471
489
  }
472
- function ft(e, t) {
490
+ function mt(e, t) {
473
491
  let n = e.toJSON(t);
474
492
  n.exactColors = {};
475
493
  for (let [t, r] of Object.entries(e)) r?.isColor && (n.exactColors[t] = [
@@ -478,27 +496,27 @@ function ft(e, t) {
478
496
  r.b
479
497
  ]);
480
498
  e.ior !== void 0 && (n.exactIor = e.ior), e.diffuseTransmission !== void 0 && (n.diffuseTransmission = e.diffuseTransmission);
481
- for (let t of Xe) e[t]?.isTexture && ((n.engineTextures ??= {})[t] = e[t].uuid);
499
+ for (let t of Qe) e[t]?.isTexture && ((n.engineTextures ??= {})[t] = e[t].uuid);
482
500
  return n;
483
501
  }
484
- function pt(e, t) {
502
+ function ht(e, t) {
485
503
  for (let n of Object.values(e)) n?.isTexture && t.set(n.uuid, n);
486
504
  }
487
- function mt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}) {
488
- let i = new ct(), a = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t) => {
489
- let n = ot(e);
490
- if (!n) throw new V(`${e.type} "${e.name}" cannot be cached`);
505
+ function gt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}) {
506
+ let i = new ut(), a = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t) => {
507
+ let n = ct(e);
508
+ if (!n) throw new R(`${e.type} "${e.name}" cannot be cached`);
491
509
  let r = {
492
510
  type: n,
493
511
  uuid: e.uuid,
494
512
  parent: t,
495
- userData: st(e.userData, `${n} "${e.name}"`)
513
+ userData: lt(e.userData, `${n} "${e.name}"`)
496
514
  };
497
- for (let t of at) r[t] = e[t];
515
+ for (let t of st) r[t] = e[t];
498
516
  if (r.position = e.position.toArray(), r.quaternion = e.quaternion.toArray(), r.scale = e.scale.toArray(), r.layers = e.layers.mask, e.matrixAutoUpdate || (r.matrix = e.matrix.toArray()), e.isMesh) {
499
517
  o.set(e.geometry.uuid, e.geometry);
500
518
  let t = Array.isArray(e.material) ? e.material : [e.material];
501
- for (let e of t) s.set(e.uuid, e), pt(e, c);
519
+ for (let e of t) s.set(e.uuid, e), ht(e, c);
502
520
  r.geometry = e.geometry.uuid, r.material = Array.isArray(e.material) ? t.map((e) => e.uuid) : e.material.uuid;
503
521
  }
504
522
  if (e.isInstancedMesh && (r.count = e.count, r.instanceMatrix = i.add(e.instanceMatrix.array), r.instanceColor = e.instanceColor ? i.add(e.instanceColor.array) : null), e.isCamera) for (let t of [
@@ -517,7 +535,7 @@ function mt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
517
535
  ]) e[t] !== void 0 && (r[t] = e[t]);
518
536
  if (e.isLight) {
519
537
  r.color = e.color.toArray();
520
- for (let t of it) e[t] !== void 0 && (r[t] = e[t]);
538
+ for (let t of ot) e[t] !== void 0 && (r[t] = e[t]);
521
539
  e.target && (r.target = e.target.uuid);
522
540
  }
523
541
  let u = a.push(r) - 1;
@@ -533,9 +551,9 @@ function mt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
533
551
  manifest: {
534
552
  v: 2,
535
553
  nodes: a,
536
- geometries: [...o.values()].map((e) => ut(e, i)),
537
- textures: [...c.values()].map((e) => dt(e, i)),
538
- materials: [...s.values()].map((e) => ft(e, u)),
554
+ geometries: [...o.values()].map((e) => ft(e, i)),
555
+ textures: [...c.values()].map((e) => pt(e, i)),
556
+ materials: [...s.values()].map((e) => mt(e, u)),
539
557
  animations: n.map((e) => h.toJSON(e)),
540
558
  environment: t ? t.uuid : null,
541
559
  stats: r
@@ -544,32 +562,32 @@ function mt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
544
562
  byteLength: i.length
545
563
  };
546
564
  }
547
- async function ht(e, { manifest: t, sections: n }, { release: r = !1 } = {}) {
565
+ async function _t(e, { manifest: t, sections: n }, { release: r = !1 } = {}) {
548
566
  for (let t of n) {
549
567
  let { offset: n, array: i } = t, a = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
550
- for (let t = 0; t < a.length; t += et) await e.write("data.bin", a.subarray(t, Math.min(a.length, t + et)), { at: n + t });
568
+ for (let t = 0; t < a.length; t += nt) await e.write("data.bin", a.subarray(t, Math.min(a.length, t + nt)), { at: n + t });
551
569
  r && (t.array = null);
552
570
  }
553
571
  n.length === 0 && await e.write("data.bin", new Uint8Array()), await e.writeJSON("graph.json", t);
554
572
  }
555
- function gt(e) {
556
- let t = nt[e];
573
+ function vt(e) {
574
+ let t = it[e];
557
575
  if (!t) throw Error(`scene graph: unknown array type ${e}`);
558
576
  return t;
559
577
  }
560
- async function _t(e, t) {
578
+ async function yt(e, t) {
561
579
  let n = /* @__PURE__ */ new Map(), r = [...t].sort((e, t) => e.offset - t.offset), i = null, a = 0;
562
580
  for (let t of r) {
563
- let { offset: r, byteLength: o, type: s } = t, c = gt(s), l = r + o;
564
- if (o > tt) {
581
+ let { offset: r, byteLength: o, type: s } = t, c = vt(s), l = r + o;
582
+ if (o > rt) {
565
583
  n.set(r, new c(await e.slice(r, l).arrayBuffer()));
566
584
  continue;
567
585
  }
568
- (!i || r < a || l > a + i.byteLength) && (a = r, i = await e.slice(r, Math.min(e.size, r + tt)).arrayBuffer()), n.set(r, new c(i.slice(r - a, l - a)));
586
+ (!i || r < a || l > a + i.byteLength) && (a = r, i = await e.slice(r, Math.min(e.size, r + rt)).arrayBuffer()), n.set(r, new c(i.slice(r - a, l - a)));
569
587
  }
570
588
  return n;
571
589
  }
572
- function vt(e) {
590
+ function bt(e) {
573
591
  let t = [];
574
592
  for (let n of e.nodes) n.instanceMatrix && t.push(n.instanceMatrix), n.instanceColor && t.push(n.instanceColor);
575
593
  for (let n of e.geometries) {
@@ -579,24 +597,24 @@ function vt(e) {
579
597
  for (let n of e.textures) n.data && t.push(n.data.section);
580
598
  return t;
581
599
  }
582
- function yt(e, t) {
600
+ function xt(e, t) {
583
601
  let n = new _(e.get(t.section.offset), t.itemSize, t.normalized);
584
602
  return n.name = t.name, n;
585
603
  }
586
- function bt(e, t) {
587
- for (let n of rt) t[n] !== void 0 && (e[n] = t[n]);
604
+ function St(e, t) {
605
+ for (let n of at) t[n] !== void 0 && (e[n] = t[n]);
588
606
  e.repeat.fromArray(t.repeat), e.offset.fromArray(t.offset), e.center.fromArray(t.center), e.rotation = t.rotation, e.uuid = t.uuid, Object.assign(e.userData, t.userData), e.needsUpdate = !0;
589
607
  }
590
- async function xt(e, t, { loadTexture: n }) {
608
+ async function Ct(e, t, { loadTexture: n }) {
591
609
  if (e?.v !== 2) throw Error("scene graph: unknown format");
592
- let r = await _t(t, vt(e)), i = (e) => r.get(e.offset), a = {};
610
+ let r = await yt(t, bt(e)), i = (e) => r.get(e.offset), a = {};
593
611
  for (let t of e.textures) {
594
612
  let e;
595
613
  if (t.path) {
596
614
  if (e = await n(t.path, t.loader), !e) throw Error(`scene graph: "${t.path}" is missing from the archive`);
597
- e.userData[Ze] = t.path, e.userData[Qe] = t.loader;
615
+ e.userData[$e] = t.path, e.userData[et] = t.loader;
598
616
  } else e = new b(i(t.data.section), t.data.width, t.data.height);
599
- bt(e, t), a[t.uuid] = e;
617
+ St(e, t), a[t.uuid] = e;
600
618
  }
601
619
  let o = new M().setTextures(a), s = {};
602
620
  for (let t of e.materials) {
@@ -610,8 +628,8 @@ async function xt(e, t, { loadTexture: n }) {
610
628
  for (let t of e.geometries) {
611
629
  let e = new v();
612
630
  e.uuid = t.uuid, e.name = t.name;
613
- for (let [n, i] of Object.entries(t.attributes)) e.setAttribute(n, yt(r, i));
614
- t.index && e.setIndex(yt(r, t.index));
631
+ for (let [n, i] of Object.entries(t.attributes)) e.setAttribute(n, xt(r, i));
632
+ t.index && e.setIndex(xt(r, t.index));
615
633
  for (let n of t.groups) e.addGroup(n.start, n.count, n.materialIndex);
616
634
  e.setDrawRange(t.drawRange.start, t.drawRange.count), e.userData = t.userData, c[t.uuid] = e;
617
635
  }
@@ -646,7 +664,7 @@ async function xt(e, t, { loadTexture: n }) {
646
664
  default: n = new ie();
647
665
  }
648
666
  n.uuid = t.uuid;
649
- for (let e of at) n[e] = t[e];
667
+ for (let e of st) n[e] = t[e];
650
668
  if (n.position.fromArray(t.position), n.quaternion.fromArray(t.quaternion), n.scale.fromArray(t.scale), n.layers.mask = t.layers, n.userData = t.userData, t.matrix && n.matrix.fromArray(t.matrix), n.isCamera) {
651
669
  for (let e of [
652
670
  "fov",
@@ -666,7 +684,7 @@ async function xt(e, t, { loadTexture: n }) {
666
684
  }
667
685
  if (n.isLight) {
668
686
  n.color.fromArray(t.color);
669
- for (let e of it) t[e] !== void 0 && (n[e] = t[e]);
687
+ for (let e of ot) t[e] !== void 0 && (n[e] = t[e]);
670
688
  }
671
689
  l.push(n), t.parent >= 0 && l[t.parent].add(n);
672
690
  }
@@ -682,42 +700,42 @@ async function xt(e, t, { loadTexture: n }) {
682
700
  }
683
701
  //#endregion
684
702
  //#region src/Processor/PBRT/buffers.js
685
- var St = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && typeof e.buffer.transfer == "function" && !(typeof SharedArrayBuffer < "u" && e.buffer instanceof SharedArrayBuffer);
686
- function H(e) {
687
- e && St(e) && e.buffer.transfer(0);
703
+ var wt = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && typeof e.buffer.transfer == "function" && !(typeof SharedArrayBuffer < "u" && e.buffer instanceof SharedArrayBuffer);
704
+ function z(e) {
705
+ e && wt(e) && e.buffer.transfer(0);
688
706
  }
689
- function U(e, t) {
707
+ function B(e, t) {
690
708
  let n = e.constructor;
691
- if (St(e)) return new n(e.buffer.transfer(t * n.BYTES_PER_ELEMENT));
709
+ if (wt(e)) return new n(e.buffer.transfer(t * n.BYTES_PER_ELEMENT));
692
710
  let r = new n(t);
693
711
  return r.set(t < e.length ? e.subarray(0, t) : e), r;
694
712
  }
695
713
  //#endregion
696
714
  //#region src/Processor/PBRT/PBRTTokenizer.js
697
- var W = {
715
+ var V = {
698
716
  STRING: "string",
699
717
  NUMBER: "number",
700
718
  WORD: "word",
701
719
  LBRACKET: "[",
702
720
  RBRACKET: "]"
703
- }, Ct = 9, wt = 10, Tt = 12, Et = 13, Dt = 32, Ot = 34, kt = 35, At = 43, jt = 45, Mt = 46, Nt = 48, Pt = 57, Ft = 91, It = 93, Lt = 69, Rt = 101, zt = (e) => e === Dt || e === Ct || e === wt || e === Et || e === Tt, G = (e) => e >= Nt && e <= Pt, Bt = 15, Vt = 22, Ht = (() => {
704
- let e = new Float64Array(Vt + 1);
721
+ }, Tt = 9, Et = 10, Dt = 12, Ot = 13, kt = 32, At = 34, jt = 35, Mt = 43, Nt = 45, Pt = 46, Ft = 48, It = 57, Lt = 91, Rt = 93, zt = 69, Bt = 101, Vt = (e) => e === kt || e === Tt || e === Et || e === Ot || e === Dt, H = (e) => e >= Ft && e <= It, Ht = 15, Ut = 22, Wt = (() => {
722
+ let e = new Float64Array(Ut + 1);
705
723
  for (let t = 0; t < e.length; t++) e[t] = 10 ** t;
706
724
  return e;
707
- })(), Ut = new TextDecoder();
708
- function K(e, t, n) {
725
+ })(), Gt = new TextDecoder();
726
+ function Kt(e, t, n) {
709
727
  if (n - t === 0) return "";
710
728
  let r = !0;
711
729
  for (let i = t; i < n; i++) if (e[i] > 127) {
712
730
  r = !1;
713
731
  break;
714
732
  }
715
- if (!r) return Ut.decode(e.subarray(t, n));
733
+ if (!r) return Gt.decode(e.subarray(t, n));
716
734
  let i = "";
717
735
  for (let r = t; r < n; r++) i += String.fromCharCode(e[r]);
718
736
  return i;
719
737
  }
720
- var Wt = class {
738
+ var qt = class {
721
739
  constructor(e) {
722
740
  this.bytes = typeof e == "string" ? new TextEncoder().encode(e) : e, this.i = 0, this.n = this.bytes.length, this._ahead = null;
723
741
  }
@@ -731,73 +749,73 @@ var Wt = class {
731
749
  _scan() {
732
750
  let e = this.bytes, t = this.i, n = this.n;
733
751
  for (;;) {
734
- for (; t < n && zt(e[t]);) t++;
735
- if (t < n && e[t] === kt) {
736
- for (; t < n && e[t] !== wt;) t++;
752
+ for (; t < n && Vt(e[t]);) t++;
753
+ if (t < n && e[t] === jt) {
754
+ for (; t < n && e[t] !== Et;) t++;
737
755
  continue;
738
756
  }
739
757
  break;
740
758
  }
741
759
  if (t >= n) return this.i = t, null;
742
760
  let r = e[t];
743
- if (r === Ft) return this.i = t + 1, { type: W.LBRACKET };
744
- if (r === It) return this.i = t + 1, { type: W.RBRACKET };
745
- if (r === Ot) {
761
+ if (r === Lt) return this.i = t + 1, { type: V.LBRACKET };
762
+ if (r === Rt) return this.i = t + 1, { type: V.RBRACKET };
763
+ if (r === At) {
746
764
  let r = ++t;
747
- for (; t < n && e[t] !== Ot;) t++;
765
+ for (; t < n && e[t] !== At;) t++;
748
766
  if (t >= n) throw Error("PBRT tokenizer: unterminated string literal");
749
767
  return this.i = t + 1, {
750
- type: W.STRING,
751
- value: K(e, r, t)
768
+ type: V.STRING,
769
+ value: Kt(e, r, t)
752
770
  };
753
771
  }
754
- if (G(r) || r === Mt && G(e[t + 1]) || (r === jt || r === At) && (G(e[t + 1]) || e[t + 1] === Mt && G(e[t + 2]))) return this._scanNumber(t);
772
+ if (H(r) || r === Pt && H(e[t + 1]) || (r === Nt || r === Mt) && (H(e[t + 1]) || e[t + 1] === Pt && H(e[t + 2]))) return this._scanNumber(t);
755
773
  let i = t;
756
774
  for (; t < n;) {
757
775
  let n = e[t];
758
- if (zt(n) || n === Ot || n === Ft || n === It || n === kt) break;
776
+ if (Vt(n) || n === At || n === Lt || n === Rt || n === jt) break;
759
777
  t++;
760
778
  }
761
779
  return this.i = t, {
762
- type: W.WORD,
763
- value: K(e, i, t)
780
+ type: V.WORD,
781
+ value: Kt(e, i, t)
764
782
  };
765
783
  }
766
784
  _scanNumber(e) {
767
785
  let t = this.bytes, n = this.n, r = e, i = !1;
768
- t[r] === jt ? (i = !0, r++) : t[r] === At && r++;
786
+ t[r] === Nt ? (i = !0, r++) : t[r] === Mt && r++;
769
787
  let a = 0, o = 0, s = 0;
770
- for (; r < n && G(t[r]);) a = a * 10 + (t[r] - Nt), o++, r++;
771
- if (r < n && t[r] === Mt) for (r++; r < n && G(t[r]);) a = a * 10 + (t[r] - Nt), o++, s++, r++;
788
+ for (; r < n && H(t[r]);) a = a * 10 + (t[r] - Ft), o++, r++;
789
+ if (r < n && t[r] === Pt) for (r++; r < n && H(t[r]);) a = a * 10 + (t[r] - Ft), o++, s++, r++;
772
790
  let c = 0;
773
- if (r < n && (t[r] === Rt || t[r] === Lt)) {
791
+ if (r < n && (t[r] === Bt || t[r] === zt)) {
774
792
  let e = r + 1, i = !1;
775
- if (e < n && (t[e] === jt || t[e] === At) && (i = t[e] === jt, e++), e < n && G(t[e])) {
793
+ if (e < n && (t[e] === Nt || t[e] === Mt) && (i = t[e] === Nt, e++), e < n && H(t[e])) {
776
794
  let a = 0;
777
- for (; e < n && G(t[e]);) a = a * 10 + (t[e] - Nt), e++;
795
+ for (; e < n && H(t[e]);) a = a * 10 + (t[e] - Ft), e++;
778
796
  c = i ? -a : a, r = e;
779
797
  }
780
798
  }
781
- if (this.i = r, o === 0) throw Error(`PBRT tokenizer: invalid number "${K(t, e, r)}"`);
799
+ if (this.i = r, o === 0) throw Error(`PBRT tokenizer: invalid number "${Kt(t, e, r)}"`);
782
800
  let l = c - s;
783
- if (!(o <= Bt && l >= -Vt && l <= Vt)) {
784
- let n = Number(K(t, e, r));
785
- if (Number.isNaN(n)) throw Error(`PBRT tokenizer: invalid number "${K(t, e, r)}"`);
801
+ if (!(o <= Ht && l >= -Ut && l <= Ut)) {
802
+ let n = Number(Kt(t, e, r));
803
+ if (Number.isNaN(n)) throw Error(`PBRT tokenizer: invalid number "${Kt(t, e, r)}"`);
786
804
  return {
787
- type: W.NUMBER,
805
+ type: V.NUMBER,
788
806
  value: n
789
807
  };
790
808
  }
791
- let u = l === 0 ? a : l > 0 ? a * Ht[l] : a / Ht[-l];
809
+ let u = l === 0 ? a : l > 0 ? a * Wt[l] : a / Wt[-l];
792
810
  return i && (u = -u), {
793
- type: W.NUMBER,
811
+ type: V.NUMBER,
794
812
  value: u
795
813
  };
796
814
  }
797
815
  };
798
816
  //#endregion
799
817
  //#region src/Processor/PBRT/PBRTMath.js
800
- function Gt() {
818
+ function Jt() {
801
819
  return [
802
820
  1,
803
821
  0,
@@ -817,17 +835,17 @@ function Gt() {
817
835
  1
818
836
  ];
819
837
  }
820
- function Kt(e) {
838
+ function Yt(e) {
821
839
  return e[0] * (e[5] * e[10] - e[6] * e[9]) - e[4] * (e[1] * e[10] - e[2] * e[9]) + e[8] * (e[1] * e[6] - e[2] * e[5]);
822
840
  }
823
- function qt(e, t, n, r) {
841
+ function Xt(e, t, n, r) {
824
842
  for (let i = 0; i < 4; i++) {
825
843
  let a = r[i * 4], o = r[i * 4 + 1], s = r[i * 4 + 2], c = r[i * 4 + 3];
826
844
  for (let r = 0; r < 4; r++) e[i * 4 + r] = t[n + r] * a + t[n + 4 + r] * o + t[n + 8 + r] * s + t[n + 12 + r] * c;
827
845
  }
828
846
  return e;
829
847
  }
830
- function q(e, t) {
848
+ function U(e, t) {
831
849
  let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], k = t[11], A = t[12], j = t[13], M = t[14], N = t[15];
832
850
  return [
833
851
  n * v + o * y + u * b + m * x,
@@ -848,7 +866,7 @@ function q(e, t) {
848
866
  a * A + l * j + p * M + _ * N
849
867
  ];
850
868
  }
851
- function Jt(e, t, n) {
869
+ function Zt(e, t, n) {
852
870
  return [
853
871
  1,
854
872
  0,
@@ -868,7 +886,7 @@ function Jt(e, t, n) {
868
886
  1
869
887
  ];
870
888
  }
871
- function Yt(e, t, n) {
889
+ function Qt(e, t, n) {
872
890
  return [
873
891
  e,
874
892
  0,
@@ -888,7 +906,7 @@ function Yt(e, t, n) {
888
906
  1
889
907
  ];
890
908
  }
891
- function Xt(e, t, n, r) {
909
+ function $t(e, t, n, r) {
892
910
  let i = Math.hypot(t, n, r) || 1;
893
911
  t /= i, n /= i, r /= i;
894
912
  let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
@@ -911,21 +929,21 @@ function Xt(e, t, n, r) {
911
929
  1
912
930
  ];
913
931
  }
914
- function Zt(e, t) {
932
+ function en(e, t) {
915
933
  return [
916
934
  e[0] - t[0],
917
935
  e[1] - t[1],
918
936
  e[2] - t[2]
919
937
  ];
920
938
  }
921
- function Qt(e, t) {
939
+ function tn(e, t) {
922
940
  return [
923
941
  e[1] * t[2] - e[2] * t[1],
924
942
  e[2] * t[0] - e[0] * t[2],
925
943
  e[0] * t[1] - e[1] * t[0]
926
944
  ];
927
945
  }
928
- function $t(e) {
946
+ function nn(e) {
929
947
  let t = Math.hypot(e[0], e[1], e[2]) || 1;
930
948
  return [
931
949
  e[0] / t,
@@ -933,8 +951,8 @@ function $t(e) {
933
951
  e[2] / t
934
952
  ];
935
953
  }
936
- function en(e, t, n) {
937
- let r = $t(Zt(t, e)), i = $t(Qt($t(n), r)), a = Qt(r, i);
954
+ function rn(e, t, n) {
955
+ let r = nn(en(t, e)), i = nn(tn(nn(n), r)), a = tn(r, i);
938
956
  return [
939
957
  i[0],
940
958
  i[1],
@@ -954,9 +972,9 @@ function en(e, t, n) {
954
972
  1
955
973
  ];
956
974
  }
957
- function J(e) {
975
+ function W(e) {
958
976
  let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
959
- if (x === 0) return Gt();
977
+ if (x === 0) return Jt();
960
978
  let S = 1 / x;
961
979
  return [
962
980
  _ * S,
@@ -979,7 +997,7 @@ function J(e) {
979
997
  }
980
998
  //#endregion
981
999
  //#region src/Processor/PBRT/PBRTParser.js
982
- var tn = 8, nn = 1, rn = 2, Y = 3, an = new Set([
1000
+ var an = 8, on = 1, sn = 2, G = 3, cn = new Set([
983
1001
  "Identity",
984
1002
  "Transform",
985
1003
  "CoordinateSystem",
@@ -998,12 +1016,12 @@ var tn = 8, nn = 1, rn = 2, Y = 3, an = new Set([
998
1016
  "ObjectEnd",
999
1017
  "ObjectInstance"
1000
1018
  ]);
1001
- function on(e, t) {
1019
+ function ln(e, t) {
1002
1020
  if (e === t) return !0;
1003
1021
  for (let n = 0; n < 16; n++) if (e[n] !== t[n]) return !1;
1004
1022
  return !0;
1005
1023
  }
1006
- var sn = {
1024
+ var un = {
1007
1025
  integer: Int32Array,
1008
1026
  point3: Float32Array,
1009
1027
  point2: Float32Array,
@@ -1012,7 +1030,7 @@ var sn = {
1012
1030
  vector: Float32Array,
1013
1031
  normal: Float32Array,
1014
1032
  rgb: Float32Array
1015
- }, cn = class {
1033
+ }, dn = class {
1016
1034
  constructor(e = {}) {
1017
1035
  this.releaseInclude = e.releaseInclude || null, this.resolveInclude = e.resolveInclude || (() => {
1018
1036
  throw Error("PBRTParser: Include used but no resolveInclude provided");
@@ -1034,7 +1052,7 @@ var sn = {
1034
1052
  },
1035
1053
  hasMotion: !1,
1036
1054
  warnings: []
1037
- }, this.ctm = Gt(), this.ctmEnd = null, this.activeTransform = Y, this._ctmSource = null, this._ctmValue = null, this.state = {
1055
+ }, this.ctm = Jt(), this.ctmEnd = null, this.activeTransform = G, this._ctmSource = null, this._ctmValue = null, this.state = {
1038
1056
  material: null,
1039
1057
  areaLight: null,
1040
1058
  reverseOrientation: !1,
@@ -1042,8 +1060,8 @@ var sn = {
1042
1060
  }, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.dirStack = [""], this.stream = null, this._warnedUnknown = /* @__PURE__ */ new Set();
1043
1061
  }
1044
1062
  async parse(e, t = "") {
1045
- this.dirStack = [t], await this._run(new Wt(e)), this._movedShapes && (this.ir.shapes = this.ir.shapes.filter(Boolean));
1046
- for (let e of this.ir.instances.values()) e.matrices = U(e.matrices, e.count * 16), e.matricesEnd &&= U(e.matricesEnd, e.count * 16);
1063
+ this.dirStack = [t], await this._run(new qt(e)), this._movedShapes && (this.ir.shapes = this.ir.shapes.filter(Boolean));
1064
+ for (let e of this.ir.instances.values()) e.matrices = B(e.matrices, e.count * 16), e.matricesEnd &&= B(e.matricesEnd, e.count * 16);
1047
1065
  return this.ir;
1048
1066
  }
1049
1067
  _addInstance(e, t = this.ctm) {
@@ -1061,7 +1079,7 @@ var sn = {
1061
1079
  let r = (n.count + 1) * 16;
1062
1080
  if (r > n.matrices.length) {
1063
1081
  let e = Math.max(r, n.matrices.length * 2);
1064
- n.matrices = U(n.matrices, e), n.matricesEnd &&= U(n.matricesEnd, e);
1082
+ n.matrices = B(n.matrices, e), n.matricesEnd &&= B(n.matricesEnd, e);
1065
1083
  }
1066
1084
  let i = n.count * 16;
1067
1085
  for (let e = 0; e < 16; e++) n.matrices[i + e] = t[e];
@@ -1076,23 +1094,23 @@ var sn = {
1076
1094
  return this._ctmSource !== this.ctm && (this._ctmSource = this.ctm, this._ctmValue = this.ctm.slice()), this._ctmValue;
1077
1095
  }
1078
1096
  _ctmEndSnapshot() {
1079
- return this.ctmEnd === null || on(this.ctmEnd, this.ctm) ? null : (this.ir.hasMotion = !0, this.ctmEnd.slice());
1097
+ return this.ctmEnd === null || ln(this.ctmEnd, this.ctm) ? null : (this.ir.hasMotion = !0, this.ctmEnd.slice());
1080
1098
  }
1081
1099
  _concat(e) {
1082
- if (this.activeTransform === Y && this.ctmEnd === null) {
1083
- this.ctm = q(this.ctm, e);
1100
+ if (this.activeTransform === G && this.ctmEnd === null) {
1101
+ this.ctm = U(this.ctm, e);
1084
1102
  return;
1085
1103
  }
1086
1104
  let t = this.ctmEnd ?? this.ctm;
1087
- this.ctmEnd = this.activeTransform & rn ? q(t, e) : t, this.activeTransform & nn && (this.ctm = q(this.ctm, e));
1105
+ this.ctmEnd = this.activeTransform & sn ? U(t, e) : t, this.activeTransform & on && (this.ctm = U(this.ctm, e));
1088
1106
  }
1089
1107
  _setCTM(e) {
1090
- if (this.activeTransform === Y) {
1108
+ if (this.activeTransform === G) {
1091
1109
  this.ctm = e, this.ctmEnd = null;
1092
1110
  return;
1093
1111
  }
1094
1112
  let t = this.ctmEnd ?? this.ctm;
1095
- this.ctmEnd = this.activeTransform & rn ? e : t, this.activeTransform & nn && (this.ctm = e);
1113
+ this.ctmEnd = this.activeTransform & sn ? e : t, this.activeTransform & on && (this.ctm = e);
1096
1114
  }
1097
1115
  _pushGraphicsState() {
1098
1116
  this.attributeStack.push({
@@ -1122,12 +1140,12 @@ var sn = {
1122
1140
  }
1123
1141
  _expectNumber(e) {
1124
1142
  let t = this._next();
1125
- if (!t || t.type !== W.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
1143
+ if (!t || t.type !== V.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
1126
1144
  return t.value;
1127
1145
  }
1128
1146
  _expectString(e) {
1129
1147
  let t = this._next();
1130
- if (!t || t.type !== W.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
1148
+ if (!t || t.type !== V.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
1131
1149
  return t.value;
1132
1150
  }
1133
1151
  _readNumbers(e) {
@@ -1136,17 +1154,17 @@ var sn = {
1136
1154
  return t;
1137
1155
  }
1138
1156
  _readBracketedOrBareNumbers(e) {
1139
- if (this._peek() && this._peek().type === W.LBRACKET) {
1157
+ if (this._peek() && this._peek().type === V.LBRACKET) {
1140
1158
  this._next();
1141
1159
  let e = [];
1142
- for (; this._peek() && this._peek().type !== W.RBRACKET;) e.push(this._expectNumber("transform element"));
1160
+ for (; this._peek() && this._peek().type !== V.RBRACKET;) e.push(this._expectNumber("transform element"));
1143
1161
  return this._next(), e;
1144
1162
  }
1145
1163
  return this._readNumbers(e);
1146
1164
  }
1147
1165
  _parseParams() {
1148
1166
  let e = {};
1149
- for (; this._peek() && this._peek().type === W.STRING;) {
1167
+ for (; this._peek() && this._peek().type === V.STRING;) {
1150
1168
  let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
1151
1169
  e[r] = {
1152
1170
  type: n,
@@ -1156,30 +1174,30 @@ var sn = {
1156
1174
  return e;
1157
1175
  }
1158
1176
  _parseParamValue(e) {
1159
- let t = this._peek() && this._peek().type === W.LBRACKET;
1177
+ let t = this._peek() && this._peek().type === V.LBRACKET;
1160
1178
  t && this._next();
1161
1179
  let n = () => {
1162
1180
  let e = this._peek();
1163
- return t ? e && e.type !== W.RBRACKET : !1;
1181
+ return t ? e && e.type !== V.RBRACKET : !1;
1164
1182
  };
1165
1183
  if (!t) return [this._coerceValueToken(this._next())];
1166
- if (this._peek() && this._peek().type === W.NUMBER) {
1184
+ if (this._peek() && this._peek().type === V.NUMBER) {
1167
1185
  let t = [];
1168
- for (; n() && t.length < tn;) {
1186
+ for (; n() && t.length < an;) {
1169
1187
  let e = this._next();
1170
- if (e.type !== W.NUMBER) return this._finishMixedValue(t, t.length, e);
1188
+ if (e.type !== V.NUMBER) return this._finishMixedValue(t, t.length, e);
1171
1189
  t.push(e.value);
1172
1190
  }
1173
1191
  if (!n()) return this._next(), t;
1174
- let r = new (sn[e] || Float64Array)(tn * 4);
1192
+ let r = new (un[e] || Float64Array)(an * 4);
1175
1193
  r.set(t);
1176
1194
  let i = t.length;
1177
1195
  for (; n();) {
1178
1196
  let e = this._next();
1179
- if (e.type !== W.NUMBER) return this._finishMixedValue(r, i, e);
1180
- i === r.length && (r = U(r, r.length * 2)), r[i++] = e.value;
1197
+ if (e.type !== V.NUMBER) return this._finishMixedValue(r, i, e);
1198
+ i === r.length && (r = B(r, r.length * 2)), r[i++] = e.value;
1181
1199
  }
1182
- return this._next(), i === r.length ? r : U(r, i);
1200
+ return this._next(), i === r.length ? r : B(r, i);
1183
1201
  }
1184
1202
  let r = [];
1185
1203
  for (; n();) r.push(this._coerceValueToken(this._next()));
@@ -1188,21 +1206,21 @@ var sn = {
1188
1206
  _finishMixedValue(e, t, n) {
1189
1207
  let r = [];
1190
1208
  for (let n = 0; n < t; n++) r.push(e[n]);
1191
- for (r.push(this._coerceValueToken(n)); this._peek() && this._peek().type !== W.RBRACKET;) r.push(this._coerceValueToken(this._next()));
1209
+ for (r.push(this._coerceValueToken(n)); this._peek() && this._peek().type !== V.RBRACKET;) r.push(this._coerceValueToken(this._next()));
1192
1210
  return this._next(), r;
1193
1211
  }
1194
1212
  _coerceValueToken(e) {
1195
1213
  if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
1196
- if (e.type === W.NUMBER || e.type === W.STRING) return e.value;
1197
- if (e.type === W.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
1214
+ if (e.type === V.NUMBER || e.type === V.STRING) return e.value;
1215
+ if (e.type === V.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
1198
1216
  throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
1199
1217
  }
1200
1218
  async _run(e) {
1201
1219
  let t = this.stream;
1202
1220
  this.stream = e;
1203
1221
  for (let e = this._next(); e !== null; e = this._next()) {
1204
- if (e.type !== W.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
1205
- an.has(e.value) && this._effects++;
1222
+ if (e.type !== V.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
1223
+ cn.has(e.value) && this._effects++;
1206
1224
  let t = this._directive(e.value);
1207
1225
  t !== void 0 && await t;
1208
1226
  }
@@ -1211,25 +1229,25 @@ var sn = {
1211
1229
  _directive(e) {
1212
1230
  switch (e) {
1213
1231
  case "Identity":
1214
- this._setCTM(Gt());
1232
+ this._setCTM(Jt());
1215
1233
  break;
1216
1234
  case "Translate": {
1217
1235
  let [e, t, n] = this._readNumbers(3);
1218
- this._concat(Jt(e, t, n));
1236
+ this._concat(Zt(e, t, n));
1219
1237
  break;
1220
1238
  }
1221
1239
  case "Scale": {
1222
1240
  let [e, t, n] = this._readNumbers(3);
1223
- this._concat(Yt(e, t, n));
1241
+ this._concat(Qt(e, t, n));
1224
1242
  break;
1225
1243
  }
1226
1244
  case "Rotate": {
1227
1245
  let [e, t, n, r] = this._readNumbers(4);
1228
- this._concat(Xt(e, t, n, r));
1246
+ this._concat($t(e, t, n, r));
1229
1247
  break;
1230
1248
  }
1231
1249
  case "LookAt": {
1232
- let e = this._readNumbers(9), t = en([
1250
+ let e = this._readNumbers(9), t = rn([
1233
1251
  e[0],
1234
1252
  e[1],
1235
1253
  e[2]
@@ -1242,7 +1260,7 @@ var sn = {
1242
1260
  e[7],
1243
1261
  e[8]
1244
1262
  ]);
1245
- this._concat(J(t));
1263
+ this._concat(W(t));
1246
1264
  break;
1247
1265
  }
1248
1266
  case "Transform":
@@ -1267,10 +1285,10 @@ var sn = {
1267
1285
  this.ir.camera = {
1268
1286
  type: e,
1269
1287
  params: t,
1270
- cameraToWorld: J(this.ctm)
1288
+ cameraToWorld: W(this.ctm)
1271
1289
  };
1272
1290
  let n = this._ctmEndSnapshot();
1273
- n && (this.ir.camera.cameraToWorldEnd = J(n));
1291
+ n && (this.ir.camera.cameraToWorldEnd = W(n));
1274
1292
  break;
1275
1293
  }
1276
1294
  case "Film": {
@@ -1279,12 +1297,23 @@ var sn = {
1279
1297
  this.ir.film = {
1280
1298
  xresolution: this._num(e.xresolution, 1280),
1281
1299
  yresolution: this._num(e.yresolution, 720),
1300
+ resolutionGiven: !!(e.xresolution || e.yresolution),
1282
1301
  filename: this._str(e.filename, null)
1283
1302
  };
1284
1303
  break;
1285
1304
  }
1286
- case "Integrator":
1287
- case "Sampler":
1305
+ case "Integrator": {
1306
+ this._expectString("Integrator type");
1307
+ let e = this._parseParams();
1308
+ e.maxdepth && (this.ir.integrator = { maxdepth: this._num(e.maxdepth, 5) });
1309
+ break;
1310
+ }
1311
+ case "Sampler": {
1312
+ this._expectString("Sampler type");
1313
+ let e = this._parseParams();
1314
+ e.pixelsamples && (this.ir.sampler = { pixelsamples: this._num(e.pixelsamples, 16) });
1315
+ break;
1316
+ }
1288
1317
  case "PixelFilter":
1289
1318
  case "Filter":
1290
1319
  case "Accelerator":
@@ -1293,7 +1322,7 @@ var sn = {
1293
1322
  this._skipTypeAndParams();
1294
1323
  break;
1295
1324
  case "WorldBegin":
1296
- this.ctm = Gt(), this.ctmEnd = null, this.activeTransform = Y, this.state = {
1325
+ this.ctm = Jt(), this.ctmEnd = null, this.activeTransform = G, this.state = {
1297
1326
  material: null,
1298
1327
  areaLight: null,
1299
1328
  reverseOrientation: !1,
@@ -1327,7 +1356,7 @@ var sn = {
1327
1356
  break;
1328
1357
  case "ActiveTransform": {
1329
1358
  let e = this._next()?.value;
1330
- e === "StartTime" ? this.activeTransform = nn : e === "EndTime" ? this.activeTransform = rn : e === "All" ? this.activeTransform = Y : this._warn(`ActiveTransform "${e}" not recognised`);
1359
+ e === "StartTime" ? this.activeTransform = on : e === "EndTime" ? this.activeTransform = sn : e === "All" ? this.activeTransform = G : this._warn(`ActiveTransform "${e}" not recognised`);
1331
1360
  break;
1332
1361
  }
1333
1362
  case "TransformTimes": {
@@ -1339,8 +1368,8 @@ var sn = {
1339
1368
  break;
1340
1369
  }
1341
1370
  case "MediumInterface": {
1342
- let e = this._peek()?.type === W.STRING ? this._next().value : "";
1343
- this._peek()?.type === W.STRING && this._next(), this.state.interior = e || null;
1371
+ let e = this._peek()?.type === V.STRING ? this._next().value : "";
1372
+ this._peek()?.type === V.STRING && this._next(), this.state.interior = e || null;
1344
1373
  break;
1345
1374
  }
1346
1375
  case "MakeNamedMedium": {
@@ -1392,7 +1421,7 @@ var sn = {
1392
1421
  }
1393
1422
  case "LightSource": {
1394
1423
  let e = this._expectString("LightSource type"), t = this._parseParams();
1395
- this.ctmEnd !== null && !on(this.ctmEnd, this.ctm) && this._warnOnce("animated-light", "animated LightSource transforms are not supported — using the start transform"), this.ir.lights.push({
1424
+ this.ctmEnd !== null && !ln(this.ctmEnd, this.ctm) && this._warnOnce("animated-light", "animated LightSource transforms are not supported — using the start transform"), this.ir.lights.push({
1396
1425
  type: e,
1397
1426
  params: t,
1398
1427
  ctm: this._ctmSnapshot()
@@ -1402,7 +1431,6 @@ var sn = {
1402
1431
  case "Shape": {
1403
1432
  let e = this._expectString("Shape type"), t = this._parseParams(), n = t.alpha;
1404
1433
  if (n?.type === "float" && n.value[0] <= 0) break;
1405
- n && !(n.type === "float" && n.value[0] >= 1) && this._warnOnce("alpha", "shape \"alpha\" between 0 and 1, or as a texture, is not supported — drawn opaque");
1406
1434
  let r = {
1407
1435
  type: e,
1408
1436
  params: t,
@@ -1412,7 +1440,7 @@ var sn = {
1412
1440
  reverseOrientation: this.state.reverseOrientation,
1413
1441
  interior: this.state.interior
1414
1442
  }, i = this.currentObject === null ? this._ctmEndSnapshot() : null;
1415
- i ? r.ctmEnd = i : this.currentObject !== null && this.ctmEnd !== null && !on(this.ctmEnd, this.ctm) && this._warnOnce("animated-template", "animated transforms inside ObjectBegin are not supported — using the start transform"), this._emitShape(r);
1443
+ i ? r.ctmEnd = i : this.currentObject !== null && this.ctmEnd !== null && !ln(this.ctmEnd, this.ctm) && this._warnOnce("animated-template", "animated transforms inside ObjectBegin are not supported — using the start transform"), this._emitShape(r);
1416
1444
  break;
1417
1445
  }
1418
1446
  case "ObjectBegin": {
@@ -1452,7 +1480,7 @@ var sn = {
1452
1480
  let i = n === null ? null : this._includeState(), a = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
1453
1481
  this.dirStack.push(a);
1454
1482
  try {
1455
- await this._run(new Wt(r));
1483
+ await this._run(new qt(r));
1456
1484
  } finally {
1457
1485
  this.dirStack.pop(), this.releaseInclude?.(e, t, r);
1458
1486
  }
@@ -1464,7 +1492,7 @@ var sn = {
1464
1492
  });
1465
1493
  }
1466
1494
  _includeKey(e, t) {
1467
- return !this.instanceIncludes || this.currentObject !== null || this.ctmEnd !== null || this.activeTransform !== Y || this.state.areaLight ? null : `${t}\0${e}\0${this._stateId(this.state.material)}\0${this.state.reverseOrientation}\0${this.state.interior}`;
1495
+ return !this.instanceIncludes || this.currentObject !== null || this.ctmEnd !== null || this.activeTransform !== G || this.state.areaLight ? null : `${t}\0${e}\0${this._stateId(this.state.material)}\0${this.state.reverseOrientation}\0${this.state.interior}`;
1468
1496
  }
1469
1497
  _stateId(e) {
1470
1498
  if (!e) return 0;
@@ -1484,7 +1512,7 @@ var sn = {
1484
1512
  };
1485
1513
  }
1486
1514
  _sameIncludeState(e) {
1487
- return this._effects === e.effects && this.ctmEnd === null && this.activeTransform === Y && on(this.ctm, e.ctm) && this.attributeStack.length === e.attributes && this.transformStack.length === e.transforms && this.state.material === e.material && this.state.areaLight === null && this.state.reverseOrientation === e.reverseOrientation && this.state.interior === e.interior;
1515
+ return this._effects === e.effects && this.ctmEnd === null && this.activeTransform === G && ln(this.ctm, e.ctm) && this.attributeStack.length === e.attributes && this.transformStack.length === e.transforms && this.state.material === e.material && this.state.areaLight === null && this.state.reverseOrientation === e.reverseOrientation && this.state.interior === e.interior;
1488
1516
  }
1489
1517
  _placeRepeat(e, t) {
1490
1518
  let n = this._includes.get(e);
@@ -1493,20 +1521,20 @@ var sn = {
1493
1521
  let { start: r, end: i } = n;
1494
1522
  if (i === r || this.ir.instanceCount + 2 > this.maxPlacements) return !1;
1495
1523
  for (let t = r; t < i; t++) if (!this.ir.shapes[t]) return this._includes.delete(e), !1;
1496
- let a = `${t}#${this.ir.objects.size}`, o = J(n.ctm), s = [], c = null, l = null;
1524
+ let a = `${t}#${this.ir.objects.size}`, o = W(n.ctm), s = [], c = null, l = null;
1497
1525
  for (let e = r; e < i; e++) {
1498
1526
  let t = this.ir.shapes[e];
1499
- t.ctm !== c && (l = q(o, c = t.ctm)), t.relativeCTM = l, s.push(t), this.ir.shapes[e] = null;
1527
+ t.ctm !== c && (l = U(o, c = t.ctm)), t.relativeCTM = l, s.push(t), this.ir.shapes[e] = null;
1500
1528
  }
1501
1529
  this.ir.objects.set(a, s), this._addInstance(a, n.ctm), n.template = a, this._movedShapes = !0;
1502
1530
  }
1503
1531
  return this._addInstance(n.template), !0;
1504
1532
  }
1505
1533
  _skipTypeAndParams() {
1506
- this._peek() && this._peek().type === W.STRING && this._next(), this._parseParams();
1534
+ this._peek() && this._peek().type === V.STRING && this._next(), this._parseParams();
1507
1535
  }
1508
1536
  _skipNamedAndParams() {
1509
- this._peek() && this._peek().type === W.STRING && this._next(), this._parseParams();
1537
+ this._peek() && this._peek().type === V.STRING && this._next(), this._parseParams();
1510
1538
  }
1511
1539
  _num(e, t) {
1512
1540
  return e && e.value.length ? e.value[0] : t;
@@ -1523,7 +1551,453 @@ var sn = {
1523
1551
  _warnUnknown(e) {
1524
1552
  this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
1525
1553
  }
1526
- }, ln = {
1554
+ }, fn = {
1555
+ Apple: [[
1556
+ 2.29,
1557
+ 2.39,
1558
+ 1.97
1559
+ ], [
1560
+ .003,
1561
+ .0034,
1562
+ .046
1563
+ ]],
1564
+ Chicken1: [[
1565
+ .15,
1566
+ .21,
1567
+ .38
1568
+ ], [
1569
+ .015,
1570
+ .077,
1571
+ .19
1572
+ ]],
1573
+ Chicken2: [[
1574
+ .19,
1575
+ .25,
1576
+ .32
1577
+ ], [
1578
+ .018,
1579
+ .088,
1580
+ .2
1581
+ ]],
1582
+ Cream: [[
1583
+ 7.38,
1584
+ 5.47,
1585
+ 3.15
1586
+ ], [
1587
+ 2e-4,
1588
+ .0028,
1589
+ .0163
1590
+ ]],
1591
+ Ketchup: [[
1592
+ .18,
1593
+ .07,
1594
+ .03
1595
+ ], [
1596
+ .061,
1597
+ .97,
1598
+ 1.45
1599
+ ]],
1600
+ Marble: [[
1601
+ 2.19,
1602
+ 2.62,
1603
+ 3
1604
+ ], [
1605
+ .0021,
1606
+ .0041,
1607
+ .0071
1608
+ ]],
1609
+ Potato: [[
1610
+ .68,
1611
+ .7,
1612
+ .55
1613
+ ], [
1614
+ .0024,
1615
+ .009,
1616
+ .12
1617
+ ]],
1618
+ Skimmilk: [[
1619
+ .7,
1620
+ 1.22,
1621
+ 1.9
1622
+ ], [
1623
+ .0014,
1624
+ .0025,
1625
+ .0142
1626
+ ]],
1627
+ Skin1: [[
1628
+ .74,
1629
+ .88,
1630
+ 1.01
1631
+ ], [
1632
+ .032,
1633
+ .17,
1634
+ .48
1635
+ ]],
1636
+ Skin2: [[
1637
+ 1.09,
1638
+ 1.59,
1639
+ 1.79
1640
+ ], [
1641
+ .013,
1642
+ .07,
1643
+ .145
1644
+ ]],
1645
+ Spectralon: [[
1646
+ 11.6,
1647
+ 20.4,
1648
+ 14.9
1649
+ ], [
1650
+ 0,
1651
+ 0,
1652
+ 0
1653
+ ]],
1654
+ Wholemilk: [[
1655
+ 2.55,
1656
+ 3.21,
1657
+ 3.77
1658
+ ], [
1659
+ .0011,
1660
+ .0024,
1661
+ .014
1662
+ ]],
1663
+ "Lowfat Milk": [[
1664
+ .89187,
1665
+ 1.5136,
1666
+ 2.532
1667
+ ], [
1668
+ .002875,
1669
+ .00575,
1670
+ .0115
1671
+ ]],
1672
+ "Reduced Milk": [[
1673
+ 2.4858,
1674
+ 3.1669,
1675
+ 4.5214
1676
+ ], [
1677
+ .0025556,
1678
+ .0051111,
1679
+ .012778
1680
+ ]],
1681
+ "Regular Milk": [[
1682
+ 4.5513,
1683
+ 5.8294,
1684
+ 7.136
1685
+ ], [
1686
+ .0015333,
1687
+ .0046,
1688
+ .019933
1689
+ ]],
1690
+ Espresso: [[
1691
+ .72378,
1692
+ .84557,
1693
+ 1.0247
1694
+ ], [
1695
+ 4.7984,
1696
+ 6.5751,
1697
+ 8.8493
1698
+ ]],
1699
+ "Mint Mocha Coffee": [[
1700
+ .31602,
1701
+ .38538,
1702
+ .48131
1703
+ ], [
1704
+ 3.772,
1705
+ 5.8228,
1706
+ 7.82
1707
+ ]],
1708
+ "Lowfat Soy Milk": [[
1709
+ .30576,
1710
+ .34233,
1711
+ .61664
1712
+ ], [
1713
+ .0014375,
1714
+ .0071875,
1715
+ .035937
1716
+ ]],
1717
+ "Regular Soy Milk": [[
1718
+ .59223,
1719
+ .73866,
1720
+ 1.4693
1721
+ ], [
1722
+ .0019167,
1723
+ .0095833,
1724
+ .065167
1725
+ ]],
1726
+ "Lowfat Chocolate Milk": [[
1727
+ .64925,
1728
+ .83916,
1729
+ 1.1057
1730
+ ], [
1731
+ .0115,
1732
+ .0368,
1733
+ .1564
1734
+ ]],
1735
+ "Regular Chocolate Milk": [[
1736
+ 1.4585,
1737
+ 2.1289,
1738
+ 2.9527
1739
+ ], [
1740
+ .010063,
1741
+ .043125,
1742
+ .14375
1743
+ ]],
1744
+ Coke: [[
1745
+ 89053e-9,
1746
+ 8372e-8,
1747
+ 0
1748
+ ], [
1749
+ .10014,
1750
+ .16503,
1751
+ .2468
1752
+ ]],
1753
+ Pepsi: [[
1754
+ 61697e-9,
1755
+ 42564e-9,
1756
+ 0
1757
+ ], [
1758
+ .091641,
1759
+ .14158,
1760
+ .20729
1761
+ ]],
1762
+ Sprite: [[
1763
+ 60306e-10,
1764
+ 64139e-10,
1765
+ 65504e-10
1766
+ ], [
1767
+ .001886,
1768
+ .0018308,
1769
+ .0020025
1770
+ ]],
1771
+ Gatorade: [[
1772
+ .0024574,
1773
+ .003007,
1774
+ .0037325
1775
+ ], [
1776
+ .024794,
1777
+ .019289,
1778
+ .008878
1779
+ ]],
1780
+ Chardonnay: [[
1781
+ 17982e-9,
1782
+ 13758e-9,
1783
+ 12023e-9
1784
+ ], [
1785
+ .010782,
1786
+ .011855,
1787
+ .023997
1788
+ ]],
1789
+ "White Zinfandel": [[
1790
+ 17501e-9,
1791
+ 19069e-9,
1792
+ 1288e-8
1793
+ ], [
1794
+ .012072,
1795
+ .016184,
1796
+ .019843
1797
+ ]],
1798
+ Merlot: [[
1799
+ 21129e-9,
1800
+ 0,
1801
+ 0
1802
+ ], [
1803
+ .11632,
1804
+ .25191,
1805
+ .29434
1806
+ ]],
1807
+ "Budweiser Beer": [[
1808
+ 24356e-9,
1809
+ 24079e-9,
1810
+ 10564e-9
1811
+ ], [
1812
+ .011492,
1813
+ .024911,
1814
+ .057786
1815
+ ]],
1816
+ "Coors Light Beer": [[
1817
+ 50922e-9,
1818
+ 4301e-8,
1819
+ 0
1820
+ ], [
1821
+ .006164,
1822
+ .013984,
1823
+ .034983
1824
+ ]],
1825
+ Clorox: [[
1826
+ .0024035,
1827
+ .0031373,
1828
+ .003991
1829
+ ], [
1830
+ .0033542,
1831
+ .014892,
1832
+ .026297
1833
+ ]],
1834
+ "Apple Juice": [[
1835
+ 13612e-8,
1836
+ 15836e-8,
1837
+ 227e-6
1838
+ ], [
1839
+ .012957,
1840
+ .023741,
1841
+ .052184
1842
+ ]],
1843
+ "Cranberry Juice": [[
1844
+ 10402e-8,
1845
+ 11646e-8,
1846
+ 78139e-9
1847
+ ], [
1848
+ .039437,
1849
+ .094223,
1850
+ .12426
1851
+ ]],
1852
+ "Grape Juice": [[
1853
+ 5382e-8,
1854
+ 0,
1855
+ 0
1856
+ ], [
1857
+ .10404,
1858
+ .23958,
1859
+ .29325
1860
+ ]],
1861
+ "Ruby Grapefruit Juice": [[
1862
+ .011002,
1863
+ .010927,
1864
+ .011036
1865
+ ], [
1866
+ .085867,
1867
+ .18314,
1868
+ .25262
1869
+ ]],
1870
+ "White Grapefruit Juice": [[
1871
+ .22826,
1872
+ .23998,
1873
+ .32748
1874
+ ], [
1875
+ .0138,
1876
+ .018831,
1877
+ .056781
1878
+ ]],
1879
+ Shampoo: [[
1880
+ 7176e-7,
1881
+ 8303e-7,
1882
+ 9016e-7
1883
+ ], [
1884
+ .014107,
1885
+ .045693,
1886
+ .061717
1887
+ ]],
1888
+ "Strawberry Shampoo": [[
1889
+ 15671e-8,
1890
+ 15947e-8,
1891
+ 1518e-8
1892
+ ], [
1893
+ .01449,
1894
+ .05796,
1895
+ .075823
1896
+ ]],
1897
+ "Head & Shoulders Shampoo": [[
1898
+ .023805,
1899
+ .028804,
1900
+ .034306
1901
+ ], [
1902
+ .084621,
1903
+ .15688,
1904
+ .20365
1905
+ ]],
1906
+ "Lemon Tea Powder": [[
1907
+ .040224,
1908
+ .045264,
1909
+ .051081
1910
+ ], [
1911
+ 2.4288,
1912
+ 4.5757,
1913
+ 7.2127
1914
+ ]],
1915
+ "Orange Powder": [[
1916
+ 15617e-8,
1917
+ 17482e-8,
1918
+ 1762e-7
1919
+ ], [
1920
+ .001449,
1921
+ .003441,
1922
+ .007863
1923
+ ]],
1924
+ "Pink Lemonade Powder": [[
1925
+ 12103e-8,
1926
+ 13073e-8,
1927
+ 12528e-8
1928
+ ], [
1929
+ .001165,
1930
+ .002366,
1931
+ .003195
1932
+ ]],
1933
+ "Cappuccino Powder": [[
1934
+ 1.8436,
1935
+ 2.5851,
1936
+ 2.1662
1937
+ ], [
1938
+ 35.844,
1939
+ 49.547,
1940
+ 61.084
1941
+ ]],
1942
+ "Salt Powder": [[
1943
+ .027333,
1944
+ .032451,
1945
+ .031979
1946
+ ], [
1947
+ .28415,
1948
+ .3257,
1949
+ .34148
1950
+ ]],
1951
+ "Sugar Powder": [[
1952
+ 22272e-8,
1953
+ 25513e-8,
1954
+ 271e-6
1955
+ ], [
1956
+ .012638,
1957
+ .031051,
1958
+ .050124
1959
+ ]],
1960
+ "Suisse Mocha Powder": [[
1961
+ 2.7979,
1962
+ 3.5452,
1963
+ 4.3365
1964
+ ], [
1965
+ 17.502,
1966
+ 27.004,
1967
+ 35.433
1968
+ ]],
1969
+ "Pacific Ocean Surface Water": [[
1970
+ 1764e-7,
1971
+ 32095e-8,
1972
+ 19617e-8
1973
+ ], [
1974
+ .031845,
1975
+ .031324,
1976
+ .030147
1977
+ ]]
1978
+ };
1979
+ function pn(e) {
1980
+ let t = fn[e];
1981
+ return t ? {
1982
+ sigmaS: t[0].slice(),
1983
+ sigmaA: t[1].slice()
1984
+ } : null;
1985
+ }
1986
+ function mn(e, t) {
1987
+ let n = -1.44 / (t * t) + .71 / t + .668 + .0636 * t, r = (1 + n) / (1 - n), i = Math.sqrt(3 * (1 - e));
1988
+ return e / 2 * (1 + Math.exp(-4 / 3 * r * i)) * Math.exp(-i);
1989
+ }
1990
+ function hn(e, t) {
1991
+ let n = Math.min(Math.max(e, 0), mn(1, t)), r = 0, i = 1;
1992
+ for (let e = 0; e < 48; e++) {
1993
+ let e = (r + i) / 2;
1994
+ mn(e, t) < n ? r = e : i = e;
1995
+ }
1996
+ return (r + i) / 2;
1997
+ }
1998
+ //#endregion
1999
+ //#region src/Processor/PBRT/PBRTMaterials.js
2000
+ var gn = {
1527
2001
  au: [
1528
2002
  1,
1529
2003
  .78,
@@ -1579,12 +2053,12 @@ var sn = {
1579
2053
  .9,
1580
2054
  .9
1581
2055
  ]
1582
- }, un = [
2056
+ }, _n = [
1583
2057
  .92,
1584
2058
  .92,
1585
2059
  .92
1586
2060
  ];
1587
- function dn(e) {
2061
+ function vn(e) {
1588
2062
  let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
1589
2063
  t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
1590
2064
  let a = (e) => Math.max(0, Math.min(255, e)) / 255;
@@ -1594,19 +2068,19 @@ function dn(e) {
1594
2068
  a(i) ** 2.2
1595
2069
  ];
1596
2070
  }
1597
- function X(e, t, n) {
2071
+ function K(e, t, n) {
1598
2072
  let r = e[t];
1599
2073
  return r && typeof r.value[0] == "number" ? r.value[0] : n;
1600
2074
  }
1601
- function Z(e, t, n) {
2075
+ function q(e, t, n) {
1602
2076
  let r = e[t];
1603
2077
  return r && typeof r.value[0] == "string" ? r.value[0] : n;
1604
2078
  }
1605
- function fn(e, t, n) {
2079
+ function J(e, t, n) {
1606
2080
  let r = e[t]?.value?.[0];
1607
2081
  return r === void 0 ? n : r === !0 || r === "true";
1608
2082
  }
1609
- async function Q(e, t, n, r = null) {
2083
+ async function Y(e, t, n, r = null) {
1610
2084
  let i = e[t];
1611
2085
  if (!i) return {
1612
2086
  rgb: r,
@@ -1645,14 +2119,14 @@ async function Q(e, t, n, r = null) {
1645
2119
  };
1646
2120
  }
1647
2121
  if (i.type === "blackbody") return {
1648
- rgb: dn(i.value[0]),
2122
+ rgb: vn(i.value[0]),
1649
2123
  texture: null
1650
2124
  };
1651
2125
  if (i.type === "spectrum") {
1652
2126
  if (typeof i.value[0] == "string") {
1653
- let e = pn(i.value[0]);
1654
- return e && ln[e] ? {
1655
- rgb: ln[e].slice(),
2127
+ let e = yn(i.value[0]);
2128
+ return e && gn[e] ? {
2129
+ rgb: gn[e].slice(),
1656
2130
  texture: null
1657
2131
  } : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
1658
2132
  rgb: [
@@ -1680,34 +2154,92 @@ async function Q(e, t, n, r = null) {
1680
2154
  texture: null
1681
2155
  };
1682
2156
  }
1683
- function pn(e) {
2157
+ function yn(e) {
1684
2158
  let t = e.toLowerCase().match(/metal-([a-z]+)/);
1685
2159
  if (t) return t[1];
1686
- for (let t of Object.keys(ln)) if (e.toLowerCase().includes(t)) return t;
2160
+ for (let t of Object.keys(gn)) if (e.toLowerCase().includes(t)) return t;
1687
2161
  return null;
1688
2162
  }
1689
- async function mn(e, t, n) {
2163
+ async function bn(e, t, n) {
1690
2164
  let r = e[t];
1691
2165
  return r ? typeof r.value[0] == "number" ? r.value[0] : r.type === "texture" ? await n.floatTextureMean?.(r.value[0]) ?? null : null : null;
1692
2166
  }
1693
- async function hn(e, t, n, r = "") {
1694
- let i = e.remaproughness?.value?.[0], a = (e) => i === !1 || i === "false" ? e : Math.sqrt(Math.max(e, 0)), o = null, s = await mn(e, `${r}roughness`, n);
2167
+ var xn = (e) => {
2168
+ let t = e.remaproughness?.value?.[0];
2169
+ return t !== !1 && t !== "false";
2170
+ };
2171
+ async function Sn(e, t, n, r = "") {
2172
+ let i = xn(e), a = (e) => i ? Math.sqrt(Math.max(e, 0)) : e, o = null, s = await bn(e, `${r}roughness`, n);
1695
2173
  if (s !== null) o = a(s);
1696
2174
  else {
1697
- let t = await mn(e, `${r}uroughness`, n), i = await mn(e, `${r}vroughness`, n);
2175
+ let t = await bn(e, `${r}uroughness`, n), i = await bn(e, `${r}vroughness`, n);
1698
2176
  t !== null && (o = i === null ? a(t) : (a(t) + a(i)) / 2);
1699
2177
  }
1700
2178
  return o === null ? t : Math.sqrt(Math.max(o, 0));
1701
2179
  }
1702
- async function gn(e, t, n, r, i, a) {
1703
- let o = await Q(t, "reflectance", n, null), s = t[`${r}eta`], c = t[`${r}k`], l = s && s.type === "spectrum" && typeof s.value[0] == "string";
2180
+ async function X(e, t, n, r, i, a = "") {
2181
+ let o = n[`${a}roughness`] ? [`${a}roughness`] : [`${a}uroughness`, `${a}vroughness`].filter((e) => n[e]);
2182
+ if (i.bakeFloatMap && o.some((e) => n[e].type === "texture")) {
2183
+ let r = xn(n), a = (e) => r ? Math.sqrt(Math.max(e, 0)) : Math.max(e, 0), s = await i.bakeFloatMap(n, o, (e) => Math.sqrt(e.reduce((e, t) => e + a(t), 0) / e.length));
2184
+ if (s) {
2185
+ e[`${t}Map`] = s, e[t] = 1;
2186
+ return;
2187
+ }
2188
+ }
2189
+ e[t] = await Sn(n, r, i, a);
2190
+ }
2191
+ async function Cn(e, t, n, r) {
2192
+ let i = e[t];
2193
+ return i?.type === "texture" ? await n.textureMeanRGB?.(i.value[0]) ?? r : (await Y(e, t, n, r)).rgb ?? r;
2194
+ }
2195
+ var wn = [
2196
+ .0011,
2197
+ .0024,
2198
+ .014
2199
+ ], Tn = [
2200
+ 2.55,
2201
+ 3.21,
2202
+ 3.77
2203
+ ];
2204
+ async function En(e, t, n) {
2205
+ let r = K(t, "eta", 1.33), i = K(t, "scale", 1), a = (e) => e.map((e) => Math.max(0, e * i)), o = K(t, "g", 0), s, c, l = q(t, "name", ""), u = l ? pn(l) : null;
2206
+ if (l && !u && n.warn(`subsurface: no medium named "${l}" — using pbrt's default`), u) s = a(u.sigmaA), c = a(u.sigmaS), o = 0;
2207
+ else if (t.sigma_a && t.sigma_s) s = a(await Cn(t, "sigma_a", n, wn)), c = a(await Cn(t, "sigma_s", n, Tn));
2208
+ else if (t.reflectance && !l) {
2209
+ let e = await Cn(t, "reflectance", n, [
2210
+ .5,
2211
+ .5,
2212
+ .5
2213
+ ]), i = a(t.mfp ? await Cn(t, "mfp", n, [
2214
+ 1,
2215
+ 1,
2216
+ 1
2217
+ ]) : [
2218
+ 1,
2219
+ 1,
2220
+ 1
2221
+ ]);
2222
+ s = [], c = [];
2223
+ for (let t = 0; t < 3; t++) {
2224
+ let n = 1 / Math.max(i[t], 1e-9), a = hn(e[t], r);
2225
+ c[t] = a * n / (1 - o + a * o), s[t] = n - c[t];
2226
+ }
2227
+ } else s = a(wn), c = a(Tn);
2228
+ let d = s.map((e, t) => e + c[t]);
2229
+ e.subsurface = 1, e.subsurfaceColor = new y(...d.map((e, t) => e > 0 ? c[t] / e : 0)), e.subsurfaceRadius = d.map((e) => e > 0 ? 1 / e : 1e6), e.subsurfaceRadiusScale = 1, e.subsurfaceAnisotropy = Math.max(-.99, Math.min(.99, o)), e.ior = r, e.metalness = 0, e.color.setRGB(...d.map((e, t) => {
2230
+ let n = (1 - o) * c[t];
2231
+ return e > 0 ? mn(n / (s[t] + n), r) : 0;
2232
+ })), await X(e, "roughness", t, 0, n);
2233
+ }
2234
+ async function Dn(e, t, n, r, i, a) {
2235
+ let o = await Y(t, "reflectance", n, null), s = t[`${r}eta`], c = t[`${r}k`], l = s && s.type === "spectrum" && typeof s.value[0] == "string";
1704
2236
  if (o.rgb || o.texture) i(o);
1705
2237
  else if (s && c && !l) {
1706
- let e = (await Q(t, `${r}eta`, n, [
2238
+ let e = (await Y(t, `${r}eta`, n, [
1707
2239
  .2,
1708
2240
  .92,
1709
2241
  1.1
1710
- ])).rgb, i = (await Q(t, `${r}k`, n, [
2242
+ ])).rgb, i = (await Y(t, `${r}k`, n, [
1711
2243
  3.9,
1712
2244
  2.45,
1713
2245
  2.14
@@ -1717,10 +2249,10 @@ async function gn(e, t, n, r, i, a) {
1717
2249
  o(e[1], i[1]),
1718
2250
  o(e[2], i[2])
1719
2251
  ]);
1720
- } else a(s ? (await Q(t, `${r}eta`, n, un)).rgb || un : ln.cu);
2252
+ } else a(s ? (await Y(t, `${r}eta`, n, _n)).rgb || _n : gn.cu);
1721
2253
  e.metalness = 1;
1722
2254
  }
1723
- async function _n(e, t) {
2255
+ async function On(e, t) {
1724
2256
  let n = e?.type || "diffuse", r = e?.params || {}, i = new te({
1725
2257
  side: S,
1726
2258
  roughness: 1,
@@ -1732,7 +2264,7 @@ async function _n(e, t) {
1732
2264
  };
1733
2265
  switch (n) {
1734
2266
  case "diffuse":
1735
- o(await Q(r, "reflectance", t, [
2267
+ o(await Y(r, "reflectance", t, [
1736
2268
  .5,
1737
2269
  .5,
1738
2270
  .5
@@ -1740,24 +2272,24 @@ async function _n(e, t) {
1740
2272
  break;
1741
2273
  case "conductor":
1742
2274
  case "metal":
1743
- await gn(i, r, t, "", o, a), i.roughness = await hn(r, .1, t);
2275
+ await Dn(i, r, t, "", o, a), await X(i, "roughness", r, .1, t);
1744
2276
  break;
1745
2277
  case "coatedconductor":
1746
- await gn(i, r, t, "conductor.", o, a), i.roughness = await hn(r, 0, t, "conductor."), i.clearcoat = 1, i.clearcoatRoughness = await hn(r, 0, t, "interface.");
2278
+ await Dn(i, r, t, "conductor.", o, a), await X(i, "roughness", r, 0, t, "conductor."), i.clearcoat = 1, await X(i, "clearcoatRoughness", r, 0, t, "interface.");
1747
2279
  break;
1748
2280
  case "dielectric":
1749
2281
  case "thindielectric":
1750
- i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = X(r, "eta", 1.5), i.roughness = await hn(r, 0, t), i.thickness = n === "thindielectric" ? 0 : X(r, "thickness", 0);
2282
+ i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = K(r, "eta", 1.5), await X(i, "roughness", r, 0, t), i.thickness = n === "thindielectric" ? 0 : K(r, "thickness", 0);
1751
2283
  break;
1752
2284
  case "coateddiffuse":
1753
- o(await Q(r, "reflectance", t, [
2285
+ o(await Y(r, "reflectance", t, [
1754
2286
  .5,
1755
2287
  .5,
1756
2288
  .5
1757
- ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = await hn(r, 0, t);
2289
+ ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, await X(i, "clearcoatRoughness", r, 0, t);
1758
2290
  break;
1759
2291
  case "diffusetransmission": {
1760
- let e = X(r, "scale", 1), n = (t) => Math.min(1, Math.max(0, e * t)), a = await Q(r, "transmittance", t, [
2292
+ let e = K(r, "scale", 1), n = (t) => Math.min(1, Math.max(0, e * t)), a = await Y(r, "transmittance", t, [
1761
2293
  .25,
1762
2294
  .25,
1763
2295
  .25
@@ -1765,7 +2297,7 @@ async function _n(e, t) {
1765
2297
  .5,
1766
2298
  .5,
1767
2299
  .5
1768
- ], c = Math.min(.99, Math.max(...s)), l = await Q(r, "reflectance", t, [
2300
+ ], c = Math.min(.99, Math.max(...s)), l = await Y(r, "reflectance", t, [
1769
2301
  .25,
1770
2302
  .25,
1771
2303
  .25
@@ -1786,9 +2318,9 @@ async function _n(e, t) {
1786
2318
  i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
1787
2319
  break;
1788
2320
  case "mix": {
1789
- let e = r.materials?.value || [], n = Math.max(0, Math.min(1, X(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
2321
+ let e = r.materials?.value || [], n = Math.max(0, Math.min(1, K(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
1790
2322
  if (a && o) {
1791
- let [e, s] = await Promise.all([_n(a, t), _n(o, t)]), c = r.amount, l = c?.type === "texture" ? await t.bakeMaterialMix?.(e, s, c.value[0]) : null;
2323
+ let [e, s] = await Promise.all([On(a, t), On(o, t)]), c = r.amount, l = c?.type === "texture" ? await t.bakeMaterialMix?.(e, s, c.value[0]) : null;
1792
2324
  l && (n = l.mean);
1793
2325
  let u = (e, t) => e * (1 - n) + t * n;
1794
2326
  i.color.lerpColors(e.color, s.color, n), i.roughness = u(e.roughness, s.roughness), i.metalness = u(e.metalness, s.metalness), i.ior = u(e.ior ?? 1.5, s.ior ?? 1.5), i.transmission = u(e.transmission ?? 0, s.transmission ?? 0), i.thickness = u(e.thickness ?? 0, s.thickness ?? 0), i.clearcoat = u(e.clearcoat ?? 0, s.clearcoat ?? 0), i.clearcoatRoughness = u(e.clearcoatRoughness ?? 0, s.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, s.emissive, n);
@@ -1800,9 +2332,11 @@ async function _n(e, t) {
1800
2332
  break;
1801
2333
  }
1802
2334
  case "subsurface":
2335
+ await En(i, r, t);
2336
+ break;
1803
2337
  case "hair":
1804
2338
  case "measured":
1805
- t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Q(r, "reflectance", t, [
2339
+ t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Y(r, "reflectance", t, [
1806
2340
  .5,
1807
2341
  .5,
1808
2342
  .5
@@ -1812,21 +2346,21 @@ async function _n(e, t) {
1812
2346
  t.warn(`unknown material "${n}" — using neutral diffuse`), i.color.set(new y(.6, .6, .6));
1813
2347
  break;
1814
2348
  }
1815
- let s = Z(r, "normalmap", null);
2349
+ let s = q(r, "normalmap", null);
1816
2350
  return s && t.resolveNormalMap && (i.normalMap = await t.resolveNormalMap(s)), i.roughness = Math.max(0, Math.min(1, i.roughness)), i;
1817
2351
  }
1818
2352
  //#endregion
1819
2353
  //#region src/Processor/PBRT/PBRTTextureBake.js
1820
- var vn = 4096, yn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, bn = (e) => e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
1821
- function xn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, mapping: a = null }) {
1822
- let { width: o, height: s } = e, c = e.channels ?? 4, l = new Float32Array(o * s * t), u = e.topDown !== !1;
1823
- for (let a = 0; a < s; a++) {
1824
- let d = u ? a : s - 1 - a;
1825
- for (let s = 0; s < o; s++) {
1826
- let u = (d * o + s) * c, f = (a * o + s) * t;
1827
- for (let a = 0; a < t; a++) {
1828
- let t = e.data[u + Math.min(a, c - 1)], o = r * (n ? n(t / 255) : t);
1829
- l[f + a] = i ? Math.max(0, 1 - o) : o;
2354
+ var kn = 4096, An = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, jn = (e) => e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
2355
+ function Mn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, mapping: a = null }) {
2356
+ let { width: o, height: s } = e, c = e.channels ?? 4, l = new Float32Array(o * s * t), u = e.topDown !== !1, d = (t) => n ? n(e.data[t] / 255) : e.data[t], f = t === 1 && c === 4 && Nn(e), p = t === 1 && c >= 3 && !f;
2357
+ for (let e = 0; e < s; e++) {
2358
+ let n = u ? e : s - 1 - e;
2359
+ for (let a = 0; a < o; a++) {
2360
+ let s = (n * o + a) * c, u = (e * o + a) * t;
2361
+ for (let e = 0; e < t; e++) {
2362
+ let t = r * (f ? d(s + 3) : p ? (d(s) + d(s + 1) + d(s + 2)) / 3 : d(s + Math.min(e, c - 1)));
2363
+ l[u + e] = i ? Math.max(0, 1 - t) : t;
1830
2364
  }
1831
2365
  }
1832
2366
  }
@@ -1842,12 +2376,17 @@ function xn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, ma
1842
2376
  ...a
1843
2377
  };
1844
2378
  }
1845
- function Sn(e) {
2379
+ function Nn(e) {
2380
+ let { data: t } = e, n = e.float ? 1 : 255;
2381
+ for (let e = 3; e < t.length; e += 4) if (t[e] !== n) return !0;
2382
+ return !1;
2383
+ }
2384
+ function Pn(e) {
1846
2385
  let t = 0;
1847
2386
  for (let n = 0; n < e.data.length; n++) t += e.data[n];
1848
2387
  return e.data.length ? t / e.data.length : 0;
1849
2388
  }
1850
- function Cn(e, t, n, r) {
2389
+ function Fn(e, t, n, r) {
1851
2390
  let { width: i, height: a, channels: o, data: s } = e, c = t * i - .5, l = (1 - n) * a - .5, u = Math.floor(c), d = Math.floor(l), f = c - u, p = l - d, m = (e, t) => (e % t + t) % t, h = m(u, i), g = m(u + 1, i), _ = m(d, a), v = m(d + 1, a);
1852
2391
  for (let e = 0; e < 3; e++) {
1853
2392
  let t = Math.min(e, o - 1), n = s[(_ * i + h) * o + t] * (1 - f) + s[(_ * i + g) * o + t] * f, a = s[(v * i + h) * o + t] * (1 - f) + s[(v * i + g) * o + t] * f;
@@ -1855,45 +2394,48 @@ function Cn(e, t, n, r) {
1855
2394
  }
1856
2395
  return r;
1857
2396
  }
1858
- function wn(e, t) {
1859
- let n = null;
1860
- for (let t of e) t.layer && (!n || t.layer.width * t.layer.height > n.width * n.height) && (n = t.layer);
1861
- if (!n) return null;
1862
- let r = Math.min(n.width, vn), i = Math.min(n.height, vn), a = new Uint8Array(r * i * 4), o = e.map(() => [
2397
+ function Z(e, t, { alphaOf: n = null, linear: r = !1 } = {}) {
2398
+ let i = null;
2399
+ for (let t of e) t.layer && (!i || t.layer.width * t.layer.height > i.width * i.height) && (i = t.layer);
2400
+ if (!i) return null;
2401
+ let a = Math.min(i.width, kn), o = Math.min(i.height, kn), s = new Uint8Array(a * o * 4), c = e.map(() => [
1863
2402
  0,
1864
2403
  0,
1865
2404
  0
1866
2405
  ]);
1867
- for (let s = 0; s < i; s++) {
1868
- let c = (s + .5) / i, l = (c - n.dv) / n.sv;
1869
- for (let i = 0; i < r; i++) {
1870
- let u = (i + .5) / r, d = (u - n.du) / n.su;
2406
+ for (let l = 0; l < o; l++) {
2407
+ let u = (l + .5) / o, d = (u - i.dv) / i.sv;
2408
+ for (let o = 0; o < a; o++) {
2409
+ let f = (o + .5) / a, p = (f - i.du) / i.su;
1871
2410
  for (let t = 0; t < e.length; t++) {
1872
- let r = e[t], i = o[t];
1873
- if (r.layer) {
1874
- let e = r.layer;
1875
- if (Cn(e, e === n ? u : e.su * d + e.du, e === n ? c : e.sv * l + e.dv, i), r.tint) for (let e = 0; e < 3; e++) i[e] *= r.tint[e];
1876
- } else i[0] = r.rgb[0], i[1] = r.rgb[1], i[2] = r.rgb[2];
1877
- if (r.clamp) for (let e = 0; e < 3; e++) i[e] = Math.min(1, Math.max(0, i[e]));
2411
+ let n = e[t], r = c[t];
2412
+ if (n.layer) {
2413
+ let e = n.layer;
2414
+ if (Fn(e, e === i ? f : e.su * p + e.du, e === i ? u : e.sv * d + e.dv, r), n.tint) for (let e = 0; e < 3; e++) r[e] *= n.tint[e];
2415
+ } else r[0] = n.rgb[0], r[1] = n.rgb[1], r[2] = n.rgb[2];
2416
+ if (n.clamp) for (let e = 0; e < 3; e++) r[e] = Math.min(1, Math.max(0, r[e]));
2417
+ }
2418
+ let m = t(c), h = (l * a + o) * 4;
2419
+ for (let e = 0; e < 3; e++) {
2420
+ let t = Math.min(1, Math.max(0, m[e]));
2421
+ s[h + e] = Math.round(255 * (r ? t : jn(t)));
1878
2422
  }
1879
- let f = t(o), p = (s * r + i) * 4;
1880
- for (let e = 0; e < 3; e++) a[p + e] = Math.round(255 * bn(Math.min(1, Math.max(0, f[e]))));
1881
- a[p + 3] = 255;
2423
+ s[h + 3] = n ? Math.round(255 * Math.min(1, Math.max(0, n(c)))) : 255;
1882
2424
  }
1883
2425
  }
1884
2426
  return {
1885
- data: a,
1886
- width: r,
1887
- height: i,
2427
+ data: s,
2428
+ width: a,
2429
+ height: o,
1888
2430
  mapping: {
1889
- su: n.su,
1890
- sv: n.sv,
1891
- du: n.du,
1892
- dv: n.dv
2431
+ su: i.su,
2432
+ sv: i.sv,
2433
+ du: i.du,
2434
+ dv: i.dv
1893
2435
  }
1894
2436
  };
1895
2437
  }
1896
- var Tn = ([e, t, n]) => {
2438
+ var In = ([e, t, n]) => {
1897
2439
  let r = n[0];
1898
2440
  return [
1899
2441
  e[0] + (t[0] - e[0]) * r,
@@ -1903,13 +2445,13 @@ var Tn = ([e, t, n]) => {
1903
2445
  };
1904
2446
  //#endregion
1905
2447
  //#region src/Processor/PBRT/LoopSubdivision.js
1906
- function En(e) {
2448
+ function Ln(e) {
1907
2449
  return e === 3 ? 3 / 16 : 3 / (8 * e);
1908
2450
  }
1909
- function Dn(e) {
1910
- return 1 / (e + 3 / (8 * En(e)));
2451
+ function Rn(e) {
2452
+ return 1 / (e + 3 / (8 * Ln(e)));
1911
2453
  }
1912
- function On(e, t) {
2454
+ function zn(e, t) {
1913
2455
  let n = /* @__PURE__ */ new Map(), r = [], i = [], a = [], o = [], s = [], c = t.length / 3;
1914
2456
  for (let l = 0; l < c; l++) for (let c = 0; c < 3; c++) {
1915
2457
  let u = t[l * 3 + c], d = t[l * 3 + (c + 1) % 3], f = t[l * 3 + (c + 2) % 3], p = u < d ? u : d, m = u < d ? d : u, h = p * e + m, g = n.get(h);
@@ -1931,7 +2473,7 @@ function On(e, t) {
1931
2473
  boundaryRing: u
1932
2474
  };
1933
2475
  }
1934
- function kn(e, t, n, r, i) {
2476
+ function Bn(e, t, n, r, i) {
1935
2477
  let a = new Float64Array(e.length);
1936
2478
  for (let o = 0; o < n; o++) {
1937
2479
  let n = o * 3, s = t.boundaryRing[o];
@@ -1955,8 +2497,8 @@ function kn(e, t, n, r, i) {
1955
2497
  }
1956
2498
  return a;
1957
2499
  }
1958
- function An(e, t) {
1959
- let n = e.length / 3, r = On(n, t), i = r.edgeV0.length, a = kn(e, r, n, En, 1 / 8), o = new Float64Array((n + i) * 3);
2500
+ function Vn(e, t) {
2501
+ let n = e.length / 3, r = zn(n, t), i = r.edgeV0.length, a = Bn(e, r, n, Ln, 1 / 8), o = new Float64Array((n + i) * 3);
1960
2502
  o.set(a);
1961
2503
  for (let t = 0; t < i; t++) {
1962
2504
  let i = r.edgeV0[t] * 3, a = r.edgeV1[t] * 3, s = (n + t) * 3, c = r.edgeOpp1[t];
@@ -1976,13 +2518,13 @@ function An(e, t) {
1976
2518
  indices: c
1977
2519
  };
1978
2520
  }
1979
- function jn(e, t, n, r = 2e6) {
2521
+ function Hn(e, t, n, r = 2e6) {
1980
2522
  let i = Float64Array.from(e), a = Int32Array.from(t), o = 0;
1981
2523
  for (let e = 0; e < n && !(a.length / 3 * 4 > r); e++) {
1982
- let e = An(i, a);
2524
+ let e = Vn(i, a);
1983
2525
  i = e.positions, a = e.indices, o++;
1984
2526
  }
1985
- let s = i.length / 3, c = kn(i, On(s, a), s, Dn, 1 / 5);
2527
+ let s = i.length / 3, c = Bn(i, zn(s, a), s, Rn, 1 / 5);
1986
2528
  return {
1987
2529
  positions: Float32Array.from(c),
1988
2530
  indices: Uint32Array.from(a),
@@ -1991,7 +2533,7 @@ function jn(e, t, n, r = 2e6) {
1991
2533
  }
1992
2534
  //#endregion
1993
2535
  //#region src/Processor/PBRT/EqualAreaOctahedral.js
1994
- function Mn(e, t, n) {
2536
+ function Un(e, t, n) {
1995
2537
  let r = Math.abs(e), i = Math.abs(t), a = Math.sqrt(Math.max(0, 1 - Math.abs(n))), o = Math.max(r, i), s = o === 0 ? 0 : Math.min(r, i) / o, c = 2 / Math.PI * Math.atan(s);
1996
2538
  r < i && (c = 1 - c);
1997
2539
  let l = c * a, u = a - l;
@@ -2001,7 +2543,7 @@ function Mn(e, t, n) {
2001
2543
  }
2002
2544
  return e < 0 && (u = -u), t < 0 && (l = -l), [.5 * (u + 1), .5 * (l + 1)];
2003
2545
  }
2004
- var Nn = (() => {
2546
+ var Wn = (() => {
2005
2547
  let e = new Float32Array(256);
2006
2548
  for (let t = 0; t < 256; t++) {
2007
2549
  let n = t / 255;
@@ -2009,15 +2551,15 @@ var Nn = (() => {
2009
2551
  }
2010
2552
  return e;
2011
2553
  })();
2012
- function Pn(e, t, n, r, i, a, o, s) {
2554
+ function Gn(e, t, n, r, i, a, o, s) {
2013
2555
  let c = Math.min(Math.max(i * t - .5, 0), t - 1), l = Math.min(Math.max(a * n - .5, 0), n - 1), u = Math.floor(c), d = Math.floor(l), f = Math.min(u + 1, t - 1), p = Math.min(d + 1, n - 1), m = c - u, h = l - d, g = (d * t + u) * r, _ = (d * t + f) * r, v = (p * t + u) * r, y = (p * t + f) * r;
2014
2556
  for (let t = 0; t < 3; t++) {
2015
2557
  let n = s ? s[e[g + t]] : e[g + t], r = s ? s[e[_ + t]] : e[_ + t], i = s ? s[e[v + t]] : e[v + t], a = s ? s[e[y + t]] : e[y + t], c = n * (1 - m) + r * m, l = i * (1 - m) + a * m;
2016
2558
  o[t] = c * (1 - h) + l * h;
2017
2559
  }
2018
2560
  }
2019
- function Fn(e, t, n = 1, r = 0) {
2020
- let i = r || Math.min(e.width, 4096), a = Math.max(1, i >> 1), o = new Float32Array(i * a * 4), s = t ? J(t) : null, c = e.srgb ? Nn : null, l = [
2561
+ function Kn(e, t, n = 1, r = 0) {
2562
+ let i = r || Math.min(e.width, 4096), a = Math.max(1, i >> 1), o = new Float32Array(i * a * 4), s = t ? W(t) : null, c = e.srgb ? Wn : null, l = [
2021
2563
  0,
2022
2564
  0,
2023
2565
  0
@@ -2030,8 +2572,8 @@ function Fn(e, t, n = 1, r = 0) {
2030
2572
  let e = s, t = e[0] * f + e[4] * p + e[8] * m, n = e[1] * f + e[5] * p + e[9] * m, r = e[2] * f + e[6] * p + e[10] * m, i = Math.hypot(t, n, r) || 1;
2031
2573
  f = t / i, p = n / i, m = r / i;
2032
2574
  }
2033
- let [h, g] = Mn(f, p, m);
2034
- Pn(e.data, e.width, e.height, e.channels, h, e.bottomUp ? 1 - g : g, l, c);
2575
+ let [h, g] = Un(f, p, m);
2576
+ Gn(e.data, e.width, e.height, e.channels, h, e.bottomUp ? 1 - g : g, l, c);
2035
2577
  let _ = (t * i + r) * 4;
2036
2578
  o[_] = l[0] * n, o[_ + 1] = l[1] * n, o[_ + 2] = l[2] * n, o[_ + 3] = 1;
2037
2579
  }
@@ -2044,31 +2586,31 @@ function Fn(e, t, n = 1, r = 0) {
2044
2586
  }
2045
2587
  //#endregion
2046
2588
  //#region src/Processor/PBRT/PBRTCurves.js
2047
- var In = 2;
2048
- function Ln(e, t) {
2589
+ var qn = 2;
2590
+ function Jn(e, t) {
2049
2591
  let n = e * e, r = n * e;
2050
2592
  t[0] = (1 - 3 * e + 3 * n - r) / 6, t[1] = (4 - 6 * n + 3 * r) / 6, t[2] = (1 + 3 * e + 3 * n - 3 * r) / 6, t[3] = r / 6;
2051
2593
  }
2052
- function Rn(e, t) {
2594
+ function Yn(e, t) {
2053
2595
  let n = 1 - e;
2054
2596
  t[0] = n * n * n, t[1] = 3 * n * n * e, t[2] = 3 * n * e * e, t[3] = e * e * e;
2055
2597
  }
2056
- function zn(e) {
2598
+ function Xn(e) {
2057
2599
  let t = Math.hypot(e[0], e[1], e[2]);
2058
2600
  return t > 0 && (e[0] /= t, e[1] /= t, e[2] /= t), e;
2059
2601
  }
2060
- function Bn(e, t, n) {
2602
+ function Zn(e, t, n) {
2061
2603
  return n[0] = e[1] * t[2] - e[2] * t[1], n[1] = e[2] * t[0] - e[0] * t[2], n[2] = e[0] * t[1] - e[1] * t[0], n;
2062
2604
  }
2063
- function Vn(e, t) {
2605
+ function Qn(e, t) {
2064
2606
  let n = e.length / 3;
2065
2607
  return t === "bspline" ? n - 3 : Math.max(1, (n - 1) / 3);
2066
2608
  }
2067
- function Hn(e, t, n, r, i, a, o) {
2609
+ function $n(e, t, n, r, i, a, o) {
2068
2610
  let s = Math.floor(r);
2069
2611
  s >= n && (s = n - 1);
2070
2612
  let c = r - s;
2071
- t === "bspline" ? Ln(c, i) : Rn(c, i);
2613
+ t === "bspline" ? Jn(c, i) : Yn(c, i);
2072
2614
  let l = t === "bspline" ? s : s * 3, u = 0, d = 0, f = 0;
2073
2615
  for (let t = 0; t < 4; t++) {
2074
2616
  let n = (l + t) * 3;
@@ -2076,8 +2618,8 @@ function Hn(e, t, n, r, i, a, o) {
2076
2618
  }
2077
2619
  a[o] = u, a[o + 1] = d, a[o + 2] = f;
2078
2620
  }
2079
- function Un(e, t, n) {
2080
- let r = Vn(e, t);
2621
+ function er(e, t, n) {
2622
+ let r = Qn(e, t);
2081
2623
  if (r < 1) return null;
2082
2624
  let i = Math.max(1, Math.round(n * r)), a = new Float64Array((i + 1) * 3), o = [
2083
2625
  0,
@@ -2085,18 +2627,18 @@ function Un(e, t, n) {
2085
2627
  0,
2086
2628
  0
2087
2629
  ];
2088
- for (let n = 0; n <= i; n++) Hn(e, t, r, n / i * r, o, a, n * 3);
2630
+ for (let n = 0; n <= i; n++) $n(e, t, r, n / i * r, o, a, n * 3);
2089
2631
  return {
2090
2632
  points: a,
2091
2633
  count: i + 1,
2092
2634
  spans: r
2093
2635
  };
2094
2636
  }
2095
- function Wn(e, t, n, r, i) {
2637
+ function tr(e, t, n, r, i) {
2096
2638
  let a = e[t * 3], o = e[t * 3 + 1], s = e[t * 3 + 2], c = n[r * 3], l = n[r * 3 + 1], u = n[r * 3 + 2], d = n[i * 3] - c, f = n[i * 3 + 1] - l, p = n[i * 3 + 2] - u, m = d * d + f * f + p * p, h = m > 0 ? ((a - c) * d + (o - l) * f + (s - u) * p) / m : 0;
2097
2639
  return h = h < 0 ? 0 : h > 1 ? 1 : h, Math.hypot(a - c - h * d, o - l - h * f, s - u - h * p);
2098
2640
  }
2099
- function Gn(e, t, n, r, i, a) {
2641
+ function nr(e, t, n, r, i, a) {
2100
2642
  let { points: o, count: s, spans: c } = n;
2101
2643
  if (s < 3) return null;
2102
2644
  let l = new Float64Array((s - 1) * 3), u = [
@@ -2105,12 +2647,12 @@ function Gn(e, t, n, r, i, a) {
2105
2647
  0,
2106
2648
  0
2107
2649
  ], d = s - 1;
2108
- for (let n = 0; n < d; n++) Hn(e, t, c, (n + .5) / d * c, u, l, n * 3);
2650
+ for (let n = 0; n < d; n++) $n(e, t, c, (n + .5) / d * c, u, l, n * 3);
2109
2651
  let f = 0;
2110
- for (let e = 0; e < d; e++) f = Math.max(f, Wn(l, e, o, e, e + 1));
2652
+ for (let e = 0; e < d; e++) f = Math.max(f, tr(l, e, o, e, e + 1));
2111
2653
  let p = (e) => Math.max(f, r * .5 * (i + (a - i) * (e / d))), m = (e, t) => {
2112
- for (let n = e + 1; n < t; n++) if (Wn(o, n, o, e, t) > p(n)) return !1;
2113
- for (let n = e; n < t; n++) if (Wn(l, n, o, e, t) > p(n + .5)) return !1;
2654
+ for (let n = e + 1; n < t; n++) if (tr(o, n, o, e, t) > p(n)) return !1;
2655
+ for (let n = e; n < t; n++) if (tr(l, n, o, e, t) > p(n + .5)) return !1;
2114
2656
  return !0;
2115
2657
  }, h = new Int32Array(s), g = 0;
2116
2658
  h[g++] = 0;
@@ -2121,12 +2663,12 @@ function Gn(e, t, n, r, i, a) {
2121
2663
  }
2122
2664
  return g === s ? null : h.subarray(0, g);
2123
2665
  }
2124
- function Kn(e) {
2125
- let { P: t, basis: n = "bezier", width0: r = 1, width1: i = 1, N: a = null } = e, o = Math.max(1, Math.round(e.steps ?? In)), s = Math.max(1, Math.round(e.sides ?? 1));
2666
+ function rr(e) {
2667
+ let { P: t, basis: n = "bezier", width0: r = 1, width1: i = 1, N: a = null } = e, o = Math.max(1, Math.round(e.steps ?? qn)), s = Math.max(1, Math.round(e.sides ?? 1));
2126
2668
  if (!t || t.length < 12) return null;
2127
- let c = Un(t, n, o);
2669
+ let c = er(t, n, o);
2128
2670
  if (!c) return null;
2129
- let { points: l, count: u } = c, d = e.tolerance > 0 ? Gn(t, n, c, e.tolerance, r, i) : null, f = d ? d.length : u, p = s >= 3 ? s : s * 2, m = new Float32Array(f * p * 3), h = [
2671
+ let { points: l, count: u } = c, d = e.tolerance > 0 ? nr(t, n, c, e.tolerance, r, i) : null, f = d ? d.length : u, p = s >= 3 ? s : s * 2, m = new Float32Array(f * p * 3), h = [
2130
2672
  0,
2131
2673
  0,
2132
2674
  0
@@ -2145,18 +2687,18 @@ function Kn(e) {
2145
2687
  ], y = !1, b = 0;
2146
2688
  for (let e = 0; e < u; e++) {
2147
2689
  let t = Math.max(0, e - 1), n = Math.min(u - 1, e + 1);
2148
- if (h[0] = l[n * 3] - l[t * 3], h[1] = l[n * 3 + 1] - l[t * 3 + 1], h[2] = l[n * 3 + 2] - l[t * 3 + 2], zn(h), y) {
2690
+ if (h[0] = l[n * 3] - l[t * 3], h[1] = l[n * 3 + 1] - l[t * 3 + 1], h[2] = l[n * 3 + 2] - l[t * 3 + 2], Xn(h), y) {
2149
2691
  let e = g[0] * h[0] + g[1] * h[1] + g[2] * h[2];
2150
- g[0] -= e * h[0], g[1] -= e * h[1], g[2] -= e * h[2], Math.hypot(g[0], g[1], g[2]) < 1e-9 && Bn(h, [
2692
+ g[0] -= e * h[0], g[1] -= e * h[1], g[2] -= e * h[2], Math.hypot(g[0], g[1], g[2]) < 1e-9 && Zn(h, [
2151
2693
  0,
2152
2694
  1,
2153
2695
  0
2154
- ], g), zn(g);
2696
+ ], g), Xn(g);
2155
2697
  } else {
2156
- if (a && a.length >= 3) g[0] = a[0], g[1] = a[1], g[2] = a[2], Bn(h, g, v), g[0] = v[0], g[1] = v[1], g[2] = v[2];
2698
+ if (a && a.length >= 3) g[0] = a[0], g[1] = a[1], g[2] = a[2], Zn(h, g, v), g[0] = v[0], g[1] = v[1], g[2] = v[2];
2157
2699
  else {
2158
2700
  let e = Math.abs(h[0]), t = Math.abs(h[1]), n = Math.abs(h[2]);
2159
- Bn(h, e < t && e < n ? [
2701
+ Zn(h, e < t && e < n ? [
2160
2702
  1,
2161
2703
  0,
2162
2704
  0
@@ -2170,14 +2712,14 @@ function Kn(e) {
2170
2712
  1
2171
2713
  ], g);
2172
2714
  }
2173
- Math.hypot(g[0], g[1], g[2]) < 1e-9 && Bn(h, [
2715
+ Math.hypot(g[0], g[1], g[2]) < 1e-9 && Zn(h, [
2174
2716
  0,
2175
2717
  1,
2176
2718
  0
2177
- ], g), zn(g), y = !0;
2719
+ ], g), Xn(g), y = !0;
2178
2720
  }
2179
2721
  if (d && d[b] !== e) continue;
2180
- Bn(h, g, _), zn(_);
2722
+ Zn(h, g, _), Xn(_);
2181
2723
  let o = e / (u - 1 || 1), c = (r + (i - r) * o) * .5, f = l[e * 3], x = l[e * 3 + 1], S = l[e * 3 + 2];
2182
2724
  for (let e = 0; e < p; e++) {
2183
2725
  let t, n, r;
@@ -2200,24 +2742,24 @@ function Kn(e) {
2200
2742
  }
2201
2743
  return {
2202
2744
  positions: m,
2203
- indices: C === S.length ? S : U(S, C)
2745
+ indices: C === S.length ? S : B(S, C)
2204
2746
  };
2205
2747
  }
2206
2748
  //#endregion
2207
2749
  //#region src/Processor/PBRT/PBRTSceneBuilder.js
2208
- var qn = new Set([
2750
+ var ir = new Set([
2209
2751
  "distant",
2210
2752
  "point",
2211
2753
  "spot"
2212
2754
  ]);
2213
- async function Jn(e, t, n) {
2755
+ async function ar(e, t, n) {
2214
2756
  let r = e[t];
2215
2757
  if (r?.type === "spectrum" && typeof r.value[0] == "string" && r.value[0].startsWith("stdillum")) return [
2216
2758
  1,
2217
2759
  1,
2218
2760
  1
2219
2761
  ];
2220
- let i = (await Q(e, t, n, [
2762
+ let i = (await Y(e, t, n, [
2221
2763
  1,
2222
2764
  1,
2223
2765
  1
@@ -2230,7 +2772,7 @@ async function Jn(e, t, n) {
2230
2772
  let a = .2126 * i[0] + .7152 * i[1] + .0722 * i[2];
2231
2773
  return a > 0 ? i.map((e) => e / a) : i;
2232
2774
  }
2233
- var $ = [
2775
+ var Q = [
2234
2776
  1,
2235
2777
  0,
2236
2778
  0,
@@ -2247,31 +2789,31 @@ var $ = [
2247
2789
  0,
2248
2790
  0,
2249
2791
  1
2250
- ], Yn = 4096;
2251
- function Xn(e) {
2252
- return e instanceof Uint32Array ? new I(e, 1) : ArrayBuffer.isView(e) && e.BYTES_PER_ELEMENT === 4 ? new I(new Uint32Array(e.buffer, e.byteOffset, e.length), 1) : new I(Uint32Array.from(e), 1);
2792
+ ], or = 4096;
2793
+ function sr(e) {
2794
+ return e instanceof Uint32Array ? new F(e, 1) : ArrayBuffer.isView(e) && e.BYTES_PER_ELEMENT === 4 ? new F(new Uint32Array(e.buffer, e.byteOffset, e.length), 1) : new F(Uint32Array.from(e), 1);
2253
2795
  }
2254
- function Zn(e, t) {
2796
+ function cr(e, t) {
2255
2797
  if (t <= e.length) return e;
2256
2798
  let n = e.length || 1;
2257
2799
  for (; n < t;) n *= 2;
2258
- return U(e, n);
2800
+ return B(e, n);
2259
2801
  }
2260
- function Qn(e) {
2802
+ function lr(e) {
2261
2803
  return e instanceof Float32Array ? e : Float32Array.from(e);
2262
2804
  }
2263
- var $n = 1e3, er = 45e6, tr = 6e6, nr = 256, rr = 4096, ir = 5e5, ar = 2, or = {
2805
+ var ur = 1e3, dr = 45e6, fr = 6e6, pr = 256, mr = 4096, hr = 5e5, gr = 2, _r = {
2264
2806
  flat: 1,
2265
2807
  ribbon: 1,
2266
2808
  cylinder: 2
2267
- }, sr = .05;
2268
- function cr(e, t) {
2809
+ }, vr = .05;
2810
+ function yr(e, t) {
2269
2811
  if (e.count !== t.count) return !1;
2270
2812
  for (let n = 0, r = e.count * 16; n < r; n++) if (e.matrices[n] !== t.matrices[n]) return !1;
2271
2813
  return !0;
2272
2814
  }
2273
- function lr(e, t) {
2274
- let n = Math.min(e.width, Yn), r = null;
2815
+ function br(e, t) {
2816
+ let n = Math.min(e.width, or), r = null;
2275
2817
  if (typeof OffscreenCanvas < "u") r = new OffscreenCanvas(n, n);
2276
2818
  else if (typeof document < "u") r = document.createElement("canvas"), r.width = r.height = n;
2277
2819
  else return null;
@@ -2292,7 +2834,7 @@ function lr(e, t) {
2292
2834
  return null;
2293
2835
  }
2294
2836
  }
2295
- function ur(e) {
2837
+ function xr(e) {
2296
2838
  let t = e?.image;
2297
2839
  if (!t) return null;
2298
2840
  if (ArrayBuffer.isView(t.data)) return {
@@ -2323,39 +2865,157 @@ function ur(e) {
2323
2865
  return null;
2324
2866
  }
2325
2867
  }
2326
- function dr(e) {
2327
- let t = Z(e, "encoding", "sRGB");
2868
+ function Sr(e) {
2869
+ let t = q(e, "encoding", "sRGB");
2328
2870
  if (t === "linear") return (e) => e;
2329
2871
  let n = /^gamma\s+([\d.]+)$/.exec(t);
2330
- return n ? (e) => e ** Number(n[1]) : yn;
2872
+ return n ? (e) => e ** Number(n[1]) : An;
2331
2873
  }
2332
- function fr(e) {
2874
+ function Cr(e) {
2333
2875
  return {
2334
- su: X(e, "uscale", 1),
2335
- sv: X(e, "vscale", 1),
2336
- du: X(e, "udelta", 0),
2337
- dv: X(e, "vdelta", 0)
2876
+ su: K(e, "uscale", 1),
2877
+ sv: K(e, "vscale", 1),
2878
+ du: K(e, "udelta", 0),
2879
+ dv: K(e, "vdelta", 0)
2338
2880
  };
2339
2881
  }
2340
- function pr(e, { su: t, sv: n, du: r, dv: i }) {
2882
+ function wr(e, { su: t, sv: n, du: r, dv: i }) {
2341
2883
  e.repeat.set(t, n), e.offset.set(r, i);
2342
2884
  }
2343
- function mr(e, { srgb: t }) {
2885
+ function Tr(e, { srgb: t }) {
2344
2886
  let n = e?.image?.data;
2345
2887
  if (!ArrayBuffer.isView(n) || n instanceof Uint8Array || n instanceof Uint8ClampedArray) return e;
2346
2888
  let { width: r, height: i } = e.image, a = new Uint8Array(r * i * 4), o = n.length / (r * i);
2347
2889
  for (let e = 0; e < r * i; e++) for (let r = 0; r < 4; r++) {
2348
2890
  let i = r < o ? Math.min(1, Math.max(0, n[e * o + r])) : 1;
2349
- a[e * 4 + r] = Math.round(255 * (t && r < 3 ? bn(i) : i));
2891
+ a[e * 4 + r] = Math.round(255 * (t && r < 3 ? jn(i) : i));
2892
+ }
2893
+ let s = new b(a, r, i, ue);
2894
+ return s.flipY = e.flipY, s.colorSpace = t ? P : ne, s.wrapS = s.wrapT = de, s.needsUpdate = !0, s;
2895
+ }
2896
+ function $({ data: e, width: t, height: n, mapping: r }, { srgb: i = !0 } = {}) {
2897
+ let a = new b(e, t, n, ue);
2898
+ return a.colorSpace = i ? P : ne, a.wrapS = a.wrapT = de, wr(a, r), a.needsUpdate = !0, a;
2899
+ }
2900
+ function Er(e, t, n) {
2901
+ let r = e.isOrthographicCamera === !0, i = r ? 1 : Math.tan(e.fov * Math.PI / 360), a = r ? 50 : 12 / i;
2902
+ return {
2903
+ enableDOF: !0,
2904
+ focusDistance: n,
2905
+ aperture: a * .001 / (2 * t),
2906
+ focalLength: a,
2907
+ apertureScale: 1,
2908
+ anamorphicRatio: 1,
2909
+ dofBlur: t / (n * i),
2910
+ autoFocusMode: "manual",
2911
+ afScreenPoint: {
2912
+ x: .5,
2913
+ y: .5
2914
+ },
2915
+ orthoHeight: r ? (e.top - e.bottom) / e.zoom : null
2916
+ };
2917
+ }
2918
+ function Dr(e) {
2919
+ let t = {};
2920
+ return e.integrator?.maxdepth > 0 && (t.maxBounces = Math.round(e.integrator.maxdepth)), e.sampler?.pixelsamples > 0 && (t.samples = Math.round(e.sampler.pixelsamples)), e.film?.resolutionGiven && (t.width = e.film.xresolution, t.height = e.film.yresolution), Object.keys(t).length ? t : null;
2921
+ }
2922
+ var Or = 48;
2923
+ function kr(e) {
2924
+ let t = K(e, "radius", 1), n = K(e, "zmin", -t), r = K(e, "zmax", t), i = (e) => Math.min(t, Math.max(-t, e));
2925
+ return {
2926
+ radius: t,
2927
+ zMin: i(Math.min(n, r)),
2928
+ zMax: i(Math.max(n, r)),
2929
+ phiMax: Mr(e)
2930
+ };
2931
+ }
2932
+ function Ar(e) {
2933
+ let t = K(e, "zmin", -1), n = K(e, "zmax", 1);
2934
+ return {
2935
+ radius: K(e, "radius", 1),
2936
+ zMin: Math.min(t, n),
2937
+ zMax: Math.max(t, n),
2938
+ phiMax: Mr(e)
2939
+ };
2940
+ }
2941
+ function jr(e) {
2942
+ return {
2943
+ radius: K(e, "radius", 1),
2944
+ inner: K(e, "innerradius", 0),
2945
+ height: K(e, "height", 0),
2946
+ phiMax: Mr(e)
2947
+ };
2948
+ }
2949
+ var Mr = (e) => Math.min(360, Math.max(0, K(e, "phimax", 360))) * Math.PI / 180;
2950
+ function Nr(e, t, n) {
2951
+ let r = Math.max(3, Math.ceil(Or * e / (2 * Math.PI))), i = r + 1, a = new Float32Array(i * (t + 1) * 3), o = new Float32Array(a.length), s = new Float32Array(i * (t + 1) * 2), c = new I(), l = new I();
2952
+ for (let e = 0; e <= t; e++) for (let u = 0; u <= r; u++) {
2953
+ let d = e * i + u;
2954
+ n(u / r, e / t, c, l), c.toArray(a, d * 3), l.toArray(o, d * 3), s[d * 2] = u / r, s[d * 2 + 1] = e / t;
2955
+ }
2956
+ let u = 0;
2957
+ for (let e = 0; e < a.length; e++) u = Math.max(u, Math.abs(a[e]));
2958
+ let d = (e, t) => Math.hypot(a[e * 3] - a[t * 3], a[e * 3 + 1] - a[t * 3 + 1], a[e * 3 + 2] - a[t * 3 + 2]) > u * 1e-6, f = [];
2959
+ for (let e = 0; e < t; e++) for (let t = 0; t < r; t++) {
2960
+ let n = e * i + t, r = n + 1, a = n + i, o = a + 1;
2961
+ d(n, r) && f.push(n, r, o), d(a, o) && f.push(n, o, a);
2962
+ }
2963
+ let p = new v();
2964
+ return p.setAttribute("position", new w(a, 3)), p.setAttribute("normal", new w(o, 3)), p.setAttribute("uv", new w(s, 2)), p.setIndex(new F(new Uint32Array(f), 1)), p;
2965
+ }
2966
+ function Pr(e, t) {
2967
+ let n = e.params;
2968
+ switch (e.type) {
2969
+ case "sphere": {
2970
+ let { radius: e, zMin: t, zMax: r, phiMax: i } = kr(n);
2971
+ return i * e * (r - t);
2972
+ }
2973
+ case "cylinder": {
2974
+ let { radius: e, zMin: t, zMax: r, phiMax: i } = Ar(n);
2975
+ return i * e * (r - t);
2976
+ }
2977
+ case "disk": {
2978
+ let { radius: e, inner: t, phiMax: r } = jr(n);
2979
+ return r * .5 * (e * e - t * t);
2980
+ }
2350
2981
  }
2351
- let s = new b(a, r, i, P);
2352
- return s.flipY = e.flipY, s.colorSpace = t ? F : ne, s.wrapS = s.wrapT = ue, s.needsUpdate = !0, s;
2982
+ let r = new N().fromArray(e.ctm), i = t.getAttribute("position"), a = t.index, o = a ? a.count : i.count, s = new I(), c = new I(), l = new I(), u = 0;
2983
+ for (let e = 0; e + 2 < o; e += 3) s.fromBufferAttribute(i, a ? a.getX(e) : e).applyMatrix4(r), c.fromBufferAttribute(i, a ? a.getX(e + 1) : e + 1).applyMatrix4(r), l.fromBufferAttribute(i, a ? a.getX(e + 2) : e + 2).applyMatrix4(r), u += c.sub(s).cross(l.sub(s)).length() / 2;
2984
+ return u;
2985
+ }
2986
+ var Fr = 64, Ir = 64;
2987
+ function Lr(e, t, n) {
2988
+ let r = new Uint8Array(e * t * 4);
2989
+ for (let i = 0; i < t; i++) for (let a = 0; a < e; a++) {
2990
+ let o = n((a + .5) / e, (i + .5) / t), s = (i * e + a) * 4;
2991
+ for (let e = 0; e < 3; e++) r[s + e] = Math.round(255 * jn(Math.min(1, Math.max(0, o[e]))));
2992
+ r[s + 3] = 255;
2993
+ }
2994
+ return r;
2353
2995
  }
2354
- function hr({ data: e, width: t, height: n, mapping: r }) {
2355
- let i = new b(e, t, n, P);
2356
- return i.colorSpace = F, i.wrapS = i.wrapT = ue, pr(i, r), i.needsUpdate = !0, i;
2996
+ function Rr(e) {
2997
+ let t = e.clone();
2998
+ for (let n of Object.keys(e)) n in t || (t[n] = e[n]);
2999
+ return t;
3000
+ }
3001
+ function zr(e, t) {
3002
+ let n = Rr(e);
3003
+ return n.transparent = !0, n.opacity = e.opacity * t, n;
3004
+ }
3005
+ var Br = (e, { su: t, sv: n, du: r, dv: i }) => e.repeat.x === t && e.repeat.y === n && e.offset.x === r && e.offset.y === i;
3006
+ function Vr(e, t) {
3007
+ if (e.float || !Nn(e)) return null;
3008
+ let { data: n, width: r, height: i } = e, a = new Uint8Array(256);
3009
+ for (let e = 0; e < 256; e++) a[e] = Math.round(255 * Math.min(1, Math.max(0, t(e / 255))));
3010
+ let o = new Uint8Array(r * i * 4), s = r * 4;
3011
+ for (let t = 0; t < i; t++) {
3012
+ let r = (e.topDown ? i - 1 - t : t) * s, c = t * s;
3013
+ for (let e = 0; e < s; e += 4) o[c + e] = n[r + e], o[c + e + 1] = n[r + e + 1], o[c + e + 2] = n[r + e + 2], o[c + e + 3] = a[n[r + e + 3]];
3014
+ }
3015
+ let c = new b(o, r, i, ue);
3016
+ return c.colorSpace = P, c.wrapS = c.wrapT = de, c.needsUpdate = !0, c;
2357
3017
  }
2358
- function gr(e) {
3018
+ function Hr(e) {
2359
3019
  let t = [e], n = e, r = [
2360
3020
  (e) => e.replace(/-renamed-\d+$/, ""),
2361
3021
  (e) => e.replace(/\d+$/, ""),
@@ -2368,9 +3028,9 @@ function gr(e) {
2368
3028
  }
2369
3029
  return t;
2370
3030
  }
2371
- var _r = class {
3031
+ var Ur = class {
2372
3032
  constructor(e = {}) {
2373
- this.maxTriangles = e.maxTriangles ?? er, this.maxPlacements = e.maxPlacements ?? tr, this.mergeShapesAbove = e.mergeShapesAbove ?? nr, this.curveSteps = e.curveSteps ?? ar, this.curveSides = e.curveSides ?? null, this.curveTolerance = e.curveTolerance ?? sr, this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map(), this._geometryCache = /* @__PURE__ */ new Map(), this._materialBySignature = /* @__PURE__ */ new Map(), this._noUVMaterials = /* @__PURE__ */ new Map(), this._plyCache = /* @__PURE__ */ new Map(), this._imageCache = /* @__PURE__ */ new Map(), this._termCache = /* @__PURE__ */ new Map(), this._mediumMaterials = /* @__PURE__ */ new Map();
3033
+ this.maxTriangles = e.maxTriangles ?? dr, this.maxPlacements = e.maxPlacements ?? fr, this.mergeShapesAbove = e.mergeShapesAbove ?? pr, this.curveSteps = e.curveSteps ?? gr, this.curveSides = e.curveSides ?? null, this.curveTolerance = e.curveTolerance ?? vr, this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map(), this._geometryCache = /* @__PURE__ */ new Map(), this._materialBySignature = /* @__PURE__ */ new Map(), this._noUVMaterials = /* @__PURE__ */ new Map(), this._plyCache = /* @__PURE__ */ new Map(), this._imageCache = /* @__PURE__ */ new Map(), this._termCache = /* @__PURE__ */ new Map(), this._mediumMaterials = /* @__PURE__ */ new Map(), this._alphaMaterials = /* @__PURE__ */ new Map();
2374
3034
  }
2375
3035
  warn(e) {
2376
3036
  this.warnings.push(e);
@@ -2380,10 +3040,10 @@ var _r = class {
2380
3040
  for (let { name: t } of e.animatedInstances ?? []) for (let n of e.objects.get(t) ?? []) this._keepShapes.add(n);
2381
3041
  this._plyUsers = /* @__PURE__ */ new Map(), this._plyHeld = /* @__PURE__ */ new Set();
2382
3042
  for (let t of e.shapes) if (t?.type === "plymesh") {
2383
- let e = Z(t.params, "filename", null);
3043
+ let e = q(t.params, "filename", null);
2384
3044
  this._plyUsers.set(e, (this._plyUsers.get(e) ?? 0) + 1);
2385
3045
  }
2386
- for (let t of e.objects.values()) for (let e of t) e.type === "plymesh" && this._plyHeld.add(Z(e.params, "filename", null));
3046
+ for (let t of e.objects.values()) for (let e of t) e.type === "plymesh" && this._plyHeld.add(q(e.params, "filename", null));
2387
3047
  this._recoveredColors = 0, this.reportedMeshes = 0, this.triangleCount = 0, this.placementCount = 0, this.skippedForBudget = 0, this._countedGeometries = /* @__PURE__ */ new WeakSet();
2388
3048
  let t = new D();
2389
3049
  t.name = "PBRTScene", this._batches = e.shapes.length >= this.mergeShapesAbove ? /* @__PURE__ */ new Map() : null, this._mergedBatches = 0, this.mergedShapes = 0, this.droppedNoTemplate = 0, this._animated = [];
@@ -2394,13 +3054,14 @@ var _r = class {
2394
3054
  }
2395
3055
  let r = e.shapes[n], [i, a] = await Promise.all([this._batches ? this._createGeometry(r) : this._buildGeometry(r), this._getMaterial(r)]);
2396
3056
  if (!i) continue;
2397
- if (this._batches && !r.motion && i.getAttribute("position").count <= rr) {
2398
- this._mergeShape(r, i, a, t), e.shapes[n] = null;
3057
+ let o = r.areaLight ? this._poweredMaterial(r, i, a) : a;
3058
+ if (this._batches && !r.motion && i.getAttribute("position").count <= mr) {
3059
+ this._mergeShape(r, i, o, t), e.shapes[n] = null;
2399
3060
  continue;
2400
3061
  }
2401
- r.type === "plymesh" && this._plyHeld.add(Z(r.params, "filename", null));
2402
- let o = this._meshFromGeometry(r, i, a, r.ctm, `shape_${n}`);
2403
- o && (t.add(o), r.motion && this._animate(o, r.motion));
3062
+ r.type === "plymesh" && this._plyHeld.add(q(r.params, "filename", null));
3063
+ let s = this._meshFromGeometry(r, i, o, r.ctm, `shape_${n}`);
3064
+ s && (t.add(s), r.motion && this._animate(s, r.motion));
2404
3065
  }
2405
3066
  if (this._batches) {
2406
3067
  for (let e of this._batches.values()) this._flushBatch(e[0], t), this._flushBatch(e[1], t);
@@ -2415,6 +3076,7 @@ var _r = class {
2415
3076
  camera: n,
2416
3077
  environment: i,
2417
3078
  animations: r,
3079
+ render: Dr(e),
2418
3080
  report: this.report,
2419
3081
  meshCount: this.reportedMeshes,
2420
3082
  triangleCount: this.triangleCount,
@@ -2441,11 +3103,11 @@ var _r = class {
2441
3103
  let p = new k(a, o, f);
2442
3104
  p.name = `instance_${n++}`, p.frustumCulled = !1;
2443
3105
  for (let t = 0; t < f; t++) {
2444
- if (s) qt(r, e.matrices, t * 16, s);
3106
+ if (s) Xt(r, e.matrices, t * 16, s);
2445
3107
  else for (let n = 0; n < 16; n++) r[n] = e.matrices[t * 16 + n];
2446
- p.setMatrixAt(t, i.fromArray(this.convertHandedness ? q($, r) : r));
3108
+ p.setMatrixAt(t, i.fromArray(this.convertHandedness ? U(Q, r) : r));
2447
3109
  }
2448
- p.instanceMatrix.needsUpdate = !0, t.add(p), this.placementCount += f, this.reportedMeshes += f, this.report.length < $n && this.report.push({
3110
+ p.instanceMatrix.needsUpdate = !0, t.add(p), this.placementCount += f, this.reportedMeshes += f, this.report.length < ur && this.report.push({
2449
3111
  mesh: `${p.name} ×${f}`,
2450
3112
  shape: c,
2451
3113
  material: l,
@@ -2475,7 +3137,7 @@ var _r = class {
2475
3137
  }
2476
3138
  let [r, s] = await Promise.all([this._buildGeometry(e), this._getMaterial(e)]);
2477
3139
  if (!r) continue;
2478
- if (i && e.type !== "plymesh" && r.getAttribute("position").count <= rr) {
3140
+ if (i && e.type !== "plymesh" && r.getAttribute("position").count <= mr) {
2479
3141
  this._geometryCache.delete(e);
2480
3142
  let t = this._appendToBatch(i, e, r, s, e.relativeCTM || e.ctm);
2481
3143
  this._releaseMerged(e, r), o(n, t);
@@ -2485,7 +3147,7 @@ var _r = class {
2485
3147
  a(n, r, this._materialForGeometry(e, r, s, `instances_${t}`), e.relativeCTM || e.ctm, e.type, e.material?.type || "diffuse", c);
2486
3148
  }
2487
3149
  if (i) for (let e of i.values()) o(n, e[0]), o(n, e[1]);
2488
- H(n.matrices), H(n.matricesEnd);
3150
+ z(n.matrices), z(n.matricesEnd);
2489
3151
  }
2490
3152
  }
2491
3153
  _samePlacementGroups(e) {
@@ -2502,11 +3164,11 @@ var _r = class {
2502
3164
  }
2503
3165
  let o = `${i.count}:${Array.prototype.join.call(i.matrices.subarray(0, 16), ",")}`, s = n.get(o);
2504
3166
  s || n.set(o, s = []);
2505
- let c = s.find((e) => cr(e.list, i));
3167
+ let c = s.find((e) => yr(e.list, i));
2506
3168
  if (c) {
2507
3169
  c.template === e.objects.get(c.name) && (c.template = c.template.slice());
2508
3170
  for (let e of a) c.template.push(e);
2509
- H(i.matrices);
3171
+ z(i.matrices);
2510
3172
  continue;
2511
3173
  }
2512
3174
  let l = {
@@ -2533,7 +3195,7 @@ var _r = class {
2533
3195
  let s = new D();
2534
3196
  s.name = `placement_${r}`;
2535
3197
  let c = Array.from(a.matrices.subarray(0, 16));
2536
- new N().fromArray(this.convertHandedness ? q($, c) : c).decompose(s.position, s.quaternion, s.scale);
3198
+ new N().fromArray(this.convertHandedness ? U(Q, c) : c).decompose(s.position, s.quaternion, s.scale);
2537
3199
  for (let e = 0; e < o.length; e++) {
2538
3200
  let t = o[e], [n, r] = await Promise.all([this._buildGeometry(t), this._getMaterial(t)]);
2539
3201
  if (!n) continue;
@@ -2553,7 +3215,7 @@ var _r = class {
2553
3215
  let n = [];
2554
3216
  for (let { node: e, motion: t } of this._animated) if (this._transformTracks(n, e.name, t, (e, t) => {
2555
3217
  let n = Array.from(e.subarray(t, t + 16));
2556
- return this.convertHandedness ? q($, n) : n;
3218
+ return this.convertHandedness ? U(Q, n) : n;
2557
3219
  }), t.visible) {
2558
3220
  let r = t.times, i = r.map((e, t) => t === 0 ? 0 : (r[t - 1] + e) / 2);
2559
3221
  n.push(new g(`${e.name}.visible`, i, Array.from(t.visible, (e) => e === 1)));
@@ -2573,7 +3235,7 @@ var _r = class {
2573
3235
  return n.length === 0 ? [] : [new h(e.animation.name, e.animation.duration, n)];
2574
3236
  }
2575
3237
  _transformTracks(e, t, n, r) {
2576
- let i = n.times.length, a = new Float32Array(i * 3), o = new Float32Array(i * 4), s = new Float32Array(i * 3), c = new N(), l = new L(), u = new ce(), d = new L();
3238
+ let i = n.times.length, a = new Float32Array(i * 3), o = new Float32Array(i * 4), s = new Float32Array(i * 3), c = new N(), l = new I(), u = new ce(), d = new I();
2577
3239
  for (let e = 0; e < i; e++) c.fromArray(r(n.matrices, e * 16)).decompose(l, u, d), e > 0 && u.x * o[e * 4 - 4] + u.y * o[e * 4 - 3] + u.z * o[e * 4 - 2] + u.w * o[e * 4 - 1] < 0 && u.set(-u.x, -u.y, -u.z, -u.w), l.toArray(a, e * 3), u.toArray(o, e * 4), d.toArray(s, e * 3);
2578
3240
  let f = (e, t) => {
2579
3241
  for (let n = t; n < e.length; n++) if (e[n] !== e[n % t]) return !0;
@@ -2588,10 +3250,10 @@ var _r = class {
2588
3250
  _meshFromGeometry(e, t, n, r, i, a = !1) {
2589
3251
  let o = !!t.getAttribute("uv"), s = this._materialForGeometry(e, t, n, i), c = new ee(t, s);
2590
3252
  c.name = i;
2591
- let l = this.convertHandedness && !a ? q($, r) : r;
3253
+ let l = this.convertHandedness && !a ? U(Q, r) : r;
2592
3254
  new N().fromArray(l).decompose(c.position, c.quaternion, c.scale), c.updateMatrix(), t.boundingBox || t.computeBoundingBox();
2593
- let u = t.boundingBox ? t.boundingBox.clone().applyMatrix4(c.matrix).getSize(new L()) : new L(), d = this._accountGeometry(t);
2594
- return this.placementCount++, this.reportedMeshes++, this.report.length < $n && this.report.push({
3255
+ let u = t.boundingBox ? t.boundingBox.clone().applyMatrix4(c.matrix).getSize(new I()) : new I(), d = this._accountGeometry(t);
3256
+ return this.placementCount++, this.reportedMeshes++, this.report.length < ur && this.report.push({
2595
3257
  mesh: i,
2596
3258
  shape: e.type,
2597
3259
  material: e.material?.type || "diffuse",
@@ -2607,18 +3269,18 @@ var _r = class {
2607
3269
  _materialForGeometry(e, t, n, r) {
2608
3270
  if (!n.map || t.getAttribute("uv")) return n;
2609
3271
  let i = this._noUVMaterials.get(n);
2610
- return i || (this.warn(`${r} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), i = n.clone(), i.map = null, this._noUVMaterials.set(n, i)), i;
3272
+ return i || (this.warn(`${r} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), i = Rr(n), i.map = null, this._noUVMaterials.set(n, i)), i;
2611
3273
  }
2612
3274
  _mergeShape(e, t, n, r) {
2613
3275
  this.reportedMeshes++;
2614
- let i = this.convertHandedness ? q($, e.ctm) : e.ctm, a = this._appendToBatch(this._batches, e, t, n, i);
3276
+ let i = this.convertHandedness ? U(Q, e.ctm) : e.ctm, a = this._appendToBatch(this._batches, e, t, n, i);
2615
3277
  this._releaseMerged(e, t), a && this._flushBatch(a, r);
2616
3278
  }
2617
3279
  _releaseMerged(e, t) {
2618
- if (!this._keepShapes?.has(e) && !(e.type === "plymesh" && !this._lastPlyUse(Z(e.params, "filename", null)))) {
2619
- for (let e in t.attributes) H(t.attributes[e].array);
2620
- H(t.index?.array);
2621
- for (let t in e.params) ArrayBuffer.isView(e.params[t]?.value) && H(e.params[t].value);
3280
+ if (!this._keepShapes?.has(e) && !(e.type === "plymesh" && !this._lastPlyUse(q(e.params, "filename", null)))) {
3281
+ for (let e in t.attributes) z(t.attributes[e].array);
3282
+ z(t.index?.array);
3283
+ for (let t in e.params) ArrayBuffer.isView(e.params[t]?.value) && z(e.params[t].value);
2622
3284
  }
2623
3285
  }
2624
3286
  _lastPlyUse(e) {
@@ -2641,8 +3303,8 @@ var _r = class {
2641
3303
  indexCount: 0,
2642
3304
  triangles: 0
2643
3305
  });
2644
- let m = i, h = J(m), g = p.vertexCount;
2645
- p.positions = Zn(p.positions, (g + u) * 3), p.normals = Zn(p.normals, (g + u) * 3), c && (p.uvs = Zn(p.uvs, (g + u) * 2));
3306
+ let m = i, h = W(m), g = p.vertexCount;
3307
+ p.positions = cr(p.positions, (g + u) * 3), p.normals = cr(p.normals, (g + u) * 3), c && (p.uvs = cr(p.uvs, (g + u) * 2));
2646
3308
  let _ = o.array, v = p.positions, y = s ? s.array : null, b = p.normals;
2647
3309
  for (let e = 0; e < u; e++) {
2648
3310
  let t = e * 3, n = (g + e) * 3, r = _[t], i = _[t + 1], a = _[t + 2];
@@ -2652,19 +3314,19 @@ var _r = class {
2652
3314
  }
2653
3315
  c && p.uvs.set(c.array.subarray(0, u * 2), g * 2);
2654
3316
  let x = l ? l.count : u;
2655
- p.indices = Zn(p.indices, p.indexCount + x);
3317
+ p.indices = cr(p.indices, p.indexCount + x);
2656
3318
  let S = p.indices, C = l ? l.array : null;
2657
3319
  for (let e = 0; e < x; e++) S[p.indexCount + e] = g + (C ? C[e] : e);
2658
- return p.vertexCount += u, p.indexCount += x, p.triangles += x / 3, p.triangles >= ir ? (d[f] = null, p) : null;
3320
+ return p.vertexCount += u, p.indexCount += x, p.triangles += x / 3, p.triangles >= hr ? (d[f] = null, p) : null;
2659
3321
  }
2660
3322
  _batchGeometry(e) {
2661
3323
  let t = new v();
2662
- return t.setAttribute("position", new w(U(e.positions, e.vertexCount * 3), 3)), t.setAttribute("normal", new w(U(e.normals, e.vertexCount * 3), 3)), e.uvs && t.setAttribute("uv", new w(U(e.uvs, e.vertexCount * 2), 2)), t.setIndex(new I(U(e.indices, e.indexCount), 1)), e.positions = e.normals = e.uvs = e.indices = null, t;
3324
+ return t.setAttribute("position", new w(B(e.positions, e.vertexCount * 3), 3)), t.setAttribute("normal", new w(B(e.normals, e.vertexCount * 3), 3)), e.uvs && t.setAttribute("uv", new w(B(e.uvs, e.vertexCount * 2), 2)), t.setIndex(new F(B(e.indices, e.indexCount), 1)), e.positions = e.normals = e.uvs = e.indices = null, t;
2663
3325
  }
2664
3326
  _flushBatch(e, t) {
2665
3327
  if (!e || e.triangles === 0) return;
2666
3328
  let n = new ee(this._batchGeometry(e), e.material);
2667
- n.name = `merged_${this._mergedBatches++}`, n.frustumCulled = !1, t.add(n), this.placementCount++, this.report.length < $n && this.report.push({
3329
+ n.name = `merged_${this._mergedBatches++}`, n.frustumCulled = !1, t.add(n), this.placementCount++, this.report.length < ur && this.report.push({
2668
3330
  mesh: n.name,
2669
3331
  shape: "merged",
2670
3332
  material: "-",
@@ -2683,7 +3345,7 @@ var _r = class {
2683
3345
  }
2684
3346
  async _createGeometry(e) {
2685
3347
  let t = await this._shapeGeometry(e);
2686
- return t && e.areaLight && !fn(e.areaLight.params, "twosided", !1) ? this._facingEmission(e, t) : t;
3348
+ return t && e.areaLight && !J(e.areaLight.params, "twosided", !1) ? this._facingEmission(e, t) : t;
2687
3349
  }
2688
3350
  _facingEmission(e, t) {
2689
3351
  let n = t.userData.pbrtNormals ? t.getAttribute("normal") : null;
@@ -2700,7 +3362,7 @@ var _r = class {
2700
3362
  if (c === 0) return t;
2701
3363
  let l = new v();
2702
3364
  for (let e in t.attributes) l.setAttribute(e, t.getAttribute(e));
2703
- return l.setIndex(new I(s, 1)), l;
3365
+ return l.setIndex(new F(s, 1)), l;
2704
3366
  }
2705
3367
  _shapeGeometry(e) {
2706
3368
  switch (e.type) {
@@ -2711,6 +3373,7 @@ var _r = class {
2711
3373
  case "plymesh": return this._plyMesh(e.params);
2712
3374
  case "sphere": return this._sphere(e.params);
2713
3375
  case "disk": return this._disk(e.params);
3376
+ case "cylinder": return this._cylinder(e.params);
2714
3377
  default: return this.warn(`shape "${e.type}" not supported — skipped`), null;
2715
3378
  }
2716
3379
  }
@@ -2718,59 +3381,85 @@ var _r = class {
2718
3381
  let t = e.P?.value;
2719
3382
  if (!t || t.length < 9) return this.warn("trianglemesh missing P"), null;
2720
3383
  let n = new v();
2721
- n.setAttribute("position", new w(Qn(t), 3));
3384
+ n.setAttribute("position", new w(lr(t), 3));
2722
3385
  let r = e.N?.value;
2723
- r && r.length === t.length && (n.setAttribute("normal", new w(Qn(r), 3)), n.userData.pbrtNormals = !0);
3386
+ r && r.length === t.length && (n.setAttribute("normal", new w(lr(r), 3)), n.userData.pbrtNormals = !0);
2724
3387
  let i = (e.uv || e.st)?.value;
2725
- i && i.length === t.length / 3 * 2 && n.setAttribute("uv", new w(Qn(i), 2));
3388
+ i && i.length === t.length / 3 * 2 && n.setAttribute("uv", new w(lr(i), 2));
2726
3389
  let a = e.indices?.value;
2727
- return a && a.length && n.setIndex(Xn(a)), r || n.computeVertexNormals(), n;
3390
+ return a && a.length && n.setIndex(sr(a)), r || n.computeVertexNormals(), n;
2728
3391
  }
2729
3392
  _curve(e) {
2730
3393
  let t = e.P?.value;
2731
3394
  if (!t || t.length < 12) return this.warn("curve needs at least 4 control points"), null;
2732
- let n = Math.round(X(e, "degree", 3));
3395
+ let n = Math.round(K(e, "degree", 3));
2733
3396
  if (n !== 3) return this.warn(`curve degree ${n} not supported — only cubic`), null;
2734
- let r = Z(e, "type", "flat"), i = X(e, "width", 1), a = Kn({
3397
+ let r = q(e, "type", "flat"), i = K(e, "width", 1), a = rr({
2735
3398
  P: t,
2736
- basis: Z(e, "basis", "bezier"),
2737
- width0: X(e, "width0", i),
2738
- width1: X(e, "width1", i),
3399
+ basis: q(e, "basis", "bezier"),
3400
+ width0: K(e, "width0", i),
3401
+ width1: K(e, "width1", i),
2739
3402
  N: e.N?.value || null,
2740
3403
  steps: this.curveSteps,
2741
- sides: this.curveSides ?? or[r] ?? 1,
3404
+ sides: this.curveSides ?? _r[r] ?? 1,
2742
3405
  tolerance: this.curveTolerance
2743
3406
  });
2744
3407
  if (!a) return this.warn("curve could not be tessellated"), null;
2745
3408
  let o = new v();
2746
- return o.setAttribute("position", new w(a.positions, 3)), o.setIndex(new I(a.indices, 1)), o.computeVertexNormals(), o;
3409
+ return o.setAttribute("position", new w(a.positions, 3)), o.setIndex(new F(a.indices, 1)), o.computeVertexNormals(), o;
2747
3410
  }
2748
3411
  _loopSubdiv(e) {
2749
3412
  let t = e.P?.value, n = e.indices?.value;
2750
3413
  if (!t || t.length < 9 || !n || n.length < 3) return this.warn("loopsubdiv missing P/indices"), null;
2751
- let r = Math.max(0, Math.min(6, Math.round(X(e, "levels", 3)))), { positions: i, indices: a, levels: o } = jn(t, n, r);
3414
+ let r = Math.max(0, Math.min(6, Math.round(K(e, "levels", 3)))), { positions: i, indices: a, levels: o } = Hn(t, n, r);
2752
3415
  o < r && this.warn(`loopsubdiv refined ${o}/${r} levels — the control mesh is too dense for the triangle budget`);
2753
3416
  let s = new v();
2754
- return s.setAttribute("position", new w(i, 3)), s.setIndex(new I(a, 1)), s.computeVertexNormals(), s;
3417
+ return s.setAttribute("position", new w(i, 3)), s.setIndex(new F(a, 1)), s.computeVertexNormals(), s;
2755
3418
  }
2756
3419
  _bilinearMesh(e) {
2757
- let t = e.P?.value, n = e.indices?.value;
3420
+ let t = e.P?.value, n = e.indices?.value ?? (t?.length === 12 ? [
3421
+ 0,
3422
+ 1,
3423
+ 2,
3424
+ 3
3425
+ ] : null);
2758
3426
  if (!t || !n) return this.warn("bilinearmesh missing P/indices"), null;
2759
- let r = [];
2760
- for (let e = 0; e + 3 < n.length; e += 4) {
2761
- let [t, i, a, o] = [
2762
- n[e],
2763
- n[e + 1],
2764
- n[e + 2],
2765
- n[e + 3]
2766
- ];
2767
- r.push(t, i, a, t, a, o);
3427
+ let r = t.length / 3, i = e.uv?.value?.length === r * 2 ? e.uv.value : null, a = e.N?.value?.length === r * 3 ? e.N.value : null, o = new v();
3428
+ if (i) {
3429
+ let e = [];
3430
+ for (let t = 0; t + 3 < n.length; t += 4) {
3431
+ let [r, i, a, o] = [
3432
+ n[t],
3433
+ n[t + 1],
3434
+ n[t + 2],
3435
+ n[t + 3]
3436
+ ];
3437
+ e.push(r, i, o, r, o, a);
3438
+ }
3439
+ o.setAttribute("position", new w(Float32Array.from(t), 3)), o.setAttribute("uv", new w(Float32Array.from(i), 2)), a && o.setAttribute("normal", new w(Float32Array.from(a), 3)), o.setIndex(new F(new Uint32Array(e), 1));
3440
+ } else {
3441
+ let e = Math.floor(n.length / 4), r = new Float32Array(e * 12), i = a ? new Float32Array(e * 12) : null, s = new Float32Array(e * 8), c = new Uint32Array(e * 6);
3442
+ for (let o = 0; o < e; o++) {
3443
+ for (let e = 0; e < 4; e++) {
3444
+ let c = n[o * 4 + e];
3445
+ for (let n = 0; n < 3; n++) r[o * 12 + e * 3 + n] = t[c * 3 + n], i && (i[o * 12 + e * 3 + n] = a[c * 3 + n]);
3446
+ s[o * 8 + e * 2] = e & 1, s[o * 8 + e * 2 + 1] = e >> 1;
3447
+ }
3448
+ c.set([
3449
+ 0,
3450
+ 1,
3451
+ 3,
3452
+ 0,
3453
+ 3,
3454
+ 2
3455
+ ].map((e) => o * 4 + e), o * 6);
3456
+ }
3457
+ o.setAttribute("position", new w(r, 3)), o.setAttribute("uv", new w(s, 2)), i && o.setAttribute("normal", new w(i, 3)), o.setIndex(new F(c, 1));
2768
3458
  }
2769
- let i = new v();
2770
- return i.setAttribute("position", new w(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
3459
+ return a ? o.userData.pbrtNormals = !0 : o.computeVertexNormals(), o;
2771
3460
  }
2772
3461
  _plyMesh(e) {
2773
- let t = Z(e, "filename", null);
3462
+ let t = q(e, "filename", null);
2774
3463
  if (!t) return this.warn("plymesh missing filename"), null;
2775
3464
  let n = this._plyCache.get(t);
2776
3465
  return n || this._plyCache.set(t, n = this._decodePly(t)), n;
@@ -2784,25 +3473,64 @@ var _r = class {
2784
3473
  }
2785
3474
  }
2786
3475
  _sphere(e) {
2787
- return new de(X(e, "radius", 1), 48, 32);
3476
+ let { radius: t, zMin: n, zMax: r, phiMax: i } = kr(e), a = Math.acos(n / t), o = Math.acos(r / t);
3477
+ return Nr(i, Math.max(1, Math.ceil(32 * (a - o) / Math.PI)), (e, n, r, s) => {
3478
+ let c = e * i, l = a + n * (o - a);
3479
+ s.set(Math.sin(l) * Math.cos(c), Math.sin(l) * Math.sin(c), Math.cos(l)), r.copy(s).multiplyScalar(t);
3480
+ });
3481
+ }
3482
+ _cylinder(e) {
3483
+ let { radius: t, zMin: n, zMax: r, phiMax: i } = Ar(e);
3484
+ return Nr(i, 1, (e, a, o, s) => {
3485
+ let c = e * i;
3486
+ s.set(Math.cos(c), Math.sin(c), 0), o.set(t * s.x, t * s.y, n + a * (r - n));
3487
+ });
2788
3488
  }
2789
3489
  _disk(e) {
2790
- let t = X(e, "radius", 1), n = X(e, "innerradius", 0), r = X(e, "height", 0), i = [], a = [];
2791
- for (let e = 0; e < 48; e++) {
2792
- let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
2793
- i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
2794
- }
2795
- let o = new v();
2796
- return o.setAttribute("position", new w(Float32Array.from(i), 3)), o.setIndex(a), o.computeVertexNormals(), o;
3490
+ let { radius: t, inner: n, height: r, phiMax: i } = jr(e);
3491
+ return Nr(i, 1, (e, a, o, s) => {
3492
+ let c = e * i, l = t - a * (t - n);
3493
+ o.set(l * Math.cos(c), l * Math.sin(c), r), s.set(0, 0, 1);
3494
+ });
2797
3495
  }
2798
3496
  async _getMaterial(e) {
2799
3497
  let t = await this._surfaceMaterial(e);
2800
- return e.interior ? this._inMedium(t, e.interior) : t;
3498
+ return e.interior && (t = await this._inMedium(t, e.interior)), e.params.alpha ? this._withAlpha(t, e.params.alpha) : t;
3499
+ }
3500
+ _withAlpha(e, t) {
3501
+ let n = t.type === "texture" ? t.value[0] : `#${t.value[0]}`, r = this._alphaMaterials.get(e);
3502
+ return r || this._alphaMaterials.set(e, r = /* @__PURE__ */ new Map()), r.has(n) || r.set(n, this._createAlphaMaterial(e, t)), r.get(n);
3503
+ }
3504
+ async _createAlphaMaterial(e, t) {
3505
+ if (t.type !== "texture") return t.value[0] < 1 ? zr(e, t.value[0]) : e;
3506
+ let n = t.value[0], r = await this._alphaMap(e.map, n);
3507
+ if (!r) return this.warn(`shape alpha "${n}" could not be read here — drawn opaque`), e;
3508
+ if (r.constant !== void 0) return r.constant < 1 ? zr(e, r.constant) : e;
3509
+ let i = Rr(e);
3510
+ return i.map = r, i.transparent = !0, i;
3511
+ }
3512
+ async _alphaMap(e, t) {
3513
+ let n = this.ir.namedTextures.get(t), r = n?.class === "imagemap" ? q(n.params, "filename", null) : null;
3514
+ if (r && e?.userData.pbrtImage === r && q(n.params, "mapping", "uv") === "uv" && K(n.params, "scale", 1) === 1 && !J(n.params, "invert", !1) && Br(e, Cr(n.params))) {
3515
+ let t = xr(e), r = t && Vr(t, Sr(n.params));
3516
+ if (r) return wr(r, Cr(n.params)), r;
3517
+ }
3518
+ let i = await this._bakeTerm(t, 1);
3519
+ if (!i) return null;
3520
+ if (!i.layer) return { constant: i.rgb[0] };
3521
+ let a = e ? this._textureLayer(e, 3) : null;
3522
+ if (e && !a) return null;
3523
+ let o = Z([a ? { layer: a } : { rgb: [
3524
+ 1,
3525
+ 1,
3526
+ 1
3527
+ ] }, i], ([e]) => e, { alphaOf: ([, e]) => e[0] });
3528
+ return o && $(o);
2801
3529
  }
2802
3530
  async _surfaceMaterial(e) {
2803
3531
  let t = this._materialCache.get(e.material);
2804
3532
  if (t || (t = /* @__PURE__ */ new Map(), this._materialCache.set(e.material, t)), t.has(e.areaLight)) return t.get(e.areaLight);
2805
- let n = this._materialContext(), r = await _n(e.material, n);
3533
+ let n = this._materialContext(), r = await On(e.material, n);
2806
3534
  e.areaLight && await this._applyAreaLight(r, e.areaLight, n);
2807
3535
  let i = this._dedupeMaterial(r);
2808
3536
  return t.set(e.areaLight, i), i;
@@ -2814,13 +3542,25 @@ var _r = class {
2814
3542
  warn: (e) => this.warn(e),
2815
3543
  floatTextureMean: async (e) => {
2816
3544
  let t = await this._bakeTerm(e, 1);
2817
- return t ? t.layer ? Sn(t.layer) : t.rgb[0] : null;
3545
+ return t ? t.layer ? Pn(t.layer) : t.rgb[0] : null;
2818
3546
  },
2819
3547
  bakeMaterialMix: (e, t, n) => this._bakeMaterialMix(e, t, n),
3548
+ bakeFloatMap: (e, t, n) => this._floatMap(e, t, n),
3549
+ textureMeanRGB: async (e) => {
3550
+ let t = await this._bakeTerm(e, 3);
3551
+ if (!t?.layer) return t?.rgb ?? null;
3552
+ let { data: n } = t.layer, r = [
3553
+ 0,
3554
+ 0,
3555
+ 0
3556
+ ];
3557
+ for (let e = 0; e < n.length; e++) r[e % 3] += n[e];
3558
+ return r.map((e, r) => e / (n.length / 3) * (t.tint?.[r] ?? 1));
3559
+ },
2820
3560
  resolveNormalMap: async (e) => {
2821
3561
  let t = await this._image(e);
2822
3562
  if (!t) return null;
2823
- let n = mr(t, { srgb: !1 }), r = n === t ? t.clone() : n;
3563
+ let n = Tr(t, { srgb: !1 }), r = n === t ? t.clone() : n;
2824
3564
  return r.colorSpace = ne, r;
2825
3565
  }
2826
3566
  };
@@ -2831,33 +3571,41 @@ var _r = class {
2831
3571
  return n || this._mediumMaterials.set(e, n = /* @__PURE__ */ new Map()), n.has(t) || n.set(t, this._attenuated(e, t)), n.get(t);
2832
3572
  }
2833
3573
  async _attenuated(e, t) {
2834
- let n = this.ir.media?.get(t), r = n && Z(n, "type", "");
3574
+ let n = this.ir.media?.get(t), r = n && q(n, "type", "");
2835
3575
  if (r !== "homogeneous") return this.warn(n ? `medium "${t}" (${r}) is not supported — "${t}" glass left clear` : `medium "${t}" not defined`), e;
2836
- n.preset && this.warn(`medium preset "${Z(n, "preset", "")}" is not supported — using sigma_a / sigma_s`);
2837
- let i = this._materialContext(), a = (await Q(n, "sigma_a", i, [
3576
+ n.preset && this.warn(`medium preset "${q(n, "preset", "")}" is not supported — using sigma_a / sigma_s`);
3577
+ let i = this._materialContext(), a = (await Y(n, "sigma_a", i, [
2838
3578
  1,
2839
3579
  1,
2840
3580
  1
2841
- ])).rgb, o = (await Q(n, "sigma_s", i, [
3581
+ ])).rgb, o = (await Y(n, "sigma_s", i, [
2842
3582
  1,
2843
3583
  1,
2844
3584
  1
2845
- ])).rgb, s = X(n, "scale", 1), c = [
3585
+ ])).rgb, s = K(n, "scale", 1), c = [
2846
3586
  0,
2847
3587
  1,
2848
3588
  2
2849
3589
  ].map((e) => (a[e] + o[e]) * s), l = Math.max(...c);
2850
3590
  if (!(l > 0)) return e;
2851
- let u = e.clone();
3591
+ let u = Rr(e);
2852
3592
  return u.attenuationDistance = 1 / l, u.attenuationColor.setRGB(...c.map((e) => Math.exp(-e / l))), this._dedupeMaterial(u);
2853
3593
  }
2854
3594
  _dedupeMaterial(e) {
2855
- let t = e.color, n = e.emissive, r = `${t.r},${t.g},${t.b}|${n.r},${n.g},${n.b}|${e.emissiveIntensity}|${e.map ? e.map.uuid : "-"}|${e.roughness}|${e.metalness}|${e.transmission}|${e.ior}|${e.thickness}|${e.clearcoat}|${e.clearcoatRoughness}|${e.opacity}|${e.side}|${e.normalMap ? e.normalMap.uuid : "-"}|${e.attenuationDistance}|${e.attenuationColor.toArray()}|${e.specularIntensity}|${e.diffuseTransmission ?? 0}|${e.diffuseTransmissionColor?.toArray() ?? "-"}`;
3595
+ let t = e.color, n = e.emissive, r = `${t.r},${t.g},${t.b}|${n.r},${n.g},${n.b}|${e.emissiveIntensity}|${e.map ? e.map.uuid : "-"}|${e.roughness}|${e.roughnessMap?.uuid ?? "-"}|${e.metalness}|${e.transmission}|${e.ior}|${e.thickness}|${e.clearcoat}|${e.clearcoatRoughness}|${e.clearcoatRoughnessMap?.uuid ?? "-"}|${e.opacity}|${e.side}|${e.normalMap ? e.normalMap.uuid : "-"}|${e.attenuationDistance}|${e.attenuationColor.toArray()}|${e.specularIntensity}|${e.diffuseTransmission ?? 0}|${e.diffuseTransmissionColor?.toArray() ?? "-"}|${e.subsurface ?? 0}|${e.subsurfaceColor?.toArray() ?? "-"}|${e.subsurfaceRadius ?? "-"}|${e.subsurfaceAnisotropy ?? 0}`;
2856
3596
  return this._materialBySignature.get(r) || (this._materialBySignature.set(r, e), e);
2857
3597
  }
3598
+ _poweredMaterial(e, t, n) {
3599
+ let r = K(e.areaLight.params, "power", -1);
3600
+ if (!(r > 0)) return n;
3601
+ let i = Pr(e, t) * (J(e.areaLight.params, "twosided", !1) ? 2 : 1);
3602
+ if (!(i > 0)) return n;
3603
+ let a = Rr(n);
3604
+ return a.emissiveIntensity = n.emissiveIntensity * r / (Math.PI * i), a;
3605
+ }
2858
3606
  async _applyAreaLight(e, t, n) {
2859
- let r = await Jn(t.params, "L", n), i = X(t.params, "scale", 1);
2860
- e.emissive.setRGB(r[0], r[1], r[2]), e.emissiveIntensity = i, e.side = fn(t.params, "twosided", !1) ? S : E;
3607
+ let r = await ar(t.params, "L", n), i = K(t.params, "scale", 1);
3608
+ e.emissive.setRGB(r[0], r[1], r[2]), e.emissiveIntensity = i, e.side = J(t.params, "twosided", !1) ? S : E;
2861
3609
  }
2862
3610
  async _resolveNamedTexture(e) {
2863
3611
  if (this._textureCache.has(e)) return this._textureCache.get(e);
@@ -2876,35 +3624,104 @@ var _r = class {
2876
3624
  e.value[0],
2877
3625
  e.value[0]
2878
3626
  ] });
2879
- } else if (t.class === "scale") n = await this._resolveScaleTexture(e, t);
3627
+ } else if (t.class === "checkerboard" || t.class === "bilerp") n = await this._proceduralTexture(e, t);
3628
+ else if (t.class === "scale") n = await this._resolveScaleTexture(e, t);
2880
3629
  else {
2881
3630
  let r = this._colorFromLikeNamedMaterial(e);
2882
3631
  r ? (n = { constant: r.rgb }, this._recoveredColors++) : this.warn(`texture class "${t.class}" not supported (texture "${e}")`);
2883
3632
  }
2884
3633
  return this._textureCache.set(e, n), n;
2885
3634
  }
3635
+ async _proceduralTexture(e, t) {
3636
+ let n = t.params, r = this._materialContext(), i = async (e, t) => {
3637
+ let i = n[e];
3638
+ return i?.type === "texture" ? await r.textureMeanRGB(i.value[0]) ?? t : (await Y(n, e, r, t)).rgb ?? t;
3639
+ }, a = q(n, "mapping", "uv");
3640
+ a !== "uv" && this.warn(`texture "${e}": "${a}" mapping is not supported — using the mesh's uv`);
3641
+ let { su: o, sv: s, du: c, dv: l } = Cr(n);
3642
+ if (t.class === "checkerboard") {
3643
+ if (K(n, "dimension", 2) !== 2) return this.warn(`texture "${e}": a 3D checkerboard is not supported`), null;
3644
+ let [t, r] = await Promise.all([i("tex1", [
3645
+ 1,
3646
+ 1,
3647
+ 1
3648
+ ]), i("tex2", [
3649
+ 0,
3650
+ 0,
3651
+ 0
3652
+ ])]), a = 2 * Fr;
3653
+ return { texture: $({
3654
+ data: Lr(a, a, (e, n) => (Math.floor(2 * e) + Math.floor(2 * n)) % 2 ? r : t),
3655
+ width: a,
3656
+ height: a,
3657
+ mapping: {
3658
+ su: o / 2,
3659
+ sv: s / 2,
3660
+ du: c / 2,
3661
+ dv: l / 2
3662
+ }
3663
+ }) };
3664
+ }
3665
+ let [u, d, f, p] = await Promise.all([
3666
+ i("v00", [
3667
+ 0,
3668
+ 0,
3669
+ 0
3670
+ ]),
3671
+ i("v01", [
3672
+ 1,
3673
+ 1,
3674
+ 1
3675
+ ]),
3676
+ i("v10", [
3677
+ 0,
3678
+ 0,
3679
+ 0
3680
+ ]),
3681
+ i("v11", [
3682
+ 1,
3683
+ 1,
3684
+ 1
3685
+ ])
3686
+ ]);
3687
+ return { texture: $({
3688
+ data: Lr(Ir, Ir, (e, t) => [
3689
+ 0,
3690
+ 1,
3691
+ 2
3692
+ ].map((n) => (1 - e) * (1 - t) * u[n] + e * (1 - t) * f[n] + (1 - e) * t * d[n] + e * t * p[n])),
3693
+ width: Ir,
3694
+ height: Ir,
3695
+ mapping: {
3696
+ su: o,
3697
+ sv: s,
3698
+ du: c,
3699
+ dv: l
3700
+ }
3701
+ }) };
3702
+ }
2886
3703
  _image(e) {
2887
3704
  let t = this._imageCache.get(e);
2888
3705
  return t || (t = Promise.resolve().then(() => this.resolveImage(e)).catch((t) => (this.warn(`failed to load image ${e}: ${t.message}`), null)), this._imageCache.set(e, t)), t;
2889
3706
  }
2890
3707
  async _imageMapTexture(e, t) {
2891
- let n = Z(t.params, "filename", null);
3708
+ let n = q(t.params, "filename", null);
2892
3709
  if (!n) return null;
2893
3710
  let r = await this._image(n);
2894
3711
  if (!r) return this.warn(`image not found for texture "${e}": ${n}`), null;
2895
- let i = Z(t.params, "mapping", "uv");
3712
+ let i = q(t.params, "mapping", "uv");
2896
3713
  i !== "uv" && this.warn(`texture "${e}": "${i}" mapping is not supported — using the mesh's uv`);
2897
- let a = X(t.params, "scale", 1);
2898
- if (a > 1 || fn(t.params, "invert", !1)) {
2899
- let t = await this._bakeTerm(e, 3), n = t?.layer && wn([{
3714
+ let a = K(t.params, "scale", 1);
3715
+ if (a > 1 || J(t.params, "invert", !1)) {
3716
+ let t = await this._bakeTerm(e, 3), n = t?.layer && Z([{
2900
3717
  ...t,
2901
3718
  clamp: !0
2902
3719
  }], ([e]) => e);
2903
- if (n) return { texture: hr(n) };
3720
+ if (n) return { texture: $(n) };
2904
3721
  this.warn(`texture "${e}": its scale or invert could not be baked here — ignored`);
2905
3722
  }
2906
- let o = mr(r, { srgb: !0 }), s = o === r ? r.clone() : o;
2907
- return pr(s, fr(t.params)), s.needsUpdate = !0, a < 1 ? {
3723
+ let o = Tr(r, { srgb: !0 }), s = o === r ? r.clone() : o;
3724
+ return s.userData.pbrtImage = n, wr(s, Cr(t.params)), s.needsUpdate = !0, a < 1 ? {
2908
3725
  texture: s,
2909
3726
  constant: [
2910
3727
  a,
@@ -2913,6 +3730,23 @@ var _r = class {
2913
3730
  ]
2914
3731
  } : { texture: s };
2915
3732
  }
3733
+ async _floatMap(e, t, n) {
3734
+ let r = await Promise.all(t.map((t) => this._paramTerm(e, t, 1, [
3735
+ 0,
3736
+ 0,
3737
+ 0
3738
+ ])));
3739
+ if (r.some((e) => !e)) return null;
3740
+ let i = Z(r, (e) => {
3741
+ let t = n(e.map((e) => e[0]));
3742
+ return [
3743
+ t,
3744
+ t,
3745
+ t
3746
+ ];
3747
+ }, { linear: !0 });
3748
+ return i && $(i, { srgb: !1 });
3749
+ }
2916
3750
  async _mixTexture(e, t) {
2917
3751
  let [n, r, i] = await Promise.all([
2918
3752
  this._paramTerm(t.params, "tex1", 3, [
@@ -2932,7 +3766,7 @@ var _r = class {
2932
3766
  ])
2933
3767
  ]);
2934
3768
  if (!n || !r || !i) return this.warn(`texture "${e}": a "mix" input could not be read here`), null;
2935
- let a = (e) => e.map((e) => Math.min(1, Math.max(0, e))), o = wn([
3769
+ let a = (e) => e.map((e) => Math.min(1, Math.max(0, e))), o = Z([
2936
3770
  {
2937
3771
  ...n,
2938
3772
  clamp: !0
@@ -2942,8 +3776,8 @@ var _r = class {
2942
3776
  clamp: !0
2943
3777
  },
2944
3778
  i
2945
- ], Tn);
2946
- return o ? { texture: hr(o) } : { constant: Tn([
3779
+ ], In);
3780
+ return o ? { texture: $(o) } : { constant: In([
2947
3781
  a(n.rgb),
2948
3782
  a(r.rgb),
2949
3783
  i.rgb
@@ -2953,7 +3787,7 @@ var _r = class {
2953
3787
  let i = e[t];
2954
3788
  if (!i) return { rgb: r };
2955
3789
  if (i.type === "texture") return this._bakeTerm(i.value[0], n);
2956
- let a = (await Q(e, t, this._materialContext(), r)).rgb;
3790
+ let a = (await Y(e, t, this._materialContext(), r)).rgb;
2957
3791
  return a ? { rgb: a } : null;
2958
3792
  }
2959
3793
  _bakeTerm(e, t) {
@@ -2963,14 +3797,14 @@ var _r = class {
2963
3797
  async _createBakeTerm(e, t) {
2964
3798
  let n = this.ir.namedTextures.get(e);
2965
3799
  if (n?.class === "imagemap") {
2966
- if (Z(n.params, "mapping", "uv") !== "uv") return null;
2967
- let e = Z(n.params, "filename", null), r = ur(e && await this._image(e));
2968
- return r ? { layer: xn(r, {
3800
+ if (q(n.params, "mapping", "uv") !== "uv") return null;
3801
+ let e = q(n.params, "filename", null), r = xr(e && await this._image(e));
3802
+ return r ? { layer: Mn(r, {
2969
3803
  channels: t,
2970
- decode: r.float ? null : dr(n.params),
2971
- scale: X(n.params, "scale", 1),
2972
- invert: fn(n.params, "invert", !1),
2973
- mapping: fr(n.params)
3804
+ decode: r.float ? null : Sr(n.params),
3805
+ scale: K(n.params, "scale", 1),
3806
+ invert: J(n.params, "invert", !1),
3807
+ mapping: Cr(n.params)
2974
3808
  }) } : null;
2975
3809
  }
2976
3810
  let r = await this._resolveNamedTexture(e);
@@ -2983,12 +3817,12 @@ var _r = class {
2983
3817
  } : null;
2984
3818
  }
2985
3819
  _textureLayer(e, t) {
2986
- let n = ur(e);
3820
+ let n = xr(e);
2987
3821
  if (!n) return null;
2988
- let r = !n.float && e.colorSpace === F;
2989
- return xn(n, {
3822
+ let r = !n.float && e.colorSpace === P;
3823
+ return Mn(n, {
2990
3824
  channels: t,
2991
- decode: n.float ? null : r ? yn : (e) => e,
3825
+ decode: n.float ? null : r ? An : (e) => e,
2992
3826
  mapping: {
2993
3827
  su: e.repeat.x,
2994
3828
  sv: e.repeat.y,
@@ -3004,7 +3838,7 @@ var _r = class {
3004
3838
  mean: r.rgb[0],
3005
3839
  texture: null
3006
3840
  };
3007
- let i = Sn(r.layer), a = (e) => {
3841
+ let i = Pn(r.layer), a = (e) => {
3008
3842
  if (!e.map) return {
3009
3843
  rgb: e.color.toArray(),
3010
3844
  clamp: !0
@@ -3020,18 +3854,18 @@ var _r = class {
3020
3854
  mean: i,
3021
3855
  texture: null
3022
3856
  };
3023
- let c = wn([
3857
+ let c = Z([
3024
3858
  o,
3025
3859
  s,
3026
3860
  r
3027
- ], Tn);
3861
+ ], In);
3028
3862
  return {
3029
3863
  mean: i,
3030
- texture: c ? hr(c) : null
3864
+ texture: c ? $(c) : null
3031
3865
  };
3032
3866
  }
3033
3867
  _colorFromLikeNamedMaterial(e) {
3034
- for (let t of gr(e)) {
3868
+ for (let t of Hr(e)) {
3035
3869
  let e = (this.ir?.namedMaterials?.get(t))?.params?.reflectance;
3036
3870
  if (e && (e.type === "rgb" || e.type === "color")) return {
3037
3871
  name: t,
@@ -3060,11 +3894,11 @@ var _r = class {
3060
3894
  e[2] * t[0]
3061
3895
  ];
3062
3896
  if (n && r) {
3063
- let e = wn([{
3897
+ let e = Z([{
3064
3898
  ...n,
3065
3899
  clamp: !0
3066
3900
  }, r], i);
3067
- return e ? { texture: hr(e) } : { constant: i([n.rgb, r.rgb]) };
3901
+ return e ? { texture: $(e) } : { constant: i([n.rgb, r.rgb]) };
3068
3902
  }
3069
3903
  this.warn(`texture "${e}": its "scale" texture could not be read here — ignored`);
3070
3904
  }
@@ -3133,14 +3967,16 @@ var _r = class {
3133
3967
  let t = e.params?.screenwindow?.value, i = t?.length === 4 ? (t[3] - t[2]) / 2 : Math.max(1, 1 / n);
3134
3968
  r = new ae(-i * n, i * n, i, -i, .01, 1e4);
3135
3969
  } else r = new oe(this._verticalFov(e.params, n), n, .01, 1e4);
3136
- return r.name = "PBRT Camera", this._poseCamera(r, e.cameraToWorld), r.updateMatrixWorld(!0), r;
3970
+ r.name = "PBRT Camera", this._poseCamera(r, e.cameraToWorld), r.updateMatrixWorld(!0);
3971
+ let i = K(e.params, "lensradius", 0);
3972
+ return i > 0 && (r.userData.__rayzeeEffects = Er(r, i, K(e.params, "focaldistance", 1e6))), r;
3137
3973
  }
3138
3974
  _poseCamera(e, t) {
3139
- let n = t, r = new L(n[12], n[13], n[14]), i = new L(n[8], n[9], n[10]), a = new L(n[4], n[5], n[6]);
3140
- this.convertHandedness && (r.z *= -1, i.z *= -1, a.z *= -1), e.up.copy(a.normalize()), e.position.copy(r), e.scale.set(1, 1, 1), e.lookAt(r.clone().add(i)), Kt(t) > 0 !== this.convertHandedness && (e.scale.x = -1);
3975
+ let n = t, r = new I(n[12], n[13], n[14]), i = new I(n[8], n[9], n[10]), a = new I(n[4], n[5], n[6]);
3976
+ this.convertHandedness && (r.z *= -1, i.z *= -1, a.z *= -1), e.up.copy(a.normalize()), e.position.copy(r), e.scale.set(1, 1, 1), e.lookAt(r.clone().add(i)), Yt(t) > 0 !== this.convertHandedness && (e.scale.x = -1);
3141
3977
  }
3142
3978
  _verticalFov(e, t) {
3143
- let n = X(e, "fov", 90);
3979
+ let n = K(e, "fov", 90);
3144
3980
  if (t >= 1) return n;
3145
3981
  let r = n * Math.PI / 180;
3146
3982
  return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
@@ -3159,14 +3995,14 @@ var _r = class {
3159
3995
  channels: e,
3160
3996
  bottomUp: !0
3161
3997
  };
3162
- } else if (a = lr(i, e.colorSpace === F), !a) return this.warn(`infinite-light image "${r}" could not be read back for octahedral conversion`), null;
3163
- let { data: o, width: s, height: c } = Fn(a, t.ctm, n), l = new b(o, s, c, P, T);
3998
+ } else if (a = br(i, e.colorSpace === P), !a) return this.warn(`infinite-light image "${r}" could not be read back for octahedral conversion`), null;
3999
+ let { data: o, width: s, height: c } = Kn(a, t.ctm, n), l = new b(o, s, c, ue, T);
3164
4000
  return l.mapping = C, l.minFilter = A, l.magFilter = A, l.needsUpdate = !0, l;
3165
4001
  }
3166
4002
  async _buildEnvironment(e) {
3167
4003
  let t = e.find((e) => e.type === "infinite");
3168
4004
  if (!t) return null;
3169
- let n = X(t.params, "scale", 1), r = Z(t.params, "filename", null);
4005
+ let n = K(t.params, "scale", 1), r = q(t.params, "filename", null);
3170
4006
  if (r) try {
3171
4007
  let e = await this.resolveEnvironment(r);
3172
4008
  if (e) {
@@ -3177,12 +4013,12 @@ var _r = class {
3177
4013
  } catch (e) {
3178
4014
  this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
3179
4015
  }
3180
- let i = (await Jn(t.params, "L", {
4016
+ let i = (await ar(t.params, "L", {
3181
4017
  resolveNamedTexture: async () => null,
3182
4018
  warn: (e) => this.warn(e)
3183
4019
  })).map((e) => e * n), a = new Float32Array(8);
3184
4020
  for (let e = 0; e < 2; e++) a[e * 4 + 0] = i[0], a[e * 4 + 1] = i[1], a[e * 4 + 2] = i[2], a[e * 4 + 3] = 1;
3185
- let o = new b(a, 2, 1, P, T);
4021
+ let o = new b(a, 2, 1, ue, T);
3186
4022
  return o.mapping = C, o.minFilter = A, o.magFilter = A, o.needsUpdate = !0, { texture: o };
3187
4023
  }
3188
4024
  async _buildLamps(e, t) {
@@ -3191,11 +4027,11 @@ var _r = class {
3191
4027
  warn: (e) => this.warn(e)
3192
4028
  };
3193
4029
  for (let r of e) {
3194
- if (!qn.has(r.type)) continue;
3195
- let e = new N().fromArray(this.convertHandedness ? q($, r.ctm) : r.ctm), i = (t, n) => {
4030
+ if (!ir.has(r.type)) continue;
4031
+ let e = new N().fromArray(this.convertHandedness ? U(Q, r.ctm) : r.ctm), i = (t, n) => {
3196
4032
  let i = r.params[t]?.value;
3197
- return new L().fromArray(i?.length >= 3 ? i : n).applyMatrix4(e);
3198
- }, a = await Jn(r.params, r.type === "distant" ? "L" : "I", n), o = X(r.params, "scale", 1), s = i("from", [
4033
+ return new I().fromArray(i?.length >= 3 ? i : n).applyMatrix4(e);
4034
+ }, a = await ar(r.params, r.type === "distant" ? "L" : "I", n), o = K(r.params, "scale", 1), s = i("from", [
3199
4035
  0,
3200
4036
  0,
3201
4037
  0
@@ -3205,13 +4041,13 @@ var _r = class {
3205
4041
  1
3206
4042
  ]), l;
3207
4043
  if (r.type === "distant") {
3208
- let e = X(r.params, "illuminance", -1);
4044
+ let e = K(r.params, "illuminance", -1);
3209
4045
  e > 0 && (o *= e), l = new x(), l.userData.__luxConverted = !0;
3210
4046
  } else if (r.type === "point") {
3211
- let e = X(r.params, "power", -1);
4047
+ let e = K(r.params, "power", -1);
3212
4048
  o *= e > 0 ? e : 4 * Math.PI, l = new se(), l.userData.__candelaConverted = !0;
3213
4049
  } else {
3214
- let e = Math.min(Math.max(X(r.params, "coneangle", 30), 0), 90) * Math.PI / 180, t = Math.min(Math.max(X(r.params, "conedeltaangle", 5) * Math.PI / 180, 0), e), n = Math.cos(e), i = Math.cos(e - t), a = X(r.params, "power", -1);
4050
+ let e = Math.min(Math.max(K(r.params, "coneangle", 30), 0), 90) * Math.PI / 180, t = Math.min(Math.max(K(r.params, "conedeltaangle", 5) * Math.PI / 180, 0), e), n = Math.cos(e), i = Math.cos(e - t), a = K(r.params, "power", -1);
3215
4051
  a > 0 && (o *= a / (2 * Math.PI * (1 - i + (i - n) / 2))), o *= 4 * Math.PI, l = new fe(), l.angle = e, l.penumbra = n < 1 ? Math.min((i - n) / (1 - n), 1) : 0, l.userData.__candelaConverted = !0;
3216
4052
  }
3217
4053
  let u = Math.max(a[0], a[1], a[2]);
@@ -3219,10 +4055,10 @@ var _r = class {
3219
4055
  }
3220
4056
  }
3221
4057
  _reportUnsupportedLights(e) {
3222
- for (let t of e) t.type !== "infinite" && !qn.has(t.type) && this.warn(`light "${t.type}" not supported (only infinite, distant, point and spot lights and emissive area lights are mapped)`);
4058
+ for (let t of e) t.type !== "infinite" && !ir.has(t.type) && this.warn(`light "${t.type}" not supported (only infinite, distant, point and spot lights and emissive area lights are mapped)`);
3223
4059
  }
3224
- }, vr = 1e3, yr = 2048, br = 1e5;
3225
- function xr(e) {
4060
+ }, Wr = 1e3, Gr = 2048, Kr = 1e5;
4061
+ function qr(e) {
3226
4062
  let t = e[0], n = (e) => {
3227
4063
  let t = e.lastIndexOf("/"), n = /^(.*?)(\d+)\.pbrt$/i.exec(e.slice(t + 1));
3228
4064
  return n ? {
@@ -3236,70 +4072,70 @@ function xr(e) {
3236
4072
  let e = n(t);
3237
4073
  e && e.group === r.group && !i.has(e.number) && i.set(e.number, t);
3238
4074
  }
3239
- return i.size < 2 ? null : [...i].sort((e, t) => e[0] - t[0]).slice(0, vr).map(([e, t]) => ({
4075
+ return i.size < 2 ? null : [...i].sort((e, t) => e[0] - t[0]).slice(0, Wr).map(([e, t]) => ({
3240
4076
  path: t,
3241
4077
  number: e
3242
4078
  }));
3243
4079
  }
3244
- function Sr(e) {
4080
+ function Jr(e) {
3245
4081
  let t = e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array ? new Uint32Array(e.buffer, e.byteOffset, e.length) : null;
3246
4082
  t ||= new Uint32Array(Float32Array.from(e).buffer);
3247
4083
  let n = 2166136261;
3248
4084
  for (let e = 0; e < t.length; e++) n = Math.imul(n ^ t[e], 16777619), n ^= n >>> 15;
3249
4085
  return (n >>> 0).toString(36) + ":" + e.length;
3250
4086
  }
3251
- function Cr(e) {
4087
+ function Yr(e) {
3252
4088
  let t = "";
3253
4089
  for (let n of Object.keys(e).sort()) {
3254
4090
  let { type: r, value: i } = e[n], a = ArrayBuffer.isView(i) || i.length > 16 && typeof i[0] == "number";
3255
- t += `${r} ${n}=${a ? "#" + Sr(i) : i.join(",")};`;
4091
+ t += `${r} ${n}=${a ? "#" + Jr(i) : i.join(",")};`;
3256
4092
  }
3257
4093
  return t;
3258
4094
  }
3259
- var wr = class {
4095
+ var Xr = class {
3260
4096
  constructor(e) {
3261
4097
  this.materialNames = /* @__PURE__ */ new Map();
3262
4098
  for (let [t, n] of e.namedMaterials) this.materialNames.set(n, t);
3263
4099
  this.cache = /* @__PURE__ */ new Map();
3264
4100
  }
3265
4101
  of(e) {
3266
- return `${e.type}|${+!!e.reverseOrientation}|${Cr(e.params)}|${this._material(e.material)}|${this._light(e.areaLight)}`;
4102
+ return `${e.type}|${+!!e.reverseOrientation}|${Yr(e.params)}|${this._material(e.material)}|${this._light(e.areaLight)}`;
3267
4103
  }
3268
4104
  _material(e) {
3269
4105
  if (!e) return "-";
3270
4106
  let t = this.cache.get(e);
3271
4107
  if (t === void 0) {
3272
4108
  let n = this.materialNames.get(e) ?? e._missingRef;
3273
- t = n === void 0 ? "I:" + e.type + ":" + Cr(e.params) : "N:" + n, this.cache.set(e, t);
4109
+ t = n === void 0 ? "I:" + e.type + ":" + Yr(e.params) : "N:" + n, this.cache.set(e, t);
3274
4110
  }
3275
4111
  return t;
3276
4112
  }
3277
4113
  _light(e) {
3278
4114
  if (!e) return "-";
3279
4115
  let t = this.cache.get(e);
3280
- return t === void 0 && this.cache.set(e, t = "L:" + e.type + ":" + Cr(e.params)), t;
4116
+ return t === void 0 && this.cache.set(e, t = "L:" + e.type + ":" + Yr(e.params)), t;
3281
4117
  }
3282
4118
  };
3283
- function Tr(e, t) {
4119
+ function Zr(e, t) {
3284
4120
  let n = new Int32Array(t.length).fill(-1), r = 0;
3285
4121
  for (; r < e.length && r < t.length && e[r] === t[r];) n[r] = r, r++;
3286
4122
  let i = e.length, a = t.length;
3287
4123
  for (; i > r && a > r && e[i - 1] === t[a - 1];) n[--a] = --i;
3288
- return r < i && r < a && !Er(e, r, i, t, r, a, n) && Or(e, r, i, t, r, a, n), n;
4124
+ return r < i && r < a && !Qr(e, r, i, t, r, a, n) && ei(e, r, i, t, r, a, n), n;
3289
4125
  }
3290
- function Er(e, t, n, r, i, a, o) {
3291
- let s = n - t, c = a - i, l = Math.min(s + c, yr), u = l + 1, d = new Int32Array(2 * l + 3), f = [];
4126
+ function Qr(e, t, n, r, i, a, o) {
4127
+ let s = n - t, c = a - i, l = Math.min(s + c, Gr), u = l + 1, d = new Int32Array(2 * l + 3), f = [];
3292
4128
  for (let n = 0; n <= l; n++) {
3293
4129
  for (let a = -n; a <= n; a += 2) {
3294
4130
  let l = a === -n || a !== n && d[u + a - 1] < d[u + a + 1] ? d[u + a + 1] : d[u + a - 1] + 1, p = l - a;
3295
4131
  for (; l < s && p < c && e[t + l] === r[i + p];) l++, p++;
3296
- if (d[u + a] = l, l >= s && p >= c) return f.push(d.slice(u - n, u + n + 1)), Dr(f, s, c, t, i, o), !0;
4132
+ if (d[u + a] = l, l >= s && p >= c) return f.push(d.slice(u - n, u + n + 1)), $r(f, s, c, t, i, o), !0;
3297
4133
  }
3298
4134
  f.push(d.slice(u - n, u + n + 1));
3299
4135
  }
3300
4136
  return !1;
3301
4137
  }
3302
- function Dr(e, t, n, r, i, a) {
4138
+ function $r(e, t, n, r, i, a) {
3303
4139
  let o = t, s = n;
3304
4140
  for (let t = e.length - 1; t > 0; t--) {
3305
4141
  let n = e[t - 1], c = (e) => n[e + t - 1], l = o - s, u = l === -t || l !== t && c(l - 1) < c(l + 1) ? l + 1 : l - 1, d = c(u), f = d - u;
@@ -3308,7 +4144,7 @@ function Dr(e, t, n, r, i, a) {
3308
4144
  }
3309
4145
  for (; o > 0 && s > 0;) a[i + --s] = r + --o;
3310
4146
  }
3311
- function Or(e, t, n, r, i, a, o) {
4147
+ function ei(e, t, n, r, i, a, o) {
3312
4148
  let s = /* @__PURE__ */ new Map();
3313
4149
  for (let r = t; r < n; r++) {
3314
4150
  let t = s.get(e[r]);
@@ -3322,11 +4158,11 @@ function Or(e, t, n, r, i, a, o) {
3322
4158
  n < t.length && (o[e] = t[n], c.set(r[e], n + 1));
3323
4159
  }
3324
4160
  }
3325
- function kr(e, t, n, r) {
4161
+ function ti(e, t, n, r) {
3326
4162
  for (let i = 0; i < 16; i++) if (e[t + i] !== n[r + i]) return !1;
3327
4163
  return !0;
3328
4164
  }
3329
- function Ar(e, t, n) {
4165
+ function ni(e, t, n) {
3330
4166
  let r = e.length, i = new Float32Array(16 * r), a = null, o = -1;
3331
4167
  for (let e = 0; e < r; e++) if (t(e)) {
3332
4168
  if (i.set(n(e), e * 16), o < 0) for (let t = 0; t < e; t++) i.copyWithin(t * 16, e * 16, e * 16 + 16);
@@ -3338,13 +4174,13 @@ function Ar(e, t, n) {
3338
4174
  visible: a
3339
4175
  };
3340
4176
  }
3341
- function jr(e) {
4177
+ function ri(e) {
3342
4178
  if (e.visible) return !1;
3343
4179
  let t = e.matrices;
3344
- for (let e = 16; e < t.length; e += 16) if (!kr(t, 0, t, e)) return !1;
4180
+ for (let e = 16; e < t.length; e += 16) if (!ti(t, 0, t, e)) return !1;
3345
4181
  return !0;
3346
4182
  }
3347
- var Mr = class {
4183
+ var ii = class {
3348
4184
  constructor(e, t) {
3349
4185
  this.times = Float32Array.from(e), this.name = t, this.base = null, this.frame = -1, this.keyIds = /* @__PURE__ */ new Map(), this.tracks = [], this.prev = null, this.placements = /* @__PURE__ */ new Map(), this.templates = /* @__PURE__ */ new Map(), this.cameras = [], this.warnings = /* @__PURE__ */ new Set();
3350
4186
  }
@@ -3352,15 +4188,15 @@ var Mr = class {
3352
4188
  let t = ++this.frame;
3353
4189
  t === 0 ? this.base = e : this._adoptDefinitions(e);
3354
4190
  for (let t of e.warnings) this.warnings.add(t);
3355
- let n = new wr(e), r = new Int32Array(e.shapes.length);
4191
+ let n = new Xr(e), r = new Int32Array(e.shapes.length);
3356
4192
  for (let t = 0; t < r.length; t++) {
3357
4193
  let i = n.of(e.shapes[t]), a = this.keyIds.get(i);
3358
4194
  a === void 0 && this.keyIds.set(i, a = this.keyIds.size), r[t] = a;
3359
4195
  }
3360
- let i = this.prev ? Tr(this.prev.keys, r) : null, a = Array(r.length);
4196
+ let i = this.prev ? Zr(this.prev.keys, r) : null, a = Array(r.length);
3361
4197
  for (let o = 0; o < r.length; o++) {
3362
4198
  let r = e.shapes[o], s = i && i[o] >= 0 ? this.prev.tracks[i[o]] : null;
3363
- s ? (s.last = t, s.ctms ? s.ctms.push(r.ctm) : r.ctm !== s.shape.ctm && !kr(r.ctm, 0, s.shape.ctm, 0) && (s.ctms = Array(t - s.first).fill(s.shape.ctm), s.ctms.push(r.ctm))) : (s = {
4199
+ s ? (s.last = t, s.ctms ? s.ctms.push(r.ctm) : r.ctm !== s.shape.ctm && !ti(r.ctm, 0, s.shape.ctm, 0) && (s.ctms = Array(t - s.first).fill(s.shape.ctm), s.ctms.push(r.ctm))) : (s = {
3364
4200
  shape: r,
3365
4201
  first: t,
3366
4202
  last: t,
@@ -3407,7 +4243,7 @@ var Mr = class {
3407
4243
  let o = this.base.instances.get(e), s = o?.count ?? 0;
3408
4244
  for (let e = 0; e < i.count; e++) {
3409
4245
  let n = e * 16;
3410
- if (e < s && kr(i.matrices, n, o.matrices, n)) continue;
4246
+ if (e < s && ti(i.matrices, n, o.matrices, n)) continue;
3411
4247
  let r = a.diffs.get(e);
3412
4248
  r || a.diffs.set(e, r = /* @__PURE__ */ new Map()), r.set(t, i.matrices.slice(n, n + 16));
3413
4249
  }
@@ -3417,12 +4253,12 @@ var Mr = class {
3417
4253
  let e = this.base, t = this.times, n = this.frame + 1;
3418
4254
  e.shapes = this.tracks.map((e) => {
3419
4255
  let { shape: r, first: i, last: a, ctms: o } = e;
3420
- return (i > 0 || a < n - 1 || o) && (r.motion = Ar(t, (e) => e >= i && e <= a, (e) => o ? o[e - i] : r.ctm)), r;
4256
+ return (i > 0 || a < n - 1 || o) && (r.motion = ni(t, (e) => e >= i && e <= a, (e) => o ? o[e - i] : r.ctm)), r;
3421
4257
  }), e.warnings = [...this.warnings], e.animatedInstances = this._finishPlacements(e, t, n);
3422
4258
  let r = this.cameras;
3423
4259
  if (r[0] && r.every(Boolean)) {
3424
- let n = Ar(t, () => !0, (e) => r[e].cameraToWorld), i = r.map((e) => e.fov ?? r[0].fov), a = i.some((e) => e !== i[0]);
3425
- (!jr(n) || a) && (e.camera.motion = {
4260
+ let n = ni(t, () => !0, (e) => r[e].cameraToWorld), i = r.map((e) => e.fov ?? r[0].fov), a = i.some((e) => e !== i[0]);
4261
+ (!ri(n) || a) && (e.camera.motion = {
3426
4262
  ...n,
3427
4263
  fov: a ? Float32Array.from(i) : null
3428
4264
  });
@@ -3440,8 +4276,8 @@ var Mr = class {
3440
4276
  for (let e = 0; e < u; e++) {
3441
4277
  let u = s.get(e), f = !!u;
3442
4278
  for (let t = 0; t < n && !f; t++) f = e >= o[t];
3443
- if (f && r.length < br) {
3444
- let n = Ar(t, (t) => e < o[t], (t) => u?.get(t) ?? c.matrices.subarray(e * 16, e * 16 + 16));
4279
+ if (f && r.length < Kr) {
4280
+ let n = ni(t, (t) => e < o[t], (t) => u?.get(t) ?? c.matrices.subarray(e * 16, e * 16 + 16));
3445
4281
  r.push({
3446
4282
  name: a,
3447
4283
  motion: n
@@ -3453,10 +4289,10 @@ var Mr = class {
3453
4289
  d.forEach((e, n) => t.set(c.matrices.subarray(e * 16, e * 16 + 16), n * 16)), e.instanceCount -= l - d.length, c.matrices = t, c.matricesEnd = null, c.count = d.length;
3454
4290
  }
3455
4291
  }
3456
- return i > 0 && e.warnings.push(`${i.toLocaleString()} moving placement(s) past ${br.toLocaleString()} left static`), r;
4292
+ return i > 0 && e.warnings.push(`${i.toLocaleString()} moving placement(s) past ${Kr.toLocaleString()} left static`), r;
3457
4293
  }
3458
4294
  };
3459
- function Nr(e) {
4295
+ function ai(e) {
3460
4296
  if (!e.hasMotion) return e;
3461
4297
  let { start: t, end: n } = e.transformTimes, r = n - t;
3462
4298
  if (!(r > 0)) return e;
@@ -3476,7 +4312,7 @@ function Nr(e) {
3476
4312
  let n = [];
3477
4313
  for (let r = 0; r < t.count; r++) {
3478
4314
  let i = r * 16;
3479
- kr(t.matrices, i, t.matricesEnd, i) || e.animatedInstances.length >= br ? n.push(r) : e.animatedInstances.push({
4315
+ ti(t.matrices, i, t.matricesEnd, i) || e.animatedInstances.length >= Kr ? n.push(r) : e.animatedInstances.push({
3480
4316
  name: t.name,
3481
4317
  motion: a(t.matrices, i, t.matricesEnd, i)
3482
4318
  });
@@ -3498,20 +4334,20 @@ function Nr(e) {
3498
4334
  }
3499
4335
  //#endregion
3500
4336
  //#region src/Processor/PBRT/index.js
3501
- var Pr = 2e6, Fr = new TextDecoder();
3502
- function Ir(e) {
4337
+ var oi = 2e6, si = new TextDecoder();
4338
+ function ci(e) {
3503
4339
  let t = e.replace(/\\/g, "/").split("/"), n = [];
3504
4340
  for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
3505
4341
  return n.join("/");
3506
4342
  }
3507
- function Lr(e, t) {
3508
- return !e || t.startsWith("/") ? Ir(t) : Ir(`${e}/${t}`);
4343
+ function li(e, t) {
4344
+ return !e || t.startsWith("/") ? ci(t) : ci(`${e}/${t}`);
3509
4345
  }
3510
- var Rr = class {
4346
+ var ui = class {
3511
4347
  constructor(e, t = null) {
3512
4348
  this.entries = e, this.source = t, this.records = [], this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
3513
4349
  let n = (e, t, n) => {
3514
- let r = Ir(e).toLowerCase();
4350
+ let r = ci(e).toLowerCase();
3515
4351
  if (this.byPath.has(r)) return;
3516
4352
  let i = {
3517
4353
  key: e,
@@ -3533,21 +4369,21 @@ var Rr = class {
3533
4369
  return e ? e.bytes ? e.bytes.subarray(0, t) : !e.lazy || !this.source ? null : this.source.readHead ? this.source.readHead(e.key, t) : this.source.read(e.key) : null;
3534
4370
  }
3535
4371
  async readPath(e, t = null) {
3536
- let n = t !== null && this.findRecord(Lr(t, e)) || this.findRecord(e);
4372
+ let n = t !== null && this.findRecord(li(t, e)) || this.findRecord(e);
3537
4373
  return this.read(n);
3538
4374
  }
3539
4375
  release(e) {
3540
4376
  e.bytes = null, delete this.entries[e.key];
3541
4377
  }
3542
4378
  releasePath(e, t = null, n = null) {
3543
- let r = t !== null && this.findRecord(Lr(t, e)) || this.findRecord(e);
3544
- r?.lazy && (this.release(r), H(n));
4379
+ let r = t !== null && this.findRecord(li(t, e)) || this.findRecord(e);
4380
+ r?.lazy && (this.release(r), z(n));
3545
4381
  }
3546
4382
  releaseScenes() {
3547
4383
  for (let e of this.records) e.norm.endsWith(".pbrt") && this.release(e);
3548
4384
  }
3549
4385
  findRecord(e) {
3550
- let t = Ir(e).toLowerCase();
4386
+ let t = ci(e).toLowerCase();
3551
4387
  if (this.byPath.has(t)) return this.byPath.get(t);
3552
4388
  let n = this.byBase.get(t.split("/").pop());
3553
4389
  return n ? n.find((e) => e.norm.endsWith("/" + t)) || (n.length === 1 ? n[0] : null) : null;
@@ -3556,7 +4392,7 @@ var Rr = class {
3556
4392
  return this.findRecord(e)?.bytes ?? null;
3557
4393
  }
3558
4394
  };
3559
- function zr(e, t, n = 0) {
4395
+ function di(e, t, n = 0) {
3560
4396
  let r = t[0], i = e.length - t.length;
3561
4397
  outer: for (let a = n; a <= i; a++) if (e[a] === r) {
3562
4398
  for (let n = 1; n < t.length; n++) if (e[a + n] !== t[n]) continue outer;
@@ -3564,8 +4400,8 @@ function zr(e, t, n = 0) {
3564
4400
  }
3565
4401
  return -1;
3566
4402
  }
3567
- var Br = (e) => Uint8Array.from(e, (e) => e.charCodeAt(0)), Vr = 4 * 1024 * 1024, Hr = Br("WorldBegin"), Ur = [Br("Include"), Br("Import")];
3568
- function Wr(e, t) {
4403
+ var fi = (e) => Uint8Array.from(e, (e) => e.charCodeAt(0)), pi = 4 * 1024 * 1024, mi = fi("WorldBegin"), hi = [fi("Include"), fi("Import")];
4404
+ function gi(e, t) {
3569
4405
  for (let n = t - 1; n >= 0; n--) {
3570
4406
  let t = e[n];
3571
4407
  if (t === 10) return !0;
@@ -3573,34 +4409,34 @@ function Wr(e, t) {
3573
4409
  }
3574
4410
  return !0;
3575
4411
  }
3576
- function Gr(e) {
3577
- for (let t = zr(e, Hr); t >= 0; t = zr(e, Hr, t + 1)) if (Wr(e, t)) return !0;
4412
+ function _i(e) {
4413
+ for (let t = di(e, mi); t >= 0; t = di(e, mi, t + 1)) if (gi(e, t)) return !0;
3578
4414
  return !1;
3579
4415
  }
3580
- function Kr(e, t) {
3581
- for (let n of Ur) for (let r = zr(e, n); r >= 0; r = zr(e, n, r + 1)) {
3582
- if (!Wr(e, r)) continue;
4416
+ function vi(e, t) {
4417
+ for (let n of hi) for (let r = di(e, n); r >= 0; r = di(e, n, r + 1)) {
4418
+ if (!gi(e, r)) continue;
3583
4419
  let i = r + n.length;
3584
4420
  for (; i < e.length && (e[i] === 32 || e[i] === 9);) i++;
3585
4421
  if (e[i] !== 34) continue;
3586
4422
  let a = ++i;
3587
4423
  for (; i < e.length && e[i] !== 34 && e[i] !== 10;) i++;
3588
4424
  if (e[i] !== 34) continue;
3589
- let o = Fr.decode(e.subarray(a, i));
3590
- t.add(Ir(o).toLowerCase().split("/").pop());
4425
+ let o = si.decode(e.subarray(a, i));
4426
+ t.add(ci(o).toLowerCase().split("/").pop());
3591
4427
  }
3592
4428
  }
3593
- function qr(e) {
4429
+ function yi(e) {
3594
4430
  let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
3595
4431
  if (t.length <= 1) return t;
3596
4432
  let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
3597
4433
  for (let i of t) {
3598
4434
  let t = e[i];
3599
- r.set(i, Gr(t)), Kr(t, n);
4435
+ r.set(i, _i(t)), vi(t, n);
3600
4436
  }
3601
- return Jr(t, r, n);
4437
+ return bi(t, r, n);
3602
4438
  }
3603
- function Jr(e, t, n) {
4439
+ function bi(e, t, n) {
3604
4440
  let r = (e, t) => {
3605
4441
  let n = e.filter(t);
3606
4442
  return n.length ? n : e;
@@ -3610,10 +4446,10 @@ function Jr(e, t, n) {
3610
4446
  return n === r ? e.length === t.length ? e < t ? -1 : +(e > t) : e.length - t.length : n - r;
3611
4447
  });
3612
4448
  }
3613
- function Yr(e) {
3614
- return qr(e)[0] || null;
4449
+ function xi(e) {
4450
+ return yi(e)[0] || null;
3615
4451
  }
3616
- async function Xr(e) {
4452
+ async function Si(e) {
3617
4453
  let t = e.records.filter((e) => e.norm.endsWith(".pbrt"));
3618
4454
  if (t.length === 0) return [];
3619
4455
  if (t.length === 1) return [t[0].key];
@@ -3621,48 +4457,48 @@ async function Xr(e) {
3621
4457
  let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = !1;
3622
4458
  for (let o of t) {
3623
4459
  let t = await n(o);
3624
- t && (i.set(o.key, Gr(t)), Kr(t, r), t.length >= Vr && (a = !0), o.lazy && (e.release(o), H(t)));
4460
+ t && (i.set(o.key, _i(t)), vi(t, r), t.length >= pi && (a = !0), o.lazy && (e.release(o), z(t)));
3625
4461
  }
3626
4462
  return {
3627
4463
  included: r,
3628
4464
  worlds: i,
3629
4465
  cut: a
3630
4466
  };
3631
- }, r = await n((t) => e.readHead(t, Vr)), { included: i, worlds: a } = [...r.worlds.values()].filter(Boolean).length === 1 || !r.cut ? r : await n((t) => e.read(t));
3632
- return Jr(t.map((e) => e.key), a, i);
4467
+ }, r = await n((t) => e.readHead(t, pi)), { included: i, worlds: a } = [...r.worlds.values()].filter(Boolean).length === 1 || !r.cut ? r : await n((t) => e.read(t));
4468
+ return bi(t.map((e) => e.key), a, i);
3633
4469
  }
3634
- async function Zr(e) {
3635
- let { vfs: t, source: n, plyParser: r, imageFromBytes: i, envFromBytes: a, convertHandedness: o } = e, s = new Rr(t, n), c = [], l = await Xr(s);
4470
+ async function Ci(e) {
4471
+ let { vfs: t, source: n, plyParser: r, imageFromBytes: i, envFromBytes: a, convertHandedness: o } = e, s = new ui(t, n), c = [], l = await Si(s);
3636
4472
  if (l.length === 0) throw Error("PBRT loader: no .pbrt file found in archive");
3637
4473
  let u = e.entryPath && l.includes(e.entryPath) ? e.entryPath : null;
3638
4474
  e.entryPath && !u && c.push(`PBRT entry "${e.entryPath}" is not a scene in this archive — auto-detecting instead`);
3639
4475
  let d = u || l[0], f = async (t) => {
3640
4476
  let n = await s.readPath(t);
3641
4477
  if (!n) throw Error(`PBRT loader: entry "${t}" not readable`);
3642
- let r = await new cn({
4478
+ let r = await new dn({
3643
4479
  resolveInclude: (e, t) => s.readPath(e, t),
3644
4480
  releaseInclude: (e, t, n) => s.releasePath(e, t, n),
3645
4481
  maxPlacements: e.maxPlacements,
3646
4482
  instanceIncludes: e.instanceIncludes
3647
4483
  }).parse(n, t.includes("/") ? t.slice(0, t.lastIndexOf("/")) : "");
3648
4484
  return s.releasePath(t, null, n), r;
3649
- }, p = performance.now(), m = !u && e.animation !== !1 ? xr(l) : null, h;
4485
+ }, p = performance.now(), m = !u && e.animation !== !1 ? qr(l) : null, h;
3650
4486
  if (m) {
3651
4487
  let e = await f(m[0].path);
3652
- if (e.shapes.length + e.instanceCount > Pr) c.push(`${m.length} animation frames found, but the scene is too large to parse once per frame — loaded "${m[0].path}" only`), m = null, h = Nr(e);
4488
+ if (e.shapes.length + e.instanceCount > oi) c.push(`${m.length} animation frames found, but the scene is too large to parse once per frame — loaded "${m[0].path}" only`), m = null, h = ai(e);
3653
4489
  else {
3654
- let t = new Mr(m.map((e) => (e.number - m[0].number) / 30), Qr(m));
4490
+ let t = new ii(m.map((e) => (e.number - m[0].number) / 30), wi(m));
3655
4491
  t.addFrame(e);
3656
4492
  for (let e = 1; e < m.length; e++) t.addFrame(await f(m[e].path));
3657
4493
  h = t.finish();
3658
4494
  }
3659
- } else h = Nr(await f(d));
4495
+ } else h = ai(await f(d));
3660
4496
  let g = performance.now() - p;
3661
4497
  s.releaseScenes();
3662
4498
  let _ = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), v = /* @__PURE__ */ new Map(), y = async (e) => {
3663
4499
  let t = await s.read(e);
3664
4500
  return t ? (s.release(e), r(_(t))) : null;
3665
- }, b = new _r({
4501
+ }, b = new Ur({
3666
4502
  convertHandedness: o,
3667
4503
  maxTriangles: e.maxTriangles,
3668
4504
  maxPlacements: e.maxPlacements,
@@ -3693,13 +4529,13 @@ async function Zr(e) {
3693
4529
  buildMs: performance.now() - x
3694
4530
  };
3695
4531
  }
3696
- function Qr(e) {
4532
+ function wi(e) {
3697
4533
  let t = e[0].path.split("/");
3698
4534
  return `${t.length > 1 ? t[t.length - 2] : t[0].replace(/\d+\.pbrt$/i, "") || "frames"} · frames ${e[0].number}–${e[e.length - 1].number}`;
3699
4535
  }
3700
4536
  //#endregion
3701
4537
  //#region src/Processor/PBRT/PFM.js
3702
- function $r(e) {
4538
+ function Ti(e) {
3703
4539
  let t = 0, n = () => {
3704
4540
  for (; t < e.length && e[t] <= 32;) t++;
3705
4541
  let n = t;
@@ -3723,16 +4559,16 @@ function $r(e) {
3723
4559
  height: a
3724
4560
  };
3725
4561
  }
3726
- function ei(e) {
3727
- let { data: t, width: n, height: r } = $r(e), i = new b(t, n, r, P, T);
4562
+ function Ei(e) {
4563
+ let { data: t, width: n, height: r } = Ti(e), i = new b(t, n, r, ue, T);
3728
4564
  return i.minFilter = A, i.magFilter = A, i.needsUpdate = !0, i;
3729
4565
  }
3730
4566
  //#endregion
3731
4567
  //#region src/Processor/ArchiveImporter.js
3732
- var ti = /* @__PURE__ */ e({
3733
- ARCHIVE_ELEMENT_PROMPT_BYTES: () => ai,
3734
- ArchiveImporter: () => oi
3735
- }), ni = /\.(usd|usda|usdc)$/i, ri = /\.(png|jpg|jpeg|avif)$/i, ii = 3e4, ai = 4e9, oi = class e {
4568
+ var Di = /* @__PURE__ */ e({
4569
+ ARCHIVE_ELEMENT_PROMPT_BYTES: () => ji,
4570
+ ArchiveImporter: () => Mi
4571
+ }), Oi = /\.(usd|usda|usdc)$/i, ki = /\.(png|jpg|jpeg|avif)$/i, Ai = 3e4, ji = 4e9, Mi = class e {
3736
4572
  static FORMATS = f;
3737
4573
  constructor(e) {
3738
4574
  this.loader = e, this._pendingGraph = null, this.lastPBRTStats = null;
@@ -3744,22 +4580,22 @@ var ti = /* @__PURE__ */ e({
3744
4580
  return e instanceof Uint8Array ? e.subarray(0, t) : typeof e.slice == "function" && typeof e.arrayBuffer == "function" ? new Uint8Array(await e.slice(0, t).arrayBuffer()) : new Uint8Array((await this.loader.readFileAsArrayBuffer(e)).slice(0, t));
3745
4581
  }
3746
4582
  async inspectArchive(e) {
3747
- let n = Te(await this._readHead(e)), r = (e) => t({
4583
+ let n = Ee(await this._readHead(e)), r = (e) => t({
3748
4584
  isLoading: !0,
3749
4585
  status: `Scanning archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
3750
4586
  progress: 4
3751
4587
  }), i;
3752
4588
  if (n === "gzip") {
3753
4589
  let t = await this._unpackGzip(e, e.name);
3754
- t ? (i = t.index.listing, t.release()) : {listing: i} = await Le(e, {
4590
+ t ? (i = t.index.listing, t.release()) : {listing: i} = await ze(e, {
3755
4591
  filter: () => !1,
3756
4592
  onProgress: r
3757
4593
  });
3758
- } else i = n === "tar" ? (await Je(e, this.loader.storage))?.listing ?? await ze(e, { onProgress: r }) : (await p(e)).map((e) => ({
4594
+ } else i = n === "tar" ? (await Xe(e, this.loader.storage))?.listing ?? await Ve(e, { onProgress: r }) : (await p(e)).map((e) => ({
3759
4595
  path: e.name,
3760
4596
  size: e.size
3761
4597
  }));
3762
- let { root: a, elements: o } = Ue(i);
4598
+ let { root: a, elements: o } = Ge(i);
3763
4599
  return {
3764
4600
  kind: n ?? "zip",
3765
4601
  root: a,
@@ -3768,11 +4604,16 @@ var ti = /* @__PURE__ */ e({
3768
4604
  totalBytes: i.reduce((e, t) => e + t.size, 0)
3769
4605
  };
3770
4606
  }
3771
- async _unpackGzip(e, n) {
4607
+ async _unpackGzip(e, n, r = null) {
4608
+ let i = (Array.isArray(r) ? r : [r]).filter(Boolean);
3772
4609
  try {
3773
- return await qe(e, {
4610
+ return await Ye(e, {
3774
4611
  storage: this.loader.storage,
3775
4612
  label: n,
4613
+ ...i.length ? {
4614
+ filter: We(i),
4615
+ part: [...i].sort().join(",")
4616
+ } : {},
3776
4617
  onProgress: (e) => t({
3777
4618
  isLoading: !0,
3778
4619
  status: `Unpacking archive… ${(e / 1e9).toFixed(1)} GB`,
@@ -3785,7 +4626,7 @@ var ti = /* @__PURE__ */ e({
3785
4626
  }
3786
4627
  async loadArchiveFromFile(e, t, { pbrtEntry: n = null, element: r = null, byteBudget: i, promptBytes: a, ...o } = {}) {
3787
4628
  try {
3788
- let s = Te(await this._readHead(e)), c = this.loader.storage ? u(await l(e)) : null, d = {
4629
+ let s = Ee(await this._readHead(e)), c = this.loader.storage ? u(await l(e)) : null, d = {
3789
4630
  element: r,
3790
4631
  promptBytes: a,
3791
4632
  pbrtEntry: n,
@@ -3794,7 +4635,7 @@ var ti = /* @__PURE__ */ e({
3794
4635
  };
3795
4636
  if (s === "tar") return await this._loadSeekable(e, t, d);
3796
4637
  if (s === "gzip") {
3797
- let a = await this._unpackGzip(e, t);
4638
+ let a = await this._unpackGzip(e, t, r);
3798
4639
  if (a) try {
3799
4640
  return await this._loadSeekable(a.file, t, {
3800
4641
  ...d,
@@ -3804,7 +4645,7 @@ var ti = /* @__PURE__ */ e({
3804
4645
  a.release();
3805
4646
  }
3806
4647
  let l = await this._readStreamedArchive(e, t, s, r, i);
3807
- if (Yr(l)) return await this.loadPBRTFromZip(l, t, n, o);
4648
+ if (xi(l)) return await this.loadPBRTFromZip(l, t, n, o);
3808
4649
  let u = await this._loadNonPBRTArchive(l, t);
3809
4650
  return this.loader._sourceKey = this.loader._keyed("archive", c), u;
3810
4651
  }
@@ -3839,7 +4680,7 @@ var ti = /* @__PURE__ */ e({
3839
4680
  status: "Opening the stored scene...",
3840
4681
  progress: 6
3841
4682
  });
3842
- let e = await c.json("graph.json"), a = await c.file("data.bin"), o = new Rr({}, n), s = await xt(e, a, { loadTexture: async (e, t) => {
4683
+ let e = await c.json("graph.json"), a = await c.file("data.bin"), o = new ui({}, n), s = await Ct(e, a, { loadTexture: async (e, t) => {
3843
4684
  let n = await o.readPath(e);
3844
4685
  return n ? t === "environment" ? i(n, e) : r(n, e) : null;
3845
4686
  } });
@@ -3864,7 +4705,7 @@ var ti = /* @__PURE__ */ e({
3864
4705
  if (!i) return;
3865
4706
  let a;
3866
4707
  try {
3867
- a = mt(t.group, {
4708
+ a = gt(t.group, {
3868
4709
  environment: t.environment?.texture ?? null,
3869
4710
  animations: t.animations ?? [],
3870
4711
  stats: {
@@ -3877,11 +4718,12 @@ var ti = /* @__PURE__ */ e({
3877
4718
  placementCount: t.placementCount,
3878
4719
  mergedShapes: t.mergedShapes,
3879
4720
  skippedForBudget: t.skippedForBudget,
3880
- droppedNoTemplate: t.droppedNoTemplate
4721
+ droppedNoTemplate: t.droppedNoTemplate,
4722
+ render: t.render ?? null
3881
4723
  }
3882
4724
  });
3883
4725
  } catch (e) {
3884
- e instanceof V ? console.info(`Scene not stored for next time: ${e.message}`) : console.warn("Scene not stored for next time:", e);
4726
+ e instanceof R ? console.info(`Scene not stored for next time: ${e.message}`) : console.warn("Scene not stored for next time:", e);
3885
4727
  return;
3886
4728
  }
3887
4729
  let o = {
@@ -3906,18 +4748,18 @@ var ti = /* @__PURE__ */ e({
3906
4748
  expectedBytes: t.encoded.byteLength
3907
4749
  });
3908
4750
  if (n) try {
3909
- await ht(n, t.encoded, { release: !0 }), await n.commit({ triangles: t.triangles });
4751
+ await _t(n, t.encoded, { release: !0 }), await n.commit({ triangles: t.triangles });
3910
4752
  } catch (e) {
3911
4753
  await n.abort(), console.warn("Storing the scene failed:", e);
3912
4754
  }
3913
4755
  })().catch((e) => console.warn("Storing the scene failed:", e));
3914
4756
  }
3915
4757
  async _openSeekableArchive(e, n, r, i, { index: a = null, zip: o = !1 } = {}) {
3916
- let s = Array.isArray(r) ? r.filter(Boolean) : r ? [r] : [], c = s.length ? He(s) : null, l;
4758
+ let s = Array.isArray(r) ? r.filter(Boolean) : r ? [r] : [], c = s.length ? We(s) : null, l;
3917
4759
  if (o) l = await m(e, { filter: c });
3918
4760
  else {
3919
- let n = a ?? await Je(e, this.loader.storage);
3920
- l = await Ve(e, {
4761
+ let n = a ?? await Xe(e, this.loader.storage);
4762
+ l = await Ue(e, {
3921
4763
  index: n,
3922
4764
  headersOnly: !0,
3923
4765
  filter: c,
@@ -3926,14 +4768,14 @@ var ti = /* @__PURE__ */ e({
3926
4768
  status: `Indexing archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
3927
4769
  progress: 4
3928
4770
  })
3929
- }), n || Ye(e, this.loader.storage, l.index).catch(() => {});
4771
+ }), n || Ze(e, this.loader.storage, l.index).catch(() => {});
3930
4772
  }
3931
4773
  let u = l.listing.reduce((e, t) => e + t.size, 0);
3932
4774
  return s.length === 0 && this._requireElementChoice(n, l.listing, u, i), console.info(`Archive "${n}": indexed ${l.indexed} entries, ${(u / 1e9).toFixed(1)} GB, none resident` + (s.length ? `, ${s.length} part${s.length > 1 ? "s" : ""} selected.` : ".")), l;
3933
4775
  }
3934
- _requireElementChoice(e, t, n, r = ai) {
4776
+ _requireElementChoice(e, t, n, r = ji) {
3935
4777
  if (n < r) return;
3936
- let { root: i, elements: s } = Ue(t);
4778
+ let { root: i, elements: s } = Ge(t);
3937
4779
  if (s.length < 2) return;
3938
4780
  let c = /* @__PURE__ */ Error(`"${e}" holds ${(n / 1e9).toFixed(1)} GB across ${s.length} parts. Choose which to load — loading all of them at once may exhaust memory.`);
3939
4781
  throw c.code = "ARCHIVE_NEEDS_ELEMENT", c.root = i, c.elements = s, c.totalBytes = n, this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `archive holds ${(n / 1e9).toFixed(1)} GB across ${s.length} parts; choose which to load`, {
@@ -3943,8 +4785,8 @@ var ti = /* @__PURE__ */ e({
3943
4785
  }, o.WARNING), c;
3944
4786
  }
3945
4787
  async _readStreamedArchive(e, n, r, i, s) {
3946
- let c = Array.isArray(i) ? i.filter(Boolean) : i ? [i] : [], { entries: l, listing: u, retainedBytes: d, truncated: f } = await Le(e, {
3947
- filter: c.length ? He(c) : null,
4788
+ let c = Array.isArray(i) ? i.filter(Boolean) : i ? [i] : [], { entries: l, listing: u, retainedBytes: d, truncated: f } = await ze(e, {
4789
+ filter: c.length ? We(c) : null,
3948
4790
  ...s === void 0 ? {} : { byteBudget: s },
3949
4791
  onProgress: (e) => t({
3950
4792
  isLoading: !0,
@@ -3953,7 +4795,7 @@ var ti = /* @__PURE__ */ e({
3953
4795
  })
3954
4796
  });
3955
4797
  if (f && c.length === 0) {
3956
- let { root: e, elements: t } = Ue(u), r = u.reduce((e, t) => e + t.size, 0), i = /* @__PURE__ */ Error(`"${n}" unpacks to ${(r / 1e9).toFixed(1)} GB, past the load budget. Load one of its ${t.length} parts instead.`);
4798
+ let { root: e, elements: t } = Ge(u), r = u.reduce((e, t) => e + t.size, 0), i = /* @__PURE__ */ Error(`"${n}" unpacks to ${(r / 1e9).toFixed(1)} GB, past the load budget. Load one of its ${t.length} parts instead.`);
3957
4799
  throw i.code = "ARCHIVE_NEEDS_ELEMENT", i.root = e, i.elements = t, i.totalBytes = r, this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `archive unpacks to ${(r / 1e9).toFixed(1)} GB; choose one of ${t.length} parts`, {
3958
4800
  root: e,
3959
4801
  elements: t.map((e) => e.prefix),
@@ -3961,7 +4803,7 @@ var ti = /* @__PURE__ */ e({
3961
4803
  }, o.WARNING), i;
3962
4804
  }
3963
4805
  if (f) {
3964
- let e = He(c), t = u.filter((t) => e(t.path, t.size) && !l[t.path]).length;
4806
+ let e = We(c), t = u.filter((t) => e(t.path, t.size) && !l[t.path]).length;
3965
4807
  this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `${t} files of the chosen parts were left out: they did not fit the ${((s ?? 15e8) / 1e9).toFixed(1)} GB in-memory read budget`, {
3966
4808
  elements: c,
3967
4809
  missing: t,
@@ -3981,12 +4823,12 @@ var ti = /* @__PURE__ */ e({
3981
4823
  }
3982
4824
  let d = (e) => this.loader.loaderCache.ply.parse(e), f = async (e, t) => {
3983
4825
  let n = await this._pbrtTextureFromBytes(e, t);
3984
- return n && (n.userData[Ze] = t), n;
4826
+ return n && (n.userData[$e] = t), n;
3985
4827
  }, p = async (e, t) => {
3986
4828
  let r = t.split(".").pop().toLowerCase(), i = new Blob([e]), a = r === "pfm" ? null : URL.createObjectURL(i);
3987
4829
  try {
3988
- let o = a ? await this.loader.loadEnvironmentByExtension(a, r, { loader: r === "exr" ? this._exrLoader() : null }) : ei(e);
3989
- return o.mapping = C, n(o, `bytes:${await c(i)}`), o.userData[Ze] = t, o.userData[Qe] = "environment", o;
4830
+ let o = a ? await this.loader.loadEnvironmentByExtension(a, r, { loader: r === "exr" ? this._exrLoader() : null }) : Ei(e);
4831
+ return o.mapping = C, n(o, `bytes:${await c(i)}`), o.userData[$e] = t, o.userData[et] = "environment", o;
3990
4832
  } finally {
3991
4833
  a && URL.revokeObjectURL(a);
3992
4834
  }
@@ -3999,10 +4841,10 @@ var ti = /* @__PURE__ */ e({
3999
4841
  curveSides: l.curveSides,
4000
4842
  curveTolerance: l.curveTolerance,
4001
4843
  instanceIncludes: l.instanceIncludes
4002
- }, g = u?.archiveId ? this.loader._keyed(`pbrt:2.8:${i}`, `${u.archiveId}|${s ?? ""}|${[...u.elements ?? []].sort().join(",")}|${JSON.stringify(h)}`) : null, _ = g ? await this._loadStoredGraph(g, u, {
4844
+ }, g = u?.archiveId ? this.loader._keyed(`pbrt:2.9:${i}`, `${u.archiveId}|${s ?? ""}|${[...u.elements ?? []].sort().join(",")}|${JSON.stringify(h)}`) : null, _ = g ? await this._loadStoredGraph(g, u, {
4003
4845
  imageFromBytes: f,
4004
4846
  envFromBytes: p
4005
- }) : null, v = _ ?? await Zr({
4847
+ }) : null, v = _ ?? await Ci({
4006
4848
  vfs: e,
4007
4849
  source: u,
4008
4850
  entryPath: s,
@@ -4031,10 +4873,13 @@ var ti = /* @__PURE__ */ e({
4031
4873
  let e = S.length < T ? ` (first ${S.length} of ${T})` : "";
4032
4874
  console.groupCollapsed(`PBRT loader: ${T} mesh(es) from "${E}"${e}`), console.table(S), console.groupEnd();
4033
4875
  }
4034
- return w && w.length && (console.warn(`PBRT loader: ${w.length} warning(s) parsing "${E}"`), w.forEach((e) => console.warn(" •", e))), b?.texture && (b.texture.generateMipmaps = !0, this.loader.applyEnvironmentToScene(b.texture)), y.name = E || r, this.loader.releaseTargetModel(), this.loader._sourceKey = g, g && !_ && this._storeGraph(g, v, r), this.loader.targetModel = y, this.loader.animations = x ?? [], this.loader.sceneMetadata = { environment: b?.texture ? {
4035
- rotation: 0,
4036
- intensity: 1
4037
- } : { enabled: !1 } }, t({
4876
+ return w && w.length && (console.warn(`PBRT loader: ${w.length} warning(s) parsing "${E}"`), w.forEach((e) => console.warn(" •", e))), b?.texture && (b.texture.generateMipmaps = !0, this.loader.applyEnvironmentToScene(b.texture)), y.name = E || r, this.loader.releaseTargetModel(), this.loader._sourceKey = g, g && !_ && this._storeGraph(g, v, r), this.loader.targetModel = y, this.loader.animations = x ?? [], this.loader.sceneMetadata = {
4877
+ environment: b?.texture ? {
4878
+ rotation: 0,
4879
+ intensity: 1
4880
+ } : { enabled: !1 },
4881
+ ...v.render ? { render: { ...v.render } } : {}
4882
+ }, t({
4038
4883
  isLoading: !0,
4039
4884
  status: "Processing PBRT geometry...",
4040
4885
  progress: 10
@@ -4045,22 +4890,22 @@ var ti = /* @__PURE__ */ e({
4045
4890
  }), y;
4046
4891
  }
4047
4892
  _exrLoader() {
4048
- return this.loader.loaderCache.exr ??= new ve().setDataType(T);
4893
+ return this.loader.loaderCache.exr ??= new ye().setDataType(T);
4049
4894
  }
4050
4895
  async _pbrtTextureFromBytes(e, t) {
4051
4896
  let n = t.split(".").pop().toLowerCase(), r;
4052
4897
  if (n === "exr" || n === "hdr") {
4053
4898
  let t = n === "hdr" ? this.loader.loaderCache.hdr || (this.loader.loaderCache.hdr = new he().setDataType(T)) : this._exrLoader();
4054
4899
  r = await this._loadViaObjectURL(t, e);
4055
- } else if (n === "pfm") r = ei(e);
4900
+ } else if (n === "pfm") r = Ei(e);
4056
4901
  else if (n === "tga") {
4057
4902
  if (!this.loader.loaderCache.tga) {
4058
4903
  let { TGALoader: e } = await import("three/examples/jsm/loaders/TGALoader.js");
4059
4904
  this.loader.loaderCache.tga = new e();
4060
4905
  }
4061
- r = await this._loadViaObjectURL(this.loader.loaderCache.tga, e), r.colorSpace = F;
4062
- } else r = new pe(await createImageBitmap(new Blob([e]))), r.colorSpace = F;
4063
- return r.wrapS = r.wrapT = ue, r.needsUpdate = !0, r;
4906
+ r = await this._loadViaObjectURL(this.loader.loaderCache.tga, e), r.colorSpace = P;
4907
+ } else r = new pe(await createImageBitmap(new Blob([e]))), r.colorSpace = P;
4908
+ return r.wrapS = r.wrapT = de, r.needsUpdate = !0, r;
4064
4909
  }
4065
4910
  async _loadViaObjectURL(e, t) {
4066
4911
  let n = URL.createObjectURL(new Blob([t]));
@@ -4124,24 +4969,24 @@ var ti = /* @__PURE__ */ e({
4124
4969
  }
4125
4970
  for (let t in e) {
4126
4971
  let n = t.split(".").pop().toLowerCase();
4127
- if (n === "obj" || this.loader.getFileFormat(t)?.type === "model") return ni.test(t) ? await this.loadUSDHierarchyFromZip(e) : (console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e));
4972
+ if (n === "obj" || this.loader.getFileFormat(t)?.type === "model") return Oi.test(t) ? await this.loadUSDHierarchyFromZip(e) : (console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e));
4128
4973
  }
4129
4974
  throw Error("No supported model files found in the ZIP archive");
4130
4975
  }
4131
4976
  async loadUSDHierarchyFromZip(t) {
4132
- let n = Object.keys(t).filter((e) => ni.test(e));
4977
+ let n = Object.keys(t).filter((e) => Oi.test(e));
4133
4978
  if (n.length === 0) throw Error("No USD layers found in the ZIP archive");
4134
4979
  let r = e._pickUSDRootLayer(n);
4135
4980
  console.log(`Loading USD scene from ZIP: ${r} (${n.length} layers)`);
4136
4981
  let i = { [r]: [t[r], { level: 0 }] };
4137
- for (let e of Object.keys(t)) e !== r && (ni.test(e) || ri.test(e)) && (i[e] = [t[e], { level: 0 }]);
4138
- return await this.loader._loadModelFileByExtension(new File([_e(i)], r), r);
4982
+ for (let e of Object.keys(t)) e !== r && (Oi.test(e) || ki.test(e)) && (i[e] = [t[e], { level: 0 }]);
4983
+ return await this.loader._loadModelFileByExtension(new File([ve(i)], r), r);
4139
4984
  }
4140
4985
  static _pickUSDRootLayer(e) {
4141
4986
  let t = (e) => e.split("/").length, n = Math.min(...e.map(t)), r = e.filter((e) => t(e) === n);
4142
4987
  return r.find((e) => {
4143
4988
  let t = e.split("/");
4144
- return t.length > 1 && t[t.length - 1].replace(ni, "") === t[t.length - 2];
4989
+ return t.length > 1 && t[t.length - 1].replace(Oi, "") === t[t.length - 2];
4145
4990
  }) || r[0];
4146
4991
  }
4147
4992
  async loadModelFromZipEntry(e, n, r, i) {
@@ -4177,7 +5022,7 @@ var ti = /* @__PURE__ */ e({
4177
5022
  }
4178
5023
  async handleGltfFromZip(e, t, n, r) {
4179
5024
  if (e === "gltf") {
4180
- let e = R(t), i = new j(), a = n.split("/").slice(0, -1).join("/");
5025
+ let e = _e(t), i = new j(), a = n.split("/").slice(0, -1).join("/");
4181
5026
  i.setURLModifier((e) => this.resolveZipResource(e, a, r));
4182
5027
  let o = await this.loader.createGLTFLoader();
4183
5028
  o.manager = i;
@@ -4199,7 +5044,7 @@ var ti = /* @__PURE__ */ e({
4199
5044
  } else return await this.loader.loadGLBFromArrayBuffer(t.buffer, n);
4200
5045
  }
4201
5046
  async handleObjFromZip(e, t, n) {
4202
- let r = R(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
5047
+ let r = _e(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
4203
5048
  i && i[1] && (a = await this.loadMtlFromZip(i[1], t, n));
4204
5049
  let { OBJLoader: o } = await import("three/examples/jsm/loaders/OBJLoader.js"), s = new o();
4205
5050
  a && s.setMaterials(a);
@@ -4216,8 +5061,8 @@ var ti = /* @__PURE__ */ e({
4216
5061
  s(), o?.(e);
4217
5062
  });
4218
5063
  }, e.preload(), t.length === 0) return e;
4219
- let r, i = await Promise.race([Promise.all(t).then(() => !0), new Promise((e) => r = setTimeout(() => e(!1), ii))]);
4220
- return clearTimeout(r), i || this.loader._issues?.record(a.TEXTURE_BUILD_FAILED, `MTL textures did not decode within ${ii}ms; affected materials render untextured`, { pending: t.length }), e;
5064
+ let r, i = await Promise.race([Promise.all(t).then(() => !0), new Promise((e) => r = setTimeout(() => e(!1), Ai))]);
5065
+ return clearTimeout(r), i || this.loader._issues?.record(a.TEXTURE_BUILD_FAILED, `MTL textures did not decode within ${Ai}ms; affected materials render untextured`, { pending: t.length }), e;
4221
5066
  }
4222
5067
  async loadMtlFromZip(e, t, n) {
4223
5068
  let r = t.split("/").slice(0, -1).join("/"), i = [
@@ -4226,7 +5071,7 @@ var ti = /* @__PURE__ */ e({
4226
5071
  e.split("/").pop()
4227
5072
  ];
4228
5073
  for (let e of i) if (n[e]) {
4229
- let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = R(n[e]), a = new j();
5074
+ let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = _e(n[e]), a = new j();
4230
5075
  a.setURLModifier((e) => this.resolveZipResource(e, r, n));
4231
5076
  let o = new t(a).parse(i, r);
4232
5077
  return await this.preloadMtlTextures(o), o;
@@ -4252,7 +5097,7 @@ var ti = /* @__PURE__ */ e({
4252
5097
  await this.preloadMtlTextures(d);
4253
5098
  let f = new a(s);
4254
5099
  f.setMaterials(d);
4255
- let p = R(e.content), m = f.parse(p);
5100
+ let p = _e(e.content), m = f.parse(p);
4256
5101
  return this.loader.releaseTargetModel(), this.loader.targetModel = m, await this.loader.onModelLoad(this.loader.targetModel), o.forEach((e) => URL.revokeObjectURL(e)), this.loader.dispatchEvent({
4257
5102
  type: "load",
4258
5103
  model: m,
@@ -4260,7 +5105,7 @@ var ti = /* @__PURE__ */ e({
4260
5105
  }), m;
4261
5106
  }
4262
5107
  prepareFixedMtlContent(e) {
4263
- return R(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
5108
+ return _e(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
4264
5109
  }
4265
5110
  resolveTextureInZip(e, t, n, r, i, a) {
4266
5111
  let o = e.split("?")[0].split("#")[0].replace(/^\.\/|^\//, ""), s = r.path.split("/").pop();
@@ -4297,4 +5142,4 @@ var ti = /* @__PURE__ */ e({
4297
5142
  }
4298
5143
  };
4299
5144
  //#endregion
4300
- export { oi as n, ti as r, ai as t };
5145
+ export { Mi as n, Di as r, ji as t };