@objectifthunes/three-book 0.7.0 → 0.8.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 u from "three";
2
- class bt {
1
+ import * as l from "three";
2
+ class It {
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 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();
4
+ this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new l.Vector3(), this._scratchRP1 = new l.Vector3(), this._scratchRP2 = new l.Vector3(), this._scratchRollClosest = new l.Vector3(), this._scratchRollEuler = new l.Vector3(), this._scratchOffsetRoll = new l.Vector3();
5
5
  }
6
6
  // ── Properties ────────────────────────────────────────────────────────
7
7
  /** Returns internal vector — do NOT mutate. Copy if you need to store it. */
@@ -33,8 +33,8 @@ class bt {
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, 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);
36
+ const n = s * Math.PI / 180, r = e * Math.PI / 180, o = Math.cos(n), h = Math.sin(n), u = t * o, c = t * h, d = 0, f = Math.cos(r), g = Math.sin(r), m = u * f + d * g, _ = c, p = -u * g + d * f;
37
+ return i.set(m, _, p);
38
38
  }
39
39
  /**
40
40
  * Rolls `point` in place around the cylinder. Mutates and returns `point`.
@@ -78,145 +78,145 @@ class bt {
78
78
  }
79
79
  // ── Value-type clone ──────────────────────────────────────────────────
80
80
  clone() {
81
- const t = new bt();
81
+ const t = new It();
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 yt(h, t, e, s, i = 1 / 0, n = 1 / 60) {
85
+ function vt(a, t, e, s, i = 1 / 0, n = 1 / 60) {
86
86
  s = Math.max(s, 1e-4);
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,
87
+ const r = 2 / s, o = r * n, h = 1 / (1 + o + 0.48 * o * o + 0.235 * o * o * o);
88
+ let u = a - t;
89
+ const c = t, d = i * s;
90
+ u = l.MathUtils.clamp(u, -d, d), t = a - u;
91
+ const f = (e + r * u) * n;
92
+ e = (e - r * f) * h;
93
+ let g = t + (u + f) * h;
94
+ return c - a > 0 == g > c && (g = c, e = (g - c) / n), { value: g, velocity: e };
95
+ }
96
+ function Pe(a, t, e, s, i = 1 / 0, n = 1 / 60) {
97
+ const r = vt(
98
+ a.x,
99
99
  t.x,
100
100
  e.x,
101
101
  s.x,
102
102
  i,
103
103
  n
104
- ), o = yt(
105
- h.y,
104
+ ), o = vt(
105
+ a.y,
106
106
  t.y,
107
107
  e.y,
108
108
  s.y,
109
109
  i,
110
110
  n
111
- ), c = yt(
112
- h.z,
111
+ ), h = vt(
112
+ a.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(r.velocity, o.velocity, c.velocity), h.set(r.value, o.value, c.value);
119
+ return e.set(r.velocity, o.velocity, h.velocity), a.set(r.value, o.value, h.value);
120
120
  }
121
- function zt(h, t, e) {
122
- const s = t * t - 4 * h * e;
121
+ function Zt(a, t, e) {
122
+ const s = t * t - 4 * a * 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 * h), root1: 0 };
126
+ return { rootCount: 1, root0: -t / (2 * a), root1: 0 };
127
127
  {
128
128
  const i = Math.sqrt(s);
129
129
  return {
130
130
  rootCount: 2,
131
- root0: (-t + i) / (2 * h),
132
- root1: (-t - i) / (2 * h)
131
+ root0: (-t + i) / (2 * a),
132
+ root1: (-t - i) / (2 * a)
133
133
  };
134
134
  }
135
135
  }
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,
136
+ const Xt = new l.Vector2();
137
+ function Lt(a, t, e, s) {
138
+ return Se(a, t, e) ? s.copy(a) : (Xt.set(a.x, t.y), Te(
139
+ Xt,
140
+ a,
141
141
  t,
142
142
  e,
143
143
  s
144
144
  ));
145
145
  }
146
- function fe(h, t, e) {
147
- const s = h.x - t.x;
148
- let i = h.y - t.y;
146
+ function Se(a, t, e) {
147
+ const s = a.x - t.x;
148
+ let i = a.y - t.y;
149
149
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
150
150
  }
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) {
151
+ function Te(a, t, e, s, i) {
152
+ const n = e.x, r = e.y, o = a.x, h = a.y, u = t.x, c = t.y, d = s.x, f = s.y, g = 1 / (d * d), m = 1 / (f * f);
153
+ if (Math.abs(o - u) < 1e-5) {
154
154
  if (o >= n - d && o <= n + d) {
155
- const f = zt(
155
+ const _ = Zt(
156
156
  m,
157
157
  -2 * m * r,
158
- _ * (o * o - 2 * n * o + n * n) + m * r * r - 1
158
+ g * (o * o - 2 * n * o + n * n) + m * r * r - 1
159
159
  );
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);
160
+ if (_.rootCount === 1)
161
+ return i.set(o, _.root0);
162
+ if (_.rootCount === 2) {
163
+ let p = _.root0, M = _.root1;
164
+ return h < c && ([p, M] = [M, p]), i.set(o, M);
165
165
  }
166
166
  }
167
167
  } else {
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
168
+ const _ = (c - h) / (u - o), p = h - _ * o, M = p - r, C = Zt(
169
+ g + m * _ * _,
170
+ 2 * M * _ * m - 2 * n * g,
171
+ n * n * g + M * M * m - 1
172
172
  );
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);
173
+ if (C.rootCount === 1)
174
+ return i.set(C.root0, _ * C.root0 + p);
175
+ if (C.rootCount === 2) {
176
+ let y = C.root0, P = C.root1;
177
+ return o < u && ([y, P] = [P, y]), i.set(P, _ * P + p);
178
178
  }
179
179
  }
180
- return i.copy(h);
180
+ return i.copy(a);
181
181
  }
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;
182
+ const kt = new l.Vector3(), Nt = new l.Vector3(), Ut = new l.Ray();
183
+ function Et(a, t) {
184
+ return kt.copy(a.origin).applyMatrix4(t), Nt.copy(a.origin).add(a.direction).applyMatrix4(t), Ut.set(kt, Nt.sub(kt).normalize()), Ut;
185
185
  }
186
- function pe(h) {
187
- const t = h.x;
188
- h.set(-t, h.y, h.z + t, h.w);
186
+ function ve(a) {
187
+ const t = a.x;
188
+ a.set(-t, a.y, a.z + t, a.w);
189
189
  }
190
- function xe(h) {
191
- const t = h.y;
192
- h.set(h.x, -t, h.z, h.w + t);
190
+ function ke(a) {
191
+ const t = a.y;
192
+ a.set(a.x, -t, a.z, a.w + t);
193
193
  }
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;
194
+ var mt = /* @__PURE__ */ ((a) => (a[a.LeftToRight = 0] = "LeftToRight", a[a.RightToLeft = 1] = "RightToLeft", a[a.UpToDown = 2] = "UpToDown", a[a.DownToUp = 3] = "DownToUp", a))(mt || {});
195
+ const ot = Math.PI / 180, ut = 180 / Math.PI;
196
+ function q(a, t, e) {
197
+ return a < t ? t : a > e ? e : a;
198
198
  }
199
- function st(h) {
200
- return h < 0 ? 0 : h > 1 ? 1 : h;
199
+ function at(a) {
200
+ return a < 0 ? 0 : a > 1 ? 1 : a;
201
201
  }
202
- function E(h, t, e) {
203
- return e = st(e), h + (t - h) * e;
202
+ function G(a, t, e) {
203
+ return e = at(e), a + (t - a) * e;
204
204
  }
205
- function Zt(h, t, e) {
206
- return h + (t - h) * e;
205
+ function Wt(a, t, e) {
206
+ return a + (t - a) * e;
207
207
  }
208
- function nt(h, t, e) {
209
- return h !== t ? st((e - h) / (t - h)) : 0;
208
+ function ht(a, t, e) {
209
+ return a !== t ? at((e - a) / (t - a)) : 0;
210
210
  }
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);
211
+ var wt = /* @__PURE__ */ ((a) => (a[a.Surface = 0] = "Surface", a[a.Edge = 1] = "Edge", a))(wt || {});
212
+ const be = 1192093e-13;
213
+ function Gt(a, t, e) {
214
+ return e = at((e - a) / (t - a)), e * e * (3 - 2 * e);
215
215
  }
216
- class ye {
216
+ class Be {
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 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;
219
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new l.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Rigid = !1, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new It(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new l.Plane(), this.m_StartHandle = new l.Vector3(), this.m_CurrentHandle = new l.Vector3(), this.m_EndHandle = new l.Vector3(), this.m_PrevHandle = new l.Vector3(), this.m_HandleOffset = new l.Vector3(), this.m_HandleVelocity = new l.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new l.Vector3(), this._ucCurrentHandle = new l.Vector3(), this._ucHandleDir = new l.Vector3(), this._ucA = new l.Vector3(), this._ucB = new l.Vector3(), this._ucMid = new l.Vector3(), this._ucRollResult = new l.Vector3(), this._ucCylDir = new l.Vector3(), this._utV1 = new l.Vector3(), this._utV2 = new l.Vector3(), this._utV3 = new l.Vector3(), this._utV4 = new l.Vector3(), this._chP = new l.Vector3(), this._chA = new l.Vector3(), this._chC = new l.Vector3(), this._chEllipseCenter1 = new l.Vector2(), this._chEllipseCenter2 = new l.Vector2(), this._chEllipseSize1 = new l.Vector2(), this._chEllipseSize2 = new l.Vector2(), this._chP2 = new l.Vector2(), this._dirResult = new l.Vector3(), this._gdA = new l.Vector3(), this._gdB = new l.Vector3(), this._rlMatrix = new l.Matrix4(), this._rlPlane = new l.Plane(new l.Vector3(0, 1, 0), 0), this._rlTarget = new l.Vector3(), this._rlNormal = new l.Vector3(), this._utTarget = new l.Vector3(), this._ufSmoothTime = new l.Vector3(), this._umFrontST = new l.Vector4(), this._umBackST = new l.Vector4(), this._h2uResult = new l.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
220
220
  }
221
221
  // ---- Properties (mirrors C#) ----
222
222
  get isMeshChanged() {
@@ -256,7 +256,7 @@ class ye {
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 * Q, s = Math.cos(e), i = Math.sin(e);
259
+ const e = this.zTime * 180 * ot, s = Math.cos(e), i = Math.sin(e);
260
260
  return this._dirResult.set(-s, -i, 0);
261
261
  }
262
262
  get isTurning() {
@@ -333,8 +333,8 @@ class ye {
333
333
  this.m_TurningRadius = Math.max(this.m_Size.x * 50, this.m_MinTurningRadius);
334
334
  return;
335
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(
336
+ let e = Math.max(this.m_Stiffness, 1 - at(t));
337
+ e <= 0.5 ? this.m_TurningRadius = ht(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - ht(0.5, 1, e)), 5) * ot), this.m_TurningRadius = Math.max(
338
338
  this.m_TurningRadius,
339
339
  this.m_MinTurningRadius
340
340
  );
@@ -342,7 +342,7 @@ class ye {
342
342
  startTurning(t) {
343
343
  var i, n;
344
344
  const e = t.clone();
345
- t = Ot(
345
+ t = Et(
346
346
  t,
347
347
  this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
348
348
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
@@ -368,10 +368,10 @@ class ye {
368
368
  }
369
369
  stopTurning() {
370
370
  this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
371
- const t = new u.Vector3(0, 0, 0);
371
+ const t = new l.Vector3(0, 0, 0);
372
372
  for (const e of this.m_HandleVelocities)
373
373
  t.add(e);
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);
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 = G(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);
375
375
  }
376
376
  /**
377
377
  * Called each frame while the user is dragging.
@@ -395,14 +395,14 @@ class ye {
395
395
  var s, i;
396
396
  let e = !1;
397
397
  if (this.m_IsAutoTurning) {
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(
398
+ let n = at(this.m_FallTime / this.m_FallDuration);
399
+ n = Gt(0, 1, n), n = Gt(0, 1, n), this.m_CurrentHandle.lerpVectors(
400
400
  this.m_StartHandle,
401
401
  this.m_EndHandle,
402
402
  this.m_IsFallingLeft ? n : 1 - n
403
- ), this.m_FallTime += t, e = Math.abs(n - 1) < Me;
403
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < be;
404
404
  } else
405
- this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), _e(
405
+ this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), Pe(
406
406
  this.m_CurrentHandle,
407
407
  this.m_EndHandle,
408
408
  this.m_HandleVelocity,
@@ -429,12 +429,12 @@ class ye {
429
429
  }
430
430
  getTextureCoordinate(t) {
431
431
  const e = this.raycastLocal(t, !0);
432
- return e !== null ? this.hit2UV(e) : new u.Vector2(0, 0);
432
+ return e !== null ? this.hit2UV(e) : new l.Vector2(0, 0);
433
433
  }
434
434
  raycast(t) {
435
435
  const e = {
436
- point: new u.Vector3(),
437
- textureCoordinate: new u.Vector2(),
436
+ point: new l.Vector3(),
437
+ textureCoordinate: new l.Vector2(),
438
438
  pageContent: null,
439
439
  paperIndex: 0,
440
440
  pageIndex: 0
@@ -448,12 +448,12 @@ class ye {
448
448
  }
449
449
  hit2UV(t) {
450
450
  const e = this._h2uResult.set(
451
- nt(-this.sizeXOffset, this.m_Size.x, t.x),
451
+ ht(-this.sizeXOffset, this.m_Size.x, t.x),
452
452
  t.z / this.m_Size.y
453
453
  );
454
454
  this.m_UVMargin.fixUV(e);
455
455
  const s = this.m_Book.direction;
456
- if (s === it.UpToDown || s === it.DownToUp) {
456
+ if (s === mt.UpToDown || s === mt.DownToUp) {
457
457
  const i = e.x;
458
458
  e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
459
459
  } else
@@ -465,7 +465,7 @@ class ye {
465
465
  * Returns the local-space hit point, or null if no hit / out of bounds.
466
466
  */
467
467
  raycastLocal(t, e = !1) {
468
- t = Ot(
468
+ t = Et(
469
469
  t,
470
470
  this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
471
471
  ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
@@ -503,7 +503,7 @@ class ye {
503
503
  t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
504
504
  ), this.m_SubMeshCount = t);
505
505
  const e = this._umFrontST.copy(this.m_FrontContent.textureST), s = this._umBackST.copy(this.m_BackContent.textureST);
506
- this.m_Book.direction > 1 ? xe(s) : pe(s);
506
+ this.m_Book.direction > 1 ? ke(s) : ve(s);
507
507
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
508
508
  if (t === 3) {
509
509
  let r = 0, o = 1;
@@ -546,7 +546,7 @@ class ye {
546
546
  const t = this.findTime(this._utV1);
547
547
  this._utV2.set(this.m_Size.x, 0, this.m_Size.y);
548
548
  const e = this.findTime(this._utV2);
549
- this.m_XTime = E(
549
+ this.m_XTime = G(
550
550
  Math.min(t, e),
551
551
  Math.max(t, e),
552
552
  0.9
@@ -559,26 +559,26 @@ class ye {
559
559
  this._utV3.set(s[1], 0, i[i.length - 1]);
560
560
  const o = this.rollPoint(this._utV3);
561
561
  this._utV4.set(s[2], 0, i[i.length - 1]);
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;
562
+ const h = this.rollPoint(this._utV4), u = r.x - n.x, c = r.y - n.y, d = h.x - o.x, f = h.y - o.y, g = Math.sqrt(u * u + c * c) || 1, m = Math.sqrt(d * d + f * f) || 1, _ = ut * Math.atan2(c / g, u / g), p = ut * Math.atan2(f / m, d / m), M = (_ + p) / 2;
563
563
  this.m_ZTime = M / 180;
564
564
  } else
565
565
  this.m_XTime = 0, this.m_ZTime = 0;
566
566
  }
567
567
  findTime(t) {
568
- return t = this.rollPoint(t), nt(this.m_Size.x, -this.m_Size.x, t.x);
568
+ return t = this.rollPoint(t), ht(this.m_Size.x, -this.m_Size.x, t.x);
569
569
  }
570
570
  clampHandle() {
571
571
  this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
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(
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), h = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
573
573
  0,
574
- c + (e.z - c) * (r / i)
575
- ), a = this._chEllipseCenter2.set(
574
+ h + (e.z - h) * (r / i)
575
+ ), c = this._chEllipseCenter2.set(
576
576
  0,
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);
577
+ h + (s.z - h) * (o / n)
578
+ ), d = this._chEllipseSize1.set(i, r), f = this._chEllipseSize2.set(n, o);
579
+ t.x = q(t.x, -this.m_Size.x, this.m_Size.x);
580
+ const g = this._chP2.set(t.x, t.z);
581
+ Lt(g, u, d, g), Lt(g, c, f, g), this.m_CurrentHandle.set(g.x, 0, g.y);
582
582
  }
583
583
  updateCylinder() {
584
584
  const t = this._ucStartHandle.copy(this.m_StartHandle), e = this._ucCurrentHandle.copy(this.m_CurrentHandle), s = this._ucHandleDir.copy(t).sub(e).normalize();
@@ -589,35 +589,35 @@ class ye {
589
589
  this.m_Cylinder.radius = this.m_TurningRadius, this._ucCylDir.set(-s.z, 0, s.x), this.m_Cylinder.direction = this._ucCylDir;
590
590
  for (let o = 0; o < 100; o++) {
591
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);
592
+ const h = this.m_Cylinder.rollPoint(this._ucRollResult);
593
+ if (Math.abs(e.x - h.x) < 1e-4) break;
594
+ h.x > e.x ? r.copy(this.m_Cylinder.position) : n.copy(this.m_Cylinder.position);
595
595
  }
596
596
  }
597
597
  rollPoint(t) {
598
598
  return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
599
599
  }
600
600
  startAutoTurning(t, e, s, i) {
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) {
601
+ var u, c;
602
+ if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === wt.Surface) {
603
603
  const d = this.m_Transform.scale;
604
604
  d.x *= -1;
605
605
  }
606
606
  this.switchMeshData(
607
607
  0
608
608
  /* Highpoly */
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;
609
+ ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (c = this.m_Next) == null || c.trySwitchMeshData(1), this.m_IsFallingLeft = t === wt.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
610
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;
611
+ e = q(e, -0.99, 0.99);
612
+ const o = Wt(0.5, 1, e), h = Wt(0.5, 0, e);
613
+ this.m_StartHandle.set(n, 0, r * o), this.m_EndHandle.set(-n, 0, r * h), this.m_IsAutoTurning = !0;
614
614
  }
615
615
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
616
616
  get cylinder() {
617
617
  return this.m_Cylinder;
618
618
  }
619
619
  }
620
- const rt = class rt {
620
+ const dt = class dt {
621
621
  constructor() {
622
622
  this.m_Left = 0, this.m_Right = 0, this.m_Down = 0, this.m_Up = 0;
623
623
  }
@@ -648,7 +648,7 @@ const rt = class rt {
648
648
  }
649
649
  // ── Helpers ───────────────────────────────────────────────────────────
650
650
  clamp(t) {
651
- return Math.max(rt.kMin, Math.min(t, rt.kMax));
651
+ return Math.max(dt.kMin, Math.min(t, dt.kMax));
652
652
  }
653
653
  // ── Transform ─────────────────────────────────────────────────────────
654
654
  /**
@@ -656,18 +656,18 @@ const rt = class rt {
656
656
  * book direction.
657
657
  */
658
658
  transform(t) {
659
- const e = new rt();
659
+ const e = new dt();
660
660
  switch (t) {
661
- case it.LeftToRight:
661
+ case mt.LeftToRight:
662
662
  e.m_Left = this.m_Left, e.m_Right = this.m_Right, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
663
663
  break;
664
- case it.RightToLeft:
664
+ case mt.RightToLeft:
665
665
  e.m_Left = this.m_Right, e.m_Right = this.m_Left, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
666
666
  break;
667
- case it.UpToDown:
667
+ case mt.UpToDown:
668
668
  e.m_Left = this.m_Up, e.m_Right = this.m_Down, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
669
669
  break;
670
- case it.DownToUp:
670
+ case mt.DownToUp:
671
671
  default:
672
672
  e.m_Left = this.m_Down, e.m_Right = this.m_Up, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
673
673
  break;
@@ -682,7 +682,7 @@ const rt = class rt {
682
682
  * Unity's `Mathf.InverseLerp(a, b, v)` = `(v - a) / (b - a)` clamped to [0,1].
683
683
  */
684
684
  fixUV(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;
685
+ return t.x = dt.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = dt.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
686
686
  }
687
687
  static inverseLerp(t, e, s) {
688
688
  if (t === e) return 0;
@@ -691,15 +691,15 @@ const rt = class rt {
691
691
  }
692
692
  // ── Value-type clone ──────────────────────────────────────────────────
693
693
  clone() {
694
- const t = new rt();
694
+ const t = new dt();
695
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;
696
696
  }
697
697
  };
698
- rt.kMin = 0, rt.kMax = 0.25;
699
- let wt = rt;
700
- const $ = class $ {
698
+ dt.kMin = 0, dt.kMax = 0.25;
699
+ let bt = dt;
700
+ const ct = class ct {
701
701
  constructor(t) {
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);
702
+ this.m_Material = null, this.m_Color = new l.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Rigid = !1, this.m_Quality = 0, this.m_UVMargin = new bt(), this.margin = 0, this.bookDirection = mt.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new l.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? ct.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? ct.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? ct.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);
703
703
  }
704
704
  // ── Properties ────────────────────────────────────────────────────────
705
705
  get material() {
@@ -718,19 +718,19 @@ const $ = class $ {
718
718
  return this.bookDirection > 1 ? this.m_Height : this.m_Width;
719
719
  }
720
720
  set width(t) {
721
- this.m_Width = Math.max(t, $.kMinSize);
721
+ this.m_Width = Math.max(t, ct.kMinSize);
722
722
  }
723
723
  get height() {
724
724
  return this.bookDirection > 1 ? this.m_Width : this.m_Height;
725
725
  }
726
726
  set height(t) {
727
- this.m_Height = Math.max(t, $.kMinSize);
727
+ this.m_Height = Math.max(t, ct.kMinSize);
728
728
  }
729
729
  get thickness() {
730
730
  return this.m_Thickness;
731
731
  }
732
732
  set thickness(t) {
733
- this.m_Thickness = Math.max(t, $.kMinThickness);
733
+ this.m_Thickness = Math.max(t, ct.kMinThickness);
734
734
  }
735
735
  get stiffness() {
736
736
  return this.m_Stiffness;
@@ -749,8 +749,8 @@ const $ = class $ {
749
749
  }
750
750
  set quality(t) {
751
751
  this.m_Quality = Math.max(
752
- $.kMinQuality,
753
- Math.min(t, $.kMaxQuality)
752
+ ct.kMinQuality,
753
+ Math.min(t, ct.kMaxQuality)
754
754
  );
755
755
  }
756
756
  get uvMargin() {
@@ -760,15 +760,15 @@ const $ = class $ {
760
760
  this.m_UVMargin = t;
761
761
  }
762
762
  get size() {
763
- return new u.Vector2(this.width, this.height);
763
+ return new l.Vector2(this.width, this.height);
764
764
  }
765
765
  };
766
- $.kMinSize = 1, $.kMinThickness = 1e-4, $.kMinQuality = 1, $.kMaxQuality = 5;
767
- let ct = $;
768
- class Xt {
766
+ ct.kMinSize = 1, ct.kMinThickness = 1e-4, ct.kMinQuality = 1, ct.kMaxQuality = 5;
767
+ let ft = ct;
768
+ class qt {
769
769
  constructor(t) {
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();
770
+ this.m_Texture = null, this.m_TextureST = new l.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
771
+ const e = t.material ?? new l.MeshStandardMaterial();
772
772
  this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
773
773
  }
774
774
  get materials1() {
@@ -803,15 +803,15 @@ class Xt {
803
803
  this.m_Texture = t, this.m_TextureST.copy(e), this._propertyBlockDirty = !0;
804
804
  }
805
805
  }
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);
806
+ function jt(a, t, e, s = new l.Vector3()) {
807
+ let i = t.x - a.x, n = t.y - a.y, r = t.z - a.z, o = 1 / Math.sqrt(i * i + n * n + r * r);
808
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);
809
+ let h = e.x - a.x, u = e.y - a.y, c = e.z - a.z;
810
+ o = 1 / Math.sqrt(h * h + u * u + c * c), h *= o, u *= o, c *= o;
811
+ const d = n * c - r * u, f = r * h - i * c, g = i * u - n * h;
812
+ return o = 1 / Math.sqrt(d * d + f * f + g * g), s.set(d * o, f * o, g * o);
813
813
  }
814
- class ot {
814
+ class _t {
815
815
  constructor(t, e = !1, s = !1) {
816
816
  this.prev = null, this.next = null, this.index = 0, this.value = t, this.hole = e, this.seam = s;
817
817
  }
@@ -830,7 +830,7 @@ class ot {
830
830
  }
831
831
  // ── Factory helpers ───────────────────────────────────────────────────
832
832
  createNext(t, e = !1, s = !1) {
833
- const i = new ot(t, e, s);
833
+ const i = new _t(t, e, s);
834
834
  return i.prev = this, this.next = i, i;
835
835
  }
836
836
  // ── Insertion (sorted linked-list insert) ─────────────────────────────
@@ -862,21 +862,21 @@ class ot {
862
862
  t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
863
863
  }
864
864
  }
865
- class Bt {
865
+ class At {
866
866
  constructor(t, e, s, i) {
867
867
  this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
868
868
  }
869
869
  clone() {
870
- const t = new Bt(this.prevIndex, this.index, this.nextIndex, this.time);
870
+ const t = new At(this.prevIndex, this.index, this.nextIndex, this.time);
871
871
  return t.active = this.active, t;
872
872
  }
873
873
  }
874
- class Mt {
874
+ class Tt {
875
875
  constructor(t, e, s, i, n, r = !0) {
876
876
  this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = r;
877
877
  }
878
878
  clone() {
879
- return new Mt(
879
+ return new Tt(
880
880
  this.startX,
881
881
  this.startZ,
882
882
  this.endX,
@@ -886,157 +886,157 @@ class Mt {
886
886
  );
887
887
  }
888
888
  }
889
- class ie {
889
+ class ce {
890
890
  constructor(t, e, s) {
891
891
  const i = t.size;
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);
892
+ this.leftNode = new _t(e.left * i.x, s, !0), this.rightNode = new _t((1 - e.right) * i.x, s, !0), this.downNode = new _t(e.down * i.y, s, !0), this.upNode = new _t((1 - e.up) * i.y, s, !0);
893
893
  }
894
894
  insert(t, e, s, i) {
895
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);
896
896
  }
897
897
  }
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);
898
+ function Mt(a, t) {
899
+ for (const e of a) {
900
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = ht(s.value, i.value, e.value), r = new At(s.index, e.index, i.index, n);
901
901
  t.push(r);
902
902
  }
903
903
  }
904
- function Pt(h, t, e, s, i) {
905
- for (const n of h)
904
+ function Bt(a, t, e, s, i) {
905
+ for (const n of a)
906
906
  if (n.active)
907
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);
908
+ const o = n.prevIndex, h = n.nextIndex, u = t[r * e + o], c = t[r * e + h], d = t[r * e + n.index];
909
+ i ? le(u, c, n.time, d) : d.copy(u).lerp(c, n.time);
910
910
  }
911
911
  }
912
- function St(h, t, e, s, i) {
913
- for (const n of h)
912
+ function Rt(a, t, e, s, i) {
913
+ for (const n of a)
914
914
  if (n.active)
915
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);
916
+ const o = n.prevIndex, h = n.nextIndex, u = t[o * e + r], c = t[h * e + r], d = t[n.index * e + r];
917
+ i ? le(u, c, n.time, d) : d.copy(u).lerp(c, n.time);
918
918
  }
919
919
  }
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);
920
+ function le(a, t, e, s = new l.Vector3()) {
921
+ const i = Math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
922
922
  if (i === 0 || n === 0)
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;
923
+ return s.copy(a).lerp(t, e);
924
+ const r = a.x / i, o = a.y / i, h = a.z / i, u = t.x / n, c = t.y / n, d = t.z / n;
925
+ let f = r * u + o * c + h * d;
926
+ f = Math.max(-1, Math.min(1, f));
927
+ const g = Math.acos(f);
928
+ if (g < 1e-6)
929
+ return s.copy(a).lerp(t, e);
930
+ const m = Math.sin(g), _ = Math.sin((1 - e) * g) / m, p = Math.sin(e * g) / m, M = i + (n - i) * e;
931
931
  return s.set(
932
- (r * f + l * x) * M,
933
- (o * f + a * x) * M,
934
- (c * f + d * x) * M
932
+ (r * _ + u * p) * M,
933
+ (o * _ + c * p) * M,
934
+ (h * _ + d * p) * M
935
935
  );
936
936
  }
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);
937
+ function Ht(a, t, e, s, i) {
938
+ for (const n of a) {
939
+ const r = (n.endX - n.startX + 1) * 2, o = (n.endZ - n.startZ + 1) * 2, h = e.length;
940
+ for (let c = 0, d = n.endX - n.startX; c < d; c++) {
941
+ const f = h + c * 2 + 0, g = h + c * 2 + 1, m = h + c * 2 + 2, _ = h + c * 2 + 3;
942
+ n.flip ? Qt(t, f, g, m, _, r) : Yt(t, f, g, m, _, r);
943
943
  }
944
944
  if (n.left)
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);
945
+ for (let c = 0, d = n.endZ - n.startZ; c < d; c++) {
946
+ const f = h + c * 2 + 0 + r * 2, g = h + c * 2 + 1 + r * 2, m = h + c * 2 + 2 + r * 2, _ = h + c * 2 + 3 + r * 2;
947
+ n.flip ? Qt(t, f, g, m, _, o) : Yt(t, f, g, m, _, o);
948
948
  }
949
949
  else
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);
950
+ for (let c = 0, d = n.endZ - n.startZ; c < d; c++) {
951
+ const f = h + c * 2 + 0 + r * 2 + o, g = h + c * 2 + 1 + r * 2 + o, m = h + c * 2 + 2 + r * 2 + o, _ = h + c * 2 + 3 + r * 2 + o;
952
+ n.flip ? St(t, f, g, m, _) : Pt(t, f, g, m, _);
953
953
  }
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());
954
+ const u = s * i;
955
+ for (let c = n.startX; c <= n.endX; c++) {
956
+ const d = n.startZ * s + c;
957
+ e.push(e[d].clone()), e.push(e[d + u].clone());
958
958
  }
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());
959
+ for (let c = n.startX; c <= n.endX; c++) {
960
+ const d = c + n.endZ * s;
961
+ e.push(e[d + u].clone()), e.push(e[d].clone());
962
962
  }
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());
963
+ for (let c = n.startZ; c <= n.endZ; c++) {
964
+ const d = n.startX + c * s;
965
+ e.push(e[d + u].clone()), e.push(e[d].clone());
966
966
  }
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());
967
+ for (let c = n.startZ; c <= n.endZ; c++) {
968
+ const d = c * s + n.endX;
969
+ e.push(e[d].clone()), e.push(e[d + u].clone());
970
970
  }
971
971
  }
972
972
  }
973
- function re(h, t, e, s, i) {
973
+ function ue(a, t, e, s, i) {
974
974
  const n = s * i;
975
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]);
976
+ const o = new l.Vector3();
977
+ for (const h of a) {
978
+ for (let u = h.startX; u <= h.endX; u++) {
979
+ const c = u + h.startZ * s, d = t[c], f = t[c + s];
980
+ o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[c + n]);
981
981
  }
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]);
982
+ for (let u = h.startX; u <= h.endX; u++) {
983
+ const c = u + h.endZ * s, d = t[c + n], f = t[c + n - s];
984
+ o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[c]);
985
985
  }
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]);
986
+ for (let u = h.startZ; u <= h.endZ; u++) {
987
+ const c = u * s + h.startX, d = t[c + n], f = t[c + n + 1];
988
+ o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[c]);
989
989
  }
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]);
990
+ for (let u = h.startZ; u <= h.endZ; u++) {
991
+ const c = u * s + h.endX, d = t[c], f = t[c - 1];
992
+ o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[r].copy(o), t[r++].copy(d), e[r].copy(o), t[r++].copy(t[c + n]);
993
993
  }
994
994
  }
995
995
  }
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);
996
+ function Yt(a, t, e, s, i, n) {
997
+ Pt(a, t, e, s, i), t += n, e += n, s += n, i += n, Pt(a, t, e, s, i);
998
998
  }
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);
999
+ function Qt(a, t, e, s, i, n) {
1000
+ St(a, t, e, s, i), t += n, e += n, s += n, i += n, St(a, t, e, s, i);
1001
1001
  }
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);
1002
+ function Ft(a, t, e, s, i, n, r) {
1003
+ Pt(a, e, s, i, n), e += r, s += r, i += r, n += r, St(t, e, s, i, n);
1004
1004
  }
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;
1005
+ function Ot(a, t, e, s, i, n) {
1006
+ const r = i.left * s.x, o = (1 - i.right) * s.x, h = i.down * s.y, u = (1 - i.up) * s.y, c = t.length, d = e.length;
1007
1007
  if (n > 1)
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));
1008
+ for (let g = 0; g < d; g++)
1009
+ for (let m = 0; m < c; m++) {
1010
+ const _ = ht(o, r, t[m]), p = ht(u, h, e[g]);
1011
+ a.push(new l.Vector2(p, _));
1012
1012
  }
1013
1013
  else
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));
1014
+ for (let g = 0; g < d; g++)
1015
+ for (let m = 0; m < c; m++) {
1016
+ const _ = ht(r, o, t[m]), p = ht(u, h, e[g]);
1017
+ a.push(new l.Vector2(_, p));
1018
1018
  }
1019
- const g = h.length;
1020
- for (let _ = 0; _ < g; _++)
1021
- h.push(h[_].clone());
1019
+ const f = a.length;
1020
+ for (let g = 0; g < f; g++)
1021
+ a.push(a[g].clone());
1022
1022
  }
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);
1023
+ function Pt(a, t, e, s, i) {
1024
+ a.push(t), a.push(s), a.push(e), a.push(e), a.push(s), a.push(i);
1025
1025
  }
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);
1026
+ function St(a, t, e, s, i) {
1027
+ a.push(t), a.push(e), a.push(s), a.push(e), a.push(i), a.push(s);
1028
1028
  }
1029
- const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1029
+ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1030
1030
  __proto__: null,
1031
- addBorders: Rt,
1032
- addFrontAndBackFaces: Vt,
1033
- addFrontAndBackTexcoords: Dt,
1034
- seamNodesToSeams: dt,
1035
- updateBorders: re,
1036
- updateXSeams: Pt,
1037
- updateZSeams: St
1031
+ addBorders: Ht,
1032
+ addFrontAndBackFaces: Ft,
1033
+ addFrontAndBackTexcoords: Ot,
1034
+ seamNodesToSeams: Mt,
1035
+ updateBorders: ue,
1036
+ updateXSeams: Bt,
1037
+ updateZSeams: Rt
1038
1038
  }, Symbol.toStringTag, { value: "Module" }));
1039
- class Wt {
1039
+ class $t {
1040
1040
  get geometry() {
1041
1041
  return this.m_Geometry;
1042
1042
  }
@@ -1049,33 +1049,33 @@ class Wt {
1049
1049
  constructor(t, e) {
1050
1050
  this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1051
1051
  for (let r = 0; r < e.baseVertexCount; r++)
1052
- this.m_BaseVertices[r] = new u.Vector3();
1052
+ this.m_BaseVertices[r] = new l.Vector3();
1053
1053
  this.m_Vertices = new Array(e.vertexCount);
1054
1054
  for (let r = 0; r < e.vertexCount; r++)
1055
- this.m_Vertices[r] = new u.Vector3();
1055
+ this.m_Vertices[r] = new l.Vector3();
1056
1056
  this.m_Normals = new Array(e.vertexCount);
1057
1057
  for (let r = 0; r < e.vertexCount; r++)
1058
- this.m_Normals[r] = new u.Vector3();
1058
+ this.m_Normals[r] = new l.Vector3();
1059
1059
  if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1060
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);
1061
+ this.m_Geometry.setIndex(new l.BufferAttribute(r, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1062
1062
  } else {
1063
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));
1064
+ let h = 0;
1065
+ o.set(e.frontTriangles, h), this.m_Geometry.addGroup(h, e.frontTriangles.length, 0), h += e.frontTriangles.length, o.set(e.backTriangles, h), this.m_Geometry.addGroup(h, e.backTriangles.length, 1), h += e.backTriangles.length, o.set(e.borderTriangles, h), this.m_Geometry.addGroup(h, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new l.BufferAttribute(o, 1));
1066
1066
  }
1067
1067
  const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1068
1068
  for (let r = 0; r < e.texcoords.length; r++)
1069
1069
  n[r * 2] = e.texcoords[r].x, n[r * 2 + 1] = e.texcoords[r].y;
1070
1070
  this.m_Geometry.setAttribute(
1071
1071
  "position",
1072
- new u.BufferAttribute(s, 3)
1072
+ new l.BufferAttribute(s, 3)
1073
1073
  ), this.m_Geometry.setAttribute(
1074
1074
  "normal",
1075
- new u.BufferAttribute(i, 3)
1075
+ new l.BufferAttribute(i, 3)
1076
1076
  ), this.m_Geometry.setAttribute(
1077
1077
  "uv",
1078
- new u.BufferAttribute(n, 2)
1078
+ new l.BufferAttribute(n, 2)
1079
1079
  ), this.updateBaseVertices();
1080
1080
  }
1081
1081
  // ── UpdateBaseVertices ──────────────────────────────────────────────────
@@ -1088,9 +1088,9 @@ class Wt {
1088
1088
  updateBaseVertices() {
1089
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
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]);
1091
+ for (let h = 0; h < r; h++)
1092
+ for (let u = 0; u < n; u++)
1093
+ t[o++].set(e[u] + i, 0, s[h]);
1094
1094
  }
1095
1095
  // ── UpdateMesh ─────────────────────────────────────────────────────────
1096
1096
  /**
@@ -1109,49 +1109,49 @@ class Wt {
1109
1109
  * Ported from lines ~2185-2255.
1110
1110
  */
1111
1111
  updateMesh() {
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();
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, h = new l.Vector3(), u = new l.Vector3(), c = new l.Vector3();
1113
1113
  for (let m = 0; m < o; m++)
1114
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);
1115
+ Bt(this.m_Pattern.xSeams, t, n, r, !1), Rt(this.m_Pattern.zSeams, t, n, r, !1);
1116
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);
1117
+ const _ = m + 1;
1118
+ for (let p = 0; p < n - 1; p++) {
1119
+ const M = p + 1, C = m * n + p, y = m * n + M, P = _ * n + p, B = _ * n + M, D = t[C], H = t[y], z = t[P], E = t[B];
1120
+ jt(D, z, H, h), jt(E, H, z, u), c.addVectors(h, u), s[C].add(c), s[y].add(c), s[P].add(c), s[B].add(c);
1121
1121
  }
1122
1122
  }
1123
1123
  for (let m = 0; m < o; m++)
1124
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);
1125
+ Bt(this.m_Pattern.xSeams, s, n, r, !0), Rt(this.m_Pattern.zSeams, s, n, r, !0);
1126
1126
  const d = this.m_Pattern.thickness / 2;
1127
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);
1128
+ const _ = s[m];
1129
+ s[m + o].copy(_).negate();
1130
+ const p = t[m];
1131
+ e[m].copy(p).addScaledVector(_, d), e[m + o].copy(p).addScaledVector(_, -d);
1132
1132
  }
1133
- re(this.m_Pattern.borders, e, s, n, r);
1134
- const g = this.m_Geometry.getAttribute(
1133
+ ue(this.m_Pattern.borders, e, s, n, r);
1134
+ const f = this.m_Geometry.getAttribute(
1135
1135
  "position"
1136
- ), _ = this.m_Geometry.getAttribute(
1136
+ ), g = this.m_Geometry.getAttribute(
1137
1137
  "normal"
1138
1138
  );
1139
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);
1140
+ const _ = e[m];
1141
+ f.setXYZ(m, _.x, _.y, _.z);
1142
+ const p = s[m];
1143
+ g.setXYZ(m, p.x, p.y, p.z);
1144
1144
  }
1145
- g.needsUpdate = !0, _.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1145
+ f.needsUpdate = !0, g.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1146
1146
  }
1147
1147
  }
1148
- class Ce {
1148
+ class Re {
1149
1149
  constructor() {
1150
1150
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1151
1151
  }
1152
1152
  get() {
1153
1153
  let 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;
1154
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new l.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1155
1155
  }
1156
1156
  recycle() {
1157
1157
  for (const t of this.m_UsedMeshs)
@@ -1164,7 +1164,7 @@ class Ce {
1164
1164
  this.m_Meshs.clear();
1165
1165
  }
1166
1166
  }
1167
- class we {
1167
+ class Ve {
1168
1168
  constructor(t) {
1169
1169
  this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1170
1170
  }
@@ -1173,7 +1173,7 @@ class we {
1173
1173
  }
1174
1174
  get(t) {
1175
1175
  let 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;
1176
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new De(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1177
1177
  }
1178
1178
  recycle() {
1179
1179
  for (const t of this.m_UsedRenderers)
@@ -1186,23 +1186,23 @@ class we {
1186
1186
  this.m_Renderers.clear();
1187
1187
  }
1188
1188
  getBounds() {
1189
- const t = new u.Box3();
1189
+ const t = new l.Box3();
1190
1190
  let e = !0;
1191
1191
  for (const s of this.m_UsedRenderers)
1192
1192
  e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1193
1193
  return t;
1194
1194
  }
1195
1195
  }
1196
- let Pe = 1;
1197
- class Se {
1196
+ let ze = 1;
1197
+ class De {
1198
1198
  constructor(t, e) {
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()
1199
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ze++, this.m_Object3D = new l.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new l.Mesh(
1200
+ new l.BufferGeometry(),
1201
+ new l.MeshStandardMaterial()
1202
1202
  ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D);
1203
1203
  }
1204
1204
  get bounds() {
1205
- const t = new u.Box3();
1205
+ const t = new l.Box3();
1206
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;
1207
1207
  }
1208
1208
  get id() {
@@ -1230,12 +1230,12 @@ class Se {
1230
1230
  return this.m_Mesh;
1231
1231
  }
1232
1232
  setMaterials(t) {
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();
1233
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new l.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1234
1234
  }
1235
1235
  setPropertyBlock(t, e) {
1236
1236
  this.m_PropertyBlocks.set(e, t);
1237
1237
  const s = this.getMaterial(e);
1238
- s && (this.isMapCapable(s) && (t.map instanceof u.Texture ? this.applyTextureProperty(
1238
+ s && (this.isMapCapable(s) && (t.map instanceof l.Texture ? this.applyTextureProperty(
1239
1239
  s,
1240
1240
  e,
1241
1241
  t.map,
@@ -1243,10 +1243,10 @@ class Se {
1243
1243
  ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && s.color.copy(t.color));
1244
1244
  }
1245
1245
  reset(t) {
1246
- this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new u.BufferGeometry(), this.setMaterials([]);
1246
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.setMaterials([]);
1247
1247
  }
1248
1248
  clear() {
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);
1249
+ this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1250
1250
  }
1251
1251
  destroy() {
1252
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);
@@ -1261,7 +1261,7 @@ class Se {
1261
1261
  return "map" in t;
1262
1262
  }
1263
1263
  isColorCapable(t) {
1264
- return "color" in t && t.color instanceof u.Color;
1264
+ return "color" in t && t.color instanceof l.Color;
1265
1265
  }
1266
1266
  getSTKey(t) {
1267
1267
  return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
@@ -1274,7 +1274,7 @@ class Se {
1274
1274
  }
1275
1275
  this.clearManagedTexture(e);
1276
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, {
1277
+ o.needsUpdate = !0, i && (o.repeat.set(i.x, i.y), o.offset.set(i.z, i.w), o.wrapS = l.RepeatWrapping, o.wrapT = l.RepeatWrapping), t.map = o, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1278
1278
  source: s,
1279
1279
  texture: o,
1280
1280
  stKey: n
@@ -1298,20 +1298,20 @@ class Se {
1298
1298
  e.dispose();
1299
1299
  }
1300
1300
  }
1301
- class Te {
1301
+ class Ie {
1302
1302
  constructor(t, e, s = !1) {
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());
1303
+ this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new $t(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1304
1304
  }
1305
1305
  get() {
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);
1306
+ return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new $t(this.m_MeshFactory.get(), this.m_Pattern);
1307
1307
  }
1308
1308
  free(t) {
1309
1309
  if (this.m_UseSharedData) throw new Error("Not implemented");
1310
1310
  this.m_Stack.push(t);
1311
1311
  }
1312
1312
  }
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 {
1313
+ var Vt = /* @__PURE__ */ ((a) => (a[a.Next = 0] = "Next", a[a.Back = 1] = "Back", a))(Vt || {}), Ae = /* @__PURE__ */ ((a) => (a[a.Constant = 0] = "Constant", a[a.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", a[a.Curve = 2] = "Curve", a[a.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", a))(Ae || {}), He = /* @__PURE__ */ ((a) => (a[a.PaperIndexTime = 0] = "PaperIndexTime", a[a.TurnIndexTime = 1] = "TurnIndexTime", a))(He || {});
1314
+ class Fe {
1315
1315
  constructor(t) {
1316
1316
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1317
1317
  }
@@ -1333,10 +1333,10 @@ class be {
1333
1333
  return e[s - 1].value;
1334
1334
  }
1335
1335
  }
1336
- function Gt(h, t) {
1337
- return h + Math.random() * (t - h);
1336
+ function Kt(a, t) {
1337
+ return a + Math.random() * (t - a);
1338
1338
  }
1339
- class lt {
1339
+ class gt {
1340
1340
  constructor(t, e) {
1341
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));
1342
1342
  }
@@ -1391,12 +1391,12 @@ class lt {
1391
1391
  }
1392
1392
  /** A value based on a curve. */
1393
1393
  static fromCurve(t, e) {
1394
- const s = new lt();
1394
+ const s = new gt();
1395
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;
1396
1396
  }
1397
1397
  /** A random value generated between two curves. */
1398
1398
  static fromCurveRange(t, e, s) {
1399
- const i = new lt();
1399
+ const i = new gt();
1400
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;
1401
1401
  }
1402
1402
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1404,12 +1404,12 @@ class lt {
1404
1404
  getValue(t, e) {
1405
1405
  if (this.m_Mode === 0) return this.m_Constant;
1406
1406
  if (this.m_Mode === 1)
1407
- return Gt(this.m_ConstantMin, this.m_ConstantMax);
1407
+ return Kt(this.m_ConstantMin, this.m_ConstantMax);
1408
1408
  const s = this.m_CurveTimeMode === 0 ? t : e;
1409
1409
  if (this.m_Mode === 2)
1410
1410
  return this.m_Curve.evaluate(s);
1411
1411
  if (this.m_Mode === 3)
1412
- return Gt(
1412
+ return Kt(
1413
1413
  this.m_CurveMin.evaluate(s),
1414
1414
  this.m_CurveMax.evaluate(s)
1415
1415
  );
@@ -1417,31 +1417,31 @@ class lt {
1417
1417
  }
1418
1418
  /** @internal */
1419
1419
  clampValues(t, e) {
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;
1420
+ return this.m_Constant = q(this.m_Constant, t, e), this.m_ConstantMin = q(this.m_ConstantMin, t, e), this.m_ConstantMax = q(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;
1421
1421
  }
1422
1422
  clampCurve(t, e, s) {
1423
1423
  if (this.m_Curve === null || t === null) return null;
1424
- const i = t.keys.map((c) => ({ time: c.time, value: c.value })), n = i.length;
1424
+ const i = t.keys.map((h) => ({ time: h.time, value: h.value })), n = i.length;
1425
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);
1426
+ for (let h = 0; h < n; h++) {
1427
+ const u = i[h].time;
1428
+ r = Math.min(r, u), o = Math.max(o, u);
1429
1429
  }
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;
1430
+ for (let h = 0; h < n; h++) {
1431
+ let u = i[h].time, c = i[h].value;
1432
+ u = ht(r, o, u), c = q(c, e, s), i[h].time = u, i[h].value = c;
1433
1433
  }
1434
- return new be(i);
1434
+ return new Fe(i);
1435
1435
  }
1436
1436
  // ── Value-type clone ────────────────────────────────────────────────────
1437
1437
  clone() {
1438
- const t = new lt();
1438
+ const t = new gt();
1439
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;
1440
1440
  }
1441
1441
  }
1442
- const j = class j {
1442
+ const et = class et {
1443
1443
  constructor() {
1444
- this.m_Mode = gt.Surface, this.m_Twist = new lt(), this.m_Bend = new lt(1), this.m_Duration = new lt(0.5);
1444
+ this.m_Mode = wt.Surface, this.m_Twist = new gt(), this.m_Bend = new gt(1), this.m_Duration = new gt(0.5);
1445
1445
  }
1446
1446
  // ── Properties ──────────────────────────────────────────────────────────
1447
1447
  get mode() {
@@ -1455,8 +1455,8 @@ const j = class j {
1455
1455
  }
1456
1456
  set twist(t) {
1457
1457
  this.m_Twist = t.clampValues(
1458
- j.kMinTwist,
1459
- j.kMaxTwist
1458
+ et.kMinTwist,
1459
+ et.kMaxTwist
1460
1460
  );
1461
1461
  }
1462
1462
  get bend() {
@@ -1464,8 +1464,8 @@ const j = class j {
1464
1464
  }
1465
1465
  set bend(t) {
1466
1466
  this.m_Bend = t.clampValues(
1467
- j.kMinBend,
1468
- j.kMaxBend
1467
+ et.kMinBend,
1468
+ et.kMaxBend
1469
1469
  );
1470
1470
  }
1471
1471
  get duration() {
@@ -1473,8 +1473,8 @@ const j = class j {
1473
1473
  }
1474
1474
  set duration(t) {
1475
1475
  this.m_Duration = t.clampValues(
1476
- j.kMinDuration,
1477
- j.kMaxDuration
1476
+ et.kMinDuration,
1477
+ et.kMaxDuration
1478
1478
  );
1479
1479
  }
1480
1480
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1484,73 +1484,73 @@ const j = class j {
1484
1484
  }
1485
1485
  /** @internal */
1486
1486
  getBendValue(t, e) {
1487
- return Z(
1487
+ return q(
1488
1488
  this.m_Bend.getValue(t, e),
1489
- j.kMinBend,
1490
- j.kMaxBend
1489
+ et.kMinBend,
1490
+ et.kMaxBend
1491
1491
  );
1492
1492
  }
1493
1493
  /** @internal */
1494
1494
  getDurationValue(t, e) {
1495
- return Z(
1495
+ return q(
1496
1496
  this.m_Duration.getValue(t, e),
1497
- j.kMinDuration,
1498
- j.kMaxDuration
1497
+ et.kMinDuration,
1498
+ et.kMaxDuration
1499
1499
  );
1500
1500
  }
1501
1501
  /** @internal */
1502
1502
  getTwistValue(t, e) {
1503
- return Z(
1503
+ return q(
1504
1504
  this.m_Twist.getValue(t, e),
1505
- j.kMinTwist,
1506
- j.kMaxTwist
1505
+ et.kMinTwist,
1506
+ et.kMaxTwist
1507
1507
  );
1508
1508
  }
1509
1509
  };
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 {
1510
+ et.kMinTwist = -1, et.kMaxTwist = 1, et.kMinBend = 0, et.kMaxBend = 1, et.kMinDuration = 0, et.kMaxDuration = 5;
1511
+ let Jt = et;
1512
+ class me extends Error {
1513
1513
  constructor() {
1514
1514
  super(
1515
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."
1516
1516
  );
1517
1517
  }
1518
1518
  }
1519
- const K = class K extends u.Group {
1519
+ const lt = class lt extends l.Group {
1520
1520
  // ── Constructor ────────────────────────────────────────────────────────
1521
1521
  constructor(t) {
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),
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 ft({
1523
+ color: new l.Color(1, 0, 0),
1524
1524
  width: 2.1,
1525
1525
  height: 3.1,
1526
1526
  thickness: 0.04,
1527
1527
  stiffness: 0.5
1528
- }), this.m_PagePaperSetup = new ct({
1529
- color: new u.Color(1, 1, 1),
1528
+ }), this.m_PagePaperSetup = new ft({
1529
+ color: new l.Color(1, 1, 1),
1530
1530
  width: 2,
1531
1531
  height: 3,
1532
1532
  thickness: 0.02,
1533
1533
  stiffness: 0.2
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),
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 = mt.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = l.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new ft({
1535
+ color: t.coverPaperSetup.color ?? new l.Color(1, 0, 0),
1536
1536
  width: t.coverPaperSetup.width ?? 2.1,
1537
1537
  height: t.coverPaperSetup.height ?? 3.1,
1538
1538
  thickness: t.coverPaperSetup.thickness ?? 0.04,
1539
1539
  stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1540
1540
  rigid: t.coverPaperSetup.rigid ?? !1,
1541
1541
  material: t.coverPaperSetup.material ?? null
1542
- })), t.pagePaperSetup && (this.m_PagePaperSetup = new ct({
1543
- color: t.pagePaperSetup.color ?? new u.Color(1, 1, 1),
1542
+ })), t.pagePaperSetup && (this.m_PagePaperSetup = new ft({
1543
+ color: t.pagePaperSetup.color ?? new l.Color(1, 1, 1),
1544
1544
  width: t.pagePaperSetup.width ?? 2,
1545
1545
  height: t.pagePaperSetup.height ?? 3,
1546
1546
  thickness: t.pagePaperSetup.thickness ?? 0.02,
1547
1547
  stiffness: t.pagePaperSetup.stiffness ?? 0.2,
1548
1548
  rigid: t.pagePaperSetup.rigid ?? !1,
1549
1549
  material: t.pagePaperSetup.material ?? null
1550
- }))), K.s_Instances.add(this), K.s_InstancesArray = null;
1550
+ }))), lt.s_Instances.add(this), lt.s_InstancesArray = null;
1551
1551
  }
1552
1552
  static get instances() {
1553
- return K.s_InstancesArray === null && (K.s_InstancesArray = [...K.s_Instances]), K.s_InstancesArray;
1553
+ return lt.s_InstancesArray === null && (lt.s_InstancesArray = [...lt.s_Instances]), lt.s_InstancesArray;
1554
1554
  }
1555
1555
  // ── Internal accessors ─────────────────────────────────────────────────
1556
1556
  get minPaperWidth() {
@@ -1616,7 +1616,7 @@ const K = class K extends u.Group {
1616
1616
  }
1617
1617
  set coverPaperSetup(t) {
1618
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({
1619
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === r && e.rigid === o || (this.m_CoverPaperSetup = new ft({
1620
1620
  color: t.color ?? e.color,
1621
1621
  width: s,
1622
1622
  height: i,
@@ -1631,7 +1631,7 @@ const K = class K extends u.Group {
1631
1631
  }
1632
1632
  set pagePaperSetup(t) {
1633
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({
1634
+ e.width === s && e.height === i && e.thickness === n && e.stiffness === r && e.rigid === o || (this.m_PagePaperSetup = new ft({
1635
1635
  color: t.color ?? e.color,
1636
1636
  width: s,
1637
1637
  height: i,
@@ -1670,7 +1670,7 @@ const K = class K extends u.Group {
1670
1670
  return this.m_InitialOpenProgress;
1671
1671
  }
1672
1672
  set initialOpenProgress(t) {
1673
- this.m_InitialOpenProgress = u.MathUtils.clamp(t, 0, 1);
1673
+ this.m_InitialOpenProgress = l.MathUtils.clamp(t, 0, 1);
1674
1674
  }
1675
1675
  get isBuilt() {
1676
1676
  return this.m_IsBuilt;
@@ -1730,7 +1730,7 @@ const K = class K extends u.Group {
1730
1730
  }
1731
1731
  getActivePaperSideIndices(t) {
1732
1732
  if (t.clear(), !this.m_IsBuilt) return;
1733
- const e = this.m_Content.direction === it.RightToLeft, s = this.m_Papers.length, i = (n, r) => {
1733
+ const e = this.m_Content.direction === mt.RightToLeft, s = this.m_Papers.length, i = (n, r) => {
1734
1734
  let o = n * 2;
1735
1735
  r && o++, e && (o = s * 2 - o - 1), t.add(o);
1736
1736
  };
@@ -1752,7 +1752,7 @@ const K = class K extends u.Group {
1752
1752
  */
1753
1753
  setOpenProgress(t) {
1754
1754
  this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1755
- const e = this.m_Papers.length, s = Math.round(u.MathUtils.lerp(0, e, t));
1755
+ const e = this.m_Papers.length, s = Math.round(l.MathUtils.lerp(0, e, t));
1756
1756
  for (let i = 0; i < e; i++) {
1757
1757
  const n = i >= s;
1758
1758
  this.m_Papers[i].restState(n);
@@ -1777,11 +1777,11 @@ const K = class K extends u.Group {
1777
1777
  startAutoTurning(t, e, s = 1, i = 0) {
1778
1778
  if (!this.m_IsBuilt) return !1;
1779
1779
  this.cancelPendingAutoTurns();
1780
- const n = typeof i == "number" ? new lt(i) : i;
1780
+ const n = typeof i == "number" ? new gt(i) : i;
1781
1781
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1782
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 });
1783
+ const o = r / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), u = r > 0 ? n.getValue(h, o) : 0, c = e.getModeValue(), d = e.getTwistValue(h, o), f = e.getBendValue(h, o), g = e.getDurationValue(h, o);
1784
+ this.m_AutoTurnQueue.push({ direction: t, mode: c, twist: d, bend: f, duration: g, delay: u });
1785
1785
  }
1786
1786
  return this.m_AutoTurnTimer = 0, this._frontPapersCache = null, !0;
1787
1787
  }
@@ -1809,7 +1809,7 @@ const K = class K extends u.Group {
1809
1809
  if (this.isTurning) return null;
1810
1810
  const e = this.getFrontPapers();
1811
1811
  if (e.length > 0) {
1812
- const s = t === Tt.Next, i = e[s ? e.length - 1 : 0];
1812
+ const s = t === Vt.Next, i = e[s ? e.length - 1 : 0];
1813
1813
  if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
1814
1814
  return i;
1815
1815
  }
@@ -1819,7 +1819,7 @@ const K = class K extends u.Group {
1819
1819
  const e = this.getAutoTurnPaper(t);
1820
1820
  if (e === null) return 0;
1821
1821
  let s = 1;
1822
- return t === Tt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1822
+ return t === Vt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1823
1823
  }
1824
1824
  canAutoTurn(t) {
1825
1825
  return this.getAutoTurnPaper(t) !== null;
@@ -1835,7 +1835,7 @@ const K = class K extends u.Group {
1835
1835
  */
1836
1836
  init() {
1837
1837
  var t;
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);
1838
+ lt.s_Instances.add(this), lt.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);
1839
1839
  }
1840
1840
  /**
1841
1841
  * Call every frame with delta time in seconds.
@@ -1872,52 +1872,52 @@ const K = class K extends u.Group {
1872
1872
  * it will never be garbage collected.
1873
1873
  */
1874
1874
  dispose() {
1875
- K.s_Instances.delete(this), K.s_InstancesArray = null, this.hardClear();
1875
+ lt.s_Instances.delete(this), lt.s_InstancesArray = null, this.hardClear();
1876
1876
  }
1877
1877
  // ── Build ─────────────────────────────────────────────────────────────
1878
1878
  build() {
1879
- var S;
1879
+ var A;
1880
1880
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
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);
1881
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new Re()), this.m_RendererFactory === null) {
1882
+ const T = new l.Object3D();
1883
+ T.name = "Root", this.add(T), this.m_Root = T, this.m_RendererFactory = new Ve(this.m_Root);
1884
1884
  }
1885
1885
  this.m_Direction = this.m_Content.direction;
1886
1886
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1887
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);
1888
- const e = new Xt(this.m_CoverPaperSetup), s = new Xt(this.m_PagePaperSetup);
1888
+ const e = new qt(this.m_CoverPaperSetup), s = new qt(this.m_PagePaperSetup);
1889
1889
  this.m_Content.init(this);
1890
1890
  let i = this.m_Content.coverContents, n = this.m_Content.pageContents, r = this.m_InitialOpenProgress;
1891
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;
1892
+ const o = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
1893
+ let u = 0, c = 0, d = 0;
1894
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;
1895
+ for (let T = 0; T < o; T++) {
1896
+ const b = this.m_HasCover && (T < h || T >= o - h), Q = this.m_RendererFactory.get("Paper"), F = this.m_Papers[T] = new Be(b, T, this, Q);
1897
+ F.renderer.castShadows = this.m_CastShadows, T < Math.round(l.MathUtils.lerp(0, o, r)) && (F.transform.scale.set(-1, 1, 1), F.setTime(1)), b ? (F.setContentData(i[c++], i[c++], T > h), F.setMaterialData(e), F.setPaperSetup(this.m_CoverPaperSetup)) : (F.setContentData(n[u++], n[u++]), F.setMaterialData(s), F.setPaperSetup(this.m_PagePaperSetup)), d += F.thickness;
1898
1898
  }
1899
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(
1900
+ const f = this.m_Papers[0].thickness, g = this.m_Papers[Math.floor(o / 2)].thickness;
1901
+ this.m_MinPaperThickness = Math.min(f, g), this.m_MaxPaperThickness = Math.max(f, g);
1902
+ const m = this.m_Papers[0].size.x, _ = this.m_Papers[Math.floor(o / 2)].size.x;
1903
+ this.m_MinPaperWidth = Math.min(m, _);
1904
+ const p = this.m_Papers[0].size.y, M = this.m_Papers[Math.floor(o / 2)].size.y;
1905
+ this.m_MinPaperHeight = Math.min(p, M), this.m_Bound = this.m_Binding.createBound(
1906
1906
  this,
1907
1907
  this.m_Root,
1908
1908
  this.m_RendererFactory,
1909
1909
  this.m_MeshFactory
1910
1910
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
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,
1911
+ const C = this.m_ReduceOverdraw && n.length > 0, y = this.m_ReduceSubMeshes, P = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, y), B = C ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, y, !0) : null, D = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), H = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), E = Math.floor(o / 2) - 1, W = E + 1, N = ((A = this.m_Bound) == null ? void 0 : A.bindingType) === "staple";
1912
+ for (let T = 0; T < o; T++) {
1913
+ const b = this.m_Papers[T];
1914
+ T !== 0 && (b.prev = this.m_Papers[T - 1]), T !== o - 1 && (b.next = this.m_Papers[T + 1]), b.noHole = N && (T === E || T === W), b.isCover ? b.setMeshData(H.get(), null, z) : b.setMeshData(
1915
+ P.get(),
1916
+ (B == null ? void 0 : B.get()) ?? null,
1917
1917
  D
1918
1918
  );
1919
1919
  }
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;
1920
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this._frontPapersCache = null, this.update(0), this.m_CoverPaperSetup.bookDirection = mt.LeftToRight, this.m_PagePaperSetup.bookDirection = mt.LeftToRight;
1921
1921
  }
1922
1922
  /**
1923
1923
  * Clears the built state of the book.
@@ -1942,7 +1942,7 @@ const K = class K extends u.Group {
1942
1942
  i,
1943
1943
  s
1944
1944
  );
1945
- return new Te(
1945
+ return new Ie(
1946
1946
  this.m_MeshFactory,
1947
1947
  r,
1948
1948
  e && this.m_Bound.useSharedMeshDataForLowpoly
@@ -1994,14 +1994,14 @@ const K = class K extends u.Group {
1994
1994
  return !1;
1995
1995
  this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
1996
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();
1997
+ let o = 0, h = 0;
1998
+ for (let u = 0; u < n; u++) {
1999
+ const c = this.m_Papers[u];
2000
+ this.m_HasCover && (u < r || u >= n - r) ? c.setContentData(
2001
+ t[h++],
2002
+ t[h++],
2003
+ u > r
2004
+ ) : c.setContentData(e[o++], e[o++]), c.updateMaterials();
2005
2005
  }
2006
2006
  return this.m_WasIdle = !1, !0;
2007
2007
  }
@@ -2031,15 +2031,15 @@ const K = class K extends u.Group {
2031
2031
  s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
2032
2032
  }
2033
2033
  };
2034
- K.s_Instances = /* @__PURE__ */ new Set(), K.s_InstancesArray = null;
2035
- let vt = K;
2036
- class he {
2034
+ lt.s_Instances = /* @__PURE__ */ new Set(), lt.s_InstancesArray = null;
2035
+ let zt = lt;
2036
+ class de {
2037
2037
  constructor() {
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;
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 l.Vector2(), this.thickness = 0;
2039
2039
  }
2040
2040
  }
2041
- const ae = Object.freeze(new u.Vector4(1, 1, 0, 0));
2042
- class ss {
2041
+ const _e = Object.freeze(new l.Vector4(1, 1, 0, 0));
2042
+ class us {
2043
2043
  constructor() {
2044
2044
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
2045
2045
  }
@@ -2050,7 +2050,7 @@ class ss {
2050
2050
  return this.m_IsActive;
2051
2051
  }
2052
2052
  get textureST() {
2053
- return ae;
2053
+ return _e;
2054
2054
  }
2055
2055
  get isShareable() {
2056
2056
  return !0;
@@ -2074,15 +2074,15 @@ class ss {
2074
2074
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
2075
2075
  }
2076
2076
  }
2077
- class jt {
2077
+ class te {
2078
2078
  constructor(t, e) {
2079
- this.m_Texture = t, this.m_TextureST = e ?? new u.Vector4(1, 1, 0, 0);
2079
+ this.m_Texture = t, this.m_TextureST = e ?? new l.Vector4(1, 1, 0, 0);
2080
2080
  }
2081
2081
  get texture() {
2082
2082
  return this.m_Texture;
2083
2083
  }
2084
2084
  get textureST() {
2085
- return this.m_Texture ? this.m_TextureST : ae;
2085
+ return this.m_Texture ? this.m_TextureST : _e;
2086
2086
  }
2087
2087
  isPointOverUI(t) {
2088
2088
  return !1;
@@ -2092,9 +2092,9 @@ class jt {
2092
2092
  setActive(t) {
2093
2093
  }
2094
2094
  }
2095
- class is {
2095
+ class ms {
2096
2096
  constructor() {
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;
2097
+ this.m_Direction = mt.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;
2098
2098
  }
2099
2099
  get coverCount4() {
2100
2100
  return this.nextMultipleOf4(this.m_Covers.length);
@@ -2146,12 +2146,12 @@ class is {
2146
2146
  }
2147
2147
  getContent(t) {
2148
2148
  if (t !== null) {
2149
- if (t instanceof u.Texture)
2150
- return new jt(t);
2149
+ if (t instanceof l.Texture)
2150
+ return new te(t);
2151
2151
  if (typeof t.init == "function")
2152
2152
  return t;
2153
2153
  }
2154
- return new jt(null);
2154
+ return new te(null);
2155
2155
  }
2156
2156
  init(t) {
2157
2157
  this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
@@ -2199,14 +2199,14 @@ class is {
2199
2199
  return !this.isCoverPaperSideIndex(t);
2200
2200
  }
2201
2201
  }
2202
- class ns {
2202
+ class ds {
2203
2203
  constructor(t, e) {
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) => {
2204
+ this.enabled = !0, this.m_Raycaster = new l.Raycaster(), this.m_Mouse = new l.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2205
2205
  var n;
2206
2206
  if (!this.enabled || s.button !== 0) return;
2207
2207
  this.m_IsPointerDown = !0;
2208
2208
  const i = this.m_GetRay(s);
2209
- for (const r of vt.instances)
2209
+ for (const r of zt.instances)
2210
2210
  if (r.startTurning(i)) {
2211
2211
  this.m_SelectedBook = r, (n = this.onTurnStart) == null || n.call(this, r);
2212
2212
  break;
@@ -2226,9 +2226,9 @@ class ns {
2226
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;
2227
2227
  }
2228
2228
  }
2229
- class ce {
2229
+ class fe {
2230
2230
  }
2231
- class le {
2231
+ class ge {
2232
2232
  constructor(t, e) {
2233
2233
  this.bindingType = "", this.m_Book = t, this.m_Root = e;
2234
2234
  }
@@ -2236,36 +2236,36 @@ class le {
2236
2236
  dispose() {
2237
2237
  }
2238
2238
  }
2239
- function kt(h, t, e, s) {
2239
+ function Dt(a, t, e, s) {
2240
2240
  const i = 1 - s;
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
2241
+ return new l.Vector3(
2242
+ i * i * a.x + 2 * i * s * t.x + s * s * e.x,
2243
+ i * i * a.y + 2 * i * s * t.y + s * s * e.y,
2244
+ i * i * a.z + 2 * i * s * t.z + s * s * e.z
2245
2245
  );
2246
2246
  }
2247
- function Yt(h, t) {
2248
- return h++, h === t ? 0 : h;
2247
+ function ee(a, t) {
2248
+ return a++, a === t ? 0 : a;
2249
2249
  }
2250
- function Be(h, t) {
2251
- return h === 0 ? t - 1 : h - 1;
2250
+ function Oe(a, t) {
2251
+ return a === 0 ? t - 1 : a - 1;
2252
2252
  }
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);
2253
+ const Ze = 0.01, Xe = 0.1, Le = 0.04, Ne = 0.4, Ue = 2, Ee = 10, We = 0, Ge = 5;
2254
+ function qe(a, t) {
2255
+ const e = a.clone().normalize();
2256
+ if (e.lengthSq() === 0) return new l.Quaternion();
2257
+ let s = new l.Vector3().crossVectors(t, e);
2258
2258
  if (s.lengthSq() === 0) {
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);
2259
+ const r = Math.abs(e.y) < 0.999 ? new l.Vector3(0, 1, 0) : new l.Vector3(1, 0, 0);
2260
+ s = new l.Vector3().crossVectors(r, e);
2261
2261
  }
2262
2262
  s.normalize();
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);
2263
+ const i = new l.Vector3().crossVectors(e, s).normalize(), n = new l.Matrix4().makeBasis(s, i, e);
2264
+ return new l.Quaternion().setFromRotationMatrix(n);
2265
2265
  }
2266
- class Ze {
2266
+ class je {
2267
2267
  constructor() {
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;
2268
+ this._material = null, this._color = new l.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2269
2269
  }
2270
2270
  get material() {
2271
2271
  return this._material;
@@ -2283,239 +2283,239 @@ class Ze {
2283
2283
  return this._thickness;
2284
2284
  }
2285
2285
  set thickness(t) {
2286
- this._thickness = Z(t, Re, Ve);
2286
+ this._thickness = q(t, Ze, Xe);
2287
2287
  }
2288
2288
  get margin() {
2289
2289
  return this._margin;
2290
2290
  }
2291
2291
  set margin(t) {
2292
- this._margin = st(t);
2292
+ this._margin = at(t);
2293
2293
  }
2294
2294
  get crown() {
2295
2295
  return this._crown;
2296
2296
  }
2297
2297
  set crown(t) {
2298
- this._crown = Z(t, De, ze);
2298
+ this._crown = q(t, Le, Ne);
2299
2299
  }
2300
2300
  get count() {
2301
2301
  return this._count;
2302
2302
  }
2303
2303
  set count(t) {
2304
- this._count = Z(t, Ie, Ae);
2304
+ this._count = q(t, Ue, Ee);
2305
2305
  }
2306
2306
  get quality() {
2307
2307
  return this._quality;
2308
2308
  }
2309
2309
  set quality(t) {
2310
- this._quality = Z(t, He, Fe);
2310
+ this._quality = q(t, We, Ge);
2311
2311
  }
2312
2312
  }
2313
- class Le extends le {
2313
+ class Ye extends ge {
2314
2314
  // ── Constructor ────────────────────────────────────────────────────────
2315
2315
  constructor(t, e, s, i, n) {
2316
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)
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({
2317
+ throw new me();
2318
+ const r = this.m_Book.coverPaperSetup, o = this.m_Book.pagePaperSetup, h = new l.BufferGeometry();
2319
+ this.updateStapleMesh(e, h);
2320
+ const u = n ?? new l.MeshStandardMaterial({
2321
2321
  color: e.color,
2322
2322
  metalness: 0.9,
2323
2323
  roughness: 0.3
2324
2324
  });
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(
2325
+ this.stapleMesh = new l.Mesh(h, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2326
2326
  0,
2327
2327
  0,
2328
2328
  this.m_StapleMargin + o.margin + r.margin
2329
2329
  );
2330
- let a = r.thickness;
2331
- a = Math.max(this.m_BindingRadius, a);
2330
+ let c = r.thickness;
2331
+ c = Math.max(this.m_BindingRadius, c);
2332
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);
2333
+ const f = d.size.clone();
2334
+ f.x -= this.m_BindingRadius, d.sizeXOffset = this.m_BindingRadius, d.size = f, d.setMinTurningRadius(c), d.updateTurningRadius(), this.updatePaperPosition(d);
2335
2335
  }
2336
2336
  this.updateRootPosition();
2337
2337
  }
2338
2338
  get binderRenderer() {
2339
- return this._binderRendererAdapter || (this._binderRendererAdapter = new Xe(this.stapleMesh)), this._binderRendererAdapter;
2339
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new Qe(this.stapleMesh)), this._binderRendererAdapter;
2340
2340
  }
2341
2341
  // ── updateStapleMesh ──────────────────────────────────────────────────
2342
2342
  updateStapleMesh(t, e) {
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;
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 * ot), this.m_StackHeight += this.m_BindingMidSpace;
2344
2344
  let s = t.crown;
2345
2345
  s = Math.max(s, this.m_StapleThickness * 4);
2346
2346
  const i = this.m_StapleThickness * 0.5, n = Math.max(
2347
2347
  this.m_Book.minPaperHeight / 2 - s - i,
2348
2348
  i
2349
2349
  );
2350
- this.m_StapleMargin = E(i, n, t.margin);
2350
+ this.m_StapleMargin = G(i, n, t.margin);
2351
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 = [];
2352
+ let o = t.count, h = (r - s * o) / (o - 1);
2353
+ for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && o > 2; )
2354
+ o--, h = (r - s * o) / (o - 1), h = Math.max(h, 0);
2355
+ const u = t.quality / 5, c = Math.floor(G(4, 20, u)), d = Math.floor(G(4, 10, u)), f = Math.floor(G(3, 10, u)), g = this.m_StapleThickness / 2, m = g * 2.5, _ = 0.9, p = g * 1;
2356
+ let M = s / 2 * _;
2357
+ M = Math.max(M, p * 2);
2358
+ let C = 0;
2359
+ C += this.m_Book.totalThickness / 2, C += g;
2360
+ const y = -(this.m_Book.papers[0].thickness / 2 + g), P = [];
2361
2361
  {
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),
2362
+ for (let U = 0; U < d; U++) {
2363
+ const w = U / (d - 1), L = G(-90, -180, w) * ot, S = new l.Vector3(
2364
+ p * Math.sin(L),
2365
2365
  0,
2366
- x * Math.cos(tt)
2366
+ p * Math.cos(L)
2367
2367
  );
2368
- v.x += x, v.z += x, v.x += C, T.push(v);
2368
+ S.x += p, S.z += p, S.x += y, P.push(S);
2369
2369
  }
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);
2370
+ const x = new l.Vector3(C, 0, 0), j = new l.Vector3(C + m * 0.75, 0, 0), R = new l.Vector3(C - g * 0.5, 0, M);
2371
+ for (let U = 0; U < f; U++) {
2372
+ const w = U / (f - 1), Z = Dt(x, j, R, w);
2373
+ Z.x += y, P.push(Z);
2374
2374
  }
2375
- T.reverse();
2375
+ P.reverse();
2376
2376
  }
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;
2377
+ const B = new Array(c);
2378
+ for (let x = 0; x < c; x++) {
2379
+ const R = (90 - x * (360 / c)) * ot;
2380
+ B[x] = new l.Vector3(Math.cos(R), Math.sin(R), 0), B[x].x *= 0.75;
2381
2381
  }
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
2382
+ const D = P.length, H = D * c, z = new Array(H * 2), E = new Array(H * 2), W = new Array(
2383
+ (H * 2 - 1) * c * 2 * 3
2384
2384
  );
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);
2385
+ for (let x = 0; x < H * 2; x++)
2386
+ z[x] = new l.Vector3(), E[x] = new l.Vector3();
2387
+ let N = 0;
2388
+ for (let x = 0; x < D; x++) {
2389
+ const j = P[Oe(x, D)], R = P[x], U = P[ee(x, D)];
2390
+ let w;
2391
+ if (x === 0)
2392
+ w = new l.Vector3(1, 0, -2).normalize();
2393
+ else if (x === D - 1)
2394
+ w = new l.Vector3(0, 0, 1);
2395
2395
  else {
2396
- const B = R.clone().sub(G).normalize(), q = L.clone().sub(R).normalize();
2397
- Y = B.add(q).multiplyScalar(0.5);
2396
+ const v = R.clone().sub(j).normalize(), I = U.clone().sub(R).normalize();
2397
+ w = v.add(I).multiplyScalar(0.5);
2398
2398
  }
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++;
2399
+ const Z = new l.Vector3(0, 1, 0), L = qe(w, Z), S = N;
2400
+ let V = ht(0, f / 4, x);
2401
+ V = G(0.1, 1, V), V = Math.sqrt(V);
2402
+ for (let v = 0; v < c; v++) {
2403
+ const I = B[v].clone().applyQuaternion(L).multiplyScalar(V), Y = R.clone().add(I.clone().multiplyScalar(g));
2404
+ z[N] = Y, E[N] = I.clone();
2405
+ const $ = R.clone().add(I.clone().multiplyScalar(g));
2406
+ $.z = s - $.z;
2407
+ const nt = S + c - v - 1, rt = H * 2 - nt - 1;
2408
+ z[rt] = $, E[rt] = I.clone(), N++;
2409
2409
  }
2410
2410
  }
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;
2411
+ let A = 0;
2412
+ const T = P.length * 2;
2413
+ for (let x = 0; x < T - 1; x++) {
2414
+ const j = x * c, R = (x + 1) * c;
2415
+ for (let U = 0; U < c; U++) {
2416
+ const w = ee(U, c), Z = j + U, L = j + w, S = R + w, V = R + U;
2417
+ W[A++] = Z, W[A++] = V, W[A++] = L, W[A++] = L, W[A++] = V, W[A++] = S;
2418
2418
  }
2419
2419
  }
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;
2420
+ const b = [...z], Q = [...E], F = [...W], tt = z.map((x) => x.clone()), J = [...W];
2421
+ for (let x = 0; x < o - 1; x++) {
2422
+ const j = tt.length;
2423
+ for (let R = 0; R < J.length; R++)
2424
+ J[R] += j;
2425
+ for (let R = 0; R < tt.length; R++)
2426
+ tt[R].z += h + s;
2427
+ b.push(...tt.map((R) => R.clone())), Q.push(...E.map((R) => R.clone())), F.push(...J);
2428
+ }
2429
+ const X = new Float32Array(b.length * 3), O = new Float32Array(Q.length * 3);
2430
+ for (let x = 0; x < b.length; x++)
2431
+ X[x * 3] = b[x].x, X[x * 3 + 1] = b[x].y, X[x * 3 + 2] = b[x].z, O[x * 3] = Q[x].x, O[x * 3 + 1] = Q[x].y, O[x * 3 + 2] = Q[x].z;
2432
2432
  e.setAttribute(
2433
2433
  "position",
2434
- new u.BufferAttribute(W, 3)
2434
+ new l.BufferAttribute(X, 3)
2435
2435
  ), e.setAttribute(
2436
2436
  "normal",
2437
- new u.BufferAttribute(I, 3)
2438
- ), e.setIndex(z);
2437
+ new l.BufferAttribute(O, 3)
2438
+ ), e.setIndex(F);
2439
2439
  }
2440
2440
  // ── createPaperPattern ────────────────────────────────────────────────
2441
2441
  createPaperPattern(t, e, s, i, n, r) {
2442
- const o = new he();
2442
+ const o = new de();
2443
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();
2444
+ const h = this.m_BindingRadius;
2445
+ o.baseXOffset = -h;
2446
+ const u = this.m_Quality + 1;
2447
+ this.m_BindingVertexCount = u;
2448
+ const c = t / 5, d = Math.min(e.x, e.y) / 60, f = Math.floor(
2449
+ G(0, (e.x - h) / d, c)
2450
+ ), g = Math.floor(G(0, e.y / d, c));
2451
+ let m = 2 + f + 1 + u, _ = 2 + g;
2452
+ const p = new _t(0);
2453
+ let M = p;
2454
+ const C = h / u;
2455
+ let y = 0;
2456
+ for (let S = 1; S < u + 1; S++)
2457
+ M = M.createNext(y), y += C;
2458
+ const P = (e.x - h) / (f + 1);
2459
+ for (let S = u + 1; S < m; S++)
2460
+ M = M.createNext(y), y += P;
2461
+ const B = new _t(0);
2462
+ let D = B;
2463
+ const H = e.y / (_ - 1);
2464
+ let z = 0;
2465
+ for (let S = 0; S < _ - 1; S++)
2466
+ z += H, D = D.createNext(z);
2467
+ const E = [], W = [], N = i.clone();
2468
2468
  if (n) {
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;
2469
+ let S = 0;
2470
+ this.m_Book.hasCover && (S = Math.floor(this.m_Book.coverPaperCount / 2));
2471
+ const V = Math.max(0.01, s);
2472
+ N.left = 0, N.right = (this.getPX(S + 1, s) - this.getPX(S, s) + V) / e.x, N.down = V / e.y, N.up = V / e.y;
2473
+ }
2474
+ const A = new ce(o, N, !1);
2475
+ A.insert(p, B, E, W), p.updateIndex(0), B.updateIndex(0), Mt(E, o.xSeams), Mt(W, o.zSeams);
2476
+ const T = this.m_BindingVertexCount + 2, b = new Array(T);
2477
+ o.xNoneSeamIndexes = b, M = p;
2478
+ for (let S = 0; S < T; S++) {
2479
+ b[S] = M.index;
2480
2480
  do
2481
2481
  M = M.next;
2482
2482
  while (M.seam);
2483
2483
  }
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,
2484
+ const Q = p.getValues(), F = B.getValues();
2485
+ m = Q.length, _ = F.length;
2486
+ const tt = m * _, J = [], X = new Array(tt).fill(0), O = [], x = [], j = [], R = [];
2487
+ Ot(
2488
+ J,
2489
+ Q,
2490
+ F,
2491
2491
  e,
2492
2492
  i,
2493
2493
  this.m_Book.direction
2494
2494
  );
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)
2495
+ const U = A.leftNode.index, w = A.downNode.index;
2496
+ let Z = A.rightNode.index, L = A.upNode.index;
2497
+ Z === 0 && (Z = m - 1), L === 0 && (L = _ - 1);
2498
+ for (let S = 0; S < _ - 1; S++)
2499
+ for (let V = 0; V < m - 1; V++) {
2500
+ if (n && S >= w && S < L && V >= U && V < Z)
2501
2501
  continue;
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(
2502
+ const v = S * m + V, I = S * m + (V + 1), Y = (S + 1) * m + V, $ = (S + 1) * m + (V + 1);
2503
+ X[v] += 2, X[I] += 2, X[Y] += 2, X[$] += 2, Ft(
2504
+ O,
2505
+ x,
2506
+ v,
2504
2507
  I,
2505
- y,
2506
- B,
2507
- q,
2508
- ut,
2509
- ht,
2510
- U
2508
+ Y,
2509
+ $,
2510
+ tt
2511
2511
  );
2512
2512
  }
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) {
2513
+ if (R.push(new Tt(0, 0, m - 1, _ - 1, !1, !1)), Ht(R, j, J, m, _), o.baseXArray = Q, o.baseZArray = F, o.baseVertexCount = tt, o.vertexCount = J.length, o.texcoords = J, o.weights = X, r) {
2514
2514
  o.subMeshCount = 1;
2515
- const v = [];
2516
- v.push(...I), v.push(...G), v.push(...y), o.triangles = v;
2515
+ const S = [];
2516
+ S.push(...O), S.push(...j), S.push(...x), o.triangles = S;
2517
2517
  } else
2518
- o.subMeshCount = 3, o.frontTriangles = I, o.backTriangles = y, o.borderTriangles = G;
2518
+ o.subMeshCount = 3, o.frontTriangles = O, o.backTriangles = x, o.borderTriangles = j;
2519
2519
  return o.borders = R, o;
2520
2520
  }
2521
2521
  // ── updateRootPosition ────────────────────────────────────────────────
@@ -2529,46 +2529,46 @@ class Le extends le {
2529
2529
  const e = this.m_Book.papers, s = e.length;
2530
2530
  let i = 0;
2531
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);
2532
+ for (let y = 0; y < s; y++) {
2533
+ const P = e[y];
2534
+ P.updateTime();
2535
+ const B = P.zTime, D = P.thickness;
2536
+ i += B * D, y === n && (i += B * this.m_BindingMidSpace / 2), y === r && (i += B * this.m_BindingMidSpace / 2);
2537
2537
  }
2538
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,
2539
+ const h = this.getStackZ(o), u = 180 + h;
2540
+ let c = t.isFlipped ? 1 : 0, d = G(h, u, c);
2541
+ const f = d * ot, g = new l.Vector3(
2542
+ Math.cos(f) * this.m_BindingRadius,
2543
+ Math.sin(f) * this.m_BindingRadius,
2544
2544
  0
2545
2545
  );
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;
2546
+ g.z = t.margin;
2547
+ let m = e[Math.floor(s / 2)].size.x, _ = this.m_BindingMidSpace, p = Math.sqrt(m * m - _ * _), M = Math.asin(p / m) * ut - 90;
2548
2548
  if (t.index < Math.floor(s / 2)) {
2549
- let C = 0;
2549
+ let y = 0;
2550
2550
  if (this.m_Book.alignToGround) {
2551
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;
2552
+ const P = this.m_StackHeight / 2;
2553
+ _ = q(i, 0, P) - P, p = Math.sqrt(m * m - _ * _), y = (Math.asin(p / m) * ut - 90) * 2;
2554
2554
  }
2555
- d = E(M, -C, a);
2555
+ d = G(M, -y, c);
2556
2556
  } else {
2557
- let C = 0;
2557
+ let y = 0;
2558
2558
  if (this.m_Book.alignToGround) {
2559
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;
2560
+ const P = this.m_StackHeight / 2;
2561
+ _ = P - q(i, P, P * 2), p = Math.sqrt(m * m - _ * _), y = (Math.asin(p / m) * ut - 90) * 2;
2562
2562
  }
2563
- d = E(C, -M, a);
2563
+ d = G(y, -M, c);
2564
2564
  }
2565
- t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2566
- new u.Euler(0, 0, d * Q)
2565
+ t.transform.position.copy(g), t.transform.quaternion.setFromEuler(
2566
+ new l.Euler(0, 0, d * ot)
2567
2567
  );
2568
2568
  }
2569
2569
  // ── getPX (private helper) ───────────────────────────────────────────
2570
2570
  getPX(t, e) {
2571
- const s = this.getStackHeight(t) - e / 2, n = this.getStackZ(s) * Q;
2571
+ const s = this.getStackHeight(t) - e / 2, n = this.getStackZ(s) * ot;
2572
2572
  return Math.cos(n) * this.m_BindingRadius;
2573
2573
  }
2574
2574
  // ── updatePaperPosition ───────────────────────────────────────────────
@@ -2577,33 +2577,33 @@ class Le extends le {
2577
2577
  }
2578
2578
  updatePaperPositionWithTh(t, e) {
2579
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,
2580
+ let h = t.zTime, u = G(r, o, h);
2581
+ const c = u * ot, d = new l.Vector3(
2582
+ Math.cos(c) * this.m_BindingRadius,
2583
+ Math.sin(c) * this.m_BindingRadius,
2584
2584
  0
2585
2585
  );
2586
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;
2587
+ let f = s[Math.floor(i / 2)].size.x, g = this.m_BindingMidSpace, m = Math.sqrt(f * f - g * g), _ = Math.asin(m / f) * ut - 90;
2588
2588
  if (t.index < Math.floor(i / 2)) {
2589
2589
  let M = 0;
2590
2590
  if (this.m_Book.alignToGround) {
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;
2591
+ f = s[0].size.x;
2592
+ const C = this.m_StackHeight / 2;
2593
+ g = q(e, 0, C) - C, m = Math.sqrt(f * f - g * g), M = (Math.asin(m / f) * ut - 90) * 2;
2594
2594
  }
2595
- l = E(f, -M, c);
2595
+ u = G(_, -M, h);
2596
2596
  } else {
2597
2597
  let M = 0;
2598
2598
  if (this.m_Book.alignToGround) {
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;
2599
+ f = s[0].size.x;
2600
+ const C = this.m_StackHeight / 2;
2601
+ g = C - q(e, C, C * 2), m = Math.sqrt(f * f - g * g), M = (Math.asin(m / f) * ut - 90) * 2;
2602
2602
  }
2603
- l = E(M, -f, c);
2603
+ u = G(M, -_, h);
2604
2604
  }
2605
2605
  t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2606
- new u.Euler(0, 0, l * Q)
2606
+ new l.Euler(0, 0, u * ot)
2607
2607
  );
2608
2608
  }
2609
2609
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2617,9 +2617,9 @@ class Le extends le {
2617
2617
  }
2618
2618
  // ── getStackZ ─────────────────────────────────────────────────────────
2619
2619
  getStackZ(t) {
2620
- t = Z(t, 0, this.m_StackHeight);
2620
+ t = q(t, 0, this.m_StackHeight);
2621
2621
  const e = t - this.m_StackHeight * 0.5;
2622
- return Math.asin(e / this.m_BindingRadius) * et;
2622
+ return Math.asin(e / this.m_BindingRadius) * ut;
2623
2623
  }
2624
2624
  // ── onLateUpdate ──────────────────────────────────────────────────────
2625
2625
  /** Precompute cumulative th once instead of per-paper (O(n) instead of O(n²)). */
@@ -2646,42 +2646,42 @@ class Le extends le {
2646
2646
  // ── updateBindingVertices ─────────────────────────────────────────────
2647
2647
  updateBindingVertices() {
2648
2648
  const t = this.m_Book.papers;
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
+ let e = new l.Vector3(0, 0, 0), s = new l.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(), h = t.length;
2651
+ for (let u = 0; u < h; u++) {
2652
+ const c = t[u], d = c.transform, f = c.meshData.pattern, g = c.meshData.baseVertices, m = f.baseXArray, _ = f.baseZArray, p = m.length, M = _.length, C = this.m_BindingVertexCount + 1, y = c.thickness, P = f.xNoneSeamIndexes, B = d.position.clone();
2653
+ let D = u, H = n;
2654
+ u >= Math.floor(h / 2) && (D = h - u - 1, H *= -1);
2655
+ const z = (r + y) * 0.5 + y * (D - 1), E = d.matrixWorld.clone().invert().multiply(o), W = D / (h / 2);
2656
+ i = this.m_BindingRadius * G(0.45, 0.65, 1 - W);
2657
+ for (let N = 0; N < M; N++) {
2658
+ const A = _[N], T = new l.Vector3(0, 0, B.z + A), b = B.clone();
2659
+ b.z += A;
2660
+ const Q = c.getDirection(A).multiplyScalar(i).add(b.clone());
2661
+ if (u === 0 && N === 0) {
2662
+ const O = t[h - 1], j = O.transform.position.clone().clone();
2663
+ j.z += A;
2664
+ const R = O.getDirection(A).multiplyScalar(i).add(j);
2665
+ s = Q.clone().sub(R).normalize(), e = new l.Vector3(
2666
2666
  -s.y,
2667
2667
  s.x,
2668
2668
  0
2669
2669
  ).normalize().negate();
2670
- const L = Math.atan2(e.y, e.x) * et;
2671
- this.stapleMesh.rotation.set(0, 0, L * Q);
2670
+ const U = Math.atan2(e.y, e.x) * ut;
2671
+ this.stapleMesh.rotation.set(0, 0, U * ot);
2672
2672
  }
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
2673
+ D > 0 && T.add(e.clone().multiplyScalar(z));
2674
+ const F = N * p;
2675
+ g[F] = T.clone().applyMatrix4(E), T.add(s.clone().multiplyScalar(H));
2676
+ const tt = T.clone().applyMatrix4(E), J = Q.clone().applyMatrix4(E), X = b.clone().applyMatrix4(E);
2677
+ g[F + P[1]] = tt;
2678
+ for (let O = 2; O < C; O++) {
2679
+ const x = ht(1, C, O);
2680
+ g[F + P[O]] = Dt(
2681
+ tt,
2682
+ J,
2683
+ X,
2684
+ x
2685
2685
  );
2686
2686
  }
2687
2687
  }
@@ -2711,10 +2711,10 @@ class Le extends le {
2711
2711
  }
2712
2712
  /** Releases GPU resources held by the staple mesh. */
2713
2713
  dispose() {
2714
- this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof u.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2714
+ this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof l.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2715
2715
  }
2716
2716
  }
2717
- class Xe {
2717
+ class Qe {
2718
2718
  constructor(t) {
2719
2719
  this.mesh = t;
2720
2720
  }
@@ -2728,7 +2728,7 @@ class Xe {
2728
2728
  this.mesh.castShadow = t;
2729
2729
  }
2730
2730
  get bounds() {
2731
- const t = new u.Box3();
2731
+ const t = new l.Box3();
2732
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;
2733
2733
  }
2734
2734
  get transform() {
@@ -2738,12 +2738,12 @@ class Xe {
2738
2738
  return this.mesh;
2739
2739
  }
2740
2740
  }
2741
- class rs extends ce {
2741
+ class _s extends fe {
2742
2742
  constructor() {
2743
- super(...arguments), this.quality = 3, this.stapleSetup = new Ze();
2743
+ super(...arguments), this.quality = 3, this.stapleSetup = new je();
2744
2744
  }
2745
2745
  createBound(t, e, s, i) {
2746
- return new Le(
2746
+ return new Ye(
2747
2747
  this.quality,
2748
2748
  this.stapleSetup,
2749
2749
  t,
@@ -2751,24 +2751,24 @@ class rs extends ce {
2751
2751
  );
2752
2752
  }
2753
2753
  }
2754
- const Ne = 5e-3, Ue = 0.2, Ee = 0.02, We = 0.5, Ge = 0, qe = 5;
2755
- class je {
2754
+ const $e = 5e-3, Ke = 0.2, Je = 0.02, ts = 0.5, es = 0, ss = 5;
2755
+ class is {
2756
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;
2757
+ this._hingeGap = 0.03, this._glueFlexWidth = 0.12, this._spineColor = new l.Color(0.55, 0.15, 0.15), this._spineTexture = null, this._spineMaterial = null, this._quality = 3;
2758
2758
  }
2759
2759
  /** Cloth-joint groove between a board and the spine edge (world units). */
2760
2760
  get hingeGap() {
2761
2761
  return this._hingeGap;
2762
2762
  }
2763
2763
  set hingeGap(t) {
2764
- this._hingeGap = Z(t, Ne, Ue);
2764
+ this._hingeGap = q(t, $e, Ke);
2765
2765
  }
2766
2766
  /** Width of the page gutter flex zone — glued pages never open flat. */
2767
2767
  get glueFlexWidth() {
2768
2768
  return this._glueFlexWidth;
2769
2769
  }
2770
2770
  set glueFlexWidth(t) {
2771
- this._glueFlexWidth = Z(t, Ee, We);
2771
+ this._glueFlexWidth = q(t, Je, ts);
2772
2772
  }
2773
2773
  get spineColor() {
2774
2774
  return this._spineColor;
@@ -2799,50 +2799,50 @@ class je {
2799
2799
  return this._quality;
2800
2800
  }
2801
2801
  set quality(t) {
2802
- this._quality = Z(t, Ge, qe);
2802
+ this._quality = q(t, es, ss);
2803
2803
  }
2804
2804
  }
2805
- const Ye = 30, Qt = 6, $t = 0, Kt = 1, Jt = 2, te = 3, ft = 4, at = 5;
2806
- class Qe extends le {
2805
+ const ns = 30, se = 6, ie = 0, ne = 1, re = 2, oe = 3, Ct = 4, xt = 5;
2806
+ class rs extends ge {
2807
2807
  constructor(t, e, s, i) {
2808
- if (super(s, i), this.bindingType = "glued", 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();
2808
+ if (super(s, i), this.bindingType = "glued", 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_CaseRowCount = 0, this.m_CasePathCount = 0, this.m_CaseBoardColumnCount = 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 me();
2810
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);
2811
+ this.m_StackHeight = this.m_Book.totalThickness, this.m_RadiusY = this.m_StackHeight / 2 / Math.sin(ns * ot);
2812
2812
  const r = this.m_Book.papers;
2813
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;
2814
+ for (let c = 0; c < r.length; c++) {
2815
+ const d = this.getStackHeight(c);
2816
+ this.m_GlueY[c] = d - r[c].thickness / 2 - this.m_StackHeight / 2;
2817
2817
  }
2818
- const o = this.createCaseGeometry();
2819
- this.m_OwnsClothMaterial = e.spineMaterial === null, this.m_ClothMaterial = e.spineMaterial ?? new u.MeshStandardMaterial({
2818
+ const o = new l.BufferGeometry();
2819
+ this.m_OwnsClothMaterial = e.spineMaterial === null, this.m_ClothMaterial = e.spineMaterial ?? new l.MeshStandardMaterial({
2820
2820
  color: e.spineColor,
2821
2821
  roughness: 0.75,
2822
2822
  metalness: 0,
2823
- side: u.DoubleSide
2823
+ side: l.DoubleSide
2824
2824
  }), this.m_CaseMaterials = [];
2825
- for (let a = 0; a < 5; a++)
2825
+ for (let c = 0; c < 5; c++)
2826
2826
  this.m_CaseMaterials.push(
2827
- new u.MeshStandardMaterial({
2828
- color: a === ft ? e.spineColor : n.color,
2827
+ new l.MeshStandardMaterial({
2828
+ color: c === Ct ? e.spineColor : n.color,
2829
2829
  roughness: 0.8,
2830
2830
  metalness: 0,
2831
- side: u.DoubleSide
2831
+ side: l.DoubleSide
2832
2832
  })
2833
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);
2834
+ const h = [...this.m_CaseMaterials, this.m_ClothMaterial];
2835
+ this.spineMesh = new l.Mesh(o, h), 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 u = n.thickness;
2837
+ u = Math.max(e.glueFlexWidth, u);
2838
+ for (const c of this.m_Book.papers) {
2839
+ const d = this.bindingWidthFor(c.isCover), f = c.size.clone();
2840
+ f.x -= d, c.sizeXOffset = d, c.size = f, c.setMinTurningRadius(u), c.updateTurningRadius(), this.updatePaperPosition(c);
2841
2841
  }
2842
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
2843
  }
2844
2844
  get binderRenderer() {
2845
- return this._binderRendererAdapter || (this._binderRendererAdapter = new $e(this.spineMesh)), this._binderRendererAdapter;
2845
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new os(this.spineMesh)), this._binderRendererAdapter;
2846
2846
  }
2847
2847
  bindingWidthFor(t) {
2848
2848
  return t ? this.m_Setup.hingeGap + this.m_Book.coverPaperSetup.thickness : this.m_Setup.glueFlexWidth;
@@ -2856,19 +2856,29 @@ class Qe extends le {
2856
2856
  return this.m_StackHeight / 2 + this.m_Setup.hingeGap * 0.5;
2857
2857
  }
2858
2858
  createCaseGeometry() {
2859
+ var P, B, D, H;
2859
2860
  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);
2861
+ const t = this.m_CaseSlabSegments, e = se, s = this.m_Book.papers, i = (B = (P = s[0]) == null ? void 0 : P.meshData) == null ? void 0 : B.pattern, n = (H = (D = s[s.length - 1]) == null ? void 0 : D.meshData) == null ? void 0 : H.pattern;
2862
+ if (!i || !n) return new l.BufferGeometry();
2863
+ const r = i.xNoneSeamIndexes[this.m_BindingVertexCount + 1], o = n.xNoneSeamIndexes[this.m_BindingVertexCount + 1], h = Math.max(
2864
+ i.baseXArray.length - r,
2865
+ n.baseXArray.length - o
2866
+ ), u = Math.max(i.baseZArray.length, n.baseZArray.length), c = t + 2 * e + 1, d = h * 2 + c, f = 2 * d;
2867
+ this.m_CaseLoopCount = f, this.m_CaseRowCount = u, this.m_CasePathCount = d, this.m_CaseBoardColumnCount = h;
2868
+ const g = [], m = (z, E) => {
2869
+ for (let W = 0; W < E; W++) g.push(z);
2864
2870
  };
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;
2871
+ m(ne, h - 1), m(xt, c + 1), m(re, h - 1), m(xt, 1), m(oe, h - 1), m(xt, e + 1), m(Ct, t), m(xt, e + 1), m(ie, h - 1), m(xt, 1), this.m_CaseZones = g;
2872
+ const _ = new l.BufferGeometry(), p = f * (u - 1), M = p * 6, C = p * 4 + f * 2;
2873
+ _.setAttribute("position", new l.BufferAttribute(new Float32Array(C * 3), 3)), _.setAttribute("uv", new l.BufferAttribute(new Float32Array(C * 2), 2)), _.setIndex(new l.BufferAttribute(new Uint32Array(M + (f - 2) * 6), 1));
2874
+ let y = 0;
2875
+ for (let z = 1; z <= f; z++)
2876
+ (z === f || g[z] !== g[y]) && (_.addGroup(
2877
+ y * (u - 1) * 6,
2878
+ (z - y) * (u - 1) * 6,
2879
+ g[y]
2880
+ ), y = z);
2881
+ return _.addGroup(M, (f - 2) * 6, xt), _;
2872
2882
  }
2873
2883
  /**
2874
2884
  * The case spine curve, manga-cover model: the two flat boards are joined
@@ -2881,163 +2891,201 @@ class Qe extends le {
2881
2891
  */
2882
2892
  caseCurve() {
2883
2893
  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;
2894
+ const _ = m.getDirection(m.size.y / 2), p = new l.Vector2(_.x, _.y);
2895
+ p.lengthSq() < 1e-8 && p.set(-1, 0), p.normalize();
2896
+ const M = new l.Vector2(m.transform.position.x, m.transform.position.y), C = m.size.x, y = this.bindingWidthFor(!0);
2897
+ return { d: p, pivot: M, w: C, uOf: (B) => at((B.clone().sub(M).dot(p) * -1 + y) / (C + y)) };
2898
+ }, n = i(t[0]), r = i(t[t.length - 1]), o = (this.bindingWidthFor(!0) + s + 4e-3) / 0.75, h = n.pivot, u = n.pivot.clone().addScaledVector(n.d, o), c = r.pivot.clone().addScaledVector(r.d, o), d = r.pivot;
2889
2899
  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
2900
+ const _ = 1 - m;
2901
+ return new l.Vector2(
2902
+ _ * _ * _ * h.x + 3 * _ * _ * m * u.x + 3 * _ * m * m * c.x + m * m * m * d.x,
2903
+ _ * _ * _ * h.y + 3 * _ * _ * m * u.y + 3 * _ * m * m * c.y + m * m * m * d.y
2894
2904
  );
2895
2905
  }, 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();
2906
+ const _ = 1 - m, p = 3 * _ * _ * (u.x - h.x) + 6 * _ * m * (c.x - u.x) + 3 * m * m * (d.x - c.x), M = 3 * _ * _ * (u.y - h.y) + 6 * _ * m * (c.y - u.y) + 3 * m * m * (d.y - c.y), C = new l.Vector2(M, -p);
2907
+ return C.lengthSq() < 1e-10 ? new l.Vector2(-1, 0) : C.normalize();
2898
2908
  } };
2899
2909
  }
2900
2910
  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 = [];
2911
+ var R, U;
2912
+ const e = this.m_Book.papers, s = e[0], i = e[e.length - 1], n = (R = s == null ? void 0 : s.meshData) == null ? void 0 : R.pattern, r = (U = i == null ? void 0 : i.meshData) == null ? void 0 : U.pattern;
2913
+ if (!n || !r) return;
2914
+ const o = n.xNoneSeamIndexes[this.m_BindingVertexCount + 1], h = r.xNoneSeamIndexes[this.m_BindingVertexCount + 1], u = Math.max(
2915
+ n.baseXArray.length - o,
2916
+ r.baseXArray.length - h
2917
+ ), c = Math.max(n.baseZArray.length, r.baseZArray.length);
2918
+ if (this.m_CaseRowCount !== c || this.m_CaseBoardColumnCount !== u) {
2919
+ this.m_CaseRowCount = 0;
2920
+ const w = this.createCaseGeometry();
2921
+ if (this.m_CaseRowCount === 0) return;
2922
+ this.spineMesh.geometry.dispose(), this.spineMesh.geometry = w;
2923
+ }
2924
+ const d = se, f = this.m_CaseSlabSegments, { F: g, B: m, half: _, cubic: p } = this.caseCurve(), M = f + 2 * d + 1, C = this.m_CaseRowCount, y = this.m_CasePathCount, P = this.m_CaseLoopCount, B = this.m_CaseBoardColumnCount, D = this.spineMesh.geometry, H = D.getAttribute("position"), z = D.getAttribute("uv"), E = this.m_CaseZones, W = this.spineMesh.matrixWorld.clone().invert().multiply(s.transform.matrixWorld), N = this.spineMesh.matrixWorld.clone().invert().multiply(i.transform.matrixWorld), A = (d + 1) / (M + 1), T = (d + f + 1) / (M + 1), b = new Array(C), Q = new Array(C), F = new l.Vector2(), tt = (w, Z, L, S, V, v) => {
2925
+ const I = Z.baseXArray, Y = Z.baseZArray, $ = I.length, nt = G(I[L], I[$ - 1], S), rt = G(Y[0], Y[Y.length - 1], V);
2926
+ let k = L;
2927
+ for (; k < $ - 1 && I[k] < nt; ) k++;
2928
+ const st = Math.max(L, k - 1), K = I[k] === I[st] ? 0 : ht(I[st], I[k], nt);
2929
+ let it = 0;
2930
+ for (; it < Y.length - 1 && Y[it] < rt; ) it++;
2931
+ const pt = Math.max(0, it - 1), ye = Y[it] === Y[pt] ? 0 : ht(Y[pt], Y[it], rt), yt = w.meshData.baseVertices, Ce = yt[pt * $ + st].clone().lerp(yt[pt * $ + k], K), we = yt[it * $ + st].clone().lerp(yt[it * $ + k], K);
2932
+ return Ce.lerp(we, ye).applyMatrix4(v);
2933
+ };
2934
+ let J = 0;
2935
+ for (let w = 0; w < C; w++) {
2936
+ const Z = [], L = [], S = w / Math.max(C - 1, 1);
2937
+ for (let k = B - 1; k >= 0; k--) {
2938
+ const st = k / Math.max(B - 1, 1);
2939
+ Z.push(tt(s, n, o, st, S, W)), L.push(st);
2940
+ }
2941
+ const V = Z[Z.length - 1], v = tt(i, r, h, 0, S, N), I = (V.z + v.z) * 0.5;
2942
+ for (let k = 1; k <= M; k++) {
2943
+ const st = k / (M + 1), K = p(st);
2944
+ Z.push(new l.Vector3(K.x, K.y, I)), L.push(1 - at((st - A) / (T - A)));
2945
+ }
2946
+ for (let k = 0; k < B; k++) {
2947
+ const st = k / Math.max(B - 1, 1);
2948
+ Z.push(tt(i, r, h, st, S, N)), L.push(st);
2949
+ }
2950
+ const Y = new Array(y), $ = new Array(y);
2951
+ for (let k = 0; k < y; k++) {
2952
+ const st = Z[Math.max(k - 1, 0)], K = Z[Math.min(k + 1, y - 1)];
2953
+ F.set(K.x - st.x, K.y - st.y), F.lengthSq() < 1e-10 && F.set(-1, 0), F.normalize();
2954
+ const it = F.y, pt = -F.x;
2955
+ Y[k] = Z[k].clone().add(new l.Vector3(it * _, pt * _, 0)), $[k] = Z[k].clone().add(new l.Vector3(-it * _, -pt * _, 0));
2956
+ }
2957
+ const nt = [], rt = [];
2958
+ for (let k = 0; k < y; k++)
2959
+ nt.push($[k]), rt.push(k < B ? 1 - L[k] : L[k]);
2960
+ for (let k = y - 1; k >= 0; k--)
2961
+ nt.push(Y[k]), rt.push(k >= y - B ? 1 - L[k] : L[k]);
2962
+ b[w] = nt, Q[w] = rt;
2963
+ for (const k of nt) J = Math.min(J, k.y);
2964
+ }
2965
+ this.m_CaseMinY = J;
2966
+ let X = 0;
2967
+ for (let w = 0; w < P; w++) {
2968
+ const Z = (w + 1) % P, L = E[w], S = L === xt;
2969
+ for (let V = 0; V < C - 1; V++) {
2970
+ const v = b[V][w], I = b[V][Z], Y = b[V + 1][w], $ = b[V + 1][Z];
2971
+ let nt = S ? 0 : Q[V][w], rt = S ? 1 : Q[V][Z];
2972
+ !S && L !== Ct && (nt = at(nt), rt = at(rt));
2973
+ const k = 1 - V / (C - 1), st = 1 - (V + 1) / (C - 1), K = (w * (C - 1) + V) * 4;
2974
+ H.setXYZ(K, v.x, v.y, v.z), H.setXYZ(K + 1, I.x, I.y, I.z), H.setXYZ(K + 2, Y.x, Y.y, Y.z), H.setXYZ(K + 3, $.x, $.y, $.z), z.setXY(K, nt, k), z.setXY(K + 1, rt, k), z.setXY(K + 2, nt, st), z.setXY(K + 3, rt, st);
2975
+ const it = D.getIndex();
2976
+ it.setX(X++, K + 2), it.setX(X++, K + 1), it.setX(X++, K), it.setX(X++, K + 2), it.setX(X++, K + 3), it.setX(X++, K + 1);
2977
+ }
2978
+ }
2979
+ const O = P * (C - 1) * 4;
2980
+ for (let w = 0; w < P; w++) {
2981
+ const Z = b[0][w], L = b[C - 1][w];
2982
+ H.setXYZ(O + w, Z.x, Z.y, Z.z), H.setXYZ(O + P + w, L.x, L.y, L.z), z.setXY(O + w, 0.5, 0.5), z.setXY(O + P + w, 0.5, 0.5);
2983
+ }
2984
+ const x = D.getIndex();
2985
+ let j = [];
2941
2986
  try {
2942
- w = u.ShapeUtils.triangulateShape(M, []);
2987
+ j = l.ShapeUtils.triangulateShape(
2988
+ b[0].map((w) => new l.Vector2(w.x, w.y)),
2989
+ []
2990
+ );
2943
2991
  } catch {
2944
2992
  }
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();
2993
+ for (const w of j)
2994
+ x.setX(X++, O + w[2]), x.setX(X++, O + w[1]), x.setX(X++, O + w[0]), x.setX(X++, O + P + w[0]), x.setX(X++, O + P + w[1]), x.setX(X++, O + P + w[2]);
2995
+ for (; X < x.count; ) x.setX(X++, 0);
2996
+ H.needsUpdate = !0, z.needsUpdate = !0, x.needsUpdate = !0, D.computeVertexNormals(), D.computeBoundingBox(), D.computeBoundingSphere();
2949
2997
  }
2950
2998
  /** Keeps the five zone materials pointed at the live content textures. */
2951
2999
  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));
3000
+ var n, r, o, h, u, c, d, f;
3001
+ const t = this.m_Book.papers, e = t[t.length - 1], s = (g, m, _) => {
3002
+ const p = this.m_CaseMaterials[g];
3003
+ p && (m && _ && (m.repeat.set(_.x, _.y), m.offset.set(_.z, _.w)), p.map !== m && (p.map = m, p.color.set(m ? 16777215 : this.m_Book.coverPaperSetup.color.getHex()), p.needsUpdate = !0));
2956
3004
  };
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];
3005
+ this.m_Book.hasCover && (s(ie, ((n = t[0].frontContent) == null ? void 0 : n.texture) ?? null, (r = t[0].frontContent) == null ? void 0 : r.textureST), s(ne, ((o = t[0].backContent) == null ? void 0 : o.texture) ?? null, (h = t[0].backContent) == null ? void 0 : h.textureST), s(re, ((u = e.frontContent) == null ? void 0 : u.texture) ?? null, (c = e.frontContent) == null ? void 0 : c.textureST), s(oe, ((d = e.backContent) == null ? void 0 : d.texture) ?? null, (f = e.backContent) == null ? void 0 : f.textureST));
3006
+ const i = this.m_CaseMaterials[Ct];
2959
3007
  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
3008
  }
2961
3009
  // ── createPaperPattern ────────────────────────────────────────────────
2962
3010
  createPaperPattern(t, e, s, i, n, r) {
2963
- const o = new he();
3011
+ const o = new de();
2964
3012
  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;
3013
+ const h = this.m_Book.coverPaperSetup.size, u = Math.abs(e.x - h.x) < 1e-6 && Math.abs(e.y - h.y) < 1e-6, c = this.bindingWidthFor(u);
3014
+ o.baseXOffset = -c;
2967
3015
  const d = (this.m_Quality + 1) * 2;
2968
3016
  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();
3017
+ const f = t / 5, g = Math.min(e.x, e.y) / 60, m = Math.floor(
3018
+ G(0, (e.x - c) / g, f)
3019
+ ), _ = Math.floor(G(0, e.y / g, f));
3020
+ let p = 2 + m + 1 + d, M = 2 + _;
3021
+ const C = new _t(0);
3022
+ let y = C;
3023
+ const P = c / d;
3024
+ let B = 0;
3025
+ for (let v = 1; v < d + 1; v++)
3026
+ y = y.createNext(B), B += P;
3027
+ const D = (e.x - c) / (m + 1);
3028
+ for (let v = d + 1; v < p; v++)
3029
+ y = y.createNext(B), B += D;
3030
+ const H = new _t(0);
3031
+ let z = H;
3032
+ const E = e.y / (M - 1);
3033
+ let W = 0;
3034
+ for (let v = 0; v < M - 1; v++)
3035
+ W += E, z = z.createNext(W);
3036
+ const N = [], A = [], T = i.clone();
2989
3037
  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;
3038
+ let v = 0;
3039
+ this.m_Book.hasCover && (v = Math.floor(this.m_Book.coverPaperCount / 2));
3040
+ const I = Math.max(0.01, s);
3041
+ T.left = 0, T.right = (this.getPX(v + 1, s) - this.getPX(v, s) + I) / e.x, T.down = I / e.y, T.up = I / e.y;
3042
+ }
3043
+ const b = new ce(o, T, !1);
3044
+ b.insert(C, H, N, A), C.updateIndex(0), H.updateIndex(0), Mt(N, o.xSeams), Mt(A, o.zSeams);
3045
+ const Q = this.m_BindingVertexCount + 2, F = new Array(Q);
3046
+ o.xNoneSeamIndexes = F, y = C;
3047
+ for (let v = 0; v < Q; v++) {
3048
+ F[v] = y.index;
3001
3049
  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,
3050
+ y = y.next;
3051
+ while (y.seam);
3052
+ }
3053
+ const tt = C.getValues(), J = H.getValues();
3054
+ p = tt.length, M = J.length;
3055
+ const X = p * M, O = [], x = new Array(X).fill(0), j = [], R = [], U = [], w = [];
3056
+ Ot(
3011
3057
  O,
3058
+ tt,
3059
+ J,
3012
3060
  e,
3013
3061
  i,
3014
3062
  this.m_Book.direction
3015
3063
  );
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)
3064
+ const Z = b.leftNode.index, L = b.downNode.index;
3065
+ let S = b.rightNode.index, V = b.upNode.index;
3066
+ S === 0 && (S = p - 1), V === 0 && (V = M - 1);
3067
+ for (let v = 0; v < M - 1; v++)
3068
+ for (let I = 0; I < p - 1; I++) {
3069
+ if (n && v >= L && v < V && I >= Z && I < S)
3022
3070
  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,
3071
+ const Y = v * p + I, $ = v * p + (I + 1), nt = (v + 1) * p + I, rt = (v + 1) * p + (I + 1);
3072
+ x[Y] += 2, x[$] += 2, x[nt] += 2, x[rt] += 2, Ft(
3073
+ j,
3026
3074
  R,
3027
- ut,
3028
- ht,
3029
- _t,
3030
- mt,
3031
- W
3075
+ Y,
3076
+ $,
3077
+ nt,
3078
+ rt,
3079
+ X
3032
3080
  );
3033
3081
  }
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) {
3082
+ if (w.push(new Tt(0, 0, p - 1, M - 1, !1, !1)), Ht(w, U, O, p, M), o.baseXArray = tt, o.baseZArray = J, o.baseVertexCount = X, o.vertexCount = O.length, o.texcoords = O, o.weights = x, r) {
3035
3083
  o.subMeshCount = 1;
3036
- const B = [];
3037
- B.push(...G), B.push(...L), B.push(...R), o.triangles = B;
3084
+ const v = [];
3085
+ v.push(...j), v.push(...U), v.push(...R), o.triangles = v;
3038
3086
  } else
3039
- o.subMeshCount = 3, o.frontTriangles = G, o.backTriangles = R, o.borderTriangles = L;
3040
- return o.borders = Y, o;
3087
+ o.subMeshCount = 3, o.frontTriangles = j, o.backTriangles = R, o.borderTriangles = U;
3088
+ return o.borders = w, o;
3041
3089
  }
3042
3090
  // ── Pivot placement ───────────────────────────────────────────────────
3043
3091
  /**
@@ -3047,12 +3095,12 @@ class Qe extends le {
3047
3095
  * lifts over the spine.
3048
3096
  */
3049
3097
  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;
3098
+ const o = this.bindingWidthFor(e), h = t * ot, u = G(
3099
+ Math.cos(s * ot),
3100
+ -Math.cos(i * ot),
3101
+ at(n)
3102
+ ), c = o * Math.cos(h) / Math.max(u, 1e-4);
3103
+ return r.set(q(c, -o, o), Math.sin(h) * this.m_RadiusY, 0), r;
3056
3104
  }
3057
3105
  /**
3058
3106
  * Tight-back spine angle: the case spine follows the block. Closed → 0
@@ -3061,7 +3109,7 @@ class Qe extends le {
3061
3109
  */
3062
3110
  spineAngle() {
3063
3111
  const { th: t, total: e } = this.computeThPages();
3064
- return Math.PI * st(t / e);
3112
+ return Math.PI * at(t / e);
3065
3113
  }
3066
3114
  updateRootPosition() {
3067
3115
  const t = this.m_Book.papers, e = t[0].transform.position.y, s = t[t.length - 1].transform.position.y;
@@ -3070,12 +3118,12 @@ class Qe extends le {
3070
3118
  }
3071
3119
  resetPaperPosition(t) {
3072
3120
  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));
3121
+ for (const c of e)
3122
+ c.updateTime();
3123
+ const s = this.getStackHeight(t.index) - t.thickness / 2, i = this.getStackZ(s), n = 180 + i, r = t.isFlipped ? 1 : 0, o = G(i, n, r), h = this.pivotAt(o, t.isCover, i, n, r, new l.Vector3());
3124
+ h.z = t.margin;
3125
+ const u = this.restRotation(t, r, 0);
3126
+ t.transform.position.copy(h), t.transform.quaternion.setFromEuler(new l.Euler(0, 0, u * ot));
3079
3127
  }
3080
3128
  getPX(t, e) {
3081
3129
  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));
@@ -3085,10 +3133,10 @@ class Qe extends le {
3085
3133
  this.updatePaperPositionWithTh(t, this.computeTh());
3086
3134
  }
3087
3135
  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));
3136
+ 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 = G(i, n, r), h = this.pivotAt(o, t.isCover, i, n, r, new l.Vector3());
3137
+ h.z = t.margin;
3138
+ const u = this.restRotation(t, r, e);
3139
+ t.transform.position.copy(h), t.transform.quaternion.setFromEuler(new l.Euler(0, 0, u * ot));
3092
3140
  }
3093
3141
  /**
3094
3142
  * Resting plane rotation. A glued block has no fold gap, so resting papers
@@ -3100,17 +3148,17 @@ class Qe extends le {
3100
3148
  if (t.index < Math.floor(i.length / 2)) {
3101
3149
  let o = 0;
3102
3150
  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;
3151
+ const h = i[0].size.x, u = this.m_StackHeight / 2, c = q(s, 0, u) - u, d = Math.sqrt(Math.max(h * h - c * c, 0));
3152
+ o = (Math.asin(at(d / h)) * ut - 90) * 2;
3105
3153
  }
3106
- return E(0, -o, e);
3154
+ return G(0, -o, e);
3107
3155
  }
3108
3156
  let r = 0;
3109
3157
  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;
3158
+ const o = i[0].size.x, h = this.m_StackHeight / 2, u = h - q(s, h, h * 2), c = Math.sqrt(Math.max(o * o - u * u, 0));
3159
+ r = (Math.asin(at(c / o)) * ut - 90) * 2;
3112
3160
  }
3113
- return E(r, 0, e);
3161
+ return G(r, 0, e);
3114
3162
  }
3115
3163
  getStackHeight(t) {
3116
3164
  const e = this.m_Book.papers;
@@ -3121,9 +3169,9 @@ class Qe extends le {
3121
3169
  return s;
3122
3170
  }
3123
3171
  getStackZ(t) {
3124
- t = Z(t, 0, this.m_StackHeight);
3172
+ t = q(t, 0, this.m_StackHeight);
3125
3173
  const e = t - this.m_StackHeight * 0.5;
3126
- return Math.asin(Z(e / this.m_RadiusY, -1, 1)) * et;
3174
+ return Math.asin(q(e / this.m_RadiusY, -1, 1)) * ut;
3127
3175
  }
3128
3176
  computeTh() {
3129
3177
  const t = this.m_Book.papers;
@@ -3150,46 +3198,46 @@ class Qe extends le {
3150
3198
  this.updatePaperPositionWithTh(i, e);
3151
3199
  this.m_Root.updateMatrixWorld(!0), this.refreshCaseMaterials();
3152
3200
  const s = this.spineAngle();
3153
- this.updateCaseMesh(s), this.updateGlueVertices(s);
3201
+ this.updateGlueVertices(s);
3154
3202
  for (const i of t)
3155
3203
  i.updateMesh();
3156
- this.updateRootPosition();
3204
+ this.updateCaseMesh(s), this.updateRootPosition();
3157
3205
  }
3158
3206
  // ── updateGlueVertices ────────────────────────────────────────────────
3159
3207
  //
3160
3208
  // Rewrites each paper's flex-zone vertices: a quadratic bezier from its
3161
3209
  // permanent anchor on the spine (glue line for pages, hinge edge for
3162
3210
  // 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.
3211
+ // spine and draws the glued gutter valley / cloth hinge groove.
3164
3212
  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;
3213
+ 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: h, normalAt: u } = this.caseCurve();
3214
+ for (let c = 0; c < s; c++) {
3215
+ const d = e[c], f = d.transform, g = d.meshData.pattern, m = d.meshData.baseVertices, _ = g.baseZArray, p = g.baseXArray.length, M = _.length, C = this.m_BindingVertexCount + 1, y = g.xNoneSeamIndexes, P = f.position.clone();
3216
+ let B, D, H, z;
3169
3217
  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;
3218
+ const T = c < Math.floor(s / 2) ? this.spineHalf : -this.spineHalf;
3219
+ B = -T * r, D = T * n, H = -n, z = -r;
3172
3220
  } 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;
3221
+ const A = at(0.5 - this.m_GlueY[c] / this.m_StackHeight), T = h(A), b = u(A);
3222
+ B = T.x - b.x * o, D = T.y - b.y * o, H = b.x, z = b.y;
3175
3223
  }
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
3224
+ const E = this.bindingWidthFor(d.isCover) * 0.6, W = Math.min(0.01, this.m_Book.coverPaperSetup.thickness * 0.5), N = f.matrixWorld.clone().invert().multiply(i);
3225
+ for (let A = 0; A < M; A++) {
3226
+ const T = _[A], b = new l.Vector3(
3227
+ B + H * W,
3228
+ D + z * W,
3229
+ P.z + T
3230
+ ), Q = new l.Vector3(B, D, P.z + T), F = P.clone();
3231
+ F.z += T;
3232
+ const tt = d.getDirection(T).multiplyScalar(E).add(F.clone()), J = A * p, X = b.applyMatrix4(N), O = Q.clone().applyMatrix4(N), x = tt.clone().applyMatrix4(N), j = F.clone().applyMatrix4(N);
3233
+ m[J] = X, m[J + y[1]] = O;
3234
+ for (let R = 2; R < C; R++) {
3235
+ const U = ht(1, C, R);
3236
+ m[J + y[R]] = Dt(
3237
+ O,
3238
+ x,
3239
+ j,
3240
+ U
3193
3241
  );
3194
3242
  }
3195
3243
  }
@@ -3216,7 +3264,7 @@ class Qe extends le {
3216
3264
  this.m_Book.hasCover && t.length > 0 && (t[0].renderer.transform.visible = !0, t[t.length - 1].renderer.transform.visible = !0);
3217
3265
  }
3218
3266
  }
3219
- class $e {
3267
+ class os {
3220
3268
  constructor(t) {
3221
3269
  this.mesh = t;
3222
3270
  }
@@ -3230,7 +3278,7 @@ class $e {
3230
3278
  this.mesh.castShadow = t;
3231
3279
  }
3232
3280
  get bounds() {
3233
- const t = new u.Box3();
3281
+ const t = new l.Box3();
3234
3282
  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
3283
  }
3236
3284
  get transform() {
@@ -3240,15 +3288,15 @@ class $e {
3240
3288
  return this.mesh;
3241
3289
  }
3242
3290
  }
3243
- class os extends ce {
3291
+ class fs extends fe {
3244
3292
  constructor() {
3245
- super(...arguments), this.quality = 3, this.setup = new je();
3293
+ super(...arguments), this.quality = 3, this.setup = new is();
3246
3294
  }
3247
3295
  createBound(t, e, s, i) {
3248
- return new Qe(this.quality, this.setup, t, e);
3296
+ return new rs(this.quality, this.setup, t, e);
3249
3297
  }
3250
3298
  }
3251
- class ue {
3299
+ class pe {
3252
3300
  constructor(t) {
3253
3301
  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;
3254
3302
  }
@@ -3278,8 +3326,8 @@ class ue {
3278
3326
  const n = i.split(/\s+/);
3279
3327
  let r = "";
3280
3328
  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;
3329
+ const h = r ? `${r} ${o}` : o;
3330
+ t.measureText(h).width > this.width && r ? (s.push(r), r = o) : r = h;
3283
3331
  }
3284
3332
  r && s.push(r);
3285
3333
  }
@@ -3325,8 +3373,8 @@ class ue {
3325
3373
  t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top";
3326
3374
  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;
3327
3375
  if (this.rotation !== 0) {
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);
3376
+ const h = this.x + i / 2, u = this.y + r / 2;
3377
+ t.translate(h, u), t.rotate(this.rotation), t.translate(-h, -u);
3330
3378
  }
3331
3379
  this.background && (t.fillStyle = this.background, t.fillRect(
3332
3380
  this.x - this.backgroundPadding,
@@ -3336,49 +3384,49 @@ class ue {
3336
3384
  ), 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);
3337
3385
  let o = this.y;
3338
3386
  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;
3387
+ for (let h = 0; h < e.length; h++) {
3388
+ let u = this.x;
3389
+ this.textAlign === "center" ? u = this.x + (i - t.measureText(e[h]).width) / 2 : this.textAlign === "right" && (u = this.x + i - t.measureText(e[h]).width);
3390
+ const c = o + h * s;
3391
+ if (t.fillText(e[h], u, c), this.textDecoration !== "none") {
3392
+ const d = t.shadowColor, f = t.shadowBlur;
3345
3393
  t.shadowColor = "", t.shadowBlur = 0;
3346
- const _ = t.measureText(e[c]).width;
3394
+ const g = t.measureText(e[h]).width;
3347
3395
  if (t.beginPath(), t.strokeStyle = this.color, t.lineWidth = 1, this.textDecoration === "underline") {
3348
- const m = a + this.fontSize + 2;
3349
- t.moveTo(l, m), t.lineTo(l + _, m);
3396
+ const m = c + this.fontSize + 2;
3397
+ t.moveTo(u, m), t.lineTo(u + g, m);
3350
3398
  } else if (this.textDecoration === "strikethrough") {
3351
- const m = a + this.fontSize * 0.55;
3352
- t.moveTo(l, m), t.lineTo(l + _, m);
3399
+ const m = c + this.fontSize * 0.55;
3400
+ t.moveTo(u, m), t.lineTo(u + g, m);
3353
3401
  }
3354
- t.stroke(), t.shadowColor = d, t.shadowBlur = g;
3402
+ t.stroke(), t.shadowColor = d, t.shadowBlur = f;
3355
3403
  }
3356
3404
  }
3357
3405
  t.restore();
3358
3406
  }
3359
3407
  }
3360
- function Ke(h) {
3361
- return h.map instanceof u.Texture;
3408
+ function as(a) {
3409
+ return a.map instanceof l.Texture;
3362
3410
  }
3363
- function me(h, t) {
3364
- h.traverse((e) => {
3411
+ function xe(a, t) {
3412
+ a.traverse((e) => {
3365
3413
  if (!e.isMesh) return;
3366
3414
  const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
3367
3415
  for (const n of i)
3368
- Ke(n) && n.map.image === t && (n.map.needsUpdate = !0);
3416
+ as(n) && n.map.image === t && (n.map.needsUpdate = !0);
3369
3417
  });
3370
3418
  }
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);
3419
+ function Me(a, t) {
3420
+ t.x !== void 0 && (a.x = t.x), t.y !== void 0 && (a.y = t.y), t.width !== void 0 && (a.width = t.width), t.text !== void 0 && (a.text = t.text), t.fontFamily !== void 0 && (a.fontFamily = t.fontFamily), t.fontSize !== void 0 && (a.fontSize = t.fontSize), t.fontWeight !== void 0 && (a.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (a.fontStyle = t.fontStyle), t.color !== void 0 && (a.color = t.color), t.lineHeight !== void 0 && (a.lineHeight = t.lineHeight), t.textAlign !== void 0 && (a.textAlign = t.textAlign), t.opacity !== void 0 && (a.opacity = t.opacity), t.shadowColor !== void 0 && (a.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (a.shadowBlur = t.shadowBlur), t.shadowOffsetX !== void 0 && (a.shadowOffsetX = t.shadowOffsetX), t.shadowOffsetY !== void 0 && (a.shadowOffsetY = t.shadowOffsetY), t.textTransform !== void 0 && (a.textTransform = t.textTransform), t.textDecoration !== void 0 && (a.textDecoration = t.textDecoration), t.background !== void 0 && (a.background = t.background), t.backgroundPadding !== void 0 && (a.backgroundPadding = t.backgroundPadding), t.maxLines !== void 0 && (a.maxLines = t.maxLines), t.height !== void 0 && (a.height = t.height), t.verticalAlign !== void 0 && (a.verticalAlign = t.verticalAlign), t.rotation !== void 0 && (a.rotation = t.rotation);
3373
3421
  }
3374
- class hs {
3422
+ class gs {
3375
3423
  constructor(t) {
3376
- this.texts = [], this._textureST = new u.Vector4(1, 1, 0, 0), this._dirty = !0;
3424
+ this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0), this._dirty = !0;
3377
3425
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
3378
3426
  this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
3379
3427
  const i = this.canvas.getContext("2d");
3380
3428
  if (!i) throw new Error("TextOverlayContent: could not get 2D context");
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;
3429
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace;
3382
3430
  }
3383
3431
  get texture() {
3384
3432
  return this._texture;
@@ -3399,7 +3447,7 @@ class hs {
3399
3447
  }
3400
3448
  // ── Text API ─────────────────────────────────────────────────────────────
3401
3449
  addText(t) {
3402
- const e = new ue(t);
3450
+ const e = new pe(t);
3403
3451
  return this.texts.push(e), this._dirty = !0, e;
3404
3452
  }
3405
3453
  removeText(t) {
@@ -3409,7 +3457,7 @@ class hs {
3409
3457
  /** Update a text block by index. Only provided fields are changed. */
3410
3458
  updateText(t, e) {
3411
3459
  const s = this.texts[t];
3412
- s && (de(s, e), this._dirty = !0);
3460
+ s && (Me(s, e), this._dirty = !0);
3413
3461
  }
3414
3462
  // ── Per-frame update ─────────────────────────────────────────────────────
3415
3463
  /**
@@ -3433,7 +3481,7 @@ class hs {
3433
3481
  * source image is this overlay's canvas.
3434
3482
  */
3435
3483
  syncMaterials(t) {
3436
- me(t, this.canvas);
3484
+ xe(t, this.canvas);
3437
3485
  }
3438
3486
  // ── IPageContent ─────────────────────────────────────────────────────────
3439
3487
  isPointOverUI(t) {
@@ -3447,9 +3495,9 @@ class hs {
3447
3495
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
3448
3496
  }
3449
3497
  }
3450
- class ee {
3498
+ class ae {
3451
3499
  constructor(t, e) {
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);
3500
+ this._spread = t, this._textureST = e === "left" ? new l.Vector4(0.5, 1, 0, 0) : new l.Vector4(0.5, 1, 0.5, 0);
3453
3501
  }
3454
3502
  get texture() {
3455
3503
  return this._spread.texture;
@@ -3465,18 +3513,18 @@ class ee {
3465
3513
  setActive(t) {
3466
3514
  }
3467
3515
  }
3468
- function as(h) {
3516
+ function ps(a) {
3469
3517
  const t = [];
3470
- for (let e = 1; e + 1 < h; e += 2)
3518
+ for (let e = 1; e + 1 < a; e += 2)
3471
3519
  t.push(e);
3472
3520
  return t;
3473
3521
  }
3474
- class cs {
3522
+ class xs {
3475
3523
  constructor(t) {
3476
3524
  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;
3477
3525
  const e = this.canvas.getContext("2d");
3478
3526
  if (!e) throw new Error("SpreadContent: could not get 2D context");
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");
3527
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace, this.left = new ae(this, "left"), this.right = new ae(this, "right");
3480
3528
  }
3481
3529
  get texture() {
3482
3530
  return this._texture;
@@ -3494,7 +3542,7 @@ class cs {
3494
3542
  }
3495
3543
  // ── Text API ─────────────────────────────────────────────────────────────
3496
3544
  addText(t) {
3497
- const e = new ue(t);
3545
+ const e = new pe(t);
3498
3546
  return this.texts.push(e), this._dirty = !0, e;
3499
3547
  }
3500
3548
  removeText(t) {
@@ -3504,7 +3552,7 @@ class cs {
3504
3552
  /** Update a text block by index. Only provided fields are changed. */
3505
3553
  updateText(t, e) {
3506
3554
  const s = this.texts[t];
3507
- s && (de(s, e), this._dirty = !0);
3555
+ s && (Me(s, e), this._dirty = !0);
3508
3556
  }
3509
3557
  // ── Per-frame update ─────────────────────────────────────────────────────
3510
3558
  /**
@@ -3527,117 +3575,117 @@ class cs {
3527
3575
  * source image is this spread's canvas.
3528
3576
  */
3529
3577
  syncMaterials(t) {
3530
- me(t, this.canvas);
3578
+ xe(t, this.canvas);
3531
3579
  }
3532
3580
  // ── Lifecycle ────────────────────────────────────────────────────────────
3533
3581
  dispose() {
3534
3582
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
3535
3583
  }
3536
3584
  }
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;
3585
+ const he = 256;
3586
+ function hs(a, t, e, s, i, n, r) {
3587
+ const o = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
3588
+ if (o <= 0 || h <= 0) return;
3541
3589
  if (r === "fill") {
3542
- h.drawImage(t, e, s, i, n);
3590
+ a.drawImage(t, e, s, i, n);
3543
3591
  return;
3544
3592
  }
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);
3593
+ const u = r === "contain" ? Math.min(i / o, n / h) : Math.max(i / o, n / h), c = o * u, d = h * u;
3594
+ a.drawImage(t, e + (i - c) * 0.5, s + (n - d) * 0.5, c, d);
3547
3595
  }
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;
3596
+ function Ms(a, t, e, s, i) {
3597
+ const n = i ? 0 : Math.round(Math.min(t, e) * 0.11), r = n, o = n, h = t - n * 2, u = e - n * 2, c = a.naturalWidth || a.width, d = a.naturalHeight || a.height;
3598
+ if (s === "fill" || c <= 0 || d <= 0)
3599
+ return { x: r, y: o, width: h, height: u };
3600
+ const f = s === "contain" ? Math.min(h / c, u / d) : Math.max(h / c, u / d), g = c * f, m = d * f;
3553
3601
  return {
3554
- x: r + (c - _) * 0.5,
3555
- y: o + (l - m) * 0.5,
3556
- width: _,
3602
+ x: r + (h - g) * 0.5,
3603
+ y: o + (u - m) * 0.5,
3604
+ width: g,
3557
3605
  height: m
3558
3606
  };
3559
3607
  }
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)
3608
+ function cs(a, t, e, s, i, n, r, o) {
3609
+ const h = n ? Math.round(n * he) : 512, u = r ? Math.round(r * he) : 512, c = document.createElement("canvas");
3610
+ c.width = h, c.height = u;
3611
+ const d = c.getContext("2d");
3612
+ if (d.fillStyle = a, d.fillRect(0, 0, h, u), e)
3565
3613
  if (o)
3566
3614
  d.drawImage(e, o.x, o.y, o.width, o.height);
3567
3615
  else {
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);
3616
+ const f = i ? 0 : Math.round(Math.min(h, u) * 0.11);
3617
+ hs(d, e, f, f, h - f * 2, u - f * 2, s);
3570
3618
  }
3571
3619
  else {
3572
3620
  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);
3621
+ const f = Math.round(Math.min(h, u) * 0.094);
3622
+ d.font = `bold ${f}px Arial`, d.textAlign = "center", d.textBaseline = "middle", d.fillText(t, h / 2, u / 2);
3575
3623
  }
3576
- return a;
3624
+ return c;
3577
3625
  }
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;
3626
+ function ys(a, t, e, s, i, n, r, o) {
3627
+ const h = cs(a, t, e, s, i, n, r, o), u = new l.CanvasTexture(h);
3628
+ return u.colorSpace = l.SRGBColorSpace, u;
3581
3629
  }
3582
- async function ms(h) {
3583
- if (!h) return null;
3584
- const t = URL.createObjectURL(h), e = new Image();
3630
+ async function Cs(a) {
3631
+ if (!a) return null;
3632
+ const t = URL.createObjectURL(a), e = new Image();
3585
3633
  e.decoding = "async", e.src = t;
3586
3634
  try {
3587
3635
  return await new Promise((s, i) => {
3588
- e.onload = () => s(), e.onerror = () => i(new Error(`Failed to decode image: ${h.name}`));
3636
+ e.onload = () => s(), e.onerror = () => i(new Error(`Failed to decode image: ${a.name}`));
3589
3637
  }), { image: e, objectUrl: t };
3590
3638
  } catch (s) {
3591
3639
  return URL.revokeObjectURL(t), console.error(s), null;
3592
3640
  }
3593
3641
  }
3594
3642
  export {
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 GluedBookBinding,
3612
- Qe as GluedBookBound,
3613
- je as GluedSetup,
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
3643
+ Fe as AnimationCurve,
3644
+ Vt as AutoTurnDirection,
3645
+ wt as AutoTurnMode,
3646
+ gt as AutoTurnSetting,
3647
+ He as AutoTurnSettingCurveTimeMode,
3648
+ Ae as AutoTurnSettingMode,
3649
+ Jt as AutoTurnSettings,
3650
+ zt as Book,
3651
+ fe as BookBinding,
3652
+ ge as BookBound,
3653
+ ms as BookContent,
3654
+ mt as BookDirection,
3655
+ me as BookHeightException,
3656
+ ds as BookPointerInteraction,
3657
+ De as BookRenderer,
3658
+ It as Cylinder,
3659
+ fs as GluedBookBinding,
3660
+ rs as GluedBookBound,
3661
+ is as GluedSetup,
3662
+ Re as MeshFactory,
3663
+ he as PX_PER_UNIT,
3664
+ us as PageContent,
3665
+ Be as Paper,
3666
+ Tt as PaperBorder,
3667
+ qt as PaperMaterialData,
3668
+ $t as PaperMeshData,
3669
+ Ie as PaperMeshDataPool,
3670
+ ls as PaperMeshUtility,
3671
+ _t as PaperNode,
3672
+ ce as PaperNodeMargin,
3673
+ de as PaperPattern,
3674
+ At as PaperSeam,
3675
+ ft as PaperSetup,
3676
+ bt as PaperUVMargin,
3677
+ Ve as RendererFactory,
3678
+ xs as SpreadContent,
3679
+ te as SpritePageContent2,
3680
+ _s as StapleBookBinding,
3681
+ Ye as StapleBookBound,
3682
+ je as StapleSetup,
3683
+ pe as TextBlock,
3684
+ gs as TextOverlayContent,
3685
+ Ms as computeDefaultImageRect,
3686
+ cs as createPageCanvas,
3687
+ ys as createPageTexture,
3688
+ hs as drawImageWithFit,
3689
+ ps as getSpreadPairs,
3690
+ Cs as loadImage
3643
3691
  };