@objectifthunes/three-book 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import * as o from "three";
2
- class ut {
1
+ import * as l from "three";
2
+ class wt {
3
3
  constructor() {
4
- this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0, this._positionOut = new o.Vector3(), this._scratchRP1 = new o.Vector3(), this._scratchRP2 = new o.Vector3(), this._scratchRollClosest = new o.Vector3(), this._scratchRollEuler = new o.Vector3(), this._scratchOffsetRoll = new o.Vector3();
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 ut {
33
33
  * Writes result into `out` and returns it.
34
34
  */
35
35
  eulerRotateVector(t, e, s, i) {
36
- const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), c = Math.sin(n), u = t * a, l = t * c, _ = 0, d = Math.cos(h), f = Math.sin(h), m = u * d + _ * f, g = l, p = -u * f + _ * d;
37
- return i.set(m, g, p);
36
+ const n = s * Math.PI / 180, h = e * Math.PI / 180, a = Math.cos(n), o = Math.sin(n), u = t * a, c = t * o, m = 0, f = Math.cos(h), d = Math.sin(h), _ = u * f + m * d, g = c, p = -u * d + m * f;
37
+ return i.set(_, g, p);
38
38
  }
39
39
  /**
40
40
  * Rolls `point` in place around the cylinder. Mutates and returns `point`.
@@ -78,37 +78,37 @@ class ut {
78
78
  }
79
79
  // ── Value-type clone ──────────────────────────────────────────────────
80
80
  clone() {
81
- const t = new ut();
81
+ const t = new wt();
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 ft(r, t, e, s, i = 1 / 0, n = 1 / 60) {
85
+ function dt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
86
86
  s = Math.max(s, 1e-4);
87
- const h = 2 / s, a = h * n, c = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
87
+ const h = 2 / s, a = h * n, o = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
88
88
  let u = r - t;
89
- const l = t, _ = i * s;
90
- u = o.MathUtils.clamp(u, -_, _), t = r - u;
91
- const d = (e + h * u) * n;
92
- e = (e - h * d) * c;
93
- let f = t + (u + d) * c;
94
- return l - r > 0 == f > l && (f = l, e = (f - l) / n), { value: f, velocity: e };
95
- }
96
- function Yt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
97
- const h = ft(
89
+ const c = t, m = i * s;
90
+ u = l.MathUtils.clamp(u, -m, m), t = r - u;
91
+ const f = (e + h * u) * n;
92
+ e = (e - h * f) * o;
93
+ let d = t + (u + f) * o;
94
+ return c - r > 0 == d > c && (d = c, e = (d - c) / n), { value: d, velocity: e };
95
+ }
96
+ function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
97
+ const h = dt(
98
98
  r.x,
99
99
  t.x,
100
100
  e.x,
101
101
  s.x,
102
102
  i,
103
103
  n
104
- ), a = ft(
104
+ ), a = dt(
105
105
  r.y,
106
106
  t.y,
107
107
  e.y,
108
108
  s.y,
109
109
  i,
110
110
  n
111
- ), c = ft(
111
+ ), o = dt(
112
112
  r.z,
113
113
  t.z,
114
114
  e.z,
@@ -116,15 +116,9 @@ function Yt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
116
116
  i,
117
117
  n
118
118
  );
119
- return e.set(h.velocity, a.velocity, c.velocity), new o.Vector3(h.value, a.value, c.value);
120
- }
121
- function Kt(r) {
122
- return new o.Vector3(r.x, 0, r.y);
123
- }
124
- function Jt(r) {
125
- return new o.Vector3(r.x, r.z, 0);
119
+ return e.set(h.velocity, a.velocity, o.velocity), r.set(h.value, a.value, o.value);
126
120
  }
127
- function Tt(r, t, e) {
121
+ function vt(r, t, e) {
128
122
  const s = t * t - 4 * r * e;
129
123
  if (s < 0)
130
124
  return { rootCount: 0, root0: 0, root1: 0 };
@@ -139,86 +133,90 @@ function Tt(r, t, e) {
139
133
  };
140
134
  }
141
135
  }
142
- function vt(r, t, e) {
143
- return te(r, t, e) ? r.clone() : ee(
144
- new o.Vector2(r.x, t.y),
136
+ const kt = new l.Vector2();
137
+ function Bt(r, t, e, s) {
138
+ return se(r, t, e) ? s.copy(r) : (kt.set(r.x, t.y), ie(
139
+ kt,
145
140
  r,
146
141
  t,
147
- e
148
- );
142
+ e,
143
+ s
144
+ ));
149
145
  }
150
- function te(r, t, e) {
146
+ function se(r, t, e) {
151
147
  const s = r.x - t.x;
152
148
  let i = r.y - t.y;
153
149
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
154
150
  }
155
- function ee(r, t, e, s) {
156
- const i = e.x, n = e.y, h = r.x, a = r.y, c = t.x, u = t.y, l = s.x, _ = s.y, d = 1 / (l * l), f = 1 / (_ * _);
157
- if (Math.abs(h - c) < 1e-5) {
158
- if (h >= i - l && h <= i + l) {
159
- const m = Tt(
160
- f,
161
- -2 * f * n,
162
- d * (h * h - 2 * i * h + i * i) + f * n * n - 1
151
+ function ie(r, t, e, s, i) {
152
+ const n = e.x, h = e.y, a = r.x, o = r.y, u = t.x, c = t.y, m = s.x, f = s.y, d = 1 / (m * m), _ = 1 / (f * f);
153
+ if (Math.abs(a - u) < 1e-5) {
154
+ if (a >= n - m && a <= n + m) {
155
+ const g = vt(
156
+ _,
157
+ -2 * _ * h,
158
+ d * (a * a - 2 * n * a + n * n) + _ * h * h - 1
163
159
  );
164
- if (m.rootCount === 1)
165
- return new o.Vector2(h, m.root0);
166
- if (m.rootCount === 2) {
167
- let g = m.root0, p = m.root1;
168
- return a < u && ([g, p] = [p, g]), new o.Vector2(h, p);
160
+ if (g.rootCount === 1)
161
+ return i.set(a, g.root0);
162
+ if (g.rootCount === 2) {
163
+ let p = g.root0, M = g.root1;
164
+ return o < c && ([p, M] = [M, p]), i.set(a, M);
169
165
  }
170
166
  }
171
167
  } else {
172
- const m = (u - a) / (c - h), g = a - m * h, p = g - n, M = Tt(
173
- d + f * m * m,
174
- 2 * p * m * f - 2 * i * d,
175
- i * i * d + p * p * f - 1
168
+ const g = (c - o) / (u - a), p = o - g * a, M = p - h, T = vt(
169
+ d + _ * g * g,
170
+ 2 * M * g * _ - 2 * n * d,
171
+ n * n * d + M * M * _ - 1
176
172
  );
177
- if (M.rootCount === 1)
178
- return new o.Vector2(M.root0, m * M.root0 + g);
179
- if (M.rootCount === 2) {
180
- let T = M.root0, C = M.root1;
181
- return h < c && ([T, C] = [C, T]), new o.Vector2(C, m * C + g);
173
+ if (T.rootCount === 1)
174
+ return i.set(T.root0, g * T.root0 + p);
175
+ if (T.rootCount === 2) {
176
+ let P = T.root0, C = T.root1;
177
+ return a < u && ([P, C] = [C, P]), i.set(C, g * C + p);
182
178
  }
183
179
  }
184
- return r.clone();
180
+ return i.copy(r);
185
181
  }
186
- function kt(r, t) {
187
- const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
188
- return new o.Ray(e, s.sub(e).normalize());
182
+ const ft = new l.Vector3(), Rt = new l.Vector3(), bt = new l.Ray();
183
+ function Dt(r, t) {
184
+ return ft.copy(r.origin).applyMatrix4(t), Rt.copy(r.origin).add(r.direction).applyMatrix4(t), bt.set(ft, Rt.sub(ft).normalize()), bt;
189
185
  }
190
- function se(r) {
191
- return new o.Vector4(-r.x, r.y, r.z + r.x, r.w);
186
+ function ne(r) {
187
+ const t = r.x;
188
+ r.set(-t, r.y, r.z + t, r.w);
192
189
  }
193
- function ie(r) {
194
- return new o.Vector4(r.x, -r.y, r.z, r.w + r.y);
190
+ function re(r) {
191
+ const t = r.y;
192
+ r.set(r.x, -t, r.z, r.w + t);
195
193
  }
196
194
  var j = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(j || {});
197
195
  const J = Math.PI / 180, et = 180 / Math.PI;
198
196
  function H(r, t, e) {
199
197
  return r < t ? t : r > e ? e : r;
200
198
  }
201
- function ct(r) {
199
+ function lt(r) {
202
200
  return r < 0 ? 0 : r > 1 ? 1 : r;
203
201
  }
204
202
  function F(r, t, e) {
205
- return e = ct(e), r + (t - r) * e;
203
+ return e = lt(e), r + (t - r) * e;
206
204
  }
207
- function Bt(r, t, e) {
205
+ function It(r, t, e) {
208
206
  return r + (t - r) * e;
209
207
  }
210
208
  function Q(r, t, e) {
211
- return r !== t ? ct((e - r) / (t - r)) : 0;
209
+ return r !== t ? lt((e - r) / (t - r)) : 0;
212
210
  }
213
- var mt = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(mt || {});
214
- const ne = 1192093e-13;
215
- function Rt(r, t, e) {
216
- return e = ct((e - r) / (t - r)), e * e * (3 - 2 * e);
211
+ var ut = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(ut || {});
212
+ const he = 1192093e-13;
213
+ function Vt(r, t, e) {
214
+ return e = lt((e - r) / (t - r)), e * e * (3 - 2 * e);
217
215
  }
218
- class re {
216
+ class ae {
219
217
  // ---- Constructor ----
220
218
  constructor(t, e, s, i) {
221
- this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new o.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new ut(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new o.Plane(), this.m_StartHandle = new o.Vector3(), this.m_CurrentHandle = new o.Vector3(), this.m_EndHandle = new o.Vector3(), this.m_PrevHandle = new o.Vector3(), this.m_HandleOffset = new o.Vector3(), this.m_HandleVelocity = new o.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new o.Vector3(), this._ucCurrentHandle = new o.Vector3(), this._ucHandleDir = new o.Vector3(), this._ucA = new o.Vector3(), this._ucB = new o.Vector3(), this._ucMid = new o.Vector3(), this._ucRollResult = new o.Vector3(), this._ucCylDir = new o.Vector3(), this._utV1 = new o.Vector3(), this._utV2 = new o.Vector3(), this._utV3 = new o.Vector3(), this._utV4 = new o.Vector3(), this._chP = new o.Vector3(), this._chA = new o.Vector3(), this._chC = new o.Vector3(), this._chEllipseCenter1 = new o.Vector2(), this._chEllipseCenter2 = new o.Vector2(), this._chEllipseSize1 = new o.Vector2(), this._chEllipseSize2 = new o.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
219
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new l.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new wt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new l.Plane(), this.m_StartHandle = new l.Vector3(), this.m_CurrentHandle = new l.Vector3(), this.m_EndHandle = new l.Vector3(), this.m_PrevHandle = new l.Vector3(), this.m_HandleOffset = new l.Vector3(), this.m_HandleVelocity = new l.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this._ucStartHandle = new l.Vector3(), this._ucCurrentHandle = new l.Vector3(), this._ucHandleDir = new l.Vector3(), this._ucA = new l.Vector3(), this._ucB = new l.Vector3(), this._ucMid = new l.Vector3(), this._ucRollResult = new l.Vector3(), this._ucCylDir = new l.Vector3(), this._utV1 = new l.Vector3(), this._utV2 = new l.Vector3(), this._utV3 = new l.Vector3(), this._utV4 = new l.Vector3(), this._chP = new l.Vector3(), this._chA = new l.Vector3(), this._chC = new l.Vector3(), this._chEllipseCenter1 = new l.Vector2(), this._chEllipseCenter2 = new l.Vector2(), this._chEllipseSize1 = new l.Vector2(), this._chEllipseSize2 = new l.Vector2(), this._chP2 = new l.Vector2(), this._dirResult = new l.Vector3(), this._gdA = new l.Vector3(), this._gdB = new l.Vector3(), this._rlMatrix = new l.Matrix4(), this._rlPlane = new l.Plane(new l.Vector3(0, 1, 0), 0), this._rlTarget = new l.Vector3(), this._rlNormal = new l.Vector3(), this._utTarget = new l.Vector3(), this._ufSmoothTime = new l.Vector3(), this._umFrontST = new l.Vector4(), this._umBackST = new l.Vector4(), this._h2uResult = new l.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
222
220
  }
223
221
  // ---- Properties (mirrors C#) ----
224
222
  get isMeshChanged() {
@@ -259,7 +257,7 @@ class re {
259
257
  }
260
258
  get direction() {
261
259
  const e = this.zTime * 180 * J, s = Math.cos(e), i = Math.sin(e);
262
- return new o.Vector3(-s, -i, 0);
260
+ return this._dirResult.set(-s, -i, 0);
263
261
  }
264
262
  get isTurning() {
265
263
  return this.m_IsTurning;
@@ -328,42 +326,42 @@ class re {
328
326
  this.m_MinTurningRadius = t;
329
327
  }
330
328
  updateTurningRadius(t = 1) {
331
- let e = Math.max(this.m_Stiffness, 1 - ct(t));
329
+ let e = Math.max(this.m_Stiffness, 1 - lt(t));
332
330
  e <= 0.5 ? this.m_TurningRadius = Q(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - Q(0.5, 1, e)), 5) * J), this.m_TurningRadius = Math.max(
333
331
  this.m_TurningRadius,
334
332
  this.m_MinTurningRadius
335
333
  );
336
334
  }
337
335
  startTurning(t) {
338
- var n, h;
336
+ var i, n;
339
337
  const e = t.clone();
340
- t = kt(
338
+ t = Dt(
341
339
  t,
342
- this.m_Transform.matrixWorld.clone().invert()
340
+ this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
343
341
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
344
- new o.Vector3(0, 1, 0).applyQuaternion(this.m_Transform.quaternion),
342
+ this._rlNormal.set(0, 1, 0).applyQuaternion(this.m_Transform.quaternion),
345
343
  this.m_Transform.position
346
- );
347
- const s = new o.Plane(new o.Vector3(0, 1, 0), 0), i = new o.Vector3();
348
- if (t.intersectPlane(s, i) !== null) {
349
- const a = i;
350
- if (a.x > 0 && a.x < this.m_Size.x && a.z > 0 && a.z < this.m_Size.y) {
351
- if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(a), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), a.x < this.m_Size.x * 0.9) {
352
- this.m_HandleOffset.set(a.x - this.m_Size.x, 0, 0);
353
- const c = this.m_Transform.scale;
354
- c.x *= -1;
344
+ ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
345
+ const s = this._rlTarget;
346
+ if (t.intersectPlane(this._rlPlane, s) !== null) {
347
+ const h = s;
348
+ if (h.x > 0 && h.x < this.m_Size.x && h.z > 0 && h.z < this.m_Size.y) {
349
+ if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(h), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), h.x < this.m_Size.x * 0.9) {
350
+ this.m_HandleOffset.set(h.x - this.m_Size.x, 0, 0);
351
+ const a = this.m_Transform.scale;
352
+ a.x *= -1;
355
353
  }
356
354
  return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
357
355
  0
358
356
  /* Highpoly */
359
- ), (n = this.m_Prev) == null || n.trySwitchMeshData(1), (h = this.m_Next) == null || h.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
357
+ ), (i = this.m_Prev) == null || i.trySwitchMeshData(1), (n = this.m_Next) == null || n.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
360
358
  }
361
359
  }
362
360
  return !1;
363
361
  }
364
362
  stopTurning() {
365
363
  this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
366
- const t = new o.Vector3(0, 0, 0);
364
+ const t = new l.Vector3(0, 0, 0);
367
365
  for (const e of this.m_HandleVelocities)
368
366
  t.add(e);
369
367
  t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = F(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
@@ -373,11 +371,11 @@ class re {
373
371
  * `dt` replaces Time.deltaTime.
374
372
  */
375
373
  updateTurning(t, e = 1 / 60) {
376
- const s = new o.Vector3();
374
+ const s = this._utTarget;
377
375
  if (t.intersectPlane(this.m_WorldPlane, s) !== null) {
378
376
  const i = s;
379
377
  this.m_Book.bound.resetPaperPosition(this), this.m_CurrentHandle.copy(
380
- this.m_Transform.worldToLocal(i.clone())
378
+ this.m_Transform.worldToLocal(this.m_CurrentHandle.copy(i))
381
379
  ), this.m_CurrentHandle.y = 0, this.m_CurrentHandle.add(this.m_HandleOffset), this.m_HandleVelocity.copy(this.m_CurrentHandle).sub(this.m_PrevHandle).divideScalar(e), this.m_HandleVelocities.length === 5 && this.m_HandleVelocities.shift(), this.m_HandleVelocities.push(this.m_HandleVelocity.clone()), this.m_PrevHandle.copy(this.m_CurrentHandle);
382
380
  }
383
381
  this.updateBaseVertices();
@@ -390,27 +388,21 @@ class re {
390
388
  var s, i;
391
389
  let e = !1;
392
390
  if (this.m_IsAutoTurning) {
393
- let n = ct(this.m_FallTime / this.m_FallDuration);
394
- n = Rt(0, 1, n), n = Rt(0, 1, n), this.m_CurrentHandle.lerpVectors(
391
+ let n = lt(this.m_FallTime / this.m_FallDuration);
392
+ n = Vt(0, 1, n), n = Vt(0, 1, n), this.m_CurrentHandle.lerpVectors(
395
393
  this.m_StartHandle,
396
394
  this.m_EndHandle,
397
395
  this.m_IsFallingLeft ? n : 1 - n
398
- ), this.m_FallTime += t, e = Math.abs(n - 1) < ne;
399
- } else {
400
- const n = new o.Vector3(
401
- this.m_FallTime,
402
- 0,
403
- this.m_FallTime * 0.75
404
- );
405
- this.m_CurrentHandle = Yt(
396
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < he;
397
+ } else
398
+ this._ufSmoothTime.set(this.m_FallTime, 0, this.m_FallTime * 0.75), ee(
406
399
  this.m_CurrentHandle,
407
400
  this.m_EndHandle,
408
401
  this.m_HandleVelocity,
409
- n,
402
+ this._ufSmoothTime,
410
403
  1 / 0,
411
404
  t
412
405
  ), e = Math.abs(this.m_EndHandle.x - this.m_CurrentHandle.x) < 1e-4;
413
- }
414
406
  if (e) {
415
407
  if (this.m_IsFallingLeft) {
416
408
  const n = this.m_Transform.scale;
@@ -430,12 +422,12 @@ class re {
430
422
  }
431
423
  getTextureCoordinate(t) {
432
424
  const e = this.raycastLocal(t, !0);
433
- return e !== null ? this.hit2UV(e) : new o.Vector2(0, 0);
425
+ return e !== null ? this.hit2UV(e) : new l.Vector2(0, 0);
434
426
  }
435
427
  raycast(t) {
436
428
  const e = {
437
- point: new o.Vector3(),
438
- textureCoordinate: new o.Vector2(),
429
+ point: new l.Vector3(),
430
+ textureCoordinate: new l.Vector2(),
439
431
  pageContent: null,
440
432
  paperIndex: 0,
441
433
  pageIndex: 0
@@ -448,7 +440,7 @@ class re {
448
440
  return { hit: !1, hitInfo: e };
449
441
  }
450
442
  hit2UV(t) {
451
- const e = new o.Vector2(
443
+ const e = this._h2uResult.set(
452
444
  Q(-this.sizeXOffset, this.m_Size.x, t.x),
453
445
  t.z / this.m_Size.y
454
446
  );
@@ -466,15 +458,15 @@ class re {
466
458
  * Returns the local-space hit point, or null if no hit / out of bounds.
467
459
  */
468
460
  raycastLocal(t, e = !1) {
469
- t = kt(
461
+ t = Dt(
470
462
  t,
471
- this.m_Transform.matrixWorld.clone().invert()
472
- );
473
- const s = new o.Plane(new o.Vector3(0, 1, 0), 0), i = new o.Vector3();
474
- if (t.intersectPlane(s, i) !== null) {
475
- const n = i;
476
- if (n.x > 0 && n.x < this.m_Size.x && n.z > 0 && n.z < this.m_Size.y || e)
477
- return n;
463
+ this._rlMatrix.copy(this.m_Transform.matrixWorld).invert()
464
+ ), this._rlPlane.set(this._rlPlane.normal.set(0, 1, 0), 0);
465
+ const s = this._rlTarget;
466
+ if (t.intersectPlane(this._rlPlane, s) !== null) {
467
+ const i = s;
468
+ if (i.x > 0 && i.x < this.m_Size.x && i.z > 0 && i.z < this.m_Size.y || e)
469
+ return i;
478
470
  }
479
471
  return null;
480
472
  }
@@ -503,9 +495,8 @@ class re {
503
495
  this.m_SubMeshCount !== t && (this.m_Renderer.setMaterials(
504
496
  t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
505
497
  ), this.m_SubMeshCount = t);
506
- const e = this.m_FrontContent.textureST.clone();
507
- let s = this.m_BackContent.textureST.clone();
508
- this.m_Book.direction > 1 ? s = ie(s) : s = se(s);
498
+ const e = this._umFrontST.copy(this.m_FrontContent.textureST), s = this._umBackST.copy(this.m_BackContent.textureST);
499
+ this.m_Book.direction > 1 ? re(s) : ne(s);
509
500
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
510
501
  if (t === 3) {
511
502
  let h = 0, a = 1;
@@ -539,8 +530,8 @@ class re {
539
530
  this.updateMaterials(), this.m_MeshData.updateMesh(), this.m_isMeshChanged = !0;
540
531
  }
541
532
  getDirection(t) {
542
- let e = new o.Vector3(0, 0, t), s = new o.Vector3(0.1, 0, t);
543
- return e = this.rollPoint(e), s = this.rollPoint(s), e = this.m_Transform.localToWorld(e), s = this.m_Transform.localToWorld(s), this.m_Transform.parent && (e = this.m_Transform.parent.worldToLocal(e), s = this.m_Transform.parent.worldToLocal(s)), e.sub(s).normalize();
533
+ const e = this._gdA.set(0, 0, t), s = this._gdB.set(0.1, 0, t);
534
+ return this.rollPoint(e), this.rollPoint(s), this.m_Transform.localToWorld(e), this.m_Transform.localToWorld(s), this.m_Transform.parent && (this.m_Transform.parent.worldToLocal(e), this.m_Transform.parent.worldToLocal(s)), e.sub(s).normalize();
544
535
  }
545
536
  updateTime() {
546
537
  if (this.isTurning || this.isFalling) {
@@ -561,7 +552,7 @@ class re {
561
552
  this._utV3.set(s[1], 0, i[i.length - 1]);
562
553
  const a = this.rollPoint(this._utV3);
563
554
  this._utV4.set(s[2], 0, i[i.length - 1]);
564
- const c = this.rollPoint(this._utV4), u = h.x - n.x, l = h.y - n.y, _ = c.x - a.x, d = c.y - a.y, f = Math.sqrt(u * u + l * l) || 1, m = Math.sqrt(_ * _ + d * d) || 1, g = et * Math.atan2(l / f, u / f), p = et * Math.atan2(d / m, _ / m), M = (g + p) / 2;
555
+ const o = this.rollPoint(this._utV4), u = h.x - n.x, c = h.y - n.y, m = o.x - a.x, f = o.y - a.y, d = Math.sqrt(u * u + c * c) || 1, _ = Math.sqrt(m * m + f * f) || 1, g = et * Math.atan2(c / d, u / d), p = et * Math.atan2(f / _, m / _), M = (g + p) / 2;
565
556
  this.m_ZTime = M / 180;
566
557
  } else
567
558
  this.m_XTime = 0, this.m_ZTime = 0;
@@ -571,58 +562,48 @@ class re {
571
562
  }
572
563
  clampHandle() {
573
564
  this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
574
- const t = this._chP.copy(this.m_CurrentHandle), e = this._chA.set(0, 0, 0), s = this._chC.set(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), h = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), c = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
565
+ const t = this._chP.copy(this.m_CurrentHandle), e = this._chA.set(0, 0, 0), s = this._chC.set(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), h = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), o = this.m_StartHandle.z, u = this._chEllipseCenter1.set(
575
566
  0,
576
- c + (e.z - c) * (h / i)
577
- ), l = this._chEllipseCenter2.set(
567
+ o + (e.z - o) * (h / i)
568
+ ), c = this._chEllipseCenter2.set(
578
569
  0,
579
- c + (s.z - c) * (a / n)
580
- ), _ = this._chEllipseSize1.set(i, h), d = this._chEllipseSize2.set(n, a);
570
+ o + (s.z - o) * (a / n)
571
+ ), m = this._chEllipseSize1.set(i, h), f = this._chEllipseSize2.set(n, a);
581
572
  t.x = H(t.x, -this.m_Size.x, this.m_Size.x);
582
- const f = Jt(t), m = vt(
583
- new o.Vector2(f.x, f.y),
584
- u,
585
- _
586
- ), g = vt(
587
- new o.Vector2(m.x, m.y),
588
- l,
589
- d
590
- ), p = Kt(
591
- new o.Vector3(g.x, g.y, 0)
592
- );
593
- this.m_CurrentHandle.copy(p);
573
+ const d = this._chP2.set(t.x, t.z);
574
+ Bt(d, u, m, d), Bt(d, c, f, d), this.m_CurrentHandle.set(d.x, 0, d.y);
594
575
  }
595
576
  updateCylinder() {
596
577
  const t = this._ucStartHandle.copy(this.m_StartHandle), e = this._ucCurrentHandle.copy(this.m_CurrentHandle), s = this._ucHandleDir.copy(t).sub(e).normalize();
597
578
  s.length() === 0 && s.set(1, 0, 0);
598
579
  const i = this.m_Size.x * 2 + this.m_TurningRadius * Math.PI, n = this._ucA.copy(t).sub(
599
580
  this._ucCylDir.copy(s).multiplyScalar(i)
600
- ), h = this._ucB.copy(t), a = new ut();
601
- a.radius = this.m_TurningRadius, this._ucCylDir.set(-s.z, 0, s.x), a.direction = this._ucCylDir;
602
- for (let c = 0; c < 100; c++) {
603
- this._ucMid.copy(n).add(h).multiplyScalar(0.5), a.position = this._ucMid, this.m_Cylinder = a, this.m_Book.bound.updatePaperPosition(this), this._ucRollResult.copy(t);
604
- const u = a.rollPoint(this._ucRollResult);
605
- if (Math.abs(e.x - u.x) < 1e-4) break;
606
- u.x > e.x ? h.copy(a.position) : n.copy(a.position);
581
+ ), h = this._ucB.copy(t);
582
+ this.m_Cylinder.radius = this.m_TurningRadius, this._ucCylDir.set(-s.z, 0, s.x), this.m_Cylinder.direction = this._ucCylDir;
583
+ for (let a = 0; a < 100; a++) {
584
+ this._ucMid.copy(n).add(h).multiplyScalar(0.5), this.m_Cylinder.position = this._ucMid, this.m_Book.bound.updatePaperPosition(this), this._ucRollResult.copy(t);
585
+ const o = this.m_Cylinder.rollPoint(this._ucRollResult);
586
+ if (Math.abs(e.x - o.x) < 1e-4) break;
587
+ o.x > e.x ? h.copy(this.m_Cylinder.position) : n.copy(this.m_Cylinder.position);
607
588
  }
608
589
  }
609
590
  rollPoint(t) {
610
591
  return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
611
592
  }
612
593
  startAutoTurning(t, e, s, i) {
613
- var u, l;
614
- if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === mt.Surface) {
615
- const _ = this.m_Transform.scale;
616
- _.x *= -1;
594
+ var u, c;
595
+ if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === ut.Surface) {
596
+ const m = this.m_Transform.scale;
597
+ m.x *= -1;
617
598
  }
618
599
  this.switchMeshData(
619
600
  0
620
601
  /* Highpoly */
621
- ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === mt.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
602
+ ), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (c = this.m_Next) == null || c.trySwitchMeshData(1), this.m_IsFallingLeft = t === ut.Edge, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
622
603
  const n = this.m_Size.x, h = this.m_Size.y;
623
604
  e = H(e, -0.99, 0.99);
624
- const a = Bt(0.5, 1, e), c = Bt(0.5, 0, e);
625
- this.m_StartHandle.set(n, 0, h * a), this.m_EndHandle.set(-n, 0, h * c), this.m_IsAutoTurning = !0;
605
+ const a = It(0.5, 1, e), o = It(0.5, 0, e);
606
+ this.m_StartHandle.set(n, 0, h * a), this.m_EndHandle.set(-n, 0, h * o), this.m_IsAutoTurning = !0;
626
607
  }
627
608
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
628
609
  get cylinder() {
@@ -711,7 +692,7 @@ st.kMin = 0, st.kMax = 0.25;
711
692
  let gt = st;
712
693
  const X = class X {
713
694
  constructor(t) {
714
- this.m_Material = null, this.m_Color = new o.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new o.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
695
+ this.m_Material = null, this.m_Color = new l.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = j.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new l.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? X.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? X.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? X.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
715
696
  }
716
697
  // ── Properties ────────────────────────────────────────────────────────
717
698
  get material() {
@@ -766,15 +747,15 @@ const X = class X {
766
747
  this.m_UVMargin = t;
767
748
  }
768
749
  get size() {
769
- return new o.Vector2(this.width, this.height);
750
+ return new l.Vector2(this.width, this.height);
770
751
  }
771
752
  };
772
753
  X.kMinSize = 1, X.kMinThickness = 1e-4, X.kMinQuality = 1, X.kMaxQuality = 5;
773
754
  let rt = X;
774
- class bt {
755
+ class zt {
775
756
  constructor(t) {
776
- this.m_Texture = null, this.m_TextureST = new o.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
777
- const e = t.material ?? new o.MeshStandardMaterial();
757
+ this.m_Texture = null, this.m_TextureST = new l.Vector4(1, 1, 0, 0), this._cachedPropertyBlock = null, this._propertyBlockDirty = !0;
758
+ const e = t.material ?? new l.MeshStandardMaterial();
778
759
  this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
779
760
  }
780
761
  get materials1() {
@@ -809,13 +790,13 @@ class bt {
809
790
  this.m_Texture = t, this.m_TextureST.copy(e), this._propertyBlockDirty = !0;
810
791
  }
811
792
  }
812
- function Vt(r, t, e, s = new o.Vector3()) {
793
+ function At(r, t, e, s = new l.Vector3()) {
813
794
  let i = t.x - r.x, n = t.y - r.y, h = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + h * h);
814
795
  i *= a, n *= a, h *= a;
815
- let c = e.x - r.x, u = e.y - r.y, l = e.z - r.z;
816
- a = 1 / Math.sqrt(c * c + u * u + l * l), c *= a, u *= a, l *= a;
817
- const _ = n * l - h * u, d = h * c - i * l, f = i * u - n * c;
818
- return a = 1 / Math.sqrt(_ * _ + d * d + f * f), s.set(_ * a, d * a, f * a);
796
+ let o = e.x - r.x, u = e.y - r.y, c = e.z - r.z;
797
+ a = 1 / Math.sqrt(o * o + u * u + c * c), o *= a, u *= a, c *= a;
798
+ const m = n * c - h * u, f = h * o - i * c, d = i * u - n * o;
799
+ return a = 1 / Math.sqrt(m * m + f * f + d * d), s.set(m * a, f * a, d * a);
819
800
  }
820
801
  class ht {
821
802
  constructor(t, e = !1, s = !1) {
@@ -868,21 +849,21 @@ class ht {
868
849
  t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
869
850
  }
870
851
  }
871
- class wt {
852
+ class Pt {
872
853
  constructor(t, e, s, i) {
873
854
  this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
874
855
  }
875
856
  clone() {
876
- const t = new wt(this.prevIndex, this.index, this.nextIndex, this.time);
857
+ const t = new Pt(this.prevIndex, this.index, this.nextIndex, this.time);
877
858
  return t.active = this.active, t;
878
859
  }
879
860
  }
880
- class Pt {
861
+ class Tt {
881
862
  constructor(t, e, s, i, n, h = !0) {
882
863
  this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = h;
883
864
  }
884
865
  clone() {
885
- return new Pt(
866
+ return new Tt(
886
867
  this.startX,
887
868
  this.startZ,
888
869
  this.endX,
@@ -892,7 +873,7 @@ class Pt {
892
873
  );
893
874
  }
894
875
  }
895
- class he {
876
+ class oe {
896
877
  constructor(t, e, s) {
897
878
  const i = t.size;
898
879
  this.leftNode = new ht(e.left * i.x, s, !0), this.rightNode = new ht((1 - e.right) * i.x, s, !0), this.downNode = new ht(e.down * i.y, s, !0), this.upNode = new ht((1 - e.up) * i.y, s, !0);
@@ -903,7 +884,7 @@ class he {
903
884
  }
904
885
  function pt(r, t) {
905
886
  for (const e of r) {
906
- const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new wt(s.index, e.index, i.index, n);
887
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = Q(s.value, i.value, e.value), h = new Pt(s.index, e.index, i.index, n);
907
888
  t.push(h);
908
889
  }
909
890
  }
@@ -911,138 +892,138 @@ function xt(r, t, e, s, i) {
911
892
  for (const n of r)
912
893
  if (n.active)
913
894
  for (let h = 0; h < s; h++) {
914
- const a = n.prevIndex, c = n.nextIndex, u = t[h * e + a], l = t[h * e + c], _ = t[h * e + n.index];
915
- i ? Et(u, l, n.time, _) : _.copy(u).lerp(l, n.time);
895
+ const a = n.prevIndex, o = n.nextIndex, u = t[h * e + a], c = t[h * e + o], m = t[h * e + n.index];
896
+ i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
916
897
  }
917
898
  }
918
899
  function Mt(r, t, e, s, i) {
919
900
  for (const n of r)
920
901
  if (n.active)
921
902
  for (let h = 0; h < e; h++) {
922
- const a = n.prevIndex, c = n.nextIndex, u = t[a * e + h], l = t[c * e + h], _ = t[n.index * e + h];
923
- i ? Et(u, l, n.time, _) : _.copy(u).lerp(l, n.time);
903
+ const a = n.prevIndex, o = n.nextIndex, u = t[a * e + h], c = t[o * e + h], m = t[n.index * e + h];
904
+ i ? Gt(u, c, n.time, m) : m.copy(u).lerp(c, n.time);
924
905
  }
925
906
  }
926
- function Et(r, t, e, s = new o.Vector3()) {
907
+ function Gt(r, t, e, s = new l.Vector3()) {
927
908
  const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
928
909
  if (i === 0 || n === 0)
929
910
  return s.copy(r).lerp(t, e);
930
- const h = r.x / i, a = r.y / i, c = r.z / i, u = t.x / n, l = t.y / n, _ = t.z / n;
931
- let d = h * u + a * l + c * _;
932
- d = Math.max(-1, Math.min(1, d));
933
- const f = Math.acos(d);
934
- if (f < 1e-6)
911
+ const h = r.x / i, a = r.y / i, o = r.z / i, u = t.x / n, c = t.y / n, m = t.z / n;
912
+ let f = h * u + a * c + o * m;
913
+ f = Math.max(-1, Math.min(1, f));
914
+ const d = Math.acos(f);
915
+ if (d < 1e-6)
935
916
  return s.copy(r).lerp(t, e);
936
- const m = Math.sin(f), g = Math.sin((1 - e) * f) / m, p = Math.sin(e * f) / m, M = i + (n - i) * e;
917
+ const _ = Math.sin(d), g = Math.sin((1 - e) * d) / _, p = Math.sin(e * d) / _, M = i + (n - i) * e;
937
918
  return s.set(
938
919
  (h * g + u * p) * M,
939
- (a * g + l * p) * M,
940
- (c * g + _ * p) * M
920
+ (a * g + c * p) * M,
921
+ (o * g + m * p) * M
941
922
  );
942
923
  }
943
- function Nt(r, t, e, s, i) {
924
+ function jt(r, t, e, s, i) {
944
925
  for (const n of r) {
945
- const h = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, c = e.length;
946
- for (let l = 0, _ = n.endX - n.startX; l < _; l++) {
947
- const d = c + l * 2 + 0, f = c + l * 2 + 1, m = c + l * 2 + 2, g = c + l * 2 + 3;
948
- n.flip ? It(t, d, f, m, g, h) : Dt(t, d, f, m, g, h);
926
+ const h = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, o = e.length;
927
+ for (let c = 0, m = n.endX - n.startX; c < m; c++) {
928
+ const f = o + c * 2 + 0, d = o + c * 2 + 1, _ = o + c * 2 + 2, g = o + c * 2 + 3;
929
+ n.flip ? Ft(t, f, d, _, g, h) : Ht(t, f, d, _, g, h);
949
930
  }
950
931
  if (n.left)
951
- for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
952
- const d = c + l * 2 + 0 + h * 2, f = c + l * 2 + 1 + h * 2, m = c + l * 2 + 2 + h * 2, g = c + l * 2 + 3 + h * 2;
953
- n.flip ? It(t, d, f, m, g, a) : Dt(t, d, f, m, g, a);
932
+ for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
933
+ const f = o + c * 2 + 0 + h * 2, d = o + c * 2 + 1 + h * 2, _ = o + c * 2 + 2 + h * 2, g = o + c * 2 + 3 + h * 2;
934
+ n.flip ? Ft(t, f, d, _, g, a) : Ht(t, f, d, _, g, a);
954
935
  }
955
936
  else
956
- for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
957
- const d = c + l * 2 + 0 + h * 2 + a, f = c + l * 2 + 1 + h * 2 + a, m = c + l * 2 + 2 + h * 2 + a, g = c + l * 2 + 3 + h * 2 + a;
958
- n.flip ? dt(t, d, f, m, g) : _t(t, d, f, m, g);
937
+ for (let c = 0, m = n.endZ - n.startZ; c < m; c++) {
938
+ const f = o + c * 2 + 0 + h * 2 + a, d = o + c * 2 + 1 + h * 2 + a, _ = o + c * 2 + 2 + h * 2 + a, g = o + c * 2 + 3 + h * 2 + a;
939
+ n.flip ? _t(t, f, d, _, g) : mt(t, f, d, _, g);
959
940
  }
960
941
  const u = s * i;
961
- for (let l = n.startX; l <= n.endX; l++) {
962
- const _ = n.startZ * s + l;
963
- e.push(e[_].clone()), e.push(e[_ + u].clone());
942
+ for (let c = n.startX; c <= n.endX; c++) {
943
+ const m = n.startZ * s + c;
944
+ e.push(e[m].clone()), e.push(e[m + u].clone());
964
945
  }
965
- for (let l = n.startX; l <= n.endX; l++) {
966
- const _ = l + n.endZ * s;
967
- e.push(e[_ + u].clone()), e.push(e[_].clone());
946
+ for (let c = n.startX; c <= n.endX; c++) {
947
+ const m = c + n.endZ * s;
948
+ e.push(e[m + u].clone()), e.push(e[m].clone());
968
949
  }
969
- for (let l = n.startZ; l <= n.endZ; l++) {
970
- const _ = n.startX + l * s;
971
- e.push(e[_ + u].clone()), e.push(e[_].clone());
950
+ for (let c = n.startZ; c <= n.endZ; c++) {
951
+ const m = n.startX + c * s;
952
+ e.push(e[m + u].clone()), e.push(e[m].clone());
972
953
  }
973
- for (let l = n.startZ; l <= n.endZ; l++) {
974
- const _ = l * s + n.endX;
975
- e.push(e[_].clone()), e.push(e[_ + u].clone());
954
+ for (let c = n.startZ; c <= n.endZ; c++) {
955
+ const m = c * s + n.endX;
956
+ e.push(e[m].clone()), e.push(e[m + u].clone());
976
957
  }
977
958
  }
978
959
  }
979
- function Xt(r, t, e, s, i) {
960
+ function qt(r, t, e, s, i) {
980
961
  const n = s * i;
981
962
  let h = n * 2;
982
- const a = new o.Vector3();
983
- for (const c of r) {
984
- for (let u = c.startX; u <= c.endX; u++) {
985
- const l = u + c.startZ * s, _ = t[l], d = t[l + s];
986
- a.subVectors(_, d).normalize(), c.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(_), e[h].copy(a), t[h++].copy(t[l + n]);
963
+ const a = new l.Vector3();
964
+ for (const o of r) {
965
+ for (let u = o.startX; u <= o.endX; u++) {
966
+ const c = u + o.startZ * s, m = t[c], f = t[c + s];
967
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
987
968
  }
988
- for (let u = c.startX; u <= c.endX; u++) {
989
- const l = u + c.endZ * s, _ = t[l + n], d = t[l + n - s];
990
- a.subVectors(_, d).normalize(), c.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(_), e[h].copy(a), t[h++].copy(t[l]);
969
+ for (let u = o.startX; u <= o.endX; u++) {
970
+ const c = u + o.endZ * s, m = t[c + n], f = t[c + n - s];
971
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
991
972
  }
992
- for (let u = c.startZ; u <= c.endZ; u++) {
993
- const l = u * s + c.startX, _ = t[l + n], d = t[l + n + 1];
994
- a.subVectors(_, d).normalize(), c.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(_), e[h].copy(a), t[h++].copy(t[l]);
973
+ for (let u = o.startZ; u <= o.endZ; u++) {
974
+ const c = u * s + o.startX, m = t[c + n], f = t[c + n + 1];
975
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c]);
995
976
  }
996
- for (let u = c.startZ; u <= c.endZ; u++) {
997
- const l = u * s + c.endX, _ = t[l], d = t[l - 1];
998
- a.subVectors(_, d).normalize(), c.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(_), e[h].copy(a), t[h++].copy(t[l + n]);
977
+ for (let u = o.startZ; u <= o.endZ; u++) {
978
+ const c = u * s + o.endX, m = t[c], f = t[c - 1];
979
+ a.subVectors(m, f).normalize(), o.flip && a.multiplyScalar(-1), e[h].copy(a), t[h++].copy(m), e[h].copy(a), t[h++].copy(t[c + n]);
999
980
  }
1000
981
  }
1001
982
  }
1002
- function Dt(r, t, e, s, i, n) {
1003
- _t(r, t, e, s, i), t += n, e += n, s += n, i += n, _t(r, t, e, s, i);
983
+ function Ht(r, t, e, s, i, n) {
984
+ mt(r, t, e, s, i), t += n, e += n, s += n, i += n, mt(r, t, e, s, i);
1004
985
  }
1005
- function It(r, t, e, s, i, n) {
1006
- dt(r, t, e, s, i), t += n, e += n, s += n, i += n, dt(r, t, e, s, i);
986
+ function Ft(r, t, e, s, i, n) {
987
+ _t(r, t, e, s, i), t += n, e += n, s += n, i += n, _t(r, t, e, s, i);
1007
988
  }
1008
- function Wt(r, t, e, s, i, n, h) {
1009
- _t(r, e, s, i, n), e += h, s += h, i += h, n += h, dt(t, e, s, i, n);
989
+ function Qt(r, t, e, s, i, n, h) {
990
+ mt(r, e, s, i, n), e += h, s += h, i += h, n += h, _t(t, e, s, i, n);
1010
991
  }
1011
- function Gt(r, t, e, s, i, n) {
1012
- const h = i.left * s.x, a = (1 - i.right) * s.x, c = i.down * s.y, u = (1 - i.up) * s.y, l = t.length, _ = e.length;
992
+ function $t(r, t, e, s, i, n) {
993
+ const h = i.left * s.x, a = (1 - i.right) * s.x, o = i.down * s.y, u = (1 - i.up) * s.y, c = t.length, m = e.length;
1013
994
  if (n > 1)
1014
- for (let f = 0; f < _; f++)
1015
- for (let m = 0; m < l; m++) {
1016
- const g = Q(a, h, t[m]), p = Q(u, c, e[f]);
1017
- r.push(new o.Vector2(p, g));
995
+ for (let d = 0; d < m; d++)
996
+ for (let _ = 0; _ < c; _++) {
997
+ const g = Q(a, h, t[_]), p = Q(u, o, e[d]);
998
+ r.push(new l.Vector2(p, g));
1018
999
  }
1019
1000
  else
1020
- for (let f = 0; f < _; f++)
1021
- for (let m = 0; m < l; m++) {
1022
- const g = Q(h, a, t[m]), p = Q(u, c, e[f]);
1023
- r.push(new o.Vector2(g, p));
1001
+ for (let d = 0; d < m; d++)
1002
+ for (let _ = 0; _ < c; _++) {
1003
+ const g = Q(h, a, t[_]), p = Q(u, o, e[d]);
1004
+ r.push(new l.Vector2(g, p));
1024
1005
  }
1025
- const d = r.length;
1026
- for (let f = 0; f < d; f++)
1027
- r.push(r[f].clone());
1006
+ const f = r.length;
1007
+ for (let d = 0; d < f; d++)
1008
+ r.push(r[d].clone());
1028
1009
  }
1029
- function _t(r, t, e, s, i) {
1010
+ function mt(r, t, e, s, i) {
1030
1011
  r.push(t), r.push(s), r.push(e), r.push(e), r.push(s), r.push(i);
1031
1012
  }
1032
- function dt(r, t, e, s, i) {
1013
+ function _t(r, t, e, s, i) {
1033
1014
  r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1034
1015
  }
1035
- const ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1016
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1036
1017
  __proto__: null,
1037
- addBorders: Nt,
1038
- addFrontAndBackFaces: Wt,
1039
- addFrontAndBackTexcoords: Gt,
1018
+ addBorders: jt,
1019
+ addFrontAndBackFaces: Qt,
1020
+ addFrontAndBackTexcoords: $t,
1040
1021
  seamNodesToSeams: pt,
1041
- updateBorders: Xt,
1022
+ updateBorders: qt,
1042
1023
  updateXSeams: xt,
1043
1024
  updateZSeams: Mt
1044
1025
  }, Symbol.toStringTag, { value: "Module" }));
1045
- class zt {
1026
+ class Ot {
1046
1027
  get geometry() {
1047
1028
  return this.m_Geometry;
1048
1029
  }
@@ -1055,33 +1036,33 @@ class zt {
1055
1036
  constructor(t, e) {
1056
1037
  this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1057
1038
  for (let h = 0; h < e.baseVertexCount; h++)
1058
- this.m_BaseVertices[h] = new o.Vector3();
1039
+ this.m_BaseVertices[h] = new l.Vector3();
1059
1040
  this.m_Vertices = new Array(e.vertexCount);
1060
1041
  for (let h = 0; h < e.vertexCount; h++)
1061
- this.m_Vertices[h] = new o.Vector3();
1042
+ this.m_Vertices[h] = new l.Vector3();
1062
1043
  this.m_Normals = new Array(e.vertexCount);
1063
1044
  for (let h = 0; h < e.vertexCount; h++)
1064
- this.m_Normals[h] = new o.Vector3();
1045
+ this.m_Normals[h] = new l.Vector3();
1065
1046
  if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1066
1047
  const h = new Uint32Array(e.triangles);
1067
- this.m_Geometry.setIndex(new o.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1048
+ this.m_Geometry.setIndex(new l.BufferAttribute(h, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1068
1049
  } else {
1069
1050
  const h = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(h);
1070
- let c = 0;
1071
- a.set(e.frontTriangles, c), this.m_Geometry.addGroup(c, e.frontTriangles.length, 0), c += e.frontTriangles.length, a.set(e.backTriangles, c), this.m_Geometry.addGroup(c, e.backTriangles.length, 1), c += e.backTriangles.length, a.set(e.borderTriangles, c), this.m_Geometry.addGroup(c, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new o.BufferAttribute(a, 1));
1051
+ let o = 0;
1052
+ a.set(e.frontTriangles, o), this.m_Geometry.addGroup(o, e.frontTriangles.length, 0), o += e.frontTriangles.length, a.set(e.backTriangles, o), this.m_Geometry.addGroup(o, e.backTriangles.length, 1), o += e.backTriangles.length, a.set(e.borderTriangles, o), this.m_Geometry.addGroup(o, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new l.BufferAttribute(a, 1));
1072
1053
  }
1073
1054
  const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1074
1055
  for (let h = 0; h < e.texcoords.length; h++)
1075
1056
  n[h * 2] = e.texcoords[h].x, n[h * 2 + 1] = e.texcoords[h].y;
1076
1057
  this.m_Geometry.setAttribute(
1077
1058
  "position",
1078
- new o.BufferAttribute(s, 3)
1059
+ new l.BufferAttribute(s, 3)
1079
1060
  ), this.m_Geometry.setAttribute(
1080
1061
  "normal",
1081
- new o.BufferAttribute(i, 3)
1062
+ new l.BufferAttribute(i, 3)
1082
1063
  ), this.m_Geometry.setAttribute(
1083
1064
  "uv",
1084
- new o.BufferAttribute(n, 2)
1065
+ new l.BufferAttribute(n, 2)
1085
1066
  ), this.updateBaseVertices();
1086
1067
  }
1087
1068
  // ── UpdateBaseVertices ──────────────────────────────────────────────────
@@ -1094,9 +1075,9 @@ class zt {
1094
1075
  updateBaseVertices() {
1095
1076
  const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, h = s.length;
1096
1077
  let a = 0;
1097
- for (let c = 0; c < h; c++)
1078
+ for (let o = 0; o < h; o++)
1098
1079
  for (let u = 0; u < n; u++)
1099
- t[a++].set(e[u] + i, 0, s[c]);
1080
+ t[a++].set(e[u] + i, 0, s[o]);
1100
1081
  }
1101
1082
  // ── UpdateMesh ─────────────────────────────────────────────────────────
1102
1083
  /**
@@ -1115,49 +1096,49 @@ class zt {
1115
1096
  * Ported from lines ~2185-2255.
1116
1097
  */
1117
1098
  updateMesh() {
1118
- const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, c = new o.Vector3(), u = new o.Vector3(), l = new o.Vector3();
1119
- for (let m = 0; m < a; m++)
1120
- s[m].set(0, 0, 0);
1099
+ const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, h = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, o = new l.Vector3(), u = new l.Vector3(), c = new l.Vector3();
1100
+ for (let _ = 0; _ < a; _++)
1101
+ s[_].set(0, 0, 0);
1121
1102
  xt(this.m_Pattern.xSeams, t, n, h, !1), Mt(this.m_Pattern.zSeams, t, n, h, !1);
1122
- for (let m = 0; m < h - 1; m++) {
1123
- const g = m + 1;
1103
+ for (let _ = 0; _ < h - 1; _++) {
1104
+ const g = _ + 1;
1124
1105
  for (let p = 0; p < n - 1; p++) {
1125
- const M = p + 1, T = m * n + p, C = m * n + M, S = g * n + p, k = g * n + M, D = t[T], U = t[C], L = t[S], z = t[k];
1126
- Vt(D, L, U, c), Vt(z, U, L, u), l.addVectors(c, u), s[T].add(l), s[C].add(l), s[S].add(l), s[k].add(l);
1106
+ const M = p + 1, T = _ * n + p, P = _ * n + M, C = g * n + p, k = g * n + M, I = t[T], U = t[P], L = t[C], z = t[k];
1107
+ At(I, L, U, o), At(z, U, L, u), c.addVectors(o, u), s[T].add(c), s[P].add(c), s[C].add(c), s[k].add(c);
1127
1108
  }
1128
1109
  }
1129
- for (let m = 0; m < a; m++)
1130
- s[m].divideScalar(i[m]).normalize();
1110
+ for (let _ = 0; _ < a; _++)
1111
+ s[_].divideScalar(i[_]).normalize();
1131
1112
  xt(this.m_Pattern.xSeams, s, n, h, !0), Mt(this.m_Pattern.zSeams, s, n, h, !0);
1132
- const _ = this.m_Pattern.thickness / 2;
1133
- for (let m = 0; m < a; m++) {
1134
- const g = s[m];
1135
- s[m + a].copy(g).negate();
1136
- const p = t[m];
1137
- e[m].copy(p).addScaledVector(g, _), e[m + a].copy(p).addScaledVector(g, -_);
1138
- }
1139
- Xt(this.m_Pattern.borders, e, s, n, h);
1140
- const d = this.m_Geometry.getAttribute(
1113
+ const m = this.m_Pattern.thickness / 2;
1114
+ for (let _ = 0; _ < a; _++) {
1115
+ const g = s[_];
1116
+ s[_ + a].copy(g).negate();
1117
+ const p = t[_];
1118
+ e[_].copy(p).addScaledVector(g, m), e[_ + a].copy(p).addScaledVector(g, -m);
1119
+ }
1120
+ qt(this.m_Pattern.borders, e, s, n, h);
1121
+ const f = this.m_Geometry.getAttribute(
1141
1122
  "position"
1142
- ), f = this.m_Geometry.getAttribute(
1123
+ ), d = this.m_Geometry.getAttribute(
1143
1124
  "normal"
1144
1125
  );
1145
- for (let m = 0; m < e.length; m++) {
1146
- const g = e[m];
1147
- d.setXYZ(m, g.x, g.y, g.z);
1148
- const p = s[m];
1149
- f.setXYZ(m, p.x, p.y, p.z);
1126
+ for (let _ = 0; _ < e.length; _++) {
1127
+ const g = e[_];
1128
+ f.setXYZ(_, g.x, g.y, g.z);
1129
+ const p = s[_];
1130
+ d.setXYZ(_, p.x, p.y, p.z);
1150
1131
  }
1151
- d.needsUpdate = !0, f.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1132
+ f.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1152
1133
  }
1153
1134
  }
1154
- class ae {
1135
+ class le {
1155
1136
  constructor() {
1156
1137
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1157
1138
  }
1158
1139
  get() {
1159
1140
  let t;
1160
- return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new o.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1141
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new l.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1161
1142
  }
1162
1143
  recycle() {
1163
1144
  for (const t of this.m_UsedMeshs)
@@ -1170,7 +1151,7 @@ class ae {
1170
1151
  this.m_Meshs.clear();
1171
1152
  }
1172
1153
  }
1173
- class oe {
1154
+ class ce {
1174
1155
  constructor(t) {
1175
1156
  this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1176
1157
  }
@@ -1179,7 +1160,7 @@ class oe {
1179
1160
  }
1180
1161
  get(t) {
1181
1162
  let e;
1182
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new le(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1163
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.reset(t)) : (e = new me(this.m_Root, t), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1183
1164
  }
1184
1165
  recycle() {
1185
1166
  for (const t of this.m_UsedRenderers)
@@ -1192,23 +1173,23 @@ class oe {
1192
1173
  this.m_Renderers.clear();
1193
1174
  }
1194
1175
  getBounds() {
1195
- const t = new o.Box3();
1176
+ const t = new l.Box3();
1196
1177
  let e = !0;
1197
1178
  for (const s of this.m_UsedRenderers)
1198
1179
  e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1199
1180
  return t;
1200
1181
  }
1201
1182
  }
1202
- let ce = 1;
1203
- class le {
1183
+ let ue = 1;
1184
+ class me {
1204
1185
  constructor(t, e) {
1205
- this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ce++, this.m_Object3D = new o.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new o.Mesh(
1206
- new o.BufferGeometry(),
1207
- new o.MeshStandardMaterial()
1186
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ue++, this.m_Object3D = new l.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new l.Mesh(
1187
+ new l.BufferGeometry(),
1188
+ new l.MeshStandardMaterial()
1208
1189
  ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D);
1209
1190
  }
1210
1191
  get bounds() {
1211
- const t = new o.Box3();
1192
+ const t = new l.Box3();
1212
1193
  return this.m_Mesh.geometry && (this.m_Mesh.geometry.computeBoundingBox(), this.m_Mesh.geometry.boundingBox && (t.copy(this.m_Mesh.geometry.boundingBox), t.applyMatrix4(this.m_Mesh.matrixWorld))), t;
1213
1194
  }
1214
1195
  get id() {
@@ -1236,12 +1217,12 @@ class le {
1236
1217
  return this.m_Mesh;
1237
1218
  }
1238
1219
  setMaterials(t) {
1239
- this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new o.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1220
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new l.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1240
1221
  }
1241
1222
  setPropertyBlock(t, e) {
1242
1223
  this.m_PropertyBlocks.set(e, t);
1243
1224
  const s = this.getMaterial(e);
1244
- s && (this.isMapCapable(s) && (t.map instanceof o.Texture ? this.applyTextureProperty(
1225
+ s && (this.isMapCapable(s) && (t.map instanceof l.Texture ? this.applyTextureProperty(
1245
1226
  s,
1246
1227
  e,
1247
1228
  t.map,
@@ -1249,10 +1230,10 @@ class le {
1249
1230
  ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && s.color.copy(t.color));
1250
1231
  }
1251
1232
  reset(t) {
1252
- this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new o.BufferGeometry(), this.setMaterials([]);
1233
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.setMaterials([]);
1253
1234
  }
1254
1235
  clear() {
1255
- this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new o.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1236
+ this.m_Object3D.name = "", this.m_Mesh.geometry.dispose(), this.m_Mesh.geometry = new l.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1256
1237
  }
1257
1238
  destroy() {
1258
1239
  this.disposeManagedTextures(), this.disposeCurrentMaterials(), this.m_Mesh.geometry && this.m_Mesh.geometry.dispose(), this.m_Object3D.parent && this.m_Object3D.parent.remove(this.m_Object3D);
@@ -1267,7 +1248,7 @@ class le {
1267
1248
  return "map" in t;
1268
1249
  }
1269
1250
  isColorCapable(t) {
1270
- return "color" in t && t.color instanceof o.Color;
1251
+ return "color" in t && t.color instanceof l.Color;
1271
1252
  }
1272
1253
  getSTKey(t) {
1273
1254
  return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
@@ -1280,7 +1261,7 @@ class le {
1280
1261
  }
1281
1262
  this.clearManagedTexture(e);
1282
1263
  const a = s.clone();
1283
- a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = o.RepeatWrapping, a.wrapT = o.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1264
+ a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = l.RepeatWrapping, a.wrapT = l.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1284
1265
  source: s,
1285
1266
  texture: a,
1286
1267
  stKey: n
@@ -1304,20 +1285,20 @@ class le {
1304
1285
  e.dispose();
1305
1286
  }
1306
1287
  }
1307
- class ue {
1288
+ class _e {
1308
1289
  constructor(t, e, s = !1) {
1309
- this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new zt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1290
+ this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Ot(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1310
1291
  }
1311
1292
  get() {
1312
- return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new zt(this.m_MeshFactory.get(), this.m_Pattern);
1293
+ return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Ot(this.m_MeshFactory.get(), this.m_Pattern);
1313
1294
  }
1314
1295
  free(t) {
1315
1296
  if (this.m_UseSharedData) throw new Error("Not implemented");
1316
1297
  this.m_Stack.push(t);
1317
1298
  }
1318
1299
  }
1319
- var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), me = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(me || {}), _e = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(_e || {});
1320
- class de {
1300
+ var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), de = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(de || {}), fe = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(fe || {});
1301
+ class ge {
1321
1302
  constructor(t) {
1322
1303
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1323
1304
  }
@@ -1339,7 +1320,7 @@ class de {
1339
1320
  return e[s - 1].value;
1340
1321
  }
1341
1322
  }
1342
- function At(r, t) {
1323
+ function Zt(r, t) {
1343
1324
  return r + Math.random() * (t - r);
1344
1325
  }
1345
1326
  class at {
@@ -1410,12 +1391,12 @@ class at {
1410
1391
  getValue(t, e) {
1411
1392
  if (this.m_Mode === 0) return this.m_Constant;
1412
1393
  if (this.m_Mode === 1)
1413
- return At(this.m_ConstantMin, this.m_ConstantMax);
1394
+ return Zt(this.m_ConstantMin, this.m_ConstantMax);
1414
1395
  const s = this.m_CurveTimeMode === 0 ? t : e;
1415
1396
  if (this.m_Mode === 2)
1416
1397
  return this.m_Curve.evaluate(s);
1417
1398
  if (this.m_Mode === 3)
1418
- return At(
1399
+ return Zt(
1419
1400
  this.m_CurveMin.evaluate(s),
1420
1401
  this.m_CurveMax.evaluate(s)
1421
1402
  );
@@ -1427,17 +1408,17 @@ class at {
1427
1408
  }
1428
1409
  clampCurve(t, e, s) {
1429
1410
  if (this.m_Curve === null || t === null) return null;
1430
- const i = t.keys.map((c) => ({ time: c.time, value: c.value })), n = i.length;
1411
+ const i = t.keys.map((o) => ({ time: o.time, value: o.value })), n = i.length;
1431
1412
  let h = 1 / 0, a = -1 / 0;
1432
- for (let c = 0; c < n; c++) {
1433
- const u = i[c].time;
1413
+ for (let o = 0; o < n; o++) {
1414
+ const u = i[o].time;
1434
1415
  h = Math.min(h, u), a = Math.max(a, u);
1435
1416
  }
1436
- for (let c = 0; c < n; c++) {
1437
- let u = i[c].time, l = i[c].value;
1438
- u = Q(h, a, u), l = H(l, e, s), i[c].time = u, i[c].value = l;
1417
+ for (let o = 0; o < n; o++) {
1418
+ let u = i[o].time, c = i[o].value;
1419
+ u = Q(h, a, u), c = H(c, e, s), i[o].time = u, i[o].value = c;
1439
1420
  }
1440
- return new de(i);
1421
+ return new ge(i);
1441
1422
  }
1442
1423
  // ── Value-type clone ────────────────────────────────────────────────────
1443
1424
  clone() {
@@ -1445,9 +1426,9 @@ class at {
1445
1426
  return t.m_Mode = this.m_Mode, t.m_Constant = this.m_Constant, t.m_ConstantMin = this.m_ConstantMin, t.m_ConstantMax = this.m_ConstantMax, t.m_Curve = this.m_Curve, t.m_CurveMin = this.m_CurveMin, t.m_CurveMax = this.m_CurveMax, t.m_CurveTimeMode = this.m_CurveTimeMode, t;
1446
1427
  }
1447
1428
  }
1448
- const V = class V {
1429
+ const D = class D {
1449
1430
  constructor() {
1450
- this.m_Mode = mt.Surface, this.m_Twist = new at(), this.m_Bend = new at(1), this.m_Duration = new at(0.5);
1431
+ this.m_Mode = ut.Surface, this.m_Twist = new at(), this.m_Bend = new at(1), this.m_Duration = new at(0.5);
1451
1432
  }
1452
1433
  // ── Properties ──────────────────────────────────────────────────────────
1453
1434
  get mode() {
@@ -1461,8 +1442,8 @@ const V = class V {
1461
1442
  }
1462
1443
  set twist(t) {
1463
1444
  this.m_Twist = t.clampValues(
1464
- V.kMinTwist,
1465
- V.kMaxTwist
1445
+ D.kMinTwist,
1446
+ D.kMaxTwist
1466
1447
  );
1467
1448
  }
1468
1449
  get bend() {
@@ -1470,8 +1451,8 @@ const V = class V {
1470
1451
  }
1471
1452
  set bend(t) {
1472
1453
  this.m_Bend = t.clampValues(
1473
- V.kMinBend,
1474
- V.kMaxBend
1454
+ D.kMinBend,
1455
+ D.kMaxBend
1475
1456
  );
1476
1457
  }
1477
1458
  get duration() {
@@ -1479,8 +1460,8 @@ const V = class V {
1479
1460
  }
1480
1461
  set duration(t) {
1481
1462
  this.m_Duration = t.clampValues(
1482
- V.kMinDuration,
1483
- V.kMaxDuration
1463
+ D.kMinDuration,
1464
+ D.kMaxDuration
1484
1465
  );
1485
1466
  }
1486
1467
  // ── Internal API ────────────────────────────────────────────────────────
@@ -1492,60 +1473,60 @@ const V = class V {
1492
1473
  getBendValue(t, e) {
1493
1474
  return H(
1494
1475
  this.m_Bend.getValue(t, e),
1495
- V.kMinBend,
1496
- V.kMaxBend
1476
+ D.kMinBend,
1477
+ D.kMaxBend
1497
1478
  );
1498
1479
  }
1499
1480
  /** @internal */
1500
1481
  getDurationValue(t, e) {
1501
1482
  return H(
1502
1483
  this.m_Duration.getValue(t, e),
1503
- V.kMinDuration,
1504
- V.kMaxDuration
1484
+ D.kMinDuration,
1485
+ D.kMaxDuration
1505
1486
  );
1506
1487
  }
1507
1488
  /** @internal */
1508
1489
  getTwistValue(t, e) {
1509
1490
  return H(
1510
1491
  this.m_Twist.getValue(t, e),
1511
- V.kMinTwist,
1512
- V.kMaxTwist
1492
+ D.kMinTwist,
1493
+ D.kMaxTwist
1513
1494
  );
1514
1495
  }
1515
1496
  };
1516
- V.kMinTwist = -1, V.kMaxTwist = 1, V.kMinBend = 0, V.kMaxBend = 1, V.kMinDuration = 0, V.kMaxDuration = 5;
1517
- let Ht = V;
1518
- class fe extends Error {
1497
+ D.kMinTwist = -1, D.kMaxTwist = 1, D.kMinBend = 0, D.kMaxBend = 1, D.kMinDuration = 0, D.kMaxDuration = 5;
1498
+ let Ut = D;
1499
+ class pe extends Error {
1519
1500
  constructor() {
1520
1501
  super(
1521
1502
  "The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
1522
1503
  );
1523
1504
  }
1524
1505
  }
1525
- const W = class W extends o.Group {
1506
+ const W = class W extends l.Group {
1526
1507
  // ── Constructor ────────────────────────────────────────────────────────
1527
1508
  constructor(t) {
1528
1509
  super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new rt({
1529
- color: new o.Color(1, 0, 0),
1510
+ color: new l.Color(1, 0, 0),
1530
1511
  width: 2.1,
1531
1512
  height: 3.1,
1532
1513
  thickness: 0.04,
1533
1514
  stiffness: 0.5
1534
1515
  }), this.m_PagePaperSetup = new rt({
1535
- color: new o.Color(1, 1, 1),
1516
+ color: new l.Color(1, 1, 1),
1536
1517
  width: 2,
1537
1518
  height: 3,
1538
1519
  thickness: 0.02,
1539
1520
  stiffness: 0.2
1540
- }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = o.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1541
- color: t.coverPaperSetup.color ?? new o.Color(1, 0, 0),
1521
+ }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = j.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, this._frontPapersCache = null, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = l.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new rt({
1522
+ color: t.coverPaperSetup.color ?? new l.Color(1, 0, 0),
1542
1523
  width: t.coverPaperSetup.width ?? 2.1,
1543
1524
  height: t.coverPaperSetup.height ?? 3.1,
1544
1525
  thickness: t.coverPaperSetup.thickness ?? 0.04,
1545
1526
  stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1546
1527
  material: t.coverPaperSetup.material ?? null
1547
1528
  })), t.pagePaperSetup && (this.m_PagePaperSetup = new rt({
1548
- color: t.pagePaperSetup.color ?? new o.Color(1, 1, 1),
1529
+ color: t.pagePaperSetup.color ?? new l.Color(1, 1, 1),
1549
1530
  width: t.pagePaperSetup.width ?? 2,
1550
1531
  height: t.pagePaperSetup.height ?? 3,
1551
1532
  thickness: t.pagePaperSetup.thickness ?? 0.02,
@@ -1672,7 +1653,7 @@ const W = class W extends o.Group {
1672
1653
  return this.m_InitialOpenProgress;
1673
1654
  }
1674
1655
  set initialOpenProgress(t) {
1675
- this.m_InitialOpenProgress = o.MathUtils.clamp(t, 0, 1);
1656
+ this.m_InitialOpenProgress = l.MathUtils.clamp(t, 0, 1);
1676
1657
  }
1677
1658
  get isBuilt() {
1678
1659
  return this.m_IsBuilt;
@@ -1754,7 +1735,7 @@ const W = class W extends o.Group {
1754
1735
  */
1755
1736
  setOpenProgress(t) {
1756
1737
  this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1757
- const e = this.m_Papers.length, s = Math.round(o.MathUtils.lerp(0, e, t));
1738
+ const e = this.m_Papers.length, s = Math.round(l.MathUtils.lerp(0, e, t));
1758
1739
  for (let i = 0; i < e; i++) {
1759
1740
  const n = i >= s;
1760
1741
  this.m_Papers[i].restState(n);
@@ -1782,8 +1763,8 @@ const W = class W extends o.Group {
1782
1763
  const n = typeof i == "number" ? new at(i) : i;
1783
1764
  if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1784
1765
  for (let h = 0; h < s && this.canAutoTurn(t); h++) {
1785
- const a = h / (s - 1 || 1), c = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(c, a) : 0, l = e.getModeValue(), _ = e.getTwistValue(c, a), d = e.getBendValue(c, a), f = e.getDurationValue(c, a);
1786
- this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: _, bend: d, duration: f, delay: u });
1766
+ const a = h / (s - 1 || 1), o = this.getAutoTurnPaperIndexTime(t), u = h > 0 ? n.getValue(o, a) : 0, c = e.getModeValue(), m = e.getTwistValue(o, a), f = e.getBendValue(o, a), d = e.getDurationValue(o, a);
1767
+ this.m_AutoTurnQueue.push({ direction: t, mode: c, twist: m, bend: f, duration: d, delay: u });
1787
1768
  }
1788
1769
  return this.m_AutoTurnTimer = 0, this._frontPapersCache = null, !0;
1789
1770
  }
@@ -1880,29 +1861,29 @@ const W = class W extends o.Group {
1880
1861
  build() {
1881
1862
  var B;
1882
1863
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1883
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new ae()), this.m_RendererFactory === null) {
1884
- const w = new o.Object3D();
1885
- w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new oe(this.m_Root);
1864
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new le()), this.m_RendererFactory === null) {
1865
+ const w = new l.Object3D();
1866
+ w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new ce(this.m_Root);
1886
1867
  }
1887
1868
  this.m_Direction = this.m_Content.direction;
1888
1869
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1889
1870
  this.m_Root.rotation.set(0, t, 0), this.m_CoverPaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.height < this.m_CoverPaperSetup.height ? (this.m_CoverPaperSetup.margin = 0, this.m_PagePaperSetup.margin = (this.m_CoverPaperSetup.height - this.m_PagePaperSetup.height) / 2) : (this.m_CoverPaperSetup.margin = (this.m_PagePaperSetup.height - this.m_CoverPaperSetup.height) / 2, this.m_PagePaperSetup.margin = 0);
1890
- const e = new bt(this.m_CoverPaperSetup), s = new bt(this.m_PagePaperSetup);
1871
+ const e = new zt(this.m_CoverPaperSetup), s = new zt(this.m_PagePaperSetup);
1891
1872
  this.m_Content.init(this);
1892
1873
  let i = this.m_Content.coverContents, n = this.m_Content.pageContents, h = this.m_InitialOpenProgress;
1893
1874
  this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), h = 1 - h), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1894
- const a = this.m_CoverPaperCount + this.m_PagePaperCount, c = Math.floor(i.length / 4);
1895
- let u = 0, l = 0, _ = 0;
1875
+ const a = this.m_CoverPaperCount + this.m_PagePaperCount, o = Math.floor(i.length / 4);
1876
+ let u = 0, c = 0, m = 0;
1896
1877
  this.m_Papers = new Array(a);
1897
1878
  for (let w = 0; w < a; w++) {
1898
- const v = this.m_HasCover && (w < c || w >= a - c), N = this.m_RendererFactory.get("Paper"), R = this.m_Papers[w] = new re(v, w, this, N);
1899
- R.renderer.castShadows = this.m_CastShadows, w < Math.round(o.MathUtils.lerp(0, a, h)) && (R.transform.scale.set(-1, 1, 1), R.setTime(1)), v ? (R.setContentData(i[l++], i[l++], w > c), R.setMaterialData(e), R.setPaperSetup(this.m_CoverPaperSetup)) : (R.setContentData(n[u++], n[u++]), R.setMaterialData(s), R.setPaperSetup(this.m_PagePaperSetup)), _ += R.thickness;
1900
- }
1901
- this.m_TotalThickness = _;
1902
- const d = this.m_Papers[0].thickness, f = this.m_Papers[Math.floor(a / 2)].thickness;
1903
- this.m_MinPaperThickness = Math.min(d, f), this.m_MaxPaperThickness = Math.max(d, f);
1904
- const m = this.m_Papers[0].size.x, g = this.m_Papers[Math.floor(a / 2)].size.x;
1905
- this.m_MinPaperWidth = Math.min(m, g);
1879
+ const v = this.m_HasCover && (w < o || w >= a - o), N = this.m_RendererFactory.get("Paper"), R = this.m_Papers[w] = new ae(v, w, this, N);
1880
+ R.renderer.castShadows = this.m_CastShadows, w < Math.round(l.MathUtils.lerp(0, a, h)) && (R.transform.scale.set(-1, 1, 1), R.setTime(1)), v ? (R.setContentData(i[c++], i[c++], w > o), R.setMaterialData(e), R.setPaperSetup(this.m_CoverPaperSetup)) : (R.setContentData(n[u++], n[u++]), R.setMaterialData(s), R.setPaperSetup(this.m_PagePaperSetup)), m += R.thickness;
1881
+ }
1882
+ this.m_TotalThickness = m;
1883
+ const f = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
1884
+ this.m_MinPaperThickness = Math.min(f, d), this.m_MaxPaperThickness = Math.max(f, d);
1885
+ const _ = this.m_Papers[0].size.x, g = this.m_Papers[Math.floor(a / 2)].size.x;
1886
+ this.m_MinPaperWidth = Math.min(_, g);
1906
1887
  const p = this.m_Papers[0].size.y, M = this.m_Papers[Math.floor(a / 2)].size.y;
1907
1888
  this.m_MinPaperHeight = Math.min(p, M), this.m_Bound = this.m_Binding.createBound(
1908
1889
  this,
@@ -1910,13 +1891,13 @@ const W = class W extends o.Group {
1910
1891
  this.m_RendererFactory,
1911
1892
  this.m_MeshFactory
1912
1893
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1913
- const T = this.m_ReduceOverdraw && n.length > 0, C = this.m_ReduceSubMeshes, S = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, C), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, C, !0) : null, D = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), L = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1894
+ const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes, C = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), L = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
1914
1895
  for (let w = 0; w < a; w++) {
1915
1896
  const v = this.m_Papers[w];
1916
1897
  w !== 0 && (v.prev = this.m_Papers[w - 1]), w !== a - 1 && (v.next = this.m_Papers[w + 1]), v.noHole = A && (w === z || w === E), v.isCover ? v.setMeshData(U.get(), null, L) : v.setMeshData(
1917
- S.get(),
1898
+ C.get(),
1918
1899
  (k == null ? void 0 : k.get()) ?? null,
1919
- D
1900
+ I
1920
1901
  );
1921
1902
  }
1922
1903
  this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this._frontPapersCache = null, this.update(0), this.m_CoverPaperSetup.bookDirection = j.LeftToRight, this.m_PagePaperSetup.bookDirection = j.LeftToRight;
@@ -1944,7 +1925,7 @@ const W = class W extends o.Group {
1944
1925
  i,
1945
1926
  s
1946
1927
  );
1947
- return new ue(
1928
+ return new _e(
1948
1929
  this.m_MeshFactory,
1949
1930
  h,
1950
1931
  e && this.m_Bound.useSharedMeshDataForLowpoly
@@ -1996,14 +1977,14 @@ const W = class W extends o.Group {
1996
1977
  return !1;
1997
1978
  this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
1998
1979
  const n = this.m_Papers.length, h = Math.floor(t.length / 4);
1999
- let a = 0, c = 0;
1980
+ let a = 0, o = 0;
2000
1981
  for (let u = 0; u < n; u++) {
2001
- const l = this.m_Papers[u];
2002
- this.m_HasCover && (u < h || u >= n - h) ? l.setContentData(
2003
- t[c++],
2004
- t[c++],
1982
+ const c = this.m_Papers[u];
1983
+ this.m_HasCover && (u < h || u >= n - h) ? c.setContentData(
1984
+ t[o++],
1985
+ t[o++],
2005
1986
  u > h
2006
- ) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
1987
+ ) : c.setContentData(e[a++], e[a++]), c.updateMaterials();
2007
1988
  }
2008
1989
  return this.m_WasIdle = !1, !0;
2009
1990
  }
@@ -2035,12 +2016,12 @@ const W = class W extends o.Group {
2035
2016
  };
2036
2017
  W.s_Instances = /* @__PURE__ */ new Set(), W.s_InstancesArray = null;
2037
2018
  let Ct = W;
2038
- class ge {
2019
+ class xe {
2039
2020
  constructor() {
2040
- this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new o.Vector2(), this.thickness = 0;
2021
+ this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new l.Vector2(), this.thickness = 0;
2041
2022
  }
2042
2023
  }
2043
- class Ae {
2024
+ class Fe {
2044
2025
  constructor() {
2045
2026
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
2046
2027
  }
@@ -2051,7 +2032,7 @@ class Ae {
2051
2032
  return this.m_IsActive;
2052
2033
  }
2053
2034
  get textureST() {
2054
- return new o.Vector4(1, 1, 0, 0);
2035
+ return new l.Vector4(1, 1, 0, 0);
2055
2036
  }
2056
2037
  get isShareable() {
2057
2038
  return !0;
@@ -2075,15 +2056,15 @@ class Ae {
2075
2056
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
2076
2057
  }
2077
2058
  }
2078
- class Ft {
2059
+ class Lt {
2079
2060
  constructor(t, e) {
2080
- this.m_Texture = t, this.m_TextureST = e ?? new o.Vector4(1, 1, 0, 0);
2061
+ this.m_Texture = t, this.m_TextureST = e ?? new l.Vector4(1, 1, 0, 0);
2081
2062
  }
2082
2063
  get texture() {
2083
2064
  return this.m_Texture;
2084
2065
  }
2085
2066
  get textureST() {
2086
- return this.m_Texture ? this.m_TextureST : new o.Vector4(1, 1, 0, 0);
2067
+ return this.m_Texture ? this.m_TextureST : new l.Vector4(1, 1, 0, 0);
2087
2068
  }
2088
2069
  isPointOverUI(t) {
2089
2070
  return !1;
@@ -2093,7 +2074,7 @@ class Ft {
2093
2074
  setActive(t) {
2094
2075
  }
2095
2076
  }
2096
- class He {
2077
+ class Oe {
2097
2078
  constructor() {
2098
2079
  this.m_Direction = j.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null, this._cachedCovers = null, this._cachedPages = null;
2099
2080
  }
@@ -2147,12 +2128,12 @@ class He {
2147
2128
  }
2148
2129
  getContent(t) {
2149
2130
  if (t !== null) {
2150
- if (t instanceof o.Texture)
2151
- return new Ft(t);
2131
+ if (t instanceof l.Texture)
2132
+ return new Lt(t);
2152
2133
  if (typeof t.init == "function")
2153
2134
  return t;
2154
2135
  }
2155
- return new Ft(null);
2136
+ return new Lt(null);
2156
2137
  }
2157
2138
  init(t) {
2158
2139
  this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
@@ -2200,9 +2181,9 @@ class He {
2200
2181
  return !this.isCoverPaperSideIndex(t);
2201
2182
  }
2202
2183
  }
2203
- class Fe {
2184
+ class Ze {
2204
2185
  constructor(t, e) {
2205
- this.enabled = !0, this.m_Raycaster = new o.Raycaster(), this.m_Mouse = new o.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2186
+ this.enabled = !0, this.m_Raycaster = new l.Raycaster(), this.m_Mouse = new l.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2206
2187
  var n;
2207
2188
  if (!this.enabled || s.button !== 0) return;
2208
2189
  this.m_IsPointerDown = !0;
@@ -2227,9 +2208,9 @@ class Fe {
2227
2208
  return this.m_Mouse.x = (t.clientX - e.left) / e.width * 2 - 1, this.m_Mouse.y = -((t.clientY - e.top) / e.height) * 2 + 1, this.m_Raycaster.setFromCamera(this.m_Mouse, this.m_Camera), this.m_Raycaster.ray;
2228
2209
  }
2229
2210
  }
2230
- class pe {
2211
+ class Me {
2231
2212
  }
2232
- class xe {
2213
+ class ye {
2233
2214
  constructor(t, e) {
2234
2215
  this.bindingType = "", this.m_Book = t, this.m_Root = e;
2235
2216
  }
@@ -2237,36 +2218,36 @@ class xe {
2237
2218
  dispose() {
2238
2219
  }
2239
2220
  }
2240
- function Ot(r, t, e, s) {
2221
+ function Et(r, t, e, s) {
2241
2222
  const i = 1 - s;
2242
- return new o.Vector3(
2223
+ return new l.Vector3(
2243
2224
  i * i * r.x + 2 * i * s * t.x + s * s * e.x,
2244
2225
  i * i * r.y + 2 * i * s * t.y + s * s * e.y,
2245
2226
  i * i * r.z + 2 * i * s * t.z + s * s * e.z
2246
2227
  );
2247
2228
  }
2248
- function Zt(r, t) {
2229
+ function Nt(r, t) {
2249
2230
  return r++, r === t ? 0 : r;
2250
2231
  }
2251
- function Me(r, t) {
2232
+ function Ce(r, t) {
2252
2233
  return r === 0 ? t - 1 : r - 1;
2253
2234
  }
2254
- const ye = 0.01, Ce = 0.1, we = 0.04, Pe = 0.4, Se = 2, Te = 10, ve = 0, ke = 5;
2255
- function Be(r, t) {
2235
+ const we = 0.01, Pe = 0.1, Te = 0.04, Se = 0.4, ve = 2, ke = 10, Be = 0, Re = 5;
2236
+ function be(r, t) {
2256
2237
  const e = r.clone().normalize();
2257
- if (e.lengthSq() === 0) return new o.Quaternion();
2258
- let s = new o.Vector3().crossVectors(t, e);
2238
+ if (e.lengthSq() === 0) return new l.Quaternion();
2239
+ let s = new l.Vector3().crossVectors(t, e);
2259
2240
  if (s.lengthSq() === 0) {
2260
- const h = Math.abs(e.y) < 0.999 ? new o.Vector3(0, 1, 0) : new o.Vector3(1, 0, 0);
2261
- s = new o.Vector3().crossVectors(h, e);
2241
+ const h = Math.abs(e.y) < 0.999 ? new l.Vector3(0, 1, 0) : new l.Vector3(1, 0, 0);
2242
+ s = new l.Vector3().crossVectors(h, e);
2262
2243
  }
2263
2244
  s.normalize();
2264
- const i = new o.Vector3().crossVectors(e, s).normalize(), n = new o.Matrix4().makeBasis(s, i, e);
2265
- return new o.Quaternion().setFromRotationMatrix(n);
2245
+ const i = new l.Vector3().crossVectors(e, s).normalize(), n = new l.Matrix4().makeBasis(s, i, e);
2246
+ return new l.Quaternion().setFromRotationMatrix(n);
2266
2247
  }
2267
- class Re {
2248
+ class De {
2268
2249
  constructor() {
2269
- this._material = null, this._color = new o.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2250
+ this._material = null, this._color = new l.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2270
2251
  }
2271
2252
  get material() {
2272
2253
  return this._material;
@@ -2284,55 +2265,55 @@ class Re {
2284
2265
  return this._thickness;
2285
2266
  }
2286
2267
  set thickness(t) {
2287
- this._thickness = H(t, ye, Ce);
2268
+ this._thickness = H(t, we, Pe);
2288
2269
  }
2289
2270
  get margin() {
2290
2271
  return this._margin;
2291
2272
  }
2292
2273
  set margin(t) {
2293
- this._margin = ct(t);
2274
+ this._margin = lt(t);
2294
2275
  }
2295
2276
  get crown() {
2296
2277
  return this._crown;
2297
2278
  }
2298
2279
  set crown(t) {
2299
- this._crown = H(t, we, Pe);
2280
+ this._crown = H(t, Te, Se);
2300
2281
  }
2301
2282
  get count() {
2302
2283
  return this._count;
2303
2284
  }
2304
2285
  set count(t) {
2305
- this._count = H(t, Se, Te);
2286
+ this._count = H(t, ve, ke);
2306
2287
  }
2307
2288
  get quality() {
2308
2289
  return this._quality;
2309
2290
  }
2310
2291
  set quality(t) {
2311
- this._quality = H(t, ve, ke);
2292
+ this._quality = H(t, Be, Re);
2312
2293
  }
2313
2294
  }
2314
- class be extends xe {
2295
+ class Ie extends ye {
2315
2296
  // ── Constructor ────────────────────────────────────────────────────────
2316
2297
  constructor(t, e, s, i, n) {
2317
2298
  if (super(s, i), this.bindingType = "staple", this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
2318
- throw new fe();
2319
- const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, c = new o.BufferGeometry();
2320
- this.updateStapleMesh(e, c);
2321
- const u = n ?? new o.MeshStandardMaterial({
2299
+ throw new pe();
2300
+ const h = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, o = new l.BufferGeometry();
2301
+ this.updateStapleMesh(e, o);
2302
+ const u = n ?? new l.MeshStandardMaterial({
2322
2303
  color: e.color,
2323
2304
  metalness: 0.9,
2324
2305
  roughness: 0.3
2325
2306
  });
2326
- this.stapleMesh = new o.Mesh(c, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2307
+ this.stapleMesh = new l.Mesh(o, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2327
2308
  0,
2328
2309
  0,
2329
2310
  this.m_StapleMargin + a.margin + h.margin
2330
2311
  );
2331
- let l = h.thickness;
2332
- l = Math.max(this.m_BindingRadius, l);
2333
- for (const _ of this.m_Book.papers) {
2334
- const d = _.size.clone();
2335
- d.x -= this.m_BindingRadius, _.sizeXOffset = this.m_BindingRadius, _.size = d, _.setMinTurningRadius(l), _.updateTurningRadius(), this.updatePaperPosition(_);
2312
+ let c = h.thickness;
2313
+ c = Math.max(this.m_BindingRadius, c);
2314
+ for (const m of this.m_Book.papers) {
2315
+ const f = m.size.clone();
2316
+ f.x -= this.m_BindingRadius, m.sizeXOffset = this.m_BindingRadius, m.size = f, m.setMinTurningRadius(c), m.updateTurningRadius(), this.updatePaperPosition(m);
2336
2317
  }
2337
2318
  this.updateRootPosition();
2338
2319
  }
@@ -2350,121 +2331,121 @@ class be extends xe {
2350
2331
  );
2351
2332
  this.m_StapleMargin = F(i, n, t.margin);
2352
2333
  const h = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2353
- let a = t.count, c = (h - s * a) / (a - 1);
2354
- for (c = Math.max(c, 0); c < this.m_StapleThickness * 2 && a > 2; )
2355
- a--, c = (h - s * a) / (a - 1), c = Math.max(c, 0);
2356
- const u = t.quality / 5, l = Math.floor(F(4, 20, u)), _ = Math.floor(F(4, 10, u)), d = Math.floor(F(3, 10, u)), f = this.m_StapleThickness / 2, m = f * 2.5, g = 0.9, p = f * 1;
2334
+ let a = t.count, o = (h - s * a) / (a - 1);
2335
+ for (o = Math.max(o, 0); o < this.m_StapleThickness * 2 && a > 2; )
2336
+ a--, o = (h - s * a) / (a - 1), o = Math.max(o, 0);
2337
+ const u = t.quality / 5, c = Math.floor(F(4, 20, u)), m = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), d = this.m_StapleThickness / 2, _ = d * 2.5, g = 0.9, p = d * 1;
2357
2338
  let M = s / 2 * g;
2358
2339
  M = Math.max(M, p * 2);
2359
2340
  let T = 0;
2360
- T += this.m_Book.totalThickness / 2, T += f;
2361
- const C = -(this.m_Book.papers[0].thickness / 2 + f), S = [];
2341
+ T += this.m_Book.totalThickness / 2, T += d;
2342
+ const P = -(this.m_Book.papers[0].thickness / 2 + d), C = [];
2362
2343
  {
2363
- for (let I = 0; I < _; I++) {
2364
- const G = I / (_ - 1), K = F(-90, -180, G) * J, y = new o.Vector3(
2344
+ for (let V = 0; V < m; V++) {
2345
+ const G = V / (m - 1), K = F(-90, -180, G) * J, y = new l.Vector3(
2365
2346
  p * Math.sin(K),
2366
2347
  0,
2367
2348
  p * Math.cos(K)
2368
2349
  );
2369
- y.x += p, y.z += p, y.x += C, S.push(y);
2350
+ y.x += p, y.z += p, y.x += P, C.push(y);
2370
2351
  }
2371
- const x = new o.Vector3(T, 0, 0), Z = new o.Vector3(T + m * 0.75, 0, 0), P = new o.Vector3(T - f * 0.5, 0, M);
2372
- for (let I = 0; I < d; I++) {
2373
- const G = I / (d - 1), Y = Ot(x, Z, P, G);
2374
- Y.x += C, S.push(Y);
2352
+ const x = new l.Vector3(T, 0, 0), Z = new l.Vector3(T + _ * 0.75, 0, 0), S = new l.Vector3(T - d * 0.5, 0, M);
2353
+ for (let V = 0; V < f; V++) {
2354
+ const G = V / (f - 1), Y = Et(x, Z, S, G);
2355
+ Y.x += P, C.push(Y);
2375
2356
  }
2376
- S.reverse();
2357
+ C.reverse();
2377
2358
  }
2378
- const k = new Array(l);
2379
- for (let x = 0; x < l; x++) {
2380
- const P = (90 - x * (360 / l)) * J;
2381
- k[x] = new o.Vector3(Math.cos(P), Math.sin(P), 0), k[x].x *= 0.75;
2359
+ const k = new Array(c);
2360
+ for (let x = 0; x < c; x++) {
2361
+ const S = (90 - x * (360 / c)) * J;
2362
+ k[x] = new l.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
2382
2363
  }
2383
- const D = S.length, U = D * l, L = new Array(U * 2), z = new Array(U * 2), E = new Array(
2384
- (U * 2 - 1) * l * 2 * 3
2364
+ const I = C.length, U = I * c, L = new Array(U * 2), z = new Array(U * 2), E = new Array(
2365
+ (U * 2 - 1) * c * 2 * 3
2385
2366
  );
2386
2367
  for (let x = 0; x < U * 2; x++)
2387
- L[x] = new o.Vector3(), z[x] = new o.Vector3();
2368
+ L[x] = new l.Vector3(), z[x] = new l.Vector3();
2388
2369
  let A = 0;
2389
- for (let x = 0; x < D; x++) {
2390
- const Z = S[Me(x, D)], P = S[x], I = S[Zt(x, D)];
2370
+ for (let x = 0; x < I; x++) {
2371
+ const Z = C[Ce(x, I)], S = C[x], V = C[Nt(x, I)];
2391
2372
  let G;
2392
2373
  if (x === 0)
2393
- G = new o.Vector3(1, 0, -2).normalize();
2394
- else if (x === D - 1)
2395
- G = new o.Vector3(0, 0, 1);
2374
+ G = new l.Vector3(1, 0, -2).normalize();
2375
+ else if (x === I - 1)
2376
+ G = new l.Vector3(0, 0, 1);
2396
2377
  else {
2397
- const it = P.clone().sub(Z).normalize(), nt = I.clone().sub(P).normalize();
2378
+ const it = S.clone().sub(Z).normalize(), nt = V.clone().sub(S).normalize();
2398
2379
  G = it.add(nt).multiplyScalar(0.5);
2399
2380
  }
2400
- const Y = new o.Vector3(0, 1, 0), K = Be(G, Y), y = A;
2401
- let b = Q(0, d / 4, x);
2381
+ const Y = new l.Vector3(0, 1, 0), K = be(G, Y), y = A;
2382
+ let b = Q(0, f / 4, x);
2402
2383
  b = F(0.1, 1, b), b = Math.sqrt(b);
2403
- for (let it = 0; it < l; it++) {
2404
- const nt = k[it].clone().applyQuaternion(K).multiplyScalar(b), lt = P.clone().add(nt.clone().multiplyScalar(f));
2405
- L[A] = lt, z[A] = nt.clone();
2406
- const ot = P.clone().add(nt.clone().multiplyScalar(f));
2384
+ for (let it = 0; it < c; it++) {
2385
+ const nt = k[it].clone().applyQuaternion(K).multiplyScalar(b), ct = S.clone().add(nt.clone().multiplyScalar(d));
2386
+ L[A] = ct, z[A] = nt.clone();
2387
+ const ot = S.clone().add(nt.clone().multiplyScalar(d));
2407
2388
  ot.z = s - ot.z;
2408
- const $t = y + l - it - 1, St = U * 2 - $t - 1;
2389
+ const te = y + c - it - 1, St = U * 2 - te - 1;
2409
2390
  L[St] = ot, z[St] = nt.clone(), A++;
2410
2391
  }
2411
2392
  }
2412
2393
  let B = 0;
2413
- const w = S.length * 2;
2394
+ const w = C.length * 2;
2414
2395
  for (let x = 0; x < w - 1; x++) {
2415
- const Z = x * l, P = (x + 1) * l;
2416
- for (let I = 0; I < l; I++) {
2417
- const G = Zt(I, l), Y = Z + I, K = Z + G, y = P + G, b = P + I;
2396
+ const Z = x * c, S = (x + 1) * c;
2397
+ for (let V = 0; V < c; V++) {
2398
+ const G = Nt(V, c), Y = Z + V, K = Z + G, y = S + G, b = S + V;
2418
2399
  E[B++] = Y, E[B++] = b, E[B++] = K, E[B++] = K, E[B++] = b, E[B++] = y;
2419
2400
  }
2420
2401
  }
2421
2402
  const v = [...L], N = [...z], R = [...E], $ = L.map((x) => x.clone()), tt = [...E];
2422
2403
  for (let x = 0; x < a - 1; x++) {
2423
2404
  const Z = $.length;
2424
- for (let P = 0; P < tt.length; P++)
2425
- tt[P] += Z;
2426
- for (let P = 0; P < $.length; P++)
2427
- $[P].z += c + s;
2428
- v.push(...$.map((P) => P.clone())), N.push(...z.map((P) => P.clone())), R.push(...tt);
2405
+ for (let S = 0; S < tt.length; S++)
2406
+ tt[S] += Z;
2407
+ for (let S = 0; S < $.length; S++)
2408
+ $[S].z += o + s;
2409
+ v.push(...$.map((S) => S.clone())), N.push(...z.map((S) => S.clone())), R.push(...tt);
2429
2410
  }
2430
2411
  const q = new Float32Array(v.length * 3), O = new Float32Array(N.length * 3);
2431
2412
  for (let x = 0; x < v.length; x++)
2432
2413
  q[x * 3] = v[x].x, q[x * 3 + 1] = v[x].y, q[x * 3 + 2] = v[x].z, O[x * 3] = N[x].x, O[x * 3 + 1] = N[x].y, O[x * 3 + 2] = N[x].z;
2433
2414
  e.setAttribute(
2434
2415
  "position",
2435
- new o.BufferAttribute(q, 3)
2416
+ new l.BufferAttribute(q, 3)
2436
2417
  ), e.setAttribute(
2437
2418
  "normal",
2438
- new o.BufferAttribute(O, 3)
2419
+ new l.BufferAttribute(O, 3)
2439
2420
  ), e.setIndex(R);
2440
2421
  }
2441
2422
  // ── createPaperPattern ────────────────────────────────────────────────
2442
2423
  createPaperPattern(t, e, s, i, n, h) {
2443
- const a = new ge();
2424
+ const a = new xe();
2444
2425
  a.size = e, a.thickness = s;
2445
- const c = this.m_BindingRadius;
2446
- a.baseXOffset = -c;
2426
+ const o = this.m_BindingRadius;
2427
+ a.baseXOffset = -o;
2447
2428
  const u = this.m_Quality + 1;
2448
2429
  this.m_BindingVertexCount = u;
2449
- const l = t / 5, _ = Math.min(e.x, e.y) / 60, d = Math.floor(
2450
- F(0, (e.x - c) / _, l)
2451
- ), f = Math.floor(F(0, e.y / _, l));
2452
- let m = 2 + d + 1 + u, g = 2 + f;
2430
+ const c = t / 5, m = Math.min(e.x, e.y) / 60, f = Math.floor(
2431
+ F(0, (e.x - o) / m, c)
2432
+ ), d = Math.floor(F(0, e.y / m, c));
2433
+ let _ = 2 + f + 1 + u, g = 2 + d;
2453
2434
  const p = new ht(0);
2454
2435
  let M = p;
2455
- const T = c / u;
2456
- let C = 0;
2436
+ const T = o / u;
2437
+ let P = 0;
2457
2438
  for (let y = 1; y < u + 1; y++)
2458
- M = M.createNext(C), C += T;
2459
- const S = (e.x - c) / (d + 1);
2460
- for (let y = u + 1; y < m; y++)
2461
- M = M.createNext(C), C += S;
2439
+ M = M.createNext(P), P += T;
2440
+ const C = (e.x - o) / (f + 1);
2441
+ for (let y = u + 1; y < _; y++)
2442
+ M = M.createNext(P), P += C;
2462
2443
  const k = new ht(0);
2463
- let D = k;
2444
+ let I = k;
2464
2445
  const U = e.y / (g - 1);
2465
2446
  let L = 0;
2466
2447
  for (let y = 0; y < g - 1; y++)
2467
- L += U, D = D.createNext(L);
2448
+ L += U, I = I.createNext(L);
2468
2449
  const z = [], E = [], A = i.clone();
2469
2450
  if (n) {
2470
2451
  let y = 0;
@@ -2472,7 +2453,7 @@ class be extends xe {
2472
2453
  const b = Math.max(0.01, s);
2473
2454
  A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, A.down = b / e.y, A.up = b / e.y;
2474
2455
  }
2475
- const B = new he(a, A, !1);
2456
+ const B = new oe(a, A, !1);
2476
2457
  B.insert(p, k, z, E), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(E, a.zSeams);
2477
2458
  const w = this.m_BindingVertexCount + 2, v = new Array(w);
2478
2459
  a.xNoneSeamIndexes = v, M = p;
@@ -2483,9 +2464,9 @@ class be extends xe {
2483
2464
  while (M.seam);
2484
2465
  }
2485
2466
  const N = p.getValues(), R = k.getValues();
2486
- m = N.length, g = R.length;
2487
- const $ = m * g, tt = [], q = new Array($).fill(0), O = [], x = [], Z = [], P = [];
2488
- Gt(
2467
+ _ = N.length, g = R.length;
2468
+ const $ = _ * g, tt = [], q = new Array($).fill(0), O = [], x = [], Z = [], S = [];
2469
+ $t(
2489
2470
  tt,
2490
2471
  N,
2491
2472
  R,
@@ -2493,31 +2474,31 @@ class be extends xe {
2493
2474
  i,
2494
2475
  this.m_Book.direction
2495
2476
  );
2496
- const I = B.leftNode.index, G = B.downNode.index;
2477
+ const V = B.leftNode.index, G = B.downNode.index;
2497
2478
  let Y = B.rightNode.index, K = B.upNode.index;
2498
- Y === 0 && (Y = m - 1), K === 0 && (K = g - 1);
2479
+ Y === 0 && (Y = _ - 1), K === 0 && (K = g - 1);
2499
2480
  for (let y = 0; y < g - 1; y++)
2500
- for (let b = 0; b < m - 1; b++) {
2501
- if (n && y >= G && y < K && b >= I && b < Y)
2481
+ for (let b = 0; b < _ - 1; b++) {
2482
+ if (n && y >= G && y < K && b >= V && b < Y)
2502
2483
  continue;
2503
- const it = y * m + b, nt = y * m + (b + 1), lt = (y + 1) * m + b, ot = (y + 1) * m + (b + 1);
2504
- q[it] += 2, q[nt] += 2, q[lt] += 2, q[ot] += 2, Wt(
2484
+ const it = y * _ + b, nt = y * _ + (b + 1), ct = (y + 1) * _ + b, ot = (y + 1) * _ + (b + 1);
2485
+ q[it] += 2, q[nt] += 2, q[ct] += 2, q[ot] += 2, Qt(
2505
2486
  O,
2506
2487
  x,
2507
2488
  it,
2508
2489
  nt,
2509
- lt,
2490
+ ct,
2510
2491
  ot,
2511
2492
  $
2512
2493
  );
2513
2494
  }
2514
- if (P.push(new Pt(0, 0, m - 1, g - 1, !1, !1)), Nt(P, Z, tt, m, g), a.baseXArray = N, a.baseZArray = R, a.baseVertexCount = $, a.vertexCount = tt.length, a.texcoords = tt, a.weights = q, h) {
2495
+ if (S.push(new Tt(0, 0, _ - 1, g - 1, !1, !1)), jt(S, Z, tt, _, g), a.baseXArray = N, a.baseZArray = R, a.baseVertexCount = $, a.vertexCount = tt.length, a.texcoords = tt, a.weights = q, h) {
2515
2496
  a.subMeshCount = 1;
2516
2497
  const y = [];
2517
2498
  y.push(...O), y.push(...Z), y.push(...x), a.triangles = y;
2518
2499
  } else
2519
2500
  a.subMeshCount = 3, a.frontTriangles = O, a.backTriangles = x, a.borderTriangles = Z;
2520
- return a.borders = P, a;
2501
+ return a.borders = S, a;
2521
2502
  }
2522
2503
  // ── updateRootPosition ────────────────────────────────────────────────
2523
2504
  updateRootPosition() {
@@ -2530,41 +2511,41 @@ class be extends xe {
2530
2511
  const e = this.m_Book.papers, s = e.length;
2531
2512
  let i = 0;
2532
2513
  const n = e.length / 2 - 1, h = e.length / 2;
2533
- for (let C = 0; C < s; C++) {
2534
- const S = e[C];
2535
- S.updateTime();
2536
- const k = S.zTime, D = S.thickness;
2537
- i += k * D, C === n && (i += k * this.m_BindingMidSpace / 2), C === h && (i += k * this.m_BindingMidSpace / 2);
2514
+ for (let P = 0; P < s; P++) {
2515
+ const C = e[P];
2516
+ C.updateTime();
2517
+ const k = C.zTime, I = C.thickness;
2518
+ i += k * I, P === n && (i += k * this.m_BindingMidSpace / 2), P === h && (i += k * this.m_BindingMidSpace / 2);
2538
2519
  }
2539
2520
  let a = this.getStackHeight(t.index) - t.thickness / 2;
2540
- const c = this.getStackZ(a), u = 180 + c;
2541
- let l = t.isFlipped ? 1 : 0, _ = F(c, u, l);
2542
- const d = _ * J, f = new o.Vector3(
2543
- Math.cos(d) * this.m_BindingRadius,
2544
- Math.sin(d) * this.m_BindingRadius,
2521
+ const o = this.getStackZ(a), u = 180 + o;
2522
+ let c = t.isFlipped ? 1 : 0, m = F(o, u, c);
2523
+ const f = m * J, d = new l.Vector3(
2524
+ Math.cos(f) * this.m_BindingRadius,
2525
+ Math.sin(f) * this.m_BindingRadius,
2545
2526
  0
2546
2527
  );
2547
- f.z = t.margin;
2548
- let m = e[Math.floor(s / 2)].size.x, g = this.m_BindingMidSpace, p = Math.sqrt(m * m - g * g), M = Math.asin(p / m) * et - 90;
2528
+ d.z = t.margin;
2529
+ let _ = e[Math.floor(s / 2)].size.x, g = this.m_BindingMidSpace, p = Math.sqrt(_ * _ - g * g), M = Math.asin(p / _) * et - 90;
2549
2530
  if (t.index < Math.floor(s / 2)) {
2550
- let C = 0;
2531
+ let P = 0;
2551
2532
  if (this.m_Book.alignToGround) {
2552
- m = e[0].size.x;
2553
- const S = this.m_StackHeight / 2;
2554
- g = H(i, 0, S) - S, p = Math.sqrt(m * m - g * g), C = (Math.asin(p / m) * et - 90) * 2;
2533
+ _ = e[0].size.x;
2534
+ const C = this.m_StackHeight / 2;
2535
+ g = H(i, 0, C) - C, p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2555
2536
  }
2556
- _ = F(M, -C, l);
2537
+ m = F(M, -P, c);
2557
2538
  } else {
2558
- let C = 0;
2539
+ let P = 0;
2559
2540
  if (this.m_Book.alignToGround) {
2560
- m = e[0].size.x;
2561
- const S = this.m_StackHeight / 2;
2562
- g = S - H(i, S, S * 2), p = Math.sqrt(m * m - g * g), C = (Math.asin(p / m) * et - 90) * 2;
2541
+ _ = e[0].size.x;
2542
+ const C = this.m_StackHeight / 2;
2543
+ g = C - H(i, C, C * 2), p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
2563
2544
  }
2564
- _ = F(C, -M, l);
2545
+ m = F(P, -M, c);
2565
2546
  }
2566
- t.transform.position.copy(f), t.transform.quaternion.setFromEuler(
2567
- new o.Euler(0, 0, _ * J)
2547
+ t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2548
+ new l.Euler(0, 0, m * J)
2568
2549
  );
2569
2550
  }
2570
2551
  // ── getPX (private helper) ───────────────────────────────────────────
@@ -2578,33 +2559,33 @@ class be extends xe {
2578
2559
  }
2579
2560
  updatePaperPositionWithTh(t, e) {
2580
2561
  const s = this.m_Book.papers, i = s.length, n = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(n + e), a = 180 + this.getStackZ(n + e - this.m_StackHeight);
2581
- let c = t.zTime, u = F(h, a, c);
2582
- const l = u * J, _ = new o.Vector3(
2583
- Math.cos(l) * this.m_BindingRadius,
2584
- Math.sin(l) * this.m_BindingRadius,
2562
+ let o = t.zTime, u = F(h, a, o);
2563
+ const c = u * J, m = new l.Vector3(
2564
+ Math.cos(c) * this.m_BindingRadius,
2565
+ Math.sin(c) * this.m_BindingRadius,
2585
2566
  0
2586
2567
  );
2587
- _.z = t.margin;
2588
- let d = s[Math.floor(i / 2)].size.x, f = this.m_BindingMidSpace, m = Math.sqrt(d * d - f * f), g = Math.asin(m / d) * et - 90;
2568
+ m.z = t.margin;
2569
+ let f = s[Math.floor(i / 2)].size.x, d = this.m_BindingMidSpace, _ = Math.sqrt(f * f - d * d), g = Math.asin(_ / f) * et - 90;
2589
2570
  if (t.index < Math.floor(i / 2)) {
2590
2571
  let M = 0;
2591
2572
  if (this.m_Book.alignToGround) {
2592
- d = s[0].size.x;
2573
+ f = s[0].size.x;
2593
2574
  const T = this.m_StackHeight / 2;
2594
- f = H(e, 0, T) - T, m = Math.sqrt(d * d - f * f), M = (Math.asin(m / d) * et - 90) * 2;
2575
+ d = H(e, 0, T) - T, _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2595
2576
  }
2596
- u = F(g, -M, c);
2577
+ u = F(g, -M, o);
2597
2578
  } else {
2598
2579
  let M = 0;
2599
2580
  if (this.m_Book.alignToGround) {
2600
- d = s[0].size.x;
2581
+ f = s[0].size.x;
2601
2582
  const T = this.m_StackHeight / 2;
2602
- f = T - H(e, T, T * 2), m = Math.sqrt(d * d - f * f), M = (Math.asin(m / d) * et - 90) * 2;
2583
+ d = T - H(e, T, T * 2), _ = Math.sqrt(f * f - d * d), M = (Math.asin(_ / f) * et - 90) * 2;
2603
2584
  }
2604
- u = F(M, -g, c);
2585
+ u = F(M, -g, o);
2605
2586
  }
2606
- t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2607
- new o.Euler(0, 0, u * J)
2587
+ t.transform.position.copy(m), t.transform.quaternion.setFromEuler(
2588
+ new l.Euler(0, 0, u * J)
2608
2589
  );
2609
2590
  }
2610
2591
  // ── getStackHeight ────────────────────────────────────────────────────
@@ -2647,38 +2628,38 @@ class be extends xe {
2647
2628
  // ── updateBindingVertices ─────────────────────────────────────────────
2648
2629
  updateBindingVertices() {
2649
2630
  const t = this.m_Book.papers;
2650
- let e = new o.Vector3(0, 0, 0), s = new o.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2651
- const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), c = t.length;
2652
- for (let u = 0; u < c; u++) {
2653
- const l = t[u], _ = l.transform, d = l.meshData.pattern, f = l.meshData.baseVertices, m = d.baseXArray, g = d.baseZArray, p = m.length, M = g.length, T = this.m_BindingVertexCount + 1, C = l.thickness, S = d.xNoneSeamIndexes, k = _.position.clone();
2654
- let D = u, U = n;
2655
- u >= Math.floor(c / 2) && (D = c - u - 1, U *= -1);
2656
- const L = (h + C) * 0.5 + C * (D - 1), z = _.matrixWorld.clone().invert().multiply(a), E = D / (c / 2);
2631
+ let e = new l.Vector3(0, 0, 0), s = new l.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2632
+ const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), o = t.length;
2633
+ for (let u = 0; u < o; u++) {
2634
+ const c = t[u], m = c.transform, f = c.meshData.pattern, d = c.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = c.thickness, C = f.xNoneSeamIndexes, k = m.position.clone();
2635
+ let I = u, U = n;
2636
+ u >= Math.floor(o / 2) && (I = o - u - 1, U *= -1);
2637
+ const L = (h + P) * 0.5 + P * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), E = I / (o / 2);
2657
2638
  i = this.m_BindingRadius * F(0.45, 0.65, 1 - E);
2658
2639
  for (let A = 0; A < M; A++) {
2659
- const B = g[A], w = new o.Vector3(0, 0, k.z + B), v = k.clone();
2640
+ const B = g[A], w = new l.Vector3(0, 0, k.z + B), v = k.clone();
2660
2641
  v.z += B;
2661
- const N = l.getDirection(B).multiplyScalar(i).add(v.clone());
2642
+ const N = c.getDirection(B).multiplyScalar(i).add(v.clone());
2662
2643
  if (u === 0 && A === 0) {
2663
- const O = t[c - 1], Z = O.transform.position.clone().clone();
2644
+ const O = t[o - 1], Z = O.transform.position.clone().clone();
2664
2645
  Z.z += B;
2665
- const P = O.getDirection(B).multiplyScalar(i).add(Z);
2666
- s = N.clone().sub(P).normalize(), e = new o.Vector3(
2646
+ const S = O.getDirection(B).multiplyScalar(i).add(Z);
2647
+ s = N.clone().sub(S).normalize(), e = new l.Vector3(
2667
2648
  -s.y,
2668
2649
  s.x,
2669
2650
  0
2670
2651
  ).normalize().negate();
2671
- const I = Math.atan2(e.y, e.x) * et;
2672
- this.stapleMesh.rotation.set(0, 0, I * J);
2652
+ const V = Math.atan2(e.y, e.x) * et;
2653
+ this.stapleMesh.rotation.set(0, 0, V * J);
2673
2654
  }
2674
- D > 0 && w.add(e.clone().multiplyScalar(L));
2655
+ I > 0 && w.add(e.clone().multiplyScalar(L));
2675
2656
  const R = A * p;
2676
- f[R] = w.clone().applyMatrix4(z), w.add(s.clone().multiplyScalar(U));
2657
+ d[R] = w.clone().applyMatrix4(z), w.add(s.clone().multiplyScalar(U));
2677
2658
  const $ = w.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
2678
- f[R + S[1]] = $;
2659
+ d[R + C[1]] = $;
2679
2660
  for (let O = 2; O < T; O++) {
2680
2661
  const x = Q(1, T, O);
2681
- f[R + S[O]] = Ot(
2662
+ d[R + C[O]] = Et(
2682
2663
  $,
2683
2664
  tt,
2684
2665
  q,
@@ -2712,7 +2693,7 @@ class be extends xe {
2712
2693
  }
2713
2694
  /** Releases GPU resources held by the staple mesh. */
2714
2695
  dispose() {
2715
- this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof o.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2696
+ this.stapleMesh.geometry.dispose(), this.stapleMesh.material instanceof l.Material && this.stapleMesh.material.dispose(), this.stapleMesh.parent && this.stapleMesh.parent.remove(this.stapleMesh);
2716
2697
  }
2717
2698
  }
2718
2699
  class Ve {
@@ -2729,7 +2710,7 @@ class Ve {
2729
2710
  this.mesh.castShadow = t;
2730
2711
  }
2731
2712
  get bounds() {
2732
- const t = new o.Box3();
2713
+ const t = new l.Box3();
2733
2714
  return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
2734
2715
  }
2735
2716
  get transform() {
@@ -2739,12 +2720,12 @@ class Ve {
2739
2720
  return this.mesh;
2740
2721
  }
2741
2722
  }
2742
- class Oe extends pe {
2723
+ class Ue extends Me {
2743
2724
  constructor() {
2744
- super(...arguments), this.quality = 3, this.stapleSetup = new Re();
2725
+ super(...arguments), this.quality = 3, this.stapleSetup = new De();
2745
2726
  }
2746
2727
  createBound(t, e, s, i) {
2747
- return new be(
2728
+ return new Ie(
2748
2729
  this.quality,
2749
2730
  this.stapleSetup,
2750
2731
  t,
@@ -2752,7 +2733,7 @@ class Oe extends pe {
2752
2733
  );
2753
2734
  }
2754
2735
  }
2755
- class jt {
2736
+ class Yt {
2756
2737
  constructor(t) {
2757
2738
  this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0;
2758
2739
  }
@@ -2817,28 +2798,28 @@ class jt {
2817
2798
  t.restore();
2818
2799
  }
2819
2800
  }
2820
- function De(r) {
2821
- return r.map instanceof o.Texture;
2801
+ function ze(r) {
2802
+ return r.map instanceof l.Texture;
2822
2803
  }
2823
- function qt(r, t) {
2804
+ function Kt(r, t) {
2824
2805
  r.traverse((e) => {
2825
2806
  if (!e.isMesh) return;
2826
2807
  const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2827
2808
  for (const n of i)
2828
- De(n) && n.map.image === t && (n.map.needsUpdate = !0);
2809
+ ze(n) && n.map.image === t && (n.map.needsUpdate = !0);
2829
2810
  });
2830
2811
  }
2831
- function Qt(r, t) {
2812
+ function Jt(r, t) {
2832
2813
  t.x !== void 0 && (r.x = t.x), t.y !== void 0 && (r.y = t.y), t.width !== void 0 && (r.width = t.width), t.text !== void 0 && (r.text = t.text), t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && (r.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (r.fontStyle = t.fontStyle), t.color !== void 0 && (r.color = t.color), t.lineHeight !== void 0 && (r.lineHeight = t.lineHeight), t.textAlign !== void 0 && (r.textAlign = t.textAlign), t.opacity !== void 0 && (r.opacity = t.opacity), t.shadowColor !== void 0 && (r.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (r.shadowBlur = t.shadowBlur);
2833
2814
  }
2834
- class Ze {
2815
+ class Le {
2835
2816
  constructor(t) {
2836
- this.texts = [], this._textureST = new o.Vector4(1, 1, 0, 0);
2817
+ this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0);
2837
2818
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
2838
2819
  this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
2839
2820
  const i = this.canvas.getContext("2d");
2840
2821
  if (!i) throw new Error("TextOverlayContent: could not get 2D context");
2841
- this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new o.CanvasTexture(this.canvas), this._texture.colorSpace = o.SRGBColorSpace;
2822
+ this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace;
2842
2823
  }
2843
2824
  get texture() {
2844
2825
  return this._texture;
@@ -2855,7 +2836,7 @@ class Ze {
2855
2836
  }
2856
2837
  // ── Text API ─────────────────────────────────────────────────────────────
2857
2838
  addText(t) {
2858
- const e = new jt(t);
2839
+ const e = new Yt(t);
2859
2840
  return this.texts.push(e), e;
2860
2841
  }
2861
2842
  removeText(t) {
@@ -2865,7 +2846,7 @@ class Ze {
2865
2846
  /** Update a text block by index. Only provided fields are changed. */
2866
2847
  updateText(t, e) {
2867
2848
  const s = this.texts[t];
2868
- s && Qt(s, e);
2849
+ s && Jt(s, e);
2869
2850
  }
2870
2851
  // ── Per-frame update ─────────────────────────────────────────────────────
2871
2852
  /**
@@ -2887,7 +2868,7 @@ class Ze {
2887
2868
  * source image is this overlay's canvas.
2888
2869
  */
2889
2870
  syncMaterials(t) {
2890
- qt(t, this.canvas);
2871
+ Kt(t, this.canvas);
2891
2872
  }
2892
2873
  // ── IPageContent ─────────────────────────────────────────────────────────
2893
2874
  isPointOverUI(t) {
@@ -2901,9 +2882,9 @@ class Ze {
2901
2882
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
2902
2883
  }
2903
2884
  }
2904
- class Ut {
2885
+ class Xt {
2905
2886
  constructor(t, e) {
2906
- this._spread = t, this._textureST = e === "left" ? new o.Vector4(0.5, 1, 0, 0) : new o.Vector4(0.5, 1, 0.5, 0);
2887
+ this._spread = t, this._textureST = e === "left" ? new l.Vector4(0.5, 1, 0, 0) : new l.Vector4(0.5, 1, 0.5, 0);
2907
2888
  }
2908
2889
  get texture() {
2909
2890
  return this._spread.texture;
@@ -2919,18 +2900,18 @@ class Ut {
2919
2900
  setActive(t) {
2920
2901
  }
2921
2902
  }
2922
- function Ue(r) {
2903
+ function Ee(r) {
2923
2904
  const t = [];
2924
2905
  for (let e = 1; e + 1 < r; e += 2)
2925
2906
  t.push(e);
2926
2907
  return t;
2927
2908
  }
2928
- class Le {
2909
+ class Ne {
2929
2910
  constructor(t) {
2930
2911
  this.texts = [], this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2931
2912
  const e = this.canvas.getContext("2d");
2932
2913
  if (!e) throw new Error("SpreadContent: could not get 2D context");
2933
- this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new o.CanvasTexture(this.canvas), this._texture.colorSpace = o.SRGBColorSpace, this.left = new Ut(this, "left"), this.right = new Ut(this, "right");
2914
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new l.CanvasTexture(this.canvas), this._texture.colorSpace = l.SRGBColorSpace, this.left = new Xt(this, "left"), this.right = new Xt(this, "right");
2934
2915
  }
2935
2916
  get texture() {
2936
2917
  return this._texture;
@@ -2944,7 +2925,7 @@ class Le {
2944
2925
  }
2945
2926
  // ── Text API ─────────────────────────────────────────────────────────────
2946
2927
  addText(t) {
2947
- const e = new jt(t);
2928
+ const e = new Yt(t);
2948
2929
  return this.texts.push(e), e;
2949
2930
  }
2950
2931
  removeText(t) {
@@ -2954,7 +2935,7 @@ class Le {
2954
2935
  /** Update a text block by index. Only provided fields are changed. */
2955
2936
  updateText(t, e) {
2956
2937
  const s = this.texts[t];
2957
- s && Qt(s, e);
2938
+ s && Jt(s, e);
2958
2939
  }
2959
2940
  // ── Per-frame update ─────────────────────────────────────────────────────
2960
2941
  /**
@@ -2975,40 +2956,40 @@ class Le {
2975
2956
  * source image is this spread's canvas.
2976
2957
  */
2977
2958
  syncMaterials(t) {
2978
- qt(t, this.canvas);
2959
+ Kt(t, this.canvas);
2979
2960
  }
2980
2961
  // ── Lifecycle ────────────────────────────────────────────────────────────
2981
2962
  dispose() {
2982
2963
  this._texture.dispose(), this.canvas.width = 0, this.canvas.height = 0;
2983
2964
  }
2984
2965
  }
2985
- const Lt = 256;
2986
- function Ie(r, t, e, s, i, n, h) {
2987
- const a = t.naturalWidth || t.width, c = t.naturalHeight || t.height;
2988
- if (a <= 0 || c <= 0) return;
2966
+ const Wt = 256;
2967
+ function Ae(r, t, e, s, i, n, h) {
2968
+ const a = t.naturalWidth || t.width, o = t.naturalHeight || t.height;
2969
+ if (a <= 0 || o <= 0) return;
2989
2970
  if (h === "fill") {
2990
2971
  r.drawImage(t, e, s, i, n);
2991
2972
  return;
2992
2973
  }
2993
- const u = h === "contain" ? Math.min(i / a, n / c) : Math.max(i / a, n / c), l = a * u, _ = c * u;
2994
- r.drawImage(t, e + (i - l) * 0.5, s + (n - _) * 0.5, l, _);
2974
+ const u = h === "contain" ? Math.min(i / a, n / o) : Math.max(i / a, n / o), c = a * u, m = o * u;
2975
+ r.drawImage(t, e + (i - c) * 0.5, s + (n - m) * 0.5, c, m);
2995
2976
  }
2996
- function Ee(r, t, e, s, i, n, h) {
2997
- const a = n ? Math.round(n * Lt) : 512, c = h ? Math.round(h * Lt) : 512, u = document.createElement("canvas");
2998
- u.width = a, u.height = c;
2999
- const l = u.getContext("2d");
3000
- if (l.fillStyle = r, l.fillRect(0, 0, a, c), e) {
3001
- const d = i ? 0 : Math.round(Math.min(a, c) * 0.11);
3002
- Ie(l, e, d, d, a - d * 2, c - d * 2, s);
2977
+ function Xe(r, t, e, s, i, n, h) {
2978
+ const a = n ? Math.round(n * Wt) : 512, o = h ? Math.round(h * Wt) : 512, u = document.createElement("canvas");
2979
+ u.width = a, u.height = o;
2980
+ const c = u.getContext("2d");
2981
+ if (c.fillStyle = r, c.fillRect(0, 0, a, o), e) {
2982
+ const f = i ? 0 : Math.round(Math.min(a, o) * 0.11);
2983
+ Ae(c, e, f, f, a - f * 2, o - f * 2, s);
3003
2984
  } else {
3004
- l.fillStyle = "#333";
3005
- const d = Math.round(Math.min(a, c) * 0.094);
3006
- l.font = `bold ${d}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, a / 2, c / 2);
2985
+ c.fillStyle = "#333";
2986
+ const f = Math.round(Math.min(a, o) * 0.094);
2987
+ c.font = `bold ${f}px Arial`, c.textAlign = "center", c.textBaseline = "middle", c.fillText(t, a / 2, o / 2);
3007
2988
  }
3008
- const _ = new o.CanvasTexture(u);
3009
- return _.colorSpace = o.SRGBColorSpace, _;
2989
+ const m = new l.CanvasTexture(u);
2990
+ return m.colorSpace = l.SRGBColorSpace, m;
3010
2991
  }
3011
- async function Ne(r) {
2992
+ async function We(r) {
3012
2993
  if (!r) return null;
3013
2994
  const t = URL.createObjectURL(r), e = new Image();
3014
2995
  e.decoding = "async", e.src = t;
@@ -3021,47 +3002,47 @@ async function Ne(r) {
3021
3002
  }
3022
3003
  }
3023
3004
  export {
3024
- de as AnimationCurve,
3005
+ ge as AnimationCurve,
3025
3006
  yt as AutoTurnDirection,
3026
- mt as AutoTurnMode,
3007
+ ut as AutoTurnMode,
3027
3008
  at as AutoTurnSetting,
3028
- _e as AutoTurnSettingCurveTimeMode,
3029
- me as AutoTurnSettingMode,
3030
- Ht as AutoTurnSettings,
3009
+ fe as AutoTurnSettingCurveTimeMode,
3010
+ de as AutoTurnSettingMode,
3011
+ Ut as AutoTurnSettings,
3031
3012
  Ct as Book,
3032
- pe as BookBinding,
3033
- xe as BookBound,
3034
- He as BookContent,
3013
+ Me as BookBinding,
3014
+ ye as BookBound,
3015
+ Oe as BookContent,
3035
3016
  j as BookDirection,
3036
- fe as BookHeightException,
3037
- Fe as BookPointerInteraction,
3038
- le as BookRenderer,
3039
- ut as Cylinder,
3040
- ae as MeshFactory,
3041
- Lt as PX_PER_UNIT,
3042
- Ae as PageContent,
3043
- re as Paper,
3044
- Pt as PaperBorder,
3045
- bt as PaperMaterialData,
3046
- zt as PaperMeshData,
3047
- ue as PaperMeshDataPool,
3048
- ze as PaperMeshUtility,
3017
+ pe as BookHeightException,
3018
+ Ze as BookPointerInteraction,
3019
+ me as BookRenderer,
3020
+ wt as Cylinder,
3021
+ le as MeshFactory,
3022
+ Wt as PX_PER_UNIT,
3023
+ Fe as PageContent,
3024
+ ae as Paper,
3025
+ Tt as PaperBorder,
3026
+ zt as PaperMaterialData,
3027
+ Ot as PaperMeshData,
3028
+ _e as PaperMeshDataPool,
3029
+ He as PaperMeshUtility,
3049
3030
  ht as PaperNode,
3050
- he as PaperNodeMargin,
3051
- ge as PaperPattern,
3052
- wt as PaperSeam,
3031
+ oe as PaperNodeMargin,
3032
+ xe as PaperPattern,
3033
+ Pt as PaperSeam,
3053
3034
  rt as PaperSetup,
3054
3035
  gt as PaperUVMargin,
3055
- oe as RendererFactory,
3056
- Le as SpreadContent,
3057
- Ft as SpritePageContent2,
3058
- Oe as StapleBookBinding,
3059
- be as StapleBookBound,
3060
- Re as StapleSetup,
3061
- jt as TextBlock,
3062
- Ze as TextOverlayContent,
3063
- Ee as createPageTexture,
3064
- Ie as drawImageWithFit,
3065
- Ue as getSpreadPairs,
3066
- Ne as loadImage
3036
+ ce as RendererFactory,
3037
+ Ne as SpreadContent,
3038
+ Lt as SpritePageContent2,
3039
+ Ue as StapleBookBinding,
3040
+ Ie as StapleBookBound,
3041
+ De as StapleSetup,
3042
+ Yt as TextBlock,
3043
+ Le as TextOverlayContent,
3044
+ Xe as createPageTexture,
3045
+ Ae as drawImageWithFit,
3046
+ Ee as getSpreadPairs,
3047
+ We as loadImage
3067
3048
  };