@objectifthunes/three-book 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,8 +30,8 @@ class ut {
30
30
  * 3. Rotate by Y degrees around Y-axis.
31
31
  */
32
32
  eulerRotateVector(t, e, s) {
33
- const i = s * Math.PI / 180, n = e * Math.PI / 180, o = Math.cos(i), a = Math.sin(i), h = t * o, m = t * a, l = 0, _ = Math.cos(n), p = Math.sin(n), d = h * _ + l * p, u = m, f = -h * p + l * _;
34
- return new c.Vector3(d, u, f);
33
+ const i = s * Math.PI / 180, n = e * Math.PI / 180, o = Math.cos(i), a = Math.sin(i), h = t * o, m = t * a, l = 0, d = Math.cos(n), g = Math.sin(n), _ = h * d + l * g, u = m, f = -h * g + l * d;
34
+ return new c.Vector3(_, u, f);
35
35
  }
36
36
  roll(t) {
37
37
  if (this.getSide(t) >= 0) return t;
@@ -66,33 +66,33 @@ class ut {
66
66
  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;
67
67
  }
68
68
  }
69
- function pt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
69
+ function gt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
70
70
  s = Math.max(s, 1e-4);
71
71
  const o = 2 / s, a = o * n, h = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
72
72
  let m = r - t;
73
- const l = t, _ = i * s;
74
- m = c.MathUtils.clamp(m, -_, _), t = r - m;
75
- const p = (e + o * m) * n;
76
- e = (e - o * p) * h;
77
- let d = t + (m + p) * h;
78
- return l - r > 0 == d > l && (d = l, e = (d - l) / n), { value: d, velocity: e };
79
- }
80
- function te(r, t, e, s, i = 1 / 0, n = 1 / 60) {
81
- const o = pt(
73
+ const l = t, d = i * s;
74
+ m = c.MathUtils.clamp(m, -d, d), t = r - m;
75
+ const g = (e + o * m) * n;
76
+ e = (e - o * g) * h;
77
+ let _ = t + (m + g) * h;
78
+ return l - r > 0 == _ > l && (_ = l, e = (_ - l) / n), { value: _, velocity: e };
79
+ }
80
+ function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
81
+ const o = gt(
82
82
  r.x,
83
83
  t.x,
84
84
  e.x,
85
85
  s.x,
86
86
  i,
87
87
  n
88
- ), a = pt(
88
+ ), a = gt(
89
89
  r.y,
90
90
  t.y,
91
91
  e.y,
92
92
  s.y,
93
93
  i,
94
94
  n
95
- ), h = pt(
95
+ ), h = gt(
96
96
  r.z,
97
97
  t.z,
98
98
  e.z,
@@ -102,13 +102,13 @@ function te(r, t, e, s, i = 1 / 0, n = 1 / 60) {
102
102
  );
103
103
  return e.set(o.velocity, a.velocity, h.velocity), new c.Vector3(o.value, a.value, h.value);
104
104
  }
105
- function ee(r) {
105
+ function se(r) {
106
106
  return new c.Vector3(r.x, 0, r.y);
107
107
  }
108
- function se(r) {
108
+ function ie(r) {
109
109
  return new c.Vector3(r.x, r.z, 0);
110
110
  }
111
- function St(r, t, e) {
111
+ function vt(r, t, e) {
112
112
  const s = t * t - 4 * r * e;
113
113
  if (s < 0)
114
114
  return { rootCount: 0, root0: 0, root1: 0 };
@@ -124,80 +124,80 @@ function St(r, t, e) {
124
124
  }
125
125
  }
126
126
  function kt(r, t, e) {
127
- return ie(r, t, e) ? r.clone() : ne(
127
+ return ne(r, t, e) ? r.clone() : re(
128
128
  new c.Vector2(r.x, t.y),
129
129
  r,
130
130
  t,
131
131
  e
132
132
  );
133
133
  }
134
- function ie(r, t, e) {
134
+ function ne(r, t, e) {
135
135
  const s = r.x - t.x;
136
136
  let i = r.y - t.y;
137
137
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
138
138
  }
139
- function ne(r, t, e, s) {
140
- const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, _ = s.y, p = 1 / (l * l), d = 1 / (_ * _);
139
+ function re(r, t, e, s) {
140
+ const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, d = s.y, g = 1 / (l * l), _ = 1 / (d * d);
141
141
  if (Math.abs(o - h) < 1e-5) {
142
142
  if (o >= i - l && o <= i + l) {
143
- const u = St(
144
- d,
145
- -2 * d * n,
146
- p * (o * o - 2 * i * o + i * i) + d * n * n - 1
143
+ const u = vt(
144
+ _,
145
+ -2 * _ * n,
146
+ g * (o * o - 2 * i * o + i * i) + _ * n * n - 1
147
147
  );
148
148
  if (u.rootCount === 1)
149
149
  return new c.Vector2(o, u.root0);
150
150
  if (u.rootCount === 2) {
151
- let f = u.root0, g = u.root1;
152
- return a < m && ([f, g] = [g, f]), new c.Vector2(o, g);
151
+ let f = u.root0, p = u.root1;
152
+ return a < m && ([f, p] = [p, f]), new c.Vector2(o, p);
153
153
  }
154
154
  }
155
155
  } else {
156
- const u = (m - a) / (h - o), f = a - u * o, g = f - n, w = St(
157
- p + d * u * u,
158
- 2 * g * u * d - 2 * i * p,
159
- i * i * p + g * g * d - 1
156
+ const u = (m - a) / (h - o), f = a - u * o, p = f - n, P = vt(
157
+ g + _ * u * u,
158
+ 2 * p * u * _ - 2 * i * g,
159
+ i * i * g + p * p * _ - 1
160
160
  );
161
- if (w.rootCount === 1)
162
- return new c.Vector2(w.root0, u * w.root0 + f);
163
- if (w.rootCount === 2) {
164
- let B = w.root0, x = w.root1;
161
+ if (P.rootCount === 1)
162
+ return new c.Vector2(P.root0, u * P.root0 + f);
163
+ if (P.rootCount === 2) {
164
+ let B = P.root0, x = P.root1;
165
165
  return o < h && ([B, x] = [x, B]), new c.Vector2(x, u * x + f);
166
166
  }
167
167
  }
168
168
  return r.clone();
169
169
  }
170
- function vt(r, t) {
170
+ function bt(r, t) {
171
171
  const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
172
172
  return new c.Ray(e, s.sub(e));
173
173
  }
174
- function re(r) {
174
+ function oe(r) {
175
175
  return new c.Vector4(-r.x, r.y, r.z + r.x, r.w);
176
176
  }
177
- function oe(r) {
177
+ function ae(r) {
178
178
  return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
179
179
  }
180
- var E = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(E || {});
181
- const bt = Math.PI / 180, Bt = 180 / Math.PI, ae = 1192093e-13;
182
- function _t(r) {
180
+ var X = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(X || {});
181
+ const Bt = Math.PI / 180, Rt = 180 / Math.PI, he = 1192093e-13;
182
+ function dt(r) {
183
183
  return r < 0 ? 0 : r > 1 ? 1 : r;
184
184
  }
185
- function Rt(r, t, e) {
185
+ function It(r, t, e) {
186
186
  return r < t ? t : r > e ? e : r;
187
187
  }
188
188
  function mt(r, t, e) {
189
- return r !== t ? _t((e - r) / (t - r)) : 0;
189
+ return r !== t ? dt((e - r) / (t - r)) : 0;
190
190
  }
191
- function Vt(r, t, e) {
191
+ function zt(r, t, e) {
192
192
  return r + (t - r) * e;
193
193
  }
194
- function It(r, t, e) {
194
+ function Vt(r, t, e) {
195
195
  return r + (t - r) * e;
196
196
  }
197
- function zt(r, t, e) {
198
- return e = _t((e - r) / (t - r)), e * e * (3 - 2 * e);
197
+ function Dt(r, t, e) {
198
+ return e = dt((e - r) / (t - r)), e * e * (3 - 2 * e);
199
199
  }
200
- class he {
200
+ class le {
201
201
  // ---- Constructor ----
202
202
  constructor(t, e, s, i) {
203
203
  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 ut(), 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.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
@@ -240,7 +240,7 @@ class he {
240
240
  return this.m_IsFalling || this.m_IsTurning ? this.m_Transform.scale.x === -1 ? 1 - this.m_ZTime : this.m_ZTime : this.m_Transform.scale.x === -1 ? 1 : 0;
241
241
  }
242
242
  get direction() {
243
- const e = this.zTime * 180 * bt, s = Math.cos(e), i = Math.sin(e);
243
+ const e = this.zTime * 180 * Bt, s = Math.cos(e), i = Math.sin(e);
244
244
  return new c.Vector3(-s, -i, 0);
245
245
  }
246
246
  get isTurning() {
@@ -313,8 +313,8 @@ class he {
313
313
  this.m_MinTurningRadius = t;
314
314
  }
315
315
  updateTurningRadius(t = 1) {
316
- let e = Math.max(this.m_Stiffness, 1 - _t(t));
317
- e <= 0.5 ? this.m_TurningRadius = mt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - mt(0.5, 1, e)), 5) * bt), this.m_TurningRadius = Math.max(
316
+ let e = Math.max(this.m_Stiffness, 1 - dt(t));
317
+ e <= 0.5 ? this.m_TurningRadius = mt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - mt(0.5, 1, e)), 5) * Bt), this.m_TurningRadius = Math.max(
318
318
  this.m_TurningRadius,
319
319
  this.m_MinTurningRadius
320
320
  );
@@ -322,7 +322,7 @@ class he {
322
322
  startTurning(t) {
323
323
  var n, o;
324
324
  const e = t.clone();
325
- t = vt(
325
+ t = bt(
326
326
  t,
327
327
  this.m_Transform.matrixWorld.clone().invert()
328
328
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
@@ -351,7 +351,7 @@ class he {
351
351
  const t = new c.Vector3(0, 0, 0);
352
352
  for (const e of this.m_HandleVelocities)
353
353
  t.add(e);
354
- 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 = Vt(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);
354
+ 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 = zt(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);
355
355
  }
356
356
  /**
357
357
  * Called each frame while the user is dragging.
@@ -375,19 +375,19 @@ class he {
375
375
  var s, i;
376
376
  let e = !1;
377
377
  if (this.m_IsAutoTurning) {
378
- let n = _t(this.m_FallTime / this.m_FallDuration);
379
- n = zt(0, 1, n), n = zt(0, 1, n), this.m_CurrentHandle.lerpVectors(
378
+ let n = dt(this.m_FallTime / this.m_FallDuration);
379
+ n = Dt(0, 1, n), n = Dt(0, 1, n), this.m_CurrentHandle.lerpVectors(
380
380
  this.m_StartHandle,
381
381
  this.m_EndHandle,
382
382
  this.m_IsFallingLeft ? n : 1 - n
383
- ), this.m_FallTime += t, e = Math.abs(n - 1) < ae;
383
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < he;
384
384
  } else {
385
385
  const n = new c.Vector3(
386
386
  this.m_FallTime,
387
387
  0,
388
388
  this.m_FallTime * 0.75
389
389
  );
390
- this.m_CurrentHandle = te(
390
+ this.m_CurrentHandle = ee(
391
391
  this.m_CurrentHandle,
392
392
  this.m_EndHandle,
393
393
  this.m_HandleVelocity,
@@ -439,7 +439,7 @@ class he {
439
439
  );
440
440
  this.m_UVMargin.fixUV(e);
441
441
  const s = this.m_Book.direction;
442
- if (s === E.UpToDown || s === E.DownToUp) {
442
+ if (s === X.UpToDown || s === X.DownToUp) {
443
443
  const i = e.x;
444
444
  e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
445
445
  } else
@@ -451,7 +451,7 @@ class he {
451
451
  * Returns the local-space hit point, or null if no hit / out of bounds.
452
452
  */
453
453
  raycastLocal(t, e = !1) {
454
- t = vt(
454
+ t = bt(
455
455
  t,
456
456
  this.m_Transform.matrixWorld.clone().invert()
457
457
  );
@@ -490,7 +490,7 @@ class he {
490
490
  ), this.m_SubMeshCount = t);
491
491
  const e = this.m_FrontContent.textureST.clone();
492
492
  let s = this.m_BackContent.textureST.clone();
493
- this.m_Book.direction > 1 ? s = oe(s) : s = re(s);
493
+ this.m_Book.direction > 1 ? s = ae(s) : s = oe(s);
494
494
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
495
495
  if (t === 3) {
496
496
  let o = 0, a = 1;
@@ -532,7 +532,7 @@ class he {
532
532
  const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
533
533
  new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
534
534
  );
535
- this.m_XTime = Vt(
535
+ this.m_XTime = zt(
536
536
  Math.min(t, e),
537
537
  Math.max(t, e),
538
538
  0.9
@@ -541,8 +541,8 @@ class he {
541
541
  new c.Vector3(s[1], 0, i[i.length - 1])
542
542
  ), h = this.rollPoint(
543
543
  new c.Vector3(s[2], 0, i[i.length - 1])
544
- ), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), _ = Bt * Math.atan2(m.y, m.x), p = Bt * Math.atan2(l.y, l.x), d = (_ + p) / 2;
545
- this.m_ZTime = d / 180;
544
+ ), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), d = Rt * Math.atan2(m.y, m.x), g = Rt * Math.atan2(l.y, l.x), _ = (d + g) / 2;
545
+ this.m_ZTime = _ / 180;
546
546
  } else
547
547
  this.m_XTime = 0, this.m_ZTime = 0;
548
548
  }
@@ -557,20 +557,20 @@ class he {
557
557
  ), l = new c.Vector2(
558
558
  0,
559
559
  h + (s.z - h) * (a / n)
560
- ), _ = new c.Vector2(i, o), p = new c.Vector2(n, a);
561
- t.x = Rt(t.x, -this.m_Size.x, this.m_Size.x);
562
- const d = se(t), u = kt(
563
- new c.Vector2(d.x, d.y),
560
+ ), d = new c.Vector2(i, o), g = new c.Vector2(n, a);
561
+ t.x = It(t.x, -this.m_Size.x, this.m_Size.x);
562
+ const _ = ie(t), u = kt(
563
+ new c.Vector2(_.x, _.y),
564
564
  m,
565
- _
565
+ d
566
566
  ), f = kt(
567
567
  new c.Vector2(u.x, u.y),
568
568
  l,
569
- p
570
- ), g = ee(
569
+ g
570
+ ), p = se(
571
571
  new c.Vector3(f.x, f.y, 0)
572
572
  );
573
- this.m_CurrentHandle.copy(g);
573
+ this.m_CurrentHandle.copy(p);
574
574
  }
575
575
  updateCylinder() {
576
576
  const t = this.m_StartHandle.clone(), e = this.m_CurrentHandle.clone(), s = t.clone().sub(e).normalize();
@@ -600,16 +600,16 @@ class he {
600
600
  startAutoTurning(t, e, s, i) {
601
601
  var m, l;
602
602
  if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === 0) {
603
- const _ = this.m_Transform.scale;
604
- _.x *= -1;
603
+ const d = this.m_Transform.scale;
604
+ d.x *= -1;
605
605
  }
606
606
  this.switchMeshData(
607
607
  0
608
608
  /* Highpoly */
609
609
  ), (m = this.m_Prev) == null || m.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === 1, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
610
610
  const n = this.m_Size.x, o = this.m_Size.y;
611
- e = Rt(e, -0.99, 0.99);
612
- const a = It(0.5, 1, e), h = It(0.5, 0, e);
611
+ e = It(e, -0.99, 0.99);
612
+ const a = Vt(0.5, 1, e), h = Vt(0.5, 0, e);
613
613
  this.m_StartHandle.set(n, 0, o * a), this.m_EndHandle.set(-n, 0, o * h), this.m_IsAutoTurning = !0;
614
614
  }
615
615
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
@@ -658,16 +658,16 @@ const Y = class Y {
658
658
  transform(t) {
659
659
  const e = new Y();
660
660
  switch (t) {
661
- case E.LeftToRight:
661
+ case X.LeftToRight:
662
662
  e.m_Left = this.m_Left, e.m_Right = this.m_Right, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
663
663
  break;
664
- case E.RightToLeft:
664
+ case X.RightToLeft:
665
665
  e.m_Left = this.m_Right, e.m_Right = this.m_Left, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
666
666
  break;
667
- case E.UpToDown:
667
+ case X.UpToDown:
668
668
  e.m_Left = this.m_Up, e.m_Right = this.m_Down, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
669
669
  break;
670
- case E.DownToUp:
670
+ case X.DownToUp:
671
671
  default:
672
672
  e.m_Left = this.m_Down, e.m_Right = this.m_Up, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
673
673
  break;
@@ -696,10 +696,10 @@ const Y = class Y {
696
696
  }
697
697
  };
698
698
  Y.kMin = 0, Y.kMax = 0.25;
699
- let gt = Y;
700
- const L = class L {
699
+ let pt = Y;
700
+ const U = class U {
701
701
  constructor(t) {
702
- 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 = E.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? L.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? L.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? L.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);
702
+ 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 pt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? U.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? U.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? U.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);
703
703
  }
704
704
  // ── Properties ────────────────────────────────────────────────────────
705
705
  get material() {
@@ -718,19 +718,19 @@ const L = class L {
718
718
  return this.bookDirection > 1 ? this.m_Height : this.m_Width;
719
719
  }
720
720
  set width(t) {
721
- this.m_Width = Math.max(t, L.kMinSize);
721
+ this.m_Width = Math.max(t, U.kMinSize);
722
722
  }
723
723
  get height() {
724
724
  return this.bookDirection > 1 ? this.m_Width : this.m_Height;
725
725
  }
726
726
  set height(t) {
727
- this.m_Height = Math.max(t, L.kMinSize);
727
+ this.m_Height = Math.max(t, U.kMinSize);
728
728
  }
729
729
  get thickness() {
730
730
  return this.m_Thickness;
731
731
  }
732
732
  set thickness(t) {
733
- this.m_Thickness = Math.max(t, L.kMinThickness);
733
+ this.m_Thickness = Math.max(t, U.kMinThickness);
734
734
  }
735
735
  get stiffness() {
736
736
  return this.m_Stiffness;
@@ -743,8 +743,8 @@ const L = class L {
743
743
  }
744
744
  set quality(t) {
745
745
  this.m_Quality = Math.max(
746
- L.kMinQuality,
747
- Math.min(t, L.kMaxQuality)
746
+ U.kMinQuality,
747
+ Math.min(t, U.kMaxQuality)
748
748
  );
749
749
  }
750
750
  get uvMargin() {
@@ -757,9 +757,9 @@ const L = class L {
757
757
  return new c.Vector2(this.width, this.height);
758
758
  }
759
759
  };
760
- L.kMinSize = 1, L.kMinThickness = 1e-4, L.kMinQuality = 1, L.kMaxQuality = 5;
761
- let ht = L;
762
- class Dt {
760
+ U.kMinSize = 1, U.kMinThickness = 1e-4, U.kMinQuality = 1, U.kMaxQuality = 5;
761
+ let ht = U;
762
+ class At {
763
763
  constructor(t) {
764
764
  this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
765
765
  const e = t.material ?? new c.MeshStandardMaterial();
@@ -795,13 +795,13 @@ class Dt {
795
795
  this.m_Texture = t, this.m_TextureST.copy(e);
796
796
  }
797
797
  }
798
- function At(r, t, e, s = new c.Vector3()) {
798
+ function Ht(r, t, e, s = new c.Vector3()) {
799
799
  let i = t.x - r.x, n = t.y - r.y, o = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + o * o);
800
800
  i *= a, n *= a, o *= a;
801
801
  let h = e.x - r.x, m = e.y - r.y, l = e.z - r.z;
802
802
  a = 1 / Math.sqrt(h * h + m * m + l * l), h *= a, m *= a, l *= a;
803
- const _ = n * l - o * m, p = o * h - i * l, d = i * m - n * h;
804
- return a = 1 / Math.sqrt(_ * _ + p * p + d * d), s.set(_ * a, p * a, d * a);
803
+ const d = n * l - o * m, g = o * h - i * l, _ = i * m - n * h;
804
+ return a = 1 / Math.sqrt(d * d + g * g + _ * _), s.set(d * a, g * a, _ * a);
805
805
  }
806
806
  class st {
807
807
  constructor(t, e = !1, s = !1) {
@@ -869,12 +869,12 @@ class Pt {
869
869
  return t.active = this.active, t;
870
870
  }
871
871
  }
872
- class wt {
872
+ class Tt {
873
873
  constructor(t, e, s, i, n, o = !0) {
874
874
  this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = o;
875
875
  }
876
876
  clone() {
877
- return new wt(
877
+ return new Tt(
878
878
  this.startX,
879
879
  this.startZ,
880
880
  this.endX,
@@ -884,7 +884,7 @@ class wt {
884
884
  );
885
885
  }
886
886
  }
887
- class le {
887
+ class ce {
888
888
  constructor(t, e, s) {
889
889
  const i = t.size;
890
890
  this.leftNode = new st(e.left * i.x, s, !0), this.rightNode = new st((1 - e.right) * i.x, s, !0), this.downNode = new st(e.down * i.y, s, !0), this.upNode = new st((1 - e.up) * i.y, s, !0);
@@ -908,97 +908,97 @@ function xt(r, t, e, s, i) {
908
908
  for (const n of r) {
909
909
  if (!n.active) return;
910
910
  for (let o = 0; o < s; o++) {
911
- const a = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[o * e + h], _ = t[o * e + n.index];
912
- i ? Gt(m, l, n.time, _) : _.copy(m).lerp(l, n.time);
911
+ const a = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[o * e + h], d = t[o * e + n.index];
912
+ i ? Wt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
913
913
  }
914
914
  }
915
915
  }
916
- function Ct(r, t, e, s, i) {
916
+ function yt(r, t, e, s, i) {
917
917
  for (const n of r) {
918
918
  if (!n.active) return;
919
919
  for (let o = 0; o < e; o++) {
920
- const a = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[h * e + o], _ = t[n.index * e + o];
921
- i ? Gt(m, l, n.time, _) : _.copy(m).lerp(l, n.time);
920
+ const a = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[h * e + o], d = t[n.index * e + o];
921
+ i ? Wt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
922
922
  }
923
923
  }
924
924
  }
925
- function Gt(r, t, e, s = new c.Vector3()) {
925
+ function Wt(r, t, e, s = new c.Vector3()) {
926
926
  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);
927
927
  if (i === 0 || n === 0)
928
928
  return s.copy(r).lerp(t, e);
929
- const o = r.x / i, a = r.y / i, h = r.z / i, m = t.x / n, l = t.y / n, _ = t.z / n;
930
- let p = o * m + a * l + h * _;
931
- p = Math.max(-1, Math.min(1, p));
932
- const d = Math.acos(p);
933
- if (d < 1e-6)
929
+ const o = r.x / i, a = r.y / i, h = r.z / i, m = t.x / n, l = t.y / n, d = t.z / n;
930
+ let g = o * m + a * l + h * d;
931
+ g = Math.max(-1, Math.min(1, g));
932
+ const _ = Math.acos(g);
933
+ if (_ < 1e-6)
934
934
  return s.copy(r).lerp(t, e);
935
- const u = Math.sin(d), f = Math.sin((1 - e) * d) / u, g = Math.sin(e * d) / u, w = i + (n - i) * e;
935
+ const u = Math.sin(_), f = Math.sin((1 - e) * _) / u, p = Math.sin(e * _) / u, P = i + (n - i) * e;
936
936
  return s.set(
937
- (o * f + m * g) * w,
938
- (a * f + l * g) * w,
939
- (h * f + _ * g) * w
937
+ (o * f + m * p) * P,
938
+ (a * f + l * p) * P,
939
+ (h * f + d * p) * P
940
940
  );
941
941
  }
942
942
  function qt(r, t, e, s, i) {
943
943
  for (const n of r) {
944
944
  const o = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, h = e.length;
945
- for (let l = 0, _ = n.endX - n.startX; l < _; l++) {
946
- const p = h + l * 2 + 0, d = h + l * 2 + 1, u = h + l * 2 + 2, f = h + l * 2 + 3;
947
- n.flip ? Ft(t, p, d, u, f, o) : Ht(t, p, d, u, f, o);
945
+ for (let l = 0, d = n.endX - n.startX; l < d; l++) {
946
+ const g = h + l * 2 + 0, _ = h + l * 2 + 1, u = h + l * 2 + 2, f = h + l * 2 + 3;
947
+ n.flip ? Ot(t, g, _, u, f, o) : Ft(t, g, _, u, f, o);
948
948
  }
949
949
  if (n.left)
950
- for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
951
- const p = h + l * 2 + 0 + o * 2, d = h + l * 2 + 1 + o * 2, u = h + l * 2 + 2 + o * 2, f = h + l * 2 + 3 + o * 2;
952
- n.flip ? Ft(t, p, d, u, f, a) : Ht(t, p, d, u, f, a);
950
+ for (let l = 0, d = n.endZ - n.startZ; l < d; l++) {
951
+ const g = h + l * 2 + 0 + o * 2, _ = h + l * 2 + 1 + o * 2, u = h + l * 2 + 2 + o * 2, f = h + l * 2 + 3 + o * 2;
952
+ n.flip ? Ot(t, g, _, u, f, a) : Ft(t, g, _, u, f, a);
953
953
  }
954
954
  else
955
- for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
956
- const p = h + l * 2 + 0 + o * 2 + a, d = h + l * 2 + 1 + o * 2 + a, u = h + l * 2 + 2 + o * 2 + a, f = h + l * 2 + 3 + o * 2 + a;
957
- n.flip ? ft(t, p, d, u, f) : dt(t, p, d, u, f);
955
+ for (let l = 0, d = n.endZ - n.startZ; l < d; l++) {
956
+ const g = h + l * 2 + 0 + o * 2 + a, _ = h + l * 2 + 1 + o * 2 + a, u = h + l * 2 + 2 + o * 2 + a, f = h + l * 2 + 3 + o * 2 + a;
957
+ n.flip ? ft(t, g, _, u, f) : _t(t, g, _, u, f);
958
958
  }
959
959
  const m = s * i;
960
960
  for (let l = n.startX; l <= n.endX; l++) {
961
- const _ = n.startZ * s + l;
962
- e.push(e[_].clone()), e.push(e[_ + m].clone());
961
+ const d = n.startZ * s + l;
962
+ e.push(e[d].clone()), e.push(e[d + m].clone());
963
963
  }
964
964
  for (let l = n.startX; l <= n.endX; l++) {
965
- const _ = l + n.endZ * s;
966
- e.push(e[_ + m].clone()), e.push(e[_].clone());
965
+ const d = l + n.endZ * s;
966
+ e.push(e[d + m].clone()), e.push(e[d].clone());
967
967
  }
968
968
  for (let l = n.startZ; l <= n.endZ; l++) {
969
- const _ = n.startX + l * s;
970
- e.push(e[_ + m].clone()), e.push(e[_].clone());
969
+ const d = n.startX + l * s;
970
+ e.push(e[d + m].clone()), e.push(e[d].clone());
971
971
  }
972
972
  for (let l = n.startZ; l <= n.endZ; l++) {
973
- const _ = l * s + n.endX;
974
- e.push(e[_].clone()), e.push(e[_ + m].clone());
973
+ const d = l * s + n.endX;
974
+ e.push(e[d].clone()), e.push(e[d + m].clone());
975
975
  }
976
976
  }
977
977
  }
978
- function Wt(r, t, e, s, i) {
978
+ function Qt(r, t, e, s, i) {
979
979
  const n = s * i;
980
980
  let o = n * 2;
981
981
  const a = new c.Vector3();
982
982
  for (const h of r) {
983
983
  for (let m = h.startX; m <= h.endX; m++) {
984
- const l = m + h.startZ * s, _ = t[l], p = t[l + s];
985
- a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l + n]);
984
+ const l = m + h.startZ * s, d = t[l], g = t[l + s];
985
+ a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l + n]);
986
986
  }
987
987
  for (let m = h.startX; m <= h.endX; m++) {
988
- const l = m + h.endZ * s, _ = t[l + n], p = t[l + n - s];
989
- a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l]);
988
+ const l = m + h.endZ * s, d = t[l + n], g = t[l + n - s];
989
+ a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l]);
990
990
  }
991
991
  for (let m = h.startZ; m <= h.endZ; m++) {
992
- const l = m * s + h.startX, _ = t[l + n], p = t[l + n + 1];
993
- a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l]);
992
+ const l = m * s + h.startX, d = t[l + n], g = t[l + n + 1];
993
+ a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l]);
994
994
  }
995
995
  for (let m = h.startZ; m <= h.endZ; m++) {
996
- const l = m * s + h.endX, _ = t[l], p = t[l - 1];
997
- a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l + n]);
996
+ const l = m * s + h.endX, d = t[l], g = t[l - 1];
997
+ a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l + n]);
998
998
  }
999
999
  }
1000
1000
  }
1001
- function ce(r, t, e, s, i) {
1001
+ function me(r, t, e, s, i) {
1002
1002
  const n = [];
1003
1003
  for (const o of r) {
1004
1004
  for (let a = o.startX; a < o.endX; a++) {
@@ -1010,50 +1010,50 @@ function ce(r, t, e, s, i) {
1010
1010
  n.push([m, l]);
1011
1011
  }
1012
1012
  for (let a = o.startZ; a < o.endZ; a++) {
1013
- const h = a * e + o.startX, m = (a + 1) * e + o.startX, l = t[h].clone().applyMatrix4(i), _ = t[m].clone().applyMatrix4(i);
1014
- n.push([l, _]);
1013
+ const h = a * e + o.startX, m = (a + 1) * e + o.startX, l = t[h].clone().applyMatrix4(i), d = t[m].clone().applyMatrix4(i);
1014
+ n.push([l, d]);
1015
1015
  }
1016
1016
  for (let a = o.startZ; a < o.endZ; a++) {
1017
- const h = a * e + o.endX, m = (a + 1) * e + o.endX, l = t[h].clone().applyMatrix4(i), _ = t[m].clone().applyMatrix4(i);
1018
- n.push([l, _]);
1017
+ const h = a * e + o.endX, m = (a + 1) * e + o.endX, l = t[h].clone().applyMatrix4(i), d = t[m].clone().applyMatrix4(i);
1018
+ n.push([l, d]);
1019
1019
  }
1020
1020
  }
1021
1021
  return n;
1022
1022
  }
1023
- function Ht(r, t, e, s, i, n) {
1024
- dt(r, t, e, s, i), t += n, e += n, s += n, i += n, dt(r, t, e, s, i);
1025
- }
1026
1023
  function Ft(r, t, e, s, i, n) {
1024
+ _t(r, t, e, s, i), t += n, e += n, s += n, i += n, _t(r, t, e, s, i);
1025
+ }
1026
+ function Ot(r, t, e, s, i, n) {
1027
1027
  ft(r, t, e, s, i), t += n, e += n, s += n, i += n, ft(r, t, e, s, i);
1028
1028
  }
1029
- function Qt(r, t, e, s, i, n, o) {
1030
- dt(r, e, s, i, n), e += o, s += o, i += o, n += o, ft(t, e, s, i, n);
1029
+ function $t(r, t, e, s, i, n, o) {
1030
+ _t(r, e, s, i, n), e += o, s += o, i += o, n += o, ft(t, e, s, i, n);
1031
1031
  }
1032
- function $t(r, t, e, s, i, n) {
1033
- const o = i.left * s.x, a = (1 - i.right) * s.x, h = i.down * s.y, m = (1 - i.up) * s.y, l = t.length, _ = e.length;
1032
+ function Yt(r, t, e, s, i, n) {
1033
+ const o = i.left * s.x, a = (1 - i.right) * s.x, h = i.down * s.y, m = (1 - i.up) * s.y, l = t.length, d = e.length;
1034
1034
  if (n > 1)
1035
- for (let d = 0; d < _; d++)
1035
+ for (let _ = 0; _ < d; _++)
1036
1036
  for (let u = 0; u < l; u++) {
1037
- const f = lt(a, o, t[u]), g = lt(m, h, e[d]);
1038
- r.push(new c.Vector2(g, f));
1037
+ const f = lt(a, o, t[u]), p = lt(m, h, e[_]);
1038
+ r.push(new c.Vector2(p, f));
1039
1039
  }
1040
1040
  else
1041
- for (let d = 0; d < _; d++)
1041
+ for (let _ = 0; _ < d; _++)
1042
1042
  for (let u = 0; u < l; u++) {
1043
- const f = lt(o, a, t[u]), g = lt(m, h, e[d]);
1044
- r.push(new c.Vector2(f, g));
1043
+ const f = lt(o, a, t[u]), p = lt(m, h, e[_]);
1044
+ r.push(new c.Vector2(f, p));
1045
1045
  }
1046
- const p = r.length;
1047
- for (let d = 0; d < p; d++)
1048
- r.push(r[d].clone());
1046
+ const g = r.length;
1047
+ for (let _ = 0; _ < g; _++)
1048
+ r.push(r[_].clone());
1049
1049
  }
1050
- function dt(r, t, e, s, i) {
1050
+ function _t(r, t, e, s, i) {
1051
1051
  r.push(t), r.push(s), r.push(e), r.push(e), r.push(s), r.push(i);
1052
1052
  }
1053
1053
  function ft(r, t, e, s, i) {
1054
1054
  r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1055
1055
  }
1056
- function Yt(r, t, e, s) {
1056
+ function Kt(r, t, e, s) {
1057
1057
  const i = [];
1058
1058
  for (let n = 0; n < e - 1; n++)
1059
1059
  for (let o = 0; o < t - 1; o++) {
@@ -1062,17 +1062,17 @@ function Yt(r, t, e, s) {
1062
1062
  }
1063
1063
  return i;
1064
1064
  }
1065
- const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1065
+ const Ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1066
1066
  __proto__: null,
1067
1067
  addBorders: qt,
1068
- addFrontAndBackFaces: Qt,
1069
- addFrontAndBackTexcoords: $t,
1070
- debugDrawBorders: ce,
1071
- drawWireframe: Yt,
1068
+ addFrontAndBackFaces: $t,
1069
+ addFrontAndBackTexcoords: Yt,
1070
+ debugDrawBorders: me,
1071
+ drawWireframe: Kt,
1072
1072
  seamNodesToSeams: Mt,
1073
- updateBorders: Wt,
1073
+ updateBorders: Qt,
1074
1074
  updateXSeams: xt,
1075
- updateZSeams: Ct
1075
+ updateZSeams: yt
1076
1076
  }, Symbol.toStringTag, { value: "Module" }));
1077
1077
  class Zt {
1078
1078
  get geometry() {
@@ -1150,37 +1150,37 @@ class Zt {
1150
1150
  const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, o = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, h = new c.Vector3(), m = new c.Vector3(), l = new c.Vector3();
1151
1151
  for (let u = 0; u < a; u++)
1152
1152
  s[u].set(0, 0, 0);
1153
- xt(this.m_Pattern.xSeams, t, n, o, !1), Ct(this.m_Pattern.zSeams, t, n, o, !1);
1153
+ xt(this.m_Pattern.xSeams, t, n, o, !1), yt(this.m_Pattern.zSeams, t, n, o, !1);
1154
1154
  for (let u = 0; u < o - 1; u++) {
1155
1155
  const f = u + 1;
1156
- for (let g = 0; g < n - 1; g++) {
1157
- const w = g + 1, B = u * n + g, x = u * n + w, y = f * n + g, S = f * n + w, v = t[B], Z = t[x], O = t[y], z = t[S];
1158
- At(v, O, Z, h), At(z, Z, O, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[y].add(l), s[S].add(l);
1156
+ for (let p = 0; p < n - 1; p++) {
1157
+ const P = p + 1, B = u * n + p, x = u * n + P, w = f * n + p, S = f * n + P, k = t[B], O = t[x], Z = t[w], V = t[S];
1158
+ Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[w].add(l), s[S].add(l);
1159
1159
  }
1160
1160
  }
1161
1161
  for (let u = 0; u < a; u++)
1162
1162
  s[u].divideScalar(i[u]).normalize();
1163
- xt(this.m_Pattern.xSeams, s, n, o, !0), Ct(this.m_Pattern.zSeams, s, n, o, !0);
1164
- const _ = this.m_Pattern.thickness / 2;
1163
+ xt(this.m_Pattern.xSeams, s, n, o, !0), yt(this.m_Pattern.zSeams, s, n, o, !0);
1164
+ const d = this.m_Pattern.thickness / 2;
1165
1165
  for (let u = 0; u < a; u++) {
1166
1166
  const f = s[u];
1167
1167
  s[u + a].copy(f).negate();
1168
- const g = t[u];
1169
- e[u].copy(g).addScaledVector(f, _), e[u + a].copy(g).addScaledVector(f, -_);
1168
+ const p = t[u];
1169
+ e[u].copy(p).addScaledVector(f, d), e[u + a].copy(p).addScaledVector(f, -d);
1170
1170
  }
1171
- Wt(this.m_Pattern.borders, e, s, n, o);
1172
- const p = this.m_Geometry.getAttribute(
1171
+ Qt(this.m_Pattern.borders, e, s, n, o);
1172
+ const g = this.m_Geometry.getAttribute(
1173
1173
  "position"
1174
- ), d = this.m_Geometry.getAttribute(
1174
+ ), _ = this.m_Geometry.getAttribute(
1175
1175
  "normal"
1176
1176
  );
1177
1177
  for (let u = 0; u < e.length; u++) {
1178
1178
  const f = e[u];
1179
- p.setXYZ(u, f.x, f.y, f.z);
1180
- const g = s[u];
1181
- d.setXYZ(u, g.x, g.y, g.z);
1179
+ g.setXYZ(u, f.x, f.y, f.z);
1180
+ const p = s[u];
1181
+ _.setXYZ(u, p.x, p.y, p.z);
1182
1182
  }
1183
- p.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1183
+ g.needsUpdate = !0, _.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1184
1184
  }
1185
1185
  // ── DrawWireframe (debug) ──────────────────────────────────────────────
1186
1186
  /**
@@ -1190,10 +1190,10 @@ class Zt {
1190
1190
  */
1191
1191
  drawWireframe(t) {
1192
1192
  const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
1193
- return Yt(this.m_Vertices, e, s, t);
1193
+ return Kt(this.m_Vertices, e, s, t);
1194
1194
  }
1195
1195
  }
1196
- class me {
1196
+ class ue {
1197
1197
  constructor() {
1198
1198
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1199
1199
  }
@@ -1212,7 +1212,7 @@ class me {
1212
1212
  this.m_Meshs.clear();
1213
1213
  }
1214
1214
  }
1215
- class ue {
1215
+ class de {
1216
1216
  constructor(t) {
1217
1217
  this.m_CreateMeshCollider = !1, this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1218
1218
  }
@@ -1224,7 +1224,7 @@ class ue {
1224
1224
  }
1225
1225
  get(t) {
1226
1226
  let e;
1227
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new de(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1227
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new fe(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1228
1228
  }
1229
1229
  recycle() {
1230
1230
  for (const t of this.m_UsedRenderers)
@@ -1245,7 +1245,7 @@ class ue {
1245
1245
  }
1246
1246
  }
1247
1247
  let _e = 1;
1248
- class de {
1248
+ class fe {
1249
1249
  constructor(t, e, s) {
1250
1250
  this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = _e++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1251
1251
  new c.BufferGeometry(),
@@ -1351,7 +1351,7 @@ class de {
1351
1351
  e.dispose();
1352
1352
  }
1353
1353
  }
1354
- class fe {
1354
+ class ge {
1355
1355
  constructor(t, e, s = !1) {
1356
1356
  this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Zt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1357
1357
  }
@@ -1363,8 +1363,8 @@ class fe {
1363
1363
  this.m_Stack.push(t);
1364
1364
  }
1365
1365
  }
1366
- var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), pe = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(pe || {}), ge = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(ge || {}), Me = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(Me || {});
1367
- class xe {
1366
+ var wt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(wt || {}), pe = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(pe || {}), Me = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(Me || {}), xe = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(xe || {});
1367
+ class ye {
1368
1368
  constructor(t) {
1369
1369
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1370
1370
  }
@@ -1389,10 +1389,10 @@ class xe {
1389
1389
  function nt(r, t, e) {
1390
1390
  return Math.max(t, Math.min(e, r));
1391
1391
  }
1392
- function Ce(r, t, e) {
1392
+ function we(r, t, e) {
1393
1393
  return r === t ? 0 : nt((e - r) / (t - r), 0, 1);
1394
1394
  }
1395
- function Ot(r, t) {
1395
+ function Lt(r, t) {
1396
1396
  return r + Math.random() * (t - r);
1397
1397
  }
1398
1398
  class rt {
@@ -1463,12 +1463,12 @@ class rt {
1463
1463
  getValue(t, e) {
1464
1464
  if (this.m_Mode === 0) return this.m_Constant;
1465
1465
  if (this.m_Mode === 1)
1466
- return Ot(this.m_ConstantMin, this.m_ConstantMax);
1466
+ return Lt(this.m_ConstantMin, this.m_ConstantMax);
1467
1467
  const s = this.m_CurveTimeMode === 0 ? t : e;
1468
1468
  if (this.m_Mode === 2)
1469
1469
  return this.m_Curve.evaluate(s);
1470
1470
  if (this.m_Mode === 3)
1471
- return Ot(
1471
+ return Lt(
1472
1472
  this.m_CurveMin.evaluate(s),
1473
1473
  this.m_CurveMax.evaluate(s)
1474
1474
  );
@@ -1488,9 +1488,9 @@ class rt {
1488
1488
  }
1489
1489
  for (let h = 0; h < n; h++) {
1490
1490
  let m = i[h].time, l = i[h].value;
1491
- m = Ce(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
1491
+ m = we(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
1492
1492
  }
1493
- return new xe(i);
1493
+ return new ye(i);
1494
1494
  }
1495
1495
  // ── Value-type clone ────────────────────────────────────────────────────
1496
1496
  clone() {
@@ -1567,7 +1567,7 @@ const R = class R {
1567
1567
  }
1568
1568
  };
1569
1569
  R.kMinTwist = -1, R.kMaxTwist = 1, R.kMinBend = 0, R.kMaxBend = 1, R.kMinDuration = 0, R.kMaxDuration = 5;
1570
- let Nt = R, Ze = class extends Error {
1570
+ let Nt = R, Ue = class extends Error {
1571
1571
  constructor() {
1572
1572
  super(
1573
1573
  "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."
@@ -1589,7 +1589,7 @@ const ot = class ot extends c.Group {
1589
1589
  height: 3,
1590
1590
  thickness: 0.02,
1591
1591
  stiffness: 0.2
1592
- }), 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 = E.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, 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.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), 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 ht({
1592
+ }), 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 = X.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, 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.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), 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 ht({
1593
1593
  color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1594
1594
  width: t.coverPaperSetup.width ?? 2.1,
1595
1595
  height: t.coverPaperSetup.height ?? 3.1,
@@ -1731,7 +1731,7 @@ const ot = class ot extends c.Group {
1731
1731
  }
1732
1732
  getActivePaperSideIndices(t) {
1733
1733
  if (t.length = 0, !this.m_IsBuilt) return;
1734
- const e = this.m_Content.direction === E.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1734
+ const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1735
1735
  let a = n * 2;
1736
1736
  o && a++, e && (a = s * 2 - a - 1), t.includes(a) || t.push(a);
1737
1737
  };
@@ -1768,8 +1768,8 @@ const ot = class ot extends c.Group {
1768
1768
  const n = typeof i == "number" ? new rt(i) : i;
1769
1769
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1770
1770
  for (let o = 0; o < s && this.canAutoTurn(t); o++) {
1771
- const a = o / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = o > 0 ? n.getValue(h, a) : 0, l = e.getModeValue(), _ = e.getTwistValue(h, a), p = e.getBendValue(h, a), d = e.getDurationValue(h, a);
1772
- this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: _, bend: p, duration: d, delay: m });
1771
+ const a = o / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = o > 0 ? n.getValue(h, a) : 0, l = e.getModeValue(), d = e.getTwistValue(h, a), g = e.getBendValue(h, a), _ = e.getDurationValue(h, a);
1772
+ this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: d, bend: g, duration: _, delay: m });
1773
1773
  }
1774
1774
  return this.m_AutoTurnTimer = 0, !0;
1775
1775
  }
@@ -1797,7 +1797,7 @@ const ot = class ot extends c.Group {
1797
1797
  if (this.isTurning) return null;
1798
1798
  const e = this.getFrontPapers();
1799
1799
  if (e.length > 0) {
1800
- const s = t === yt.Next, i = e[s ? e.length - 1 : 0];
1800
+ const s = t === wt.Next, i = e[s ? e.length - 1 : 0];
1801
1801
  if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
1802
1802
  return i;
1803
1803
  }
@@ -1807,7 +1807,7 @@ const ot = class ot extends c.Group {
1807
1807
  const e = this.getAutoTurnPaper(t);
1808
1808
  if (e === null) return 0;
1809
1809
  let s = 1;
1810
- return t === yt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1810
+ return t === wt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1811
1811
  }
1812
1812
  canAutoTurn(t) {
1813
1813
  return this.getAutoTurnPaper(t) !== null;
@@ -1842,46 +1842,46 @@ const ot = class ot extends c.Group {
1842
1842
  // ── Build ─────────────────────────────────────────────────────────────
1843
1843
  build() {
1844
1844
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1845
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new me()), this.m_RendererFactory === null) {
1846
- const C = new c.Object3D();
1847
- C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new ue(this.m_Root);
1845
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new ue()), this.m_RendererFactory === null) {
1846
+ const y = new c.Object3D();
1847
+ y.name = "Root", this.add(y), this.m_Root = y, this.m_RendererFactory = new de(this.m_Root);
1848
1848
  }
1849
1849
  this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
1850
1850
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1851
1851
  this.m_Root.rotation.set(0, t, 0), this.m_CoverPaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.height < this.m_CoverPaperSetup.height ? (this.m_CoverPaperSetup.margin = 0, this.m_PagePaperSetup.margin = (this.m_CoverPaperSetup.height - this.m_PagePaperSetup.height) / 2) : (this.m_CoverPaperSetup.margin = (this.m_PagePaperSetup.height - this.m_CoverPaperSetup.height) / 2, this.m_PagePaperSetup.margin = 0);
1852
- const e = new Dt(this.m_CoverPaperSetup), s = new Dt(this.m_PagePaperSetup);
1852
+ const e = new At(this.m_CoverPaperSetup), s = new At(this.m_PagePaperSetup);
1853
1853
  this.m_Content.init(this);
1854
1854
  let i = this.m_Content.coverContents, n = this.m_Content.pageContents, o = this.m_InitialOpenProgress;
1855
1855
  this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), o = 1 - o), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1856
1856
  const a = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
1857
- let m = 0, l = 0, _ = 0;
1857
+ let m = 0, l = 0, d = 0;
1858
1858
  this.m_Papers = new Array(a);
1859
- for (let C = 0; C < a; C++) {
1860
- const V = this.m_HasCover && (C < h || C >= a - h), U = this.m_RendererFactory.get("Paper"), k = this.m_Papers[C] = new he(V, C, this, U);
1861
- k.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (k.transform.scale.set(-1, 1, 1), k.setTime(1)), V ? (k.setContentData(i[l++], i[l++], C > h), k.setMaterialData(e), k.setPaperSetup(this.m_CoverPaperSetup)) : (k.setContentData(n[m++], n[m++]), k.setMaterialData(s), k.setPaperSetup(this.m_PagePaperSetup)), _ += k.thickness;
1859
+ for (let y = 0; y < a; y++) {
1860
+ const I = this.m_HasCover && (y < h || y >= a - h), N = this.m_RendererFactory.get("Paper"), v = this.m_Papers[y] = new le(I, y, this, N);
1861
+ v.renderer.castShadows = this.m_CastShadows, y < Math.round(c.MathUtils.lerp(0, a, o)) && (v.transform.scale.set(-1, 1, 1), v.setTime(1)), I ? (v.setContentData(i[l++], i[l++], y > h), v.setMaterialData(e), v.setPaperSetup(this.m_CoverPaperSetup)) : (v.setContentData(n[m++], n[m++]), v.setMaterialData(s), v.setPaperSetup(this.m_PagePaperSetup)), d += v.thickness;
1862
1862
  }
1863
- this.m_TotalThickness = _;
1864
- const p = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
1865
- this.m_MinPaperThickness = Math.min(p, d), this.m_MaxPaperThickness = Math.max(p, d);
1863
+ this.m_TotalThickness = d;
1864
+ const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(a / 2)].thickness;
1865
+ this.m_MinPaperThickness = Math.min(g, _), this.m_MaxPaperThickness = Math.max(g, _);
1866
1866
  const u = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(a / 2)].size.x;
1867
1867
  this.m_MinPaperWidth = Math.min(u, f);
1868
- const g = this.m_Papers[0].size.y, w = this.m_Papers[Math.floor(a / 2)].size.y;
1869
- this.m_MinPaperHeight = Math.min(g, w), this.m_Bound = this.m_Binding.createBound(
1868
+ const p = this.m_Papers[0].size.y, P = this.m_Papers[Math.floor(a / 2)].size.y;
1869
+ this.m_MinPaperHeight = Math.min(p, P), this.m_Bound = this.m_Binding.createBound(
1870
1870
  this,
1871
1871
  this.m_Root,
1872
1872
  this.m_RendererFactory,
1873
1873
  this.m_MeshFactory
1874
1874
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1875
- const B = this.m_ReduceOverdraw && n.length > 0, x = this.m_ReduceSubMeshes, y = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, v = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, N = z + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
- for (let C = 0; C < a; C++) {
1877
- const V = this.m_Papers[C];
1878
- C !== 0 && (V.prev = this.m_Papers[C - 1]), C !== a - 1 && (V.next = this.m_Papers[C + 1]), V.noHole = D && (C === z || C === N), V.isCover ? V.setMeshData(Z.get(), null, O) : V.setMeshData(
1879
- y.get(),
1875
+ const B = this.m_ReduceOverdraw && n.length > 0, x = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), V = Math.floor(a / 2) - 1, L = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
+ for (let y = 0; y < a; y++) {
1877
+ const I = this.m_Papers[y];
1878
+ y !== 0 && (I.prev = this.m_Papers[y - 1]), y !== a - 1 && (I.next = this.m_Papers[y + 1]), I.noHole = D && (y === V || y === L), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
1879
+ w.get(),
1880
1880
  (S == null ? void 0 : S.get()) ?? null,
1881
- v
1881
+ k
1882
1882
  );
1883
1883
  }
1884
- this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this.update(0), this.m_Bound.binderRenderer.updateCollider(), this.m_CoverPaperSetup.bookDirection = E.LeftToRight, this.m_PagePaperSetup.bookDirection = E.LeftToRight;
1884
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this.update(0), this.m_Bound.binderRenderer.updateCollider(), this.m_CoverPaperSetup.bookDirection = X.LeftToRight, this.m_PagePaperSetup.bookDirection = X.LeftToRight;
1885
1885
  }
1886
1886
  clear() {
1887
1887
  return this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_MeshFactory !== null && this.m_MeshFactory.recycle(), this.m_RendererFactory !== null && this.m_RendererFactory.recycle(), this;
@@ -1898,7 +1898,7 @@ const ot = class ot extends c.Group {
1898
1898
  i,
1899
1899
  s
1900
1900
  );
1901
- return new fe(
1901
+ return new ge(
1902
1902
  this.m_MeshFactory,
1903
1903
  o,
1904
1904
  e && this.m_Bound.useSharedMeshDataForLowpoly
@@ -1953,13 +1953,13 @@ const ot = class ot extends c.Group {
1953
1953
  }
1954
1954
  };
1955
1955
  ot.s_Instances = /* @__PURE__ */ new Set();
1956
- let Ut = ot;
1957
- class ye {
1956
+ let Ct = ot;
1957
+ class Ce {
1958
1958
  constructor() {
1959
1959
  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;
1960
1960
  }
1961
1961
  }
1962
- class Ne {
1962
+ class Xe {
1963
1963
  constructor() {
1964
1964
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
1965
1965
  }
@@ -1994,7 +1994,7 @@ class Ne {
1994
1994
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
1995
1995
  }
1996
1996
  }
1997
- class Lt {
1997
+ class Ut {
1998
1998
  constructor(t, e) {
1999
1999
  this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2000
2000
  }
@@ -2012,9 +2012,9 @@ class Lt {
2012
2012
  setActive(t) {
2013
2013
  }
2014
2014
  }
2015
- class Ue {
2015
+ class je {
2016
2016
  constructor() {
2017
- this.m_Direction = E.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
2017
+ this.m_Direction = X.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
2018
2018
  }
2019
2019
  get coverCount4() {
2020
2020
  return this.nextMultipleOf4(this.m_Covers.length);
@@ -2061,11 +2061,11 @@ class Ue {
2061
2061
  getContent(t) {
2062
2062
  if (t !== null) {
2063
2063
  if (t instanceof c.Texture)
2064
- return new Lt(t);
2064
+ return new Ut(t);
2065
2065
  if (typeof t.init == "function")
2066
2066
  return t;
2067
2067
  }
2068
- return new Lt(null);
2068
+ return new Ut(null);
2069
2069
  }
2070
2070
  init(t) {
2071
2071
  this.m_Book = t;
@@ -2113,14 +2113,41 @@ class Ue {
2113
2113
  return !this.isCoverPaperSideIndex(t);
2114
2114
  }
2115
2115
  }
2116
+ class Ge {
2117
+ constructor(t, e) {
2118
+ 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) => {
2119
+ var n;
2120
+ if (!this.enabled || s.button !== 0) return;
2121
+ this.m_IsPointerDown = !0;
2122
+ const i = this.m_GetRay(s);
2123
+ for (const o of Ct.instances)
2124
+ if (o.startTurning(i)) {
2125
+ this.m_SelectedBook = o, (n = this.onTurnStart) == null || n.call(this, o);
2126
+ break;
2127
+ }
2128
+ }, this.m_OnPointerMove = (s) => {
2129
+ !this.m_IsPointerDown || !this.m_SelectedBook || this.m_SelectedBook.updateTurning(this.m_GetRay(s));
2130
+ }, this.m_OnPointerUp = () => {
2131
+ var s;
2132
+ this.m_IsPointerDown = !1, this.m_SelectedBook && (this.m_SelectedBook.stopTurning(), (s = this.onTurnEnd) == null || s.call(this, this.m_SelectedBook), this.m_SelectedBook = null);
2133
+ }, this.m_Camera = t, this.m_DomElement = e, e.addEventListener("pointerdown", this.m_OnPointerDown), e.addEventListener("pointermove", this.m_OnPointerMove), e.addEventListener("pointerup", this.m_OnPointerUp);
2134
+ }
2135
+ dispose() {
2136
+ this.m_DomElement.removeEventListener("pointerdown", this.m_OnPointerDown), this.m_DomElement.removeEventListener("pointermove", this.m_OnPointerMove), this.m_DomElement.removeEventListener("pointerup", this.m_OnPointerUp), this.m_SelectedBook = null, this.m_IsPointerDown = !1;
2137
+ }
2138
+ m_GetRay(t) {
2139
+ const e = this.m_DomElement.getBoundingClientRect();
2140
+ 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;
2141
+ }
2142
+ }
2116
2143
  class Pe {
2117
2144
  }
2118
- class Le {
2145
+ class We {
2119
2146
  constructor(t, e) {
2120
2147
  this.m_Book = t, this.m_Root = e;
2121
2148
  }
2122
2149
  }
2123
- function Xt(r, t, e, s) {
2150
+ function Et(r, t, e, s) {
2124
2151
  const i = 1 - s;
2125
2152
  return new c.Vector3(
2126
2153
  i * i * r.x + 2 * i * s * t.x + s * s * e.x,
@@ -2128,26 +2155,26 @@ function Xt(r, t, e, s) {
2128
2155
  i * i * r.z + 2 * i * s * t.z + s * s * e.z
2129
2156
  );
2130
2157
  }
2131
- function Et(r, t) {
2158
+ function Xt(r, t) {
2132
2159
  return r++, r === t ? 0 : r;
2133
2160
  }
2134
- function we(r, t) {
2161
+ function Te(r, t) {
2135
2162
  return r === 0 ? t - 1 : r - 1;
2136
2163
  }
2137
- const Te = 0.01, Se = 0.1, ke = 0.04, ve = 0.4, be = 2, Be = 10, Re = 0, Ve = 5;
2164
+ const Se = 0.01, ve = 0.1, ke = 0.04, be = 0.4, Be = 2, Re = 10, Ie = 0, ze = 5;
2138
2165
  function et(r, t, e) {
2139
2166
  return Math.max(t, Math.min(e, r));
2140
2167
  }
2141
- function Kt(r) {
2168
+ function Jt(r) {
2142
2169
  return Math.max(0, Math.min(1, r));
2143
2170
  }
2144
2171
  function F(r, t, e) {
2145
2172
  return r + (t - r) * e;
2146
2173
  }
2147
2174
  function jt(r, t, e) {
2148
- return r === t ? 0 : Kt((e - r) / (t - r));
2175
+ return r === t ? 0 : Jt((e - r) / (t - r));
2149
2176
  }
2150
- function Ie(r, t) {
2177
+ function Ve(r, t) {
2151
2178
  const e = r.clone().normalize();
2152
2179
  if (e.lengthSq() === 0) return new c.Quaternion();
2153
2180
  let s = new c.Vector3().crossVectors(t, e);
@@ -2160,7 +2187,7 @@ function Ie(r, t) {
2160
2187
  return new c.Quaternion().setFromRotationMatrix(n);
2161
2188
  }
2162
2189
  const tt = Math.PI / 180, it = 180 / Math.PI;
2163
- class ze {
2190
+ class De {
2164
2191
  constructor() {
2165
2192
  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;
2166
2193
  }
@@ -2180,43 +2207,43 @@ class ze {
2180
2207
  return this._thickness;
2181
2208
  }
2182
2209
  set thickness(t) {
2183
- this._thickness = et(t, Te, Se);
2210
+ this._thickness = et(t, Se, ve);
2184
2211
  }
2185
2212
  get margin() {
2186
2213
  return this._margin;
2187
2214
  }
2188
2215
  set margin(t) {
2189
- this._margin = Kt(t);
2216
+ this._margin = Jt(t);
2190
2217
  }
2191
2218
  get crown() {
2192
2219
  return this._crown;
2193
2220
  }
2194
2221
  set crown(t) {
2195
- this._crown = et(t, ke, ve);
2222
+ this._crown = et(t, ke, be);
2196
2223
  }
2197
2224
  get count() {
2198
2225
  return this._count;
2199
2226
  }
2200
2227
  set count(t) {
2201
- this._count = et(t, be, Be);
2228
+ this._count = et(t, Be, Re);
2202
2229
  }
2203
2230
  get quality() {
2204
2231
  return this._quality;
2205
2232
  }
2206
2233
  set quality(t) {
2207
- this._quality = et(t, Re, Ve);
2234
+ this._quality = et(t, Ie, ze);
2208
2235
  }
2209
2236
  }
2210
- class De extends Error {
2237
+ class Ae extends Error {
2211
2238
  constructor() {
2212
2239
  super("Book height is too large relative to paper width."), this.name = "BookHeightException";
2213
2240
  }
2214
2241
  }
2215
- class Ae {
2242
+ class He {
2216
2243
  // ── Constructor ────────────────────────────────────────────────────────
2217
2244
  constructor(t, e, s, i, n) {
2218
2245
  if (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_Book = s, this.m_Root = i, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
2219
- throw new De();
2246
+ throw new Ae();
2220
2247
  const o = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
2221
2248
  this.updateStapleMesh(e, h);
2222
2249
  const m = n ?? new c.MeshStandardMaterial({
@@ -2231,14 +2258,14 @@ class Ae {
2231
2258
  );
2232
2259
  let l = o.thickness;
2233
2260
  l = Math.max(this.m_BindingRadius, l);
2234
- for (const _ of this.m_Book.papers) {
2235
- const p = _.size.clone();
2236
- p.x -= this.m_BindingRadius, _.sizeXOffset = this.m_BindingRadius, _.size = p, _.setMinTurningRadius(l), _.updateTurningRadius(), this.updatePaperPosition(_);
2261
+ for (const d of this.m_Book.papers) {
2262
+ const g = d.size.clone();
2263
+ g.x -= this.m_BindingRadius, d.sizeXOffset = this.m_BindingRadius, d.size = g, d.setMinTurningRadius(l), d.updateTurningRadius(), this.updatePaperPosition(d);
2237
2264
  }
2238
2265
  this.updateRootPosition();
2239
2266
  }
2240
2267
  get binderRenderer() {
2241
- return this._binderRendererAdapter || (this._binderRendererAdapter = new He(this.stapleMesh)), this._binderRendererAdapter;
2268
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new Fe(this.stapleMesh)), this._binderRendererAdapter;
2242
2269
  }
2243
2270
  // ── updateStapleMesh ──────────────────────────────────────────────────
2244
2271
  updateStapleMesh(t, e) {
@@ -2254,83 +2281,83 @@ class Ae {
2254
2281
  let a = t.count, h = (o - s * a) / (a - 1);
2255
2282
  for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && a > 2; )
2256
2283
  a--, h = (o - s * a) / (a - 1), h = Math.max(h, 0);
2257
- const m = t.quality / 5, l = Math.floor(F(4, 20, m)), _ = Math.floor(F(4, 10, m)), p = Math.floor(F(3, 10, m)), d = this.m_StapleThickness / 2, u = d * 2.5, f = 0.9, g = d * 1;
2258
- let w = s / 2 * f;
2259
- w = Math.max(w, g * 2);
2284
+ const m = t.quality / 5, l = Math.floor(F(4, 20, m)), d = Math.floor(F(4, 10, m)), g = Math.floor(F(3, 10, m)), _ = this.m_StapleThickness / 2, u = _ * 2.5, f = 0.9, p = _ * 1;
2285
+ let P = s / 2 * f;
2286
+ P = Math.max(P, p * 2);
2260
2287
  let B = 0;
2261
- B += this.m_Book.totalThickness / 2, B += d;
2262
- const x = -(this.m_Book.papers[0].thickness / 2 + d), y = [];
2288
+ B += this.m_Book.totalThickness / 2, B += _;
2289
+ const x = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
2263
2290
  {
2264
- for (let I = 0; I < _; I++) {
2265
- const X = I / (_ - 1), W = F(-90, -180, X) * tt, P = new c.Vector3(
2266
- g * Math.sin(W),
2291
+ for (let z = 0; z < d; z++) {
2292
+ const E = z / (d - 1), q = F(-90, -180, E) * tt, C = new c.Vector3(
2293
+ p * Math.sin(q),
2267
2294
  0,
2268
- g * Math.cos(W)
2295
+ p * Math.cos(q)
2269
2296
  );
2270
- P.x += g, P.z += g, P.x += x, y.push(P);
2297
+ C.x += p, C.z += p, C.x += x, w.push(C);
2271
2298
  }
2272
- const M = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - d * 0.5, 0, w);
2273
- for (let I = 0; I < p; I++) {
2274
- const X = I / (p - 1), q = Xt(M, H, T, X);
2275
- q.x += x, y.push(q);
2299
+ const M = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - _ * 0.5, 0, P);
2300
+ for (let z = 0; z < g; z++) {
2301
+ const E = z / (g - 1), W = Et(M, H, T, E);
2302
+ W.x += x, w.push(W);
2276
2303
  }
2277
- y.reverse();
2304
+ w.reverse();
2278
2305
  }
2279
2306
  const S = new Array(l);
2280
2307
  for (let M = 0; M < l; M++) {
2281
2308
  const T = (90 - M * (360 / l)) * tt;
2282
2309
  S[M] = new c.Vector3(Math.cos(T), Math.sin(T), 0), S[M].x *= 0.75;
2283
2310
  }
2284
- const v = y.length, Z = v * l, O = new Array(Z * 2), z = new Array(Z * 2), N = new Array(
2285
- (Z * 2 - 1) * l * 2 * 3
2311
+ const k = w.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), L = new Array(
2312
+ (O * 2 - 1) * l * 2 * 3
2286
2313
  );
2287
- for (let M = 0; M < Z * 2; M++)
2288
- O[M] = new c.Vector3(), z[M] = new c.Vector3();
2314
+ for (let M = 0; M < O * 2; M++)
2315
+ Z[M] = new c.Vector3(), V[M] = new c.Vector3();
2289
2316
  let D = 0;
2290
- for (let M = 0; M < v; M++) {
2291
- const H = y[we(M, v)], T = y[M], I = y[Et(M, v)];
2292
- let X;
2317
+ for (let M = 0; M < k; M++) {
2318
+ const H = w[Te(M, k)], T = w[M], z = w[Xt(M, k)];
2319
+ let E;
2293
2320
  if (M === 0)
2294
- X = new c.Vector3(1, 0, -2).normalize();
2295
- else if (M === v - 1)
2296
- X = new c.Vector3(0, 0, 1);
2321
+ E = new c.Vector3(1, 0, -2).normalize();
2322
+ else if (M === k - 1)
2323
+ E = new c.Vector3(0, 0, 1);
2297
2324
  else {
2298
- const K = T.clone().sub(H).normalize(), J = I.clone().sub(T).normalize();
2299
- X = K.add(J).multiplyScalar(0.5);
2325
+ const K = T.clone().sub(H).normalize(), J = z.clone().sub(T).normalize();
2326
+ E = K.add(J).multiplyScalar(0.5);
2300
2327
  }
2301
- const q = new c.Vector3(0, 1, 0), W = Ie(X, q), P = D;
2302
- let b = jt(0, p / 4, M);
2328
+ const W = new c.Vector3(0, 1, 0), q = Ve(E, W), C = D;
2329
+ let b = jt(0, g / 4, M);
2303
2330
  b = F(0.1, 1, b), b = Math.sqrt(b);
2304
2331
  for (let K = 0; K < l; K++) {
2305
- const J = S[K].clone().applyQuaternion(W).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(d));
2306
- O[D] = ct, z[D] = J.clone();
2307
- const at = T.clone().add(J.clone().multiplyScalar(d));
2332
+ const J = S[K].clone().applyQuaternion(q).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(_));
2333
+ Z[D] = ct, V[D] = J.clone();
2334
+ const at = T.clone().add(J.clone().multiplyScalar(_));
2308
2335
  at.z = s - at.z;
2309
- const Jt = P + l - K - 1, Tt = Z * 2 - Jt - 1;
2310
- O[Tt] = at, z[Tt] = J.clone(), D++;
2336
+ const te = C + l - K - 1, St = O * 2 - te - 1;
2337
+ Z[St] = at, V[St] = J.clone(), D++;
2311
2338
  }
2312
2339
  }
2313
- let C = 0;
2314
- const V = y.length * 2;
2315
- for (let M = 0; M < V - 1; M++) {
2340
+ let y = 0;
2341
+ const I = w.length * 2;
2342
+ for (let M = 0; M < I - 1; M++) {
2316
2343
  const H = M * l, T = (M + 1) * l;
2317
- for (let I = 0; I < l; I++) {
2318
- const X = Et(I, l), q = H + I, W = H + X, P = T + X, b = T + I;
2319
- N[C++] = q, N[C++] = b, N[C++] = W, N[C++] = W, N[C++] = b, N[C++] = P;
2344
+ for (let z = 0; z < l; z++) {
2345
+ const E = Xt(z, l), W = H + z, q = H + E, C = T + E, b = T + z;
2346
+ L[y++] = W, L[y++] = b, L[y++] = q, L[y++] = q, L[y++] = b, L[y++] = C;
2320
2347
  }
2321
2348
  }
2322
- const U = [...O], k = [...z], Q = [...N], G = O.map((M) => M.clone()), $ = [...N];
2349
+ const N = [...Z], v = [...V], Q = [...L], G = Z.map((M) => M.clone()), $ = [...L];
2323
2350
  for (let M = 0; M < a - 1; M++) {
2324
2351
  const H = G.length;
2325
2352
  for (let T = 0; T < $.length; T++)
2326
2353
  $[T] += H;
2327
2354
  for (let T = 0; T < G.length; T++)
2328
2355
  G[T].z += h + s;
2329
- U.push(...G.map((T) => T.clone())), k.push(...z.map((T) => T.clone())), Q.push(...$);
2356
+ N.push(...G.map((T) => T.clone())), v.push(...V.map((T) => T.clone())), Q.push(...$);
2330
2357
  }
2331
- const j = new Float32Array(U.length * 3), A = new Float32Array(k.length * 3);
2332
- for (let M = 0; M < U.length; M++)
2333
- j[M * 3] = U[M].x, j[M * 3 + 1] = U[M].y, j[M * 3 + 2] = U[M].z, A[M * 3] = k[M].x, A[M * 3 + 1] = k[M].y, A[M * 3 + 2] = k[M].z;
2358
+ const j = new Float32Array(N.length * 3), A = new Float32Array(v.length * 3);
2359
+ for (let M = 0; M < N.length; M++)
2360
+ j[M * 3] = N[M].x, j[M * 3 + 1] = N[M].y, j[M * 3 + 2] = N[M].z, A[M * 3] = v[M].x, A[M * 3 + 1] = v[M].y, A[M * 3 + 2] = v[M].z;
2334
2361
  e.setAttribute(
2335
2362
  "position",
2336
2363
  new c.BufferAttribute(j, 3)
@@ -2341,68 +2368,68 @@ class Ae {
2341
2368
  }
2342
2369
  // ── createPaperPattern ────────────────────────────────────────────────
2343
2370
  createPaperPattern(t, e, s, i, n, o) {
2344
- const a = new ye();
2371
+ const a = new Ce();
2345
2372
  a.size = e, a.thickness = s;
2346
2373
  const h = this.m_BindingRadius;
2347
2374
  a.baseXOffset = -h;
2348
2375
  const m = this.m_Quality + 1;
2349
2376
  this.m_BindingVertexCount = m;
2350
- const l = t / 5, _ = Math.min(e.x, e.y) / 60, p = Math.floor(
2351
- F(0, (e.x - h) / _, l)
2352
- ), d = Math.floor(F(0, e.y / _, l));
2353
- let u = 2 + p + 1 + m, f = 2 + d;
2354
- const g = new st(0);
2355
- let w = g;
2377
+ const l = t / 5, d = Math.min(e.x, e.y) / 60, g = Math.floor(
2378
+ F(0, (e.x - h) / d, l)
2379
+ ), _ = Math.floor(F(0, e.y / d, l));
2380
+ let u = 2 + g + 1 + m, f = 2 + _;
2381
+ const p = new st(0);
2382
+ let P = p;
2356
2383
  const B = h / m;
2357
2384
  let x = 0;
2358
- for (let P = 1; P < m + 1; P++)
2359
- w = w.createNext(x), x += B;
2360
- const y = (e.x - h) / (p + 1);
2361
- for (let P = m + 1; P < u; P++)
2362
- w = w.createNext(x), x += y;
2385
+ for (let C = 1; C < m + 1; C++)
2386
+ P = P.createNext(x), x += B;
2387
+ const w = (e.x - h) / (g + 1);
2388
+ for (let C = m + 1; C < u; C++)
2389
+ P = P.createNext(x), x += w;
2363
2390
  const S = new st(0);
2364
- let v = S;
2365
- const Z = e.y / (f - 1);
2366
- let O = 0;
2367
- for (let P = 0; P < f - 1; P++)
2368
- O += Z, v = v.createNext(O);
2369
- const z = [], N = [], D = i.clone();
2391
+ let k = S;
2392
+ const O = e.y / (f - 1);
2393
+ let Z = 0;
2394
+ for (let C = 0; C < f - 1; C++)
2395
+ Z += O, k = k.createNext(Z);
2396
+ const V = [], L = [], D = i.clone();
2370
2397
  if (n) {
2371
- let P = 0;
2372
- this.m_Book.hasCover && (P = Math.floor(this.m_Book.coverPaperCount / 2));
2398
+ let C = 0;
2399
+ this.m_Book.hasCover && (C = Math.floor(this.m_Book.coverPaperCount / 2));
2373
2400
  const b = Math.max(0.01, s);
2374
- D.left = 0, D.right = (this.getPX(P + 1, s) - this.getPX(P, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
2375
- }
2376
- const C = new le(a, D, !1);
2377
- C.insert(g, S, z, N), g.updateIndex(0), S.updateIndex(0), Mt(z, a.xSeams), Mt(N, a.zSeams);
2378
- const V = this.m_BindingVertexCount + 2, U = new Array(V);
2379
- a.xNoneSeamIndexes = U, w = g;
2380
- for (let P = 0; P < V; P++) {
2381
- U[P] = w.index;
2401
+ D.left = 0, D.right = (this.getPX(C + 1, s) - this.getPX(C, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
2402
+ }
2403
+ const y = new ce(a, D, !1);
2404
+ y.insert(p, S, V, L), p.updateIndex(0), S.updateIndex(0), Mt(V, a.xSeams), Mt(L, a.zSeams);
2405
+ const I = this.m_BindingVertexCount + 2, N = new Array(I);
2406
+ a.xNoneSeamIndexes = N, P = p;
2407
+ for (let C = 0; C < I; C++) {
2408
+ N[C] = P.index;
2382
2409
  do
2383
- w = w.next;
2384
- while (w.seam);
2410
+ P = P.next;
2411
+ while (P.seam);
2385
2412
  }
2386
- const k = g.getValues(), Q = S.getValues();
2387
- u = k.length, f = Q.length;
2413
+ const v = p.getValues(), Q = S.getValues();
2414
+ u = v.length, f = Q.length;
2388
2415
  const G = u * f, $ = [], j = new Array(G).fill(0), A = [], M = [], H = [], T = [];
2389
- $t(
2416
+ Yt(
2390
2417
  $,
2391
- k,
2418
+ v,
2392
2419
  Q,
2393
2420
  e,
2394
2421
  i,
2395
2422
  this.m_Book.direction
2396
2423
  );
2397
- const I = C.leftNode.index, X = C.downNode.index;
2398
- let q = C.rightNode.index, W = C.upNode.index;
2399
- q === 0 && (q = u - 1), W === 0 && (W = f - 1);
2400
- for (let P = 0; P < f - 1; P++)
2424
+ const z = y.leftNode.index, E = y.downNode.index;
2425
+ let W = y.rightNode.index, q = y.upNode.index;
2426
+ W === 0 && (W = u - 1), q === 0 && (q = f - 1);
2427
+ for (let C = 0; C < f - 1; C++)
2401
2428
  for (let b = 0; b < u - 1; b++) {
2402
- if (n && P >= X && P < W && b >= I && b < q)
2429
+ if (n && C >= E && C < q && b >= z && b < W)
2403
2430
  continue;
2404
- const K = P * u + b, J = P * u + (b + 1), ct = (P + 1) * u + b, at = (P + 1) * u + (b + 1);
2405
- j[K] += 2, j[J] += 2, j[ct] += 2, j[at] += 2, Qt(
2431
+ const K = C * u + b, J = C * u + (b + 1), ct = (C + 1) * u + b, at = (C + 1) * u + (b + 1);
2432
+ j[K] += 2, j[J] += 2, j[ct] += 2, j[at] += 2, $t(
2406
2433
  A,
2407
2434
  M,
2408
2435
  K,
@@ -2412,10 +2439,10 @@ class Ae {
2412
2439
  G
2413
2440
  );
2414
2441
  }
2415
- if (T.push(new wt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = k, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2442
+ if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = v, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2416
2443
  a.subMeshCount = 1;
2417
- const P = [];
2418
- P.push(...A), P.push(...H), P.push(...M), a.triangles = P;
2444
+ const C = [];
2445
+ C.push(...A), C.push(...H), C.push(...M), a.triangles = C;
2419
2446
  } else
2420
2447
  a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = M, a.borderTriangles = H;
2421
2448
  return a.borders = T, a;
@@ -2432,40 +2459,40 @@ class Ae {
2432
2459
  let i = 0;
2433
2460
  const n = e.length / 2 - 1, o = e.length / 2;
2434
2461
  for (let x = 0; x < s; x++) {
2435
- const y = e[x];
2436
- y.updateTime();
2437
- const S = y.zTime, v = y.thickness;
2438
- i += S * v, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2462
+ const w = e[x];
2463
+ w.updateTime();
2464
+ const S = w.zTime, k = w.thickness;
2465
+ i += S * k, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2439
2466
  }
2440
2467
  let a = this.getStackHeight(t.index) - t.thickness / 2;
2441
2468
  const h = this.getStackZ(a), m = 180 + h;
2442
- let l = t.isFlipped ? 1 : 0, _ = F(h, m, l);
2443
- const p = _ * tt, d = new c.Vector3(
2444
- Math.cos(p) * this.m_BindingRadius,
2445
- Math.sin(p) * this.m_BindingRadius,
2469
+ let l = t.isFlipped ? 1 : 0, d = F(h, m, l);
2470
+ const g = d * tt, _ = new c.Vector3(
2471
+ Math.cos(g) * this.m_BindingRadius,
2472
+ Math.sin(g) * this.m_BindingRadius,
2446
2473
  0
2447
2474
  );
2448
- d.z = t.margin;
2449
- let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, g = Math.sqrt(u * u - f * f), w = Math.asin(g / u) * it - 90;
2475
+ _.z = t.margin;
2476
+ let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
2450
2477
  if (t.index < Math.floor(s / 2)) {
2451
2478
  let x = 0;
2452
2479
  if (this.m_Book.alignToGround) {
2453
2480
  u = e[0].size.x;
2454
- const y = this.m_StackHeight / 2;
2455
- f = et(i, 0, y) - y, g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2481
+ const w = this.m_StackHeight / 2;
2482
+ f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2456
2483
  }
2457
- _ = F(w, -x, l);
2484
+ d = F(P, -x, l);
2458
2485
  } else {
2459
2486
  let x = 0;
2460
2487
  if (this.m_Book.alignToGround) {
2461
2488
  u = e[0].size.x;
2462
- const y = this.m_StackHeight / 2;
2463
- f = y - et(i, y, y * 2), g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2489
+ const w = this.m_StackHeight / 2;
2490
+ f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2464
2491
  }
2465
- _ = F(x, -w, l);
2492
+ d = F(x, -P, l);
2466
2493
  }
2467
- t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2468
- new c.Euler(0, 0, _ * tt)
2494
+ t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2495
+ new c.Euler(0, 0, d * tt)
2469
2496
  );
2470
2497
  }
2471
2498
  // ── getPX (private helper) ───────────────────────────────────────────
@@ -2475,10 +2502,10 @@ class Ae {
2475
2502
  const o = s.length / 2 - 1, a = s.length / 2;
2476
2503
  for (let f = 0; f < i; f++)
2477
2504
  n += 0 * e, f === o && (n += 0 * this.m_BindingMidSpace / 2), f === a && (n += 0 * this.m_BindingMidSpace / 2);
2478
- const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, d = F(m, l, 0) * tt;
2505
+ const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, _ = F(m, l, 0) * tt;
2479
2506
  return new c.Vector3(
2480
- Math.cos(d) * this.m_BindingRadius,
2481
- Math.sin(d) * this.m_BindingRadius,
2507
+ Math.cos(_) * this.m_BindingRadius,
2508
+ Math.sin(_) * this.m_BindingRadius,
2482
2509
  0
2483
2510
  ).x;
2484
2511
  }
@@ -2488,39 +2515,39 @@ class Ae {
2488
2515
  let i = 0;
2489
2516
  const n = e.length / 2 - 1, o = e.length / 2;
2490
2517
  for (let x = 0; x < s; x++) {
2491
- const y = e[x];
2492
- y.updateTime();
2493
- const S = y.zTime, v = y.thickness;
2494
- i += S * v, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2518
+ const w = e[x];
2519
+ w.updateTime();
2520
+ const S = w.zTime, k = w.thickness;
2521
+ i += S * k, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2495
2522
  }
2496
2523
  const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
2497
- let l = t.zTime, _ = F(h, m, l);
2498
- const p = _ * tt, d = new c.Vector3(
2499
- Math.cos(p) * this.m_BindingRadius,
2500
- Math.sin(p) * this.m_BindingRadius,
2524
+ let l = t.zTime, d = F(h, m, l);
2525
+ const g = d * tt, _ = new c.Vector3(
2526
+ Math.cos(g) * this.m_BindingRadius,
2527
+ Math.sin(g) * this.m_BindingRadius,
2501
2528
  0
2502
2529
  );
2503
- d.z = t.margin;
2504
- let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, g = Math.sqrt(u * u - f * f), w = Math.asin(g / u) * it - 90;
2530
+ _.z = t.margin;
2531
+ let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
2505
2532
  if (t.index < Math.floor(s / 2)) {
2506
2533
  let x = 0;
2507
2534
  if (this.m_Book.alignToGround) {
2508
2535
  u = e[0].size.x;
2509
- const y = this.m_StackHeight / 2;
2510
- f = et(i, 0, y) - y, g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2536
+ const w = this.m_StackHeight / 2;
2537
+ f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2511
2538
  }
2512
- _ = F(w, -x, l);
2539
+ d = F(P, -x, l);
2513
2540
  } else {
2514
2541
  let x = 0;
2515
2542
  if (this.m_Book.alignToGround) {
2516
2543
  u = e[0].size.x;
2517
- const y = this.m_StackHeight / 2;
2518
- f = y - et(i, y, y * 2), g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2544
+ const w = this.m_StackHeight / 2;
2545
+ f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2519
2546
  }
2520
- _ = F(x, -w, l);
2547
+ d = F(x, -P, l);
2521
2548
  }
2522
- t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2523
- new c.Euler(0, 0, _ * tt)
2549
+ t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2550
+ new c.Euler(0, 0, d * tt)
2524
2551
  );
2525
2552
  }
2526
2553
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2554,35 +2581,35 @@ class Ae {
2554
2581
  let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2555
2582
  const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
2556
2583
  for (let m = 0; m < h; m++) {
2557
- const l = t[m], _ = l.transform, p = l.meshData.pattern, d = l.meshData.baseVertices, u = p.baseXArray, f = p.baseZArray, g = u.length, w = f.length, B = this.m_BindingVertexCount + 1, x = l.thickness, y = p.xNoneSeamIndexes, S = _.position.clone();
2558
- let v = m, Z = n;
2559
- m >= Math.floor(h / 2) && (v = h - m - 1, Z *= -1);
2560
- const O = (o + x) * 0.5 + x * (v - 1), z = _.matrixWorld.clone().invert().multiply(a), N = v / (h / 2);
2561
- i = this.m_BindingRadius * F(0.45, 0.65, 1 - N);
2562
- for (let D = 0; D < w; D++) {
2563
- const C = f[D], V = new c.Vector3(0, 0, S.z + C), U = S.clone();
2564
- U.z += C;
2565
- const k = l.getDirection(C).multiplyScalar(i).add(U.clone());
2584
+ const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, x = l.thickness, w = g.xNoneSeamIndexes, S = d.position.clone();
2585
+ let k = m, O = n;
2586
+ m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
2587
+ const Z = (o + x) * 0.5 + x * (k - 1), V = d.matrixWorld.clone().invert().multiply(a), L = k / (h / 2);
2588
+ i = this.m_BindingRadius * F(0.45, 0.65, 1 - L);
2589
+ for (let D = 0; D < P; D++) {
2590
+ const y = f[D], I = new c.Vector3(0, 0, S.z + y), N = S.clone();
2591
+ N.z += y;
2592
+ const v = l.getDirection(y).multiplyScalar(i).add(N.clone());
2566
2593
  if (m === 0 && D === 0) {
2567
2594
  const A = t[h - 1], H = A.transform.position.clone().clone();
2568
- H.z += C;
2569
- const T = A.getDirection(C).multiplyScalar(i).add(H);
2570
- s = k.clone().sub(T).normalize(), e = new c.Vector3(
2595
+ H.z += y;
2596
+ const T = A.getDirection(y).multiplyScalar(i).add(H);
2597
+ s = v.clone().sub(T).normalize(), e = new c.Vector3(
2571
2598
  -s.y,
2572
2599
  s.x,
2573
2600
  0
2574
2601
  ).normalize().negate();
2575
- const I = Math.atan2(e.y, e.x) * it;
2576
- this.stapleMesh.rotation.set(0, 0, I * tt);
2602
+ const z = Math.atan2(e.y, e.x) * it;
2603
+ this.stapleMesh.rotation.set(0, 0, z * tt);
2577
2604
  }
2578
- v > 0 && V.add(e.clone().multiplyScalar(O));
2579
- const Q = D * g;
2580
- d[Q] = V.clone().applyMatrix4(z), V.add(s.clone().multiplyScalar(Z));
2581
- const G = V.clone().applyMatrix4(z), $ = k.clone().applyMatrix4(z), j = U.clone().applyMatrix4(z);
2582
- d[Q + y[1]] = G;
2605
+ k > 0 && I.add(e.clone().multiplyScalar(Z));
2606
+ const Q = D * p;
2607
+ _[Q] = I.clone().applyMatrix4(V), I.add(s.clone().multiplyScalar(O));
2608
+ const G = I.clone().applyMatrix4(V), $ = v.clone().applyMatrix4(V), j = N.clone().applyMatrix4(V);
2609
+ _[Q + w[1]] = G;
2583
2610
  for (let A = 2; A < B; A++) {
2584
2611
  const M = jt(1, B, A);
2585
- d[Q + y[A]] = Xt(
2612
+ _[Q + w[A]] = Et(
2586
2613
  G,
2587
2614
  $,
2588
2615
  j,
@@ -2615,7 +2642,7 @@ class Ae {
2615
2642
  return this.m_StapleThickness;
2616
2643
  }
2617
2644
  }
2618
- class He {
2645
+ class Fe {
2619
2646
  constructor(t) {
2620
2647
  this.mesh = t;
2621
2648
  }
@@ -2641,12 +2668,12 @@ class He {
2641
2668
  return this.mesh;
2642
2669
  }
2643
2670
  }
2644
- class Xe extends Pe {
2671
+ class qe extends Pe {
2645
2672
  constructor() {
2646
- super(...arguments), this.quality = 3, this.stapleSetup = new ze();
2673
+ super(...arguments), this.quality = 3, this.stapleSetup = new De();
2647
2674
  }
2648
2675
  createBound(t, e, s, i) {
2649
- return new Ae(
2676
+ return new He(
2650
2677
  this.quality,
2651
2678
  this.stapleSetup,
2652
2679
  t,
@@ -2654,39 +2681,227 @@ class Xe extends Pe {
2654
2681
  );
2655
2682
  }
2656
2683
  }
2684
+ class Oe {
2685
+ constructor(t) {
2686
+ 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;
2687
+ }
2688
+ _font() {
2689
+ return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px ${this.fontFamily}`;
2690
+ }
2691
+ /**
2692
+ * Word-wrap `text` into lines that fit within `width` pixels.
2693
+ * Respects explicit newlines.
2694
+ */
2695
+ wrapLines(t) {
2696
+ if (!this.text) return [];
2697
+ if (t.font = this._font(), this.width <= 0) return this.text.split(`
2698
+ `);
2699
+ const e = [];
2700
+ for (const s of this.text.split(`
2701
+ `)) {
2702
+ if (s === "") {
2703
+ e.push("");
2704
+ continue;
2705
+ }
2706
+ const i = s.split(/\s+/);
2707
+ let n = "";
2708
+ for (const o of i) {
2709
+ const a = n ? `${n} ${o}` : o;
2710
+ t.measureText(a).width > this.width && n ? (e.push(n), n = o) : n = a;
2711
+ }
2712
+ n && e.push(n);
2713
+ }
2714
+ return e;
2715
+ }
2716
+ /** Total rendered height in canvas pixels. */
2717
+ measureHeight(t) {
2718
+ return this.wrapLines(t).length * this.fontSize * this.lineHeight;
2719
+ }
2720
+ /** Returns true if the point (px, py) is within the text bounding box. */
2721
+ hitTest(t, e, s) {
2722
+ const i = this.wrapLines(t);
2723
+ if (i.length === 0) return !1;
2724
+ const n = i.length * this.fontSize * this.lineHeight, o = this.width > 0 ? this.width : this._maxLineWidth(t, i);
2725
+ return e >= this.x && e <= this.x + o && s >= this.y && s <= this.y + n;
2726
+ }
2727
+ _maxLineWidth(t, e) {
2728
+ t.font = this._font();
2729
+ let s = 0;
2730
+ for (const i of e) {
2731
+ const n = t.measureText(i).width;
2732
+ n > s && (s = n);
2733
+ }
2734
+ return s;
2735
+ }
2736
+ draw(t) {
2737
+ if (!this.text || this.opacity <= 0) return;
2738
+ const e = this.wrapLines(t);
2739
+ if (e.length === 0) return;
2740
+ t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top", this.shadowColor && this.shadowBlur > 0 && (t.shadowColor = this.shadowColor, t.shadowBlur = this.shadowBlur);
2741
+ const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
2742
+ for (let n = 0; n < e.length; n++) {
2743
+ let o = this.x;
2744
+ this.textAlign === "center" ? o = this.x + (i - t.measureText(e[n]).width) / 2 : this.textAlign === "right" && (o = this.x + i - t.measureText(e[n]).width), t.fillText(e[n], o, this.y + n * s);
2745
+ }
2746
+ t.restore();
2747
+ }
2748
+ }
2749
+ function Ze(r) {
2750
+ return r.map instanceof c.Texture;
2751
+ }
2752
+ class Qe {
2753
+ constructor(t) {
2754
+ this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
2755
+ const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
2756
+ this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
2757
+ const i = this.canvas.getContext("2d");
2758
+ if (!i) throw new Error("TextOverlayContent: could not get 2D context");
2759
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace;
2760
+ }
2761
+ get texture() {
2762
+ return this._texture;
2763
+ }
2764
+ get textureST() {
2765
+ return this._textureST;
2766
+ }
2767
+ /** The base layer drawn beneath text blocks. */
2768
+ get source() {
2769
+ return this._source;
2770
+ }
2771
+ set source(t) {
2772
+ this._source = t;
2773
+ }
2774
+ // ── Text API ─────────────────────────────────────────────────────────────
2775
+ addText(t) {
2776
+ const e = new Oe(t);
2777
+ return this.texts.push(e), e;
2778
+ }
2779
+ removeText(t) {
2780
+ const e = this.texts.indexOf(t);
2781
+ e !== -1 && this.texts.splice(e, 1);
2782
+ }
2783
+ /** Update a text block by index. Only provided fields are changed. */
2784
+ updateText(t, e) {
2785
+ const s = this.texts[t];
2786
+ s && (e.x !== void 0 && (s.x = e.x), e.y !== void 0 && (s.y = e.y), e.width !== void 0 && (s.width = e.width), e.text !== void 0 && (s.text = e.text), e.fontFamily !== void 0 && (s.fontFamily = e.fontFamily), e.fontSize !== void 0 && (s.fontSize = e.fontSize), e.fontWeight !== void 0 && (s.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (s.fontStyle = e.fontStyle), e.color !== void 0 && (s.color = e.color), e.lineHeight !== void 0 && (s.lineHeight = e.lineHeight), e.textAlign !== void 0 && (s.textAlign = e.textAlign), e.opacity !== void 0 && (s.opacity = e.opacity), e.shadowColor !== void 0 && (s.shadowColor = e.shadowColor), e.shadowBlur !== void 0 && (s.shadowBlur = e.shadowBlur));
2787
+ }
2788
+ // ── Per-frame update ─────────────────────────────────────────────────────
2789
+ /**
2790
+ * Re-composite the canvas: source layer + text blocks.
2791
+ * Call every frame (or when content changes).
2792
+ *
2793
+ * @param root Optional THREE.Object3D to traverse for texture sync
2794
+ * (same pattern as SpriteScene — needed because three-book
2795
+ * clones material textures).
2796
+ */
2797
+ update(t) {
2798
+ const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2799
+ e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2800
+ for (const o of this.texts) o.draw(e);
2801
+ this._texture.needsUpdate = !0, t && this.syncMaterials(t);
2802
+ }
2803
+ /**
2804
+ * Traverse `root` and set `needsUpdate = true` on every material map whose
2805
+ * source image is this overlay's canvas.
2806
+ */
2807
+ syncMaterials(t) {
2808
+ t.traverse((e) => {
2809
+ if (!e.isMesh) return;
2810
+ const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2811
+ for (const n of i)
2812
+ Ze(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
2813
+ });
2814
+ }
2815
+ // ── IPageContent ─────────────────────────────────────────────────────────
2816
+ isPointOverUI(t) {
2817
+ return !1;
2818
+ }
2819
+ init(t) {
2820
+ }
2821
+ setActive(t) {
2822
+ }
2823
+ dispose() {
2824
+ this._texture.dispose();
2825
+ }
2826
+ }
2827
+ const Gt = 256;
2828
+ function Le(r, t, e, s, i, n, o) {
2829
+ const a = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
2830
+ if (a <= 0 || h <= 0) return;
2831
+ if (o === "fill") {
2832
+ r.drawImage(t, e, s, i, n);
2833
+ return;
2834
+ }
2835
+ const m = o === "contain" ? Math.min(i / a, n / h) : Math.max(i / a, n / h), l = a * m, d = h * m;
2836
+ r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
2837
+ }
2838
+ function $e(r, t, e, s, i, n, o) {
2839
+ const a = n ? Math.round(n * Gt) : 512, h = o ? Math.round(o * Gt) : 512, m = document.createElement("canvas");
2840
+ m.width = a, m.height = h;
2841
+ const l = m.getContext("2d");
2842
+ if (l.fillStyle = r, l.fillRect(0, 0, a, h), e) {
2843
+ const g = i ? 0 : Math.round(Math.min(a, h) * 0.11);
2844
+ Le(l, e, g, g, a - g * 2, h - g * 2, s);
2845
+ } else {
2846
+ l.fillStyle = "#333";
2847
+ const g = Math.round(Math.min(a, h) * 0.094);
2848
+ l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, a / 2, h / 2);
2849
+ }
2850
+ const d = new c.CanvasTexture(m);
2851
+ return d.colorSpace = c.SRGBColorSpace, d;
2852
+ }
2853
+ async function Ye(r) {
2854
+ if (!r) return null;
2855
+ const t = URL.createObjectURL(r), e = new Image();
2856
+ e.decoding = "async", e.src = t;
2857
+ try {
2858
+ return await new Promise((s, i) => {
2859
+ e.onload = () => s(), e.onerror = () => i(new Error(`Failed to decode image: ${r.name}`));
2860
+ }), { image: e, objectUrl: t };
2861
+ } catch (s) {
2862
+ return URL.revokeObjectURL(t), console.error(s), null;
2863
+ }
2864
+ }
2657
2865
  export {
2658
- xe as AnimationCurve,
2659
- yt as AutoTurnDirection,
2866
+ ye as AnimationCurve,
2867
+ wt as AutoTurnDirection,
2660
2868
  pe as AutoTurnMode,
2661
2869
  rt as AutoTurnSetting,
2662
- Me as AutoTurnSettingCurveTimeMode,
2663
- ge as AutoTurnSettingMode,
2870
+ xe as AutoTurnSettingCurveTimeMode,
2871
+ Me as AutoTurnSettingMode,
2664
2872
  Nt as AutoTurnSettings,
2665
- Ut as Book,
2873
+ Ct as Book,
2666
2874
  Pe as BookBinding,
2667
- Le as BookBound,
2668
- Ue as BookContent,
2669
- E as BookDirection,
2670
- Ze as BookHeightException,
2671
- de as BookRenderer,
2875
+ We as BookBound,
2876
+ je as BookContent,
2877
+ X as BookDirection,
2878
+ Ue as BookHeightException,
2879
+ Ge as BookPointerInteraction,
2880
+ fe as BookRenderer,
2672
2881
  ut as Cylinder,
2673
- me as MeshFactory,
2674
- Ne as PageContent,
2675
- he as Paper,
2676
- wt as PaperBorder,
2677
- Dt as PaperMaterialData,
2882
+ ue as MeshFactory,
2883
+ Gt as PX_PER_UNIT,
2884
+ Xe as PageContent,
2885
+ le as Paper,
2886
+ Tt as PaperBorder,
2887
+ At as PaperMaterialData,
2678
2888
  Zt as PaperMeshData,
2679
- fe as PaperMeshDataPool,
2680
- Fe as PaperMeshUtility,
2889
+ ge as PaperMeshDataPool,
2890
+ Ne as PaperMeshUtility,
2681
2891
  st as PaperNode,
2682
- le as PaperNodeMargin,
2683
- ye as PaperPattern,
2892
+ ce as PaperNodeMargin,
2893
+ Ce as PaperPattern,
2684
2894
  Pt as PaperSeam,
2685
2895
  ht as PaperSetup,
2686
- gt as PaperUVMargin,
2687
- ue as RendererFactory,
2688
- Lt as SpritePageContent2,
2689
- Xe as StapleBookBinding,
2690
- Ae as StapleBookBound,
2691
- ze as StapleSetup
2896
+ pt as PaperUVMargin,
2897
+ de as RendererFactory,
2898
+ Ut as SpritePageContent2,
2899
+ qe as StapleBookBinding,
2900
+ He as StapleBookBound,
2901
+ De as StapleSetup,
2902
+ Oe as TextBlock,
2903
+ Qe as TextOverlayContent,
2904
+ $e as createPageTexture,
2905
+ Le as drawImageWithFit,
2906
+ Ye as loadImage
2692
2907
  };