@objectifthunes/three-book 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -77,7 +77,7 @@ function gt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
77
77
  let _ = t + (m + g) * h;
78
78
  return l - r > 0 == _ > l && (_ = l, e = (_ - l) / n), { value: _, velocity: e };
79
79
  }
80
- function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
80
+ function ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
81
81
  const o = gt(
82
82
  r.x,
83
83
  t.x,
@@ -102,13 +102,13 @@ function ee(r, t, e, s, i = 1 / 0, n = 1 / 60) {
102
102
  );
103
103
  return e.set(o.velocity, a.velocity, h.velocity), new c.Vector3(o.value, a.value, h.value);
104
104
  }
105
- function se(r) {
105
+ function ne(r) {
106
106
  return new c.Vector3(r.x, 0, r.y);
107
107
  }
108
- function ie(r) {
108
+ function re(r) {
109
109
  return new c.Vector3(r.x, r.z, 0);
110
110
  }
111
- function vt(r, t, e) {
111
+ function St(r, t, e) {
112
112
  const s = t * t - 4 * r * e;
113
113
  if (s < 0)
114
114
  return { rootCount: 0, root0: 0, root1: 0 };
@@ -124,23 +124,23 @@ function vt(r, t, e) {
124
124
  }
125
125
  }
126
126
  function kt(r, t, e) {
127
- return ne(r, t, e) ? r.clone() : re(
127
+ return oe(r, t, e) ? r.clone() : ae(
128
128
  new c.Vector2(r.x, t.y),
129
129
  r,
130
130
  t,
131
131
  e
132
132
  );
133
133
  }
134
- function ne(r, t, e) {
134
+ function oe(r, t, e) {
135
135
  const s = r.x - t.x;
136
136
  let i = r.y - t.y;
137
137
  return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
138
138
  }
139
- function re(r, t, e, s) {
139
+ function ae(r, t, e, s) {
140
140
  const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, d = s.y, g = 1 / (l * l), _ = 1 / (d * d);
141
141
  if (Math.abs(o - h) < 1e-5) {
142
142
  if (o >= i - l && o <= i + l) {
143
- const u = vt(
143
+ const u = St(
144
144
  _,
145
145
  -2 * _ * n,
146
146
  g * (o * o - 2 * i * o + i * i) + _ * n * n - 1
@@ -153,7 +153,7 @@ function re(r, t, e, s) {
153
153
  }
154
154
  }
155
155
  } else {
156
- const u = (m - a) / (h - o), f = a - u * o, p = f - n, P = vt(
156
+ const u = (m - a) / (h - o), f = a - u * o, p = f - n, P = St(
157
157
  g + _ * u * u,
158
158
  2 * p * u * _ - 2 * i * g,
159
159
  i * i * g + p * p * _ - 1
@@ -161,8 +161,8 @@ function re(r, t, e, s) {
161
161
  if (P.rootCount === 1)
162
162
  return new c.Vector2(P.root0, u * P.root0 + f);
163
163
  if (P.rootCount === 2) {
164
- let B = P.root0, x = P.root1;
165
- return o < h && ([B, x] = [x, B]), new c.Vector2(x, u * x + f);
164
+ let B = P.root0, M = P.root1;
165
+ return o < h && ([B, M] = [M, B]), new c.Vector2(M, u * M + f);
166
166
  }
167
167
  }
168
168
  return r.clone();
@@ -171,14 +171,14 @@ function bt(r, t) {
171
171
  const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
172
172
  return new c.Ray(e, s.sub(e));
173
173
  }
174
- function oe(r) {
174
+ function he(r) {
175
175
  return new c.Vector4(-r.x, r.y, r.z + r.x, r.w);
176
176
  }
177
- function ae(r) {
177
+ function le(r) {
178
178
  return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
179
179
  }
180
180
  var X = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(X || {});
181
- const Bt = Math.PI / 180, Rt = 180 / Math.PI, he = 1192093e-13;
181
+ const Bt = Math.PI / 180, Rt = 180 / Math.PI, ce = 1192093e-13;
182
182
  function dt(r) {
183
183
  return r < 0 ? 0 : r > 1 ? 1 : r;
184
184
  }
@@ -197,7 +197,7 @@ function Vt(r, t, e) {
197
197
  function Dt(r, t, e) {
198
198
  return e = dt((e - r) / (t - r)), e * e * (3 - 2 * e);
199
199
  }
200
- class le {
200
+ class me {
201
201
  // ---- Constructor ----
202
202
  constructor(t, e, s, i) {
203
203
  this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new ut(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
@@ -380,14 +380,14 @@ class le {
380
380
  this.m_StartHandle,
381
381
  this.m_EndHandle,
382
382
  this.m_IsFallingLeft ? n : 1 - n
383
- ), this.m_FallTime += t, e = Math.abs(n - 1) < he;
383
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < ce;
384
384
  } else {
385
385
  const n = new c.Vector3(
386
386
  this.m_FallTime,
387
387
  0,
388
388
  this.m_FallTime * 0.75
389
389
  );
390
- this.m_CurrentHandle = ee(
390
+ this.m_CurrentHandle = ie(
391
391
  this.m_CurrentHandle,
392
392
  this.m_EndHandle,
393
393
  this.m_HandleVelocity,
@@ -490,7 +490,7 @@ class le {
490
490
  ), this.m_SubMeshCount = t);
491
491
  const e = this.m_FrontContent.textureST.clone();
492
492
  let s = this.m_BackContent.textureST.clone();
493
- this.m_Book.direction > 1 ? s = ae(s) : s = oe(s);
493
+ this.m_Book.direction > 1 ? s = le(s) : s = he(s);
494
494
  const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
495
495
  if (t === 3) {
496
496
  let o = 0, a = 1;
@@ -559,7 +559,7 @@ class le {
559
559
  h + (s.z - h) * (a / n)
560
560
  ), d = new c.Vector2(i, o), g = new c.Vector2(n, a);
561
561
  t.x = It(t.x, -this.m_Size.x, this.m_Size.x);
562
- const _ = ie(t), u = kt(
562
+ const _ = re(t), u = kt(
563
563
  new c.Vector2(_.x, _.y),
564
564
  m,
565
565
  d
@@ -567,7 +567,7 @@ class le {
567
567
  new c.Vector2(u.x, u.y),
568
568
  l,
569
569
  g
570
- ), p = se(
570
+ ), p = ne(
571
571
  new c.Vector3(f.x, f.y, 0)
572
572
  );
573
573
  this.m_CurrentHandle.copy(p);
@@ -697,9 +697,9 @@ const Y = class Y {
697
697
  };
698
698
  Y.kMin = 0, Y.kMax = 0.25;
699
699
  let pt = Y;
700
- const U = class U {
700
+ const N = class N {
701
701
  constructor(t) {
702
- this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new pt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? U.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? U.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? U.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
702
+ this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new pt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? N.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? N.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? N.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
703
703
  }
704
704
  // ── Properties ────────────────────────────────────────────────────────
705
705
  get material() {
@@ -718,19 +718,19 @@ const U = class U {
718
718
  return this.bookDirection > 1 ? this.m_Height : this.m_Width;
719
719
  }
720
720
  set width(t) {
721
- this.m_Width = Math.max(t, U.kMinSize);
721
+ this.m_Width = Math.max(t, N.kMinSize);
722
722
  }
723
723
  get height() {
724
724
  return this.bookDirection > 1 ? this.m_Width : this.m_Height;
725
725
  }
726
726
  set height(t) {
727
- this.m_Height = Math.max(t, U.kMinSize);
727
+ this.m_Height = Math.max(t, N.kMinSize);
728
728
  }
729
729
  get thickness() {
730
730
  return this.m_Thickness;
731
731
  }
732
732
  set thickness(t) {
733
- this.m_Thickness = Math.max(t, U.kMinThickness);
733
+ this.m_Thickness = Math.max(t, N.kMinThickness);
734
734
  }
735
735
  get stiffness() {
736
736
  return this.m_Stiffness;
@@ -743,8 +743,8 @@ const U = class U {
743
743
  }
744
744
  set quality(t) {
745
745
  this.m_Quality = Math.max(
746
- U.kMinQuality,
747
- Math.min(t, U.kMaxQuality)
746
+ N.kMinQuality,
747
+ Math.min(t, N.kMaxQuality)
748
748
  );
749
749
  }
750
750
  get uvMargin() {
@@ -757,8 +757,8 @@ const U = class U {
757
757
  return new c.Vector2(this.width, this.height);
758
758
  }
759
759
  };
760
- U.kMinSize = 1, U.kMinThickness = 1e-4, U.kMinQuality = 1, U.kMaxQuality = 5;
761
- let ht = U;
760
+ N.kMinSize = 1, N.kMinThickness = 1e-4, N.kMinQuality = 1, N.kMaxQuality = 5;
761
+ let ht = N;
762
762
  class At {
763
763
  constructor(t) {
764
764
  this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
@@ -884,7 +884,7 @@ class Tt {
884
884
  );
885
885
  }
886
886
  }
887
- class ce {
887
+ class ue {
888
888
  constructor(t, e, s) {
889
889
  const i = t.size;
890
890
  this.leftNode = new st(e.left * i.x, s, !0), this.rightNode = new st((1 - e.right) * i.x, s, !0), this.downNode = new st(e.down * i.y, s, !0), this.upNode = new st((1 - e.up) * i.y, s, !0);
@@ -898,31 +898,31 @@ function lt(r, t, e) {
898
898
  const s = (e - r) / (t - r);
899
899
  return Math.max(0, Math.min(1, s));
900
900
  }
901
- function Mt(r, t) {
901
+ function xt(r, t) {
902
902
  for (const e of r) {
903
903
  const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new Pt(s.index, e.index, i.index, n);
904
904
  t.push(o);
905
905
  }
906
906
  }
907
- function xt(r, t, e, s, i) {
907
+ function Mt(r, t, e, s, i) {
908
908
  for (const n of r) {
909
909
  if (!n.active) return;
910
910
  for (let o = 0; o < s; o++) {
911
911
  const a = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[o * e + h], d = t[o * e + n.index];
912
- i ? Wt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
912
+ i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
913
913
  }
914
914
  }
915
915
  }
916
- function yt(r, t, e, s, i) {
916
+ function Ct(r, t, e, s, i) {
917
917
  for (const n of r) {
918
918
  if (!n.active) return;
919
919
  for (let o = 0; o < e; o++) {
920
920
  const a = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[h * e + o], d = t[n.index * e + o];
921
- i ? Wt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
921
+ i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
922
922
  }
923
923
  }
924
924
  }
925
- function Wt(r, t, e, s = new c.Vector3()) {
925
+ function qt(r, t, e, s = new c.Vector3()) {
926
926
  const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
927
927
  if (i === 0 || n === 0)
928
928
  return s.copy(r).lerp(t, e);
@@ -939,7 +939,7 @@ function Wt(r, t, e, s = new c.Vector3()) {
939
939
  (h * f + d * p) * P
940
940
  );
941
941
  }
942
- function qt(r, t, e, s, i) {
942
+ function Qt(r, t, e, s, i) {
943
943
  for (const n of r) {
944
944
  const o = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, h = e.length;
945
945
  for (let l = 0, d = n.endX - n.startX; l < d; l++) {
@@ -975,7 +975,7 @@ function qt(r, t, e, s, i) {
975
975
  }
976
976
  }
977
977
  }
978
- function Qt(r, t, e, s, i) {
978
+ function $t(r, t, e, s, i) {
979
979
  const n = s * i;
980
980
  let o = n * 2;
981
981
  const a = new c.Vector3();
@@ -998,7 +998,7 @@ function Qt(r, t, e, s, i) {
998
998
  }
999
999
  }
1000
1000
  }
1001
- function me(r, t, e, s, i) {
1001
+ function de(r, t, e, s, i) {
1002
1002
  const n = [];
1003
1003
  for (const o of r) {
1004
1004
  for (let a = o.startX; a < o.endX; a++) {
@@ -1026,10 +1026,10 @@ function Ft(r, t, e, s, i, n) {
1026
1026
  function Ot(r, t, e, s, i, n) {
1027
1027
  ft(r, t, e, s, i), t += n, e += n, s += n, i += n, ft(r, t, e, s, i);
1028
1028
  }
1029
- function $t(r, t, e, s, i, n, o) {
1029
+ function Yt(r, t, e, s, i, n, o) {
1030
1030
  _t(r, e, s, i, n), e += o, s += o, i += o, n += o, ft(t, e, s, i, n);
1031
1031
  }
1032
- function Yt(r, t, e, s, i, n) {
1032
+ function Kt(r, t, e, s, i, n) {
1033
1033
  const o = i.left * s.x, a = (1 - i.right) * s.x, h = i.down * s.y, m = (1 - i.up) * s.y, l = t.length, d = e.length;
1034
1034
  if (n > 1)
1035
1035
  for (let _ = 0; _ < d; _++)
@@ -1053,7 +1053,7 @@ function _t(r, t, e, s, i) {
1053
1053
  function ft(r, t, e, s, i) {
1054
1054
  r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1055
1055
  }
1056
- function Kt(r, t, e, s) {
1056
+ function Jt(r, t, e, s) {
1057
1057
  const i = [];
1058
1058
  for (let n = 0; n < e - 1; n++)
1059
1059
  for (let o = 0; o < t - 1; o++) {
@@ -1062,17 +1062,17 @@ function Kt(r, t, e, s) {
1062
1062
  }
1063
1063
  return i;
1064
1064
  }
1065
- const Ne = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1065
+ const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1066
1066
  __proto__: null,
1067
- addBorders: qt,
1068
- addFrontAndBackFaces: $t,
1069
- addFrontAndBackTexcoords: Yt,
1070
- debugDrawBorders: me,
1071
- drawWireframe: Kt,
1072
- seamNodesToSeams: Mt,
1073
- updateBorders: Qt,
1074
- updateXSeams: xt,
1075
- updateZSeams: yt
1067
+ addBorders: Qt,
1068
+ addFrontAndBackFaces: Yt,
1069
+ addFrontAndBackTexcoords: Kt,
1070
+ debugDrawBorders: de,
1071
+ drawWireframe: Jt,
1072
+ seamNodesToSeams: xt,
1073
+ updateBorders: $t,
1074
+ updateXSeams: Mt,
1075
+ updateZSeams: Ct
1076
1076
  }, Symbol.toStringTag, { value: "Module" }));
1077
1077
  class Zt {
1078
1078
  get geometry() {
@@ -1150,17 +1150,17 @@ class Zt {
1150
1150
  const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, o = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, h = new c.Vector3(), m = new c.Vector3(), l = new c.Vector3();
1151
1151
  for (let u = 0; u < a; u++)
1152
1152
  s[u].set(0, 0, 0);
1153
- xt(this.m_Pattern.xSeams, t, n, o, !1), yt(this.m_Pattern.zSeams, t, n, o, !1);
1153
+ Mt(this.m_Pattern.xSeams, t, n, o, !1), Ct(this.m_Pattern.zSeams, t, n, o, !1);
1154
1154
  for (let u = 0; u < o - 1; u++) {
1155
1155
  const f = u + 1;
1156
1156
  for (let p = 0; p < n - 1; p++) {
1157
- const P = p + 1, B = u * n + p, x = u * n + P, w = f * n + p, S = f * n + P, k = t[B], O = t[x], Z = t[w], V = t[S];
1158
- Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[w].add(l), s[S].add(l);
1157
+ const P = p + 1, B = u * n + p, M = u * n + P, w = f * n + p, v = f * n + P, k = t[B], O = t[M], Z = t[w], V = t[v];
1158
+ Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[w].add(l), s[v].add(l);
1159
1159
  }
1160
1160
  }
1161
1161
  for (let u = 0; u < a; u++)
1162
1162
  s[u].divideScalar(i[u]).normalize();
1163
- xt(this.m_Pattern.xSeams, s, n, o, !0), yt(this.m_Pattern.zSeams, s, n, o, !0);
1163
+ Mt(this.m_Pattern.xSeams, s, n, o, !0), Ct(this.m_Pattern.zSeams, s, n, o, !0);
1164
1164
  const d = this.m_Pattern.thickness / 2;
1165
1165
  for (let u = 0; u < a; u++) {
1166
1166
  const f = s[u];
@@ -1168,7 +1168,7 @@ class Zt {
1168
1168
  const p = t[u];
1169
1169
  e[u].copy(p).addScaledVector(f, d), e[u + a].copy(p).addScaledVector(f, -d);
1170
1170
  }
1171
- Qt(this.m_Pattern.borders, e, s, n, o);
1171
+ $t(this.m_Pattern.borders, e, s, n, o);
1172
1172
  const g = this.m_Geometry.getAttribute(
1173
1173
  "position"
1174
1174
  ), _ = this.m_Geometry.getAttribute(
@@ -1190,10 +1190,10 @@ class Zt {
1190
1190
  */
1191
1191
  drawWireframe(t) {
1192
1192
  const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
1193
- return Kt(this.m_Vertices, e, s, t);
1193
+ return Jt(this.m_Vertices, e, s, t);
1194
1194
  }
1195
1195
  }
1196
- class ue {
1196
+ class _e {
1197
1197
  constructor() {
1198
1198
  this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1199
1199
  }
@@ -1212,7 +1212,7 @@ class ue {
1212
1212
  this.m_Meshs.clear();
1213
1213
  }
1214
1214
  }
1215
- class de {
1215
+ class fe {
1216
1216
  constructor(t) {
1217
1217
  this.m_CreateMeshCollider = !1, this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1218
1218
  }
@@ -1224,7 +1224,7 @@ class de {
1224
1224
  }
1225
1225
  get(t) {
1226
1226
  let e;
1227
- return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new fe(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1227
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new pe(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1228
1228
  }
1229
1229
  recycle() {
1230
1230
  for (const t of this.m_UsedRenderers)
@@ -1244,10 +1244,10 @@ class de {
1244
1244
  return t;
1245
1245
  }
1246
1246
  }
1247
- let _e = 1;
1248
- class fe {
1247
+ let ge = 1;
1248
+ class pe {
1249
1249
  constructor(t, e, s) {
1250
- this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = _e++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1250
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ge++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1251
1251
  new c.BufferGeometry(),
1252
1252
  new c.MeshStandardMaterial()
1253
1253
  ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
@@ -1351,7 +1351,7 @@ class fe {
1351
1351
  e.dispose();
1352
1352
  }
1353
1353
  }
1354
- class ge {
1354
+ class xe {
1355
1355
  constructor(t, e, s = !1) {
1356
1356
  this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Zt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1357
1357
  }
@@ -1363,7 +1363,7 @@ class ge {
1363
1363
  this.m_Stack.push(t);
1364
1364
  }
1365
1365
  }
1366
- var wt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(wt || {}), pe = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(pe || {}), 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 || {}), xe = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(xe || {});
1366
+ var wt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(wt || {}), Me = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(Me || {}), Ce = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(Ce || {}), we = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(we || {});
1367
1367
  class ye {
1368
1368
  constructor(t) {
1369
1369
  this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
@@ -1389,10 +1389,10 @@ class ye {
1389
1389
  function nt(r, t, e) {
1390
1390
  return Math.max(t, Math.min(e, r));
1391
1391
  }
1392
- function we(r, t, e) {
1392
+ function Pe(r, t, e) {
1393
1393
  return r === t ? 0 : nt((e - r) / (t - r), 0, 1);
1394
1394
  }
1395
- function Lt(r, t) {
1395
+ function Ut(r, t) {
1396
1396
  return r + Math.random() * (t - r);
1397
1397
  }
1398
1398
  class rt {
@@ -1463,12 +1463,12 @@ class rt {
1463
1463
  getValue(t, e) {
1464
1464
  if (this.m_Mode === 0) return this.m_Constant;
1465
1465
  if (this.m_Mode === 1)
1466
- return Lt(this.m_ConstantMin, this.m_ConstantMax);
1466
+ return Ut(this.m_ConstantMin, this.m_ConstantMax);
1467
1467
  const s = this.m_CurveTimeMode === 0 ? t : e;
1468
1468
  if (this.m_Mode === 2)
1469
1469
  return this.m_Curve.evaluate(s);
1470
1470
  if (this.m_Mode === 3)
1471
- return Lt(
1471
+ return Ut(
1472
1472
  this.m_CurveMin.evaluate(s),
1473
1473
  this.m_CurveMax.evaluate(s)
1474
1474
  );
@@ -1488,7 +1488,7 @@ class rt {
1488
1488
  }
1489
1489
  for (let h = 0; h < n; h++) {
1490
1490
  let m = i[h].time, l = i[h].value;
1491
- m = we(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
1491
+ m = Pe(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
1492
1492
  }
1493
1493
  return new ye(i);
1494
1494
  }
@@ -1567,7 +1567,7 @@ const R = class R {
1567
1567
  }
1568
1568
  };
1569
1569
  R.kMinTwist = -1, R.kMaxTwist = 1, R.kMinBend = 0, R.kMaxBend = 1, R.kMinDuration = 0, R.kMaxDuration = 5;
1570
- let Nt = R, Ue = class extends Error {
1570
+ let Lt = R, Xe = class extends Error {
1571
1571
  constructor() {
1572
1572
  super(
1573
1573
  "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."
@@ -1842,9 +1842,9 @@ const ot = class ot extends c.Group {
1842
1842
  // ── Build ─────────────────────────────────────────────────────────────
1843
1843
  build() {
1844
1844
  if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1845
- if (this.m_MeshFactory === null && (this.m_MeshFactory = new ue()), this.m_RendererFactory === null) {
1846
- const y = new c.Object3D();
1847
- y.name = "Root", this.add(y), this.m_Root = y, this.m_RendererFactory = new de(this.m_Root);
1845
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new _e()), this.m_RendererFactory === null) {
1846
+ const C = new c.Object3D();
1847
+ C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new fe(this.m_Root);
1848
1848
  }
1849
1849
  this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
1850
1850
  const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
@@ -1856,9 +1856,9 @@ const ot = class ot extends c.Group {
1856
1856
  const a = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
1857
1857
  let m = 0, l = 0, d = 0;
1858
1858
  this.m_Papers = new Array(a);
1859
- for (let y = 0; y < a; y++) {
1860
- const I = this.m_HasCover && (y < h || y >= a - h), N = this.m_RendererFactory.get("Paper"), v = this.m_Papers[y] = new le(I, y, this, N);
1861
- v.renderer.castShadows = this.m_CastShadows, y < Math.round(c.MathUtils.lerp(0, a, o)) && (v.transform.scale.set(-1, 1, 1), v.setTime(1)), I ? (v.setContentData(i[l++], i[l++], y > h), v.setMaterialData(e), v.setPaperSetup(this.m_CoverPaperSetup)) : (v.setContentData(n[m++], n[m++]), v.setMaterialData(s), v.setPaperSetup(this.m_PagePaperSetup)), d += v.thickness;
1859
+ for (let C = 0; C < a; C++) {
1860
+ const I = this.m_HasCover && (C < h || C >= a - h), L = this.m_RendererFactory.get("Paper"), S = this.m_Papers[C] = new me(I, C, this, L);
1861
+ S.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (S.transform.scale.set(-1, 1, 1), S.setTime(1)), I ? (S.setContentData(i[l++], i[l++], C > h), S.setMaterialData(e), S.setPaperSetup(this.m_CoverPaperSetup)) : (S.setContentData(n[m++], n[m++]), S.setMaterialData(s), S.setPaperSetup(this.m_PagePaperSetup)), d += S.thickness;
1862
1862
  }
1863
1863
  this.m_TotalThickness = d;
1864
1864
  const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(a / 2)].thickness;
@@ -1872,12 +1872,12 @@ const ot = class ot extends c.Group {
1872
1872
  this.m_RendererFactory,
1873
1873
  this.m_MeshFactory
1874
1874
  ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1875
- const B = this.m_ReduceOverdraw && n.length > 0, x = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), V = Math.floor(a / 2) - 1, L = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
- for (let y = 0; y < a; y++) {
1877
- const I = this.m_Papers[y];
1878
- y !== 0 && (I.prev = this.m_Papers[y - 1]), y !== a - 1 && (I.next = this.m_Papers[y + 1]), I.noHole = D && (y === V || y === L), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
1875
+ const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), v = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), V = Math.floor(a / 2) - 1, U = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
+ for (let C = 0; C < a; C++) {
1877
+ const I = this.m_Papers[C];
1878
+ C !== 0 && (I.prev = this.m_Papers[C - 1]), C !== a - 1 && (I.next = this.m_Papers[C + 1]), I.noHole = D && (C === V || C === U), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
1879
1879
  w.get(),
1880
- (S == null ? void 0 : S.get()) ?? null,
1880
+ (v == null ? void 0 : v.get()) ?? null,
1881
1881
  k
1882
1882
  );
1883
1883
  }
@@ -1898,7 +1898,7 @@ const ot = class ot extends c.Group {
1898
1898
  i,
1899
1899
  s
1900
1900
  );
1901
- return new ge(
1901
+ return new xe(
1902
1902
  this.m_MeshFactory,
1903
1903
  o,
1904
1904
  e && this.m_Bound.useSharedMeshDataForLowpoly
@@ -1935,6 +1935,54 @@ const ot = class ot extends c.Group {
1935
1935
  }
1936
1936
  return null;
1937
1937
  }
1938
+ // ── Real-time content updates ──────────────────────────────────────
1939
+ /**
1940
+ * Hot-swap page/cover content without rebuilding geometry.
1941
+ * Preserves open progress, turning state, and animations.
1942
+ * If the new content has a different page/cover structure, falls back
1943
+ * to a full rebuild with state preservation.
1944
+ */
1945
+ updateContent(t) {
1946
+ if (!this.m_IsBuilt) {
1947
+ this.m_Content = t;
1948
+ return;
1949
+ }
1950
+ const e = this.getCurrentOpenProgress();
1951
+ this.m_Content = t, this.m_Content.init(this), this.refreshContent() || (this.build(), this.setOpenProgress(e));
1952
+ }
1953
+ /**
1954
+ * Re-apply all page/cover textures from the current BookContent
1955
+ * to existing papers without rebuilding geometry.
1956
+ * Returns false if a structural rebuild is needed (page count changed).
1957
+ */
1958
+ refreshContent() {
1959
+ if (!this.m_IsBuilt || !this.m_Content) return !1;
1960
+ let t = this.m_Content.coverContents, e = this.m_Content.pageContents;
1961
+ const s = Math.floor(t.length / 2), i = Math.floor(e.length / 2);
1962
+ if (s !== this.m_CoverPaperCount || i !== this.m_PagePaperCount)
1963
+ return !1;
1964
+ this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
1965
+ const n = this.m_Papers.length, o = Math.floor(t.length / 4);
1966
+ let a = 0, h = 0;
1967
+ for (let m = 0; m < n; m++) {
1968
+ const l = this.m_Papers[m];
1969
+ this.m_HasCover && (m < o || m >= n - o) ? l.setContentData(
1970
+ t[h++],
1971
+ t[h++],
1972
+ m > o
1973
+ ) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
1974
+ }
1975
+ return this.m_WasIdle = !1, !0;
1976
+ }
1977
+ getCurrentOpenProgress() {
1978
+ const t = this.m_Papers.length;
1979
+ if (t === 0) return this.m_InitialOpenProgress;
1980
+ let e = 0;
1981
+ for (const i of this.m_Papers)
1982
+ i.isOnRightStack || e++;
1983
+ let s = e / t;
1984
+ return this.m_Content && this.m_Content.direction % 2 !== 0 && (s = 1 - s), s;
1985
+ }
1938
1986
  // ── Live Pages ────────────────────────────────────────────────────────
1939
1987
  updateLivePages() {
1940
1988
  const t = /* @__PURE__ */ new Set(), e = this.m_Papers.length;
@@ -1953,13 +2001,13 @@ const ot = class ot extends c.Group {
1953
2001
  }
1954
2002
  };
1955
2003
  ot.s_Instances = /* @__PURE__ */ new Set();
1956
- let Ct = ot;
1957
- class Ce {
2004
+ let yt = ot;
2005
+ class Te {
1958
2006
  constructor() {
1959
2007
  this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
1960
2008
  }
1961
2009
  }
1962
- class Xe {
2010
+ class je {
1963
2011
  constructor() {
1964
2012
  this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
1965
2013
  }
@@ -1994,7 +2042,7 @@ class Xe {
1994
2042
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
1995
2043
  }
1996
2044
  }
1997
- class Ut {
2045
+ class Nt {
1998
2046
  constructor(t, e) {
1999
2047
  this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2000
2048
  }
@@ -2012,7 +2060,7 @@ class Ut {
2012
2060
  setActive(t) {
2013
2061
  }
2014
2062
  }
2015
- class je {
2063
+ class Ge {
2016
2064
  constructor() {
2017
2065
  this.m_Direction = X.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
2018
2066
  }
@@ -2061,11 +2109,11 @@ class je {
2061
2109
  getContent(t) {
2062
2110
  if (t !== null) {
2063
2111
  if (t instanceof c.Texture)
2064
- return new Ut(t);
2112
+ return new Nt(t);
2065
2113
  if (typeof t.init == "function")
2066
2114
  return t;
2067
2115
  }
2068
- return new Ut(null);
2116
+ return new Nt(null);
2069
2117
  }
2070
2118
  init(t) {
2071
2119
  this.m_Book = t;
@@ -2113,14 +2161,14 @@ class je {
2113
2161
  return !this.isCoverPaperSideIndex(t);
2114
2162
  }
2115
2163
  }
2116
- class Ge {
2164
+ class qe {
2117
2165
  constructor(t, e) {
2118
2166
  this.enabled = !0, this.m_Raycaster = new c.Raycaster(), this.m_Mouse = new c.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
2119
2167
  var n;
2120
2168
  if (!this.enabled || s.button !== 0) return;
2121
2169
  this.m_IsPointerDown = !0;
2122
2170
  const i = this.m_GetRay(s);
2123
- for (const o of Ct.instances)
2171
+ for (const o of yt.instances)
2124
2172
  if (o.startTurning(i)) {
2125
2173
  this.m_SelectedBook = o, (n = this.onTurnStart) == null || n.call(this, o);
2126
2174
  break;
@@ -2140,9 +2188,9 @@ class Ge {
2140
2188
  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;
2141
2189
  }
2142
2190
  }
2143
- class Pe {
2191
+ class ve {
2144
2192
  }
2145
- class We {
2193
+ class Qe {
2146
2194
  constructor(t, e) {
2147
2195
  this.m_Book = t, this.m_Root = e;
2148
2196
  }
@@ -2158,23 +2206,23 @@ function Et(r, t, e, s) {
2158
2206
  function Xt(r, t) {
2159
2207
  return r++, r === t ? 0 : r;
2160
2208
  }
2161
- function Te(r, t) {
2209
+ function Se(r, t) {
2162
2210
  return r === 0 ? t - 1 : r - 1;
2163
2211
  }
2164
- const Se = 0.01, ve = 0.1, ke = 0.04, be = 0.4, Be = 2, Re = 10, Ie = 0, ze = 5;
2212
+ const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4, Ie = 2, ze = 10, Ve = 0, De = 5;
2165
2213
  function et(r, t, e) {
2166
2214
  return Math.max(t, Math.min(e, r));
2167
2215
  }
2168
- function Jt(r) {
2216
+ function te(r) {
2169
2217
  return Math.max(0, Math.min(1, r));
2170
2218
  }
2171
2219
  function F(r, t, e) {
2172
2220
  return r + (t - r) * e;
2173
2221
  }
2174
- function jt(r, t, e) {
2175
- return r === t ? 0 : Jt((e - r) / (t - r));
2222
+ function Wt(r, t, e) {
2223
+ return r === t ? 0 : te((e - r) / (t - r));
2176
2224
  }
2177
- function Ve(r, t) {
2225
+ function Ae(r, t) {
2178
2226
  const e = r.clone().normalize();
2179
2227
  if (e.lengthSq() === 0) return new c.Quaternion();
2180
2228
  let s = new c.Vector3().crossVectors(t, e);
@@ -2187,7 +2235,7 @@ function Ve(r, t) {
2187
2235
  return new c.Quaternion().setFromRotationMatrix(n);
2188
2236
  }
2189
2237
  const tt = Math.PI / 180, it = 180 / Math.PI;
2190
- class De {
2238
+ class He {
2191
2239
  constructor() {
2192
2240
  this._material = null, this._color = new c.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
2193
2241
  }
@@ -2207,43 +2255,43 @@ class De {
2207
2255
  return this._thickness;
2208
2256
  }
2209
2257
  set thickness(t) {
2210
- this._thickness = et(t, Se, ve);
2258
+ this._thickness = et(t, ke, be);
2211
2259
  }
2212
2260
  get margin() {
2213
2261
  return this._margin;
2214
2262
  }
2215
2263
  set margin(t) {
2216
- this._margin = Jt(t);
2264
+ this._margin = te(t);
2217
2265
  }
2218
2266
  get crown() {
2219
2267
  return this._crown;
2220
2268
  }
2221
2269
  set crown(t) {
2222
- this._crown = et(t, ke, be);
2270
+ this._crown = et(t, Be, Re);
2223
2271
  }
2224
2272
  get count() {
2225
2273
  return this._count;
2226
2274
  }
2227
2275
  set count(t) {
2228
- this._count = et(t, Be, Re);
2276
+ this._count = et(t, Ie, ze);
2229
2277
  }
2230
2278
  get quality() {
2231
2279
  return this._quality;
2232
2280
  }
2233
2281
  set quality(t) {
2234
- this._quality = et(t, Ie, ze);
2282
+ this._quality = et(t, Ve, De);
2235
2283
  }
2236
2284
  }
2237
- class Ae extends Error {
2285
+ class Fe extends Error {
2238
2286
  constructor() {
2239
2287
  super("Book height is too large relative to paper width."), this.name = "BookHeightException";
2240
2288
  }
2241
2289
  }
2242
- class He {
2290
+ class Oe {
2243
2291
  // ── Constructor ────────────────────────────────────────────────────────
2244
2292
  constructor(t, e, s, i, n) {
2245
2293
  if (this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Book = s, this.m_Root = i, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
2246
- throw new Ae();
2294
+ throw new Fe();
2247
2295
  const o = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
2248
2296
  this.updateStapleMesh(e, h);
2249
2297
  const m = n ?? new c.MeshStandardMaterial({
@@ -2265,7 +2313,7 @@ class He {
2265
2313
  this.updateRootPosition();
2266
2314
  }
2267
2315
  get binderRenderer() {
2268
- return this._binderRendererAdapter || (this._binderRendererAdapter = new Fe(this.stapleMesh)), this._binderRendererAdapter;
2316
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new Ze(this.stapleMesh)), this._binderRendererAdapter;
2269
2317
  }
2270
2318
  // ── updateStapleMesh ──────────────────────────────────────────────────
2271
2319
  updateStapleMesh(t, e) {
@@ -2286,81 +2334,81 @@ class He {
2286
2334
  P = Math.max(P, p * 2);
2287
2335
  let B = 0;
2288
2336
  B += this.m_Book.totalThickness / 2, B += _;
2289
- const x = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
2337
+ const M = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
2290
2338
  {
2291
2339
  for (let z = 0; z < d; z++) {
2292
- const E = z / (d - 1), q = F(-90, -180, E) * tt, C = new c.Vector3(
2340
+ const E = z / (d - 1), q = F(-90, -180, E) * tt, y = new c.Vector3(
2293
2341
  p * Math.sin(q),
2294
2342
  0,
2295
2343
  p * Math.cos(q)
2296
2344
  );
2297
- C.x += p, C.z += p, C.x += x, w.push(C);
2345
+ y.x += p, y.z += p, y.x += M, w.push(y);
2298
2346
  }
2299
- const M = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - _ * 0.5, 0, P);
2347
+ const x = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - _ * 0.5, 0, P);
2300
2348
  for (let z = 0; z < g; z++) {
2301
- const E = z / (g - 1), W = Et(M, H, T, E);
2302
- W.x += x, w.push(W);
2349
+ const E = z / (g - 1), G = Et(x, H, T, E);
2350
+ G.x += M, w.push(G);
2303
2351
  }
2304
2352
  w.reverse();
2305
2353
  }
2306
- const S = new Array(l);
2307
- for (let M = 0; M < l; M++) {
2308
- const T = (90 - M * (360 / l)) * tt;
2309
- S[M] = new c.Vector3(Math.cos(T), Math.sin(T), 0), S[M].x *= 0.75;
2354
+ const v = new Array(l);
2355
+ for (let x = 0; x < l; x++) {
2356
+ const T = (90 - x * (360 / l)) * tt;
2357
+ v[x] = new c.Vector3(Math.cos(T), Math.sin(T), 0), v[x].x *= 0.75;
2310
2358
  }
2311
- const k = w.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), L = new Array(
2359
+ const k = w.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), U = new Array(
2312
2360
  (O * 2 - 1) * l * 2 * 3
2313
2361
  );
2314
- for (let M = 0; M < O * 2; M++)
2315
- Z[M] = new c.Vector3(), V[M] = new c.Vector3();
2362
+ for (let x = 0; x < O * 2; x++)
2363
+ Z[x] = new c.Vector3(), V[x] = new c.Vector3();
2316
2364
  let D = 0;
2317
- for (let M = 0; M < k; M++) {
2318
- const H = w[Te(M, k)], T = w[M], z = w[Xt(M, k)];
2365
+ for (let x = 0; x < k; x++) {
2366
+ const H = w[Se(x, k)], T = w[x], z = w[Xt(x, k)];
2319
2367
  let E;
2320
- if (M === 0)
2368
+ if (x === 0)
2321
2369
  E = new c.Vector3(1, 0, -2).normalize();
2322
- else if (M === k - 1)
2370
+ else if (x === k - 1)
2323
2371
  E = new c.Vector3(0, 0, 1);
2324
2372
  else {
2325
2373
  const K = T.clone().sub(H).normalize(), J = z.clone().sub(T).normalize();
2326
2374
  E = K.add(J).multiplyScalar(0.5);
2327
2375
  }
2328
- const W = new c.Vector3(0, 1, 0), q = Ve(E, W), C = D;
2329
- let b = jt(0, g / 4, M);
2376
+ const G = new c.Vector3(0, 1, 0), q = Ae(E, G), y = D;
2377
+ let b = Wt(0, g / 4, x);
2330
2378
  b = F(0.1, 1, b), b = Math.sqrt(b);
2331
2379
  for (let K = 0; K < l; K++) {
2332
- const J = S[K].clone().applyQuaternion(q).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(_));
2380
+ const J = v[K].clone().applyQuaternion(q).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(_));
2333
2381
  Z[D] = ct, V[D] = J.clone();
2334
2382
  const at = T.clone().add(J.clone().multiplyScalar(_));
2335
2383
  at.z = s - at.z;
2336
- const te = C + l - K - 1, St = O * 2 - te - 1;
2337
- Z[St] = at, V[St] = J.clone(), D++;
2384
+ const se = y + l - K - 1, vt = O * 2 - se - 1;
2385
+ Z[vt] = at, V[vt] = J.clone(), D++;
2338
2386
  }
2339
2387
  }
2340
- let y = 0;
2388
+ let C = 0;
2341
2389
  const I = w.length * 2;
2342
- for (let M = 0; M < I - 1; M++) {
2343
- const H = M * l, T = (M + 1) * l;
2390
+ for (let x = 0; x < I - 1; x++) {
2391
+ const H = x * l, T = (x + 1) * l;
2344
2392
  for (let z = 0; z < l; z++) {
2345
- const E = Xt(z, l), W = H + z, q = H + E, C = T + E, b = T + z;
2346
- L[y++] = W, L[y++] = b, L[y++] = q, L[y++] = q, L[y++] = b, L[y++] = C;
2393
+ const E = Xt(z, l), G = H + z, q = H + E, y = T + E, b = T + z;
2394
+ U[C++] = G, U[C++] = b, U[C++] = q, U[C++] = q, U[C++] = b, U[C++] = y;
2347
2395
  }
2348
2396
  }
2349
- const N = [...Z], v = [...V], Q = [...L], G = Z.map((M) => M.clone()), $ = [...L];
2350
- for (let M = 0; M < a - 1; M++) {
2351
- const H = G.length;
2397
+ const L = [...Z], S = [...V], Q = [...U], j = Z.map((x) => x.clone()), $ = [...U];
2398
+ for (let x = 0; x < a - 1; x++) {
2399
+ const H = j.length;
2352
2400
  for (let T = 0; T < $.length; T++)
2353
2401
  $[T] += H;
2354
- for (let T = 0; T < G.length; T++)
2355
- G[T].z += h + s;
2356
- N.push(...G.map((T) => T.clone())), v.push(...V.map((T) => T.clone())), Q.push(...$);
2402
+ for (let T = 0; T < j.length; T++)
2403
+ j[T].z += h + s;
2404
+ L.push(...j.map((T) => T.clone())), S.push(...V.map((T) => T.clone())), Q.push(...$);
2357
2405
  }
2358
- const j = new Float32Array(N.length * 3), A = new Float32Array(v.length * 3);
2359
- for (let M = 0; M < N.length; M++)
2360
- j[M * 3] = N[M].x, j[M * 3 + 1] = N[M].y, j[M * 3 + 2] = N[M].z, A[M * 3] = v[M].x, A[M * 3 + 1] = v[M].y, A[M * 3 + 2] = v[M].z;
2406
+ const W = new Float32Array(L.length * 3), A = new Float32Array(S.length * 3);
2407
+ for (let x = 0; x < L.length; x++)
2408
+ W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] = S[x].x, A[x * 3 + 1] = S[x].y, A[x * 3 + 2] = S[x].z;
2361
2409
  e.setAttribute(
2362
2410
  "position",
2363
- new c.BufferAttribute(j, 3)
2411
+ new c.BufferAttribute(W, 3)
2364
2412
  ), e.setAttribute(
2365
2413
  "normal",
2366
2414
  new c.BufferAttribute(A, 3)
@@ -2368,7 +2416,7 @@ class He {
2368
2416
  }
2369
2417
  // ── createPaperPattern ────────────────────────────────────────────────
2370
2418
  createPaperPattern(t, e, s, i, n, o) {
2371
- const a = new Ce();
2419
+ const a = new Te();
2372
2420
  a.size = e, a.thickness = s;
2373
2421
  const h = this.m_BindingRadius;
2374
2422
  a.baseXOffset = -h;
@@ -2381,70 +2429,70 @@ class He {
2381
2429
  const p = new st(0);
2382
2430
  let P = p;
2383
2431
  const B = h / m;
2384
- let x = 0;
2385
- for (let C = 1; C < m + 1; C++)
2386
- P = P.createNext(x), x += B;
2432
+ let M = 0;
2433
+ for (let y = 1; y < m + 1; y++)
2434
+ P = P.createNext(M), M += B;
2387
2435
  const w = (e.x - h) / (g + 1);
2388
- for (let C = m + 1; C < u; C++)
2389
- P = P.createNext(x), x += w;
2390
- const S = new st(0);
2391
- let k = S;
2436
+ for (let y = m + 1; y < u; y++)
2437
+ P = P.createNext(M), M += w;
2438
+ const v = new st(0);
2439
+ let k = v;
2392
2440
  const O = e.y / (f - 1);
2393
2441
  let Z = 0;
2394
- for (let C = 0; C < f - 1; C++)
2442
+ for (let y = 0; y < f - 1; y++)
2395
2443
  Z += O, k = k.createNext(Z);
2396
- const V = [], L = [], D = i.clone();
2444
+ const V = [], U = [], D = i.clone();
2397
2445
  if (n) {
2398
- let C = 0;
2399
- this.m_Book.hasCover && (C = Math.floor(this.m_Book.coverPaperCount / 2));
2446
+ let y = 0;
2447
+ this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
2400
2448
  const b = Math.max(0.01, s);
2401
- D.left = 0, D.right = (this.getPX(C + 1, s) - this.getPX(C, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
2402
- }
2403
- const y = new ce(a, D, !1);
2404
- y.insert(p, S, V, L), p.updateIndex(0), S.updateIndex(0), Mt(V, a.xSeams), Mt(L, a.zSeams);
2405
- const I = this.m_BindingVertexCount + 2, N = new Array(I);
2406
- a.xNoneSeamIndexes = N, P = p;
2407
- for (let C = 0; C < I; C++) {
2408
- N[C] = P.index;
2449
+ D.left = 0, D.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
2450
+ }
2451
+ const C = new ue(a, D, !1);
2452
+ C.insert(p, v, V, U), p.updateIndex(0), v.updateIndex(0), xt(V, a.xSeams), xt(U, a.zSeams);
2453
+ const I = this.m_BindingVertexCount + 2, L = new Array(I);
2454
+ a.xNoneSeamIndexes = L, P = p;
2455
+ for (let y = 0; y < I; y++) {
2456
+ L[y] = P.index;
2409
2457
  do
2410
2458
  P = P.next;
2411
2459
  while (P.seam);
2412
2460
  }
2413
- const v = p.getValues(), Q = S.getValues();
2414
- u = v.length, f = Q.length;
2415
- const G = u * f, $ = [], j = new Array(G).fill(0), A = [], M = [], H = [], T = [];
2416
- Yt(
2461
+ const S = p.getValues(), Q = v.getValues();
2462
+ u = S.length, f = Q.length;
2463
+ const j = u * f, $ = [], W = new Array(j).fill(0), A = [], x = [], H = [], T = [];
2464
+ Kt(
2417
2465
  $,
2418
- v,
2466
+ S,
2419
2467
  Q,
2420
2468
  e,
2421
2469
  i,
2422
2470
  this.m_Book.direction
2423
2471
  );
2424
- const z = y.leftNode.index, E = y.downNode.index;
2425
- let W = y.rightNode.index, q = y.upNode.index;
2426
- W === 0 && (W = u - 1), q === 0 && (q = f - 1);
2427
- for (let C = 0; C < f - 1; C++)
2472
+ const z = C.leftNode.index, E = C.downNode.index;
2473
+ let G = C.rightNode.index, q = C.upNode.index;
2474
+ G === 0 && (G = u - 1), q === 0 && (q = f - 1);
2475
+ for (let y = 0; y < f - 1; y++)
2428
2476
  for (let b = 0; b < u - 1; b++) {
2429
- if (n && C >= E && C < q && b >= z && b < W)
2477
+ if (n && y >= E && y < q && b >= z && b < G)
2430
2478
  continue;
2431
- const K = C * u + b, J = C * u + (b + 1), ct = (C + 1) * u + b, at = (C + 1) * u + (b + 1);
2432
- j[K] += 2, j[J] += 2, j[ct] += 2, j[at] += 2, $t(
2479
+ const K = y * u + b, J = y * u + (b + 1), ct = (y + 1) * u + b, at = (y + 1) * u + (b + 1);
2480
+ W[K] += 2, W[J] += 2, W[ct] += 2, W[at] += 2, Yt(
2433
2481
  A,
2434
- M,
2482
+ x,
2435
2483
  K,
2436
2484
  J,
2437
2485
  ct,
2438
2486
  at,
2439
- G
2487
+ j
2440
2488
  );
2441
2489
  }
2442
- if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = v, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2490
+ if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), Qt(T, H, $, u, f), a.baseXArray = S, a.baseZArray = Q, a.baseVertexCount = j, a.vertexCount = $.length, a.texcoords = $, a.weights = W, o) {
2443
2491
  a.subMeshCount = 1;
2444
- const C = [];
2445
- C.push(...A), C.push(...H), C.push(...M), a.triangles = C;
2492
+ const y = [];
2493
+ y.push(...A), y.push(...H), y.push(...x), a.triangles = y;
2446
2494
  } else
2447
- a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = M, a.borderTriangles = H;
2495
+ a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = x, a.borderTriangles = H;
2448
2496
  return a.borders = T, a;
2449
2497
  }
2450
2498
  // ── updateRootPosition ────────────────────────────────────────────────
@@ -2458,11 +2506,11 @@ class He {
2458
2506
  const e = this.m_Book.papers, s = e.length;
2459
2507
  let i = 0;
2460
2508
  const n = e.length / 2 - 1, o = e.length / 2;
2461
- for (let x = 0; x < s; x++) {
2462
- const w = e[x];
2509
+ for (let M = 0; M < s; M++) {
2510
+ const w = e[M];
2463
2511
  w.updateTime();
2464
- const S = w.zTime, k = w.thickness;
2465
- i += S * k, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2512
+ const v = w.zTime, k = w.thickness;
2513
+ i += v * k, M === n && (i += v * this.m_BindingMidSpace / 2), M === o && (i += v * this.m_BindingMidSpace / 2);
2466
2514
  }
2467
2515
  let a = this.getStackHeight(t.index) - t.thickness / 2;
2468
2516
  const h = this.getStackZ(a), m = 180 + h;
@@ -2475,21 +2523,21 @@ class He {
2475
2523
  _.z = t.margin;
2476
2524
  let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
2477
2525
  if (t.index < Math.floor(s / 2)) {
2478
- let x = 0;
2526
+ let M = 0;
2479
2527
  if (this.m_Book.alignToGround) {
2480
2528
  u = e[0].size.x;
2481
2529
  const w = this.m_StackHeight / 2;
2482
- f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2530
+ f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2483
2531
  }
2484
- d = F(P, -x, l);
2532
+ d = F(P, -M, l);
2485
2533
  } else {
2486
- let x = 0;
2534
+ let M = 0;
2487
2535
  if (this.m_Book.alignToGround) {
2488
2536
  u = e[0].size.x;
2489
2537
  const w = this.m_StackHeight / 2;
2490
- f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2538
+ f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2491
2539
  }
2492
- d = F(x, -P, l);
2540
+ d = F(M, -P, l);
2493
2541
  }
2494
2542
  t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2495
2543
  new c.Euler(0, 0, d * tt)
@@ -2514,11 +2562,11 @@ class He {
2514
2562
  const e = this.m_Book.papers, s = e.length;
2515
2563
  let i = 0;
2516
2564
  const n = e.length / 2 - 1, o = e.length / 2;
2517
- for (let x = 0; x < s; x++) {
2518
- const w = e[x];
2565
+ for (let M = 0; M < s; M++) {
2566
+ const w = e[M];
2519
2567
  w.updateTime();
2520
- const S = w.zTime, k = w.thickness;
2521
- i += S * k, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2568
+ const v = w.zTime, k = w.thickness;
2569
+ i += v * k, M === n && (i += v * this.m_BindingMidSpace / 2), M === o && (i += v * this.m_BindingMidSpace / 2);
2522
2570
  }
2523
2571
  const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
2524
2572
  let l = t.zTime, d = F(h, m, l);
@@ -2530,21 +2578,21 @@ class He {
2530
2578
  _.z = t.margin;
2531
2579
  let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
2532
2580
  if (t.index < Math.floor(s / 2)) {
2533
- let x = 0;
2581
+ let M = 0;
2534
2582
  if (this.m_Book.alignToGround) {
2535
2583
  u = e[0].size.x;
2536
2584
  const w = this.m_StackHeight / 2;
2537
- f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2585
+ f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2538
2586
  }
2539
- d = F(P, -x, l);
2587
+ d = F(P, -M, l);
2540
2588
  } else {
2541
- let x = 0;
2589
+ let M = 0;
2542
2590
  if (this.m_Book.alignToGround) {
2543
2591
  u = e[0].size.x;
2544
2592
  const w = this.m_StackHeight / 2;
2545
- f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), x = (Math.asin(p / u) * it - 90) * 2;
2593
+ f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
2546
2594
  }
2547
- d = F(x, -P, l);
2595
+ d = F(M, -P, l);
2548
2596
  }
2549
2597
  t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
2550
2598
  new c.Euler(0, 0, d * tt)
@@ -2581,20 +2629,20 @@ class He {
2581
2629
  let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2582
2630
  const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
2583
2631
  for (let m = 0; m < h; m++) {
2584
- const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, x = l.thickness, w = g.xNoneSeamIndexes, S = d.position.clone();
2632
+ const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, M = l.thickness, w = g.xNoneSeamIndexes, v = d.position.clone();
2585
2633
  let k = m, O = n;
2586
2634
  m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
2587
- const Z = (o + x) * 0.5 + x * (k - 1), V = d.matrixWorld.clone().invert().multiply(a), L = k / (h / 2);
2588
- i = this.m_BindingRadius * F(0.45, 0.65, 1 - L);
2635
+ const Z = (o + M) * 0.5 + M * (k - 1), V = d.matrixWorld.clone().invert().multiply(a), U = k / (h / 2);
2636
+ i = this.m_BindingRadius * F(0.45, 0.65, 1 - U);
2589
2637
  for (let D = 0; D < P; D++) {
2590
- const y = f[D], I = new c.Vector3(0, 0, S.z + y), N = S.clone();
2591
- N.z += y;
2592
- const v = l.getDirection(y).multiplyScalar(i).add(N.clone());
2638
+ const C = f[D], I = new c.Vector3(0, 0, v.z + C), L = v.clone();
2639
+ L.z += C;
2640
+ const S = l.getDirection(C).multiplyScalar(i).add(L.clone());
2593
2641
  if (m === 0 && D === 0) {
2594
2642
  const A = t[h - 1], H = A.transform.position.clone().clone();
2595
- H.z += y;
2596
- const T = A.getDirection(y).multiplyScalar(i).add(H);
2597
- s = v.clone().sub(T).normalize(), e = new c.Vector3(
2643
+ H.z += C;
2644
+ const T = A.getDirection(C).multiplyScalar(i).add(H);
2645
+ s = S.clone().sub(T).normalize(), e = new c.Vector3(
2598
2646
  -s.y,
2599
2647
  s.x,
2600
2648
  0
@@ -2605,15 +2653,15 @@ class He {
2605
2653
  k > 0 && I.add(e.clone().multiplyScalar(Z));
2606
2654
  const Q = D * p;
2607
2655
  _[Q] = I.clone().applyMatrix4(V), I.add(s.clone().multiplyScalar(O));
2608
- const G = I.clone().applyMatrix4(V), $ = v.clone().applyMatrix4(V), j = N.clone().applyMatrix4(V);
2609
- _[Q + w[1]] = G;
2656
+ const j = I.clone().applyMatrix4(V), $ = S.clone().applyMatrix4(V), W = L.clone().applyMatrix4(V);
2657
+ _[Q + w[1]] = j;
2610
2658
  for (let A = 2; A < B; A++) {
2611
- const M = jt(1, B, A);
2659
+ const x = Wt(1, B, A);
2612
2660
  _[Q + w[A]] = Et(
2613
- G,
2614
- $,
2615
2661
  j,
2616
- M
2662
+ $,
2663
+ W,
2664
+ x
2617
2665
  );
2618
2666
  }
2619
2667
  }
@@ -2642,7 +2690,7 @@ class He {
2642
2690
  return this.m_StapleThickness;
2643
2691
  }
2644
2692
  }
2645
- class Fe {
2693
+ class Ze {
2646
2694
  constructor(t) {
2647
2695
  this.mesh = t;
2648
2696
  }
@@ -2668,12 +2716,12 @@ class Fe {
2668
2716
  return this.mesh;
2669
2717
  }
2670
2718
  }
2671
- class qe extends Pe {
2719
+ class $e extends ve {
2672
2720
  constructor() {
2673
- super(...arguments), this.quality = 3, this.stapleSetup = new De();
2721
+ super(...arguments), this.quality = 3, this.stapleSetup = new He();
2674
2722
  }
2675
2723
  createBound(t, e, s, i) {
2676
- return new He(
2724
+ return new Oe(
2677
2725
  this.quality,
2678
2726
  this.stapleSetup,
2679
2727
  t,
@@ -2681,7 +2729,7 @@ class qe extends Pe {
2681
2729
  );
2682
2730
  }
2683
2731
  }
2684
- class Oe {
2732
+ class ee {
2685
2733
  constructor(t) {
2686
2734
  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;
2687
2735
  }
@@ -2746,10 +2794,10 @@ class Oe {
2746
2794
  t.restore();
2747
2795
  }
2748
2796
  }
2749
- function Ze(r) {
2797
+ function Ue(r) {
2750
2798
  return r.map instanceof c.Texture;
2751
2799
  }
2752
- class Qe {
2800
+ class Ye {
2753
2801
  constructor(t) {
2754
2802
  this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
2755
2803
  const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
@@ -2773,7 +2821,7 @@ class Qe {
2773
2821
  }
2774
2822
  // ── Text API ─────────────────────────────────────────────────────────────
2775
2823
  addText(t) {
2776
- const e = new Oe(t);
2824
+ const e = new ee(t);
2777
2825
  return this.texts.push(e), e;
2778
2826
  }
2779
2827
  removeText(t) {
@@ -2809,7 +2857,7 @@ class Qe {
2809
2857
  if (!e.isMesh) return;
2810
2858
  const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2811
2859
  for (const n of i)
2812
- Ze(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
2860
+ Ue(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
2813
2861
  });
2814
2862
  }
2815
2863
  // ── IPageContent ─────────────────────────────────────────────────────────
@@ -2824,8 +2872,97 @@ class Qe {
2824
2872
  this._texture.dispose();
2825
2873
  }
2826
2874
  }
2875
+ function Le(r) {
2876
+ return r.map instanceof c.Texture;
2877
+ }
2878
+ class jt {
2879
+ constructor(t, e) {
2880
+ this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
2881
+ }
2882
+ get texture() {
2883
+ return this._spread.texture;
2884
+ }
2885
+ get textureST() {
2886
+ return this._textureST;
2887
+ }
2888
+ isPointOverUI(t) {
2889
+ return !1;
2890
+ }
2891
+ init(t) {
2892
+ }
2893
+ setActive(t) {
2894
+ }
2895
+ }
2896
+ function Ke(r) {
2897
+ const t = [];
2898
+ for (let e = 1; e + 1 < r; e += 2)
2899
+ t.push(e);
2900
+ return t;
2901
+ }
2902
+ class Je {
2903
+ constructor(t) {
2904
+ this.texts = [], this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
2905
+ const e = this.canvas.getContext("2d");
2906
+ if (!e) throw new Error("SpreadContent: could not get 2D context");
2907
+ this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new jt(this, "left"), this.right = new jt(this, "right");
2908
+ }
2909
+ get texture() {
2910
+ return this._texture;
2911
+ }
2912
+ /** The base layer drawn beneath text blocks (full spread width). */
2913
+ get source() {
2914
+ return this._source;
2915
+ }
2916
+ set source(t) {
2917
+ this._source = t;
2918
+ }
2919
+ // ── Text API ─────────────────────────────────────────────────────────────
2920
+ addText(t) {
2921
+ const e = new ee(t);
2922
+ return this.texts.push(e), e;
2923
+ }
2924
+ removeText(t) {
2925
+ const e = this.texts.indexOf(t);
2926
+ e !== -1 && this.texts.splice(e, 1);
2927
+ }
2928
+ /** Update a text block by index. Only provided fields are changed. */
2929
+ updateText(t, e) {
2930
+ const s = this.texts[t];
2931
+ s && (e.x !== void 0 && (s.x = e.x), e.y !== void 0 && (s.y = e.y), e.width !== void 0 && (s.width = e.width), e.text !== void 0 && (s.text = e.text), e.fontFamily !== void 0 && (s.fontFamily = e.fontFamily), e.fontSize !== void 0 && (s.fontSize = e.fontSize), e.fontWeight !== void 0 && (s.fontWeight = e.fontWeight), e.fontStyle !== void 0 && (s.fontStyle = e.fontStyle), e.color !== void 0 && (s.color = e.color), e.lineHeight !== void 0 && (s.lineHeight = e.lineHeight), e.textAlign !== void 0 && (s.textAlign = e.textAlign), e.opacity !== void 0 && (s.opacity = e.opacity), e.shadowColor !== void 0 && (s.shadowColor = e.shadowColor), e.shadowBlur !== void 0 && (s.shadowBlur = e.shadowBlur));
2932
+ }
2933
+ // ── Per-frame update ─────────────────────────────────────────────────────
2934
+ /**
2935
+ * Re-composite the canvas: source layer + text blocks.
2936
+ * Call every frame (or when content changes).
2937
+ *
2938
+ * @param root Optional THREE.Object3D to traverse for texture sync
2939
+ * (needed because three-book clones material textures).
2940
+ */
2941
+ update(t) {
2942
+ const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
2943
+ e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
2944
+ for (const o of this.texts) o.draw(e);
2945
+ this._texture.needsUpdate = !0, t && this.syncMaterials(t);
2946
+ }
2947
+ /**
2948
+ * Traverse `root` and set `needsUpdate = true` on every material map whose
2949
+ * source image is this spread's canvas.
2950
+ */
2951
+ syncMaterials(t) {
2952
+ t.traverse((e) => {
2953
+ if (!e.isMesh) return;
2954
+ const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
2955
+ for (const n of i)
2956
+ Le(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
2957
+ });
2958
+ }
2959
+ // ── Lifecycle ────────────────────────────────────────────────────────────
2960
+ dispose() {
2961
+ this._texture.dispose();
2962
+ }
2963
+ }
2827
2964
  const Gt = 256;
2828
- function Le(r, t, e, s, i, n, o) {
2965
+ function Ne(r, t, e, s, i, n, o) {
2829
2966
  const a = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
2830
2967
  if (a <= 0 || h <= 0) return;
2831
2968
  if (o === "fill") {
@@ -2835,13 +2972,13 @@ function Le(r, t, e, s, i, n, o) {
2835
2972
  const m = o === "contain" ? Math.min(i / a, n / h) : Math.max(i / a, n / h), l = a * m, d = h * m;
2836
2973
  r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
2837
2974
  }
2838
- function $e(r, t, e, s, i, n, o) {
2975
+ function ts(r, t, e, s, i, n, o) {
2839
2976
  const a = n ? Math.round(n * Gt) : 512, h = o ? Math.round(o * Gt) : 512, m = document.createElement("canvas");
2840
2977
  m.width = a, m.height = h;
2841
2978
  const l = m.getContext("2d");
2842
2979
  if (l.fillStyle = r, l.fillRect(0, 0, a, h), e) {
2843
2980
  const g = i ? 0 : Math.round(Math.min(a, h) * 0.11);
2844
- Le(l, e, g, g, a - g * 2, h - g * 2, s);
2981
+ Ne(l, e, g, g, a - g * 2, h - g * 2, s);
2845
2982
  } else {
2846
2983
  l.fillStyle = "#333";
2847
2984
  const g = Math.round(Math.min(a, h) * 0.094);
@@ -2850,7 +2987,7 @@ function $e(r, t, e, s, i, n, o) {
2850
2987
  const d = new c.CanvasTexture(m);
2851
2988
  return d.colorSpace = c.SRGBColorSpace, d;
2852
2989
  }
2853
- async function Ye(r) {
2990
+ async function es(r) {
2854
2991
  if (!r) return null;
2855
2992
  const t = URL.createObjectURL(r), e = new Image();
2856
2993
  e.decoding = "async", e.src = t;
@@ -2865,43 +3002,45 @@ async function Ye(r) {
2865
3002
  export {
2866
3003
  ye as AnimationCurve,
2867
3004
  wt as AutoTurnDirection,
2868
- pe as AutoTurnMode,
3005
+ Me as AutoTurnMode,
2869
3006
  rt as AutoTurnSetting,
2870
- xe as AutoTurnSettingCurveTimeMode,
2871
- Me as AutoTurnSettingMode,
2872
- Nt as AutoTurnSettings,
2873
- Ct as Book,
2874
- Pe as BookBinding,
2875
- We as BookBound,
2876
- je as BookContent,
3007
+ we as AutoTurnSettingCurveTimeMode,
3008
+ Ce as AutoTurnSettingMode,
3009
+ Lt as AutoTurnSettings,
3010
+ yt as Book,
3011
+ ve as BookBinding,
3012
+ Qe as BookBound,
3013
+ Ge as BookContent,
2877
3014
  X as BookDirection,
2878
- Ue as BookHeightException,
2879
- Ge as BookPointerInteraction,
2880
- fe as BookRenderer,
3015
+ Xe as BookHeightException,
3016
+ qe as BookPointerInteraction,
3017
+ pe as BookRenderer,
2881
3018
  ut as Cylinder,
2882
- ue as MeshFactory,
3019
+ _e as MeshFactory,
2883
3020
  Gt as PX_PER_UNIT,
2884
- Xe as PageContent,
2885
- le as Paper,
3021
+ je as PageContent,
3022
+ me as Paper,
2886
3023
  Tt as PaperBorder,
2887
3024
  At as PaperMaterialData,
2888
3025
  Zt as PaperMeshData,
2889
- ge as PaperMeshDataPool,
2890
- Ne as PaperMeshUtility,
3026
+ xe as PaperMeshDataPool,
3027
+ Ee as PaperMeshUtility,
2891
3028
  st as PaperNode,
2892
- ce as PaperNodeMargin,
2893
- Ce as PaperPattern,
3029
+ ue as PaperNodeMargin,
3030
+ Te as PaperPattern,
2894
3031
  Pt as PaperSeam,
2895
3032
  ht as PaperSetup,
2896
3033
  pt as PaperUVMargin,
2897
- de as RendererFactory,
2898
- Ut as SpritePageContent2,
2899
- qe as StapleBookBinding,
2900
- He as StapleBookBound,
2901
- De as StapleSetup,
2902
- Oe as TextBlock,
2903
- Qe as TextOverlayContent,
2904
- $e as createPageTexture,
2905
- Le as drawImageWithFit,
2906
- Ye as loadImage
3034
+ fe as RendererFactory,
3035
+ Je as SpreadContent,
3036
+ Nt as SpritePageContent2,
3037
+ $e as StapleBookBinding,
3038
+ Oe as StapleBookBound,
3039
+ He as StapleSetup,
3040
+ ee as TextBlock,
3041
+ Ye as TextOverlayContent,
3042
+ ts as createPageTexture,
3043
+ Ne as drawImageWithFit,
3044
+ Ke as getSpreadPairs,
3045
+ es as loadImage
2907
3046
  };