@objectifthunes/three-book 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/AutoTurn.d.ts +2 -10
  2. package/dist/AutoTurn.d.ts.map +1 -1
  3. package/dist/Book.d.ts +34 -14
  4. package/dist/Book.d.ts.map +1 -1
  5. package/dist/BookBinding.d.ts +7 -2
  6. package/dist/BookBinding.d.ts.map +1 -1
  7. package/dist/BookContent.d.ts +4 -0
  8. package/dist/BookContent.d.ts.map +1 -1
  9. package/dist/Cylinder.d.ts +25 -1
  10. package/dist/Cylinder.d.ts.map +1 -1
  11. package/dist/PageContent.d.ts +2 -7
  12. package/dist/PageContent.d.ts.map +1 -1
  13. package/dist/Paper.d.ts +37 -51
  14. package/dist/Paper.d.ts.map +1 -1
  15. package/dist/PaperMaterialData.d.ts +6 -1
  16. package/dist/PaperMaterialData.d.ts.map +1 -1
  17. package/dist/PaperMeshData.d.ts +0 -6
  18. package/dist/PaperMeshData.d.ts.map +1 -1
  19. package/dist/PaperMeshUtility.d.ts +0 -16
  20. package/dist/PaperMeshUtility.d.ts.map +1 -1
  21. package/dist/PaperNode.d.ts +0 -1
  22. package/dist/PaperNode.d.ts.map +1 -1
  23. package/dist/Renderer.d.ts +6 -9
  24. package/dist/Renderer.d.ts.map +1 -1
  25. package/dist/SpreadContent.d.ts.map +1 -1
  26. package/dist/StapleBinding.d.ts +12 -57
  27. package/dist/StapleBinding.d.ts.map +1 -1
  28. package/dist/TextOverlayContent.d.ts.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +972 -1024
  32. package/dist/mathUtils.d.ts +18 -0
  33. package/dist/mathUtils.d.ts.map +1 -0
  34. package/dist/textContentUtils.d.ts +26 -0
  35. package/dist/textContentUtils.d.ts.map +1 -0
  36. package/dist/types.d.ts +57 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/utils/EllipseUtility.d.ts +4 -3
  39. package/dist/utils/EllipseUtility.d.ts.map +1 -1
  40. package/dist/utils/LoopUtility.d.ts +0 -5
  41. package/dist/utils/LoopUtility.d.ts.map +1 -1
  42. package/dist/utils/MatrixUtility.d.ts +2 -1
  43. package/dist/utils/MatrixUtility.d.ts.map +1 -1
  44. package/dist/utils/TextureUtility.d.ts +4 -5
  45. package/dist/utils/TextureUtility.d.ts.map +1 -1
  46. package/dist/utils/VectorUtility.d.ts +5 -15
  47. package/dist/utils/VectorUtility.d.ts.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/utils/index.d.ts +0 -8
  50. package/dist/utils/index.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
- import * as c from "three";
2
- class ut {
1
+ import * as l from "three";
2
+ class wt {
3
3
  constructor() {
4
- this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0;
4
+ this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new l.Vector3(), this._scratchRP1 = new l.Vector3(), this._scratchRP2 = new l.Vector3(), this._scratchRollClosest = new l.Vector3(), this._scratchRollEuler = new l.Vector3(), this._scratchOffsetRoll = new l.Vector3();
5
5
  }
6
6
  // ── Properties ────────────────────────────────────────────────────────
7
+ /** Returns internal vector — do NOT mutate. Copy if you need to store it. */
7
8
  get position() {
8
- return new c.Vector3(this.m_PositionX, 0, this.m_PositionZ);
9
+ return this._positionOut.set(this.m_PositionX, 0, this.m_PositionZ);
9
10
  }
10
11
  set position(t) {
11
12
  this.m_PositionX = t.x, this.m_PositionZ = t.z;
@@ -18,7 +19,7 @@ class ut {
18
19
  }
19
20
  // ── Public API ────────────────────────────────────────────────────────
20
21
  rollPoint(t) {
21
- return this.roll(t.clone()).sub(this.getOffset(t.clone()));
22
+ return this._scratchRP1.copy(t), this.roll(this._scratchRP1), this._scratchRP2.copy(t), this.getOffset(this._scratchRP2), t.copy(this._scratchRP1).sub(this._scratchRP2), t;
22
23
  }
23
24
  // ── Private helpers ───────────────────────────────────────────────────
24
25
  /**
@@ -28,31 +29,46 @@ class ut {
28
29
  * 1. Rotate (x, 0, 0) by Z degrees around Z-axis.
29
30
  * 2. Rotate by X degrees around X-axis (X = 0 here, so skip).
30
31
  * 3. Rotate by Y degrees around Y-axis.
32
+ *
33
+ * Writes result into `out` and returns it.
31
34
  */
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, 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
+ eulerRotateVector(t, e, s, i) {
36
+ const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), o = Math.sin(n), u = t * a, c = t * o, m = 0, f = Math.cos(h), d = Math.sin(h), _ = u * f + m * d, g = c, p = -u * d + m * f;
37
+ return i.set(_, g, p);
35
38
  }
39
+ /**
40
+ * Rolls `point` in place around the cylinder. Mutates and returns `point`.
41
+ * Uses _scratchRollClosest for closest-point calculation and
42
+ * _scratchRollEuler for euler rotation result.
43
+ */
36
44
  roll(t) {
37
45
  if (this.getSide(t) >= 0) return t;
38
- const e = this.getClosestPoint(t.clone());
46
+ this._scratchRollClosest.copy(t), this.getClosestPointInto(this._scratchRollClosest);
47
+ const e = this._scratchRollClosest;
39
48
  let s = t.distanceTo(e);
40
- if (s > Math.PI * this.m_Radius) {
41
- s = s - Math.PI * this.m_Radius;
42
- const i = this.eulerRotateVector(-s, this.m_EulerY, 0);
43
- t.copy(i.add(e)), t.y += this.m_Radius * 2;
44
- } else {
45
- const i = 180 / Math.PI * (s / this.m_Radius) - 90, n = this.eulerRotateVector(this.m_Radius, this.m_EulerY, i);
46
- t.copy(n.add(e)), t.y += this.m_Radius;
49
+ if (s > Math.PI * this.m_Radius)
50
+ s = s - Math.PI * this.m_Radius, this.eulerRotateVector(-s, this.m_EulerY, 0, this._scratchRollEuler), t.copy(this._scratchRollEuler.add(e)), t.y += this.m_Radius * 2;
51
+ else {
52
+ const i = 180 / Math.PI * (s / this.m_Radius) - 90;
53
+ this.eulerRotateVector(this.m_Radius, this.m_EulerY, i, this._scratchRollEuler), t.copy(this._scratchRollEuler.add(e)), t.y += this.m_Radius;
47
54
  }
48
55
  return t;
49
56
  }
57
+ /**
58
+ * Computes offset for `point`. Mutates and returns `point`.
59
+ * Offset = roll(point with x=0) with z adjusted.
60
+ * Uses _scratchOffsetRoll to hold a copy for rolling (avoids aliasing
61
+ * with `point` itself when roll() internally reads and writes).
62
+ */
50
63
  getOffset(t) {
51
- t.x = 0;
52
- const e = this.roll(t.clone());
53
- return e.z -= t.z, e;
64
+ const e = t.z;
65
+ return this._scratchOffsetRoll.set(0, t.y, t.z), this.roll(this._scratchOffsetRoll), t.copy(this._scratchOffsetRoll), t.z -= e, t;
54
66
  }
55
- getClosestPoint(t) {
67
+ /**
68
+ * Projects `point` onto the cylinder axis, writing the result into `point`.
69
+ * Returns the mutated `point`.
70
+ */
71
+ getClosestPointInto(t) {
56
72
  const e = t.x - this.m_PositionX, s = t.z - this.m_PositionZ, i = e * this.m_DirectionX + s * this.m_DirectionZ;
57
73
  return t.x = this.m_PositionX + this.m_DirectionX * i, t.z = this.m_PositionZ + this.m_DirectionZ * i, t;
58
74
  }
@@ -62,37 +78,37 @@ class ut {
62
78
  }
63
79
  // ── Value-type clone ──────────────────────────────────────────────────
64
80
  clone() {
65
- const t = new ut();
81
+ const t = new wt();
66
82
  return t.m_PositionX = this.m_PositionX, t.m_PositionZ = this.m_PositionZ, t.m_DirectionX = this.m_DirectionX, t.m_DirectionZ = this.m_DirectionZ, t.m_EulerY = this.m_EulerY, t.m_Radius = this.m_Radius, t;
67
83
  }
68
84
  }
69
- function gt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
85
+ function dt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
70
86
  s = Math.max(s, 1e-4);
71
- const o = 2 / s, a = o * n, h = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
72
- let m = r - t;
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 ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
81
- const o = gt(
87
+ const h = 2 / s, a = h * n, o = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
88
+ let u = r - t;
89
+ const c = t, m = i * s;
90
+ u = l.MathUtils.clamp(u, -m, m), t = r - u;
91
+ const f = (e + h * u) * n;
92
+ e = (e - h * f) * o;
93
+ let d = t + (u + f) * o;
94
+ return c - r > 0 == d > c && (d = c, e = (d - c) / n), { value: d, velocity: e };
95
+ }
96
+ function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
97
+ const h = dt(
82
98
  r.x,
83
99
  t.x,
84
100
  e.x,
85
101
  s.x,
86
102
  i,
87
103
  n
88
- ), a = gt(
104
+ ), a = dt(
89
105
  r.y,
90
106
  t.y,
91
107
  e.y,
92
108
  s.y,
93
109
  i,
94
110
  n
95
- ), h = gt(
111
+ ), o = dt(
96
112
  r.z,
97
113
  t.z,
98
114
  e.z,
@@ -100,20 +116,14 @@ function ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
100
116
  i,
101
117
  n
102
118
  );
103
- return e.set(o.velocity, a.velocity, h.velocity), new c.Vector3(o.value, a.value, h.value);
104
- }
105
- function ne(r) {
106
- return new c.Vector3(r.x, 0, r.y);
107
- }
108
- function re(r) {
109
- return new c.Vector3(r.x, r.z, 0);
119
+ return e.set(h.velocity, a.velocity, o.velocity), r.set(h.value, a.value, o.value);
110
120
  }
111
121
  function vt(r, t, e) {
112
122
  const s = t * t - 4 * r * e;
113
123
  if (s < 0)
114
124
  return { rootCount: 0, root0: 0, root1: 0 };
115
125
  if (s === 0)
116
- return { rootCount: 1, root0: -t / 2 * r, root1: 0 };
126
+ return { rootCount: 1, root0: -t / (2 * r), root1: 0 };
117
127
  {
118
128
  const i = Math.sqrt(s);
119
129
  return {
@@ -123,84 +133,90 @@ function vt(r, t, e) {
123
133
  };
124
134
  }
125
135
  }
126
- function kt(r, t, e) {
127
- return oe(r, t, e) ? r.clone() : ae(
128
- new c.Vector2(r.x, t.y),
136
+ const kt = new l.Vector2();
137
+ function Bt(r, t, e, s) {
138
+ return se(r, t, e) ? s.copy(r) : (kt.set(r.x, t.y), ie(
139
+ kt,
129
140
  r,
130
141
  t,
131
- e
132
- );
142
+ e,
143
+ s
144
+ ));
133
145
  }
134
- function oe(r, t, e) {
146
+ function se(r, t, e) {
135
147
  const s = r.x - t.x;
136
148
  let i = r.y - t.y;
137
149
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
138
150
  }
139
- function ae(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
- if (Math.abs(o - h) < 1e-5) {
142
- if (o >= i - l && o <= i + l) {
143
- const u = vt(
151
+ function ie(r, t, e, s, i) {
152
+ const n = e.x, h = e.y, a = r.x, o = r.y, u = t.x, c = t.y, m = s.x, f = s.y, d = 1 / (m * m), _ = 1 / (f * f);
153
+ if (Math.abs(a - u) < 1e-5) {
154
+ if (a >= n - m && a <= n + m) {
155
+ const g = vt(
144
156
  _,
145
- -2 * _ * n,
146
- g * (o * o - 2 * i * o + i * i) + _ * n * n - 1
157
+ -2 * _ * h,
158
+ d * (a * a - 2 * n * a + n * n) + _ * h * h - 1
147
159
  );
148
- if (u.rootCount === 1)
149
- return new c.Vector2(o, u.root0);
150
- if (u.rootCount === 2) {
151
- let f = u.root0, p = u.root1;
152
- return a < m && ([f, p] = [p, f]), new c.Vector2(o, p);
160
+ if (g.rootCount === 1)
161
+ return i.set(a, g.root0);
162
+ if (g.rootCount === 2) {
163
+ let p = g.root0, M = g.root1;
164
+ return o < c && ([p, M] = [M, p]), i.set(a, M);
153
165
  }
154
166
  }
155
167
  } else {
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
168
+ const g = (c - o) / (u - a), p = o - g * a, M = p - h, T = vt(
169
+ d + _ * g * g,
170
+ 2 * M * g * _ - 2 * n * d,
171
+ n * n * d + M * M * _ - 1
160
172
  );
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, M = P.root1;
165
- return o < h && ([B, M] = [M, B]), new c.Vector2(M, u * M + f);
173
+ if (T.rootCount === 1)
174
+ return i.set(T.root0, g * T.root0 + p);
175
+ if (T.rootCount === 2) {
176
+ let P = T.root0, C = T.root1;
177
+ return a < u && ([P, C] = [C, P]), i.set(C, g * C + p);
166
178
  }
167
179
  }
168
- return r.clone();
169
- }
170
- function bt(r, t) {
171
- const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
172
- return new c.Ray(e, s.sub(e));
180
+ return i.copy(r);
173
181
  }
174
- function he(r) {
175
- return new c.Vector4(-r.x, r.y, r.z + r.x, r.w);
182
+ const ft = new l.Vector3(), Rt = new l.Vector3(), bt = new l.Ray();
183
+ function Dt(r, t) {
184
+ return ft.copy(r.origin).applyMatrix4(t), Rt.copy(r.origin).add(r.direction).applyMatrix4(t), bt.set(ft, Rt.sub(ft).normalize()), bt;
176
185
  }
177
- function le(r) {
178
- return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
186
+ function ne(r) {
187
+ const t = r.x;
188
+ r.set(-t, r.y, r.z + t, r.w);
179
189
  }
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, ce = 1192093e-13;
182
- function dt(r) {
183
- return r < 0 ? 0 : r > 1 ? 1 : r;
190
+ function re(r) {
191
+ const t = r.y;
192
+ r.set(r.x, -t, r.z, r.w + t);
184
193
  }
185
- function Dt(r, t, e) {
194
+ var j = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(j || {});
195
+ const J = Math.PI / 180, et = 180 / Math.PI;
196
+ function H(r, t, e) {
186
197
  return r < t ? t : r > e ? e : r;
187
198
  }
188
- function mt(r, t, e) {
189
- return r !== t ? dt((e - r) / (t - r)) : 0;
199
+ function lt(r) {
200
+ return r < 0 ? 0 : r > 1 ? 1 : r;
201
+ }
202
+ function F(r, t, e) {
203
+ return e = lt(e), r + (t - r) * e;
190
204
  }
191
205
  function It(r, t, e) {
192
206
  return r + (t - r) * e;
193
207
  }
194
- function zt(r, t, e) {
195
- return r + (t - r) * e;
208
+ function Q(r, t, e) {
209
+ return r !== t ? lt((e - r) / (t - r)) : 0;
196
210
  }
211
+ var ut = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(ut || {});
212
+ const he = 1192093e-13;
197
213
  function Vt(r, t, e) {
198
- return e = dt((e - r) / (t - r)), e * e * (3 - 2 * e);
214
+ return e = lt((e - r) / (t - r)), e * e * (3 - 2 * e);
199
215
  }
200
- class me {
216
+ class ae {
201
217
  // ---- Constructor ----
202
218
  constructor(t, e, s, i) {
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;
219
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new l.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new wt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new l.Plane(), this.m_StartHandle = new l.Vector3(), this.m_CurrentHandle = new l.Vector3(), this.m_EndHandle = new l.Vector3(), this.m_PrevHandle = new l.Vector3(), this.m_HandleOffset = new l.Vector3(), this.m_HandleVelocity = new l.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new l.Vector3(), this._ucCurrentHandle = new l.Vector3(), this._ucHandleDir = new l.Vector3(), this._ucA = new l.Vector3(), this._ucB = new l.Vector3(), this._ucMid = new l.Vector3(), this._ucRollResult = new l.Vector3(), this._ucCylDir = new l.Vector3(), this._utV1 = new l.Vector3(), this._utV2 = new l.Vector3(), this._utV3 = new l.Vector3(), this._utV4 = new l.Vector3(), this._chP = new l.Vector3(), this._chA = new l.Vector3(), this._chC = new l.Vector3(), this._chEllipseCenter1 = new l.Vector2(), this._chEllipseCenter2 = new l.Vector2(), this._chEllipseSize1 = new l.Vector2(), this._chEllipseSize2 = new l.Vector2(), this._chP2 = new l.Vector2(), this._dirResult = new l.Vector3(), this._gdA = new l.Vector3(), this._gdB = new l.Vector3(), this._rlMatrix = new l.Matrix4(), this._rlPlane = new l.Plane(new l.Vector3(0, 1, 0), 0), this._rlTarget = new l.Vector3(), this._rlNormal = new l.Vector3(), this._utTarget = new l.Vector3(), this._ufSmoothTime = new l.Vector3(), this._umFrontST = new l.Vector4(), this._umBackST = new l.Vector4(), this._h2uResult = new l.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
204
220
  }
205
221
  // ---- Properties (mirrors C#) ----
206
222
  get isMeshChanged() {
@@ -240,8 +256,8 @@ class me {
240
256
  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
257
  }
242
258
  get direction() {
243
- const e = this.zTime * 180 * Bt, s = Math.cos(e), i = Math.sin(e);
244
- return new c.Vector3(-s, -i, 0);
259
+ const e = this.zTime * 180 * J, s = Math.cos(e), i = Math.sin(e);
260
+ return this._dirResult.set(-s, -i, 0);
245
261
  }
246
262
  get isTurning() {
247
263
  return this.m_IsTurning;
@@ -281,9 +297,6 @@ class me {
281
297
  get isIdle() {
282
298
  return !this.m_IsFalling && !this.m_IsTurning;
283
299
  }
284
- get isInMiddelOfStack() {
285
- return this.m_Prev === null || this.m_Next === null ? !1 : this.isIdle && this.m_Prev.isIdle && this.m_Next.isIdle && this.m_Prev.isOnRightStack === this.m_Next.isOnRightStack;
286
- }
287
300
  // ---- Methods (faithful port, same order as C#) ----
288
301
  setTime(t) {
289
302
  this.m_XTime = t, this.m_ZTime = t;
@@ -313,56 +326,56 @@ class me {
313
326
  this.m_MinTurningRadius = t;
314
327
  }
315
328
  updateTurningRadius(t = 1) {
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(
329
+ let e = Math.max(this.m_Stiffness, 1 - lt(t));
330
+ e <= 0.5 ? this.m_TurningRadius = Q(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - Q(0.5, 1, e)), 5) * J), this.m_TurningRadius = Math.max(
318
331
  this.m_TurningRadius,
319
332
  this.m_MinTurningRadius
320
333
  );
321
334
  }
322
335
  startTurning(t) {
323
- var n, o;
336
+ var i, n;
324
337
  const e = t.clone();
325
- t = bt(
338
+ t = Dt(
326
339
  t,
327
- this.m_Transform.matrixWorld.clone().invert()
340
+ this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
328
341
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
329
- new c.Vector3(0, 1, 0).applyQuaternion(this.m_Transform.quaternion),
342
+ this._rlNormal.set(0, 1, 0).applyQuaternion(this.m_Transform.quaternion),
330
343
  this.m_Transform.position
331
- );
332
- const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
333
- if (t.intersectPlane(s, i) !== null) {
334
- const a = i;
335
- if (a.x > 0 && a.x < this.m_Size.x && a.z > 0 && a.z < this.m_Size.y) {
336
- if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(a), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), a.x < this.m_Size.x * 0.9) {
337
- this.m_HandleOffset.set(a.x - this.m_Size.x, 0, 0);
338
- const h = this.m_Transform.scale;
339
- h.x *= -1;
344
+ ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
345
+ const s = this._rlTarget;
346
+ if (t.intersectPlane(this._rlPlane, s) !== null) {
347
+ const h = s;
348
+ if (h.x > 0 && h.x < this.m_Size.x && h.z > 0 && h.z < this.m_Size.y) {
349
+ if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(h), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), h.x < this.m_Size.x * 0.9) {
350
+ this.m_HandleOffset.set(h.x - this.m_Size.x, 0, 0);
351
+ const a = this.m_Transform.scale;
352
+ a.x *= -1;
340
353
  }
341
354
  return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
342
355
  0
343
356
  /* Highpoly */
344
- ), (n = this.m_Prev) == null || n.trySwitchMeshData(1), (o = this.m_Next) == null || o.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
357
+ ), (i = this.m_Prev) == null || i.trySwitchMeshData(1), (n = this.m_Next) == null || n.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
345
358
  }
346
359
  }
347
360
  return !1;
348
361
  }
349
362
  stopTurning() {
350
363
  this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
351
- const t = new c.Vector3(0, 0, 0);
364
+ const t = new l.Vector3(0, 0, 0);
352
365
  for (const e of this.m_HandleVelocities)
353
366
  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 = It(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);
367
+ t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = F(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
355
368
  }
356
369
  /**
357
370
  * Called each frame while the user is dragging.
358
371
  * `dt` replaces Time.deltaTime.
359
372
  */
360
373
  updateTurning(t, e = 1 / 60) {
361
- const s = new c.Vector3();
374
+ const s = this._utTarget;
362
375
  if (t.intersectPlane(this.m_WorldPlane, s) !== null) {
363
376
  const i = s;
364
377
  this.m_Book.bound.resetPaperPosition(this), this.m_CurrentHandle.copy(
365
- this.m_Transform.worldToLocal(i.clone())
378
+ this.m_Transform.worldToLocal(this.m_CurrentHandle.copy(i))
366
379
  ), this.m_CurrentHandle.y = 0, this.m_CurrentHandle.add(this.m_HandleOffset), this.m_HandleVelocity.copy(this.m_CurrentHandle).sub(this.m_PrevHandle).divideScalar(e), this.m_HandleVelocities.length === 5 && this.m_HandleVelocities.shift(), this.m_HandleVelocities.push(this.m_HandleVelocity.clone()), this.m_PrevHandle.copy(this.m_CurrentHandle);
367
380
  }
368
381
  this.updateBaseVertices();
@@ -375,27 +388,21 @@ class me {
375
388
  var s, i;
376
389
  let e = !1;
377
390
  if (this.m_IsAutoTurning) {
378
- let n = dt(this.m_FallTime / this.m_FallDuration);
391
+ let n = lt(this.m_FallTime / this.m_FallDuration);
379
392
  n = Vt(0, 1, n), n = Vt(0, 1, n), this.m_CurrentHandle.lerpVectors(
380
393
  this.m_StartHandle,
381
394
  this.m_EndHandle,
382
395
  this.m_IsFallingLeft ? n : 1 - n
383
- ), this.m_FallTime += t, e = Math.abs(n - 1) < ce;
384
- } else {
385
- const n = new c.Vector3(
386
- this.m_FallTime,
387
- 0,
388
- this.m_FallTime * 0.75
389
- );
390
- this.m_CurrentHandle = ie(
396
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < he;
397
+ } else
398
+ this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), ee(
391
399
  this.m_CurrentHandle,
392
400
  this.m_EndHandle,
393
401
  this.m_HandleVelocity,
394
- n,
402
+ this._ufSmoothTime,
395
403
  1 / 0,
396
404
  t
397
405
  ), e = Math.abs(this.m_EndHandle.x - this.m_CurrentHandle.x) < 1e-4;
398
- }
399
406
  if (e) {
400
407
  if (this.m_IsFallingLeft) {
401
408
  const n = this.m_Transform.scale;
@@ -415,12 +422,12 @@ class me {
415
422
  }
416
423
  getTextureCoordinate(t) {
417
424
  const e = this.raycastLocal(t, !0);
418
- return e !== null ? this.hit2UV(e) : new c.Vector2(0, 0);
425
+ return e !== null ? this.hit2UV(e) : new l.Vector2(0, 0);
419
426
  }
420
427
  raycast(t) {
421
428
  const e = {
422
- point: new c.Vector3(),
423
- textureCoordinate: new c.Vector2(),
429
+ point: new l.Vector3(),
430
+ textureCoordinate: new l.Vector2(),
424
431
  pageContent: null,
425
432
  paperIndex: 0,
426
433
  pageIndex: 0
@@ -433,13 +440,13 @@ class me {
433
440
  return { hit: !1, hitInfo: e };
434
441
  }
435
442
  hit2UV(t) {
436
- const e = new c.Vector2(
437
- mt(-this.sizeXOffset, this.m_Size.x, t.x),
443
+ const e = this._h2uResult.set(
444
+ Q(-this.sizeXOffset, this.m_Size.x, t.x),
438
445
  t.z / this.m_Size.y
439
446
  );
440
447
  this.m_UVMargin.fixUV(e);
441
448
  const s = this.m_Book.direction;
442
- if (s === X.UpToDown || s === X.DownToUp) {
449
+ if (s === j.UpToDown || s === j.DownToUp) {
443
450
  const i = e.x;
444
451
  e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
445
452
  } else
@@ -451,15 +458,15 @@ class me {
451
458
  * Returns the local-space hit point, or null if no hit / out of bounds.
452
459
  */
453
460
  raycastLocal(t, e = !1) {
454
- t = bt(
461
+ t = Dt(
455
462
  t,
456
- this.m_Transform.matrixWorld.clone().invert()
457
- );
458
- const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
459
- if (t.intersectPlane(s, i) !== null) {
460
- const n = i;
461
- if (n.x > 0 && n.x < this.m_Size.x && n.z > 0 && n.z < this.m_Size.y || e)
462
- return n;
463
+ this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
464
+ ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
465
+ const s = this._rlTarget;
466
+ if (t.intersectPlane(this._rlPlane, s) !== null) {
467
+ const i = s;
468
+ if (i.x > 0 && i.x < this.m_Size.x && i.z > 0 && i.z < this.m_Size.y || e)
469
+ return i;
463
470
  }
464
471
  return null;
465
472
  }
@@ -488,15 +495,14 @@ class me {
488
495
  this.m_SubMeshCount !== t && (this.m_Renderer.setMaterials(
489
496
  t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
490
497
  ), this.m_SubMeshCount = t);
491
- const e = this.m_FrontContent.textureST.clone();
492
- let s = this.m_BackContent.textureST.clone();
493
- this.m_Book.direction > 1 ? s = le(s) : s = he(s);
498
+ const e = this._umFrontST.copy(this.m_FrontContent.textureST), s = this._umBackST.copy(this.m_BackContent.textureST);
499
+ this.m_Book.direction > 1 ? re(s) : ne(s);
494
500
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
495
501
  if (t === 3) {
496
- let o = 0, a = 1;
497
- this.m_Transform.scale.x === -1 && (o = 1, a = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
502
+ let h = 0, a = 1;
503
+ this.m_Transform.scale.x === -1 && (h = 1, a = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
498
504
  this.m_MaterialData.propertyBlock,
499
- o
505
+ h
500
506
  ), this.m_UseBackContentForSides || this.m_Renderer.setPropertyBlock(
501
507
  this.m_MaterialData.propertyBlock,
502
508
  2
@@ -524,100 +530,87 @@ class me {
524
530
  this.updateMaterials(), this.m_MeshData.updateMesh(), this.m_isMeshChanged = !0;
525
531
  }
526
532
  getDirection(t) {
527
- let e = new c.Vector3(0, 0, t), s = new c.Vector3(0.1, 0, t);
528
- return e = this.rollPoint(e), s = this.rollPoint(s), e = this.m_Transform.localToWorld(e), s = this.m_Transform.localToWorld(s), this.m_Transform.parent && (e = this.m_Transform.parent.worldToLocal(e), s = this.m_Transform.parent.worldToLocal(s)), e.sub(s).normalize();
533
+ const e = this._gdA.set(0, 0, t), s = this._gdB.set(0.1, 0, t);
534
+ return this.rollPoint(e), this.rollPoint(s), this.m_Transform.localToWorld(e), this.m_Transform.localToWorld(s), this.m_Transform.parent && (this.m_Transform.parent.worldToLocal(e), this.m_Transform.parent.worldToLocal(s)), e.sub(s).normalize();
529
535
  }
530
536
  updateTime() {
531
537
  if (this.isTurning || this.isFalling) {
532
- const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
533
- new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
534
- );
535
- this.m_XTime = It(
538
+ this._utV1.set(this.m_Size.x, 0, 0);
539
+ const t = this.findTime(this._utV1);
540
+ this._utV2.set(this.m_Size.x, 0, this.m_Size.y);
541
+ const e = this.findTime(this._utV2);
542
+ this.m_XTime = F(
536
543
  Math.min(t, e),
537
544
  Math.max(t, e),
538
545
  0.9
539
546
  );
540
- const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, n = this.rollPoint(new c.Vector3(s[1], 0, 0)), o = this.rollPoint(new c.Vector3(s[2], 0, 0)), a = this.rollPoint(
541
- new c.Vector3(s[1], 0, i[i.length - 1])
542
- ), h = this.rollPoint(
543
- new c.Vector3(s[2], 0, i[i.length - 1])
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;
547
+ const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray;
548
+ this._utV1.set(s[1], 0, 0);
549
+ const n = this.rollPoint(this._utV1);
550
+ this._utV2.set(s[2], 0, 0);
551
+ const h = this.rollPoint(this._utV2);
552
+ this._utV3.set(s[1], 0, i[i.length - 1]);
553
+ const a = this.rollPoint(this._utV3);
554
+ this._utV4.set(s[2], 0, i[i.length - 1]);
555
+ const o = this.rollPoint(this._utV4), u = h.x - n.x, c = h.y - n.y, m = o.x - a.x, f = o.y - a.y, d = Math.sqrt(u * u + c * c) || 1, _ = Math.sqrt(m * m + f * f) || 1, g = et * Math.atan2(c / d, u / d), p = et * Math.atan2(f / _, m / _), M = (g + p) / 2;
556
+ this.m_ZTime = M / 180;
546
557
  } else
547
558
  this.m_XTime = 0, this.m_ZTime = 0;
548
559
  }
549
560
  findTime(t) {
550
- return t = this.rollPoint(t), mt(this.m_Size.x, -this.m_Size.x, t.x);
561
+ return t = this.rollPoint(t), Q(this.m_Size.x, -this.m_Size.x, t.x);
551
562
  }
552
563
  clampHandle() {
553
564
  this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
554
- const t = this.m_CurrentHandle.clone(), e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), o = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), h = this.m_StartHandle.z, m = new c.Vector2(
565
+ const t = this._chP.copy(this.m_CurrentHandle), e = this._chA.set(0, 0, 0), s = this._chC.set(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), h = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), o = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
555
566
  0,
556
- h + (e.z - h) * (o / i)
557
- ), l = new c.Vector2(
567
+ o + (e.z - o) * (h / i)
568
+ ), c = this._chEllipseCenter2.set(
558
569
  0,
559
- h + (s.z - h) * (a / n)
560
- ), d = new c.Vector2(i, o), g = new c.Vector2(n, a);
561
- t.x = Dt(t.x, -this.m_Size.x, this.m_Size.x);
562
- const _ = re(t), u = kt(
563
- new c.Vector2(_.x, _.y),
564
- m,
565
- d
566
- ), f = kt(
567
- new c.Vector2(u.x, u.y),
568
- l,
569
- g
570
- ), p = ne(
571
- new c.Vector3(f.x, f.y, 0)
572
- );
573
- this.m_CurrentHandle.copy(p);
570
+ o + (s.z - o) * (a / n)
571
+ ), m = this._chEllipseSize1.set(i, h), f = this._chEllipseSize2.set(n, a);
572
+ t.x = H(t.x, -this.m_Size.x, this.m_Size.x);
573
+ const d = this._chP2.set(t.x, t.z);
574
+ Bt(d, u, m, d), Bt(d, c, f, d), this.m_CurrentHandle.set(d.x, 0, d.y);
574
575
  }
575
576
  updateCylinder() {
576
- const t = this.m_StartHandle.clone(), e = this.m_CurrentHandle.clone(), s = t.clone().sub(e).normalize();
577
+ const t = this._ucStartHandle.copy(this.m_StartHandle), e = this._ucCurrentHandle.copy(this.m_CurrentHandle), s = this._ucHandleDir.copy(t).sub(e).normalize();
577
578
  s.length() === 0 && s.set(1, 0, 0);
578
- const i = t.clone().sub(
579
- s.clone().multiplyScalar(
580
- this.m_Size.x * 2 + this.m_TurningRadius * Math.PI
581
- )
582
- ), n = t.clone(), o = new ut();
583
- o.radius = this.m_TurningRadius, o.direction = new c.Vector3(
584
- -s.z,
585
- 0,
586
- s.x
587
- );
579
+ const i = this.m_Size.x * 2 + this.m_TurningRadius * Math.PI, n = this._ucA.copy(t).sub(
580
+ this._ucCylDir.copy(s).multiplyScalar(i)
581
+ ), h = this._ucB.copy(t);
582
+ this.m_Cylinder.radius = this.m_TurningRadius, this._ucCylDir.set(-s.z, 0, s.x), this.m_Cylinder.direction = this._ucCylDir;
588
583
  for (let a = 0; a < 100; a++) {
589
- o.position = i.clone().add(n).multiplyScalar(0.5), this.m_Cylinder = o, this.m_Book.bound.updatePaperPosition(this);
590
- const h = o.rollPoint(t.clone());
591
- if (Math.abs(e.x - h.x) < 1e-4) break;
592
- h.x > e.x ? n.copy(o.position) : i.copy(o.position);
584
+ this._ucMid.copy(n).add(h).multiplyScalar(0.5), this.m_Cylinder.position = this._ucMid, this.m_Book.bound.updatePaperPosition(this), this._ucRollResult.copy(t);
585
+ const o = this.m_Cylinder.rollPoint(this._ucRollResult);
586
+ if (Math.abs(e.x - o.x) < 1e-4) break;
587
+ o.x > e.x ? h.copy(this.m_Cylinder.position) : n.copy(this.m_Cylinder.position);
593
588
  }
594
589
  }
595
590
  rollPoint(t) {
596
591
  return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
597
592
  }
598
- drawWireframe(t) {
599
- }
600
593
  startAutoTurning(t, e, s, i) {
601
- var m, l;
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 d = this.m_Transform.scale;
604
- d.x *= -1;
594
+ var u, c;
595
+ if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === ut.Surface) {
596
+ const m = this.m_Transform.scale;
597
+ m.x *= -1;
605
598
  }
606
599
  this.switchMeshData(
607
600
  0
608
601
  /* Highpoly */
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
- const n = this.m_Size.x, o = this.m_Size.y;
611
- e = Dt(e, -0.99, 0.99);
612
- const a = zt(0.5, 1, e), h = zt(0.5, 0, e);
613
- this.m_StartHandle.set(n, 0, o * a), this.m_EndHandle.set(-n, 0, o * h), this.m_IsAutoTurning = !0;
602
+ ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (c = this.m_Next) == null || c.trySwitchMeshData(1), this.m_IsFallingLeft = t === ut.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
603
+ const n = this.m_Size.x, h = this.m_Size.y;
604
+ e = H(e, -0.99, 0.99);
605
+ const a = It(0.5, 1, e), o = It(0.5, 0, e);
606
+ this.m_StartHandle.set(n, 0, h * a), this.m_EndHandle.set(-n, 0, h * o), this.m_IsAutoTurning = !0;
614
607
  }
615
608
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
616
609
  get cylinder() {
617
610
  return this.m_Cylinder;
618
611
  }
619
612
  }
620
- const Y = class Y {
613
+ const st = class st {
621
614
  constructor() {
622
615
  this.m_Left = 0, this.m_Right = 0, this.m_Down = 0, this.m_Up = 0;
623
616
  }
@@ -648,7 +641,7 @@ const Y = class Y {
648
641
  }
649
642
  // ── Helpers ───────────────────────────────────────────────────────────
650
643
  clamp(t) {
651
- return Math.max(Y.kMin, Math.min(t, Y.kMax));
644
+ return Math.max(st.kMin, Math.min(t, st.kMax));
652
645
  }
653
646
  // ── Transform ─────────────────────────────────────────────────────────
654
647
  /**
@@ -656,18 +649,18 @@ const Y = class Y {
656
649
  * book direction.
657
650
  */
658
651
  transform(t) {
659
- const e = new Y();
652
+ const e = new st();
660
653
  switch (t) {
661
- case X.LeftToRight:
654
+ case j.LeftToRight:
662
655
  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
656
  break;
664
- case X.RightToLeft:
657
+ case j.RightToLeft:
665
658
  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
659
  break;
667
- case X.UpToDown:
660
+ case j.UpToDown:
668
661
  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
662
  break;
670
- case X.DownToUp:
663
+ case j.DownToUp:
671
664
  default:
672
665
  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
666
  break;
@@ -682,7 +675,7 @@ const Y = class Y {
682
675
  * Unity's `Mathf.InverseLerp(a, b, v)` = `(v - a) / (b - a)` clamped to [0,1].
683
676
  */
684
677
  fixUV(t) {
685
- return t.x = Y.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = Y.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
678
+ return t.x = st.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = st.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
686
679
  }
687
680
  static inverseLerp(t, e, s) {
688
681
  if (t === e) return 0;
@@ -691,15 +684,15 @@ const Y = class Y {
691
684
  }
692
685
  // ── Value-type clone ──────────────────────────────────────────────────
693
686
  clone() {
694
- const t = new Y();
687
+ const t = new st();
695
688
  return t.m_Left = this.m_Left, t.m_Right = this.m_Right, t.m_Down = this.m_Down, t.m_Up = this.m_Up, t;
696
689
  }
697
690
  };
698
- Y.kMin = 0, Y.kMax = 0.25;
699
- let pt = Y;
700
- const N = class N {
691
+ st.kMin = 0, st.kMax = 0.25;
692
+ let gt = st;
693
+ const X = class X {
701
694
  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 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) ?? N.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? N.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? N.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
695
+ this.m_Material = null, this.m_Color = new l.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new l.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
703
696
  }
704
697
  // ── Properties ────────────────────────────────────────────────────────
705
698
  get material() {
@@ -718,19 +711,19 @@ const N = class N {
718
711
  return this.bookDirection > 1 ? this.m_Height : this.m_Width;
719
712
  }
720
713
  set width(t) {
721
- this.m_Width = Math.max(t, N.kMinSize);
714
+ this.m_Width = Math.max(t, X.kMinSize);
722
715
  }
723
716
  get height() {
724
717
  return this.bookDirection > 1 ? this.m_Width : this.m_Height;
725
718
  }
726
719
  set height(t) {
727
- this.m_Height = Math.max(t, N.kMinSize);
720
+ this.m_Height = Math.max(t, X.kMinSize);
728
721
  }
729
722
  get thickness() {
730
723
  return this.m_Thickness;
731
724
  }
732
725
  set thickness(t) {
733
- this.m_Thickness = Math.max(t, N.kMinThickness);
726
+ this.m_Thickness = Math.max(t, X.kMinThickness);
734
727
  }
735
728
  get stiffness() {
736
729
  return this.m_Stiffness;
@@ -743,8 +736,8 @@ const N = class N {
743
736
  }
744
737
  set quality(t) {
745
738
  this.m_Quality = Math.max(
746
- N.kMinQuality,
747
- Math.min(t, N.kMaxQuality)
739
+ X.kMinQuality,
740
+ Math.min(t, X.kMaxQuality)
748
741
  );
749
742
  }
750
743
  get uvMargin() {
@@ -754,15 +747,15 @@ const N = class N {
754
747
  this.m_UVMargin = t;
755
748
  }
756
749
  get size() {
757
- return new c.Vector2(this.width, this.height);
750
+ return new l.Vector2(this.width, this.height);
758
751
  }
759
752
  };
760
- N.kMinSize = 1, N.kMinThickness = 1e-4, N.kMinQuality = 1, N.kMaxQuality = 5;
761
- let nt = N;
762
- class At {
753
+ X.kMinSize = 1, X.kMinThickness = 1e-4, X.kMinQuality = 1, X.kMaxQuality = 5;
754
+ let rt = X;
755
+ class zt {
763
756
  constructor(t) {
764
- this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
765
- const e = t.material ?? new c.MeshStandardMaterial();
757
+ this.m_Texture = null, this.m_TextureST = new l.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
758
+ const e = t.material ?? new l.MeshStandardMaterial();
766
759
  this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
767
760
  }
768
761
  get materials1() {
@@ -783,27 +776,29 @@ class At {
783
776
  /**
784
777
  * Mirrors Unity's MaterialPropertyBlock: stores color, texture, and textureST.
785
778
  * Paper.ts reads this after calling updatePropertyBlock.
779
+ *
780
+ * Returns a cached object — callers must NOT mutate the returned values.
786
781
  */
787
782
  get propertyBlock() {
788
- return {
783
+ return (this._propertyBlockDirty || this._cachedPropertyBlock === null) && (this._cachedPropertyBlock = {
789
784
  color: this.m_Color.clone(),
790
785
  map: this.m_Texture,
791
786
  textureST: this.m_TextureST.clone()
792
- };
787
+ }, this._propertyBlockDirty = !1), this._cachedPropertyBlock;
793
788
  }
794
789
  updatePropertyBlock(t, e) {
795
- this.m_Texture = t, this.m_TextureST.copy(e);
790
+ this.m_Texture = t, this.m_TextureST.copy(e), this._propertyBlockDirty = !0;
796
791
  }
797
792
  }
798
- function Ht(r, t, e, s = new c.Vector3()) {
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
- i *= a, n *= a, o *= a;
801
- let h = e.x - r.x, m = e.y - r.y, l = e.z - r.z;
802
- a = 1 / Math.sqrt(h * h + m * m + l * l), h *= a, m *= a, l *= 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);
793
+ function At(r, t, e, s = new l.Vector3()) {
794
+ let i = t.x - r.x, n = t.y - r.y, h = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + h * h);
795
+ i *= a, n *= a, h *= a;
796
+ let o = e.x - r.x, u = e.y - r.y, c = e.z - r.z;
797
+ a = 1 / Math.sqrt(o * o + u * u + c * c), o *= a, u *= a, c *= a;
798
+ const m = n * c - h * u, f = h * o - i * c, d = i * u - n * o;
799
+ return a = 1 / Math.sqrt(m * m + f * f + d * d), s.set(m * a, f * a, d * a);
805
800
  }
806
- class st {
801
+ class ht {
807
802
  constructor(t, e = !1, s = !1) {
808
803
  this.prev = null, this.next = null, this.index = 0, this.value = t, this.hole = e, this.seam = s;
809
804
  }
@@ -822,13 +817,7 @@ class st {
822
817
  }
823
818
  // ── Factory helpers ───────────────────────────────────────────────────
824
819
  createNext(t, e = !1, s = !1) {
825
- const i = new st(t, e, s);
826
- return i.prev = this, this.next = i, i;
827
- }
828
- // C# had a double overload — in TS numbers are already IEEE 754 doubles.
829
- // Keeping a separate method for parity; it simply casts to number.
830
- createNextFromDouble(t, e = !1, s = !1) {
831
- const i = new st(t, e, s);
820
+ const i = new ht(t, e, s);
832
821
  return i.prev = this, this.next = i, i;
833
822
  }
834
823
  // ── Insertion (sorted linked-list insert) ─────────────────────────────
@@ -869,12 +858,12 @@ class Pt {
869
858
  return t.active = this.active, t;
870
859
  }
871
860
  }
872
- class St {
873
- constructor(t, e, s, i, n, o = !0) {
874
- this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = o;
861
+ class Tt {
862
+ constructor(t, e, s, i, n, h = !0) {
863
+ this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = h;
875
864
  }
876
865
  clone() {
877
- return new St(
866
+ return new Tt(
878
867
  this.startX,
879
868
  this.startZ,
880
869
  this.endX,
@@ -884,197 +873,157 @@ class St {
884
873
  );
885
874
  }
886
875
  }
887
- class ue {
876
+ class oe {
888
877
  constructor(t, e, s) {
889
878
  const i = t.size;
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);
879
+ this.leftNode = new ht(e.left * i.x, s, !0), this.rightNode = new ht((1 - e.right) * i.x, s, !0), this.downNode = new ht(e.down * i.y, s, !0), this.upNode = new ht((1 - e.up) * i.y, s, !0);
891
880
  }
892
881
  insert(t, e, s, i) {
893
882
  t.insert(this.leftNode) && s.push(this.leftNode), t.insert(this.rightNode) && s.push(this.rightNode), e.insert(this.downNode) && i.push(this.downNode), e.insert(this.upNode) && i.push(this.upNode);
894
883
  }
895
884
  }
896
- function lt(r, t, e) {
897
- if (r === t) return 0;
898
- const s = (e - r) / (t - r);
899
- return Math.max(0, Math.min(1, s));
900
- }
901
- function xt(r, t) {
885
+ function pt(r, t) {
902
886
  for (const e of r) {
903
- const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new Pt(s.index, e.index, i.index, n);
904
- t.push(o);
887
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new Pt(s.index, e.index, i.index, n);
888
+ t.push(h);
905
889
  }
906
890
  }
907
- function Mt(r, t, e, s, i) {
908
- for (const n of r) {
909
- if (!n.active) return;
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], d = t[o * e + n.index];
912
- i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
913
- }
914
- }
891
+ function xt(r, t, e, s, i) {
892
+ for (const n of r)
893
+ if (n.active)
894
+ for (let h = 0; h < s; h++) {
895
+ const a = n.prevIndex, o = n.nextIndex, u = t[h * e + a], c = t[h * e + o], m = t[h * e + n.index];
896
+ i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
897
+ }
915
898
  }
916
- function Ct(r, t, e, s, i) {
917
- for (const n of r) {
918
- if (!n.active) return;
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], d = t[n.index * e + o];
921
- i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
922
- }
923
- }
899
+ function Mt(r, t, e, s, i) {
900
+ for (const n of r)
901
+ if (n.active)
902
+ for (let h = 0; h < e; h++) {
903
+ const a = n.prevIndex, o = n.nextIndex, u = t[a * e + h], c = t[o * e + h], m = t[n.index * e + h];
904
+ i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
905
+ }
924
906
  }
925
- function qt(r, t, e, s = new c.Vector3()) {
907
+ function Gt(r, t, e, s = new l.Vector3()) {
926
908
  const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
927
909
  if (i === 0 || n === 0)
928
910
  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, 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)
911
+ const h = r.x / i, a = r.y / i, o = r.z / i, u = t.x / n, c = t.y / n, m = t.z / n;
912
+ let f = h * u + a * c + o * m;
913
+ f = Math.max(-1, Math.min(1, f));
914
+ const d = Math.acos(f);
915
+ if (d < 1e-6)
934
916
  return s.copy(r).lerp(t, e);
935
- const u = Math.sin(_), f = Math.sin((1 - e) * _) / u, p = Math.sin(e * _) / u, P = i + (n - i) * e;
917
+ const _ = Math.sin(d), g = Math.sin((1 - e) * d) / _, p = Math.sin(e * d) / _, M = i + (n - i) * e;
936
918
  return s.set(
937
- (o * f + m * p) * P,
938
- (a * f + l * p) * P,
939
- (h * f + d * p) * P
919
+ (h * g + u * p) * M,
920
+ (a * g + c * p) * M,
921
+ (o * g + m * p) * M
940
922
  );
941
923
  }
942
- function Qt(r, t, e, s, i) {
924
+ function jt(r, t, e, s, i) {
943
925
  for (const n of r) {
944
- const o = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, h = e.length;
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);
926
+ const h = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, o = e.length;
927
+ for (let c = 0, m = n.endX - n.startX; c < m; c++) {
928
+ const f = o + c * 2 + 0, d = o + c * 2 + 1, _ = o + c * 2 + 2, g = o + c * 2 + 3;
929
+ n.flip ? Ft(t, f, d, _, g, h) : Ht(t, f, d, _, g, h);
948
930
  }
949
931
  if (n.left)
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);
932
+ for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
933
+ const f = o + c * 2 + 0 + h * 2, d = o + c * 2 + 1 + h * 2, _ = o + c * 2 + 2 + h * 2, g = o + c * 2 + 3 + h * 2;
934
+ n.flip ? Ft(t, f, d, _, g, a) : Ht(t, f, d, _, g, a);
953
935
  }
954
936
  else
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);
937
+ for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
938
+ const f = o + c * 2 + 0 + h * 2 + a, d = o + c * 2 + 1 + h * 2 + a, _ = o + c * 2 + 2 + h * 2 + a, g = o + c * 2 + 3 + h * 2 + a;
939
+ n.flip ? _t(t, f, d, _, g) : mt(t, f, d, _, g);
958
940
  }
959
- const m = s * i;
960
- for (let l = n.startX; l <= n.endX; l++) {
961
- const d = n.startZ * s + l;
962
- e.push(e[d].clone()), e.push(e[d + m].clone());
941
+ const u = s * i;
942
+ for (let c = n.startX; c <= n.endX; c++) {
943
+ const m = n.startZ * s + c;
944
+ e.push(e[m].clone()), e.push(e[m + u].clone());
963
945
  }
964
- for (let l = n.startX; l <= n.endX; l++) {
965
- const d = l + n.endZ * s;
966
- e.push(e[d + m].clone()), e.push(e[d].clone());
946
+ for (let c = n.startX; c <= n.endX; c++) {
947
+ const m = c + n.endZ * s;
948
+ e.push(e[m + u].clone()), e.push(e[m].clone());
967
949
  }
968
- for (let l = n.startZ; l <= n.endZ; l++) {
969
- const d = n.startX + l * s;
970
- e.push(e[d + m].clone()), e.push(e[d].clone());
950
+ for (let c = n.startZ; c <= n.endZ; c++) {
951
+ const m = n.startX + c * s;
952
+ e.push(e[m + u].clone()), e.push(e[m].clone());
971
953
  }
972
- for (let l = n.startZ; l <= n.endZ; l++) {
973
- const d = l * s + n.endX;
974
- e.push(e[d].clone()), e.push(e[d + m].clone());
954
+ for (let c = n.startZ; c <= n.endZ; c++) {
955
+ const m = c * s + n.endX;
956
+ e.push(e[m].clone()), e.push(e[m + u].clone());
975
957
  }
976
958
  }
977
959
  }
978
- function $t(r, t, e, s, i) {
960
+ function qt(r, t, e, s, i) {
979
961
  const n = s * i;
980
- let o = n * 2;
981
- const a = new c.Vector3();
982
- for (const h of r) {
983
- for (let m = h.startX; m <= h.endX; m++) {
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
- }
987
- for (let m = h.startX; m <= h.endX; m++) {
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
- }
991
- for (let m = h.startZ; m <= h.endZ; m++) {
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
- }
995
- for (let m = h.startZ; m <= h.endZ; m++) {
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
- }
999
- }
1000
- }
1001
- function de(r, t, e, s, i) {
1002
- const n = [];
962
+ let h = n * 2;
963
+ const a = new l.Vector3();
1003
964
  for (const o of r) {
1004
- for (let a = o.startX; a < o.endX; a++) {
1005
- const h = a + o.startZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
1006
- n.push([m, l]);
965
+ for (let u = o.startX; u <= o.endX; u++) {
966
+ const c = u + o.startZ * s, m = t[c], f = t[c + s];
967
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
1007
968
  }
1008
- for (let a = o.startX; a < o.endX; a++) {
1009
- const h = a + o.endZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
1010
- n.push([m, l]);
969
+ for (let u = o.startX; u <= o.endX; u++) {
970
+ const c = u + o.endZ * s, m = t[c + n], f = t[c + n - s];
971
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
1011
972
  }
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), d = t[m].clone().applyMatrix4(i);
1014
- n.push([l, d]);
973
+ for (let u = o.startZ; u <= o.endZ; u++) {
974
+ const c = u * s + o.startX, m = t[c + n], f = t[c + n + 1];
975
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
1015
976
  }
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), d = t[m].clone().applyMatrix4(i);
1018
- n.push([l, d]);
977
+ for (let u = o.startZ; u <= o.endZ; u++) {
978
+ const c = u * s + o.endX, m = t[c], f = t[c - 1];
979
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
1019
980
  }
1020
981
  }
1021
- return n;
982
+ }
983
+ function Ht(r, t, e, s, i, n) {
984
+ mt(r, t, e, s, i), t += n, e += n, s += n, i += n, mt(r, t, e, s, i);
1022
985
  }
1023
986
  function Ft(r, t, e, s, i, n) {
1024
987
  _t(r, t, e, s, i), t += n, e += n, s += n, i += n, _t(r, t, e, s, i);
1025
988
  }
1026
- function Ot(r, t, e, s, i, n) {
1027
- ft(r, t, e, s, i), t += n, e += n, s += n, i += n, ft(r, t, e, s, i);
989
+ function Qt(r, t, e, s, i, n, h) {
990
+ mt(r, e, s, i, n), e += h, s += h, i += h, n += h, _t(t, e, s, i, n);
1028
991
  }
1029
- function Yt(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
- }
1032
- function Kt(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;
992
+ function $t(r, t, e, s, i, n) {
993
+ const h = i.left * s.x, a = (1 - i.right) * s.x, o = i.down * s.y, u = (1 - i.up) * s.y, c = t.length, m = e.length;
1034
994
  if (n > 1)
1035
- for (let _ = 0; _ < d; _++)
1036
- for (let u = 0; u < l; u++) {
1037
- const f = lt(a, o, t[u]), p = lt(m, h, e[_]);
1038
- r.push(new c.Vector2(p, f));
995
+ for (let d = 0; d < m; d++)
996
+ for (let _ = 0; _ < c; _++) {
997
+ const g = Q(a, h, t[_]), p = Q(u, o, e[d]);
998
+ r.push(new l.Vector2(p, g));
1039
999
  }
1040
1000
  else
1041
- for (let _ = 0; _ < d; _++)
1042
- for (let u = 0; u < l; u++) {
1043
- const f = lt(o, a, t[u]), p = lt(m, h, e[_]);
1044
- r.push(new c.Vector2(f, p));
1001
+ for (let d = 0; d < m; d++)
1002
+ for (let _ = 0; _ < c; _++) {
1003
+ const g = Q(h, a, t[_]), p = Q(u, o, e[d]);
1004
+ r.push(new l.Vector2(g, p));
1045
1005
  }
1046
- const g = r.length;
1047
- for (let _ = 0; _ < g; _++)
1048
- r.push(r[_].clone());
1006
+ const f = r.length;
1007
+ for (let d = 0; d < f; d++)
1008
+ r.push(r[d].clone());
1049
1009
  }
1050
- function _t(r, t, e, s, i) {
1010
+ function mt(r, t, e, s, i) {
1051
1011
  r.push(t), r.push(s), r.push(e), r.push(e), r.push(s), r.push(i);
1052
1012
  }
1053
- function ft(r, t, e, s, i) {
1013
+ function _t(r, t, e, s, i) {
1054
1014
  r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1055
1015
  }
1056
- function Jt(r, t, e, s) {
1057
- const i = [];
1058
- for (let n = 0; n < e - 1; n++)
1059
- for (let o = 0; o < t - 1; o++) {
1060
- let a = r[n * t + o].clone(), h = r[n * t + o + 1].clone(), m = r[(n + 1) * t + o].clone(), l = r[(n + 1) * t + o + 1].clone();
1061
- a.applyMatrix4(s), h.applyMatrix4(s), m.applyMatrix4(s), l.applyMatrix4(s), i.push([a, h, m, l]);
1062
- }
1063
- return i;
1064
- }
1065
- const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1016
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1066
1017
  __proto__: null,
1067
- addBorders: Qt,
1068
- addFrontAndBackFaces: Yt,
1069
- addFrontAndBackTexcoords: Kt,
1070
- debugDrawBorders: de,
1071
- drawWireframe: Jt,
1072
- seamNodesToSeams: xt,
1073
- updateBorders: $t,
1074
- updateXSeams: Mt,
1075
- updateZSeams: Ct
1018
+ addBorders: jt,
1019
+ addFrontAndBackFaces: Qt,
1020
+ addFrontAndBackTexcoords: $t,
1021
+ seamNodesToSeams: pt,
1022
+ updateBorders: qt,
1023
+ updateXSeams: xt,
1024
+ updateZSeams: Mt
1076
1025
  }, Symbol.toStringTag, { value: "Module" }));
1077
- class Zt {
1026
+ class Ot {
1078
1027
  get geometry() {
1079
1028
  return this.m_Geometry;
1080
1029
  }
@@ -1086,34 +1035,34 @@ class Zt {
1086
1035
  }
1087
1036
  constructor(t, e) {
1088
1037
  this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1089
- for (let o = 0; o < e.baseVertexCount; o++)
1090
- this.m_BaseVertices[o] = new c.Vector3();
1038
+ for (let h = 0; h < e.baseVertexCount; h++)
1039
+ this.m_BaseVertices[h] = new l.Vector3();
1091
1040
  this.m_Vertices = new Array(e.vertexCount);
1092
- for (let o = 0; o < e.vertexCount; o++)
1093
- this.m_Vertices[o] = new c.Vector3();
1041
+ for (let h = 0; h < e.vertexCount; h++)
1042
+ this.m_Vertices[h] = new l.Vector3();
1094
1043
  this.m_Normals = new Array(e.vertexCount);
1095
- for (let o = 0; o < e.vertexCount; o++)
1096
- this.m_Normals[o] = new c.Vector3();
1044
+ for (let h = 0; h < e.vertexCount; h++)
1045
+ this.m_Normals[h] = new l.Vector3();
1097
1046
  if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1098
- const o = new Uint32Array(e.triangles);
1099
- this.m_Geometry.setIndex(new c.BufferAttribute(o, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1047
+ const h = new Uint32Array(e.triangles);
1048
+ this.m_Geometry.setIndex(new l.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1100
1049
  } else {
1101
- const o = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(o);
1102
- let h = 0;
1103
- a.set(e.frontTriangles, h), this.m_Geometry.addGroup(h, e.frontTriangles.length, 0), h += e.frontTriangles.length, a.set(e.backTriangles, h), this.m_Geometry.addGroup(h, e.backTriangles.length, 1), h += e.backTriangles.length, a.set(e.borderTriangles, h), this.m_Geometry.addGroup(h, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(a, 1));
1050
+ const h = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(h);
1051
+ let o = 0;
1052
+ a.set(e.frontTriangles, o), this.m_Geometry.addGroup(o, e.frontTriangles.length, 0), o += e.frontTriangles.length, a.set(e.backTriangles, o), this.m_Geometry.addGroup(o, e.backTriangles.length, 1), o += e.backTriangles.length, a.set(e.borderTriangles, o), this.m_Geometry.addGroup(o, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new l.BufferAttribute(a, 1));
1104
1053
  }
1105
1054
  const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1106
- for (let o = 0; o < e.texcoords.length; o++)
1107
- n[o * 2] = e.texcoords[o].x, n[o * 2 + 1] = e.texcoords[o].y;
1055
+ for (let h = 0; h < e.texcoords.length; h++)
1056
+ n[h * 2] = e.texcoords[h].x, n[h * 2 + 1] = e.texcoords[h].y;
1108
1057
  this.m_Geometry.setAttribute(
1109
1058
  "position",
1110
- new c.BufferAttribute(s, 3)
1059
+ new l.BufferAttribute(s, 3)
1111
1060
  ), this.m_Geometry.setAttribute(
1112
1061
  "normal",
1113
- new c.BufferAttribute(i, 3)
1062
+ new l.BufferAttribute(i, 3)
1114
1063
  ), this.m_Geometry.setAttribute(
1115
1064
  "uv",
1116
- new c.BufferAttribute(n, 2)
1065
+ new l.BufferAttribute(n, 2)
1117
1066
  ), this.updateBaseVertices();
1118
1067
  }
1119
1068
  // ── UpdateBaseVertices ──────────────────────────────────────────────────
@@ -1124,11 +1073,11 @@ class Zt {
1124
1073
  * Ported from lines ~2167-2183.
1125
1074
  */
1126
1075
  updateBaseVertices() {
1127
- const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, o = s.length;
1076
+ const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, h = s.length;
1128
1077
  let a = 0;
1129
- for (let h = 0; h < o; h++)
1130
- for (let m = 0; m < n; m++)
1131
- t[a++].set(e[m] + i, 0, s[h]);
1078
+ for (let o = 0; o < h; o++)
1079
+ for (let u = 0; u < n; u++)
1080
+ t[a++].set(e[u] + i, 0, s[o]);
1132
1081
  }
1133
1082
  // ── UpdateMesh ─────────────────────────────────────────────────────────
1134
1083
  /**
@@ -1147,59 +1096,49 @@ class Zt {
1147
1096
  * Ported from lines ~2185-2255.
1148
1097
  */
1149
1098
  updateMesh() {
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
- for (let u = 0; u < a; u++)
1152
- s[u].set(0, 0, 0);
1153
- Mt(this.m_Pattern.xSeams, t, n, o, !1), Ct(this.m_Pattern.zSeams, t, n, o, !1);
1154
- for (let u = 0; u < o - 1; u++) {
1155
- const f = u + 1;
1099
+ const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, o = new l.Vector3(), u = new l.Vector3(), c = new l.Vector3();
1100
+ for (let _ = 0; _ < a; _++)
1101
+ s[_].set(0, 0, 0);
1102
+ xt(this.m_Pattern.xSeams, t, n, h, !1), Mt(this.m_Pattern.zSeams, t, n, h, !1);
1103
+ for (let _ = 0; _ < h - 1; _++) {
1104
+ const g = _ + 1;
1156
1105
  for (let p = 0; p < n - 1; p++) {
1157
- const P = p + 1, B = u * n + p, M = u * n + P, w = f * n + p, T = f * n + P, k = t[B], O = t[M], Z = t[w], z = t[T];
1158
- Ht(k, Z, O, h), Ht(z, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[w].add(l), s[T].add(l);
1106
+ const M = p + 1, T = _ * n + p, P = _ * n + M, C = g * n + p, k = g * n + M, I = t[T], U = t[P], L = t[C], z = t[k];
1107
+ At(I, L, U, o), At(z, U, L, u), c.addVectors(o, u), s[T].add(c), s[P].add(c), s[C].add(c), s[k].add(c);
1159
1108
  }
1160
1109
  }
1161
- for (let u = 0; u < a; u++)
1162
- s[u].divideScalar(i[u]).normalize();
1163
- Mt(this.m_Pattern.xSeams, s, n, o, !0), Ct(this.m_Pattern.zSeams, s, n, o, !0);
1164
- const d = this.m_Pattern.thickness / 2;
1165
- for (let u = 0; u < a; u++) {
1166
- const f = s[u];
1167
- s[u + a].copy(f).negate();
1168
- const p = t[u];
1169
- e[u].copy(p).addScaledVector(f, d), e[u + a].copy(p).addScaledVector(f, -d);
1170
- }
1171
- $t(this.m_Pattern.borders, e, s, n, o);
1172
- const g = this.m_Geometry.getAttribute(
1110
+ for (let _ = 0; _ < a; _++)
1111
+ s[_].divideScalar(i[_]).normalize();
1112
+ xt(this.m_Pattern.xSeams, s, n, h, !0), Mt(this.m_Pattern.zSeams, s, n, h, !0);
1113
+ const m = this.m_Pattern.thickness / 2;
1114
+ for (let _ = 0; _ < a; _++) {
1115
+ const g = s[_];
1116
+ s[_ + a].copy(g).negate();
1117
+ const p = t[_];
1118
+ e[_].copy(p).addScaledVector(g, m), e[_ + a].copy(p).addScaledVector(g, -m);
1119
+ }
1120
+ qt(this.m_Pattern.borders, e, s, n, h);
1121
+ const f = this.m_Geometry.getAttribute(
1173
1122
  "position"
1174
- ), _ = this.m_Geometry.getAttribute(
1123
+ ), d = this.m_Geometry.getAttribute(
1175
1124
  "normal"
1176
1125
  );
1177
- for (let u = 0; u < e.length; u++) {
1178
- const f = e[u];
1179
- g.setXYZ(u, f.x, f.y, f.z);
1180
- const p = s[u];
1181
- _.setXYZ(u, p.x, p.y, p.z);
1126
+ for (let _ = 0; _ < e.length; _++) {
1127
+ const g = e[_];
1128
+ f.setXYZ(_, g.x, g.y, g.z);
1129
+ const p = s[_];
1130
+ d.setXYZ(_, p.x, p.y, p.z);
1182
1131
  }
1183
- g.needsUpdate = !0, _.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1184
- }
1185
- // ── DrawWireframe (debug) ──────────────────────────────────────────────
1186
- /**
1187
- * Returns wireframe quad data for debug visualisation.
1188
- *
1189
- * Ported from lines ~2257-2262.
1190
- */
1191
- drawWireframe(t) {
1192
- const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
1193
- return Jt(this.m_Vertices, e, s, t);
1132
+ f.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1194
1133
  }
1195
1134
  }
1196
- class _e {
1135
+ class le {
1197
1136
  constructor() {
1198
1137
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1199
1138
  }
1200
1139
  get() {
1201
1140
  let t;
1202
- return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new c.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1141
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new l.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1203
1142
  }
1204
1143
  recycle() {
1205
1144
  for (const t of this.m_UsedMeshs)
@@ -1212,19 +1151,16 @@ class _e {
1212
1151
  this.m_Meshs.clear();
1213
1152
  }
1214
1153
  }
1215
- class fe {
1154
+ class ce {
1216
1155
  constructor(t) {
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
- }
1219
- set createColliders(t) {
1220
- this.m_CreateMeshCollider = t;
1156
+ this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1221
1157
  }
1222
1158
  get ids() {
1223
1159
  return [...this.m_Ids];
1224
1160
  }
1225
1161
  get(t) {
1226
1162
  let e;
1227
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new pe(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1163
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new me(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1228
1164
  }
1229
1165
  recycle() {
1230
1166
  for (const t of this.m_UsedRenderers)
@@ -1237,29 +1173,23 @@ class fe {
1237
1173
  this.m_Renderers.clear();
1238
1174
  }
1239
1175
  getBounds() {
1240
- const t = new c.Box3();
1176
+ const t = new l.Box3();
1241
1177
  let e = !0;
1242
1178
  for (const s of this.m_UsedRenderers)
1243
1179
  e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1244
1180
  return t;
1245
1181
  }
1246
1182
  }
1247
- let ge = 1;
1248
- class pe {
1249
- constructor(t, e, s) {
1250
- this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ge++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1251
- new c.BufferGeometry(),
1252
- new c.MeshStandardMaterial()
1253
- ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
1254
- }
1255
- get createCollider() {
1256
- return this.m_CreateCollider;
1257
- }
1258
- set createCollider(t) {
1259
- this.m_CreateCollider = t;
1183
+ let ue = 1;
1184
+ class me {
1185
+ constructor(t, e) {
1186
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ue++, this.m_Object3D = new l.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new l.Mesh(
1187
+ new l.BufferGeometry(),
1188
+ new l.MeshStandardMaterial()
1189
+ ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D);
1260
1190
  }
1261
1191
  get bounds() {
1262
- const t = new c.Box3();
1192
+ const t = new l.Box3();
1263
1193
  return this.m_Mesh.geometry && (this.m_Mesh.geometry.computeBoundingBox(), this.m_Mesh.geometry.boundingBox && (t.copy(this.m_Mesh.geometry.boundingBox), t.applyMatrix4(this.m_Mesh.matrixWorld))), t;
1264
1194
  }
1265
1195
  get id() {
@@ -1271,9 +1201,15 @@ class pe {
1271
1201
  get visibility() {
1272
1202
  return this.m_Visibility;
1273
1203
  }
1204
+ get castShadows() {
1205
+ return this.m_Mesh.castShadow;
1206
+ }
1274
1207
  set castShadows(t) {
1275
1208
  this.m_Mesh.castShadow = t;
1276
1209
  }
1210
+ get mesh() {
1211
+ return this.m_Mesh.geometry ?? null;
1212
+ }
1277
1213
  set mesh(t) {
1278
1214
  t && (this.m_Mesh.geometry = t);
1279
1215
  }
@@ -1281,23 +1217,23 @@ class pe {
1281
1217
  return this.m_Mesh;
1282
1218
  }
1283
1219
  setMaterials(t) {
1284
- this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new c.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1220
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new l.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1285
1221
  }
1286
1222
  setPropertyBlock(t, e) {
1287
1223
  this.m_PropertyBlocks.set(e, t);
1288
1224
  const s = this.getMaterial(e);
1289
- s && (this.isMapCapable(s) && (t.map instanceof c.Texture ? this.applyTextureProperty(
1225
+ s && (this.isMapCapable(s) && (t.map instanceof l.Texture ? this.applyTextureProperty(
1290
1226
  s,
1291
1227
  e,
1292
1228
  t.map,
1293
1229
  t.textureST
1294
- ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && t.color instanceof c.Color && s.color.copy(t.color));
1230
+ ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && s.color.copy(t.color));
1295
1231
  }
1296
1232
  reset(t) {
1297
- this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry = new c.BufferGeometry(), this.setMaterials([]);
1233
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.setMaterials([]);
1298
1234
  }
1299
1235
  clear() {
1300
- this.m_Object3D.name = "", this.m_Mesh.geometry = new c.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1236
+ this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1301
1237
  }
1302
1238
  destroy() {
1303
1239
  this.disposeManagedTextures(), this.disposeCurrentMaterials(), this.m_Mesh.geometry && this.m_Mesh.geometry.dispose(), this.m_Object3D.parent && this.m_Object3D.parent.remove(this.m_Object3D);
@@ -1305,8 +1241,6 @@ class pe {
1305
1241
  setVisibility(t) {
1306
1242
  this.m_Visibility !== t && (this.m_Visibility = t, this.m_Object3D.visible = t);
1307
1243
  }
1308
- updateCollider() {
1309
- }
1310
1244
  getMaterial(t) {
1311
1245
  return Array.isArray(this.m_Mesh.material) ? this.m_Mesh.material[t] ?? null : this.m_Mesh.material;
1312
1246
  }
@@ -1314,20 +1248,20 @@ class pe {
1314
1248
  return "map" in t;
1315
1249
  }
1316
1250
  isColorCapable(t) {
1317
- return "color" in t && t.color instanceof c.Color;
1251
+ return "color" in t && t.color instanceof l.Color;
1318
1252
  }
1319
1253
  getSTKey(t) {
1320
1254
  return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
1321
1255
  }
1322
1256
  applyTextureProperty(t, e, s, i) {
1323
- const n = this.getSTKey(i), o = this.m_MaterialTextures.get(e);
1324
- if (o && o.source === s && o.stKey === n) {
1325
- t.map !== o.texture && (t.map = o.texture, t.needsUpdate = !0);
1257
+ const n = this.getSTKey(i), h = this.m_MaterialTextures.get(e);
1258
+ if (h && h.source === s && h.stKey === n) {
1259
+ t.map !== h.texture && (t.map = h.texture, t.needsUpdate = !0);
1326
1260
  return;
1327
1261
  }
1328
1262
  this.clearManagedTexture(e);
1329
1263
  const a = s.clone();
1330
- a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = c.RepeatWrapping, a.wrapT = c.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1264
+ a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = l.RepeatWrapping, a.wrapT = l.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1331
1265
  source: s,
1332
1266
  texture: a,
1333
1267
  stKey: n
@@ -1351,20 +1285,20 @@ class pe {
1351
1285
  e.dispose();
1352
1286
  }
1353
1287
  }
1354
- class xe {
1288
+ class _e {
1355
1289
  constructor(t, e, s = !1) {
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());
1290
+ this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Ot(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1357
1291
  }
1358
1292
  get() {
1359
- return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Zt(this.m_MeshFactory.get(), this.m_Pattern);
1293
+ return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Ot(this.m_MeshFactory.get(), this.m_Pattern);
1360
1294
  }
1361
1295
  free(t) {
1362
1296
  if (this.m_UseSharedData) throw new Error("Not implemented");
1363
1297
  this.m_Stack.push(t);
1364
1298
  }
1365
1299
  }
1366
- var wt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(wt || {}), Me = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(Me || {}), Ce = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(Ce || {}), we = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(we || {});
1367
- class ye {
1300
+ var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), de = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(de || {}), fe = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(fe || {});
1301
+ class ge {
1368
1302
  constructor(t) {
1369
1303
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1370
1304
  }
@@ -1386,16 +1320,10 @@ class ye {
1386
1320
  return e[s - 1].value;
1387
1321
  }
1388
1322
  }
1389
- function rt(r, t, e) {
1390
- return Math.max(t, Math.min(e, r));
1391
- }
1392
- function Pe(r, t, e) {
1393
- return r === t ? 0 : rt((e - r) / (t - r), 0, 1);
1394
- }
1395
- function Ut(r, t) {
1323
+ function Zt(r, t) {
1396
1324
  return r + Math.random() * (t - r);
1397
1325
  }
1398
- class ot {
1326
+ class at {
1399
1327
  constructor(t, e) {
1400
1328
  this.m_Mode = 0, this.m_Constant = 0, this.m_ConstantMin = 0, this.m_ConstantMax = 0, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_CurveTimeMode = 0, t !== void 0 && (e === void 0 ? (this.m_Constant = t, this.m_ConstantMin = t, this.m_ConstantMax = t, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_Mode = 0, this.m_CurveTimeMode = 0) : (this.m_Constant = 0, this.m_ConstantMin = t, this.m_ConstantMax = e, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_Mode = 1, this.m_CurveTimeMode = 0));
1401
1329
  }
@@ -1450,12 +1378,12 @@ class ot {
1450
1378
  }
1451
1379
  /** A value based on a curve. */
1452
1380
  static fromCurve(t, e) {
1453
- const s = new ot();
1381
+ const s = new at();
1454
1382
  return s.m_Constant = 0, s.m_ConstantMin = 0, s.m_ConstantMax = 0, s.m_Curve = t, s.m_CurveMin = null, s.m_CurveMax = null, s.m_Mode = 2, s.m_CurveTimeMode = e, s;
1455
1383
  }
1456
1384
  /** A random value generated between two curves. */
1457
1385
  static fromCurveRange(t, e, s) {
1458
- const i = new ot();
1386
+ const i = new at();
1459
1387
  return i.m_Constant = 0, i.m_ConstantMin = 0, i.m_ConstantMax = 0, i.m_Curve = null, i.m_CurveMin = t, i.m_CurveMax = e, i.m_Mode = 3, i.m_CurveTimeMode = s, i;
1460
1388
  }
1461
1389
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1463,12 +1391,12 @@ class ot {
1463
1391
  getValue(t, e) {
1464
1392
  if (this.m_Mode === 0) return this.m_Constant;
1465
1393
  if (this.m_Mode === 1)
1466
- return Ut(this.m_ConstantMin, this.m_ConstantMax);
1394
+ return Zt(this.m_ConstantMin, this.m_ConstantMax);
1467
1395
  const s = this.m_CurveTimeMode === 0 ? t : e;
1468
1396
  if (this.m_Mode === 2)
1469
1397
  return this.m_Curve.evaluate(s);
1470
1398
  if (this.m_Mode === 3)
1471
- return Ut(
1399
+ return Zt(
1472
1400
  this.m_CurveMin.evaluate(s),
1473
1401
  this.m_CurveMax.evaluate(s)
1474
1402
  );
@@ -1476,31 +1404,31 @@ class ot {
1476
1404
  }
1477
1405
  /** @internal */
1478
1406
  clampValues(t, e) {
1479
- return this.m_Constant = rt(this.m_Constant, t, e), this.m_ConstantMin = rt(this.m_ConstantMin, t, e), this.m_ConstantMax = rt(this.m_ConstantMax, t, e), this.m_Curve = this.clampCurve(this.m_Curve, t, e), this.m_CurveMin = this.clampCurve(this.m_CurveMin, t, e), this.m_CurveMax = this.clampCurve(this.m_CurveMax, t, e), this;
1407
+ return this.m_Constant = H(this.m_Constant, t, e), this.m_ConstantMin = H(this.m_ConstantMin, t, e), this.m_ConstantMax = H(this.m_ConstantMax, t, e), this.m_Curve = this.clampCurve(this.m_Curve, t, e), this.m_CurveMin = this.clampCurve(this.m_CurveMin, t, e), this.m_CurveMax = this.clampCurve(this.m_CurveMax, t, e), this;
1480
1408
  }
1481
1409
  clampCurve(t, e, s) {
1482
1410
  if (this.m_Curve === null || t === null) return null;
1483
- const i = t.keys.map((h) => ({ time: h.time, value: h.value })), n = i.length;
1484
- let o = 1 / 0, a = -1 / 0;
1485
- for (let h = 0; h < n; h++) {
1486
- const m = i[h].time;
1487
- o = Math.min(o, m), a = Math.max(a, m);
1411
+ const i = t.keys.map((o) => ({ time: o.time, value: o.value })), n = i.length;
1412
+ let h = 1 / 0, a = -1 / 0;
1413
+ for (let o = 0; o < n; o++) {
1414
+ const u = i[o].time;
1415
+ h = Math.min(h, u), a = Math.max(a, u);
1488
1416
  }
1489
- for (let h = 0; h < n; h++) {
1490
- let m = i[h].time, l = i[h].value;
1491
- m = Pe(o, a, m), l = rt(l, e, s), i[h].time = m, i[h].value = l;
1417
+ for (let o = 0; o < n; o++) {
1418
+ let u = i[o].time, c = i[o].value;
1419
+ u = Q(h, a, u), c = H(c, e, s), i[o].time = u, i[o].value = c;
1492
1420
  }
1493
- return new ye(i);
1421
+ return new ge(i);
1494
1422
  }
1495
1423
  // ── Value-type clone ────────────────────────────────────────────────────
1496
1424
  clone() {
1497
- const t = new ot();
1425
+ const t = new at();
1498
1426
  return t.m_Mode = this.m_Mode, t.m_Constant = this.m_Constant, t.m_ConstantMin = this.m_ConstantMin, t.m_ConstantMax = this.m_ConstantMax, t.m_Curve = this.m_Curve, t.m_CurveMin = this.m_CurveMin, t.m_CurveMax = this.m_CurveMax, t.m_CurveTimeMode = this.m_CurveTimeMode, t;
1499
1427
  }
1500
1428
  }
1501
- const R = class R {
1429
+ const D = class D {
1502
1430
  constructor() {
1503
- this.m_Mode = 0, this.m_Twist = new ot(), this.m_Bend = new ot(1), this.m_Duration = new ot(0.5);
1431
+ this.m_Mode = ut.Surface, this.m_Twist = new at(), this.m_Bend = new at(1), this.m_Duration = new at(0.5);
1504
1432
  }
1505
1433
  // ── Properties ──────────────────────────────────────────────────────────
1506
1434
  get mode() {
@@ -1514,8 +1442,8 @@ const R = class R {
1514
1442
  }
1515
1443
  set twist(t) {
1516
1444
  this.m_Twist = t.clampValues(
1517
- R.kMinTwist,
1518
- R.kMaxTwist
1445
+ D.kMinTwist,
1446
+ D.kMaxTwist
1519
1447
  );
1520
1448
  }
1521
1449
  get bend() {
@@ -1523,8 +1451,8 @@ const R = class R {
1523
1451
  }
1524
1452
  set bend(t) {
1525
1453
  this.m_Bend = t.clampValues(
1526
- R.kMinBend,
1527
- R.kMaxBend
1454
+ D.kMinBend,
1455
+ D.kMaxBend
1528
1456
  );
1529
1457
  }
1530
1458
  get duration() {
@@ -1532,8 +1460,8 @@ const R = class R {
1532
1460
  }
1533
1461
  set duration(t) {
1534
1462
  this.m_Duration = t.clampValues(
1535
- R.kMinDuration,
1536
- R.kMaxDuration
1463
+ D.kMinDuration,
1464
+ D.kMaxDuration
1537
1465
  );
1538
1466
  }
1539
1467
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1543,70 +1471,71 @@ const R = class R {
1543
1471
  }
1544
1472
  /** @internal */
1545
1473
  getBendValue(t, e) {
1546
- return rt(
1474
+ return H(
1547
1475
  this.m_Bend.getValue(t, e),
1548
- R.kMinBend,
1549
- R.kMaxBend
1476
+ D.kMinBend,
1477
+ D.kMaxBend
1550
1478
  );
1551
1479
  }
1552
1480
  /** @internal */
1553
1481
  getDurationValue(t, e) {
1554
- return rt(
1482
+ return H(
1555
1483
  this.m_Duration.getValue(t, e),
1556
- R.kMinDuration,
1557
- R.kMaxDuration
1484
+ D.kMinDuration,
1485
+ D.kMaxDuration
1558
1486
  );
1559
1487
  }
1560
1488
  /** @internal */
1561
1489
  getTwistValue(t, e) {
1562
- return rt(
1490
+ return H(
1563
1491
  this.m_Twist.getValue(t, e),
1564
- R.kMinTwist,
1565
- R.kMaxTwist
1492
+ D.kMinTwist,
1493
+ D.kMaxTwist
1566
1494
  );
1567
1495
  }
1568
1496
  };
1569
- R.kMinTwist = -1, R.kMaxTwist = 1, R.kMinBend = 0, R.kMaxBend = 1, R.kMinDuration = 0, R.kMaxDuration = 5;
1570
- let Lt = R, Xe = class extends Error {
1497
+ D.kMinTwist = -1, D.kMaxTwist = 1, D.kMinBend = 0, D.kMaxBend = 1, D.kMinDuration = 0, D.kMaxDuration = 5;
1498
+ let Ut = D;
1499
+ class pe extends Error {
1571
1500
  constructor() {
1572
1501
  super(
1573
1502
  "The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
1574
1503
  );
1575
1504
  }
1576
- };
1577
- const at = class at extends c.Group {
1505
+ }
1506
+ const W = class W extends l.Group {
1578
1507
  // ── Constructor ────────────────────────────────────────────────────────
1579
1508
  constructor(t) {
1580
- super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_CreateColliders = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new nt({
1581
- color: new c.Color(1, 0, 0),
1509
+ super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new rt({
1510
+ color: new l.Color(1, 0, 0),
1582
1511
  width: 2.1,
1583
1512
  height: 3.1,
1584
1513
  thickness: 0.04,
1585
1514
  stiffness: 0.5
1586
- }), this.m_PagePaperSetup = new nt({
1587
- color: new c.Color(1, 1, 1),
1515
+ }), this.m_PagePaperSetup = new rt({
1516
+ color: new l.Color(1, 1, 1),
1588
1517
  width: 2,
1589
1518
  height: 3,
1590
1519
  thickness: 0.02,
1591
1520
  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 = 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, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, 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 nt({
1593
- color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1521
+ }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = l.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1522
+ color: t.coverPaperSetup.color ?? new l.Color(1, 0, 0),
1594
1523
  width: t.coverPaperSetup.width ?? 2.1,
1595
1524
  height: t.coverPaperSetup.height ?? 3.1,
1596
1525
  thickness: t.coverPaperSetup.thickness ?? 0.04,
1597
1526
  stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1598
1527
  material: t.coverPaperSetup.material ?? null
1599
- })), t.pagePaperSetup && (this.m_PagePaperSetup = new nt({
1600
- color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
1528
+ })), t.pagePaperSetup && (this.m_PagePaperSetup = new rt({
1529
+ color: t.pagePaperSetup.color ?? new l.Color(1, 1, 1),
1601
1530
  width: t.pagePaperSetup.width ?? 2,
1602
1531
  height: t.pagePaperSetup.height ?? 3,
1603
1532
  thickness: t.pagePaperSetup.thickness ?? 0.02,
1604
1533
  stiffness: t.pagePaperSetup.stiffness ?? 0.2,
1605
1534
  material: t.pagePaperSetup.material ?? null
1606
- }))), at.s_Instances.add(this);
1535
+ }))), W.s_Instances.add(this), W.s_InstancesArray = null;
1607
1536
  }
1608
1537
  static get instances() {
1609
- return [...at.s_Instances];
1538
+ return W.s_InstancesArray === null && (W.s_InstancesArray = [...W.s_Instances]), W.s_InstancesArray;
1610
1539
  }
1611
1540
  // ── Internal accessors ─────────────────────────────────────────────────
1612
1541
  get minPaperWidth() {
@@ -1671,13 +1600,13 @@ const at = class at extends c.Group {
1671
1600
  return this.m_CoverPaperSetup;
1672
1601
  }
1673
1602
  set coverPaperSetup(t) {
1674
- const e = this.m_CoverPaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, o = t.stiffness ?? e.stiffness;
1675
- e.width === s && e.height === i && e.thickness === n && e.stiffness === o || (this.m_CoverPaperSetup = new nt({
1603
+ const e = this.m_CoverPaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, h = t.stiffness ?? e.stiffness;
1604
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === h || (this.m_CoverPaperSetup = new rt({
1676
1605
  color: t.color ?? e.color,
1677
1606
  width: s,
1678
1607
  height: i,
1679
1608
  thickness: n,
1680
- stiffness: o,
1609
+ stiffness: h,
1681
1610
  material: t.material !== void 0 ? t.material : e.material
1682
1611
  }), this.m_StructuralDirty = !0);
1683
1612
  }
@@ -1685,13 +1614,13 @@ const at = class at extends c.Group {
1685
1614
  return this.m_PagePaperSetup;
1686
1615
  }
1687
1616
  set pagePaperSetup(t) {
1688
- const e = this.m_PagePaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, o = t.stiffness ?? e.stiffness;
1689
- e.width === s && e.height === i && e.thickness === n && e.stiffness === o || (this.m_PagePaperSetup = new nt({
1617
+ const e = this.m_PagePaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, h = t.stiffness ?? e.stiffness;
1618
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === h || (this.m_PagePaperSetup = new rt({
1690
1619
  color: t.color ?? e.color,
1691
1620
  width: s,
1692
1621
  height: i,
1693
1622
  thickness: n,
1694
- stiffness: o,
1623
+ stiffness: h,
1695
1624
  material: t.material !== void 0 ? t.material : e.material
1696
1625
  }), this.m_StructuralDirty = !0);
1697
1626
  }
@@ -1724,7 +1653,7 @@ const at = class at extends c.Group {
1724
1653
  return this.m_InitialOpenProgress;
1725
1654
  }
1726
1655
  set initialOpenProgress(t) {
1727
- this.m_InitialOpenProgress = c.MathUtils.clamp(t, 0, 1);
1656
+ this.m_InitialOpenProgress = l.MathUtils.clamp(t, 0, 1);
1728
1657
  }
1729
1658
  get isBuilt() {
1730
1659
  return this.m_IsBuilt;
@@ -1758,7 +1687,7 @@ const at = class at extends c.Group {
1758
1687
  get autoTurningEndTime() {
1759
1688
  return this.m_AutoTurningEndTime;
1760
1689
  }
1761
- /** Current open progress (01), read from actual paper positions. */
1690
+ /** Current open progress (0-1), read from actual paper positions. */
1762
1691
  get openProgress() {
1763
1692
  return this.getCurrentOpenProgress();
1764
1693
  }
@@ -1773,58 +1702,71 @@ const at = class at extends c.Group {
1773
1702
  }
1774
1703
  for (const s of e)
1775
1704
  if (!s.isFalling && s.startTurning(t))
1776
- return this.m_SelectedPaper = s, !0;
1705
+ return this.m_SelectedPaper = s, this._frontPapersCache = null, !0;
1777
1706
  return !1;
1778
1707
  }
1779
1708
  updateTurning(t) {
1780
1709
  this.m_IsBuilt && this.m_SelectedPaper !== null && this.m_SelectedPaper.updateTurning(t);
1781
1710
  }
1782
1711
  stopTurning() {
1783
- this.m_IsBuilt && this.m_SelectedPaper !== null && (this.m_SelectedPaper.stopTurning(), this.m_SelectedPaper = null);
1712
+ this.m_IsBuilt && this.m_SelectedPaper !== null && (this.m_SelectedPaper.stopTurning(), this.m_SelectedPaper = null, this._frontPapersCache = null);
1784
1713
  }
1785
1714
  getActivePaperSideIndices(t) {
1786
- if (t.length = 0, !this.m_IsBuilt) return;
1787
- const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1715
+ if (t.clear(), !this.m_IsBuilt) return;
1716
+ const e = this.m_Content.direction === j.RightToLeft, s = this.m_Papers.length, i = (n, h) => {
1788
1717
  let a = n * 2;
1789
- o && a++, e && (a = s * 2 - a - 1), t.includes(a) || t.push(a);
1718
+ h && a++, e && (a = s * 2 - a - 1), t.add(a);
1790
1719
  };
1791
1720
  for (let n = 0; n < s; n++) {
1792
- const o = this.m_Papers[n];
1793
- if (o.isFalling || o.isTurning)
1721
+ const h = this.m_Papers[n];
1722
+ if (h.isFalling || h.isTurning)
1794
1723
  n > 0 && i(n - 1, !0), i(n, !1), i(n, !0), n < s - 1 && i(n + 1, !1);
1795
- else if (o.isOnRightStack) {
1724
+ else if (h.isOnRightStack) {
1796
1725
  n > 0 && i(n - 1, !0), i(n, !1);
1797
1726
  break;
1798
1727
  }
1799
1728
  }
1800
- t.length === 0 && i(this.m_Papers.length - 1, !0), e && t.reverse();
1729
+ t.size === 0 && i(this.m_Papers.length - 1, !0);
1801
1730
  }
1731
+ /**
1732
+ * Sets the book's open progress to a value between 0 (fully closed) and 1 (fully open).
1733
+ * This cancels any pending auto turns and immediately moves all papers to match
1734
+ * the requested progress.
1735
+ */
1802
1736
  setOpenProgress(t) {
1803
1737
  this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1804
- const e = this.m_Papers.length, s = Math.round(c.MathUtils.lerp(0, e, t));
1738
+ const e = this.m_Papers.length, s = Math.round(l.MathUtils.lerp(0, e, t));
1805
1739
  for (let i = 0; i < e; i++) {
1806
1740
  const n = i >= s;
1807
1741
  this.m_Papers[i].restState(n);
1808
1742
  }
1809
1743
  for (let i = 0; i < e; i++)
1810
1744
  this.m_Papers[i].restMesh();
1811
- this.m_WasIdle = !1;
1745
+ this.m_WasIdle = !1, this._frontPapersCache = null;
1812
1746
  }
1813
1747
  setOpenProgressByIndex(t) {
1814
1748
  const e = this.m_Content.convertPaperSideIndexToOpenProgress(t);
1815
1749
  this.setOpenProgress(e);
1816
1750
  }
1817
1751
  // ── Auto Turning ──────────────────────────────────────────────────────
1752
+ /**
1753
+ * Starts auto-turning pages in the given direction.
1754
+ * @param direction - Which direction to turn (Next or Back)
1755
+ * @param settings - Turn animation settings (twist, bend, duration)
1756
+ * @param turnCount - Number of pages to turn
1757
+ * @param delayPerTurn - Delay between consecutive turns (number in seconds, or AutoTurnSetting)
1758
+ * @returns true if at least one turn was queued
1759
+ */
1818
1760
  startAutoTurning(t, e, s = 1, i = 0) {
1819
1761
  if (!this.m_IsBuilt) return !1;
1820
1762
  this.cancelPendingAutoTurns();
1821
- const n = typeof i == "number" ? new ot(i) : i;
1763
+ const n = typeof i == "number" ? new at(i) : i;
1822
1764
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1823
- for (let o = 0; o < s && this.canAutoTurn(t); o++) {
1824
- 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);
1825
- this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: d, bend: g, duration: _, delay: m });
1765
+ for (let h = 0; h < s && this.canAutoTurn(t); h++) {
1766
+ const a = h / (s - 1 || 1), o = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(o, a) : 0, c = e.getModeValue(), m = e.getTwistValue(o, a), f = e.getBendValue(o, a), d = e.getDurationValue(o, a);
1767
+ this.m_AutoTurnQueue.push({ direction: t, mode: c, twist: m, bend: f, duration: d, delay: u });
1826
1768
  }
1827
- return this.m_AutoTurnTimer = 0, !0;
1769
+ return this.m_AutoTurnTimer = 0, this._frontPapersCache = null, !0;
1828
1770
  }
1829
1771
  cancelPendingAutoTurns() {
1830
1772
  this.m_AutoTurnQueue.length = 0;
@@ -1844,13 +1786,13 @@ const at = class at extends c.Group {
1844
1786
  s.startAutoTurning(e.mode, e.twist, e.bend, e.duration), this.m_AutoTurningEndTime = Math.max(
1845
1787
  this.m_AutoTurningEndTime,
1846
1788
  this.m_CurrentTime + e.duration
1847
- ), this.m_AutoTurnQueue.shift(), this.m_AutoTurnQueue.length > 0 && (this.m_AutoTurnTimer = this.m_AutoTurnQueue[0].delay);
1789
+ ), this.m_AutoTurnQueue.shift(), this._frontPapersCache = null, this.m_AutoTurnQueue.length > 0 && (this.m_AutoTurnTimer = this.m_AutoTurnQueue[0].delay);
1848
1790
  }
1849
1791
  getAutoTurnPaper(t) {
1850
1792
  if (this.isTurning) return null;
1851
1793
  const e = this.getFrontPapers();
1852
1794
  if (e.length > 0) {
1853
- const s = t === wt.Next, i = e[s ? e.length - 1 : 0];
1795
+ const s = t === yt.Next, i = e[s ? e.length - 1 : 0];
1854
1796
  if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
1855
1797
  return i;
1856
1798
  }
@@ -1860,7 +1802,7 @@ const at = class at extends c.Group {
1860
1802
  const e = this.getAutoTurnPaper(t);
1861
1803
  if (e === null) return 0;
1862
1804
  let s = 1;
1863
- return t === wt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1805
+ return t === yt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1864
1806
  }
1865
1807
  canAutoTurn(t) {
1866
1808
  return this.getAutoTurnPaper(t) !== null;
@@ -1876,11 +1818,12 @@ const at = class at extends c.Group {
1876
1818
  */
1877
1819
  init() {
1878
1820
  var t;
1879
- at.s_Instances.add(this), this.hardClear(), this.m_BuildOnAwake && (this.build(), this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = (t = this.m_Content) == null ? void 0 : t.direction);
1821
+ W.s_Instances.add(this), W.s_InstancesArray = null, this.hardClear(), this.m_BuildOnAwake && (this.build(), this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = (t = this.m_Content) == null ? void 0 : t.direction);
1880
1822
  }
1881
1823
  /**
1882
- * Call every frame with delta time.
1824
+ * Call every frame with delta time in seconds.
1883
1825
  * Equivalent to Unity's LateUpdate.
1826
+ * @param dt - Delta time in seconds since the last frame
1884
1827
  */
1885
1828
  update(t) {
1886
1829
  var e;
@@ -1902,64 +1845,79 @@ const at = class at extends c.Group {
1902
1845
  this.m_WasIdle = this.isIdle;
1903
1846
  for (const s of this.m_Papers)
1904
1847
  s.isFalling && s.updateFalling(t);
1905
- this.updateLivePages(), this.m_Bound.onLateUpdate();
1848
+ this._frontPapersCache = null, this.updateLivePages(), this.m_Bound.onLateUpdate();
1906
1849
  }
1907
1850
  }
1851
+ /**
1852
+ * Dispose the book and release all resources.
1853
+ * MANDATORY: You must call dispose() when removing a Book to prevent memory leaks.
1854
+ * The Book holds a reference in the static `s_Instances` set; without dispose(),
1855
+ * it will never be garbage collected.
1856
+ */
1908
1857
  dispose() {
1909
- at.s_Instances.delete(this), this.hardClear();
1858
+ W.s_Instances.delete(this), W.s_InstancesArray = null, this.hardClear();
1910
1859
  }
1911
1860
  // ── Build ─────────────────────────────────────────────────────────────
1912
1861
  build() {
1862
+ var B;
1913
1863
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1914
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new _e()), this.m_RendererFactory === null) {
1915
- const C = new c.Object3D();
1916
- C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new fe(this.m_Root);
1864
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new le()), this.m_RendererFactory === null) {
1865
+ const w = new l.Object3D();
1866
+ w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new ce(this.m_Root);
1917
1867
  }
1918
- this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
1868
+ this.m_Direction = this.m_Content.direction;
1919
1869
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1920
1870
  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);
1921
- const e = new At(this.m_CoverPaperSetup), s = new At(this.m_PagePaperSetup);
1871
+ const e = new zt(this.m_CoverPaperSetup), s = new zt(this.m_PagePaperSetup);
1922
1872
  this.m_Content.init(this);
1923
- let i = this.m_Content.coverContents, n = this.m_Content.pageContents, o = this.m_InitialOpenProgress;
1924
- 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);
1925
- const a = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
1926
- let m = 0, l = 0, d = 0;
1873
+ let i = this.m_Content.coverContents, n = this.m_Content.pageContents, h = this.m_InitialOpenProgress;
1874
+ this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), h = 1 - h), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1875
+ const a = this.m_CoverPaperCount + this.m_PagePaperCount, o = Math.floor(i.length / 4);
1876
+ let u = 0, c = 0, m = 0;
1927
1877
  this.m_Papers = new Array(a);
1928
- for (let C = 0; C < a; C++) {
1929
- const D = this.m_HasCover && (C < h || C >= a - h), L = this.m_RendererFactory.get("Paper"), v = this.m_Papers[C] = new me(D, C, this, L);
1930
- v.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (v.transform.scale.set(-1, 1, 1), v.setTime(1)), D ? (v.setContentData(i[l++], i[l++], C > 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;
1931
- }
1932
- this.m_TotalThickness = d;
1933
- const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(a / 2)].thickness;
1934
- this.m_MinPaperThickness = Math.min(g, _), this.m_MaxPaperThickness = Math.max(g, _);
1935
- const u = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(a / 2)].size.x;
1936
- this.m_MinPaperWidth = Math.min(u, f);
1937
- const p = this.m_Papers[0].size.y, P = this.m_Papers[Math.floor(a / 2)].size.y;
1938
- this.m_MinPaperHeight = Math.min(p, P), this.m_Bound = this.m_Binding.createBound(
1878
+ for (let w = 0; w < a; w++) {
1879
+ const v = this.m_HasCover && (w < o || w >= a - o), N = this.m_RendererFactory.get("Paper"), R = this.m_Papers[w] = new ae(v, w, this, N);
1880
+ R.renderer.castShadows = this.m_CastShadows, w < Math.round(l.MathUtils.lerp(0, a, h)) && (R.transform.scale.set(-1, 1, 1), R.setTime(1)), v ? (R.setContentData(i[c++], i[c++], w > o), R.setMaterialData(e), R.setPaperSetup(this.m_CoverPaperSetup)) : (R.setContentData(n[u++], n[u++]), R.setMaterialData(s), R.setPaperSetup(this.m_PagePaperSetup)), m += R.thickness;
1881
+ }
1882
+ this.m_TotalThickness = m;
1883
+ const f = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
1884
+ this.m_MinPaperThickness = Math.min(f, d), this.m_MaxPaperThickness = Math.max(f, d);
1885
+ const _ = this.m_Papers[0].size.x, g = this.m_Papers[Math.floor(a / 2)].size.x;
1886
+ this.m_MinPaperWidth = Math.min(_, g);
1887
+ const p = this.m_Papers[0].size.y, M = this.m_Papers[Math.floor(a / 2)].size.y;
1888
+ this.m_MinPaperHeight = Math.min(p, M), this.m_Bound = this.m_Binding.createBound(
1939
1889
  this,
1940
1890
  this.m_Root,
1941
1891
  this.m_RendererFactory,
1942
1892
  this.m_MeshFactory
1943
1893
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1944
- const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), T = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, U = z + 1, V = this.m_Bound.constructor.name.includes("Staple");
1945
- for (let C = 0; C < a; C++) {
1946
- const D = this.m_Papers[C];
1947
- C !== 0 && (D.prev = this.m_Papers[C - 1]), C !== a - 1 && (D.next = this.m_Papers[C + 1]), D.noHole = V && (C === z || C === U), D.isCover ? D.setMeshData(O.get(), null, Z) : D.setMeshData(
1948
- w.get(),
1949
- (T == null ? void 0 : T.get()) ?? null,
1950
- k
1894
+ const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes, C = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), L = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1895
+ for (let w = 0; w < a; w++) {
1896
+ const v = this.m_Papers[w];
1897
+ w !== 0 && (v.prev = this.m_Papers[w - 1]), w !== a - 1 && (v.next = this.m_Papers[w + 1]), v.noHole = A && (w === z || w === E), v.isCover ? v.setMeshData(U.get(), null, L) : v.setMeshData(
1898
+ C.get(),
1899
+ (k == null ? void 0 : k.get()) ?? null,
1900
+ I
1951
1901
  );
1952
1902
  }
1953
- 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;
1903
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this._frontPapersCache = null, this.update(0), this.m_CoverPaperSetup.bookDirection = j.LeftToRight, this.m_PagePaperSetup.bookDirection = j.LeftToRight;
1954
1904
  }
1905
+ /**
1906
+ * Clears the built state of the book.
1907
+ * NOTE: This does NOT call super.clear() — it has different semantics from
1908
+ * THREE.Group.clear(). It resets internal book state (papers, bound, flags)
1909
+ * without removing children from the Three.js scene graph.
1910
+ */
1955
1911
  clear() {
1956
- 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;
1912
+ var t;
1913
+ return this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, (t = this.m_Bound) == null || t.dispose(), this.m_Bound = null, this._frontPapersCache = null, this.m_MeshFactory !== null && this.m_MeshFactory.recycle(), this.m_RendererFactory !== null && this.m_RendererFactory.recycle(), this;
1957
1914
  }
1958
1915
  hardClear() {
1959
- this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_Root !== null && (this.remove(this.m_Root), this.m_Root = null), this.m_MeshFactory !== null && (this.m_MeshFactory.destroy(), this.m_MeshFactory = null), this.m_RendererFactory !== null && (this.m_RendererFactory.destroy(), this.m_RendererFactory = null);
1916
+ var t;
1917
+ this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, (t = this.m_Bound) == null || t.dispose(), this.m_Bound = null, this._frontPapersCache = null, this.m_Root !== null && (this.remove(this.m_Root), this.m_Root = null), this.m_MeshFactory !== null && (this.m_MeshFactory.destroy(), this.m_MeshFactory = null), this.m_RendererFactory !== null && (this.m_RendererFactory.destroy(), this.m_RendererFactory = null);
1960
1918
  }
1961
1919
  createPaperMeshDataPool(t, e, s = !1, i = !1) {
1962
- const n = e ? 0 : t.quality, o = this.m_Bound.createPaperPattern(
1920
+ const n = e ? 0 : t.quality, h = this.m_Bound.createPaperPattern(
1963
1921
  n,
1964
1922
  t.size,
1965
1923
  t.thickness,
@@ -1967,14 +1925,16 @@ const at = class at extends c.Group {
1967
1925
  i,
1968
1926
  s
1969
1927
  );
1970
- return new xe(
1928
+ return new _e(
1971
1929
  this.m_MeshFactory,
1972
- o,
1930
+ h,
1973
1931
  e && this.m_Bound.useSharedMeshDataForLowpoly
1974
1932
  );
1975
1933
  }
1976
1934
  // ── Query methods ─────────────────────────────────────────────────────
1977
1935
  getFrontPapers() {
1936
+ if (this._frontPapersCache !== null)
1937
+ return this._frontPapersCache;
1978
1938
  const t = [];
1979
1939
  if (this.m_SelectedPaper !== null) {
1980
1940
  const e = this.m_SelectedPaper.index;
@@ -1987,7 +1947,7 @@ const at = class at extends c.Group {
1987
1947
  }
1988
1948
  t.length === 0 && t.push(this.m_Papers[this.m_Papers.length - 1]);
1989
1949
  }
1990
- return t;
1950
+ return this._frontPapersCache = t, t;
1991
1951
  }
1992
1952
  getAverageTime() {
1993
1953
  const t = this.m_Papers.length;
@@ -2016,15 +1976,15 @@ const at = class at extends c.Group {
2016
1976
  if (s !== this.m_CoverPaperCount || i !== this.m_PagePaperCount)
2017
1977
  return !1;
2018
1978
  this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
2019
- const n = this.m_Papers.length, o = Math.floor(t.length / 4);
2020
- let a = 0, h = 0;
2021
- for (let m = 0; m < n; m++) {
2022
- const l = this.m_Papers[m];
2023
- this.m_HasCover && (m < o || m >= n - o) ? l.setContentData(
2024
- t[h++],
2025
- t[h++],
2026
- m > o
2027
- ) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
1979
+ const n = this.m_Papers.length, h = Math.floor(t.length / 4);
1980
+ let a = 0, o = 0;
1981
+ for (let u = 0; u < n; u++) {
1982
+ const c = this.m_Papers[u];
1983
+ this.m_HasCover && (u < h || u >= n - h) ? c.setContentData(
1984
+ t[o++],
1985
+ t[o++],
1986
+ u > h
1987
+ ) : c.setContentData(e[a++], e[a++]), c.updateMaterials();
2028
1988
  }
2029
1989
  return this.m_WasIdle = !1, !0;
2030
1990
  }
@@ -2054,14 +2014,14 @@ const at = class at extends c.Group {
2054
2014
  s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
2055
2015
  }
2056
2016
  };
2057
- at.s_Instances = /* @__PURE__ */ new Set();
2058
- let yt = at;
2059
- class Se {
2017
+ W.s_Instances = /* @__PURE__ */ new Set(), W.s_InstancesArray = null;
2018
+ let Ct = W;
2019
+ class xe {
2060
2020
  constructor() {
2061
- 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;
2021
+ this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new l.Vector2(), this.thickness = 0;
2062
2022
  }
2063
2023
  }
2064
- class Ge {
2024
+ class Fe {
2065
2025
  constructor() {
2066
2026
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
2067
2027
  }
@@ -2072,7 +2032,7 @@ class Ge {
2072
2032
  return this.m_IsActive;
2073
2033
  }
2074
2034
  get textureST() {
2075
- return new c.Vector4(1, 1, 0, 0);
2035
+ return new l.Vector4(1, 1, 0, 0);
2076
2036
  }
2077
2037
  get isShareable() {
2078
2038
  return !0;
@@ -2096,15 +2056,15 @@ class Ge {
2096
2056
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
2097
2057
  }
2098
2058
  }
2099
- class Nt {
2059
+ class Lt {
2100
2060
  constructor(t, e) {
2101
- this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2061
+ this.m_Texture = t, this.m_TextureST = e ?? new l.Vector4(1, 1, 0, 0);
2102
2062
  }
2103
2063
  get texture() {
2104
2064
  return this.m_Texture;
2105
2065
  }
2106
2066
  get textureST() {
2107
- return this.m_Texture ? this.m_TextureST : new c.Vector4(1, 1, 0, 0);
2067
+ return this.m_Texture ? this.m_TextureST : new l.Vector4(1, 1, 0, 0);
2108
2068
  }
2109
2069
  isPointOverUI(t) {
2110
2070
  return !1;
@@ -2114,9 +2074,9 @@ class Nt {
2114
2074
  setActive(t) {
2115
2075
  }
2116
2076
  }
2117
- class je {
2077
+ class Oe {
2118
2078
  constructor() {
2119
- 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;
2079
+ this.m_Direction = j.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null, this._cachedCovers = null, this._cachedPages = null;
2120
2080
  }
2121
2081
  get coverCount4() {
2122
2082
  return this.nextMultipleOf4(this.m_Covers.length);
@@ -2130,9 +2090,15 @@ class je {
2130
2090
  get covers() {
2131
2091
  return this.m_Covers;
2132
2092
  }
2093
+ set covers(t) {
2094
+ this.m_Covers = t, this._cachedCovers = null;
2095
+ }
2133
2096
  get pages() {
2134
2097
  return this.m_Pages;
2135
2098
  }
2099
+ set pages(t) {
2100
+ this.m_Pages = t, this._cachedPages = null;
2101
+ }
2136
2102
  get isEmpty() {
2137
2103
  return this.m_Covers.length === 0 && this.m_Pages.length === 0;
2138
2104
  }
@@ -2143,18 +2109,18 @@ class je {
2143
2109
  this.m_Direction = t;
2144
2110
  }
2145
2111
  get coverContents() {
2146
- return this.getContents(this.m_Covers, !1);
2112
+ return this._cachedCovers === null && (this._cachedCovers = this.getContents(this.m_Covers, !1)), this._cachedCovers;
2147
2113
  }
2148
2114
  get pageContents() {
2149
- return this.getContents(this.m_Pages, !1);
2115
+ return this._cachedPages === null && (this._cachedPages = this.getContents(this.m_Pages, !1)), this._cachedPages;
2150
2116
  }
2151
2117
  getContents(t, e) {
2152
2118
  const s = t.length;
2153
2119
  let i = this.nextMultipleOf4(s);
2154
2120
  e && (i = Math.min(i, 4));
2155
2121
  const n = new Array(i);
2156
- for (let o = 0; o < i; o++)
2157
- n[o] = this.getContent(o < s ? t[o] : null);
2122
+ for (let h = 0; h < i; h++)
2123
+ n[h] = this.getContent(h < s ? t[h] : null);
2158
2124
  return n;
2159
2125
  }
2160
2126
  nextMultipleOf4(t) {
@@ -2162,15 +2128,15 @@ class je {
2162
2128
  }
2163
2129
  getContent(t) {
2164
2130
  if (t !== null) {
2165
- if (t instanceof c.Texture)
2166
- return new Nt(t);
2131
+ if (t instanceof l.Texture)
2132
+ return new Lt(t);
2167
2133
  if (typeof t.init == "function")
2168
2134
  return t;
2169
2135
  }
2170
- return new Nt(null);
2136
+ return new Lt(null);
2171
2137
  }
2172
2138
  init(t) {
2173
- this.m_Book = t;
2139
+ this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
2174
2140
  for (const e of this.coverContents)
2175
2141
  e.init(this);
2176
2142
  for (const e of this.pageContents)
@@ -2215,16 +2181,16 @@ class je {
2215
2181
  return !this.isCoverPaperSideIndex(t);
2216
2182
  }
2217
2183
  }
2218
- class qe {
2184
+ class Ze {
2219
2185
  constructor(t, e) {
2220
- 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) => {
2186
+ this.enabled = !0, this.m_Raycaster = new l.Raycaster(), this.m_Mouse = new l.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2221
2187
  var n;
2222
2188
  if (!this.enabled || s.button !== 0) return;
2223
2189
  this.m_IsPointerDown = !0;
2224
2190
  const i = this.m_GetRay(s);
2225
- for (const o of yt.instances)
2226
- if (o.startTurning(i)) {
2227
- this.m_SelectedBook = o, (n = this.onTurnStart) == null || n.call(this, o);
2191
+ for (const h of Ct.instances)
2192
+ if (h.startTurning(i)) {
2193
+ this.m_SelectedBook = h, (n = this.onTurnStart) == null || n.call(this, h);
2228
2194
  break;
2229
2195
  }
2230
2196
  }, this.m_OnPointerMove = (s) => {
@@ -2242,56 +2208,46 @@ class qe {
2242
2208
  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;
2243
2209
  }
2244
2210
  }
2245
- class Te {
2211
+ class Me {
2246
2212
  }
2247
- class Qe {
2213
+ class ye {
2248
2214
  constructor(t, e) {
2249
- this.m_Book = t, this.m_Root = e;
2215
+ this.bindingType = "", this.m_Book = t, this.m_Root = e;
2216
+ }
2217
+ /** Release GPU resources. Override in subclasses. */
2218
+ dispose() {
2250
2219
  }
2251
2220
  }
2252
2221
  function Et(r, t, e, s) {
2253
2222
  const i = 1 - s;
2254
- return new c.Vector3(
2223
+ return new l.Vector3(
2255
2224
  i * i * r.x + 2 * i * s * t.x + s * s * e.x,
2256
2225
  i * i * r.y + 2 * i * s * t.y + s * s * e.y,
2257
2226
  i * i * r.z + 2 * i * s * t.z + s * s * e.z
2258
2227
  );
2259
2228
  }
2260
- function Xt(r, t) {
2229
+ function Nt(r, t) {
2261
2230
  return r++, r === t ? 0 : r;
2262
2231
  }
2263
- function ve(r, t) {
2232
+ function Ce(r, t) {
2264
2233
  return r === 0 ? t - 1 : r - 1;
2265
2234
  }
2266
- const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4, De = 2, Ie = 10, ze = 0, Ve = 5;
2267
- function et(r, t, e) {
2268
- return Math.max(t, Math.min(e, r));
2269
- }
2270
- function te(r) {
2271
- return Math.max(0, Math.min(1, r));
2272
- }
2273
- function F(r, t, e) {
2274
- return r + (t - r) * e;
2275
- }
2276
- function Wt(r, t, e) {
2277
- return r === t ? 0 : te((e - r) / (t - r));
2278
- }
2279
- function Ae(r, t) {
2235
+ const we = 0.01, Pe = 0.1, Te = 0.04, Se = 0.4, ve = 2, ke = 10, Be = 0, Re = 5;
2236
+ function be(r, t) {
2280
2237
  const e = r.clone().normalize();
2281
- if (e.lengthSq() === 0) return new c.Quaternion();
2282
- let s = new c.Vector3().crossVectors(t, e);
2238
+ if (e.lengthSq() === 0) return new l.Quaternion();
2239
+ let s = new l.Vector3().crossVectors(t, e);
2283
2240
  if (s.lengthSq() === 0) {
2284
- const o = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
2285
- s = new c.Vector3().crossVectors(o, e);
2241
+ const h = Math.abs(e.y) < 0.999 ? new l.Vector3(0, 1, 0) : new l.Vector3(1, 0, 0);
2242
+ s = new l.Vector3().crossVectors(h, e);
2286
2243
  }
2287
2244
  s.normalize();
2288
- const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
2289
- return new c.Quaternion().setFromRotationMatrix(n);
2245
+ const i = new l.Vector3().crossVectors(e, s).normalize(), n = new l.Matrix4().makeBasis(s, i, e);
2246
+ return new l.Quaternion().setFromRotationMatrix(n);
2290
2247
  }
2291
- const tt = Math.PI / 180, it = 180 / Math.PI;
2292
- class He {
2248
+ class De {
2293
2249
  constructor() {
2294
- 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;
2250
+ this._material = null, this._color = new l.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2295
2251
  }
2296
2252
  get material() {
2297
2253
  return this._material;
@@ -2309,69 +2265,64 @@ class He {
2309
2265
  return this._thickness;
2310
2266
  }
2311
2267
  set thickness(t) {
2312
- this._thickness = et(t, ke, be);
2268
+ this._thickness = H(t, we, Pe);
2313
2269
  }
2314
2270
  get margin() {
2315
2271
  return this._margin;
2316
2272
  }
2317
2273
  set margin(t) {
2318
- this._margin = te(t);
2274
+ this._margin = lt(t);
2319
2275
  }
2320
2276
  get crown() {
2321
2277
  return this._crown;
2322
2278
  }
2323
2279
  set crown(t) {
2324
- this._crown = et(t, Be, Re);
2280
+ this._crown = H(t, Te, Se);
2325
2281
  }
2326
2282
  get count() {
2327
2283
  return this._count;
2328
2284
  }
2329
2285
  set count(t) {
2330
- this._count = et(t, De, Ie);
2286
+ this._count = H(t, ve, ke);
2331
2287
  }
2332
2288
  get quality() {
2333
2289
  return this._quality;
2334
2290
  }
2335
2291
  set quality(t) {
2336
- this._quality = et(t, ze, Ve);
2292
+ this._quality = H(t, Be, Re);
2337
2293
  }
2338
2294
  }
2339
- class Fe extends Error {
2340
- constructor() {
2341
- super("Book height is too large relative to paper width."), this.name = "BookHeightException";
2342
- }
2343
- }
2344
- class Oe {
2295
+ class Ie extends ye {
2345
2296
  // ── Constructor ────────────────────────────────────────────────────────
2346
2297
  constructor(t, e, s, i, n) {
2347
- 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)
2348
- throw new Fe();
2349
- const o = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
2350
- this.updateStapleMesh(e, h);
2351
- const m = n ?? new c.MeshStandardMaterial({
2298
+ if (super(s, i), this.bindingType = "staple", this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
2299
+ throw new pe();
2300
+ const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, o = new l.BufferGeometry();
2301
+ this.updateStapleMesh(e, o);
2302
+ const u = n ?? new l.MeshStandardMaterial({
2352
2303
  color: e.color,
2353
2304
  metalness: 0.9,
2354
2305
  roughness: 0.3
2355
2306
  });
2356
- this.stapleMesh = new c.Mesh(h, m), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2307
+ this.stapleMesh = new l.Mesh(o, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2357
2308
  0,
2358
2309
  0,
2359
- this.m_StapleMargin + a.margin + o.margin
2310
+ this.m_StapleMargin + a.margin + h.margin
2360
2311
  );
2361
- let l = o.thickness;
2362
- l = Math.max(this.m_BindingRadius, l);
2363
- for (const d of this.m_Book.papers) {
2364
- const g = d.size.clone();
2365
- g.x -= this.m_BindingRadius, d.sizeXOffset = this.m_BindingRadius, d.size = g, d.setMinTurningRadius(l), d.updateTurningRadius(), this.updatePaperPosition(d);
2312
+ let c = h.thickness;
2313
+ c = Math.max(this.m_BindingRadius, c);
2314
+ for (const m of this.m_Book.papers) {
2315
+ const f = m.size.clone();
2316
+ f.x -= this.m_BindingRadius, m.sizeXOffset = this.m_BindingRadius, m.size = f, m.setMinTurningRadius(c), m.updateTurningRadius(), this.updatePaperPosition(m);
2366
2317
  }
2367
2318
  this.updateRootPosition();
2368
2319
  }
2369
2320
  get binderRenderer() {
2370
- return this._binderRendererAdapter || (this._binderRendererAdapter = new Ze(this.stapleMesh)), this._binderRendererAdapter;
2321
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new Ve(this.stapleMesh)), this._binderRendererAdapter;
2371
2322
  }
2372
2323
  // ── updateStapleMesh ──────────────────────────────────────────────────
2373
2324
  updateStapleMesh(t, e) {
2374
- this.m_StapleThickness = t.thickness, this.m_StackHeight = this.m_Book.totalThickness, this.m_BindingMidSpace = this.m_StapleThickness * 1.75, this.m_BindingRadius = (this.m_StackHeight + this.m_BindingMidSpace) / 2 / Math.sin(45 * tt), this.m_StackHeight += this.m_BindingMidSpace;
2325
+ this.m_StapleThickness = t.thickness, this.m_StackHeight = this.m_Book.totalThickness, this.m_BindingMidSpace = this.m_StapleThickness * 1.75, this.m_BindingRadius = (this.m_StackHeight + this.m_BindingMidSpace) / 2 / Math.sin(45 * J), this.m_StackHeight += this.m_BindingMidSpace;
2375
2326
  let s = t.crown;
2376
2327
  s = Math.max(s, this.m_StapleThickness * 4);
2377
2328
  const i = this.m_StapleThickness * 0.5, n = Math.max(
@@ -2379,174 +2330,174 @@ class Oe {
2379
2330
  i
2380
2331
  );
2381
2332
  this.m_StapleMargin = F(i, n, t.margin);
2382
- const o = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2383
- let a = t.count, h = (o - s * a) / (a - 1);
2384
- for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && a > 2; )
2385
- a--, h = (o - s * a) / (a - 1), h = Math.max(h, 0);
2386
- 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;
2387
- let P = s / 2 * f;
2388
- P = Math.max(P, p * 2);
2389
- let B = 0;
2390
- B += this.m_Book.totalThickness / 2, B += _;
2391
- const M = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
2333
+ const h = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2334
+ let a = t.count, o = (h - s * a) / (a - 1);
2335
+ for (o = Math.max(o, 0); o < this.m_StapleThickness * 2 && a > 2; )
2336
+ a--, o = (h - s * a) / (a - 1), o = Math.max(o, 0);
2337
+ const u = t.quality / 5, c = Math.floor(F(4, 20, u)), m = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), d = this.m_StapleThickness / 2, _ = d * 2.5, g = 0.9, p = d * 1;
2338
+ let M = s / 2 * g;
2339
+ M = Math.max(M, p * 2);
2340
+ let T = 0;
2341
+ T += this.m_Book.totalThickness / 2, T += d;
2342
+ const P = -(this.m_Book.papers[0].thickness / 2 + d), C = [];
2392
2343
  {
2393
- for (let I = 0; I < d; I++) {
2394
- const E = I / (d - 1), q = F(-90, -180, E) * tt, y = new c.Vector3(
2395
- p * Math.sin(q),
2344
+ for (let V = 0; V < m; V++) {
2345
+ const G = V / (m - 1), K = F(-90, -180, G) * J, y = new l.Vector3(
2346
+ p * Math.sin(K),
2396
2347
  0,
2397
- p * Math.cos(q)
2348
+ p * Math.cos(K)
2398
2349
  );
2399
- y.x += p, y.z += p, y.x += M, w.push(y);
2350
+ y.x += p, y.z += p, y.x += P, C.push(y);
2400
2351
  }
2401
- const x = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), S = new c.Vector3(B - _ * 0.5, 0, P);
2402
- for (let I = 0; I < g; I++) {
2403
- const E = I / (g - 1), j = Et(x, H, S, E);
2404
- j.x += M, w.push(j);
2352
+ const x = new l.Vector3(T, 0, 0), Z = new l.Vector3(T + _ * 0.75, 0, 0), S = new l.Vector3(T - d * 0.5, 0, M);
2353
+ for (let V = 0; V < f; V++) {
2354
+ const G = V / (f - 1), Y = Et(x, Z, S, G);
2355
+ Y.x += P, C.push(Y);
2405
2356
  }
2406
- w.reverse();
2357
+ C.reverse();
2407
2358
  }
2408
- const T = new Array(l);
2409
- for (let x = 0; x < l; x++) {
2410
- const S = (90 - x * (360 / l)) * tt;
2411
- T[x] = new c.Vector3(Math.cos(S), Math.sin(S), 0), T[x].x *= 0.75;
2359
+ const k = new Array(c);
2360
+ for (let x = 0; x < c; x++) {
2361
+ const S = (90 - x * (360 / c)) * J;
2362
+ k[x] = new l.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
2412
2363
  }
2413
- const k = w.length, O = k * l, Z = new Array(O * 2), z = new Array(O * 2), U = new Array(
2414
- (O * 2 - 1) * l * 2 * 3
2364
+ const I = C.length, U = I * c, L = new Array(U * 2), z = new Array(U * 2), E = new Array(
2365
+ (U * 2 - 1) * c * 2 * 3
2415
2366
  );
2416
- for (let x = 0; x < O * 2; x++)
2417
- Z[x] = new c.Vector3(), z[x] = new c.Vector3();
2418
- let V = 0;
2419
- for (let x = 0; x < k; x++) {
2420
- const H = w[ve(x, k)], S = w[x], I = w[Xt(x, k)];
2421
- let E;
2367
+ for (let x = 0; x < U * 2; x++)
2368
+ L[x] = new l.Vector3(), z[x] = new l.Vector3();
2369
+ let A = 0;
2370
+ for (let x = 0; x < I; x++) {
2371
+ const Z = C[Ce(x, I)], S = C[x], V = C[Nt(x, I)];
2372
+ let G;
2422
2373
  if (x === 0)
2423
- E = new c.Vector3(1, 0, -2).normalize();
2424
- else if (x === k - 1)
2425
- E = new c.Vector3(0, 0, 1);
2374
+ G = new l.Vector3(1, 0, -2).normalize();
2375
+ else if (x === I - 1)
2376
+ G = new l.Vector3(0, 0, 1);
2426
2377
  else {
2427
- const K = S.clone().sub(H).normalize(), J = I.clone().sub(S).normalize();
2428
- E = K.add(J).multiplyScalar(0.5);
2378
+ const it = S.clone().sub(Z).normalize(), nt = V.clone().sub(S).normalize();
2379
+ G = it.add(nt).multiplyScalar(0.5);
2429
2380
  }
2430
- const j = new c.Vector3(0, 1, 0), q = Ae(E, j), y = V;
2431
- let b = Wt(0, g / 4, x);
2381
+ const Y = new l.Vector3(0, 1, 0), K = be(G, Y), y = A;
2382
+ let b = Q(0, f / 4, x);
2432
2383
  b = F(0.1, 1, b), b = Math.sqrt(b);
2433
- for (let K = 0; K < l; K++) {
2434
- const J = T[K].clone().applyQuaternion(q).multiplyScalar(b), ct = S.clone().add(J.clone().multiplyScalar(_));
2435
- Z[V] = ct, z[V] = J.clone();
2436
- const ht = S.clone().add(J.clone().multiplyScalar(_));
2437
- ht.z = s - ht.z;
2438
- const se = y + l - K - 1, Tt = O * 2 - se - 1;
2439
- Z[Tt] = ht, z[Tt] = J.clone(), V++;
2384
+ for (let it = 0; it < c; it++) {
2385
+ const nt = k[it].clone().applyQuaternion(K).multiplyScalar(b), ct = S.clone().add(nt.clone().multiplyScalar(d));
2386
+ L[A] = ct, z[A] = nt.clone();
2387
+ const ot = S.clone().add(nt.clone().multiplyScalar(d));
2388
+ ot.z = s - ot.z;
2389
+ const te = y + c - it - 1, St = U * 2 - te - 1;
2390
+ L[St] = ot, z[St] = nt.clone(), A++;
2440
2391
  }
2441
2392
  }
2442
- let C = 0;
2443
- const D = w.length * 2;
2444
- for (let x = 0; x < D - 1; x++) {
2445
- const H = x * l, S = (x + 1) * l;
2446
- for (let I = 0; I < l; I++) {
2447
- const E = Xt(I, l), j = H + I, q = H + E, y = S + E, b = S + I;
2448
- U[C++] = j, U[C++] = b, U[C++] = q, U[C++] = q, U[C++] = b, U[C++] = y;
2393
+ let B = 0;
2394
+ const w = C.length * 2;
2395
+ for (let x = 0; x < w - 1; x++) {
2396
+ const Z = x * c, S = (x + 1) * c;
2397
+ for (let V = 0; V < c; V++) {
2398
+ const G = Nt(V, c), Y = Z + V, K = Z + G, y = S + G, b = S + V;
2399
+ E[B++] = Y, E[B++] = b, E[B++] = K, E[B++] = K, E[B++] = b, E[B++] = y;
2449
2400
  }
2450
2401
  }
2451
- const L = [...Z], v = [...z], Q = [...U], G = Z.map((x) => x.clone()), $ = [...U];
2402
+ const v = [...L], N = [...z], R = [...E], $ = L.map((x) => x.clone()), tt = [...E];
2452
2403
  for (let x = 0; x < a - 1; x++) {
2453
- const H = G.length;
2404
+ const Z = $.length;
2405
+ for (let S = 0; S < tt.length; S++)
2406
+ tt[S] += Z;
2454
2407
  for (let S = 0; S < $.length; S++)
2455
- $[S] += H;
2456
- for (let S = 0; S < G.length; S++)
2457
- G[S].z += h + s;
2458
- L.push(...G.map((S) => S.clone())), v.push(...z.map((S) => S.clone())), Q.push(...$);
2408
+ $[S].z += o + s;
2409
+ v.push(...$.map((S) => S.clone())), N.push(...z.map((S) => S.clone())), R.push(...tt);
2459
2410
  }
2460
- const W = new Float32Array(L.length * 3), A = new Float32Array(v.length * 3);
2461
- for (let x = 0; x < L.length; x++)
2462
- W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] = v[x].x, A[x * 3 + 1] = v[x].y, A[x * 3 + 2] = v[x].z;
2411
+ const q = new Float32Array(v.length * 3), O = new Float32Array(N.length * 3);
2412
+ for (let x = 0; x < v.length; x++)
2413
+ q[x * 3] = v[x].x, q[x * 3 + 1] = v[x].y, q[x * 3 + 2] = v[x].z, O[x * 3] = N[x].x, O[x * 3 + 1] = N[x].y, O[x * 3 + 2] = N[x].z;
2463
2414
  e.setAttribute(
2464
2415
  "position",
2465
- new c.BufferAttribute(W, 3)
2416
+ new l.BufferAttribute(q, 3)
2466
2417
  ), e.setAttribute(
2467
2418
  "normal",
2468
- new c.BufferAttribute(A, 3)
2469
- ), e.setIndex(Q);
2419
+ new l.BufferAttribute(O, 3)
2420
+ ), e.setIndex(R);
2470
2421
  }
2471
2422
  // ── createPaperPattern ────────────────────────────────────────────────
2472
- createPaperPattern(t, e, s, i, n, o) {
2473
- const a = new Se();
2423
+ createPaperPattern(t, e, s, i, n, h) {
2424
+ const a = new xe();
2474
2425
  a.size = e, a.thickness = s;
2475
- const h = this.m_BindingRadius;
2476
- a.baseXOffset = -h;
2477
- const m = this.m_Quality + 1;
2478
- this.m_BindingVertexCount = m;
2479
- const l = t / 5, d = Math.min(e.x, e.y) / 60, g = Math.floor(
2480
- F(0, (e.x - h) / d, l)
2481
- ), _ = Math.floor(F(0, e.y / d, l));
2482
- let u = 2 + g + 1 + m, f = 2 + _;
2483
- const p = new st(0);
2484
- let P = p;
2485
- const B = h / m;
2486
- let M = 0;
2487
- for (let y = 1; y < m + 1; y++)
2488
- P = P.createNext(M), M += B;
2489
- const w = (e.x - h) / (g + 1);
2490
- for (let y = m + 1; y < u; y++)
2491
- P = P.createNext(M), M += w;
2492
- const T = new st(0);
2493
- let k = T;
2494
- const O = e.y / (f - 1);
2495
- let Z = 0;
2496
- for (let y = 0; y < f - 1; y++)
2497
- Z += O, k = k.createNext(Z);
2498
- const z = [], U = [], V = i.clone();
2426
+ const o = this.m_BindingRadius;
2427
+ a.baseXOffset = -o;
2428
+ const u = this.m_Quality + 1;
2429
+ this.m_BindingVertexCount = u;
2430
+ const c = t / 5, m = Math.min(e.x, e.y) / 60, f = Math.floor(
2431
+ F(0, (e.x - o) / m, c)
2432
+ ), d = Math.floor(F(0, e.y / m, c));
2433
+ let _ = 2 + f + 1 + u, g = 2 + d;
2434
+ const p = new ht(0);
2435
+ let M = p;
2436
+ const T = o / u;
2437
+ let P = 0;
2438
+ for (let y = 1; y < u + 1; y++)
2439
+ M = M.createNext(P), P += T;
2440
+ const C = (e.x - o) / (f + 1);
2441
+ for (let y = u + 1; y < _; y++)
2442
+ M = M.createNext(P), P += C;
2443
+ const k = new ht(0);
2444
+ let I = k;
2445
+ const U = e.y / (g - 1);
2446
+ let L = 0;
2447
+ for (let y = 0; y < g - 1; y++)
2448
+ L += U, I = I.createNext(L);
2449
+ const z = [], E = [], A = i.clone();
2499
2450
  if (n) {
2500
2451
  let y = 0;
2501
2452
  this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
2502
2453
  const b = Math.max(0.01, s);
2503
- V.left = 0, V.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, V.down = b / e.y, V.up = b / e.y;
2504
- }
2505
- const C = new ue(a, V, !1);
2506
- C.insert(p, T, z, U), p.updateIndex(0), T.updateIndex(0), xt(z, a.xSeams), xt(U, a.zSeams);
2507
- const D = this.m_BindingVertexCount + 2, L = new Array(D);
2508
- a.xNoneSeamIndexes = L, P = p;
2509
- for (let y = 0; y < D; y++) {
2510
- L[y] = P.index;
2454
+ A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, A.down = b / e.y, A.up = b / e.y;
2455
+ }
2456
+ const B = new oe(a, A, !1);
2457
+ B.insert(p, k, z, E), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(E, a.zSeams);
2458
+ const w = this.m_BindingVertexCount + 2, v = new Array(w);
2459
+ a.xNoneSeamIndexes = v, M = p;
2460
+ for (let y = 0; y < w; y++) {
2461
+ v[y] = M.index;
2511
2462
  do
2512
- P = P.next;
2513
- while (P.seam);
2514
- }
2515
- const v = p.getValues(), Q = T.getValues();
2516
- u = v.length, f = Q.length;
2517
- const G = u * f, $ = [], W = new Array(G).fill(0), A = [], x = [], H = [], S = [];
2518
- Kt(
2519
- $,
2520
- v,
2521
- Q,
2463
+ M = M.next;
2464
+ while (M.seam);
2465
+ }
2466
+ const N = p.getValues(), R = k.getValues();
2467
+ _ = N.length, g = R.length;
2468
+ const $ = _ * g, tt = [], q = new Array($).fill(0), O = [], x = [], Z = [], S = [];
2469
+ $t(
2470
+ tt,
2471
+ N,
2472
+ R,
2522
2473
  e,
2523
2474
  i,
2524
2475
  this.m_Book.direction
2525
2476
  );
2526
- const I = C.leftNode.index, E = C.downNode.index;
2527
- let j = C.rightNode.index, q = C.upNode.index;
2528
- j === 0 && (j = u - 1), q === 0 && (q = f - 1);
2529
- for (let y = 0; y < f - 1; y++)
2530
- for (let b = 0; b < u - 1; b++) {
2531
- if (n && y >= E && y < q && b >= I && b < j)
2477
+ const V = B.leftNode.index, G = B.downNode.index;
2478
+ let Y = B.rightNode.index, K = B.upNode.index;
2479
+ Y === 0 && (Y = _ - 1), K === 0 && (K = g - 1);
2480
+ for (let y = 0; y < g - 1; y++)
2481
+ for (let b = 0; b < _ - 1; b++) {
2482
+ if (n && y >= G && y < K && b >= V && b < Y)
2532
2483
  continue;
2533
- const K = y * u + b, J = y * u + (b + 1), ct = (y + 1) * u + b, ht = (y + 1) * u + (b + 1);
2534
- W[K] += 2, W[J] += 2, W[ct] += 2, W[ht] += 2, Yt(
2535
- A,
2484
+ const it = y * _ + b, nt = y * _ + (b + 1), ct = (y + 1) * _ + b, ot = (y + 1) * _ + (b + 1);
2485
+ q[it] += 2, q[nt] += 2, q[ct] += 2, q[ot] += 2, Qt(
2486
+ O,
2536
2487
  x,
2537
- K,
2538
- J,
2488
+ it,
2489
+ nt,
2539
2490
  ct,
2540
- ht,
2541
- G
2491
+ ot,
2492
+ $
2542
2493
  );
2543
2494
  }
2544
- if (S.push(new St(0, 0, u - 1, f - 1, !1, !1)), Qt(S, H, $, u, f), a.baseXArray = v, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = W, o) {
2495
+ if (S.push(new Tt(0, 0, _ - 1, g - 1, !1, !1)), jt(S, Z, tt, _, g), a.baseXArray = N, a.baseZArray = R, a.baseVertexCount = $, a.vertexCount = tt.length, a.texcoords = tt, a.weights = q, h) {
2545
2496
  a.subMeshCount = 1;
2546
2497
  const y = [];
2547
- y.push(...A), y.push(...H), y.push(...x), a.triangles = y;
2498
+ y.push(...O), y.push(...Z), y.push(...x), a.triangles = y;
2548
2499
  } else
2549
- a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = x, a.borderTriangles = H;
2500
+ a.subMeshCount = 3, a.frontTriangles = O, a.backTriangles = x, a.borderTriangles = Z;
2550
2501
  return a.borders = S, a;
2551
2502
  }
2552
2503
  // ── updateRootPosition ────────────────────────────────────────────────
@@ -2559,97 +2510,82 @@ class Oe {
2559
2510
  resetPaperPosition(t) {
2560
2511
  const e = this.m_Book.papers, s = e.length;
2561
2512
  let i = 0;
2562
- const n = e.length / 2 - 1, o = e.length / 2;
2563
- for (let M = 0; M < s; M++) {
2564
- const w = e[M];
2565
- w.updateTime();
2566
- const T = w.zTime, k = w.thickness;
2567
- i += T * k, M === n && (i += T * this.m_BindingMidSpace / 2), M === o && (i += T * this.m_BindingMidSpace / 2);
2513
+ const n = e.length / 2 - 1, h = e.length / 2;
2514
+ for (let P = 0; P < s; P++) {
2515
+ const C = e[P];
2516
+ C.updateTime();
2517
+ const k = C.zTime, I = C.thickness;
2518
+ i += k * I, P === n && (i += k * this.m_BindingMidSpace / 2), P === h && (i += k * this.m_BindingMidSpace / 2);
2568
2519
  }
2569
2520
  let a = this.getStackHeight(t.index) - t.thickness / 2;
2570
- const h = this.getStackZ(a), m = 180 + h;
2571
- let l = t.isFlipped ? 1 : 0, d = F(h, m, l);
2572
- const g = d * tt, _ = new c.Vector3(
2573
- Math.cos(g) * this.m_BindingRadius,
2574
- Math.sin(g) * this.m_BindingRadius,
2521
+ const o = this.getStackZ(a), u = 180 + o;
2522
+ let c = t.isFlipped ? 1 : 0, m = F(o, u, c);
2523
+ const f = m * J, d = new l.Vector3(
2524
+ Math.cos(f) * this.m_BindingRadius,
2525
+ Math.sin(f) * this.m_BindingRadius,
2575
2526
  0
2576
2527
  );
2577
- _.z = t.margin;
2578
- 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;
2528
+ d.z = t.margin;
2529
+ let _ = e[Math.floor(s / 2)].size.x, g = this.m_BindingMidSpace, p = Math.sqrt(_ * _ - g * g), M = Math.asin(p / _) * et - 90;
2579
2530
  if (t.index < Math.floor(s / 2)) {
2580
- let M = 0;
2531
+ let P = 0;
2581
2532
  if (this.m_Book.alignToGround) {
2582
- u = e[0].size.x;
2583
- const w = this.m_StackHeight / 2;
2584
- f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2533
+ _ = e[0].size.x;
2534
+ const C = this.m_StackHeight / 2;
2535
+ g = H(i, 0, C) - C, p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2585
2536
  }
2586
- d = F(P, -M, l);
2537
+ m = F(M, -P, c);
2587
2538
  } else {
2588
- let M = 0;
2539
+ let P = 0;
2589
2540
  if (this.m_Book.alignToGround) {
2590
- u = e[0].size.x;
2591
- const w = this.m_StackHeight / 2;
2592
- f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2541
+ _ = e[0].size.x;
2542
+ const C = this.m_StackHeight / 2;
2543
+ g = C - H(i, C, C * 2), p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2593
2544
  }
2594
- d = F(M, -P, l);
2545
+ m = F(P, -M, c);
2595
2546
  }
2596
- t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2597
- new c.Euler(0, 0, d * tt)
2547
+ t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2548
+ new l.Euler(0, 0, m * J)
2598
2549
  );
2599
2550
  }
2600
2551
  // ── getPX (private helper) ───────────────────────────────────────────
2601
2552
  getPX(t, e) {
2602
- const s = this.m_Book.papers, i = s.length;
2603
- let n = 0;
2604
- const o = s.length / 2 - 1, a = s.length / 2;
2605
- for (let f = 0; f < i; f++)
2606
- n += 0 * e, f === o && (n += 0 * this.m_BindingMidSpace / 2), f === a && (n += 0 * this.m_BindingMidSpace / 2);
2607
- const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, _ = F(m, l, 0) * tt;
2608
- return new c.Vector3(
2609
- Math.cos(_) * this.m_BindingRadius,
2610
- Math.sin(_) * this.m_BindingRadius,
2611
- 0
2612
- ).x;
2553
+ const s = this.getStackHeight(t) - e / 2, n = this.getStackZ(s) * J;
2554
+ return Math.cos(n) * this.m_BindingRadius;
2613
2555
  }
2614
2556
  // ── updatePaperPosition ───────────────────────────────────────────────
2615
2557
  updatePaperPosition(t) {
2616
- const e = this.m_Book.papers, s = e.length;
2617
- let i = 0;
2618
- const n = e.length / 2 - 1, o = e.length / 2;
2619
- for (let M = 0; M < s; M++) {
2620
- const w = e[M];
2621
- w.updateTime();
2622
- const T = w.zTime, k = w.thickness;
2623
- i += T * k, M === n && (i += T * this.m_BindingMidSpace / 2), M === o && (i += T * this.m_BindingMidSpace / 2);
2624
- }
2625
- const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
2626
- let l = t.zTime, d = F(h, m, l);
2627
- const g = d * tt, _ = new c.Vector3(
2628
- Math.cos(g) * this.m_BindingRadius,
2629
- Math.sin(g) * this.m_BindingRadius,
2558
+ this.updatePaperPositionWithTh(t, this.computeTh());
2559
+ }
2560
+ updatePaperPositionWithTh(t, e) {
2561
+ const s = this.m_Book.papers, i = s.length, n = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(n + e), a = 180 + this.getStackZ(n + e - this.m_StackHeight);
2562
+ let o = t.zTime, u = F(h, a, o);
2563
+ const c = u * J, m = new l.Vector3(
2564
+ Math.cos(c) * this.m_BindingRadius,
2565
+ Math.sin(c) * this.m_BindingRadius,
2630
2566
  0
2631
2567
  );
2632
- _.z = t.margin;
2633
- 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;
2634
- if (t.index < Math.floor(s / 2)) {
2568
+ m.z = t.margin;
2569
+ let f = s[Math.floor(i / 2)].size.x, d = this.m_BindingMidSpace, _ = Math.sqrt(f * f - d * d), g = Math.asin(_ / f) * et - 90;
2570
+ if (t.index < Math.floor(i / 2)) {
2635
2571
  let M = 0;
2636
2572
  if (this.m_Book.alignToGround) {
2637
- u = e[0].size.x;
2638
- const w = this.m_StackHeight / 2;
2639
- f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2573
+ f = s[0].size.x;
2574
+ const T = this.m_StackHeight / 2;
2575
+ d = H(e, 0, T) - T, _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2640
2576
  }
2641
- d = F(P, -M, l);
2577
+ u = F(g, -M, o);
2642
2578
  } else {
2643
2579
  let M = 0;
2644
2580
  if (this.m_Book.alignToGround) {
2645
- u = e[0].size.x;
2646
- const w = this.m_StackHeight / 2;
2647
- f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2581
+ f = s[0].size.x;
2582
+ const T = this.m_StackHeight / 2;
2583
+ d = T - H(e, T, T * 2), _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2648
2584
  }
2649
- d = F(M, -P, l);
2585
+ u = F(M, -g, o);
2650
2586
  }
2651
- t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2652
- new c.Euler(0, 0, d * tt)
2587
+ t.transform.position.copy(m), t.transform.quaternion.setFromEuler(
2588
+ new l.Euler(0, 0, u * J)
2653
2589
  );
2654
2590
  }
2655
2591
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2663,58 +2599,70 @@ class Oe {
2663
2599
  }
2664
2600
  // ── getStackZ ─────────────────────────────────────────────────────────
2665
2601
  getStackZ(t) {
2666
- t = et(t, 0, this.m_StackHeight);
2602
+ t = H(t, 0, this.m_StackHeight);
2667
2603
  const e = t - this.m_StackHeight * 0.5;
2668
- return Math.asin(e / this.m_BindingRadius) * it;
2604
+ return Math.asin(e / this.m_BindingRadius) * et;
2669
2605
  }
2670
2606
  // ── onLateUpdate ──────────────────────────────────────────────────────
2607
+ /** Precompute cumulative th once instead of per-paper (O(n) instead of O(n²)). */
2608
+ computeTh() {
2609
+ const t = this.m_Book.papers, e = t.length / 2 - 1, s = t.length / 2;
2610
+ let i = 0;
2611
+ for (let n = 0; n < t.length; n++) {
2612
+ const h = t[n];
2613
+ h.updateTime();
2614
+ const a = h.zTime;
2615
+ i += a * h.thickness, n === e && (i += a * this.m_BindingMidSpace / 2), n === s && (i += a * this.m_BindingMidSpace / 2);
2616
+ }
2617
+ return i;
2618
+ }
2671
2619
  onLateUpdate() {
2672
- const t = this.m_Book.papers;
2673
- for (const e of t)
2674
- this.updatePaperPosition(e);
2620
+ const t = this.m_Book.papers, e = this.computeTh();
2621
+ for (const s of t)
2622
+ this.updatePaperPositionWithTh(s, e);
2675
2623
  this.m_Root.updateMatrixWorld(!0), this.updateBindingVertices();
2676
- for (const e of t)
2677
- e.updateMesh();
2624
+ for (const s of t)
2625
+ s.updateMesh();
2678
2626
  this.updateRootPosition();
2679
2627
  }
2680
2628
  // ── updateBindingVertices ─────────────────────────────────────────────
2681
2629
  updateBindingVertices() {
2682
2630
  const t = this.m_Book.papers;
2683
- let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2684
- const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
2685
- for (let m = 0; m < h; m++) {
2686
- 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, M = l.thickness, w = g.xNoneSeamIndexes, T = d.position.clone();
2687
- let k = m, O = n;
2688
- m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
2689
- const Z = (o + M) * 0.5 + M * (k - 1), z = d.matrixWorld.clone().invert().multiply(a), U = k / (h / 2);
2690
- i = this.m_BindingRadius * F(0.45, 0.65, 1 - U);
2691
- for (let V = 0; V < P; V++) {
2692
- const C = f[V], D = new c.Vector3(0, 0, T.z + C), L = T.clone();
2693
- L.z += C;
2694
- const v = l.getDirection(C).multiplyScalar(i).add(L.clone());
2695
- if (m === 0 && V === 0) {
2696
- const A = t[h - 1], H = A.transform.position.clone().clone();
2697
- H.z += C;
2698
- const S = A.getDirection(C).multiplyScalar(i).add(H);
2699
- s = v.clone().sub(S).normalize(), e = new c.Vector3(
2631
+ let e = new l.Vector3(0, 0, 0), s = new l.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2632
+ const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), o = t.length;
2633
+ for (let u = 0; u < o; u++) {
2634
+ const c = t[u], m = c.transform, f = c.meshData.pattern, d = c.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = c.thickness, C = f.xNoneSeamIndexes, k = m.position.clone();
2635
+ let I = u, U = n;
2636
+ u >= Math.floor(o / 2) && (I = o - u - 1, U *= -1);
2637
+ const L = (h + P) * 0.5 + P * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), E = I / (o / 2);
2638
+ i = this.m_BindingRadius * F(0.45, 0.65, 1 - E);
2639
+ for (let A = 0; A < M; A++) {
2640
+ const B = g[A], w = new l.Vector3(0, 0, k.z + B), v = k.clone();
2641
+ v.z += B;
2642
+ const N = c.getDirection(B).multiplyScalar(i).add(v.clone());
2643
+ if (u === 0 && A === 0) {
2644
+ const O = t[o - 1], Z = O.transform.position.clone().clone();
2645
+ Z.z += B;
2646
+ const S = O.getDirection(B).multiplyScalar(i).add(Z);
2647
+ s = N.clone().sub(S).normalize(), e = new l.Vector3(
2700
2648
  -s.y,
2701
2649
  s.x,
2702
2650
  0
2703
2651
  ).normalize().negate();
2704
- const I = Math.atan2(e.y, e.x) * it;
2705
- this.stapleMesh.rotation.set(0, 0, I * tt);
2652
+ const V = Math.atan2(e.y, e.x) * et;
2653
+ this.stapleMesh.rotation.set(0, 0, V * J);
2706
2654
  }
2707
- k > 0 && D.add(e.clone().multiplyScalar(Z));
2708
- const Q = V * p;
2709
- _[Q] = D.clone().applyMatrix4(z), D.add(s.clone().multiplyScalar(O));
2710
- const G = D.clone().applyMatrix4(z), $ = v.clone().applyMatrix4(z), W = L.clone().applyMatrix4(z);
2711
- _[Q + w[1]] = G;
2712
- for (let A = 2; A < B; A++) {
2713
- const x = Wt(1, B, A);
2714
- _[Q + w[A]] = Et(
2715
- G,
2655
+ I > 0 && w.add(e.clone().multiplyScalar(L));
2656
+ const R = A * p;
2657
+ d[R] = w.clone().applyMatrix4(z), w.add(s.clone().multiplyScalar(U));
2658
+ const $ = w.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
2659
+ d[R + C[1]] = $;
2660
+ for (let O = 2; O < T; O++) {
2661
+ const x = Q(1, T, O);
2662
+ d[R + C[O]] = Et(
2716
2663
  $,
2717
- W,
2664
+ tt,
2665
+ q,
2718
2666
  x
2719
2667
  );
2720
2668
  }
@@ -2743,16 +2691,18 @@ class Oe {
2743
2691
  get stapleThickness() {
2744
2692
  return this.m_StapleThickness;
2745
2693
  }
2694
+ /** Releases GPU resources held by the staple mesh. */
2695
+ dispose() {
2696
+ this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof l.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2697
+ }
2746
2698
  }
2747
- class Ze {
2699
+ class Ve {
2748
2700
  constructor(t) {
2749
2701
  this.mesh = t;
2750
2702
  }
2751
2703
  setVisibility(t) {
2752
2704
  this.mesh.visible = t;
2753
2705
  }
2754
- updateCollider() {
2755
- }
2756
2706
  get castShadows() {
2757
2707
  return this.mesh.castShadow;
2758
2708
  }
@@ -2760,7 +2710,7 @@ class Ze {
2760
2710
  this.mesh.castShadow = t;
2761
2711
  }
2762
2712
  get bounds() {
2763
- const t = new c.Box3();
2713
+ const t = new l.Box3();
2764
2714
  return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
2765
2715
  }
2766
2716
  get transform() {
@@ -2770,12 +2720,12 @@ class Ze {
2770
2720
  return this.mesh;
2771
2721
  }
2772
2722
  }
2773
- class $e extends Te {
2723
+ class Ue extends Me {
2774
2724
  constructor() {
2775
- super(...arguments), this.quality = 3, this.stapleSetup = new He();
2725
+ super(...arguments), this.quality = 3, this.stapleSetup = new De();
2776
2726
  }
2777
2727
  createBound(t, e, s, i) {
2778
- return new Oe(
2728
+ return new Ie(
2779
2729
  this.quality,
2780
2730
  this.stapleSetup,
2781
2731
  t,
@@ -2783,7 +2733,7 @@ class $e extends Te {
2783
2733
  );
2784
2734
  }
2785
2735
  }
2786
- class ee {
2736
+ class Yt {
2787
2737
  constructor(t) {
2788
2738
  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;
2789
2739
  }
@@ -2807,9 +2757,9 @@ class ee {
2807
2757
  }
2808
2758
  const i = s.split(/\s+/);
2809
2759
  let n = "";
2810
- for (const o of i) {
2811
- const a = n ? `${n} ${o}` : o;
2812
- t.measureText(a).width > this.width && n ? (e.push(n), n = o) : n = a;
2760
+ for (const h of i) {
2761
+ const a = n ? `${n} ${h}` : h;
2762
+ t.measureText(a).width > this.width && n ? (e.push(n), n = h) : n = a;
2813
2763
  }
2814
2764
  n && e.push(n);
2815
2765
  }
@@ -2823,8 +2773,8 @@ class ee {
2823
2773
  hitTest(t, e, s) {
2824
2774
  const i = this.wrapLines(t);
2825
2775
  if (i.length === 0) return !1;
2826
- const n = i.length * this.fontSize * this.lineHeight, o = this.width > 0 ? this.width : this._maxLineWidth(t, i);
2827
- return e >= this.x && e <= this.x + o && s >= this.y && s <= this.y + n;
2776
+ const n = i.length * this.fontSize * this.lineHeight, h = this.width > 0 ? this.width : this._maxLineWidth(t, i);
2777
+ return e >= this.x && e <= this.x + h && s >= this.y && s <= this.y + n;
2828
2778
  }
2829
2779
  _maxLineWidth(t, e) {
2830
2780
  t.font = this._font();
@@ -2842,23 +2792,34 @@ class ee {
2842
2792
  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);
2843
2793
  const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
2844
2794
  for (let n = 0; n < e.length; n++) {
2845
- let o = this.x;
2846
- 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);
2795
+ let h = this.x;
2796
+ this.textAlign === "center" ? h = this.x + (i - t.measureText(e[n]).width) / 2 : this.textAlign === "right" && (h = this.x + i - t.measureText(e[n]).width), t.fillText(e[n], h, this.y + n * s);
2847
2797
  }
2848
2798
  t.restore();
2849
2799
  }
2850
2800
  }
2851
- function Ue(r) {
2852
- return r.map instanceof c.Texture;
2801
+ function ze(r) {
2802
+ return r.map instanceof l.Texture;
2803
+ }
2804
+ function Kt(r, t) {
2805
+ r.traverse((e) => {
2806
+ if (!e.isMesh) return;
2807
+ const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2808
+ for (const n of i)
2809
+ ze(n) && n.map.image === t && (n.map.needsUpdate = !0);
2810
+ });
2853
2811
  }
2854
- class Ye {
2812
+ function Jt(r, t) {
2813
+ t.x !== void 0 && (r.x = t.x), t.y !== void 0 && (r.y = t.y), t.width !== void 0 && (r.width = t.width), t.text !== void 0 && (r.text = t.text), t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && (r.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (r.fontStyle = t.fontStyle), t.color !== void 0 && (r.color = t.color), t.lineHeight !== void 0 && (r.lineHeight = t.lineHeight), t.textAlign !== void 0 && (r.textAlign = t.textAlign), t.opacity !== void 0 && (r.opacity = t.opacity), t.shadowColor !== void 0 && (r.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (r.shadowBlur = t.shadowBlur);
2814
+ }
2815
+ class Le {
2855
2816
  constructor(t) {
2856
- this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
2817
+ this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0);
2857
2818
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
2858
2819
  this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
2859
2820
  const i = this.canvas.getContext("2d");
2860
2821
  if (!i) throw new Error("TextOverlayContent: could not get 2D context");
2861
- this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace;
2822
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace;
2862
2823
  }
2863
2824
  get texture() {
2864
2825
  return this._texture;
@@ -2875,7 +2836,7 @@ class Ye {
2875
2836
  }
2876
2837
  // ── Text API ─────────────────────────────────────────────────────────────
2877
2838
  addText(t) {
2878
- const e = new ee(t);
2839
+ const e = new Yt(t);
2879
2840
  return this.texts.push(e), e;
2880
2841
  }
2881
2842
  removeText(t) {
@@ -2885,7 +2846,7 @@ class Ye {
2885
2846
  /** Update a text block by index. Only provided fields are changed. */
2886
2847
  updateText(t, e) {
2887
2848
  const s = this.texts[t];
2888
- 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));
2849
+ s && Jt(s, e);
2889
2850
  }
2890
2851
  // ── Per-frame update ─────────────────────────────────────────────────────
2891
2852
  /**
@@ -2899,7 +2860,7 @@ class Ye {
2899
2860
  update(t) {
2900
2861
  const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2901
2862
  e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2902
- for (const o of this.texts) o.draw(e);
2863
+ for (const h of this.texts) h.draw(e);
2903
2864
  this._texture.needsUpdate = !0, t && this.syncMaterials(t);
2904
2865
  }
2905
2866
  /**
@@ -2907,12 +2868,7 @@ class Ye {
2907
2868
  * source image is this overlay's canvas.
2908
2869
  */
2909
2870
  syncMaterials(t) {
2910
- t.traverse((e) => {
2911
- if (!e.isMesh) return;
2912
- const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2913
- for (const n of i)
2914
- Ue(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
2915
- });
2871
+ Kt(t, this.canvas);
2916
2872
  }
2917
2873
  // ── IPageContent ─────────────────────────────────────────────────────────
2918
2874
  isPointOverUI(t) {
@@ -2923,15 +2879,12 @@ class Ye {
2923
2879
  setActive(t) {
2924
2880
  }
2925
2881
  dispose() {
2926
- this._texture.dispose();
2882
+ this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
2927
2883
  }
2928
2884
  }
2929
- function Le(r) {
2930
- return r.map instanceof c.Texture;
2931
- }
2932
- class Gt {
2885
+ class Xt {
2933
2886
  constructor(t, e) {
2934
- this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
2887
+ this._spread = t, this._textureST = e === "left" ? new l.Vector4(0.5, 1, 0, 0) : new l.Vector4(0.5, 1, 0.5, 0);
2935
2888
  }
2936
2889
  get texture() {
2937
2890
  return this._spread.texture;
@@ -2947,18 +2900,18 @@ class Gt {
2947
2900
  setActive(t) {
2948
2901
  }
2949
2902
  }
2950
- function Ke(r) {
2903
+ function Ee(r) {
2951
2904
  const t = [];
2952
2905
  for (let e = 1; e + 1 < r; e += 2)
2953
2906
  t.push(e);
2954
2907
  return t;
2955
2908
  }
2956
- class Je {
2909
+ class Ne {
2957
2910
  constructor(t) {
2958
2911
  this.texts = [], this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2959
2912
  const e = this.canvas.getContext("2d");
2960
2913
  if (!e) throw new Error("SpreadContent: could not get 2D context");
2961
- this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new Gt(this, "left"), this.right = new Gt(this, "right");
2914
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace, this.left = new Xt(this, "left"), this.right = new Xt(this, "right");
2962
2915
  }
2963
2916
  get texture() {
2964
2917
  return this._texture;
@@ -2972,7 +2925,7 @@ class Je {
2972
2925
  }
2973
2926
  // ── Text API ─────────────────────────────────────────────────────────────
2974
2927
  addText(t) {
2975
- const e = new ee(t);
2928
+ const e = new Yt(t);
2976
2929
  return this.texts.push(e), e;
2977
2930
  }
2978
2931
  removeText(t) {
@@ -2982,7 +2935,7 @@ class Je {
2982
2935
  /** Update a text block by index. Only provided fields are changed. */
2983
2936
  updateText(t, e) {
2984
2937
  const s = this.texts[t];
2985
- 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));
2938
+ s && Jt(s, e);
2986
2939
  }
2987
2940
  // ── Per-frame update ─────────────────────────────────────────────────────
2988
2941
  /**
@@ -2995,7 +2948,7 @@ class Je {
2995
2948
  update(t) {
2996
2949
  const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2997
2950
  e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2998
- for (const o of this.texts) o.draw(e);
2951
+ for (const h of this.texts) h.draw(e);
2999
2952
  this._texture.needsUpdate = !0, t && this.syncMaterials(t);
3000
2953
  }
3001
2954
  /**
@@ -3003,45 +2956,40 @@ class Je {
3003
2956
  * source image is this spread's canvas.
3004
2957
  */
3005
2958
  syncMaterials(t) {
3006
- t.traverse((e) => {
3007
- if (!e.isMesh) return;
3008
- const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
3009
- for (const n of i)
3010
- Le(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
3011
- });
2959
+ Kt(t, this.canvas);
3012
2960
  }
3013
2961
  // ── Lifecycle ────────────────────────────────────────────────────────────
3014
2962
  dispose() {
3015
- this._texture.dispose();
2963
+ this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
3016
2964
  }
3017
2965
  }
3018
- const jt = 256;
3019
- function Ne(r, t, e, s, i, n, o) {
3020
- const a = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
3021
- if (a <= 0 || h <= 0) return;
3022
- if (o === "fill") {
2966
+ const Wt = 256;
2967
+ function Ae(r, t, e, s, i, n, h) {
2968
+ const a = t.naturalWidth || t.width, o = t.naturalHeight || t.height;
2969
+ if (a <= 0 || o <= 0) return;
2970
+ if (h === "fill") {
3023
2971
  r.drawImage(t, e, s, i, n);
3024
2972
  return;
3025
2973
  }
3026
- const m = o === "contain" ? Math.min(i / a, n / h) : Math.max(i / a, n / h), l = a * m, d = h * m;
3027
- r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
2974
+ const u = h === "contain" ? Math.min(i / a, n / o) : Math.max(i / a, n / o), c = a * u, m = o * u;
2975
+ r.drawImage(t, e + (i - c) * 0.5, s + (n - m) * 0.5, c, m);
3028
2976
  }
3029
- function ts(r, t, e, s, i, n, o) {
3030
- const a = n ? Math.round(n * jt) : 512, h = o ? Math.round(o * jt) : 512, m = document.createElement("canvas");
3031
- m.width = a, m.height = h;
3032
- const l = m.getContext("2d");
3033
- if (l.fillStyle = r, l.fillRect(0, 0, a, h), e) {
3034
- const g = i ? 0 : Math.round(Math.min(a, h) * 0.11);
3035
- Ne(l, e, g, g, a - g * 2, h - g * 2, s);
2977
+ function Xe(r, t, e, s, i, n, h) {
2978
+ const a = n ? Math.round(n * Wt) : 512, o = h ? Math.round(h * Wt) : 512, u = document.createElement("canvas");
2979
+ u.width = a, u.height = o;
2980
+ const c = u.getContext("2d");
2981
+ if (c.fillStyle = r, c.fillRect(0, 0, a, o), e) {
2982
+ const f = i ? 0 : Math.round(Math.min(a, o) * 0.11);
2983
+ Ae(c, e, f, f, a - f * 2, o - f * 2, s);
3036
2984
  } else {
3037
- l.fillStyle = "#333";
3038
- const g = Math.round(Math.min(a, h) * 0.094);
3039
- l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, a / 2, h / 2);
2985
+ c.fillStyle = "#333";
2986
+ const f = Math.round(Math.min(a, o) * 0.094);
2987
+ c.font = `bold ${f}px Arial`, c.textAlign = "center", c.textBaseline = "middle", c.fillText(t, a / 2, o / 2);
3040
2988
  }
3041
- const d = new c.CanvasTexture(m);
3042
- return d.colorSpace = c.SRGBColorSpace, d;
2989
+ const m = new l.CanvasTexture(u);
2990
+ return m.colorSpace = l.SRGBColorSpace, m;
3043
2991
  }
3044
- async function es(r) {
2992
+ async function We(r) {
3045
2993
  if (!r) return null;
3046
2994
  const t = URL.createObjectURL(r), e = new Image();
3047
2995
  e.decoding = "async", e.src = t;
@@ -3054,47 +3002,47 @@ async function es(r) {
3054
3002
  }
3055
3003
  }
3056
3004
  export {
3057
- ye as AnimationCurve,
3058
- wt as AutoTurnDirection,
3059
- Me as AutoTurnMode,
3060
- ot as AutoTurnSetting,
3061
- we as AutoTurnSettingCurveTimeMode,
3062
- Ce as AutoTurnSettingMode,
3063
- Lt as AutoTurnSettings,
3064
- yt as Book,
3065
- Te as BookBinding,
3066
- Qe as BookBound,
3067
- je as BookContent,
3068
- X as BookDirection,
3069
- Xe as BookHeightException,
3070
- qe as BookPointerInteraction,
3071
- pe as BookRenderer,
3072
- ut as Cylinder,
3073
- _e as MeshFactory,
3074
- jt as PX_PER_UNIT,
3075
- Ge as PageContent,
3076
- me as Paper,
3077
- St as PaperBorder,
3078
- At as PaperMaterialData,
3079
- Zt as PaperMeshData,
3080
- xe as PaperMeshDataPool,
3081
- Ee as PaperMeshUtility,
3082
- st as PaperNode,
3083
- ue as PaperNodeMargin,
3084
- Se as PaperPattern,
3005
+ ge as AnimationCurve,
3006
+ yt as AutoTurnDirection,
3007
+ ut as AutoTurnMode,
3008
+ at as AutoTurnSetting,
3009
+ fe as AutoTurnSettingCurveTimeMode,
3010
+ de as AutoTurnSettingMode,
3011
+ Ut as AutoTurnSettings,
3012
+ Ct as Book,
3013
+ Me as BookBinding,
3014
+ ye as BookBound,
3015
+ Oe as BookContent,
3016
+ j as BookDirection,
3017
+ pe as BookHeightException,
3018
+ Ze as BookPointerInteraction,
3019
+ me as BookRenderer,
3020
+ wt as Cylinder,
3021
+ le as MeshFactory,
3022
+ Wt as PX_PER_UNIT,
3023
+ Fe as PageContent,
3024
+ ae as Paper,
3025
+ Tt as PaperBorder,
3026
+ zt as PaperMaterialData,
3027
+ Ot as PaperMeshData,
3028
+ _e as PaperMeshDataPool,
3029
+ He as PaperMeshUtility,
3030
+ ht as PaperNode,
3031
+ oe as PaperNodeMargin,
3032
+ xe as PaperPattern,
3085
3033
  Pt as PaperSeam,
3086
- nt as PaperSetup,
3087
- pt as PaperUVMargin,
3088
- fe as RendererFactory,
3089
- Je as SpreadContent,
3090
- Nt as SpritePageContent2,
3091
- $e as StapleBookBinding,
3092
- Oe as StapleBookBound,
3093
- He as StapleSetup,
3094
- ee as TextBlock,
3095
- Ye as TextOverlayContent,
3096
- ts as createPageTexture,
3097
- Ne as drawImageWithFit,
3098
- Ke as getSpreadPairs,
3099
- es as loadImage
3034
+ rt as PaperSetup,
3035
+ gt as PaperUVMargin,
3036
+ ce as RendererFactory,
3037
+ Ne as SpreadContent,
3038
+ Lt as SpritePageContent2,
3039
+ Ue as StapleBookBinding,
3040
+ Ie as StapleBookBound,
3041
+ De as StapleSetup,
3042
+ Yt as TextBlock,
3043
+ Le as TextOverlayContent,
3044
+ Xe as createPageTexture,
3045
+ Ae as drawImageWithFit,
3046
+ Ee as getSpreadPairs,
3047
+ We as loadImage
3100
3048
  };