softbox 4.8.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import * as J from "three";
2
- import { UnsignedIntType as re, DataTexture as M, NearestFilter as T, IntType as we, FloatType as R, UnsignedByteType as Me, UnsignedShortType as Mt, ByteType as Be, ShortType as At, RGBAFormat as I, RGBAIntegerFormat as Ae, RGIntegerFormat as ft, RedIntegerFormat as Ct, RGFormat as ht, RedFormat as me, BufferAttribute as P, BufferGeometry as Q, Matrix4 as O, Matrix3 as Ft, Vector3 as F, Vector4 as K, MeshBasicMaterial as Dt, Mesh as Pt, ShaderMaterial as ge, NoBlending as ie, WebGLRenderTarget as ae, Vector2 as q, PerspectiveCamera as dt, DataUtils as k, HalfFloatType as D, LinearFilter as C, RepeatWrapping as z, ClampToEdgeWrapping as N, Source as Et, Quaternion as kt, DataArrayTexture as Ot, DoubleSide as zt, BackSide as Nt, FrontSide as Ht, WebGLArrayRenderTarget as Bt, Color as se, NoToneMapping as Wt, NormalBlending as mt, EquirectangularReflectionMapping as pt, Spherical as Lt, LinearMipMapLinearFilter as Ut, Clock as Vt, Scene as Gt, AdditiveBlending as qt } from "three";
3
- import { g as $t, a as jt, B as We, I as Yt, C as Xt, O as Qt, S as Kt, b as Zt, L as Jt, c as er, M as tr, T as rr, D as ar, d as ir, R as S, e as B, E as W } from "./index-C4Vga5nj.js";
4
- import { F as Z } from "./Pass-DOcH4lwV.js";
5
- function sr(s) {
6
- switch (s) {
1
+ import * as _ from "three";
2
+ import { UnsignedIntType as ae, DataTexture as F, NearestFilter as T, IntType as we, FloatType as R, UnsignedByteType as Me, UnsignedShortType as Mt, ByteType as Be, ShortType as At, RGBAFormat as I, RGBAIntegerFormat as Ae, RGIntegerFormat as ft, RedIntegerFormat as Ft, RGFormat as ht, RedFormat as pe, BufferAttribute as O, BufferGeometry as ee, Matrix4 as z, Matrix3 as Ct, Vector3 as P, Vector4 as te, MeshBasicMaterial as Dt, Mesh as Pt, ShaderMaterial as ge, NoBlending as se, WebGLRenderTarget as ie, Vector2 as X, PerspectiveCamera as dt, DataUtils as N, HalfFloatType as E, LinearFilter as D, RepeatWrapping as H, ClampToEdgeWrapping as B, Source as Et, Quaternion as Ot, DataArrayTexture as kt, DoubleSide as Nt, BackSide as zt, FrontSide as Ht, WebGLArrayRenderTarget as Bt, Color as oe, NoToneMapping as Wt, NormalBlending as mt, EquirectangularReflectionMapping as pt, Spherical as Lt, LinearMipMapLinearFilter as Ut, Clock as Gt, Scene as Vt, AdditiveBlending as qt } from "three";
3
+ import { F as Y } from "./Pass-DOcH4lwV.js";
4
+ import { g as $t, a as jt, B as We, I as Yt, C as Xt, O as Qt, S as Kt, b as Zt, L as Jt, c as er, M as tr, T as rr, D as ar, d as ir, P as sr, R as S, e as L, E as U } from "./index-DOb7Peb_.js";
5
+ function or(o) {
6
+ switch (o) {
7
7
  case 1:
8
8
  return "R";
9
9
  case 2:
@@ -15,10 +15,10 @@ function sr(s) {
15
15
  }
16
16
  throw new Error();
17
17
  }
18
- function or(s) {
19
- switch (s) {
18
+ function nr(o) {
19
+ switch (o) {
20
20
  case 1:
21
- return me;
21
+ return pe;
22
22
  case 2:
23
23
  return ht;
24
24
  case 3:
@@ -27,10 +27,10 @@ function or(s) {
27
27
  return I;
28
28
  }
29
29
  }
30
- function Le(s) {
31
- switch (s) {
30
+ function Le(o) {
31
+ switch (o) {
32
32
  case 1:
33
- return Ct;
33
+ return Ft;
34
34
  case 2:
35
35
  return ft;
36
36
  case 3:
@@ -39,7 +39,7 @@ function Le(s) {
39
39
  return Ae;
40
40
  }
41
41
  }
42
- class gt extends M {
42
+ class gt extends F {
43
43
  constructor() {
44
44
  super(), this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.overrideItemSize = null, this._forcedType = null;
45
45
  }
@@ -60,17 +60,17 @@ class gt extends M {
60
60
  throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");
61
61
  e.itemSize = t, e.count = i * r / t;
62
62
  }
63
- const o = e.itemSize, a = e.count, l = e.normalized, f = e.array.constructor, d = f.BYTES_PER_ELEMENT;
64
- let h = this._forcedType, u = o;
63
+ const s = e.itemSize, a = e.count, l = e.normalized, u = e.array.constructor, d = u.BYTES_PER_ELEMENT;
64
+ let h = this._forcedType, f = s;
65
65
  if (h === null)
66
- switch (f) {
66
+ switch (u) {
67
67
  case Float32Array:
68
68
  h = R;
69
69
  break;
70
70
  case Uint8Array:
71
71
  case Uint16Array:
72
72
  case Uint32Array:
73
- h = re;
73
+ h = ae;
74
74
  break;
75
75
  case Int8Array:
76
76
  case Int16Array:
@@ -78,31 +78,31 @@ class gt extends M {
78
78
  h = we;
79
79
  break;
80
80
  }
81
- let n, x, m, g, c = sr(o);
81
+ let n, x, m, g, c = or(s);
82
82
  switch (h) {
83
83
  case R:
84
- m = 1, x = or(o), l && d === 1 ? (g = f, c += "8", f === Uint8Array ? n = Me : (n = Be, c += "_SNORM")) : (g = Float32Array, c += "32F", n = R);
84
+ m = 1, x = nr(s), l && d === 1 ? (g = u, c += "8", u === Uint8Array ? n = Me : (n = Be, c += "_SNORM")) : (g = Float32Array, c += "32F", n = R);
85
85
  break;
86
86
  case we:
87
- c += d * 8 + "I", m = l ? Math.pow(2, f.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(o), d === 1 ? (g = Int8Array, n = Be) : d === 2 ? (g = Int16Array, n = At) : (g = Int32Array, n = we);
87
+ c += d * 8 + "I", m = l ? Math.pow(2, u.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(s), d === 1 ? (g = Int8Array, n = Be) : d === 2 ? (g = Int16Array, n = At) : (g = Int32Array, n = we);
88
88
  break;
89
- case re:
90
- c += d * 8 + "UI", m = l ? Math.pow(2, f.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(o), d === 1 ? (g = Uint8Array, n = Me) : d === 2 ? (g = Uint16Array, n = Mt) : (g = Uint32Array, n = re);
89
+ case ae:
90
+ c += d * 8 + "UI", m = l ? Math.pow(2, u.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(s), d === 1 ? (g = Uint8Array, n = Me) : d === 2 ? (g = Uint16Array, n = Mt) : (g = Uint32Array, n = ae);
91
91
  break;
92
92
  }
93
- u === 3 && (x === I || x === Ae) && (u = 4);
94
- const p = Math.ceil(Math.sqrt(a)) || 1, v = u * p * p, b = new g(v), y = e.normalized;
93
+ f === 3 && (x === I || x === Ae) && (f = 4);
94
+ const p = Math.ceil(Math.sqrt(a)) || 1, v = f * p * p, b = new g(v), y = e.normalized;
95
95
  e.normalized = !1;
96
96
  for (let w = 0; w < a; w++) {
97
- const E = u * w;
98
- b[E] = e.getX(w) / m, o >= 2 && (b[E + 1] = e.getY(w) / m), o >= 3 && (b[E + 2] = e.getZ(w) / m, u === 4 && (b[E + 3] = 1)), o >= 4 && (b[E + 3] = e.getW(w) / m);
97
+ const k = f * w;
98
+ b[k] = e.getX(w) / m, s >= 2 && (b[k + 1] = e.getY(w) / m), s >= 3 && (b[k + 2] = e.getZ(w) / m, f === 4 && (b[k + 3] = 1)), s >= 4 && (b[k + 3] = e.getW(w) / m);
99
99
  }
100
100
  e.normalized = y, this.internalFormat = c, this.format = x, this.type = n, this.image.width = p, this.image.height = p, this.image.data = b, this.needsUpdate = !0, this.dispose(), e.itemSize = r, e.count = i;
101
101
  }
102
102
  }
103
103
  class vt extends gt {
104
104
  constructor() {
105
- super(), this._forcedType = re;
105
+ super(), this._forcedType = ae;
106
106
  }
107
107
  }
108
108
  class xt extends gt {
@@ -110,9 +110,9 @@ class xt extends gt {
110
110
  super(), this._forcedType = R;
111
111
  }
112
112
  }
113
- class nr {
113
+ class lr {
114
114
  constructor() {
115
- this.index = new vt(), this.position = new xt(), this.bvhBounds = new M(), this.bvhContents = new M(), this._cachedIndexAttr = null, this.index.overrideItemSize = 3;
115
+ this.index = new vt(), this.position = new xt(), this.bvhBounds = new F(), this.bvhContents = new F(), this._cachedIndexAttr = null, this.index.overrideItemSize = 3;
116
116
  }
117
117
  /**
118
118
  * Updates the object and associated textures with data from the provided BVH.
@@ -122,16 +122,16 @@ class nr {
122
122
  */
123
123
  updateFrom(e) {
124
124
  const { geometry: t } = e;
125
- if (cr(e, this.bvhBounds, this.bvhContents), this.position.updateFrom(t.attributes.position), e.indirect) {
125
+ if (ur(e, this.bvhBounds, this.bvhContents), this.position.updateFrom(t.attributes.position), e.indirect) {
126
126
  const r = e._indirectBuffer;
127
127
  if (this._cachedIndexAttr === null || this._cachedIndexAttr.count !== r.length)
128
128
  if (t.index)
129
129
  this._cachedIndexAttr = t.index.clone();
130
130
  else {
131
131
  const i = $t(jt(t));
132
- this._cachedIndexAttr = new P(i, 1, !1);
132
+ this._cachedIndexAttr = new O(i, 1, !1);
133
133
  }
134
- lr(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
134
+ cr(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
135
135
  } else
136
136
  this.index.updateFrom(t.index);
137
137
  }
@@ -145,34 +145,34 @@ class nr {
145
145
  e && e.dispose(), t && t.dispose(), r && r.dispose(), i && i.dispose();
146
146
  }
147
147
  }
148
- function lr(s, e, t) {
149
- const r = t.array, i = s.index ? s.index.array : null;
150
- for (let o = 0, a = e.length; o < a; o++) {
151
- const l = 3 * o, f = 3 * e[o];
148
+ function cr(o, e, t) {
149
+ const r = t.array, i = o.index ? o.index.array : null;
150
+ for (let s = 0, a = e.length; s < a; s++) {
151
+ const l = 3 * s, u = 3 * e[s];
152
152
  for (let d = 0; d < 3; d++)
153
- r[l + d] = i ? i[f + d] : f + d;
153
+ r[l + d] = i ? i[u + d] : u + d;
154
154
  }
155
155
  }
156
- function cr(s, e, t) {
157
- const r = s._roots;
156
+ function ur(o, e, t) {
157
+ const r = o._roots;
158
158
  if (r.length !== 1)
159
159
  throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");
160
- const i = r[0], o = new Uint16Array(i), a = new Uint32Array(i), l = new Float32Array(i), f = i.byteLength / We, d = 2 * Math.ceil(Math.sqrt(f / 2)), h = new Float32Array(4 * d * d), u = Math.ceil(Math.sqrt(f)), n = new Uint32Array(2 * u * u);
161
- for (let x = 0; x < f; x++) {
160
+ const i = r[0], s = new Uint16Array(i), a = new Uint32Array(i), l = new Float32Array(i), u = i.byteLength / We, d = 2 * Math.ceil(Math.sqrt(u / 2)), h = new Float32Array(4 * d * d), f = Math.ceil(Math.sqrt(u)), n = new Uint32Array(2 * f * f);
161
+ for (let x = 0; x < u; x++) {
162
162
  const m = x * We / 4, g = m * 2, c = Zt(m);
163
163
  for (let p = 0; p < 3; p++)
164
164
  h[8 * x + 0 + p] = l[c + 0 + p], h[8 * x + 4 + p] = l[c + 3 + p];
165
- if (Yt(g, o)) {
166
- const p = Xt(g, o), v = Qt(m, a), b = Jt | p;
165
+ if (Yt(g, s)) {
166
+ const p = Xt(g, s), v = Qt(m, a), b = Jt | p;
167
167
  n[x * 2 + 0] = b, n[x * 2 + 1] = v;
168
168
  } else {
169
169
  const p = a[m + 6], v = Kt(m, a);
170
170
  n[x * 2 + 0] = v, n[x * 2 + 1] = p;
171
171
  }
172
172
  }
173
- e.image.data = h, e.image.width = d, e.image.height = d, e.format = I, e.type = R, e.internalFormat = "RGBA32F", e.minFilter = T, e.magFilter = T, e.generateMipmaps = !1, e.needsUpdate = !0, e.dispose(), t.image.data = n, t.image.width = u, t.image.height = u, t.format = ft, t.type = re, t.internalFormat = "RG32UI", t.minFilter = T, t.magFilter = T, t.generateMipmaps = !1, t.needsUpdate = !0, t.dispose();
173
+ e.image.data = h, e.image.width = d, e.image.height = d, e.format = I, e.type = R, e.internalFormat = "RGBA32F", e.minFilter = T, e.magFilter = T, e.generateMipmaps = !1, e.needsUpdate = !0, e.dispose(), t.image.data = n, t.image.width = f, t.image.height = f, t.format = ft, t.type = ae, t.internalFormat = "RG32UI", t.minFilter = T, t.magFilter = T, t.generateMipmaps = !1, t.needsUpdate = !0, t.dispose();
174
174
  }
175
- const ur = (
175
+ const fr = (
176
176
  /* glsl */
177
177
  `
178
178
 
@@ -257,7 +257,7 @@ void ndcToCameraRay(
257
257
 
258
258
  }
259
259
  `
260
- ), fr = (
260
+ ), hr = (
261
261
  /* glsl */
262
262
  `
263
263
 
@@ -464,7 +464,7 @@ bool _bvhIntersectFirstHit(
464
464
 
465
465
  }
466
466
  `
467
- ), hr = (
467
+ ), dr = (
468
468
  /* glsl */
469
469
  `
470
470
  struct BVH {
@@ -478,317 +478,317 @@ struct BVH {
478
478
  };
479
479
  `
480
480
  );
481
- function bt(s, e, t = 0) {
482
- if (s.isInterleavedBufferAttribute) {
483
- const r = s.itemSize;
484
- for (let i = 0, o = s.count; i < o; i++) {
481
+ function bt(o, e, t = 0) {
482
+ if (o.isInterleavedBufferAttribute) {
483
+ const r = o.itemSize;
484
+ for (let i = 0, s = o.count; i < s; i++) {
485
485
  const a = i + t;
486
- e.setX(a, s.getX(i)), r >= 2 && e.setY(a, s.getY(i)), r >= 3 && e.setZ(a, s.getZ(i)), r >= 4 && e.setW(a, s.getW(i));
486
+ e.setX(a, o.getX(i)), r >= 2 && e.setY(a, o.getY(i)), r >= 3 && e.setZ(a, o.getZ(i)), r >= 4 && e.setW(a, o.getW(i));
487
487
  }
488
488
  } else {
489
- const r = e.array, i = r.constructor, o = r.BYTES_PER_ELEMENT * s.itemSize * t;
490
- new i(r.buffer, o, s.array.length).set(s.array);
489
+ const r = e.array, i = r.constructor, s = r.BYTES_PER_ELEMENT * o.itemSize * t;
490
+ new i(r.buffer, s, o.array.length).set(o.array);
491
491
  }
492
492
  }
493
- function te(s, e = null) {
494
- const t = s.array.constructor, r = s.normalized, i = s.itemSize, o = e === null ? s.count : e;
495
- return new P(new t(i * o), i, r);
493
+ function re(o, e = null) {
494
+ const t = o.array.constructor, r = o.normalized, i = o.itemSize, s = e === null ? o.count : e;
495
+ return new O(new t(i * s), i, r);
496
496
  }
497
- function X(s, e) {
498
- if (!s && !e)
497
+ function J(o, e) {
498
+ if (!o && !e)
499
499
  return !0;
500
- if (!!s != !!e)
500
+ if (!!o != !!e)
501
501
  return !1;
502
- const t = s.count === e.count, r = s.normalized === e.normalized, i = s.array.constructor === e.array.constructor, o = s.itemSize === e.itemSize;
503
- return !(!t || !r || !i || !o);
502
+ const t = o.count === e.count, r = o.normalized === e.normalized, i = o.array.constructor === e.array.constructor, s = o.itemSize === e.itemSize;
503
+ return !(!t || !r || !i || !s);
504
504
  }
505
- function dr(s) {
506
- const e = s[0].index !== null, t = new Set(Object.keys(s[0].attributes));
507
- if (!s[0].getAttribute("position"))
505
+ function mr(o) {
506
+ const e = o[0].index !== null, t = new Set(Object.keys(o[0].attributes));
507
+ if (!o[0].getAttribute("position"))
508
508
  throw new Error("StaticGeometryGenerator: position attribute is required.");
509
- for (let r = 0; r < s.length; ++r) {
510
- const i = s[r];
511
- let o = 0;
509
+ for (let r = 0; r < o.length; ++r) {
510
+ const i = o[r];
511
+ let s = 0;
512
512
  if (e !== (i.index !== null))
513
513
  throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
514
514
  for (const a in i.attributes) {
515
515
  if (!t.has(a))
516
516
  throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + a + '" attribute exists among all geometries, or in none of them.');
517
- o++;
517
+ s++;
518
518
  }
519
- if (o !== t.size)
519
+ if (s !== t.size)
520
520
  throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.");
521
521
  }
522
522
  }
523
- function mr(s) {
523
+ function pr(o) {
524
524
  let e = 0;
525
- for (let t = 0, r = s.length; t < r; t++)
526
- e += s[t].getIndex().count;
525
+ for (let t = 0, r = o.length; t < r; t++)
526
+ e += o[t].getIndex().count;
527
527
  return e;
528
528
  }
529
- function pr(s) {
529
+ function gr(o) {
530
530
  let e = 0;
531
- for (let t = 0, r = s.length; t < r; t++)
532
- e += s[t].getAttribute("position").count;
531
+ for (let t = 0, r = o.length; t < r; t++)
532
+ e += o[t].getAttribute("position").count;
533
533
  return e;
534
534
  }
535
- function gr(s, e, t) {
536
- s.index && s.index.count !== e && s.setIndex(null);
537
- const r = s.attributes;
535
+ function vr(o, e, t) {
536
+ o.index && o.index.count !== e && o.setIndex(null);
537
+ const r = o.attributes;
538
538
  for (const i in r)
539
- r[i].count !== t && s.deleteAttribute(i);
539
+ r[i].count !== t && o.deleteAttribute(i);
540
540
  }
541
- function vr(s, e = {}, t = new Q()) {
541
+ function xr(o, e = {}, t = new ee()) {
542
542
  const {
543
543
  useGroups: r = !1,
544
544
  forceUpdate: i = !1,
545
- skipAssigningAttributes: o = [],
545
+ skipAssigningAttributes: s = [],
546
546
  overwriteIndex: a = !0
547
547
  } = e;
548
- dr(s);
549
- const l = s[0].index !== null, f = l ? mr(s) : -1, d = pr(s);
550
- if (gr(t, f, d), r) {
551
- let u = 0;
552
- for (let n = 0, x = s.length; n < x; n++) {
553
- const m = s[n];
548
+ mr(o);
549
+ const l = o[0].index !== null, u = l ? pr(o) : -1, d = gr(o);
550
+ if (vr(t, u, d), r) {
551
+ let f = 0;
552
+ for (let n = 0, x = o.length; n < x; n++) {
553
+ const m = o[n];
554
554
  let g;
555
- l ? g = m.getIndex().count : g = m.getAttribute("position").count, t.addGroup(u, g, n), u += g;
555
+ l ? g = m.getIndex().count : g = m.getAttribute("position").count, t.addGroup(f, g, n), f += g;
556
556
  }
557
557
  }
558
558
  if (l) {
559
- let u = !1;
560
- if (t.index || (t.setIndex(new P(new Uint32Array(f), 1, !1)), u = !0), u || a) {
559
+ let f = !1;
560
+ if (t.index || (t.setIndex(new O(new Uint32Array(u), 1, !1)), f = !0), f || a) {
561
561
  let n = 0, x = 0;
562
562
  const m = t.getIndex();
563
- for (let g = 0, c = s.length; g < c; g++) {
564
- const p = s[g], v = p.getIndex();
565
- if (!(!i && !u && o[g]))
563
+ for (let g = 0, c = o.length; g < c; g++) {
564
+ const p = o[g], v = p.getIndex();
565
+ if (!(!i && !f && s[g]))
566
566
  for (let y = 0; y < v.count; ++y)
567
567
  m.setX(n + y, v.getX(y) + x);
568
568
  n += v.count, x += p.getAttribute("position").count;
569
569
  }
570
570
  }
571
571
  }
572
- const h = Object.keys(s[0].attributes);
573
- for (let u = 0, n = h.length; u < n; u++) {
572
+ const h = Object.keys(o[0].attributes);
573
+ for (let f = 0, n = h.length; f < n; f++) {
574
574
  let x = !1;
575
- const m = h[u];
575
+ const m = h[f];
576
576
  if (!t.getAttribute(m)) {
577
- const p = s[0].getAttribute(m);
578
- t.setAttribute(m, te(p, d)), x = !0;
577
+ const p = o[0].getAttribute(m);
578
+ t.setAttribute(m, re(p, d)), x = !0;
579
579
  }
580
580
  let g = 0;
581
581
  const c = t.getAttribute(m);
582
- for (let p = 0, v = s.length; p < v; p++) {
583
- const b = s[p], y = !i && !x && o[p], w = b.getAttribute(m);
582
+ for (let p = 0, v = o.length; p < v; p++) {
583
+ const b = o[p], y = !i && !x && s[p], w = b.getAttribute(m);
584
584
  y || bt(w, c, g), g += w.count;
585
585
  }
586
586
  }
587
587
  }
588
- function xr(s, e, t) {
589
- const r = s.index, o = s.attributes.position.count, a = r ? r.count : o;
590
- let l = s.groups;
588
+ function br(o, e, t) {
589
+ const r = o.index, s = o.attributes.position.count, a = r ? r.count : s;
590
+ let l = o.groups;
591
591
  l.length === 0 && (l = [{ count: a, start: 0, materialIndex: 0 }]);
592
- let f = s.getAttribute("materialIndex");
593
- if (!f || f.count !== o) {
592
+ let u = o.getAttribute("materialIndex");
593
+ if (!u || u.count !== s) {
594
594
  let h;
595
- t.length <= 255 ? h = new Uint8Array(o) : h = new Uint16Array(o), f = new P(h, 1, !1), s.deleteAttribute("materialIndex"), s.setAttribute("materialIndex", f);
595
+ t.length <= 255 ? h = new Uint8Array(s) : h = new Uint16Array(s), u = new O(h, 1, !1), o.deleteAttribute("materialIndex"), o.setAttribute("materialIndex", u);
596
596
  }
597
- const d = f.array;
597
+ const d = u.array;
598
598
  for (let h = 0; h < l.length; h++) {
599
- const u = l[h], n = u.start, x = u.count, m = Math.min(x, a - n), g = Array.isArray(e) ? e[u.materialIndex] : e, c = t.indexOf(g);
599
+ const f = l[h], n = f.start, x = f.count, m = Math.min(x, a - n), g = Array.isArray(e) ? e[f.materialIndex] : e, c = t.indexOf(g);
600
600
  for (let p = 0; p < m; p++) {
601
601
  let v = n + p;
602
602
  r && (v = r.getX(v)), d[v] = c;
603
603
  }
604
604
  }
605
605
  }
606
- function br(s, e) {
607
- if (!s.index) {
608
- const t = s.attributes.position.count, r = new Array(t);
606
+ function yr(o, e) {
607
+ if (!o.index) {
608
+ const t = o.attributes.position.count, r = new Array(t);
609
609
  for (let i = 0; i < t; i++)
610
610
  r[i] = i;
611
- s.setIndex(r);
611
+ o.setIndex(r);
612
612
  }
613
- if (!s.attributes.normal && e && e.includes("normal") && s.computeVertexNormals(), !s.attributes.uv && e && e.includes("uv")) {
614
- const t = s.attributes.position.count;
615
- s.setAttribute("uv", new P(new Float32Array(t * 2), 2, !1));
613
+ if (!o.attributes.normal && e && e.includes("normal") && o.computeVertexNormals(), !o.attributes.uv && e && e.includes("uv")) {
614
+ const t = o.attributes.position.count;
615
+ o.setAttribute("uv", new O(new Float32Array(t * 2), 2, !1));
616
616
  }
617
- if (!s.attributes.uv2 && e && e.includes("uv2")) {
618
- const t = s.attributes.position.count;
619
- s.setAttribute("uv2", new P(new Float32Array(t * 2), 2, !1));
617
+ if (!o.attributes.uv2 && e && e.includes("uv2")) {
618
+ const t = o.attributes.position.count;
619
+ o.setAttribute("uv2", new O(new Float32Array(t * 2), 2, !1));
620
620
  }
621
- if (!s.attributes.tangent && e && e.includes("tangent"))
622
- if (s.attributes.uv && s.attributes.normal)
623
- s.computeTangents();
621
+ if (!o.attributes.tangent && e && e.includes("tangent"))
622
+ if (o.attributes.uv && o.attributes.normal)
623
+ o.computeTangents();
624
624
  else {
625
- const t = s.attributes.position.count;
626
- s.setAttribute("tangent", new P(new Float32Array(t * 4), 4, !1));
625
+ const t = o.attributes.position.count;
626
+ o.setAttribute("tangent", new O(new Float32Array(t * 4), 4, !1));
627
627
  }
628
- if (!s.attributes.color && e && e.includes("color")) {
629
- const t = s.attributes.position.count, r = new Float32Array(t * 4);
630
- r.fill(1), s.setAttribute("color", new P(r, 4));
628
+ if (!o.attributes.color && e && e.includes("color")) {
629
+ const t = o.attributes.position.count, r = new Float32Array(t * 4);
630
+ r.fill(1), o.setAttribute("color", new O(r, 4));
631
631
  }
632
632
  }
633
- function De(s) {
633
+ function De(o) {
634
634
  let e = 0;
635
- if (s.byteLength !== 0) {
636
- const t = new Uint8Array(s);
637
- for (let r = 0; r < s.byteLength; r++) {
635
+ if (o.byteLength !== 0) {
636
+ const t = new Uint8Array(o);
637
+ for (let r = 0; r < o.byteLength; r++) {
638
638
  const i = t[r];
639
639
  e = (e << 5) - e + i, e |= 0;
640
640
  }
641
641
  }
642
642
  return e;
643
643
  }
644
- function Ue(s) {
645
- let e = s.uuid;
646
- const t = Object.values(s.attributes);
647
- s.index && (t.push(s.index), e += `index|${s.index.version}`);
644
+ function Ue(o) {
645
+ let e = o.uuid;
646
+ const t = Object.values(o.attributes);
647
+ o.index && (t.push(o.index), e += `index|${o.index.version}`);
648
648
  const r = Object.keys(t).sort();
649
649
  for (const i of r) {
650
- const o = t[i];
651
- e += `${i}_${o.version}|`;
650
+ const s = t[i];
651
+ e += `${i}_${s.version}|`;
652
652
  }
653
653
  return e;
654
654
  }
655
- function Ve(s) {
656
- const e = s.skeleton;
655
+ function Ge(o) {
656
+ const e = o.skeleton;
657
657
  return e ? (e.boneTexture || e.computeBoneTexture(), `${De(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`) : null;
658
658
  }
659
- class yr {
659
+ class Tr {
660
660
  constructor(e = null) {
661
- this.matrixWorld = new O(), this.geometryHash = null, this.skeletonHash = null, this.primitiveCount = -1, e !== null && this.updateFrom(e);
661
+ this.matrixWorld = new z(), this.geometryHash = null, this.skeletonHash = null, this.primitiveCount = -1, e !== null && this.updateFrom(e);
662
662
  }
663
663
  updateFrom(e) {
664
664
  const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
665
- this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash = Ve(e);
665
+ this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash = Ge(e);
666
666
  }
667
667
  didChange(e) {
668
668
  const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
669
- return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash === Ve(e) && this.primitiveCount === r);
669
+ return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash === Ge(e) && this.primitiveCount === r);
670
670
  }
671
671
  }
672
- const L = /* @__PURE__ */ new F(), U = /* @__PURE__ */ new F(), V = /* @__PURE__ */ new F(), Ge = /* @__PURE__ */ new K(), le = /* @__PURE__ */ new F(), Ie = /* @__PURE__ */ new F(), qe = /* @__PURE__ */ new K(), $e = /* @__PURE__ */ new K(), ce = /* @__PURE__ */ new O(), je = /* @__PURE__ */ new O();
673
- function Ye(s, e, t) {
674
- const r = s.skeleton, i = s.geometry, o = r.bones, a = r.boneInverses;
675
- qe.fromBufferAttribute(i.attributes.skinIndex, e), $e.fromBufferAttribute(i.attributes.skinWeight, e), ce.elements.fill(0);
672
+ const G = /* @__PURE__ */ new P(), V = /* @__PURE__ */ new P(), q = /* @__PURE__ */ new P(), Ve = /* @__PURE__ */ new te(), ce = /* @__PURE__ */ new P(), Ie = /* @__PURE__ */ new P(), qe = /* @__PURE__ */ new te(), $e = /* @__PURE__ */ new te(), ue = /* @__PURE__ */ new z(), je = /* @__PURE__ */ new z();
673
+ function Ye(o, e, t) {
674
+ const r = o.skeleton, i = o.geometry, s = r.bones, a = r.boneInverses;
675
+ qe.fromBufferAttribute(i.attributes.skinIndex, e), $e.fromBufferAttribute(i.attributes.skinWeight, e), ue.elements.fill(0);
676
676
  for (let l = 0; l < 4; l++) {
677
- const f = $e.getComponent(l);
678
- if (f !== 0) {
677
+ const u = $e.getComponent(l);
678
+ if (u !== 0) {
679
679
  const d = qe.getComponent(l);
680
- je.multiplyMatrices(o[d].matrixWorld, a[d]), Tr(ce, je, f);
680
+ je.multiplyMatrices(s[d].matrixWorld, a[d]), wr(ue, je, u);
681
681
  }
682
682
  }
683
- return ce.multiply(s.bindMatrix).premultiply(s.bindMatrixInverse), t.transformDirection(ce), t;
683
+ return ue.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse), t.transformDirection(ue), t;
684
684
  }
685
- function Re(s, e, t, r, i) {
686
- le.set(0, 0, 0);
687
- for (let o = 0, a = s.length; o < a; o++) {
688
- const l = e[o], f = s[o];
689
- l !== 0 && (Ie.fromBufferAttribute(f, r), t ? le.addScaledVector(Ie, l) : le.addScaledVector(Ie.sub(i), l));
685
+ function Re(o, e, t, r, i) {
686
+ ce.set(0, 0, 0);
687
+ for (let s = 0, a = o.length; s < a; s++) {
688
+ const l = e[s], u = o[s];
689
+ l !== 0 && (Ie.fromBufferAttribute(u, r), t ? ce.addScaledVector(Ie, l) : ce.addScaledVector(Ie.sub(i), l));
690
690
  }
691
- i.add(le);
691
+ i.add(ce);
692
692
  }
693
- function Tr(s, e, t) {
694
- const r = s.elements, i = e.elements;
695
- for (let o = 0, a = i.length; o < a; o++)
696
- r[o] += i[o] * t;
693
+ function wr(o, e, t) {
694
+ const r = o.elements, i = e.elements;
695
+ for (let s = 0, a = i.length; s < a; s++)
696
+ r[s] += i[s] * t;
697
697
  }
698
- function wr(s) {
699
- const { index: e, attributes: t } = s;
698
+ function Ir(o) {
699
+ const { index: e, attributes: t } = o;
700
700
  if (e)
701
701
  for (let r = 0, i = e.count; r < i; r += 3) {
702
- const o = e.getX(r), a = e.getX(r + 2);
703
- e.setX(r, a), e.setX(r + 2, o);
702
+ const s = e.getX(r), a = e.getX(r + 2);
703
+ e.setX(r, a), e.setX(r + 2, s);
704
704
  }
705
705
  else
706
706
  for (const r in t) {
707
- const i = t[r], o = i.itemSize;
707
+ const i = t[r], s = i.itemSize;
708
708
  for (let a = 0, l = i.count; a < l; a += 3)
709
- for (let f = 0; f < o; f++) {
710
- const d = i.getComponent(a, f), h = i.getComponent(a + 2, f);
711
- i.setComponent(a, f, h), i.setComponent(a + 2, f, d);
709
+ for (let u = 0; u < s; u++) {
710
+ const d = i.getComponent(a, u), h = i.getComponent(a + 2, u);
711
+ i.setComponent(a, u, h), i.setComponent(a + 2, u, d);
712
712
  }
713
713
  }
714
- return s;
714
+ return o;
715
715
  }
716
- function Ir(s, e = {}, t = new Q()) {
716
+ function Rr(o, e = {}, t = new ee()) {
717
717
  e = {
718
718
  applyWorldTransforms: !0,
719
719
  attributes: [],
720
720
  ...e
721
721
  };
722
- const r = s.geometry, i = e.applyWorldTransforms, o = e.attributes.includes("normal"), a = e.attributes.includes("tangent"), l = r.attributes, f = t.attributes;
722
+ const r = o.geometry, i = e.applyWorldTransforms, s = e.attributes.includes("normal"), a = e.attributes.includes("tangent"), l = r.attributes, u = t.attributes;
723
723
  for (const v in t.attributes)
724
724
  (!e.attributes.includes(v) || !(v in r.attributes)) && t.deleteAttribute(v);
725
- !t.index && r.index && (t.index = r.index.clone()), f.position || t.setAttribute("position", te(l.position)), o && !f.normal && l.normal && t.setAttribute("normal", te(l.normal)), a && !f.tangent && l.tangent && t.setAttribute("tangent", te(l.tangent)), X(r.index, t.index), X(l.position, f.position), o && X(l.normal, f.normal), a && X(l.tangent, f.tangent);
726
- const d = l.position, h = o ? l.normal : null, u = a ? l.tangent : null, n = r.morphAttributes.position, x = r.morphAttributes.normal, m = r.morphAttributes.tangent, g = r.morphTargetsRelative, c = s.morphTargetInfluences, p = new Ft();
727
- p.getNormalMatrix(s.matrixWorld), r.index && t.index.array.set(r.index.array);
725
+ !t.index && r.index && (t.index = r.index.clone()), u.position || t.setAttribute("position", re(l.position)), s && !u.normal && l.normal && t.setAttribute("normal", re(l.normal)), a && !u.tangent && l.tangent && t.setAttribute("tangent", re(l.tangent)), J(r.index, t.index), J(l.position, u.position), s && J(l.normal, u.normal), a && J(l.tangent, u.tangent);
726
+ const d = l.position, h = s ? l.normal : null, f = a ? l.tangent : null, n = r.morphAttributes.position, x = r.morphAttributes.normal, m = r.morphAttributes.tangent, g = r.morphTargetsRelative, c = o.morphTargetInfluences, p = new Ct();
727
+ p.getNormalMatrix(o.matrixWorld), r.index && t.index.array.set(r.index.array);
728
728
  for (let v = 0, b = l.position.count; v < b; v++)
729
- L.fromBufferAttribute(d, v), h && U.fromBufferAttribute(h, v), u && (Ge.fromBufferAttribute(u, v), V.fromBufferAttribute(u, v)), c && (n && Re(n, c, g, v, L), x && Re(x, c, g, v, U), m && Re(m, c, g, v, V)), s.isSkinnedMesh && (s.applyBoneTransform(v, L), h && Ye(s, v, U), u && Ye(s, v, V)), i && L.applyMatrix4(s.matrixWorld), f.position.setXYZ(v, L.x, L.y, L.z), h && (i && U.applyNormalMatrix(p), f.normal.setXYZ(v, U.x, U.y, U.z)), u && (i && V.transformDirection(s.matrixWorld), f.tangent.setXYZW(v, V.x, V.y, V.z, Ge.w));
729
+ G.fromBufferAttribute(d, v), h && V.fromBufferAttribute(h, v), f && (Ve.fromBufferAttribute(f, v), q.fromBufferAttribute(f, v)), c && (n && Re(n, c, g, v, G), x && Re(x, c, g, v, V), m && Re(m, c, g, v, q)), o.isSkinnedMesh && (o.applyBoneTransform(v, G), h && Ye(o, v, V), f && Ye(o, v, q)), i && G.applyMatrix4(o.matrixWorld), u.position.setXYZ(v, G.x, G.y, G.z), h && (i && V.applyNormalMatrix(p), u.normal.setXYZ(v, V.x, V.y, V.z)), f && (i && q.transformDirection(o.matrixWorld), u.tangent.setXYZW(v, q.x, q.y, q.z, Ve.w));
730
730
  for (const v in e.attributes) {
731
731
  const b = e.attributes[v];
732
- b === "position" || b === "tangent" || b === "normal" || !(b in l) || (f[b] || t.setAttribute(b, te(l[b])), X(l[b], f[b]), bt(l[b], f[b]));
732
+ b === "position" || b === "tangent" || b === "normal" || !(b in l) || (u[b] || t.setAttribute(b, re(l[b])), J(l[b], u[b]), bt(l[b], u[b]));
733
733
  }
734
- return s.matrixWorld.determinant() < 0 && wr(t), t;
734
+ return o.matrixWorld.determinant() < 0 && Ir(t), t;
735
735
  }
736
- class Rr extends Q {
736
+ class _r extends ee {
737
737
  constructor() {
738
- super(), this.version = 0, this.hash = null, this._diff = new yr();
738
+ super(), this.version = 0, this.hash = null, this._diff = new Tr();
739
739
  }
740
740
  // returns whether the passed mesh is compatible with this baked geometry
741
741
  // such that it can be updated without resizing attributes
742
742
  isCompatible(e, t) {
743
743
  const r = e.geometry;
744
744
  for (let i = 0; i < t.length; i++) {
745
- const o = t[i], a = r.attributes[o], l = this.attributes[o];
746
- if (a && !X(a, l))
745
+ const s = t[i], a = r.attributes[s], l = this.attributes[s];
746
+ if (a && !J(a, l))
747
747
  return !1;
748
748
  }
749
749
  return !0;
750
750
  }
751
751
  updateFrom(e, t) {
752
752
  const r = this._diff;
753
- return r.didChange(e) ? (Ir(e, t, this), r.updateFrom(e), this.version++, this.hash = `${this.uuid}_${this.version}`, !0) : !1;
753
+ return r.didChange(e) ? (Rr(e, t, this), r.updateFrom(e), this.version++, this.hash = `${this.uuid}_${this.version}`, !0) : !1;
754
754
  }
755
755
  }
756
- const Ce = 0, yt = 1, Tt = 2;
757
- function Sr(s, e) {
758
- for (let t = 0, r = s.length; t < r; t++)
759
- s[t].traverseVisible((o) => {
760
- o.isMesh && e(o);
756
+ const Fe = 0, yt = 1, Tt = 2;
757
+ function Sr(o, e) {
758
+ for (let t = 0, r = o.length; t < r; t++)
759
+ o[t].traverseVisible((s) => {
760
+ s.isMesh && e(s);
761
761
  });
762
762
  }
763
- function _r(s) {
763
+ function Mr(o) {
764
764
  const e = [];
765
- for (let t = 0, r = s.length; t < r; t++) {
766
- const i = s[t];
765
+ for (let t = 0, r = o.length; t < r; t++) {
766
+ const i = o[t];
767
767
  Array.isArray(i.material) ? e.push(...i.material) : e.push(i.material);
768
768
  }
769
769
  return e;
770
770
  }
771
- function Mr(s, e, t) {
772
- if (s.length === 0) {
771
+ function Ar(o, e, t) {
772
+ if (o.length === 0) {
773
773
  e.setIndex(null);
774
774
  const r = e.attributes;
775
775
  for (const i in r)
776
776
  e.deleteAttribute(i);
777
777
  for (const i in t.attributes)
778
- e.setAttribute(t.attributes[i], new P(new Float32Array(0), 4, !1));
778
+ e.setAttribute(t.attributes[i], new O(new Float32Array(0), 4, !1));
779
779
  } else
780
- vr(s, t, e);
780
+ xr(o, t, e);
781
781
  for (const r in e.attributes)
782
782
  e.attributes[r].needsUpdate = !0;
783
783
  }
784
- class Ar {
784
+ class Fr {
785
785
  constructor(e) {
786
786
  this.objects = null, this.useGroups = !0, this.applyWorldTransforms = !0, this.generateMissingAttributes = !0, this.overwriteIndex = !0, this.attributes = ["position", "normal", "color", "tangent", "uv", "uv2"], this._intermediateGeometry = /* @__PURE__ */ new Map(), this._geometryMergeSets = /* @__PURE__ */ new WeakMap(), this._mergeOrder = [], this._dummyMesh = null, this.setObjects(e || []);
787
787
  }
788
788
  _getDummyMesh() {
789
789
  if (!this._dummyMesh) {
790
- const e = new Dt(), t = new Q();
791
- t.setAttribute("position", new P(new Float32Array(9), 3)), this._dummyMesh = new Pt(t, e);
790
+ const e = new Dt(), t = new ee();
791
+ t.setAttribute("position", new O(new Float32Array(9), 3)), this._dummyMesh = new Pt(t, e);
792
792
  }
793
793
  return this._dummyMesh;
794
794
  }
@@ -803,68 +803,68 @@ class Ar {
803
803
  attributes: this.attributes,
804
804
  applyWorldTransforms: this.applyWorldTransforms
805
805
  };
806
- for (let o = 0, a = t.length; o < a; o++) {
807
- const l = t[o], f = l.uuid;
808
- r.delete(f);
809
- let d = e.get(f);
810
- (!d || !d.isCompatible(l, this.attributes)) && (d && d.dispose(), d = new Rr(), e.set(f, d)), d.updateFrom(l, i) && this.generateMissingAttributes && br(d, this.attributes);
806
+ for (let s = 0, a = t.length; s < a; s++) {
807
+ const l = t[s], u = l.uuid;
808
+ r.delete(u);
809
+ let d = e.get(u);
810
+ (!d || !d.isCompatible(l, this.attributes)) && (d && d.dispose(), d = new _r(), e.set(u, d)), d.updateFrom(l, i) && this.generateMissingAttributes && yr(d, this.attributes);
811
811
  }
812
- r.forEach((o) => {
813
- e.delete(o);
812
+ r.forEach((s) => {
813
+ e.delete(s);
814
814
  });
815
815
  }
816
816
  setObjects(e) {
817
817
  Array.isArray(e) ? this.objects = [...e] : this.objects = [e];
818
818
  }
819
- generate(e = new Q()) {
820
- const { useGroups: t, overwriteIndex: r, _intermediateGeometry: i, _geometryMergeSets: o } = this, a = this._getMeshes(), l = [], f = [], d = o.get(e) || [];
819
+ generate(e = new ee()) {
820
+ const { useGroups: t, overwriteIndex: r, _intermediateGeometry: i, _geometryMergeSets: s } = this, a = this._getMeshes(), l = [], u = [], d = s.get(e) || [];
821
821
  this._updateIntermediateGeometries();
822
822
  let h = !1;
823
823
  a.length !== d.length && (h = !0);
824
824
  for (let n = 0, x = a.length; n < x; n++) {
825
825
  const m = a[n], g = i.get(m.uuid);
826
- f.push(g);
826
+ u.push(g);
827
827
  const c = d[n];
828
828
  !c || c.uuid !== g.uuid ? (l.push(!1), h = !0) : c.version !== g.version ? l.push(!1) : l.push(!0);
829
829
  }
830
- Mr(f, e, { useGroups: t, forceUpdate: h, skipAssigningAttributes: l, overwriteIndex: r }), h && e.dispose(), o.set(e, f.map((n) => ({
830
+ Ar(u, e, { useGroups: t, forceUpdate: h, skipAssigningAttributes: l, overwriteIndex: r }), h && e.dispose(), s.set(e, u.map((n) => ({
831
831
  version: n.version,
832
832
  uuid: n.uuid
833
833
  })));
834
- let u = Ce;
835
- return h ? u = Tt : l.includes(!1) && (u = yt), {
836
- changeType: u,
837
- materials: _r(a),
834
+ let f = Fe;
835
+ return h ? f = Tt : l.includes(!1) && (f = yt), {
836
+ changeType: f,
837
+ materials: Mr(a),
838
838
  geometry: e
839
839
  };
840
840
  }
841
841
  }
842
- function Cr(s) {
842
+ function Cr(o) {
843
843
  const e = /* @__PURE__ */ new Set();
844
- for (let t = 0, r = s.length; t < r; t++) {
845
- const i = s[t];
846
- for (const o in i) {
847
- const a = i[o];
844
+ for (let t = 0, r = o.length; t < r; t++) {
845
+ const i = o[t];
846
+ for (const s in i) {
847
+ const a = i[s];
848
848
  a && a.isTexture && e.add(a);
849
849
  }
850
850
  }
851
851
  return Array.from(e);
852
852
  }
853
- function Fr(s) {
853
+ function Dr(o) {
854
854
  const e = [], t = /* @__PURE__ */ new Set();
855
- for (let i = 0, o = s.length; i < o; i++)
856
- s[i].traverse((a) => {
855
+ for (let i = 0, s = o.length; i < s; i++)
856
+ o[i].traverse((a) => {
857
857
  a.visible && (a.isRectAreaLight || a.isSpotLight || a.isPointLight || a.isDirectionalLight) && (e.push(a), a.iesMap && t.add(a.iesMap));
858
858
  });
859
- const r = Array.from(t).sort((i, o) => i.uuid < o.uuid ? 1 : i.uuid > o.uuid ? -1 : 0);
859
+ const r = Array.from(t).sort((i, s) => i.uuid < s.uuid ? 1 : i.uuid > s.uuid ? -1 : 0);
860
860
  return { lights: e, iesTextures: r };
861
861
  }
862
- class Dr {
862
+ class Pr {
863
863
  get initialized() {
864
864
  return !!this.bvh;
865
865
  }
866
866
  constructor(e) {
867
- this.bvhOptions = {}, this.attributes = ["position", "normal", "tangent", "color", "uv", "uv2"], this.generateBVH = !0, this.bvh = null, this.geometry = new Q(), this.staticGeometryGenerator = new Ar(e), this._bvhWorker = null, this._pendingGenerate = null, this._buildAsync = !1;
867
+ this.bvhOptions = {}, this.attributes = ["position", "normal", "tangent", "color", "uv", "uv2"], this.generateBVH = !0, this.bvh = null, this.geometry = new ee(), this.staticGeometryGenerator = new Fr(e), this._bvhWorker = null, this._pendingGenerate = null, this._buildAsync = !1;
868
868
  }
869
869
  setObjects(e) {
870
870
  this.staticGeometryGenerator.setObjects(e);
@@ -884,36 +884,36 @@ class Dr {
884
884
  }
885
885
  }
886
886
  generate(e = null) {
887
- const { staticGeometryGenerator: t, geometry: r, attributes: i } = this, o = t.objects;
888
- t.attributes = i, o.forEach((u) => {
889
- u.traverse((n) => {
887
+ const { staticGeometryGenerator: t, geometry: r, attributes: i } = this, s = t.objects;
888
+ t.attributes = i, s.forEach((f) => {
889
+ f.traverse((n) => {
890
890
  n.isSkinnedMesh && n.skeleton && n.skeleton.update();
891
891
  });
892
892
  });
893
- const a = t.generate(r), l = a.materials, f = Cr(l), { lights: d, iesTextures: h } = Fr(o);
894
- if (a.changeType !== Ce && xr(r, l, l), this.generateBVH) {
893
+ const a = t.generate(r), l = a.materials, u = Cr(l), { lights: d, iesTextures: h } = Dr(s);
894
+ if (a.changeType !== Fe && br(r, l, l), this.generateBVH) {
895
895
  if (this.bvh instanceof Promise)
896
896
  throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");
897
897
  if (a.changeType === Tt) {
898
- const u = {
898
+ const f = {
899
899
  strategy: er,
900
900
  maxLeafTris: 1,
901
901
  indirect: !0,
902
902
  onProgress: e,
903
903
  ...this.bvhOptions
904
904
  };
905
- this._buildAsync ? this.bvh = this._bvhWorker.generate(r, u) : this.bvh = new tr(r, u);
905
+ this._buildAsync ? this.bvh = this._bvhWorker.generate(r, f) : this.bvh = new tr(r, f);
906
906
  } else a.changeType === yt && this.bvh.refit();
907
907
  }
908
908
  return {
909
- bvhChanged: a.changeType !== Ce,
909
+ bvhChanged: a.changeType !== Fe,
910
910
  bvh: this.bvh,
911
911
  lights: d,
912
912
  iesTextures: h,
913
913
  geometry: r,
914
914
  materials: l,
915
- textures: f,
916
- objects: o
915
+ textures: u,
916
+ objects: s
917
917
  };
918
918
  }
919
919
  }
@@ -945,10 +945,10 @@ class Pe extends ge {
945
945
  return !1;
946
946
  }
947
947
  }
948
- class Pr extends Pe {
948
+ class Er extends Pe {
949
949
  constructor(e) {
950
950
  super({
951
- blending: ie,
951
+ blending: se,
952
952
  uniforms: {
953
953
  target1: { value: null },
954
954
  target2: { value: null },
@@ -1002,9 +1002,9 @@ class Pr extends Pe {
1002
1002
  }), this.setValues(e);
1003
1003
  }
1004
1004
  }
1005
- function ue(s = 1) {
1005
+ function fe(o = 1) {
1006
1006
  let e = "uint";
1007
- return s > 1 && (e = "uvec" + s), /* glsl */
1007
+ return o > 1 && (e = "uvec" + o), /* glsl */
1008
1008
  `
1009
1009
  ${e} sobolReverseBits( ${e} x ) {
1010
1010
 
@@ -1042,9 +1042,9 @@ function ue(s = 1) {
1042
1042
  }
1043
1043
  `;
1044
1044
  }
1045
- function fe(s = 1) {
1046
- let e = "uint", t = "float", r = "", i = ".r", o = "1u";
1047
- return s > 1 && (e = "uvec" + s, t = "vec" + s, r = s + "", s === 2 ? (i = ".rg", o = "uvec2( 1u, 2u )") : s === 3 ? (i = ".rgb", o = "uvec3( 1u, 2u, 3u )") : (i = "", o = "uvec4( 1u, 2u, 3u, 4u )")), /* glsl */
1045
+ function he(o = 1) {
1046
+ let e = "uint", t = "float", r = "", i = ".r", s = "1u";
1047
+ return o > 1 && (e = "uvec" + o, t = "vec" + o, r = o + "", o === 2 ? (i = ".rg", s = "uvec2( 1u, 2u )") : o === 3 ? (i = ".rgb", s = "uvec3( 1u, 2u, 3u )") : (i = "", s = "uvec4( 1u, 2u, 3u, 4u )")), /* glsl */
1048
1048
  `
1049
1049
 
1050
1050
  ${t} sobol${r}( int effect ) {
@@ -1057,7 +1057,7 @@ function fe(s = 1) {
1057
1057
  ${t} sobol_pt = sobolGetTexturePoint( shuffled_index )${i};
1058
1058
  ${e} result = ${e}( sobol_pt * 16777216.0 );
1059
1059
 
1060
- ${e} seed2 = sobolHashCombine( seed, ${o} );
1060
+ ${e} seed2 = sobolHashCombine( seed, ${s} );
1061
1061
  result = nestedUniformScrambleBase2( result, seed2 );
1062
1062
 
1063
1063
  return SOBOL_FACTOR * ${t}( result >> 8 );
@@ -1073,10 +1073,10 @@ const wt = (
1073
1073
  const float SOBOL_FACTOR = 1.0 / 16777216.0;
1074
1074
  const uint SOBOL_MAX_POINTS = 256u * 256u;
1075
1075
 
1076
- ${ue(1)}
1077
- ${ue(2)}
1078
- ${ue(3)}
1079
- ${ue(4)}
1076
+ ${fe(1)}
1077
+ ${fe(2)}
1078
+ ${fe(3)}
1079
+ ${fe(4)}
1080
1080
 
1081
1081
  uint sobolHash( uint x ) {
1082
1082
 
@@ -1091,7 +1091,7 @@ const wt = (
1091
1091
  }
1092
1092
 
1093
1093
  `
1094
- ), Er = (
1094
+ ), Or = (
1095
1095
  /* glsl */
1096
1096
  `
1097
1097
 
@@ -1212,19 +1212,19 @@ const wt = (
1212
1212
 
1213
1213
  }
1214
1214
 
1215
- ${fe(1)}
1216
- ${fe(2)}
1217
- ${fe(3)}
1218
- ${fe(4)}
1215
+ ${he(1)}
1216
+ ${he(2)}
1217
+ ${he(3)}
1218
+ ${he(4)}
1219
1219
 
1220
1220
  `
1221
1221
  );
1222
- class Or extends Pe {
1222
+ class Nr extends Pe {
1223
1223
  constructor() {
1224
1224
  super({
1225
- blending: ie,
1225
+ blending: se,
1226
1226
  uniforms: {
1227
- resolution: { value: new q() }
1227
+ resolution: { value: new X() }
1228
1228
  },
1229
1229
  vertexShader: (
1230
1230
  /* glsl */
@@ -1244,7 +1244,7 @@ class Or extends Pe {
1244
1244
  `
1245
1245
 
1246
1246
  ${wt}
1247
- ${Er}
1247
+ ${Or}
1248
1248
 
1249
1249
  varying vec2 vUv;
1250
1250
  uniform vec2 resolution;
@@ -1261,7 +1261,7 @@ class Or extends Pe {
1261
1261
  }
1262
1262
  class zr {
1263
1263
  generate(e, t = 256) {
1264
- const r = new ae(t, t, {
1264
+ const r = new ie(t, t, {
1265
1265
  type: R,
1266
1266
  format: I,
1267
1267
  minFilter: T,
@@ -1269,11 +1269,11 @@ class zr {
1269
1269
  generateMipmaps: !1
1270
1270
  }), i = e.getRenderTarget();
1271
1271
  e.setRenderTarget(r);
1272
- const o = new Z(new Or());
1273
- return o.material.resolution.set(t, t), o.render(e), e.setRenderTarget(i), o.dispose(), r;
1272
+ const s = new Y(new Nr());
1273
+ return s.material.resolution.set(t, t), s.render(e), e.setRenderTarget(i), s.dispose(), r;
1274
1274
  }
1275
1275
  }
1276
- class Nr extends dt {
1276
+ class Hr extends dt {
1277
1277
  set bokehSize(e) {
1278
1278
  this.fStop = this.getFocalLength() / e;
1279
1279
  }
@@ -1287,132 +1287,132 @@ class Nr extends dt {
1287
1287
  return super.copy(e, t), this.fStop = e.fStop, this.apertureBlades = e.apertureBlades, this.apertureRotation = e.apertureRotation, this.focusDistance = e.focusDistance, this.anamorphicRatio = e.anamorphicRatio, this;
1288
1288
  }
1289
1289
  }
1290
- class Hr {
1290
+ class Br {
1291
1291
  constructor() {
1292
1292
  this.bokehSize = 0, this.apertureBlades = 0, this.apertureRotation = 0, this.focusDistance = 10, this.anamorphicRatio = 1;
1293
1293
  }
1294
1294
  updateFrom(e) {
1295
- e instanceof Nr ? (this.bokehSize = e.bokehSize, this.apertureBlades = e.apertureBlades, this.apertureRotation = e.apertureRotation, this.focusDistance = e.focusDistance, this.anamorphicRatio = e.anamorphicRatio) : (this.bokehSize = 0, this.apertureRotation = 0, this.apertureBlades = 0, this.focusDistance = 10, this.anamorphicRatio = 1);
1295
+ e instanceof Hr ? (this.bokehSize = e.bokehSize, this.apertureBlades = e.apertureBlades, this.apertureRotation = e.apertureRotation, this.focusDistance = e.focusDistance, this.anamorphicRatio = e.anamorphicRatio) : (this.bokehSize = 0, this.apertureRotation = 0, this.apertureBlades = 0, this.focusDistance = 10, this.anamorphicRatio = 1);
1296
1296
  }
1297
1297
  }
1298
- function Se(s) {
1299
- const e = new Uint16Array(s.length);
1300
- for (let t = 0, r = s.length; t < r; ++t)
1301
- e[t] = k.toHalfFloat(s[t]);
1298
+ function _e(o) {
1299
+ const e = new Uint16Array(o.length);
1300
+ for (let t = 0, r = o.length; t < r; ++t)
1301
+ e[t] = N.toHalfFloat(o[t]);
1302
1302
  return e;
1303
1303
  }
1304
- function Xe(s, e, t = 0, r = s.length) {
1305
- let i = t, o = t + r - 1;
1306
- for (; i < o; ) {
1307
- const a = i + o >> 1;
1308
- s[a] < e ? i = a + 1 : o = a;
1304
+ function Xe(o, e, t = 0, r = o.length) {
1305
+ let i = t, s = t + r - 1;
1306
+ for (; i < s; ) {
1307
+ const a = i + s >> 1;
1308
+ o[a] < e ? i = a + 1 : s = a;
1309
1309
  }
1310
1310
  return i - t;
1311
1311
  }
1312
- function Br(s, e, t) {
1313
- return 0.2126 * s + 0.7152 * e + 0.0722 * t;
1312
+ function Wr(o, e, t) {
1313
+ return 0.2126 * o + 0.7152 * e + 0.0722 * t;
1314
1314
  }
1315
- function Wr(s, e = D) {
1316
- const t = s.clone();
1315
+ function Lr(o, e = E) {
1316
+ const t = o.clone();
1317
1317
  t.source = new Et({ ...t.image });
1318
- const { width: r, height: i, data: o } = t.image;
1319
- let a = o;
1318
+ const { width: r, height: i, data: s } = t.image;
1319
+ let a = s;
1320
1320
  if (t.type !== e) {
1321
- e === D ? a = new Uint16Array(o.length) : a = new Float32Array(o.length);
1321
+ e === E ? a = new Uint16Array(s.length) : a = new Float32Array(s.length);
1322
1322
  let l;
1323
- o instanceof Int8Array || o instanceof Int16Array || o instanceof Int32Array ? l = 2 ** (8 * o.BYTES_PER_ELEMENT - 1) - 1 : l = 2 ** (8 * o.BYTES_PER_ELEMENT) - 1;
1324
- for (let f = 0, d = o.length; f < d; f++) {
1325
- let h = o[f];
1326
- t.type === D && (h = k.fromHalfFloat(o[f])), t.type !== R && t.type !== D && (h /= l), e === D && (a[f] = k.toHalfFloat(h));
1323
+ s instanceof Int8Array || s instanceof Int16Array || s instanceof Int32Array ? l = 2 ** (8 * s.BYTES_PER_ELEMENT - 1) - 1 : l = 2 ** (8 * s.BYTES_PER_ELEMENT) - 1;
1324
+ for (let u = 0, d = s.length; u < d; u++) {
1325
+ let h = s[u];
1326
+ t.type === E && (h = N.fromHalfFloat(s[u])), t.type !== R && t.type !== E && (h /= l), e === E && (a[u] = N.toHalfFloat(h));
1327
1327
  }
1328
1328
  t.image.data = a, t.type = e;
1329
1329
  }
1330
1330
  if (t.flipY) {
1331
1331
  const l = a;
1332
1332
  a = a.slice();
1333
- for (let f = 0; f < i; f++)
1333
+ for (let u = 0; u < i; u++)
1334
1334
  for (let d = 0; d < r; d++) {
1335
- const h = i - f - 1, u = 4 * (f * r + d), n = 4 * (h * r + d);
1336
- a[n + 0] = l[u + 0], a[n + 1] = l[u + 1], a[n + 2] = l[u + 2], a[n + 3] = l[u + 3];
1335
+ const h = i - u - 1, f = 4 * (u * r + d), n = 4 * (h * r + d);
1336
+ a[n + 0] = l[f + 0], a[n + 1] = l[f + 1], a[n + 2] = l[f + 2], a[n + 3] = l[f + 3];
1337
1337
  }
1338
1338
  t.flipY = !1, t.image.data = a;
1339
1339
  }
1340
1340
  return t;
1341
1341
  }
1342
- class Lr {
1342
+ class Ur {
1343
1343
  constructor() {
1344
- const e = new M(Se(new Float32Array([0, 0, 0, 0])), 1, 1);
1345
- e.type = D, e.format = I, e.minFilter = C, e.magFilter = C, e.wrapS = z, e.wrapT = z, e.generateMipmaps = !1, e.needsUpdate = !0;
1346
- const t = new M(Se(new Float32Array([0, 1])), 1, 2);
1347
- t.type = D, t.format = me, t.minFilter = C, t.magFilter = C, t.generateMipmaps = !1, t.needsUpdate = !0;
1348
- const r = new M(Se(new Float32Array([0, 0, 1, 1])), 2, 2);
1349
- r.type = D, r.format = me, r.minFilter = C, r.magFilter = C, r.generateMipmaps = !1, r.needsUpdate = !0, this.map = e, this.marginalWeights = t, this.conditionalWeights = r, this.totalSum = 0;
1344
+ const e = new F(_e(new Float32Array([0, 0, 0, 0])), 1, 1);
1345
+ e.type = E, e.format = I, e.minFilter = D, e.magFilter = D, e.wrapS = H, e.wrapT = H, e.generateMipmaps = !1, e.needsUpdate = !0;
1346
+ const t = new F(_e(new Float32Array([0, 1])), 1, 2);
1347
+ t.type = E, t.format = pe, t.minFilter = D, t.magFilter = D, t.generateMipmaps = !1, t.needsUpdate = !0;
1348
+ const r = new F(_e(new Float32Array([0, 0, 1, 1])), 2, 2);
1349
+ r.type = E, r.format = pe, r.minFilter = D, r.magFilter = D, r.generateMipmaps = !1, r.needsUpdate = !0, this.map = e, this.marginalWeights = t, this.conditionalWeights = r, this.totalSum = 0;
1350
1350
  }
1351
1351
  dispose() {
1352
1352
  this.marginalWeights.dispose(), this.conditionalWeights.dispose(), this.map.dispose();
1353
1353
  }
1354
1354
  updateFrom(e) {
1355
- const t = Wr(e);
1356
- t.wrapS = z, t.wrapT = N;
1357
- const { width: r, height: i, data: o } = t.image, a = new Float32Array(r * i), l = new Float32Array(r * i), f = new Float32Array(i), d = new Float32Array(i);
1358
- let h = 0, u = 0;
1355
+ const t = Lr(e);
1356
+ t.wrapS = H, t.wrapT = B;
1357
+ const { width: r, height: i, data: s } = t.image, a = new Float32Array(r * i), l = new Float32Array(r * i), u = new Float32Array(i), d = new Float32Array(i);
1358
+ let h = 0, f = 0;
1359
1359
  for (let c = 0; c < i; c++) {
1360
1360
  let p = 0;
1361
1361
  for (let v = 0; v < r; v++) {
1362
- const b = c * r + v, y = k.fromHalfFloat(o[4 * b + 0]), w = k.fromHalfFloat(o[4 * b + 1]), E = k.fromHalfFloat(o[4 * b + 2]), H = Br(y, w, E);
1363
- p += H, h += H, a[b] = H, l[b] = p;
1362
+ const b = c * r + v, y = N.fromHalfFloat(s[4 * b + 0]), w = N.fromHalfFloat(s[4 * b + 1]), k = N.fromHalfFloat(s[4 * b + 2]), W = Wr(y, w, k);
1363
+ p += W, h += W, a[b] = W, l[b] = p;
1364
1364
  }
1365
1365
  if (p !== 0)
1366
1366
  for (let v = c * r, b = c * r + r; v < b; v++)
1367
1367
  a[v] /= p, l[v] /= p;
1368
- u += p, f[c] = p, d[c] = u;
1368
+ f += p, u[c] = p, d[c] = f;
1369
1369
  }
1370
- if (u !== 0)
1371
- for (let c = 0, p = f.length; c < p; c++)
1372
- f[c] /= u, d[c] /= u;
1370
+ if (f !== 0)
1371
+ for (let c = 0, p = u.length; c < p; c++)
1372
+ u[c] /= f, d[c] /= f;
1373
1373
  const n = new Uint16Array(i), x = new Uint16Array(r * i);
1374
1374
  for (let c = 0; c < i; c++) {
1375
1375
  const p = (c + 1) / i, v = Xe(d, p);
1376
- n[c] = k.toHalfFloat((v + 0.5) / i);
1376
+ n[c] = N.toHalfFloat((v + 0.5) / i);
1377
1377
  }
1378
1378
  for (let c = 0; c < i; c++)
1379
1379
  for (let p = 0; p < r; p++) {
1380
1380
  const v = c * r + p, b = (p + 1) / r, y = Xe(l, b, c * r, r);
1381
- x[v] = k.toHalfFloat((y + 0.5) / r);
1381
+ x[v] = N.toHalfFloat((y + 0.5) / r);
1382
1382
  }
1383
1383
  this.dispose();
1384
1384
  const { marginalWeights: m, conditionalWeights: g } = this;
1385
1385
  m.image = { width: i, height: 1, data: n }, m.needsUpdate = !0, g.image = { width: r, height: i, data: x }, g.needsUpdate = !0, this.totalSum = h, this.map = t;
1386
1386
  }
1387
1387
  }
1388
- const _e = 6, Ur = 0, Vr = 1, Gr = 2, qr = 3, $r = 4, A = new F(), _ = new F(), Qe = new O(), $ = new kt(), Ke = new F(), j = new F(), jr = new F(0, 1, 0);
1389
- class Yr {
1388
+ const Se = 6, Gr = 0, Vr = 1, qr = 2, $r = 3, jr = 4, C = new P(), A = new P(), Qe = new z(), Q = new Ot(), Ke = new P(), K = new P(), Yr = new P(0, 1, 0);
1389
+ class Xr {
1390
1390
  constructor() {
1391
- const e = new M(new Float32Array(4), 1, 1);
1392
- e.format = I, e.type = R, e.wrapS = N, e.wrapT = N, e.generateMipmaps = !1, e.minFilter = T, e.magFilter = T, this.tex = e, this.count = 0;
1391
+ const e = new F(new Float32Array(4), 1, 1);
1392
+ e.format = I, e.type = R, e.wrapS = B, e.wrapT = B, e.generateMipmaps = !1, e.minFilter = T, e.magFilter = T, this.tex = e, this.count = 0;
1393
1393
  }
1394
1394
  updateFrom(e, t = []) {
1395
- const r = this.tex, i = Math.max(e.length * _e, 1), o = Math.ceil(Math.sqrt(i));
1396
- r.image.width !== o && (r.dispose(), r.image.data = new Float32Array(o * o * 4), r.image.width = o, r.image.height = o);
1395
+ const r = this.tex, i = Math.max(e.length * Se, 1), s = Math.ceil(Math.sqrt(i));
1396
+ r.image.width !== s && (r.dispose(), r.image.data = new Float32Array(s * s * 4), r.image.width = s, r.image.height = s);
1397
1397
  const a = r.image.data;
1398
- for (let f = 0, d = e.length; f < d; f++) {
1399
- const h = e[f], u = f * _e * 4;
1398
+ for (let u = 0, d = e.length; u < d; u++) {
1399
+ const h = e[u], f = u * Se * 4;
1400
1400
  let n = 0;
1401
- for (let m = 0; m < _e * 4; m++)
1402
- a[u + m] = 0;
1403
- h.getWorldPosition(_), a[u + n++] = _.x, a[u + n++] = _.y, a[u + n++] = _.z;
1404
- let x = Ur;
1405
- if (h.isRectAreaLight && h.isCircular ? x = Vr : h.isSpotLight ? x = Gr : h.isDirectionalLight ? x = qr : h.isPointLight && (x = $r), a[u + n++] = x, a[u + n++] = h.color.r, a[u + n++] = h.color.g, a[u + n++] = h.color.b, a[u + n++] = h.intensity, h.getWorldQuaternion($), h.isRectAreaLight)
1406
- A.set(h.width, 0, 0).applyQuaternion($), a[u + n++] = A.x, a[u + n++] = A.y, a[u + n++] = A.z, n++, _.set(0, h.height, 0).applyQuaternion($), a[u + n++] = _.x, a[u + n++] = _.y, a[u + n++] = _.z, a[u + n++] = A.cross(_).length() * (h.isCircular ? Math.PI / 4 : 1);
1401
+ for (let m = 0; m < Se * 4; m++)
1402
+ a[f + m] = 0;
1403
+ h.getWorldPosition(A), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z;
1404
+ let x = Gr;
1405
+ if (h.isRectAreaLight && h.isCircular ? x = Vr : h.isSpotLight ? x = qr : h.isDirectionalLight ? x = $r : h.isPointLight && (x = jr), a[f + n++] = x, a[f + n++] = h.color.r, a[f + n++] = h.color.g, a[f + n++] = h.color.b, a[f + n++] = h.intensity, h.getWorldQuaternion(Q), h.isRectAreaLight)
1406
+ C.set(h.width, 0, 0).applyQuaternion(Q), a[f + n++] = C.x, a[f + n++] = C.y, a[f + n++] = C.z, n++, A.set(0, h.height, 0).applyQuaternion(Q), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z, a[f + n++] = C.cross(A).length() * (h.isCircular ? Math.PI / 4 : 1);
1407
1407
  else if (h.isSpotLight) {
1408
1408
  const m = h.radius || 0;
1409
- Ke.setFromMatrixPosition(h.matrixWorld), j.setFromMatrixPosition(h.target.matrixWorld), Qe.lookAt(Ke, j, jr), $.setFromRotationMatrix(Qe), A.set(1, 0, 0).applyQuaternion($), a[u + n++] = A.x, a[u + n++] = A.y, a[u + n++] = A.z, n++, _.set(0, 1, 0).applyQuaternion($), a[u + n++] = _.x, a[u + n++] = _.y, a[u + n++] = _.z, a[u + n++] = Math.PI * m * m, a[u + n++] = m, a[u + n++] = h.decay, a[u + n++] = h.distance, a[u + n++] = Math.cos(h.angle), a[u + n++] = Math.cos(h.angle * (1 - h.penumbra)), a[u + n++] = h.iesMap ? t.indexOf(h.iesMap) : -1;
1409
+ Ke.setFromMatrixPosition(h.matrixWorld), K.setFromMatrixPosition(h.target.matrixWorld), Qe.lookAt(Ke, K, Yr), Q.setFromRotationMatrix(Qe), C.set(1, 0, 0).applyQuaternion(Q), a[f + n++] = C.x, a[f + n++] = C.y, a[f + n++] = C.z, n++, A.set(0, 1, 0).applyQuaternion(Q), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z, a[f + n++] = Math.PI * m * m, a[f + n++] = m, a[f + n++] = h.decay, a[f + n++] = h.distance, a[f + n++] = Math.cos(h.angle), a[f + n++] = Math.cos(h.angle * (1 - h.penumbra)), a[f + n++] = h.iesMap ? t.indexOf(h.iesMap) : -1;
1410
1410
  } else if (h.isPointLight) {
1411
- const m = A.setFromMatrixPosition(h.matrixWorld);
1412
- a[u + n++] = m.x, a[u + n++] = m.y, a[u + n++] = m.z, n++, n += 4, n += 1, a[u + n++] = h.decay, a[u + n++] = h.distance;
1411
+ const m = C.setFromMatrixPosition(h.matrixWorld);
1412
+ a[f + n++] = m.x, a[f + n++] = m.y, a[f + n++] = m.z, n++, n += 4, n += 1, a[f + n++] = h.decay, a[f + n++] = h.distance;
1413
1413
  } else if (h.isDirectionalLight) {
1414
- const m = A.setFromMatrixPosition(h.matrixWorld), g = _.setFromMatrixPosition(h.target.matrixWorld);
1415
- j.subVectors(m, g).normalize(), a[u + n++] = j.x, a[u + n++] = j.y, a[u + n++] = j.z;
1414
+ const m = C.setFromMatrixPosition(h.matrixWorld), g = A.setFromMatrixPosition(h.target.matrixWorld);
1415
+ K.subVectors(m, g).normalize(), a[f + n++] = K.x, a[f + n++] = K.y, a[f + n++] = K.z;
1416
1416
  }
1417
1417
  }
1418
1418
  this.count = e.length;
@@ -1420,12 +1420,12 @@ class Yr {
1420
1420
  return this.hash !== l ? (this.hash = l, r.needsUpdate = !0, !0) : !1;
1421
1421
  }
1422
1422
  }
1423
- function Ze(s, e, t, r, i) {
1423
+ function Ze(o, e, t, r, i) {
1424
1424
  if (e > r)
1425
1425
  throw new Error();
1426
- const o = s.length / e, a = s.constructor.BYTES_PER_ELEMENT * 8;
1426
+ const s = o.length / e, a = o.constructor.BYTES_PER_ELEMENT * 8;
1427
1427
  let l = 1;
1428
- switch (s.constructor) {
1428
+ switch (o.constructor) {
1429
1429
  case Uint8Array:
1430
1430
  case Uint16Array:
1431
1431
  case Uint32Array:
@@ -1437,52 +1437,52 @@ function Ze(s, e, t, r, i) {
1437
1437
  l = 2 ** (a - 1) - 1;
1438
1438
  break;
1439
1439
  }
1440
- for (let f = 0; f < o; f++) {
1441
- const d = 4 * f, h = e * f;
1442
- for (let u = 0; u < r; u++)
1443
- t[i + d + u] = e >= u + 1 ? s[h + u] / l : 0;
1440
+ for (let u = 0; u < s; u++) {
1441
+ const d = 4 * u, h = e * u;
1442
+ for (let f = 0; f < r; f++)
1443
+ t[i + d + f] = e >= f + 1 ? o[h + f] / l : 0;
1444
1444
  }
1445
1445
  }
1446
- class Xr extends Ot {
1446
+ class Qr extends kt {
1447
1447
  constructor() {
1448
1448
  super(), this._textures = [], this.type = R, this.format = I, this.internalFormat = "RGBA32F";
1449
1449
  }
1450
1450
  updateAttribute(e, t) {
1451
1451
  const r = this._textures[e];
1452
1452
  r.updateFrom(t);
1453
- const i = r.image, o = this.image;
1454
- if (i.width !== o.width || i.height !== o.height)
1453
+ const i = r.image, s = this.image;
1454
+ if (i.width !== s.width || i.height !== s.height)
1455
1455
  throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");
1456
- const { width: a, height: l, data: f } = o, h = a * l * 4 * e;
1457
- let u = t.itemSize;
1458
- u === 3 && (u = 4), Ze(r.image.data, u, f, 4, h), this.dispose(), this.needsUpdate = !0;
1456
+ const { width: a, height: l, data: u } = s, h = a * l * 4 * e;
1457
+ let f = t.itemSize;
1458
+ f === 3 && (f = 4), Ze(r.image.data, f, u, 4, h), this.dispose(), this.needsUpdate = !0;
1459
1459
  }
1460
1460
  setAttributes(e) {
1461
1461
  const t = e[0].count, r = e.length;
1462
- for (let u = 0, n = r; u < n; u++)
1463
- if (e[u].count !== t)
1462
+ for (let f = 0, n = r; f < n; f++)
1463
+ if (e[f].count !== t)
1464
1464
  throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");
1465
1465
  const i = this._textures;
1466
1466
  for (; i.length < r; ) {
1467
- const u = new xt();
1468
- i.push(u);
1467
+ const f = new xt();
1468
+ i.push(f);
1469
1469
  }
1470
1470
  for (; i.length > r; )
1471
1471
  i.pop();
1472
- for (let u = 0, n = r; u < n; u++)
1473
- i[u].updateFrom(e[u]);
1472
+ for (let f = 0, n = r; f < n; f++)
1473
+ i[f].updateFrom(e[f]);
1474
1474
  const a = i[0].image, l = this.image;
1475
1475
  (a.width !== l.width || a.height !== l.height || a.depth !== r) && (l.width = a.width, l.height = a.height, l.depth = r, l.data = new Float32Array(l.width * l.height * l.depth * 4));
1476
- const { data: f, width: d, height: h } = l;
1477
- for (let u = 0, n = r; u < n; u++) {
1478
- const x = i[u], g = d * h * 4 * u;
1479
- let c = e[u].itemSize;
1480
- c === 3 && (c = 4), Ze(x.image.data, c, f, 4, g);
1476
+ const { data: u, width: d, height: h } = l;
1477
+ for (let f = 0, n = r; f < n; f++) {
1478
+ const x = i[f], g = d * h * 4 * f;
1479
+ let c = e[f].itemSize;
1480
+ c === 3 && (c = 4), Ze(x.image.data, c, u, 4, g);
1481
1481
  }
1482
1482
  this.dispose(), this.needsUpdate = !0;
1483
1483
  }
1484
1484
  }
1485
- class Qr extends Xr {
1485
+ class Kr extends Qr {
1486
1486
  updateNormalAttribute(e) {
1487
1487
  this.updateAttribute(0, e);
1488
1488
  }
@@ -1499,44 +1499,44 @@ class Qr extends Xr {
1499
1499
  this.setAttributes([e, t, r, i]);
1500
1500
  }
1501
1501
  }
1502
- function Ee(s, e) {
1503
- return s.uuid < e.uuid ? 1 : s.uuid > e.uuid ? -1 : 0;
1502
+ function Ee(o, e) {
1503
+ return o.uuid < e.uuid ? 1 : o.uuid > e.uuid ? -1 : 0;
1504
1504
  }
1505
- function Fe(s) {
1506
- return `${s.source.uuid}:${s.colorSpace}`;
1505
+ function Ce(o) {
1506
+ return `${o.source.uuid}:${o.colorSpace}`;
1507
1507
  }
1508
- function Kr(s) {
1508
+ function Zr(o) {
1509
1509
  const e = /* @__PURE__ */ new Set(), t = [];
1510
- for (let r = 0, i = s.length; r < i; r++) {
1511
- const o = s[r], a = Fe(o);
1512
- e.has(a) || (e.add(a), t.push(o));
1510
+ for (let r = 0, i = o.length; r < i; r++) {
1511
+ const s = o[r], a = Ce(s);
1512
+ e.has(a) || (e.add(a), t.push(s));
1513
1513
  }
1514
1514
  return t;
1515
1515
  }
1516
- function Zr(s) {
1517
- const e = s.map((r) => r.iesMap || null).filter((r) => r), t = new Set(e);
1516
+ function Jr(o) {
1517
+ const e = o.map((r) => r.iesMap || null).filter((r) => r), t = new Set(e);
1518
1518
  return Array.from(t).sort(Ee);
1519
1519
  }
1520
- function Jr(s) {
1520
+ function ea(o) {
1521
1521
  const e = /* @__PURE__ */ new Set();
1522
- for (let r = 0, i = s.length; r < i; r++) {
1523
- const o = s[r];
1524
- for (const a in o) {
1525
- const l = o[a];
1522
+ for (let r = 0, i = o.length; r < i; r++) {
1523
+ const s = o[r];
1524
+ for (const a in s) {
1525
+ const l = s[a];
1526
1526
  l && l.isTexture && e.add(l);
1527
1527
  }
1528
1528
  }
1529
1529
  const t = Array.from(e);
1530
- return Kr(t).sort(Ee);
1530
+ return Zr(t).sort(Ee);
1531
1531
  }
1532
- function ea(s) {
1532
+ function ta(o) {
1533
1533
  const e = [];
1534
- return s.traverse((t) => {
1534
+ return o.traverse((t) => {
1535
1535
  t.visible && (t.isRectAreaLight || t.isSpotLight || t.isPointLight || t.isDirectionalLight) && e.push(t);
1536
1536
  }), e.sort(Ee);
1537
1537
  }
1538
1538
  const It = 45, Je = It * 4;
1539
- class ta {
1539
+ class ra {
1540
1540
  constructor() {
1541
1541
  this._features = {};
1542
1542
  }
@@ -1550,22 +1550,22 @@ class ta {
1550
1550
  this._features = {};
1551
1551
  }
1552
1552
  }
1553
- class ra extends M {
1553
+ class aa extends F {
1554
1554
  constructor() {
1555
- super(new Float32Array(4), 1, 1), this.format = I, this.type = R, this.wrapS = N, this.wrapT = N, this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.features = new ta();
1555
+ super(new Float32Array(4), 1, 1), this.format = I, this.type = R, this.wrapS = B, this.wrapT = B, this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.features = new ra();
1556
1556
  }
1557
1557
  updateFrom(e, t) {
1558
1558
  function r(m, g, c = -1) {
1559
1559
  if (g in m && m[g]) {
1560
- const p = Fe(m[g]);
1561
- return u[p];
1560
+ const p = Ce(m[g]);
1561
+ return f[p];
1562
1562
  } else
1563
1563
  return c;
1564
1564
  }
1565
1565
  function i(m, g, c) {
1566
1566
  return g in m ? m[g] : c;
1567
1567
  }
1568
- function o(m, g, c, p) {
1568
+ function s(m, g, c, p) {
1569
1569
  const v = m[g] && m[g].isTexture ? m[g] : null;
1570
1570
  if (v) {
1571
1571
  v.matrixAutoUpdate && v.updateMatrix();
@@ -1576,10 +1576,10 @@ class ra extends M {
1576
1576
  return 8;
1577
1577
  }
1578
1578
  let a = 0;
1579
- const l = e.length * It, f = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: h } = this, u = {};
1579
+ const l = e.length * It, u = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: h } = this, f = {};
1580
1580
  for (let m = 0, g = t.length; m < g; m++)
1581
- u[Fe(t[m])] = m;
1582
- d.width !== f && (this.dispose(), d.data = new Float32Array(f * f * 4), d.width = f, d.height = f);
1581
+ f[Ce(t[m])] = m;
1582
+ d.width !== u && (this.dispose(), d.data = new Float32Array(u * u * 4), d.width = u, d.height = u);
1583
1583
  const n = d.data;
1584
1584
  h.reset();
1585
1585
  for (let m = 0, g = e.length; m < g; m++) {
@@ -1602,63 +1602,63 @@ class ra extends M {
1602
1602
  case Ht:
1603
1603
  n[a++] = 1;
1604
1604
  break;
1605
- case Nt:
1605
+ case zt:
1606
1606
  n[a++] = -1;
1607
1607
  break;
1608
- case zt:
1608
+ case Nt:
1609
1609
  n[a++] = 0;
1610
1610
  break;
1611
1611
  }
1612
- n[a++] = Number(i(c, "matte", !1)), n[a++] = Number(i(c, "castShadow", !0)), n[a++] = Number(c.vertexColors) | Number(c.flatShading) << 1, n[a++] = Number(c.transparent), a += o(c, "map", n, a), a += o(c, "metalnessMap", n, a), a += o(c, "roughnessMap", n, a), a += o(c, "transmissionMap", n, a), a += o(c, "emissiveMap", n, a), a += o(c, "normalMap", n, a), a += o(c, "clearcoatMap", n, a), a += o(c, "clearcoatNormalMap", n, a), a += o(c, "clearcoatRoughnessMap", n, a), a += o(c, "sheenColorMap", n, a), a += o(c, "sheenRoughnessMap", n, a), a += o(c, "iridescenceMap", n, a), a += o(c, "iridescenceThicknessMap", n, a), a += o(c, "specularColorMap", n, a), a += o(c, "specularIntensityMap", n, a);
1612
+ n[a++] = Number(i(c, "matte", !1)), n[a++] = Number(i(c, "castShadow", !0)), n[a++] = Number(c.vertexColors) | Number(c.flatShading) << 1, n[a++] = Number(c.transparent), a += s(c, "map", n, a), a += s(c, "metalnessMap", n, a), a += s(c, "roughnessMap", n, a), a += s(c, "transmissionMap", n, a), a += s(c, "emissiveMap", n, a), a += s(c, "normalMap", n, a), a += s(c, "clearcoatMap", n, a), a += s(c, "clearcoatNormalMap", n, a), a += s(c, "clearcoatRoughnessMap", n, a), a += s(c, "sheenColorMap", n, a), a += s(c, "sheenRoughnessMap", n, a), a += s(c, "iridescenceMap", n, a), a += s(c, "iridescenceThicknessMap", n, a), a += s(c, "specularColorMap", n, a), a += s(c, "specularIntensityMap", n, a);
1613
1613
  }
1614
1614
  const x = De(n.buffer);
1615
1615
  return this.hash !== x ? (this.hash = x, this.needsUpdate = !0, !0) : !1;
1616
1616
  }
1617
1617
  }
1618
- const et = new se();
1619
- function aa(s) {
1620
- return s ? `${s.uuid}:${s.version}` : null;
1618
+ const et = new oe();
1619
+ function ia(o) {
1620
+ return o ? `${o.uuid}:${o.version}` : null;
1621
1621
  }
1622
- function ia(s, e) {
1622
+ function sa(o, e) {
1623
1623
  for (const t in e)
1624
- t in s && (s[t] = e[t]);
1624
+ t in o && (o[t] = e[t]);
1625
1625
  }
1626
1626
  class tt extends Bt {
1627
1627
  constructor(e, t, r) {
1628
1628
  const i = {
1629
1629
  format: I,
1630
1630
  type: Me,
1631
- minFilter: C,
1632
- magFilter: C,
1633
- wrapS: z,
1634
- wrapT: z,
1631
+ minFilter: D,
1632
+ magFilter: D,
1633
+ wrapS: H,
1634
+ wrapT: H,
1635
1635
  generateMipmaps: !1,
1636
1636
  ...r
1637
1637
  };
1638
- super(e, t, 1, i), ia(this.texture, i), this.texture.setTextures = (...a) => {
1638
+ super(e, t, 1, i), sa(this.texture, i), this.texture.setTextures = (...a) => {
1639
1639
  this.setTextures(...a);
1640
1640
  }, this.hashes = [null];
1641
- const o = new Z(new sa());
1642
- this.fsQuad = o;
1641
+ const s = new Y(new oa());
1642
+ this.fsQuad = s;
1643
1643
  }
1644
1644
  setTextures(e, t, r = this.width, i = this.height) {
1645
- const o = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
1645
+ const s = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
1646
1646
  e.getClearColor(et);
1647
- const f = t.length || 1;
1648
- (r !== this.width || i !== this.height || this.depth !== f) && (this.setSize(r, i, f), this.hashes = new Array(f).fill(null)), e.setClearColor(0, 0), e.toneMapping = Wt;
1647
+ const u = t.length || 1;
1648
+ (r !== this.width || i !== this.height || this.depth !== u) && (this.setSize(r, i, u), this.hashes = new Array(u).fill(null)), e.setClearColor(0, 0), e.toneMapping = Wt;
1649
1649
  const d = this.fsQuad, h = this.hashes;
1650
- let u = !1;
1651
- for (let n = 0, x = f; n < x; n++) {
1652
- const m = t[n], g = aa(m);
1653
- m && (h[n] !== g || m.isWebGLRenderTarget) && (m.matrixAutoUpdate = !1, m.matrix.identity(), d.material.map = m, e.setRenderTarget(this, n), d.render(e), m.updateMatrix(), m.matrixAutoUpdate = !0, h[n] = g, u = !0);
1650
+ let f = !1;
1651
+ for (let n = 0, x = u; n < x; n++) {
1652
+ const m = t[n], g = ia(m);
1653
+ m && (h[n] !== g || m.isWebGLRenderTarget) && (m.matrixAutoUpdate = !1, m.matrix.identity(), d.material.map = m, e.setRenderTarget(this, n), d.render(e), m.updateMatrix(), m.matrixAutoUpdate = !0, h[n] = g, f = !0);
1654
1654
  }
1655
- return d.material.map = null, e.setClearColor(et, l), e.setRenderTarget(o), e.toneMapping = a, u;
1655
+ return d.material.map = null, e.setClearColor(et, l), e.setRenderTarget(s), e.toneMapping = a, f;
1656
1656
  }
1657
1657
  dispose() {
1658
1658
  super.dispose(), this.fsQuad.dispose();
1659
1659
  }
1660
1660
  }
1661
- class sa extends ge {
1661
+ class oa extends ge {
1662
1662
  get map() {
1663
1663
  return this.uniforms.map.value;
1664
1664
  }
@@ -1697,60 +1697,60 @@ class sa extends ge {
1697
1697
  });
1698
1698
  }
1699
1699
  }
1700
- function oa(s, e = Math.random()) {
1701
- for (let t = s.length - 1; t > 0; t--) {
1702
- const r = Math.floor(e() * (t + 1)), i = s[t];
1703
- s[t] = s[r], s[r] = i;
1700
+ function na(o, e = Math.random()) {
1701
+ for (let t = o.length - 1; t > 0; t--) {
1702
+ const r = Math.floor(e() * (t + 1)), i = o[t];
1703
+ o[t] = o[r], o[r] = i;
1704
1704
  }
1705
- return s;
1705
+ return o;
1706
1706
  }
1707
- class na {
1707
+ class la {
1708
1708
  constructor(e, t, r = Math.random) {
1709
- const i = e ** t, o = new Uint16Array(i);
1709
+ const i = e ** t, s = new Uint16Array(i);
1710
1710
  let a = i;
1711
1711
  for (let l = 0; l < i; l++)
1712
- o[l] = l;
1712
+ s[l] = l;
1713
1713
  this.samples = new Float32Array(t), this.strataCount = e, this.reset = function() {
1714
1714
  for (let l = 0; l < i; l++)
1715
- o[l] = l;
1715
+ s[l] = l;
1716
1716
  a = 0;
1717
1717
  }, this.reshuffle = function() {
1718
1718
  a = 0;
1719
1719
  }, this.next = function() {
1720
1720
  const { samples: l } = this;
1721
- a >= o.length && (oa(o, r), this.reshuffle());
1722
- let f = o[a++];
1721
+ a >= s.length && (na(s, r), this.reshuffle());
1722
+ let u = s[a++];
1723
1723
  for (let d = 0; d < t; d++)
1724
- l[d] = (f % e + r()) / e, f = Math.floor(f / e);
1724
+ l[d] = (u % e + r()) / e, u = Math.floor(u / e);
1725
1725
  return l;
1726
1726
  };
1727
1727
  }
1728
1728
  }
1729
- class la {
1729
+ class ca {
1730
1730
  constructor(e, t, r = Math.random) {
1731
1731
  let i = 0;
1732
- for (const f of t)
1733
- i += f;
1734
- const o = new Float32Array(i), a = [];
1732
+ for (const u of t)
1733
+ i += u;
1734
+ const s = new Float32Array(i), a = [];
1735
1735
  let l = 0;
1736
- for (const f of t) {
1737
- const d = new na(e, f, r);
1738
- d.samples = new Float32Array(o.buffer, l, d.samples.length), l += d.samples.length * 4, a.push(d);
1736
+ for (const u of t) {
1737
+ const d = new la(e, u, r);
1738
+ d.samples = new Float32Array(s.buffer, l, d.samples.length), l += d.samples.length * 4, a.push(d);
1739
1739
  }
1740
- this.samples = o, this.strataCount = e, this.next = function() {
1741
- for (const f of a)
1742
- f.next();
1743
- return o;
1740
+ this.samples = s, this.strataCount = e, this.next = function() {
1741
+ for (const u of a)
1742
+ u.next();
1743
+ return s;
1744
1744
  }, this.reshuffle = function() {
1745
- for (const f of a)
1746
- f.reshuffle();
1745
+ for (const u of a)
1746
+ u.reshuffle();
1747
1747
  }, this.reset = function() {
1748
- for (const f of a)
1749
- f.reset();
1748
+ for (const u of a)
1749
+ u.reset();
1750
1750
  };
1751
1751
  }
1752
1752
  }
1753
- class ca {
1753
+ class ua {
1754
1754
  constructor(e = 0) {
1755
1755
  this.m = 2147483648, this.a = 1103515245, this.c = 12345, this.seed = e;
1756
1756
  }
@@ -1761,15 +1761,15 @@ class ca {
1761
1761
  return this.nextInt() / (this.m - 1);
1762
1762
  }
1763
1763
  }
1764
- class ua extends M {
1764
+ class fa extends F {
1765
1765
  constructor(e = 1, t = 1, r = 8) {
1766
- super(new Float32Array(1), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.strata = r, this.sampler = null, this.generator = new ca(), this.stableNoise = !1, this.random = () => this.stableNoise ? this.generator.nextFloat() : Math.random(), this.init(e, t, r);
1766
+ super(new Float32Array(1), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.strata = r, this.sampler = null, this.generator = new ua(), this.stableNoise = !1, this.random = () => this.stableNoise ? this.generator.nextFloat() : Math.random(), this.init(e, t, r);
1767
1767
  }
1768
1768
  init(e = this.image.height, t = this.image.width, r = this.strata) {
1769
1769
  const { image: i } = this;
1770
1770
  if (i.width === t && i.height === e && this.sampler !== null)
1771
1771
  return;
1772
- const o = new Array(e * t).fill(4), a = new la(r, o, this.random);
1772
+ const s = new Array(e * t).fill(4), a = new ca(r, s, this.random);
1773
1773
  i.width = t, i.height = e, i.data = a.samples, this.sampler = a, this.dispose(), this.next();
1774
1774
  }
1775
1775
  next() {
@@ -1779,16 +1779,16 @@ class ua extends M {
1779
1779
  this.sampler.reset(), this.generator.seed = 0;
1780
1780
  }
1781
1781
  }
1782
- function fa(s, e = Math.random) {
1783
- for (let t = s.length - 1; t > 0; t--) {
1784
- const r = ~~((e() - 1e-6) * t), i = s[t];
1785
- s[t] = s[r], s[r] = i;
1782
+ function ha(o, e = Math.random) {
1783
+ for (let t = o.length - 1; t > 0; t--) {
1784
+ const r = ~~((e() - 1e-6) * t), i = o[t];
1785
+ o[t] = o[r], o[r] = i;
1786
1786
  }
1787
1787
  }
1788
- function ha(s, e) {
1789
- s.fill(0);
1788
+ function da(o, e) {
1789
+ o.fill(0);
1790
1790
  for (let t = 0; t < e; t++)
1791
- s[t] = 1;
1791
+ o[t] = 1;
1792
1792
  }
1793
1793
  class rt {
1794
1794
  constructor(e) {
@@ -1797,33 +1797,33 @@ class rt {
1797
1797
  findVoid() {
1798
1798
  const { score: e, binaryPattern: t } = this;
1799
1799
  let r = 1 / 0, i = -1;
1800
- for (let o = 0, a = t.length; o < a; o++) {
1801
- if (t[o] !== 0)
1800
+ for (let s = 0, a = t.length; s < a; s++) {
1801
+ if (t[s] !== 0)
1802
1802
  continue;
1803
- const l = e[o];
1804
- l < r && (r = l, i = o);
1803
+ const l = e[s];
1804
+ l < r && (r = l, i = s);
1805
1805
  }
1806
1806
  return i;
1807
1807
  }
1808
1808
  findCluster() {
1809
1809
  const { score: e, binaryPattern: t } = this;
1810
1810
  let r = -1 / 0, i = -1;
1811
- for (let o = 0, a = t.length; o < a; o++) {
1812
- if (t[o] !== 1)
1811
+ for (let s = 0, a = t.length; s < a; s++) {
1812
+ if (t[s] !== 1)
1813
1813
  continue;
1814
- const l = e[o];
1815
- l > r && (r = l, i = o);
1814
+ const l = e[s];
1815
+ l > r && (r = l, i = s);
1816
1816
  }
1817
1817
  return i;
1818
1818
  }
1819
1819
  setSigma(e) {
1820
1820
  if (e === this.sigma)
1821
1821
  return;
1822
- const t = ~~(Math.sqrt(20 * e ** 2) + 1), r = 2 * t + 1, i = new Float32Array(r * r), o = e * e;
1822
+ const t = ~~(Math.sqrt(20 * e ** 2) + 1), r = 2 * t + 1, i = new Float32Array(r * r), s = e * e;
1823
1823
  for (let a = -t; a <= t; a++)
1824
1824
  for (let l = -t; l <= t; l++) {
1825
- const f = (t + l) * r + a + t, d = a * a + l * l;
1826
- i[f] = Math.E ** (-d / (2 * o));
1825
+ const u = (t + l) * r + a + t, d = a * a + l * l;
1826
+ i[u] = Math.E ** (-d / (2 * s));
1827
1827
  }
1828
1828
  this.lookupTable = i, this.sigma = e, this.radius = t;
1829
1829
  }
@@ -1833,7 +1833,7 @@ class rt {
1833
1833
  invert() {
1834
1834
  const { binaryPattern: e, score: t, size: r } = this;
1835
1835
  t.fill(0);
1836
- for (let i = 0, o = e.length; i < o; i++)
1836
+ for (let i = 0, s = e.length; i < s; i++)
1837
1837
  if (e[i] === 0) {
1838
1838
  const a = ~~(i / r), l = i - a * r;
1839
1839
  this.updateScore(l, a, 1), e[i] = 1;
@@ -1841,16 +1841,16 @@ class rt {
1841
1841
  e[i] = 0;
1842
1842
  }
1843
1843
  updateScore(e, t, r) {
1844
- const { size: i, score: o, lookupTable: a } = this, l = this.radius, f = 2 * l + 1;
1844
+ const { size: i, score: s, lookupTable: a } = this, l = this.radius, u = 2 * l + 1;
1845
1845
  for (let d = -l; d <= l; d++)
1846
1846
  for (let h = -l; h <= l; h++) {
1847
- const u = (l + h) * f + d + l, n = a[u];
1847
+ const f = (l + h) * u + d + l, n = a[f];
1848
1848
  let x = e + d;
1849
1849
  x = x < 0 ? i + x : x % i;
1850
1850
  let m = t + h;
1851
1851
  m = m < 0 ? i + m : m % i;
1852
1852
  const g = m * i + x;
1853
- o[g] += r * n;
1853
+ s[g] += r * n;
1854
1854
  }
1855
1855
  }
1856
1856
  addPointIndex(e) {
@@ -1867,7 +1867,7 @@ class rt {
1867
1867
  this.resize(e.size), this.score.set(e.score), this.binaryPattern.set(e.binaryPattern), this.setSigma(e.sigma), this.count = e.count;
1868
1868
  }
1869
1869
  }
1870
- class da {
1870
+ class ma {
1871
1871
  constructor() {
1872
1872
  this.random = Math.random, this.sigma = 1.5, this.size = 64, this.majorityPointsRatio = 0.1, this.samples = new rt(1), this.savedSamples = new rt(1);
1873
1873
  }
@@ -1877,76 +1877,76 @@ class da {
1877
1877
  savedSamples: t,
1878
1878
  sigma: r,
1879
1879
  majorityPointsRatio: i,
1880
- size: o
1880
+ size: s
1881
1881
  } = this;
1882
- e.resize(o), e.setSigma(r);
1883
- const a = Math.floor(o * o * i), l = e.binaryPattern;
1884
- ha(l, a), fa(l, this.random);
1885
- for (let u = 0, n = l.length; u < n; u++)
1886
- l[u] === 1 && e.addPointIndex(u);
1882
+ e.resize(s), e.setSigma(r);
1883
+ const a = Math.floor(s * s * i), l = e.binaryPattern;
1884
+ da(l, a), ha(l, this.random);
1885
+ for (let f = 0, n = l.length; f < n; f++)
1886
+ l[f] === 1 && e.addPointIndex(f);
1887
1887
  for (; ; ) {
1888
- const u = e.findCluster();
1889
- e.removePointIndex(u);
1888
+ const f = e.findCluster();
1889
+ e.removePointIndex(f);
1890
1890
  const n = e.findVoid();
1891
- if (u === n) {
1892
- e.addPointIndex(u);
1891
+ if (f === n) {
1892
+ e.addPointIndex(f);
1893
1893
  break;
1894
1894
  }
1895
1895
  e.addPointIndex(n);
1896
1896
  }
1897
- const f = new Uint32Array(o * o);
1897
+ const u = new Uint32Array(s * s);
1898
1898
  t.copy(e);
1899
1899
  let d;
1900
1900
  for (d = e.count - 1; d >= 0; ) {
1901
- const u = e.findCluster();
1902
- e.removePointIndex(u), f[u] = d, d--;
1901
+ const f = e.findCluster();
1902
+ e.removePointIndex(f), u[f] = d, d--;
1903
1903
  }
1904
- const h = o * o;
1904
+ const h = s * s;
1905
1905
  for (d = t.count; d < h / 2; ) {
1906
- const u = t.findVoid();
1907
- t.addPointIndex(u), f[u] = d, d++;
1906
+ const f = t.findVoid();
1907
+ t.addPointIndex(f), u[f] = d, d++;
1908
1908
  }
1909
1909
  for (t.invert(); d < h; ) {
1910
- const u = t.findCluster();
1911
- t.removePointIndex(u), f[u] = d, d++;
1910
+ const f = t.findCluster();
1911
+ t.removePointIndex(f), u[f] = d, d++;
1912
1912
  }
1913
- return { data: f, maxValue: h };
1913
+ return { data: u, maxValue: h };
1914
1914
  }
1915
1915
  }
1916
- function ma(s) {
1917
- return s >= 3 ? 4 : s;
1916
+ function pa(o) {
1917
+ return o >= 3 ? 4 : o;
1918
1918
  }
1919
- function pa(s) {
1920
- switch (s) {
1919
+ function ga(o) {
1920
+ switch (o) {
1921
1921
  case 1:
1922
- return me;
1922
+ return pe;
1923
1923
  case 2:
1924
1924
  return ht;
1925
1925
  default:
1926
1926
  return I;
1927
1927
  }
1928
1928
  }
1929
- class ga extends M {
1929
+ class va extends F {
1930
1930
  constructor(e = 64, t = 1) {
1931
1931
  super(new Float32Array(4), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.size = e, this.channels = t, this.update();
1932
1932
  }
1933
1933
  update() {
1934
- const e = this.channels, t = this.size, r = new da();
1934
+ const e = this.channels, t = this.size, r = new ma();
1935
1935
  r.channels = e, r.size = t;
1936
- const i = ma(e), o = pa(i);
1937
- (this.image.width !== t || o !== this.format) && (this.image.width = t, this.image.height = t, this.image.data = new Float32Array(t ** 2 * i), this.format = o, this.dispose());
1936
+ const i = pa(e), s = ga(i);
1937
+ (this.image.width !== t || s !== this.format) && (this.image.width = t, this.image.height = t, this.image.data = new Float32Array(t ** 2 * i), this.format = s, this.dispose());
1938
1938
  const a = this.image.data;
1939
- for (let l = 0, f = e; l < f; l++) {
1940
- const d = r.generate(), h = d.data, u = d.maxValue;
1939
+ for (let l = 0, u = e; l < u; l++) {
1940
+ const d = r.generate(), h = d.data, f = d.maxValue;
1941
1941
  for (let n = 0, x = h.length; n < x; n++) {
1942
- const m = h[n] / u;
1942
+ const m = h[n] / f;
1943
1943
  a[n * i + l] = m;
1944
1944
  }
1945
1945
  }
1946
1946
  this.needsUpdate = !0;
1947
1947
  }
1948
1948
  }
1949
- const va = (
1949
+ const xa = (
1950
1950
  /* glsl */
1951
1951
  `
1952
1952
 
@@ -1961,7 +1961,7 @@ const va = (
1961
1961
  };
1962
1962
 
1963
1963
  `
1964
- ), xa = (
1964
+ ), ba = (
1965
1965
  /* glsl */
1966
1966
  `
1967
1967
 
@@ -1976,7 +1976,7 @@ const va = (
1976
1976
  };
1977
1977
 
1978
1978
  `
1979
- ), ba = (
1979
+ ), ya = (
1980
1980
  /* glsl */
1981
1981
  `
1982
1982
 
@@ -2065,7 +2065,7 @@ const va = (
2065
2065
  }
2066
2066
 
2067
2067
  `
2068
- ), ya = (
2068
+ ), Ta = (
2069
2069
  /* glsl */
2070
2070
  `
2071
2071
 
@@ -2275,7 +2275,7 @@ const va = (
2275
2275
  }
2276
2276
 
2277
2277
  `
2278
- ), Ta = (
2278
+ ), wa = (
2279
2279
  /* glsl */
2280
2280
  `
2281
2281
 
@@ -2340,7 +2340,7 @@ const va = (
2340
2340
  };
2341
2341
 
2342
2342
  `
2343
- ), wa = (
2343
+ ), Ia = (
2344
2344
  /* glsl */
2345
2345
  `
2346
2346
 
@@ -2410,7 +2410,7 @@ const va = (
2410
2410
 
2411
2411
  }
2412
2412
  `
2413
- ), Ia = (
2413
+ ), Ra = (
2414
2414
  /* glsl */
2415
2415
  `
2416
2416
 
@@ -2628,7 +2628,7 @@ const va = (
2628
2628
  }
2629
2629
 
2630
2630
  `
2631
- ), Ra = (
2631
+ ), _a = (
2632
2632
  /* glsl */
2633
2633
  `
2634
2634
 
@@ -2822,7 +2822,7 @@ const va = (
2822
2822
  }
2823
2823
 
2824
2824
  `
2825
- ), _a = (
2825
+ ), Ma = (
2826
2826
  /* glsl */
2827
2827
  `
2828
2828
 
@@ -2905,7 +2905,7 @@ const va = (
2905
2905
  }
2906
2906
 
2907
2907
  `
2908
- ), Ma = (
2908
+ ), Aa = (
2909
2909
  /* glsl */
2910
2910
  `
2911
2911
 
@@ -2969,7 +2969,7 @@ const va = (
2969
2969
  }
2970
2970
 
2971
2971
  `
2972
- ), Aa = (
2972
+ ), Fa = (
2973
2973
  /*glsl */
2974
2974
  `
2975
2975
 
@@ -3224,7 +3224,7 @@ const va = (
3224
3224
  }
3225
3225
 
3226
3226
  `
3227
- ), Fa = (
3227
+ ), Da = (
3228
3228
  /* glsl */
3229
3229
  `
3230
3230
 
@@ -3665,7 +3665,7 @@ const va = (
3665
3665
  }
3666
3666
 
3667
3667
  `
3668
- ), Da = (
3668
+ ), Pa = (
3669
3669
  /* glsl */
3670
3670
  `
3671
3671
 
@@ -3689,7 +3689,7 @@ const va = (
3689
3689
  }
3690
3690
 
3691
3691
  `
3692
- ), Pa = (
3692
+ ), Ea = (
3693
3693
  /* glsl */
3694
3694
  `
3695
3695
 
@@ -3793,7 +3793,7 @@ const va = (
3793
3793
  }
3794
3794
 
3795
3795
  `
3796
- ), Ea = (
3796
+ ), Oa = (
3797
3797
  /* glsl */
3798
3798
  `
3799
3799
 
@@ -4030,7 +4030,7 @@ const va = (
4030
4030
  }
4031
4031
 
4032
4032
  `
4033
- ), Oa = (
4033
+ ), Na = (
4034
4034
  /* glsl */
4035
4035
  `
4036
4036
 
@@ -4274,7 +4274,7 @@ bool bvhIntersectFogVolumeHit(
4274
4274
  }
4275
4275
 
4276
4276
  `
4277
- ), Na = (
4277
+ ), Ha = (
4278
4278
  /* glsl */
4279
4279
  `
4280
4280
 
@@ -4360,7 +4360,7 @@ bool bvhIntersectFogVolumeHit(
4360
4360
  }
4361
4361
 
4362
4362
  `
4363
- ), Ha = (
4363
+ ), Ba = (
4364
4364
  /*glsl*/
4365
4365
  `
4366
4366
 
@@ -4459,7 +4459,7 @@ bool bvhIntersectFogVolumeHit(
4459
4459
  }
4460
4460
 
4461
4461
  `
4462
- ), Ba = (
4462
+ ), Wa = (
4463
4463
  /* glsl */
4464
4464
  `
4465
4465
 
@@ -4784,7 +4784,7 @@ bool bvhIntersectFogVolumeHit(
4784
4784
 
4785
4785
  }
4786
4786
  `
4787
- ), Wa = (
4787
+ ), La = (
4788
4788
  /* glsl */
4789
4789
  `
4790
4790
 
@@ -4836,7 +4836,7 @@ bool bvhIntersectFogVolumeHit(
4836
4836
  }
4837
4837
 
4838
4838
  `
4839
- ), La = (
4839
+ ), Ua = (
4840
4840
  /* glsl */
4841
4841
  `
4842
4842
 
@@ -4887,7 +4887,7 @@ bool bvhIntersectFogVolumeHit(
4887
4887
 
4888
4888
  `
4889
4889
  );
4890
- class Ua extends Pe {
4890
+ class Ga extends Pe {
4891
4891
  onBeforeRender() {
4892
4892
  this.setDefine("FEATURE_DOF", this.physicalCamera.bokehSize === 0 ? 0 : 1), this.setDefine("FEATURE_BACKGROUND_MAP", this.backgroundMap ? 1 : 0), this.setDefine("FEATURE_FOG", this.materials.features.isUsed("FOG") ? 1 : 0);
4893
4893
  }
@@ -4917,42 +4917,42 @@ class Ua extends Pe {
4917
4917
  },
4918
4918
  uniforms: {
4919
4919
  // path trace uniforms
4920
- resolution: { value: new q() },
4920
+ resolution: { value: new X() },
4921
4921
  opacity: { value: 1 },
4922
4922
  bounces: { value: 10 },
4923
4923
  transmissiveBounces: { value: 10 },
4924
4924
  filterGlossyFactor: { value: 0 },
4925
4925
  // camera uniforms
4926
- physicalCamera: { value: new Hr() },
4927
- cameraWorldMatrix: { value: new O() },
4928
- invProjectionMatrix: { value: new O() },
4926
+ physicalCamera: { value: new Br() },
4927
+ cameraWorldMatrix: { value: new z() },
4928
+ invProjectionMatrix: { value: new z() },
4929
4929
  // scene uniforms
4930
- bvh: { value: new nr() },
4931
- attributesArray: { value: new Qr() },
4930
+ bvh: { value: new lr() },
4931
+ attributesArray: { value: new Kr() },
4932
4932
  materialIndexAttribute: { value: new vt() },
4933
- materials: { value: new ra() },
4933
+ materials: { value: new aa() },
4934
4934
  textures: { value: new tt().texture },
4935
4935
  // light uniforms
4936
- lights: { value: new Yr() },
4936
+ lights: { value: new Xr() },
4937
4937
  iesProfiles: { value: new tt(360, 180, {
4938
- type: D,
4939
- wrapS: N,
4940
- wrapT: N
4938
+ type: E,
4939
+ wrapS: B,
4940
+ wrapT: B
4941
4941
  }).texture },
4942
4942
  environmentIntensity: { value: 1 },
4943
- environmentRotation: { value: new O() },
4944
- envMapInfo: { value: new Lr() },
4943
+ environmentRotation: { value: new z() },
4944
+ envMapInfo: { value: new Ur() },
4945
4945
  // background uniforms
4946
4946
  backgroundBlur: { value: 0 },
4947
4947
  backgroundMap: { value: null },
4948
4948
  backgroundAlpha: { value: 1 },
4949
4949
  backgroundIntensity: { value: 1 },
4950
- backgroundRotation: { value: new O() },
4950
+ backgroundRotation: { value: new z() },
4951
4951
  // randomness uniforms
4952
4952
  seed: { value: 0 },
4953
4953
  sobolTexture: { value: null },
4954
- stratifiedTexture: { value: new ua() },
4955
- stratifiedOffsetTexture: { value: new ga(64, 1) }
4954
+ stratifiedTexture: { value: new fa() },
4955
+ stratifiedOffsetTexture: { value: new va(64, 1) }
4956
4956
  },
4957
4957
  vertexShader: (
4958
4958
  /* glsl */
@@ -4984,16 +4984,16 @@ class Ua extends Pe {
4984
4984
  #include <common>
4985
4985
 
4986
4986
  // bvh intersection
4987
- ${ur}
4988
- ${hr}
4989
4987
  ${fr}
4988
+ ${dr}
4989
+ ${hr}
4990
4990
 
4991
4991
  // uniform structs
4992
- ${va}
4993
- ${ba}
4994
4992
  ${xa}
4995
4993
  ${ya}
4994
+ ${ba}
4996
4995
  ${Ta}
4996
+ ${wa}
4997
4997
 
4998
4998
  // random
4999
4999
  #if RANDOM_TYPE == 2 // Stratified List
@@ -5029,11 +5029,11 @@ class Ua extends Pe {
5029
5029
  #endif
5030
5030
 
5031
5031
  // common
5032
- ${Aa}
5032
+ ${Fa}
5033
5033
  ${Sa}
5034
5034
  ${Rt}
5035
- ${_a}
5036
5035
  ${Ma}
5036
+ ${Aa}
5037
5037
 
5038
5038
  // environment
5039
5039
  uniform EquirectHdrInfo envMapInfo;
@@ -5089,16 +5089,16 @@ class Ua extends Pe {
5089
5089
  float lightsDenom;
5090
5090
 
5091
5091
  // sampling
5092
- ${Ra}
5093
- ${wa}
5092
+ ${_a}
5094
5093
  ${Ia}
5094
+ ${Ra}
5095
5095
 
5096
+ ${Na}
5097
+ ${Ea}
5098
+ ${ka}
5096
5099
  ${Oa}
5097
5100
  ${Pa}
5098
- ${ka}
5099
- ${Ea}
5100
5101
  ${Da}
5101
- ${Fa}
5102
5102
 
5103
5103
  float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
5104
5104
 
@@ -5130,12 +5130,12 @@ class Ua extends Pe {
5130
5130
 
5131
5131
  }
5132
5132
 
5133
- ${Wa}
5134
- ${Na}
5135
5133
  ${La}
5136
- ${za}
5137
5134
  ${Ha}
5135
+ ${Ua}
5136
+ ${za}
5138
5137
  ${Ba}
5138
+ ${Wa}
5139
5139
 
5140
5140
  void main() {
5141
5141
 
@@ -5434,48 +5434,48 @@ class Ua extends Pe {
5434
5434
  }
5435
5435
  function* Va() {
5436
5436
  const {
5437
- _renderer: s,
5437
+ _renderer: o,
5438
5438
  _fsQuad: e,
5439
5439
  _blendQuad: t,
5440
5440
  _primaryTarget: r,
5441
5441
  _blendTargets: i,
5442
- _sobolTarget: o,
5442
+ _sobolTarget: s,
5443
5443
  _subframe: a,
5444
5444
  alpha: l,
5445
- material: f
5446
- } = this, d = new K(), h = new K(), u = t.material;
5445
+ material: u
5446
+ } = this, d = new te(), h = new te(), f = t.material;
5447
5447
  let [n, x] = i;
5448
5448
  for (; ; ) {
5449
- l ? (u.opacity = this._opacityFactor / (this.samples + 1), f.blending = ie, f.opacity = 1) : (f.opacity = this._opacityFactor / (this.samples + 1), f.blending = mt);
5449
+ l ? (f.opacity = this._opacityFactor / (this.samples + 1), u.blending = se, u.opacity = 1) : (u.opacity = this._opacityFactor / (this.samples + 1), u.blending = mt);
5450
5450
  const [m, g, c, p] = a, v = r.width, b = r.height;
5451
- f.resolution.set(v * c, b * p), f.sobolTexture = o.texture, f.stratifiedTexture.init(20, f.bounces + f.transmissiveBounces + 5), f.stratifiedTexture.next(), f.seed++;
5452
- const y = this.tiles.x || 1, w = this.tiles.y || 1, E = y * w, H = Math.ceil(v * c), ve = Math.ceil(b * p), ke = Math.floor(m * v), Oe = Math.floor(g * b), xe = Math.ceil(H / y), be = Math.ceil(ve / w);
5453
- for (let oe = 0; oe < w; oe++)
5454
- for (let ne = 0; ne < y; ne++) {
5455
- const ze = s.getRenderTarget(), St = s.autoClear, _t = s.getScissorTest();
5456
- s.getScissor(d), s.getViewport(h);
5457
- let ye = ne, Ne = oe;
5451
+ u.resolution.set(v * c, b * p), u.sobolTexture = s.texture, u.stratifiedTexture.init(20, u.bounces + u.transmissiveBounces + 5), u.stratifiedTexture.next(), u.seed++;
5452
+ const y = this.tiles.x || 1, w = this.tiles.y || 1, k = y * w, W = Math.ceil(v * c), ve = Math.ceil(b * p), Oe = Math.floor(m * v), ke = Math.floor(g * b), xe = Math.ceil(W / y), be = Math.ceil(ve / w);
5453
+ for (let ne = 0; ne < w; ne++)
5454
+ for (let le = 0; le < y; le++) {
5455
+ const Ne = o.getRenderTarget(), _t = o.autoClear, St = o.getScissorTest();
5456
+ o.getScissor(d), o.getViewport(h);
5457
+ let ye = le, ze = ne;
5458
5458
  if (!this.stableTiles) {
5459
5459
  const Te = this._currentTile % (y * w);
5460
- ye = Te % y, Ne = ~~(Te / y), this._currentTile = Te + 1;
5460
+ ye = Te % y, ze = ~~(Te / y), this._currentTile = Te + 1;
5461
5461
  }
5462
- const He = w - Ne - 1;
5462
+ const He = w - ze - 1;
5463
5463
  r.scissor.set(
5464
- ke + ye * xe,
5465
- Oe + He * be,
5466
- Math.min(xe, H - ye * xe),
5464
+ Oe + ye * xe,
5465
+ ke + He * be,
5466
+ Math.min(xe, W - ye * xe),
5467
5467
  Math.min(be, ve - He * be)
5468
5468
  ), r.viewport.set(
5469
- ke,
5470
5469
  Oe,
5471
- H,
5470
+ ke,
5471
+ W,
5472
5472
  ve
5473
- ), s.setRenderTarget(r), s.setScissorTest(!0), s.autoClear = !1, e.render(s), s.setViewport(h), s.setScissor(d), s.setScissorTest(_t), s.setRenderTarget(ze), s.autoClear = St, l && (u.target1 = n.texture, u.target2 = r.texture, s.setRenderTarget(x), t.render(s), s.setRenderTarget(ze)), this.samples += 1 / E, ne === y - 1 && oe === w - 1 && (this.samples = Math.round(this.samples)), yield;
5473
+ ), o.setRenderTarget(r), o.setScissorTest(!0), o.autoClear = !1, e.render(o), o.setViewport(h), o.setScissor(d), o.setScissorTest(St), o.setRenderTarget(Ne), o.autoClear = _t, l && (f.target1 = n.texture, f.target2 = r.texture, o.setRenderTarget(x), t.render(o), o.setRenderTarget(Ne)), this.samples += 1 / k, le === y - 1 && ne === w - 1 && (this.samples = Math.round(this.samples)), yield;
5474
5474
  }
5475
5475
  [n, x] = [x, n];
5476
5476
  }
5477
5477
  }
5478
- const it = new se();
5478
+ const it = new oe();
5479
5479
  class st {
5480
5480
  get material() {
5481
5481
  return this._fsQuad.material;
@@ -5496,19 +5496,19 @@ class st {
5496
5496
  return !!this._compilePromise;
5497
5497
  }
5498
5498
  constructor(e) {
5499
- this.camera = null, this.tiles = new q(3, 3), this.stableNoise = !1, this.stableTiles = !0, this.samples = 0, this._subframe = new K(0, 0, 1, 1), this._opacityFactor = 1, this._renderer = e, this._alpha = !1, this._fsQuad = new Z(new Ua()), this._blendQuad = new Z(new Pr()), this._task = null, this._currentTile = 0, this._compilePromise = null, this._sobolTarget = new zr().generate(e), this._primaryTarget = new ae(1, 1, {
5499
+ this.camera = null, this.tiles = new X(3, 3), this.stableNoise = !1, this.stableTiles = !0, this.samples = 0, this._subframe = new te(0, 0, 1, 1), this._opacityFactor = 1, this._renderer = e, this._alpha = !1, this._fsQuad = new Y(new Ga()), this._blendQuad = new Y(new Er()), this._task = null, this._currentTile = 0, this._compilePromise = null, this._sobolTarget = new zr().generate(e), this._primaryTarget = new ie(1, 1, {
5500
5500
  format: I,
5501
5501
  type: R,
5502
5502
  magFilter: T,
5503
5503
  minFilter: T
5504
5504
  }), this._blendTargets = [
5505
- new ae(1, 1, {
5505
+ new ie(1, 1, {
5506
5506
  format: I,
5507
5507
  type: R,
5508
5508
  magFilter: T,
5509
5509
  minFilter: T
5510
5510
  }),
5511
- new ae(1, 1, {
5511
+ new ie(1, 1, {
5512
5512
  format: I,
5513
5513
  type: R,
5514
5514
  magFilter: T,
@@ -5540,15 +5540,15 @@ class st {
5540
5540
  this._primaryTarget.dispose(), this._blendTargets[0].dispose(), this._blendTargets[1].dispose(), this._sobolTarget.dispose(), this._fsQuad.dispose(), this._blendQuad.dispose(), this._task = null;
5541
5541
  }
5542
5542
  reset() {
5543
- const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(), o = e.getClearAlpha();
5544
- e.getClearColor(it), e.setRenderTarget(t), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[0]), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[1]), e.setClearColor(0, 0), e.clearColor(), e.setClearColor(it, o), e.setRenderTarget(i), this.samples = 0, this._task = null, this.material.stratifiedTexture.stableNoise = this.stableNoise, this.stableNoise && (this.material.seed = 0, this.material.stratifiedTexture.reset());
5543
+ const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(), s = e.getClearAlpha();
5544
+ e.getClearColor(it), e.setRenderTarget(t), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[0]), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[1]), e.setClearColor(0, 0), e.clearColor(), e.setClearColor(it, s), e.setRenderTarget(i), this.samples = 0, this._task = null, this.material.stratifiedTexture.stableNoise = this.stableNoise, this.stableNoise && (this.material.seed = 0, this.material.stratifiedTexture.reset());
5545
5545
  }
5546
5546
  update() {
5547
5547
  this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task = Va.call(this)), this._task.next());
5548
5548
  }
5549
5549
  }
5550
- const G = new q(), ot = new q(), he = new Lt(), de = new se();
5551
- class Ga extends M {
5550
+ const $ = new X(), ot = new X(), de = new Lt(), me = new oe();
5551
+ class qa extends F {
5552
5552
  constructor(e = 512, t = 512) {
5553
5553
  super(
5554
5554
  new Float32Array(e * t * 4),
@@ -5557,40 +5557,40 @@ class Ga extends M {
5557
5557
  I,
5558
5558
  R,
5559
5559
  pt,
5560
- z,
5561
- N,
5562
- C,
5563
- C
5560
+ H,
5561
+ B,
5562
+ D,
5563
+ D
5564
5564
  ), this.generationCallback = null;
5565
5565
  }
5566
5566
  update() {
5567
5567
  this.dispose(), this.needsUpdate = !0;
5568
5568
  const { data: e, width: t, height: r } = this.image;
5569
5569
  for (let i = 0; i < t; i++)
5570
- for (let o = 0; o < r; o++) {
5571
- ot.set(t, r), G.set(i / t, o / r), G.x -= 0.5, G.y = 1 - G.y, he.theta = G.x * 2 * Math.PI, he.phi = G.y * Math.PI, he.radius = 1, this.generationCallback(he, G, ot, de);
5572
- const l = 4 * (o * t + i);
5573
- e[l + 0] = de.r, e[l + 1] = de.g, e[l + 2] = de.b, e[l + 3] = 1;
5570
+ for (let s = 0; s < r; s++) {
5571
+ ot.set(t, r), $.set(i / t, s / r), $.x -= 0.5, $.y = 1 - $.y, de.theta = $.x * 2 * Math.PI, de.phi = $.y * Math.PI, de.radius = 1, this.generationCallback(de, $, ot, me);
5572
+ const l = 4 * (s * t + i);
5573
+ e[l + 0] = me.r, e[l + 1] = me.g, e[l + 2] = me.b, e[l + 3] = 1;
5574
5574
  }
5575
5575
  }
5576
5576
  copy(e) {
5577
5577
  return super.copy(e), this.generationCallback = e.generationCallback, this;
5578
5578
  }
5579
5579
  }
5580
- const nt = new F();
5581
- class qa extends Ga {
5580
+ const nt = new P();
5581
+ class $a extends qa {
5582
5582
  constructor(e = 512) {
5583
- super(e, e), this.topColor = new se().set(16777215), this.bottomColor = new se().set(0), this.exponent = 2, this.generationCallback = (t, r, i, o) => {
5583
+ super(e, e), this.topColor = new oe().set(16777215), this.bottomColor = new oe().set(0), this.exponent = 2, this.generationCallback = (t, r, i, s) => {
5584
5584
  nt.setFromSpherical(t);
5585
5585
  const a = nt.y * 0.5 + 0.5;
5586
- o.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
5586
+ s.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
5587
5587
  };
5588
5588
  }
5589
5589
  copy(e) {
5590
5590
  return super.copy(e), this.topColor.copy(e.topColor), this.bottomColor.copy(e.bottomColor), this;
5591
5591
  }
5592
5592
  }
5593
- class $a extends ge {
5593
+ class ja extends ge {
5594
5594
  get map() {
5595
5595
  return this.uniforms.map.value;
5596
5596
  }
@@ -5677,7 +5677,7 @@ class $a extends ge {
5677
5677
  }), this.setValues(e);
5678
5678
  }
5679
5679
  }
5680
- class ja extends ge {
5680
+ class Ya extends ge {
5681
5681
  constructor() {
5682
5682
  super({
5683
5683
  uniforms: {
@@ -5722,36 +5722,36 @@ class ja extends ge {
5722
5722
  }
5723
5723
  class lt {
5724
5724
  constructor(e) {
5725
- this._renderer = e, this._quad = new Z(new ja());
5725
+ this._renderer = e, this._quad = new Y(new Ya());
5726
5726
  }
5727
5727
  generate(e, t = null, r = null) {
5728
5728
  if (!e.isCubeTexture)
5729
5729
  throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");
5730
- const i = e.images[0], o = this._renderer, a = this._quad;
5730
+ const i = e.images[0], s = this._renderer, a = this._quad;
5731
5731
  t === null && (t = 4 * i.height), r === null && (r = 2 * i.height);
5732
- const l = new ae(t, r, {
5732
+ const l = new ie(t, r, {
5733
5733
  type: R,
5734
5734
  colorSpace: i.colorSpace
5735
- }), f = i.height, d = Math.log2(f) - 2, h = 1 / f, u = 1 / (3 * Math.max(Math.pow(2, d), 112));
5736
- a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH = u, a.material.defines.CUBEUV_TEXEL_HEIGHT = h, a.material.uniforms.envMap.value = e, a.material.uniforms.flipEnvMap.value = e.isRenderTargetTexture ? 1 : -1, a.material.needsUpdate = !0;
5737
- const n = o.getRenderTarget(), x = o.autoClear;
5738
- o.autoClear = !0, o.setRenderTarget(l), a.render(o), o.setRenderTarget(n), o.autoClear = x;
5735
+ }), u = i.height, d = Math.log2(u) - 2, h = 1 / u, f = 1 / (3 * Math.max(Math.pow(2, d), 112));
5736
+ a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH = f, a.material.defines.CUBEUV_TEXEL_HEIGHT = h, a.material.uniforms.envMap.value = e, a.material.uniforms.flipEnvMap.value = e.isRenderTargetTexture ? 1 : -1, a.material.needsUpdate = !0;
5737
+ const n = s.getRenderTarget(), x = s.autoClear;
5738
+ s.autoClear = !0, s.setRenderTarget(l), a.render(s), s.setRenderTarget(n), s.autoClear = x;
5739
5739
  const m = new Uint16Array(t * r * 4), g = new Float32Array(t * r * 4);
5740
- o.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
5740
+ s.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
5741
5741
  for (let p = 0, v = g.length; p < v; p++)
5742
- m[p] = k.toHalfFloat(g[p]);
5743
- const c = new M(m, t, r, I, D);
5744
- return c.minFilter = Ut, c.magFilter = C, c.wrapS = z, c.wrapT = z, c.mapping = pt, c.needsUpdate = !0, c;
5742
+ m[p] = N.toHalfFloat(g[p]);
5743
+ const c = new F(m, t, r, I, E);
5744
+ return c.minFilter = Ut, c.magFilter = D, c.wrapS = H, c.wrapT = H, c.mapping = pt, c.needsUpdate = !0, c;
5745
5745
  }
5746
5746
  dispose() {
5747
5747
  this._quad.dispose();
5748
5748
  }
5749
5749
  }
5750
- function Ya(s) {
5751
- return s.extensions.get("EXT_float_blend");
5750
+ function Xa(o) {
5751
+ return o.extensions.get("EXT_float_blend");
5752
5752
  }
5753
- const Y = new q();
5754
- class Xa {
5753
+ const Z = new X();
5754
+ class Qa {
5755
5755
  get multipleImportanceSampling() {
5756
5756
  return !!this._pathTracer.material.defines.FEATURE_MIS;
5757
5757
  }
@@ -5795,17 +5795,17 @@ class Xa {
5795
5795
  return !!this._pathTracer.isCompiling;
5796
5796
  }
5797
5797
  constructor(e) {
5798
- this._renderer = e, this._generator = new Dr(), this._pathTracer = new st(e), this._queueReset = !1, this._clock = new Vt(), this._compilePromise = null, this._lowResPathTracer = new st(e), this._lowResPathTracer.tiles.set(1, 1), this._quad = new Z(new $a({
5798
+ this._renderer = e, this._generator = new Pr(), this._pathTracer = new st(e), this._queueReset = !1, this._clock = new Gt(), this._compilePromise = null, this._lowResPathTracer = new st(e), this._lowResPathTracer.tiles.set(1, 1), this._quad = new Y(new ja({
5799
5799
  map: null,
5800
5800
  transparent: !0,
5801
- blending: ie,
5801
+ blending: se,
5802
5802
  premultipliedAlpha: e.getContextAttributes().premultipliedAlpha
5803
- })), this._materials = null, this._previousEnvironment = null, this._previousBackground = null, this._internalBackground = null, this.renderDelay = 100, this.minSamples = 5, this.fadeDuration = 500, this.enablePathTracing = !0, this.pausePathTracing = !1, this.dynamicLowRes = !1, this.lowResScale = 0.25, this.renderScale = 1, this.synchronizeRenderSize = !0, this.rasterizeScene = !0, this.renderToCanvas = !0, this.textureSize = new q(1024, 1024), this.rasterizeSceneCallback = (t, r) => {
5803
+ })), this._materials = null, this._previousEnvironment = null, this._previousBackground = null, this._internalBackground = null, this.renderDelay = 100, this.minSamples = 5, this.fadeDuration = 500, this.enablePathTracing = !0, this.pausePathTracing = !1, this.dynamicLowRes = !1, this.lowResScale = 0.25, this.renderScale = 1, this.synchronizeRenderSize = !0, this.rasterizeScene = !0, this.renderToCanvas = !0, this.textureSize = new X(1024, 1024), this.rasterizeSceneCallback = (t, r) => {
5804
5804
  this._renderer.render(t, r);
5805
5805
  }, this.renderToCanvasCallback = (t, r, i) => {
5806
- const o = r.autoClear;
5807
- r.autoClear = !1, i.render(r), r.autoClear = o;
5808
- }, this.setScene(new Gt(), new dt());
5806
+ const s = r.autoClear;
5807
+ r.autoClear = !1, i.render(r), r.autoClear = s;
5808
+ }, this.setScene(new Vt(), new dt());
5809
5809
  }
5810
5810
  setBVHWorker(e) {
5811
5811
  this._generator.setBVHWorker(e);
@@ -5814,10 +5814,10 @@ class Xa {
5814
5814
  e.updateMatrixWorld(!0), t.updateMatrixWorld();
5815
5815
  const i = this._generator;
5816
5816
  if (i.setObjects(e), this._buildAsync)
5817
- return i.generateAsync(r.onProgress).then((o) => this._updateFromResults(e, t, o));
5817
+ return i.generateAsync(r.onProgress).then((s) => this._updateFromResults(e, t, s));
5818
5818
  {
5819
- const o = i.generate();
5820
- return this._updateFromResults(e, t, o);
5819
+ const s = i.generate();
5820
+ return this._updateFromResults(e, t, s);
5821
5821
  }
5822
5822
  }
5823
5823
  setSceneAsync(...e) {
@@ -5833,19 +5833,19 @@ class Xa {
5833
5833
  e.updateMatrixWorld(), this._pathTracer.setCamera(e), this._lowResPathTracer.setCamera(e), this.reset();
5834
5834
  }
5835
5835
  updateMaterials() {
5836
- const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize, o = Jr(r);
5837
- e.textures.setTextures(t, o, i.x, i.y), e.materials.updateFrom(r, o), this.reset();
5836
+ const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize, s = ea(r);
5837
+ e.textures.setTextures(t, s, i.x, i.y), e.materials.updateFrom(r, s), this.reset();
5838
5838
  }
5839
5839
  updateLights() {
5840
- const e = this.scene, t = this._renderer, r = this._pathTracer.material, i = ea(e), o = Zr(i);
5841
- r.lights.updateFrom(i, o), r.iesProfiles.setTextures(t, o), this.reset();
5840
+ const e = this.scene, t = this._renderer, r = this._pathTracer.material, i = ta(e), s = Jr(i);
5841
+ r.lights.updateFrom(i, s), r.iesProfiles.setTextures(t, s), this.reset();
5842
5842
  }
5843
5843
  updateEnvironment() {
5844
5844
  const e = this.scene, t = this._pathTracer.material;
5845
5845
  if (this._internalBackground && (this._internalBackground.dispose(), this._internalBackground = null), t.backgroundBlur = e.backgroundBlurriness, t.backgroundIntensity = e.backgroundIntensity ?? 1, t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(), e.background === null)
5846
5846
  t.backgroundMap = null, t.backgroundAlpha = 0;
5847
5847
  else if (e.background.isColor) {
5848
- this._colorBackground = this._colorBackground || new qa(16);
5848
+ this._colorBackground = this._colorBackground || new $a(16);
5849
5849
  const r = this._colorBackground;
5850
5850
  r.topColor.equals(e.background) || (r.topColor.set(e.background), r.bottomColor.set(e.background), r.update()), t.backgroundMap = r, t.backgroundAlpha = 1;
5851
5851
  } else if (e.background.isCubeTexture) {
@@ -5869,34 +5869,34 @@ class Xa {
5869
5869
  _updateFromResults(e, t, r) {
5870
5870
  const {
5871
5871
  materials: i,
5872
- geometry: o,
5872
+ geometry: s,
5873
5873
  bvh: a,
5874
5874
  bvhChanged: l
5875
5875
  } = r;
5876
5876
  this._materials = i;
5877
5877
  const d = this._pathTracer.material;
5878
5878
  return l && (d.bvh.updateFrom(a), d.attributesArray.updateFrom(
5879
- o.attributes.normal,
5880
- o.attributes.tangent,
5881
- o.attributes.uv,
5882
- o.attributes.color
5883
- ), d.materialIndexAttribute.updateFrom(o.attributes.materialIndex)), this._previousScene = e, this.scene = e, this.camera = t, this.updateCamera(), this.updateMaterials(), this.updateEnvironment(), this.updateLights(), r;
5879
+ s.attributes.normal,
5880
+ s.attributes.tangent,
5881
+ s.attributes.uv,
5882
+ s.attributes.color
5883
+ ), d.materialIndexAttribute.updateFrom(s.attributes.materialIndex)), this._previousScene = e, this.scene = e, this.camera = t, this.updateCamera(), this.updateMaterials(), this.updateEnvironment(), this.updateLights(), r;
5884
5884
  }
5885
5885
  renderSample() {
5886
- const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock, o = this._quad;
5887
- this._updateScale(), this._queueReset && (t.reset(), e.reset(), this._queueReset = !1, o.material.opacity = 0, i.start());
5886
+ const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock, s = this._quad;
5887
+ this._updateScale(), this._queueReset && (t.reset(), e.reset(), this._queueReset = !1, s.material.opacity = 0, i.start());
5888
5888
  const a = i.getDelta() * 1e3, l = i.getElapsedTime() * 1e3;
5889
- if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !Ya(r), e.alpha = t.alpha, this.renderToCanvas) {
5890
- const f = this._renderer, d = this.minSamples;
5891
- if (l >= this.renderDelay && this.samples >= this.minSamples && (this.fadeDuration !== 0 ? o.material.opacity = Math.min(o.material.opacity + a / this.fadeDuration, 1) : o.material.opacity = 1), !this.enablePathTracing || this.samples < d || o.material.opacity < 1) {
5889
+ if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !Xa(r), e.alpha = t.alpha, this.renderToCanvas) {
5890
+ const u = this._renderer, d = this.minSamples;
5891
+ if (l >= this.renderDelay && this.samples >= this.minSamples && (this.fadeDuration !== 0 ? s.material.opacity = Math.min(s.material.opacity + a / this.fadeDuration, 1) : s.material.opacity = 1), !this.enablePathTracing || this.samples < d || s.material.opacity < 1) {
5892
5892
  if (this.dynamicLowRes && !this.isCompiling) {
5893
5893
  e.samples < 1 && (e.material = t.material, e.update());
5894
- const h = o.material.opacity;
5895
- o.material.opacity = 1 - o.material.opacity, o.material.map = e.target.texture, o.render(f), o.material.opacity = h;
5894
+ const h = s.material.opacity;
5895
+ s.material.opacity = 1 - s.material.opacity, s.material.map = e.target.texture, s.render(u), s.material.opacity = h;
5896
5896
  }
5897
5897
  (!this.dynamicLowRes && this.rasterizeScene || this.dynamicLowRes && this.isCompiling) && this.rasterizeSceneCallback(this.scene, this.camera);
5898
5898
  }
5899
- this.enablePathTracing && o.material.opacity > 0 && (o.material.opacity < 1 && (o.material.blending = this.dynamicLowRes ? qt : mt), o.material.map = t.target.texture, this.renderToCanvasCallback(t.target, f, o), o.material.blending = ie);
5899
+ this.enablePathTracing && s.material.opacity > 0 && (s.material.opacity < 1 && (s.material.blending = this.dynamicLowRes ? qt : mt), s.material.map = t.target.texture, this.renderToCanvasCallback(t.target, u, s), s.material.blending = se);
5900
5900
  }
5901
5901
  }
5902
5902
  reset() {
@@ -5907,30 +5907,30 @@ class Xa {
5907
5907
  }
5908
5908
  _updateScale() {
5909
5909
  if (this.synchronizeRenderSize) {
5910
- this._renderer.getDrawingBufferSize(Y);
5911
- const e = Math.floor(this.renderScale * Y.x), t = Math.floor(this.renderScale * Y.y);
5912
- if (this._pathTracer.getSize(Y), Y.x !== e || Y.y !== t) {
5910
+ this._renderer.getDrawingBufferSize(Z);
5911
+ const e = Math.floor(this.renderScale * Z.x), t = Math.floor(this.renderScale * Z.y);
5912
+ if (this._pathTracer.getSize(Z), Z.x !== e || Z.y !== t) {
5913
5913
  const r = this.lowResScale;
5914
5914
  this._pathTracer.setSize(e, t), this._lowResPathTracer.setSize(Math.floor(e * r), Math.floor(t * r));
5915
5915
  }
5916
5916
  }
5917
5917
  }
5918
5918
  }
5919
- function ct(s) {
5920
- return typeof s == "object" && s !== null && "getInternalRenderer" in s && typeof s.getInternalRenderer == "function";
5919
+ function ct(o) {
5920
+ return typeof o == "object" && o !== null && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
5921
5921
  }
5922
- function ee(s) {
5923
- return s !== null && typeof s == "object" && "getInternalRenderer" in s && typeof s.getInternalRenderer == "function";
5922
+ function j(o) {
5923
+ return o !== null && typeof o == "object" && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
5924
5924
  }
5925
- const pe = class pe {
5925
+ const M = class M {
5926
5926
  constructor() {
5927
- this.pathTracer = null, this.enabled = !1, this.renderer = null, this.sampleCount = 0, this.createAttempts = 0, this.maxCreateAttempts = 10, this.sceneInitialized = !1, this.environmentWaitFrames = 0, this.maxEnvironmentWaitFrames = 300, this.disposed = !1, this.convertedEnvTexture = null, this.resumable = !1, this.lastCameraMoveTime = -1 / 0, this.cameraDirty = !1, this.events = new rr(), this.settings = {
5927
+ this.pathTracer = null, this.enabled = !1, this.renderer = null, this.sampleCount = 0, this.createAttempts = 0, this.maxCreateAttempts = 10, this.sceneInitialized = !1, this.environmentWaitFrames = 0, this.maxEnvironmentWaitFrames = 300, this.disposed = !1, this.convertedEnvTexture = null, this.resumable = !1, this.lastCameraMoveTime = -1 / 0, this.cameraDirty = !1, this.events = new rr(), this.rasterFadeTarget = null, this.fadeQuad = null, this.fadeToneMapping = null, this.fadeSupported = !0, this.settings = {
5928
5928
  samples: ar,
5929
5929
  bounces: 4,
5930
5930
  // Reduce bounces for better performance
5931
5931
  transmissiveBounces: 2,
5932
5932
  // Reduce transmissive bounces
5933
- renderScale: 0.5,
5933
+ renderScale: 1,
5934
5934
  // Start with lower resolution for better performance
5935
5935
  lowResScale: 0.5,
5936
5936
  dynamicLowRes: !0,
@@ -5938,24 +5938,28 @@ const pe = class pe {
5938
5938
  };
5939
5939
  }
5940
5940
  /**
5941
- * Hand the scene to the path tracer with the viewer's own contact-shadow
5942
- * helpers hidden: the tracer computes physically-correct contact shadows
5943
- * itself, so ingesting the baked disc double-darkens the contact area (and
5944
- * the live ShadowMaterial catcher is equally meaningless to it). The
5945
- * generator skips invisible nodes; visibility is restored right after the
5946
- * ingest so the raster fallback path keeps its baked shadow.
5941
+ * Hand the scene to the path tracer with the raster-only contact-shadow
5942
+ * helpers hidden and the tracer-only ground floor shown. The `ShadowMaterial`
5943
+ * catcher (and the baked disc) are raster shadow-map tricks the tracer can't
5944
+ * use — ingesting them double-darkens or floats the contact area — so they're
5945
+ * hidden; the PATH_TRACING_FLOOR_FLAG disc is the mirror image, a real matte
5946
+ * surface kept invisible in the raster view and flipped on only here so the
5947
+ * tracer has something physical to cast a contact shadow onto (otherwise the
5948
+ * model floats in the traced render). The generator only reads currently-
5949
+ * visible nodes, and both sets are restored right after the ingest so the
5950
+ * raster fallback keeps its clean invisible-floor look.
5947
5951
  */
5948
5952
  ingestSceneWithoutShadowHelpers(e, t) {
5949
- var i;
5950
- const r = [];
5951
- e.traverse((o) => {
5952
- var a;
5953
- (a = o.userData) != null && a[ir] && o.visible && r.push(o);
5954
- }), r.forEach((o) => o.visible = !1);
5953
+ var s;
5954
+ const r = [], i = [];
5955
+ e.traverse((a) => {
5956
+ var l, u;
5957
+ (l = a.userData) != null && l[ir] && a.visible ? r.push(a) : (u = a.userData) != null && u[sr] && !a.visible && i.push(a);
5958
+ }), r.forEach((a) => a.visible = !1), i.forEach((a) => a.visible = !0);
5955
5959
  try {
5956
- (i = this.pathTracer) == null || i.setScene(e, t);
5960
+ (s = this.pathTracer) == null || s.setScene(e, t);
5957
5961
  } finally {
5958
- r.forEach((o) => o.visible = !0);
5962
+ r.forEach((a) => a.visible = !0), i.forEach((a) => a.visible = !1);
5959
5963
  }
5960
5964
  }
5961
5965
  /**
@@ -5970,32 +5974,32 @@ const pe = class pe {
5970
5974
  if (!i)
5971
5975
  return null;
5972
5976
  i.drawImage(t, 0, 0);
5973
- const o = i.getImageData(0, 0, r.width, r.height), a = new Float32Array(o.data.length);
5974
- for (let f = 0; f < o.data.length; f++)
5975
- a[f] = o.data[f] / 255;
5976
- const l = new J.DataTexture(
5977
+ const s = i.getImageData(0, 0, r.width, r.height), a = new Float32Array(s.data.length);
5978
+ for (let u = 0; u < s.data.length; u++)
5979
+ a[u] = s.data[u] / 255;
5980
+ const l = new _.DataTexture(
5977
5981
  a,
5978
5982
  r.width,
5979
5983
  r.height,
5980
- J.RGBAFormat,
5981
- J.FloatType
5984
+ _.RGBAFormat,
5985
+ _.FloatType
5982
5986
  );
5983
5987
  return l.mapping = e.mapping, l.wrapS = e.wrapS, l.wrapT = e.wrapT, l.magFilter = e.magFilter, l.minFilter = e.minFilter, l.anisotropy = e.anisotropy, l.needsUpdate = !0, l;
5984
5988
  }
5985
5989
  async initialize(e) {
5986
5990
  try {
5987
5991
  return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ? S.ok(void 0) : S.err(
5988
- new B(
5992
+ new L(
5989
5993
  "Path tracing is not supported in this environment",
5990
- W.PATH_TRACING_INIT_FAILED,
5994
+ U.PATH_TRACING_INIT_FAILED,
5991
5995
  { reason: "WebGL2 or required extensions not available" }
5992
5996
  )
5993
5997
  );
5994
5998
  } catch (t) {
5995
5999
  return S.err(
5996
- new B(
6000
+ new L(
5997
6001
  "Failed to initialize path tracing",
5998
- W.PATH_TRACING_INIT_FAILED,
6002
+ U.PATH_TRACING_INIT_FAILED,
5999
6003
  { originalError: t }
6000
6004
  )
6001
6005
  );
@@ -6004,24 +6008,24 @@ const pe = class pe {
6004
6008
  createPathTracer() {
6005
6009
  if (this.disposed)
6006
6010
  return S.err(
6007
- new B(
6011
+ new L(
6008
6012
  "Instance is disposed",
6009
- W.INVALID_STATE
6013
+ U.INVALID_STATE
6010
6014
  )
6011
6015
  );
6012
6016
  try {
6013
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6014
- return e ? (this.pathTracer = new Xa(e), this.pathTracer.tiles && "set" in this.pathTracer.tiles && this.pathTracer.tiles.set(1, 1), this.pathTracer.bounces = this.settings.bounces, this.settings.transmissiveBounces !== void 0 && (this.pathTracer.transmissiveBounces = this.settings.transmissiveBounces), this.pathTracer.renderScale = this.settings.renderScale, this.pathTracer.dynamicLowRes = this.settings.dynamicLowRes, this.pathTracer.lowResScale = this.settings.lowResScale, e.setRenderTarget(null), S.ok(void 0)) : S.err(
6015
- new B(
6017
+ const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6018
+ return e ? (this.pathTracer = new Qa(e), this.pathTracer.tiles && "set" in this.pathTracer.tiles && this.pathTracer.tiles.set(1, 1), this.pathTracer.bounces = this.settings.bounces, this.settings.transmissiveBounces !== void 0 && (this.pathTracer.transmissiveBounces = this.settings.transmissiveBounces), this.pathTracer.renderScale = this.settings.renderScale, this.pathTracer.dynamicLowRes = this.settings.dynamicLowRes, this.pathTracer.lowResScale = this.settings.lowResScale, e.setRenderTarget(null), S.ok(void 0)) : S.err(
6019
+ new L(
6016
6020
  "Renderer not ready, will retry",
6017
- W.RENDERER_NOT_INITIALIZED
6021
+ U.RENDERER_NOT_INITIALIZED
6018
6022
  )
6019
6023
  );
6020
6024
  } catch (e) {
6021
6025
  return S.err(
6022
- new B(
6026
+ new L(
6023
6027
  "Failed to create path tracer",
6024
- W.PATH_TRACING_INIT_FAILED,
6028
+ U.PATH_TRACING_INIT_FAILED,
6025
6029
  { originalError: e }
6026
6030
  )
6027
6031
  );
@@ -6030,7 +6034,7 @@ const pe = class pe {
6030
6034
  setEnabled(e) {
6031
6035
  if (this.enabled !== e && (this.enabled = e, !e)) {
6032
6036
  this.resumable = !1, this.reset(), this.sceneInitialized = !1;
6033
- const t = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6037
+ const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6034
6038
  t && (t.autoClear = !0);
6035
6039
  }
6036
6040
  }
@@ -6066,18 +6070,18 @@ const pe = class pe {
6066
6070
  const i = this.extractThreeObjects(e, t);
6067
6071
  if (!i)
6068
6072
  return S.err(
6069
- new B(
6073
+ new L(
6070
6074
  "Could not extract Three.js scene or camera",
6071
- W.INVALID_PARAMETER
6075
+ U.INVALID_PARAMETER
6072
6076
  )
6073
6077
  );
6074
- const { threeScene: o, threeCamera: a } = i;
6078
+ const { threeScene: s, threeCamera: a } = i;
6075
6079
  if (!this.sceneInitialized) {
6076
6080
  const l = await this.initializeSceneForPathTracing(
6077
6081
  r,
6078
6082
  e,
6079
6083
  t,
6080
- o,
6084
+ s,
6081
6085
  a
6082
6086
  );
6083
6087
  if (l)
@@ -6086,9 +6090,9 @@ const pe = class pe {
6086
6090
  return this.sceneInitialized ? this.accumulateSample(r, e, t) : r.render(e, t);
6087
6091
  } catch (i) {
6088
6092
  return S.err(
6089
- new B(
6093
+ new L(
6090
6094
  "Failed to render with path tracing",
6091
- W.RENDER_FAILED,
6095
+ U.RENDER_FAILED,
6092
6096
  { originalError: i }
6093
6097
  )
6094
6098
  );
@@ -6102,10 +6106,10 @@ const pe = class pe {
6102
6106
  * while still waiting for the renderer, or after giving up and disabling.
6103
6107
  */
6104
6108
  ensurePathTracerCreated(e, t, r) {
6105
- var o;
6109
+ var s;
6106
6110
  this.createAttempts++;
6107
6111
  const i = this.createPathTracer();
6108
- return i.ok ? (this.createAttempts = 0, null) : (this.createAttempts < this.maxCreateAttempts && ((o = i.error) == null ? void 0 : o.message) === "Renderer not ready, will retry" || (this.disableAfterSelfPause("gave-up"), this.createAttempts = 0), e.render(t, r));
6112
+ return i.ok ? (this.createAttempts = 0, null) : (this.createAttempts < this.maxCreateAttempts && ((s = i.error) == null ? void 0 : s.message) === "Renderer not ready, will retry" || (this.disableAfterSelfPause("gave-up"), this.createAttempts = 0), e.render(t, r));
6109
6113
  }
6110
6114
  /** Unwraps the Three.js scene/camera from their adapters, or null if either fails. */
6111
6115
  extractThreeObjects(e, t) {
@@ -6120,47 +6124,47 @@ const pe = class pe {
6120
6124
  * Result when render() should return it immediately instead — still
6121
6125
  * waiting, or the environment shape isn't one the tracer can use.
6122
6126
  */
6123
- async initializeSceneForPathTracing(e, t, r, i, o) {
6127
+ async initializeSceneForPathTracing(e, t, r, i, s) {
6124
6128
  var a;
6125
6129
  try {
6126
6130
  const l = i.__originalEnvironmentTexture;
6127
6131
  if (!i.environment && !l)
6128
6132
  return this.environmentWaitFrames++, this.environmentWaitFrames >= this.maxEnvironmentWaitFrames && (this.disableAfterSelfPause("gave-up"), this.environmentWaitFrames = 0), e.render(t, r);
6129
6133
  if (this.environmentWaitFrames = 0, l && l.isCubeTexture) {
6130
- const f = i.environment;
6134
+ const u = i.environment;
6131
6135
  i.environment = l;
6132
6136
  try {
6133
- this.ingestSceneWithoutShadowHelpers(i, o), this.sceneInitialized = !0;
6137
+ this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
6134
6138
  } finally {
6135
- i.environment = f;
6139
+ i.environment = u;
6136
6140
  }
6137
- } else if (l && l.mapping === J.EquirectangularReflectionMapping) {
6138
- let f = l;
6141
+ } else if (l && l.mapping === _.EquirectangularReflectionMapping) {
6142
+ let u = l;
6139
6143
  if (l.image instanceof HTMLImageElement)
6140
6144
  if (this.convertedEnvTexture)
6141
- f = this.convertedEnvTexture;
6145
+ u = this.convertedEnvTexture;
6142
6146
  else {
6143
6147
  const h = this.convertToDataTexture(l);
6144
6148
  if (!h)
6145
6149
  throw new Error("Failed to convert environment texture to DataTexture");
6146
- this.convertedEnvTexture = h, f = h;
6150
+ this.convertedEnvTexture = h, u = h;
6147
6151
  }
6148
6152
  const d = i.environment;
6149
- i.environment = f;
6153
+ i.environment = u;
6150
6154
  try {
6151
6155
  const h = l.image;
6152
- h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((u) => {
6156
+ h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((f) => {
6153
6157
  h.onload = () => {
6154
- l.needsUpdate = !0, u();
6158
+ l.needsUpdate = !0, f();
6155
6159
  }, h.onerror = () => {
6156
- u();
6157
- }, h.complete && u();
6158
- }), this.ingestSceneWithoutShadowHelpers(i, o), this.sceneInitialized = !0, i.environment = d;
6160
+ f();
6161
+ }, h.complete && f();
6162
+ }), this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0, i.environment = d;
6159
6163
  } catch (h) {
6160
6164
  throw i.environment = d, h;
6161
6165
  }
6162
- } else if (((a = i.environment) == null ? void 0 : a.mapping) === J.EquirectangularReflectionMapping)
6163
- this.ingestSceneWithoutShadowHelpers(i, o), this.sceneInitialized = !0;
6166
+ } else if (((a = i.environment) == null ? void 0 : a.mapping) === _.EquirectangularReflectionMapping)
6167
+ this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
6164
6168
  else
6165
6169
  return this.disableAfterSelfPause("gave-up"), e.render(t, r);
6166
6170
  } catch (l) {
@@ -6174,29 +6178,140 @@ const pe = class pe {
6174
6178
  * feedback, accumulates a tracer sample, and detects completion.
6175
6179
  */
6176
6180
  accumulateSample(e, t, r) {
6177
- var o, a;
6181
+ var s, a;
6178
6182
  if (this.sampleCount === 0)
6179
6183
  try {
6180
- (o = this.pathTracer) == null || o.updateLights();
6184
+ (s = this.pathTracer) == null || s.updateLights();
6181
6185
  } catch (l) {
6182
6186
  console.warn("Failed to update lights for path tracing:", l);
6183
6187
  }
6184
6188
  const i = e.render(t, r);
6185
- return i.ok ? performance.now() - this.lastCameraMoveTime < pe.CAMERA_SETTLE_MS ? S.ok(void 0) : (this.cameraDirty && (this.cameraDirty = !1, (a = this.pathTracer) == null || a.updateCamera()), this.accumulateOneSample(), this.sampleCount++, this.sampleCount === this.settings.samples ? this.captureCompletedFrame() : S.ok(void 0)) : i;
6189
+ if (!i.ok)
6190
+ return i;
6191
+ if (performance.now() - this.lastCameraMoveTime < M.CAMERA_SETTLE_MS)
6192
+ return S.ok(void 0);
6193
+ if (this.cameraDirty && (this.cameraDirty = !1, (a = this.pathTracer) == null || a.updateCamera()), this.fadeSupported && this.sampleCount === 0 && this.runFadeStep(() => this.captureRasterFade(e, t, r)), this.accumulateOneSample(), this.sampleCount++, this.fadeSupported && this.sampleCount < M.FADE_SAMPLES) {
6194
+ const l = 1 - this.pathTracedLayerOpacity(this.sampleCount);
6195
+ this.runFadeStep(() => this.renderRasterFade(l));
6196
+ }
6197
+ return this.sampleCount === this.settings.samples ? this.captureCompletedFrame() : S.ok(void 0);
6198
+ }
6199
+ /** Run a cosmetic dissolve step, disabling the dissolve for the rest of the
6200
+ * session if it throws — it must never take the render down with it. */
6201
+ runFadeStep(e) {
6202
+ try {
6203
+ e();
6204
+ } catch (t) {
6205
+ console.warn("Path-tracing startup dissolve unavailable; showing samples directly:", t), this.fadeSupported = !1;
6206
+ }
6207
+ }
6208
+ /** Opacity of the path-traced layer over the raster snapshot as accumulation
6209
+ * progresses: 0 for the opening (noisiest) samples, eased up to a low preview
6210
+ * cap while the image is still grainy — so the tracer's noise never reads
6211
+ * above the cap — then released to fully opaque as it resolves. */
6212
+ pathTracedLayerOpacity(e) {
6213
+ const t = M.FADE_HOLD_SAMPLES, r = M.FADE_SAMPLES, i = M.FADE_PREVIEW_OPACITY, s = t + (r - t) * M.FADE_RELEASE_FRACTION;
6214
+ return e < s ? i * M.smoothstep(t, s, e) : i + (1 - i) * M.smoothstep(s, r, e);
6215
+ }
6216
+ static smoothstep(e, t, r) {
6217
+ const i = Math.min(1, Math.max(0, (r - e) / (t - e)));
6218
+ return i * i * (3 - 2 * i);
6219
+ }
6220
+ /** Render the current raster frame into a linear offscreen target to fade out
6221
+ * over the resolving path-traced image. It is captured pre-tone-mapping
6222
+ * (three only tone-maps when drawing to the canvas, never to a target), so the
6223
+ * fade shader applies the renderer's tone mapping + sRGB itself and the
6224
+ * snapshot matches the frame on screen instead of coming out dark. */
6225
+ captureRasterFade(e, t, r) {
6226
+ const i = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6227
+ if (!i)
6228
+ return;
6229
+ const s = i.getDrawingBufferSize(new _.Vector2());
6230
+ this.rasterFadeTarget ? (this.rasterFadeTarget.width !== s.x || this.rasterFadeTarget.height !== s.y) && this.rasterFadeTarget.setSize(s.x, s.y) : (this.rasterFadeTarget = new _.WebGLRenderTarget(s.x, s.y, { type: _.HalfFloatType }), this.rasterFadeTarget.texture.colorSpace = _.LinearSRGBColorSpace);
6231
+ const a = i.getRenderTarget();
6232
+ i.setRenderTarget(this.rasterFadeTarget), e.render(t, r), i.setRenderTarget(a);
6233
+ }
6234
+ /** Composite the captured raster over the on-canvas path-traced frame at the
6235
+ * given opacity (1 = pure raster, 0 = fully revealed path tracing). */
6236
+ renderRasterFade(e) {
6237
+ var a, l;
6238
+ const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6239
+ if (!t || !this.rasterFadeTarget)
6240
+ return;
6241
+ (!this.fadeQuad || this.fadeToneMapping !== t.toneMapping) && ((l = (a = this.fadeQuad) == null ? void 0 : a.material) == null || l.dispose(), this.fadeToneMapping = t.toneMapping, this.fadeQuad = new Y(this.createFadeMaterial(t.toneMapping)));
6242
+ const r = this.fadeQuad.material;
6243
+ r.uniforms.tRaster.value = this.rasterFadeTarget.texture, r.uniforms.uOpacity.value = e;
6244
+ const i = t.autoClear, s = t.getRenderTarget();
6245
+ t.setRenderTarget(null), t.autoClear = !1;
6246
+ try {
6247
+ this.fadeQuad.render(t);
6248
+ } finally {
6249
+ t.autoClear = i, t.setRenderTarget(s);
6250
+ }
6251
+ }
6252
+ /** A fade material that tone-maps + sRGB-encodes a linear snapshot exactly the
6253
+ * way the renderer would when drawing to the canvas (mirrors OutputPass), then
6254
+ * applies the fade alpha — so the dissolve's first frame matches the on-screen
6255
+ * raster instead of the darker un-tone-mapped image. */
6256
+ createFadeMaterial(e) {
6257
+ const t = {
6258
+ [_.LinearToneMapping]: "LINEAR_TONE_MAPPING",
6259
+ [_.ReinhardToneMapping]: "REINHARD_TONE_MAPPING",
6260
+ [_.CineonToneMapping]: "CINEON_TONE_MAPPING",
6261
+ [_.ACESFilmicToneMapping]: "ACES_FILMIC_TONE_MAPPING",
6262
+ [_.AgXToneMapping]: "AGX_TONE_MAPPING",
6263
+ [_.NeutralToneMapping]: "NEUTRAL_TONE_MAPPING"
6264
+ }, r = {}, i = t[e];
6265
+ return i && (r[i] = ""), new _.ShaderMaterial({
6266
+ defines: r,
6267
+ uniforms: {
6268
+ tRaster: { value: null },
6269
+ uOpacity: { value: 1 }
6270
+ },
6271
+ vertexShader: `
6272
+ varying vec2 vUv;
6273
+ void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }
6274
+ `,
6275
+ fragmentShader: `
6276
+ uniform sampler2D tRaster;
6277
+ uniform float uOpacity;
6278
+ varying vec2 vUv;
6279
+ void main() {
6280
+ vec3 color = texture2D( tRaster, vUv ).rgb;
6281
+ #ifdef LINEAR_TONE_MAPPING
6282
+ color = LinearToneMapping( color );
6283
+ #elif defined( REINHARD_TONE_MAPPING )
6284
+ color = ReinhardToneMapping( color );
6285
+ #elif defined( CINEON_TONE_MAPPING )
6286
+ color = CineonToneMapping( color );
6287
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
6288
+ color = ACESFilmicToneMapping( color );
6289
+ #elif defined( AGX_TONE_MAPPING )
6290
+ color = AgXToneMapping( color );
6291
+ #elif defined( NEUTRAL_TONE_MAPPING )
6292
+ color = NeutralToneMapping( color );
6293
+ #endif
6294
+ gl_FragColor = vec4( sRGBTransferOETF( vec4( color, 1.0 ) ).rgb, uOpacity );
6295
+ }
6296
+ `,
6297
+ transparent: !0,
6298
+ depthTest: !1,
6299
+ depthWrite: !1
6300
+ });
6186
6301
  }
6187
6302
  /**
6188
6303
  * Render while path tracing is disabled: keep the final accumulated image on
6189
6304
  * screen if we just completed, otherwise delegate to the standard renderer.
6190
6305
  */
6191
6306
  renderWhileDisabled(e, t) {
6192
- return this.renderer ? this.sampleCount >= this.settings.samples && this.sampleCount > 0 ? (this.pathTracer && ee(this.renderer) && this.renderer.getInternalRenderer().setRenderTarget(null), S.ok(void 0)) : this.renderer.render(e, t) : S.ok(void 0);
6307
+ return this.renderer ? this.sampleCount >= this.settings.samples && this.sampleCount > 0 ? (this.pathTracer && j(this.renderer) && this.renderer.getInternalRenderer().setRenderTarget(null), S.ok(void 0)) : this.renderer.render(e, t) : S.ok(void 0);
6193
6308
  }
6194
6309
  /**
6195
6310
  * Render a single path-tracing sample into the internal buffer, preserving the
6196
6311
  * renderer's autoClear/render-target state so the standard view stays visible.
6197
6312
  */
6198
6313
  accumulateOneSample() {
6199
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6314
+ const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6200
6315
  if (!e)
6201
6316
  throw new Error("Three.js renderer not available");
6202
6317
  const t = e.autoClear, r = e.getRenderTarget();
@@ -6210,7 +6325,7 @@ const pe = class pe {
6210
6325
  * stale frame frozen on screen.
6211
6326
  */
6212
6327
  captureCompletedFrame() {
6213
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6328
+ const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6214
6329
  if (e && this.pathTracer)
6215
6330
  try {
6216
6331
  const t = e.autoClear;
@@ -6255,14 +6370,14 @@ const pe = class pe {
6255
6370
  }
6256
6371
  this.pathTracer = null;
6257
6372
  }
6258
- this.convertedEnvTexture && (this.convertedEnvTexture.dispose(), this.convertedEnvTexture = null), this.sampleCount = 0, this.sceneInitialized = !1, this.createAttempts = 0, this.renderer = null;
6373
+ this.convertedEnvTexture && (this.convertedEnvTexture.dispose(), this.convertedEnvTexture = null), this.fadeQuad && (this.fadeQuad.material.dispose(), this.fadeQuad = null), this.fadeToneMapping = null, this.rasterFadeTarget && (this.rasterFadeTarget.dispose(), this.rasterFadeTarget = null), this.sampleCount = 0, this.sceneInitialized = !1, this.createAttempts = 0, this.renderer = null;
6259
6374
  }
6260
6375
  isSupported() {
6261
6376
  return document.createElement("canvas").getContext("webgl2") !== null;
6262
6377
  }
6263
6378
  };
6264
- pe.CAMERA_SETTLE_MS = 200;
6265
- let ut = pe;
6379
+ M.CAMERA_SETTLE_MS = 200, M.FADE_SAMPLES = 256, M.FADE_HOLD_SAMPLES = 4, M.FADE_PREVIEW_OPACITY = 0.3, M.FADE_RELEASE_FRACTION = 0.5;
6380
+ let ut = M;
6266
6381
  export {
6267
6382
  ut as ThreePathTracingService
6268
6383
  };