softbox 4.7.0 → 4.9.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,8 +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 Ct, ByteType as Be, ShortType as Ft, RGBAFormat as I, RGBAIntegerFormat as Ae, RGIntegerFormat as ft, RedIntegerFormat as Dt, RGFormat as dt, RedFormat as me, BufferAttribute as P, BufferGeometry as q, Matrix4 as O, Matrix3 as Pt, Vector3 as F, Vector4 as K, MeshBasicMaterial as Et, Mesh as mt, OrthographicCamera as kt, Float32BufferAttribute as We, ShaderMaterial as ge, NoBlending as ie, WebGLRenderTarget as ae, Vector2 as $, PerspectiveCamera as pt, DataUtils as k, HalfFloatType as D, LinearFilter as C, RepeatWrapping as z, ClampToEdgeWrapping as N, Source as Ot, Quaternion as zt, DataArrayTexture as Nt, DoubleSide as Ht, BackSide as Bt, FrontSide as Wt, WebGLArrayRenderTarget as Lt, Color as se, NoToneMapping as Ut, NormalBlending as gt, EquirectangularReflectionMapping as vt, Spherical as Vt, LinearMipMapLinearFilter as Gt, Clock as qt, Scene as $t, AdditiveBlending as jt } from "three";
3
- import { g as Yt, a as Xt, B as Le, I as Qt, C as Kt, O as Zt, S as Jt, b as er, L as tr, c as rr, M as ar, T as ir, D as sr, d as or, R as _, e as B, E as W } from "./index-DXbG9xpu.js";
4
- function nr(s) {
5
- 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-op1Vhyk7.js";
5
+ function or(o) {
6
+ switch (o) {
6
7
  case 1:
7
8
  return "R";
8
9
  case 2:
@@ -14,22 +15,22 @@ function nr(s) {
14
15
  }
15
16
  throw new Error();
16
17
  }
17
- function lr(s) {
18
- switch (s) {
18
+ function nr(o) {
19
+ switch (o) {
19
20
  case 1:
20
- return me;
21
+ return pe;
21
22
  case 2:
22
- return dt;
23
+ return ht;
23
24
  case 3:
24
25
  return I;
25
26
  case 4:
26
27
  return I;
27
28
  }
28
29
  }
29
- function Ue(s) {
30
- switch (s) {
30
+ function Le(o) {
31
+ switch (o) {
31
32
  case 1:
32
- return Dt;
33
+ return Ft;
33
34
  case 2:
34
35
  return ft;
35
36
  case 3:
@@ -38,7 +39,7 @@ function Ue(s) {
38
39
  return Ae;
39
40
  }
40
41
  }
41
- class xt extends M {
42
+ class gt extends F {
42
43
  constructor() {
43
44
  super(), this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.overrideItemSize = null, this._forcedType = null;
44
45
  }
@@ -59,59 +60,59 @@ class xt extends M {
59
60
  throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");
60
61
  e.itemSize = t, e.count = i * r / t;
61
62
  }
62
- const o = e.itemSize, a = e.count, l = e.normalized, h = e.array.constructor, d = h.BYTES_PER_ELEMENT;
63
- let f = this._forcedType, u = o;
64
- if (f === null)
65
- switch (h) {
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
+ if (h === null)
66
+ switch (u) {
66
67
  case Float32Array:
67
- f = R;
68
+ h = R;
68
69
  break;
69
70
  case Uint8Array:
70
71
  case Uint16Array:
71
72
  case Uint32Array:
72
- f = re;
73
+ h = ae;
73
74
  break;
74
75
  case Int8Array:
75
76
  case Int16Array:
76
77
  case Int32Array:
77
- f = we;
78
+ h = we;
78
79
  break;
79
80
  }
80
- let n, x, m, g, c = nr(o);
81
- switch (f) {
81
+ let n, x, m, g, c = or(s);
82
+ switch (h) {
82
83
  case R:
83
- m = 1, x = lr(o), l && d === 1 ? (g = h, c += "8", h === 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);
84
85
  break;
85
86
  case we:
86
- c += d * 8 + "I", m = l ? Math.pow(2, h.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Ue(o), d === 1 ? (g = Int8Array, n = Be) : d === 2 ? (g = Int16Array, n = Ft) : (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);
87
88
  break;
88
- case re:
89
- c += d * 8 + "UI", m = l ? Math.pow(2, h.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Ue(o), d === 1 ? (g = Uint8Array, n = Me) : d === 2 ? (g = Uint16Array, n = Ct) : (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);
90
91
  break;
91
92
  }
92
- u === 3 && (x === I || x === Ae) && (u = 4);
93
- 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;
94
95
  e.normalized = !1;
95
96
  for (let w = 0; w < a; w++) {
96
- const E = u * w;
97
- 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);
98
99
  }
99
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;
100
101
  }
101
102
  }
102
- class bt extends xt {
103
+ class vt extends gt {
103
104
  constructor() {
104
- super(), this._forcedType = re;
105
+ super(), this._forcedType = ae;
105
106
  }
106
107
  }
107
- class yt extends xt {
108
+ class xt extends gt {
108
109
  constructor() {
109
110
  super(), this._forcedType = R;
110
111
  }
111
112
  }
112
- class cr {
113
+ class lr {
113
114
  constructor() {
114
- this.index = new bt(), this.position = new yt(), 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;
115
116
  }
116
117
  /**
117
118
  * Updates the object and associated textures with data from the provided BVH.
@@ -121,16 +122,16 @@ class cr {
121
122
  */
122
123
  updateFrom(e) {
123
124
  const { geometry: t } = e;
124
- if (hr(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) {
125
126
  const r = e._indirectBuffer;
126
127
  if (this._cachedIndexAttr === null || this._cachedIndexAttr.count !== r.length)
127
128
  if (t.index)
128
129
  this._cachedIndexAttr = t.index.clone();
129
130
  else {
130
- const i = Yt(Xt(t));
131
- this._cachedIndexAttr = new P(i, 1, !1);
131
+ const i = $t(jt(t));
132
+ this._cachedIndexAttr = new O(i, 1, !1);
132
133
  }
133
- ur(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
134
+ cr(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
134
135
  } else
135
136
  this.index.updateFrom(t.index);
136
137
  }
@@ -144,32 +145,32 @@ class cr {
144
145
  e && e.dispose(), t && t.dispose(), r && r.dispose(), i && i.dispose();
145
146
  }
146
147
  }
147
- function ur(s, e, t) {
148
- const r = t.array, i = s.index ? s.index.array : null;
149
- for (let o = 0, a = e.length; o < a; o++) {
150
- const l = 3 * o, h = 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];
151
152
  for (let d = 0; d < 3; d++)
152
- r[l + d] = i ? i[h + d] : h + d;
153
+ r[l + d] = i ? i[u + d] : u + d;
153
154
  }
154
155
  }
155
- function hr(s, e, t) {
156
- const r = s._roots;
156
+ function ur(o, e, t) {
157
+ const r = o._roots;
157
158
  if (r.length !== 1)
158
159
  throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");
159
- const i = r[0], o = new Uint16Array(i), a = new Uint32Array(i), l = new Float32Array(i), h = i.byteLength / Le, d = 2 * Math.ceil(Math.sqrt(h / 2)), f = new Float32Array(4 * d * d), u = Math.ceil(Math.sqrt(h)), n = new Uint32Array(2 * u * u);
160
- for (let x = 0; x < h; x++) {
161
- const m = x * Le / 4, g = m * 2, c = er(m);
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
+ const m = x * We / 4, g = m * 2, c = Zt(m);
162
163
  for (let p = 0; p < 3; p++)
163
- f[8 * x + 0 + p] = l[c + 0 + p], f[8 * x + 4 + p] = l[c + 3 + p];
164
- if (Qt(g, o)) {
165
- const p = Kt(g, o), v = Zt(m, a), b = tr | p;
164
+ h[8 * x + 0 + p] = l[c + 0 + p], h[8 * x + 4 + p] = l[c + 3 + p];
165
+ if (Yt(g, s)) {
166
+ const p = Xt(g, s), v = Qt(m, a), b = Jt | p;
166
167
  n[x * 2 + 0] = b, n[x * 2 + 1] = v;
167
168
  } else {
168
- const p = a[m + 6], v = Jt(m, a);
169
+ const p = a[m + 6], v = Kt(m, a);
169
170
  n[x * 2 + 0] = v, n[x * 2 + 1] = p;
170
171
  }
171
172
  }
172
- e.image.data = f, 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();
173
174
  }
174
175
  const fr = (
175
176
  /* glsl */
@@ -256,7 +257,7 @@ void ndcToCameraRay(
256
257
 
257
258
  }
258
259
  `
259
- ), dr = (
260
+ ), hr = (
260
261
  /* glsl */
261
262
  `
262
263
 
@@ -463,7 +464,7 @@ bool _bvhIntersectFirstHit(
463
464
 
464
465
  }
465
466
  `
466
- ), mr = (
467
+ ), dr = (
467
468
  /* glsl */
468
469
  `
469
470
  struct BVH {
@@ -477,306 +478,306 @@ struct BVH {
477
478
  };
478
479
  `
479
480
  );
480
- function Tt(s, e, t = 0) {
481
- if (s.isInterleavedBufferAttribute) {
482
- const r = s.itemSize;
483
- 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++) {
484
485
  const a = i + t;
485
- 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));
486
487
  }
487
488
  } else {
488
- const r = e.array, i = r.constructor, o = r.BYTES_PER_ELEMENT * s.itemSize * t;
489
- 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);
490
491
  }
491
492
  }
492
- function te(s, e = null) {
493
- const t = s.array.constructor, r = s.normalized, i = s.itemSize, o = e === null ? s.count : e;
494
- 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);
495
496
  }
496
- function Q(s, e) {
497
- if (!s && !e)
497
+ function J(o, e) {
498
+ if (!o && !e)
498
499
  return !0;
499
- if (!!s != !!e)
500
+ if (!!o != !!e)
500
501
  return !1;
501
- const t = s.count === e.count, r = s.normalized === e.normalized, i = s.array.constructor === e.array.constructor, o = s.itemSize === e.itemSize;
502
- 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);
503
504
  }
504
- function pr(s) {
505
- const e = s[0].index !== null, t = new Set(Object.keys(s[0].attributes));
506
- 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"))
507
508
  throw new Error("StaticGeometryGenerator: position attribute is required.");
508
- for (let r = 0; r < s.length; ++r) {
509
- const i = s[r];
510
- let o = 0;
509
+ for (let r = 0; r < o.length; ++r) {
510
+ const i = o[r];
511
+ let s = 0;
511
512
  if (e !== (i.index !== null))
512
513
  throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
513
514
  for (const a in i.attributes) {
514
515
  if (!t.has(a))
515
516
  throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + a + '" attribute exists among all geometries, or in none of them.');
516
- o++;
517
+ s++;
517
518
  }
518
- if (o !== t.size)
519
+ if (s !== t.size)
519
520
  throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.");
520
521
  }
521
522
  }
522
- function gr(s) {
523
+ function pr(o) {
523
524
  let e = 0;
524
- for (let t = 0, r = s.length; t < r; t++)
525
- e += s[t].getIndex().count;
525
+ for (let t = 0, r = o.length; t < r; t++)
526
+ e += o[t].getIndex().count;
526
527
  return e;
527
528
  }
528
- function vr(s) {
529
+ function gr(o) {
529
530
  let e = 0;
530
- for (let t = 0, r = s.length; t < r; t++)
531
- e += s[t].getAttribute("position").count;
531
+ for (let t = 0, r = o.length; t < r; t++)
532
+ e += o[t].getAttribute("position").count;
532
533
  return e;
533
534
  }
534
- function xr(s, e, t) {
535
- s.index && s.index.count !== e && s.setIndex(null);
536
- 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;
537
538
  for (const i in r)
538
- r[i].count !== t && s.deleteAttribute(i);
539
+ r[i].count !== t && o.deleteAttribute(i);
539
540
  }
540
- function br(s, e = {}, t = new q()) {
541
+ function xr(o, e = {}, t = new ee()) {
541
542
  const {
542
543
  useGroups: r = !1,
543
544
  forceUpdate: i = !1,
544
- skipAssigningAttributes: o = [],
545
+ skipAssigningAttributes: s = [],
545
546
  overwriteIndex: a = !0
546
547
  } = e;
547
- pr(s);
548
- const l = s[0].index !== null, h = l ? gr(s) : -1, d = vr(s);
549
- if (xr(t, h, d), r) {
550
- let u = 0;
551
- for (let n = 0, x = s.length; n < x; n++) {
552
- 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];
553
554
  let g;
554
- 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;
555
556
  }
556
557
  }
557
558
  if (l) {
558
- let u = !1;
559
- if (t.index || (t.setIndex(new P(new Uint32Array(h), 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) {
560
561
  let n = 0, x = 0;
561
562
  const m = t.getIndex();
562
- for (let g = 0, c = s.length; g < c; g++) {
563
- const p = s[g], v = p.getIndex();
564
- 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]))
565
566
  for (let y = 0; y < v.count; ++y)
566
567
  m.setX(n + y, v.getX(y) + x);
567
568
  n += v.count, x += p.getAttribute("position").count;
568
569
  }
569
570
  }
570
571
  }
571
- const f = Object.keys(s[0].attributes);
572
- for (let u = 0, n = f.length; u < n; u++) {
572
+ const h = Object.keys(o[0].attributes);
573
+ for (let f = 0, n = h.length; f < n; f++) {
573
574
  let x = !1;
574
- const m = f[u];
575
+ const m = h[f];
575
576
  if (!t.getAttribute(m)) {
576
- const p = s[0].getAttribute(m);
577
- t.setAttribute(m, te(p, d)), x = !0;
577
+ const p = o[0].getAttribute(m);
578
+ t.setAttribute(m, re(p, d)), x = !0;
578
579
  }
579
580
  let g = 0;
580
581
  const c = t.getAttribute(m);
581
- for (let p = 0, v = s.length; p < v; p++) {
582
- const b = s[p], y = !i && !x && o[p], w = b.getAttribute(m);
583
- y || Tt(w, c, g), g += w.count;
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
+ y || bt(w, c, g), g += w.count;
584
585
  }
585
586
  }
586
587
  }
587
- function yr(s, e, t) {
588
- const r = s.index, o = s.attributes.position.count, a = r ? r.count : o;
589
- 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;
590
591
  l.length === 0 && (l = [{ count: a, start: 0, materialIndex: 0 }]);
591
- let h = s.getAttribute("materialIndex");
592
- if (!h || h.count !== o) {
593
- let f;
594
- t.length <= 255 ? f = new Uint8Array(o) : f = new Uint16Array(o), h = new P(f, 1, !1), s.deleteAttribute("materialIndex"), s.setAttribute("materialIndex", h);
595
- }
596
- const d = h.array;
597
- for (let f = 0; f < l.length; f++) {
598
- const u = l[f], n = u.start, x = u.count, m = Math.min(x, a - n), g = Array.isArray(e) ? e[u.materialIndex] : e, c = t.indexOf(g);
592
+ let u = o.getAttribute("materialIndex");
593
+ if (!u || u.count !== s) {
594
+ let h;
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
+ }
597
+ const d = u.array;
598
+ for (let h = 0; h < l.length; h++) {
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);
599
600
  for (let p = 0; p < m; p++) {
600
601
  let v = n + p;
601
602
  r && (v = r.getX(v)), d[v] = c;
602
603
  }
603
604
  }
604
605
  }
605
- function Tr(s, e) {
606
- if (!s.index) {
607
- 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);
608
609
  for (let i = 0; i < t; i++)
609
610
  r[i] = i;
610
- s.setIndex(r);
611
+ o.setIndex(r);
611
612
  }
612
- if (!s.attributes.normal && e && e.includes("normal") && s.computeVertexNormals(), !s.attributes.uv && e && e.includes("uv")) {
613
- const t = s.attributes.position.count;
614
- 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));
615
616
  }
616
- if (!s.attributes.uv2 && e && e.includes("uv2")) {
617
- const t = s.attributes.position.count;
618
- 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));
619
620
  }
620
- if (!s.attributes.tangent && e && e.includes("tangent"))
621
- if (s.attributes.uv && s.attributes.normal)
622
- s.computeTangents();
621
+ if (!o.attributes.tangent && e && e.includes("tangent"))
622
+ if (o.attributes.uv && o.attributes.normal)
623
+ o.computeTangents();
623
624
  else {
624
- const t = s.attributes.position.count;
625
- 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));
626
627
  }
627
- if (!s.attributes.color && e && e.includes("color")) {
628
- const t = s.attributes.position.count, r = new Float32Array(t * 4);
629
- 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));
630
631
  }
631
632
  }
632
- function De(s) {
633
+ function De(o) {
633
634
  let e = 0;
634
- if (s.byteLength !== 0) {
635
- const t = new Uint8Array(s);
636
- 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++) {
637
638
  const i = t[r];
638
639
  e = (e << 5) - e + i, e |= 0;
639
640
  }
640
641
  }
641
642
  return e;
642
643
  }
643
- function Ve(s) {
644
- let e = s.uuid;
645
- const t = Object.values(s.attributes);
646
- 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}`);
647
648
  const r = Object.keys(t).sort();
648
649
  for (const i of r) {
649
- const o = t[i];
650
- e += `${i}_${o.version}|`;
650
+ const s = t[i];
651
+ e += `${i}_${s.version}|`;
651
652
  }
652
653
  return e;
653
654
  }
654
- function Ge(s) {
655
- const e = s.skeleton;
655
+ function Ge(o) {
656
+ const e = o.skeleton;
656
657
  return e ? (e.boneTexture || e.computeBoneTexture(), `${De(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`) : null;
657
658
  }
658
- class wr {
659
+ class Tr {
659
660
  constructor(e = null) {
660
- 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);
661
662
  }
662
663
  updateFrom(e) {
663
664
  const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
664
- this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ve(t), this.primitiveCount = r, this.skeletonHash = Ge(e);
665
+ this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash = Ge(e);
665
666
  }
666
667
  didChange(e) {
667
668
  const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
668
- return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ve(t) && this.skeletonHash === Ge(e) && this.primitiveCount === r);
669
+ return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash === Ge(e) && this.primitiveCount === r);
669
670
  }
670
671
  }
671
- const L = /* @__PURE__ */ new F(), U = /* @__PURE__ */ new F(), V = /* @__PURE__ */ new F(), qe = /* @__PURE__ */ new K(), le = /* @__PURE__ */ new F(), Ie = /* @__PURE__ */ new F(), $e = /* @__PURE__ */ new K(), je = /* @__PURE__ */ new K(), ce = /* @__PURE__ */ new O(), Ye = /* @__PURE__ */ new O();
672
- function Xe(s, e, t) {
673
- const r = s.skeleton, i = s.geometry, o = r.bones, a = r.boneInverses;
674
- $e.fromBufferAttribute(i.attributes.skinIndex, e), je.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);
675
676
  for (let l = 0; l < 4; l++) {
676
- const h = je.getComponent(l);
677
- if (h !== 0) {
678
- const d = $e.getComponent(l);
679
- Ye.multiplyMatrices(o[d].matrixWorld, a[d]), Ir(ce, Ye, h);
677
+ const u = $e.getComponent(l);
678
+ if (u !== 0) {
679
+ const d = qe.getComponent(l);
680
+ je.multiplyMatrices(s[d].matrixWorld, a[d]), wr(ue, je, u);
680
681
  }
681
682
  }
682
- 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;
683
684
  }
684
- function Re(s, e, t, r, i) {
685
- le.set(0, 0, 0);
686
- for (let o = 0, a = s.length; o < a; o++) {
687
- const l = e[o], h = s[o];
688
- l !== 0 && (Ie.fromBufferAttribute(h, 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));
689
690
  }
690
- i.add(le);
691
+ i.add(ce);
691
692
  }
692
- function Ir(s, e, t) {
693
- const r = s.elements, i = e.elements;
694
- for (let o = 0, a = i.length; o < a; o++)
695
- 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;
696
697
  }
697
- function Rr(s) {
698
- const { index: e, attributes: t } = s;
698
+ function Ir(o) {
699
+ const { index: e, attributes: t } = o;
699
700
  if (e)
700
701
  for (let r = 0, i = e.count; r < i; r += 3) {
701
- const o = e.getX(r), a = e.getX(r + 2);
702
- 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);
703
704
  }
704
705
  else
705
706
  for (const r in t) {
706
- const i = t[r], o = i.itemSize;
707
+ const i = t[r], s = i.itemSize;
707
708
  for (let a = 0, l = i.count; a < l; a += 3)
708
- for (let h = 0; h < o; h++) {
709
- const d = i.getComponent(a, h), f = i.getComponent(a + 2, h);
710
- i.setComponent(a, h, f), i.setComponent(a + 2, h, 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);
711
712
  }
712
713
  }
713
- return s;
714
+ return o;
714
715
  }
715
- function _r(s, e = {}, t = new q()) {
716
+ function Rr(o, e = {}, t = new ee()) {
716
717
  e = {
717
718
  applyWorldTransforms: !0,
718
719
  attributes: [],
719
720
  ...e
720
721
  };
721
- const r = s.geometry, i = e.applyWorldTransforms, o = e.attributes.includes("normal"), a = e.attributes.includes("tangent"), l = r.attributes, h = 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;
722
723
  for (const v in t.attributes)
723
724
  (!e.attributes.includes(v) || !(v in r.attributes)) && t.deleteAttribute(v);
724
- !t.index && r.index && (t.index = r.index.clone()), h.position || t.setAttribute("position", te(l.position)), o && !h.normal && l.normal && t.setAttribute("normal", te(l.normal)), a && !h.tangent && l.tangent && t.setAttribute("tangent", te(l.tangent)), Q(r.index, t.index), Q(l.position, h.position), o && Q(l.normal, h.normal), a && Q(l.tangent, h.tangent);
725
- const d = l.position, f = 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 Pt();
726
- 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);
727
728
  for (let v = 0, b = l.position.count; v < b; v++)
728
- L.fromBufferAttribute(d, v), f && U.fromBufferAttribute(f, v), u && (qe.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), f && Xe(s, v, U), u && Xe(s, v, V)), i && L.applyMatrix4(s.matrixWorld), h.position.setXYZ(v, L.x, L.y, L.z), f && (i && U.applyNormalMatrix(p), h.normal.setXYZ(v, U.x, U.y, U.z)), u && (i && V.transformDirection(s.matrixWorld), h.tangent.setXYZW(v, V.x, V.y, V.z, qe.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));
729
730
  for (const v in e.attributes) {
730
731
  const b = e.attributes[v];
731
- b === "position" || b === "tangent" || b === "normal" || !(b in l) || (h[b] || t.setAttribute(b, te(l[b])), Q(l[b], h[b]), Tt(l[b], h[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]));
732
733
  }
733
- return s.matrixWorld.determinant() < 0 && Rr(t), t;
734
+ return o.matrixWorld.determinant() < 0 && Ir(t), t;
734
735
  }
735
- class Sr extends q {
736
+ class _r extends ee {
736
737
  constructor() {
737
- super(), this.version = 0, this.hash = null, this._diff = new wr();
738
+ super(), this.version = 0, this.hash = null, this._diff = new Tr();
738
739
  }
739
740
  // returns whether the passed mesh is compatible with this baked geometry
740
741
  // such that it can be updated without resizing attributes
741
742
  isCompatible(e, t) {
742
743
  const r = e.geometry;
743
744
  for (let i = 0; i < t.length; i++) {
744
- const o = t[i], a = r.attributes[o], l = this.attributes[o];
745
- if (a && !Q(a, l))
745
+ const s = t[i], a = r.attributes[s], l = this.attributes[s];
746
+ if (a && !J(a, l))
746
747
  return !1;
747
748
  }
748
749
  return !0;
749
750
  }
750
751
  updateFrom(e, t) {
751
752
  const r = this._diff;
752
- return r.didChange(e) ? (_r(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;
753
754
  }
754
755
  }
755
- const Ce = 0, wt = 1, It = 2;
756
- function Mr(s, e) {
757
- for (let t = 0, r = s.length; t < r; t++)
758
- s[t].traverseVisible((o) => {
759
- 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);
760
761
  });
761
762
  }
762
- function Ar(s) {
763
+ function Mr(o) {
763
764
  const e = [];
764
- for (let t = 0, r = s.length; t < r; t++) {
765
- const i = s[t];
765
+ for (let t = 0, r = o.length; t < r; t++) {
766
+ const i = o[t];
766
767
  Array.isArray(i.material) ? e.push(...i.material) : e.push(i.material);
767
768
  }
768
769
  return e;
769
770
  }
770
- function Cr(s, e, t) {
771
- if (s.length === 0) {
771
+ function Ar(o, e, t) {
772
+ if (o.length === 0) {
772
773
  e.setIndex(null);
773
774
  const r = e.attributes;
774
775
  for (const i in r)
775
776
  e.deleteAttribute(i);
776
777
  for (const i in t.attributes)
777
- 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));
778
779
  } else
779
- br(s, t, e);
780
+ xr(o, t, e);
780
781
  for (const r in e.attributes)
781
782
  e.attributes[r].needsUpdate = !0;
782
783
  }
@@ -786,14 +787,14 @@ class Fr {
786
787
  }
787
788
  _getDummyMesh() {
788
789
  if (!this._dummyMesh) {
789
- const e = new Et(), t = new q();
790
- t.setAttribute("position", new P(new Float32Array(9), 3)), this._dummyMesh = new mt(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);
791
792
  }
792
793
  return this._dummyMesh;
793
794
  }
794
795
  _getMeshes() {
795
796
  const e = [];
796
- return Mr(this.objects, (t) => {
797
+ return Sr(this.objects, (t) => {
797
798
  e.push(t);
798
799
  }), e.sort((t, r) => t.uuid > r.uuid ? 1 : t.uuid < r.uuid ? -1 : 0), e.length === 0 && e.push(this._getDummyMesh()), e;
799
800
  }
@@ -802,68 +803,68 @@ class Fr {
802
803
  attributes: this.attributes,
803
804
  applyWorldTransforms: this.applyWorldTransforms
804
805
  };
805
- for (let o = 0, a = t.length; o < a; o++) {
806
- const l = t[o], h = l.uuid;
807
- r.delete(h);
808
- let d = e.get(h);
809
- (!d || !d.isCompatible(l, this.attributes)) && (d && d.dispose(), d = new Sr(), e.set(h, d)), d.updateFrom(l, i) && this.generateMissingAttributes && Tr(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);
810
811
  }
811
- r.forEach((o) => {
812
- e.delete(o);
812
+ r.forEach((s) => {
813
+ e.delete(s);
813
814
  });
814
815
  }
815
816
  setObjects(e) {
816
817
  Array.isArray(e) ? this.objects = [...e] : this.objects = [e];
817
818
  }
818
- generate(e = new q()) {
819
- const { useGroups: t, overwriteIndex: r, _intermediateGeometry: i, _geometryMergeSets: o } = this, a = this._getMeshes(), l = [], h = [], 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) || [];
820
821
  this._updateIntermediateGeometries();
821
- let f = !1;
822
- a.length !== d.length && (f = !0);
822
+ let h = !1;
823
+ a.length !== d.length && (h = !0);
823
824
  for (let n = 0, x = a.length; n < x; n++) {
824
825
  const m = a[n], g = i.get(m.uuid);
825
- h.push(g);
826
+ u.push(g);
826
827
  const c = d[n];
827
- !c || c.uuid !== g.uuid ? (l.push(!1), f = !0) : c.version !== g.version ? l.push(!1) : l.push(!0);
828
+ !c || c.uuid !== g.uuid ? (l.push(!1), h = !0) : c.version !== g.version ? l.push(!1) : l.push(!0);
828
829
  }
829
- Cr(h, e, { useGroups: t, forceUpdate: f, skipAssigningAttributes: l, overwriteIndex: r }), f && e.dispose(), o.set(e, h.map((n) => ({
830
+ Ar(u, e, { useGroups: t, forceUpdate: h, skipAssigningAttributes: l, overwriteIndex: r }), h && e.dispose(), s.set(e, u.map((n) => ({
830
831
  version: n.version,
831
832
  uuid: n.uuid
832
833
  })));
833
- let u = Ce;
834
- return f ? u = It : l.includes(!1) && (u = wt), {
835
- changeType: u,
836
- materials: Ar(a),
834
+ let f = Fe;
835
+ return h ? f = Tt : l.includes(!1) && (f = yt), {
836
+ changeType: f,
837
+ materials: Mr(a),
837
838
  geometry: e
838
839
  };
839
840
  }
840
841
  }
841
- function Dr(s) {
842
+ function Cr(o) {
842
843
  const e = /* @__PURE__ */ new Set();
843
- for (let t = 0, r = s.length; t < r; t++) {
844
- const i = s[t];
845
- for (const o in i) {
846
- 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];
847
848
  a && a.isTexture && e.add(a);
848
849
  }
849
850
  }
850
851
  return Array.from(e);
851
852
  }
852
- function Pr(s) {
853
+ function Dr(o) {
853
854
  const e = [], t = /* @__PURE__ */ new Set();
854
- for (let i = 0, o = s.length; i < o; i++)
855
- s[i].traverse((a) => {
855
+ for (let i = 0, s = o.length; i < s; i++)
856
+ o[i].traverse((a) => {
856
857
  a.visible && (a.isRectAreaLight || a.isSpotLight || a.isPointLight || a.isDirectionalLight) && (e.push(a), a.iesMap && t.add(a.iesMap));
857
858
  });
858
- 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);
859
860
  return { lights: e, iesTextures: r };
860
861
  }
861
- class Er {
862
+ class Pr {
862
863
  get initialized() {
863
864
  return !!this.bvh;
864
865
  }
865
866
  constructor(e) {
866
- this.bvhOptions = {}, this.attributes = ["position", "normal", "tangent", "color", "uv", "uv2"], this.generateBVH = !0, this.bvh = null, this.geometry = new q(), this.staticGeometryGenerator = new Fr(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;
867
868
  }
868
869
  setObjects(e) {
869
870
  this.staticGeometryGenerator.setObjects(e);
@@ -883,82 +884,39 @@ class Er {
883
884
  }
884
885
  }
885
886
  generate(e = null) {
886
- const { staticGeometryGenerator: t, geometry: r, attributes: i } = this, o = t.objects;
887
- t.attributes = i, o.forEach((u) => {
888
- 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) => {
889
890
  n.isSkinnedMesh && n.skeleton && n.skeleton.update();
890
891
  });
891
892
  });
892
- const a = t.generate(r), l = a.materials, h = Dr(l), { lights: d, iesTextures: f } = Pr(o);
893
- if (a.changeType !== Ce && yr(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) {
894
895
  if (this.bvh instanceof Promise)
895
896
  throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");
896
- if (a.changeType === It) {
897
- const u = {
898
- strategy: rr,
897
+ if (a.changeType === Tt) {
898
+ const f = {
899
+ strategy: er,
899
900
  maxLeafTris: 1,
900
901
  indirect: !0,
901
902
  onProgress: e,
902
903
  ...this.bvhOptions
903
904
  };
904
- this._buildAsync ? this.bvh = this._bvhWorker.generate(r, u) : this.bvh = new ar(r, u);
905
- } else a.changeType === wt && this.bvh.refit();
905
+ this._buildAsync ? this.bvh = this._bvhWorker.generate(r, f) : this.bvh = new tr(r, f);
906
+ } else a.changeType === yt && this.bvh.refit();
906
907
  }
907
908
  return {
908
- bvhChanged: a.changeType !== Ce,
909
+ bvhChanged: a.changeType !== Fe,
909
910
  bvh: this.bvh,
910
911
  lights: d,
911
- iesTextures: f,
912
+ iesTextures: h,
912
913
  geometry: r,
913
914
  materials: l,
914
- textures: h,
915
- objects: o
915
+ textures: u,
916
+ objects: s
916
917
  };
917
918
  }
918
919
  }
919
- const kr = new kt(-1, 1, 1, -1, 0, 1);
920
- class Or extends q {
921
- constructor() {
922
- super(), this.setAttribute("position", new We([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new We([0, 2, 0, 0, 2, 0], 2));
923
- }
924
- }
925
- const zr = new Or();
926
- class Z {
927
- /**
928
- * Constructs a new full screen quad.
929
- *
930
- * @param {?Material} material - The material to render te full screen quad with.
931
- */
932
- constructor(e) {
933
- this._mesh = new mt(zr, e);
934
- }
935
- /**
936
- * Frees the GPU-related resources allocated by this instance. Call this
937
- * method whenever the instance is no longer used in your app.
938
- */
939
- dispose() {
940
- this._mesh.geometry.dispose();
941
- }
942
- /**
943
- * Renders the full screen quad.
944
- *
945
- * @param {WebGLRenderer} renderer - The renderer.
946
- */
947
- render(e) {
948
- e.render(this._mesh, kr);
949
- }
950
- /**
951
- * The quad's material.
952
- *
953
- * @type {?Material}
954
- */
955
- get material() {
956
- return this._mesh.material;
957
- }
958
- set material(e) {
959
- this._mesh.material = e;
960
- }
961
- }
962
920
  class Pe extends ge {
963
921
  set needsUpdate(e) {
964
922
  super.needsUpdate = !0, this.dispatchEvent({
@@ -987,10 +945,10 @@ class Pe extends ge {
987
945
  return !1;
988
946
  }
989
947
  }
990
- class Nr extends Pe {
948
+ class Er extends Pe {
991
949
  constructor(e) {
992
950
  super({
993
- blending: ie,
951
+ blending: se,
994
952
  uniforms: {
995
953
  target1: { value: null },
996
954
  target2: { value: null },
@@ -1044,9 +1002,9 @@ class Nr extends Pe {
1044
1002
  }), this.setValues(e);
1045
1003
  }
1046
1004
  }
1047
- function ue(s = 1) {
1005
+ function fe(o = 1) {
1048
1006
  let e = "uint";
1049
- return s > 1 && (e = "uvec" + s), /* glsl */
1007
+ return o > 1 && (e = "uvec" + o), /* glsl */
1050
1008
  `
1051
1009
  ${e} sobolReverseBits( ${e} x ) {
1052
1010
 
@@ -1084,9 +1042,9 @@ function ue(s = 1) {
1084
1042
  }
1085
1043
  `;
1086
1044
  }
1087
- function he(s = 1) {
1088
- let e = "uint", t = "float", r = "", i = ".r", o = "1u";
1089
- 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 */
1090
1048
  `
1091
1049
 
1092
1050
  ${t} sobol${r}( int effect ) {
@@ -1099,7 +1057,7 @@ function he(s = 1) {
1099
1057
  ${t} sobol_pt = sobolGetTexturePoint( shuffled_index )${i};
1100
1058
  ${e} result = ${e}( sobol_pt * 16777216.0 );
1101
1059
 
1102
- ${e} seed2 = sobolHashCombine( seed, ${o} );
1060
+ ${e} seed2 = sobolHashCombine( seed, ${s} );
1103
1061
  result = nestedUniformScrambleBase2( result, seed2 );
1104
1062
 
1105
1063
  return SOBOL_FACTOR * ${t}( result >> 8 );
@@ -1107,7 +1065,7 @@ function he(s = 1) {
1107
1065
  }
1108
1066
  `;
1109
1067
  }
1110
- const Rt = (
1068
+ const wt = (
1111
1069
  /* glsl */
1112
1070
  `
1113
1071
 
@@ -1115,10 +1073,10 @@ const Rt = (
1115
1073
  const float SOBOL_FACTOR = 1.0 / 16777216.0;
1116
1074
  const uint SOBOL_MAX_POINTS = 256u * 256u;
1117
1075
 
1118
- ${ue(1)}
1119
- ${ue(2)}
1120
- ${ue(3)}
1121
- ${ue(4)}
1076
+ ${fe(1)}
1077
+ ${fe(2)}
1078
+ ${fe(3)}
1079
+ ${fe(4)}
1122
1080
 
1123
1081
  uint sobolHash( uint x ) {
1124
1082
 
@@ -1133,7 +1091,7 @@ const Rt = (
1133
1091
  }
1134
1092
 
1135
1093
  `
1136
- ), Hr = (
1094
+ ), Or = (
1137
1095
  /* glsl */
1138
1096
  `
1139
1097
 
@@ -1214,7 +1172,7 @@ const Rt = (
1214
1172
  }
1215
1173
 
1216
1174
  `
1217
- ), Br = (
1175
+ ), kr = (
1218
1176
  /* glsl */
1219
1177
  `
1220
1178
 
@@ -1261,12 +1219,12 @@ const Rt = (
1261
1219
 
1262
1220
  `
1263
1221
  );
1264
- class Wr extends Pe {
1222
+ class Nr extends Pe {
1265
1223
  constructor() {
1266
1224
  super({
1267
- blending: ie,
1225
+ blending: se,
1268
1226
  uniforms: {
1269
- resolution: { value: new $() }
1227
+ resolution: { value: new X() }
1270
1228
  },
1271
1229
  vertexShader: (
1272
1230
  /* glsl */
@@ -1285,8 +1243,8 @@ class Wr extends Pe {
1285
1243
  /* glsl */
1286
1244
  `
1287
1245
 
1288
- ${Rt}
1289
- ${Hr}
1246
+ ${wt}
1247
+ ${Or}
1290
1248
 
1291
1249
  varying vec2 vUv;
1292
1250
  uniform vec2 resolution;
@@ -1301,9 +1259,9 @@ class Wr extends Pe {
1301
1259
  });
1302
1260
  }
1303
1261
  }
1304
- class Lr {
1262
+ class zr {
1305
1263
  generate(e, t = 256) {
1306
- const r = new ae(t, t, {
1264
+ const r = new ie(t, t, {
1307
1265
  type: R,
1308
1266
  format: I,
1309
1267
  minFilter: T,
@@ -1311,11 +1269,11 @@ class Lr {
1311
1269
  generateMipmaps: !1
1312
1270
  }), i = e.getRenderTarget();
1313
1271
  e.setRenderTarget(r);
1314
- const o = new Z(new Wr());
1315
- 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;
1316
1274
  }
1317
1275
  }
1318
- class Ur extends pt {
1276
+ class Hr extends dt {
1319
1277
  set bokehSize(e) {
1320
1278
  this.fStop = this.getFocalLength() / e;
1321
1279
  }
@@ -1329,132 +1287,132 @@ class Ur extends pt {
1329
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;
1330
1288
  }
1331
1289
  }
1332
- class Vr {
1290
+ class Br {
1333
1291
  constructor() {
1334
1292
  this.bokehSize = 0, this.apertureBlades = 0, this.apertureRotation = 0, this.focusDistance = 10, this.anamorphicRatio = 1;
1335
1293
  }
1336
1294
  updateFrom(e) {
1337
- e instanceof Ur ? (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);
1338
1296
  }
1339
1297
  }
1340
- function _e(s) {
1341
- const e = new Uint16Array(s.length);
1342
- for (let t = 0, r = s.length; t < r; ++t)
1343
- 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]);
1344
1302
  return e;
1345
1303
  }
1346
- function Qe(s, e, t = 0, r = s.length) {
1347
- let i = t, o = t + r - 1;
1348
- for (; i < o; ) {
1349
- const a = i + o >> 1;
1350
- 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;
1351
1309
  }
1352
1310
  return i - t;
1353
1311
  }
1354
- function Gr(s, e, t) {
1355
- 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;
1356
1314
  }
1357
- function qr(s, e = D) {
1358
- const t = s.clone();
1359
- t.source = new Ot({ ...t.image });
1360
- const { width: r, height: i, data: o } = t.image;
1361
- let a = o;
1315
+ function Lr(o, e = E) {
1316
+ const t = o.clone();
1317
+ t.source = new Et({ ...t.image });
1318
+ const { width: r, height: i, data: s } = t.image;
1319
+ let a = s;
1362
1320
  if (t.type !== e) {
1363
- 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);
1364
1322
  let l;
1365
- 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;
1366
- for (let h = 0, d = o.length; h < d; h++) {
1367
- let f = o[h];
1368
- t.type === D && (f = k.fromHalfFloat(o[h])), t.type !== R && t.type !== D && (f /= l), e === D && (a[h] = k.toHalfFloat(f));
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));
1369
1327
  }
1370
1328
  t.image.data = a, t.type = e;
1371
1329
  }
1372
1330
  if (t.flipY) {
1373
1331
  const l = a;
1374
1332
  a = a.slice();
1375
- for (let h = 0; h < i; h++)
1333
+ for (let u = 0; u < i; u++)
1376
1334
  for (let d = 0; d < r; d++) {
1377
- const f = i - h - 1, u = 4 * (h * r + d), n = 4 * (f * r + d);
1378
- 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];
1379
1337
  }
1380
1338
  t.flipY = !1, t.image.data = a;
1381
1339
  }
1382
1340
  return t;
1383
1341
  }
1384
- class $r {
1342
+ class Ur {
1385
1343
  constructor() {
1386
- const e = new M(_e(new Float32Array([0, 0, 0, 0])), 1, 1);
1387
- e.type = D, e.format = I, e.minFilter = C, e.magFilter = C, e.wrapS = z, e.wrapT = z, e.generateMipmaps = !1, e.needsUpdate = !0;
1388
- const t = new M(_e(new Float32Array([0, 1])), 1, 2);
1389
- t.type = D, t.format = me, t.minFilter = C, t.magFilter = C, t.generateMipmaps = !1, t.needsUpdate = !0;
1390
- const r = new M(_e(new Float32Array([0, 0, 1, 1])), 2, 2);
1391
- 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;
1392
1350
  }
1393
1351
  dispose() {
1394
1352
  this.marginalWeights.dispose(), this.conditionalWeights.dispose(), this.map.dispose();
1395
1353
  }
1396
1354
  updateFrom(e) {
1397
- const t = qr(e);
1398
- t.wrapS = z, t.wrapT = N;
1399
- const { width: r, height: i, data: o } = t.image, a = new Float32Array(r * i), l = new Float32Array(r * i), h = new Float32Array(i), d = new Float32Array(i);
1400
- let f = 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;
1401
1359
  for (let c = 0; c < i; c++) {
1402
1360
  let p = 0;
1403
1361
  for (let v = 0; v < r; v++) {
1404
- 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 = Gr(y, w, E);
1405
- p += H, f += 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;
1406
1364
  }
1407
1365
  if (p !== 0)
1408
1366
  for (let v = c * r, b = c * r + r; v < b; v++)
1409
1367
  a[v] /= p, l[v] /= p;
1410
- u += p, h[c] = p, d[c] = u;
1368
+ f += p, u[c] = p, d[c] = f;
1411
1369
  }
1412
- if (u !== 0)
1413
- for (let c = 0, p = h.length; c < p; c++)
1414
- h[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;
1415
1373
  const n = new Uint16Array(i), x = new Uint16Array(r * i);
1416
1374
  for (let c = 0; c < i; c++) {
1417
- const p = (c + 1) / i, v = Qe(d, p);
1418
- n[c] = k.toHalfFloat((v + 0.5) / i);
1375
+ const p = (c + 1) / i, v = Xe(d, p);
1376
+ n[c] = N.toHalfFloat((v + 0.5) / i);
1419
1377
  }
1420
1378
  for (let c = 0; c < i; c++)
1421
1379
  for (let p = 0; p < r; p++) {
1422
- const v = c * r + p, b = (p + 1) / r, y = Qe(l, b, c * r, r);
1423
- x[v] = k.toHalfFloat((y + 0.5) / r);
1380
+ const v = c * r + p, b = (p + 1) / r, y = Xe(l, b, c * r, r);
1381
+ x[v] = N.toHalfFloat((y + 0.5) / r);
1424
1382
  }
1425
1383
  this.dispose();
1426
1384
  const { marginalWeights: m, conditionalWeights: g } = this;
1427
- m.image = { width: i, height: 1, data: n }, m.needsUpdate = !0, g.image = { width: r, height: i, data: x }, g.needsUpdate = !0, this.totalSum = f, this.map = t;
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;
1428
1386
  }
1429
1387
  }
1430
- const Se = 6, jr = 0, Yr = 1, Xr = 2, Qr = 3, Kr = 4, A = new F(), S = new F(), Ke = new O(), j = new zt(), Ze = new F(), Y = new F(), Zr = new F(0, 1, 0);
1431
- class Jr {
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 {
1432
1390
  constructor() {
1433
- const e = new M(new Float32Array(4), 1, 1);
1434
- 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;
1435
1393
  }
1436
1394
  updateFrom(e, t = []) {
1437
- const r = this.tex, i = Math.max(e.length * Se, 1), o = Math.ceil(Math.sqrt(i));
1438
- 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);
1439
1397
  const a = r.image.data;
1440
- for (let h = 0, d = e.length; h < d; h++) {
1441
- const f = e[h], u = h * Se * 4;
1398
+ for (let u = 0, d = e.length; u < d; u++) {
1399
+ const h = e[u], f = u * Se * 4;
1442
1400
  let n = 0;
1443
1401
  for (let m = 0; m < Se * 4; m++)
1444
- a[u + m] = 0;
1445
- f.getWorldPosition(S), a[u + n++] = S.x, a[u + n++] = S.y, a[u + n++] = S.z;
1446
- let x = jr;
1447
- if (f.isRectAreaLight && f.isCircular ? x = Yr : f.isSpotLight ? x = Xr : f.isDirectionalLight ? x = Qr : f.isPointLight && (x = Kr), a[u + n++] = x, a[u + n++] = f.color.r, a[u + n++] = f.color.g, a[u + n++] = f.color.b, a[u + n++] = f.intensity, f.getWorldQuaternion(j), f.isRectAreaLight)
1448
- A.set(f.width, 0, 0).applyQuaternion(j), a[u + n++] = A.x, a[u + n++] = A.y, a[u + n++] = A.z, n++, S.set(0, f.height, 0).applyQuaternion(j), a[u + n++] = S.x, a[u + n++] = S.y, a[u + n++] = S.z, a[u + n++] = A.cross(S).length() * (f.isCircular ? Math.PI / 4 : 1);
1449
- else if (f.isSpotLight) {
1450
- const m = f.radius || 0;
1451
- Ze.setFromMatrixPosition(f.matrixWorld), Y.setFromMatrixPosition(f.target.matrixWorld), Ke.lookAt(Ze, Y, Zr), j.setFromRotationMatrix(Ke), A.set(1, 0, 0).applyQuaternion(j), a[u + n++] = A.x, a[u + n++] = A.y, a[u + n++] = A.z, n++, S.set(0, 1, 0).applyQuaternion(j), a[u + n++] = S.x, a[u + n++] = S.y, a[u + n++] = S.z, a[u + n++] = Math.PI * m * m, a[u + n++] = m, a[u + n++] = f.decay, a[u + n++] = f.distance, a[u + n++] = Math.cos(f.angle), a[u + n++] = Math.cos(f.angle * (1 - f.penumbra)), a[u + n++] = f.iesMap ? t.indexOf(f.iesMap) : -1;
1452
- } else if (f.isPointLight) {
1453
- const m = A.setFromMatrixPosition(f.matrixWorld);
1454
- a[u + n++] = m.x, a[u + n++] = m.y, a[u + n++] = m.z, n++, n += 4, n += 1, a[u + n++] = f.decay, a[u + n++] = f.distance;
1455
- } else if (f.isDirectionalLight) {
1456
- const m = A.setFromMatrixPosition(f.matrixWorld), g = S.setFromMatrixPosition(f.target.matrixWorld);
1457
- Y.subVectors(m, g).normalize(), a[u + n++] = Y.x, a[u + n++] = Y.y, a[u + n++] = Y.z;
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
+ else if (h.isSpotLight) {
1408
+ const m = h.radius || 0;
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
+ } else if (h.isPointLight) {
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
+ } else if (h.isDirectionalLight) {
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;
1458
1416
  }
1459
1417
  }
1460
1418
  this.count = e.length;
@@ -1462,12 +1420,12 @@ class Jr {
1462
1420
  return this.hash !== l ? (this.hash = l, r.needsUpdate = !0, !0) : !1;
1463
1421
  }
1464
1422
  }
1465
- function Je(s, e, t, r, i) {
1423
+ function Ze(o, e, t, r, i) {
1466
1424
  if (e > r)
1467
1425
  throw new Error();
1468
- 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;
1469
1427
  let l = 1;
1470
- switch (s.constructor) {
1428
+ switch (o.constructor) {
1471
1429
  case Uint8Array:
1472
1430
  case Uint16Array:
1473
1431
  case Uint32Array:
@@ -1479,52 +1437,52 @@ function Je(s, e, t, r, i) {
1479
1437
  l = 2 ** (a - 1) - 1;
1480
1438
  break;
1481
1439
  }
1482
- for (let h = 0; h < o; h++) {
1483
- const d = 4 * h, f = e * h;
1484
- for (let u = 0; u < r; u++)
1485
- t[i + d + u] = e >= u + 1 ? s[f + 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;
1486
1444
  }
1487
1445
  }
1488
- class ea extends Nt {
1446
+ class Qr extends kt {
1489
1447
  constructor() {
1490
1448
  super(), this._textures = [], this.type = R, this.format = I, this.internalFormat = "RGBA32F";
1491
1449
  }
1492
1450
  updateAttribute(e, t) {
1493
1451
  const r = this._textures[e];
1494
1452
  r.updateFrom(t);
1495
- const i = r.image, o = this.image;
1496
- 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)
1497
1455
  throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");
1498
- const { width: a, height: l, data: h } = o, f = a * l * 4 * e;
1499
- let u = t.itemSize;
1500
- u === 3 && (u = 4), Je(r.image.data, u, h, 4, f), 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;
1501
1459
  }
1502
1460
  setAttributes(e) {
1503
1461
  const t = e[0].count, r = e.length;
1504
- for (let u = 0, n = r; u < n; u++)
1505
- if (e[u].count !== t)
1462
+ for (let f = 0, n = r; f < n; f++)
1463
+ if (e[f].count !== t)
1506
1464
  throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");
1507
1465
  const i = this._textures;
1508
1466
  for (; i.length < r; ) {
1509
- const u = new yt();
1510
- i.push(u);
1467
+ const f = new xt();
1468
+ i.push(f);
1511
1469
  }
1512
1470
  for (; i.length > r; )
1513
1471
  i.pop();
1514
- for (let u = 0, n = r; u < n; u++)
1515
- i[u].updateFrom(e[u]);
1472
+ for (let f = 0, n = r; f < n; f++)
1473
+ i[f].updateFrom(e[f]);
1516
1474
  const a = i[0].image, l = this.image;
1517
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));
1518
- const { data: h, width: d, height: f } = l;
1519
- for (let u = 0, n = r; u < n; u++) {
1520
- const x = i[u], g = d * f * 4 * u;
1521
- let c = e[u].itemSize;
1522
- c === 3 && (c = 4), Je(x.image.data, c, h, 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);
1523
1481
  }
1524
1482
  this.dispose(), this.needsUpdate = !0;
1525
1483
  }
1526
1484
  }
1527
- class ta extends ea {
1485
+ class Kr extends Qr {
1528
1486
  updateNormalAttribute(e) {
1529
1487
  this.updateAttribute(0, e);
1530
1488
  }
@@ -1541,44 +1499,44 @@ class ta extends ea {
1541
1499
  this.setAttributes([e, t, r, i]);
1542
1500
  }
1543
1501
  }
1544
- function Ee(s, e) {
1545
- 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;
1546
1504
  }
1547
- function Fe(s) {
1548
- return `${s.source.uuid}:${s.colorSpace}`;
1505
+ function Ce(o) {
1506
+ return `${o.source.uuid}:${o.colorSpace}`;
1549
1507
  }
1550
- function ra(s) {
1508
+ function Zr(o) {
1551
1509
  const e = /* @__PURE__ */ new Set(), t = [];
1552
- for (let r = 0, i = s.length; r < i; r++) {
1553
- const o = s[r], a = Fe(o);
1554
- 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));
1555
1513
  }
1556
1514
  return t;
1557
1515
  }
1558
- function aa(s) {
1559
- 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);
1560
1518
  return Array.from(t).sort(Ee);
1561
1519
  }
1562
- function ia(s) {
1520
+ function ea(o) {
1563
1521
  const e = /* @__PURE__ */ new Set();
1564
- for (let r = 0, i = s.length; r < i; r++) {
1565
- const o = s[r];
1566
- for (const a in o) {
1567
- 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];
1568
1526
  l && l.isTexture && e.add(l);
1569
1527
  }
1570
1528
  }
1571
1529
  const t = Array.from(e);
1572
- return ra(t).sort(Ee);
1530
+ return Zr(t).sort(Ee);
1573
1531
  }
1574
- function sa(s) {
1532
+ function ta(o) {
1575
1533
  const e = [];
1576
- return s.traverse((t) => {
1534
+ return o.traverse((t) => {
1577
1535
  t.visible && (t.isRectAreaLight || t.isSpotLight || t.isPointLight || t.isDirectionalLight) && e.push(t);
1578
1536
  }), e.sort(Ee);
1579
1537
  }
1580
- const _t = 45, et = _t * 4;
1581
- class oa {
1538
+ const It = 45, Je = It * 4;
1539
+ class ra {
1582
1540
  constructor() {
1583
1541
  this._features = {};
1584
1542
  }
@@ -1592,22 +1550,22 @@ class oa {
1592
1550
  this._features = {};
1593
1551
  }
1594
1552
  }
1595
- class na extends M {
1553
+ class aa extends F {
1596
1554
  constructor() {
1597
- 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 oa();
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();
1598
1556
  }
1599
1557
  updateFrom(e, t) {
1600
1558
  function r(m, g, c = -1) {
1601
1559
  if (g in m && m[g]) {
1602
- const p = Fe(m[g]);
1603
- return u[p];
1560
+ const p = Ce(m[g]);
1561
+ return f[p];
1604
1562
  } else
1605
1563
  return c;
1606
1564
  }
1607
1565
  function i(m, g, c) {
1608
1566
  return g in m ? m[g] : c;
1609
1567
  }
1610
- function o(m, g, c, p) {
1568
+ function s(m, g, c, p) {
1611
1569
  const v = m[g] && m[g].isTexture ? m[g] : null;
1612
1570
  if (v) {
1613
1571
  v.matrixAutoUpdate && v.updateMatrix();
@@ -1618,19 +1576,19 @@ class na extends M {
1618
1576
  return 8;
1619
1577
  }
1620
1578
  let a = 0;
1621
- const l = e.length * _t, h = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: f } = this, u = {};
1579
+ const l = e.length * It, u = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: h } = this, f = {};
1622
1580
  for (let m = 0, g = t.length; m < g; m++)
1623
- u[Fe(t[m])] = m;
1624
- d.width !== h && (this.dispose(), d.data = new Float32Array(h * h * 4), d.width = h, d.height = h);
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);
1625
1583
  const n = d.data;
1626
- f.reset();
1584
+ h.reset();
1627
1585
  for (let m = 0, g = e.length; m < g; m++) {
1628
1586
  const c = e[m];
1629
1587
  if (c.isFogVolumeMaterial) {
1630
- f.setUsed("FOG");
1631
- for (let b = 0; b < et; b++)
1588
+ h.setUsed("FOG");
1589
+ for (let b = 0; b < Je; b++)
1632
1590
  n[a + b] = 0;
1633
- n[a + 0 + 0] = c.color.r, n[a + 0 + 1] = c.color.g, n[a + 0 + 2] = c.color.b, n[a + 8 + 3] = i(c, "emissiveIntensity", 0), n[a + 12 + 0] = c.emissive.r, n[a + 12 + 1] = c.emissive.g, n[a + 12 + 2] = c.emissive.b, n[a + 52 + 1] = c.density, n[a + 52 + 3] = 0, n[a + 56 + 2] = 4, a += et;
1591
+ n[a + 0 + 0] = c.color.r, n[a + 0 + 1] = c.color.g, n[a + 0 + 2] = c.color.b, n[a + 8 + 3] = i(c, "emissiveIntensity", 0), n[a + 12 + 0] = c.emissive.r, n[a + 12 + 1] = c.emissive.g, n[a + 12 + 2] = c.emissive.b, n[a + 52 + 1] = c.density, n[a + 52 + 3] = 0, n[a + 56 + 2] = 4, a += Je;
1634
1592
  continue;
1635
1593
  }
1636
1594
  n[a++] = c.color.r, n[a++] = c.color.g, n[a++] = c.color.b, n[a++] = r(c, "map"), n[a++] = i(c, "metalness", 0), n[a++] = r(c, "metalnessMap"), n[a++] = i(c, "roughness", 0), n[a++] = r(c, "roughnessMap"), n[a++] = i(c, "ior", 1.5), n[a++] = i(c, "transmission", 0), n[a++] = r(c, "transmissionMap"), n[a++] = i(c, "emissiveIntensity", 0), "emissive" in c ? (n[a++] = c.emissive.r, n[a++] = c.emissive.g, n[a++] = c.emissive.b) : (n[a++] = 0, n[a++] = 0, n[a++] = 0), n[a++] = r(c, "emissiveMap"), n[a++] = r(c, "normalMap"), "normalScale" in c ? (n[a++] = c.normalScale.x, n[a++] = c.normalScale.y) : (n[a++] = 1, n[a++] = 1), n[a++] = i(c, "clearcoat", 0), n[a++] = r(c, "clearcoatMap"), n[a++] = i(c, "clearcoatRoughness", 0), n[a++] = r(c, "clearcoatRoughnessMap"), n[a++] = r(c, "clearcoatNormalMap"), "clearcoatNormalScale" in c ? (n[a++] = c.clearcoatNormalScale.x, n[a++] = c.clearcoatNormalScale.y) : (n[a++] = 1, n[a++] = 1), a++, n[a++] = i(c, "sheen", 0), "sheenColor" in c ? (n[a++] = c.sheenColor.r, n[a++] = c.sheenColor.g, n[a++] = c.sheenColor.b) : (n[a++] = 0, n[a++] = 0, n[a++] = 0), n[a++] = r(c, "sheenColorMap"), n[a++] = i(c, "sheenRoughness", 0), n[a++] = r(c, "sheenRoughnessMap"), n[a++] = r(c, "iridescenceMap"), n[a++] = r(c, "iridescenceThicknessMap"), n[a++] = i(c, "iridescence", 0), n[a++] = i(c, "iridescenceIOR", 1.3);
@@ -1641,66 +1599,66 @@ class na extends M {
1641
1599
  n[a++] = 0;
1642
1600
  else
1643
1601
  switch (c.side) {
1644
- case Wt:
1602
+ case Ht:
1645
1603
  n[a++] = 1;
1646
1604
  break;
1647
- case Bt:
1605
+ case zt:
1648
1606
  n[a++] = -1;
1649
1607
  break;
1650
- case Ht:
1608
+ case Nt:
1651
1609
  n[a++] = 0;
1652
1610
  break;
1653
1611
  }
1654
- 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);
1655
1613
  }
1656
1614
  const x = De(n.buffer);
1657
1615
  return this.hash !== x ? (this.hash = x, this.needsUpdate = !0, !0) : !1;
1658
1616
  }
1659
1617
  }
1660
- const tt = new se();
1661
- function la(s) {
1662
- return s ? `${s.uuid}:${s.version}` : null;
1618
+ const et = new oe();
1619
+ function ia(o) {
1620
+ return o ? `${o.uuid}:${o.version}` : null;
1663
1621
  }
1664
- function ca(s, e) {
1622
+ function sa(o, e) {
1665
1623
  for (const t in e)
1666
- t in s && (s[t] = e[t]);
1624
+ t in o && (o[t] = e[t]);
1667
1625
  }
1668
- class rt extends Lt {
1626
+ class tt extends Bt {
1669
1627
  constructor(e, t, r) {
1670
1628
  const i = {
1671
1629
  format: I,
1672
1630
  type: Me,
1673
- minFilter: C,
1674
- magFilter: C,
1675
- wrapS: z,
1676
- wrapT: z,
1631
+ minFilter: D,
1632
+ magFilter: D,
1633
+ wrapS: H,
1634
+ wrapT: H,
1677
1635
  generateMipmaps: !1,
1678
1636
  ...r
1679
1637
  };
1680
- super(e, t, 1, i), ca(this.texture, i), this.texture.setTextures = (...a) => {
1638
+ super(e, t, 1, i), sa(this.texture, i), this.texture.setTextures = (...a) => {
1681
1639
  this.setTextures(...a);
1682
1640
  }, this.hashes = [null];
1683
- const o = new Z(new ua());
1684
- this.fsQuad = o;
1641
+ const s = new Y(new oa());
1642
+ this.fsQuad = s;
1685
1643
  }
1686
1644
  setTextures(e, t, r = this.width, i = this.height) {
1687
- const o = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
1688
- e.getClearColor(tt);
1689
- const h = t.length || 1;
1690
- (r !== this.width || i !== this.height || this.depth !== h) && (this.setSize(r, i, h), this.hashes = new Array(h).fill(null)), e.setClearColor(0, 0), e.toneMapping = Ut;
1691
- const d = this.fsQuad, f = this.hashes;
1692
- let u = !1;
1693
- for (let n = 0, x = h; n < x; n++) {
1694
- const m = t[n], g = la(m);
1695
- m && (f[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, f[n] = g, u = !0);
1645
+ const s = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
1646
+ e.getClearColor(et);
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
+ const d = this.fsQuad, h = this.hashes;
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);
1696
1654
  }
1697
- return d.material.map = null, e.setClearColor(tt, 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;
1698
1656
  }
1699
1657
  dispose() {
1700
1658
  super.dispose(), this.fsQuad.dispose();
1701
1659
  }
1702
1660
  }
1703
- class ua extends ge {
1661
+ class oa extends ge {
1704
1662
  get map() {
1705
1663
  return this.uniforms.map.value;
1706
1664
  }
@@ -1739,60 +1697,60 @@ class ua extends ge {
1739
1697
  });
1740
1698
  }
1741
1699
  }
1742
- function ha(s, e = Math.random()) {
1743
- for (let t = s.length - 1; t > 0; t--) {
1744
- const r = Math.floor(e() * (t + 1)), i = s[t];
1745
- 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;
1746
1704
  }
1747
- return s;
1705
+ return o;
1748
1706
  }
1749
- class fa {
1707
+ class la {
1750
1708
  constructor(e, t, r = Math.random) {
1751
- const i = e ** t, o = new Uint16Array(i);
1709
+ const i = e ** t, s = new Uint16Array(i);
1752
1710
  let a = i;
1753
1711
  for (let l = 0; l < i; l++)
1754
- o[l] = l;
1712
+ s[l] = l;
1755
1713
  this.samples = new Float32Array(t), this.strataCount = e, this.reset = function() {
1756
1714
  for (let l = 0; l < i; l++)
1757
- o[l] = l;
1715
+ s[l] = l;
1758
1716
  a = 0;
1759
1717
  }, this.reshuffle = function() {
1760
1718
  a = 0;
1761
1719
  }, this.next = function() {
1762
1720
  const { samples: l } = this;
1763
- a >= o.length && (ha(o, r), this.reshuffle());
1764
- let h = o[a++];
1721
+ a >= s.length && (na(s, r), this.reshuffle());
1722
+ let u = s[a++];
1765
1723
  for (let d = 0; d < t; d++)
1766
- l[d] = (h % e + r()) / e, h = Math.floor(h / e);
1724
+ l[d] = (u % e + r()) / e, u = Math.floor(u / e);
1767
1725
  return l;
1768
1726
  };
1769
1727
  }
1770
1728
  }
1771
- class da {
1729
+ class ca {
1772
1730
  constructor(e, t, r = Math.random) {
1773
1731
  let i = 0;
1774
- for (const h of t)
1775
- i += h;
1776
- const o = new Float32Array(i), a = [];
1732
+ for (const u of t)
1733
+ i += u;
1734
+ const s = new Float32Array(i), a = [];
1777
1735
  let l = 0;
1778
- for (const h of t) {
1779
- const d = new fa(e, h, r);
1780
- 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);
1781
1739
  }
1782
- this.samples = o, this.strataCount = e, this.next = function() {
1783
- for (const h of a)
1784
- h.next();
1785
- return o;
1740
+ this.samples = s, this.strataCount = e, this.next = function() {
1741
+ for (const u of a)
1742
+ u.next();
1743
+ return s;
1786
1744
  }, this.reshuffle = function() {
1787
- for (const h of a)
1788
- h.reshuffle();
1745
+ for (const u of a)
1746
+ u.reshuffle();
1789
1747
  }, this.reset = function() {
1790
- for (const h of a)
1791
- h.reset();
1748
+ for (const u of a)
1749
+ u.reset();
1792
1750
  };
1793
1751
  }
1794
1752
  }
1795
- class ma {
1753
+ class ua {
1796
1754
  constructor(e = 0) {
1797
1755
  this.m = 2147483648, this.a = 1103515245, this.c = 12345, this.seed = e;
1798
1756
  }
@@ -1803,15 +1761,15 @@ class ma {
1803
1761
  return this.nextInt() / (this.m - 1);
1804
1762
  }
1805
1763
  }
1806
- class pa extends M {
1764
+ class fa extends F {
1807
1765
  constructor(e = 1, t = 1, r = 8) {
1808
- super(new Float32Array(1), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.strata = r, this.sampler = null, this.generator = new ma(), 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);
1809
1767
  }
1810
1768
  init(e = this.image.height, t = this.image.width, r = this.strata) {
1811
1769
  const { image: i } = this;
1812
1770
  if (i.width === t && i.height === e && this.sampler !== null)
1813
1771
  return;
1814
- const o = new Array(e * t).fill(4), a = new da(r, o, this.random);
1772
+ const s = new Array(e * t).fill(4), a = new ca(r, s, this.random);
1815
1773
  i.width = t, i.height = e, i.data = a.samples, this.sampler = a, this.dispose(), this.next();
1816
1774
  }
1817
1775
  next() {
@@ -1821,51 +1779,51 @@ class pa extends M {
1821
1779
  this.sampler.reset(), this.generator.seed = 0;
1822
1780
  }
1823
1781
  }
1824
- function ga(s, e = Math.random) {
1825
- for (let t = s.length - 1; t > 0; t--) {
1826
- const r = ~~((e() - 1e-6) * t), i = s[t];
1827
- 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;
1828
1786
  }
1829
1787
  }
1830
- function va(s, e) {
1831
- s.fill(0);
1788
+ function da(o, e) {
1789
+ o.fill(0);
1832
1790
  for (let t = 0; t < e; t++)
1833
- s[t] = 1;
1791
+ o[t] = 1;
1834
1792
  }
1835
- class at {
1793
+ class rt {
1836
1794
  constructor(e) {
1837
1795
  this.count = 0, this.size = -1, this.sigma = -1, this.radius = -1, this.lookupTable = null, this.score = null, this.binaryPattern = null, this.resize(e), this.setSigma(1.5);
1838
1796
  }
1839
1797
  findVoid() {
1840
1798
  const { score: e, binaryPattern: t } = this;
1841
1799
  let r = 1 / 0, i = -1;
1842
- for (let o = 0, a = t.length; o < a; o++) {
1843
- if (t[o] !== 0)
1800
+ for (let s = 0, a = t.length; s < a; s++) {
1801
+ if (t[s] !== 0)
1844
1802
  continue;
1845
- const l = e[o];
1846
- l < r && (r = l, i = o);
1803
+ const l = e[s];
1804
+ l < r && (r = l, i = s);
1847
1805
  }
1848
1806
  return i;
1849
1807
  }
1850
1808
  findCluster() {
1851
1809
  const { score: e, binaryPattern: t } = this;
1852
1810
  let r = -1 / 0, i = -1;
1853
- for (let o = 0, a = t.length; o < a; o++) {
1854
- if (t[o] !== 1)
1811
+ for (let s = 0, a = t.length; s < a; s++) {
1812
+ if (t[s] !== 1)
1855
1813
  continue;
1856
- const l = e[o];
1857
- l > r && (r = l, i = o);
1814
+ const l = e[s];
1815
+ l > r && (r = l, i = s);
1858
1816
  }
1859
1817
  return i;
1860
1818
  }
1861
1819
  setSigma(e) {
1862
1820
  if (e === this.sigma)
1863
1821
  return;
1864
- 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;
1865
1823
  for (let a = -t; a <= t; a++)
1866
1824
  for (let l = -t; l <= t; l++) {
1867
- const h = (t + l) * r + a + t, d = a * a + l * l;
1868
- i[h] = 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));
1869
1827
  }
1870
1828
  this.lookupTable = i, this.sigma = e, this.radius = t;
1871
1829
  }
@@ -1875,7 +1833,7 @@ class at {
1875
1833
  invert() {
1876
1834
  const { binaryPattern: e, score: t, size: r } = this;
1877
1835
  t.fill(0);
1878
- for (let i = 0, o = e.length; i < o; i++)
1836
+ for (let i = 0, s = e.length; i < s; i++)
1879
1837
  if (e[i] === 0) {
1880
1838
  const a = ~~(i / r), l = i - a * r;
1881
1839
  this.updateScore(l, a, 1), e[i] = 1;
@@ -1883,16 +1841,16 @@ class at {
1883
1841
  e[i] = 0;
1884
1842
  }
1885
1843
  updateScore(e, t, r) {
1886
- const { size: i, score: o, lookupTable: a } = this, l = this.radius, h = 2 * l + 1;
1844
+ const { size: i, score: s, lookupTable: a } = this, l = this.radius, u = 2 * l + 1;
1887
1845
  for (let d = -l; d <= l; d++)
1888
- for (let f = -l; f <= l; f++) {
1889
- const u = (l + f) * h + d + l, n = a[u];
1846
+ for (let h = -l; h <= l; h++) {
1847
+ const f = (l + h) * u + d + l, n = a[f];
1890
1848
  let x = e + d;
1891
1849
  x = x < 0 ? i + x : x % i;
1892
- let m = t + f;
1850
+ let m = t + h;
1893
1851
  m = m < 0 ? i + m : m % i;
1894
1852
  const g = m * i + x;
1895
- o[g] += r * n;
1853
+ s[g] += r * n;
1896
1854
  }
1897
1855
  }
1898
1856
  addPointIndex(e) {
@@ -1909,9 +1867,9 @@ class at {
1909
1867
  this.resize(e.size), this.score.set(e.score), this.binaryPattern.set(e.binaryPattern), this.setSigma(e.sigma), this.count = e.count;
1910
1868
  }
1911
1869
  }
1912
- class xa {
1870
+ class ma {
1913
1871
  constructor() {
1914
- this.random = Math.random, this.sigma = 1.5, this.size = 64, this.majorityPointsRatio = 0.1, this.samples = new at(1), this.savedSamples = new at(1);
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);
1915
1873
  }
1916
1874
  generate() {
1917
1875
  const {
@@ -1919,76 +1877,76 @@ class xa {
1919
1877
  savedSamples: t,
1920
1878
  sigma: r,
1921
1879
  majorityPointsRatio: i,
1922
- size: o
1880
+ size: s
1923
1881
  } = this;
1924
- e.resize(o), e.setSigma(r);
1925
- const a = Math.floor(o * o * i), l = e.binaryPattern;
1926
- va(l, a), ga(l, this.random);
1927
- for (let u = 0, n = l.length; u < n; u++)
1928
- 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);
1929
1887
  for (; ; ) {
1930
- const u = e.findCluster();
1931
- e.removePointIndex(u);
1888
+ const f = e.findCluster();
1889
+ e.removePointIndex(f);
1932
1890
  const n = e.findVoid();
1933
- if (u === n) {
1934
- e.addPointIndex(u);
1891
+ if (f === n) {
1892
+ e.addPointIndex(f);
1935
1893
  break;
1936
1894
  }
1937
1895
  e.addPointIndex(n);
1938
1896
  }
1939
- const h = new Uint32Array(o * o);
1897
+ const u = new Uint32Array(s * s);
1940
1898
  t.copy(e);
1941
1899
  let d;
1942
1900
  for (d = e.count - 1; d >= 0; ) {
1943
- const u = e.findCluster();
1944
- e.removePointIndex(u), h[u] = d, d--;
1901
+ const f = e.findCluster();
1902
+ e.removePointIndex(f), u[f] = d, d--;
1945
1903
  }
1946
- const f = o * o;
1947
- for (d = t.count; d < f / 2; ) {
1948
- const u = t.findVoid();
1949
- t.addPointIndex(u), h[u] = d, d++;
1904
+ const h = s * s;
1905
+ for (d = t.count; d < h / 2; ) {
1906
+ const f = t.findVoid();
1907
+ t.addPointIndex(f), u[f] = d, d++;
1950
1908
  }
1951
- for (t.invert(); d < f; ) {
1952
- const u = t.findCluster();
1953
- t.removePointIndex(u), h[u] = d, d++;
1909
+ for (t.invert(); d < h; ) {
1910
+ const f = t.findCluster();
1911
+ t.removePointIndex(f), u[f] = d, d++;
1954
1912
  }
1955
- return { data: h, maxValue: f };
1913
+ return { data: u, maxValue: h };
1956
1914
  }
1957
1915
  }
1958
- function ba(s) {
1959
- return s >= 3 ? 4 : s;
1916
+ function pa(o) {
1917
+ return o >= 3 ? 4 : o;
1960
1918
  }
1961
- function ya(s) {
1962
- switch (s) {
1919
+ function ga(o) {
1920
+ switch (o) {
1963
1921
  case 1:
1964
- return me;
1922
+ return pe;
1965
1923
  case 2:
1966
- return dt;
1924
+ return ht;
1967
1925
  default:
1968
1926
  return I;
1969
1927
  }
1970
1928
  }
1971
- class Ta extends M {
1929
+ class va extends F {
1972
1930
  constructor(e = 64, t = 1) {
1973
1931
  super(new Float32Array(4), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.size = e, this.channels = t, this.update();
1974
1932
  }
1975
1933
  update() {
1976
- const e = this.channels, t = this.size, r = new xa();
1934
+ const e = this.channels, t = this.size, r = new ma();
1977
1935
  r.channels = e, r.size = t;
1978
- const i = ba(e), o = ya(i);
1979
- (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());
1980
1938
  const a = this.image.data;
1981
- for (let l = 0, h = e; l < h; l++) {
1982
- const d = r.generate(), f = d.data, u = d.maxValue;
1983
- for (let n = 0, x = f.length; n < x; n++) {
1984
- const m = f[n] / u;
1939
+ for (let l = 0, u = e; l < u; l++) {
1940
+ const d = r.generate(), h = d.data, f = d.maxValue;
1941
+ for (let n = 0, x = h.length; n < x; n++) {
1942
+ const m = h[n] / f;
1985
1943
  a[n * i + l] = m;
1986
1944
  }
1987
1945
  }
1988
1946
  this.needsUpdate = !0;
1989
1947
  }
1990
1948
  }
1991
- const wa = (
1949
+ const xa = (
1992
1950
  /* glsl */
1993
1951
  `
1994
1952
 
@@ -2003,7 +1961,7 @@ const wa = (
2003
1961
  };
2004
1962
 
2005
1963
  `
2006
- ), Ia = (
1964
+ ), ba = (
2007
1965
  /* glsl */
2008
1966
  `
2009
1967
 
@@ -2018,7 +1976,7 @@ const wa = (
2018
1976
  };
2019
1977
 
2020
1978
  `
2021
- ), Ra = (
1979
+ ), ya = (
2022
1980
  /* glsl */
2023
1981
  `
2024
1982
 
@@ -2107,7 +2065,7 @@ const wa = (
2107
2065
  }
2108
2066
 
2109
2067
  `
2110
- ), _a = (
2068
+ ), Ta = (
2111
2069
  /* glsl */
2112
2070
  `
2113
2071
 
@@ -2317,7 +2275,7 @@ const wa = (
2317
2275
  }
2318
2276
 
2319
2277
  `
2320
- ), Sa = (
2278
+ ), wa = (
2321
2279
  /* glsl */
2322
2280
  `
2323
2281
 
@@ -2382,7 +2340,7 @@ const wa = (
2382
2340
  };
2383
2341
 
2384
2342
  `
2385
- ), Ma = (
2343
+ ), Ia = (
2386
2344
  /* glsl */
2387
2345
  `
2388
2346
 
@@ -2452,7 +2410,7 @@ const wa = (
2452
2410
 
2453
2411
  }
2454
2412
  `
2455
- ), Aa = (
2413
+ ), Ra = (
2456
2414
  /* glsl */
2457
2415
  `
2458
2416
 
@@ -2670,7 +2628,7 @@ const wa = (
2670
2628
  }
2671
2629
 
2672
2630
  `
2673
- ), Ca = (
2631
+ ), _a = (
2674
2632
  /* glsl */
2675
2633
  `
2676
2634
 
@@ -2758,7 +2716,7 @@ const wa = (
2758
2716
 
2759
2717
 
2760
2718
  `
2761
- ), Fa = (
2719
+ ), Sa = (
2762
2720
  /* glsl */
2763
2721
  `
2764
2722
 
@@ -2864,7 +2822,7 @@ const wa = (
2864
2822
  }
2865
2823
 
2866
2824
  `
2867
- ), Da = (
2825
+ ), Ma = (
2868
2826
  /* glsl */
2869
2827
  `
2870
2828
 
@@ -2947,7 +2905,7 @@ const wa = (
2947
2905
  }
2948
2906
 
2949
2907
  `
2950
- ), Pa = (
2908
+ ), Aa = (
2951
2909
  /* glsl */
2952
2910
  `
2953
2911
 
@@ -3011,7 +2969,7 @@ const wa = (
3011
2969
  }
3012
2970
 
3013
2971
  `
3014
- ), Ea = (
2972
+ ), Fa = (
3015
2973
  /*glsl */
3016
2974
  `
3017
2975
 
@@ -3037,7 +2995,7 @@ const wa = (
3037
2995
  }
3038
2996
 
3039
2997
  `
3040
- ), St = (
2998
+ ), Rt = (
3041
2999
  /* glsl */
3042
3000
  `
3043
3001
 
@@ -3155,7 +3113,7 @@ const wa = (
3155
3113
 
3156
3114
  }
3157
3115
  `
3158
- ), it = (
3116
+ ), at = (
3159
3117
  /* glsl */
3160
3118
  `
3161
3119
 
@@ -3214,7 +3172,7 @@ const wa = (
3214
3172
 
3215
3173
  }
3216
3174
  `
3217
- ), ka = (
3175
+ ), Ca = (
3218
3176
  /* glsl */
3219
3177
  `
3220
3178
 
@@ -3266,7 +3224,7 @@ const wa = (
3266
3224
  }
3267
3225
 
3268
3226
  `
3269
- ), Oa = (
3227
+ ), Da = (
3270
3228
  /* glsl */
3271
3229
  `
3272
3230
 
@@ -3707,7 +3665,7 @@ const wa = (
3707
3665
  }
3708
3666
 
3709
3667
  `
3710
- ), za = (
3668
+ ), Pa = (
3711
3669
  /* glsl */
3712
3670
  `
3713
3671
 
@@ -3731,7 +3689,7 @@ const wa = (
3731
3689
  }
3732
3690
 
3733
3691
  `
3734
- ), Na = (
3692
+ ), Ea = (
3735
3693
  /* glsl */
3736
3694
  `
3737
3695
 
@@ -3835,7 +3793,7 @@ const wa = (
3835
3793
  }
3836
3794
 
3837
3795
  `
3838
- ), Ha = (
3796
+ ), Oa = (
3839
3797
  /* glsl */
3840
3798
  `
3841
3799
 
@@ -3972,7 +3930,7 @@ const wa = (
3972
3930
  }
3973
3931
 
3974
3932
  `
3975
- ), Ba = (
3933
+ ), ka = (
3976
3934
  /* glsl */
3977
3935
  `
3978
3936
 
@@ -4072,7 +4030,7 @@ const wa = (
4072
4030
  }
4073
4031
 
4074
4032
  `
4075
- ), Wa = (
4033
+ ), Na = (
4076
4034
  /* glsl */
4077
4035
  `
4078
4036
 
@@ -4136,7 +4094,7 @@ bool bvhIntersectFogVolumeHit(
4136
4094
  }
4137
4095
 
4138
4096
  `
4139
- ), La = (
4097
+ ), za = (
4140
4098
  /* glsl */
4141
4099
  `
4142
4100
 
@@ -4316,7 +4274,7 @@ bool bvhIntersectFogVolumeHit(
4316
4274
  }
4317
4275
 
4318
4276
  `
4319
- ), Ua = (
4277
+ ), Ha = (
4320
4278
  /* glsl */
4321
4279
  `
4322
4280
 
@@ -4402,7 +4360,7 @@ bool bvhIntersectFogVolumeHit(
4402
4360
  }
4403
4361
 
4404
4362
  `
4405
- ), Va = (
4363
+ ), Ba = (
4406
4364
  /*glsl*/
4407
4365
  `
4408
4366
 
@@ -4501,7 +4459,7 @@ bool bvhIntersectFogVolumeHit(
4501
4459
  }
4502
4460
 
4503
4461
  `
4504
- ), Ga = (
4462
+ ), Wa = (
4505
4463
  /* glsl */
4506
4464
  `
4507
4465
 
@@ -4826,7 +4784,7 @@ bool bvhIntersectFogVolumeHit(
4826
4784
 
4827
4785
  }
4828
4786
  `
4829
- ), qa = (
4787
+ ), La = (
4830
4788
  /* glsl */
4831
4789
  `
4832
4790
 
@@ -4878,7 +4836,7 @@ bool bvhIntersectFogVolumeHit(
4878
4836
  }
4879
4837
 
4880
4838
  `
4881
- ), $a = (
4839
+ ), Ua = (
4882
4840
  /* glsl */
4883
4841
  `
4884
4842
 
@@ -4929,7 +4887,7 @@ bool bvhIntersectFogVolumeHit(
4929
4887
 
4930
4888
  `
4931
4889
  );
4932
- class ja extends Pe {
4890
+ class Ga extends Pe {
4933
4891
  onBeforeRender() {
4934
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);
4935
4893
  }
@@ -4959,42 +4917,42 @@ class ja extends Pe {
4959
4917
  },
4960
4918
  uniforms: {
4961
4919
  // path trace uniforms
4962
- resolution: { value: new $() },
4920
+ resolution: { value: new X() },
4963
4921
  opacity: { value: 1 },
4964
4922
  bounces: { value: 10 },
4965
4923
  transmissiveBounces: { value: 10 },
4966
4924
  filterGlossyFactor: { value: 0 },
4967
4925
  // camera uniforms
4968
- physicalCamera: { value: new Vr() },
4969
- cameraWorldMatrix: { value: new O() },
4970
- invProjectionMatrix: { value: new O() },
4926
+ physicalCamera: { value: new Br() },
4927
+ cameraWorldMatrix: { value: new z() },
4928
+ invProjectionMatrix: { value: new z() },
4971
4929
  // scene uniforms
4972
- bvh: { value: new cr() },
4973
- attributesArray: { value: new ta() },
4974
- materialIndexAttribute: { value: new bt() },
4975
- materials: { value: new na() },
4976
- textures: { value: new rt().texture },
4930
+ bvh: { value: new lr() },
4931
+ attributesArray: { value: new Kr() },
4932
+ materialIndexAttribute: { value: new vt() },
4933
+ materials: { value: new aa() },
4934
+ textures: { value: new tt().texture },
4977
4935
  // light uniforms
4978
- lights: { value: new Jr() },
4979
- iesProfiles: { value: new rt(360, 180, {
4980
- type: D,
4981
- wrapS: N,
4982
- wrapT: N
4936
+ lights: { value: new Xr() },
4937
+ iesProfiles: { value: new tt(360, 180, {
4938
+ type: E,
4939
+ wrapS: B,
4940
+ wrapT: B
4983
4941
  }).texture },
4984
4942
  environmentIntensity: { value: 1 },
4985
- environmentRotation: { value: new O() },
4986
- envMapInfo: { value: new $r() },
4943
+ environmentRotation: { value: new z() },
4944
+ envMapInfo: { value: new Ur() },
4987
4945
  // background uniforms
4988
4946
  backgroundBlur: { value: 0 },
4989
4947
  backgroundMap: { value: null },
4990
4948
  backgroundAlpha: { value: 1 },
4991
4949
  backgroundIntensity: { value: 1 },
4992
- backgroundRotation: { value: new O() },
4950
+ backgroundRotation: { value: new z() },
4993
4951
  // randomness uniforms
4994
4952
  seed: { value: 0 },
4995
4953
  sobolTexture: { value: null },
4996
- stratifiedTexture: { value: new pa() },
4997
- stratifiedOffsetTexture: { value: new Ta(64, 1) }
4954
+ stratifiedTexture: { value: new fa() },
4955
+ stratifiedOffsetTexture: { value: new va(64, 1) }
4998
4956
  },
4999
4957
  vertexShader: (
5000
4958
  /* glsl */
@@ -5027,26 +4985,26 @@ class ja extends Pe {
5027
4985
 
5028
4986
  // bvh intersection
5029
4987
  ${fr}
5030
- ${mr}
5031
4988
  ${dr}
4989
+ ${hr}
5032
4990
 
5033
4991
  // uniform structs
4992
+ ${xa}
4993
+ ${ya}
4994
+ ${ba}
4995
+ ${Ta}
5034
4996
  ${wa}
5035
- ${Ra}
5036
- ${Ia}
5037
- ${_a}
5038
- ${Sa}
5039
4997
 
5040
4998
  // random
5041
4999
  #if RANDOM_TYPE == 2 // Stratified List
5042
5000
 
5043
- ${ka}
5001
+ ${Ca}
5044
5002
 
5045
5003
  #elif RANDOM_TYPE == 1 // Sobol
5046
5004
 
5047
- ${it}
5048
- ${Rt}
5049
- ${Br}
5005
+ ${at}
5006
+ ${wt}
5007
+ ${kr}
5050
5008
 
5051
5009
  #define rand(v) sobol(v)
5052
5010
  #define rand2(v) sobol2(v)
@@ -5055,7 +5013,7 @@ class ja extends Pe {
5055
5013
 
5056
5014
  #else // PCG
5057
5015
 
5058
- ${it}
5016
+ ${at}
5059
5017
 
5060
5018
  // Using the sobol functions seems to break the the compiler on MacOS
5061
5019
  // - specifically the "sobolReverseBits" function.
@@ -5071,11 +5029,11 @@ class ja extends Pe {
5071
5029
  #endif
5072
5030
 
5073
5031
  // common
5074
- ${Ea}
5075
5032
  ${Fa}
5076
- ${St}
5077
- ${Da}
5078
- ${Pa}
5033
+ ${Sa}
5034
+ ${Rt}
5035
+ ${Ma}
5036
+ ${Aa}
5079
5037
 
5080
5038
  // environment
5081
5039
  uniform EquirectHdrInfo envMapInfo;
@@ -5131,16 +5089,16 @@ class ja extends Pe {
5131
5089
  float lightsDenom;
5132
5090
 
5133
5091
  // sampling
5134
- ${Ca}
5135
- ${Ma}
5136
- ${Aa}
5092
+ ${_a}
5093
+ ${Ia}
5094
+ ${Ra}
5137
5095
 
5138
- ${Wa}
5139
5096
  ${Na}
5140
- ${Ba}
5141
- ${Ha}
5142
- ${za}
5097
+ ${Ea}
5098
+ ${ka}
5143
5099
  ${Oa}
5100
+ ${Pa}
5101
+ ${Da}
5144
5102
 
5145
5103
  float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
5146
5104
 
@@ -5172,12 +5130,12 @@ class ja extends Pe {
5172
5130
 
5173
5131
  }
5174
5132
 
5175
- ${qa}
5176
- ${Ua}
5177
- ${$a}
5178
5133
  ${La}
5179
- ${Va}
5180
- ${Ga}
5134
+ ${Ha}
5135
+ ${Ua}
5136
+ ${za}
5137
+ ${Ba}
5138
+ ${Wa}
5181
5139
 
5182
5140
  void main() {
5183
5141
 
@@ -5474,51 +5432,51 @@ class ja extends Pe {
5474
5432
  }), this.setValues(e);
5475
5433
  }
5476
5434
  }
5477
- function* Ya() {
5435
+ function* Va() {
5478
5436
  const {
5479
- _renderer: s,
5437
+ _renderer: o,
5480
5438
  _fsQuad: e,
5481
5439
  _blendQuad: t,
5482
5440
  _primaryTarget: r,
5483
5441
  _blendTargets: i,
5484
- _sobolTarget: o,
5442
+ _sobolTarget: s,
5485
5443
  _subframe: a,
5486
5444
  alpha: l,
5487
- material: h
5488
- } = this, d = new K(), f = new K(), u = t.material;
5445
+ material: u
5446
+ } = this, d = new te(), h = new te(), f = t.material;
5489
5447
  let [n, x] = i;
5490
5448
  for (; ; ) {
5491
- l ? (u.opacity = this._opacityFactor / (this.samples + 1), h.blending = ie, h.opacity = 1) : (h.opacity = this._opacityFactor / (this.samples + 1), h.blending = gt);
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);
5492
5450
  const [m, g, c, p] = a, v = r.width, b = r.height;
5493
- h.resolution.set(v * c, b * p), h.sobolTexture = o.texture, h.stratifiedTexture.init(20, h.bounces + h.transmissiveBounces + 5), h.stratifiedTexture.next(), h.seed++;
5494
- 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);
5495
- for (let oe = 0; oe < w; oe++)
5496
- for (let ne = 0; ne < y; ne++) {
5497
- const ze = s.getRenderTarget(), Mt = s.autoClear, At = s.getScissorTest();
5498
- s.getScissor(d), s.getViewport(f);
5499
- 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;
5500
5458
  if (!this.stableTiles) {
5501
5459
  const Te = this._currentTile % (y * w);
5502
- ye = Te % y, Ne = ~~(Te / y), this._currentTile = Te + 1;
5460
+ ye = Te % y, ze = ~~(Te / y), this._currentTile = Te + 1;
5503
5461
  }
5504
- const He = w - Ne - 1;
5462
+ const He = w - ze - 1;
5505
5463
  r.scissor.set(
5506
- ke + ye * xe,
5507
- Oe + He * be,
5508
- Math.min(xe, H - ye * xe),
5464
+ Oe + ye * xe,
5465
+ ke + He * be,
5466
+ Math.min(xe, W - ye * xe),
5509
5467
  Math.min(be, ve - He * be)
5510
5468
  ), r.viewport.set(
5511
- ke,
5512
5469
  Oe,
5513
- H,
5470
+ ke,
5471
+ W,
5514
5472
  ve
5515
- ), s.setRenderTarget(r), s.setScissorTest(!0), s.autoClear = !1, e.render(s), s.setViewport(f), s.setScissor(d), s.setScissorTest(At), s.setRenderTarget(ze), s.autoClear = Mt, 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;
5516
5474
  }
5517
5475
  [n, x] = [x, n];
5518
5476
  }
5519
5477
  }
5520
- const st = new se();
5521
- class ot {
5478
+ const it = new oe();
5479
+ class st {
5522
5480
  get material() {
5523
5481
  return this._fsQuad.material;
5524
5482
  }
@@ -5538,19 +5496,19 @@ class ot {
5538
5496
  return !!this._compilePromise;
5539
5497
  }
5540
5498
  constructor(e) {
5541
- this.camera = null, this.tiles = new $(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 ja()), this._blendQuad = new Z(new Nr()), this._task = null, this._currentTile = 0, this._compilePromise = null, this._sobolTarget = new Lr().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, {
5542
5500
  format: I,
5543
5501
  type: R,
5544
5502
  magFilter: T,
5545
5503
  minFilter: T
5546
5504
  }), this._blendTargets = [
5547
- new ae(1, 1, {
5505
+ new ie(1, 1, {
5548
5506
  format: I,
5549
5507
  type: R,
5550
5508
  magFilter: T,
5551
5509
  minFilter: T
5552
5510
  }),
5553
- new ae(1, 1, {
5511
+ new ie(1, 1, {
5554
5512
  format: I,
5555
5513
  type: R,
5556
5514
  magFilter: T,
@@ -5582,15 +5540,15 @@ class ot {
5582
5540
  this._primaryTarget.dispose(), this._blendTargets[0].dispose(), this._blendTargets[1].dispose(), this._sobolTarget.dispose(), this._fsQuad.dispose(), this._blendQuad.dispose(), this._task = null;
5583
5541
  }
5584
5542
  reset() {
5585
- const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(), o = e.getClearAlpha();
5586
- e.getClearColor(st), 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(st, 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());
5587
5545
  }
5588
5546
  update() {
5589
- this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task = Ya.call(this)), this._task.next());
5547
+ this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task = Va.call(this)), this._task.next());
5590
5548
  }
5591
5549
  }
5592
- const G = new $(), nt = new $(), fe = new Vt(), de = new se();
5593
- class Xa extends M {
5550
+ const $ = new X(), ot = new X(), de = new Lt(), me = new oe();
5551
+ class qa extends F {
5594
5552
  constructor(e = 512, t = 512) {
5595
5553
  super(
5596
5554
  new Float32Array(e * t * 4),
@@ -5598,41 +5556,41 @@ class Xa extends M {
5598
5556
  t,
5599
5557
  I,
5600
5558
  R,
5601
- vt,
5602
- z,
5603
- N,
5604
- C,
5605
- C
5559
+ pt,
5560
+ H,
5561
+ B,
5562
+ D,
5563
+ D
5606
5564
  ), this.generationCallback = null;
5607
5565
  }
5608
5566
  update() {
5609
5567
  this.dispose(), this.needsUpdate = !0;
5610
5568
  const { data: e, width: t, height: r } = this.image;
5611
5569
  for (let i = 0; i < t; i++)
5612
- for (let o = 0; o < r; o++) {
5613
- nt.set(t, r), G.set(i / t, o / r), G.x -= 0.5, G.y = 1 - G.y, fe.theta = G.x * 2 * Math.PI, fe.phi = G.y * Math.PI, fe.radius = 1, this.generationCallback(fe, G, nt, de);
5614
- const l = 4 * (o * t + i);
5615
- 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;
5616
5574
  }
5617
5575
  }
5618
5576
  copy(e) {
5619
5577
  return super.copy(e), this.generationCallback = e.generationCallback, this;
5620
5578
  }
5621
5579
  }
5622
- const lt = new F();
5623
- class Qa extends Xa {
5580
+ const nt = new P();
5581
+ class $a extends qa {
5624
5582
  constructor(e = 512) {
5625
- super(e, e), this.topColor = new se().set(16777215), this.bottomColor = new se().set(0), this.exponent = 2, this.generationCallback = (t, r, i, o) => {
5626
- lt.setFromSpherical(t);
5627
- const a = lt.y * 0.5 + 0.5;
5628
- o.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
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
+ nt.setFromSpherical(t);
5585
+ const a = nt.y * 0.5 + 0.5;
5586
+ s.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
5629
5587
  };
5630
5588
  }
5631
5589
  copy(e) {
5632
5590
  return super.copy(e), this.topColor.copy(e.topColor), this.bottomColor.copy(e.bottomColor), this;
5633
5591
  }
5634
5592
  }
5635
- class Ka extends ge {
5593
+ class ja extends ge {
5636
5594
  get map() {
5637
5595
  return this.uniforms.map.value;
5638
5596
  }
@@ -5719,7 +5677,7 @@ class Ka extends ge {
5719
5677
  }), this.setValues(e);
5720
5678
  }
5721
5679
  }
5722
- class Za extends ge {
5680
+ class Ya extends ge {
5723
5681
  constructor() {
5724
5682
  super({
5725
5683
  uniforms: {
@@ -5749,7 +5707,7 @@ class Za extends ge {
5749
5707
  #include <common>
5750
5708
  #include <cube_uv_reflection_fragment>
5751
5709
 
5752
- ${St}
5710
+ ${Rt}
5753
5711
 
5754
5712
  void main() {
5755
5713
 
@@ -5762,38 +5720,38 @@ class Za extends ge {
5762
5720
  }), this.depthWrite = !1, this.depthTest = !1;
5763
5721
  }
5764
5722
  }
5765
- class ct {
5723
+ class lt {
5766
5724
  constructor(e) {
5767
- this._renderer = e, this._quad = new Z(new Za());
5725
+ this._renderer = e, this._quad = new Y(new Ya());
5768
5726
  }
5769
5727
  generate(e, t = null, r = null) {
5770
5728
  if (!e.isCubeTexture)
5771
5729
  throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");
5772
- const i = e.images[0], o = this._renderer, a = this._quad;
5730
+ const i = e.images[0], s = this._renderer, a = this._quad;
5773
5731
  t === null && (t = 4 * i.height), r === null && (r = 2 * i.height);
5774
- const l = new ae(t, r, {
5732
+ const l = new ie(t, r, {
5775
5733
  type: R,
5776
5734
  colorSpace: i.colorSpace
5777
- }), h = i.height, d = Math.log2(h) - 2, f = 1 / h, u = 1 / (3 * Math.max(Math.pow(2, d), 112));
5778
- a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH = u, a.material.defines.CUBEUV_TEXEL_HEIGHT = f, a.material.uniforms.envMap.value = e, a.material.uniforms.flipEnvMap.value = e.isRenderTargetTexture ? 1 : -1, a.material.needsUpdate = !0;
5779
- const n = o.getRenderTarget(), x = o.autoClear;
5780
- 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;
5781
5739
  const m = new Uint16Array(t * r * 4), g = new Float32Array(t * r * 4);
5782
- o.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
5740
+ s.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
5783
5741
  for (let p = 0, v = g.length; p < v; p++)
5784
- m[p] = k.toHalfFloat(g[p]);
5785
- const c = new M(m, t, r, I, D);
5786
- return c.minFilter = Gt, c.magFilter = C, c.wrapS = z, c.wrapT = z, c.mapping = vt, 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;
5787
5745
  }
5788
5746
  dispose() {
5789
5747
  this._quad.dispose();
5790
5748
  }
5791
5749
  }
5792
- function Ja(s) {
5793
- return s.extensions.get("EXT_float_blend");
5750
+ function Xa(o) {
5751
+ return o.extensions.get("EXT_float_blend");
5794
5752
  }
5795
- const X = new $();
5796
- class ei {
5753
+ const Z = new X();
5754
+ class Qa {
5797
5755
  get multipleImportanceSampling() {
5798
5756
  return !!this._pathTracer.material.defines.FEATURE_MIS;
5799
5757
  }
@@ -5837,17 +5795,17 @@ class ei {
5837
5795
  return !!this._pathTracer.isCompiling;
5838
5796
  }
5839
5797
  constructor(e) {
5840
- this._renderer = e, this._generator = new Er(), this._pathTracer = new ot(e), this._queueReset = !1, this._clock = new qt(), this._compilePromise = null, this._lowResPathTracer = new ot(e), this._lowResPathTracer.tiles.set(1, 1), this._quad = new Z(new Ka({
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({
5841
5799
  map: null,
5842
5800
  transparent: !0,
5843
- blending: ie,
5801
+ blending: se,
5844
5802
  premultipliedAlpha: e.getContextAttributes().premultipliedAlpha
5845
- })), 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 $(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) => {
5846
5804
  this._renderer.render(t, r);
5847
5805
  }, this.renderToCanvasCallback = (t, r, i) => {
5848
- const o = r.autoClear;
5849
- r.autoClear = !1, i.render(r), r.autoClear = o;
5850
- }, this.setScene(new $t(), new pt());
5806
+ const s = r.autoClear;
5807
+ r.autoClear = !1, i.render(r), r.autoClear = s;
5808
+ }, this.setScene(new Vt(), new dt());
5851
5809
  }
5852
5810
  setBVHWorker(e) {
5853
5811
  this._generator.setBVHWorker(e);
@@ -5856,10 +5814,10 @@ class ei {
5856
5814
  e.updateMatrixWorld(!0), t.updateMatrixWorld();
5857
5815
  const i = this._generator;
5858
5816
  if (i.setObjects(e), this._buildAsync)
5859
- 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));
5860
5818
  {
5861
- const o = i.generate();
5862
- return this._updateFromResults(e, t, o);
5819
+ const s = i.generate();
5820
+ return this._updateFromResults(e, t, s);
5863
5821
  }
5864
5822
  }
5865
5823
  setSceneAsync(...e) {
@@ -5875,24 +5833,24 @@ class ei {
5875
5833
  e.updateMatrixWorld(), this._pathTracer.setCamera(e), this._lowResPathTracer.setCamera(e), this.reset();
5876
5834
  }
5877
5835
  updateMaterials() {
5878
- const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize, o = ia(r);
5879
- 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();
5880
5838
  }
5881
5839
  updateLights() {
5882
- const e = this.scene, t = this._renderer, r = this._pathTracer.material, i = sa(e), o = aa(i);
5883
- 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();
5884
5842
  }
5885
5843
  updateEnvironment() {
5886
5844
  const e = this.scene, t = this._pathTracer.material;
5887
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)
5888
5846
  t.backgroundMap = null, t.backgroundAlpha = 0;
5889
5847
  else if (e.background.isColor) {
5890
- this._colorBackground = this._colorBackground || new Qa(16);
5848
+ this._colorBackground = this._colorBackground || new $a(16);
5891
5849
  const r = this._colorBackground;
5892
5850
  r.topColor.equals(e.background) || (r.topColor.set(e.background), r.bottomColor.set(e.background), r.update()), t.backgroundMap = r, t.backgroundAlpha = 1;
5893
5851
  } else if (e.background.isCubeTexture) {
5894
5852
  if (e.background !== this._previousBackground) {
5895
- const r = new ct(this._renderer).generate(e.background);
5853
+ const r = new lt(this._renderer).generate(e.background);
5896
5854
  this._internalBackground = r, t.backgroundMap = r, t.backgroundAlpha = 1;
5897
5855
  }
5898
5856
  } else
@@ -5900,7 +5858,7 @@ class ei {
5900
5858
  if (t.environmentIntensity = e.environmentIntensity ?? 1, t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(), this._previousEnvironment !== e.environment)
5901
5859
  if (e.environment !== null)
5902
5860
  if (e.environment.isCubeTexture) {
5903
- const r = new ct(this._renderer).generate(e.environment);
5861
+ const r = new lt(this._renderer).generate(e.environment);
5904
5862
  t.envMapInfo.updateFrom(r);
5905
5863
  } else
5906
5864
  t.envMapInfo.updateFrom(e.environment);
@@ -5911,34 +5869,34 @@ class ei {
5911
5869
  _updateFromResults(e, t, r) {
5912
5870
  const {
5913
5871
  materials: i,
5914
- geometry: o,
5872
+ geometry: s,
5915
5873
  bvh: a,
5916
5874
  bvhChanged: l
5917
5875
  } = r;
5918
5876
  this._materials = i;
5919
5877
  const d = this._pathTracer.material;
5920
5878
  return l && (d.bvh.updateFrom(a), d.attributesArray.updateFrom(
5921
- o.attributes.normal,
5922
- o.attributes.tangent,
5923
- o.attributes.uv,
5924
- o.attributes.color
5925
- ), 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;
5926
5884
  }
5927
5885
  renderSample() {
5928
- const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock, o = this._quad;
5929
- 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());
5930
5888
  const a = i.getDelta() * 1e3, l = i.getElapsedTime() * 1e3;
5931
- if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !Ja(r), e.alpha = t.alpha, this.renderToCanvas) {
5932
- const h = this._renderer, d = this.minSamples;
5933
- 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) {
5934
5892
  if (this.dynamicLowRes && !this.isCompiling) {
5935
5893
  e.samples < 1 && (e.material = t.material, e.update());
5936
- const f = o.material.opacity;
5937
- o.material.opacity = 1 - o.material.opacity, o.material.map = e.target.texture, o.render(h), o.material.opacity = f;
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;
5938
5896
  }
5939
5897
  (!this.dynamicLowRes && this.rasterizeScene || this.dynamicLowRes && this.isCompiling) && this.rasterizeSceneCallback(this.scene, this.camera);
5940
5898
  }
5941
- this.enablePathTracing && o.material.opacity > 0 && (o.material.opacity < 1 && (o.material.blending = this.dynamicLowRes ? jt : gt), o.material.map = t.target.texture, this.renderToCanvasCallback(t.target, h, 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);
5942
5900
  }
5943
5901
  }
5944
5902
  reset() {
@@ -5949,30 +5907,30 @@ class ei {
5949
5907
  }
5950
5908
  _updateScale() {
5951
5909
  if (this.synchronizeRenderSize) {
5952
- this._renderer.getDrawingBufferSize(X);
5953
- const e = Math.floor(this.renderScale * X.x), t = Math.floor(this.renderScale * X.y);
5954
- if (this._pathTracer.getSize(X), X.x !== e || X.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) {
5955
5913
  const r = this.lowResScale;
5956
5914
  this._pathTracer.setSize(e, t), this._lowResPathTracer.setSize(Math.floor(e * r), Math.floor(t * r));
5957
5915
  }
5958
5916
  }
5959
5917
  }
5960
5918
  }
5961
- function ut(s) {
5962
- 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";
5963
5921
  }
5964
- function ee(s) {
5965
- 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";
5966
5924
  }
5967
- const pe = class pe {
5925
+ const M = class M {
5968
5926
  constructor() {
5969
- 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 ir(), this.settings = {
5970
- samples: sr,
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
+ samples: ar,
5971
5929
  bounces: 4,
5972
5930
  // Reduce bounces for better performance
5973
5931
  transmissiveBounces: 2,
5974
5932
  // Reduce transmissive bounces
5975
- renderScale: 0.5,
5933
+ renderScale: 1,
5976
5934
  // Start with lower resolution for better performance
5977
5935
  lowResScale: 0.5,
5978
5936
  dynamicLowRes: !0,
@@ -5980,24 +5938,28 @@ const pe = class pe {
5980
5938
  };
5981
5939
  }
5982
5940
  /**
5983
- * Hand the scene to the path tracer with the viewer's own contact-shadow
5984
- * helpers hidden: the tracer computes physically-correct contact shadows
5985
- * itself, so ingesting the baked disc double-darkens the contact area (and
5986
- * the live ShadowMaterial catcher is equally meaningless to it). The
5987
- * generator skips invisible nodes; visibility is restored right after the
5988
- * 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.
5989
5951
  */
5990
5952
  ingestSceneWithoutShadowHelpers(e, t) {
5991
- var i;
5992
- const r = [];
5993
- e.traverse((o) => {
5994
- var a;
5995
- (a = o.userData) != null && a[or] && o.visible && r.push(o);
5996
- }), 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);
5997
5959
  try {
5998
- (i = this.pathTracer) == null || i.setScene(e, t);
5960
+ (s = this.pathTracer) == null || s.setScene(e, t);
5999
5961
  } finally {
6000
- r.forEach((o) => o.visible = !0);
5962
+ r.forEach((a) => a.visible = !0), i.forEach((a) => a.visible = !1);
6001
5963
  }
6002
5964
  }
6003
5965
  /**
@@ -6012,32 +5974,32 @@ const pe = class pe {
6012
5974
  if (!i)
6013
5975
  return null;
6014
5976
  i.drawImage(t, 0, 0);
6015
- const o = i.getImageData(0, 0, r.width, r.height), a = new Float32Array(o.data.length);
6016
- for (let h = 0; h < o.data.length; h++)
6017
- a[h] = o.data[h] / 255;
6018
- 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(
6019
5981
  a,
6020
5982
  r.width,
6021
5983
  r.height,
6022
- J.RGBAFormat,
6023
- J.FloatType
5984
+ _.RGBAFormat,
5985
+ _.FloatType
6024
5986
  );
6025
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;
6026
5988
  }
6027
5989
  async initialize(e) {
6028
5990
  try {
6029
- return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ? _.ok(void 0) : _.err(
6030
- new B(
5991
+ return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ? S.ok(void 0) : S.err(
5992
+ new L(
6031
5993
  "Path tracing is not supported in this environment",
6032
- W.PATH_TRACING_INIT_FAILED,
5994
+ U.PATH_TRACING_INIT_FAILED,
6033
5995
  { reason: "WebGL2 or required extensions not available" }
6034
5996
  )
6035
5997
  );
6036
5998
  } catch (t) {
6037
- return _.err(
6038
- new B(
5999
+ return S.err(
6000
+ new L(
6039
6001
  "Failed to initialize path tracing",
6040
- W.PATH_TRACING_INIT_FAILED,
6002
+ U.PATH_TRACING_INIT_FAILED,
6041
6003
  { originalError: t }
6042
6004
  )
6043
6005
  );
@@ -6045,25 +6007,25 @@ const pe = class pe {
6045
6007
  }
6046
6008
  createPathTracer() {
6047
6009
  if (this.disposed)
6048
- return _.err(
6049
- new B(
6010
+ return S.err(
6011
+ new L(
6050
6012
  "Instance is disposed",
6051
- W.INVALID_STATE
6013
+ U.INVALID_STATE
6052
6014
  )
6053
6015
  );
6054
6016
  try {
6055
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6056
- return e ? (this.pathTracer = new ei(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), _.ok(void 0)) : _.err(
6057
- 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(
6058
6020
  "Renderer not ready, will retry",
6059
- W.RENDERER_NOT_INITIALIZED
6021
+ U.RENDERER_NOT_INITIALIZED
6060
6022
  )
6061
6023
  );
6062
6024
  } catch (e) {
6063
- return _.err(
6064
- new B(
6025
+ return S.err(
6026
+ new L(
6065
6027
  "Failed to create path tracer",
6066
- W.PATH_TRACING_INIT_FAILED,
6028
+ U.PATH_TRACING_INIT_FAILED,
6067
6029
  { originalError: e }
6068
6030
  )
6069
6031
  );
@@ -6072,7 +6034,7 @@ const pe = class pe {
6072
6034
  setEnabled(e) {
6073
6035
  if (this.enabled !== e && (this.enabled = e, !e)) {
6074
6036
  this.resumable = !1, this.reset(), this.sceneInitialized = !1;
6075
- const t = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6037
+ const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6076
6038
  t && (t.autoClear = !0);
6077
6039
  }
6078
6040
  }
@@ -6093,10 +6055,10 @@ const pe = class pe {
6093
6055
  }
6094
6056
  async render(e, t) {
6095
6057
  if (this.disposed)
6096
- return _.ok(void 0);
6058
+ return S.ok(void 0);
6097
6059
  const r = this.renderer;
6098
6060
  if (!r)
6099
- return _.ok(void 0);
6061
+ return S.ok(void 0);
6100
6062
  if (!this.enabled)
6101
6063
  return this.renderWhileDisabled(e, t);
6102
6064
  if (!this.pathTracer) {
@@ -6107,19 +6069,19 @@ const pe = class pe {
6107
6069
  try {
6108
6070
  const i = this.extractThreeObjects(e, t);
6109
6071
  if (!i)
6110
- return _.err(
6111
- new B(
6072
+ return S.err(
6073
+ new L(
6112
6074
  "Could not extract Three.js scene or camera",
6113
- W.INVALID_PARAMETER
6075
+ U.INVALID_PARAMETER
6114
6076
  )
6115
6077
  );
6116
- const { threeScene: o, threeCamera: a } = i;
6078
+ const { threeScene: s, threeCamera: a } = i;
6117
6079
  if (!this.sceneInitialized) {
6118
6080
  const l = await this.initializeSceneForPathTracing(
6119
6081
  r,
6120
6082
  e,
6121
6083
  t,
6122
- o,
6084
+ s,
6123
6085
  a
6124
6086
  );
6125
6087
  if (l)
@@ -6127,10 +6089,10 @@ const pe = class pe {
6127
6089
  }
6128
6090
  return this.sceneInitialized ? this.accumulateSample(r, e, t) : r.render(e, t);
6129
6091
  } catch (i) {
6130
- return _.err(
6131
- new B(
6092
+ return S.err(
6093
+ new L(
6132
6094
  "Failed to render with path tracing",
6133
- W.RENDER_FAILED,
6095
+ U.RENDER_FAILED,
6134
6096
  { originalError: i }
6135
6097
  )
6136
6098
  );
@@ -6144,15 +6106,15 @@ const pe = class pe {
6144
6106
  * while still waiting for the renderer, or after giving up and disabling.
6145
6107
  */
6146
6108
  ensurePathTracerCreated(e, t, r) {
6147
- var o;
6109
+ var s;
6148
6110
  this.createAttempts++;
6149
6111
  const i = this.createPathTracer();
6150
- 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));
6151
6113
  }
6152
6114
  /** Unwraps the Three.js scene/camera from their adapters, or null if either fails. */
6153
6115
  extractThreeObjects(e, t) {
6154
6116
  let r = null, i = null;
6155
- return ut(e) && (r = e.getInternalRenderer()), ut(t) && (i = t.getInternalRenderer()), !r || !i ? null : { threeScene: r, threeCamera: i };
6117
+ return ct(e) && (r = e.getInternalRenderer()), ct(t) && (i = t.getInternalRenderer()), !r || !i ? null : { threeScene: r, threeCamera: i };
6156
6118
  }
6157
6119
  /**
6158
6120
  * First-frame setup: waits for an environment texture, converts an
@@ -6162,47 +6124,47 @@ const pe = class pe {
6162
6124
  * Result when render() should return it immediately instead — still
6163
6125
  * waiting, or the environment shape isn't one the tracer can use.
6164
6126
  */
6165
- async initializeSceneForPathTracing(e, t, r, i, o) {
6127
+ async initializeSceneForPathTracing(e, t, r, i, s) {
6166
6128
  var a;
6167
6129
  try {
6168
6130
  const l = i.__originalEnvironmentTexture;
6169
6131
  if (!i.environment && !l)
6170
6132
  return this.environmentWaitFrames++, this.environmentWaitFrames >= this.maxEnvironmentWaitFrames && (this.disableAfterSelfPause("gave-up"), this.environmentWaitFrames = 0), e.render(t, r);
6171
6133
  if (this.environmentWaitFrames = 0, l && l.isCubeTexture) {
6172
- const h = i.environment;
6134
+ const u = i.environment;
6173
6135
  i.environment = l;
6174
6136
  try {
6175
- this.ingestSceneWithoutShadowHelpers(i, o), this.sceneInitialized = !0;
6137
+ this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
6176
6138
  } finally {
6177
- i.environment = h;
6139
+ i.environment = u;
6178
6140
  }
6179
- } else if (l && l.mapping === J.EquirectangularReflectionMapping) {
6180
- let h = l;
6141
+ } else if (l && l.mapping === _.EquirectangularReflectionMapping) {
6142
+ let u = l;
6181
6143
  if (l.image instanceof HTMLImageElement)
6182
6144
  if (this.convertedEnvTexture)
6183
- h = this.convertedEnvTexture;
6145
+ u = this.convertedEnvTexture;
6184
6146
  else {
6185
- const f = this.convertToDataTexture(l);
6186
- if (!f)
6147
+ const h = this.convertToDataTexture(l);
6148
+ if (!h)
6187
6149
  throw new Error("Failed to convert environment texture to DataTexture");
6188
- this.convertedEnvTexture = f, h = f;
6150
+ this.convertedEnvTexture = h, u = h;
6189
6151
  }
6190
6152
  const d = i.environment;
6191
- i.environment = h;
6153
+ i.environment = u;
6192
6154
  try {
6193
- const f = l.image;
6194
- f && !("data" in f && f.data) && f instanceof HTMLImageElement && !f.complete && await new Promise((u) => {
6195
- f.onload = () => {
6196
- l.needsUpdate = !0, u();
6197
- }, f.onerror = () => {
6198
- u();
6199
- }, f.complete && u();
6200
- }), this.ingestSceneWithoutShadowHelpers(i, o), this.sceneInitialized = !0, i.environment = d;
6201
- } catch (f) {
6202
- throw i.environment = d, f;
6155
+ const h = l.image;
6156
+ h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((f) => {
6157
+ h.onload = () => {
6158
+ l.needsUpdate = !0, f();
6159
+ }, h.onerror = () => {
6160
+ f();
6161
+ }, h.complete && f();
6162
+ }), this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0, i.environment = d;
6163
+ } catch (h) {
6164
+ throw i.environment = d, h;
6203
6165
  }
6204
- } else if (((a = i.environment) == null ? void 0 : a.mapping) === J.EquirectangularReflectionMapping)
6205
- 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;
6206
6168
  else
6207
6169
  return this.disableAfterSelfPause("gave-up"), e.render(t, r);
6208
6170
  } catch (l) {
@@ -6216,29 +6178,140 @@ const pe = class pe {
6216
6178
  * feedback, accumulates a tracer sample, and detects completion.
6217
6179
  */
6218
6180
  accumulateSample(e, t, r) {
6219
- var o, a;
6181
+ var s, a;
6220
6182
  if (this.sampleCount === 0)
6221
6183
  try {
6222
- (o = this.pathTracer) == null || o.updateLights();
6184
+ (s = this.pathTracer) == null || s.updateLights();
6223
6185
  } catch (l) {
6224
6186
  console.warn("Failed to update lights for path tracing:", l);
6225
6187
  }
6226
6188
  const i = e.render(t, r);
6227
- return i.ok ? performance.now() - this.lastCameraMoveTime < pe.CAMERA_SETTLE_MS ? _.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() : _.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
+ });
6228
6301
  }
6229
6302
  /**
6230
6303
  * Render while path tracing is disabled: keep the final accumulated image on
6231
6304
  * screen if we just completed, otherwise delegate to the standard renderer.
6232
6305
  */
6233
6306
  renderWhileDisabled(e, t) {
6234
- return this.renderer ? this.sampleCount >= this.settings.samples && this.sampleCount > 0 ? (this.pathTracer && ee(this.renderer) && this.renderer.getInternalRenderer().setRenderTarget(null), _.ok(void 0)) : this.renderer.render(e, t) : _.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);
6235
6308
  }
6236
6309
  /**
6237
6310
  * Render a single path-tracing sample into the internal buffer, preserving the
6238
6311
  * renderer's autoClear/render-target state so the standard view stays visible.
6239
6312
  */
6240
6313
  accumulateOneSample() {
6241
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6314
+ const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6242
6315
  if (!e)
6243
6316
  throw new Error("Three.js renderer not available");
6244
6317
  const t = e.autoClear, r = e.getRenderTarget();
@@ -6252,7 +6325,7 @@ const pe = class pe {
6252
6325
  * stale frame frozen on screen.
6253
6326
  */
6254
6327
  captureCompletedFrame() {
6255
- const e = ee(this.renderer) ? this.renderer.getInternalRenderer() : null;
6328
+ const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
6256
6329
  if (e && this.pathTracer)
6257
6330
  try {
6258
6331
  const t = e.autoClear;
@@ -6262,7 +6335,7 @@ const pe = class pe {
6262
6335
  } catch (t) {
6263
6336
  console.warn("Failed to present path traced result:", t);
6264
6337
  }
6265
- return this.disableAfterSelfPause("completed"), _.ok(void 0);
6338
+ return this.disableAfterSelfPause("completed"), S.ok(void 0);
6266
6339
  }
6267
6340
  getSampleCount() {
6268
6341
  return this.sampleCount;
@@ -6297,14 +6370,14 @@ const pe = class pe {
6297
6370
  }
6298
6371
  this.pathTracer = null;
6299
6372
  }
6300
- 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;
6301
6374
  }
6302
6375
  isSupported() {
6303
6376
  return document.createElement("canvas").getContext("webgl2") !== null;
6304
6377
  }
6305
6378
  };
6306
- pe.CAMERA_SETTLE_MS = 200;
6307
- let ht = 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;
6308
6381
  export {
6309
- ht as ThreePathTracingService
6382
+ ut as ThreePathTracingService
6310
6383
  };