@objectifthunes/three-book 0.1.4 → 0.1.5

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.
@@ -0,0 +1,30 @@
1
+ import * as THREE from 'three';
2
+ import { Book } from './Book';
3
+ /**
4
+ * Wires pointer events on a DOM element to Book's interactive turning API.
5
+ *
6
+ * Usage:
7
+ * const interaction = new BookPointerInteraction(camera, renderer.domElement);
8
+ * interaction.onTurnStart = (book) => { controls.enabled = false; };
9
+ * interaction.onTurnEnd = (book) => { controls.enabled = true; };
10
+ * // Later: interaction.dispose();
11
+ */
12
+ export declare class BookPointerInteraction {
13
+ /** Set to false to temporarily disable interaction without disposing. */
14
+ enabled: boolean;
15
+ onTurnStart?: (book: Book) => void;
16
+ onTurnEnd?: (book: Book) => void;
17
+ private readonly m_Camera;
18
+ private readonly m_DomElement;
19
+ private readonly m_Raycaster;
20
+ private readonly m_Mouse;
21
+ private m_SelectedBook;
22
+ private m_IsPointerDown;
23
+ constructor(camera: THREE.Camera, domElement: HTMLElement);
24
+ dispose(): void;
25
+ private m_GetRay;
26
+ private m_OnPointerDown;
27
+ private m_OnPointerMove;
28
+ private m_OnPointerUp;
29
+ }
30
+ //# sourceMappingURL=BookPointerInteraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BookPointerInteraction.d.ts","sourceRoot":"","sources":["../src/BookPointerInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACjC,yEAAyE;IACzE,OAAO,EAAE,OAAO,CAAQ;IAExB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuB;IAC/C,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,eAAe,CAAS;gBAEpB,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW;IAQzD,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,eAAe,CAWrB;IAEF,OAAO,CAAC,eAAe,CAGrB;IAEF,OAAO,CAAC,aAAa,CAOnB;CACH"}
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export { PaperSeam, PaperBorder, PaperNodeMargin } from './PaperStructs';
12
12
  export { Cylinder } from './Cylinder';
13
13
  export { BookContent } from './BookContent';
14
14
  export { BookDirection } from './BookDirection';
15
+ export { BookPointerInteraction } from './BookPointerInteraction';
15
16
  export { BookBinding, BookBound } from './BookBinding';
16
17
  export { StapleBookBound, StapleBookBinding, StapleSetup } from './StapleBinding';
17
18
  export { AutoTurnDirection, AutoTurnMode, AutoTurnSettings, AutoTurnSetting, AutoTurnSettingMode, AutoTurnSettingCurveTimeMode, AnimationCurve, } from './AutoTurn';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAElF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,4BAA4B,EAC5B,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3F,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AACnD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAElF,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,4BAA4B,EAC5B,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3F,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -108,7 +108,7 @@ function ee(r) {
108
108
  function se(r) {
109
109
  return new c.Vector3(r.x, r.z, 0);
110
110
  }
111
- function St(r, t, e) {
111
+ function kt(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 };
@@ -123,7 +123,7 @@ function St(r, t, e) {
123
123
  };
124
124
  }
125
125
  }
126
- function kt(r, t, e) {
126
+ function vt(r, t, e) {
127
127
  return ie(r, t, e) ? r.clone() : ne(
128
128
  new c.Vector2(r.x, t.y),
129
129
  r,
@@ -140,7 +140,7 @@ function ne(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, _ = s.y, p = 1 / (l * l), d = 1 / (_ * _);
141
141
  if (Math.abs(o - h) < 1e-5) {
142
142
  if (o >= i - l && o <= i + l) {
143
- const u = St(
143
+ const u = kt(
144
144
  d,
145
145
  -2 * d * n,
146
146
  p * (o * o - 2 * i * o + i * i) + d * n * n - 1
@@ -153,7 +153,7 @@ function ne(r, t, e, s) {
153
153
  }
154
154
  }
155
155
  } else {
156
- const u = (m - a) / (h - o), f = a - u * o, g = f - n, w = St(
156
+ const u = (m - a) / (h - o), f = a - u * o, g = f - n, w = kt(
157
157
  p + d * u * u,
158
158
  2 * g * u * d - 2 * i * p,
159
159
  i * i * p + g * g * d - 1
@@ -167,7 +167,7 @@ function ne(r, t, e, s) {
167
167
  }
168
168
  return r.clone();
169
169
  }
170
- function vt(r, t) {
170
+ 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
  }
@@ -177,12 +177,12 @@ function re(r) {
177
177
  function oe(r) {
178
178
  return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
179
179
  }
180
- var E = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(E || {});
181
- const bt = Math.PI / 180, Bt = 180 / Math.PI, ae = 1192093e-13;
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, ae = 1192093e-13;
182
182
  function _t(r) {
183
183
  return r < 0 ? 0 : r > 1 ? 1 : r;
184
184
  }
185
- function Rt(r, t, e) {
185
+ function It(r, t, e) {
186
186
  return r < t ? t : r > e ? e : r;
187
187
  }
188
188
  function mt(r, t, e) {
@@ -191,10 +191,10 @@ function mt(r, t, e) {
191
191
  function Vt(r, t, e) {
192
192
  return r + (t - r) * e;
193
193
  }
194
- function It(r, t, e) {
194
+ function zt(r, t, e) {
195
195
  return r + (t - r) * e;
196
196
  }
197
- function zt(r, t, e) {
197
+ function Dt(r, t, e) {
198
198
  return e = _t((e - r) / (t - r)), e * e * (3 - 2 * e);
199
199
  }
200
200
  class he {
@@ -240,7 +240,7 @@ class he {
240
240
  return this.m_IsFalling || this.m_IsTurning ? this.m_Transform.scale.x === -1 ? 1 - this.m_ZTime : this.m_ZTime : this.m_Transform.scale.x === -1 ? 1 : 0;
241
241
  }
242
242
  get direction() {
243
- const e = this.zTime * 180 * bt, s = Math.cos(e), i = Math.sin(e);
243
+ const e = this.zTime * 180 * Bt, s = Math.cos(e), i = Math.sin(e);
244
244
  return new c.Vector3(-s, -i, 0);
245
245
  }
246
246
  get isTurning() {
@@ -314,7 +314,7 @@ class he {
314
314
  }
315
315
  updateTurningRadius(t = 1) {
316
316
  let e = Math.max(this.m_Stiffness, 1 - _t(t));
317
- e <= 0.5 ? this.m_TurningRadius = mt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - mt(0.5, 1, e)), 5) * bt), this.m_TurningRadius = Math.max(
317
+ e <= 0.5 ? this.m_TurningRadius = mt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - mt(0.5, 1, e)), 5) * Bt), this.m_TurningRadius = Math.max(
318
318
  this.m_TurningRadius,
319
319
  this.m_MinTurningRadius
320
320
  );
@@ -322,7 +322,7 @@ class he {
322
322
  startTurning(t) {
323
323
  var n, o;
324
324
  const e = t.clone();
325
- t = vt(
325
+ t = bt(
326
326
  t,
327
327
  this.m_Transform.matrixWorld.clone().invert()
328
328
  ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
@@ -376,7 +376,7 @@ class he {
376
376
  let e = !1;
377
377
  if (this.m_IsAutoTurning) {
378
378
  let n = _t(this.m_FallTime / this.m_FallDuration);
379
- n = zt(0, 1, n), n = zt(0, 1, n), this.m_CurrentHandle.lerpVectors(
379
+ n = Dt(0, 1, n), n = Dt(0, 1, n), this.m_CurrentHandle.lerpVectors(
380
380
  this.m_StartHandle,
381
381
  this.m_EndHandle,
382
382
  this.m_IsFallingLeft ? n : 1 - n
@@ -439,7 +439,7 @@ class he {
439
439
  );
440
440
  this.m_UVMargin.fixUV(e);
441
441
  const s = this.m_Book.direction;
442
- if (s === E.UpToDown || s === E.DownToUp) {
442
+ if (s === X.UpToDown || s === X.DownToUp) {
443
443
  const i = e.x;
444
444
  e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
445
445
  } else
@@ -451,7 +451,7 @@ class he {
451
451
  * Returns the local-space hit point, or null if no hit / out of bounds.
452
452
  */
453
453
  raycastLocal(t, e = !1) {
454
- t = vt(
454
+ t = bt(
455
455
  t,
456
456
  this.m_Transform.matrixWorld.clone().invert()
457
457
  );
@@ -541,7 +541,7 @@ class he {
541
541
  new c.Vector3(s[1], 0, i[i.length - 1])
542
542
  ), h = this.rollPoint(
543
543
  new c.Vector3(s[2], 0, i[i.length - 1])
544
- ), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), _ = Bt * Math.atan2(m.y, m.x), p = Bt * Math.atan2(l.y, l.x), d = (_ + p) / 2;
544
+ ), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), _ = Rt * Math.atan2(m.y, m.x), p = Rt * Math.atan2(l.y, l.x), d = (_ + p) / 2;
545
545
  this.m_ZTime = d / 180;
546
546
  } else
547
547
  this.m_XTime = 0, this.m_ZTime = 0;
@@ -558,12 +558,12 @@ class he {
558
558
  0,
559
559
  h + (s.z - h) * (a / n)
560
560
  ), _ = new c.Vector2(i, o), p = new c.Vector2(n, a);
561
- t.x = Rt(t.x, -this.m_Size.x, this.m_Size.x);
562
- const d = se(t), u = kt(
561
+ t.x = It(t.x, -this.m_Size.x, this.m_Size.x);
562
+ const d = se(t), u = vt(
563
563
  new c.Vector2(d.x, d.y),
564
564
  m,
565
565
  _
566
- ), f = kt(
566
+ ), f = vt(
567
567
  new c.Vector2(u.x, u.y),
568
568
  l,
569
569
  p
@@ -608,8 +608,8 @@ class he {
608
608
  /* Highpoly */
609
609
  ), (m = this.m_Prev) == null || m.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === 1, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
610
610
  const n = this.m_Size.x, o = this.m_Size.y;
611
- e = Rt(e, -0.99, 0.99);
612
- const a = It(0.5, 1, e), h = It(0.5, 0, e);
611
+ e = It(e, -0.99, 0.99);
612
+ const a = zt(0.5, 1, e), h = zt(0.5, 0, e);
613
613
  this.m_StartHandle.set(n, 0, o * a), this.m_EndHandle.set(-n, 0, o * h), this.m_IsAutoTurning = !0;
614
614
  }
615
615
  // ---- Public getter for the cylinder (used by BookBound etc.) ----
@@ -658,16 +658,16 @@ const Y = class Y {
658
658
  transform(t) {
659
659
  const e = new Y();
660
660
  switch (t) {
661
- case E.LeftToRight:
661
+ case X.LeftToRight:
662
662
  e.m_Left = this.m_Left, e.m_Right = this.m_Right, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
663
663
  break;
664
- case E.RightToLeft:
664
+ case X.RightToLeft:
665
665
  e.m_Left = this.m_Right, e.m_Right = this.m_Left, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
666
666
  break;
667
- case E.UpToDown:
667
+ case X.UpToDown:
668
668
  e.m_Left = this.m_Up, e.m_Right = this.m_Down, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
669
669
  break;
670
- case E.DownToUp:
670
+ case X.DownToUp:
671
671
  default:
672
672
  e.m_Left = this.m_Down, e.m_Right = this.m_Up, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
673
673
  break;
@@ -697,9 +697,9 @@ const Y = class Y {
697
697
  };
698
698
  Y.kMin = 0, Y.kMax = 0.25;
699
699
  let gt = Y;
700
- const L = class L {
700
+ const U = class U {
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 gt(), this.margin = 0, this.bookDirection = E.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? L.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? L.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? L.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 gt(), 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);
703
703
  }
704
704
  // ── Properties ────────────────────────────────────────────────────────
705
705
  get material() {
@@ -718,19 +718,19 @@ const L = class L {
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, L.kMinSize);
721
+ this.m_Width = Math.max(t, U.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, L.kMinSize);
727
+ this.m_Height = Math.max(t, U.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, L.kMinThickness);
733
+ this.m_Thickness = Math.max(t, U.kMinThickness);
734
734
  }
735
735
  get stiffness() {
736
736
  return this.m_Stiffness;
@@ -743,8 +743,8 @@ const L = class L {
743
743
  }
744
744
  set quality(t) {
745
745
  this.m_Quality = Math.max(
746
- L.kMinQuality,
747
- Math.min(t, L.kMaxQuality)
746
+ U.kMinQuality,
747
+ Math.min(t, U.kMaxQuality)
748
748
  );
749
749
  }
750
750
  get uvMargin() {
@@ -757,9 +757,9 @@ const L = class L {
757
757
  return new c.Vector2(this.width, this.height);
758
758
  }
759
759
  };
760
- L.kMinSize = 1, L.kMinThickness = 1e-4, L.kMinQuality = 1, L.kMaxQuality = 5;
761
- let ht = L;
762
- class Dt {
760
+ U.kMinSize = 1, U.kMinThickness = 1e-4, U.kMinQuality = 1, U.kMaxQuality = 5;
761
+ let ht = U;
762
+ class At {
763
763
  constructor(t) {
764
764
  this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
765
765
  const e = t.material ?? new c.MeshStandardMaterial();
@@ -795,7 +795,7 @@ class Dt {
795
795
  this.m_Texture = t, this.m_TextureST.copy(e);
796
796
  }
797
797
  }
798
- function At(r, t, e, s = new c.Vector3()) {
798
+ function Ht(r, t, e, s = new c.Vector3()) {
799
799
  let i = t.x - r.x, n = t.y - r.y, o = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + o * o);
800
800
  i *= a, n *= a, o *= a;
801
801
  let h = e.x - r.x, m = e.y - r.y, l = e.z - r.z;
@@ -860,21 +860,21 @@ class st {
860
860
  t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
861
861
  }
862
862
  }
863
- class Pt {
863
+ class wt {
864
864
  constructor(t, e, s, i) {
865
865
  this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
866
866
  }
867
867
  clone() {
868
- const t = new Pt(this.prevIndex, this.index, this.nextIndex, this.time);
868
+ const t = new wt(this.prevIndex, this.index, this.nextIndex, this.time);
869
869
  return t.active = this.active, t;
870
870
  }
871
871
  }
872
- class wt {
872
+ class Tt {
873
873
  constructor(t, e, s, i, n, o = !0) {
874
874
  this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = o;
875
875
  }
876
876
  clone() {
877
- return new wt(
877
+ return new Tt(
878
878
  this.startX,
879
879
  this.startZ,
880
880
  this.endX,
@@ -900,7 +900,7 @@ function lt(r, t, e) {
900
900
  }
901
901
  function Mt(r, t) {
902
902
  for (const e of r) {
903
- const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new Pt(s.index, e.index, i.index, n);
903
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new wt(s.index, e.index, i.index, n);
904
904
  t.push(o);
905
905
  }
906
906
  }
@@ -944,12 +944,12 @@ function qt(r, t, e, s, i) {
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, _ = n.endX - n.startX; l < _; l++) {
946
946
  const p = h + l * 2 + 0, d = h + l * 2 + 1, u = h + l * 2 + 2, f = h + l * 2 + 3;
947
- n.flip ? Ft(t, p, d, u, f, o) : Ht(t, p, d, u, f, o);
947
+ n.flip ? Ot(t, p, d, u, f, o) : Ft(t, p, d, u, f, o);
948
948
  }
949
949
  if (n.left)
950
950
  for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
951
951
  const p = h + l * 2 + 0 + o * 2, d = h + l * 2 + 1 + o * 2, u = h + l * 2 + 2 + o * 2, f = h + l * 2 + 3 + o * 2;
952
- n.flip ? Ft(t, p, d, u, f, a) : Ht(t, p, d, u, f, a);
952
+ n.flip ? Ot(t, p, d, u, f, a) : Ft(t, p, d, u, f, a);
953
953
  }
954
954
  else
955
955
  for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
@@ -1020,10 +1020,10 @@ function ce(r, t, e, s, i) {
1020
1020
  }
1021
1021
  return n;
1022
1022
  }
1023
- function Ht(r, t, e, s, i, n) {
1023
+ function Ft(r, t, e, s, i, n) {
1024
1024
  dt(r, t, e, s, i), t += n, e += n, s += n, i += n, dt(r, t, e, s, i);
1025
1025
  }
1026
- function Ft(r, t, e, s, i, n) {
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
1029
  function Qt(r, t, e, s, i, n, o) {
@@ -1154,8 +1154,8 @@ class Zt {
1154
1154
  for (let u = 0; u < o - 1; u++) {
1155
1155
  const f = u + 1;
1156
1156
  for (let g = 0; g < n - 1; g++) {
1157
- const w = g + 1, B = u * n + g, x = u * n + w, y = f * n + g, S = f * n + w, v = t[B], Z = t[x], O = t[y], z = t[S];
1158
- At(v, O, Z, h), At(z, Z, O, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[y].add(l), s[S].add(l);
1157
+ const w = g + 1, B = u * n + g, x = u * n + w, y = f * n + g, S = f * n + w, v = t[B], O = t[x], Z = t[y], z = t[S];
1158
+ Ht(v, Z, O, h), Ht(z, O, Z, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[y].add(l), s[S].add(l);
1159
1159
  }
1160
1160
  }
1161
1161
  for (let u = 0; u < a; u++)
@@ -1392,7 +1392,7 @@ function nt(r, t, e) {
1392
1392
  function Ce(r, t, e) {
1393
1393
  return r === t ? 0 : nt((e - r) / (t - r), 0, 1);
1394
1394
  }
1395
- function Ot(r, t) {
1395
+ function Nt(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 Ot(this.m_ConstantMin, this.m_ConstantMax);
1466
+ return Nt(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 Ot(
1471
+ return Nt(
1472
1472
  this.m_CurveMin.evaluate(s),
1473
1473
  this.m_CurveMax.evaluate(s)
1474
1474
  );
@@ -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, Ze = class extends Error {
1570
+ let Lt = R, Oe = 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."
@@ -1589,7 +1589,7 @@ const ot = class ot extends c.Group {
1589
1589
  height: 3,
1590
1590
  thickness: 0.02,
1591
1591
  stiffness: 0.2
1592
- }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = E.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new ht({
1592
+ }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = X.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new ht({
1593
1593
  color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1594
1594
  width: t.coverPaperSetup.width ?? 2.1,
1595
1595
  height: t.coverPaperSetup.height ?? 3.1,
@@ -1731,7 +1731,7 @@ const ot = class ot extends c.Group {
1731
1731
  }
1732
1732
  getActivePaperSideIndices(t) {
1733
1733
  if (t.length = 0, !this.m_IsBuilt) return;
1734
- const e = this.m_Content.direction === E.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1734
+ const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1735
1735
  let a = n * 2;
1736
1736
  o && a++, e && (a = s * 2 - a - 1), t.includes(a) || t.push(a);
1737
1737
  };
@@ -1849,7 +1849,7 @@ const ot = class ot extends c.Group {
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;
1851
1851
  this.m_Root.rotation.set(0, t, 0), this.m_CoverPaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.height < this.m_CoverPaperSetup.height ? (this.m_CoverPaperSetup.margin = 0, this.m_PagePaperSetup.margin = (this.m_CoverPaperSetup.height - this.m_PagePaperSetup.height) / 2) : (this.m_CoverPaperSetup.margin = (this.m_PagePaperSetup.height - this.m_CoverPaperSetup.height) / 2, this.m_PagePaperSetup.margin = 0);
1852
- const e = new Dt(this.m_CoverPaperSetup), s = new Dt(this.m_PagePaperSetup);
1852
+ const e = new At(this.m_CoverPaperSetup), s = new At(this.m_PagePaperSetup);
1853
1853
  this.m_Content.init(this);
1854
1854
  let i = this.m_Content.coverContents, n = this.m_Content.pageContents, o = this.m_InitialOpenProgress;
1855
1855
  this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), o = 1 - o), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
@@ -1857,8 +1857,8 @@ const ot = class ot extends c.Group {
1857
1857
  let m = 0, l = 0, _ = 0;
1858
1858
  this.m_Papers = new Array(a);
1859
1859
  for (let C = 0; C < a; C++) {
1860
- const V = this.m_HasCover && (C < h || C >= a - h), U = this.m_RendererFactory.get("Paper"), k = this.m_Papers[C] = new he(V, C, this, U);
1861
- k.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (k.transform.scale.set(-1, 1, 1), k.setTime(1)), V ? (k.setContentData(i[l++], i[l++], C > h), k.setMaterialData(e), k.setPaperSetup(this.m_CoverPaperSetup)) : (k.setContentData(n[m++], n[m++]), k.setMaterialData(s), k.setPaperSetup(this.m_PagePaperSetup)), _ += k.thickness;
1860
+ const I = this.m_HasCover && (C < h || C >= a - h), L = this.m_RendererFactory.get("Paper"), k = this.m_Papers[C] = new he(I, C, this, L);
1861
+ k.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (k.transform.scale.set(-1, 1, 1), k.setTime(1)), I ? (k.setContentData(i[l++], i[l++], C > h), k.setMaterialData(e), k.setPaperSetup(this.m_CoverPaperSetup)) : (k.setContentData(n[m++], n[m++]), k.setMaterialData(s), k.setPaperSetup(this.m_PagePaperSetup)), _ += k.thickness;
1862
1862
  }
1863
1863
  this.m_TotalThickness = _;
1864
1864
  const p = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
@@ -1872,16 +1872,16 @@ 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, y = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, v = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, N = z + 1, D = this.m_Bound.constructor.name.includes("Staple");
1875
+ const B = this.m_ReduceOverdraw && n.length > 0, x = this.m_ReduceSubMeshes, y = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, v = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, N = z + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
1876
  for (let C = 0; C < a; C++) {
1877
- const V = this.m_Papers[C];
1878
- C !== 0 && (V.prev = this.m_Papers[C - 1]), C !== a - 1 && (V.next = this.m_Papers[C + 1]), V.noHole = D && (C === z || C === N), V.isCover ? V.setMeshData(Z.get(), null, O) : V.setMeshData(
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 === z || C === N), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
1879
1879
  y.get(),
1880
1880
  (S == null ? void 0 : S.get()) ?? null,
1881
1881
  v
1882
1882
  );
1883
1883
  }
1884
- this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this.update(0), this.m_Bound.binderRenderer.updateCollider(), this.m_CoverPaperSetup.bookDirection = E.LeftToRight, this.m_PagePaperSetup.bookDirection = E.LeftToRight;
1884
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this.update(0), this.m_Bound.binderRenderer.updateCollider(), this.m_CoverPaperSetup.bookDirection = X.LeftToRight, this.m_PagePaperSetup.bookDirection = X.LeftToRight;
1885
1885
  }
1886
1886
  clear() {
1887
1887
  return this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_MeshFactory !== null && this.m_MeshFactory.recycle(), this.m_RendererFactory !== null && this.m_RendererFactory.recycle(), this;
@@ -1953,7 +1953,7 @@ const ot = class ot extends c.Group {
1953
1953
  }
1954
1954
  };
1955
1955
  ot.s_Instances = /* @__PURE__ */ new Set();
1956
- let Ut = ot;
1956
+ let Pt = ot;
1957
1957
  class ye {
1958
1958
  constructor() {
1959
1959
  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;
@@ -1994,7 +1994,7 @@ class Ne {
1994
1994
  this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
1995
1995
  }
1996
1996
  }
1997
- class Lt {
1997
+ class Ut {
1998
1998
  constructor(t, e) {
1999
1999
  this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2000
2000
  }
@@ -2012,9 +2012,9 @@ class Lt {
2012
2012
  setActive(t) {
2013
2013
  }
2014
2014
  }
2015
- class Ue {
2015
+ class Le {
2016
2016
  constructor() {
2017
- this.m_Direction = E.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
2017
+ 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
2018
  }
2019
2019
  get coverCount4() {
2020
2020
  return this.nextMultipleOf4(this.m_Covers.length);
@@ -2061,11 +2061,11 @@ class Ue {
2061
2061
  getContent(t) {
2062
2062
  if (t !== null) {
2063
2063
  if (t instanceof c.Texture)
2064
- return new Lt(t);
2064
+ return new Ut(t);
2065
2065
  if (typeof t.init == "function")
2066
2066
  return t;
2067
2067
  }
2068
- return new Lt(null);
2068
+ return new Ut(null);
2069
2069
  }
2070
2070
  init(t) {
2071
2071
  this.m_Book = t;
@@ -2113,14 +2113,41 @@ class Ue {
2113
2113
  return !this.isCoverPaperSideIndex(t);
2114
2114
  }
2115
2115
  }
2116
+ class Ue {
2117
+ constructor(t, e) {
2118
+ 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
+ var n;
2120
+ if (!this.enabled || s.button !== 0) return;
2121
+ this.m_IsPointerDown = !0;
2122
+ const i = this.m_GetRay(s);
2123
+ for (const o of Pt.instances)
2124
+ if (o.startTurning(i)) {
2125
+ this.m_SelectedBook = o, (n = this.onTurnStart) == null || n.call(this, o);
2126
+ break;
2127
+ }
2128
+ }, this.m_OnPointerMove = (s) => {
2129
+ !this.m_IsPointerDown || !this.m_SelectedBook || this.m_SelectedBook.updateTurning(this.m_GetRay(s));
2130
+ }, this.m_OnPointerUp = () => {
2131
+ var s;
2132
+ this.m_IsPointerDown = !1, this.m_SelectedBook && (this.m_SelectedBook.stopTurning(), (s = this.onTurnEnd) == null || s.call(this, this.m_SelectedBook), this.m_SelectedBook = null);
2133
+ }, this.m_Camera = t, this.m_DomElement = e, e.addEventListener("pointerdown", this.m_OnPointerDown), e.addEventListener("pointermove", this.m_OnPointerMove), e.addEventListener("pointerup", this.m_OnPointerUp);
2134
+ }
2135
+ dispose() {
2136
+ this.m_DomElement.removeEventListener("pointerdown", this.m_OnPointerDown), this.m_DomElement.removeEventListener("pointermove", this.m_OnPointerMove), this.m_DomElement.removeEventListener("pointerup", this.m_OnPointerUp), this.m_SelectedBook = null, this.m_IsPointerDown = !1;
2137
+ }
2138
+ m_GetRay(t) {
2139
+ const e = this.m_DomElement.getBoundingClientRect();
2140
+ 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
+ }
2142
+ }
2116
2143
  class Pe {
2117
2144
  }
2118
- class Le {
2145
+ class Ee {
2119
2146
  constructor(t, e) {
2120
2147
  this.m_Book = t, this.m_Root = e;
2121
2148
  }
2122
2149
  }
2123
- function Xt(r, t, e, s) {
2150
+ function Et(r, t, e, s) {
2124
2151
  const i = 1 - s;
2125
2152
  return new c.Vector3(
2126
2153
  i * i * r.x + 2 * i * s * t.x + s * s * e.x,
@@ -2128,13 +2155,13 @@ function Xt(r, t, e, s) {
2128
2155
  i * i * r.z + 2 * i * s * t.z + s * s * e.z
2129
2156
  );
2130
2157
  }
2131
- function Et(r, t) {
2158
+ function Xt(r, t) {
2132
2159
  return r++, r === t ? 0 : r;
2133
2160
  }
2134
2161
  function we(r, t) {
2135
2162
  return r === 0 ? t - 1 : r - 1;
2136
2163
  }
2137
- const Te = 0.01, Se = 0.1, ke = 0.04, ve = 0.4, be = 2, Be = 10, Re = 0, Ve = 5;
2164
+ const Te = 0.01, Se = 0.1, ke = 0.04, ve = 0.4, be = 2, Be = 10, Re = 0, Ie = 5;
2138
2165
  function et(r, t, e) {
2139
2166
  return Math.max(t, Math.min(e, r));
2140
2167
  }
@@ -2147,7 +2174,7 @@ function F(r, t, e) {
2147
2174
  function jt(r, t, e) {
2148
2175
  return r === t ? 0 : Kt((e - r) / (t - r));
2149
2176
  }
2150
- function Ie(r, t) {
2177
+ function Ve(r, t) {
2151
2178
  const e = r.clone().normalize();
2152
2179
  if (e.lengthSq() === 0) return new c.Quaternion();
2153
2180
  let s = new c.Vector3().crossVectors(t, e);
@@ -2204,7 +2231,7 @@ class ze {
2204
2231
  return this._quality;
2205
2232
  }
2206
2233
  set quality(t) {
2207
- this._quality = et(t, Re, Ve);
2234
+ this._quality = et(t, Re, Ie);
2208
2235
  }
2209
2236
  }
2210
2237
  class De extends Error {
@@ -2261,8 +2288,8 @@ class Ae {
2261
2288
  B += this.m_Book.totalThickness / 2, B += d;
2262
2289
  const x = -(this.m_Book.papers[0].thickness / 2 + d), y = [];
2263
2290
  {
2264
- for (let I = 0; I < _; I++) {
2265
- const X = I / (_ - 1), W = F(-90, -180, X) * tt, P = new c.Vector3(
2291
+ for (let V = 0; V < _; V++) {
2292
+ const E = V / (_ - 1), W = F(-90, -180, E) * tt, P = new c.Vector3(
2266
2293
  g * Math.sin(W),
2267
2294
  0,
2268
2295
  g * Math.cos(W)
@@ -2270,8 +2297,8 @@ class Ae {
2270
2297
  P.x += g, P.z += g, P.x += x, y.push(P);
2271
2298
  }
2272
2299
  const M = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - d * 0.5, 0, w);
2273
- for (let I = 0; I < p; I++) {
2274
- const X = I / (p - 1), q = Xt(M, H, T, X);
2300
+ for (let V = 0; V < p; V++) {
2301
+ const E = V / (p - 1), q = Et(M, H, T, E);
2275
2302
  q.x += x, y.push(q);
2276
2303
  }
2277
2304
  y.reverse();
@@ -2281,56 +2308,56 @@ class Ae {
2281
2308
  const T = (90 - M * (360 / l)) * tt;
2282
2309
  S[M] = new c.Vector3(Math.cos(T), Math.sin(T), 0), S[M].x *= 0.75;
2283
2310
  }
2284
- const v = y.length, Z = v * l, O = new Array(Z * 2), z = new Array(Z * 2), N = new Array(
2285
- (Z * 2 - 1) * l * 2 * 3
2311
+ const v = y.length, O = v * l, Z = new Array(O * 2), z = new Array(O * 2), N = new Array(
2312
+ (O * 2 - 1) * l * 2 * 3
2286
2313
  );
2287
- for (let M = 0; M < Z * 2; M++)
2288
- O[M] = new c.Vector3(), z[M] = new c.Vector3();
2314
+ for (let M = 0; M < O * 2; M++)
2315
+ Z[M] = new c.Vector3(), z[M] = new c.Vector3();
2289
2316
  let D = 0;
2290
2317
  for (let M = 0; M < v; M++) {
2291
- const H = y[we(M, v)], T = y[M], I = y[Et(M, v)];
2292
- let X;
2318
+ const H = y[we(M, v)], T = y[M], V = y[Xt(M, v)];
2319
+ let E;
2293
2320
  if (M === 0)
2294
- X = new c.Vector3(1, 0, -2).normalize();
2321
+ E = new c.Vector3(1, 0, -2).normalize();
2295
2322
  else if (M === v - 1)
2296
- X = new c.Vector3(0, 0, 1);
2323
+ E = new c.Vector3(0, 0, 1);
2297
2324
  else {
2298
- const K = T.clone().sub(H).normalize(), J = I.clone().sub(T).normalize();
2299
- X = K.add(J).multiplyScalar(0.5);
2325
+ const K = T.clone().sub(H).normalize(), J = V.clone().sub(T).normalize();
2326
+ E = K.add(J).multiplyScalar(0.5);
2300
2327
  }
2301
- const q = new c.Vector3(0, 1, 0), W = Ie(X, q), P = D;
2328
+ const q = new c.Vector3(0, 1, 0), W = Ve(E, q), P = D;
2302
2329
  let b = jt(0, p / 4, M);
2303
2330
  b = F(0.1, 1, b), b = Math.sqrt(b);
2304
2331
  for (let K = 0; K < l; K++) {
2305
2332
  const J = S[K].clone().applyQuaternion(W).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(d));
2306
- O[D] = ct, z[D] = J.clone();
2333
+ Z[D] = ct, z[D] = J.clone();
2307
2334
  const at = T.clone().add(J.clone().multiplyScalar(d));
2308
2335
  at.z = s - at.z;
2309
- const Jt = P + l - K - 1, Tt = Z * 2 - Jt - 1;
2310
- O[Tt] = at, z[Tt] = J.clone(), D++;
2336
+ const Jt = P + l - K - 1, St = O * 2 - Jt - 1;
2337
+ Z[St] = at, z[St] = J.clone(), D++;
2311
2338
  }
2312
2339
  }
2313
2340
  let C = 0;
2314
- const V = y.length * 2;
2315
- for (let M = 0; M < V - 1; M++) {
2341
+ const I = y.length * 2;
2342
+ for (let M = 0; M < I - 1; M++) {
2316
2343
  const H = M * l, T = (M + 1) * l;
2317
- for (let I = 0; I < l; I++) {
2318
- const X = Et(I, l), q = H + I, W = H + X, P = T + X, b = T + I;
2344
+ for (let V = 0; V < l; V++) {
2345
+ const E = Xt(V, l), q = H + V, W = H + E, P = T + E, b = T + V;
2319
2346
  N[C++] = q, N[C++] = b, N[C++] = W, N[C++] = W, N[C++] = b, N[C++] = P;
2320
2347
  }
2321
2348
  }
2322
- const U = [...O], k = [...z], Q = [...N], G = O.map((M) => M.clone()), $ = [...N];
2349
+ const L = [...Z], k = [...z], Q = [...N], G = Z.map((M) => M.clone()), $ = [...N];
2323
2350
  for (let M = 0; M < a - 1; M++) {
2324
2351
  const H = G.length;
2325
2352
  for (let T = 0; T < $.length; T++)
2326
2353
  $[T] += H;
2327
2354
  for (let T = 0; T < G.length; T++)
2328
2355
  G[T].z += h + s;
2329
- U.push(...G.map((T) => T.clone())), k.push(...z.map((T) => T.clone())), Q.push(...$);
2356
+ L.push(...G.map((T) => T.clone())), k.push(...z.map((T) => T.clone())), Q.push(...$);
2330
2357
  }
2331
- const j = new Float32Array(U.length * 3), A = new Float32Array(k.length * 3);
2332
- for (let M = 0; M < U.length; M++)
2333
- j[M * 3] = U[M].x, j[M * 3 + 1] = U[M].y, j[M * 3 + 2] = U[M].z, A[M * 3] = k[M].x, A[M * 3 + 1] = k[M].y, A[M * 3 + 2] = k[M].z;
2358
+ const j = new Float32Array(L.length * 3), A = new Float32Array(k.length * 3);
2359
+ for (let M = 0; M < L.length; M++)
2360
+ j[M * 3] = L[M].x, j[M * 3 + 1] = L[M].y, j[M * 3 + 2] = L[M].z, A[M * 3] = k[M].x, A[M * 3 + 1] = k[M].y, A[M * 3 + 2] = k[M].z;
2334
2361
  e.setAttribute(
2335
2362
  "position",
2336
2363
  new c.BufferAttribute(j, 3)
@@ -2362,10 +2389,10 @@ class Ae {
2362
2389
  w = w.createNext(x), x += y;
2363
2390
  const S = new st(0);
2364
2391
  let v = S;
2365
- const Z = e.y / (f - 1);
2366
- let O = 0;
2392
+ const O = e.y / (f - 1);
2393
+ let Z = 0;
2367
2394
  for (let P = 0; P < f - 1; P++)
2368
- O += Z, v = v.createNext(O);
2395
+ Z += O, v = v.createNext(Z);
2369
2396
  const z = [], N = [], D = i.clone();
2370
2397
  if (n) {
2371
2398
  let P = 0;
@@ -2375,10 +2402,10 @@ class Ae {
2375
2402
  }
2376
2403
  const C = new le(a, D, !1);
2377
2404
  C.insert(g, S, z, N), g.updateIndex(0), S.updateIndex(0), Mt(z, a.xSeams), Mt(N, a.zSeams);
2378
- const V = this.m_BindingVertexCount + 2, U = new Array(V);
2379
- a.xNoneSeamIndexes = U, w = g;
2380
- for (let P = 0; P < V; P++) {
2381
- U[P] = w.index;
2405
+ const I = this.m_BindingVertexCount + 2, L = new Array(I);
2406
+ a.xNoneSeamIndexes = L, w = g;
2407
+ for (let P = 0; P < I; P++) {
2408
+ L[P] = w.index;
2382
2409
  do
2383
2410
  w = w.next;
2384
2411
  while (w.seam);
@@ -2394,12 +2421,12 @@ class Ae {
2394
2421
  i,
2395
2422
  this.m_Book.direction
2396
2423
  );
2397
- const I = C.leftNode.index, X = C.downNode.index;
2424
+ const V = C.leftNode.index, E = C.downNode.index;
2398
2425
  let q = C.rightNode.index, W = C.upNode.index;
2399
2426
  q === 0 && (q = u - 1), W === 0 && (W = f - 1);
2400
2427
  for (let P = 0; P < f - 1; P++)
2401
2428
  for (let b = 0; b < u - 1; b++) {
2402
- if (n && P >= X && P < W && b >= I && b < q)
2429
+ if (n && P >= E && P < W && b >= V && b < q)
2403
2430
  continue;
2404
2431
  const K = P * u + b, J = P * u + (b + 1), ct = (P + 1) * u + b, at = (P + 1) * u + (b + 1);
2405
2432
  j[K] += 2, j[J] += 2, j[ct] += 2, j[at] += 2, Qt(
@@ -2412,7 +2439,7 @@ class Ae {
2412
2439
  G
2413
2440
  );
2414
2441
  }
2415
- if (T.push(new wt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = k, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2442
+ if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = k, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2416
2443
  a.subMeshCount = 1;
2417
2444
  const P = [];
2418
2445
  P.push(...A), P.push(...H), P.push(...M), a.triangles = P;
@@ -2555,14 +2582,14 @@ class Ae {
2555
2582
  const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
2556
2583
  for (let m = 0; m < h; m++) {
2557
2584
  const l = t[m], _ = l.transform, p = l.meshData.pattern, d = l.meshData.baseVertices, u = p.baseXArray, f = p.baseZArray, g = u.length, w = f.length, B = this.m_BindingVertexCount + 1, x = l.thickness, y = p.xNoneSeamIndexes, S = _.position.clone();
2558
- let v = m, Z = n;
2559
- m >= Math.floor(h / 2) && (v = h - m - 1, Z *= -1);
2560
- const O = (o + x) * 0.5 + x * (v - 1), z = _.matrixWorld.clone().invert().multiply(a), N = v / (h / 2);
2585
+ let v = m, O = n;
2586
+ m >= Math.floor(h / 2) && (v = h - m - 1, O *= -1);
2587
+ const Z = (o + x) * 0.5 + x * (v - 1), z = _.matrixWorld.clone().invert().multiply(a), N = v / (h / 2);
2561
2588
  i = this.m_BindingRadius * F(0.45, 0.65, 1 - N);
2562
2589
  for (let D = 0; D < w; D++) {
2563
- const C = f[D], V = new c.Vector3(0, 0, S.z + C), U = S.clone();
2564
- U.z += C;
2565
- const k = l.getDirection(C).multiplyScalar(i).add(U.clone());
2590
+ const C = f[D], I = new c.Vector3(0, 0, S.z + C), L = S.clone();
2591
+ L.z += C;
2592
+ const k = l.getDirection(C).multiplyScalar(i).add(L.clone());
2566
2593
  if (m === 0 && D === 0) {
2567
2594
  const A = t[h - 1], H = A.transform.position.clone().clone();
2568
2595
  H.z += C;
@@ -2572,17 +2599,17 @@ class Ae {
2572
2599
  s.x,
2573
2600
  0
2574
2601
  ).normalize().negate();
2575
- const I = Math.atan2(e.y, e.x) * it;
2576
- this.stapleMesh.rotation.set(0, 0, I * tt);
2602
+ const V = Math.atan2(e.y, e.x) * it;
2603
+ this.stapleMesh.rotation.set(0, 0, V * tt);
2577
2604
  }
2578
- v > 0 && V.add(e.clone().multiplyScalar(O));
2605
+ v > 0 && I.add(e.clone().multiplyScalar(Z));
2579
2606
  const Q = D * g;
2580
- d[Q] = V.clone().applyMatrix4(z), V.add(s.clone().multiplyScalar(Z));
2581
- const G = V.clone().applyMatrix4(z), $ = k.clone().applyMatrix4(z), j = U.clone().applyMatrix4(z);
2607
+ d[Q] = I.clone().applyMatrix4(z), I.add(s.clone().multiplyScalar(O));
2608
+ const G = I.clone().applyMatrix4(z), $ = k.clone().applyMatrix4(z), j = L.clone().applyMatrix4(z);
2582
2609
  d[Q + y[1]] = G;
2583
2610
  for (let A = 2; A < B; A++) {
2584
2611
  const M = jt(1, B, A);
2585
- d[Q + y[A]] = Xt(
2612
+ d[Q + y[A]] = Et(
2586
2613
  G,
2587
2614
  $,
2588
2615
  j,
@@ -2661,31 +2688,32 @@ export {
2661
2688
  rt as AutoTurnSetting,
2662
2689
  Me as AutoTurnSettingCurveTimeMode,
2663
2690
  ge as AutoTurnSettingMode,
2664
- Nt as AutoTurnSettings,
2665
- Ut as Book,
2691
+ Lt as AutoTurnSettings,
2692
+ Pt as Book,
2666
2693
  Pe as BookBinding,
2667
- Le as BookBound,
2668
- Ue as BookContent,
2669
- E as BookDirection,
2670
- Ze as BookHeightException,
2694
+ Ee as BookBound,
2695
+ Le as BookContent,
2696
+ X as BookDirection,
2697
+ Oe as BookHeightException,
2698
+ Ue as BookPointerInteraction,
2671
2699
  de as BookRenderer,
2672
2700
  ut as Cylinder,
2673
2701
  me as MeshFactory,
2674
2702
  Ne as PageContent,
2675
2703
  he as Paper,
2676
- wt as PaperBorder,
2677
- Dt as PaperMaterialData,
2704
+ Tt as PaperBorder,
2705
+ At as PaperMaterialData,
2678
2706
  Zt as PaperMeshData,
2679
2707
  fe as PaperMeshDataPool,
2680
2708
  Fe as PaperMeshUtility,
2681
2709
  st as PaperNode,
2682
2710
  le as PaperNodeMargin,
2683
2711
  ye as PaperPattern,
2684
- Pt as PaperSeam,
2712
+ wt as PaperSeam,
2685
2713
  ht as PaperSetup,
2686
2714
  gt as PaperUVMargin,
2687
2715
  ue as RendererFactory,
2688
- Lt as SpritePageContent2,
2716
+ Ut as SpritePageContent2,
2689
2717
  Xe as StapleBookBinding,
2690
2718
  Ae as StapleBookBound,
2691
2719
  ze as StapleSetup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectifthunes/three-book",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",