@objectifthunes/three-book 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as l from "three";
2
- class wt {
1
+ import * as c from "three";
2
+ class Pt {
3
3
  constructor() {
4
- this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new l.Vector3(), this._scratchRP1 = new l.Vector3(), this._scratchRP2 = new l.Vector3(), this._scratchRollClosest = new l.Vector3(), this._scratchRollEuler = new l.Vector3(), this._scratchOffsetRoll = new l.Vector3();
4
+ this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new c.Vector3(), this._scratchRP1 = new c.Vector3(), this._scratchRP2 = new c.Vector3(), this._scratchRollClosest = new c.Vector3(), this._scratchRollEuler = new c.Vector3(), this._scratchOffsetRoll = new c.Vector3();
5
5
  }
6
6
  // ── Properties ────────────────────────────────────────────────────────
7
7
  /** Returns internal vector — do NOT mutate. Copy if you need to store it. */
@@ -33,7 +33,7 @@ class wt {
33
33
  * Writes result into `out` and returns it.
34
34
  */
35
35
  eulerRotateVector(t, e, s, i) {
36
- const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), o = Math.sin(n), u = t * a, c = t * o, m = 0, f = Math.cos(h), d = Math.sin(h), _ = u * f + m * d, g = c, p = -u * d + m * f;
36
+ const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), o = Math.sin(n), u = t * a, l = t * o, m = 0, f = Math.cos(h), d = Math.sin(h), _ = u * f + m * d, g = l, p = -u * d + m * f;
37
37
  return i.set(_, g, p);
38
38
  }
39
39
  /**
@@ -78,7 +78,7 @@ class wt {
78
78
  }
79
79
  // ── Value-type clone ──────────────────────────────────────────────────
80
80
  clone() {
81
- const t = new wt();
81
+ const t = new Pt();
82
82
  return t.m_PositionX = this.m_PositionX, t.m_PositionZ = this.m_PositionZ, t.m_DirectionX = this.m_DirectionX, t.m_DirectionZ = this.m_DirectionZ, t.m_EulerY = this.m_EulerY, t.m_Radius = this.m_Radius, t;
83
83
  }
84
84
  }
@@ -86,14 +86,14 @@ function dt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
86
86
  s = Math.max(s, 1e-4);
87
87
  const h = 2 / s, a = h * n, o = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
88
88
  let u = r - t;
89
- const c = t, m = i * s;
90
- u = l.MathUtils.clamp(u, -m, m), t = r - u;
89
+ const l = t, m = i * s;
90
+ u = c.MathUtils.clamp(u, -m, m), t = r - u;
91
91
  const f = (e + h * u) * n;
92
92
  e = (e - h * f) * o;
93
93
  let d = t + (u + f) * o;
94
- return c - r > 0 == d > c && (d = c, e = (d - c) / n), { value: d, velocity: e };
94
+ return l - r > 0 == d > l && (d = l, e = (d - l) / n), { value: d, velocity: e };
95
95
  }
96
- function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
96
+ function se(r, t, e, s, i = 1 / 0, n = 1 / 60) {
97
97
  const h = dt(
98
98
  r.x,
99
99
  t.x,
@@ -133,9 +133,9 @@ function vt(r, t, e) {
133
133
  };
134
134
  }
135
135
  }
136
- const kt = new l.Vector2();
136
+ const kt = new c.Vector2();
137
137
  function Bt(r, t, e, s) {
138
- return se(r, t, e) ? s.copy(r) : (kt.set(r.x, t.y), ie(
138
+ return ie(r, t, e) ? s.copy(r) : (kt.set(r.x, t.y), ne(
139
139
  kt,
140
140
  r,
141
141
  t,
@@ -143,13 +143,13 @@ function Bt(r, t, e, s) {
143
143
  s
144
144
  ));
145
145
  }
146
- function se(r, t, e) {
146
+ function ie(r, t, e) {
147
147
  const s = r.x - t.x;
148
148
  let i = r.y - t.y;
149
149
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
150
150
  }
151
- function ie(r, t, e, s, i) {
152
- const n = e.x, h = e.y, a = r.x, o = r.y, u = t.x, c = t.y, m = s.x, f = s.y, d = 1 / (m * m), _ = 1 / (f * f);
151
+ function ne(r, t, e, s, i) {
152
+ const n = e.x, h = e.y, a = r.x, o = r.y, u = t.x, l = t.y, m = s.x, f = s.y, d = 1 / (m * m), _ = 1 / (f * f);
153
153
  if (Math.abs(a - u) < 1e-5) {
154
154
  if (a >= n - m && a <= n + m) {
155
155
  const g = vt(
@@ -161,11 +161,11 @@ function ie(r, t, e, s, i) {
161
161
  return i.set(a, g.root0);
162
162
  if (g.rootCount === 2) {
163
163
  let p = g.root0, M = g.root1;
164
- return o < c && ([p, M] = [M, p]), i.set(a, M);
164
+ return o < l && ([p, M] = [M, p]), i.set(a, M);
165
165
  }
166
166
  }
167
167
  } else {
168
- const g = (c - o) / (u - a), p = o - g * a, M = p - h, T = vt(
168
+ const g = (l - o) / (u - a), p = o - g * a, M = p - h, T = vt(
169
169
  d + _ * g * g,
170
170
  2 * M * g * _ - 2 * n * d,
171
171
  n * n * d + M * M * _ - 1
@@ -173,21 +173,21 @@ function ie(r, t, e, s, i) {
173
173
  if (T.rootCount === 1)
174
174
  return i.set(T.root0, g * T.root0 + p);
175
175
  if (T.rootCount === 2) {
176
- let P = T.root0, C = T.root1;
177
- return a < u && ([P, C] = [C, P]), i.set(C, g * C + p);
176
+ let w = T.root0, C = T.root1;
177
+ return a < u && ([w, C] = [C, w]), i.set(C, g * C + p);
178
178
  }
179
179
  }
180
180
  return i.copy(r);
181
181
  }
182
- const ft = new l.Vector3(), Rt = new l.Vector3(), bt = new l.Ray();
182
+ const ft = new c.Vector3(), Rt = new c.Vector3(), bt = new c.Ray();
183
183
  function Dt(r, t) {
184
184
  return ft.copy(r.origin).applyMatrix4(t), Rt.copy(r.origin).add(r.direction).applyMatrix4(t), bt.set(ft, Rt.sub(ft).normalize()), bt;
185
185
  }
186
- function ne(r) {
186
+ function re(r) {
187
187
  const t = r.x;
188
188
  r.set(-t, r.y, r.z + t, r.w);
189
189
  }
190
- function re(r) {
190
+ function he(r) {
191
191
  const t = r.y;
192
192
  r.set(r.x, -t, r.z, r.w + t);
193
193
  }
@@ -209,14 +209,14 @@ function Q(r, t, e) {
209
209
  return r !== t ? lt((e - r) / (t - r)) : 0;
210
210
  }
211
211
  var ut = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(ut || {});
212
- const he = 1192093e-13;
212
+ const ae = 1192093e-13;
213
213
  function Vt(r, t, e) {
214
214
  return e = lt((e - r) / (t - r)), e * e * (3 - 2 * e);
215
215
  }
216
- class ae {
216
+ class oe {
217
217
  // ---- Constructor ----
218
218
  constructor(t, e, s, i) {
219
- this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new l.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new wt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new l.Plane(), this.m_StartHandle = new l.Vector3(), this.m_CurrentHandle = new l.Vector3(), this.m_EndHandle = new l.Vector3(), this.m_PrevHandle = new l.Vector3(), this.m_HandleOffset = new l.Vector3(), this.m_HandleVelocity = new l.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new l.Vector3(), this._ucCurrentHandle = new l.Vector3(), this._ucHandleDir = new l.Vector3(), this._ucA = new l.Vector3(), this._ucB = new l.Vector3(), this._ucMid = new l.Vector3(), this._ucRollResult = new l.Vector3(), this._ucCylDir = new l.Vector3(), this._utV1 = new l.Vector3(), this._utV2 = new l.Vector3(), this._utV3 = new l.Vector3(), this._utV4 = new l.Vector3(), this._chP = new l.Vector3(), this._chA = new l.Vector3(), this._chC = new l.Vector3(), this._chEllipseCenter1 = new l.Vector2(), this._chEllipseCenter2 = new l.Vector2(), this._chEllipseSize1 = new l.Vector2(), this._chEllipseSize2 = new l.Vector2(), this._chP2 = new l.Vector2(), this._dirResult = new l.Vector3(), this._gdA = new l.Vector3(), this._gdB = new l.Vector3(), this._rlMatrix = new l.Matrix4(), this._rlPlane = new l.Plane(new l.Vector3(0, 1, 0), 0), this._rlTarget = new l.Vector3(), this._rlNormal = new l.Vector3(), this._utTarget = new l.Vector3(), this._ufSmoothTime = new l.Vector3(), this._umFrontST = new l.Vector4(), this._umBackST = new l.Vector4(), this._h2uResult = new l.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
219
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new Pt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new c.Vector3(), this._ucCurrentHandle = new c.Vector3(), this._ucHandleDir = new c.Vector3(), this._ucA = new c.Vector3(), this._ucB = new c.Vector3(), this._ucMid = new c.Vector3(), this._ucRollResult = new c.Vector3(), this._ucCylDir = new c.Vector3(), this._utV1 = new c.Vector3(), this._utV2 = new c.Vector3(), this._utV3 = new c.Vector3(), this._utV4 = new c.Vector3(), this._chP = new c.Vector3(), this._chA = new c.Vector3(), this._chC = new c.Vector3(), this._chEllipseCenter1 = new c.Vector2(), this._chEllipseCenter2 = new c.Vector2(), this._chEllipseSize1 = new c.Vector2(), this._chEllipseSize2 = new c.Vector2(), this._chP2 = new c.Vector2(), this._dirResult = new c.Vector3(), this._gdA = new c.Vector3(), this._gdB = new c.Vector3(), this._rlMatrix = new c.Matrix4(), this._rlPlane = new c.Plane(new c.Vector3(0, 1, 0), 0), this._rlTarget = new c.Vector3(), this._rlNormal = new c.Vector3(), this._utTarget = new c.Vector3(), this._ufSmoothTime = new c.Vector3(), this._umFrontST = new c.Vector4(), this._umBackST = new c.Vector4(), this._h2uResult = new c.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
220
220
  }
221
221
  // ---- Properties (mirrors C#) ----
222
222
  get isMeshChanged() {
@@ -361,7 +361,7 @@ class ae {
361
361
  }
362
362
  stopTurning() {
363
363
  this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
364
- const t = new l.Vector3(0, 0, 0);
364
+ const t = new c.Vector3(0, 0, 0);
365
365
  for (const e of this.m_HandleVelocities)
366
366
  t.add(e);
367
367
  t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = F(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
@@ -393,9 +393,9 @@ class ae {
393
393
  this.m_StartHandle,
394
394
  this.m_EndHandle,
395
395
  this.m_IsFallingLeft ? n : 1 - n
396
- ), this.m_FallTime += t, e = Math.abs(n - 1) < he;
396
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < ae;
397
397
  } else
398
- this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), ee(
398
+ this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), se(
399
399
  this.m_CurrentHandle,
400
400
  this.m_EndHandle,
401
401
  this.m_HandleVelocity,
@@ -422,12 +422,12 @@ class ae {
422
422
  }
423
423
  getTextureCoordinate(t) {
424
424
  const e = this.raycastLocal(t, !0);
425
- return e !== null ? this.hit2UV(e) : new l.Vector2(0, 0);
425
+ return e !== null ? this.hit2UV(e) : new c.Vector2(0, 0);
426
426
  }
427
427
  raycast(t) {
428
428
  const e = {
429
- point: new l.Vector3(),
430
- textureCoordinate: new l.Vector2(),
429
+ point: new c.Vector3(),
430
+ textureCoordinate: new c.Vector2(),
431
431
  pageContent: null,
432
432
  paperIndex: 0,
433
433
  pageIndex: 0
@@ -496,7 +496,7 @@ class ae {
496
496
  t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
497
497
  ), this.m_SubMeshCount = t);
498
498
  const e = this._umFrontST.copy(this.m_FrontContent.textureST), s = this._umBackST.copy(this.m_BackContent.textureST);
499
- this.m_Book.direction > 1 ? re(s) : ne(s);
499
+ this.m_Book.direction > 1 ? he(s) : re(s);
500
500
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
501
501
  if (t === 3) {
502
502
  let h = 0, a = 1;
@@ -552,7 +552,7 @@ class ae {
552
552
  this._utV3.set(s[1], 0, i[i.length - 1]);
553
553
  const a = this.rollPoint(this._utV3);
554
554
  this._utV4.set(s[2], 0, i[i.length - 1]);
555
- const o = this.rollPoint(this._utV4), u = h.x - n.x, c = h.y - n.y, m = o.x - a.x, f = o.y - a.y, d = Math.sqrt(u * u + c * c) || 1, _ = Math.sqrt(m * m + f * f) || 1, g = et * Math.atan2(c / d, u / d), p = et * Math.atan2(f / _, m / _), M = (g + p) / 2;
555
+ const o = this.rollPoint(this._utV4), u = h.x - n.x, l = h.y - n.y, m = o.x - a.x, f = o.y - a.y, d = Math.sqrt(u * u + l * l) || 1, _ = Math.sqrt(m * m + f * f) || 1, g = et * Math.atan2(l / d, u / d), p = et * Math.atan2(f / _, m / _), M = (g + p) / 2;
556
556
  this.m_ZTime = M / 180;
557
557
  } else
558
558
  this.m_XTime = 0, this.m_ZTime = 0;
@@ -565,13 +565,13 @@ class ae {
565
565
  const t = this._chP.copy(this.m_CurrentHandle), e = this._chA.set(0, 0, 0), s = this._chC.set(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), h = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), o = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
566
566
  0,
567
567
  o + (e.z - o) * (h / i)
568
- ), c = this._chEllipseCenter2.set(
568
+ ), l = this._chEllipseCenter2.set(
569
569
  0,
570
570
  o + (s.z - o) * (a / n)
571
571
  ), m = this._chEllipseSize1.set(i, h), f = this._chEllipseSize2.set(n, a);
572
572
  t.x = H(t.x, -this.m_Size.x, this.m_Size.x);
573
573
  const d = this._chP2.set(t.x, t.z);
574
- Bt(d, u, m, d), Bt(d, c, f, d), this.m_CurrentHandle.set(d.x, 0, d.y);
574
+ Bt(d, u, m, d), Bt(d, l, f, d), this.m_CurrentHandle.set(d.x, 0, d.y);
575
575
  }
576
576
  updateCylinder() {
577
577
  const t = this._ucStartHandle.copy(this.m_StartHandle), e = this._ucCurrentHandle.copy(this.m_CurrentHandle), s = this._ucHandleDir.copy(t).sub(e).normalize();
@@ -591,7 +591,7 @@ class ae {
591
591
  return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
592
592
  }
593
593
  startAutoTurning(t, e, s, i) {
594
- var u, c;
594
+ var u, l;
595
595
  if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === ut.Surface) {
596
596
  const m = this.m_Transform.scale;
597
597
  m.x *= -1;
@@ -599,7 +599,7 @@ class ae {
599
599
  this.switchMeshData(
600
600
  0
601
601
  /* Highpoly */
602
- ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (c = this.m_Next) == null || c.trySwitchMeshData(1), this.m_IsFallingLeft = t === ut.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
602
+ ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === ut.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
603
603
  const n = this.m_Size.x, h = this.m_Size.y;
604
604
  e = H(e, -0.99, 0.99);
605
605
  const a = It(0.5, 1, e), o = It(0.5, 0, e);
@@ -692,7 +692,7 @@ st.kMin = 0, st.kMax = 0.25;
692
692
  let gt = st;
693
693
  const X = class X {
694
694
  constructor(t) {
695
- this.m_Material = null, this.m_Color = new l.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new l.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
695
+ this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
696
696
  }
697
697
  // ── Properties ────────────────────────────────────────────────────────
698
698
  get material() {
@@ -747,15 +747,15 @@ const X = class X {
747
747
  this.m_UVMargin = t;
748
748
  }
749
749
  get size() {
750
- return new l.Vector2(this.width, this.height);
750
+ return new c.Vector2(this.width, this.height);
751
751
  }
752
752
  };
753
753
  X.kMinSize = 1, X.kMinThickness = 1e-4, X.kMinQuality = 1, X.kMaxQuality = 5;
754
754
  let rt = X;
755
755
  class zt {
756
756
  constructor(t) {
757
- this.m_Texture = null, this.m_TextureST = new l.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
758
- const e = t.material ?? new l.MeshStandardMaterial();
757
+ this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
758
+ const e = t.material ?? new c.MeshStandardMaterial();
759
759
  this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
760
760
  }
761
761
  get materials1() {
@@ -790,12 +790,12 @@ class zt {
790
790
  this.m_Texture = t, this.m_TextureST.copy(e), this._propertyBlockDirty = !0;
791
791
  }
792
792
  }
793
- function At(r, t, e, s = new l.Vector3()) {
793
+ function At(r, t, e, s = new c.Vector3()) {
794
794
  let i = t.x - r.x, n = t.y - r.y, h = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + h * h);
795
795
  i *= a, n *= a, h *= a;
796
- let o = e.x - r.x, u = e.y - r.y, c = e.z - r.z;
797
- a = 1 / Math.sqrt(o * o + u * u + c * c), o *= a, u *= a, c *= a;
798
- const m = n * c - h * u, f = h * o - i * c, d = i * u - n * o;
796
+ let o = e.x - r.x, u = e.y - r.y, l = e.z - r.z;
797
+ a = 1 / Math.sqrt(o * o + u * u + l * l), o *= a, u *= a, l *= a;
798
+ const m = n * l - h * u, f = h * o - i * l, d = i * u - n * o;
799
799
  return a = 1 / Math.sqrt(m * m + f * f + d * d), s.set(m * a, f * a, d * a);
800
800
  }
801
801
  class ht {
@@ -849,12 +849,12 @@ class ht {
849
849
  t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
850
850
  }
851
851
  }
852
- class Pt {
852
+ class wt {
853
853
  constructor(t, e, s, i) {
854
854
  this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
855
855
  }
856
856
  clone() {
857
- const t = new Pt(this.prevIndex, this.index, this.nextIndex, this.time);
857
+ const t = new wt(this.prevIndex, this.index, this.nextIndex, this.time);
858
858
  return t.active = this.active, t;
859
859
  }
860
860
  }
@@ -873,7 +873,7 @@ class Tt {
873
873
  );
874
874
  }
875
875
  }
876
- class oe {
876
+ class le {
877
877
  constructor(t, e, s) {
878
878
  const i = t.size;
879
879
  this.leftNode = new ht(e.left * i.x, s, !0), this.rightNode = new ht((1 - e.right) * i.x, s, !0), this.downNode = new ht(e.down * i.y, s, !0), this.upNode = new ht((1 - e.up) * i.y, s, !0);
@@ -884,7 +884,7 @@ class oe {
884
884
  }
885
885
  function pt(r, t) {
886
886
  for (const e of r) {
887
- const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new Pt(s.index, e.index, i.index, n);
887
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new wt(s.index, e.index, i.index, n);
888
888
  t.push(h);
889
889
  }
890
890
  }
@@ -892,24 +892,24 @@ function xt(r, t, e, s, i) {
892
892
  for (const n of r)
893
893
  if (n.active)
894
894
  for (let h = 0; h < s; h++) {
895
- const a = n.prevIndex, o = n.nextIndex, u = t[h * e + a], c = t[h * e + o], m = t[h * e + n.index];
896
- i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
895
+ const a = n.prevIndex, o = n.nextIndex, u = t[h * e + a], l = t[h * e + o], m = t[h * e + n.index];
896
+ i ? Gt(u, l, n.time, m) : m.copy(u).lerp(l, n.time);
897
897
  }
898
898
  }
899
899
  function Mt(r, t, e, s, i) {
900
900
  for (const n of r)
901
901
  if (n.active)
902
902
  for (let h = 0; h < e; h++) {
903
- const a = n.prevIndex, o = n.nextIndex, u = t[a * e + h], c = t[o * e + h], m = t[n.index * e + h];
904
- i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
903
+ const a = n.prevIndex, o = n.nextIndex, u = t[a * e + h], l = t[o * e + h], m = t[n.index * e + h];
904
+ i ? Gt(u, l, n.time, m) : m.copy(u).lerp(l, n.time);
905
905
  }
906
906
  }
907
- function Gt(r, t, e, s = new l.Vector3()) {
907
+ function Gt(r, t, e, s = new c.Vector3()) {
908
908
  const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
909
909
  if (i === 0 || n === 0)
910
910
  return s.copy(r).lerp(t, e);
911
- const h = r.x / i, a = r.y / i, o = r.z / i, u = t.x / n, c = t.y / n, m = t.z / n;
912
- let f = h * u + a * c + o * m;
911
+ const h = r.x / i, a = r.y / i, o = r.z / i, u = t.x / n, l = t.y / n, m = t.z / n;
912
+ let f = h * u + a * l + o * m;
913
913
  f = Math.max(-1, Math.min(1, f));
914
914
  const d = Math.acos(f);
915
915
  if (d < 1e-6)
@@ -917,42 +917,42 @@ function Gt(r, t, e, s = new l.Vector3()) {
917
917
  const _ = Math.sin(d), g = Math.sin((1 - e) * d) / _, p = Math.sin(e * d) / _, M = i + (n - i) * e;
918
918
  return s.set(
919
919
  (h * g + u * p) * M,
920
- (a * g + c * p) * M,
920
+ (a * g + l * p) * M,
921
921
  (o * g + m * p) * M
922
922
  );
923
923
  }
924
924
  function jt(r, t, e, s, i) {
925
925
  for (const n of r) {
926
926
  const h = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, o = e.length;
927
- for (let c = 0, m = n.endX - n.startX; c < m; c++) {
928
- const f = o + c * 2 + 0, d = o + c * 2 + 1, _ = o + c * 2 + 2, g = o + c * 2 + 3;
927
+ for (let l = 0, m = n.endX - n.startX; l < m; l++) {
928
+ const f = o + l * 2 + 0, d = o + l * 2 + 1, _ = o + l * 2 + 2, g = o + l * 2 + 3;
929
929
  n.flip ? Ft(t, f, d, _, g, h) : Ht(t, f, d, _, g, h);
930
930
  }
931
931
  if (n.left)
932
- for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
933
- const f = o + c * 2 + 0 + h * 2, d = o + c * 2 + 1 + h * 2, _ = o + c * 2 + 2 + h * 2, g = o + c * 2 + 3 + h * 2;
932
+ for (let l = 0, m = n.endZ - n.startZ; l < m; l++) {
933
+ const f = o + l * 2 + 0 + h * 2, d = o + l * 2 + 1 + h * 2, _ = o + l * 2 + 2 + h * 2, g = o + l * 2 + 3 + h * 2;
934
934
  n.flip ? Ft(t, f, d, _, g, a) : Ht(t, f, d, _, g, a);
935
935
  }
936
936
  else
937
- for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
938
- const f = o + c * 2 + 0 + h * 2 + a, d = o + c * 2 + 1 + h * 2 + a, _ = o + c * 2 + 2 + h * 2 + a, g = o + c * 2 + 3 + h * 2 + a;
937
+ for (let l = 0, m = n.endZ - n.startZ; l < m; l++) {
938
+ const f = o + l * 2 + 0 + h * 2 + a, d = o + l * 2 + 1 + h * 2 + a, _ = o + l * 2 + 2 + h * 2 + a, g = o + l * 2 + 3 + h * 2 + a;
939
939
  n.flip ? _t(t, f, d, _, g) : mt(t, f, d, _, g);
940
940
  }
941
941
  const u = s * i;
942
- for (let c = n.startX; c <= n.endX; c++) {
943
- const m = n.startZ * s + c;
942
+ for (let l = n.startX; l <= n.endX; l++) {
943
+ const m = n.startZ * s + l;
944
944
  e.push(e[m].clone()), e.push(e[m + u].clone());
945
945
  }
946
- for (let c = n.startX; c <= n.endX; c++) {
947
- const m = c + n.endZ * s;
946
+ for (let l = n.startX; l <= n.endX; l++) {
947
+ const m = l + n.endZ * s;
948
948
  e.push(e[m + u].clone()), e.push(e[m].clone());
949
949
  }
950
- for (let c = n.startZ; c <= n.endZ; c++) {
951
- const m = n.startX + c * s;
950
+ for (let l = n.startZ; l <= n.endZ; l++) {
951
+ const m = n.startX + l * s;
952
952
  e.push(e[m + u].clone()), e.push(e[m].clone());
953
953
  }
954
- for (let c = n.startZ; c <= n.endZ; c++) {
955
- const m = c * s + n.endX;
954
+ for (let l = n.startZ; l <= n.endZ; l++) {
955
+ const m = l * s + n.endX;
956
956
  e.push(e[m].clone()), e.push(e[m + u].clone());
957
957
  }
958
958
  }
@@ -960,23 +960,23 @@ function jt(r, t, e, s, i) {
960
960
  function qt(r, t, e, s, i) {
961
961
  const n = s * i;
962
962
  let h = n * 2;
963
- const a = new l.Vector3();
963
+ const a = new c.Vector3();
964
964
  for (const o of r) {
965
965
  for (let u = o.startX; u <= o.endX; u++) {
966
- const c = u + o.startZ * s, m = t[c], f = t[c + s];
967
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
966
+ const l = u + o.startZ * s, m = t[l], f = t[l + s];
967
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l + n]);
968
968
  }
969
969
  for (let u = o.startX; u <= o.endX; u++) {
970
- const c = u + o.endZ * s, m = t[c + n], f = t[c + n - s];
971
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
970
+ const l = u + o.endZ * s, m = t[l + n], f = t[l + n - s];
971
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l]);
972
972
  }
973
973
  for (let u = o.startZ; u <= o.endZ; u++) {
974
- const c = u * s + o.startX, m = t[c + n], f = t[c + n + 1];
975
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
974
+ const l = u * s + o.startX, m = t[l + n], f = t[l + n + 1];
975
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l]);
976
976
  }
977
977
  for (let u = o.startZ; u <= o.endZ; u++) {
978
- const c = u * s + o.endX, m = t[c], f = t[c - 1];
979
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
978
+ const l = u * s + o.endX, m = t[l], f = t[l - 1];
979
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l + n]);
980
980
  }
981
981
  }
982
982
  }
@@ -990,18 +990,18 @@ function Qt(r, t, e, s, i, n, h) {
990
990
  mt(r, e, s, i, n), e += h, s += h, i += h, n += h, _t(t, e, s, i, n);
991
991
  }
992
992
  function $t(r, t, e, s, i, n) {
993
- const h = i.left * s.x, a = (1 - i.right) * s.x, o = i.down * s.y, u = (1 - i.up) * s.y, c = t.length, m = e.length;
993
+ const h = i.left * s.x, a = (1 - i.right) * s.x, o = i.down * s.y, u = (1 - i.up) * s.y, l = t.length, m = e.length;
994
994
  if (n > 1)
995
995
  for (let d = 0; d < m; d++)
996
- for (let _ = 0; _ < c; _++) {
996
+ for (let _ = 0; _ < l; _++) {
997
997
  const g = Q(a, h, t[_]), p = Q(u, o, e[d]);
998
- r.push(new l.Vector2(p, g));
998
+ r.push(new c.Vector2(p, g));
999
999
  }
1000
1000
  else
1001
1001
  for (let d = 0; d < m; d++)
1002
- for (let _ = 0; _ < c; _++) {
1002
+ for (let _ = 0; _ < l; _++) {
1003
1003
  const g = Q(h, a, t[_]), p = Q(u, o, e[d]);
1004
- r.push(new l.Vector2(g, p));
1004
+ r.push(new c.Vector2(g, p));
1005
1005
  }
1006
1006
  const f = r.length;
1007
1007
  for (let d = 0; d < f; d++)
@@ -1013,7 +1013,7 @@ function mt(r, t, e, s, i) {
1013
1013
  function _t(r, t, e, s, i) {
1014
1014
  r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1015
1015
  }
1016
- const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1016
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1017
1017
  __proto__: null,
1018
1018
  addBorders: jt,
1019
1019
  addFrontAndBackFaces: Qt,
@@ -1036,33 +1036,33 @@ class Ot {
1036
1036
  constructor(t, e) {
1037
1037
  this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1038
1038
  for (let h = 0; h < e.baseVertexCount; h++)
1039
- this.m_BaseVertices[h] = new l.Vector3();
1039
+ this.m_BaseVertices[h] = new c.Vector3();
1040
1040
  this.m_Vertices = new Array(e.vertexCount);
1041
1041
  for (let h = 0; h < e.vertexCount; h++)
1042
- this.m_Vertices[h] = new l.Vector3();
1042
+ this.m_Vertices[h] = new c.Vector3();
1043
1043
  this.m_Normals = new Array(e.vertexCount);
1044
1044
  for (let h = 0; h < e.vertexCount; h++)
1045
- this.m_Normals[h] = new l.Vector3();
1045
+ this.m_Normals[h] = new c.Vector3();
1046
1046
  if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1047
1047
  const h = new Uint32Array(e.triangles);
1048
- this.m_Geometry.setIndex(new l.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1048
+ this.m_Geometry.setIndex(new c.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1049
1049
  } else {
1050
1050
  const h = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(h);
1051
1051
  let o = 0;
1052
- a.set(e.frontTriangles, o), this.m_Geometry.addGroup(o, e.frontTriangles.length, 0), o += e.frontTriangles.length, a.set(e.backTriangles, o), this.m_Geometry.addGroup(o, e.backTriangles.length, 1), o += e.backTriangles.length, a.set(e.borderTriangles, o), this.m_Geometry.addGroup(o, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new l.BufferAttribute(a, 1));
1052
+ a.set(e.frontTriangles, o), this.m_Geometry.addGroup(o, e.frontTriangles.length, 0), o += e.frontTriangles.length, a.set(e.backTriangles, o), this.m_Geometry.addGroup(o, e.backTriangles.length, 1), o += e.backTriangles.length, a.set(e.borderTriangles, o), this.m_Geometry.addGroup(o, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(a, 1));
1053
1053
  }
1054
1054
  const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1055
1055
  for (let h = 0; h < e.texcoords.length; h++)
1056
1056
  n[h * 2] = e.texcoords[h].x, n[h * 2 + 1] = e.texcoords[h].y;
1057
1057
  this.m_Geometry.setAttribute(
1058
1058
  "position",
1059
- new l.BufferAttribute(s, 3)
1059
+ new c.BufferAttribute(s, 3)
1060
1060
  ), this.m_Geometry.setAttribute(
1061
1061
  "normal",
1062
- new l.BufferAttribute(i, 3)
1062
+ new c.BufferAttribute(i, 3)
1063
1063
  ), this.m_Geometry.setAttribute(
1064
1064
  "uv",
1065
- new l.BufferAttribute(n, 2)
1065
+ new c.BufferAttribute(n, 2)
1066
1066
  ), this.updateBaseVertices();
1067
1067
  }
1068
1068
  // ── UpdateBaseVertices ──────────────────────────────────────────────────
@@ -1096,15 +1096,15 @@ class Ot {
1096
1096
  * Ported from lines ~2185-2255.
1097
1097
  */
1098
1098
  updateMesh() {
1099
- const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, o = new l.Vector3(), u = new l.Vector3(), c = new l.Vector3();
1099
+ const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, o = new c.Vector3(), u = new c.Vector3(), l = new c.Vector3();
1100
1100
  for (let _ = 0; _ < a; _++)
1101
1101
  s[_].set(0, 0, 0);
1102
1102
  xt(this.m_Pattern.xSeams, t, n, h, !1), Mt(this.m_Pattern.zSeams, t, n, h, !1);
1103
1103
  for (let _ = 0; _ < h - 1; _++) {
1104
1104
  const g = _ + 1;
1105
1105
  for (let p = 0; p < n - 1; p++) {
1106
- const M = p + 1, T = _ * n + p, P = _ * n + M, C = g * n + p, k = g * n + M, I = t[T], U = t[P], L = t[C], z = t[k];
1107
- At(I, L, U, o), At(z, U, L, u), c.addVectors(o, u), s[T].add(c), s[P].add(c), s[C].add(c), s[k].add(c);
1106
+ const M = p + 1, T = _ * n + p, w = _ * n + M, C = g * n + p, k = g * n + M, I = t[T], U = t[w], E = t[C], z = t[k];
1107
+ At(I, E, U, o), At(z, U, E, u), l.addVectors(o, u), s[T].add(l), s[w].add(l), s[C].add(l), s[k].add(l);
1108
1108
  }
1109
1109
  }
1110
1110
  for (let _ = 0; _ < a; _++)
@@ -1132,13 +1132,13 @@ class Ot {
1132
1132
  f.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1133
1133
  }
1134
1134
  }
1135
- class le {
1135
+ class ce {
1136
1136
  constructor() {
1137
1137
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1138
1138
  }
1139
1139
  get() {
1140
1140
  let t;
1141
- return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new l.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1141
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new c.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1142
1142
  }
1143
1143
  recycle() {
1144
1144
  for (const t of this.m_UsedMeshs)
@@ -1151,7 +1151,7 @@ class le {
1151
1151
  this.m_Meshs.clear();
1152
1152
  }
1153
1153
  }
1154
- class ce {
1154
+ class ue {
1155
1155
  constructor(t) {
1156
1156
  this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1157
1157
  }
@@ -1160,7 +1160,7 @@ class ce {
1160
1160
  }
1161
1161
  get(t) {
1162
1162
  let e;
1163
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new me(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1163
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new _e(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1164
1164
  }
1165
1165
  recycle() {
1166
1166
  for (const t of this.m_UsedRenderers)
@@ -1173,23 +1173,23 @@ class ce {
1173
1173
  this.m_Renderers.clear();
1174
1174
  }
1175
1175
  getBounds() {
1176
- const t = new l.Box3();
1176
+ const t = new c.Box3();
1177
1177
  let e = !0;
1178
1178
  for (const s of this.m_UsedRenderers)
1179
1179
  e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1180
1180
  return t;
1181
1181
  }
1182
1182
  }
1183
- let ue = 1;
1184
- class me {
1183
+ let me = 1;
1184
+ class _e {
1185
1185
  constructor(t, e) {
1186
- this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ue++, this.m_Object3D = new l.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new l.Mesh(
1187
- new l.BufferGeometry(),
1188
- new l.MeshStandardMaterial()
1186
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = me++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1187
+ new c.BufferGeometry(),
1188
+ new c.MeshStandardMaterial()
1189
1189
  ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D);
1190
1190
  }
1191
1191
  get bounds() {
1192
- const t = new l.Box3();
1192
+ const t = new c.Box3();
1193
1193
  return this.m_Mesh.geometry && (this.m_Mesh.geometry.computeBoundingBox(), this.m_Mesh.geometry.boundingBox && (t.copy(this.m_Mesh.geometry.boundingBox), t.applyMatrix4(this.m_Mesh.matrixWorld))), t;
1194
1194
  }
1195
1195
  get id() {
@@ -1217,12 +1217,12 @@ class me {
1217
1217
  return this.m_Mesh;
1218
1218
  }
1219
1219
  setMaterials(t) {
1220
- this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new l.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1220
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new c.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1221
1221
  }
1222
1222
  setPropertyBlock(t, e) {
1223
1223
  this.m_PropertyBlocks.set(e, t);
1224
1224
  const s = this.getMaterial(e);
1225
- s && (this.isMapCapable(s) && (t.map instanceof l.Texture ? this.applyTextureProperty(
1225
+ s && (this.isMapCapable(s) && (t.map instanceof c.Texture ? this.applyTextureProperty(
1226
1226
  s,
1227
1227
  e,
1228
1228
  t.map,
@@ -1230,10 +1230,10 @@ class me {
1230
1230
  ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && s.color.copy(t.color));
1231
1231
  }
1232
1232
  reset(t) {
1233
- this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.setMaterials([]);
1233
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new c.BufferGeometry(), this.setMaterials([]);
1234
1234
  }
1235
1235
  clear() {
1236
- this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1236
+ this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new c.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1237
1237
  }
1238
1238
  destroy() {
1239
1239
  this.disposeManagedTextures(), this.disposeCurrentMaterials(), this.m_Mesh.geometry && this.m_Mesh.geometry.dispose(), this.m_Object3D.parent && this.m_Object3D.parent.remove(this.m_Object3D);
@@ -1248,7 +1248,7 @@ class me {
1248
1248
  return "map" in t;
1249
1249
  }
1250
1250
  isColorCapable(t) {
1251
- return "color" in t && t.color instanceof l.Color;
1251
+ return "color" in t && t.color instanceof c.Color;
1252
1252
  }
1253
1253
  getSTKey(t) {
1254
1254
  return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
@@ -1261,7 +1261,7 @@ class me {
1261
1261
  }
1262
1262
  this.clearManagedTexture(e);
1263
1263
  const a = s.clone();
1264
- a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = l.RepeatWrapping, a.wrapT = l.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1264
+ a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = c.RepeatWrapping, a.wrapT = c.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1265
1265
  source: s,
1266
1266
  texture: a,
1267
1267
  stKey: n
@@ -1285,7 +1285,7 @@ class me {
1285
1285
  e.dispose();
1286
1286
  }
1287
1287
  }
1288
- class _e {
1288
+ class de {
1289
1289
  constructor(t, e, s = !1) {
1290
1290
  this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Ot(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1291
1291
  }
@@ -1297,8 +1297,8 @@ class _e {
1297
1297
  this.m_Stack.push(t);
1298
1298
  }
1299
1299
  }
1300
- var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), de = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(de || {}), fe = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(fe || {});
1301
- class ge {
1300
+ var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), fe = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(fe || {}), ge = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(ge || {});
1301
+ class pe {
1302
1302
  constructor(t) {
1303
1303
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1304
1304
  }
@@ -1415,10 +1415,10 @@ class at {
1415
1415
  h = Math.min(h, u), a = Math.max(a, u);
1416
1416
  }
1417
1417
  for (let o = 0; o < n; o++) {
1418
- let u = i[o].time, c = i[o].value;
1419
- u = Q(h, a, u), c = H(c, e, s), i[o].time = u, i[o].value = c;
1418
+ let u = i[o].time, l = i[o].value;
1419
+ u = Q(h, a, u), l = H(l, e, s), i[o].time = u, i[o].value = l;
1420
1420
  }
1421
- return new ge(i);
1421
+ return new pe(i);
1422
1422
  }
1423
1423
  // ── Value-type clone ────────────────────────────────────────────────────
1424
1424
  clone() {
@@ -1496,37 +1496,37 @@ const D = class D {
1496
1496
  };
1497
1497
  D.kMinTwist = -1, D.kMaxTwist = 1, D.kMinBend = 0, D.kMaxBend = 1, D.kMinDuration = 0, D.kMaxDuration = 5;
1498
1498
  let Ut = D;
1499
- class pe extends Error {
1499
+ class xe extends Error {
1500
1500
  constructor() {
1501
1501
  super(
1502
1502
  "The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
1503
1503
  );
1504
1504
  }
1505
1505
  }
1506
- const W = class W extends l.Group {
1506
+ const W = class W extends c.Group {
1507
1507
  // ── Constructor ────────────────────────────────────────────────────────
1508
1508
  constructor(t) {
1509
1509
  super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new rt({
1510
- color: new l.Color(1, 0, 0),
1510
+ color: new c.Color(1, 0, 0),
1511
1511
  width: 2.1,
1512
1512
  height: 3.1,
1513
1513
  thickness: 0.04,
1514
1514
  stiffness: 0.5
1515
1515
  }), this.m_PagePaperSetup = new rt({
1516
- color: new l.Color(1, 1, 1),
1516
+ color: new c.Color(1, 1, 1),
1517
1517
  width: 2,
1518
1518
  height: 3,
1519
1519
  thickness: 0.02,
1520
1520
  stiffness: 0.2
1521
- }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = l.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1522
- color: t.coverPaperSetup.color ?? new l.Color(1, 0, 0),
1521
+ }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1522
+ color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1523
1523
  width: t.coverPaperSetup.width ?? 2.1,
1524
1524
  height: t.coverPaperSetup.height ?? 3.1,
1525
1525
  thickness: t.coverPaperSetup.thickness ?? 0.04,
1526
1526
  stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1527
1527
  material: t.coverPaperSetup.material ?? null
1528
1528
  })), t.pagePaperSetup && (this.m_PagePaperSetup = new rt({
1529
- color: t.pagePaperSetup.color ?? new l.Color(1, 1, 1),
1529
+ color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
1530
1530
  width: t.pagePaperSetup.width ?? 2,
1531
1531
  height: t.pagePaperSetup.height ?? 3,
1532
1532
  thickness: t.pagePaperSetup.thickness ?? 0.02,
@@ -1653,7 +1653,7 @@ const W = class W extends l.Group {
1653
1653
  return this.m_InitialOpenProgress;
1654
1654
  }
1655
1655
  set initialOpenProgress(t) {
1656
- this.m_InitialOpenProgress = l.MathUtils.clamp(t, 0, 1);
1656
+ this.m_InitialOpenProgress = c.MathUtils.clamp(t, 0, 1);
1657
1657
  }
1658
1658
  get isBuilt() {
1659
1659
  return this.m_IsBuilt;
@@ -1735,7 +1735,7 @@ const W = class W extends l.Group {
1735
1735
  */
1736
1736
  setOpenProgress(t) {
1737
1737
  this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1738
- const e = this.m_Papers.length, s = Math.round(l.MathUtils.lerp(0, e, t));
1738
+ const e = this.m_Papers.length, s = Math.round(c.MathUtils.lerp(0, e, t));
1739
1739
  for (let i = 0; i < e; i++) {
1740
1740
  const n = i >= s;
1741
1741
  this.m_Papers[i].restState(n);
@@ -1763,8 +1763,8 @@ const W = class W extends l.Group {
1763
1763
  const n = typeof i == "number" ? new at(i) : i;
1764
1764
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1765
1765
  for (let h = 0; h < s && this.canAutoTurn(t); h++) {
1766
- const a = h / (s - 1 || 1), o = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(o, a) : 0, c = e.getModeValue(), m = e.getTwistValue(o, a), f = e.getBendValue(o, a), d = e.getDurationValue(o, a);
1767
- this.m_AutoTurnQueue.push({ direction: t, mode: c, twist: m, bend: f, duration: d, delay: u });
1766
+ const a = h / (s - 1 || 1), o = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(o, a) : 0, l = e.getModeValue(), m = e.getTwistValue(o, a), f = e.getBendValue(o, a), d = e.getDurationValue(o, a);
1767
+ this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: m, bend: f, duration: d, delay: u });
1768
1768
  }
1769
1769
  return this.m_AutoTurnTimer = 0, this._frontPapersCache = null, !0;
1770
1770
  }
@@ -1861,9 +1861,9 @@ const W = class W extends l.Group {
1861
1861
  build() {
1862
1862
  var B;
1863
1863
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1864
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new le()), this.m_RendererFactory === null) {
1865
- const w = new l.Object3D();
1866
- w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new ce(this.m_Root);
1864
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new ce()), this.m_RendererFactory === null) {
1865
+ const P = new c.Object3D();
1866
+ P.name = "Root", this.add(P), this.m_Root = P, this.m_RendererFactory = new ue(this.m_Root);
1867
1867
  }
1868
1868
  this.m_Direction = this.m_Content.direction;
1869
1869
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
@@ -1873,11 +1873,11 @@ const W = class W extends l.Group {
1873
1873
  let i = this.m_Content.coverContents, n = this.m_Content.pageContents, h = this.m_InitialOpenProgress;
1874
1874
  this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), h = 1 - h), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1875
1875
  const a = this.m_CoverPaperCount + this.m_PagePaperCount, o = Math.floor(i.length / 4);
1876
- let u = 0, c = 0, m = 0;
1876
+ let u = 0, l = 0, m = 0;
1877
1877
  this.m_Papers = new Array(a);
1878
- for (let w = 0; w < a; w++) {
1879
- const v = this.m_HasCover && (w < o || w >= a - o), N = this.m_RendererFactory.get("Paper"), R = this.m_Papers[w] = new ae(v, w, this, N);
1880
- R.renderer.castShadows = this.m_CastShadows, w < Math.round(l.MathUtils.lerp(0, a, h)) && (R.transform.scale.set(-1, 1, 1), R.setTime(1)), v ? (R.setContentData(i[c++], i[c++], w > o), R.setMaterialData(e), R.setPaperSetup(this.m_CoverPaperSetup)) : (R.setContentData(n[u++], n[u++]), R.setMaterialData(s), R.setPaperSetup(this.m_PagePaperSetup)), m += R.thickness;
1878
+ for (let P = 0; P < a; P++) {
1879
+ const v = this.m_HasCover && (P < o || P >= a - o), N = this.m_RendererFactory.get("Paper"), R = this.m_Papers[P] = new oe(v, P, this, N);
1880
+ R.renderer.castShadows = this.m_CastShadows, P < Math.round(c.MathUtils.lerp(0, a, h)) && (R.transform.scale.set(-1, 1, 1), R.setTime(1)), v ? (R.setContentData(i[l++], i[l++], P > o), R.setMaterialData(e), R.setPaperSetup(this.m_CoverPaperSetup)) : (R.setContentData(n[u++], n[u++]), R.setMaterialData(s), R.setPaperSetup(this.m_PagePaperSetup)), m += R.thickness;
1881
1881
  }
1882
1882
  this.m_TotalThickness = m;
1883
1883
  const f = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
@@ -1891,10 +1891,10 @@ const W = class W extends l.Group {
1891
1891
  this.m_RendererFactory,
1892
1892
  this.m_MeshFactory
1893
1893
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1894
- const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes, C = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), L = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1895
- for (let w = 0; w < a; w++) {
1896
- const v = this.m_Papers[w];
1897
- w !== 0 && (v.prev = this.m_Papers[w - 1]), w !== a - 1 && (v.next = this.m_Papers[w + 1]), v.noHole = A && (w === z || w === E), v.isCover ? v.setMeshData(U.get(), null, L) : v.setMeshData(
1894
+ const T = this.m_ReduceOverdraw && n.length > 0, w = this.m_ReduceSubMeshes, C = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, w), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, w, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), E = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, L = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1895
+ for (let P = 0; P < a; P++) {
1896
+ const v = this.m_Papers[P];
1897
+ P !== 0 && (v.prev = this.m_Papers[P - 1]), P !== a - 1 && (v.next = this.m_Papers[P + 1]), v.noHole = A && (P === z || P === L), v.isCover ? v.setMeshData(U.get(), null, E) : v.setMeshData(
1898
1898
  C.get(),
1899
1899
  (k == null ? void 0 : k.get()) ?? null,
1900
1900
  I
@@ -1925,7 +1925,7 @@ const W = class W extends l.Group {
1925
1925
  i,
1926
1926
  s
1927
1927
  );
1928
- return new _e(
1928
+ return new de(
1929
1929
  this.m_MeshFactory,
1930
1930
  h,
1931
1931
  e && this.m_Bound.useSharedMeshDataForLowpoly
@@ -1979,12 +1979,12 @@ const W = class W extends l.Group {
1979
1979
  const n = this.m_Papers.length, h = Math.floor(t.length / 4);
1980
1980
  let a = 0, o = 0;
1981
1981
  for (let u = 0; u < n; u++) {
1982
- const c = this.m_Papers[u];
1983
- this.m_HasCover && (u < h || u >= n - h) ? c.setContentData(
1982
+ const l = this.m_Papers[u];
1983
+ this.m_HasCover && (u < h || u >= n - h) ? l.setContentData(
1984
1984
  t[o++],
1985
1985
  t[o++],
1986
1986
  u > h
1987
- ) : c.setContentData(e[a++], e[a++]), c.updateMaterials();
1987
+ ) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
1988
1988
  }
1989
1989
  return this.m_WasIdle = !1, !0;
1990
1990
  }
@@ -2016,12 +2016,13 @@ const W = class W extends l.Group {
2016
2016
  };
2017
2017
  W.s_Instances = /* @__PURE__ */ new Set(), W.s_InstancesArray = null;
2018
2018
  let Ct = W;
2019
- class xe {
2019
+ class Me {
2020
2020
  constructor() {
2021
- this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new l.Vector2(), this.thickness = 0;
2021
+ this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
2022
2022
  }
2023
2023
  }
2024
- class Fe {
2024
+ const Yt = Object.freeze(new c.Vector4(1, 1, 0, 0));
2025
+ class Oe {
2025
2026
  constructor() {
2026
2027
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
2027
2028
  }
@@ -2032,7 +2033,7 @@ class Fe {
2032
2033
  return this.m_IsActive;
2033
2034
  }
2034
2035
  get textureST() {
2035
- return new l.Vector4(1, 1, 0, 0);
2036
+ return Yt;
2036
2037
  }
2037
2038
  get isShareable() {
2038
2039
  return !0;
@@ -2056,15 +2057,15 @@ class Fe {
2056
2057
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
2057
2058
  }
2058
2059
  }
2059
- class Lt {
2060
+ class Et {
2060
2061
  constructor(t, e) {
2061
- this.m_Texture = t, this.m_TextureST = e ?? new l.Vector4(1, 1, 0, 0);
2062
+ this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2062
2063
  }
2063
2064
  get texture() {
2064
2065
  return this.m_Texture;
2065
2066
  }
2066
2067
  get textureST() {
2067
- return this.m_Texture ? this.m_TextureST : new l.Vector4(1, 1, 0, 0);
2068
+ return this.m_Texture ? this.m_TextureST : Yt;
2068
2069
  }
2069
2070
  isPointOverUI(t) {
2070
2071
  return !1;
@@ -2074,7 +2075,7 @@ class Lt {
2074
2075
  setActive(t) {
2075
2076
  }
2076
2077
  }
2077
- class Oe {
2078
+ class Ze {
2078
2079
  constructor() {
2079
2080
  this.m_Direction = j.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null, this._cachedCovers = null, this._cachedPages = null;
2080
2081
  }
@@ -2128,12 +2129,12 @@ class Oe {
2128
2129
  }
2129
2130
  getContent(t) {
2130
2131
  if (t !== null) {
2131
- if (t instanceof l.Texture)
2132
- return new Lt(t);
2132
+ if (t instanceof c.Texture)
2133
+ return new Et(t);
2133
2134
  if (typeof t.init == "function")
2134
2135
  return t;
2135
2136
  }
2136
- return new Lt(null);
2137
+ return new Et(null);
2137
2138
  }
2138
2139
  init(t) {
2139
2140
  this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
@@ -2181,9 +2182,9 @@ class Oe {
2181
2182
  return !this.isCoverPaperSideIndex(t);
2182
2183
  }
2183
2184
  }
2184
- class Ze {
2185
+ class Ue {
2185
2186
  constructor(t, e) {
2186
- this.enabled = !0, this.m_Raycaster = new l.Raycaster(), this.m_Mouse = new l.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2187
+ this.enabled = !0, this.m_Raycaster = new c.Raycaster(), this.m_Mouse = new c.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2187
2188
  var n;
2188
2189
  if (!this.enabled || s.button !== 0) return;
2189
2190
  this.m_IsPointerDown = !0;
@@ -2208,9 +2209,9 @@ class Ze {
2208
2209
  return this.m_Mouse.x = (t.clientX - e.left) / e.width * 2 - 1, this.m_Mouse.y = -((t.clientY - e.top) / e.height) * 2 + 1, this.m_Raycaster.setFromCamera(this.m_Mouse, this.m_Camera), this.m_Raycaster.ray;
2209
2210
  }
2210
2211
  }
2211
- class Me {
2212
- }
2213
2212
  class ye {
2213
+ }
2214
+ class Ce {
2214
2215
  constructor(t, e) {
2215
2216
  this.bindingType = "", this.m_Book = t, this.m_Root = e;
2216
2217
  }
@@ -2218,9 +2219,9 @@ class ye {
2218
2219
  dispose() {
2219
2220
  }
2220
2221
  }
2221
- function Et(r, t, e, s) {
2222
+ function Lt(r, t, e, s) {
2222
2223
  const i = 1 - s;
2223
- return new l.Vector3(
2224
+ return new c.Vector3(
2224
2225
  i * i * r.x + 2 * i * s * t.x + s * s * e.x,
2225
2226
  i * i * r.y + 2 * i * s * t.y + s * s * e.y,
2226
2227
  i * i * r.z + 2 * i * s * t.z + s * s * e.z
@@ -2229,25 +2230,25 @@ function Et(r, t, e, s) {
2229
2230
  function Nt(r, t) {
2230
2231
  return r++, r === t ? 0 : r;
2231
2232
  }
2232
- function Ce(r, t) {
2233
+ function Pe(r, t) {
2233
2234
  return r === 0 ? t - 1 : r - 1;
2234
2235
  }
2235
- const we = 0.01, Pe = 0.1, Te = 0.04, Se = 0.4, ve = 2, ke = 10, Be = 0, Re = 5;
2236
- function be(r, t) {
2236
+ const we = 0.01, Te = 0.1, Se = 0.04, ve = 0.4, ke = 2, Be = 10, Re = 0, be = 5;
2237
+ function De(r, t) {
2237
2238
  const e = r.clone().normalize();
2238
- if (e.lengthSq() === 0) return new l.Quaternion();
2239
- let s = new l.Vector3().crossVectors(t, e);
2239
+ if (e.lengthSq() === 0) return new c.Quaternion();
2240
+ let s = new c.Vector3().crossVectors(t, e);
2240
2241
  if (s.lengthSq() === 0) {
2241
- const h = Math.abs(e.y) < 0.999 ? new l.Vector3(0, 1, 0) : new l.Vector3(1, 0, 0);
2242
- s = new l.Vector3().crossVectors(h, e);
2242
+ const h = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
2243
+ s = new c.Vector3().crossVectors(h, e);
2243
2244
  }
2244
2245
  s.normalize();
2245
- const i = new l.Vector3().crossVectors(e, s).normalize(), n = new l.Matrix4().makeBasis(s, i, e);
2246
- return new l.Quaternion().setFromRotationMatrix(n);
2246
+ const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
2247
+ return new c.Quaternion().setFromRotationMatrix(n);
2247
2248
  }
2248
- class De {
2249
+ class Ie {
2249
2250
  constructor() {
2250
- this._material = null, this._color = new l.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2251
+ this._material = null, this._color = new c.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2251
2252
  }
2252
2253
  get material() {
2253
2254
  return this._material;
@@ -2265,7 +2266,7 @@ class De {
2265
2266
  return this._thickness;
2266
2267
  }
2267
2268
  set thickness(t) {
2268
- this._thickness = H(t, we, Pe);
2269
+ this._thickness = H(t, we, Te);
2269
2270
  }
2270
2271
  get margin() {
2271
2272
  return this._margin;
@@ -2277,48 +2278,48 @@ class De {
2277
2278
  return this._crown;
2278
2279
  }
2279
2280
  set crown(t) {
2280
- this._crown = H(t, Te, Se);
2281
+ this._crown = H(t, Se, ve);
2281
2282
  }
2282
2283
  get count() {
2283
2284
  return this._count;
2284
2285
  }
2285
2286
  set count(t) {
2286
- this._count = H(t, ve, ke);
2287
+ this._count = H(t, ke, Be);
2287
2288
  }
2288
2289
  get quality() {
2289
2290
  return this._quality;
2290
2291
  }
2291
2292
  set quality(t) {
2292
- this._quality = H(t, Be, Re);
2293
+ this._quality = H(t, Re, be);
2293
2294
  }
2294
2295
  }
2295
- class Ie extends ye {
2296
+ class Ve extends Ce {
2296
2297
  // ── Constructor ────────────────────────────────────────────────────────
2297
2298
  constructor(t, e, s, i, n) {
2298
2299
  if (super(s, i), this.bindingType = "staple", this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
2299
- throw new pe();
2300
- const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, o = new l.BufferGeometry();
2300
+ throw new xe();
2301
+ const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, o = new c.BufferGeometry();
2301
2302
  this.updateStapleMesh(e, o);
2302
- const u = n ?? new l.MeshStandardMaterial({
2303
+ const u = n ?? new c.MeshStandardMaterial({
2303
2304
  color: e.color,
2304
2305
  metalness: 0.9,
2305
2306
  roughness: 0.3
2306
2307
  });
2307
- this.stapleMesh = new l.Mesh(o, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2308
+ this.stapleMesh = new c.Mesh(o, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2308
2309
  0,
2309
2310
  0,
2310
2311
  this.m_StapleMargin + a.margin + h.margin
2311
2312
  );
2312
- let c = h.thickness;
2313
- c = Math.max(this.m_BindingRadius, c);
2313
+ let l = h.thickness;
2314
+ l = Math.max(this.m_BindingRadius, l);
2314
2315
  for (const m of this.m_Book.papers) {
2315
2316
  const f = m.size.clone();
2316
- f.x -= this.m_BindingRadius, m.sizeXOffset = this.m_BindingRadius, m.size = f, m.setMinTurningRadius(c), m.updateTurningRadius(), this.updatePaperPosition(m);
2317
+ f.x -= this.m_BindingRadius, m.sizeXOffset = this.m_BindingRadius, m.size = f, m.setMinTurningRadius(l), m.updateTurningRadius(), this.updatePaperPosition(m);
2317
2318
  }
2318
2319
  this.updateRootPosition();
2319
2320
  }
2320
2321
  get binderRenderer() {
2321
- return this._binderRendererAdapter || (this._binderRendererAdapter = new Ve(this.stapleMesh)), this._binderRendererAdapter;
2322
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new ze(this.stapleMesh)), this._binderRendererAdapter;
2322
2323
  }
2323
2324
  // ── updateStapleMesh ──────────────────────────────────────────────────
2324
2325
  updateStapleMesh(t, e) {
@@ -2334,72 +2335,72 @@ class Ie extends ye {
2334
2335
  let a = t.count, o = (h - s * a) / (a - 1);
2335
2336
  for (o = Math.max(o, 0); o < this.m_StapleThickness * 2 && a > 2; )
2336
2337
  a--, o = (h - s * a) / (a - 1), o = Math.max(o, 0);
2337
- const u = t.quality / 5, c = Math.floor(F(4, 20, u)), m = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), d = this.m_StapleThickness / 2, _ = d * 2.5, g = 0.9, p = d * 1;
2338
+ const u = t.quality / 5, l = Math.floor(F(4, 20, u)), m = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), d = this.m_StapleThickness / 2, _ = d * 2.5, g = 0.9, p = d * 1;
2338
2339
  let M = s / 2 * g;
2339
2340
  M = Math.max(M, p * 2);
2340
2341
  let T = 0;
2341
2342
  T += this.m_Book.totalThickness / 2, T += d;
2342
- const P = -(this.m_Book.papers[0].thickness / 2 + d), C = [];
2343
+ const w = -(this.m_Book.papers[0].thickness / 2 + d), C = [];
2343
2344
  {
2344
2345
  for (let V = 0; V < m; V++) {
2345
- const G = V / (m - 1), K = F(-90, -180, G) * J, y = new l.Vector3(
2346
+ const G = V / (m - 1), K = F(-90, -180, G) * J, y = new c.Vector3(
2346
2347
  p * Math.sin(K),
2347
2348
  0,
2348
2349
  p * Math.cos(K)
2349
2350
  );
2350
- y.x += p, y.z += p, y.x += P, C.push(y);
2351
+ y.x += p, y.z += p, y.x += w, C.push(y);
2351
2352
  }
2352
- const x = new l.Vector3(T, 0, 0), Z = new l.Vector3(T + _ * 0.75, 0, 0), S = new l.Vector3(T - d * 0.5, 0, M);
2353
+ const x = new c.Vector3(T, 0, 0), Z = new c.Vector3(T + _ * 0.75, 0, 0), S = new c.Vector3(T - d * 0.5, 0, M);
2353
2354
  for (let V = 0; V < f; V++) {
2354
- const G = V / (f - 1), Y = Et(x, Z, S, G);
2355
- Y.x += P, C.push(Y);
2355
+ const G = V / (f - 1), Y = Lt(x, Z, S, G);
2356
+ Y.x += w, C.push(Y);
2356
2357
  }
2357
2358
  C.reverse();
2358
2359
  }
2359
- const k = new Array(c);
2360
- for (let x = 0; x < c; x++) {
2361
- const S = (90 - x * (360 / c)) * J;
2362
- k[x] = new l.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
2360
+ const k = new Array(l);
2361
+ for (let x = 0; x < l; x++) {
2362
+ const S = (90 - x * (360 / l)) * J;
2363
+ k[x] = new c.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
2363
2364
  }
2364
- const I = C.length, U = I * c, L = new Array(U * 2), z = new Array(U * 2), E = new Array(
2365
- (U * 2 - 1) * c * 2 * 3
2365
+ const I = C.length, U = I * l, E = new Array(U * 2), z = new Array(U * 2), L = new Array(
2366
+ (U * 2 - 1) * l * 2 * 3
2366
2367
  );
2367
2368
  for (let x = 0; x < U * 2; x++)
2368
- L[x] = new l.Vector3(), z[x] = new l.Vector3();
2369
+ E[x] = new c.Vector3(), z[x] = new c.Vector3();
2369
2370
  let A = 0;
2370
2371
  for (let x = 0; x < I; x++) {
2371
- const Z = C[Ce(x, I)], S = C[x], V = C[Nt(x, I)];
2372
+ const Z = C[Pe(x, I)], S = C[x], V = C[Nt(x, I)];
2372
2373
  let G;
2373
2374
  if (x === 0)
2374
- G = new l.Vector3(1, 0, -2).normalize();
2375
+ G = new c.Vector3(1, 0, -2).normalize();
2375
2376
  else if (x === I - 1)
2376
- G = new l.Vector3(0, 0, 1);
2377
+ G = new c.Vector3(0, 0, 1);
2377
2378
  else {
2378
2379
  const it = S.clone().sub(Z).normalize(), nt = V.clone().sub(S).normalize();
2379
2380
  G = it.add(nt).multiplyScalar(0.5);
2380
2381
  }
2381
- const Y = new l.Vector3(0, 1, 0), K = be(G, Y), y = A;
2382
+ const Y = new c.Vector3(0, 1, 0), K = De(G, Y), y = A;
2382
2383
  let b = Q(0, f / 4, x);
2383
2384
  b = F(0.1, 1, b), b = Math.sqrt(b);
2384
- for (let it = 0; it < c; it++) {
2385
+ for (let it = 0; it < l; it++) {
2385
2386
  const nt = k[it].clone().applyQuaternion(K).multiplyScalar(b), ct = S.clone().add(nt.clone().multiplyScalar(d));
2386
- L[A] = ct, z[A] = nt.clone();
2387
+ E[A] = ct, z[A] = nt.clone();
2387
2388
  const ot = S.clone().add(nt.clone().multiplyScalar(d));
2388
2389
  ot.z = s - ot.z;
2389
- const te = y + c - it - 1, St = U * 2 - te - 1;
2390
- L[St] = ot, z[St] = nt.clone(), A++;
2390
+ const ee = y + l - it - 1, St = U * 2 - ee - 1;
2391
+ E[St] = ot, z[St] = nt.clone(), A++;
2391
2392
  }
2392
2393
  }
2393
2394
  let B = 0;
2394
- const w = C.length * 2;
2395
- for (let x = 0; x < w - 1; x++) {
2396
- const Z = x * c, S = (x + 1) * c;
2397
- for (let V = 0; V < c; V++) {
2398
- const G = Nt(V, c), Y = Z + V, K = Z + G, y = S + G, b = S + V;
2399
- E[B++] = Y, E[B++] = b, E[B++] = K, E[B++] = K, E[B++] = b, E[B++] = y;
2395
+ const P = C.length * 2;
2396
+ for (let x = 0; x < P - 1; x++) {
2397
+ const Z = x * l, S = (x + 1) * l;
2398
+ for (let V = 0; V < l; V++) {
2399
+ const G = Nt(V, l), Y = Z + V, K = Z + G, y = S + G, b = S + V;
2400
+ L[B++] = Y, L[B++] = b, L[B++] = K, L[B++] = K, L[B++] = b, L[B++] = y;
2400
2401
  }
2401
2402
  }
2402
- const v = [...L], N = [...z], R = [...E], $ = L.map((x) => x.clone()), tt = [...E];
2403
+ const v = [...E], N = [...z], R = [...L], $ = E.map((x) => x.clone()), tt = [...L];
2403
2404
  for (let x = 0; x < a - 1; x++) {
2404
2405
  const Z = $.length;
2405
2406
  for (let S = 0; S < tt.length; S++)
@@ -2413,51 +2414,51 @@ class Ie extends ye {
2413
2414
  q[x * 3] = v[x].x, q[x * 3 + 1] = v[x].y, q[x * 3 + 2] = v[x].z, O[x * 3] = N[x].x, O[x * 3 + 1] = N[x].y, O[x * 3 + 2] = N[x].z;
2414
2415
  e.setAttribute(
2415
2416
  "position",
2416
- new l.BufferAttribute(q, 3)
2417
+ new c.BufferAttribute(q, 3)
2417
2418
  ), e.setAttribute(
2418
2419
  "normal",
2419
- new l.BufferAttribute(O, 3)
2420
+ new c.BufferAttribute(O, 3)
2420
2421
  ), e.setIndex(R);
2421
2422
  }
2422
2423
  // ── createPaperPattern ────────────────────────────────────────────────
2423
2424
  createPaperPattern(t, e, s, i, n, h) {
2424
- const a = new xe();
2425
+ const a = new Me();
2425
2426
  a.size = e, a.thickness = s;
2426
2427
  const o = this.m_BindingRadius;
2427
2428
  a.baseXOffset = -o;
2428
2429
  const u = this.m_Quality + 1;
2429
2430
  this.m_BindingVertexCount = u;
2430
- const c = t / 5, m = Math.min(e.x, e.y) / 60, f = Math.floor(
2431
- F(0, (e.x - o) / m, c)
2432
- ), d = Math.floor(F(0, e.y / m, c));
2431
+ const l = t / 5, m = Math.min(e.x, e.y) / 60, f = Math.floor(
2432
+ F(0, (e.x - o) / m, l)
2433
+ ), d = Math.floor(F(0, e.y / m, l));
2433
2434
  let _ = 2 + f + 1 + u, g = 2 + d;
2434
2435
  const p = new ht(0);
2435
2436
  let M = p;
2436
2437
  const T = o / u;
2437
- let P = 0;
2438
+ let w = 0;
2438
2439
  for (let y = 1; y < u + 1; y++)
2439
- M = M.createNext(P), P += T;
2440
+ M = M.createNext(w), w += T;
2440
2441
  const C = (e.x - o) / (f + 1);
2441
2442
  for (let y = u + 1; y < _; y++)
2442
- M = M.createNext(P), P += C;
2443
+ M = M.createNext(w), w += C;
2443
2444
  const k = new ht(0);
2444
2445
  let I = k;
2445
2446
  const U = e.y / (g - 1);
2446
- let L = 0;
2447
+ let E = 0;
2447
2448
  for (let y = 0; y < g - 1; y++)
2448
- L += U, I = I.createNext(L);
2449
- const z = [], E = [], A = i.clone();
2449
+ E += U, I = I.createNext(E);
2450
+ const z = [], L = [], A = i.clone();
2450
2451
  if (n) {
2451
2452
  let y = 0;
2452
2453
  this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
2453
2454
  const b = Math.max(0.01, s);
2454
2455
  A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, A.down = b / e.y, A.up = b / e.y;
2455
2456
  }
2456
- const B = new oe(a, A, !1);
2457
- B.insert(p, k, z, E), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(E, a.zSeams);
2458
- const w = this.m_BindingVertexCount + 2, v = new Array(w);
2457
+ const B = new le(a, A, !1);
2458
+ B.insert(p, k, z, L), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(L, a.zSeams);
2459
+ const P = this.m_BindingVertexCount + 2, v = new Array(P);
2459
2460
  a.xNoneSeamIndexes = v, M = p;
2460
- for (let y = 0; y < w; y++) {
2461
+ for (let y = 0; y < P; y++) {
2461
2462
  v[y] = M.index;
2462
2463
  do
2463
2464
  M = M.next;
@@ -2511,16 +2512,16 @@ class Ie extends ye {
2511
2512
  const e = this.m_Book.papers, s = e.length;
2512
2513
  let i = 0;
2513
2514
  const n = e.length / 2 - 1, h = e.length / 2;
2514
- for (let P = 0; P < s; P++) {
2515
- const C = e[P];
2515
+ for (let w = 0; w < s; w++) {
2516
+ const C = e[w];
2516
2517
  C.updateTime();
2517
2518
  const k = C.zTime, I = C.thickness;
2518
- i += k * I, P === n && (i += k * this.m_BindingMidSpace / 2), P === h && (i += k * this.m_BindingMidSpace / 2);
2519
+ i += k * I, w === n && (i += k * this.m_BindingMidSpace / 2), w === h && (i += k * this.m_BindingMidSpace / 2);
2519
2520
  }
2520
2521
  let a = this.getStackHeight(t.index) - t.thickness / 2;
2521
2522
  const o = this.getStackZ(a), u = 180 + o;
2522
- let c = t.isFlipped ? 1 : 0, m = F(o, u, c);
2523
- const f = m * J, d = new l.Vector3(
2523
+ let l = t.isFlipped ? 1 : 0, m = F(o, u, l);
2524
+ const f = m * J, d = new c.Vector3(
2524
2525
  Math.cos(f) * this.m_BindingRadius,
2525
2526
  Math.sin(f) * this.m_BindingRadius,
2526
2527
  0
@@ -2528,24 +2529,24 @@ class Ie extends ye {
2528
2529
  d.z = t.margin;
2529
2530
  let _ = e[Math.floor(s / 2)].size.x, g = this.m_BindingMidSpace, p = Math.sqrt(_ * _ - g * g), M = Math.asin(p / _) * et - 90;
2530
2531
  if (t.index < Math.floor(s / 2)) {
2531
- let P = 0;
2532
+ let w = 0;
2532
2533
  if (this.m_Book.alignToGround) {
2533
2534
  _ = e[0].size.x;
2534
2535
  const C = this.m_StackHeight / 2;
2535
- g = H(i, 0, C) - C, p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2536
+ g = H(i, 0, C) - C, p = Math.sqrt(_ * _ - g * g), w = (Math.asin(p / _) * et - 90) * 2;
2536
2537
  }
2537
- m = F(M, -P, c);
2538
+ m = F(M, -w, l);
2538
2539
  } else {
2539
- let P = 0;
2540
+ let w = 0;
2540
2541
  if (this.m_Book.alignToGround) {
2541
2542
  _ = e[0].size.x;
2542
2543
  const C = this.m_StackHeight / 2;
2543
- g = C - H(i, C, C * 2), p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2544
+ g = C - H(i, C, C * 2), p = Math.sqrt(_ * _ - g * g), w = (Math.asin(p / _) * et - 90) * 2;
2544
2545
  }
2545
- m = F(P, -M, c);
2546
+ m = F(w, -M, l);
2546
2547
  }
2547
2548
  t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2548
- new l.Euler(0, 0, m * J)
2549
+ new c.Euler(0, 0, m * J)
2549
2550
  );
2550
2551
  }
2551
2552
  // ── getPX (private helper) ───────────────────────────────────────────
@@ -2560,9 +2561,9 @@ class Ie extends ye {
2560
2561
  updatePaperPositionWithTh(t, e) {
2561
2562
  const s = this.m_Book.papers, i = s.length, n = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(n + e), a = 180 + this.getStackZ(n + e - this.m_StackHeight);
2562
2563
  let o = t.zTime, u = F(h, a, o);
2563
- const c = u * J, m = new l.Vector3(
2564
- Math.cos(c) * this.m_BindingRadius,
2565
- Math.sin(c) * this.m_BindingRadius,
2564
+ const l = u * J, m = new c.Vector3(
2565
+ Math.cos(l) * this.m_BindingRadius,
2566
+ Math.sin(l) * this.m_BindingRadius,
2566
2567
  0
2567
2568
  );
2568
2569
  m.z = t.margin;
@@ -2585,7 +2586,7 @@ class Ie extends ye {
2585
2586
  u = F(M, -g, o);
2586
2587
  }
2587
2588
  t.transform.position.copy(m), t.transform.quaternion.setFromEuler(
2588
- new l.Euler(0, 0, u * J)
2589
+ new c.Euler(0, 0, u * J)
2589
2590
  );
2590
2591
  }
2591
2592
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2628,23 +2629,23 @@ class Ie extends ye {
2628
2629
  // ── updateBindingVertices ─────────────────────────────────────────────
2629
2630
  updateBindingVertices() {
2630
2631
  const t = this.m_Book.papers;
2631
- let e = new l.Vector3(0, 0, 0), s = new l.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2632
+ let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2632
2633
  const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), o = t.length;
2633
2634
  for (let u = 0; u < o; u++) {
2634
- const c = t[u], m = c.transform, f = c.meshData.pattern, d = c.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = c.thickness, C = f.xNoneSeamIndexes, k = m.position.clone();
2635
+ const l = t[u], m = l.transform, f = l.meshData.pattern, d = l.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, w = l.thickness, C = f.xNoneSeamIndexes, k = m.position.clone();
2635
2636
  let I = u, U = n;
2636
2637
  u >= Math.floor(o / 2) && (I = o - u - 1, U *= -1);
2637
- const L = (h + P) * 0.5 + P * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), E = I / (o / 2);
2638
- i = this.m_BindingRadius * F(0.45, 0.65, 1 - E);
2638
+ const E = (h + w) * 0.5 + w * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), L = I / (o / 2);
2639
+ i = this.m_BindingRadius * F(0.45, 0.65, 1 - L);
2639
2640
  for (let A = 0; A < M; A++) {
2640
- const B = g[A], w = new l.Vector3(0, 0, k.z + B), v = k.clone();
2641
+ const B = g[A], P = new c.Vector3(0, 0, k.z + B), v = k.clone();
2641
2642
  v.z += B;
2642
- const N = c.getDirection(B).multiplyScalar(i).add(v.clone());
2643
+ const N = l.getDirection(B).multiplyScalar(i).add(v.clone());
2643
2644
  if (u === 0 && A === 0) {
2644
2645
  const O = t[o - 1], Z = O.transform.position.clone().clone();
2645
2646
  Z.z += B;
2646
2647
  const S = O.getDirection(B).multiplyScalar(i).add(Z);
2647
- s = N.clone().sub(S).normalize(), e = new l.Vector3(
2648
+ s = N.clone().sub(S).normalize(), e = new c.Vector3(
2648
2649
  -s.y,
2649
2650
  s.x,
2650
2651
  0
@@ -2652,14 +2653,14 @@ class Ie extends ye {
2652
2653
  const V = Math.atan2(e.y, e.x) * et;
2653
2654
  this.stapleMesh.rotation.set(0, 0, V * J);
2654
2655
  }
2655
- I > 0 && w.add(e.clone().multiplyScalar(L));
2656
+ I > 0 && P.add(e.clone().multiplyScalar(E));
2656
2657
  const R = A * p;
2657
- d[R] = w.clone().applyMatrix4(z), w.add(s.clone().multiplyScalar(U));
2658
- const $ = w.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
2658
+ d[R] = P.clone().applyMatrix4(z), P.add(s.clone().multiplyScalar(U));
2659
+ const $ = P.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
2659
2660
  d[R + C[1]] = $;
2660
2661
  for (let O = 2; O < T; O++) {
2661
2662
  const x = Q(1, T, O);
2662
- d[R + C[O]] = Et(
2663
+ d[R + C[O]] = Lt(
2663
2664
  $,
2664
2665
  tt,
2665
2666
  q,
@@ -2693,10 +2694,10 @@ class Ie extends ye {
2693
2694
  }
2694
2695
  /** Releases GPU resources held by the staple mesh. */
2695
2696
  dispose() {
2696
- this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof l.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2697
+ this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof c.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2697
2698
  }
2698
2699
  }
2699
- class Ve {
2700
+ class ze {
2700
2701
  constructor(t) {
2701
2702
  this.mesh = t;
2702
2703
  }
@@ -2710,7 +2711,7 @@ class Ve {
2710
2711
  this.mesh.castShadow = t;
2711
2712
  }
2712
2713
  get bounds() {
2713
- const t = new l.Box3();
2714
+ const t = new c.Box3();
2714
2715
  return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
2715
2716
  }
2716
2717
  get transform() {
@@ -2720,12 +2721,12 @@ class Ve {
2720
2721
  return this.mesh;
2721
2722
  }
2722
2723
  }
2723
- class Ue extends Me {
2724
+ class Ee extends ye {
2724
2725
  constructor() {
2725
- super(...arguments), this.quality = 3, this.stapleSetup = new De();
2726
+ super(...arguments), this.quality = 3, this.stapleSetup = new Ie();
2726
2727
  }
2727
2728
  createBound(t, e, s, i) {
2728
- return new Ie(
2729
+ return new Ve(
2729
2730
  this.quality,
2730
2731
  this.stapleSetup,
2731
2732
  t,
@@ -2733,7 +2734,7 @@ class Ue extends Me {
2733
2734
  );
2734
2735
  }
2735
2736
  }
2736
- class Yt {
2737
+ class Kt {
2737
2738
  constructor(t) {
2738
2739
  this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0;
2739
2740
  }
@@ -2798,28 +2799,28 @@ class Yt {
2798
2799
  t.restore();
2799
2800
  }
2800
2801
  }
2801
- function ze(r) {
2802
- return r.map instanceof l.Texture;
2802
+ function Ae(r) {
2803
+ return r.map instanceof c.Texture;
2803
2804
  }
2804
- function Kt(r, t) {
2805
+ function Jt(r, t) {
2805
2806
  r.traverse((e) => {
2806
2807
  if (!e.isMesh) return;
2807
2808
  const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2808
2809
  for (const n of i)
2809
- ze(n) && n.map.image === t && (n.map.needsUpdate = !0);
2810
+ Ae(n) && n.map.image === t && (n.map.needsUpdate = !0);
2810
2811
  });
2811
2812
  }
2812
- function Jt(r, t) {
2813
+ function te(r, t) {
2813
2814
  t.x !== void 0 && (r.x = t.x), t.y !== void 0 && (r.y = t.y), t.width !== void 0 && (r.width = t.width), t.text !== void 0 && (r.text = t.text), t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && (r.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (r.fontStyle = t.fontStyle), t.color !== void 0 && (r.color = t.color), t.lineHeight !== void 0 && (r.lineHeight = t.lineHeight), t.textAlign !== void 0 && (r.textAlign = t.textAlign), t.opacity !== void 0 && (r.opacity = t.opacity), t.shadowColor !== void 0 && (r.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (r.shadowBlur = t.shadowBlur);
2814
2815
  }
2815
2816
  class Le {
2816
2817
  constructor(t) {
2817
- this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0), this._dirty = !0;
2818
+ this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0), this._dirty = !0;
2818
2819
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
2819
2820
  this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
2820
2821
  const i = this.canvas.getContext("2d");
2821
2822
  if (!i) throw new Error("TextOverlayContent: could not get 2D context");
2822
- this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace;
2823
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace;
2823
2824
  }
2824
2825
  get texture() {
2825
2826
  return this._texture;
@@ -2840,7 +2841,7 @@ class Le {
2840
2841
  }
2841
2842
  // ── Text API ─────────────────────────────────────────────────────────────
2842
2843
  addText(t) {
2843
- const e = new Yt(t);
2844
+ const e = new Kt(t);
2844
2845
  return this.texts.push(e), this._dirty = !0, e;
2845
2846
  }
2846
2847
  removeText(t) {
@@ -2850,7 +2851,7 @@ class Le {
2850
2851
  /** Update a text block by index. Only provided fields are changed. */
2851
2852
  updateText(t, e) {
2852
2853
  const s = this.texts[t];
2853
- s && (Jt(s, e), this._dirty = !0);
2854
+ s && (te(s, e), this._dirty = !0);
2854
2855
  }
2855
2856
  // ── Per-frame update ─────────────────────────────────────────────────────
2856
2857
  /**
@@ -2874,7 +2875,7 @@ class Le {
2874
2875
  * source image is this overlay's canvas.
2875
2876
  */
2876
2877
  syncMaterials(t) {
2877
- Kt(t, this.canvas);
2878
+ Jt(t, this.canvas);
2878
2879
  }
2879
2880
  // ── IPageContent ─────────────────────────────────────────────────────────
2880
2881
  isPointOverUI(t) {
@@ -2890,7 +2891,7 @@ class Le {
2890
2891
  }
2891
2892
  class Xt {
2892
2893
  constructor(t, e) {
2893
- this._spread = t, this._textureST = e === "left" ? new l.Vector4(0.5, 1, 0, 0) : new l.Vector4(0.5, 1, 0.5, 0);
2894
+ this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
2894
2895
  }
2895
2896
  get texture() {
2896
2897
  return this._spread.texture;
@@ -2906,18 +2907,18 @@ class Xt {
2906
2907
  setActive(t) {
2907
2908
  }
2908
2909
  }
2909
- function Ee(r) {
2910
+ function Ne(r) {
2910
2911
  const t = [];
2911
2912
  for (let e = 1; e + 1 < r; e += 2)
2912
2913
  t.push(e);
2913
2914
  return t;
2914
2915
  }
2915
- class Ne {
2916
+ class Xe {
2916
2917
  constructor(t) {
2917
- this.texts = [], this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2918
+ this.texts = [], this._dirty = !0, this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2918
2919
  const e = this.canvas.getContext("2d");
2919
2920
  if (!e) throw new Error("SpreadContent: could not get 2D context");
2920
- this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace, this.left = new Xt(this, "left"), this.right = new Xt(this, "right");
2921
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new Xt(this, "left"), this.right = new Xt(this, "right");
2921
2922
  }
2922
2923
  get texture() {
2923
2924
  return this._texture;
@@ -2927,21 +2928,25 @@ class Ne {
2927
2928
  return this._source;
2928
2929
  }
2929
2930
  set source(t) {
2930
- this._source = t;
2931
+ this._source = t, this._dirty = !0;
2932
+ }
2933
+ /** Mark the spread as needing a re-composite on the next update(). */
2934
+ markDirty() {
2935
+ this._dirty = !0;
2931
2936
  }
2932
2937
  // ── Text API ─────────────────────────────────────────────────────────────
2933
2938
  addText(t) {
2934
- const e = new Yt(t);
2935
- return this.texts.push(e), e;
2939
+ const e = new Kt(t);
2940
+ return this.texts.push(e), this._dirty = !0, e;
2936
2941
  }
2937
2942
  removeText(t) {
2938
2943
  const e = this.texts.indexOf(t);
2939
- e !== -1 && this.texts.splice(e, 1);
2944
+ e !== -1 && (this.texts.splice(e, 1), this._dirty = !0);
2940
2945
  }
2941
2946
  /** Update a text block by index. Only provided fields are changed. */
2942
2947
  updateText(t, e) {
2943
2948
  const s = this.texts[t];
2944
- s && Jt(s, e);
2949
+ s && (te(s, e), this._dirty = !0);
2945
2950
  }
2946
2951
  // ── Per-frame update ─────────────────────────────────────────────────────
2947
2952
  /**
@@ -2952,6 +2957,8 @@ class Ne {
2952
2957
  * (needed because three-book clones material textures).
2953
2958
  */
2954
2959
  update(t) {
2960
+ if (!this._dirty && !this._source) return;
2961
+ this._dirty = !1;
2955
2962
  const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2956
2963
  e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2957
2964
  for (const h of this.texts) h.draw(e);
@@ -2962,7 +2969,7 @@ class Ne {
2962
2969
  * source image is this spread's canvas.
2963
2970
  */
2964
2971
  syncMaterials(t) {
2965
- Kt(t, this.canvas);
2972
+ Jt(t, this.canvas);
2966
2973
  }
2967
2974
  // ── Lifecycle ────────────────────────────────────────────────────────────
2968
2975
  dispose() {
@@ -2970,32 +2977,32 @@ class Ne {
2970
2977
  }
2971
2978
  }
2972
2979
  const Wt = 256;
2973
- function Ae(r, t, e, s, i, n, h) {
2980
+ function He(r, t, e, s, i, n, h) {
2974
2981
  const a = t.naturalWidth || t.width, o = t.naturalHeight || t.height;
2975
2982
  if (a <= 0 || o <= 0) return;
2976
2983
  if (h === "fill") {
2977
2984
  r.drawImage(t, e, s, i, n);
2978
2985
  return;
2979
2986
  }
2980
- const u = h === "contain" ? Math.min(i / a, n / o) : Math.max(i / a, n / o), c = a * u, m = o * u;
2981
- r.drawImage(t, e + (i - c) * 0.5, s + (n - m) * 0.5, c, m);
2987
+ const u = h === "contain" ? Math.min(i / a, n / o) : Math.max(i / a, n / o), l = a * u, m = o * u;
2988
+ r.drawImage(t, e + (i - l) * 0.5, s + (n - m) * 0.5, l, m);
2982
2989
  }
2983
- function Xe(r, t, e, s, i, n, h) {
2990
+ function We(r, t, e, s, i, n, h) {
2984
2991
  const a = n ? Math.round(n * Wt) : 512, o = h ? Math.round(h * Wt) : 512, u = document.createElement("canvas");
2985
2992
  u.width = a, u.height = o;
2986
- const c = u.getContext("2d");
2987
- if (c.fillStyle = r, c.fillRect(0, 0, a, o), e) {
2993
+ const l = u.getContext("2d");
2994
+ if (l.fillStyle = r, l.fillRect(0, 0, a, o), e) {
2988
2995
  const f = i ? 0 : Math.round(Math.min(a, o) * 0.11);
2989
- Ae(c, e, f, f, a - f * 2, o - f * 2, s);
2996
+ He(l, e, f, f, a - f * 2, o - f * 2, s);
2990
2997
  } else {
2991
- c.fillStyle = "#333";
2998
+ l.fillStyle = "#333";
2992
2999
  const f = Math.round(Math.min(a, o) * 0.094);
2993
- c.font = `bold ${f}px Arial`, c.textAlign = "center", c.textBaseline = "middle", c.fillText(t, a / 2, o / 2);
3000
+ l.font = `bold ${f}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, a / 2, o / 2);
2994
3001
  }
2995
- const m = new l.CanvasTexture(u);
2996
- return m.colorSpace = l.SRGBColorSpace, m;
3002
+ const m = new c.CanvasTexture(u);
3003
+ return m.colorSpace = c.SRGBColorSpace, m;
2997
3004
  }
2998
- async function We(r) {
3005
+ async function Ge(r) {
2999
3006
  if (!r) return null;
3000
3007
  const t = URL.createObjectURL(r), e = new Image();
3001
3008
  e.decoding = "async", e.src = t;
@@ -3008,47 +3015,47 @@ async function We(r) {
3008
3015
  }
3009
3016
  }
3010
3017
  export {
3011
- ge as AnimationCurve,
3018
+ pe as AnimationCurve,
3012
3019
  yt as AutoTurnDirection,
3013
3020
  ut as AutoTurnMode,
3014
3021
  at as AutoTurnSetting,
3015
- fe as AutoTurnSettingCurveTimeMode,
3016
- de as AutoTurnSettingMode,
3022
+ ge as AutoTurnSettingCurveTimeMode,
3023
+ fe as AutoTurnSettingMode,
3017
3024
  Ut as AutoTurnSettings,
3018
3025
  Ct as Book,
3019
- Me as BookBinding,
3020
- ye as BookBound,
3021
- Oe as BookContent,
3026
+ ye as BookBinding,
3027
+ Ce as BookBound,
3028
+ Ze as BookContent,
3022
3029
  j as BookDirection,
3023
- pe as BookHeightException,
3024
- Ze as BookPointerInteraction,
3025
- me as BookRenderer,
3026
- wt as Cylinder,
3027
- le as MeshFactory,
3030
+ xe as BookHeightException,
3031
+ Ue as BookPointerInteraction,
3032
+ _e as BookRenderer,
3033
+ Pt as Cylinder,
3034
+ ce as MeshFactory,
3028
3035
  Wt as PX_PER_UNIT,
3029
- Fe as PageContent,
3030
- ae as Paper,
3036
+ Oe as PageContent,
3037
+ oe as Paper,
3031
3038
  Tt as PaperBorder,
3032
3039
  zt as PaperMaterialData,
3033
3040
  Ot as PaperMeshData,
3034
- _e as PaperMeshDataPool,
3035
- He as PaperMeshUtility,
3041
+ de as PaperMeshDataPool,
3042
+ Fe as PaperMeshUtility,
3036
3043
  ht as PaperNode,
3037
- oe as PaperNodeMargin,
3038
- xe as PaperPattern,
3039
- Pt as PaperSeam,
3044
+ le as PaperNodeMargin,
3045
+ Me as PaperPattern,
3046
+ wt as PaperSeam,
3040
3047
  rt as PaperSetup,
3041
3048
  gt as PaperUVMargin,
3042
- ce as RendererFactory,
3043
- Ne as SpreadContent,
3044
- Lt as SpritePageContent2,
3045
- Ue as StapleBookBinding,
3046
- Ie as StapleBookBound,
3047
- De as StapleSetup,
3048
- Yt as TextBlock,
3049
+ ue as RendererFactory,
3050
+ Xe as SpreadContent,
3051
+ Et as SpritePageContent2,
3052
+ Ee as StapleBookBinding,
3053
+ Ve as StapleBookBound,
3054
+ Ie as StapleSetup,
3055
+ Kt as TextBlock,
3049
3056
  Le as TextOverlayContent,
3050
- Xe as createPageTexture,
3051
- Ae as drawImageWithFit,
3052
- Ee as getSpreadPairs,
3053
- We as loadImage
3057
+ We as createPageTexture,
3058
+ He as drawImageWithFit,
3059
+ Ne as getSpreadPairs,
3060
+ Ge as loadImage
3054
3061
  };