@objectifthunes/three-book 0.5.9 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as c from "three";
2
- class Ct {
1
+ import * as u from "three";
2
+ class bt {
3
3
  constructor() {
4
- this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new c.Vector3(), this._scratchRP1 = new c.Vector3(), this._scratchRP2 = new c.Vector3(), this._scratchRollClosest = new c.Vector3(), this._scratchRollEuler = new c.Vector3(), this._scratchOffsetRoll = new c.Vector3();
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 u.Vector3(), this._scratchRP1 = new u.Vector3(), this._scratchRP2 = new u.Vector3(), this._scratchRollClosest = new u.Vector3(), this._scratchRollEuler = new u.Vector3(), this._scratchOffsetRoll = new u.Vector3();
5
5
  }
6
6
  // ── Properties ────────────────────────────────────────────────────────
7
7
  /** Returns internal vector — do NOT mutate. Copy if you need to store it. */
@@ -33,8 +33,8 @@ class Ct {
33
33
  * Writes result into `out` and returns it.
34
34
  */
35
35
  eulerRotateVector(t, e, s, i) {
36
- const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), o = Math.sin(n), u = t * a, l = t * o, m = 0, f = Math.cos(h), d = Math.sin(h), _ = u * f + m * d, g = l, p = -u * d + m * f;
37
- return i.set(_, g, p);
36
+ const n = s * Math.PI / 180, r = e * Math.PI / 180, o = Math.cos(n), c = Math.sin(n), l = t * o, a = t * c, d = 0, g = Math.cos(r), _ = Math.sin(r), m = l * g + d * _, f = a, x = -l * _ + d * g;
37
+ return i.set(m, f, x);
38
38
  }
39
39
  /**
40
40
  * Rolls `point` in place around the cylinder. Mutates and returns `point`.
@@ -78,145 +78,145 @@ class Ct {
78
78
  }
79
79
  // ── Value-type clone ──────────────────────────────────────────────────
80
80
  clone() {
81
- const t = new Ct();
81
+ const t = new bt();
82
82
  return t.m_PositionX = this.m_PositionX, t.m_PositionZ = this.m_PositionZ, t.m_DirectionX = this.m_DirectionX, t.m_DirectionZ = this.m_DirectionZ, t.m_EulerY = this.m_EulerY, t.m_Radius = this.m_Radius, t;
83
83
  }
84
84
  }
85
- function dt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
85
+ function yt(h, t, e, s, i = 1 / 0, n = 1 / 60) {
86
86
  s = Math.max(s, 1e-4);
87
- const h = 2 / s, a = h * n, o = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
88
- let u = r - t;
89
- const l = t, m = i * s;
90
- u = c.MathUtils.clamp(u, -m, m), t = r - u;
91
- const f = (e + h * u) * n;
92
- e = (e - h * f) * o;
93
- let d = t + (u + f) * o;
94
- return l - r > 0 == d > l && (d = l, e = (d - l) / n), { value: d, velocity: e };
95
- }
96
- function se(r, t, e, s, i = 1 / 0, n = 1 / 60) {
97
- const h = dt(
98
- r.x,
87
+ const r = 2 / s, o = r * n, c = 1 / (1 + o + 0.48 * o * o + 0.235 * o * o * o);
88
+ let l = h - t;
89
+ const a = t, d = i * s;
90
+ l = u.MathUtils.clamp(l, -d, d), t = h - l;
91
+ const g = (e + r * l) * n;
92
+ e = (e - r * g) * c;
93
+ let _ = t + (l + g) * c;
94
+ return a - h > 0 == _ > a && (_ = a, e = (_ - a) / n), { value: _, velocity: e };
95
+ }
96
+ function _e(h, t, e, s, i = 1 / 0, n = 1 / 60) {
97
+ const r = yt(
98
+ h.x,
99
99
  t.x,
100
100
  e.x,
101
101
  s.x,
102
102
  i,
103
103
  n
104
- ), a = dt(
105
- r.y,
104
+ ), o = yt(
105
+ h.y,
106
106
  t.y,
107
107
  e.y,
108
108
  s.y,
109
109
  i,
110
110
  n
111
- ), o = dt(
112
- r.z,
111
+ ), c = yt(
112
+ h.z,
113
113
  t.z,
114
114
  e.z,
115
115
  s.z,
116
116
  i,
117
117
  n
118
118
  );
119
- return e.set(h.velocity, a.velocity, o.velocity), r.set(h.value, a.value, o.value);
119
+ return e.set(r.velocity, o.velocity, c.velocity), h.set(r.value, o.value, c.value);
120
120
  }
121
- function vt(r, t, e) {
122
- const s = t * t - 4 * r * e;
121
+ function zt(h, t, e) {
122
+ const s = t * t - 4 * h * e;
123
123
  if (s < 0)
124
124
  return { rootCount: 0, root0: 0, root1: 0 };
125
125
  if (s === 0)
126
- return { rootCount: 1, root0: -t / (2 * r), root1: 0 };
126
+ return { rootCount: 1, root0: -t / (2 * h), root1: 0 };
127
127
  {
128
128
  const i = Math.sqrt(s);
129
129
  return {
130
130
  rootCount: 2,
131
- root0: (-t + i) / (2 * r),
132
- root1: (-t - i) / (2 * r)
131
+ root0: (-t + i) / (2 * h),
132
+ root1: (-t - i) / (2 * h)
133
133
  };
134
134
  }
135
135
  }
136
- const kt = new c.Vector2();
137
- function Bt(r, t, e, s) {
138
- return ie(r, t, e) ? s.copy(r) : (kt.set(r.x, t.y), ne(
139
- kt,
140
- r,
136
+ const It = new u.Vector2();
137
+ function At(h, t, e, s) {
138
+ return fe(h, t, e) ? s.copy(h) : (It.set(h.x, t.y), ge(
139
+ It,
140
+ h,
141
141
  t,
142
142
  e,
143
143
  s
144
144
  ));
145
145
  }
146
- function ie(r, t, e) {
147
- const s = r.x - t.x;
148
- let i = r.y - t.y;
146
+ function fe(h, t, e) {
147
+ const s = h.x - t.x;
148
+ let i = h.y - t.y;
149
149
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
150
150
  }
151
- function ne(r, t, e, s, i) {
152
- const n = e.x, h = e.y, a = r.x, o = r.y, u = t.x, l = t.y, m = s.x, f = s.y, d = 1 / (m * m), _ = 1 / (f * f);
153
- if (Math.abs(a - u) < 1e-5) {
154
- if (a >= n - m && a <= n + m) {
155
- const g = vt(
156
- _,
157
- -2 * _ * h,
158
- d * (a * a - 2 * n * a + n * n) + _ * h * h - 1
151
+ function ge(h, t, e, s, i) {
152
+ const n = e.x, r = e.y, o = h.x, c = h.y, l = t.x, a = t.y, d = s.x, g = s.y, _ = 1 / (d * d), m = 1 / (g * g);
153
+ if (Math.abs(o - l) < 1e-5) {
154
+ if (o >= n - d && o <= n + d) {
155
+ const f = zt(
156
+ m,
157
+ -2 * m * r,
158
+ _ * (o * o - 2 * n * o + n * n) + m * r * r - 1
159
159
  );
160
- if (g.rootCount === 1)
161
- return i.set(a, g.root0);
162
- if (g.rootCount === 2) {
163
- let p = g.root0, M = g.root1;
164
- return o < l && ([p, M] = [M, p]), i.set(a, M);
160
+ if (f.rootCount === 1)
161
+ return i.set(o, f.root0);
162
+ if (f.rootCount === 2) {
163
+ let x = f.root0, M = f.root1;
164
+ return c < a && ([x, M] = [M, x]), i.set(o, M);
165
165
  }
166
166
  }
167
167
  } else {
168
- const g = (l - o) / (u - a), p = o - g * a, M = p - h, T = vt(
169
- d + _ * g * g,
170
- 2 * M * g * _ - 2 * n * d,
171
- n * n * d + M * M * _ - 1
168
+ const f = (a - c) / (l - o), x = c - f * o, M = x - r, P = zt(
169
+ _ + m * f * f,
170
+ 2 * M * f * m - 2 * n * _,
171
+ n * n * _ + M * M * m - 1
172
172
  );
173
- if (T.rootCount === 1)
174
- return i.set(T.root0, g * T.root0 + p);
175
- if (T.rootCount === 2) {
176
- let P = T.root0, w = T.root1;
177
- return a < u && ([P, w] = [w, P]), i.set(w, g * w + p);
173
+ if (P.rootCount === 1)
174
+ return i.set(P.root0, f * P.root0 + x);
175
+ if (P.rootCount === 2) {
176
+ let C = P.root0, T = P.root1;
177
+ return o < l && ([C, T] = [T, C]), i.set(T, f * T + x);
178
178
  }
179
179
  }
180
- return i.copy(r);
180
+ return i.copy(h);
181
181
  }
182
- const ft = new c.Vector3(), bt = new c.Vector3(), Rt = new c.Ray();
183
- function Dt(r, t) {
184
- return ft.copy(r.origin).applyMatrix4(t), bt.copy(r.origin).add(r.direction).applyMatrix4(t), Rt.set(ft, bt.sub(ft).normalize()), Rt;
182
+ const Ct = new u.Vector3(), Ht = new u.Vector3(), Ft = new u.Ray();
183
+ function Ot(h, t) {
184
+ return Ct.copy(h.origin).applyMatrix4(t), Ht.copy(h.origin).add(h.direction).applyMatrix4(t), Ft.set(Ct, Ht.sub(Ct).normalize()), Ft;
185
185
  }
186
- function re(r) {
187
- const t = r.x;
188
- r.set(-t, r.y, r.z + t, r.w);
186
+ function pe(h) {
187
+ const t = h.x;
188
+ h.set(-t, h.y, h.z + t, h.w);
189
189
  }
190
- function he(r) {
191
- const t = r.y;
192
- r.set(r.x, -t, r.z, r.w + t);
190
+ function xe(h) {
191
+ const t = h.y;
192
+ h.set(h.x, -t, h.z, h.w + t);
193
193
  }
194
- var j = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(j || {});
195
- const J = Math.PI / 180, et = 180 / Math.PI;
196
- function H(r, t, e) {
197
- return r < t ? t : r > e ? e : r;
194
+ var it = /* @__PURE__ */ ((h) => (h[h.LeftToRight = 0] = "LeftToRight", h[h.RightToLeft = 1] = "RightToLeft", h[h.UpToDown = 2] = "UpToDown", h[h.DownToUp = 3] = "DownToUp", h))(it || {});
195
+ const Q = Math.PI / 180, et = 180 / Math.PI;
196
+ function Z(h, t, e) {
197
+ return h < t ? t : h > e ? e : h;
198
198
  }
199
- function lt(r) {
200
- return r < 0 ? 0 : r > 1 ? 1 : r;
199
+ function st(h) {
200
+ return h < 0 ? 0 : h > 1 ? 1 : h;
201
201
  }
202
- function F(r, t, e) {
203
- return e = lt(e), r + (t - r) * e;
202
+ function E(h, t, e) {
203
+ return e = st(e), h + (t - h) * e;
204
204
  }
205
- function It(r, t, e) {
206
- return r + (t - r) * e;
205
+ function Zt(h, t, e) {
206
+ return h + (t - h) * e;
207
207
  }
208
- function Q(r, t, e) {
209
- return r !== t ? lt((e - r) / (t - r)) : 0;
208
+ function nt(h, t, e) {
209
+ return h !== t ? st((e - h) / (t - h)) : 0;
210
210
  }
211
- var ut = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(ut || {});
212
- const ae = 1192093e-13;
213
- function Vt(r, t, e) {
214
- return e = lt((e - r) / (t - r)), e * e * (3 - 2 * e);
211
+ var gt = /* @__PURE__ */ ((h) => (h[h.Surface = 0] = "Surface", h[h.Edge = 1] = "Edge", h))(gt || {});
212
+ const Me = 1192093e-13;
213
+ function Lt(h, t, e) {
214
+ return e = st((e - h) / (t - h)), e * e * (3 - 2 * e);
215
215
  }
216
- class oe {
216
+ class ye {
217
217
  // ---- Constructor ----
218
218
  constructor(t, e, s, i) {
219
- this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new Ct(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new c.Vector3(), this._ucCurrentHandle = new c.Vector3(), this._ucHandleDir = new c.Vector3(), this._ucA = new c.Vector3(), this._ucB = new c.Vector3(), this._ucMid = new c.Vector3(), this._ucRollResult = new c.Vector3(), this._ucCylDir = new c.Vector3(), this._utV1 = new c.Vector3(), this._utV2 = new c.Vector3(), this._utV3 = new c.Vector3(), this._utV4 = new c.Vector3(), this._chP = new c.Vector3(), this._chA = new c.Vector3(), this._chC = new c.Vector3(), this._chEllipseCenter1 = new c.Vector2(), this._chEllipseCenter2 = new c.Vector2(), this._chEllipseSize1 = new c.Vector2(), this._chEllipseSize2 = new c.Vector2(), this._chP2 = new c.Vector2(), this._dirResult = new c.Vector3(), this._gdA = new c.Vector3(), this._gdB = new c.Vector3(), this._rlMatrix = new c.Matrix4(), this._rlPlane = new c.Plane(new c.Vector3(0, 1, 0), 0), this._rlTarget = new c.Vector3(), this._rlNormal = new c.Vector3(), this._utTarget = new c.Vector3(), this._ufSmoothTime = new c.Vector3(), this._umFrontST = new c.Vector4(), this._umBackST = new c.Vector4(), this._h2uResult = new c.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
219
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new u.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Rigid = !1, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new bt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new u.Plane(), this.m_StartHandle = new u.Vector3(), this.m_CurrentHandle = new u.Vector3(), this.m_EndHandle = new u.Vector3(), this.m_PrevHandle = new u.Vector3(), this.m_HandleOffset = new u.Vector3(), this.m_HandleVelocity = new u.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 u.Vector3(), this._ucCurrentHandle = new u.Vector3(), this._ucHandleDir = new u.Vector3(), this._ucA = new u.Vector3(), this._ucB = new u.Vector3(), this._ucMid = new u.Vector3(), this._ucRollResult = new u.Vector3(), this._ucCylDir = new u.Vector3(), this._utV1 = new u.Vector3(), this._utV2 = new u.Vector3(), this._utV3 = new u.Vector3(), this._utV4 = new u.Vector3(), this._chP = new u.Vector3(), this._chA = new u.Vector3(), this._chC = new u.Vector3(), this._chEllipseCenter1 = new u.Vector2(), this._chEllipseCenter2 = new u.Vector2(), this._chEllipseSize1 = new u.Vector2(), this._chEllipseSize2 = new u.Vector2(), this._chP2 = new u.Vector2(), this._dirResult = new u.Vector3(), this._gdA = new u.Vector3(), this._gdB = new u.Vector3(), this._rlMatrix = new u.Matrix4(), this._rlPlane = new u.Plane(new u.Vector3(0, 1, 0), 0), this._rlTarget = new u.Vector3(), this._rlNormal = new u.Vector3(), this._utTarget = new u.Vector3(), this._ufSmoothTime = new u.Vector3(), this._umFrontST = new u.Vector4(), this._umBackST = new u.Vector4(), this._h2uResult = new u.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
220
220
  }
221
221
  // ---- Properties (mirrors C#) ----
222
222
  get isMeshChanged() {
@@ -256,7 +256,7 @@ class oe {
256
256
  return this.m_IsFalling || this.m_IsTurning ? this.m_Transform.scale.x === -1 ? 1 - this.m_ZTime : this.m_ZTime : this.m_Transform.scale.x === -1 ? 1 : 0;
257
257
  }
258
258
  get direction() {
259
- const e = this.zTime * 180 * J, s = Math.cos(e), i = Math.sin(e);
259
+ const e = this.zTime * 180 * Q, s = Math.cos(e), i = Math.sin(e);
260
260
  return this._dirResult.set(-s, -i, 0);
261
261
  }
262
262
  get isTurning() {
@@ -317,7 +317,7 @@ class oe {
317
317
  this.m_MaterialData = t;
318
318
  }
319
319
  setPaperSetup(t) {
320
- this.m_Size.set(t.size.x, t.size.y), this.m_Thickness = t.thickness, this.m_Stiffness = t.stiffness, this.m_Margin = t.margin, this.m_UVMargin = t.uvMargin;
320
+ this.m_Size.set(t.size.x, t.size.y), this.m_Thickness = t.thickness, this.m_Stiffness = t.stiffness, this.m_Rigid = t.rigid, this.m_Margin = t.margin, this.m_UVMargin = t.uvMargin;
321
321
  }
322
322
  setContentData(t, e, s = !1) {
323
323
  this.m_FrontContent = t, this.m_BackContent = e, this.m_UseBackContentForSides = s;
@@ -325,9 +325,16 @@ class oe {
325
325
  setMinTurningRadius(t) {
326
326
  this.m_MinTurningRadius = t;
327
327
  }
328
+ get rigid() {
329
+ return this.m_Rigid;
330
+ }
328
331
  updateTurningRadius(t = 1) {
329
- let e = Math.max(this.m_Stiffness, 1 - lt(t));
330
- e <= 0.5 ? this.m_TurningRadius = Q(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - Q(0.5, 1, e)), 5) * J), this.m_TurningRadius = Math.max(
332
+ if (this.m_Rigid) {
333
+ this.m_TurningRadius = Math.max(this.m_Size.x * 50, this.m_MinTurningRadius);
334
+ return;
335
+ }
336
+ let e = Math.max(this.m_Stiffness, 1 - st(t));
337
+ e <= 0.5 ? this.m_TurningRadius = nt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - nt(0.5, 1, e)), 5) * Q), this.m_TurningRadius = Math.max(
331
338
  this.m_TurningRadius,
332
339
  this.m_MinTurningRadius
333
340
  );
@@ -335,7 +342,7 @@ class oe {
335
342
  startTurning(t) {
336
343
  var i, n;
337
344
  const e = t.clone();
338
- t = Dt(
345
+ t = Ot(
339
346
  t,
340
347
  this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
341
348
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
@@ -344,12 +351,12 @@ class oe {
344
351
  ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
345
352
  const s = this._rlTarget;
346
353
  if (t.intersectPlane(this._rlPlane, s) !== null) {
347
- const h = s;
348
- if (h.x > 0 && h.x < this.m_Size.x && h.z > 0 && h.z < this.m_Size.y) {
349
- if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(h), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), h.x < this.m_Size.x * 0.9) {
350
- this.m_HandleOffset.set(h.x - this.m_Size.x, 0, 0);
351
- const a = this.m_Transform.scale;
352
- a.x *= -1;
354
+ const r = s;
355
+ if (r.x > 0 && r.x < this.m_Size.x && r.z > 0 && r.z < this.m_Size.y) {
356
+ if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(r), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), r.x < this.m_Size.x * 0.9) {
357
+ this.m_HandleOffset.set(r.x - this.m_Size.x, 0, 0);
358
+ const o = this.m_Transform.scale;
359
+ o.x *= -1;
353
360
  }
354
361
  return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
355
362
  0
@@ -361,10 +368,10 @@ class oe {
361
368
  }
362
369
  stopTurning() {
363
370
  this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
364
- const t = new c.Vector3(0, 0, 0);
371
+ const t = new u.Vector3(0, 0, 0);
365
372
  for (const e of this.m_HandleVelocities)
366
373
  t.add(e);
367
- t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = F(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
374
+ 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 = E(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);
368
375
  }
369
376
  /**
370
377
  * Called each frame while the user is dragging.
@@ -388,14 +395,14 @@ class oe {
388
395
  var s, i;
389
396
  let e = !1;
390
397
  if (this.m_IsAutoTurning) {
391
- let n = lt(this.m_FallTime / this.m_FallDuration);
392
- n = Vt(0, 1, n), n = Vt(0, 1, n), this.m_CurrentHandle.lerpVectors(
398
+ let n = st(this.m_FallTime / this.m_FallDuration);
399
+ n = Lt(0, 1, n), n = Lt(0, 1, n), this.m_CurrentHandle.lerpVectors(
393
400
  this.m_StartHandle,
394
401
  this.m_EndHandle,
395
402
  this.m_IsFallingLeft ? n : 1 - n
396
- ), this.m_FallTime += t, e = Math.abs(n - 1) < ae;
403
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < Me;
397
404
  } else
398
- this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), se(
405
+ this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), _e(
399
406
  this.m_CurrentHandle,
400
407
  this.m_EndHandle,
401
408
  this.m_HandleVelocity,
@@ -422,12 +429,12 @@ class oe {
422
429
  }
423
430
  getTextureCoordinate(t) {
424
431
  const e = this.raycastLocal(t, !0);
425
- return e !== null ? this.hit2UV(e) : new c.Vector2(0, 0);
432
+ return e !== null ? this.hit2UV(e) : new u.Vector2(0, 0);
426
433
  }
427
434
  raycast(t) {
428
435
  const e = {
429
- point: new c.Vector3(),
430
- textureCoordinate: new c.Vector2(),
436
+ point: new u.Vector3(),
437
+ textureCoordinate: new u.Vector2(),
431
438
  pageContent: null,
432
439
  paperIndex: 0,
433
440
  pageIndex: 0
@@ -441,12 +448,12 @@ class oe {
441
448
  }
442
449
  hit2UV(t) {
443
450
  const e = this._h2uResult.set(
444
- Q(-this.sizeXOffset, this.m_Size.x, t.x),
451
+ nt(-this.sizeXOffset, this.m_Size.x, t.x),
445
452
  t.z / this.m_Size.y
446
453
  );
447
454
  this.m_UVMargin.fixUV(e);
448
455
  const s = this.m_Book.direction;
449
- if (s === j.UpToDown || s === j.DownToUp) {
456
+ if (s === it.UpToDown || s === it.DownToUp) {
450
457
  const i = e.x;
451
458
  e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
452
459
  } else
@@ -458,7 +465,7 @@ class oe {
458
465
  * Returns the local-space hit point, or null if no hit / out of bounds.
459
466
  */
460
467
  raycastLocal(t, e = !1) {
461
- t = Dt(
468
+ t = Ot(
462
469
  t,
463
470
  this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
464
471
  ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
@@ -496,19 +503,19 @@ class oe {
496
503
  t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
497
504
  ), this.m_SubMeshCount = t);
498
505
  const e = this._umFrontST.copy(this.m_FrontContent.textureST), s = this._umBackST.copy(this.m_BackContent.textureST);
499
- this.m_Book.direction > 1 ? he(s) : re(s);
506
+ this.m_Book.direction > 1 ? xe(s) : pe(s);
500
507
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
501
508
  if (t === 3) {
502
- let h = 0, a = 1;
503
- this.m_Transform.scale.x === -1 && (h = 1, a = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
509
+ let r = 0, o = 1;
510
+ this.m_Transform.scale.x === -1 && (r = 1, o = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
504
511
  this.m_MaterialData.propertyBlock,
505
- h
512
+ r
506
513
  ), this.m_UseBackContentForSides || this.m_Renderer.setPropertyBlock(
507
514
  this.m_MaterialData.propertyBlock,
508
515
  2
509
516
  ), this.m_MaterialData.updatePropertyBlock(n, s), this.m_Renderer.setPropertyBlock(
510
517
  this.m_MaterialData.propertyBlock,
511
- a
518
+ o
512
519
  ), this.m_UseBackContentForSides && this.m_Renderer.setPropertyBlock(
513
520
  this.m_MaterialData.propertyBlock,
514
521
  2
@@ -539,7 +546,7 @@ class oe {
539
546
  const t = this.findTime(this._utV1);
540
547
  this._utV2.set(this.m_Size.x, 0, this.m_Size.y);
541
548
  const e = this.findTime(this._utV2);
542
- this.m_XTime = F(
549
+ this.m_XTime = E(
543
550
  Math.min(t, e),
544
551
  Math.max(t, e),
545
552
  0.9
@@ -548,69 +555,69 @@ class oe {
548
555
  this._utV1.set(s[1], 0, 0);
549
556
  const n = this.rollPoint(this._utV1);
550
557
  this._utV2.set(s[2], 0, 0);
551
- const h = this.rollPoint(this._utV2);
558
+ const r = this.rollPoint(this._utV2);
552
559
  this._utV3.set(s[1], 0, i[i.length - 1]);
553
- const a = this.rollPoint(this._utV3);
560
+ const o = this.rollPoint(this._utV3);
554
561
  this._utV4.set(s[2], 0, i[i.length - 1]);
555
- const o = this.rollPoint(this._utV4), u = h.x - n.x, l = h.y - n.y, m = o.x - a.x, f = o.y - a.y, d = Math.sqrt(u * u + l * l) || 1, _ = Math.sqrt(m * m + f * f) || 1, g = et * Math.atan2(l / d, u / d), p = et * Math.atan2(f / _, m / _), M = (g + p) / 2;
562
+ const c = this.rollPoint(this._utV4), l = r.x - n.x, a = r.y - n.y, d = c.x - o.x, g = c.y - o.y, _ = Math.sqrt(l * l + a * a) || 1, m = Math.sqrt(d * d + g * g) || 1, f = et * Math.atan2(a / _, l / _), x = et * Math.atan2(g / m, d / m), M = (f + x) / 2;
556
563
  this.m_ZTime = M / 180;
557
564
  } else
558
565
  this.m_XTime = 0, this.m_ZTime = 0;
559
566
  }
560
567
  findTime(t) {
561
- return t = this.rollPoint(t), Q(this.m_Size.x, -this.m_Size.x, t.x);
568
+ return t = this.rollPoint(t), nt(this.m_Size.x, -this.m_Size.x, t.x);
562
569
  }
563
570
  clampHandle() {
564
571
  this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
565
- const t = this._chP.copy(this.m_CurrentHandle), e = this._chA.set(0, 0, 0), s = this._chC.set(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), h = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), o = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
572
+ 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), r = Math.max(i - this.m_TurningRadius, 0.01), o = Math.max(n - this.m_TurningRadius, 0.01), c = this.m_StartHandle.z, l = this._chEllipseCenter1.set(
566
573
  0,
567
- o + (e.z - o) * (h / i)
568
- ), l = this._chEllipseCenter2.set(
574
+ c + (e.z - c) * (r / i)
575
+ ), a = this._chEllipseCenter2.set(
569
576
  0,
570
- o + (s.z - o) * (a / n)
571
- ), m = this._chEllipseSize1.set(i, h), f = this._chEllipseSize2.set(n, a);
572
- t.x = H(t.x, -this.m_Size.x, this.m_Size.x);
573
- const d = this._chP2.set(t.x, t.z);
574
- Bt(d, u, m, d), Bt(d, l, f, d), this.m_CurrentHandle.set(d.x, 0, d.y);
577
+ c + (s.z - c) * (o / n)
578
+ ), d = this._chEllipseSize1.set(i, r), g = this._chEllipseSize2.set(n, o);
579
+ t.x = Z(t.x, -this.m_Size.x, this.m_Size.x);
580
+ const _ = this._chP2.set(t.x, t.z);
581
+ At(_, l, d, _), At(_, a, g, _), this.m_CurrentHandle.set(_.x, 0, _.y);
575
582
  }
576
583
  updateCylinder() {
577
584
  const t = this._ucStartHandle.copy(this.m_StartHandle), e = this._ucCurrentHandle.copy(this.m_CurrentHandle), s = this._ucHandleDir.copy(t).sub(e).normalize();
578
585
  s.length() === 0 && s.set(1, 0, 0);
579
586
  const i = this.m_Size.x * 2 + this.m_TurningRadius * Math.PI, n = this._ucA.copy(t).sub(
580
587
  this._ucCylDir.copy(s).multiplyScalar(i)
581
- ), h = this._ucB.copy(t);
588
+ ), r = this._ucB.copy(t);
582
589
  this.m_Cylinder.radius = this.m_TurningRadius, this._ucCylDir.set(-s.z, 0, s.x), this.m_Cylinder.direction = this._ucCylDir;
583
- for (let a = 0; a < 100; a++) {
584
- this._ucMid.copy(n).add(h).multiplyScalar(0.5), this.m_Cylinder.position = this._ucMid, this.m_Book.bound.updatePaperPosition(this), this._ucRollResult.copy(t);
585
- const o = this.m_Cylinder.rollPoint(this._ucRollResult);
586
- if (Math.abs(e.x - o.x) < 1e-4) break;
587
- o.x > e.x ? h.copy(this.m_Cylinder.position) : n.copy(this.m_Cylinder.position);
590
+ for (let o = 0; o < 100; o++) {
591
+ this._ucMid.copy(n).add(r).multiplyScalar(0.5), this.m_Cylinder.position = this._ucMid, this.m_Book.bound.updatePaperPosition(this), this._ucRollResult.copy(t);
592
+ const c = this.m_Cylinder.rollPoint(this._ucRollResult);
593
+ if (Math.abs(e.x - c.x) < 1e-4) break;
594
+ c.x > e.x ? r.copy(this.m_Cylinder.position) : n.copy(this.m_Cylinder.position);
588
595
  }
589
596
  }
590
597
  rollPoint(t) {
591
598
  return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
592
599
  }
593
600
  startAutoTurning(t, e, s, i) {
594
- var u, l;
595
- if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === ut.Surface) {
596
- const m = this.m_Transform.scale;
597
- m.x *= -1;
601
+ var l, a;
602
+ if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === gt.Surface) {
603
+ const d = this.m_Transform.scale;
604
+ d.x *= -1;
598
605
  }
599
606
  this.switchMeshData(
600
607
  0
601
608
  /* Highpoly */
602
- ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === ut.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
603
- const n = this.m_Size.x, h = this.m_Size.y;
604
- e = H(e, -0.99, 0.99);
605
- const a = It(0.5, 1, e), o = It(0.5, 0, e);
606
- this.m_StartHandle.set(n, 0, h * a), this.m_EndHandle.set(-n, 0, h * o), this.m_IsAutoTurning = !0;
609
+ ), (l = this.m_Prev) == null || l.trySwitchMeshData(1), (a = this.m_Next) == null || a.trySwitchMeshData(1), this.m_IsFallingLeft = t === gt.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
610
+ const n = this.m_Size.x, r = this.m_Size.y;
611
+ e = Z(e, -0.99, 0.99);
612
+ const o = Zt(0.5, 1, e), c = Zt(0.5, 0, e);
613
+ this.m_StartHandle.set(n, 0, r * o), this.m_EndHandle.set(-n, 0, r * c), this.m_IsAutoTurning = !0;
607
614
  }
608
615
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
609
616
  get cylinder() {
610
617
  return this.m_Cylinder;
611
618
  }
612
619
  }
613
- const st = class st {
620
+ const rt = class rt {
614
621
  constructor() {
615
622
  this.m_Left = 0, this.m_Right = 0, this.m_Down = 0, this.m_Up = 0;
616
623
  }
@@ -641,7 +648,7 @@ const st = class st {
641
648
  }
642
649
  // ── Helpers ───────────────────────────────────────────────────────────
643
650
  clamp(t) {
644
- return Math.max(st.kMin, Math.min(t, st.kMax));
651
+ return Math.max(rt.kMin, Math.min(t, rt.kMax));
645
652
  }
646
653
  // ── Transform ─────────────────────────────────────────────────────────
647
654
  /**
@@ -649,18 +656,18 @@ const st = class st {
649
656
  * book direction.
650
657
  */
651
658
  transform(t) {
652
- const e = new st();
659
+ const e = new rt();
653
660
  switch (t) {
654
- case j.LeftToRight:
661
+ case it.LeftToRight:
655
662
  e.m_Left = this.m_Left, e.m_Right = this.m_Right, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
656
663
  break;
657
- case j.RightToLeft:
664
+ case it.RightToLeft:
658
665
  e.m_Left = this.m_Right, e.m_Right = this.m_Left, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
659
666
  break;
660
- case j.UpToDown:
667
+ case it.UpToDown:
661
668
  e.m_Left = this.m_Up, e.m_Right = this.m_Down, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
662
669
  break;
663
- case j.DownToUp:
670
+ case it.DownToUp:
664
671
  default:
665
672
  e.m_Left = this.m_Down, e.m_Right = this.m_Up, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
666
673
  break;
@@ -675,7 +682,7 @@ const st = class st {
675
682
  * Unity's `Mathf.InverseLerp(a, b, v)` = `(v - a) / (b - a)` clamped to [0,1].
676
683
  */
677
684
  fixUV(t) {
678
- return t.x = st.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = st.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
685
+ return t.x = rt.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = rt.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
679
686
  }
680
687
  static inverseLerp(t, e, s) {
681
688
  if (t === e) return 0;
@@ -684,15 +691,15 @@ const st = class st {
684
691
  }
685
692
  // ── Value-type clone ──────────────────────────────────────────────────
686
693
  clone() {
687
- const t = new st();
694
+ const t = new rt();
688
695
  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;
689
696
  }
690
697
  };
691
- st.kMin = 0, st.kMax = 0.25;
692
- let gt = st;
693
- const X = class X {
698
+ rt.kMin = 0, rt.kMax = 0.25;
699
+ let wt = rt;
700
+ const $ = class $ {
694
701
  constructor(t) {
695
- this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
702
+ this.m_Material = null, this.m_Color = new u.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Rigid = !1, this.m_Quality = 0, this.m_UVMargin = new wt(), this.margin = 0, this.bookDirection = it.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new u.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? $.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? $.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? $.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.rigid = (t == null ? void 0 : t.rigid) ?? !1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
696
703
  }
697
704
  // ── Properties ────────────────────────────────────────────────────────
698
705
  get material() {
@@ -711,19 +718,19 @@ const X = class X {
711
718
  return this.bookDirection > 1 ? this.m_Height : this.m_Width;
712
719
  }
713
720
  set width(t) {
714
- this.m_Width = Math.max(t, X.kMinSize);
721
+ this.m_Width = Math.max(t, $.kMinSize);
715
722
  }
716
723
  get height() {
717
724
  return this.bookDirection > 1 ? this.m_Width : this.m_Height;
718
725
  }
719
726
  set height(t) {
720
- this.m_Height = Math.max(t, X.kMinSize);
727
+ this.m_Height = Math.max(t, $.kMinSize);
721
728
  }
722
729
  get thickness() {
723
730
  return this.m_Thickness;
724
731
  }
725
732
  set thickness(t) {
726
- this.m_Thickness = Math.max(t, X.kMinThickness);
733
+ this.m_Thickness = Math.max(t, $.kMinThickness);
727
734
  }
728
735
  get stiffness() {
729
736
  return this.m_Stiffness;
@@ -731,13 +738,19 @@ const X = class X {
731
738
  set stiffness(t) {
732
739
  this.m_Stiffness = Math.max(0, Math.min(1, t));
733
740
  }
741
+ get rigid() {
742
+ return this.m_Rigid;
743
+ }
744
+ set rigid(t) {
745
+ this.m_Rigid = t;
746
+ }
734
747
  get quality() {
735
748
  return this.m_Quality;
736
749
  }
737
750
  set quality(t) {
738
751
  this.m_Quality = Math.max(
739
- X.kMinQuality,
740
- Math.min(t, X.kMaxQuality)
752
+ $.kMinQuality,
753
+ Math.min(t, $.kMaxQuality)
741
754
  );
742
755
  }
743
756
  get uvMargin() {
@@ -747,15 +760,15 @@ const X = class X {
747
760
  this.m_UVMargin = t;
748
761
  }
749
762
  get size() {
750
- return new c.Vector2(this.width, this.height);
763
+ return new u.Vector2(this.width, this.height);
751
764
  }
752
765
  };
753
- X.kMinSize = 1, X.kMinThickness = 1e-4, X.kMinQuality = 1, X.kMaxQuality = 5;
754
- let rt = X;
755
- class zt {
766
+ $.kMinSize = 1, $.kMinThickness = 1e-4, $.kMinQuality = 1, $.kMaxQuality = 5;
767
+ let ct = $;
768
+ class Xt {
756
769
  constructor(t) {
757
- this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
758
- const e = t.material ?? new c.MeshStandardMaterial();
770
+ this.m_Texture = null, this.m_TextureST = new u.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
771
+ const e = t.material ?? new u.MeshStandardMaterial();
759
772
  this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
760
773
  }
761
774
  get materials1() {
@@ -790,15 +803,15 @@ class zt {
790
803
  this.m_Texture = t, this.m_TextureST.copy(e), this._propertyBlockDirty = !0;
791
804
  }
792
805
  }
793
- function At(r, t, e, s = new c.Vector3()) {
794
- let i = t.x - r.x, n = t.y - r.y, h = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + h * h);
795
- i *= a, n *= a, h *= a;
796
- let o = e.x - r.x, u = e.y - r.y, l = e.z - r.z;
797
- a = 1 / Math.sqrt(o * o + u * u + l * l), o *= a, u *= a, l *= a;
798
- const m = n * l - h * u, f = h * o - i * l, d = i * u - n * o;
799
- return a = 1 / Math.sqrt(m * m + f * f + d * d), s.set(m * a, f * a, d * a);
806
+ function Nt(h, t, e, s = new u.Vector3()) {
807
+ let i = t.x - h.x, n = t.y - h.y, r = t.z - h.z, o = 1 / Math.sqrt(i * i + n * n + r * r);
808
+ i *= o, n *= o, r *= o;
809
+ let c = e.x - h.x, l = e.y - h.y, a = e.z - h.z;
810
+ o = 1 / Math.sqrt(c * c + l * l + a * a), c *= o, l *= o, a *= o;
811
+ const d = n * a - r * l, g = r * c - i * a, _ = i * l - n * c;
812
+ return o = 1 / Math.sqrt(d * d + g * g + _ * _), s.set(d * o, g * o, _ * o);
800
813
  }
801
- class ht {
814
+ class ot {
802
815
  constructor(t, e = !1, s = !1) {
803
816
  this.prev = null, this.next = null, this.index = 0, this.value = t, this.hole = e, this.seam = s;
804
817
  }
@@ -817,7 +830,7 @@ class ht {
817
830
  }
818
831
  // ── Factory helpers ───────────────────────────────────────────────────
819
832
  createNext(t, e = !1, s = !1) {
820
- const i = new ht(t, e, s);
833
+ const i = new ot(t, e, s);
821
834
  return i.prev = this, this.next = i, i;
822
835
  }
823
836
  // ── Insertion (sorted linked-list insert) ─────────────────────────────
@@ -849,21 +862,21 @@ class ht {
849
862
  t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
850
863
  }
851
864
  }
852
- class Pt {
865
+ class Bt {
853
866
  constructor(t, e, s, i) {
854
867
  this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
855
868
  }
856
869
  clone() {
857
- const t = new Pt(this.prevIndex, this.index, this.nextIndex, this.time);
870
+ const t = new Bt(this.prevIndex, this.index, this.nextIndex, this.time);
858
871
  return t.active = this.active, t;
859
872
  }
860
873
  }
861
- class Tt {
862
- constructor(t, e, s, i, n, h = !0) {
863
- this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = h;
874
+ class Mt {
875
+ constructor(t, e, s, i, n, r = !0) {
876
+ this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = r;
864
877
  }
865
878
  clone() {
866
- return new Tt(
879
+ return new Mt(
867
880
  this.startX,
868
881
  this.startZ,
869
882
  this.endX,
@@ -873,157 +886,157 @@ class Tt {
873
886
  );
874
887
  }
875
888
  }
876
- class le {
889
+ class ie {
877
890
  constructor(t, e, s) {
878
891
  const i = t.size;
879
- this.leftNode = new ht(e.left * i.x, s, !0), this.rightNode = new ht((1 - e.right) * i.x, s, !0), this.downNode = new ht(e.down * i.y, s, !0), this.upNode = new ht((1 - e.up) * i.y, s, !0);
892
+ this.leftNode = new ot(e.left * i.x, s, !0), this.rightNode = new ot((1 - e.right) * i.x, s, !0), this.downNode = new ot(e.down * i.y, s, !0), this.upNode = new ot((1 - e.up) * i.y, s, !0);
880
893
  }
881
894
  insert(t, e, s, i) {
882
895
  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);
883
896
  }
884
897
  }
885
- function pt(r, t) {
886
- for (const e of r) {
887
- const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new Pt(s.index, e.index, i.index, n);
888
- t.push(h);
898
+ function dt(h, t) {
899
+ for (const e of h) {
900
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = nt(s.value, i.value, e.value), r = new Bt(s.index, e.index, i.index, n);
901
+ t.push(r);
889
902
  }
890
903
  }
891
- function xt(r, t, e, s, i) {
892
- for (const n of r)
904
+ function Pt(h, t, e, s, i) {
905
+ for (const n of h)
893
906
  if (n.active)
894
- for (let h = 0; h < s; h++) {
895
- const a = n.prevIndex, o = n.nextIndex, u = t[h * e + a], l = t[h * e + o], m = t[h * e + n.index];
896
- i ? Gt(u, l, n.time, m) : m.copy(u).lerp(l, n.time);
907
+ for (let r = 0; r < s; r++) {
908
+ const o = n.prevIndex, c = n.nextIndex, l = t[r * e + o], a = t[r * e + c], d = t[r * e + n.index];
909
+ i ? ne(l, a, n.time, d) : d.copy(l).lerp(a, n.time);
897
910
  }
898
911
  }
899
- function Mt(r, t, e, s, i) {
900
- for (const n of r)
912
+ function St(h, t, e, s, i) {
913
+ for (const n of h)
901
914
  if (n.active)
902
- for (let h = 0; h < e; h++) {
903
- const a = n.prevIndex, o = n.nextIndex, u = t[a * e + h], l = t[o * e + h], m = t[n.index * e + h];
904
- i ? Gt(u, l, n.time, m) : m.copy(u).lerp(l, n.time);
915
+ for (let r = 0; r < e; r++) {
916
+ const o = n.prevIndex, c = n.nextIndex, l = t[o * e + r], a = t[c * e + r], d = t[n.index * e + r];
917
+ i ? ne(l, a, n.time, d) : d.copy(l).lerp(a, n.time);
905
918
  }
906
919
  }
907
- function Gt(r, t, e, s = new c.Vector3()) {
908
- const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
920
+ function ne(h, t, e, s = new u.Vector3()) {
921
+ const i = Math.sqrt(h.x * h.x + h.y * h.y + h.z * h.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
909
922
  if (i === 0 || n === 0)
910
- return s.copy(r).lerp(t, e);
911
- const h = r.x / i, a = r.y / i, o = r.z / i, u = t.x / n, l = t.y / n, m = t.z / n;
912
- let f = h * u + a * l + o * m;
913
- f = Math.max(-1, Math.min(1, f));
914
- const d = Math.acos(f);
915
- if (d < 1e-6)
916
- return s.copy(r).lerp(t, e);
917
- const _ = Math.sin(d), g = Math.sin((1 - e) * d) / _, p = Math.sin(e * d) / _, M = i + (n - i) * e;
923
+ return s.copy(h).lerp(t, e);
924
+ const r = h.x / i, o = h.y / i, c = h.z / i, l = t.x / n, a = t.y / n, d = t.z / n;
925
+ let g = r * l + o * a + c * d;
926
+ g = Math.max(-1, Math.min(1, g));
927
+ const _ = Math.acos(g);
928
+ if (_ < 1e-6)
929
+ return s.copy(h).lerp(t, e);
930
+ const m = Math.sin(_), f = Math.sin((1 - e) * _) / m, x = Math.sin(e * _) / m, M = i + (n - i) * e;
918
931
  return s.set(
919
- (h * g + u * p) * M,
920
- (a * g + l * p) * M,
921
- (o * g + m * p) * M
932
+ (r * f + l * x) * M,
933
+ (o * f + a * x) * M,
934
+ (c * f + d * x) * M
922
935
  );
923
936
  }
924
- function jt(r, t, e, s, i) {
925
- for (const n of r) {
926
- const h = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, o = e.length;
927
- for (let l = 0, m = n.endX - n.startX; l < m; l++) {
928
- const f = o + l * 2 + 0, d = o + l * 2 + 1, _ = o + l * 2 + 2, g = o + l * 2 + 3;
929
- n.flip ? Ft(t, f, d, _, g, h) : Ht(t, f, d, _, g, h);
937
+ function Rt(h, t, e, s, i) {
938
+ for (const n of h) {
939
+ const r = (n.endX - n.startX + 1) * 2, o = (n.endZ - n.startZ + 1) * 2, c = e.length;
940
+ for (let a = 0, d = n.endX - n.startX; a < d; a++) {
941
+ const g = c + a * 2 + 0, _ = c + a * 2 + 1, m = c + a * 2 + 2, f = c + a * 2 + 3;
942
+ n.flip ? Et(t, g, _, m, f, r) : Ut(t, g, _, m, f, r);
930
943
  }
931
944
  if (n.left)
932
- for (let l = 0, m = n.endZ - n.startZ; l < m; l++) {
933
- const f = o + l * 2 + 0 + h * 2, d = o + l * 2 + 1 + h * 2, _ = o + l * 2 + 2 + h * 2, g = o + l * 2 + 3 + h * 2;
934
- n.flip ? Ft(t, f, d, _, g, a) : Ht(t, f, d, _, g, a);
945
+ for (let a = 0, d = n.endZ - n.startZ; a < d; a++) {
946
+ const g = c + a * 2 + 0 + r * 2, _ = c + a * 2 + 1 + r * 2, m = c + a * 2 + 2 + r * 2, f = c + a * 2 + 3 + r * 2;
947
+ n.flip ? Et(t, g, _, m, f, o) : Ut(t, g, _, m, f, o);
935
948
  }
936
949
  else
937
- for (let l = 0, m = n.endZ - n.startZ; l < m; l++) {
938
- const f = o + l * 2 + 0 + h * 2 + a, d = o + l * 2 + 1 + h * 2 + a, _ = o + l * 2 + 2 + h * 2 + a, g = o + l * 2 + 3 + h * 2 + a;
939
- n.flip ? _t(t, f, d, _, g) : mt(t, f, d, _, g);
950
+ for (let a = 0, d = n.endZ - n.startZ; a < d; a++) {
951
+ const g = c + a * 2 + 0 + r * 2 + o, _ = c + a * 2 + 1 + r * 2 + o, m = c + a * 2 + 2 + r * 2 + o, f = c + a * 2 + 3 + r * 2 + o;
952
+ n.flip ? xt(t, g, _, m, f) : pt(t, g, _, m, f);
940
953
  }
941
- const u = s * i;
942
- for (let l = n.startX; l <= n.endX; l++) {
943
- const m = n.startZ * s + l;
944
- e.push(e[m].clone()), e.push(e[m + u].clone());
954
+ const l = s * i;
955
+ for (let a = n.startX; a <= n.endX; a++) {
956
+ const d = n.startZ * s + a;
957
+ e.push(e[d].clone()), e.push(e[d + l].clone());
945
958
  }
946
- for (let l = n.startX; l <= n.endX; l++) {
947
- const m = l + n.endZ * s;
948
- e.push(e[m + u].clone()), e.push(e[m].clone());
959
+ for (let a = n.startX; a <= n.endX; a++) {
960
+ const d = a + n.endZ * s;
961
+ e.push(e[d + l].clone()), e.push(e[d].clone());
949
962
  }
950
- for (let l = n.startZ; l <= n.endZ; l++) {
951
- const m = n.startX + l * s;
952
- e.push(e[m + u].clone()), e.push(e[m].clone());
963
+ for (let a = n.startZ; a <= n.endZ; a++) {
964
+ const d = n.startX + a * s;
965
+ e.push(e[d + l].clone()), e.push(e[d].clone());
953
966
  }
954
- for (let l = n.startZ; l <= n.endZ; l++) {
955
- const m = l * s + n.endX;
956
- e.push(e[m].clone()), e.push(e[m + u].clone());
967
+ for (let a = n.startZ; a <= n.endZ; a++) {
968
+ const d = a * s + n.endX;
969
+ e.push(e[d].clone()), e.push(e[d + l].clone());
957
970
  }
958
971
  }
959
972
  }
960
- function qt(r, t, e, s, i) {
973
+ function re(h, t, e, s, i) {
961
974
  const n = s * i;
962
- let h = n * 2;
963
- const a = new c.Vector3();
964
- for (const o of r) {
965
- for (let u = o.startX; u <= o.endX; u++) {
966
- const l = u + o.startZ * s, m = t[l], f = t[l + s];
967
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l + n]);
975
+ let r = n * 2;
976
+ const o = new u.Vector3();
977
+ for (const c of h) {
978
+ for (let l = c.startX; l <= c.endX; l++) {
979
+ const a = l + c.startZ * s, d = t[a], g = t[a + s];
980
+ o.subVectors(d, g).normalize(), c.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[a + n]);
968
981
  }
969
- for (let u = o.startX; u <= o.endX; u++) {
970
- const l = u + o.endZ * s, m = t[l + n], f = t[l + n - s];
971
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l]);
982
+ for (let l = c.startX; l <= c.endX; l++) {
983
+ const a = l + c.endZ * s, d = t[a + n], g = t[a + n - s];
984
+ o.subVectors(d, g).normalize(), c.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[a]);
972
985
  }
973
- for (let u = o.startZ; u <= o.endZ; u++) {
974
- const l = u * s + o.startX, m = t[l + n], f = t[l + n + 1];
975
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l]);
986
+ for (let l = c.startZ; l <= c.endZ; l++) {
987
+ const a = l * s + c.startX, d = t[a + n], g = t[a + n + 1];
988
+ o.subVectors(d, g).normalize(), c.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[a]);
976
989
  }
977
- for (let u = o.startZ; u <= o.endZ; u++) {
978
- const l = u * s + o.endX, m = t[l], f = t[l - 1];
979
- a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[l + n]);
990
+ for (let l = c.startZ; l <= c.endZ; l++) {
991
+ const a = l * s + c.endX, d = t[a], g = t[a - 1];
992
+ o.subVectors(d, g).normalize(), c.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[a + n]);
980
993
  }
981
994
  }
982
995
  }
983
- function Ht(r, t, e, s, i, n) {
984
- mt(r, t, e, s, i), t += n, e += n, s += n, i += n, mt(r, t, e, s, i);
996
+ function Ut(h, t, e, s, i, n) {
997
+ pt(h, t, e, s, i), t += n, e += n, s += n, i += n, pt(h, t, e, s, i);
985
998
  }
986
- function Ft(r, t, e, s, i, n) {
987
- _t(r, t, e, s, i), t += n, e += n, s += n, i += n, _t(r, t, e, s, i);
999
+ function Et(h, t, e, s, i, n) {
1000
+ xt(h, t, e, s, i), t += n, e += n, s += n, i += n, xt(h, t, e, s, i);
988
1001
  }
989
- function Qt(r, t, e, s, i, n, h) {
990
- mt(r, e, s, i, n), e += h, s += h, i += h, n += h, _t(t, e, s, i, n);
1002
+ function Vt(h, t, e, s, i, n, r) {
1003
+ pt(h, e, s, i, n), e += r, s += r, i += r, n += r, xt(t, e, s, i, n);
991
1004
  }
992
- function Yt(r, t, e, s, i, n) {
993
- const h = i.left * s.x, a = (1 - i.right) * s.x, o = i.down * s.y, u = (1 - i.up) * s.y, l = t.length, m = e.length;
1005
+ function Dt(h, t, e, s, i, n) {
1006
+ const r = i.left * s.x, o = (1 - i.right) * s.x, c = i.down * s.y, l = (1 - i.up) * s.y, a = t.length, d = e.length;
994
1007
  if (n > 1)
995
- for (let d = 0; d < m; d++)
996
- for (let _ = 0; _ < l; _++) {
997
- const g = Q(a, h, t[_]), p = Q(u, o, e[d]);
998
- r.push(new c.Vector2(p, g));
1008
+ for (let _ = 0; _ < d; _++)
1009
+ for (let m = 0; m < a; m++) {
1010
+ const f = nt(o, r, t[m]), x = nt(l, c, e[_]);
1011
+ h.push(new u.Vector2(x, f));
999
1012
  }
1000
1013
  else
1001
- for (let d = 0; d < m; d++)
1002
- for (let _ = 0; _ < l; _++) {
1003
- const g = Q(h, a, t[_]), p = Q(u, o, e[d]);
1004
- r.push(new c.Vector2(g, p));
1014
+ for (let _ = 0; _ < d; _++)
1015
+ for (let m = 0; m < a; m++) {
1016
+ const f = nt(r, o, t[m]), x = nt(l, c, e[_]);
1017
+ h.push(new u.Vector2(f, x));
1005
1018
  }
1006
- const f = r.length;
1007
- for (let d = 0; d < f; d++)
1008
- r.push(r[d].clone());
1019
+ const g = h.length;
1020
+ for (let _ = 0; _ < g; _++)
1021
+ h.push(h[_].clone());
1009
1022
  }
1010
- function mt(r, t, e, s, i) {
1011
- r.push(t), r.push(s), r.push(e), r.push(e), r.push(s), r.push(i);
1023
+ function pt(h, t, e, s, i) {
1024
+ h.push(t), h.push(s), h.push(e), h.push(e), h.push(s), h.push(i);
1012
1025
  }
1013
- function _t(r, t, e, s, i) {
1014
- r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1026
+ function xt(h, t, e, s, i) {
1027
+ h.push(t), h.push(e), h.push(s), h.push(e), h.push(i), h.push(s);
1015
1028
  }
1016
- const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1029
+ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1017
1030
  __proto__: null,
1018
- addBorders: jt,
1019
- addFrontAndBackFaces: Qt,
1020
- addFrontAndBackTexcoords: Yt,
1021
- seamNodesToSeams: pt,
1022
- updateBorders: qt,
1023
- updateXSeams: xt,
1024
- updateZSeams: Mt
1031
+ addBorders: Rt,
1032
+ addFrontAndBackFaces: Vt,
1033
+ addFrontAndBackTexcoords: Dt,
1034
+ seamNodesToSeams: dt,
1035
+ updateBorders: re,
1036
+ updateXSeams: Pt,
1037
+ updateZSeams: St
1025
1038
  }, Symbol.toStringTag, { value: "Module" }));
1026
- class Ot {
1039
+ class Wt {
1027
1040
  get geometry() {
1028
1041
  return this.m_Geometry;
1029
1042
  }
@@ -1035,34 +1048,34 @@ class Ot {
1035
1048
  }
1036
1049
  constructor(t, e) {
1037
1050
  this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1038
- for (let h = 0; h < e.baseVertexCount; h++)
1039
- this.m_BaseVertices[h] = new c.Vector3();
1051
+ for (let r = 0; r < e.baseVertexCount; r++)
1052
+ this.m_BaseVertices[r] = new u.Vector3();
1040
1053
  this.m_Vertices = new Array(e.vertexCount);
1041
- for (let h = 0; h < e.vertexCount; h++)
1042
- this.m_Vertices[h] = new c.Vector3();
1054
+ for (let r = 0; r < e.vertexCount; r++)
1055
+ this.m_Vertices[r] = new u.Vector3();
1043
1056
  this.m_Normals = new Array(e.vertexCount);
1044
- for (let h = 0; h < e.vertexCount; h++)
1045
- this.m_Normals[h] = new c.Vector3();
1057
+ for (let r = 0; r < e.vertexCount; r++)
1058
+ this.m_Normals[r] = new u.Vector3();
1046
1059
  if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1047
- const h = new Uint32Array(e.triangles);
1048
- this.m_Geometry.setIndex(new c.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1060
+ const r = new Uint32Array(e.triangles);
1061
+ this.m_Geometry.setIndex(new u.BufferAttribute(r, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1049
1062
  } else {
1050
- const h = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(h);
1051
- let o = 0;
1052
- a.set(e.frontTriangles, o), this.m_Geometry.addGroup(o, e.frontTriangles.length, 0), o += e.frontTriangles.length, a.set(e.backTriangles, o), this.m_Geometry.addGroup(o, e.backTriangles.length, 1), o += e.backTriangles.length, a.set(e.borderTriangles, o), this.m_Geometry.addGroup(o, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(a, 1));
1063
+ const r = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, o = new Uint32Array(r);
1064
+ let c = 0;
1065
+ o.set(e.frontTriangles, c), this.m_Geometry.addGroup(c, e.frontTriangles.length, 0), c += e.frontTriangles.length, o.set(e.backTriangles, c), this.m_Geometry.addGroup(c, e.backTriangles.length, 1), c += e.backTriangles.length, o.set(e.borderTriangles, c), this.m_Geometry.addGroup(c, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new u.BufferAttribute(o, 1));
1053
1066
  }
1054
1067
  const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1055
- for (let h = 0; h < e.texcoords.length; h++)
1056
- n[h * 2] = e.texcoords[h].x, n[h * 2 + 1] = e.texcoords[h].y;
1068
+ for (let r = 0; r < e.texcoords.length; r++)
1069
+ n[r * 2] = e.texcoords[r].x, n[r * 2 + 1] = e.texcoords[r].y;
1057
1070
  this.m_Geometry.setAttribute(
1058
1071
  "position",
1059
- new c.BufferAttribute(s, 3)
1072
+ new u.BufferAttribute(s, 3)
1060
1073
  ), this.m_Geometry.setAttribute(
1061
1074
  "normal",
1062
- new c.BufferAttribute(i, 3)
1075
+ new u.BufferAttribute(i, 3)
1063
1076
  ), this.m_Geometry.setAttribute(
1064
1077
  "uv",
1065
- new c.BufferAttribute(n, 2)
1078
+ new u.BufferAttribute(n, 2)
1066
1079
  ), this.updateBaseVertices();
1067
1080
  }
1068
1081
  // ── UpdateBaseVertices ──────────────────────────────────────────────────
@@ -1073,11 +1086,11 @@ class Ot {
1073
1086
  * Ported from lines ~2167-2183.
1074
1087
  */
1075
1088
  updateBaseVertices() {
1076
- const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, h = s.length;
1077
- let a = 0;
1078
- for (let o = 0; o < h; o++)
1079
- for (let u = 0; u < n; u++)
1080
- t[a++].set(e[u] + i, 0, s[o]);
1089
+ const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, r = s.length;
1090
+ let o = 0;
1091
+ for (let c = 0; c < r; c++)
1092
+ for (let l = 0; l < n; l++)
1093
+ t[o++].set(e[l] + i, 0, s[c]);
1081
1094
  }
1082
1095
  // ── UpdateMesh ─────────────────────────────────────────────────────────
1083
1096
  /**
@@ -1096,49 +1109,49 @@ class Ot {
1096
1109
  * Ported from lines ~2185-2255.
1097
1110
  */
1098
1111
  updateMesh() {
1099
- const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, o = new c.Vector3(), u = new c.Vector3(), l = new c.Vector3();
1100
- for (let _ = 0; _ < a; _++)
1101
- s[_].set(0, 0, 0);
1102
- xt(this.m_Pattern.xSeams, t, n, h, !1), Mt(this.m_Pattern.zSeams, t, n, h, !1);
1103
- for (let _ = 0; _ < h - 1; _++) {
1104
- const g = _ + 1;
1105
- for (let p = 0; p < n - 1; p++) {
1106
- const M = p + 1, T = _ * n + p, P = _ * n + M, w = g * n + p, k = g * n + M, I = t[T], Z = t[P], U = t[w], z = t[k];
1107
- At(I, U, Z, o), At(z, Z, U, u), l.addVectors(o, u), s[T].add(l), s[P].add(l), s[w].add(l), s[k].add(l);
1112
+ const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, r = this.m_Pattern.baseZArray.length, o = this.m_Pattern.baseVertexCount, c = new u.Vector3(), l = new u.Vector3(), a = new u.Vector3();
1113
+ for (let m = 0; m < o; m++)
1114
+ s[m].set(0, 0, 0);
1115
+ Pt(this.m_Pattern.xSeams, t, n, r, !1), St(this.m_Pattern.zSeams, t, n, r, !1);
1116
+ for (let m = 0; m < r - 1; m++) {
1117
+ const f = m + 1;
1118
+ for (let x = 0; x < n - 1; x++) {
1119
+ const M = x + 1, P = m * n + x, C = m * n + M, T = f * n + x, b = f * n + M, D = t[P], A = t[C], N = t[T], F = t[b];
1120
+ Nt(D, N, A, c), Nt(F, A, N, l), a.addVectors(c, l), s[P].add(a), s[C].add(a), s[T].add(a), s[b].add(a);
1108
1121
  }
1109
1122
  }
1110
- for (let _ = 0; _ < a; _++)
1111
- s[_].divideScalar(i[_]).normalize();
1112
- xt(this.m_Pattern.xSeams, s, n, h, !0), Mt(this.m_Pattern.zSeams, s, n, h, !0);
1113
- const m = this.m_Pattern.thickness / 2;
1114
- for (let _ = 0; _ < a; _++) {
1115
- const g = s[_];
1116
- s[_ + a].copy(g).negate();
1117
- const p = t[_];
1118
- e[_].copy(p).addScaledVector(g, m), e[_ + a].copy(p).addScaledVector(g, -m);
1119
- }
1120
- qt(this.m_Pattern.borders, e, s, n, h);
1121
- const f = this.m_Geometry.getAttribute(
1123
+ for (let m = 0; m < o; m++)
1124
+ s[m].divideScalar(i[m]).normalize();
1125
+ Pt(this.m_Pattern.xSeams, s, n, r, !0), St(this.m_Pattern.zSeams, s, n, r, !0);
1126
+ const d = this.m_Pattern.thickness / 2;
1127
+ for (let m = 0; m < o; m++) {
1128
+ const f = s[m];
1129
+ s[m + o].copy(f).negate();
1130
+ const x = t[m];
1131
+ e[m].copy(x).addScaledVector(f, d), e[m + o].copy(x).addScaledVector(f, -d);
1132
+ }
1133
+ re(this.m_Pattern.borders, e, s, n, r);
1134
+ const g = this.m_Geometry.getAttribute(
1122
1135
  "position"
1123
- ), d = this.m_Geometry.getAttribute(
1136
+ ), _ = this.m_Geometry.getAttribute(
1124
1137
  "normal"
1125
1138
  );
1126
- for (let _ = 0; _ < e.length; _++) {
1127
- const g = e[_];
1128
- f.setXYZ(_, g.x, g.y, g.z);
1129
- const p = s[_];
1130
- d.setXYZ(_, p.x, p.y, p.z);
1139
+ for (let m = 0; m < e.length; m++) {
1140
+ const f = e[m];
1141
+ g.setXYZ(m, f.x, f.y, f.z);
1142
+ const x = s[m];
1143
+ _.setXYZ(m, x.x, x.y, x.z);
1131
1144
  }
1132
- f.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1145
+ g.needsUpdate = !0, _.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1133
1146
  }
1134
1147
  }
1135
- class ce {
1148
+ class Ce {
1136
1149
  constructor() {
1137
1150
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1138
1151
  }
1139
1152
  get() {
1140
1153
  let t;
1141
- return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new c.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1154
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new u.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1142
1155
  }
1143
1156
  recycle() {
1144
1157
  for (const t of this.m_UsedMeshs)
@@ -1151,7 +1164,7 @@ class ce {
1151
1164
  this.m_Meshs.clear();
1152
1165
  }
1153
1166
  }
1154
- class ue {
1167
+ class we {
1155
1168
  constructor(t) {
1156
1169
  this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1157
1170
  }
@@ -1160,7 +1173,7 @@ class ue {
1160
1173
  }
1161
1174
  get(t) {
1162
1175
  let e;
1163
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new _e(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1176
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new Se(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1164
1177
  }
1165
1178
  recycle() {
1166
1179
  for (const t of this.m_UsedRenderers)
@@ -1173,23 +1186,23 @@ class ue {
1173
1186
  this.m_Renderers.clear();
1174
1187
  }
1175
1188
  getBounds() {
1176
- const t = new c.Box3();
1189
+ const t = new u.Box3();
1177
1190
  let e = !0;
1178
1191
  for (const s of this.m_UsedRenderers)
1179
1192
  e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1180
1193
  return t;
1181
1194
  }
1182
1195
  }
1183
- let me = 1;
1184
- class _e {
1196
+ let Pe = 1;
1197
+ class Se {
1185
1198
  constructor(t, e) {
1186
- this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = me++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1187
- new c.BufferGeometry(),
1188
- new c.MeshStandardMaterial()
1199
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = Pe++, this.m_Object3D = new u.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new u.Mesh(
1200
+ new u.BufferGeometry(),
1201
+ new u.MeshStandardMaterial()
1189
1202
  ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D);
1190
1203
  }
1191
1204
  get bounds() {
1192
- const t = new c.Box3();
1205
+ const t = new u.Box3();
1193
1206
  return this.m_Mesh.geometry && (this.m_Mesh.geometry.computeBoundingBox(), this.m_Mesh.geometry.boundingBox && (t.copy(this.m_Mesh.geometry.boundingBox), t.applyMatrix4(this.m_Mesh.matrixWorld))), t;
1194
1207
  }
1195
1208
  get id() {
@@ -1217,12 +1230,12 @@ class _e {
1217
1230
  return this.m_Mesh;
1218
1231
  }
1219
1232
  setMaterials(t) {
1220
- this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new c.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1233
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new u.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1221
1234
  }
1222
1235
  setPropertyBlock(t, e) {
1223
1236
  this.m_PropertyBlocks.set(e, t);
1224
1237
  const s = this.getMaterial(e);
1225
- s && (this.isMapCapable(s) && (t.map instanceof c.Texture ? this.applyTextureProperty(
1238
+ s && (this.isMapCapable(s) && (t.map instanceof u.Texture ? this.applyTextureProperty(
1226
1239
  s,
1227
1240
  e,
1228
1241
  t.map,
@@ -1230,10 +1243,10 @@ class _e {
1230
1243
  ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && s.color.copy(t.color));
1231
1244
  }
1232
1245
  reset(t) {
1233
- this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new c.BufferGeometry(), this.setMaterials([]);
1246
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new u.BufferGeometry(), this.setMaterials([]);
1234
1247
  }
1235
1248
  clear() {
1236
- this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new c.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1249
+ this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new u.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1237
1250
  }
1238
1251
  destroy() {
1239
1252
  this.disposeManagedTextures(), this.disposeCurrentMaterials(), this.m_Mesh.geometry && this.m_Mesh.geometry.dispose(), this.m_Object3D.parent && this.m_Object3D.parent.remove(this.m_Object3D);
@@ -1248,22 +1261,22 @@ class _e {
1248
1261
  return "map" in t;
1249
1262
  }
1250
1263
  isColorCapable(t) {
1251
- return "color" in t && t.color instanceof c.Color;
1264
+ return "color" in t && t.color instanceof u.Color;
1252
1265
  }
1253
1266
  getSTKey(t) {
1254
1267
  return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
1255
1268
  }
1256
1269
  applyTextureProperty(t, e, s, i) {
1257
- const n = this.getSTKey(i), h = this.m_MaterialTextures.get(e);
1258
- if (h && h.source === s && h.stKey === n) {
1259
- t.map !== h.texture && (t.map = h.texture, t.needsUpdate = !0);
1270
+ const n = this.getSTKey(i), r = this.m_MaterialTextures.get(e);
1271
+ if (r && r.source === s && r.stKey === n) {
1272
+ t.map !== r.texture && (t.map = r.texture, t.needsUpdate = !0);
1260
1273
  return;
1261
1274
  }
1262
1275
  this.clearManagedTexture(e);
1263
- const a = s.clone();
1264
- a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = c.RepeatWrapping, a.wrapT = c.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1276
+ const o = s.clone();
1277
+ o.needsUpdate = !0, i && (o.repeat.set(i.x, i.y), o.offset.set(i.z, i.w), o.wrapS = u.RepeatWrapping, o.wrapT = u.RepeatWrapping), t.map = o, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1265
1278
  source: s,
1266
- texture: a,
1279
+ texture: o,
1267
1280
  stKey: n
1268
1281
  });
1269
1282
  }
@@ -1285,20 +1298,20 @@ class _e {
1285
1298
  e.dispose();
1286
1299
  }
1287
1300
  }
1288
- class de {
1301
+ class Te {
1289
1302
  constructor(t, e, s = !1) {
1290
- this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Ot(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1303
+ this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Wt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1291
1304
  }
1292
1305
  get() {
1293
- return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Ot(this.m_MeshFactory.get(), this.m_Pattern);
1306
+ return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Wt(this.m_MeshFactory.get(), this.m_Pattern);
1294
1307
  }
1295
1308
  free(t) {
1296
1309
  if (this.m_UseSharedData) throw new Error("Not implemented");
1297
1310
  this.m_Stack.push(t);
1298
1311
  }
1299
1312
  }
1300
- var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), fe = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(fe || {}), ge = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(ge || {});
1301
- class pe {
1313
+ var Tt = /* @__PURE__ */ ((h) => (h[h.Next = 0] = "Next", h[h.Back = 1] = "Back", h))(Tt || {}), ve = /* @__PURE__ */ ((h) => (h[h.Constant = 0] = "Constant", h[h.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", h[h.Curve = 2] = "Curve", h[h.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", h))(ve || {}), ke = /* @__PURE__ */ ((h) => (h[h.PaperIndexTime = 0] = "PaperIndexTime", h[h.TurnIndexTime = 1] = "TurnIndexTime", h))(ke || {});
1314
+ class be {
1302
1315
  constructor(t) {
1303
1316
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1304
1317
  }
@@ -1320,10 +1333,10 @@ class pe {
1320
1333
  return e[s - 1].value;
1321
1334
  }
1322
1335
  }
1323
- function Lt(r, t) {
1324
- return r + Math.random() * (t - r);
1336
+ function Gt(h, t) {
1337
+ return h + Math.random() * (t - h);
1325
1338
  }
1326
- class at {
1339
+ class lt {
1327
1340
  constructor(t, e) {
1328
1341
  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));
1329
1342
  }
@@ -1378,12 +1391,12 @@ class at {
1378
1391
  }
1379
1392
  /** A value based on a curve. */
1380
1393
  static fromCurve(t, e) {
1381
- const s = new at();
1394
+ const s = new lt();
1382
1395
  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;
1383
1396
  }
1384
1397
  /** A random value generated between two curves. */
1385
1398
  static fromCurveRange(t, e, s) {
1386
- const i = new at();
1399
+ const i = new lt();
1387
1400
  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;
1388
1401
  }
1389
1402
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1391,12 +1404,12 @@ class at {
1391
1404
  getValue(t, e) {
1392
1405
  if (this.m_Mode === 0) return this.m_Constant;
1393
1406
  if (this.m_Mode === 1)
1394
- return Lt(this.m_ConstantMin, this.m_ConstantMax);
1407
+ return Gt(this.m_ConstantMin, this.m_ConstantMax);
1395
1408
  const s = this.m_CurveTimeMode === 0 ? t : e;
1396
1409
  if (this.m_Mode === 2)
1397
1410
  return this.m_Curve.evaluate(s);
1398
1411
  if (this.m_Mode === 3)
1399
- return Lt(
1412
+ return Gt(
1400
1413
  this.m_CurveMin.evaluate(s),
1401
1414
  this.m_CurveMax.evaluate(s)
1402
1415
  );
@@ -1404,31 +1417,31 @@ class at {
1404
1417
  }
1405
1418
  /** @internal */
1406
1419
  clampValues(t, e) {
1407
- return this.m_Constant = H(this.m_Constant, t, e), this.m_ConstantMin = H(this.m_ConstantMin, t, e), this.m_ConstantMax = H(this.m_ConstantMax, t, e), this.m_Curve = this.clampCurve(this.m_Curve, t, e), this.m_CurveMin = this.clampCurve(this.m_CurveMin, t, e), this.m_CurveMax = this.clampCurve(this.m_CurveMax, t, e), this;
1420
+ return this.m_Constant = Z(this.m_Constant, t, e), this.m_ConstantMin = Z(this.m_ConstantMin, t, e), this.m_ConstantMax = Z(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;
1408
1421
  }
1409
1422
  clampCurve(t, e, s) {
1410
1423
  if (this.m_Curve === null || t === null) return null;
1411
- const i = t.keys.map((o) => ({ time: o.time, value: o.value })), n = i.length;
1412
- let h = 1 / 0, a = -1 / 0;
1413
- for (let o = 0; o < n; o++) {
1414
- const u = i[o].time;
1415
- h = Math.min(h, u), a = Math.max(a, u);
1424
+ const i = t.keys.map((c) => ({ time: c.time, value: c.value })), n = i.length;
1425
+ let r = 1 / 0, o = -1 / 0;
1426
+ for (let c = 0; c < n; c++) {
1427
+ const l = i[c].time;
1428
+ r = Math.min(r, l), o = Math.max(o, l);
1416
1429
  }
1417
- for (let o = 0; o < n; o++) {
1418
- let u = i[o].time, l = i[o].value;
1419
- u = Q(h, a, u), l = H(l, e, s), i[o].time = u, i[o].value = l;
1430
+ for (let c = 0; c < n; c++) {
1431
+ let l = i[c].time, a = i[c].value;
1432
+ l = nt(r, o, l), a = Z(a, e, s), i[c].time = l, i[c].value = a;
1420
1433
  }
1421
- return new pe(i);
1434
+ return new be(i);
1422
1435
  }
1423
1436
  // ── Value-type clone ────────────────────────────────────────────────────
1424
1437
  clone() {
1425
- const t = new at();
1438
+ const t = new lt();
1426
1439
  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;
1427
1440
  }
1428
1441
  }
1429
- const D = class D {
1442
+ const j = class j {
1430
1443
  constructor() {
1431
- this.m_Mode = ut.Surface, this.m_Twist = new at(), this.m_Bend = new at(1), this.m_Duration = new at(0.5);
1444
+ this.m_Mode = gt.Surface, this.m_Twist = new lt(), this.m_Bend = new lt(1), this.m_Duration = new lt(0.5);
1432
1445
  }
1433
1446
  // ── Properties ──────────────────────────────────────────────────────────
1434
1447
  get mode() {
@@ -1442,8 +1455,8 @@ const D = class D {
1442
1455
  }
1443
1456
  set twist(t) {
1444
1457
  this.m_Twist = t.clampValues(
1445
- D.kMinTwist,
1446
- D.kMaxTwist
1458
+ j.kMinTwist,
1459
+ j.kMaxTwist
1447
1460
  );
1448
1461
  }
1449
1462
  get bend() {
@@ -1451,8 +1464,8 @@ const D = class D {
1451
1464
  }
1452
1465
  set bend(t) {
1453
1466
  this.m_Bend = t.clampValues(
1454
- D.kMinBend,
1455
- D.kMaxBend
1467
+ j.kMinBend,
1468
+ j.kMaxBend
1456
1469
  );
1457
1470
  }
1458
1471
  get duration() {
@@ -1460,8 +1473,8 @@ const D = class D {
1460
1473
  }
1461
1474
  set duration(t) {
1462
1475
  this.m_Duration = t.clampValues(
1463
- D.kMinDuration,
1464
- D.kMaxDuration
1476
+ j.kMinDuration,
1477
+ j.kMaxDuration
1465
1478
  );
1466
1479
  }
1467
1480
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1471,71 +1484,73 @@ const D = class D {
1471
1484
  }
1472
1485
  /** @internal */
1473
1486
  getBendValue(t, e) {
1474
- return H(
1487
+ return Z(
1475
1488
  this.m_Bend.getValue(t, e),
1476
- D.kMinBend,
1477
- D.kMaxBend
1489
+ j.kMinBend,
1490
+ j.kMaxBend
1478
1491
  );
1479
1492
  }
1480
1493
  /** @internal */
1481
1494
  getDurationValue(t, e) {
1482
- return H(
1495
+ return Z(
1483
1496
  this.m_Duration.getValue(t, e),
1484
- D.kMinDuration,
1485
- D.kMaxDuration
1497
+ j.kMinDuration,
1498
+ j.kMaxDuration
1486
1499
  );
1487
1500
  }
1488
1501
  /** @internal */
1489
1502
  getTwistValue(t, e) {
1490
- return H(
1503
+ return Z(
1491
1504
  this.m_Twist.getValue(t, e),
1492
- D.kMinTwist,
1493
- D.kMaxTwist
1505
+ j.kMinTwist,
1506
+ j.kMaxTwist
1494
1507
  );
1495
1508
  }
1496
1509
  };
1497
- D.kMinTwist = -1, D.kMaxTwist = 1, D.kMinBend = 0, D.kMaxBend = 1, D.kMinDuration = 0, D.kMaxDuration = 5;
1498
- let Zt = D;
1499
- class xe extends Error {
1510
+ j.kMinTwist = -1, j.kMaxTwist = 1, j.kMinBend = 0, j.kMaxBend = 1, j.kMinDuration = 0, j.kMaxDuration = 5;
1511
+ let qt = j;
1512
+ class oe extends Error {
1500
1513
  constructor() {
1501
1514
  super(
1502
1515
  "The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
1503
1516
  );
1504
1517
  }
1505
1518
  }
1506
- const W = class W extends c.Group {
1519
+ const K = class K extends u.Group {
1507
1520
  // ── Constructor ────────────────────────────────────────────────────────
1508
1521
  constructor(t) {
1509
- super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new rt({
1510
- color: new c.Color(1, 0, 0),
1522
+ 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 ct({
1523
+ color: new u.Color(1, 0, 0),
1511
1524
  width: 2.1,
1512
1525
  height: 3.1,
1513
1526
  thickness: 0.04,
1514
1527
  stiffness: 0.5
1515
- }), this.m_PagePaperSetup = new rt({
1516
- color: new c.Color(1, 1, 1),
1528
+ }), this.m_PagePaperSetup = new ct({
1529
+ color: new u.Color(1, 1, 1),
1517
1530
  width: 2,
1518
1531
  height: 3,
1519
1532
  thickness: 0.02,
1520
1533
  stiffness: 0.2
1521
- }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1522
- color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1534
+ }), 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 = it.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 = u.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 ct({
1535
+ color: t.coverPaperSetup.color ?? new u.Color(1, 0, 0),
1523
1536
  width: t.coverPaperSetup.width ?? 2.1,
1524
1537
  height: t.coverPaperSetup.height ?? 3.1,
1525
1538
  thickness: t.coverPaperSetup.thickness ?? 0.04,
1526
1539
  stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1540
+ rigid: t.coverPaperSetup.rigid ?? !1,
1527
1541
  material: t.coverPaperSetup.material ?? null
1528
- })), t.pagePaperSetup && (this.m_PagePaperSetup = new rt({
1529
- color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
1542
+ })), t.pagePaperSetup && (this.m_PagePaperSetup = new ct({
1543
+ color: t.pagePaperSetup.color ?? new u.Color(1, 1, 1),
1530
1544
  width: t.pagePaperSetup.width ?? 2,
1531
1545
  height: t.pagePaperSetup.height ?? 3,
1532
1546
  thickness: t.pagePaperSetup.thickness ?? 0.02,
1533
1547
  stiffness: t.pagePaperSetup.stiffness ?? 0.2,
1548
+ rigid: t.pagePaperSetup.rigid ?? !1,
1534
1549
  material: t.pagePaperSetup.material ?? null
1535
- }))), W.s_Instances.add(this), W.s_InstancesArray = null;
1550
+ }))), K.s_Instances.add(this), K.s_InstancesArray = null;
1536
1551
  }
1537
1552
  static get instances() {
1538
- return W.s_InstancesArray === null && (W.s_InstancesArray = [...W.s_Instances]), W.s_InstancesArray;
1553
+ return K.s_InstancesArray === null && (K.s_InstancesArray = [...K.s_Instances]), K.s_InstancesArray;
1539
1554
  }
1540
1555
  // ── Internal accessors ─────────────────────────────────────────────────
1541
1556
  get minPaperWidth() {
@@ -1600,13 +1615,14 @@ const W = class W extends c.Group {
1600
1615
  return this.m_CoverPaperSetup;
1601
1616
  }
1602
1617
  set coverPaperSetup(t) {
1603
- const e = this.m_CoverPaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, h = t.stiffness ?? e.stiffness;
1604
- e.width === s && e.height === i && e.thickness === n && e.stiffness === h || (this.m_CoverPaperSetup = new rt({
1618
+ const e = this.m_CoverPaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, r = t.stiffness ?? e.stiffness, o = t.rigid ?? e.rigid;
1619
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === r && e.rigid === o || (this.m_CoverPaperSetup = new ct({
1605
1620
  color: t.color ?? e.color,
1606
1621
  width: s,
1607
1622
  height: i,
1608
1623
  thickness: n,
1609
- stiffness: h,
1624
+ stiffness: r,
1625
+ rigid: o,
1610
1626
  material: t.material !== void 0 ? t.material : e.material
1611
1627
  }), this.m_StructuralDirty = !0);
1612
1628
  }
@@ -1614,13 +1630,14 @@ const W = class W extends c.Group {
1614
1630
  return this.m_PagePaperSetup;
1615
1631
  }
1616
1632
  set pagePaperSetup(t) {
1617
- const e = this.m_PagePaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, h = t.stiffness ?? e.stiffness;
1618
- e.width === s && e.height === i && e.thickness === n && e.stiffness === h || (this.m_PagePaperSetup = new rt({
1633
+ const e = this.m_PagePaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, r = t.stiffness ?? e.stiffness, o = t.rigid ?? e.rigid;
1634
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === r && e.rigid === o || (this.m_PagePaperSetup = new ct({
1619
1635
  color: t.color ?? e.color,
1620
1636
  width: s,
1621
1637
  height: i,
1622
1638
  thickness: n,
1623
- stiffness: h,
1639
+ stiffness: r,
1640
+ rigid: o,
1624
1641
  material: t.material !== void 0 ? t.material : e.material
1625
1642
  }), this.m_StructuralDirty = !0);
1626
1643
  }
@@ -1653,7 +1670,7 @@ const W = class W extends c.Group {
1653
1670
  return this.m_InitialOpenProgress;
1654
1671
  }
1655
1672
  set initialOpenProgress(t) {
1656
- this.m_InitialOpenProgress = c.MathUtils.clamp(t, 0, 1);
1673
+ this.m_InitialOpenProgress = u.MathUtils.clamp(t, 0, 1);
1657
1674
  }
1658
1675
  get isBuilt() {
1659
1676
  return this.m_IsBuilt;
@@ -1713,15 +1730,15 @@ const W = class W extends c.Group {
1713
1730
  }
1714
1731
  getActivePaperSideIndices(t) {
1715
1732
  if (t.clear(), !this.m_IsBuilt) return;
1716
- const e = this.m_Content.direction === j.RightToLeft, s = this.m_Papers.length, i = (n, h) => {
1717
- let a = n * 2;
1718
- h && a++, e && (a = s * 2 - a - 1), t.add(a);
1733
+ const e = this.m_Content.direction === it.RightToLeft, s = this.m_Papers.length, i = (n, r) => {
1734
+ let o = n * 2;
1735
+ r && o++, e && (o = s * 2 - o - 1), t.add(o);
1719
1736
  };
1720
1737
  for (let n = 0; n < s; n++) {
1721
- const h = this.m_Papers[n];
1722
- if (h.isFalling || h.isTurning)
1738
+ const r = this.m_Papers[n];
1739
+ if (r.isFalling || r.isTurning)
1723
1740
  n > 0 && i(n - 1, !0), i(n, !1), i(n, !0), n < s - 1 && i(n + 1, !1);
1724
- else if (h.isOnRightStack) {
1741
+ else if (r.isOnRightStack) {
1725
1742
  n > 0 && i(n - 1, !0), i(n, !1);
1726
1743
  break;
1727
1744
  }
@@ -1735,7 +1752,7 @@ const W = class W extends c.Group {
1735
1752
  */
1736
1753
  setOpenProgress(t) {
1737
1754
  this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1738
- const e = this.m_Papers.length, s = Math.round(c.MathUtils.lerp(0, e, t));
1755
+ const e = this.m_Papers.length, s = Math.round(u.MathUtils.lerp(0, e, t));
1739
1756
  for (let i = 0; i < e; i++) {
1740
1757
  const n = i >= s;
1741
1758
  this.m_Papers[i].restState(n);
@@ -1760,11 +1777,11 @@ const W = class W extends c.Group {
1760
1777
  startAutoTurning(t, e, s = 1, i = 0) {
1761
1778
  if (!this.m_IsBuilt) return !1;
1762
1779
  this.cancelPendingAutoTurns();
1763
- const n = typeof i == "number" ? new at(i) : i;
1780
+ const n = typeof i == "number" ? new lt(i) : i;
1764
1781
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1765
- for (let h = 0; h < s && this.canAutoTurn(t); h++) {
1766
- const a = h / (s - 1 || 1), o = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(o, a) : 0, l = e.getModeValue(), m = e.getTwistValue(o, a), f = e.getBendValue(o, a), d = e.getDurationValue(o, a);
1767
- this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: m, bend: f, duration: d, delay: u });
1782
+ for (let r = 0; r < s && this.canAutoTurn(t); r++) {
1783
+ const o = r / (s - 1 || 1), c = this.getAutoTurnPaperIndexTime(t), l = r > 0 ? n.getValue(c, o) : 0, a = e.getModeValue(), d = e.getTwistValue(c, o), g = e.getBendValue(c, o), _ = e.getDurationValue(c, o);
1784
+ this.m_AutoTurnQueue.push({ direction: t, mode: a, twist: d, bend: g, duration: _, delay: l });
1768
1785
  }
1769
1786
  return this.m_AutoTurnTimer = 0, this._frontPapersCache = null, !0;
1770
1787
  }
@@ -1792,7 +1809,7 @@ const W = class W extends c.Group {
1792
1809
  if (this.isTurning) return null;
1793
1810
  const e = this.getFrontPapers();
1794
1811
  if (e.length > 0) {
1795
- const s = t === yt.Next, i = e[s ? e.length - 1 : 0];
1812
+ const s = t === Tt.Next, i = e[s ? e.length - 1 : 0];
1796
1813
  if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
1797
1814
  return i;
1798
1815
  }
@@ -1802,7 +1819,7 @@ const W = class W extends c.Group {
1802
1819
  const e = this.getAutoTurnPaper(t);
1803
1820
  if (e === null) return 0;
1804
1821
  let s = 1;
1805
- return t === yt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1822
+ return t === Tt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1806
1823
  }
1807
1824
  canAutoTurn(t) {
1808
1825
  return this.getAutoTurnPaper(t) !== null;
@@ -1818,7 +1835,7 @@ const W = class W extends c.Group {
1818
1835
  */
1819
1836
  init() {
1820
1837
  var t;
1821
- W.s_Instances.add(this), W.s_InstancesArray = null, this.hardClear(), this.m_BuildOnAwake && (this.build(), this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = (t = this.m_Content) == null ? void 0 : t.direction);
1838
+ K.s_Instances.add(this), K.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);
1822
1839
  }
1823
1840
  /**
1824
1841
  * Call every frame with delta time in seconds.
@@ -1855,52 +1872,52 @@ const W = class W extends c.Group {
1855
1872
  * it will never be garbage collected.
1856
1873
  */
1857
1874
  dispose() {
1858
- W.s_Instances.delete(this), W.s_InstancesArray = null, this.hardClear();
1875
+ K.s_Instances.delete(this), K.s_InstancesArray = null, this.hardClear();
1859
1876
  }
1860
1877
  // ── Build ─────────────────────────────────────────────────────────────
1861
1878
  build() {
1862
- var B;
1879
+ var S;
1863
1880
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1864
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new ce()), this.m_RendererFactory === null) {
1865
- const C = new c.Object3D();
1866
- C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new ue(this.m_Root);
1881
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new Ce()), this.m_RendererFactory === null) {
1882
+ const w = new u.Object3D();
1883
+ w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new we(this.m_Root);
1867
1884
  }
1868
1885
  this.m_Direction = this.m_Content.direction;
1869
1886
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1870
1887
  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);
1871
- const e = new zt(this.m_CoverPaperSetup), s = new zt(this.m_PagePaperSetup);
1888
+ const e = new Xt(this.m_CoverPaperSetup), s = new Xt(this.m_PagePaperSetup);
1872
1889
  this.m_Content.init(this);
1873
- let i = this.m_Content.coverContents, n = this.m_Content.pageContents, h = this.m_InitialOpenProgress;
1874
- this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), h = 1 - h), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1875
- const a = this.m_CoverPaperCount + this.m_PagePaperCount, o = Math.floor(i.length / 4);
1876
- let u = 0, l = 0, m = 0;
1877
- this.m_Papers = new Array(a);
1878
- for (let C = 0; C < a; C++) {
1879
- const v = this.m_HasCover && (C < o || C >= a - o), N = this.m_RendererFactory.get("Paper"), b = this.m_Papers[C] = new oe(v, C, this, N);
1880
- b.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, h)) && (b.transform.scale.set(-1, 1, 1), b.setTime(1)), v ? (b.setContentData(i[l++], i[l++], C > o), b.setMaterialData(e), b.setPaperSetup(this.m_CoverPaperSetup)) : (b.setContentData(n[u++], n[u++]), b.setMaterialData(s), b.setPaperSetup(this.m_PagePaperSetup)), m += b.thickness;
1881
- }
1882
- this.m_TotalThickness = m;
1883
- const f = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
1884
- this.m_MinPaperThickness = Math.min(f, d), this.m_MaxPaperThickness = Math.max(f, d);
1885
- const _ = this.m_Papers[0].size.x, g = this.m_Papers[Math.floor(a / 2)].size.x;
1886
- this.m_MinPaperWidth = Math.min(_, g);
1887
- const p = this.m_Papers[0].size.y, M = this.m_Papers[Math.floor(a / 2)].size.y;
1888
- this.m_MinPaperHeight = Math.min(p, M), this.m_Bound = this.m_Binding.createBound(
1890
+ let i = this.m_Content.coverContents, n = this.m_Content.pageContents, r = this.m_InitialOpenProgress;
1891
+ this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), r = 1 - r), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1892
+ const o = this.m_CoverPaperCount + this.m_PagePaperCount, c = Math.floor(i.length / 4);
1893
+ let l = 0, a = 0, d = 0;
1894
+ this.m_Papers = new Array(o);
1895
+ for (let w = 0; w < o; w++) {
1896
+ const p = this.m_HasCover && (w < c || w >= o - c), V = this.m_RendererFactory.get("Paper"), z = this.m_Papers[w] = new ye(p, w, this, V);
1897
+ z.renderer.castShadows = this.m_CastShadows, w < Math.round(u.MathUtils.lerp(0, o, r)) && (z.transform.scale.set(-1, 1, 1), z.setTime(1)), p ? (z.setContentData(i[a++], i[a++], w > c), z.setMaterialData(e), z.setPaperSetup(this.m_CoverPaperSetup)) : (z.setContentData(n[l++], n[l++]), z.setMaterialData(s), z.setPaperSetup(this.m_PagePaperSetup)), d += z.thickness;
1898
+ }
1899
+ this.m_TotalThickness = d;
1900
+ const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(o / 2)].thickness;
1901
+ this.m_MinPaperThickness = Math.min(g, _), this.m_MaxPaperThickness = Math.max(g, _);
1902
+ const m = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(o / 2)].size.x;
1903
+ this.m_MinPaperWidth = Math.min(m, f);
1904
+ const x = this.m_Papers[0].size.y, M = this.m_Papers[Math.floor(o / 2)].size.y;
1905
+ this.m_MinPaperHeight = Math.min(x, M), this.m_Bound = this.m_Binding.createBound(
1889
1906
  this,
1890
1907
  this.m_Root,
1891
1908
  this.m_RendererFactory,
1892
1909
  this.m_MeshFactory
1893
1910
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1894
- const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1895
- for (let C = 0; C < a; C++) {
1896
- const v = this.m_Papers[C];
1897
- C !== 0 && (v.prev = this.m_Papers[C - 1]), C !== a - 1 && (v.next = this.m_Papers[C + 1]), v.noHole = A && (C === z || C === E), v.isCover ? v.setMeshData(Z.get(), null, U) : v.setMeshData(
1898
- w.get(),
1899
- (k == null ? void 0 : k.get()) ?? null,
1900
- I
1911
+ const P = this.m_ReduceOverdraw && n.length > 0, C = this.m_ReduceSubMeshes, T = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, C), b = P ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, C, !0) : null, D = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), A = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), N = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), F = Math.floor(o / 2) - 1, H = F + 1, k = ((S = this.m_Bound) == null ? void 0 : S.bindingType) === "staple";
1912
+ for (let w = 0; w < o; w++) {
1913
+ const p = this.m_Papers[w];
1914
+ w !== 0 && (p.prev = this.m_Papers[w - 1]), w !== o - 1 && (p.next = this.m_Papers[w + 1]), p.noHole = k && (w === F || w === H), p.isCover ? p.setMeshData(A.get(), null, N) : p.setMeshData(
1915
+ T.get(),
1916
+ (b == null ? void 0 : b.get()) ?? null,
1917
+ D
1901
1918
  );
1902
1919
  }
1903
- this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this._frontPapersCache = null, this.update(0), this.m_CoverPaperSetup.bookDirection = j.LeftToRight, this.m_PagePaperSetup.bookDirection = j.LeftToRight;
1920
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this._frontPapersCache = null, this.update(0), this.m_CoverPaperSetup.bookDirection = it.LeftToRight, this.m_PagePaperSetup.bookDirection = it.LeftToRight;
1904
1921
  }
1905
1922
  /**
1906
1923
  * Clears the built state of the book.
@@ -1917,7 +1934,7 @@ const W = class W extends c.Group {
1917
1934
  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);
1918
1935
  }
1919
1936
  createPaperMeshDataPool(t, e, s = !1, i = !1) {
1920
- const n = e ? 0 : t.quality, h = this.m_Bound.createPaperPattern(
1937
+ const n = e ? 0 : t.quality, r = this.m_Bound.createPaperPattern(
1921
1938
  n,
1922
1939
  t.size,
1923
1940
  t.thickness,
@@ -1925,9 +1942,9 @@ const W = class W extends c.Group {
1925
1942
  i,
1926
1943
  s
1927
1944
  );
1928
- return new de(
1945
+ return new Te(
1929
1946
  this.m_MeshFactory,
1930
- h,
1947
+ r,
1931
1948
  e && this.m_Bound.useSharedMeshDataForLowpoly
1932
1949
  );
1933
1950
  }
@@ -1976,15 +1993,15 @@ const W = class W extends c.Group {
1976
1993
  if (s !== this.m_CoverPaperCount || i !== this.m_PagePaperCount)
1977
1994
  return !1;
1978
1995
  this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
1979
- const n = this.m_Papers.length, h = Math.floor(t.length / 4);
1980
- let a = 0, o = 0;
1981
- for (let u = 0; u < n; u++) {
1982
- const l = this.m_Papers[u];
1983
- this.m_HasCover && (u < h || u >= n - h) ? l.setContentData(
1984
- t[o++],
1985
- t[o++],
1986
- u > h
1987
- ) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
1996
+ const n = this.m_Papers.length, r = Math.floor(t.length / 4);
1997
+ let o = 0, c = 0;
1998
+ for (let l = 0; l < n; l++) {
1999
+ const a = this.m_Papers[l];
2000
+ this.m_HasCover && (l < r || l >= n - r) ? a.setContentData(
2001
+ t[c++],
2002
+ t[c++],
2003
+ l > r
2004
+ ) : a.setContentData(e[o++], e[o++]), a.updateMaterials();
1988
2005
  }
1989
2006
  return this.m_WasIdle = !1, !0;
1990
2007
  }
@@ -2014,15 +2031,15 @@ const W = class W extends c.Group {
2014
2031
  s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
2015
2032
  }
2016
2033
  };
2017
- W.s_Instances = /* @__PURE__ */ new Set(), W.s_InstancesArray = null;
2018
- let wt = W;
2019
- class Me {
2034
+ K.s_Instances = /* @__PURE__ */ new Set(), K.s_InstancesArray = null;
2035
+ let vt = K;
2036
+ class he {
2020
2037
  constructor() {
2021
- this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
2038
+ 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 u.Vector2(), this.thickness = 0;
2022
2039
  }
2023
2040
  }
2024
- const $t = Object.freeze(new c.Vector4(1, 1, 0, 0));
2025
- class Le {
2041
+ const ae = Object.freeze(new u.Vector4(1, 1, 0, 0));
2042
+ class ss {
2026
2043
  constructor() {
2027
2044
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
2028
2045
  }
@@ -2033,7 +2050,7 @@ class Le {
2033
2050
  return this.m_IsActive;
2034
2051
  }
2035
2052
  get textureST() {
2036
- return $t;
2053
+ return ae;
2037
2054
  }
2038
2055
  get isShareable() {
2039
2056
  return !0;
@@ -2057,15 +2074,15 @@ class Le {
2057
2074
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
2058
2075
  }
2059
2076
  }
2060
- class Ut {
2077
+ class jt {
2061
2078
  constructor(t, e) {
2062
- this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2079
+ this.m_Texture = t, this.m_TextureST = e ?? new u.Vector4(1, 1, 0, 0);
2063
2080
  }
2064
2081
  get texture() {
2065
2082
  return this.m_Texture;
2066
2083
  }
2067
2084
  get textureST() {
2068
- return this.m_Texture ? this.m_TextureST : $t;
2085
+ return this.m_Texture ? this.m_TextureST : ae;
2069
2086
  }
2070
2087
  isPointOverUI(t) {
2071
2088
  return !1;
@@ -2075,9 +2092,9 @@ class Ut {
2075
2092
  setActive(t) {
2076
2093
  }
2077
2094
  }
2078
- class Ze {
2095
+ class is {
2079
2096
  constructor() {
2080
- this.m_Direction = j.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null, this._cachedCovers = null, this._cachedPages = null;
2097
+ this.m_Direction = it.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;
2081
2098
  }
2082
2099
  get coverCount4() {
2083
2100
  return this.nextMultipleOf4(this.m_Covers.length);
@@ -2120,8 +2137,8 @@ class Ze {
2120
2137
  let i = this.nextMultipleOf4(s);
2121
2138
  e && (i = Math.min(i, 4));
2122
2139
  const n = new Array(i);
2123
- for (let h = 0; h < i; h++)
2124
- n[h] = this.getContent(h < s ? t[h] : null);
2140
+ for (let r = 0; r < i; r++)
2141
+ n[r] = this.getContent(r < s ? t[r] : null);
2125
2142
  return n;
2126
2143
  }
2127
2144
  nextMultipleOf4(t) {
@@ -2129,12 +2146,12 @@ class Ze {
2129
2146
  }
2130
2147
  getContent(t) {
2131
2148
  if (t !== null) {
2132
- if (t instanceof c.Texture)
2133
- return new Ut(t);
2149
+ if (t instanceof u.Texture)
2150
+ return new jt(t);
2134
2151
  if (typeof t.init == "function")
2135
2152
  return t;
2136
2153
  }
2137
- return new Ut(null);
2154
+ return new jt(null);
2138
2155
  }
2139
2156
  init(t) {
2140
2157
  this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
@@ -2182,16 +2199,16 @@ class Ze {
2182
2199
  return !this.isCoverPaperSideIndex(t);
2183
2200
  }
2184
2201
  }
2185
- class Ue {
2202
+ class ns {
2186
2203
  constructor(t, e) {
2187
- this.enabled = !0, this.m_Raycaster = new c.Raycaster(), this.m_Mouse = new c.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2204
+ this.enabled = !0, this.m_Raycaster = new u.Raycaster(), this.m_Mouse = new u.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2188
2205
  var n;
2189
2206
  if (!this.enabled || s.button !== 0) return;
2190
2207
  this.m_IsPointerDown = !0;
2191
2208
  const i = this.m_GetRay(s);
2192
- for (const h of wt.instances)
2193
- if (h.startTurning(i)) {
2194
- this.m_SelectedBook = h, (n = this.onTurnStart) == null || n.call(this, h);
2209
+ for (const r of vt.instances)
2210
+ if (r.startTurning(i)) {
2211
+ this.m_SelectedBook = r, (n = this.onTurnStart) == null || n.call(this, r);
2195
2212
  break;
2196
2213
  }
2197
2214
  }, this.m_OnPointerMove = (s) => {
@@ -2209,9 +2226,9 @@ class Ue {
2209
2226
  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;
2210
2227
  }
2211
2228
  }
2212
- class ye {
2229
+ class ce {
2213
2230
  }
2214
- class we {
2231
+ class le {
2215
2232
  constructor(t, e) {
2216
2233
  this.bindingType = "", this.m_Book = t, this.m_Root = e;
2217
2234
  }
@@ -2219,36 +2236,36 @@ class we {
2219
2236
  dispose() {
2220
2237
  }
2221
2238
  }
2222
- function Et(r, t, e, s) {
2239
+ function kt(h, t, e, s) {
2223
2240
  const i = 1 - s;
2224
- return new c.Vector3(
2225
- i * i * r.x + 2 * i * s * t.x + s * s * e.x,
2226
- i * i * r.y + 2 * i * s * t.y + s * s * e.y,
2227
- i * i * r.z + 2 * i * s * t.z + s * s * e.z
2241
+ return new u.Vector3(
2242
+ i * i * h.x + 2 * i * s * t.x + s * s * e.x,
2243
+ i * i * h.y + 2 * i * s * t.y + s * s * e.y,
2244
+ i * i * h.z + 2 * i * s * t.z + s * s * e.z
2228
2245
  );
2229
2246
  }
2230
- function Nt(r, t) {
2231
- return r++, r === t ? 0 : r;
2247
+ function Yt(h, t) {
2248
+ return h++, h === t ? 0 : h;
2232
2249
  }
2233
- function Ce(r, t) {
2234
- return r === 0 ? t - 1 : r - 1;
2250
+ function Be(h, t) {
2251
+ return h === 0 ? t - 1 : h - 1;
2235
2252
  }
2236
- const Pe = 0.01, Te = 0.1, Se = 0.04, ve = 0.4, ke = 2, Be = 10, be = 0, Re = 5;
2237
- function De(r, t) {
2238
- const e = r.clone().normalize();
2239
- if (e.lengthSq() === 0) return new c.Quaternion();
2240
- let s = new c.Vector3().crossVectors(t, e);
2253
+ const Re = 0.01, Ve = 0.1, De = 0.04, ze = 0.4, Ie = 2, Ae = 10, He = 0, Fe = 5;
2254
+ function Oe(h, t) {
2255
+ const e = h.clone().normalize();
2256
+ if (e.lengthSq() === 0) return new u.Quaternion();
2257
+ let s = new u.Vector3().crossVectors(t, e);
2241
2258
  if (s.lengthSq() === 0) {
2242
- const h = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
2243
- s = new c.Vector3().crossVectors(h, e);
2259
+ const r = Math.abs(e.y) < 0.999 ? new u.Vector3(0, 1, 0) : new u.Vector3(1, 0, 0);
2260
+ s = new u.Vector3().crossVectors(r, e);
2244
2261
  }
2245
2262
  s.normalize();
2246
- const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
2247
- return new c.Quaternion().setFromRotationMatrix(n);
2263
+ const i = new u.Vector3().crossVectors(e, s).normalize(), n = new u.Matrix4().makeBasis(s, i, e);
2264
+ return new u.Quaternion().setFromRotationMatrix(n);
2248
2265
  }
2249
- class Ie {
2266
+ class Ze {
2250
2267
  constructor() {
2251
- this._material = null, this._color = new c.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2268
+ this._material = null, this._color = new u.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2252
2269
  }
2253
2270
  get material() {
2254
2271
  return this._material;
@@ -2266,240 +2283,240 @@ class Ie {
2266
2283
  return this._thickness;
2267
2284
  }
2268
2285
  set thickness(t) {
2269
- this._thickness = H(t, Pe, Te);
2286
+ this._thickness = Z(t, Re, Ve);
2270
2287
  }
2271
2288
  get margin() {
2272
2289
  return this._margin;
2273
2290
  }
2274
2291
  set margin(t) {
2275
- this._margin = lt(t);
2292
+ this._margin = st(t);
2276
2293
  }
2277
2294
  get crown() {
2278
2295
  return this._crown;
2279
2296
  }
2280
2297
  set crown(t) {
2281
- this._crown = H(t, Se, ve);
2298
+ this._crown = Z(t, De, ze);
2282
2299
  }
2283
2300
  get count() {
2284
2301
  return this._count;
2285
2302
  }
2286
2303
  set count(t) {
2287
- this._count = H(t, ke, Be);
2304
+ this._count = Z(t, Ie, Ae);
2288
2305
  }
2289
2306
  get quality() {
2290
2307
  return this._quality;
2291
2308
  }
2292
2309
  set quality(t) {
2293
- this._quality = H(t, be, Re);
2310
+ this._quality = Z(t, He, Fe);
2294
2311
  }
2295
2312
  }
2296
- class Ve extends we {
2313
+ class Le extends le {
2297
2314
  // ── Constructor ────────────────────────────────────────────────────────
2298
2315
  constructor(t, e, s, i, n) {
2299
2316
  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)
2300
- throw new xe();
2301
- const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, o = new c.BufferGeometry();
2302
- this.updateStapleMesh(e, o);
2303
- const u = n ?? new c.MeshStandardMaterial({
2317
+ throw new oe();
2318
+ const r = this.m_Book.coverPaperSetup, o = this.m_Book.pagePaperSetup, c = new u.BufferGeometry();
2319
+ this.updateStapleMesh(e, c);
2320
+ const l = n ?? new u.MeshStandardMaterial({
2304
2321
  color: e.color,
2305
2322
  metalness: 0.9,
2306
2323
  roughness: 0.3
2307
2324
  });
2308
- this.stapleMesh = new c.Mesh(o, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2325
+ this.stapleMesh = new u.Mesh(c, l), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2309
2326
  0,
2310
2327
  0,
2311
- this.m_StapleMargin + a.margin + h.margin
2328
+ this.m_StapleMargin + o.margin + r.margin
2312
2329
  );
2313
- let l = h.thickness;
2314
- l = Math.max(this.m_BindingRadius, l);
2315
- for (const m of this.m_Book.papers) {
2316
- const f = m.size.clone();
2317
- f.x -= this.m_BindingRadius, m.sizeXOffset = this.m_BindingRadius, m.size = f, m.setMinTurningRadius(l), m.updateTurningRadius(), this.updatePaperPosition(m);
2330
+ let a = r.thickness;
2331
+ a = Math.max(this.m_BindingRadius, a);
2332
+ for (const d of this.m_Book.papers) {
2333
+ const g = d.size.clone();
2334
+ g.x -= this.m_BindingRadius, d.sizeXOffset = this.m_BindingRadius, d.size = g, d.setMinTurningRadius(a), d.updateTurningRadius(), this.updatePaperPosition(d);
2318
2335
  }
2319
2336
  this.updateRootPosition();
2320
2337
  }
2321
2338
  get binderRenderer() {
2322
- return this._binderRendererAdapter || (this._binderRendererAdapter = new ze(this.stapleMesh)), this._binderRendererAdapter;
2339
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new Xe(this.stapleMesh)), this._binderRendererAdapter;
2323
2340
  }
2324
2341
  // ── updateStapleMesh ──────────────────────────────────────────────────
2325
2342
  updateStapleMesh(t, e) {
2326
- 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;
2343
+ 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 * Q), this.m_StackHeight += this.m_BindingMidSpace;
2327
2344
  let s = t.crown;
2328
2345
  s = Math.max(s, this.m_StapleThickness * 4);
2329
2346
  const i = this.m_StapleThickness * 0.5, n = Math.max(
2330
2347
  this.m_Book.minPaperHeight / 2 - s - i,
2331
2348
  i
2332
2349
  );
2333
- this.m_StapleMargin = F(i, n, t.margin);
2334
- const h = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2335
- let a = t.count, o = (h - s * a) / (a - 1);
2336
- for (o = Math.max(o, 0); o < this.m_StapleThickness * 2 && a > 2; )
2337
- a--, o = (h - s * a) / (a - 1), o = Math.max(o, 0);
2338
- const u = t.quality / 5, l = Math.floor(F(4, 20, u)), m = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), d = this.m_StapleThickness / 2, _ = d * 2.5, g = 0.9, p = d * 1;
2339
- let M = s / 2 * g;
2340
- M = Math.max(M, p * 2);
2341
- let T = 0;
2342
- T += this.m_Book.totalThickness / 2, T += d;
2343
- const P = -(this.m_Book.papers[0].thickness / 2 + d), w = [];
2350
+ this.m_StapleMargin = E(i, n, t.margin);
2351
+ const r = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2352
+ let o = t.count, c = (r - s * o) / (o - 1);
2353
+ for (c = Math.max(c, 0); c < this.m_StapleThickness * 2 && o > 2; )
2354
+ o--, c = (r - s * o) / (o - 1), c = Math.max(c, 0);
2355
+ const l = t.quality / 5, a = Math.floor(E(4, 20, l)), d = Math.floor(E(4, 10, l)), g = Math.floor(E(3, 10, l)), _ = this.m_StapleThickness / 2, m = _ * 2.5, f = 0.9, x = _ * 1;
2356
+ let M = s / 2 * f;
2357
+ M = Math.max(M, x * 2);
2358
+ let P = 0;
2359
+ P += this.m_Book.totalThickness / 2, P += _;
2360
+ const C = -(this.m_Book.papers[0].thickness / 2 + _), T = [];
2344
2361
  {
2345
- for (let V = 0; V < m; V++) {
2346
- const G = V / (m - 1), K = F(-90, -180, G) * J, y = new c.Vector3(
2347
- p * Math.sin(K),
2362
+ for (let L = 0; L < d; L++) {
2363
+ const Y = L / (d - 1), tt = E(-90, -180, Y) * Q, v = new u.Vector3(
2364
+ x * Math.sin(tt),
2348
2365
  0,
2349
- p * Math.cos(K)
2366
+ x * Math.cos(tt)
2350
2367
  );
2351
- y.x += p, y.z += p, y.x += P, w.push(y);
2368
+ v.x += x, v.z += x, v.x += C, T.push(v);
2352
2369
  }
2353
- const x = new c.Vector3(T, 0, 0), L = new c.Vector3(T + _ * 0.75, 0, 0), S = new c.Vector3(T - d * 0.5, 0, M);
2354
- for (let V = 0; V < f; V++) {
2355
- const G = V / (f - 1), $ = Et(x, L, S, G);
2356
- $.x += P, w.push($);
2370
+ const y = new u.Vector3(P, 0, 0), G = new u.Vector3(P + m * 0.75, 0, 0), R = new u.Vector3(P - _ * 0.5, 0, M);
2371
+ for (let L = 0; L < g; L++) {
2372
+ const Y = L / (g - 1), J = kt(y, G, R, Y);
2373
+ J.x += C, T.push(J);
2357
2374
  }
2358
- w.reverse();
2375
+ T.reverse();
2359
2376
  }
2360
- const k = new Array(l);
2361
- for (let x = 0; x < l; x++) {
2362
- const S = (90 - x * (360 / l)) * J;
2363
- k[x] = new c.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
2377
+ const b = new Array(a);
2378
+ for (let y = 0; y < a; y++) {
2379
+ const R = (90 - y * (360 / a)) * Q;
2380
+ b[y] = new u.Vector3(Math.cos(R), Math.sin(R), 0), b[y].x *= 0.75;
2364
2381
  }
2365
- const I = w.length, Z = I * l, U = new Array(Z * 2), z = new Array(Z * 2), E = new Array(
2366
- (Z * 2 - 1) * l * 2 * 3
2382
+ const D = T.length, A = D * a, N = new Array(A * 2), F = new Array(A * 2), H = new Array(
2383
+ (A * 2 - 1) * a * 2 * 3
2367
2384
  );
2368
- for (let x = 0; x < Z * 2; x++)
2369
- U[x] = new c.Vector3(), z[x] = new c.Vector3();
2370
- let A = 0;
2371
- for (let x = 0; x < I; x++) {
2372
- const L = w[Ce(x, I)], S = w[x], V = w[Nt(x, I)];
2373
- let G;
2374
- if (x === 0)
2375
- G = new c.Vector3(1, 0, -2).normalize();
2376
- else if (x === I - 1)
2377
- G = new c.Vector3(0, 0, 1);
2385
+ for (let y = 0; y < A * 2; y++)
2386
+ N[y] = new u.Vector3(), F[y] = new u.Vector3();
2387
+ let k = 0;
2388
+ for (let y = 0; y < D; y++) {
2389
+ const G = T[Be(y, D)], R = T[y], L = T[Yt(y, D)];
2390
+ let Y;
2391
+ if (y === 0)
2392
+ Y = new u.Vector3(1, 0, -2).normalize();
2393
+ else if (y === D - 1)
2394
+ Y = new u.Vector3(0, 0, 1);
2378
2395
  else {
2379
- const it = S.clone().sub(L).normalize(), nt = V.clone().sub(S).normalize();
2380
- G = it.add(nt).multiplyScalar(0.5);
2396
+ const B = R.clone().sub(G).normalize(), q = L.clone().sub(R).normalize();
2397
+ Y = B.add(q).multiplyScalar(0.5);
2381
2398
  }
2382
- const $ = new c.Vector3(0, 1, 0), K = De(G, $), y = A;
2383
- let R = Q(0, f / 4, x);
2384
- R = F(0.1, 1, R), R = Math.sqrt(R);
2385
- for (let it = 0; it < l; it++) {
2386
- const nt = k[it].clone().applyQuaternion(K).multiplyScalar(R), ct = S.clone().add(nt.clone().multiplyScalar(d));
2387
- U[A] = ct, z[A] = nt.clone();
2388
- const ot = S.clone().add(nt.clone().multiplyScalar(d));
2389
- ot.z = s - ot.z;
2390
- const ee = y + l - it - 1, St = Z * 2 - ee - 1;
2391
- U[St] = ot, z[St] = nt.clone(), A++;
2399
+ const J = new u.Vector3(0, 1, 0), tt = Oe(Y, J), v = k;
2400
+ let X = nt(0, g / 4, y);
2401
+ X = E(0.1, 1, X), X = Math.sqrt(X);
2402
+ for (let B = 0; B < a; B++) {
2403
+ const q = b[B].clone().applyQuaternion(tt).multiplyScalar(X), ut = R.clone().add(q.clone().multiplyScalar(_));
2404
+ N[k] = ut, F[k] = q.clone();
2405
+ const ht = R.clone().add(q.clone().multiplyScalar(_));
2406
+ ht.z = s - ht.z;
2407
+ const _t = v + a - B - 1, mt = A * 2 - _t - 1;
2408
+ N[mt] = ht, F[mt] = q.clone(), k++;
2392
2409
  }
2393
2410
  }
2394
- let B = 0;
2395
- const C = w.length * 2;
2396
- for (let x = 0; x < C - 1; x++) {
2397
- const L = x * l, S = (x + 1) * l;
2398
- for (let V = 0; V < l; V++) {
2399
- const G = Nt(V, l), $ = L + V, K = L + G, y = S + G, R = S + V;
2400
- E[B++] = $, E[B++] = R, E[B++] = K, E[B++] = K, E[B++] = R, E[B++] = y;
2411
+ let S = 0;
2412
+ const w = T.length * 2;
2413
+ for (let y = 0; y < w - 1; y++) {
2414
+ const G = y * a, R = (y + 1) * a;
2415
+ for (let L = 0; L < a; L++) {
2416
+ const Y = Yt(L, a), J = G + L, tt = G + Y, v = R + Y, X = R + L;
2417
+ H[S++] = J, H[S++] = X, H[S++] = tt, H[S++] = tt, H[S++] = X, H[S++] = v;
2401
2418
  }
2402
2419
  }
2403
- const v = [...U], N = [...z], b = [...E], Y = U.map((x) => x.clone()), tt = [...E];
2404
- for (let x = 0; x < a - 1; x++) {
2405
- const L = Y.length;
2406
- for (let S = 0; S < tt.length; S++)
2407
- tt[S] += L;
2408
- for (let S = 0; S < Y.length; S++)
2409
- Y[S].z += o + s;
2410
- v.push(...Y.map((S) => S.clone())), N.push(...z.map((S) => S.clone())), b.push(...tt);
2411
- }
2412
- const q = new Float32Array(v.length * 3), O = new Float32Array(N.length * 3);
2413
- for (let x = 0; x < v.length; x++)
2414
- q[x * 3] = v[x].x, q[x * 3 + 1] = v[x].y, q[x * 3 + 2] = v[x].z, O[x * 3] = N[x].x, O[x * 3 + 1] = N[x].y, O[x * 3 + 2] = N[x].z;
2420
+ const p = [...N], V = [...F], z = [...H], U = N.map((y) => y.clone()), O = [...H];
2421
+ for (let y = 0; y < o - 1; y++) {
2422
+ const G = U.length;
2423
+ for (let R = 0; R < O.length; R++)
2424
+ O[R] += G;
2425
+ for (let R = 0; R < U.length; R++)
2426
+ U[R].z += c + s;
2427
+ p.push(...U.map((R) => R.clone())), V.push(...F.map((R) => R.clone())), z.push(...O);
2428
+ }
2429
+ const W = new Float32Array(p.length * 3), I = new Float32Array(V.length * 3);
2430
+ for (let y = 0; y < p.length; y++)
2431
+ W[y * 3] = p[y].x, W[y * 3 + 1] = p[y].y, W[y * 3 + 2] = p[y].z, I[y * 3] = V[y].x, I[y * 3 + 1] = V[y].y, I[y * 3 + 2] = V[y].z;
2415
2432
  e.setAttribute(
2416
2433
  "position",
2417
- new c.BufferAttribute(q, 3)
2434
+ new u.BufferAttribute(W, 3)
2418
2435
  ), e.setAttribute(
2419
2436
  "normal",
2420
- new c.BufferAttribute(O, 3)
2421
- ), e.setIndex(b);
2437
+ new u.BufferAttribute(I, 3)
2438
+ ), e.setIndex(z);
2422
2439
  }
2423
2440
  // ── createPaperPattern ────────────────────────────────────────────────
2424
- createPaperPattern(t, e, s, i, n, h) {
2425
- const a = new Me();
2426
- a.size = e, a.thickness = s;
2427
- const o = this.m_BindingRadius;
2428
- a.baseXOffset = -o;
2429
- const u = this.m_Quality + 1;
2430
- this.m_BindingVertexCount = u;
2431
- const l = t / 5, m = Math.min(e.x, e.y) / 60, f = Math.floor(
2432
- F(0, (e.x - o) / m, l)
2433
- ), d = Math.floor(F(0, e.y / m, l));
2434
- let _ = 2 + f + 1 + u, g = 2 + d;
2435
- const p = new ht(0);
2436
- let M = p;
2437
- const T = o / u;
2438
- let P = 0;
2439
- for (let y = 1; y < u + 1; y++)
2440
- M = M.createNext(P), P += T;
2441
- const w = (e.x - o) / (f + 1);
2442
- for (let y = u + 1; y < _; y++)
2443
- M = M.createNext(P), P += w;
2444
- const k = new ht(0);
2445
- let I = k;
2446
- const Z = e.y / (g - 1);
2447
- let U = 0;
2448
- for (let y = 0; y < g - 1; y++)
2449
- U += Z, I = I.createNext(U);
2450
- const z = [], E = [], A = i.clone();
2441
+ createPaperPattern(t, e, s, i, n, r) {
2442
+ const o = new he();
2443
+ o.size = e, o.thickness = s;
2444
+ const c = this.m_BindingRadius;
2445
+ o.baseXOffset = -c;
2446
+ const l = this.m_Quality + 1;
2447
+ this.m_BindingVertexCount = l;
2448
+ const a = t / 5, d = Math.min(e.x, e.y) / 60, g = Math.floor(
2449
+ E(0, (e.x - c) / d, a)
2450
+ ), _ = Math.floor(E(0, e.y / d, a));
2451
+ let m = 2 + g + 1 + l, f = 2 + _;
2452
+ const x = new ot(0);
2453
+ let M = x;
2454
+ const P = c / l;
2455
+ let C = 0;
2456
+ for (let v = 1; v < l + 1; v++)
2457
+ M = M.createNext(C), C += P;
2458
+ const T = (e.x - c) / (g + 1);
2459
+ for (let v = l + 1; v < m; v++)
2460
+ M = M.createNext(C), C += T;
2461
+ const b = new ot(0);
2462
+ let D = b;
2463
+ const A = e.y / (f - 1);
2464
+ let N = 0;
2465
+ for (let v = 0; v < f - 1; v++)
2466
+ N += A, D = D.createNext(N);
2467
+ const F = [], H = [], k = i.clone();
2451
2468
  if (n) {
2452
- let y = 0;
2453
- this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
2454
- const R = Math.max(0.01, s);
2455
- A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) + R) / e.x, A.down = R / e.y, A.up = R / e.y;
2456
- }
2457
- const B = new le(a, A, !1);
2458
- B.insert(p, k, z, E), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(E, a.zSeams);
2459
- const C = this.m_BindingVertexCount + 2, v = new Array(C);
2460
- a.xNoneSeamIndexes = v, M = p;
2461
- for (let y = 0; y < C; y++) {
2462
- v[y] = M.index;
2469
+ let v = 0;
2470
+ this.m_Book.hasCover && (v = Math.floor(this.m_Book.coverPaperCount / 2));
2471
+ const X = Math.max(0.01, s);
2472
+ k.left = 0, k.right = (this.getPX(v + 1, s) - this.getPX(v, s) + X) / e.x, k.down = X / e.y, k.up = X / e.y;
2473
+ }
2474
+ const S = new ie(o, k, !1);
2475
+ S.insert(x, b, F, H), x.updateIndex(0), b.updateIndex(0), dt(F, o.xSeams), dt(H, o.zSeams);
2476
+ const w = this.m_BindingVertexCount + 2, p = new Array(w);
2477
+ o.xNoneSeamIndexes = p, M = x;
2478
+ for (let v = 0; v < w; v++) {
2479
+ p[v] = M.index;
2463
2480
  do
2464
2481
  M = M.next;
2465
2482
  while (M.seam);
2466
2483
  }
2467
- const N = p.getValues(), b = k.getValues();
2468
- _ = N.length, g = b.length;
2469
- const Y = _ * g, tt = [], q = new Array(Y).fill(0), O = [], x = [], L = [], S = [];
2470
- Yt(
2471
- tt,
2472
- N,
2473
- b,
2484
+ const V = x.getValues(), z = b.getValues();
2485
+ m = V.length, f = z.length;
2486
+ const U = m * f, O = [], W = new Array(U).fill(0), I = [], y = [], G = [], R = [];
2487
+ Dt(
2488
+ O,
2489
+ V,
2490
+ z,
2474
2491
  e,
2475
2492
  i,
2476
2493
  this.m_Book.direction
2477
2494
  );
2478
- const V = B.leftNode.index, G = B.downNode.index;
2479
- let $ = B.rightNode.index, K = B.upNode.index;
2480
- $ === 0 && ($ = _ - 1), K === 0 && (K = g - 1);
2481
- for (let y = 0; y < g - 1; y++)
2482
- for (let R = 0; R < _ - 1; R++) {
2483
- if (n && y >= G && y < K && R >= V && R < $)
2495
+ const L = S.leftNode.index, Y = S.downNode.index;
2496
+ let J = S.rightNode.index, tt = S.upNode.index;
2497
+ J === 0 && (J = m - 1), tt === 0 && (tt = f - 1);
2498
+ for (let v = 0; v < f - 1; v++)
2499
+ for (let X = 0; X < m - 1; X++) {
2500
+ if (n && v >= Y && v < tt && X >= L && X < J)
2484
2501
  continue;
2485
- const it = y * _ + R, nt = y * _ + (R + 1), ct = (y + 1) * _ + R, ot = (y + 1) * _ + (R + 1);
2486
- q[it] += 2, q[nt] += 2, q[ct] += 2, q[ot] += 2, Qt(
2487
- O,
2488
- x,
2489
- it,
2490
- nt,
2491
- ct,
2492
- ot,
2493
- Y
2502
+ const B = v * m + X, q = v * m + (X + 1), ut = (v + 1) * m + X, ht = (v + 1) * m + (X + 1);
2503
+ W[B] += 2, W[q] += 2, W[ut] += 2, W[ht] += 2, Vt(
2504
+ I,
2505
+ y,
2506
+ B,
2507
+ q,
2508
+ ut,
2509
+ ht,
2510
+ U
2494
2511
  );
2495
2512
  }
2496
- if (S.push(new Tt(0, 0, _ - 1, g - 1, !1, !1)), jt(S, L, tt, _, g), a.baseXArray = N, a.baseZArray = b, a.baseVertexCount = Y, a.vertexCount = tt.length, a.texcoords = tt, a.weights = q, h) {
2497
- a.subMeshCount = 1;
2498
- const y = [];
2499
- y.push(...O), y.push(...L), y.push(...x), a.triangles = y;
2513
+ if (R.push(new Mt(0, 0, m - 1, f - 1, !1, !1)), Rt(R, G, O, m, f), o.baseXArray = V, o.baseZArray = z, o.baseVertexCount = U, o.vertexCount = O.length, o.texcoords = O, o.weights = W, r) {
2514
+ o.subMeshCount = 1;
2515
+ const v = [];
2516
+ v.push(...I), v.push(...G), v.push(...y), o.triangles = v;
2500
2517
  } else
2501
- a.subMeshCount = 3, a.frontTriangles = O, a.backTriangles = x, a.borderTriangles = L;
2502
- return a.borders = S, a;
2518
+ o.subMeshCount = 3, o.frontTriangles = I, o.backTriangles = y, o.borderTriangles = G;
2519
+ return o.borders = R, o;
2503
2520
  }
2504
2521
  // ── updateRootPosition ────────────────────────────────────────────────
2505
2522
  updateRootPosition() {
@@ -2511,47 +2528,47 @@ class Ve extends we {
2511
2528
  resetPaperPosition(t) {
2512
2529
  const e = this.m_Book.papers, s = e.length;
2513
2530
  let i = 0;
2514
- const n = e.length / 2 - 1, h = e.length / 2;
2515
- for (let P = 0; P < s; P++) {
2516
- const w = e[P];
2517
- w.updateTime();
2518
- const k = w.zTime, I = w.thickness;
2519
- i += k * I, P === n && (i += k * this.m_BindingMidSpace / 2), P === h && (i += k * this.m_BindingMidSpace / 2);
2520
- }
2521
- let a = this.getStackHeight(t.index) - t.thickness / 2;
2522
- const o = this.getStackZ(a), u = 180 + o;
2523
- let l = t.isFlipped ? 1 : 0, m = F(o, u, l);
2524
- const f = m * J, d = new c.Vector3(
2525
- Math.cos(f) * this.m_BindingRadius,
2526
- Math.sin(f) * this.m_BindingRadius,
2531
+ const n = e.length / 2 - 1, r = e.length / 2;
2532
+ for (let C = 0; C < s; C++) {
2533
+ const T = e[C];
2534
+ T.updateTime();
2535
+ const b = T.zTime, D = T.thickness;
2536
+ i += b * D, C === n && (i += b * this.m_BindingMidSpace / 2), C === r && (i += b * this.m_BindingMidSpace / 2);
2537
+ }
2538
+ let o = this.getStackHeight(t.index) - t.thickness / 2;
2539
+ const c = this.getStackZ(o), l = 180 + c;
2540
+ let a = t.isFlipped ? 1 : 0, d = E(c, l, a);
2541
+ const g = d * Q, _ = new u.Vector3(
2542
+ Math.cos(g) * this.m_BindingRadius,
2543
+ Math.sin(g) * this.m_BindingRadius,
2527
2544
  0
2528
2545
  );
2529
- d.z = t.margin;
2530
- let _ = e[Math.floor(s / 2)].size.x, g = this.m_BindingMidSpace, p = Math.sqrt(_ * _ - g * g), M = Math.asin(p / _) * et - 90;
2546
+ _.z = t.margin;
2547
+ let m = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, x = Math.sqrt(m * m - f * f), M = Math.asin(x / m) * et - 90;
2531
2548
  if (t.index < Math.floor(s / 2)) {
2532
- let P = 0;
2549
+ let C = 0;
2533
2550
  if (this.m_Book.alignToGround) {
2534
- _ = e[0].size.x;
2535
- const w = this.m_StackHeight / 2;
2536
- g = H(i, 0, w) - w, p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2551
+ m = e[0].size.x;
2552
+ const T = this.m_StackHeight / 2;
2553
+ f = Z(i, 0, T) - T, x = Math.sqrt(m * m - f * f), C = (Math.asin(x / m) * et - 90) * 2;
2537
2554
  }
2538
- m = F(M, -P, l);
2555
+ d = E(M, -C, a);
2539
2556
  } else {
2540
- let P = 0;
2557
+ let C = 0;
2541
2558
  if (this.m_Book.alignToGround) {
2542
- _ = e[0].size.x;
2543
- const w = this.m_StackHeight / 2;
2544
- g = w - H(i, w, w * 2), p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2559
+ m = e[0].size.x;
2560
+ const T = this.m_StackHeight / 2;
2561
+ f = T - Z(i, T, T * 2), x = Math.sqrt(m * m - f * f), C = (Math.asin(x / m) * et - 90) * 2;
2545
2562
  }
2546
- m = F(P, -M, l);
2563
+ d = E(C, -M, a);
2547
2564
  }
2548
- t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2549
- new c.Euler(0, 0, m * J)
2565
+ t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2566
+ new u.Euler(0, 0, d * Q)
2550
2567
  );
2551
2568
  }
2552
2569
  // ── getPX (private helper) ───────────────────────────────────────────
2553
2570
  getPX(t, e) {
2554
- const s = this.getStackHeight(t) - e / 2, n = this.getStackZ(s) * J;
2571
+ const s = this.getStackHeight(t) - e / 2, n = this.getStackZ(s) * Q;
2555
2572
  return Math.cos(n) * this.m_BindingRadius;
2556
2573
  }
2557
2574
  // ── updatePaperPosition ───────────────────────────────────────────────
@@ -2559,34 +2576,34 @@ class Ve extends we {
2559
2576
  this.updatePaperPositionWithTh(t, this.computeTh());
2560
2577
  }
2561
2578
  updatePaperPositionWithTh(t, e) {
2562
- const s = this.m_Book.papers, i = s.length, n = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(n + e), a = 180 + this.getStackZ(n + e - this.m_StackHeight);
2563
- let o = t.zTime, u = F(h, a, o);
2564
- const l = u * J, m = new c.Vector3(
2565
- Math.cos(l) * this.m_BindingRadius,
2566
- Math.sin(l) * this.m_BindingRadius,
2579
+ const s = this.m_Book.papers, i = s.length, n = this.getStackHeight(t.index) - t.thickness / 2, r = this.getStackZ(n + e), o = 180 + this.getStackZ(n + e - this.m_StackHeight);
2580
+ let c = t.zTime, l = E(r, o, c);
2581
+ const a = l * Q, d = new u.Vector3(
2582
+ Math.cos(a) * this.m_BindingRadius,
2583
+ Math.sin(a) * this.m_BindingRadius,
2567
2584
  0
2568
2585
  );
2569
- m.z = t.margin;
2570
- let f = s[Math.floor(i / 2)].size.x, d = this.m_BindingMidSpace, _ = Math.sqrt(f * f - d * d), g = Math.asin(_ / f) * et - 90;
2586
+ d.z = t.margin;
2587
+ let g = s[Math.floor(i / 2)].size.x, _ = this.m_BindingMidSpace, m = Math.sqrt(g * g - _ * _), f = Math.asin(m / g) * et - 90;
2571
2588
  if (t.index < Math.floor(i / 2)) {
2572
2589
  let M = 0;
2573
2590
  if (this.m_Book.alignToGround) {
2574
- f = s[0].size.x;
2575
- const T = this.m_StackHeight / 2;
2576
- d = H(e, 0, T) - T, _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2591
+ g = s[0].size.x;
2592
+ const P = this.m_StackHeight / 2;
2593
+ _ = Z(e, 0, P) - P, m = Math.sqrt(g * g - _ * _), M = (Math.asin(m / g) * et - 90) * 2;
2577
2594
  }
2578
- u = F(g, -M, o);
2595
+ l = E(f, -M, c);
2579
2596
  } else {
2580
2597
  let M = 0;
2581
2598
  if (this.m_Book.alignToGround) {
2582
- f = s[0].size.x;
2583
- const T = this.m_StackHeight / 2;
2584
- d = T - H(e, T, T * 2), _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2599
+ g = s[0].size.x;
2600
+ const P = this.m_StackHeight / 2;
2601
+ _ = P - Z(e, P, P * 2), m = Math.sqrt(g * g - _ * _), M = (Math.asin(m / g) * et - 90) * 2;
2585
2602
  }
2586
- u = F(M, -g, o);
2603
+ l = E(M, -f, c);
2587
2604
  }
2588
- t.transform.position.copy(m), t.transform.quaternion.setFromEuler(
2589
- new c.Euler(0, 0, u * J)
2605
+ t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2606
+ new u.Euler(0, 0, l * Q)
2590
2607
  );
2591
2608
  }
2592
2609
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2600,7 +2617,7 @@ class Ve extends we {
2600
2617
  }
2601
2618
  // ── getStackZ ─────────────────────────────────────────────────────────
2602
2619
  getStackZ(t) {
2603
- t = H(t, 0, this.m_StackHeight);
2620
+ t = Z(t, 0, this.m_StackHeight);
2604
2621
  const e = t - this.m_StackHeight * 0.5;
2605
2622
  return Math.asin(e / this.m_BindingRadius) * et;
2606
2623
  }
@@ -2610,10 +2627,10 @@ class Ve extends we {
2610
2627
  const t = this.m_Book.papers, e = t.length / 2 - 1, s = t.length / 2;
2611
2628
  let i = 0;
2612
2629
  for (let n = 0; n < t.length; n++) {
2613
- const h = t[n];
2614
- h.updateTime();
2615
- const a = h.zTime;
2616
- i += a * h.thickness, n === e && (i += a * this.m_BindingMidSpace / 2), n === s && (i += a * this.m_BindingMidSpace / 2);
2630
+ const r = t[n];
2631
+ r.updateTime();
2632
+ const o = r.zTime;
2633
+ i += o * r.thickness, n === e && (i += o * this.m_BindingMidSpace / 2), n === s && (i += o * this.m_BindingMidSpace / 2);
2617
2634
  }
2618
2635
  return i;
2619
2636
  }
@@ -2629,42 +2646,42 @@ class Ve extends we {
2629
2646
  // ── updateBindingVertices ─────────────────────────────────────────────
2630
2647
  updateBindingVertices() {
2631
2648
  const t = this.m_Book.papers;
2632
- let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2633
- const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), o = t.length;
2634
- for (let u = 0; u < o; u++) {
2635
- const l = t[u], m = l.transform, f = l.meshData.pattern, d = l.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = l.thickness, w = f.xNoneSeamIndexes, k = m.position.clone();
2636
- let I = u, Z = n;
2637
- u >= Math.floor(o / 2) && (I = o - u - 1, Z *= -1);
2638
- const U = (h + P) * 0.5 + P * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), E = I / (o / 2);
2639
- i = this.m_BindingRadius * F(0.45, 0.65, 1 - E);
2640
- for (let A = 0; A < M; A++) {
2641
- const B = g[A], C = new c.Vector3(0, 0, k.z + B), v = k.clone();
2642
- v.z += B;
2643
- const N = l.getDirection(B).multiplyScalar(i).add(v.clone());
2644
- if (u === 0 && A === 0) {
2645
- const O = t[o - 1], L = O.transform.position.clone().clone();
2646
- L.z += B;
2647
- const S = O.getDirection(B).multiplyScalar(i).add(L);
2648
- s = N.clone().sub(S).normalize(), e = new c.Vector3(
2649
+ let e = new u.Vector3(0, 0, 0), s = new u.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2650
+ const n = this.m_StapleThickness * 0.5, r = t[0].thickness, o = this.m_Root.matrixWorld.clone(), c = t.length;
2651
+ for (let l = 0; l < c; l++) {
2652
+ const a = t[l], d = a.transform, g = a.meshData.pattern, _ = a.meshData.baseVertices, m = g.baseXArray, f = g.baseZArray, x = m.length, M = f.length, P = this.m_BindingVertexCount + 1, C = a.thickness, T = g.xNoneSeamIndexes, b = d.position.clone();
2653
+ let D = l, A = n;
2654
+ l >= Math.floor(c / 2) && (D = c - l - 1, A *= -1);
2655
+ const N = (r + C) * 0.5 + C * (D - 1), F = d.matrixWorld.clone().invert().multiply(o), H = D / (c / 2);
2656
+ i = this.m_BindingRadius * E(0.45, 0.65, 1 - H);
2657
+ for (let k = 0; k < M; k++) {
2658
+ const S = f[k], w = new u.Vector3(0, 0, b.z + S), p = b.clone();
2659
+ p.z += S;
2660
+ const V = a.getDirection(S).multiplyScalar(i).add(p.clone());
2661
+ if (l === 0 && k === 0) {
2662
+ const I = t[c - 1], G = I.transform.position.clone().clone();
2663
+ G.z += S;
2664
+ const R = I.getDirection(S).multiplyScalar(i).add(G);
2665
+ s = V.clone().sub(R).normalize(), e = new u.Vector3(
2649
2666
  -s.y,
2650
2667
  s.x,
2651
2668
  0
2652
2669
  ).normalize().negate();
2653
- const V = Math.atan2(e.y, e.x) * et;
2654
- this.stapleMesh.rotation.set(0, 0, V * J);
2670
+ const L = Math.atan2(e.y, e.x) * et;
2671
+ this.stapleMesh.rotation.set(0, 0, L * Q);
2655
2672
  }
2656
- I > 0 && C.add(e.clone().multiplyScalar(U));
2657
- const b = A * p;
2658
- d[b] = C.clone().applyMatrix4(z), C.add(s.clone().multiplyScalar(Z));
2659
- const Y = C.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
2660
- d[b + w[1]] = Y;
2661
- for (let O = 2; O < T; O++) {
2662
- const x = Q(1, T, O);
2663
- d[b + w[O]] = Et(
2664
- Y,
2665
- tt,
2666
- q,
2667
- x
2673
+ D > 0 && w.add(e.clone().multiplyScalar(N));
2674
+ const z = k * x;
2675
+ _[z] = w.clone().applyMatrix4(F), w.add(s.clone().multiplyScalar(A));
2676
+ const U = w.clone().applyMatrix4(F), O = V.clone().applyMatrix4(F), W = p.clone().applyMatrix4(F);
2677
+ _[z + T[1]] = U;
2678
+ for (let I = 2; I < P; I++) {
2679
+ const y = nt(1, P, I);
2680
+ _[z + T[I]] = kt(
2681
+ U,
2682
+ O,
2683
+ W,
2684
+ y
2668
2685
  );
2669
2686
  }
2670
2687
  }
@@ -2694,10 +2711,10 @@ class Ve extends we {
2694
2711
  }
2695
2712
  /** Releases GPU resources held by the staple mesh. */
2696
2713
  dispose() {
2697
- this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof c.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2714
+ this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof u.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2698
2715
  }
2699
2716
  }
2700
- class ze {
2717
+ class Xe {
2701
2718
  constructor(t) {
2702
2719
  this.mesh = t;
2703
2720
  }
@@ -2711,7 +2728,7 @@ class ze {
2711
2728
  this.mesh.castShadow = t;
2712
2729
  }
2713
2730
  get bounds() {
2714
- const t = new c.Box3();
2731
+ const t = new u.Box3();
2715
2732
  return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
2716
2733
  }
2717
2734
  get transform() {
@@ -2721,12 +2738,12 @@ class ze {
2721
2738
  return this.mesh;
2722
2739
  }
2723
2740
  }
2724
- class Ee extends ye {
2741
+ class rs extends ce {
2725
2742
  constructor() {
2726
- super(...arguments), this.quality = 3, this.stapleSetup = new Ie();
2743
+ super(...arguments), this.quality = 3, this.stapleSetup = new Ze();
2727
2744
  }
2728
2745
  createBound(t, e, s, i) {
2729
- return new Ve(
2746
+ return new Le(
2730
2747
  this.quality,
2731
2748
  this.stapleSetup,
2732
2749
  t,
@@ -2734,7 +2751,504 @@ class Ee extends ye {
2734
2751
  );
2735
2752
  }
2736
2753
  }
2737
- class Kt {
2754
+ const Ne = 5e-3, Ue = 0.2, Ee = 0.02, We = 0.5, Ge = 0, qe = 5;
2755
+ class je {
2756
+ constructor() {
2757
+ this._hingeGap = 0.03, this._glueFlexWidth = 0.12, this._spineColor = new u.Color(0.55, 0.15, 0.15), this._spineTexture = null, this._spineMaterial = null, this._quality = 3;
2758
+ }
2759
+ /** Cloth-joint groove between a board and the spine edge (world units). */
2760
+ get hingeGap() {
2761
+ return this._hingeGap;
2762
+ }
2763
+ set hingeGap(t) {
2764
+ this._hingeGap = Z(t, Ne, Ue);
2765
+ }
2766
+ /** Width of the page gutter flex zone — glued pages never open flat. */
2767
+ get glueFlexWidth() {
2768
+ return this._glueFlexWidth;
2769
+ }
2770
+ set glueFlexWidth(t) {
2771
+ this._glueFlexWidth = Z(t, Ee, We);
2772
+ }
2773
+ get spineColor() {
2774
+ return this._spineColor;
2775
+ }
2776
+ set spineColor(t) {
2777
+ this._spineColor = t;
2778
+ }
2779
+ /**
2780
+ * Artwork/text for the spine zone (u across the spine width front→back
2781
+ * crown, v along the book height). Render text into a canvas texture the
2782
+ * same way as cover faces. Null → plain spineColor.
2783
+ */
2784
+ get spineTexture() {
2785
+ return this._spineTexture;
2786
+ }
2787
+ set spineTexture(t) {
2788
+ this._spineTexture = t;
2789
+ }
2790
+ /** Custom cloth material for edges/joints. Overrides spineColor. */
2791
+ get spineMaterial() {
2792
+ return this._spineMaterial;
2793
+ }
2794
+ set spineMaterial(t) {
2795
+ this._spineMaterial = t;
2796
+ }
2797
+ /** Segment count for the rounded spine profile. */
2798
+ get quality() {
2799
+ return this._quality;
2800
+ }
2801
+ set quality(t) {
2802
+ this._quality = Z(t, Ge, qe);
2803
+ }
2804
+ }
2805
+ const Ye = 30, Qt = 6, $t = 0, Kt = 1, Jt = 2, te = 3, ft = 4, at = 5;
2806
+ class Qe extends le {
2807
+ constructor(t, e, s, i) {
2808
+ if (super(s, i), this.bindingType = "hardcover", this.m_StackHeight = 0, this.m_RadiusY = 0, this.m_GlueY = [], this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_CaseSlabSegments = 8, this.m_CaseLoopCount = 0, this.m_CaseMinY = 0, this.m_CaseMaterials = [], this.m_ClothMaterial = null, this.m_OwnsClothMaterial = !1, this.m_CaseZones = [], this.m_Quality = t, this.m_Setup = e, s.totalThickness * 1.25 > s.minPaperWidth)
2809
+ throw new oe();
2810
+ const n = this.m_Book.coverPaperSetup;
2811
+ this.m_StackHeight = this.m_Book.totalThickness, this.m_RadiusY = this.m_StackHeight / 2 / Math.sin(Ye * Q);
2812
+ const r = this.m_Book.papers;
2813
+ this.m_GlueY = new Array(r.length);
2814
+ for (let a = 0; a < r.length; a++) {
2815
+ const d = this.getStackHeight(a);
2816
+ this.m_GlueY[a] = d - r[a].thickness / 2 - this.m_StackHeight / 2;
2817
+ }
2818
+ const o = this.createCaseGeometry();
2819
+ this.m_OwnsClothMaterial = e.spineMaterial === null, this.m_ClothMaterial = e.spineMaterial ?? new u.MeshStandardMaterial({
2820
+ color: e.spineColor,
2821
+ roughness: 0.75,
2822
+ metalness: 0,
2823
+ side: u.DoubleSide
2824
+ }), this.m_CaseMaterials = [];
2825
+ for (let a = 0; a < 5; a++)
2826
+ this.m_CaseMaterials.push(
2827
+ new u.MeshStandardMaterial({
2828
+ color: a === ft ? e.spineColor : n.color,
2829
+ roughness: 0.8,
2830
+ metalness: 0,
2831
+ side: u.DoubleSide
2832
+ })
2833
+ );
2834
+ const c = [...this.m_CaseMaterials, this.m_ClothMaterial];
2835
+ this.spineMesh = new u.Mesh(o, c), this.spineMesh.name = "Case", this.spineMesh.castShadow = this.m_Book.castShadows, i.add(this.spineMesh), this.spineMesh.position.set(0, 0, n.margin);
2836
+ let l = n.thickness;
2837
+ l = Math.max(e.glueFlexWidth, l);
2838
+ for (const a of this.m_Book.papers) {
2839
+ const d = this.bindingWidthFor(a.isCover), g = a.size.clone();
2840
+ g.x -= d, a.sizeXOffset = d, a.size = g, a.setMinTurningRadius(l), a.updateTurningRadius(), this.updatePaperPosition(a);
2841
+ }
2842
+ this.m_Book.hasCover && (r[0].renderer.transform.visible = !1, r[r.length - 1].renderer.transform.visible = !1), this.m_Root.updateMatrixWorld(!0), this.refreshCaseMaterials(), this.updateCaseMesh(this.spineAngle()), this.updateRootPosition();
2843
+ }
2844
+ get binderRenderer() {
2845
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new $e(this.spineMesh)), this._binderRendererAdapter;
2846
+ }
2847
+ bindingWidthFor(t) {
2848
+ return t ? this.m_Setup.hingeGap + this.m_Book.coverPaperSetup.thickness : this.m_Setup.glueFlexWidth;
2849
+ }
2850
+ /**
2851
+ * Half-extent of the spine slab. The board hinges anchor exactly on the
2852
+ * slab's crown edges — a shared value, or the joint opens a see-through
2853
+ * slot between cloth and slab.
2854
+ */
2855
+ get spineHalf() {
2856
+ return this.m_StackHeight / 2 + this.m_Setup.hingeGap * 0.5;
2857
+ }
2858
+ createCaseGeometry() {
2859
+ this.m_CaseSlabSegments = Math.max(6, (this.m_Setup.quality + 1) * 4);
2860
+ const t = this.m_CaseSlabSegments, e = Qt, i = 2 * (t + 2 * e + 5);
2861
+ this.m_CaseLoopCount = i;
2862
+ const n = [], r = (a, d) => {
2863
+ for (let g = 0; g < d; g++) n.push(a);
2864
+ };
2865
+ r(Kt, 1), r(at, e + 1), r(at, t), r(at, e + 1), r(Jt, 1), r(at, 1), r(te, 1), r(at, e + 1), r(ft, t), r(at, e + 1), r($t, 1), r(at, 1), this.m_CaseZones = n;
2866
+ const o = new u.BufferGeometry(), c = i * 4 + i * 2;
2867
+ o.setAttribute("position", new u.BufferAttribute(new Float32Array(c * 3), 3)), o.setAttribute("uv", new u.BufferAttribute(new Float32Array(c * 2), 2)), o.setIndex(new u.BufferAttribute(new Uint16Array(i * 6 + (i - 2) * 6), 1));
2868
+ let l = 0;
2869
+ for (let a = 1; a <= i; a++)
2870
+ (a === i || n[a] !== n[l]) && (o.addGroup(l * 6, (a - l) * 6, n[l]), l = a);
2871
+ return o.addGroup(i * 6, (i - 2) * 6, at), o;
2872
+ }
2873
+ /**
2874
+ * The case spine curve, manga-cover model: the two flat boards are joined
2875
+ * by ONE smooth cubic whose handles run along each board's own direction —
2876
+ * tangent-continuous with both boards at every opening angle, closed-C /
2877
+ * open-S shape emerging from the board transforms, nothing to glitch. The
2878
+ * handle length is chosen so the curve's INNER face hugs the closed block
2879
+ * (apex a hair off the glue wall). Shared by the case mesh and the page
2880
+ * glue so pages attach to the real spine surface.
2881
+ */
2882
+ caseCurve() {
2883
+ const t = this.m_Book.papers, s = this.m_Book.coverPaperSetup.thickness / 2, i = (m) => {
2884
+ const f = m.getDirection(m.size.y / 2), x = new u.Vector2(f.x, f.y);
2885
+ x.lengthSq() < 1e-8 && x.set(-1, 0), x.normalize();
2886
+ const M = new u.Vector2(m.transform.position.x, m.transform.position.y), P = m.size.x, C = this.bindingWidthFor(!0);
2887
+ return { d: x, pivot: M, w: P, uOf: (b) => st((b.clone().sub(M).dot(x) * -1 + C) / (P + C)) };
2888
+ }, n = i(t[0]), r = i(t[t.length - 1]), o = (this.bindingWidthFor(!0) + s + 4e-3) / 0.75, c = n.pivot, l = n.pivot.clone().addScaledVector(n.d, o), a = r.pivot.clone().addScaledVector(r.d, o), d = r.pivot;
2889
+ return { F: n, B: r, half: s, cubic: (m) => {
2890
+ const f = 1 - m;
2891
+ return new u.Vector2(
2892
+ f * f * f * c.x + 3 * f * f * m * l.x + 3 * f * m * m * a.x + m * m * m * d.x,
2893
+ f * f * f * c.y + 3 * f * f * m * l.y + 3 * f * m * m * a.y + m * m * m * d.y
2894
+ );
2895
+ }, normalAt: (m) => {
2896
+ const f = 1 - m, x = 3 * f * f * (l.x - c.x) + 6 * f * m * (a.x - l.x) + 3 * m * m * (d.x - a.x), M = 3 * f * f * (l.y - c.y) + 6 * f * m * (a.y - l.y) + 3 * m * m * (d.y - a.y), P = new u.Vector2(M, -x);
2897
+ return P.lengthSq() < 1e-10 ? new u.Vector2(-1, 0) : P.normalize();
2898
+ } };
2899
+ }
2900
+ updateCaseMesh(t) {
2901
+ const e = Qt, s = this.m_CaseSlabSegments, { F: i, B: n, half: r, cubic: o } = this.caseCurve(), c = s + 2 * e + 1, l = [], a = [], d = (e + 1) / (c + 1), g = (e + s + 1) / (c + 1);
2902
+ l.push(i.pivot.clone().addScaledVector(i.d, -i.w)), a.push(1), l.push(i.pivot.clone()), a.push(0);
2903
+ for (let p = 1; p <= c; p++) {
2904
+ const V = p / (c + 1);
2905
+ l.push(o(V)), a.push(1 - st((V - d) / (g - d)));
2906
+ }
2907
+ l.push(n.pivot.clone()), a.push(0), l.push(n.pivot.clone().addScaledVector(n.d, -n.w)), a.push(1);
2908
+ const _ = l.length, m = new Array(_), f = new Array(_), x = new u.Vector2();
2909
+ for (let p = 0; p < _; p++) {
2910
+ const V = l[Math.max(p - 1, 0)], z = l[Math.min(p + 1, _ - 1)];
2911
+ x.set(z.x - V.x, z.y - V.y), x.lengthSq() < 1e-10 && x.set(-1, 0), x.normalize();
2912
+ const U = x.y, O = -x.x;
2913
+ m[p] = new u.Vector2(l[p].x + U * r, l[p].y + O * r), f[p] = new u.Vector2(l[p].x - U * r, l[p].y - O * r);
2914
+ }
2915
+ const M = [], P = [];
2916
+ for (let p = 0; p < _; p++)
2917
+ M.push(f[p]), P.push(p <= 1 ? 1 - a[p] : a[p]);
2918
+ for (let p = _ - 1; p >= 0; p--)
2919
+ M.push(m[p]), P.push(p >= _ - 2 ? 1 - a[p] : a[p]);
2920
+ const C = this.m_CaseLoopCount, T = this.m_Book.coverPaperSetup.height, b = this.spineMesh.geometry, D = b.getAttribute("position"), A = b.getAttribute("uv"), N = this.m_CaseZones;
2921
+ let F = 0;
2922
+ for (const p of M) F = Math.min(F, p.y);
2923
+ this.m_CaseMinY = F;
2924
+ for (let p = 0; p < C; p++) {
2925
+ const V = (p + 1) % C, z = N[p], U = z === at;
2926
+ let O = U ? 0 : P[p], W = U ? 1 : P[V];
2927
+ !U && z !== ft && (O = O < 0.5 ? 0 : 1, W = W < 0.5 ? 0 : 1);
2928
+ const I = p * 4;
2929
+ D.setXYZ(I, M[p].x, M[p].y, 0), D.setXYZ(I + 1, M[V].x, M[V].y, 0), D.setXYZ(I + 2, M[p].x, M[p].y, T), D.setXYZ(I + 3, M[V].x, M[V].y, T), A.setXY(I, O, 1), A.setXY(I + 1, W, 1), A.setXY(I + 2, O, 0), A.setXY(I + 3, W, 0);
2930
+ }
2931
+ const H = C * 4;
2932
+ for (let p = 0; p < C; p++)
2933
+ D.setXYZ(H + p, M[p].x, M[p].y, 0), D.setXYZ(H + C + p, M[p].x, M[p].y, T), A.setXY(H + p, 0.5, 0.5), A.setXY(H + C + p, 0.5, 0.5);
2934
+ const k = b.getIndex();
2935
+ let S = 0;
2936
+ for (let p = 0; p < C; p++) {
2937
+ const V = p * 4;
2938
+ k.setX(S++, V + 2), k.setX(S++, V + 1), k.setX(S++, V), k.setX(S++, V + 2), k.setX(S++, V + 3), k.setX(S++, V + 1);
2939
+ }
2940
+ let w = [];
2941
+ try {
2942
+ w = u.ShapeUtils.triangulateShape(M, []);
2943
+ } catch {
2944
+ }
2945
+ for (const p of w)
2946
+ k.setX(S++, H + p[2]), k.setX(S++, H + p[1]), k.setX(S++, H + p[0]), k.setX(S++, H + C + p[0]), k.setX(S++, H + C + p[1]), k.setX(S++, H + C + p[2]);
2947
+ for (; S < k.count; ) k.setX(S++, 0);
2948
+ D.needsUpdate = !0, A.needsUpdate = !0, k.needsUpdate = !0, b.computeVertexNormals(), b.computeBoundingSphere();
2949
+ }
2950
+ /** Keeps the five zone materials pointed at the live content textures. */
2951
+ refreshCaseMaterials() {
2952
+ var n, r, o, c, l, a, d, g;
2953
+ const t = this.m_Book.papers, e = t[t.length - 1], s = (_, m, f) => {
2954
+ const x = this.m_CaseMaterials[_];
2955
+ x && (m && f && (m.repeat.set(f.x, f.y), m.offset.set(f.z, f.w)), x.map !== m && (x.map = m, x.color.set(m ? 16777215 : this.m_Book.coverPaperSetup.color.getHex()), x.needsUpdate = !0));
2956
+ };
2957
+ this.m_Book.hasCover && (s($t, ((n = t[0].frontContent) == null ? void 0 : n.texture) ?? null, (r = t[0].frontContent) == null ? void 0 : r.textureST), s(Kt, ((o = t[0].backContent) == null ? void 0 : o.texture) ?? null, (c = t[0].backContent) == null ? void 0 : c.textureST), s(Jt, ((l = e.frontContent) == null ? void 0 : l.texture) ?? null, (a = e.frontContent) == null ? void 0 : a.textureST), s(te, ((d = e.backContent) == null ? void 0 : d.texture) ?? null, (g = e.backContent) == null ? void 0 : g.textureST));
2958
+ const i = this.m_CaseMaterials[ft];
2959
+ i && i.map !== this.m_Setup.spineTexture && (i.map = this.m_Setup.spineTexture, i.color.set(this.m_Setup.spineTexture ? 16777215 : this.m_Setup.spineColor.getHex()), i.needsUpdate = !0);
2960
+ }
2961
+ // ── createPaperPattern ────────────────────────────────────────────────
2962
+ createPaperPattern(t, e, s, i, n, r) {
2963
+ const o = new he();
2964
+ o.size = e, o.thickness = s;
2965
+ const c = this.m_Book.coverPaperSetup.size, l = Math.abs(e.x - c.x) < 1e-6 && Math.abs(e.y - c.y) < 1e-6, a = this.bindingWidthFor(l);
2966
+ o.baseXOffset = -a;
2967
+ const d = (this.m_Quality + 1) * 2;
2968
+ this.m_BindingVertexCount = d;
2969
+ const g = t / 5, _ = Math.min(e.x, e.y) / 60, m = Math.floor(
2970
+ E(0, (e.x - a) / _, g)
2971
+ ), f = Math.floor(E(0, e.y / _, g));
2972
+ let x = 2 + m + 1 + d, M = 2 + f;
2973
+ const P = new ot(0);
2974
+ let C = P;
2975
+ const T = a / d;
2976
+ let b = 0;
2977
+ for (let B = 1; B < d + 1; B++)
2978
+ C = C.createNext(b), b += T;
2979
+ const D = (e.x - a) / (m + 1);
2980
+ for (let B = d + 1; B < x; B++)
2981
+ C = C.createNext(b), b += D;
2982
+ const A = new ot(0);
2983
+ let N = A;
2984
+ const F = e.y / (M - 1);
2985
+ let H = 0;
2986
+ for (let B = 0; B < M - 1; B++)
2987
+ H += F, N = N.createNext(H);
2988
+ const k = [], S = [], w = i.clone();
2989
+ if (n) {
2990
+ let B = 0;
2991
+ this.m_Book.hasCover && (B = Math.floor(this.m_Book.coverPaperCount / 2));
2992
+ const q = Math.max(0.01, s);
2993
+ w.left = 0, w.right = (this.getPX(B + 1, s) - this.getPX(B, s) + q) / e.x, w.down = q / e.y, w.up = q / e.y;
2994
+ }
2995
+ const p = new ie(o, w, !1);
2996
+ p.insert(P, A, k, S), P.updateIndex(0), A.updateIndex(0), dt(k, o.xSeams), dt(S, o.zSeams);
2997
+ const V = this.m_BindingVertexCount + 2, z = new Array(V);
2998
+ o.xNoneSeamIndexes = z, C = P;
2999
+ for (let B = 0; B < V; B++) {
3000
+ z[B] = C.index;
3001
+ do
3002
+ C = C.next;
3003
+ while (C.seam);
3004
+ }
3005
+ const U = P.getValues(), O = A.getValues();
3006
+ x = U.length, M = O.length;
3007
+ const W = x * M, I = [], y = new Array(W).fill(0), G = [], R = [], L = [], Y = [];
3008
+ Dt(
3009
+ I,
3010
+ U,
3011
+ O,
3012
+ e,
3013
+ i,
3014
+ this.m_Book.direction
3015
+ );
3016
+ const J = p.leftNode.index, tt = p.downNode.index;
3017
+ let v = p.rightNode.index, X = p.upNode.index;
3018
+ v === 0 && (v = x - 1), X === 0 && (X = M - 1);
3019
+ for (let B = 0; B < M - 1; B++)
3020
+ for (let q = 0; q < x - 1; q++) {
3021
+ if (n && B >= tt && B < X && q >= J && q < v)
3022
+ continue;
3023
+ const ut = B * x + q, ht = B * x + (q + 1), _t = (B + 1) * x + q, mt = (B + 1) * x + (q + 1);
3024
+ y[ut] += 2, y[ht] += 2, y[_t] += 2, y[mt] += 2, Vt(
3025
+ G,
3026
+ R,
3027
+ ut,
3028
+ ht,
3029
+ _t,
3030
+ mt,
3031
+ W
3032
+ );
3033
+ }
3034
+ if (Y.push(new Mt(0, 0, x - 1, M - 1, !1, !1)), Rt(Y, L, I, x, M), o.baseXArray = U, o.baseZArray = O, o.baseVertexCount = W, o.vertexCount = I.length, o.texcoords = I, o.weights = y, r) {
3035
+ o.subMeshCount = 1;
3036
+ const B = [];
3037
+ B.push(...G), B.push(...L), B.push(...R), o.triangles = B;
3038
+ } else
3039
+ o.subMeshCount = 3, o.frontTriangles = G, o.backTriangles = R, o.borderTriangles = L;
3040
+ return o.borders = Y, o;
3041
+ }
3042
+ // ── Pivot placement ───────────────────────────────────────────────────
3043
+ /**
3044
+ * Pivot for angle z (deg). y follows the stack; x is normalised so every
3045
+ * resting sheet pivots at exactly ±bindingWidth — glued fore edges stay
3046
+ * flush — while a turning sheet still sweeps smoothly through x = 0 as it
3047
+ * lifts over the spine.
3048
+ */
3049
+ pivotAt(t, e, s, i, n, r) {
3050
+ const o = this.bindingWidthFor(e), c = t * Q, l = E(
3051
+ Math.cos(s * Q),
3052
+ -Math.cos(i * Q),
3053
+ st(n)
3054
+ ), a = o * Math.cos(c) / Math.max(l, 1e-4);
3055
+ return r.set(Z(a, -o, o), Math.sin(c) * this.m_RadiusY, 0), r;
3056
+ }
3057
+ /**
3058
+ * Tight-back spine angle: the case spine follows the block. Closed → 0
3059
+ * (vertical slab against the block spine); open flat → 90° (slab lying
3060
+ * under the gutter); fully turned over → 180°.
3061
+ */
3062
+ spineAngle() {
3063
+ const { th: t, total: e } = this.computeThPages();
3064
+ return Math.PI * st(t / e);
3065
+ }
3066
+ updateRootPosition() {
3067
+ const t = this.m_Book.papers, e = t[0].transform.position.y, s = t[t.length - 1].transform.position.y;
3068
+ let i = -Math.min(e, s);
3069
+ i += t[0].thickness / 2, i = Math.max(i, -this.m_CaseMinY), this.m_Root.position.set(0, i, this.m_Root.position.z);
3070
+ }
3071
+ resetPaperPosition(t) {
3072
+ const e = this.m_Book.papers;
3073
+ for (const a of e)
3074
+ a.updateTime();
3075
+ const s = this.getStackHeight(t.index) - t.thickness / 2, i = this.getStackZ(s), n = 180 + i, r = t.isFlipped ? 1 : 0, o = E(i, n, r), c = this.pivotAt(o, t.isCover, i, n, r, new u.Vector3());
3076
+ c.z = t.margin;
3077
+ const l = this.restRotation(t, r, 0);
3078
+ t.transform.position.copy(c), t.transform.quaternion.setFromEuler(new u.Euler(0, 0, l * Q));
3079
+ }
3080
+ getPX(t, e) {
3081
+ const s = this.m_Book.hasCover && (t < Math.floor(this.m_Book.coverPaperCount / 2) || t >= this.m_Book.papers.length - Math.floor(this.m_Book.coverPaperCount / 2));
3082
+ return this.bindingWidthFor(s);
3083
+ }
3084
+ updatePaperPosition(t) {
3085
+ this.updatePaperPositionWithTh(t, this.computeTh());
3086
+ }
3087
+ updatePaperPositionWithTh(t, e) {
3088
+ const s = this.getStackHeight(t.index) - t.thickness / 2, i = this.getStackZ(s + e), n = 180 + this.getStackZ(s + e - this.m_StackHeight), r = t.zTime, o = E(i, n, r), c = this.pivotAt(o, t.isCover, i, n, r, new u.Vector3());
3089
+ c.z = t.margin;
3090
+ const l = this.restRotation(t, r, e);
3091
+ t.transform.position.copy(c), t.transform.quaternion.setFromEuler(new u.Euler(0, 0, l * Q));
3092
+ }
3093
+ /**
3094
+ * Resting plane rotation. A glued block has no fold gap, so resting papers
3095
+ * lie flat (0°); with alignToGround the outer papers tilt so both stacks
3096
+ * touch the ground exactly like the staple binding does.
3097
+ */
3098
+ restRotation(t, e, s) {
3099
+ const i = this.m_Book.papers;
3100
+ if (t.index < Math.floor(i.length / 2)) {
3101
+ let o = 0;
3102
+ if (this.m_Book.alignToGround) {
3103
+ const c = i[0].size.x, l = this.m_StackHeight / 2, a = Z(s, 0, l) - l, d = Math.sqrt(Math.max(c * c - a * a, 0));
3104
+ o = (Math.asin(st(d / c)) * et - 90) * 2;
3105
+ }
3106
+ return E(0, -o, e);
3107
+ }
3108
+ let r = 0;
3109
+ if (this.m_Book.alignToGround) {
3110
+ const o = i[0].size.x, c = this.m_StackHeight / 2, l = c - Z(s, c, c * 2), a = Math.sqrt(Math.max(o * o - l * l, 0));
3111
+ r = (Math.asin(st(a / o)) * et - 90) * 2;
3112
+ }
3113
+ return E(r, 0, e);
3114
+ }
3115
+ getStackHeight(t) {
3116
+ const e = this.m_Book.papers;
3117
+ let s = 0;
3118
+ const i = e.length;
3119
+ for (let n = t; n < i; n++)
3120
+ s += e[n].thickness;
3121
+ return s;
3122
+ }
3123
+ getStackZ(t) {
3124
+ t = Z(t, 0, this.m_StackHeight);
3125
+ const e = t - this.m_StackHeight * 0.5;
3126
+ return Math.asin(Z(e / this.m_RadiusY, -1, 1)) * et;
3127
+ }
3128
+ computeTh() {
3129
+ const t = this.m_Book.papers;
3130
+ let e = 0;
3131
+ for (const s of t)
3132
+ s.updateTime(), e += s.zTime * s.thickness;
3133
+ return e;
3134
+ }
3135
+ /**
3136
+ * Turned thickness of the TEXT BLOCK only. The tight-back spine follows the
3137
+ * block, not the covers — opening just a cover must leave the spine flat
3138
+ * (driving it with total th jams the rotated slab into the open hinge).
3139
+ */
3140
+ computeThPages() {
3141
+ const t = this.m_Book.papers;
3142
+ let e = 0, s = 0;
3143
+ for (const i of t)
3144
+ i.isCover || (i.updateTime(), e += i.zTime * i.thickness, s += i.thickness);
3145
+ return { th: e, total: Math.max(s, 1e-6) };
3146
+ }
3147
+ onLateUpdate() {
3148
+ const t = this.m_Book.papers, e = this.computeTh();
3149
+ for (const i of t)
3150
+ this.updatePaperPositionWithTh(i, e);
3151
+ this.m_Root.updateMatrixWorld(!0), this.refreshCaseMaterials();
3152
+ const s = this.spineAngle();
3153
+ this.updateCaseMesh(s), this.updateGlueVertices(s);
3154
+ for (const i of t)
3155
+ i.updateMesh();
3156
+ this.updateRootPosition();
3157
+ }
3158
+ // ── updateGlueVertices ────────────────────────────────────────────────
3159
+ //
3160
+ // Rewrites each paper's flex-zone vertices: a quadratic bezier from its
3161
+ // permanent anchor on the spine (glue line for pages, hinge edge for
3162
+ // boards) out to the free sheet. This is what fuses the block to the
3163
+ // spine and draws the hardcover gutter valley / cloth hinge groove.
3164
+ updateGlueVertices(t) {
3165
+ const e = this.m_Book.papers, s = e.length, i = this.m_Root.matrixWorld.clone(), n = Math.cos(t), r = Math.sin(t), { half: o, cubic: c, normalAt: l } = this.caseCurve();
3166
+ for (let a = 0; a < s; a++) {
3167
+ const d = e[a], g = d.transform, _ = d.meshData.pattern, m = d.meshData.baseVertices, f = _.baseZArray, x = _.baseXArray.length, M = f.length, P = this.m_BindingVertexCount + 1, C = _.xNoneSeamIndexes, T = g.position.clone();
3168
+ let b, D, A, N;
3169
+ if (d.isCover) {
3170
+ const w = a < Math.floor(s / 2) ? this.spineHalf : -this.spineHalf;
3171
+ b = -w * r, D = w * n, A = -n, N = -r;
3172
+ } else {
3173
+ const S = st(0.5 - this.m_GlueY[a] / this.m_StackHeight), w = c(S), p = l(S);
3174
+ b = w.x - p.x * o, D = w.y - p.y * o, A = p.x, N = p.y;
3175
+ }
3176
+ const F = this.bindingWidthFor(d.isCover) * 0.6, H = Math.min(0.01, this.m_Book.coverPaperSetup.thickness * 0.5), k = g.matrixWorld.clone().invert().multiply(i);
3177
+ for (let S = 0; S < M; S++) {
3178
+ const w = f[S], p = new u.Vector3(
3179
+ b + A * H,
3180
+ D + N * H,
3181
+ T.z + w
3182
+ ), V = new u.Vector3(b, D, T.z + w), z = T.clone();
3183
+ z.z += w;
3184
+ const U = d.getDirection(w).multiplyScalar(F).add(z.clone()), O = S * x, W = p.applyMatrix4(k), I = V.clone().applyMatrix4(k), y = U.clone().applyMatrix4(k), G = z.clone().applyMatrix4(k);
3185
+ m[O] = W, m[O + C[1]] = I;
3186
+ for (let R = 2; R < P; R++) {
3187
+ const L = nt(1, P, R);
3188
+ m[O + C[R]] = kt(
3189
+ I,
3190
+ y,
3191
+ G,
3192
+ L
3193
+ );
3194
+ }
3195
+ }
3196
+ }
3197
+ }
3198
+ // ── Getters ───────────────────────────────────────────────────────────
3199
+ get stackHeight() {
3200
+ return this.m_StackHeight;
3201
+ }
3202
+ get bindingVertexCount() {
3203
+ return this.m_BindingVertexCount;
3204
+ }
3205
+ get quality() {
3206
+ return this.m_Quality;
3207
+ }
3208
+ get setup() {
3209
+ return this.m_Setup;
3210
+ }
3211
+ dispose() {
3212
+ this.spineMesh.geometry.dispose();
3213
+ for (const e of this.m_CaseMaterials) e.dispose();
3214
+ this.m_CaseMaterials = [], this.m_OwnsClothMaterial && this.m_ClothMaterial && this.m_ClothMaterial.dispose(), this.m_ClothMaterial = null, this.spineMesh.parent && this.spineMesh.parent.remove(this.spineMesh);
3215
+ const t = this.m_Book.papers;
3216
+ this.m_Book.hasCover && t.length > 0 && (t[0].renderer.transform.visible = !0, t[t.length - 1].renderer.transform.visible = !0);
3217
+ }
3218
+ }
3219
+ class $e {
3220
+ constructor(t) {
3221
+ this.mesh = t;
3222
+ }
3223
+ setVisibility(t) {
3224
+ this.mesh.visible = t;
3225
+ }
3226
+ get castShadows() {
3227
+ return this.mesh.castShadow;
3228
+ }
3229
+ set castShadows(t) {
3230
+ this.mesh.castShadow = t;
3231
+ }
3232
+ get bounds() {
3233
+ const t = new u.Box3();
3234
+ return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
3235
+ }
3236
+ get transform() {
3237
+ return this.mesh;
3238
+ }
3239
+ get meshObject() {
3240
+ return this.mesh;
3241
+ }
3242
+ }
3243
+ class os extends ce {
3244
+ constructor() {
3245
+ super(...arguments), this.quality = 3, this.setup = new je();
3246
+ }
3247
+ createBound(t, e, s, i) {
3248
+ return new Qe(this.quality, this.setup, t, e);
3249
+ }
3250
+ }
3251
+ class ue {
2738
3252
  constructor(t) {
2739
3253
  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, this.shadowOffsetX = (t == null ? void 0 : t.shadowOffsetX) ?? 0, this.shadowOffsetY = (t == null ? void 0 : t.shadowOffsetY) ?? 0, this.textTransform = (t == null ? void 0 : t.textTransform) ?? "none", this.textDecoration = (t == null ? void 0 : t.textDecoration) ?? "none", this.background = (t == null ? void 0 : t.background) ?? "", this.backgroundPadding = (t == null ? void 0 : t.backgroundPadding) ?? 0, this.maxLines = (t == null ? void 0 : t.maxLines) ?? 0, this.height = (t == null ? void 0 : t.height) ?? 0, this.verticalAlign = (t == null ? void 0 : t.verticalAlign) ?? "top", this.rotation = (t == null ? void 0 : t.rotation) ?? 0;
2740
3254
  }
@@ -2762,12 +3276,12 @@ class Kt {
2762
3276
  continue;
2763
3277
  }
2764
3278
  const n = i.split(/\s+/);
2765
- let h = "";
2766
- for (const a of n) {
2767
- const o = h ? `${h} ${a}` : a;
2768
- t.measureText(o).width > this.width && h ? (s.push(h), h = a) : h = o;
3279
+ let r = "";
3280
+ for (const o of n) {
3281
+ const c = r ? `${r} ${o}` : o;
3282
+ t.measureText(c).width > this.width && r ? (s.push(r), r = o) : r = c;
2769
3283
  }
2770
- h && s.push(h);
3284
+ r && s.push(r);
2771
3285
  }
2772
3286
  return this._applyMaxLines(t, s);
2773
3287
  }
@@ -2792,8 +3306,8 @@ class Kt {
2792
3306
  hitTest(t, e, s) {
2793
3307
  const i = this.wrapLines(t);
2794
3308
  if (i.length === 0) return !1;
2795
- const n = i.length * this.fontSize * this.lineHeight, h = this.height > 0 ? this.height : n, a = this.width > 0 ? this.width : this._maxLineWidth(t, i);
2796
- return e >= this.x && e <= this.x + a && s >= this.y && s <= this.y + h;
3309
+ const n = i.length * this.fontSize * this.lineHeight, r = this.height > 0 ? this.height : n, o = this.width > 0 ? this.width : this._maxLineWidth(t, i);
3310
+ return e >= this.x && e <= this.x + o && s >= this.y && s <= this.y + r;
2797
3311
  }
2798
3312
  _maxLineWidth(t, e) {
2799
3313
  t.font = this._font();
@@ -2809,62 +3323,62 @@ class Kt {
2809
3323
  const e = this.wrapLines(t);
2810
3324
  if (e.length === 0) return;
2811
3325
  t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top";
2812
- const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e), n = e.length * s, h = this.height > 0 ? this.height : n;
3326
+ const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e), n = e.length * s, r = this.height > 0 ? this.height : n;
2813
3327
  if (this.rotation !== 0) {
2814
- const o = this.x + i / 2, u = this.y + h / 2;
2815
- t.translate(o, u), t.rotate(this.rotation), t.translate(-o, -u);
3328
+ const c = this.x + i / 2, l = this.y + r / 2;
3329
+ t.translate(c, l), t.rotate(this.rotation), t.translate(-c, -l);
2816
3330
  }
2817
3331
  this.background && (t.fillStyle = this.background, t.fillRect(
2818
3332
  this.x - this.backgroundPadding,
2819
3333
  this.y - this.backgroundPadding,
2820
3334
  i + this.backgroundPadding * 2,
2821
- h + this.backgroundPadding * 2
3335
+ r + this.backgroundPadding * 2
2822
3336
  ), t.fillStyle = this.color), this.shadowColor && this.shadowBlur > 0 && (t.shadowColor = this.shadowColor, t.shadowBlur = this.shadowBlur, t.shadowOffsetX = this.shadowOffsetX, t.shadowOffsetY = this.shadowOffsetY);
2823
- let a = this.y;
2824
- this.height > 0 && this.verticalAlign !== "top" && (this.verticalAlign === "middle" ? a = this.y + (this.height - n) / 2 : this.verticalAlign === "bottom" && (a = this.y + this.height - n));
2825
- for (let o = 0; o < e.length; o++) {
2826
- let u = this.x;
2827
- this.textAlign === "center" ? u = this.x + (i - t.measureText(e[o]).width) / 2 : this.textAlign === "right" && (u = this.x + i - t.measureText(e[o]).width);
2828
- const l = a + o * s;
2829
- if (t.fillText(e[o], u, l), this.textDecoration !== "none") {
2830
- const m = t.shadowColor, f = t.shadowBlur;
3337
+ let o = this.y;
3338
+ this.height > 0 && this.verticalAlign !== "top" && (this.verticalAlign === "middle" ? o = this.y + (this.height - n) / 2 : this.verticalAlign === "bottom" && (o = this.y + this.height - n));
3339
+ for (let c = 0; c < e.length; c++) {
3340
+ let l = this.x;
3341
+ this.textAlign === "center" ? l = this.x + (i - t.measureText(e[c]).width) / 2 : this.textAlign === "right" && (l = this.x + i - t.measureText(e[c]).width);
3342
+ const a = o + c * s;
3343
+ if (t.fillText(e[c], l, a), this.textDecoration !== "none") {
3344
+ const d = t.shadowColor, g = t.shadowBlur;
2831
3345
  t.shadowColor = "", t.shadowBlur = 0;
2832
- const d = t.measureText(e[o]).width;
3346
+ const _ = t.measureText(e[c]).width;
2833
3347
  if (t.beginPath(), t.strokeStyle = this.color, t.lineWidth = 1, this.textDecoration === "underline") {
2834
- const _ = l + this.fontSize + 2;
2835
- t.moveTo(u, _), t.lineTo(u + d, _);
3348
+ const m = a + this.fontSize + 2;
3349
+ t.moveTo(l, m), t.lineTo(l + _, m);
2836
3350
  } else if (this.textDecoration === "strikethrough") {
2837
- const _ = l + this.fontSize * 0.55;
2838
- t.moveTo(u, _), t.lineTo(u + d, _);
3351
+ const m = a + this.fontSize * 0.55;
3352
+ t.moveTo(l, m), t.lineTo(l + _, m);
2839
3353
  }
2840
- t.stroke(), t.shadowColor = m, t.shadowBlur = f;
3354
+ t.stroke(), t.shadowColor = d, t.shadowBlur = g;
2841
3355
  }
2842
3356
  }
2843
3357
  t.restore();
2844
3358
  }
2845
3359
  }
2846
- function Ae(r) {
2847
- return r.map instanceof c.Texture;
3360
+ function Ke(h) {
3361
+ return h.map instanceof u.Texture;
2848
3362
  }
2849
- function Jt(r, t) {
2850
- r.traverse((e) => {
3363
+ function me(h, t) {
3364
+ h.traverse((e) => {
2851
3365
  if (!e.isMesh) return;
2852
3366
  const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2853
3367
  for (const n of i)
2854
- Ae(n) && n.map.image === t && (n.map.needsUpdate = !0);
3368
+ Ke(n) && n.map.image === t && (n.map.needsUpdate = !0);
2855
3369
  });
2856
3370
  }
2857
- function te(r, t) {
2858
- 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), t.shadowOffsetX !== void 0 && (r.shadowOffsetX = t.shadowOffsetX), t.shadowOffsetY !== void 0 && (r.shadowOffsetY = t.shadowOffsetY), t.textTransform !== void 0 && (r.textTransform = t.textTransform), t.textDecoration !== void 0 && (r.textDecoration = t.textDecoration), t.background !== void 0 && (r.background = t.background), t.backgroundPadding !== void 0 && (r.backgroundPadding = t.backgroundPadding), t.maxLines !== void 0 && (r.maxLines = t.maxLines), t.height !== void 0 && (r.height = t.height), t.verticalAlign !== void 0 && (r.verticalAlign = t.verticalAlign), t.rotation !== void 0 && (r.rotation = t.rotation);
3371
+ function de(h, t) {
3372
+ t.x !== void 0 && (h.x = t.x), t.y !== void 0 && (h.y = t.y), t.width !== void 0 && (h.width = t.width), t.text !== void 0 && (h.text = t.text), t.fontFamily !== void 0 && (h.fontFamily = t.fontFamily), t.fontSize !== void 0 && (h.fontSize = t.fontSize), t.fontWeight !== void 0 && (h.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (h.fontStyle = t.fontStyle), t.color !== void 0 && (h.color = t.color), t.lineHeight !== void 0 && (h.lineHeight = t.lineHeight), t.textAlign !== void 0 && (h.textAlign = t.textAlign), t.opacity !== void 0 && (h.opacity = t.opacity), t.shadowColor !== void 0 && (h.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (h.shadowBlur = t.shadowBlur), t.shadowOffsetX !== void 0 && (h.shadowOffsetX = t.shadowOffsetX), t.shadowOffsetY !== void 0 && (h.shadowOffsetY = t.shadowOffsetY), t.textTransform !== void 0 && (h.textTransform = t.textTransform), t.textDecoration !== void 0 && (h.textDecoration = t.textDecoration), t.background !== void 0 && (h.background = t.background), t.backgroundPadding !== void 0 && (h.backgroundPadding = t.backgroundPadding), t.maxLines !== void 0 && (h.maxLines = t.maxLines), t.height !== void 0 && (h.height = t.height), t.verticalAlign !== void 0 && (h.verticalAlign = t.verticalAlign), t.rotation !== void 0 && (h.rotation = t.rotation);
2859
3373
  }
2860
- class Ne {
3374
+ class hs {
2861
3375
  constructor(t) {
2862
- this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0), this._dirty = !0;
3376
+ this.texts = [], this._textureST = new u.Vector4(1, 1, 0, 0), this._dirty = !0;
2863
3377
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
2864
3378
  this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
2865
3379
  const i = this.canvas.getContext("2d");
2866
3380
  if (!i) throw new Error("TextOverlayContent: could not get 2D context");
2867
- this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace;
3381
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new u.CanvasTexture(this.canvas), this._texture.colorSpace = u.SRGBColorSpace;
2868
3382
  }
2869
3383
  get texture() {
2870
3384
  return this._texture;
@@ -2885,7 +3399,7 @@ class Ne {
2885
3399
  }
2886
3400
  // ── Text API ─────────────────────────────────────────────────────────────
2887
3401
  addText(t) {
2888
- const e = new Kt(t);
3402
+ const e = new ue(t);
2889
3403
  return this.texts.push(e), this._dirty = !0, e;
2890
3404
  }
2891
3405
  removeText(t) {
@@ -2895,7 +3409,7 @@ class Ne {
2895
3409
  /** Update a text block by index. Only provided fields are changed. */
2896
3410
  updateText(t, e) {
2897
3411
  const s = this.texts[t];
2898
- s && (te(s, e), this._dirty = !0);
3412
+ s && (de(s, e), this._dirty = !0);
2899
3413
  }
2900
3414
  // ── Per-frame update ─────────────────────────────────────────────────────
2901
3415
  /**
@@ -2911,7 +3425,7 @@ class Ne {
2911
3425
  this._dirty = !1;
2912
3426
  const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2913
3427
  e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2914
- for (const h of this.texts) h.draw(e);
3428
+ for (const r of this.texts) r.draw(e);
2915
3429
  this._texture.needsUpdate = !0, t && this.syncMaterials(t);
2916
3430
  }
2917
3431
  /**
@@ -2919,7 +3433,7 @@ class Ne {
2919
3433
  * source image is this overlay's canvas.
2920
3434
  */
2921
3435
  syncMaterials(t) {
2922
- Jt(t, this.canvas);
3436
+ me(t, this.canvas);
2923
3437
  }
2924
3438
  // ── IPageContent ─────────────────────────────────────────────────────────
2925
3439
  isPointOverUI(t) {
@@ -2933,9 +3447,9 @@ class Ne {
2933
3447
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
2934
3448
  }
2935
3449
  }
2936
- class Xt {
3450
+ class ee {
2937
3451
  constructor(t, e) {
2938
- this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
3452
+ this._spread = t, this._textureST = e === "left" ? new u.Vector4(0.5, 1, 0, 0) : new u.Vector4(0.5, 1, 0.5, 0);
2939
3453
  }
2940
3454
  get texture() {
2941
3455
  return this._spread.texture;
@@ -2951,18 +3465,18 @@ class Xt {
2951
3465
  setActive(t) {
2952
3466
  }
2953
3467
  }
2954
- function Xe(r) {
3468
+ function as(h) {
2955
3469
  const t = [];
2956
- for (let e = 1; e + 1 < r; e += 2)
3470
+ for (let e = 1; e + 1 < h; e += 2)
2957
3471
  t.push(e);
2958
3472
  return t;
2959
3473
  }
2960
- class We {
3474
+ class cs {
2961
3475
  constructor(t) {
2962
3476
  this.texts = [], this._dirty = !0, this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2963
3477
  const e = this.canvas.getContext("2d");
2964
3478
  if (!e) throw new Error("SpreadContent: could not get 2D context");
2965
- this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new Xt(this, "left"), this.right = new Xt(this, "right");
3479
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new u.CanvasTexture(this.canvas), this._texture.colorSpace = u.SRGBColorSpace, this.left = new ee(this, "left"), this.right = new ee(this, "right");
2966
3480
  }
2967
3481
  get texture() {
2968
3482
  return this._texture;
@@ -2980,7 +3494,7 @@ class We {
2980
3494
  }
2981
3495
  // ── Text API ─────────────────────────────────────────────────────────────
2982
3496
  addText(t) {
2983
- const e = new Kt(t);
3497
+ const e = new ue(t);
2984
3498
  return this.texts.push(e), this._dirty = !0, e;
2985
3499
  }
2986
3500
  removeText(t) {
@@ -2990,7 +3504,7 @@ class We {
2990
3504
  /** Update a text block by index. Only provided fields are changed. */
2991
3505
  updateText(t, e) {
2992
3506
  const s = this.texts[t];
2993
- s && (te(s, e), this._dirty = !0);
3507
+ s && (de(s, e), this._dirty = !0);
2994
3508
  }
2995
3509
  // ── Per-frame update ─────────────────────────────────────────────────────
2996
3510
  /**
@@ -3005,7 +3519,7 @@ class We {
3005
3519
  this._dirty = !1;
3006
3520
  const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
3007
3521
  e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
3008
- for (const h of this.texts) h.draw(e);
3522
+ for (const r of this.texts) r.draw(e);
3009
3523
  this._texture.needsUpdate = !0, t && this.syncMaterials(t);
3010
3524
  }
3011
3525
  /**
@@ -3013,114 +3527,117 @@ class We {
3013
3527
  * source image is this spread's canvas.
3014
3528
  */
3015
3529
  syncMaterials(t) {
3016
- Jt(t, this.canvas);
3530
+ me(t, this.canvas);
3017
3531
  }
3018
3532
  // ── Lifecycle ────────────────────────────────────────────────────────────
3019
3533
  dispose() {
3020
3534
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
3021
3535
  }
3022
3536
  }
3023
- const Wt = 256;
3024
- function He(r, t, e, s, i, n, h) {
3025
- const a = t.naturalWidth || t.width, o = t.naturalHeight || t.height;
3026
- if (a <= 0 || o <= 0) return;
3027
- if (h === "fill") {
3028
- r.drawImage(t, e, s, i, n);
3537
+ const se = 256;
3538
+ function Je(h, t, e, s, i, n, r) {
3539
+ const o = t.naturalWidth || t.width, c = t.naturalHeight || t.height;
3540
+ if (o <= 0 || c <= 0) return;
3541
+ if (r === "fill") {
3542
+ h.drawImage(t, e, s, i, n);
3029
3543
  return;
3030
3544
  }
3031
- const u = h === "contain" ? Math.min(i / a, n / o) : Math.max(i / a, n / o), l = a * u, m = o * u;
3032
- r.drawImage(t, e + (i - l) * 0.5, s + (n - m) * 0.5, l, m);
3545
+ const l = r === "contain" ? Math.min(i / o, n / c) : Math.max(i / o, n / c), a = o * l, d = c * l;
3546
+ h.drawImage(t, e + (i - a) * 0.5, s + (n - d) * 0.5, a, d);
3033
3547
  }
3034
- function Ge(r, t, e, s, i) {
3035
- const n = i ? 0 : Math.round(Math.min(t, e) * 0.11), h = n, a = n, o = t - n * 2, u = e - n * 2, l = r.naturalWidth || r.width, m = r.naturalHeight || r.height;
3036
- if (s === "fill" || l <= 0 || m <= 0)
3037
- return { x: h, y: a, width: o, height: u };
3038
- const f = s === "contain" ? Math.min(o / l, u / m) : Math.max(o / l, u / m), d = l * f, _ = m * f;
3548
+ function ls(h, t, e, s, i) {
3549
+ const n = i ? 0 : Math.round(Math.min(t, e) * 0.11), r = n, o = n, c = t - n * 2, l = e - n * 2, a = h.naturalWidth || h.width, d = h.naturalHeight || h.height;
3550
+ if (s === "fill" || a <= 0 || d <= 0)
3551
+ return { x: r, y: o, width: c, height: l };
3552
+ const g = s === "contain" ? Math.min(c / a, l / d) : Math.max(c / a, l / d), _ = a * g, m = d * g;
3039
3553
  return {
3040
- x: h + (o - d) * 0.5,
3041
- y: a + (u - _) * 0.5,
3042
- width: d,
3043
- height: _
3554
+ x: r + (c - _) * 0.5,
3555
+ y: o + (l - m) * 0.5,
3556
+ width: _,
3557
+ height: m
3044
3558
  };
3045
3559
  }
3046
- function Fe(r, t, e, s, i, n, h, a) {
3047
- const o = n ? Math.round(n * Wt) : 512, u = h ? Math.round(h * Wt) : 512, l = document.createElement("canvas");
3048
- l.width = o, l.height = u;
3049
- const m = l.getContext("2d");
3050
- if (m.fillStyle = r, m.fillRect(0, 0, o, u), e)
3051
- if (a)
3052
- m.drawImage(e, a.x, a.y, a.width, a.height);
3560
+ function ts(h, t, e, s, i, n, r, o) {
3561
+ const c = n ? Math.round(n * se) : 512, l = r ? Math.round(r * se) : 512, a = document.createElement("canvas");
3562
+ a.width = c, a.height = l;
3563
+ const d = a.getContext("2d");
3564
+ if (d.fillStyle = h, d.fillRect(0, 0, c, l), e)
3565
+ if (o)
3566
+ d.drawImage(e, o.x, o.y, o.width, o.height);
3053
3567
  else {
3054
- const f = i ? 0 : Math.round(Math.min(o, u) * 0.11);
3055
- He(m, e, f, f, o - f * 2, u - f * 2, s);
3568
+ const g = i ? 0 : Math.round(Math.min(c, l) * 0.11);
3569
+ Je(d, e, g, g, c - g * 2, l - g * 2, s);
3056
3570
  }
3057
3571
  else {
3058
- m.fillStyle = "#333";
3059
- const f = Math.round(Math.min(o, u) * 0.094);
3060
- m.font = `bold ${f}px Arial`, m.textAlign = "center", m.textBaseline = "middle", m.fillText(t, o / 2, u / 2);
3572
+ d.fillStyle = "#333";
3573
+ const g = Math.round(Math.min(c, l) * 0.094);
3574
+ d.font = `bold ${g}px Arial`, d.textAlign = "center", d.textBaseline = "middle", d.fillText(t, c / 2, l / 2);
3061
3575
  }
3062
- return l;
3576
+ return a;
3063
3577
  }
3064
- function je(r, t, e, s, i, n, h, a) {
3065
- const o = Fe(r, t, e, s, i, n, h, a), u = new c.CanvasTexture(o);
3066
- return u.colorSpace = c.SRGBColorSpace, u;
3578
+ function us(h, t, e, s, i, n, r, o) {
3579
+ const c = ts(h, t, e, s, i, n, r, o), l = new u.CanvasTexture(c);
3580
+ return l.colorSpace = u.SRGBColorSpace, l;
3067
3581
  }
3068
- async function qe(r) {
3069
- if (!r) return null;
3070
- const t = URL.createObjectURL(r), e = new Image();
3582
+ async function ms(h) {
3583
+ if (!h) return null;
3584
+ const t = URL.createObjectURL(h), e = new Image();
3071
3585
  e.decoding = "async", e.src = t;
3072
3586
  try {
3073
3587
  return await new Promise((s, i) => {
3074
- e.onload = () => s(), e.onerror = () => i(new Error(`Failed to decode image: ${r.name}`));
3588
+ e.onload = () => s(), e.onerror = () => i(new Error(`Failed to decode image: ${h.name}`));
3075
3589
  }), { image: e, objectUrl: t };
3076
3590
  } catch (s) {
3077
3591
  return URL.revokeObjectURL(t), console.error(s), null;
3078
3592
  }
3079
3593
  }
3080
3594
  export {
3081
- pe as AnimationCurve,
3082
- yt as AutoTurnDirection,
3083
- ut as AutoTurnMode,
3084
- at as AutoTurnSetting,
3085
- ge as AutoTurnSettingCurveTimeMode,
3086
- fe as AutoTurnSettingMode,
3087
- Zt as AutoTurnSettings,
3088
- wt as Book,
3089
- ye as BookBinding,
3090
- we as BookBound,
3091
- Ze as BookContent,
3092
- j as BookDirection,
3093
- xe as BookHeightException,
3094
- Ue as BookPointerInteraction,
3095
- _e as BookRenderer,
3096
- Ct as Cylinder,
3097
- ce as MeshFactory,
3098
- Wt as PX_PER_UNIT,
3099
- Le as PageContent,
3100
- oe as Paper,
3101
- Tt as PaperBorder,
3102
- zt as PaperMaterialData,
3103
- Ot as PaperMeshData,
3104
- de as PaperMeshDataPool,
3105
- Oe as PaperMeshUtility,
3106
- ht as PaperNode,
3107
- le as PaperNodeMargin,
3108
- Me as PaperPattern,
3109
- Pt as PaperSeam,
3110
- rt as PaperSetup,
3111
- gt as PaperUVMargin,
3112
- ue as RendererFactory,
3113
- We as SpreadContent,
3114
- Ut as SpritePageContent2,
3115
- Ee as StapleBookBinding,
3116
- Ve as StapleBookBound,
3117
- Ie as StapleSetup,
3118
- Kt as TextBlock,
3119
- Ne as TextOverlayContent,
3120
- Ge as computeDefaultImageRect,
3121
- Fe as createPageCanvas,
3122
- je as createPageTexture,
3123
- He as drawImageWithFit,
3124
- Xe as getSpreadPairs,
3125
- qe as loadImage
3595
+ be as AnimationCurve,
3596
+ Tt as AutoTurnDirection,
3597
+ gt as AutoTurnMode,
3598
+ lt as AutoTurnSetting,
3599
+ ke as AutoTurnSettingCurveTimeMode,
3600
+ ve as AutoTurnSettingMode,
3601
+ qt as AutoTurnSettings,
3602
+ vt as Book,
3603
+ ce as BookBinding,
3604
+ le as BookBound,
3605
+ is as BookContent,
3606
+ it as BookDirection,
3607
+ oe as BookHeightException,
3608
+ ns as BookPointerInteraction,
3609
+ Se as BookRenderer,
3610
+ bt as Cylinder,
3611
+ os as HardcoverBookBinding,
3612
+ Qe as HardcoverBookBound,
3613
+ je as HardcoverSetup,
3614
+ Ce as MeshFactory,
3615
+ se as PX_PER_UNIT,
3616
+ ss as PageContent,
3617
+ ye as Paper,
3618
+ Mt as PaperBorder,
3619
+ Xt as PaperMaterialData,
3620
+ Wt as PaperMeshData,
3621
+ Te as PaperMeshDataPool,
3622
+ es as PaperMeshUtility,
3623
+ ot as PaperNode,
3624
+ ie as PaperNodeMargin,
3625
+ he as PaperPattern,
3626
+ Bt as PaperSeam,
3627
+ ct as PaperSetup,
3628
+ wt as PaperUVMargin,
3629
+ we as RendererFactory,
3630
+ cs as SpreadContent,
3631
+ jt as SpritePageContent2,
3632
+ rs as StapleBookBinding,
3633
+ Le as StapleBookBound,
3634
+ Ze as StapleSetup,
3635
+ ue as TextBlock,
3636
+ hs as TextOverlayContent,
3637
+ ls as computeDefaultImageRect,
3638
+ ts as createPageCanvas,
3639
+ us as createPageTexture,
3640
+ Je as drawImageWithFit,
3641
+ as as getSpreadPairs,
3642
+ ms as loadImage
3126
3643
  };