@objectifthunes/three-book 0.3.1 → 0.4.1

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