rayzee 11.1.1 → 11.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +24 -2
  2. package/dist/{ArchiveImporter-CFcggGqi.js → ArchiveImporter-D_x863yu.js} +882 -829
  3. package/dist/{BidirectionalIntegrator-DIPN8lJW.js → BidirectionalIntegrator-DmkxxEOR.js} +226 -226
  4. package/dist/{NeuralRetouch-Doo3a4vY.js → NeuralRetouch-Cr-otSW8.js} +2 -2
  5. package/dist/{NeuralSuperRes-B-rNIU_R.js → NeuralSuperRes-B7E3_M0t.js} +2 -2
  6. package/dist/{PathTracer-D_LmDeLh.js → PathTracer-D6nbknj5.js} +2958 -3000
  7. package/dist/{PhysicalSky-DYffGJ3O.js → PhysicalSky-Dq5VSiCQ.js} +1 -1
  8. package/dist/{RayzeeRenderer-DWx7D714.js → RayzeeRenderer-DbjqO6v-.js} +400 -361
  9. package/dist/SceneMetadata-D2Sh-0e-.js +110 -0
  10. package/dist/addons/archives.es.js +1 -1
  11. package/dist/addons/bidirectional.es.js +1 -1
  12. package/dist/addons/physical-sky.es.js +1 -1
  13. package/dist/addons/storage.es.js +1 -1
  14. package/dist/{identity-DrQsGT2o.js → identity-C1cLD1C0.js} +14 -4
  15. package/dist/{openStorage-DwcBRUj7.js → openStorage-Fe9BoS1_.js} +1 -1
  16. package/dist/rayzee-core.es.js +6 -6
  17. package/dist/rayzee.es.js +827 -827
  18. package/dist/rayzee.umd.js +95 -94
  19. package/dist/{sceneCachePolicy-Bk8sI5PZ.js → sceneCachePolicy-C4-4qwt6.js} +71 -29
  20. package/package.json +1 -1
  21. package/src/Processor/ArchiveImporter.js +130 -96
  22. package/src/Processor/ArchiveReader.js +46 -3
  23. package/src/Processor/AssetLoader.js +26 -1
  24. package/src/Processor/archiveFormats.js +35 -0
  25. package/src/RayzeeRenderer.js +42 -11
  26. package/src/Storage/identity.js +22 -1
  27. package/src/Storage/index.js +1 -1
  28. package/src/TSL/MaterialEvaluation.js +4 -3
  29. package/src/core.js +1 -1
  30. package/src/index.js +2 -2
  31. package/dist/archiveFormats-tnAoUL1j.js +0 -94
  32. /package/dist/{ToneMapGPU-CjU3osDd.js → ToneMapGPU-BOjpul7A.js} +0 -0
@@ -1,16 +1,16 @@
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
- import { n as a, r as o } from "./EngineIssues-CIZnXHsF.js";
4
- import { r as s } from "./shared-BGBcSxBQ.js";
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-tnAoUL1j.js";
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 ue, RepeatWrapping as de, SRGBColorSpace as P, SpotLight as fe, Texture as pe, Uint32BufferAttribute as F, Vector3 as I, VectorKeyframeTrack as me } from "three";
1
+ import { n as e } from "./BidirectionalIntegrator-DmkxxEOR.js";
2
+ import { C as t, L as n, g as r, n as i, r as a } from "./sceneCachePolicy-C4-4qwt6.js";
3
+ import { n as o, r as s } from "./EngineIssues-CIZnXHsF.js";
4
+ import { r as c } from "./shared-BGBcSxBQ.js";
5
+ import { i as l, n as u, o as d, r as f } from "./identity-C1cLD1C0.js";
6
+ import { r as p, t as m } from "./SceneMetadata-D2Sh-0e-.js";
7
+ import { n as h, t as g } from "./ZipReader-gDSWr0I5.js";
8
+ import { AnimationClip as _, BooleanKeyframeTrack as v, BufferAttribute as y, BufferGeometry as b, Color as x, DataTexture as S, DirectionalLight as C, DoubleSide as w, EquirectangularReflectionMapping as T, Float32BufferAttribute as E, FloatType as D, FrontSide as O, Group as k, InstancedBufferAttribute as A, InstancedMesh as j, LinearFilter as M, LoadingManager as N, MaterialLoader as ee, Matrix4 as P, Mesh as te, MeshPhysicalMaterial as ne, NoColorSpace as re, NumberKeyframeTrack as ie, Object3D as ae, OrthographicCamera as oe, PerspectiveCamera as se, PointLight as ce, Quaternion as le, QuaternionKeyframeTrack as ue, RGBAFormat as F, RepeatWrapping as de, SRGBColorSpace as I, SpotLight as fe, Texture as pe, Uint32BufferAttribute as L, Vector3 as R, VectorKeyframeTrack as me } from "three";
9
9
  import { HDRLoader as he } from "three/addons/loaders/HDRLoader.js";
10
10
  import { Gunzip as ge, strFromU8 as _e, zipSync as ve } from "three/addons/libs/fflate.module.js";
11
11
  import { EXRLoader as ye } from "three/addons/loaders/EXRLoader.js";
12
12
  //#region src/Processor/ArchiveReader.js
13
- var L = 512, be = 4 << 20, xe = 15e8, Se = new TextDecoder();
13
+ var z = 512, be = 4 << 20, xe = 15e8, Se = new TextDecoder();
14
14
  function Ce(e) {
15
15
  return e.length >= 2 && e[0] === 31 && e[1] === 139;
16
16
  }
@@ -48,7 +48,7 @@ function Ae(e) {
48
48
  let t = Se.decode(e).match(/^\d+ path=(.*)$/m);
49
49
  return t ? t[1] : null;
50
50
  }
51
- var je = (e) => e + (L - e % L) % L, Me = (e) => e === "L" || e === "x" || e === "X";
51
+ var je = (e) => e + (z - e % z) % z, Me = (e) => e === "L" || e === "x" || e === "X";
52
52
  function Ne(e) {
53
53
  let t = De(e, 345, 155), n = De(e, 0, 100);
54
54
  return {
@@ -61,20 +61,20 @@ function Pe(e, t) {
61
61
  return e === "5" || e === "g" || e === "K" || t.endsWith("/") || e !== "0" && e !== " " ? null : ke(t) || null;
62
62
  }
63
63
  function Fe(e) {
64
- for (let t = 0; t < L; t++) if (e[t] !== 0) return !1;
64
+ for (let t = 0; t < z; t++) if (e[t] !== 0) return !1;
65
65
  return !0;
66
66
  }
67
67
  var Ie = class {
68
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;
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(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;
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(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());
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());
78
78
  } else {
79
79
  let t = Math.min(this._remaining, e.length - n);
80
80
  if (this.sink && this._indexed && this._sinkLeft > 0) {
@@ -101,7 +101,7 @@ var Ie = class {
101
101
  }
102
102
  _readHeader() {
103
103
  let e = this._header, t = !0;
104
- for (let n = 0; n < L; n++) if (e[n] !== 0) {
104
+ for (let n = 0; n < z; n++) if (e[n] !== 0) {
105
105
  t = !1;
106
106
  break;
107
107
  }
@@ -183,12 +183,12 @@ async function Ve(e, { onProgress: t = null } = {}) {
183
183
  let o = Math.min(n, t + Math.max(r, Be));
184
184
  return i = new Uint8Array(await e.slice(t, o).arrayBuffer()), a = t, i.subarray(0, r);
185
185
  };
186
- for (; s + L <= n;) {
187
- let e = await l(s, L);
186
+ for (; s + z <= n;) {
187
+ let e = await l(s, z);
188
188
  if (Fe(e)) break;
189
189
  let { type: n, size: i, name: a } = Ne(e), u = o ?? a;
190
190
  o = null;
191
- let d = s + L;
191
+ let d = s + z;
192
192
  if (Me(n)) {
193
193
  let e = await l(d, i);
194
194
  o = n === "L" ? De(e, 0, e.length) : Ae(e);
@@ -246,6 +246,11 @@ async function Ue(e, t = {}) {
246
246
  let r = d.get(t);
247
247
  return r ? new Uint8Array(await e.slice(r.offset, r.offset + Math.min(r.size, n)).arrayBuffer()) : null;
248
248
  },
249
+ slice: async (t) => {
250
+ if (o[t]) return new Blob([o[t]]);
251
+ let n = d.get(t);
252
+ return n ? e.slice(n.offset, n.offset + n.size) : null;
253
+ },
249
254
  retainedBytes: c,
250
255
  truncated: l,
251
256
  indexed: d.size,
@@ -255,7 +260,33 @@ async function Ue(e, t = {}) {
255
260
  } : null
256
261
  };
257
262
  }
258
- function We(e) {
263
+ function We(e, { filter: t = null } = {}) {
264
+ let n = /* @__PURE__ */ new Map(), r = e.files.map(({ path: e, file: r }) => t && !t(e, r.size) ? {
265
+ path: e,
266
+ size: r.size
267
+ } : (n.set(e, r), {
268
+ path: e,
269
+ size: r.size,
270
+ offset: 0
271
+ }));
272
+ return {
273
+ entries: Object.create(null),
274
+ listing: r,
275
+ read: async (e) => {
276
+ let t = n.get(e);
277
+ return t ? new Uint8Array(await t.arrayBuffer()) : null;
278
+ },
279
+ readHead: async (e, t) => {
280
+ let r = n.get(e);
281
+ return r ? new Uint8Array(await r.slice(0, t).arrayBuffer()) : null;
282
+ },
283
+ slice: async (e) => n.get(e) ?? null,
284
+ retainedBytes: 0,
285
+ truncated: !1,
286
+ indexed: n.size
287
+ };
288
+ }
289
+ function Ge(e) {
259
290
  let t = (Array.isArray(e) ? e : [e]).filter(Boolean).map((e) => {
260
291
  let t = ke(e);
261
292
  return {
@@ -271,7 +302,7 @@ function We(e) {
271
302
  return !1;
272
303
  };
273
304
  }
274
- function Ge(e) {
305
+ function Ke(e) {
275
306
  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));
276
307
  if (!t.length) return {
277
308
  root: null,
@@ -298,19 +329,19 @@ function Ge(e) {
298
329
  }
299
330
  //#endregion
300
331
  //#region src/Processor/ArchiveCache.js
301
- var Ke = 1, qe = 3;
302
- async function Je(e, t) {
303
- return `${e}:${u(await l(t))}`;
332
+ var qe = 1, Je = 3;
333
+ async function Ye(e, t) {
334
+ return `${e}:${l(await u(t))}`;
304
335
  }
305
- async function Ye(e, { storage: t, label: n = e.name, onProgress: r = null, filter: i = null, part: o = null }) {
336
+ async function Xe(e, { storage: t, label: n = e.name, onProgress: r = null, filter: i = null, part: a = null }) {
306
337
  if (!t || typeof DecompressionStream > "u") return null;
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}`));
338
+ let s = t.area(c.ARCHIVES), l = await Ye("gunzip", e), u = l, d = await s.open(l);
339
+ !d && i && (d = await s.open(u = `${l}|${a}`));
309
340
  let f = !!d;
310
341
  if (!d) {
311
- let l = await c.create(u, i ? { label: `${n} (${o})` } : {
342
+ let l = await s.create(u, i ? { label: `${n} (${a})` } : {
312
343
  label: n,
313
- expectedBytes: e.size * qe
344
+ expectedBytes: e.size * Je
314
345
  });
315
346
  if (!l) return null;
316
347
  let f = null, p = He(i ? {
@@ -327,7 +358,7 @@ async function Ye(e, { storage: t, label: n = e.name, onProgress: r = null, filt
327
358
  try {
328
359
  let t = e.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(m), n = await l.writeStream("data.tar", t, { onProgress: r });
329
360
  await l.writeJSON("index.json", {
330
- v: Ke,
361
+ v: qe,
331
362
  listing: p.finish()
332
363
  }), await l.commit({
333
364
  compressedBytes: e.size,
@@ -335,32 +366,32 @@ async function Ye(e, { storage: t, label: n = e.name, onProgress: r = null, filt
335
366
  });
336
367
  } catch (e) {
337
368
  if (await l.abort(), e?.name !== "QuotaExceededError") throw e;
338
- return t._issue(a.STORAGE_QUOTA_EXCEEDED, `ran out of room unpacking ${n}; reading it in memory instead`, { area: s.ARCHIVES }), null;
369
+ return t._issue(o.STORAGE_QUOTA_EXCEEDED, `ran out of room unpacking ${n}; reading it in memory instead`, { area: c.ARCHIVES }), null;
339
370
  }
340
- if (d = await c.open(u, { wait: !0 }), !d) return null;
371
+ if (d = await s.open(u, { wait: !0 }), !d) return null;
341
372
  }
342
373
  let p = await d.file("data.tar"), m = await d.json("index.json");
343
- return !p || m?.v !== Ke ? (d.release(), null) : {
374
+ return !p || m?.v !== qe ? (d.release(), null) : {
344
375
  file: p,
345
376
  index: m,
346
377
  release: () => d.release(),
347
378
  cached: f
348
379
  };
349
380
  }
350
- async function Xe(e, t) {
381
+ async function Ze(e, t) {
351
382
  if (!t) return null;
352
- let n = await t.area(s.ARCHIVES).open(await Je("tarindex", e));
383
+ let n = await t.area(c.ARCHIVES).open(await Ye("tarindex", e));
353
384
  if (!n) return null;
354
385
  try {
355
386
  let e = await n.json("index.json");
356
- return e?.v === Ke ? e : null;
387
+ return e?.v === qe ? e : null;
357
388
  } finally {
358
389
  n.release();
359
390
  }
360
391
  }
361
- async function Ze(e, t, n) {
392
+ async function Qe(e, t, n) {
362
393
  if (!t || !n) return !1;
363
- let r = await t.area(s.ARCHIVES).create(await Je("tarindex", e), { label: `${e.name} (index)` });
394
+ let r = await t.area(c.ARCHIVES).create(await Ye("tarindex", e), { label: `${e.name} (index)` });
364
395
  if (!r) return !1;
365
396
  try {
366
397
  return await r.writeJSON("index.json", n), await r.commit(), !0;
@@ -368,7 +399,7 @@ async function Ze(e, t, n) {
368
399
  return await r.abort(), !1;
369
400
  }
370
401
  }
371
- var Qe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], $e = "__rayzeeArchivePath", et = "__rayzeeArchiveLoader", tt = 64, nt = 32 << 20, rt = 64 << 20, it = {
402
+ var $e = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], et = "__rayzeeArchivePath", tt = "__rayzeeArchiveLoader", nt = 64, rt = 32 << 20, it = 64 << 20, at = {
372
403
  Float32Array,
373
404
  Float64Array,
374
405
  Int8Array,
@@ -378,7 +409,7 @@ var Qe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], $e = "__rayz
378
409
  Uint16Array,
379
410
  Uint32Array,
380
411
  Uint8ClampedArray
381
- }, at = [
412
+ }, ot = [
382
413
  "name",
383
414
  "mapping",
384
415
  "channel",
@@ -394,13 +425,13 @@ var Qe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], $e = "__rayz
394
425
  "premultiplyAlpha",
395
426
  "unpackAlignment",
396
427
  "colorSpace"
397
- ], ot = [
428
+ ], st = [
398
429
  "intensity",
399
430
  "distance",
400
431
  "decay",
401
432
  "angle",
402
433
  "penumbra"
403
- ], st = [
434
+ ], ct = [
404
435
  "name",
405
436
  "visible",
406
437
  "castShadow",
@@ -408,28 +439,28 @@ var Qe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], $e = "__rayz
408
439
  "frustumCulled",
409
440
  "renderOrder",
410
441
  "matrixAutoUpdate"
411
- ], R = class extends Error {
442
+ ], B = class extends Error {
412
443
  constructor(e) {
413
444
  super(e), this.name = "SceneGraphUnsupported";
414
445
  }
415
446
  };
416
- function ct(e) {
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;
447
+ function lt(e) {
448
+ 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 === ae ? "Object3D" : null;
418
449
  }
419
- function lt(e, t) {
450
+ function ut(e, t) {
420
451
  try {
421
452
  let t = JSON.parse(JSON.stringify(e ?? {}));
422
- return delete t[$e], delete t[et], t;
453
+ return delete t[et], delete t[tt], t;
423
454
  } catch {
424
- throw new R(`${t}: userData is not plain JSON`);
455
+ throw new B(`${t}: userData is not plain JSON`);
425
456
  }
426
457
  }
427
- var ut = class {
458
+ var dt = class {
428
459
  constructor() {
429
460
  this.sections = [], this.length = 0;
430
461
  }
431
462
  add(e) {
432
- let t = Math.ceil(this.length / tt) * tt;
463
+ let t = Math.ceil(this.length / nt) * nt;
433
464
  return this.sections.push({
434
465
  offset: t,
435
466
  array: e
@@ -441,8 +472,8 @@ var ut = class {
441
472
  };
442
473
  }
443
474
  };
444
- function dt(e, t, n) {
445
- if (e.isInterleavedBufferAttribute || !ArrayBuffer.isView(e.array)) throw new R(`${n}: interleaved or non-typed attribute`);
475
+ function ft(e, t, n) {
476
+ if (e.isInterleavedBufferAttribute || !ArrayBuffer.isView(e.array)) throw new B(`${n}: interleaved or non-typed attribute`);
446
477
  return {
447
478
  section: t.add(e.array),
448
479
  itemSize: e.itemSize,
@@ -450,44 +481,44 @@ function dt(e, t, n) {
450
481
  name: e.name ?? ""
451
482
  };
452
483
  }
453
- function ft(e, t) {
484
+ function pt(e, t) {
454
485
  let n = `geometry ${e.name || e.uuid}`;
455
- if (Object.keys(e.morphAttributes ?? {}).length) throw new R(`${n}: morph targets`);
486
+ if (Object.keys(e.morphAttributes ?? {}).length) throw new B(`${n}: morph targets`);
456
487
  let r = {};
457
- for (let [i, a] of Object.entries(e.attributes)) r[i] = dt(a, t, n);
488
+ for (let [i, a] of Object.entries(e.attributes)) r[i] = ft(a, t, n);
458
489
  return {
459
490
  uuid: e.uuid,
460
491
  name: e.name,
461
492
  attributes: r,
462
- index: e.index ? dt(e.index, t, n) : null,
493
+ index: e.index ? ft(e.index, t, n) : null,
463
494
  groups: e.groups.map((e) => ({ ...e })),
464
495
  drawRange: { ...e.drawRange },
465
- userData: lt(e.userData, n)
496
+ userData: ut(e.userData, n)
466
497
  };
467
498
  }
468
- function pt(e, t) {
499
+ function mt(e, t) {
469
500
  let n = {
470
501
  uuid: e.uuid,
471
- userData: lt(e.userData, `texture ${e.uuid}`)
502
+ userData: ut(e.userData, `texture ${e.uuid}`)
472
503
  };
473
- for (let t of at) n[t] = e[t];
504
+ for (let t of ot) n[t] = e[t];
474
505
  for (let t of [
475
506
  "repeat",
476
507
  "offset",
477
508
  "center"
478
509
  ]) n[t] = e[t].toArray();
479
510
  n.rotation = e.rotation;
480
- let r = e.userData?.[$e];
511
+ let r = e.userData?.[et];
481
512
  if (r) n.path = r, n.loader = e.userData.__rayzeeArchiveLoader ?? "image";
482
513
  else if (e.isDataTexture && ArrayBuffer.isView(e.image?.data)) n.data = {
483
514
  section: t.add(e.image.data),
484
515
  width: e.image.width,
485
516
  height: e.image.height
486
517
  };
487
- else throw new R(`texture ${e.name || e.uuid}: no archive path and no pixel data to keep`);
518
+ else throw new B(`texture ${e.name || e.uuid}: no archive path and no pixel data to keep`);
488
519
  return n;
489
520
  }
490
- function mt(e, t) {
521
+ function ht(e, t) {
491
522
  let n = e.toJSON(t);
492
523
  n.exactColors = {};
493
524
  for (let [t, r] of Object.entries(e)) r?.isColor && (n.exactColors[t] = [
@@ -496,27 +527,27 @@ function mt(e, t) {
496
527
  r.b
497
528
  ]);
498
529
  e.ior !== void 0 && (n.exactIor = e.ior), e.diffuseTransmission !== void 0 && (n.diffuseTransmission = e.diffuseTransmission);
499
- for (let t of Qe) e[t]?.isTexture && ((n.engineTextures ??= {})[t] = e[t].uuid);
530
+ for (let t of $e) e[t]?.isTexture && ((n.engineTextures ??= {})[t] = e[t].uuid);
500
531
  return n;
501
532
  }
502
- function ht(e, t) {
533
+ function gt(e, t) {
503
534
  for (let n of Object.values(e)) n?.isTexture && t.set(n.uuid, n);
504
535
  }
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`);
536
+ function _t(e, { environment: t = null, animations: n = [], stats: r = {} } = {}) {
537
+ let i = new dt(), a = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t) => {
538
+ let n = lt(e);
539
+ if (!n) throw new B(`${e.type} "${e.name}" cannot be cached`);
509
540
  let r = {
510
541
  type: n,
511
542
  uuid: e.uuid,
512
543
  parent: t,
513
- userData: lt(e.userData, `${n} "${e.name}"`)
544
+ userData: ut(e.userData, `${n} "${e.name}"`)
514
545
  };
515
- for (let t of st) r[t] = e[t];
546
+ for (let t of ct) r[t] = e[t];
516
547
  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) {
517
548
  o.set(e.geometry.uuid, e.geometry);
518
549
  let t = Array.isArray(e.material) ? e.material : [e.material];
519
- for (let e of t) s.set(e.uuid, e), ht(e, c);
550
+ for (let e of t) s.set(e.uuid, e), gt(e, c);
520
551
  r.geometry = e.geometry.uuid, r.material = Array.isArray(e.material) ? t.map((e) => e.uuid) : e.material.uuid;
521
552
  }
522
553
  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 [
@@ -535,7 +566,7 @@ function gt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
535
566
  ]) e[t] !== void 0 && (r[t] = e[t]);
536
567
  if (e.isLight) {
537
568
  r.color = e.color.toArray();
538
- for (let t of ot) e[t] !== void 0 && (r[t] = e[t]);
569
+ for (let t of st) e[t] !== void 0 && (r[t] = e[t]);
539
570
  e.target && (r.target = e.target.uuid);
540
571
  }
541
572
  let u = a.push(r) - 1;
@@ -551,10 +582,10 @@ function gt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
551
582
  manifest: {
552
583
  v: 2,
553
584
  nodes: a,
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)),
557
- animations: n.map((e) => h.toJSON(e)),
585
+ geometries: [...o.values()].map((e) => pt(e, i)),
586
+ textures: [...c.values()].map((e) => mt(e, i)),
587
+ materials: [...s.values()].map((e) => ht(e, u)),
588
+ animations: n.map((e) => _.toJSON(e)),
558
589
  environment: t ? t.uuid : null,
559
590
  stats: r
560
591
  },
@@ -562,32 +593,32 @@ function gt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}
562
593
  byteLength: i.length
563
594
  };
564
595
  }
565
- async function _t(e, { manifest: t, sections: n }, { release: r = !1 } = {}) {
596
+ async function vt(e, { manifest: t, sections: n }, { release: r = !1 } = {}) {
566
597
  for (let t of n) {
567
598
  let { offset: n, array: i } = t, a = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
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 });
599
+ for (let t = 0; t < a.length; t += rt) await e.write("data.bin", a.subarray(t, Math.min(a.length, t + rt)), { at: n + t });
569
600
  r && (t.array = null);
570
601
  }
571
602
  n.length === 0 && await e.write("data.bin", new Uint8Array()), await e.writeJSON("graph.json", t);
572
603
  }
573
- function vt(e) {
574
- let t = it[e];
604
+ function yt(e) {
605
+ let t = at[e];
575
606
  if (!t) throw Error(`scene graph: unknown array type ${e}`);
576
607
  return t;
577
608
  }
578
- async function yt(e, t) {
609
+ async function bt(e, t) {
579
610
  let n = /* @__PURE__ */ new Map(), r = [...t].sort((e, t) => e.offset - t.offset), i = null, a = 0;
580
611
  for (let t of r) {
581
- let { offset: r, byteLength: o, type: s } = t, c = vt(s), l = r + o;
582
- if (o > rt) {
612
+ let { offset: r, byteLength: o, type: s } = t, c = yt(s), l = r + o;
613
+ if (o > it) {
583
614
  n.set(r, new c(await e.slice(r, l).arrayBuffer()));
584
615
  continue;
585
616
  }
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)));
617
+ (!i || r < a || l > a + i.byteLength) && (a = r, i = await e.slice(r, Math.min(e.size, r + it)).arrayBuffer()), n.set(r, new c(i.slice(r - a, l - a)));
587
618
  }
588
619
  return n;
589
620
  }
590
- function bt(e) {
621
+ function xt(e) {
591
622
  let t = [];
592
623
  for (let n of e.nodes) n.instanceMatrix && t.push(n.instanceMatrix), n.instanceColor && t.push(n.instanceColor);
593
624
  for (let n of e.geometries) {
@@ -597,39 +628,39 @@ function bt(e) {
597
628
  for (let n of e.textures) n.data && t.push(n.data.section);
598
629
  return t;
599
630
  }
600
- function xt(e, t) {
601
- let n = new _(e.get(t.section.offset), t.itemSize, t.normalized);
631
+ function St(e, t) {
632
+ let n = new y(e.get(t.section.offset), t.itemSize, t.normalized);
602
633
  return n.name = t.name, n;
603
634
  }
604
- function St(e, t) {
605
- for (let n of at) t[n] !== void 0 && (e[n] = t[n]);
635
+ function Ct(e, t) {
636
+ for (let n of ot) t[n] !== void 0 && (e[n] = t[n]);
606
637
  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;
607
638
  }
608
- async function Ct(e, t, { loadTexture: n }) {
639
+ async function wt(e, t, { loadTexture: n }) {
609
640
  if (e?.v !== 2) throw Error("scene graph: unknown format");
610
- let r = await yt(t, bt(e)), i = (e) => r.get(e.offset), a = {};
641
+ let r = await bt(t, xt(e)), i = (e) => r.get(e.offset), a = {};
611
642
  for (let t of e.textures) {
612
643
  let e;
613
644
  if (t.path) {
614
645
  if (e = await n(t.path, t.loader), !e) throw Error(`scene graph: "${t.path}" is missing from the archive`);
615
- e.userData[$e] = t.path, e.userData[et] = t.loader;
616
- } else e = new b(i(t.data.section), t.data.width, t.data.height);
617
- St(e, t), a[t.uuid] = e;
646
+ e.userData[et] = t.path, e.userData[tt] = t.loader;
647
+ } else e = new S(i(t.data.section), t.data.width, t.data.height);
648
+ Ct(e, t), a[t.uuid] = e;
618
649
  }
619
- let o = new M().setTextures(a), s = {};
650
+ let o = new ee().setTextures(a), s = {};
620
651
  for (let t of e.materials) {
621
652
  let e = o.parse(t);
622
- for (let [n, r] of Object.entries(t.exactColors ?? {})) n === "diffuseTransmissionColor" && (e[n] = new y()), e[n]?.setRGB(r[0], r[1], r[2]);
653
+ for (let [n, r] of Object.entries(t.exactColors ?? {})) n === "diffuseTransmissionColor" && (e[n] = new x()), e[n]?.setRGB(r[0], r[1], r[2]);
623
654
  t.exactIor !== void 0 && (e.ior = t.exactIor), t.diffuseTransmission !== void 0 && (e.diffuseTransmission = t.diffuseTransmission);
624
655
  for (let [n, r] of Object.entries(t.engineTextures ?? {})) a[r] && (e[n] = a[r]);
625
656
  s[t.uuid] = e;
626
657
  }
627
658
  let c = {};
628
659
  for (let t of e.geometries) {
629
- let e = new v();
660
+ let e = new b();
630
661
  e.uuid = t.uuid, e.name = t.name;
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));
662
+ for (let [n, i] of Object.entries(t.attributes)) e.setAttribute(n, St(r, i));
663
+ t.index && e.setIndex(St(r, t.index));
633
664
  for (let n of t.groups) e.addGroup(n.start, n.count, n.materialIndex);
634
665
  e.setDrawRange(t.drawRange.start, t.drawRange.count), e.userData = t.userData, c[t.uuid] = e;
635
666
  }
@@ -638,33 +669,33 @@ async function Ct(e, t, { loadTexture: n }) {
638
669
  let e = Array.isArray(t.material) ? t.material.map((e) => s[e]) : s[t.material], n;
639
670
  switch (t.type) {
640
671
  case "InstancedMesh":
641
- n = new k(c[t.geometry], e, 1), n.instanceMatrix = new O(i(t.instanceMatrix), 16), n.count = t.count, t.instanceColor && (n.instanceColor = new O(i(t.instanceColor), 3));
672
+ n = new j(c[t.geometry], e, 1), n.instanceMatrix = new A(i(t.instanceMatrix), 16), n.count = t.count, t.instanceColor && (n.instanceColor = new A(i(t.instanceColor), 3));
642
673
  break;
643
674
  case "Mesh":
644
- n = new ee(c[t.geometry], e);
675
+ n = new te(c[t.geometry], e);
645
676
  break;
646
677
  case "PerspectiveCamera":
647
- n = new oe();
678
+ n = new se();
648
679
  break;
649
680
  case "OrthographicCamera":
650
- n = new ae();
681
+ n = new oe();
651
682
  break;
652
683
  case "Group":
653
- n = new D();
684
+ n = new k();
654
685
  break;
655
686
  case "DirectionalLight":
656
- n = new x();
687
+ n = new C();
657
688
  break;
658
689
  case "PointLight":
659
- n = new se();
690
+ n = new ce();
660
691
  break;
661
692
  case "SpotLight":
662
693
  n = new fe();
663
694
  break;
664
- default: n = new ie();
695
+ default: n = new ae();
665
696
  }
666
697
  n.uuid = t.uuid;
667
- for (let e of st) n[e] = t[e];
698
+ for (let e of ct) n[e] = t[e];
668
699
  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) {
669
700
  for (let e of [
670
701
  "fov",
@@ -684,7 +715,7 @@ async function Ct(e, t, { loadTexture: n }) {
684
715
  }
685
716
  if (n.isLight) {
686
717
  n.color.fromArray(t.color);
687
- for (let e of ot) t[e] !== void 0 && (n[e] = t[e]);
718
+ for (let e of st) t[e] !== void 0 && (n[e] = t[e]);
688
719
  }
689
720
  l.push(n), t.parent >= 0 && l[t.parent].add(n);
690
721
  }
@@ -694,48 +725,48 @@ async function Ct(e, t, { loadTexture: n }) {
694
725
  }), {
695
726
  root: l[0],
696
727
  environment: e.environment ? a[e.environment] : null,
697
- animations: e.animations.map((e) => h.parse(e)),
728
+ animations: e.animations.map((e) => _.parse(e)),
698
729
  stats: e.stats
699
730
  };
700
731
  }
701
732
  //#endregion
702
733
  //#region src/Processor/PBRT/buffers.js
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);
734
+ var Tt = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && typeof e.buffer.transfer == "function" && !(typeof SharedArrayBuffer < "u" && e.buffer instanceof SharedArrayBuffer);
735
+ function V(e) {
736
+ e && Tt(e) && e.buffer.transfer(0);
706
737
  }
707
- function B(e, t) {
738
+ function H(e, t) {
708
739
  let n = e.constructor;
709
- if (wt(e)) return new n(e.buffer.transfer(t * n.BYTES_PER_ELEMENT));
740
+ if (Tt(e)) return new n(e.buffer.transfer(t * n.BYTES_PER_ELEMENT));
710
741
  let r = new n(t);
711
742
  return r.set(t < e.length ? e.subarray(0, t) : e), r;
712
743
  }
713
744
  //#endregion
714
745
  //#region src/Processor/PBRT/PBRTTokenizer.js
715
- var V = {
746
+ var U = {
716
747
  STRING: "string",
717
748
  NUMBER: "number",
718
749
  WORD: "word",
719
750
  LBRACKET: "[",
720
751
  RBRACKET: "]"
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);
752
+ }, Et = 9, Dt = 10, Ot = 12, kt = 13, At = 32, jt = 34, Mt = 35, Nt = 43, Pt = 45, Ft = 46, It = 48, Lt = 57, Rt = 91, zt = 93, Bt = 69, Vt = 101, Ht = (e) => e === At || e === Et || e === Dt || e === kt || e === Ot, W = (e) => e >= It && e <= Lt, Ut = 15, Wt = 22, Gt = (() => {
753
+ let e = new Float64Array(Wt + 1);
723
754
  for (let t = 0; t < e.length; t++) e[t] = 10 ** t;
724
755
  return e;
725
- })(), Gt = new TextDecoder();
726
- function Kt(e, t, n) {
756
+ })(), Kt = new TextDecoder();
757
+ function qt(e, t, n) {
727
758
  if (n - t === 0) return "";
728
759
  let r = !0;
729
760
  for (let i = t; i < n; i++) if (e[i] > 127) {
730
761
  r = !1;
731
762
  break;
732
763
  }
733
- if (!r) return Gt.decode(e.subarray(t, n));
764
+ if (!r) return Kt.decode(e.subarray(t, n));
734
765
  let i = "";
735
766
  for (let r = t; r < n; r++) i += String.fromCharCode(e[r]);
736
767
  return i;
737
768
  }
738
- var qt = class {
769
+ var Jt = class {
739
770
  constructor(e) {
740
771
  this.bytes = typeof e == "string" ? new TextEncoder().encode(e) : e, this.i = 0, this.n = this.bytes.length, this._ahead = null;
741
772
  }
@@ -749,73 +780,73 @@ var qt = class {
749
780
  _scan() {
750
781
  let e = this.bytes, t = this.i, n = this.n;
751
782
  for (;;) {
752
- for (; t < n && Vt(e[t]);) t++;
753
- if (t < n && e[t] === jt) {
754
- for (; t < n && e[t] !== Et;) t++;
783
+ for (; t < n && Ht(e[t]);) t++;
784
+ if (t < n && e[t] === Mt) {
785
+ for (; t < n && e[t] !== Dt;) t++;
755
786
  continue;
756
787
  }
757
788
  break;
758
789
  }
759
790
  if (t >= n) return this.i = t, null;
760
791
  let r = e[t];
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) {
792
+ if (r === Rt) return this.i = t + 1, { type: U.LBRACKET };
793
+ if (r === zt) return this.i = t + 1, { type: U.RBRACKET };
794
+ if (r === jt) {
764
795
  let r = ++t;
765
- for (; t < n && e[t] !== At;) t++;
796
+ for (; t < n && e[t] !== jt;) t++;
766
797
  if (t >= n) throw Error("PBRT tokenizer: unterminated string literal");
767
798
  return this.i = t + 1, {
768
- type: V.STRING,
769
- value: Kt(e, r, t)
799
+ type: U.STRING,
800
+ value: qt(e, r, t)
770
801
  };
771
802
  }
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);
803
+ if (W(r) || r === Ft && W(e[t + 1]) || (r === Pt || r === Nt) && (W(e[t + 1]) || e[t + 1] === Ft && W(e[t + 2]))) return this._scanNumber(t);
773
804
  let i = t;
774
805
  for (; t < n;) {
775
806
  let n = e[t];
776
- if (Vt(n) || n === At || n === Lt || n === Rt || n === jt) break;
807
+ if (Ht(n) || n === jt || n === Rt || n === zt || n === Mt) break;
777
808
  t++;
778
809
  }
779
810
  return this.i = t, {
780
- type: V.WORD,
781
- value: Kt(e, i, t)
811
+ type: U.WORD,
812
+ value: qt(e, i, t)
782
813
  };
783
814
  }
784
815
  _scanNumber(e) {
785
816
  let t = this.bytes, n = this.n, r = e, i = !1;
786
- t[r] === Nt ? (i = !0, r++) : t[r] === Mt && r++;
817
+ t[r] === Pt ? (i = !0, r++) : t[r] === Nt && r++;
787
818
  let a = 0, o = 0, s = 0;
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++;
819
+ for (; r < n && W(t[r]);) a = a * 10 + (t[r] - It), o++, r++;
820
+ if (r < n && t[r] === Ft) for (r++; r < n && W(t[r]);) a = a * 10 + (t[r] - It), o++, s++, r++;
790
821
  let c = 0;
791
- if (r < n && (t[r] === Bt || t[r] === zt)) {
822
+ if (r < n && (t[r] === Vt || t[r] === Bt)) {
792
823
  let e = r + 1, i = !1;
793
- if (e < n && (t[e] === Nt || t[e] === Mt) && (i = t[e] === Nt, e++), e < n && H(t[e])) {
824
+ if (e < n && (t[e] === Pt || t[e] === Nt) && (i = t[e] === Pt, e++), e < n && W(t[e])) {
794
825
  let a = 0;
795
- for (; e < n && H(t[e]);) a = a * 10 + (t[e] - Ft), e++;
826
+ for (; e < n && W(t[e]);) a = a * 10 + (t[e] - It), e++;
796
827
  c = i ? -a : a, r = e;
797
828
  }
798
829
  }
799
- if (this.i = r, o === 0) throw Error(`PBRT tokenizer: invalid number "${Kt(t, e, r)}"`);
830
+ if (this.i = r, o === 0) throw Error(`PBRT tokenizer: invalid number "${qt(t, e, r)}"`);
800
831
  let l = c - s;
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)}"`);
832
+ if (!(o <= Ut && l >= -Wt && l <= Wt)) {
833
+ let n = Number(qt(t, e, r));
834
+ if (Number.isNaN(n)) throw Error(`PBRT tokenizer: invalid number "${qt(t, e, r)}"`);
804
835
  return {
805
- type: V.NUMBER,
836
+ type: U.NUMBER,
806
837
  value: n
807
838
  };
808
839
  }
809
- let u = l === 0 ? a : l > 0 ? a * Wt[l] : a / Wt[-l];
840
+ let u = l === 0 ? a : l > 0 ? a * Gt[l] : a / Gt[-l];
810
841
  return i && (u = -u), {
811
- type: V.NUMBER,
842
+ type: U.NUMBER,
812
843
  value: u
813
844
  };
814
845
  }
815
846
  };
816
847
  //#endregion
817
848
  //#region src/Processor/PBRT/PBRTMath.js
818
- function Jt() {
849
+ function Yt() {
819
850
  return [
820
851
  1,
821
852
  0,
@@ -835,17 +866,17 @@ function Jt() {
835
866
  1
836
867
  ];
837
868
  }
838
- function Yt(e) {
869
+ function Xt(e) {
839
870
  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]);
840
871
  }
841
- function Xt(e, t, n, r) {
872
+ function Zt(e, t, n, r) {
842
873
  for (let i = 0; i < 4; i++) {
843
874
  let a = r[i * 4], o = r[i * 4 + 1], s = r[i * 4 + 2], c = r[i * 4 + 3];
844
875
  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;
845
876
  }
846
877
  return e;
847
878
  }
848
- function U(e, t) {
879
+ function G(e, t) {
849
880
  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];
850
881
  return [
851
882
  n * v + o * y + u * b + m * x,
@@ -866,7 +897,7 @@ function U(e, t) {
866
897
  a * A + l * j + p * M + _ * N
867
898
  ];
868
899
  }
869
- function Zt(e, t, n) {
900
+ function Qt(e, t, n) {
870
901
  return [
871
902
  1,
872
903
  0,
@@ -886,7 +917,7 @@ function Zt(e, t, n) {
886
917
  1
887
918
  ];
888
919
  }
889
- function Qt(e, t, n) {
920
+ function $t(e, t, n) {
890
921
  return [
891
922
  e,
892
923
  0,
@@ -906,7 +937,7 @@ function Qt(e, t, n) {
906
937
  1
907
938
  ];
908
939
  }
909
- function $t(e, t, n, r) {
940
+ function en(e, t, n, r) {
910
941
  let i = Math.hypot(t, n, r) || 1;
911
942
  t /= i, n /= i, r /= i;
912
943
  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;
@@ -929,21 +960,21 @@ function $t(e, t, n, r) {
929
960
  1
930
961
  ];
931
962
  }
932
- function en(e, t) {
963
+ function tn(e, t) {
933
964
  return [
934
965
  e[0] - t[0],
935
966
  e[1] - t[1],
936
967
  e[2] - t[2]
937
968
  ];
938
969
  }
939
- function tn(e, t) {
970
+ function nn(e, t) {
940
971
  return [
941
972
  e[1] * t[2] - e[2] * t[1],
942
973
  e[2] * t[0] - e[0] * t[2],
943
974
  e[0] * t[1] - e[1] * t[0]
944
975
  ];
945
976
  }
946
- function nn(e) {
977
+ function rn(e) {
947
978
  let t = Math.hypot(e[0], e[1], e[2]) || 1;
948
979
  return [
949
980
  e[0] / t,
@@ -951,8 +982,8 @@ function nn(e) {
951
982
  e[2] / t
952
983
  ];
953
984
  }
954
- function rn(e, t, n) {
955
- let r = nn(en(t, e)), i = nn(tn(nn(n), r)), a = tn(r, i);
985
+ function an(e, t, n) {
986
+ let r = rn(tn(t, e)), i = rn(nn(rn(n), r)), a = nn(r, i);
956
987
  return [
957
988
  i[0],
958
989
  i[1],
@@ -972,9 +1003,9 @@ function rn(e, t, n) {
972
1003
  1
973
1004
  ];
974
1005
  }
975
- function W(e) {
1006
+ function K(e) {
976
1007
  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;
977
- if (x === 0) return Jt();
1008
+ if (x === 0) return Yt();
978
1009
  let S = 1 / x;
979
1010
  return [
980
1011
  _ * S,
@@ -997,7 +1028,7 @@ function W(e) {
997
1028
  }
998
1029
  //#endregion
999
1030
  //#region src/Processor/PBRT/PBRTParser.js
1000
- var an = 8, on = 1, sn = 2, G = 3, cn = new Set([
1031
+ var on = 8, sn = 1, cn = 2, q = 3, ln = new Set([
1001
1032
  "Identity",
1002
1033
  "Transform",
1003
1034
  "CoordinateSystem",
@@ -1016,12 +1047,12 @@ var an = 8, on = 1, sn = 2, G = 3, cn = new Set([
1016
1047
  "ObjectEnd",
1017
1048
  "ObjectInstance"
1018
1049
  ]);
1019
- function ln(e, t) {
1050
+ function un(e, t) {
1020
1051
  if (e === t) return !0;
1021
1052
  for (let n = 0; n < 16; n++) if (e[n] !== t[n]) return !1;
1022
1053
  return !0;
1023
1054
  }
1024
- var un = {
1055
+ var dn = {
1025
1056
  integer: Int32Array,
1026
1057
  point3: Float32Array,
1027
1058
  point2: Float32Array,
@@ -1030,7 +1061,7 @@ var un = {
1030
1061
  vector: Float32Array,
1031
1062
  normal: Float32Array,
1032
1063
  rgb: Float32Array
1033
- }, dn = class {
1064
+ }, fn = class {
1034
1065
  constructor(e = {}) {
1035
1066
  this.releaseInclude = e.releaseInclude || null, this.resolveInclude = e.resolveInclude || (() => {
1036
1067
  throw Error("PBRTParser: Include used but no resolveInclude provided");
@@ -1052,7 +1083,7 @@ var un = {
1052
1083
  },
1053
1084
  hasMotion: !1,
1054
1085
  warnings: []
1055
- }, this.ctm = Jt(), this.ctmEnd = null, this.activeTransform = G, this._ctmSource = null, this._ctmValue = null, this.state = {
1086
+ }, this.ctm = Yt(), this.ctmEnd = null, this.activeTransform = q, this._ctmSource = null, this._ctmValue = null, this.state = {
1056
1087
  material: null,
1057
1088
  areaLight: null,
1058
1089
  reverseOrientation: !1,
@@ -1060,8 +1091,8 @@ var un = {
1060
1091
  }, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.dirStack = [""], this.stream = null, this._warnedUnknown = /* @__PURE__ */ new Set();
1061
1092
  }
1062
1093
  async parse(e, t = "") {
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);
1094
+ this.dirStack = [t], await this._run(new Jt(e)), this._movedShapes && (this.ir.shapes = this.ir.shapes.filter(Boolean));
1095
+ for (let e of this.ir.instances.values()) e.matrices = H(e.matrices, e.count * 16), e.matricesEnd &&= H(e.matricesEnd, e.count * 16);
1065
1096
  return this.ir;
1066
1097
  }
1067
1098
  _addInstance(e, t = this.ctm) {
@@ -1079,7 +1110,7 @@ var un = {
1079
1110
  let r = (n.count + 1) * 16;
1080
1111
  if (r > n.matrices.length) {
1081
1112
  let e = Math.max(r, n.matrices.length * 2);
1082
- n.matrices = B(n.matrices, e), n.matricesEnd &&= B(n.matricesEnd, e);
1113
+ n.matrices = H(n.matrices, e), n.matricesEnd &&= H(n.matricesEnd, e);
1083
1114
  }
1084
1115
  let i = n.count * 16;
1085
1116
  for (let e = 0; e < 16; e++) n.matrices[i + e] = t[e];
@@ -1094,23 +1125,23 @@ var un = {
1094
1125
  return this._ctmSource !== this.ctm && (this._ctmSource = this.ctm, this._ctmValue = this.ctm.slice()), this._ctmValue;
1095
1126
  }
1096
1127
  _ctmEndSnapshot() {
1097
- return this.ctmEnd === null || ln(this.ctmEnd, this.ctm) ? null : (this.ir.hasMotion = !0, this.ctmEnd.slice());
1128
+ return this.ctmEnd === null || un(this.ctmEnd, this.ctm) ? null : (this.ir.hasMotion = !0, this.ctmEnd.slice());
1098
1129
  }
1099
1130
  _concat(e) {
1100
- if (this.activeTransform === G && this.ctmEnd === null) {
1101
- this.ctm = U(this.ctm, e);
1131
+ if (this.activeTransform === q && this.ctmEnd === null) {
1132
+ this.ctm = G(this.ctm, e);
1102
1133
  return;
1103
1134
  }
1104
1135
  let t = this.ctmEnd ?? this.ctm;
1105
- this.ctmEnd = this.activeTransform & sn ? U(t, e) : t, this.activeTransform & on && (this.ctm = U(this.ctm, e));
1136
+ this.ctmEnd = this.activeTransform & cn ? G(t, e) : t, this.activeTransform & sn && (this.ctm = G(this.ctm, e));
1106
1137
  }
1107
1138
  _setCTM(e) {
1108
- if (this.activeTransform === G) {
1139
+ if (this.activeTransform === q) {
1109
1140
  this.ctm = e, this.ctmEnd = null;
1110
1141
  return;
1111
1142
  }
1112
1143
  let t = this.ctmEnd ?? this.ctm;
1113
- this.ctmEnd = this.activeTransform & sn ? e : t, this.activeTransform & on && (this.ctm = e);
1144
+ this.ctmEnd = this.activeTransform & cn ? e : t, this.activeTransform & sn && (this.ctm = e);
1114
1145
  }
1115
1146
  _pushGraphicsState() {
1116
1147
  this.attributeStack.push({
@@ -1140,12 +1171,12 @@ var un = {
1140
1171
  }
1141
1172
  _expectNumber(e) {
1142
1173
  let t = this._next();
1143
- if (!t || t.type !== V.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
1174
+ if (!t || t.type !== U.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
1144
1175
  return t.value;
1145
1176
  }
1146
1177
  _expectString(e) {
1147
1178
  let t = this._next();
1148
- if (!t || t.type !== V.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
1179
+ if (!t || t.type !== U.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
1149
1180
  return t.value;
1150
1181
  }
1151
1182
  _readNumbers(e) {
@@ -1154,17 +1185,17 @@ var un = {
1154
1185
  return t;
1155
1186
  }
1156
1187
  _readBracketedOrBareNumbers(e) {
1157
- if (this._peek() && this._peek().type === V.LBRACKET) {
1188
+ if (this._peek() && this._peek().type === U.LBRACKET) {
1158
1189
  this._next();
1159
1190
  let e = [];
1160
- for (; this._peek() && this._peek().type !== V.RBRACKET;) e.push(this._expectNumber("transform element"));
1191
+ for (; this._peek() && this._peek().type !== U.RBRACKET;) e.push(this._expectNumber("transform element"));
1161
1192
  return this._next(), e;
1162
1193
  }
1163
1194
  return this._readNumbers(e);
1164
1195
  }
1165
1196
  _parseParams() {
1166
1197
  let e = {};
1167
- for (; this._peek() && this._peek().type === V.STRING;) {
1198
+ for (; this._peek() && this._peek().type === U.STRING;) {
1168
1199
  let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
1169
1200
  e[r] = {
1170
1201
  type: n,
@@ -1174,30 +1205,30 @@ var un = {
1174
1205
  return e;
1175
1206
  }
1176
1207
  _parseParamValue(e) {
1177
- let t = this._peek() && this._peek().type === V.LBRACKET;
1208
+ let t = this._peek() && this._peek().type === U.LBRACKET;
1178
1209
  t && this._next();
1179
1210
  let n = () => {
1180
1211
  let e = this._peek();
1181
- return t ? e && e.type !== V.RBRACKET : !1;
1212
+ return t ? e && e.type !== U.RBRACKET : !1;
1182
1213
  };
1183
1214
  if (!t) return [this._coerceValueToken(this._next())];
1184
- if (this._peek() && this._peek().type === V.NUMBER) {
1215
+ if (this._peek() && this._peek().type === U.NUMBER) {
1185
1216
  let t = [];
1186
- for (; n() && t.length < an;) {
1217
+ for (; n() && t.length < on;) {
1187
1218
  let e = this._next();
1188
- if (e.type !== V.NUMBER) return this._finishMixedValue(t, t.length, e);
1219
+ if (e.type !== U.NUMBER) return this._finishMixedValue(t, t.length, e);
1189
1220
  t.push(e.value);
1190
1221
  }
1191
1222
  if (!n()) return this._next(), t;
1192
- let r = new (un[e] || Float64Array)(an * 4);
1223
+ let r = new (dn[e] || Float64Array)(on * 4);
1193
1224
  r.set(t);
1194
1225
  let i = t.length;
1195
1226
  for (; n();) {
1196
1227
  let e = this._next();
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;
1228
+ if (e.type !== U.NUMBER) return this._finishMixedValue(r, i, e);
1229
+ i === r.length && (r = H(r, r.length * 2)), r[i++] = e.value;
1199
1230
  }
1200
- return this._next(), i === r.length ? r : B(r, i);
1231
+ return this._next(), i === r.length ? r : H(r, i);
1201
1232
  }
1202
1233
  let r = [];
1203
1234
  for (; n();) r.push(this._coerceValueToken(this._next()));
@@ -1206,21 +1237,21 @@ var un = {
1206
1237
  _finishMixedValue(e, t, n) {
1207
1238
  let r = [];
1208
1239
  for (let n = 0; n < t; n++) r.push(e[n]);
1209
- for (r.push(this._coerceValueToken(n)); this._peek() && this._peek().type !== V.RBRACKET;) r.push(this._coerceValueToken(this._next()));
1240
+ for (r.push(this._coerceValueToken(n)); this._peek() && this._peek().type !== U.RBRACKET;) r.push(this._coerceValueToken(this._next()));
1210
1241
  return this._next(), r;
1211
1242
  }
1212
1243
  _coerceValueToken(e) {
1213
1244
  if (!e) throw Error("PBRT parser: unexpected EOF in parameter 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;
1245
+ if (e.type === U.NUMBER || e.type === U.STRING) return e.value;
1246
+ if (e.type === U.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
1216
1247
  throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
1217
1248
  }
1218
1249
  async _run(e) {
1219
1250
  let t = this.stream;
1220
1251
  this.stream = e;
1221
1252
  for (let e = this._next(); e !== null; e = this._next()) {
1222
- if (e.type !== V.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
1223
- cn.has(e.value) && this._effects++;
1253
+ if (e.type !== U.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
1254
+ ln.has(e.value) && this._effects++;
1224
1255
  let t = this._directive(e.value);
1225
1256
  t !== void 0 && await t;
1226
1257
  }
@@ -1229,25 +1260,25 @@ var un = {
1229
1260
  _directive(e) {
1230
1261
  switch (e) {
1231
1262
  case "Identity":
1232
- this._setCTM(Jt());
1263
+ this._setCTM(Yt());
1233
1264
  break;
1234
1265
  case "Translate": {
1235
1266
  let [e, t, n] = this._readNumbers(3);
1236
- this._concat(Zt(e, t, n));
1267
+ this._concat(Qt(e, t, n));
1237
1268
  break;
1238
1269
  }
1239
1270
  case "Scale": {
1240
1271
  let [e, t, n] = this._readNumbers(3);
1241
- this._concat(Qt(e, t, n));
1272
+ this._concat($t(e, t, n));
1242
1273
  break;
1243
1274
  }
1244
1275
  case "Rotate": {
1245
1276
  let [e, t, n, r] = this._readNumbers(4);
1246
- this._concat($t(e, t, n, r));
1277
+ this._concat(en(e, t, n, r));
1247
1278
  break;
1248
1279
  }
1249
1280
  case "LookAt": {
1250
- let e = this._readNumbers(9), t = rn([
1281
+ let e = this._readNumbers(9), t = an([
1251
1282
  e[0],
1252
1283
  e[1],
1253
1284
  e[2]
@@ -1260,7 +1291,7 @@ var un = {
1260
1291
  e[7],
1261
1292
  e[8]
1262
1293
  ]);
1263
- this._concat(W(t));
1294
+ this._concat(K(t));
1264
1295
  break;
1265
1296
  }
1266
1297
  case "Transform":
@@ -1285,10 +1316,10 @@ var un = {
1285
1316
  this.ir.camera = {
1286
1317
  type: e,
1287
1318
  params: t,
1288
- cameraToWorld: W(this.ctm)
1319
+ cameraToWorld: K(this.ctm)
1289
1320
  };
1290
1321
  let n = this._ctmEndSnapshot();
1291
- n && (this.ir.camera.cameraToWorldEnd = W(n));
1322
+ n && (this.ir.camera.cameraToWorldEnd = K(n));
1292
1323
  break;
1293
1324
  }
1294
1325
  case "Film": {
@@ -1322,7 +1353,7 @@ var un = {
1322
1353
  this._skipTypeAndParams();
1323
1354
  break;
1324
1355
  case "WorldBegin":
1325
- this.ctm = Jt(), this.ctmEnd = null, this.activeTransform = G, this.state = {
1356
+ this.ctm = Yt(), this.ctmEnd = null, this.activeTransform = q, this.state = {
1326
1357
  material: null,
1327
1358
  areaLight: null,
1328
1359
  reverseOrientation: !1,
@@ -1356,7 +1387,7 @@ var un = {
1356
1387
  break;
1357
1388
  case "ActiveTransform": {
1358
1389
  let e = this._next()?.value;
1359
- e === "StartTime" ? this.activeTransform = on : e === "EndTime" ? this.activeTransform = sn : e === "All" ? this.activeTransform = G : this._warn(`ActiveTransform "${e}" not recognised`);
1390
+ e === "StartTime" ? this.activeTransform = sn : e === "EndTime" ? this.activeTransform = cn : e === "All" ? this.activeTransform = q : this._warn(`ActiveTransform "${e}" not recognised`);
1360
1391
  break;
1361
1392
  }
1362
1393
  case "TransformTimes": {
@@ -1368,8 +1399,8 @@ var un = {
1368
1399
  break;
1369
1400
  }
1370
1401
  case "MediumInterface": {
1371
- let e = this._peek()?.type === V.STRING ? this._next().value : "";
1372
- this._peek()?.type === V.STRING && this._next(), this.state.interior = e || null;
1402
+ let e = this._peek()?.type === U.STRING ? this._next().value : "";
1403
+ this._peek()?.type === U.STRING && this._next(), this.state.interior = e || null;
1373
1404
  break;
1374
1405
  }
1375
1406
  case "MakeNamedMedium": {
@@ -1421,7 +1452,7 @@ var un = {
1421
1452
  }
1422
1453
  case "LightSource": {
1423
1454
  let e = this._expectString("LightSource type"), t = this._parseParams();
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({
1455
+ this.ctmEnd !== null && !un(this.ctmEnd, this.ctm) && this._warnOnce("animated-light", "animated LightSource transforms are not supported — using the start transform"), this.ir.lights.push({
1425
1456
  type: e,
1426
1457
  params: t,
1427
1458
  ctm: this._ctmSnapshot()
@@ -1440,7 +1471,7 @@ var un = {
1440
1471
  reverseOrientation: this.state.reverseOrientation,
1441
1472
  interior: this.state.interior
1442
1473
  }, i = this.currentObject === null ? this._ctmEndSnapshot() : null;
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);
1474
+ i ? r.ctmEnd = i : this.currentObject !== null && this.ctmEnd !== null && !un(this.ctmEnd, this.ctm) && this._warnOnce("animated-template", "animated transforms inside ObjectBegin are not supported — using the start transform"), this._emitShape(r);
1444
1475
  break;
1445
1476
  }
1446
1477
  case "ObjectBegin": {
@@ -1480,7 +1511,7 @@ var un = {
1480
1511
  let i = n === null ? null : this._includeState(), a = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
1481
1512
  this.dirStack.push(a);
1482
1513
  try {
1483
- await this._run(new qt(r));
1514
+ await this._run(new Jt(r));
1484
1515
  } finally {
1485
1516
  this.dirStack.pop(), this.releaseInclude?.(e, t, r);
1486
1517
  }
@@ -1492,7 +1523,7 @@ var un = {
1492
1523
  });
1493
1524
  }
1494
1525
  _includeKey(e, t) {
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}`;
1526
+ return !this.instanceIncludes || this.currentObject !== null || this.ctmEnd !== null || this.activeTransform !== q || this.state.areaLight ? null : `${t}\0${e}\0${this._stateId(this.state.material)}\0${this.state.reverseOrientation}\0${this.state.interior}`;
1496
1527
  }
1497
1528
  _stateId(e) {
1498
1529
  if (!e) return 0;
@@ -1512,7 +1543,7 @@ var un = {
1512
1543
  };
1513
1544
  }
1514
1545
  _sameIncludeState(e) {
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;
1546
+ return this._effects === e.effects && this.ctmEnd === null && this.activeTransform === q && un(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;
1516
1547
  }
1517
1548
  _placeRepeat(e, t) {
1518
1549
  let n = this._includes.get(e);
@@ -1521,20 +1552,20 @@ var un = {
1521
1552
  let { start: r, end: i } = n;
1522
1553
  if (i === r || this.ir.instanceCount + 2 > this.maxPlacements) return !1;
1523
1554
  for (let t = r; t < i; t++) if (!this.ir.shapes[t]) return this._includes.delete(e), !1;
1524
- let a = `${t}#${this.ir.objects.size}`, o = W(n.ctm), s = [], c = null, l = null;
1555
+ let a = `${t}#${this.ir.objects.size}`, o = K(n.ctm), s = [], c = null, l = null;
1525
1556
  for (let e = r; e < i; e++) {
1526
1557
  let t = this.ir.shapes[e];
1527
- t.ctm !== c && (l = U(o, c = t.ctm)), t.relativeCTM = l, s.push(t), this.ir.shapes[e] = null;
1558
+ t.ctm !== c && (l = G(o, c = t.ctm)), t.relativeCTM = l, s.push(t), this.ir.shapes[e] = null;
1528
1559
  }
1529
1560
  this.ir.objects.set(a, s), this._addInstance(a, n.ctm), n.template = a, this._movedShapes = !0;
1530
1561
  }
1531
1562
  return this._addInstance(n.template), !0;
1532
1563
  }
1533
1564
  _skipTypeAndParams() {
1534
- this._peek() && this._peek().type === V.STRING && this._next(), this._parseParams();
1565
+ this._peek() && this._peek().type === U.STRING && this._next(), this._parseParams();
1535
1566
  }
1536
1567
  _skipNamedAndParams() {
1537
- this._peek() && this._peek().type === V.STRING && this._next(), this._parseParams();
1568
+ this._peek() && this._peek().type === U.STRING && this._next(), this._parseParams();
1538
1569
  }
1539
1570
  _num(e, t) {
1540
1571
  return e && e.value.length ? e.value[0] : t;
@@ -1551,7 +1582,7 @@ var un = {
1551
1582
  _warnUnknown(e) {
1552
1583
  this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
1553
1584
  }
1554
- }, fn = {
1585
+ }, pn = {
1555
1586
  Apple: [[
1556
1587
  2.29,
1557
1588
  2.39,
@@ -1976,28 +2007,28 @@ var un = {
1976
2007
  .030147
1977
2008
  ]]
1978
2009
  };
1979
- function pn(e) {
1980
- let t = fn[e];
2010
+ function mn(e) {
2011
+ let t = pn[e];
1981
2012
  return t ? {
1982
2013
  sigmaS: t[0].slice(),
1983
2014
  sigmaA: t[1].slice()
1984
2015
  } : null;
1985
2016
  }
1986
- function mn(e, t) {
2017
+ function hn(e, t) {
1987
2018
  let n = -1.44 / (t * t) + .71 / t + .668 + .0636 * t, r = (1 + n) / (1 - n), i = Math.sqrt(3 * (1 - e));
1988
2019
  return e / 2 * (1 + Math.exp(-4 / 3 * r * i)) * Math.exp(-i);
1989
2020
  }
1990
- function hn(e, t) {
1991
- let n = Math.min(Math.max(e, 0), mn(1, t)), r = 0, i = 1;
2021
+ function gn(e, t) {
2022
+ let n = Math.min(Math.max(e, 0), hn(1, t)), r = 0, i = 1;
1992
2023
  for (let e = 0; e < 48; e++) {
1993
2024
  let e = (r + i) / 2;
1994
- mn(e, t) < n ? r = e : i = e;
2025
+ hn(e, t) < n ? r = e : i = e;
1995
2026
  }
1996
2027
  return (r + i) / 2;
1997
2028
  }
1998
2029
  //#endregion
1999
2030
  //#region src/Processor/PBRT/PBRTMaterials.js
2000
- var gn = {
2031
+ var _n = {
2001
2032
  au: [
2002
2033
  1,
2003
2034
  .78,
@@ -2053,12 +2084,12 @@ var gn = {
2053
2084
  .9,
2054
2085
  .9
2055
2086
  ]
2056
- }, _n = [
2087
+ }, vn = [
2057
2088
  .92,
2058
2089
  .92,
2059
2090
  .92
2060
2091
  ];
2061
- function vn(e) {
2092
+ function yn(e) {
2062
2093
  let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
2063
2094
  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;
2064
2095
  let a = (e) => Math.max(0, Math.min(255, e)) / 255;
@@ -2068,19 +2099,19 @@ function vn(e) {
2068
2099
  a(i) ** 2.2
2069
2100
  ];
2070
2101
  }
2071
- function K(e, t, n) {
2102
+ function J(e, t, n) {
2072
2103
  let r = e[t];
2073
2104
  return r && typeof r.value[0] == "number" ? r.value[0] : n;
2074
2105
  }
2075
- function q(e, t, n) {
2106
+ function Y(e, t, n) {
2076
2107
  let r = e[t];
2077
2108
  return r && typeof r.value[0] == "string" ? r.value[0] : n;
2078
2109
  }
2079
- function J(e, t, n) {
2110
+ function X(e, t, n) {
2080
2111
  let r = e[t]?.value?.[0];
2081
2112
  return r === void 0 ? n : r === !0 || r === "true";
2082
2113
  }
2083
- async function Y(e, t, n, r = null) {
2114
+ async function Z(e, t, n, r = null) {
2084
2115
  let i = e[t];
2085
2116
  if (!i) return {
2086
2117
  rgb: r,
@@ -2119,14 +2150,14 @@ async function Y(e, t, n, r = null) {
2119
2150
  };
2120
2151
  }
2121
2152
  if (i.type === "blackbody") return {
2122
- rgb: vn(i.value[0]),
2153
+ rgb: yn(i.value[0]),
2123
2154
  texture: null
2124
2155
  };
2125
2156
  if (i.type === "spectrum") {
2126
2157
  if (typeof i.value[0] == "string") {
2127
- let e = yn(i.value[0]);
2128
- return e && gn[e] ? {
2129
- rgb: gn[e].slice(),
2158
+ let e = bn(i.value[0]);
2159
+ return e && _n[e] ? {
2160
+ rgb: _n[e].slice(),
2130
2161
  texture: null
2131
2162
  } : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
2132
2163
  rgb: [
@@ -2154,63 +2185,63 @@ async function Y(e, t, n, r = null) {
2154
2185
  texture: null
2155
2186
  };
2156
2187
  }
2157
- function yn(e) {
2188
+ function bn(e) {
2158
2189
  let t = e.toLowerCase().match(/metal-([a-z]+)/);
2159
2190
  if (t) return t[1];
2160
- for (let t of Object.keys(gn)) if (e.toLowerCase().includes(t)) return t;
2191
+ for (let t of Object.keys(_n)) if (e.toLowerCase().includes(t)) return t;
2161
2192
  return null;
2162
2193
  }
2163
- async function bn(e, t, n) {
2194
+ async function xn(e, t, n) {
2164
2195
  let r = e[t];
2165
2196
  return r ? typeof r.value[0] == "number" ? r.value[0] : r.type === "texture" ? await n.floatTextureMean?.(r.value[0]) ?? null : null : null;
2166
2197
  }
2167
- var xn = (e) => {
2198
+ var Sn = (e) => {
2168
2199
  let t = e.remaproughness?.value?.[0];
2169
2200
  return t !== !1 && t !== "false";
2170
2201
  };
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);
2202
+ async function Cn(e, t, n, r = "") {
2203
+ let i = Sn(e), a = (e) => i ? Math.sqrt(Math.max(e, 0)) : e, o = null, s = await xn(e, `${r}roughness`, n);
2173
2204
  if (s !== null) o = a(s);
2174
2205
  else {
2175
- let t = await bn(e, `${r}uroughness`, n), i = await bn(e, `${r}vroughness`, n);
2206
+ let t = await xn(e, `${r}uroughness`, n), i = await xn(e, `${r}vroughness`, n);
2176
2207
  t !== null && (o = i === null ? a(t) : (a(t) + a(i)) / 2);
2177
2208
  }
2178
2209
  return o === null ? t : Math.sqrt(Math.max(o, 0));
2179
2210
  }
2180
- async function X(e, t, n, r, i, a = "") {
2211
+ async function Q(e, t, n, r, i, a = "") {
2181
2212
  let o = n[`${a}roughness`] ? [`${a}roughness`] : [`${a}uroughness`, `${a}vroughness`].filter((e) => n[e]);
2182
2213
  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));
2214
+ let r = Sn(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
2215
  if (s) {
2185
2216
  e[`${t}Map`] = s, e[t] = 1;
2186
2217
  return;
2187
2218
  }
2188
2219
  }
2189
- e[t] = await Sn(n, r, i, a);
2220
+ e[t] = await Cn(n, r, i, a);
2190
2221
  }
2191
- async function Cn(e, t, n, r) {
2222
+ async function wn(e, t, n, r) {
2192
2223
  let i = e[t];
2193
- return i?.type === "texture" ? await n.textureMeanRGB?.(i.value[0]) ?? r : (await Y(e, t, n, r)).rgb ?? r;
2224
+ return i?.type === "texture" ? await n.textureMeanRGB?.(i.value[0]) ?? r : (await Z(e, t, n, r)).rgb ?? r;
2194
2225
  }
2195
- var wn = [
2226
+ var Tn = [
2196
2227
  .0011,
2197
2228
  .0024,
2198
2229
  .014
2199
- ], Tn = [
2230
+ ], En = [
2200
2231
  2.55,
2201
2232
  3.21,
2202
2233
  3.77
2203
2234
  ];
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;
2235
+ async function Dn(e, t, n) {
2236
+ let r = J(t, "eta", 1.33), i = J(t, "scale", 1), a = (e) => e.map((e) => Math.max(0, e * i)), o = J(t, "g", 0), s, c, l = Y(t, "name", ""), u = l ? mn(l) : null;
2206
2237
  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));
2238
+ else if (t.sigma_a && t.sigma_s) s = a(await wn(t, "sigma_a", n, Tn)), c = a(await wn(t, "sigma_s", n, En));
2208
2239
  else if (t.reflectance && !l) {
2209
- let e = await Cn(t, "reflectance", n, [
2240
+ let e = await wn(t, "reflectance", n, [
2210
2241
  .5,
2211
2242
  .5,
2212
2243
  .5
2213
- ]), i = a(t.mfp ? await Cn(t, "mfp", n, [
2244
+ ]), i = a(t.mfp ? await wn(t, "mfp", n, [
2214
2245
  1,
2215
2246
  1,
2216
2247
  1
@@ -2221,25 +2252,25 @@ async function En(e, t, n) {
2221
2252
  ]);
2222
2253
  s = [], c = [];
2223
2254
  for (let t = 0; t < 3; t++) {
2224
- let n = 1 / Math.max(i[t], 1e-9), a = hn(e[t], r);
2255
+ let n = 1 / Math.max(i[t], 1e-9), a = gn(e[t], r);
2225
2256
  c[t] = a * n / (1 - o + a * o), s[t] = n - c[t];
2226
2257
  }
2227
- } else s = a(wn), c = a(Tn);
2258
+ } else s = a(Tn), c = a(En);
2228
2259
  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) => {
2260
+ e.subsurface = 1, e.subsurfaceColor = new x(...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
2261
  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);
2262
+ return e > 0 ? hn(n / (s[t] + n), r) : 0;
2263
+ })), await Q(e, "roughness", t, 0, n);
2233
2264
  }
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";
2265
+ async function On(e, t, n, r, i, a) {
2266
+ let o = await Z(t, "reflectance", n, null), s = t[`${r}eta`], c = t[`${r}k`], l = s && s.type === "spectrum" && typeof s.value[0] == "string";
2236
2267
  if (o.rgb || o.texture) i(o);
2237
2268
  else if (s && c && !l) {
2238
- let e = (await Y(t, `${r}eta`, n, [
2269
+ let e = (await Z(t, `${r}eta`, n, [
2239
2270
  .2,
2240
2271
  .92,
2241
2272
  1.1
2242
- ])).rgb, i = (await Y(t, `${r}k`, n, [
2273
+ ])).rgb, i = (await Z(t, `${r}k`, n, [
2243
2274
  3.9,
2244
2275
  2.45,
2245
2276
  2.14
@@ -2249,12 +2280,12 @@ async function Dn(e, t, n, r, i, a) {
2249
2280
  o(e[1], i[1]),
2250
2281
  o(e[2], i[2])
2251
2282
  ]);
2252
- } else a(s ? (await Y(t, `${r}eta`, n, _n)).rgb || _n : gn.cu);
2283
+ } else a(s ? (await Z(t, `${r}eta`, n, vn)).rgb || vn : _n.cu);
2253
2284
  e.metalness = 1;
2254
2285
  }
2255
- async function On(e, t) {
2256
- let n = e?.type || "diffuse", r = e?.params || {}, i = new te({
2257
- side: S,
2286
+ async function kn(e, t) {
2287
+ let n = e?.type || "diffuse", r = e?.params || {}, i = new ne({
2288
+ side: w,
2258
2289
  roughness: 1,
2259
2290
  metalness: 0
2260
2291
  }), a = (e) => {
@@ -2264,7 +2295,7 @@ async function On(e, t) {
2264
2295
  };
2265
2296
  switch (n) {
2266
2297
  case "diffuse":
2267
- o(await Y(r, "reflectance", t, [
2298
+ o(await Z(r, "reflectance", t, [
2268
2299
  .5,
2269
2300
  .5,
2270
2301
  .5
@@ -2272,24 +2303,24 @@ async function On(e, t) {
2272
2303
  break;
2273
2304
  case "conductor":
2274
2305
  case "metal":
2275
- await Dn(i, r, t, "", o, a), await X(i, "roughness", r, .1, t);
2306
+ await On(i, r, t, "", o, a), await Q(i, "roughness", r, .1, t);
2276
2307
  break;
2277
2308
  case "coatedconductor":
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.");
2309
+ await On(i, r, t, "conductor.", o, a), await Q(i, "roughness", r, 0, t, "conductor."), i.clearcoat = 1, await Q(i, "clearcoatRoughness", r, 0, t, "interface.");
2279
2310
  break;
2280
2311
  case "dielectric":
2281
2312
  case "thindielectric":
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);
2313
+ i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = J(r, "eta", 1.5), await Q(i, "roughness", r, 0, t), i.thickness = n === "thindielectric" ? 0 : J(r, "thickness", 0);
2283
2314
  break;
2284
2315
  case "coateddiffuse":
2285
- o(await Y(r, "reflectance", t, [
2316
+ o(await Z(r, "reflectance", t, [
2286
2317
  .5,
2287
2318
  .5,
2288
2319
  .5
2289
- ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, await X(i, "clearcoatRoughness", r, 0, t);
2320
+ ])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, await Q(i, "clearcoatRoughness", r, 0, t);
2290
2321
  break;
2291
2322
  case "diffusetransmission": {
2292
- let e = K(r, "scale", 1), n = (t) => Math.min(1, Math.max(0, e * t)), a = await Y(r, "transmittance", t, [
2323
+ let e = J(r, "scale", 1), n = (t) => Math.min(1, Math.max(0, e * t)), a = await Z(r, "transmittance", t, [
2293
2324
  .25,
2294
2325
  .25,
2295
2326
  .25
@@ -2297,7 +2328,7 @@ async function On(e, t) {
2297
2328
  .5,
2298
2329
  .5,
2299
2330
  .5
2300
- ], c = Math.min(.99, Math.max(...s)), l = await Y(r, "reflectance", t, [
2331
+ ], c = Math.min(.99, Math.max(...s)), l = await Z(r, "reflectance", t, [
2301
2332
  .25,
2302
2333
  .25,
2303
2334
  .25
@@ -2309,7 +2340,7 @@ async function On(e, t) {
2309
2340
  1,
2310
2341
  1
2311
2342
  ].map(u) : null
2312
- }), a.texture && t.warn("diffusetransmission: a textured \"transmittance\" is not supported — using 0.5"), i.diffuseTransmission = c, i.diffuseTransmissionColor = new y().setRGB(...s.map((e) => c > 0 ? Math.min(1, e / c) : 1)), i.roughness = 1, i.metalness = 0, i.specularIntensity = 0;
2343
+ }), a.texture && t.warn("diffusetransmission: a textured \"transmittance\" is not supported — using 0.5"), i.diffuseTransmission = c, i.diffuseTransmissionColor = new x().setRGB(...s.map((e) => c > 0 ? Math.min(1, e / c) : 1)), i.roughness = 1, i.metalness = 0, i.specularIntensity = 0;
2313
2344
  break;
2314
2345
  }
2315
2346
  case "interface":
@@ -2318,42 +2349,42 @@ async function On(e, t) {
2318
2349
  i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
2319
2350
  break;
2320
2351
  case "mix": {
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;
2352
+ let e = r.materials?.value || [], n = Math.max(0, Math.min(1, J(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
2322
2353
  if (a && o) {
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;
2354
+ let [e, s] = await Promise.all([kn(a, t), kn(o, t)]), c = r.amount, l = c?.type === "texture" ? await t.bakeMaterialMix?.(e, s, c.value[0]) : null;
2324
2355
  l && (n = l.mean);
2325
2356
  let u = (e, t) => e * (1 - n) + t * n;
2326
2357
  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);
2327
2358
  let d = e.diffuseTransmission ?? 0, f = s.diffuseTransmission ?? 0;
2328
- (d > 0 || f > 0) && (i.diffuseTransmission = u(d, f), i.diffuseTransmissionColor = new y().lerpColors(e.diffuseTransmissionColor ?? new y(1, 1, 1), s.diffuseTransmissionColor ?? new y(1, 1, 1), n)), i.emissiveIntensity = u(e.emissiveIntensity ?? 0, s.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : s.map) || null, i.normalMap = (n < .5 ? e.normalMap : s.normalMap) || null, l?.texture && (i.map = l.texture, i.color.setRGB(1, 1, 1));
2359
+ (d > 0 || f > 0) && (i.diffuseTransmission = u(d, f), i.diffuseTransmissionColor = new x().lerpColors(e.diffuseTransmissionColor ?? new x(1, 1, 1), s.diffuseTransmissionColor ?? new x(1, 1, 1), n)), i.emissiveIntensity = u(e.emissiveIntensity ?? 0, s.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : s.map) || null, i.normalMap = (n < .5 ? e.normalMap : s.normalMap) || null, l?.texture && (i.map = l.texture, i.color.setRGB(1, 1, 1));
2329
2360
  break;
2330
2361
  }
2331
- t.warn(`material "mix" — could not resolve inner materials [${e.join(", ")}], falling back to diffuse`), i.color.set(new y(.6, .6, .6));
2362
+ t.warn(`material "mix" — could not resolve inner materials [${e.join(", ")}], falling back to diffuse`), i.color.set(new x(.6, .6, .6));
2332
2363
  break;
2333
2364
  }
2334
2365
  case "subsurface":
2335
- await En(i, r, t);
2366
+ await Dn(i, r, t);
2336
2367
  break;
2337
2368
  case "hair":
2338
2369
  case "measured":
2339
- t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Y(r, "reflectance", t, [
2370
+ t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Z(r, "reflectance", t, [
2340
2371
  .5,
2341
2372
  .5,
2342
2373
  .5
2343
2374
  ])).rgb), i.roughness = 1;
2344
2375
  break;
2345
2376
  default:
2346
- t.warn(`unknown material "${n}" — using neutral diffuse`), i.color.set(new y(.6, .6, .6));
2377
+ t.warn(`unknown material "${n}" — using neutral diffuse`), i.color.set(new x(.6, .6, .6));
2347
2378
  break;
2348
2379
  }
2349
- let s = q(r, "normalmap", null);
2380
+ let s = Y(r, "normalmap", null);
2350
2381
  return s && t.resolveNormalMap && (i.normalMap = await t.resolveNormalMap(s)), i.roughness = Math.max(0, Math.min(1, i.roughness)), i;
2351
2382
  }
2352
2383
  //#endregion
2353
2384
  //#region src/Processor/PBRT/PBRTTextureBake.js
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;
2385
+ var An = 4096, jn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, Mn = (e) => e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
2386
+ function Nn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, mapping: a = null }) {
2387
+ 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 && Pn(e), p = t === 1 && c >= 3 && !f;
2357
2388
  for (let e = 0; e < s; e++) {
2358
2389
  let n = u ? e : s - 1 - e;
2359
2390
  for (let a = 0; a < o; a++) {
@@ -2376,17 +2407,17 @@ function Mn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, ma
2376
2407
  ...a
2377
2408
  };
2378
2409
  }
2379
- function Nn(e) {
2410
+ function Pn(e) {
2380
2411
  let { data: t } = e, n = e.float ? 1 : 255;
2381
2412
  for (let e = 3; e < t.length; e += 4) if (t[e] !== n) return !0;
2382
2413
  return !1;
2383
2414
  }
2384
- function Pn(e) {
2415
+ function Fn(e) {
2385
2416
  let t = 0;
2386
2417
  for (let n = 0; n < e.data.length; n++) t += e.data[n];
2387
2418
  return e.data.length ? t / e.data.length : 0;
2388
2419
  }
2389
- function Fn(e, t, n, r) {
2420
+ function In(e, t, n, r) {
2390
2421
  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);
2391
2422
  for (let e = 0; e < 3; e++) {
2392
2423
  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;
@@ -2394,11 +2425,11 @@ function Fn(e, t, n, r) {
2394
2425
  }
2395
2426
  return r;
2396
2427
  }
2397
- function Z(e, t, { alphaOf: n = null, linear: r = !1 } = {}) {
2428
+ function Ln(e, t, { alphaOf: n = null, linear: r = !1 } = {}) {
2398
2429
  let i = null;
2399
2430
  for (let t of e) t.layer && (!i || t.layer.width * t.layer.height > i.width * i.height) && (i = t.layer);
2400
2431
  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(() => [
2432
+ let a = Math.min(i.width, An), o = Math.min(i.height, An), s = new Uint8Array(a * o * 4), c = e.map(() => [
2402
2433
  0,
2403
2434
  0,
2404
2435
  0
@@ -2411,14 +2442,14 @@ function Z(e, t, { alphaOf: n = null, linear: r = !1 } = {}) {
2411
2442
  let n = e[t], r = c[t];
2412
2443
  if (n.layer) {
2413
2444
  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];
2445
+ if (In(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
2446
  } else r[0] = n.rgb[0], r[1] = n.rgb[1], r[2] = n.rgb[2];
2416
2447
  if (n.clamp) for (let e = 0; e < 3; e++) r[e] = Math.min(1, Math.max(0, r[e]));
2417
2448
  }
2418
2449
  let m = t(c), h = (l * a + o) * 4;
2419
2450
  for (let e = 0; e < 3; e++) {
2420
2451
  let t = Math.min(1, Math.max(0, m[e]));
2421
- s[h + e] = Math.round(255 * (r ? t : jn(t)));
2452
+ s[h + e] = Math.round(255 * (r ? t : Mn(t)));
2422
2453
  }
2423
2454
  s[h + 3] = n ? Math.round(255 * Math.min(1, Math.max(0, n(c)))) : 255;
2424
2455
  }
@@ -2435,7 +2466,7 @@ function Z(e, t, { alphaOf: n = null, linear: r = !1 } = {}) {
2435
2466
  }
2436
2467
  };
2437
2468
  }
2438
- var In = ([e, t, n]) => {
2469
+ var Rn = ([e, t, n]) => {
2439
2470
  let r = n[0];
2440
2471
  return [
2441
2472
  e[0] + (t[0] - e[0]) * r,
@@ -2445,13 +2476,13 @@ var In = ([e, t, n]) => {
2445
2476
  };
2446
2477
  //#endregion
2447
2478
  //#region src/Processor/PBRT/LoopSubdivision.js
2448
- function Ln(e) {
2479
+ function zn(e) {
2449
2480
  return e === 3 ? 3 / 16 : 3 / (8 * e);
2450
2481
  }
2451
- function Rn(e) {
2452
- return 1 / (e + 3 / (8 * Ln(e)));
2482
+ function Bn(e) {
2483
+ return 1 / (e + 3 / (8 * zn(e)));
2453
2484
  }
2454
- function zn(e, t) {
2485
+ function Vn(e, t) {
2455
2486
  let n = /* @__PURE__ */ new Map(), r = [], i = [], a = [], o = [], s = [], c = t.length / 3;
2456
2487
  for (let l = 0; l < c; l++) for (let c = 0; c < 3; c++) {
2457
2488
  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);
@@ -2473,7 +2504,7 @@ function zn(e, t) {
2473
2504
  boundaryRing: u
2474
2505
  };
2475
2506
  }
2476
- function Bn(e, t, n, r, i) {
2507
+ function Hn(e, t, n, r, i) {
2477
2508
  let a = new Float64Array(e.length);
2478
2509
  for (let o = 0; o < n; o++) {
2479
2510
  let n = o * 3, s = t.boundaryRing[o];
@@ -2497,8 +2528,8 @@ function Bn(e, t, n, r, i) {
2497
2528
  }
2498
2529
  return a;
2499
2530
  }
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);
2531
+ function Un(e, t) {
2532
+ let n = e.length / 3, r = Vn(n, t), i = r.edgeV0.length, a = Hn(e, r, n, zn, 1 / 8), o = new Float64Array((n + i) * 3);
2502
2533
  o.set(a);
2503
2534
  for (let t = 0; t < i; t++) {
2504
2535
  let i = r.edgeV0[t] * 3, a = r.edgeV1[t] * 3, s = (n + t) * 3, c = r.edgeOpp1[t];
@@ -2518,13 +2549,13 @@ function Vn(e, t) {
2518
2549
  indices: c
2519
2550
  };
2520
2551
  }
2521
- function Hn(e, t, n, r = 2e6) {
2552
+ function Wn(e, t, n, r = 2e6) {
2522
2553
  let i = Float64Array.from(e), a = Int32Array.from(t), o = 0;
2523
2554
  for (let e = 0; e < n && !(a.length / 3 * 4 > r); e++) {
2524
- let e = Vn(i, a);
2555
+ let e = Un(i, a);
2525
2556
  i = e.positions, a = e.indices, o++;
2526
2557
  }
2527
- let s = i.length / 3, c = Bn(i, zn(s, a), s, Rn, 1 / 5);
2558
+ let s = i.length / 3, c = Hn(i, Vn(s, a), s, Bn, 1 / 5);
2528
2559
  return {
2529
2560
  positions: Float32Array.from(c),
2530
2561
  indices: Uint32Array.from(a),
@@ -2533,7 +2564,7 @@ function Hn(e, t, n, r = 2e6) {
2533
2564
  }
2534
2565
  //#endregion
2535
2566
  //#region src/Processor/PBRT/EqualAreaOctahedral.js
2536
- function Un(e, t, n) {
2567
+ function Gn(e, t, n) {
2537
2568
  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);
2538
2569
  r < i && (c = 1 - c);
2539
2570
  let l = c * a, u = a - l;
@@ -2543,7 +2574,7 @@ function Un(e, t, n) {
2543
2574
  }
2544
2575
  return e < 0 && (u = -u), t < 0 && (l = -l), [.5 * (u + 1), .5 * (l + 1)];
2545
2576
  }
2546
- var Wn = (() => {
2577
+ var Kn = (() => {
2547
2578
  let e = new Float32Array(256);
2548
2579
  for (let t = 0; t < 256; t++) {
2549
2580
  let n = t / 255;
@@ -2551,15 +2582,15 @@ var Wn = (() => {
2551
2582
  }
2552
2583
  return e;
2553
2584
  })();
2554
- function Gn(e, t, n, r, i, a, o, s) {
2585
+ function qn(e, t, n, r, i, a, o, s) {
2555
2586
  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;
2556
2587
  for (let t = 0; t < 3; t++) {
2557
2588
  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;
2558
2589
  o[t] = c * (1 - h) + l * h;
2559
2590
  }
2560
2591
  }
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 = [
2592
+ function Jn(e, t, n = 1, r = 0) {
2593
+ let i = r || Math.min(e.width, 4096), a = Math.max(1, i >> 1), o = new Float32Array(i * a * 4), s = t ? K(t) : null, c = e.srgb ? Kn : null, l = [
2563
2594
  0,
2564
2595
  0,
2565
2596
  0
@@ -2572,8 +2603,8 @@ function Kn(e, t, n = 1, r = 0) {
2572
2603
  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;
2573
2604
  f = t / i, p = n / i, m = r / i;
2574
2605
  }
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);
2606
+ let [h, g] = Gn(f, p, m);
2607
+ qn(e.data, e.width, e.height, e.channels, h, e.bottomUp ? 1 - g : g, l, c);
2577
2608
  let _ = (t * i + r) * 4;
2578
2609
  o[_] = l[0] * n, o[_ + 1] = l[1] * n, o[_ + 2] = l[2] * n, o[_ + 3] = 1;
2579
2610
  }
@@ -2586,31 +2617,31 @@ function Kn(e, t, n = 1, r = 0) {
2586
2617
  }
2587
2618
  //#endregion
2588
2619
  //#region src/Processor/PBRT/PBRTCurves.js
2589
- var qn = 2;
2590
- function Jn(e, t) {
2620
+ var Yn = 2;
2621
+ function Xn(e, t) {
2591
2622
  let n = e * e, r = n * e;
2592
2623
  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;
2593
2624
  }
2594
- function Yn(e, t) {
2625
+ function Zn(e, t) {
2595
2626
  let n = 1 - e;
2596
2627
  t[0] = n * n * n, t[1] = 3 * n * n * e, t[2] = 3 * n * e * e, t[3] = e * e * e;
2597
2628
  }
2598
- function Xn(e) {
2629
+ function Qn(e) {
2599
2630
  let t = Math.hypot(e[0], e[1], e[2]);
2600
2631
  return t > 0 && (e[0] /= t, e[1] /= t, e[2] /= t), e;
2601
2632
  }
2602
- function Zn(e, t, n) {
2633
+ function $n(e, t, n) {
2603
2634
  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;
2604
2635
  }
2605
- function Qn(e, t) {
2636
+ function er(e, t) {
2606
2637
  let n = e.length / 3;
2607
2638
  return t === "bspline" ? n - 3 : Math.max(1, (n - 1) / 3);
2608
2639
  }
2609
- function $n(e, t, n, r, i, a, o) {
2640
+ function tr(e, t, n, r, i, a, o) {
2610
2641
  let s = Math.floor(r);
2611
2642
  s >= n && (s = n - 1);
2612
2643
  let c = r - s;
2613
- t === "bspline" ? Jn(c, i) : Yn(c, i);
2644
+ t === "bspline" ? Xn(c, i) : Zn(c, i);
2614
2645
  let l = t === "bspline" ? s : s * 3, u = 0, d = 0, f = 0;
2615
2646
  for (let t = 0; t < 4; t++) {
2616
2647
  let n = (l + t) * 3;
@@ -2618,8 +2649,8 @@ function $n(e, t, n, r, i, a, o) {
2618
2649
  }
2619
2650
  a[o] = u, a[o + 1] = d, a[o + 2] = f;
2620
2651
  }
2621
- function er(e, t, n) {
2622
- let r = Qn(e, t);
2652
+ function nr(e, t, n) {
2653
+ let r = er(e, t);
2623
2654
  if (r < 1) return null;
2624
2655
  let i = Math.max(1, Math.round(n * r)), a = new Float64Array((i + 1) * 3), o = [
2625
2656
  0,
@@ -2627,18 +2658,18 @@ function er(e, t, n) {
2627
2658
  0,
2628
2659
  0
2629
2660
  ];
2630
- for (let n = 0; n <= i; n++) $n(e, t, r, n / i * r, o, a, n * 3);
2661
+ for (let n = 0; n <= i; n++) tr(e, t, r, n / i * r, o, a, n * 3);
2631
2662
  return {
2632
2663
  points: a,
2633
2664
  count: i + 1,
2634
2665
  spans: r
2635
2666
  };
2636
2667
  }
2637
- function tr(e, t, n, r, i) {
2668
+ function rr(e, t, n, r, i) {
2638
2669
  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;
2639
2670
  return h = h < 0 ? 0 : h > 1 ? 1 : h, Math.hypot(a - c - h * d, o - l - h * f, s - u - h * p);
2640
2671
  }
2641
- function nr(e, t, n, r, i, a) {
2672
+ function ir(e, t, n, r, i, a) {
2642
2673
  let { points: o, count: s, spans: c } = n;
2643
2674
  if (s < 3) return null;
2644
2675
  let l = new Float64Array((s - 1) * 3), u = [
@@ -2647,12 +2678,12 @@ function nr(e, t, n, r, i, a) {
2647
2678
  0,
2648
2679
  0
2649
2680
  ], d = s - 1;
2650
- for (let n = 0; n < d; n++) $n(e, t, c, (n + .5) / d * c, u, l, n * 3);
2681
+ for (let n = 0; n < d; n++) tr(e, t, c, (n + .5) / d * c, u, l, n * 3);
2651
2682
  let f = 0;
2652
- for (let e = 0; e < d; e++) f = Math.max(f, tr(l, e, o, e, e + 1));
2683
+ for (let e = 0; e < d; e++) f = Math.max(f, rr(l, e, o, e, e + 1));
2653
2684
  let p = (e) => Math.max(f, r * .5 * (i + (a - i) * (e / d))), m = (e, t) => {
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;
2685
+ for (let n = e + 1; n < t; n++) if (rr(o, n, o, e, t) > p(n)) return !1;
2686
+ for (let n = e; n < t; n++) if (rr(l, n, o, e, t) > p(n + .5)) return !1;
2656
2687
  return !0;
2657
2688
  }, h = new Int32Array(s), g = 0;
2658
2689
  h[g++] = 0;
@@ -2663,12 +2694,12 @@ function nr(e, t, n, r, i, a) {
2663
2694
  }
2664
2695
  return g === s ? null : h.subarray(0, g);
2665
2696
  }
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));
2697
+ function ar(e) {
2698
+ let { P: t, basis: n = "bezier", width0: r = 1, width1: i = 1, N: a = null } = e, o = Math.max(1, Math.round(e.steps ?? Yn)), s = Math.max(1, Math.round(e.sides ?? 1));
2668
2699
  if (!t || t.length < 12) return null;
2669
- let c = er(t, n, o);
2700
+ let c = nr(t, n, o);
2670
2701
  if (!c) return null;
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 = [
2702
+ let { points: l, count: u } = c, d = e.tolerance > 0 ? ir(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 = [
2672
2703
  0,
2673
2704
  0,
2674
2705
  0
@@ -2687,18 +2718,18 @@ function rr(e) {
2687
2718
  ], y = !1, b = 0;
2688
2719
  for (let e = 0; e < u; e++) {
2689
2720
  let t = Math.max(0, e - 1), n = Math.min(u - 1, e + 1);
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) {
2721
+ 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], Qn(h), y) {
2691
2722
  let e = g[0] * h[0] + g[1] * h[1] + g[2] * h[2];
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, [
2723
+ 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 && $n(h, [
2693
2724
  0,
2694
2725
  1,
2695
2726
  0
2696
- ], g), Xn(g);
2727
+ ], g), Qn(g);
2697
2728
  } else {
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];
2729
+ if (a && a.length >= 3) g[0] = a[0], g[1] = a[1], g[2] = a[2], $n(h, g, v), g[0] = v[0], g[1] = v[1], g[2] = v[2];
2699
2730
  else {
2700
2731
  let e = Math.abs(h[0]), t = Math.abs(h[1]), n = Math.abs(h[2]);
2701
- Zn(h, e < t && e < n ? [
2732
+ $n(h, e < t && e < n ? [
2702
2733
  1,
2703
2734
  0,
2704
2735
  0
@@ -2712,14 +2743,14 @@ function rr(e) {
2712
2743
  1
2713
2744
  ], g);
2714
2745
  }
2715
- Math.hypot(g[0], g[1], g[2]) < 1e-9 && Zn(h, [
2746
+ Math.hypot(g[0], g[1], g[2]) < 1e-9 && $n(h, [
2716
2747
  0,
2717
2748
  1,
2718
2749
  0
2719
- ], g), Xn(g), y = !0;
2750
+ ], g), Qn(g), y = !0;
2720
2751
  }
2721
2752
  if (d && d[b] !== e) continue;
2722
- Zn(h, g, _), Xn(_);
2753
+ $n(h, g, _), Qn(_);
2723
2754
  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];
2724
2755
  for (let e = 0; e < p; e++) {
2725
2756
  let t, n, r;
@@ -2742,24 +2773,24 @@ function rr(e) {
2742
2773
  }
2743
2774
  return {
2744
2775
  positions: m,
2745
- indices: C === S.length ? S : B(S, C)
2776
+ indices: C === S.length ? S : H(S, C)
2746
2777
  };
2747
2778
  }
2748
2779
  //#endregion
2749
2780
  //#region src/Processor/PBRT/PBRTSceneBuilder.js
2750
- var ir = new Set([
2781
+ var or = new Set([
2751
2782
  "distant",
2752
2783
  "point",
2753
2784
  "spot"
2754
2785
  ]);
2755
- async function ar(e, t, n) {
2786
+ async function sr(e, t, n) {
2756
2787
  let r = e[t];
2757
2788
  if (r?.type === "spectrum" && typeof r.value[0] == "string" && r.value[0].startsWith("stdillum")) return [
2758
2789
  1,
2759
2790
  1,
2760
2791
  1
2761
2792
  ];
2762
- let i = (await Y(e, t, n, [
2793
+ let i = (await Z(e, t, n, [
2763
2794
  1,
2764
2795
  1,
2765
2796
  1
@@ -2772,7 +2803,7 @@ async function ar(e, t, n) {
2772
2803
  let a = .2126 * i[0] + .7152 * i[1] + .0722 * i[2];
2773
2804
  return a > 0 ? i.map((e) => e / a) : i;
2774
2805
  }
2775
- var Q = [
2806
+ var cr = [
2776
2807
  1,
2777
2808
  0,
2778
2809
  0,
@@ -2789,31 +2820,31 @@ var Q = [
2789
2820
  0,
2790
2821
  0,
2791
2822
  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);
2823
+ ], lr = 4096;
2824
+ function ur(e) {
2825
+ return e instanceof Uint32Array ? new L(e, 1) : ArrayBuffer.isView(e) && e.BYTES_PER_ELEMENT === 4 ? new L(new Uint32Array(e.buffer, e.byteOffset, e.length), 1) : new L(Uint32Array.from(e), 1);
2795
2826
  }
2796
- function cr(e, t) {
2827
+ function dr(e, t) {
2797
2828
  if (t <= e.length) return e;
2798
2829
  let n = e.length || 1;
2799
2830
  for (; n < t;) n *= 2;
2800
- return B(e, n);
2831
+ return H(e, n);
2801
2832
  }
2802
- function lr(e) {
2833
+ function fr(e) {
2803
2834
  return e instanceof Float32Array ? e : Float32Array.from(e);
2804
2835
  }
2805
- var ur = 1e3, dr = 45e6, fr = 6e6, pr = 256, mr = 4096, hr = 5e5, gr = 2, _r = {
2836
+ var pr = 1e3, mr = 45e6, hr = 6e6, gr = 256, _r = 4096, vr = 5e5, yr = 2, br = {
2806
2837
  flat: 1,
2807
2838
  ribbon: 1,
2808
2839
  cylinder: 2
2809
- }, vr = .05;
2810
- function yr(e, t) {
2840
+ }, xr = .05;
2841
+ function Sr(e, t) {
2811
2842
  if (e.count !== t.count) return !1;
2812
2843
  for (let n = 0, r = e.count * 16; n < r; n++) if (e.matrices[n] !== t.matrices[n]) return !1;
2813
2844
  return !0;
2814
2845
  }
2815
- function br(e, t) {
2816
- let n = Math.min(e.width, or), r = null;
2846
+ function Cr(e, t) {
2847
+ let n = Math.min(e.width, lr), r = null;
2817
2848
  if (typeof OffscreenCanvas < "u") r = new OffscreenCanvas(n, n);
2818
2849
  else if (typeof document < "u") r = document.createElement("canvas"), r.width = r.height = n;
2819
2850
  else return null;
@@ -2834,7 +2865,7 @@ function br(e, t) {
2834
2865
  return null;
2835
2866
  }
2836
2867
  }
2837
- function xr(e) {
2868
+ function wr(e) {
2838
2869
  let t = e?.image;
2839
2870
  if (!t) return null;
2840
2871
  if (ArrayBuffer.isView(t.data)) return {
@@ -2865,39 +2896,39 @@ function xr(e) {
2865
2896
  return null;
2866
2897
  }
2867
2898
  }
2868
- function Sr(e) {
2869
- let t = q(e, "encoding", "sRGB");
2899
+ function Tr(e) {
2900
+ let t = Y(e, "encoding", "sRGB");
2870
2901
  if (t === "linear") return (e) => e;
2871
2902
  let n = /^gamma\s+([\d.]+)$/.exec(t);
2872
- return n ? (e) => e ** Number(n[1]) : An;
2903
+ return n ? (e) => e ** Number(n[1]) : jn;
2873
2904
  }
2874
- function Cr(e) {
2905
+ function Er(e) {
2875
2906
  return {
2876
- su: K(e, "uscale", 1),
2877
- sv: K(e, "vscale", 1),
2878
- du: K(e, "udelta", 0),
2879
- dv: K(e, "vdelta", 0)
2907
+ su: J(e, "uscale", 1),
2908
+ sv: J(e, "vscale", 1),
2909
+ du: J(e, "udelta", 0),
2910
+ dv: J(e, "vdelta", 0)
2880
2911
  };
2881
2912
  }
2882
- function wr(e, { su: t, sv: n, du: r, dv: i }) {
2913
+ function Dr(e, { su: t, sv: n, du: r, dv: i }) {
2883
2914
  e.repeat.set(t, n), e.offset.set(r, i);
2884
2915
  }
2885
- function Tr(e, { srgb: t }) {
2916
+ function Or(e, { srgb: t }) {
2886
2917
  let n = e?.image?.data;
2887
2918
  if (!ArrayBuffer.isView(n) || n instanceof Uint8Array || n instanceof Uint8ClampedArray) return e;
2888
2919
  let { width: r, height: i } = e.image, a = new Uint8Array(r * i * 4), o = n.length / (r * i);
2889
2920
  for (let e = 0; e < r * i; e++) for (let r = 0; r < 4; r++) {
2890
2921
  let i = r < o ? Math.min(1, Math.max(0, n[e * o + r])) : 1;
2891
- a[e * 4 + r] = Math.round(255 * (t && r < 3 ? jn(i) : i));
2922
+ a[e * 4 + r] = Math.round(255 * (t && r < 3 ? Mn(i) : i));
2892
2923
  }
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;
2924
+ let s = new S(a, r, i, F);
2925
+ return s.flipY = e.flipY, s.colorSpace = t ? I : re, s.wrapS = s.wrapT = de, s.needsUpdate = !0, s;
2895
2926
  }
2896
2927
  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;
2928
+ let a = new S(e, t, n, F);
2929
+ return a.colorSpace = i ? I : re, a.wrapS = a.wrapT = de, Dr(a, r), a.needsUpdate = !0, a;
2899
2930
  }
2900
- function Er(e, t, n) {
2931
+ function kr(e, t, n) {
2901
2932
  let r = e.isOrthographicCamera === !0, i = r ? 1 : Math.tan(e.fov * Math.PI / 360), a = r ? 50 : 12 / i;
2902
2933
  return {
2903
2934
  enableDOF: !0,
@@ -2915,40 +2946,40 @@ function Er(e, t, n) {
2915
2946
  orthoHeight: r ? (e.top - e.bottom) / e.zoom : null
2916
2947
  };
2917
2948
  }
2918
- function Dr(e) {
2949
+ function Ar(e) {
2919
2950
  let t = {};
2920
2951
  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
2952
  }
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));
2953
+ var jr = 48;
2954
+ function Mr(e) {
2955
+ let t = J(e, "radius", 1), n = J(e, "zmin", -t), r = J(e, "zmax", t), i = (e) => Math.min(t, Math.max(-t, e));
2925
2956
  return {
2926
2957
  radius: t,
2927
2958
  zMin: i(Math.min(n, r)),
2928
2959
  zMax: i(Math.max(n, r)),
2929
- phiMax: Mr(e)
2960
+ phiMax: Fr(e)
2930
2961
  };
2931
2962
  }
2932
- function Ar(e) {
2933
- let t = K(e, "zmin", -1), n = K(e, "zmax", 1);
2963
+ function Nr(e) {
2964
+ let t = J(e, "zmin", -1), n = J(e, "zmax", 1);
2934
2965
  return {
2935
- radius: K(e, "radius", 1),
2966
+ radius: J(e, "radius", 1),
2936
2967
  zMin: Math.min(t, n),
2937
2968
  zMax: Math.max(t, n),
2938
- phiMax: Mr(e)
2969
+ phiMax: Fr(e)
2939
2970
  };
2940
2971
  }
2941
- function jr(e) {
2972
+ function Pr(e) {
2942
2973
  return {
2943
- radius: K(e, "radius", 1),
2944
- inner: K(e, "innerradius", 0),
2945
- height: K(e, "height", 0),
2946
- phiMax: Mr(e)
2974
+ radius: J(e, "radius", 1),
2975
+ inner: J(e, "innerradius", 0),
2976
+ height: J(e, "height", 0),
2977
+ phiMax: Fr(e)
2947
2978
  };
2948
2979
  }
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();
2980
+ var Fr = (e) => Math.min(360, Math.max(0, J(e, "phimax", 360))) * Math.PI / 180;
2981
+ function Ir(e, t, n) {
2982
+ let r = Math.max(3, Math.ceil(jr * 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 R(), l = new R();
2952
2983
  for (let e = 0; e <= t; e++) for (let u = 0; u <= r; u++) {
2953
2984
  let d = e * i + u;
2954
2985
  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;
@@ -2960,51 +2991,51 @@ function Nr(e, t, n) {
2960
2991
  let n = e * i + t, r = n + 1, a = n + i, o = a + 1;
2961
2992
  d(n, r) && f.push(n, r, o), d(a, o) && f.push(n, o, a);
2962
2993
  }
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;
2994
+ let p = new b();
2995
+ return p.setAttribute("position", new E(a, 3)), p.setAttribute("normal", new E(o, 3)), p.setAttribute("uv", new E(s, 2)), p.setIndex(new L(new Uint32Array(f), 1)), p;
2965
2996
  }
2966
- function Pr(e, t) {
2997
+ function Lr(e, t) {
2967
2998
  let n = e.params;
2968
2999
  switch (e.type) {
2969
3000
  case "sphere": {
2970
- let { radius: e, zMin: t, zMax: r, phiMax: i } = kr(n);
3001
+ let { radius: e, zMin: t, zMax: r, phiMax: i } = Mr(n);
2971
3002
  return i * e * (r - t);
2972
3003
  }
2973
3004
  case "cylinder": {
2974
- let { radius: e, zMin: t, zMax: r, phiMax: i } = Ar(n);
3005
+ let { radius: e, zMin: t, zMax: r, phiMax: i } = Nr(n);
2975
3006
  return i * e * (r - t);
2976
3007
  }
2977
3008
  case "disk": {
2978
- let { radius: e, inner: t, phiMax: r } = jr(n);
3009
+ let { radius: e, inner: t, phiMax: r } = Pr(n);
2979
3010
  return r * .5 * (e * e - t * t);
2980
3011
  }
2981
3012
  }
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;
3013
+ let r = new P().fromArray(e.ctm), i = t.getAttribute("position"), a = t.index, o = a ? a.count : i.count, s = new R(), c = new R(), l = new R(), u = 0;
2983
3014
  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
3015
  return u;
2985
3016
  }
2986
- var Fr = 64, Ir = 64;
2987
- function Lr(e, t, n) {
3017
+ var Rr = 64, zr = 64;
3018
+ function Br(e, t, n) {
2988
3019
  let r = new Uint8Array(e * t * 4);
2989
3020
  for (let i = 0; i < t; i++) for (let a = 0; a < e; a++) {
2990
3021
  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]))));
3022
+ for (let e = 0; e < 3; e++) r[s + e] = Math.round(255 * Mn(Math.min(1, Math.max(0, o[e]))));
2992
3023
  r[s + 3] = 255;
2993
3024
  }
2994
3025
  return r;
2995
3026
  }
2996
- function Rr(e) {
3027
+ function Vr(e) {
2997
3028
  let t = e.clone();
2998
3029
  for (let n of Object.keys(e)) n in t || (t[n] = e[n]);
2999
3030
  return t;
3000
3031
  }
3001
- function zr(e, t) {
3002
- let n = Rr(e);
3032
+ function Hr(e, t) {
3033
+ let n = Vr(e);
3003
3034
  return n.transparent = !0, n.opacity = e.opacity * t, n;
3004
3035
  }
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;
3036
+ var Ur = (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;
3037
+ function Wr(e, t) {
3038
+ if (e.float || !Pn(e)) return null;
3008
3039
  let { data: n, width: r, height: i } = e, a = new Uint8Array(256);
3009
3040
  for (let e = 0; e < 256; e++) a[e] = Math.round(255 * Math.min(1, Math.max(0, t(e / 255))));
3010
3041
  let o = new Uint8Array(r * i * 4), s = r * 4;
@@ -3012,10 +3043,10 @@ function Vr(e, t) {
3012
3043
  let r = (e.topDown ? i - 1 - t : t) * s, c = t * s;
3013
3044
  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
3045
  }
3015
- let c = new b(o, r, i, ue);
3016
- return c.colorSpace = P, c.wrapS = c.wrapT = de, c.needsUpdate = !0, c;
3046
+ let c = new S(o, r, i, F);
3047
+ return c.colorSpace = I, c.wrapS = c.wrapT = de, c.needsUpdate = !0, c;
3017
3048
  }
3018
- function Hr(e) {
3049
+ function Gr(e) {
3019
3050
  let t = [e], n = e, r = [
3020
3051
  (e) => e.replace(/-renamed-\d+$/, ""),
3021
3052
  (e) => e.replace(/\d+$/, ""),
@@ -3028,9 +3059,9 @@ function Hr(e) {
3028
3059
  }
3029
3060
  return t;
3030
3061
  }
3031
- var Ur = class {
3062
+ var Kr = class {
3032
3063
  constructor(e = {}) {
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();
3064
+ this.maxTriangles = e.maxTriangles ?? mr, this.maxPlacements = e.maxPlacements ?? hr, this.mergeShapesAbove = e.mergeShapesAbove ?? gr, this.curveSteps = e.curveSteps ?? yr, this.curveSides = e.curveSides ?? null, this.curveTolerance = e.curveTolerance ?? xr, 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();
3034
3065
  }
3035
3066
  warn(e) {
3036
3067
  this.warnings.push(e);
@@ -3040,12 +3071,12 @@ var Ur = class {
3040
3071
  for (let { name: t } of e.animatedInstances ?? []) for (let n of e.objects.get(t) ?? []) this._keepShapes.add(n);
3041
3072
  this._plyUsers = /* @__PURE__ */ new Map(), this._plyHeld = /* @__PURE__ */ new Set();
3042
3073
  for (let t of e.shapes) if (t?.type === "plymesh") {
3043
- let e = q(t.params, "filename", null);
3074
+ let e = Y(t.params, "filename", null);
3044
3075
  this._plyUsers.set(e, (this._plyUsers.get(e) ?? 0) + 1);
3045
3076
  }
3046
- for (let t of e.objects.values()) for (let e of t) e.type === "plymesh" && this._plyHeld.add(q(e.params, "filename", null));
3077
+ for (let t of e.objects.values()) for (let e of t) e.type === "plymesh" && this._plyHeld.add(Y(e.params, "filename", null));
3047
3078
  this._recoveredColors = 0, this.reportedMeshes = 0, this.triangleCount = 0, this.placementCount = 0, this.skippedForBudget = 0, this._countedGeometries = /* @__PURE__ */ new WeakSet();
3048
- let t = new D();
3079
+ let t = new k();
3049
3080
  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 = [];
3050
3081
  for (let n = 0; n < e.shapes.length; n++) {
3051
3082
  if (this._overBudget()) {
@@ -3055,11 +3086,11 @@ var Ur = class {
3055
3086
  let r = e.shapes[n], [i, a] = await Promise.all([this._batches ? this._createGeometry(r) : this._buildGeometry(r), this._getMaterial(r)]);
3056
3087
  if (!i) continue;
3057
3088
  let o = r.areaLight ? this._poweredMaterial(r, i, a) : a;
3058
- if (this._batches && !r.motion && i.getAttribute("position").count <= mr) {
3089
+ if (this._batches && !r.motion && i.getAttribute("position").count <= _r) {
3059
3090
  this._mergeShape(r, i, o, t), e.shapes[n] = null;
3060
3091
  continue;
3061
3092
  }
3062
- r.type === "plymesh" && this._plyHeld.add(q(r.params, "filename", null));
3093
+ r.type === "plymesh" && this._plyHeld.add(Y(r.params, "filename", null));
3063
3094
  let s = this._meshFromGeometry(r, i, o, r.ctm, `shape_${n}`);
3064
3095
  s && (t.add(s), r.motion && this._animate(s, r.motion));
3065
3096
  }
@@ -3076,7 +3107,7 @@ var Ur = class {
3076
3107
  camera: n,
3077
3108
  environment: i,
3078
3109
  animations: r,
3079
- render: Dr(e),
3110
+ render: Ar(e),
3080
3111
  report: this.report,
3081
3112
  meshCount: this.reportedMeshes,
3082
3113
  triangleCount: this.triangleCount,
@@ -3097,17 +3128,17 @@ var Ur = class {
3097
3128
  async _buildInstances(e, t) {
3098
3129
  let n = 0;
3099
3130
  e.skippedInstances > 0 && (this.skippedForBudget += e.skippedInstances);
3100
- let r = new Float64Array(16), i = new N(), a = (e, a, o, s, c, l, u) => {
3131
+ let r = new Float64Array(16), i = new P(), a = (e, a, o, s, c, l, u) => {
3101
3132
  let d = Math.max(0, this.maxPlacements - this.placementCount), f = Math.min(e.count, d);
3102
3133
  if (f < e.count && (this.skippedForBudget += e.count - f), f === 0) return;
3103
- let p = new k(a, o, f);
3134
+ let p = new j(a, o, f);
3104
3135
  p.name = `instance_${n++}`, p.frustumCulled = !1;
3105
3136
  for (let t = 0; t < f; t++) {
3106
- if (s) Xt(r, e.matrices, t * 16, s);
3137
+ if (s) Zt(r, e.matrices, t * 16, s);
3107
3138
  else for (let n = 0; n < 16; n++) r[n] = e.matrices[t * 16 + n];
3108
- p.setMatrixAt(t, i.fromArray(this.convertHandedness ? U(Q, r) : r));
3139
+ p.setMatrixAt(t, i.fromArray(this.convertHandedness ? G(cr, r) : r));
3109
3140
  }
3110
- p.instanceMatrix.needsUpdate = !0, t.add(p), this.placementCount += f, this.reportedMeshes += f, this.report.length < ur && this.report.push({
3141
+ p.instanceMatrix.needsUpdate = !0, t.add(p), this.placementCount += f, this.reportedMeshes += f, this.report.length < pr && this.report.push({
3111
3142
  mesh: `${p.name} ×${f}`,
3112
3143
  shape: c,
3113
3144
  material: l,
@@ -3137,7 +3168,7 @@ var Ur = class {
3137
3168
  }
3138
3169
  let [r, s] = await Promise.all([this._buildGeometry(e), this._getMaterial(e)]);
3139
3170
  if (!r) continue;
3140
- if (i && e.type !== "plymesh" && r.getAttribute("position").count <= mr) {
3171
+ if (i && e.type !== "plymesh" && r.getAttribute("position").count <= _r) {
3141
3172
  this._geometryCache.delete(e);
3142
3173
  let t = this._appendToBatch(i, e, r, s, e.relativeCTM || e.ctm);
3143
3174
  this._releaseMerged(e, r), o(n, t);
@@ -3147,7 +3178,7 @@ var Ur = class {
3147
3178
  a(n, r, this._materialForGeometry(e, r, s, `instances_${t}`), e.relativeCTM || e.ctm, e.type, e.material?.type || "diffuse", c);
3148
3179
  }
3149
3180
  if (i) for (let e of i.values()) o(n, e[0]), o(n, e[1]);
3150
- z(n.matrices), z(n.matricesEnd);
3181
+ V(n.matrices), V(n.matricesEnd);
3151
3182
  }
3152
3183
  }
3153
3184
  _samePlacementGroups(e) {
@@ -3164,11 +3195,11 @@ var Ur = class {
3164
3195
  }
3165
3196
  let o = `${i.count}:${Array.prototype.join.call(i.matrices.subarray(0, 16), ",")}`, s = n.get(o);
3166
3197
  s || n.set(o, s = []);
3167
- let c = s.find((e) => yr(e.list, i));
3198
+ let c = s.find((e) => Sr(e.list, i));
3168
3199
  if (c) {
3169
3200
  c.template === e.objects.get(c.name) && (c.template = c.template.slice());
3170
3201
  for (let e of a) c.template.push(e);
3171
- z(i.matrices);
3202
+ V(i.matrices);
3172
3203
  continue;
3173
3204
  }
3174
3205
  let l = {
@@ -3192,10 +3223,10 @@ var Ur = class {
3192
3223
  this.skippedForBudget += n.length - r;
3193
3224
  break;
3194
3225
  }
3195
- let s = new D();
3226
+ let s = new k();
3196
3227
  s.name = `placement_${r}`;
3197
3228
  let c = Array.from(a.matrices.subarray(0, 16));
3198
- new N().fromArray(this.convertHandedness ? U(Q, c) : c).decompose(s.position, s.quaternion, s.scale);
3229
+ new P().fromArray(this.convertHandedness ? G(cr, c) : c).decompose(s.position, s.quaternion, s.scale);
3199
3230
  for (let e = 0; e < o.length; e++) {
3200
3231
  let t = o[e], [n, r] = await Promise.all([this._buildGeometry(t), this._getMaterial(t)]);
3201
3232
  if (!n) continue;
@@ -3215,45 +3246,45 @@ var Ur = class {
3215
3246
  let n = [];
3216
3247
  for (let { node: e, motion: t } of this._animated) if (this._transformTracks(n, e.name, t, (e, t) => {
3217
3248
  let n = Array.from(e.subarray(t, t + 16));
3218
- return this.convertHandedness ? U(Q, n) : n;
3249
+ return this.convertHandedness ? G(cr, n) : n;
3219
3250
  }), t.visible) {
3220
3251
  let r = t.times, i = r.map((e, t) => t === 0 ? 0 : (r[t - 1] + e) / 2);
3221
- n.push(new g(`${e.name}.visible`, i, Array.from(t.visible, (e) => e === 1)));
3252
+ n.push(new v(`${e.name}.visible`, i, Array.from(t.visible, (e) => e === 1)));
3222
3253
  }
3223
3254
  let r = e.camera?.motion;
3224
3255
  if (t && r) {
3225
- let e = new oe();
3256
+ let e = new se();
3226
3257
  if (this._transformTracks(n, t.name, r, (t, n) => (this._poseCamera(e, t.subarray(n, n + 16)), e.updateMatrix(), e.matrix.elements)), r.fov && t.isPerspectiveCamera) {
3227
3258
  let e = Array.from(r.fov, (e) => this._verticalFov({ fov: {
3228
3259
  type: "float",
3229
3260
  value: [e]
3230
3261
  } }, t.aspect));
3231
- n.push(new re(`${t.name}.fov`, r.times.slice(), e));
3262
+ n.push(new ie(`${t.name}.fov`, r.times.slice(), e));
3232
3263
  }
3233
3264
  }
3234
3265
  for (let e of n) e.optimize();
3235
- return n.length === 0 ? [] : [new h(e.animation.name, e.animation.duration, n)];
3266
+ return n.length === 0 ? [] : [new _(e.animation.name, e.animation.duration, n)];
3236
3267
  }
3237
3268
  _transformTracks(e, t, n, r) {
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();
3269
+ let i = n.times.length, a = new Float32Array(i * 3), o = new Float32Array(i * 4), s = new Float32Array(i * 3), c = new P(), l = new R(), u = new le(), d = new R();
3239
3270
  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);
3240
3271
  let f = (e, t) => {
3241
3272
  for (let n = t; n < e.length; n++) if (e[n] !== e[n % t]) return !0;
3242
3273
  return !1;
3243
3274
  };
3244
- f(a, 3) && e.push(new me(`${t}.position`, n.times.slice(), a)), f(o, 4) && e.push(new le(`${t}.quaternion`, n.times.slice(), o)), f(s, 3) && e.push(new me(`${t}.scale`, n.times.slice(), s));
3275
+ f(a, 3) && e.push(new me(`${t}.position`, n.times.slice(), a)), f(o, 4) && e.push(new ue(`${t}.quaternion`, n.times.slice(), o)), f(s, 3) && e.push(new me(`${t}.scale`, n.times.slice(), s));
3245
3276
  }
3246
3277
  async _buildShapeMesh(e, t, n) {
3247
3278
  let [r, i] = await Promise.all([this._buildGeometry(e), this._getMaterial(e)]);
3248
3279
  return r ? this._meshFromGeometry(e, r, i, t, n) : null;
3249
3280
  }
3250
3281
  _meshFromGeometry(e, t, n, r, i, a = !1) {
3251
- let o = !!t.getAttribute("uv"), s = this._materialForGeometry(e, t, n, i), c = new ee(t, s);
3282
+ let o = !!t.getAttribute("uv"), s = this._materialForGeometry(e, t, n, i), c = new te(t, s);
3252
3283
  c.name = i;
3253
- let l = this.convertHandedness && !a ? U(Q, r) : r;
3254
- new N().fromArray(l).decompose(c.position, c.quaternion, c.scale), c.updateMatrix(), t.boundingBox || t.computeBoundingBox();
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({
3284
+ let l = this.convertHandedness && !a ? G(cr, r) : r;
3285
+ new P().fromArray(l).decompose(c.position, c.quaternion, c.scale), c.updateMatrix(), t.boundingBox || t.computeBoundingBox();
3286
+ let u = t.boundingBox ? t.boundingBox.clone().applyMatrix4(c.matrix).getSize(new R()) : new R(), d = this._accountGeometry(t);
3287
+ return this.placementCount++, this.reportedMeshes++, this.report.length < pr && this.report.push({
3257
3288
  mesh: i,
3258
3289
  shape: e.type,
3259
3290
  material: e.material?.type || "diffuse",
@@ -3269,18 +3300,18 @@ var Ur = class {
3269
3300
  _materialForGeometry(e, t, n, r) {
3270
3301
  if (!n.map || t.getAttribute("uv")) return n;
3271
3302
  let i = this._noUVMaterials.get(n);
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;
3303
+ return i || (this.warn(`${r} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), i = Vr(n), i.map = null, this._noUVMaterials.set(n, i)), i;
3273
3304
  }
3274
3305
  _mergeShape(e, t, n, r) {
3275
3306
  this.reportedMeshes++;
3276
- let i = this.convertHandedness ? U(Q, e.ctm) : e.ctm, a = this._appendToBatch(this._batches, e, t, n, i);
3307
+ let i = this.convertHandedness ? G(cr, e.ctm) : e.ctm, a = this._appendToBatch(this._batches, e, t, n, i);
3277
3308
  this._releaseMerged(e, t), a && this._flushBatch(a, r);
3278
3309
  }
3279
3310
  _releaseMerged(e, t) {
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);
3311
+ if (!this._keepShapes?.has(e) && !(e.type === "plymesh" && !this._lastPlyUse(Y(e.params, "filename", null)))) {
3312
+ for (let e in t.attributes) V(t.attributes[e].array);
3313
+ V(t.index?.array);
3314
+ for (let t in e.params) ArrayBuffer.isView(e.params[t]?.value) && V(e.params[t].value);
3284
3315
  }
3285
3316
  }
3286
3317
  _lastPlyUse(e) {
@@ -3303,8 +3334,8 @@ var Ur = class {
3303
3334
  indexCount: 0,
3304
3335
  triangles: 0
3305
3336
  });
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));
3337
+ let m = i, h = K(m), g = p.vertexCount;
3338
+ p.positions = dr(p.positions, (g + u) * 3), p.normals = dr(p.normals, (g + u) * 3), c && (p.uvs = dr(p.uvs, (g + u) * 2));
3308
3339
  let _ = o.array, v = p.positions, y = s ? s.array : null, b = p.normals;
3309
3340
  for (let e = 0; e < u; e++) {
3310
3341
  let t = e * 3, n = (g + e) * 3, r = _[t], i = _[t + 1], a = _[t + 2];
@@ -3314,19 +3345,19 @@ var Ur = class {
3314
3345
  }
3315
3346
  c && p.uvs.set(c.array.subarray(0, u * 2), g * 2);
3316
3347
  let x = l ? l.count : u;
3317
- p.indices = cr(p.indices, p.indexCount + x);
3348
+ p.indices = dr(p.indices, p.indexCount + x);
3318
3349
  let S = p.indices, C = l ? l.array : null;
3319
3350
  for (let e = 0; e < x; e++) S[p.indexCount + e] = g + (C ? C[e] : e);
3320
- return p.vertexCount += u, p.indexCount += x, p.triangles += x / 3, p.triangles >= hr ? (d[f] = null, p) : null;
3351
+ return p.vertexCount += u, p.indexCount += x, p.triangles += x / 3, p.triangles >= vr ? (d[f] = null, p) : null;
3321
3352
  }
3322
3353
  _batchGeometry(e) {
3323
- let t = new v();
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;
3354
+ let t = new b();
3355
+ return t.setAttribute("position", new E(H(e.positions, e.vertexCount * 3), 3)), t.setAttribute("normal", new E(H(e.normals, e.vertexCount * 3), 3)), e.uvs && t.setAttribute("uv", new E(H(e.uvs, e.vertexCount * 2), 2)), t.setIndex(new L(H(e.indices, e.indexCount), 1)), e.positions = e.normals = e.uvs = e.indices = null, t;
3325
3356
  }
3326
3357
  _flushBatch(e, t) {
3327
3358
  if (!e || e.triangles === 0) return;
3328
- let n = new ee(this._batchGeometry(e), e.material);
3329
- n.name = `merged_${this._mergedBatches++}`, n.frustumCulled = !1, t.add(n), this.placementCount++, this.report.length < ur && this.report.push({
3359
+ let n = new te(this._batchGeometry(e), e.material);
3360
+ n.name = `merged_${this._mergedBatches++}`, n.frustumCulled = !1, t.add(n), this.placementCount++, this.report.length < pr && this.report.push({
3330
3361
  mesh: n.name,
3331
3362
  shape: "merged",
3332
3363
  material: "-",
@@ -3345,7 +3376,7 @@ var Ur = class {
3345
3376
  }
3346
3377
  async _createGeometry(e) {
3347
3378
  let t = await this._shapeGeometry(e);
3348
- return t && e.areaLight && !J(e.areaLight.params, "twosided", !1) ? this._facingEmission(e, t) : t;
3379
+ return t && e.areaLight && !X(e.areaLight.params, "twosided", !1) ? this._facingEmission(e, t) : t;
3349
3380
  }
3350
3381
  _facingEmission(e, t) {
3351
3382
  let n = t.userData.pbrtNormals ? t.getAttribute("normal") : null;
@@ -3360,9 +3391,9 @@ var Ur = class {
3360
3391
  s[t] = n, s[t + 1] = u ? l : o, s[t + 2] = u ? o : l, u && c++;
3361
3392
  }
3362
3393
  if (c === 0) return t;
3363
- let l = new v();
3394
+ let l = new b();
3364
3395
  for (let e in t.attributes) l.setAttribute(e, t.getAttribute(e));
3365
- return l.setIndex(new F(s, 1)), l;
3396
+ return l.setIndex(new L(s, 1)), l;
3366
3397
  }
3367
3398
  _shapeGeometry(e) {
3368
3399
  switch (e.type) {
@@ -3380,41 +3411,41 @@ var Ur = class {
3380
3411
  _triangleMesh(e) {
3381
3412
  let t = e.P?.value;
3382
3413
  if (!t || t.length < 9) return this.warn("trianglemesh missing P"), null;
3383
- let n = new v();
3384
- n.setAttribute("position", new w(lr(t), 3));
3414
+ let n = new b();
3415
+ n.setAttribute("position", new E(fr(t), 3));
3385
3416
  let r = e.N?.value;
3386
- r && r.length === t.length && (n.setAttribute("normal", new w(lr(r), 3)), n.userData.pbrtNormals = !0);
3417
+ r && r.length === t.length && (n.setAttribute("normal", new E(fr(r), 3)), n.userData.pbrtNormals = !0);
3387
3418
  let i = (e.uv || e.st)?.value;
3388
- i && i.length === t.length / 3 * 2 && n.setAttribute("uv", new w(lr(i), 2));
3419
+ i && i.length === t.length / 3 * 2 && n.setAttribute("uv", new E(fr(i), 2));
3389
3420
  let a = e.indices?.value;
3390
- return a && a.length && n.setIndex(sr(a)), r || n.computeVertexNormals(), n;
3421
+ return a && a.length && n.setIndex(ur(a)), r || n.computeVertexNormals(), n;
3391
3422
  }
3392
3423
  _curve(e) {
3393
3424
  let t = e.P?.value;
3394
3425
  if (!t || t.length < 12) return this.warn("curve needs at least 4 control points"), null;
3395
- let n = Math.round(K(e, "degree", 3));
3426
+ let n = Math.round(J(e, "degree", 3));
3396
3427
  if (n !== 3) return this.warn(`curve degree ${n} not supported — only cubic`), null;
3397
- let r = q(e, "type", "flat"), i = K(e, "width", 1), a = rr({
3428
+ let r = Y(e, "type", "flat"), i = J(e, "width", 1), a = ar({
3398
3429
  P: t,
3399
- basis: q(e, "basis", "bezier"),
3400
- width0: K(e, "width0", i),
3401
- width1: K(e, "width1", i),
3430
+ basis: Y(e, "basis", "bezier"),
3431
+ width0: J(e, "width0", i),
3432
+ width1: J(e, "width1", i),
3402
3433
  N: e.N?.value || null,
3403
3434
  steps: this.curveSteps,
3404
- sides: this.curveSides ?? _r[r] ?? 1,
3435
+ sides: this.curveSides ?? br[r] ?? 1,
3405
3436
  tolerance: this.curveTolerance
3406
3437
  });
3407
3438
  if (!a) return this.warn("curve could not be tessellated"), null;
3408
- let o = new v();
3409
- return o.setAttribute("position", new w(a.positions, 3)), o.setIndex(new F(a.indices, 1)), o.computeVertexNormals(), o;
3439
+ let o = new b();
3440
+ return o.setAttribute("position", new E(a.positions, 3)), o.setIndex(new L(a.indices, 1)), o.computeVertexNormals(), o;
3410
3441
  }
3411
3442
  _loopSubdiv(e) {
3412
3443
  let t = e.P?.value, n = e.indices?.value;
3413
3444
  if (!t || t.length < 9 || !n || n.length < 3) return this.warn("loopsubdiv missing P/indices"), null;
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);
3445
+ let r = Math.max(0, Math.min(6, Math.round(J(e, "levels", 3)))), { positions: i, indices: a, levels: o } = Wn(t, n, r);
3415
3446
  o < r && this.warn(`loopsubdiv refined ${o}/${r} levels — the control mesh is too dense for the triangle budget`);
3416
- let s = new v();
3417
- return s.setAttribute("position", new w(i, 3)), s.setIndex(new F(a, 1)), s.computeVertexNormals(), s;
3447
+ let s = new b();
3448
+ return s.setAttribute("position", new E(i, 3)), s.setIndex(new L(a, 1)), s.computeVertexNormals(), s;
3418
3449
  }
3419
3450
  _bilinearMesh(e) {
3420
3451
  let t = e.P?.value, n = e.indices?.value ?? (t?.length === 12 ? [
@@ -3424,7 +3455,7 @@ var Ur = class {
3424
3455
  3
3425
3456
  ] : null);
3426
3457
  if (!t || !n) return this.warn("bilinearmesh missing P/indices"), null;
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();
3458
+ 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 b();
3428
3459
  if (i) {
3429
3460
  let e = [];
3430
3461
  for (let t = 0; t + 3 < n.length; t += 4) {
@@ -3436,7 +3467,7 @@ var Ur = class {
3436
3467
  ];
3437
3468
  e.push(r, i, o, r, o, a);
3438
3469
  }
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));
3470
+ o.setAttribute("position", new E(Float32Array.from(t), 3)), o.setAttribute("uv", new E(Float32Array.from(i), 2)), a && o.setAttribute("normal", new E(Float32Array.from(a), 3)), o.setIndex(new L(new Uint32Array(e), 1));
3440
3471
  } else {
3441
3472
  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
3473
  for (let o = 0; o < e; o++) {
@@ -3454,12 +3485,12 @@ var Ur = class {
3454
3485
  2
3455
3486
  ].map((e) => o * 4 + e), o * 6);
3456
3487
  }
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));
3488
+ o.setAttribute("position", new E(r, 3)), o.setAttribute("uv", new E(s, 2)), i && o.setAttribute("normal", new E(i, 3)), o.setIndex(new L(c, 1));
3458
3489
  }
3459
3490
  return a ? o.userData.pbrtNormals = !0 : o.computeVertexNormals(), o;
3460
3491
  }
3461
3492
  _plyMesh(e) {
3462
- let t = q(e, "filename", null);
3493
+ let t = Y(e, "filename", null);
3463
3494
  if (!t) return this.warn("plymesh missing filename"), null;
3464
3495
  let n = this._plyCache.get(t);
3465
3496
  return n || this._plyCache.set(t, n = this._decodePly(t)), n;
@@ -3473,22 +3504,22 @@ var Ur = class {
3473
3504
  }
3474
3505
  }
3475
3506
  _sphere(e) {
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) => {
3507
+ let { radius: t, zMin: n, zMax: r, phiMax: i } = Mr(e), a = Math.acos(n / t), o = Math.acos(r / t);
3508
+ return Ir(i, Math.max(1, Math.ceil(32 * (a - o) / Math.PI)), (e, n, r, s) => {
3478
3509
  let c = e * i, l = a + n * (o - a);
3479
3510
  s.set(Math.sin(l) * Math.cos(c), Math.sin(l) * Math.sin(c), Math.cos(l)), r.copy(s).multiplyScalar(t);
3480
3511
  });
3481
3512
  }
3482
3513
  _cylinder(e) {
3483
- let { radius: t, zMin: n, zMax: r, phiMax: i } = Ar(e);
3484
- return Nr(i, 1, (e, a, o, s) => {
3514
+ let { radius: t, zMin: n, zMax: r, phiMax: i } = Nr(e);
3515
+ return Ir(i, 1, (e, a, o, s) => {
3485
3516
  let c = e * i;
3486
3517
  s.set(Math.cos(c), Math.sin(c), 0), o.set(t * s.x, t * s.y, n + a * (r - n));
3487
3518
  });
3488
3519
  }
3489
3520
  _disk(e) {
3490
- let { radius: t, inner: n, height: r, phiMax: i } = jr(e);
3491
- return Nr(i, 1, (e, a, o, s) => {
3521
+ let { radius: t, inner: n, height: r, phiMax: i } = Pr(e);
3522
+ return Ir(i, 1, (e, a, o, s) => {
3492
3523
  let c = e * i, l = t - a * (t - n);
3493
3524
  o.set(l * Math.cos(c), l * Math.sin(c), r), s.set(0, 0, 1);
3494
3525
  });
@@ -3502,25 +3533,25 @@ var Ur = class {
3502
3533
  return r || this._alphaMaterials.set(e, r = /* @__PURE__ */ new Map()), r.has(n) || r.set(n, this._createAlphaMaterial(e, t)), r.get(n);
3503
3534
  }
3504
3535
  async _createAlphaMaterial(e, t) {
3505
- if (t.type !== "texture") return t.value[0] < 1 ? zr(e, t.value[0]) : e;
3536
+ if (t.type !== "texture") return t.value[0] < 1 ? Hr(e, t.value[0]) : e;
3506
3537
  let n = t.value[0], r = await this._alphaMap(e.map, n);
3507
3538
  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);
3539
+ if (r.constant !== void 0) return r.constant < 1 ? Hr(e, r.constant) : e;
3540
+ let i = Vr(e);
3510
3541
  return i.map = r, i.transparent = !0, i;
3511
3542
  }
3512
3543
  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;
3544
+ let n = this.ir.namedTextures.get(t), r = n?.class === "imagemap" ? Y(n.params, "filename", null) : null;
3545
+ if (r && e?.userData.pbrtImage === r && Y(n.params, "mapping", "uv") === "uv" && J(n.params, "scale", 1) === 1 && !X(n.params, "invert", !1) && Ur(e, Er(n.params))) {
3546
+ let t = wr(e), r = t && Wr(t, Tr(n.params));
3547
+ if (r) return Dr(r, Er(n.params)), r;
3517
3548
  }
3518
3549
  let i = await this._bakeTerm(t, 1);
3519
3550
  if (!i) return null;
3520
3551
  if (!i.layer) return { constant: i.rgb[0] };
3521
3552
  let a = e ? this._textureLayer(e, 3) : null;
3522
3553
  if (e && !a) return null;
3523
- let o = Z([a ? { layer: a } : { rgb: [
3554
+ let o = Ln([a ? { layer: a } : { rgb: [
3524
3555
  1,
3525
3556
  1,
3526
3557
  1
@@ -3530,7 +3561,7 @@ var Ur = class {
3530
3561
  async _surfaceMaterial(e) {
3531
3562
  let t = this._materialCache.get(e.material);
3532
3563
  if (t || (t = /* @__PURE__ */ new Map(), this._materialCache.set(e.material, t)), t.has(e.areaLight)) return t.get(e.areaLight);
3533
- let n = this._materialContext(), r = await On(e.material, n);
3564
+ let n = this._materialContext(), r = await kn(e.material, n);
3534
3565
  e.areaLight && await this._applyAreaLight(r, e.areaLight, n);
3535
3566
  let i = this._dedupeMaterial(r);
3536
3567
  return t.set(e.areaLight, i), i;
@@ -3542,7 +3573,7 @@ var Ur = class {
3542
3573
  warn: (e) => this.warn(e),
3543
3574
  floatTextureMean: async (e) => {
3544
3575
  let t = await this._bakeTerm(e, 1);
3545
- return t ? t.layer ? Pn(t.layer) : t.rgb[0] : null;
3576
+ return t ? t.layer ? Fn(t.layer) : t.rgb[0] : null;
3546
3577
  },
3547
3578
  bakeMaterialMix: (e, t, n) => this._bakeMaterialMix(e, t, n),
3548
3579
  bakeFloatMap: (e, t, n) => this._floatMap(e, t, n),
@@ -3560,8 +3591,8 @@ var Ur = class {
3560
3591
  resolveNormalMap: async (e) => {
3561
3592
  let t = await this._image(e);
3562
3593
  if (!t) return null;
3563
- let n = Tr(t, { srgb: !1 }), r = n === t ? t.clone() : n;
3564
- return r.colorSpace = ne, r;
3594
+ let n = Or(t, { srgb: !1 }), r = n === t ? t.clone() : n;
3595
+ return r.colorSpace = re, r;
3565
3596
  }
3566
3597
  };
3567
3598
  }
@@ -3571,24 +3602,24 @@ var Ur = class {
3571
3602
  return n || this._mediumMaterials.set(e, n = /* @__PURE__ */ new Map()), n.has(t) || n.set(t, this._attenuated(e, t)), n.get(t);
3572
3603
  }
3573
3604
  async _attenuated(e, t) {
3574
- let n = this.ir.media?.get(t), r = n && q(n, "type", "");
3605
+ let n = this.ir.media?.get(t), r = n && Y(n, "type", "");
3575
3606
  if (r !== "homogeneous") return this.warn(n ? `medium "${t}" (${r}) is not supported — "${t}" glass left clear` : `medium "${t}" not defined`), e;
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, [
3607
+ n.preset && this.warn(`medium preset "${Y(n, "preset", "")}" is not supported — using sigma_a / sigma_s`);
3608
+ let i = this._materialContext(), a = (await Z(n, "sigma_a", i, [
3578
3609
  1,
3579
3610
  1,
3580
3611
  1
3581
- ])).rgb, o = (await Y(n, "sigma_s", i, [
3612
+ ])).rgb, o = (await Z(n, "sigma_s", i, [
3582
3613
  1,
3583
3614
  1,
3584
3615
  1
3585
- ])).rgb, s = K(n, "scale", 1), c = [
3616
+ ])).rgb, s = J(n, "scale", 1), c = [
3586
3617
  0,
3587
3618
  1,
3588
3619
  2
3589
3620
  ].map((e) => (a[e] + o[e]) * s), l = Math.max(...c);
3590
3621
  if (!(l > 0)) return e;
3591
- let u = Rr(e);
3622
+ let u = Vr(e);
3592
3623
  return u.attenuationDistance = 1 / l, u.attenuationColor.setRGB(...c.map((e) => Math.exp(-e / l))), this._dedupeMaterial(u);
3593
3624
  }
3594
3625
  _dedupeMaterial(e) {
@@ -3596,16 +3627,16 @@ var Ur = class {
3596
3627
  return this._materialBySignature.get(r) || (this._materialBySignature.set(r, e), e);
3597
3628
  }
3598
3629
  _poweredMaterial(e, t, n) {
3599
- let r = K(e.areaLight.params, "power", -1);
3630
+ let r = J(e.areaLight.params, "power", -1);
3600
3631
  if (!(r > 0)) return n;
3601
- let i = Pr(e, t) * (J(e.areaLight.params, "twosided", !1) ? 2 : 1);
3632
+ let i = Lr(e, t) * (X(e.areaLight.params, "twosided", !1) ? 2 : 1);
3602
3633
  if (!(i > 0)) return n;
3603
- let a = Rr(n);
3634
+ let a = Vr(n);
3604
3635
  return a.emissiveIntensity = n.emissiveIntensity * r / (Math.PI * i), a;
3605
3636
  }
3606
3637
  async _applyAreaLight(e, t, n) {
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;
3638
+ let r = await sr(t.params, "L", n), i = J(t.params, "scale", 1);
3639
+ e.emissive.setRGB(r[0], r[1], r[2]), e.emissiveIntensity = i, e.side = X(t.params, "twosided", !1) ? w : O;
3609
3640
  }
3610
3641
  async _resolveNamedTexture(e) {
3611
3642
  if (this._textureCache.has(e)) return this._textureCache.get(e);
@@ -3635,12 +3666,12 @@ var Ur = class {
3635
3666
  async _proceduralTexture(e, t) {
3636
3667
  let n = t.params, r = this._materialContext(), i = async (e, t) => {
3637
3668
  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");
3669
+ return i?.type === "texture" ? await r.textureMeanRGB(i.value[0]) ?? t : (await Z(n, e, r, t)).rgb ?? t;
3670
+ }, a = Y(n, "mapping", "uv");
3640
3671
  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);
3672
+ let { su: o, sv: s, du: c, dv: l } = Er(n);
3642
3673
  if (t.class === "checkerboard") {
3643
- if (K(n, "dimension", 2) !== 2) return this.warn(`texture "${e}": a 3D checkerboard is not supported`), null;
3674
+ if (J(n, "dimension", 2) !== 2) return this.warn(`texture "${e}": a 3D checkerboard is not supported`), null;
3644
3675
  let [t, r] = await Promise.all([i("tex1", [
3645
3676
  1,
3646
3677
  1,
@@ -3649,9 +3680,9 @@ var Ur = class {
3649
3680
  0,
3650
3681
  0,
3651
3682
  0
3652
- ])]), a = 2 * Fr;
3683
+ ])]), a = 2 * Rr;
3653
3684
  return { texture: $({
3654
- data: Lr(a, a, (e, n) => (Math.floor(2 * e) + Math.floor(2 * n)) % 2 ? r : t),
3685
+ data: Br(a, a, (e, n) => (Math.floor(2 * e) + Math.floor(2 * n)) % 2 ? r : t),
3655
3686
  width: a,
3656
3687
  height: a,
3657
3688
  mapping: {
@@ -3685,13 +3716,13 @@ var Ur = class {
3685
3716
  ])
3686
3717
  ]);
3687
3718
  return { texture: $({
3688
- data: Lr(Ir, Ir, (e, t) => [
3719
+ data: Br(zr, zr, (e, t) => [
3689
3720
  0,
3690
3721
  1,
3691
3722
  2
3692
3723
  ].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,
3724
+ width: zr,
3725
+ height: zr,
3695
3726
  mapping: {
3696
3727
  su: o,
3697
3728
  sv: s,
@@ -3705,23 +3736,23 @@ var Ur = class {
3705
3736
  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;
3706
3737
  }
3707
3738
  async _imageMapTexture(e, t) {
3708
- let n = q(t.params, "filename", null);
3739
+ let n = Y(t.params, "filename", null);
3709
3740
  if (!n) return null;
3710
3741
  let r = await this._image(n);
3711
3742
  if (!r) return this.warn(`image not found for texture "${e}": ${n}`), null;
3712
- let i = q(t.params, "mapping", "uv");
3743
+ let i = Y(t.params, "mapping", "uv");
3713
3744
  i !== "uv" && this.warn(`texture "${e}": "${i}" mapping is not supported — using the mesh's uv`);
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([{
3745
+ let a = J(t.params, "scale", 1);
3746
+ if (a > 1 || X(t.params, "invert", !1)) {
3747
+ let t = await this._bakeTerm(e, 3), n = t?.layer && Ln([{
3717
3748
  ...t,
3718
3749
  clamp: !0
3719
3750
  }], ([e]) => e);
3720
3751
  if (n) return { texture: $(n) };
3721
3752
  this.warn(`texture "${e}": its scale or invert could not be baked here — ignored`);
3722
3753
  }
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 ? {
3754
+ let o = Or(r, { srgb: !0 }), s = o === r ? r.clone() : o;
3755
+ return s.userData.pbrtImage = n, Dr(s, Er(t.params)), s.needsUpdate = !0, a < 1 ? {
3725
3756
  texture: s,
3726
3757
  constant: [
3727
3758
  a,
@@ -3737,7 +3768,7 @@ var Ur = class {
3737
3768
  0
3738
3769
  ])));
3739
3770
  if (r.some((e) => !e)) return null;
3740
- let i = Z(r, (e) => {
3771
+ let i = Ln(r, (e) => {
3741
3772
  let t = n(e.map((e) => e[0]));
3742
3773
  return [
3743
3774
  t,
@@ -3766,7 +3797,7 @@ var Ur = class {
3766
3797
  ])
3767
3798
  ]);
3768
3799
  if (!n || !r || !i) return this.warn(`texture "${e}": a "mix" input could not be read here`), null;
3769
- let a = (e) => e.map((e) => Math.min(1, Math.max(0, e))), o = Z([
3800
+ let a = (e) => e.map((e) => Math.min(1, Math.max(0, e))), o = Ln([
3770
3801
  {
3771
3802
  ...n,
3772
3803
  clamp: !0
@@ -3776,8 +3807,8 @@ var Ur = class {
3776
3807
  clamp: !0
3777
3808
  },
3778
3809
  i
3779
- ], In);
3780
- return o ? { texture: $(o) } : { constant: In([
3810
+ ], Rn);
3811
+ return o ? { texture: $(o) } : { constant: Rn([
3781
3812
  a(n.rgb),
3782
3813
  a(r.rgb),
3783
3814
  i.rgb
@@ -3787,7 +3818,7 @@ var Ur = class {
3787
3818
  let i = e[t];
3788
3819
  if (!i) return { rgb: r };
3789
3820
  if (i.type === "texture") return this._bakeTerm(i.value[0], n);
3790
- let a = (await Y(e, t, this._materialContext(), r)).rgb;
3821
+ let a = (await Z(e, t, this._materialContext(), r)).rgb;
3791
3822
  return a ? { rgb: a } : null;
3792
3823
  }
3793
3824
  _bakeTerm(e, t) {
@@ -3797,14 +3828,14 @@ var Ur = class {
3797
3828
  async _createBakeTerm(e, t) {
3798
3829
  let n = this.ir.namedTextures.get(e);
3799
3830
  if (n?.class === "imagemap") {
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, {
3831
+ if (Y(n.params, "mapping", "uv") !== "uv") return null;
3832
+ let e = Y(n.params, "filename", null), r = wr(e && await this._image(e));
3833
+ return r ? { layer: Nn(r, {
3803
3834
  channels: t,
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)
3835
+ decode: r.float ? null : Tr(n.params),
3836
+ scale: J(n.params, "scale", 1),
3837
+ invert: X(n.params, "invert", !1),
3838
+ mapping: Er(n.params)
3808
3839
  }) } : null;
3809
3840
  }
3810
3841
  let r = await this._resolveNamedTexture(e);
@@ -3817,12 +3848,12 @@ var Ur = class {
3817
3848
  } : null;
3818
3849
  }
3819
3850
  _textureLayer(e, t) {
3820
- let n = xr(e);
3851
+ let n = wr(e);
3821
3852
  if (!n) return null;
3822
- let r = !n.float && e.colorSpace === P;
3823
- return Mn(n, {
3853
+ let r = !n.float && e.colorSpace === I;
3854
+ return Nn(n, {
3824
3855
  channels: t,
3825
- decode: n.float ? null : r ? An : (e) => e,
3856
+ decode: n.float ? null : r ? jn : (e) => e,
3826
3857
  mapping: {
3827
3858
  su: e.repeat.x,
3828
3859
  sv: e.repeat.y,
@@ -3838,7 +3869,7 @@ var Ur = class {
3838
3869
  mean: r.rgb[0],
3839
3870
  texture: null
3840
3871
  };
3841
- let i = Pn(r.layer), a = (e) => {
3872
+ let i = Fn(r.layer), a = (e) => {
3842
3873
  if (!e.map) return {
3843
3874
  rgb: e.color.toArray(),
3844
3875
  clamp: !0
@@ -3854,18 +3885,18 @@ var Ur = class {
3854
3885
  mean: i,
3855
3886
  texture: null
3856
3887
  };
3857
- let c = Z([
3888
+ let c = Ln([
3858
3889
  o,
3859
3890
  s,
3860
3891
  r
3861
- ], In);
3892
+ ], Rn);
3862
3893
  return {
3863
3894
  mean: i,
3864
3895
  texture: c ? $(c) : null
3865
3896
  };
3866
3897
  }
3867
3898
  _colorFromLikeNamedMaterial(e) {
3868
- for (let t of Hr(e)) {
3899
+ for (let t of Gr(e)) {
3869
3900
  let e = (this.ir?.namedMaterials?.get(t))?.params?.reflectance;
3870
3901
  if (e && (e.type === "rgb" || e.type === "color")) return {
3871
3902
  name: t,
@@ -3894,7 +3925,7 @@ var Ur = class {
3894
3925
  e[2] * t[0]
3895
3926
  ];
3896
3927
  if (n && r) {
3897
- let e = Z([{
3928
+ let e = Ln([{
3898
3929
  ...n,
3899
3930
  clamp: !0
3900
3931
  }, r], i);
@@ -3965,18 +3996,18 @@ var Ur = class {
3965
3996
  let n = t && t.yresolution ? t.xresolution / t.yresolution : 16 / 9, r;
3966
3997
  if (e.type === "orthographic") {
3967
3998
  let t = e.params?.screenwindow?.value, i = t?.length === 4 ? (t[3] - t[2]) / 2 : Math.max(1, 1 / n);
3968
- r = new ae(-i * n, i * n, i, -i, .01, 1e4);
3969
- } else r = new oe(this._verticalFov(e.params, n), n, .01, 1e4);
3999
+ r = new oe(-i * n, i * n, i, -i, .01, 1e4);
4000
+ } else r = new se(this._verticalFov(e.params, n), n, .01, 1e4);
3970
4001
  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;
4002
+ let i = J(e.params, "lensradius", 0);
4003
+ return i > 0 && (r.userData.__rayzeeEffects = kr(r, i, J(e.params, "focaldistance", 1e6))), r;
3973
4004
  }
3974
4005
  _poseCamera(e, t) {
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);
4006
+ let n = t, r = new R(n[12], n[13], n[14]), i = new R(n[8], n[9], n[10]), a = new R(n[4], n[5], n[6]);
4007
+ 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)), Xt(t) > 0 !== this.convertHandedness && (e.scale.x = -1);
3977
4008
  }
3978
4009
  _verticalFov(e, t) {
3979
- let n = K(e, "fov", 90);
4010
+ let n = J(e, "fov", 90);
3980
4011
  if (t >= 1) return n;
3981
4012
  let r = n * Math.PI / 180;
3982
4013
  return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
@@ -3995,31 +4026,31 @@ var Ur = class {
3995
4026
  channels: e,
3996
4027
  bottomUp: !0
3997
4028
  };
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);
4000
- return l.mapping = C, l.minFilter = A, l.magFilter = A, l.needsUpdate = !0, l;
4029
+ } else if (a = Cr(i, e.colorSpace === I), !a) return this.warn(`infinite-light image "${r}" could not be read back for octahedral conversion`), null;
4030
+ let { data: o, width: s, height: c } = Jn(a, t.ctm, n), l = new S(o, s, c, F, D);
4031
+ return l.mapping = T, l.minFilter = M, l.magFilter = M, l.needsUpdate = !0, l;
4001
4032
  }
4002
4033
  async _buildEnvironment(e) {
4003
4034
  let t = e.find((e) => e.type === "infinite");
4004
4035
  if (!t) return null;
4005
- let n = K(t.params, "scale", 1), r = q(t.params, "filename", null);
4036
+ let n = J(t.params, "scale", 1), r = Y(t.params, "filename", null);
4006
4037
  if (r) try {
4007
4038
  let e = await this.resolveEnvironment(r);
4008
4039
  if (e) {
4009
4040
  let i = this._equirectFromInfiniteLight(e, t, n, r);
4010
- return i ? { texture: i } : (e.mapping = C, { texture: e });
4041
+ return i ? { texture: i } : (e.mapping = T, { texture: e });
4011
4042
  }
4012
4043
  this.warn(`infinite-light image not found: ${r}`);
4013
4044
  } catch (e) {
4014
4045
  this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
4015
4046
  }
4016
- let i = (await ar(t.params, "L", {
4047
+ let i = (await sr(t.params, "L", {
4017
4048
  resolveNamedTexture: async () => null,
4018
4049
  warn: (e) => this.warn(e)
4019
4050
  })).map((e) => e * n), a = new Float32Array(8);
4020
4051
  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;
4021
- let o = new b(a, 2, 1, ue, T);
4022
- return o.mapping = C, o.minFilter = A, o.magFilter = A, o.needsUpdate = !0, { texture: o };
4052
+ let o = new S(a, 2, 1, F, D);
4053
+ return o.mapping = T, o.minFilter = M, o.magFilter = M, o.needsUpdate = !0, { texture: o };
4023
4054
  }
4024
4055
  async _buildLamps(e, t) {
4025
4056
  let n = {
@@ -4027,11 +4058,11 @@ var Ur = class {
4027
4058
  warn: (e) => this.warn(e)
4028
4059
  };
4029
4060
  for (let r of e) {
4030
- if (!ir.has(r.type)) continue;
4031
- let e = new N().fromArray(this.convertHandedness ? U(Q, r.ctm) : r.ctm), i = (t, n) => {
4061
+ if (!or.has(r.type)) continue;
4062
+ let e = new P().fromArray(this.convertHandedness ? G(cr, r.ctm) : r.ctm), i = (t, n) => {
4032
4063
  let i = r.params[t]?.value;
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", [
4064
+ return new R().fromArray(i?.length >= 3 ? i : n).applyMatrix4(e);
4065
+ }, a = await sr(r.params, r.type === "distant" ? "L" : "I", n), o = J(r.params, "scale", 1), s = i("from", [
4035
4066
  0,
4036
4067
  0,
4037
4068
  0
@@ -4041,13 +4072,13 @@ var Ur = class {
4041
4072
  1
4042
4073
  ]), l;
4043
4074
  if (r.type === "distant") {
4044
- let e = K(r.params, "illuminance", -1);
4045
- e > 0 && (o *= e), l = new x(), l.userData.__luxConverted = !0;
4075
+ let e = J(r.params, "illuminance", -1);
4076
+ e > 0 && (o *= e), l = new C(), l.userData.__luxConverted = !0;
4046
4077
  } else if (r.type === "point") {
4047
- let e = K(r.params, "power", -1);
4048
- o *= e > 0 ? e : 4 * Math.PI, l = new se(), l.userData.__candelaConverted = !0;
4078
+ let e = J(r.params, "power", -1);
4079
+ o *= e > 0 ? e : 4 * Math.PI, l = new ce(), l.userData.__candelaConverted = !0;
4049
4080
  } else {
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);
4081
+ let e = Math.min(Math.max(J(r.params, "coneangle", 30), 0), 90) * Math.PI / 180, t = Math.min(Math.max(J(r.params, "conedeltaangle", 5) * Math.PI / 180, 0), e), n = Math.cos(e), i = Math.cos(e - t), a = J(r.params, "power", -1);
4051
4082
  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;
4052
4083
  }
4053
4084
  let u = Math.max(a[0], a[1], a[2]);
@@ -4055,10 +4086,10 @@ var Ur = class {
4055
4086
  }
4056
4087
  }
4057
4088
  _reportUnsupportedLights(e) {
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)`);
4089
+ for (let t of e) t.type !== "infinite" && !or.has(t.type) && this.warn(`light "${t.type}" not supported (only infinite, distant, point and spot lights and emissive area lights are mapped)`);
4059
4090
  }
4060
- }, Wr = 1e3, Gr = 2048, Kr = 1e5;
4061
- function qr(e) {
4091
+ }, qr = 1e3, Jr = 2048, Yr = 1e5;
4092
+ function Xr(e) {
4062
4093
  let t = e[0], n = (e) => {
4063
4094
  let t = e.lastIndexOf("/"), n = /^(.*?)(\d+)\.pbrt$/i.exec(e.slice(t + 1));
4064
4095
  return n ? {
@@ -4072,70 +4103,70 @@ function qr(e) {
4072
4103
  let e = n(t);
4073
4104
  e && e.group === r.group && !i.has(e.number) && i.set(e.number, t);
4074
4105
  }
4075
- return i.size < 2 ? null : [...i].sort((e, t) => e[0] - t[0]).slice(0, Wr).map(([e, t]) => ({
4106
+ return i.size < 2 ? null : [...i].sort((e, t) => e[0] - t[0]).slice(0, qr).map(([e, t]) => ({
4076
4107
  path: t,
4077
4108
  number: e
4078
4109
  }));
4079
4110
  }
4080
- function Jr(e) {
4111
+ function Zr(e) {
4081
4112
  let t = e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array ? new Uint32Array(e.buffer, e.byteOffset, e.length) : null;
4082
4113
  t ||= new Uint32Array(Float32Array.from(e).buffer);
4083
4114
  let n = 2166136261;
4084
4115
  for (let e = 0; e < t.length; e++) n = Math.imul(n ^ t[e], 16777619), n ^= n >>> 15;
4085
4116
  return (n >>> 0).toString(36) + ":" + e.length;
4086
4117
  }
4087
- function Yr(e) {
4118
+ function Qr(e) {
4088
4119
  let t = "";
4089
4120
  for (let n of Object.keys(e).sort()) {
4090
4121
  let { type: r, value: i } = e[n], a = ArrayBuffer.isView(i) || i.length > 16 && typeof i[0] == "number";
4091
- t += `${r} ${n}=${a ? "#" + Jr(i) : i.join(",")};`;
4122
+ t += `${r} ${n}=${a ? "#" + Zr(i) : i.join(",")};`;
4092
4123
  }
4093
4124
  return t;
4094
4125
  }
4095
- var Xr = class {
4126
+ var $r = class {
4096
4127
  constructor(e) {
4097
4128
  this.materialNames = /* @__PURE__ */ new Map();
4098
4129
  for (let [t, n] of e.namedMaterials) this.materialNames.set(n, t);
4099
4130
  this.cache = /* @__PURE__ */ new Map();
4100
4131
  }
4101
4132
  of(e) {
4102
- return `${e.type}|${+!!e.reverseOrientation}|${Yr(e.params)}|${this._material(e.material)}|${this._light(e.areaLight)}`;
4133
+ return `${e.type}|${+!!e.reverseOrientation}|${Qr(e.params)}|${this._material(e.material)}|${this._light(e.areaLight)}`;
4103
4134
  }
4104
4135
  _material(e) {
4105
4136
  if (!e) return "-";
4106
4137
  let t = this.cache.get(e);
4107
4138
  if (t === void 0) {
4108
4139
  let n = this.materialNames.get(e) ?? e._missingRef;
4109
- t = n === void 0 ? "I:" + e.type + ":" + Yr(e.params) : "N:" + n, this.cache.set(e, t);
4140
+ t = n === void 0 ? "I:" + e.type + ":" + Qr(e.params) : "N:" + n, this.cache.set(e, t);
4110
4141
  }
4111
4142
  return t;
4112
4143
  }
4113
4144
  _light(e) {
4114
4145
  if (!e) return "-";
4115
4146
  let t = this.cache.get(e);
4116
- return t === void 0 && this.cache.set(e, t = "L:" + e.type + ":" + Yr(e.params)), t;
4147
+ return t === void 0 && this.cache.set(e, t = "L:" + e.type + ":" + Qr(e.params)), t;
4117
4148
  }
4118
4149
  };
4119
- function Zr(e, t) {
4150
+ function ei(e, t) {
4120
4151
  let n = new Int32Array(t.length).fill(-1), r = 0;
4121
4152
  for (; r < e.length && r < t.length && e[r] === t[r];) n[r] = r, r++;
4122
4153
  let i = e.length, a = t.length;
4123
4154
  for (; i > r && a > r && e[i - 1] === t[a - 1];) n[--a] = --i;
4124
- return r < i && r < a && !Qr(e, r, i, t, r, a, n) && ei(e, r, i, t, r, a, n), n;
4155
+ return r < i && r < a && !ti(e, r, i, t, r, a, n) && ri(e, r, i, t, r, a, n), n;
4125
4156
  }
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 = [];
4157
+ function ti(e, t, n, r, i, a, o) {
4158
+ let s = n - t, c = a - i, l = Math.min(s + c, Jr), u = l + 1, d = new Int32Array(2 * l + 3), f = [];
4128
4159
  for (let n = 0; n <= l; n++) {
4129
4160
  for (let a = -n; a <= n; a += 2) {
4130
4161
  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;
4131
4162
  for (; l < s && p < c && e[t + l] === r[i + p];) l++, p++;
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;
4163
+ if (d[u + a] = l, l >= s && p >= c) return f.push(d.slice(u - n, u + n + 1)), ni(f, s, c, t, i, o), !0;
4133
4164
  }
4134
4165
  f.push(d.slice(u - n, u + n + 1));
4135
4166
  }
4136
4167
  return !1;
4137
4168
  }
4138
- function $r(e, t, n, r, i, a) {
4169
+ function ni(e, t, n, r, i, a) {
4139
4170
  let o = t, s = n;
4140
4171
  for (let t = e.length - 1; t > 0; t--) {
4141
4172
  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;
@@ -4144,7 +4175,7 @@ function $r(e, t, n, r, i, a) {
4144
4175
  }
4145
4176
  for (; o > 0 && s > 0;) a[i + --s] = r + --o;
4146
4177
  }
4147
- function ei(e, t, n, r, i, a, o) {
4178
+ function ri(e, t, n, r, i, a, o) {
4148
4179
  let s = /* @__PURE__ */ new Map();
4149
4180
  for (let r = t; r < n; r++) {
4150
4181
  let t = s.get(e[r]);
@@ -4158,11 +4189,11 @@ function ei(e, t, n, r, i, a, o) {
4158
4189
  n < t.length && (o[e] = t[n], c.set(r[e], n + 1));
4159
4190
  }
4160
4191
  }
4161
- function ti(e, t, n, r) {
4192
+ function ii(e, t, n, r) {
4162
4193
  for (let i = 0; i < 16; i++) if (e[t + i] !== n[r + i]) return !1;
4163
4194
  return !0;
4164
4195
  }
4165
- function ni(e, t, n) {
4196
+ function ai(e, t, n) {
4166
4197
  let r = e.length, i = new Float32Array(16 * r), a = null, o = -1;
4167
4198
  for (let e = 0; e < r; e++) if (t(e)) {
4168
4199
  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);
@@ -4174,13 +4205,13 @@ function ni(e, t, n) {
4174
4205
  visible: a
4175
4206
  };
4176
4207
  }
4177
- function ri(e) {
4208
+ function oi(e) {
4178
4209
  if (e.visible) return !1;
4179
4210
  let t = e.matrices;
4180
- for (let e = 16; e < t.length; e += 16) if (!ti(t, 0, t, e)) return !1;
4211
+ for (let e = 16; e < t.length; e += 16) if (!ii(t, 0, t, e)) return !1;
4181
4212
  return !0;
4182
4213
  }
4183
- var ii = class {
4214
+ var si = class {
4184
4215
  constructor(e, t) {
4185
4216
  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();
4186
4217
  }
@@ -4188,15 +4219,15 @@ var ii = class {
4188
4219
  let t = ++this.frame;
4189
4220
  t === 0 ? this.base = e : this._adoptDefinitions(e);
4190
4221
  for (let t of e.warnings) this.warnings.add(t);
4191
- let n = new Xr(e), r = new Int32Array(e.shapes.length);
4222
+ let n = new $r(e), r = new Int32Array(e.shapes.length);
4192
4223
  for (let t = 0; t < r.length; t++) {
4193
4224
  let i = n.of(e.shapes[t]), a = this.keyIds.get(i);
4194
4225
  a === void 0 && this.keyIds.set(i, a = this.keyIds.size), r[t] = a;
4195
4226
  }
4196
- let i = this.prev ? Zr(this.prev.keys, r) : null, a = Array(r.length);
4227
+ let i = this.prev ? ei(this.prev.keys, r) : null, a = Array(r.length);
4197
4228
  for (let o = 0; o < r.length; o++) {
4198
4229
  let r = e.shapes[o], s = i && i[o] >= 0 ? this.prev.tracks[i[o]] : null;
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 = {
4230
+ s ? (s.last = t, s.ctms ? s.ctms.push(r.ctm) : r.ctm !== s.shape.ctm && !ii(r.ctm, 0, s.shape.ctm, 0) && (s.ctms = Array(t - s.first).fill(s.shape.ctm), s.ctms.push(r.ctm))) : (s = {
4200
4231
  shape: r,
4201
4232
  first: t,
4202
4233
  last: t,
@@ -4243,7 +4274,7 @@ var ii = class {
4243
4274
  let o = this.base.instances.get(e), s = o?.count ?? 0;
4244
4275
  for (let e = 0; e < i.count; e++) {
4245
4276
  let n = e * 16;
4246
- if (e < s && ti(i.matrices, n, o.matrices, n)) continue;
4277
+ if (e < s && ii(i.matrices, n, o.matrices, n)) continue;
4247
4278
  let r = a.diffs.get(e);
4248
4279
  r || a.diffs.set(e, r = /* @__PURE__ */ new Map()), r.set(t, i.matrices.slice(n, n + 16));
4249
4280
  }
@@ -4253,12 +4284,12 @@ var ii = class {
4253
4284
  let e = this.base, t = this.times, n = this.frame + 1;
4254
4285
  e.shapes = this.tracks.map((e) => {
4255
4286
  let { shape: r, first: i, last: a, ctms: o } = e;
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;
4287
+ return (i > 0 || a < n - 1 || o) && (r.motion = ai(t, (e) => e >= i && e <= a, (e) => o ? o[e - i] : r.ctm)), r;
4257
4288
  }), e.warnings = [...this.warnings], e.animatedInstances = this._finishPlacements(e, t, n);
4258
4289
  let r = this.cameras;
4259
4290
  if (r[0] && r.every(Boolean)) {
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 = {
4291
+ let n = ai(t, () => !0, (e) => r[e].cameraToWorld), i = r.map((e) => e.fov ?? r[0].fov), a = i.some((e) => e !== i[0]);
4292
+ (!oi(n) || a) && (e.camera.motion = {
4262
4293
  ...n,
4263
4294
  fov: a ? Float32Array.from(i) : null
4264
4295
  });
@@ -4276,8 +4307,8 @@ var ii = class {
4276
4307
  for (let e = 0; e < u; e++) {
4277
4308
  let u = s.get(e), f = !!u;
4278
4309
  for (let t = 0; t < n && !f; t++) f = e >= o[t];
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));
4310
+ if (f && r.length < Yr) {
4311
+ let n = ai(t, (t) => e < o[t], (t) => u?.get(t) ?? c.matrices.subarray(e * 16, e * 16 + 16));
4281
4312
  r.push({
4282
4313
  name: a,
4283
4314
  motion: n
@@ -4289,10 +4320,10 @@ var ii = class {
4289
4320
  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;
4290
4321
  }
4291
4322
  }
4292
- return i > 0 && e.warnings.push(`${i.toLocaleString()} moving placement(s) past ${Kr.toLocaleString()} left static`), r;
4323
+ return i > 0 && e.warnings.push(`${i.toLocaleString()} moving placement(s) past ${Yr.toLocaleString()} left static`), r;
4293
4324
  }
4294
4325
  };
4295
- function ai(e) {
4326
+ function ci(e) {
4296
4327
  if (!e.hasMotion) return e;
4297
4328
  let { start: t, end: n } = e.transformTimes, r = n - t;
4298
4329
  if (!(r > 0)) return e;
@@ -4312,7 +4343,7 @@ function ai(e) {
4312
4343
  let n = [];
4313
4344
  for (let r = 0; r < t.count; r++) {
4314
4345
  let i = r * 16;
4315
- ti(t.matrices, i, t.matricesEnd, i) || e.animatedInstances.length >= Kr ? n.push(r) : e.animatedInstances.push({
4346
+ ii(t.matrices, i, t.matricesEnd, i) || e.animatedInstances.length >= Yr ? n.push(r) : e.animatedInstances.push({
4316
4347
  name: t.name,
4317
4348
  motion: a(t.matrices, i, t.matricesEnd, i)
4318
4349
  });
@@ -4334,20 +4365,20 @@ function ai(e) {
4334
4365
  }
4335
4366
  //#endregion
4336
4367
  //#region src/Processor/PBRT/index.js
4337
- var oi = 2e6, si = new TextDecoder();
4338
- function ci(e) {
4368
+ var li = 2e6, ui = new TextDecoder();
4369
+ function di(e) {
4339
4370
  let t = e.replace(/\\/g, "/").split("/"), n = [];
4340
4371
  for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
4341
4372
  return n.join("/");
4342
4373
  }
4343
- function li(e, t) {
4344
- return !e || t.startsWith("/") ? ci(t) : ci(`${e}/${t}`);
4374
+ function fi(e, t) {
4375
+ return !e || t.startsWith("/") ? di(t) : di(`${e}/${t}`);
4345
4376
  }
4346
- var ui = class {
4377
+ var pi = class {
4347
4378
  constructor(e, t = null) {
4348
4379
  this.entries = e, this.source = t, this.records = [], this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
4349
4380
  let n = (e, t, n) => {
4350
- let r = ci(e).toLowerCase();
4381
+ let r = di(e).toLowerCase();
4351
4382
  if (this.byPath.has(r)) return;
4352
4383
  let i = {
4353
4384
  key: e,
@@ -4369,21 +4400,21 @@ var ui = class {
4369
4400
  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;
4370
4401
  }
4371
4402
  async readPath(e, t = null) {
4372
- let n = t !== null && this.findRecord(li(t, e)) || this.findRecord(e);
4403
+ let n = t !== null && this.findRecord(fi(t, e)) || this.findRecord(e);
4373
4404
  return this.read(n);
4374
4405
  }
4375
4406
  release(e) {
4376
4407
  e.bytes = null, delete this.entries[e.key];
4377
4408
  }
4378
4409
  releasePath(e, t = null, n = null) {
4379
- let r = t !== null && this.findRecord(li(t, e)) || this.findRecord(e);
4380
- r?.lazy && (this.release(r), z(n));
4410
+ let r = t !== null && this.findRecord(fi(t, e)) || this.findRecord(e);
4411
+ r?.lazy && (this.release(r), V(n));
4381
4412
  }
4382
4413
  releaseScenes() {
4383
4414
  for (let e of this.records) e.norm.endsWith(".pbrt") && this.release(e);
4384
4415
  }
4385
4416
  findRecord(e) {
4386
- let t = ci(e).toLowerCase();
4417
+ let t = di(e).toLowerCase();
4387
4418
  if (this.byPath.has(t)) return this.byPath.get(t);
4388
4419
  let n = this.byBase.get(t.split("/").pop());
4389
4420
  return n ? n.find((e) => e.norm.endsWith("/" + t)) || (n.length === 1 ? n[0] : null) : null;
@@ -4392,7 +4423,7 @@ var ui = class {
4392
4423
  return this.findRecord(e)?.bytes ?? null;
4393
4424
  }
4394
4425
  };
4395
- function di(e, t, n = 0) {
4426
+ function mi(e, t, n = 0) {
4396
4427
  let r = t[0], i = e.length - t.length;
4397
4428
  outer: for (let a = n; a <= i; a++) if (e[a] === r) {
4398
4429
  for (let n = 1; n < t.length; n++) if (e[a + n] !== t[n]) continue outer;
@@ -4400,8 +4431,8 @@ function di(e, t, n = 0) {
4400
4431
  }
4401
4432
  return -1;
4402
4433
  }
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) {
4434
+ var hi = (e) => Uint8Array.from(e, (e) => e.charCodeAt(0)), gi = 4 * 1024 * 1024, _i = hi("WorldBegin"), vi = [hi("Include"), hi("Import")];
4435
+ function yi(e, t) {
4405
4436
  for (let n = t - 1; n >= 0; n--) {
4406
4437
  let t = e[n];
4407
4438
  if (t === 10) return !0;
@@ -4409,34 +4440,34 @@ function gi(e, t) {
4409
4440
  }
4410
4441
  return !0;
4411
4442
  }
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;
4443
+ function bi(e) {
4444
+ for (let t = mi(e, _i); t >= 0; t = mi(e, _i, t + 1)) if (yi(e, t)) return !0;
4414
4445
  return !1;
4415
4446
  }
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;
4447
+ function xi(e, t) {
4448
+ for (let n of vi) for (let r = mi(e, n); r >= 0; r = mi(e, n, r + 1)) {
4449
+ if (!yi(e, r)) continue;
4419
4450
  let i = r + n.length;
4420
4451
  for (; i < e.length && (e[i] === 32 || e[i] === 9);) i++;
4421
4452
  if (e[i] !== 34) continue;
4422
4453
  let a = ++i;
4423
4454
  for (; i < e.length && e[i] !== 34 && e[i] !== 10;) i++;
4424
4455
  if (e[i] !== 34) continue;
4425
- let o = si.decode(e.subarray(a, i));
4426
- t.add(ci(o).toLowerCase().split("/").pop());
4456
+ let o = ui.decode(e.subarray(a, i));
4457
+ t.add(di(o).toLowerCase().split("/").pop());
4427
4458
  }
4428
4459
  }
4429
- function yi(e) {
4460
+ function Si(e) {
4430
4461
  let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
4431
4462
  if (t.length <= 1) return t;
4432
4463
  let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
4433
4464
  for (let i of t) {
4434
4465
  let t = e[i];
4435
- r.set(i, _i(t)), vi(t, n);
4466
+ r.set(i, bi(t)), xi(t, n);
4436
4467
  }
4437
- return bi(t, r, n);
4468
+ return Ci(t, r, n);
4438
4469
  }
4439
- function bi(e, t, n) {
4470
+ function Ci(e, t, n) {
4440
4471
  let r = (e, t) => {
4441
4472
  let n = e.filter(t);
4442
4473
  return n.length ? n : e;
@@ -4446,10 +4477,10 @@ function bi(e, t, n) {
4446
4477
  return n === r ? e.length === t.length ? e < t ? -1 : +(e > t) : e.length - t.length : n - r;
4447
4478
  });
4448
4479
  }
4449
- function xi(e) {
4450
- return yi(e)[0] || null;
4480
+ function wi(e) {
4481
+ return Si(e)[0] || null;
4451
4482
  }
4452
- async function Si(e) {
4483
+ async function Ti(e) {
4453
4484
  let t = e.records.filter((e) => e.norm.endsWith(".pbrt"));
4454
4485
  if (t.length === 0) return [];
4455
4486
  if (t.length === 1) return [t[0].key];
@@ -4457,48 +4488,48 @@ async function Si(e) {
4457
4488
  let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = !1;
4458
4489
  for (let o of t) {
4459
4490
  let t = await n(o);
4460
- t && (i.set(o.key, _i(t)), vi(t, r), t.length >= pi && (a = !0), o.lazy && (e.release(o), z(t)));
4491
+ t && (i.set(o.key, bi(t)), xi(t, r), t.length >= gi && (a = !0), o.lazy && (e.release(o), V(t)));
4461
4492
  }
4462
4493
  return {
4463
4494
  included: r,
4464
4495
  worlds: i,
4465
4496
  cut: a
4466
4497
  };
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);
4498
+ }, r = await n((t) => e.readHead(t, gi)), { included: i, worlds: a } = [...r.worlds.values()].filter(Boolean).length === 1 || !r.cut ? r : await n((t) => e.read(t));
4499
+ return Ci(t.map((e) => e.key), a, i);
4469
4500
  }
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);
4501
+ async function Ei(e) {
4502
+ let { vfs: t, source: n, plyParser: r, imageFromBytes: i, envFromBytes: a, convertHandedness: o } = e, s = new pi(t, n), c = [], l = await Ti(s);
4472
4503
  if (l.length === 0) throw Error("PBRT loader: no .pbrt file found in archive");
4473
4504
  let u = e.entryPath && l.includes(e.entryPath) ? e.entryPath : null;
4474
4505
  e.entryPath && !u && c.push(`PBRT entry "${e.entryPath}" is not a scene in this archive — auto-detecting instead`);
4475
4506
  let d = u || l[0], f = async (t) => {
4476
4507
  let n = await s.readPath(t);
4477
4508
  if (!n) throw Error(`PBRT loader: entry "${t}" not readable`);
4478
- let r = await new dn({
4509
+ let r = await new fn({
4479
4510
  resolveInclude: (e, t) => s.readPath(e, t),
4480
4511
  releaseInclude: (e, t, n) => s.releasePath(e, t, n),
4481
4512
  maxPlacements: e.maxPlacements,
4482
4513
  instanceIncludes: e.instanceIncludes
4483
4514
  }).parse(n, t.includes("/") ? t.slice(0, t.lastIndexOf("/")) : "");
4484
4515
  return s.releasePath(t, null, n), r;
4485
- }, p = performance.now(), m = !u && e.animation !== !1 ? qr(l) : null, h;
4516
+ }, p = performance.now(), m = !u && e.animation !== !1 ? Xr(l) : null, h;
4486
4517
  if (m) {
4487
4518
  let e = await f(m[0].path);
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);
4519
+ if (e.shapes.length + e.instanceCount > li) 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 = ci(e);
4489
4520
  else {
4490
- let t = new ii(m.map((e) => (e.number - m[0].number) / 30), wi(m));
4521
+ let t = new si(m.map((e) => (e.number - m[0].number) / 30), Di(m));
4491
4522
  t.addFrame(e);
4492
4523
  for (let e = 1; e < m.length; e++) t.addFrame(await f(m[e].path));
4493
4524
  h = t.finish();
4494
4525
  }
4495
- } else h = ai(await f(d));
4526
+ } else h = ci(await f(d));
4496
4527
  let g = performance.now() - p;
4497
4528
  s.releaseScenes();
4498
4529
  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) => {
4499
4530
  let t = await s.read(e);
4500
4531
  return t ? (s.release(e), r(_(t))) : null;
4501
- }, b = new Ur({
4532
+ }, b = new Kr({
4502
4533
  convertHandedness: o,
4503
4534
  maxTriangles: e.maxTriangles,
4504
4535
  maxPlacements: e.maxPlacements,
@@ -4529,13 +4560,13 @@ async function Ci(e) {
4529
4560
  buildMs: performance.now() - x
4530
4561
  };
4531
4562
  }
4532
- function wi(e) {
4563
+ function Di(e) {
4533
4564
  let t = e[0].path.split("/");
4534
4565
  return `${t.length > 1 ? t[t.length - 2] : t[0].replace(/\d+\.pbrt$/i, "") || "frames"} · frames ${e[0].number}–${e[e.length - 1].number}`;
4535
4566
  }
4536
4567
  //#endregion
4537
4568
  //#region src/Processor/PBRT/PFM.js
4538
- function Ti(e) {
4569
+ function Oi(e) {
4539
4570
  let t = 0, n = () => {
4540
4571
  for (; t < e.length && e[t] <= 32;) t++;
4541
4572
  let n = t;
@@ -4559,17 +4590,33 @@ function Ti(e) {
4559
4590
  height: a
4560
4591
  };
4561
4592
  }
4562
- function Ei(e) {
4563
- let { data: t, width: n, height: r } = Ti(e), i = new b(t, n, r, ue, T);
4564
- return i.minFilter = A, i.magFilter = A, i.needsUpdate = !0, i;
4593
+ function ki(e) {
4594
+ let { data: t, width: n, height: r } = Oi(e), i = new S(t, n, r, F, D);
4595
+ return i.minFilter = M, i.magFilter = M, i.needsUpdate = !0, i;
4565
4596
  }
4566
4597
  //#endregion
4567
4598
  //#region src/Processor/ArchiveImporter.js
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 {
4572
- static FORMATS = f;
4599
+ var Ai = /* @__PURE__ */ e({
4600
+ ARCHIVE_ELEMENT_PROMPT_BYTES: () => Bi,
4601
+ ArchiveImporter: () => Vi
4602
+ }), ji = /\.(usd|usda|usdc)$/i, Mi = /\.(png|jpg|jpeg|avif)$/i, Ni = 3e4, Pi = [
4603
+ "scene.gltf",
4604
+ "scene.glb",
4605
+ "model.gltf",
4606
+ "model.glb",
4607
+ "main.gltf",
4608
+ "main.glb",
4609
+ "asset.gltf",
4610
+ "asset.glb"
4611
+ ], Fi = (e) => e instanceof Blob ? e : new Blob([e], { type: "application/octet-stream" }), Ii = async (e) => e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : e, Li = async (e) => e instanceof Blob ? e.text() : _e(e), Ri = (e, t) => {
4612
+ let n = [];
4613
+ for (let r of `${e}/${t}`.split("/")) r === ".." ? n.pop() : r && r !== "." && n.push(r);
4614
+ return n.join("/");
4615
+ }, zi = async (e) => {
4616
+ let t = await Ii(e);
4617
+ return t.byteOffset === 0 && t.byteLength === t.buffer.byteLength ? t.buffer : t.slice().buffer;
4618
+ }, Bi = 4e9, Vi = class e {
4619
+ static FORMATS = p;
4573
4620
  constructor(e) {
4574
4621
  this.loader = e, this._pendingGraph = null, this.lastPBRTStats = null;
4575
4622
  }
@@ -4580,53 +4627,53 @@ var Di = /* @__PURE__ */ e({
4580
4627
  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));
4581
4628
  }
4582
4629
  async inspectArchive(e) {
4583
- let n = Ee(await this._readHead(e)), r = (e) => t({
4630
+ let t = Ee(await this._readHead(e)), r = (e) => n({
4584
4631
  isLoading: !0,
4585
4632
  status: `Scanning archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
4586
4633
  progress: 4
4587
4634
  }), i;
4588
- if (n === "gzip") {
4635
+ if (t === "gzip") {
4589
4636
  let t = await this._unpackGzip(e, e.name);
4590
4637
  t ? (i = t.index.listing, t.release()) : {listing: i} = await ze(e, {
4591
4638
  filter: () => !1,
4592
4639
  onProgress: r
4593
4640
  });
4594
- } else i = n === "tar" ? (await Xe(e, this.loader.storage))?.listing ?? await Ve(e, { onProgress: r }) : (await p(e)).map((e) => ({
4641
+ } else i = t === "tar" ? (await Ze(e, this.loader.storage))?.listing ?? await Ve(e, { onProgress: r }) : (await h(e)).map((e) => ({
4595
4642
  path: e.name,
4596
4643
  size: e.size
4597
4644
  }));
4598
- let { root: a, elements: o } = Ge(i);
4645
+ let { root: a, elements: o } = Ke(i);
4599
4646
  return {
4600
- kind: n ?? "zip",
4647
+ kind: t ?? "zip",
4601
4648
  root: a,
4602
4649
  elements: o,
4603
4650
  entryCount: i.length,
4604
4651
  totalBytes: i.reduce((e, t) => e + t.size, 0)
4605
4652
  };
4606
4653
  }
4607
- async _unpackGzip(e, n, r = null) {
4654
+ async _unpackGzip(e, t, r = null) {
4608
4655
  let i = (Array.isArray(r) ? r : [r]).filter(Boolean);
4609
4656
  try {
4610
- return await Ye(e, {
4657
+ return await Xe(e, {
4611
4658
  storage: this.loader.storage,
4612
- label: n,
4659
+ label: t,
4613
4660
  ...i.length ? {
4614
- filter: We(i),
4661
+ filter: Ge(i),
4615
4662
  part: [...i].sort().join(",")
4616
4663
  } : {},
4617
- onProgress: (e) => t({
4664
+ onProgress: (e) => n({
4618
4665
  isLoading: !0,
4619
4666
  status: `Unpacking archive… ${(e / 1e9).toFixed(1)} GB`,
4620
4667
  progress: 4
4621
4668
  })
4622
4669
  });
4623
4670
  } catch (e) {
4624
- return console.warn(`Unpacking "${n}" to storage failed, reading it in memory: ${e.message}`), null;
4671
+ return console.warn(`Unpacking "${t}" to storage failed, reading it in memory: ${e.message}`), null;
4625
4672
  }
4626
4673
  }
4627
4674
  async loadArchiveFromFile(e, t, { pbrtEntry: n = null, element: r = null, byteBudget: i, promptBytes: a, ...o } = {}) {
4628
4675
  try {
4629
- let s = Ee(await this._readHead(e)), c = this.loader.storage ? u(await l(e)) : null, d = {
4676
+ let s = Ee(await this._readHead(e)), c = this.loader.storage ? l(await u(e)) : null, d = {
4630
4677
  element: r,
4631
4678
  promptBytes: a,
4632
4679
  pbrtEntry: n,
@@ -4645,7 +4692,7 @@ var Di = /* @__PURE__ */ e({
4645
4692
  a.release();
4646
4693
  }
4647
4694
  let l = await this._readStreamedArchive(e, t, s, r, i);
4648
- if (xi(l)) return await this.loadPBRTFromZip(l, t, n, o);
4695
+ if (wi(l)) return await this.loadPBRTFromZip(l, t, n, o);
4649
4696
  let u = await this._loadNonPBRTArchive(l, t);
4650
4697
  return this.loader._sourceKey = this.loader._keyed("archive", c), u;
4651
4698
  }
@@ -4657,6 +4704,18 @@ var Di = /* @__PURE__ */ e({
4657
4704
  throw e?.code !== "ARCHIVE_NEEDS_ELEMENT" && console.error("Error loading archive:", e), e;
4658
4705
  }
4659
4706
  }
4707
+ async loadFolder(e, { pbrtEntry: t = null, element: n = null, promptBytes: r, ...i } = {}) {
4708
+ let a = (Array.isArray(n) ? n : [n]).filter(Boolean), o = We(e, { filter: a.length ? Ge(a) : null }), s = o.listing.reduce((e, t) => e + t.size, 0);
4709
+ a.length === 0 && this._requireElementChoice(e.name, o.listing, s, r), console.info(`Folder "${e.name}": ${o.listing.length} files, ${(s / 1e9).toFixed(1)} GB` + (a.length ? `, ${a.length} part${a.length > 1 ? "s" : ""} selected.` : "."));
4710
+ let c = this.loader.storage ? l(await f(e)) : null;
4711
+ return await this._loadSource(o, e.name, {
4712
+ element: n,
4713
+ pbrtEntry: t,
4714
+ pbrt: i,
4715
+ archiveId: c,
4716
+ kind: "folder"
4717
+ });
4718
+ }
4660
4719
  async _loadNonPBRTArchive(e, t) {
4661
4720
  return await this.processObjMtlPairsInZip(e, t) || await this.findAndLoadModelFromZip(e, t);
4662
4721
  }
@@ -4665,30 +4724,39 @@ var Di = /* @__PURE__ */ e({
4665
4724
  index: o,
4666
4725
  zip: s
4667
4726
  });
4668
- if (l.archiveId = c, l.elements = (Array.isArray(n) ? n : [n]).filter(Boolean), l.listing.some((e) => e.path.toLowerCase().endsWith(".pbrt"))) return await this.loadPBRTFromZip({}, t, i, a, l);
4669
- for (let e of l.listing) e.offset !== void 0 && (l.entries[e.path] ??= await l.read(e.path));
4670
- let u = await this._loadNonPBRTArchive(l.entries, t);
4671
- return this.loader._sourceKey = this.loader._keyed("archive", c), u;
4672
- }
4673
- async _loadStoredGraph(e, n, { imageFromBytes: r, envFromBytes: i }) {
4674
- let o = this.loader.storage?.area(s.SCENES), c = o ? await o.open(e) : null;
4675
- if (!c) return null;
4727
+ return await this._loadSource(l, t, {
4728
+ element: n,
4729
+ pbrtEntry: i,
4730
+ pbrt: a,
4731
+ archiveId: c
4732
+ });
4733
+ }
4734
+ async _loadSource(e, t, { element: n, pbrtEntry: r, pbrt: i, archiveId: a, kind: o = "archive" }) {
4735
+ if (e.archiveId = a, e.elements = (Array.isArray(n) ? n : [n]).filter(Boolean), e.listing.some((e) => e.path.toLowerCase().endsWith(".pbrt"))) return await this.loadPBRTFromZip({}, t, r, i, e);
4736
+ let s = Object.create(null);
4737
+ for (let t of e.listing) t.offset !== void 0 && (s[t.path] = e.entries[t.path] ?? await e.slice(t.path));
4738
+ let c = await this._loadNonPBRTArchive(s, t);
4739
+ return this.loader._sourceKey = this.loader._keyed(o, a), c;
4740
+ }
4741
+ async _loadStoredGraph(e, t, { imageFromBytes: r, envFromBytes: i }) {
4742
+ let a = this.loader.storage?.area(c.SCENES), s = a ? await a.open(e) : null;
4743
+ if (!s) return null;
4676
4744
  let l = performance.now(), u = null;
4677
4745
  try {
4678
- t({
4746
+ n({
4679
4747
  isLoading: !0,
4680
4748
  status: "Opening the stored scene...",
4681
4749
  progress: 6
4682
4750
  });
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) => {
4751
+ let e = await s.json("graph.json"), a = await s.file("data.bin"), o = new pi({}, t), c = await wt(e, a, { loadTexture: async (e, t) => {
4684
4752
  let n = await o.readPath(e);
4685
4753
  return n ? t === "environment" ? i(n, e) : r(n, e) : null;
4686
4754
  } });
4687
4755
  return {
4688
- ...s.stats,
4689
- group: s.root,
4690
- environment: s.environment ? { texture: s.environment } : null,
4691
- animations: s.animations,
4756
+ ...c.stats,
4757
+ group: c.root,
4758
+ environment: c.environment ? { texture: c.environment } : null,
4759
+ animations: c.animations,
4692
4760
  report: null,
4693
4761
  parseMs: 0,
4694
4762
  buildMs: performance.now() - l,
@@ -4697,15 +4765,15 @@ var Di = /* @__PURE__ */ e({
4697
4765
  } catch (e) {
4698
4766
  return u = e, null;
4699
4767
  } finally {
4700
- c.release(), u && (console.warn(`The stored scene could not be used, parsing the archive instead: ${u.message}`), this.loader._issues?.warn(a.STORAGE_ENTRY_CORRUPT, `stored scene unusable: ${u.message}`, { key: e }), o.remove(e).catch(() => {}));
4768
+ s.release(), u && (console.warn(`The stored scene could not be used, parsing the archive instead: ${u.message}`), this.loader._issues?.warn(o.STORAGE_ENTRY_CORRUPT, `stored scene unusable: ${u.message}`, { key: e }), a.remove(e).catch(() => {}));
4701
4769
  }
4702
4770
  }
4703
4771
  _storeGraph(e, t, n) {
4704
- let i = this.loader.storage?.area(s.SCENES);
4705
- if (!i) return;
4772
+ let r = this.loader.storage?.area(c.SCENES);
4773
+ if (!r) return;
4706
4774
  let a;
4707
4775
  try {
4708
- a = gt(t.group, {
4776
+ a = _t(t.group, {
4709
4777
  environment: t.environment?.texture ?? null,
4710
4778
  animations: t.animations ?? [],
4711
4779
  stats: {
@@ -4723,7 +4791,7 @@ var Di = /* @__PURE__ */ e({
4723
4791
  }
4724
4792
  });
4725
4793
  } catch (e) {
4726
- e instanceof R ? console.info(`Scene not stored for next time: ${e.message}`) : console.warn("Scene not stored for next time:", e);
4794
+ e instanceof B ? console.info(`Scene not stored for next time: ${e.message}`) : console.warn("Scene not stored for next time:", e);
4727
4795
  return;
4728
4796
  }
4729
4797
  let o = {
@@ -4733,13 +4801,13 @@ var Di = /* @__PURE__ */ e({
4733
4801
  parseMs: (t.parseMs ?? 0) + (t.buildMs ?? 0),
4734
4802
  triangles: t.triangleCount ?? null
4735
4803
  };
4736
- r(o.parseMs, a.byteLength) ? this._writeGraph(i, o) : this._pendingGraph = o;
4804
+ i(o.parseMs, a.byteLength) ? this._writeGraph(r, o) : this._pendingGraph = o;
4737
4805
  }
4738
4806
  flushPendingGraph(e) {
4739
4807
  let t = this._pendingGraph;
4740
4808
  this._pendingGraph = null;
4741
- let n = this.loader.storage?.area(s.SCENES);
4742
- !t || !n || !r(t.parseMs + e, t.encoded.byteLength) || this._writeGraph(n, t);
4809
+ let n = this.loader.storage?.area(c.SCENES);
4810
+ !t || !n || !i(t.parseMs + e, t.encoded.byteLength) || this._writeGraph(n, t);
4743
4811
  }
4744
4812
  _writeGraph(e, t) {
4745
4813
  (async () => {
@@ -4748,72 +4816,72 @@ var Di = /* @__PURE__ */ e({
4748
4816
  expectedBytes: t.encoded.byteLength
4749
4817
  });
4750
4818
  if (n) try {
4751
- await _t(n, t.encoded, { release: !0 }), await n.commit({ triangles: t.triangles });
4819
+ await vt(n, t.encoded, { release: !0 }), await n.commit({ triangles: t.triangles });
4752
4820
  } catch (e) {
4753
4821
  await n.abort(), console.warn("Storing the scene failed:", e);
4754
4822
  }
4755
4823
  })().catch((e) => console.warn("Storing the scene failed:", e));
4756
4824
  }
4757
- async _openSeekableArchive(e, n, r, i, { index: a = null, zip: o = !1 } = {}) {
4758
- let s = Array.isArray(r) ? r.filter(Boolean) : r ? [r] : [], c = s.length ? We(s) : null, l;
4759
- if (o) l = await m(e, { filter: c });
4825
+ async _openSeekableArchive(e, t, r, i, { index: a = null, zip: o = !1 } = {}) {
4826
+ let s = Array.isArray(r) ? r.filter(Boolean) : r ? [r] : [], c = s.length ? Ge(s) : null, l;
4827
+ if (o) l = await g(e, { filter: c });
4760
4828
  else {
4761
- let n = a ?? await Xe(e, this.loader.storage);
4829
+ let t = a ?? await Ze(e, this.loader.storage);
4762
4830
  l = await Ue(e, {
4763
- index: n,
4831
+ index: t,
4764
4832
  headersOnly: !0,
4765
4833
  filter: c,
4766
- onProgress: (e) => t({
4834
+ onProgress: (e) => n({
4767
4835
  isLoading: !0,
4768
4836
  status: `Indexing archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
4769
4837
  progress: 4
4770
4838
  })
4771
- }), n || Ze(e, this.loader.storage, l.index).catch(() => {});
4839
+ }), t || Qe(e, this.loader.storage, l.index).catch(() => {});
4772
4840
  }
4773
4841
  let u = l.listing.reduce((e, t) => e + t.size, 0);
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;
4842
+ return s.length === 0 && this._requireElementChoice(t, l.listing, u, i), console.info(`Archive "${t}": indexed ${l.indexed} entries, ${(u / 1e9).toFixed(1)} GB, none resident` + (s.length ? `, ${s.length} part${s.length > 1 ? "s" : ""} selected.` : ".")), l;
4775
4843
  }
4776
- _requireElementChoice(e, t, n, r = ji) {
4844
+ _requireElementChoice(e, t, n, r = Bi) {
4777
4845
  if (n < r) return;
4778
- let { root: i, elements: s } = Ge(t);
4779
- if (s.length < 2) return;
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.`);
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`, {
4846
+ let { root: i, elements: a } = Ke(t);
4847
+ if (a.length < 2) return;
4848
+ let c = /* @__PURE__ */ Error(`"${e}" holds ${(n / 1e9).toFixed(1)} GB across ${a.length} parts. Choose which to load — loading all of them at once may exhaust memory.`);
4849
+ throw c.code = "ARCHIVE_NEEDS_ELEMENT", c.root = i, c.elements = a, c.totalBytes = n, this.loader._issues?.record(o.ASSET_ARCHIVE_TOO_LARGE, `archive holds ${(n / 1e9).toFixed(1)} GB across ${a.length} parts; choose which to load`, {
4782
4850
  root: i,
4783
- elements: s.map((e) => e.prefix),
4851
+ elements: a.map((e) => e.prefix),
4784
4852
  totalBytes: n
4785
- }, o.WARNING), c;
4853
+ }, s.WARNING), c;
4786
4854
  }
4787
- async _readStreamedArchive(e, n, r, i, s) {
4855
+ async _readStreamedArchive(e, t, r, i, a) {
4788
4856
  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,
4790
- ...s === void 0 ? {} : { byteBudget: s },
4791
- onProgress: (e) => t({
4857
+ filter: c.length ? Ge(c) : null,
4858
+ ...a === void 0 ? {} : { byteBudget: a },
4859
+ onProgress: (e) => n({
4792
4860
  isLoading: !0,
4793
4861
  status: `Reading archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
4794
4862
  progress: 4
4795
4863
  })
4796
4864
  });
4797
4865
  if (f && c.length === 0) {
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.`);
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`, {
4866
+ let { root: e, elements: n } = Ke(u), r = u.reduce((e, t) => e + t.size, 0), i = /* @__PURE__ */ Error(`"${t}" unpacks to ${(r / 1e9).toFixed(1)} GB, past the load budget. Load one of its ${n.length} parts instead.`);
4867
+ throw i.code = "ARCHIVE_NEEDS_ELEMENT", i.root = e, i.elements = n, i.totalBytes = r, this.loader._issues?.record(o.ASSET_ARCHIVE_TOO_LARGE, `archive unpacks to ${(r / 1e9).toFixed(1)} GB; choose one of ${n.length} parts`, {
4800
4868
  root: e,
4801
- elements: t.map((e) => e.prefix),
4869
+ elements: n.map((e) => e.prefix),
4802
4870
  totalBytes: r
4803
- }, o.WARNING), i;
4871
+ }, s.WARNING), i;
4804
4872
  }
4805
4873
  if (f) {
4806
- let e = We(c), t = u.filter((t) => e(t.path, t.size) && !l[t.path]).length;
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`, {
4874
+ let e = Ge(c), t = u.filter((t) => e(t.path, t.size) && !l[t.path]).length;
4875
+ this.loader._issues?.record(o.ASSET_ARCHIVE_TOO_LARGE, `${t} files of the chosen parts were left out: they did not fit the ${((a ?? 15e8) / 1e9).toFixed(1)} GB in-memory read budget`, {
4808
4876
  elements: c,
4809
4877
  missing: t,
4810
4878
  retainedBytes: d
4811
- }, o.WARNING);
4879
+ }, s.WARNING);
4812
4880
  }
4813
- return c.length && console.info(`Archive "${n}": loaded ${c.map((e) => `"${e}"`).join(", ")} — ${Object.keys(l).length} of ${u.length} files, ${(d / 1048576).toFixed(1)} MB.`), l;
4881
+ return c.length && console.info(`Archive "${t}": loaded ${c.map((e) => `"${e}"`).join(", ")} — ${Object.keys(l).length} of ${u.length} files, ${(d / 1048576).toFixed(1)} MB.`), l;
4814
4882
  }
4815
- async loadPBRTFromZip(e, r, s = null, l = {}, u = null) {
4816
- if (t({
4883
+ async loadPBRTFromZip(e, t, i = null, c = {}, l = null) {
4884
+ if (n({
4817
4885
  isLoading: !0,
4818
4886
  status: "Parsing PBRT scene...",
4819
4887
  progress: 5
@@ -4821,38 +4889,38 @@ var Di = /* @__PURE__ */ e({
4821
4889
  let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
4822
4890
  this.loader.loaderCache.ply = new e();
4823
4891
  }
4824
- let d = (e) => this.loader.loaderCache.ply.parse(e), f = async (e, t) => {
4892
+ let u = (e) => this.loader.loaderCache.ply.parse(e), f = async (e, t) => {
4825
4893
  let n = await this._pbrtTextureFromBytes(e, t);
4826
- return n && (n.userData[$e] = t), n;
4894
+ return n && (n.userData[et] = t), n;
4827
4895
  }, p = async (e, t) => {
4828
- let r = t.split(".").pop().toLowerCase(), i = new Blob([e]), a = r === "pfm" ? null : URL.createObjectURL(i);
4896
+ let n = t.split(".").pop().toLowerCase(), i = new Blob([e]), a = n === "pfm" ? null : URL.createObjectURL(i);
4829
4897
  try {
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;
4898
+ let o = a ? await this.loader.loadEnvironmentByExtension(a, n, { loader: n === "exr" ? this._exrLoader() : null }) : ki(e);
4899
+ return o.mapping = T, r(o, `bytes:${await d(i)}`), o.userData[et] = t, o.userData[tt] = "environment", o;
4832
4900
  } finally {
4833
4901
  a && URL.revokeObjectURL(a);
4834
4902
  }
4835
4903
  }, m = performance.now(), h = {
4836
- animation: l.animation,
4837
- maxTriangles: l.maxTriangles,
4838
- maxPlacements: l.maxPlacements,
4839
- mergeShapesAbove: l.mergeShapesAbove,
4840
- curveSteps: l.curveSteps,
4841
- curveSides: l.curveSides,
4842
- curveTolerance: l.curveTolerance,
4843
- instanceIncludes: l.instanceIncludes
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, {
4904
+ animation: c.animation,
4905
+ maxTriangles: c.maxTriangles,
4906
+ maxPlacements: c.maxPlacements,
4907
+ mergeShapesAbove: c.mergeShapesAbove,
4908
+ curveSteps: c.curveSteps,
4909
+ curveSides: c.curveSides,
4910
+ curveTolerance: c.curveTolerance,
4911
+ instanceIncludes: c.instanceIncludes
4912
+ }, g = l?.archiveId ? this.loader._keyed(`pbrt:2.9:${a}`, `${l.archiveId}|${i ?? ""}|${[...l.elements ?? []].sort().join(",")}|${JSON.stringify(h)}`) : null, _ = g ? await this._loadStoredGraph(g, l, {
4845
4913
  imageFromBytes: f,
4846
4914
  envFromBytes: p
4847
- }) : null, v = _ ?? await Ci({
4915
+ }) : null, v = _ ?? await Ei({
4848
4916
  vfs: e,
4849
- source: u,
4850
- entryPath: s,
4851
- plyParser: d,
4917
+ source: l,
4918
+ entryPath: i,
4919
+ plyParser: u,
4852
4920
  imageFromBytes: f,
4853
4921
  envFromBytes: p,
4854
4922
  ...h
4855
- }), { group: y, environment: b, animations: x, report: S, warnings: w, meshCount: T, entryPath: E, candidates: D, frames: O, parseMs: k, buildMs: A, triangleCount: j, placementCount: M, mergedShapes: N, skippedForBudget: ee, droppedNoTemplate: te } = v;
4923
+ }), { group: y, environment: b, animations: x, report: S, warnings: C, meshCount: w, entryPath: E, candidates: D, frames: O, parseMs: k, buildMs: A, triangleCount: j, placementCount: M, mergedShapes: N, skippedForBudget: ee, droppedNoTemplate: P } = v;
4856
4924
  _ && console.info(`PBRT scene "${E}" opened from storage in ${(A / 1e3).toFixed(1)} s, skipping the parse`), this.lastPBRTStats = {
4857
4925
  parseMs: k,
4858
4926
  buildMs: A,
@@ -4861,50 +4929,50 @@ var Di = /* @__PURE__ */ e({
4861
4929
  placementCount: M,
4862
4930
  mergedShapes: N,
4863
4931
  skippedForBudget: ee,
4864
- droppedNoTemplate: te,
4865
- meshCount: T,
4932
+ droppedNoTemplate: P,
4933
+ meshCount: w,
4866
4934
  frames: O?.length ?? 1
4867
4935
  };
4868
- let ne = new Set(O ?? [E]), re = D.filter((e) => !ne.has(e));
4869
- if (re.length > 0 && (console.warn(`PBRT archive holds ${D.length} scenes; loaded "${E}". Others: ${re.join(", ")}`), this.loader._issues?.record(a.ASSET_AMBIGUOUS_ENTRY, `archive holds ${D.length} pbrt scenes; loaded "${E}"`, {
4936
+ let te = new Set(O ?? [E]), ne = D.filter((e) => !te.has(e));
4937
+ if (ne.length > 0 && (console.warn(`PBRT archive holds ${D.length} scenes; loaded "${E}". Others: ${ne.join(", ")}`), this.loader._issues?.record(o.ASSET_AMBIGUOUS_ENTRY, `archive holds ${D.length} pbrt scenes; loaded "${E}"`, {
4870
4938
  loaded: E,
4871
- alternatives: re
4872
- }, o.WARNING)), S && S.length && typeof console.table == "function") {
4873
- let e = S.length < T ? ` (first ${S.length} of ${T})` : "";
4874
- console.groupCollapsed(`PBRT loader: ${T} mesh(es) from "${E}"${e}`), console.table(S), console.groupEnd();
4939
+ alternatives: ne
4940
+ }, s.WARNING)), S && S.length && typeof console.table == "function") {
4941
+ let e = S.length < w ? ` (first ${S.length} of ${w})` : "";
4942
+ console.groupCollapsed(`PBRT loader: ${w} mesh(es) from "${E}"${e}`), console.table(S), console.groupEnd();
4875
4943
  }
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 = {
4944
+ return C && C.length && (console.warn(`PBRT loader: ${C.length} warning(s) parsing "${E}"`), C.forEach((e) => console.warn(" •", e))), b?.texture && (b.texture.generateMipmaps = !0, this.loader.applyEnvironmentToScene(b.texture)), y.name = E || t, this.loader.releaseTargetModel(), this.loader._sourceKey = g, g && !_ && this._storeGraph(g, v, t), this.loader.targetModel = y, this.loader.animations = x ?? [], this.loader.sceneMetadata = {
4877
4945
  environment: b?.texture ? {
4878
4946
  rotation: 0,
4879
4947
  intensity: 1
4880
4948
  } : { enabled: !1 },
4881
4949
  ...v.render ? { render: { ...v.render } } : {}
4882
- }, t({
4950
+ }, n({
4883
4951
  isLoading: !0,
4884
4952
  status: "Processing PBRT geometry...",
4885
4953
  progress: 10
4886
4954
  }), await this.loader.onModelLoad(this.loader.targetModel), this.loader.dispatchEvent({
4887
4955
  type: "load",
4888
4956
  model: y,
4889
- filename: `${E} (from ZIP)`
4957
+ filename: `${E} (from ${t})`
4890
4958
  }), y;
4891
4959
  }
4892
4960
  _exrLoader() {
4893
- return this.loader.loaderCache.exr ??= new ye().setDataType(T);
4961
+ return this.loader.loaderCache.exr ??= new ye().setDataType(D);
4894
4962
  }
4895
4963
  async _pbrtTextureFromBytes(e, t) {
4896
4964
  let n = t.split(".").pop().toLowerCase(), r;
4897
4965
  if (n === "exr" || n === "hdr") {
4898
- let t = n === "hdr" ? this.loader.loaderCache.hdr || (this.loader.loaderCache.hdr = new he().setDataType(T)) : this._exrLoader();
4966
+ let t = n === "hdr" ? this.loader.loaderCache.hdr || (this.loader.loaderCache.hdr = new he().setDataType(D)) : this._exrLoader();
4899
4967
  r = await this._loadViaObjectURL(t, e);
4900
- } else if (n === "pfm") r = Ei(e);
4968
+ } else if (n === "pfm") r = ki(e);
4901
4969
  else if (n === "tga") {
4902
4970
  if (!this.loader.loaderCache.tga) {
4903
4971
  let { TGALoader: e } = await import("three/examples/jsm/loaders/TGALoader.js");
4904
4972
  this.loader.loaderCache.tga = new e();
4905
4973
  }
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;
4974
+ r = await this._loadViaObjectURL(this.loader.loaderCache.tga, e), r.colorSpace = I;
4975
+ } else r = new pe(await createImageBitmap(new Blob([e]))), r.colorSpace = I;
4908
4976
  return r.wrapS = r.wrapT = de, r.needsUpdate = !0, r;
4909
4977
  }
4910
4978
  async _loadViaObjectURL(e, t) {
@@ -4952,99 +5020,80 @@ var Di = /* @__PURE__ */ e({
4952
5020
  }
4953
5021
  return n;
4954
5022
  }
4955
- async findAndLoadModelFromZip(e) {
4956
- for (let t of [
4957
- "scene.gltf",
4958
- "scene.glb",
4959
- "model.gltf",
4960
- "model.glb",
4961
- "main.gltf",
4962
- "main.glb",
4963
- "asset.gltf",
4964
- "asset.glb"
4965
- ]) if (e[t]) {
4966
- console.log(`Found main model file: ${t}`);
4967
- let n = t.split(".").pop().toLowerCase();
4968
- return await this.loadModelFromZipEntry(e[t], t, n, e);
4969
- }
4970
- for (let t in e) {
4971
- let n = t.split(".").pop().toLowerCase();
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));
4973
- }
4974
- throw Error("No supported model files found in the ZIP archive");
5023
+ async findAndLoadModelFromZip(e, t = "the ZIP archive") {
5024
+ let n = Object.keys(e), r = n[0]?.split("/")[0], i = r !== void 0 && n.every((e) => e.startsWith(r + "/")) ? r + "/" : "", a = n.filter((e) => e.split(".").pop().toLowerCase() === "obj" || this.loader.getFileFormat(e)?.type === "model");
5025
+ if (a.length === 0) throw Error(`No supported model files found in ${t}`);
5026
+ let c = (e) => e.split("/").length * 2 + +!/\.(gltf|glb)$/i.test(e), l = Pi.map((e) => i + e).find((t) => e[t]), u = l ?? a.reduce((e, t) => c(t) < c(e) ? t : e);
5027
+ if (!l && ji.test(u)) return await this.loadUSDHierarchyFromZip(e);
5028
+ let d = a.filter((e) => e !== u && !ji.test(e));
5029
+ return d.length > 0 && (console.warn(`${t} holds ${d.length + 1} models; loaded "${u}". Others: ${d.join(", ")}`), this.loader._issues?.record(o.ASSET_AMBIGUOUS_ENTRY, `${t} holds ${d.length + 1} models; loaded "${u}"`, {
5030
+ loaded: u,
5031
+ alternatives: d.slice(0, 50)
5032
+ }, s.WARNING)), console.log(`Loading model file from ${t}: ${u}`), await this.loadModelFromZipEntry(e[u], u, u.split(".").pop().toLowerCase(), e, t);
4975
5033
  }
4976
5034
  async loadUSDHierarchyFromZip(t) {
4977
- let n = Object.keys(t).filter((e) => Oi.test(e));
5035
+ let n = Object.keys(t).filter((e) => ji.test(e));
4978
5036
  if (n.length === 0) throw Error("No USD layers found in the ZIP archive");
4979
5037
  let r = e._pickUSDRootLayer(n);
4980
5038
  console.log(`Loading USD scene from ZIP: ${r} (${n.length} layers)`);
4981
- let i = { [r]: [t[r], { level: 0 }] };
4982
- for (let e of Object.keys(t)) e !== r && (Oi.test(e) || ki.test(e)) && (i[e] = [t[e], { level: 0 }]);
5039
+ let i = { [r]: [await Ii(t[r]), { level: 0 }] };
5040
+ for (let e of Object.keys(t)) e !== r && (ji.test(e) || Mi.test(e)) && (i[e] = [await Ii(t[e]), { level: 0 }]);
4983
5041
  return await this.loader._loadModelFileByExtension(new File([ve(i)], r), r);
4984
5042
  }
4985
5043
  static _pickUSDRootLayer(e) {
4986
5044
  let t = (e) => e.split("/").length, n = Math.min(...e.map(t)), r = e.filter((e) => t(e) === n);
4987
5045
  return r.find((e) => {
4988
5046
  let t = e.split("/");
4989
- return t.length > 1 && t[t.length - 1].replace(Oi, "") === t[t.length - 2];
5047
+ return t.length > 1 && t[t.length - 1].replace(ji, "") === t[t.length - 2];
4990
5048
  }) || r[0];
4991
5049
  }
4992
- async loadModelFromZipEntry(e, n, r, i) {
5050
+ async loadModelFromZipEntry(e, t, r, i, a = "ZIP") {
4993
5051
  try {
4994
- t({
5052
+ n({
4995
5053
  isLoading: !0,
4996
- status: `Processing ${r.toUpperCase()} from ZIP...`,
5054
+ status: `Processing ${r.toUpperCase()} from ${a}...`,
4997
5055
  progress: 5
4998
5056
  });
4999
- let a = new Blob([e.buffer], { type: "application/octet-stream" }), o = URL.createObjectURL(a), s;
5057
+ let o;
5000
5058
  switch (r) {
5001
5059
  case "glb":
5002
5060
  case "gltf":
5003
- s = await this.handleGltfFromZip(r, e, n, i);
5061
+ o = await this.handleGltfFromZip(r, e, t, i);
5004
5062
  break;
5005
5063
  case "obj":
5006
- s = await this.handleObjFromZip(e, n, i);
5064
+ o = await this.handleObjFromZip(e, t, i);
5007
5065
  break;
5008
- default: s = await this.loader._loadModelFileByExtension(new File([e], n), n);
5066
+ default: o = await this.loader._loadModelFileByExtension(new File([e], t), t);
5009
5067
  }
5010
- return URL.revokeObjectURL(o), this.loader.dispatchEvent({
5068
+ return this.loader.dispatchEvent({
5011
5069
  type: "load",
5012
5070
  model: this.loader.targetModel,
5013
- filename: `${n} (from ZIP)`
5014
- }), s;
5071
+ filename: `${t} (from ${a})`
5072
+ }), o;
5015
5073
  } catch (e) {
5016
- throw console.error(`Error loading ${r} from ZIP:`, e), this.loader.dispatchEvent({
5074
+ throw console.error(`Error loading ${r} from ${a}:`, e), this.loader.dispatchEvent({
5017
5075
  type: "error",
5018
5076
  message: e.message,
5019
- filename: n
5077
+ filename: t
5020
5078
  }), e;
5021
5079
  }
5022
5080
  }
5023
- async handleGltfFromZip(e, t, n, r) {
5081
+ async handleGltfFromZip(e, n, r, i) {
5024
5082
  if (e === "gltf") {
5025
- let e = _e(t), i = new j(), a = n.split("/").slice(0, -1).join("/");
5026
- i.setURLModifier((e) => this.resolveZipResource(e, a, r));
5027
- let o = await this.loader.createGLTFLoader();
5028
- o.manager = i;
5083
+ let e = await Li(n), a = new N(), o = r.split("/").slice(0, -1).join("/");
5084
+ a.setURLModifier((e) => this.resolveZipResource(e, o, i));
5085
+ let s = await this.loader.createGLTFLoader();
5086
+ s.manager = a;
5029
5087
  try {
5030
- return await new Promise((t, n) => {
5031
- o.parse(e, "", (e) => {
5032
- try {
5033
- this.loader._throwDeferred();
5034
- } catch (e) {
5035
- n(e);
5036
- return;
5037
- }
5038
- this.loader.releaseTargetModel(), this.loader.targetModel = e.scene, this.loader.sceneMetadata = d(e), this.loader.onModelLoad(this.loader.targetModel).then(() => t(e));
5039
- }, (e) => n(e));
5040
- });
5088
+ let n = await t(() => new Promise((t, n) => s.parse(e, "", t, n)));
5089
+ return this.loader._throwDeferred(), this.loader.releaseTargetModel(), this.loader.targetModel = n.scene, this.loader.sceneMetadata = m(n), await this.loader.onModelLoad(this.loader.targetModel), n;
5041
5090
  } finally {
5042
- this.loader._disposeGLTFLoader(o);
5091
+ this.loader._disposeGLTFLoader(s);
5043
5092
  }
5044
- } else return await this.loader.loadGLBFromArrayBuffer(t.buffer, n);
5093
+ } else return await this.loader.loadGLBFromArrayBuffer(await zi(n), r);
5045
5094
  }
5046
5095
  async handleObjFromZip(e, t, n) {
5047
- let r = _e(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
5096
+ let r = await Li(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
5048
5097
  i && i[1] && (a = await this.loadMtlFromZip(i[1], t, n));
5049
5098
  let { OBJLoader: o } = await import("three/examples/jsm/loaders/OBJLoader.js"), s = new o();
5050
5099
  a && s.setMaterials(a);
@@ -5061,8 +5110,8 @@ var Di = /* @__PURE__ */ e({
5061
5110
  s(), o?.(e);
5062
5111
  });
5063
5112
  }, e.preload(), t.length === 0) return 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;
5113
+ let r, i = await Promise.race([Promise.all(t).then(() => !0), new Promise((e) => r = setTimeout(() => e(!1), Ni))]);
5114
+ return clearTimeout(r), i || this.loader._issues?.record(o.TEXTURE_BUILD_FAILED, `MTL textures did not decode within ${Ni}ms; affected materials render untextured`, { pending: t.length }), e;
5066
5115
  }
5067
5116
  async loadMtlFromZip(e, t, n) {
5068
5117
  let r = t.split("/").slice(0, -1).join("/"), i = [
@@ -5071,7 +5120,7 @@ var Di = /* @__PURE__ */ e({
5071
5120
  e.split("/").pop()
5072
5121
  ];
5073
5122
  for (let e of i) if (n[e]) {
5074
- let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = _e(n[e]), a = new j();
5123
+ let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = await Li(n[e]), a = new N();
5075
5124
  a.setURLModifier((e) => this.resolveZipResource(e, r, n));
5076
5125
  let o = new t(a).parse(i, r);
5077
5126
  return await this.preloadMtlTextures(o), o;
@@ -5079,33 +5128,37 @@ var Di = /* @__PURE__ */ e({
5079
5128
  return null;
5080
5129
  }
5081
5130
  resolveZipResource(e, t, n) {
5082
- let r = e.replace(/^\.\/|^\//, ""), i = [
5083
- r,
5084
- `${t}/${r}`,
5085
- r.split("/").pop()
5086
- ];
5087
- for (let e of i) if (n[e]) {
5088
- let t = new Blob([n[e].buffer], { type: "application/octet-stream" });
5089
- return URL.createObjectURL(t);
5131
+ if (/^(data|blob|https?):/i.test(e)) return e;
5132
+ let r = e.replace(/^\.\/|^\//, ""), i = r;
5133
+ try {
5134
+ i = decodeURIComponent(r);
5135
+ } catch {}
5136
+ for (let e of new Set([r, i])) {
5137
+ let r = e.split("/").pop(), i = [
5138
+ Ri(t, e),
5139
+ e,
5140
+ r
5141
+ ].find((e) => n[e]) ?? (r ? Object.keys(n).find((e) => e.endsWith(`/${r}`)) : void 0);
5142
+ if (i) return URL.createObjectURL(Fi(n[i]));
5090
5143
  }
5091
- return console.warn(`Resource not found in ZIP: ${e}`), e;
5144
+ return console.warn(`Resource not found in the archive: ${e}`), e;
5092
5145
  }
5093
5146
  async loadOBJMTLPairFromZip(e, t, n, r) {
5094
- let { MTLLoader: i } = await import("three/examples/jsm/loaders/MTLLoader.js"), { OBJLoader: a } = await import("three/examples/jsm/loaders/OBJLoader.js"), o = [], s = new j(), c = e.path.split("/").slice(0, -1).join("/"), l = t.path.split("/").slice(0, -1).join("/");
5147
+ let { MTLLoader: i } = await import("three/examples/jsm/loaders/MTLLoader.js"), { OBJLoader: a } = await import("three/examples/jsm/loaders/OBJLoader.js"), o = [], s = new N(), c = e.path.split("/").slice(0, -1).join("/"), l = t.path.split("/").slice(0, -1).join("/");
5095
5148
  s.setURLModifier((e) => this.resolveTextureInZip(e, c, l, t, n, o));
5096
- let u = this.prepareFixedMtlContent(t), d = new i(s).parse(u, l);
5149
+ let u = await this.prepareFixedMtlContent(t), d = new i(s).parse(u, l);
5097
5150
  await this.preloadMtlTextures(d);
5098
5151
  let f = new a(s);
5099
5152
  f.setMaterials(d);
5100
- let p = _e(e.content), m = f.parse(p);
5153
+ let p = await Li(e.content), m = f.parse(p);
5101
5154
  return this.loader.releaseTargetModel(), this.loader.targetModel = m, await this.loader.onModelLoad(this.loader.targetModel), o.forEach((e) => URL.revokeObjectURL(e)), this.loader.dispatchEvent({
5102
5155
  type: "load",
5103
5156
  model: m,
5104
5157
  filename: `${e.path} (from ${r})`
5105
5158
  }), m;
5106
5159
  }
5107
- prepareFixedMtlContent(e) {
5108
- return _e(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
5160
+ async prepareFixedMtlContent(e) {
5161
+ return (await Li(e.content)).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
5109
5162
  }
5110
5163
  resolveTextureInZip(e, t, n, r, i, a) {
5111
5164
  let o = e.split("?")[0].split("#")[0].replace(/^\.\/|^\//, ""), s = r.path.split("/").pop();
@@ -5120,26 +5173,26 @@ var Di = /* @__PURE__ */ e({
5120
5173
  o.split("/").pop()
5121
5174
  ];
5122
5175
  for (let e of c) if (i[e]) {
5123
- let t = new Blob([i[e].buffer], { type: "application/octet-stream" }), n = URL.createObjectURL(t);
5124
- return a.push(n), n;
5176
+ let t = URL.createObjectURL(Fi(i[e]));
5177
+ return a.push(t), t;
5125
5178
  }
5126
5179
  return this.findTextureWithFuzzyMatch(o, i, a) || e;
5127
5180
  }
5128
5181
  findTextureWithFuzzyMatch(e, t, n) {
5129
5182
  let r = e.split("/").pop();
5130
5183
  for (let e in t) if (e.endsWith(r)) {
5131
- let r = new Blob([t[e].buffer], { type: "application/octet-stream" }), i = URL.createObjectURL(r);
5132
- return n.push(i), i;
5184
+ let r = URL.createObjectURL(Fi(t[e]));
5185
+ return n.push(r), r;
5133
5186
  }
5134
5187
  if (r && r.length > 5) for (let e in t) {
5135
5188
  let i = e.split("/").pop();
5136
5189
  if (i.includes(r) || r.includes(i)) {
5137
- let r = new Blob([t[e].buffer], { type: "application/octet-stream" }), i = URL.createObjectURL(r);
5138
- return n.push(i), i;
5190
+ let r = URL.createObjectURL(Fi(t[e]));
5191
+ return n.push(r), r;
5139
5192
  }
5140
5193
  }
5141
5194
  return null;
5142
5195
  }
5143
5196
  };
5144
5197
  //#endregion
5145
- export { Mi as n, Di as r, ji as t };
5198
+ export { Vi as n, Ai as r, Bi as t };