@objectifthunes/react-three-book 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +53 -0
- package/dist/index.js +360 -269
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as ht, useState as
|
|
3
|
-
import { useFrame as Pt, useThree as
|
|
1
|
+
import { jsxs as re, jsx as ae } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ht, useState as Jt, useEffect as yt, createContext as oe, useContext as te, forwardRef as he, useImperativeHandle as le, useCallback as rt, useMemo as ce } from "react";
|
|
3
|
+
import { useFrame as Pt, useThree as ue } from "@react-three/fiber";
|
|
4
4
|
import * as c from "three";
|
|
5
5
|
class pt {
|
|
6
6
|
constructor() {
|
|
@@ -69,7 +69,7 @@ class pt {
|
|
|
69
69
|
return t.m_PositionX = this.m_PositionX, t.m_PositionZ = this.m_PositionZ, t.m_DirectionX = this.m_DirectionX, t.m_DirectionZ = this.m_DirectionZ, t.m_EulerY = this.m_EulerY, t.m_Radius = this.m_Radius, t;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function Ct(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
73
73
|
s = Math.max(s, 1e-4);
|
|
74
74
|
const a = 2 / s, o = a * r, h = 1 / (1 + o + 0.48 * o * o + 0.235 * o * o * o);
|
|
75
75
|
let u = n - t;
|
|
@@ -80,22 +80,22 @@ function yt(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
|
80
80
|
let g = t + (u + f) * h;
|
|
81
81
|
return l - n > 0 == g > l && (g = l, e = (g - l) / r), { value: g, velocity: e };
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const a =
|
|
83
|
+
function me(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
84
|
+
const a = Ct(
|
|
85
85
|
n.x,
|
|
86
86
|
t.x,
|
|
87
87
|
e.x,
|
|
88
88
|
s.x,
|
|
89
89
|
i,
|
|
90
90
|
r
|
|
91
|
-
), o =
|
|
91
|
+
), o = Ct(
|
|
92
92
|
n.y,
|
|
93
93
|
t.y,
|
|
94
94
|
e.y,
|
|
95
95
|
s.y,
|
|
96
96
|
i,
|
|
97
97
|
r
|
|
98
|
-
), h =
|
|
98
|
+
), h = Ct(
|
|
99
99
|
n.z,
|
|
100
100
|
t.z,
|
|
101
101
|
e.z,
|
|
@@ -105,10 +105,10 @@ function ce(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
|
105
105
|
);
|
|
106
106
|
return e.set(a.velocity, o.velocity, h.velocity), new c.Vector3(a.value, o.value, h.value);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function de(n) {
|
|
109
109
|
return new c.Vector3(n.x, 0, n.y);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function _e(n) {
|
|
112
112
|
return new c.Vector3(n.x, n.z, 0);
|
|
113
113
|
}
|
|
114
114
|
function bt(n, t, e) {
|
|
@@ -127,19 +127,19 @@ function bt(n, t, e) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
function It(n, t, e) {
|
|
130
|
-
return
|
|
130
|
+
return fe(n, t, e) ? n.clone() : ge(
|
|
131
131
|
new c.Vector2(n.x, t.y),
|
|
132
132
|
n,
|
|
133
133
|
t,
|
|
134
134
|
e
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function fe(n, t, e) {
|
|
138
138
|
const s = n.x - t.x;
|
|
139
139
|
let i = n.y - t.y;
|
|
140
140
|
return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ge(n, t, e, s) {
|
|
143
143
|
const i = e.x, r = e.y, a = n.x, o = n.y, h = t.x, u = t.y, l = s.x, d = s.y, f = 1 / (l * l), g = 1 / (d * d);
|
|
144
144
|
if (Math.abs(a - h) < 1e-5) {
|
|
145
145
|
if (a >= i - l && a <= i + l) {
|
|
@@ -174,33 +174,33 @@ function zt(n, t) {
|
|
|
174
174
|
const e = n.origin.clone().applyMatrix4(t), s = n.origin.clone().add(n.direction).applyMatrix4(t);
|
|
175
175
|
return new c.Ray(e, s.sub(e));
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function pe(n) {
|
|
178
178
|
return new c.Vector4(-n.x, n.y, n.z + n.x, n.w);
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function xe(n) {
|
|
181
181
|
return new c.Vector4(n.x, -n.y, n.z, n.w + n.y);
|
|
182
182
|
}
|
|
183
183
|
var X = /* @__PURE__ */ ((n) => (n[n.LeftToRight = 0] = "LeftToRight", n[n.RightToLeft = 1] = "RightToLeft", n[n.UpToDown = 2] = "UpToDown", n[n.DownToUp = 3] = "DownToUp", n))(X || {});
|
|
184
|
-
const Rt = Math.PI / 180, Vt = 180 / Math.PI,
|
|
184
|
+
const Rt = Math.PI / 180, Vt = 180 / Math.PI, Me = 1192093e-13;
|
|
185
185
|
function xt(n) {
|
|
186
186
|
return n < 0 ? 0 : n > 1 ? 1 : n;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function At(n, t, e) {
|
|
189
189
|
return n < t ? t : n > e ? e : n;
|
|
190
190
|
}
|
|
191
191
|
function gt(n, t, e) {
|
|
192
192
|
return n !== t ? xt((e - n) / (t - n)) : 0;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function Dt(n, t, e) {
|
|
195
195
|
return n + (t - n) * e;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Ht(n, t, e) {
|
|
198
198
|
return n + (t - n) * e;
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function Ft(n, t, e) {
|
|
201
201
|
return e = xt((e - n) / (t - n)), e * e * (3 - 2 * e);
|
|
202
202
|
}
|
|
203
|
-
class
|
|
203
|
+
class we {
|
|
204
204
|
// ---- Constructor ----
|
|
205
205
|
constructor(t, e, s, i) {
|
|
206
206
|
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 pt(), 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;
|
|
@@ -354,7 +354,7 @@ class xe {
|
|
|
354
354
|
const t = new c.Vector3(0, 0, 0);
|
|
355
355
|
for (const e of this.m_HandleVelocities)
|
|
356
356
|
t.add(e);
|
|
357
|
-
t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime =
|
|
357
|
+
t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = Dt(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Called each frame while the user is dragging.
|
|
@@ -379,18 +379,18 @@ class xe {
|
|
|
379
379
|
let e = !1;
|
|
380
380
|
if (this.m_IsAutoTurning) {
|
|
381
381
|
let r = xt(this.m_FallTime / this.m_FallDuration);
|
|
382
|
-
r =
|
|
382
|
+
r = Ft(0, 1, r), r = Ft(0, 1, r), this.m_CurrentHandle.lerpVectors(
|
|
383
383
|
this.m_StartHandle,
|
|
384
384
|
this.m_EndHandle,
|
|
385
385
|
this.m_IsFallingLeft ? r : 1 - r
|
|
386
|
-
), this.m_FallTime += t, e = Math.abs(r - 1) <
|
|
386
|
+
), this.m_FallTime += t, e = Math.abs(r - 1) < Me;
|
|
387
387
|
} else {
|
|
388
388
|
const r = new c.Vector3(
|
|
389
389
|
this.m_FallTime,
|
|
390
390
|
0,
|
|
391
391
|
this.m_FallTime * 0.75
|
|
392
392
|
);
|
|
393
|
-
this.m_CurrentHandle =
|
|
393
|
+
this.m_CurrentHandle = me(
|
|
394
394
|
this.m_CurrentHandle,
|
|
395
395
|
this.m_EndHandle,
|
|
396
396
|
this.m_HandleVelocity,
|
|
@@ -493,7 +493,7 @@ class xe {
|
|
|
493
493
|
), this.m_SubMeshCount = t);
|
|
494
494
|
const e = this.m_FrontContent.textureST.clone();
|
|
495
495
|
let s = this.m_BackContent.textureST.clone();
|
|
496
|
-
this.m_Book.direction > 1 ? s =
|
|
496
|
+
this.m_Book.direction > 1 ? s = xe(s) : s = pe(s);
|
|
497
497
|
const i = this.m_FrontContent.texture, r = this.m_BackContent.texture;
|
|
498
498
|
if (t === 3) {
|
|
499
499
|
let a = 0, o = 1;
|
|
@@ -535,7 +535,7 @@ class xe {
|
|
|
535
535
|
const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
|
|
536
536
|
new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
|
|
537
537
|
);
|
|
538
|
-
this.m_XTime =
|
|
538
|
+
this.m_XTime = Dt(
|
|
539
539
|
Math.min(t, e),
|
|
540
540
|
Math.max(t, e),
|
|
541
541
|
0.9
|
|
@@ -561,8 +561,8 @@ class xe {
|
|
|
561
561
|
0,
|
|
562
562
|
h + (s.z - h) * (o / r)
|
|
563
563
|
), d = new c.Vector2(i, a), f = new c.Vector2(r, o);
|
|
564
|
-
t.x =
|
|
565
|
-
const g =
|
|
564
|
+
t.x = At(t.x, -this.m_Size.x, this.m_Size.x);
|
|
565
|
+
const g = _e(t), m = It(
|
|
566
566
|
new c.Vector2(g.x, g.y),
|
|
567
567
|
u,
|
|
568
568
|
d
|
|
@@ -570,7 +570,7 @@ class xe {
|
|
|
570
570
|
new c.Vector2(m.x, m.y),
|
|
571
571
|
l,
|
|
572
572
|
f
|
|
573
|
-
), p =
|
|
573
|
+
), p = de(
|
|
574
574
|
new c.Vector3(_.x, _.y, 0)
|
|
575
575
|
);
|
|
576
576
|
this.m_CurrentHandle.copy(p);
|
|
@@ -611,8 +611,8 @@ class xe {
|
|
|
611
611
|
/* Highpoly */
|
|
612
612
|
), (u = this.m_Prev) == null || u.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;
|
|
613
613
|
const r = this.m_Size.x, a = this.m_Size.y;
|
|
614
|
-
e =
|
|
615
|
-
const o =
|
|
614
|
+
e = At(e, -0.99, 0.99);
|
|
615
|
+
const o = Ht(0.5, 1, e), h = Ht(0.5, 0, e);
|
|
616
616
|
this.m_StartHandle.set(r, 0, a * o), this.m_EndHandle.set(-r, 0, a * h), this.m_IsAutoTurning = !0;
|
|
617
617
|
}
|
|
618
618
|
// ---- Public getter for the cylinder (used by BookBound etc.) ----
|
|
@@ -887,7 +887,7 @@ class St {
|
|
|
887
887
|
);
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
class
|
|
890
|
+
class ye {
|
|
891
891
|
constructor(t, e, s) {
|
|
892
892
|
const i = t.size;
|
|
893
893
|
this.leftNode = new it(e.left * i.x, s, !0), this.rightNode = new it((1 - e.right) * i.x, s, !0), this.downNode = new it(e.down * i.y, s, !0), this.upNode = new it((1 - e.up) * i.y, s, !0);
|
|
@@ -912,7 +912,7 @@ function Nt(n, t, e, s, i) {
|
|
|
912
912
|
if (!r.active) return;
|
|
913
913
|
for (let a = 0; a < s; a++) {
|
|
914
914
|
const o = r.prevIndex, h = r.nextIndex, u = t[a * e + o], l = t[a * e + h], d = t[a * e + r.index];
|
|
915
|
-
i ?
|
|
915
|
+
i ? ee(u, l, r.time, d) : d.copy(u).lerp(l, r.time);
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
}
|
|
@@ -921,11 +921,11 @@ function Ut(n, t, e, s, i) {
|
|
|
921
921
|
if (!r.active) return;
|
|
922
922
|
for (let a = 0; a < e; a++) {
|
|
923
923
|
const o = r.prevIndex, h = r.nextIndex, u = t[o * e + a], l = t[h * e + a], d = t[r.index * e + a];
|
|
924
|
-
i ?
|
|
924
|
+
i ? ee(u, l, r.time, d) : d.copy(u).lerp(l, r.time);
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
-
function
|
|
928
|
+
function ee(n, t, e, s = new c.Vector3()) {
|
|
929
929
|
const i = Math.sqrt(n.x * n.x + n.y * n.y + n.z * n.z), r = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
|
|
930
930
|
if (i === 0 || r === 0)
|
|
931
931
|
return s.copy(n).lerp(t, e);
|
|
@@ -942,7 +942,7 @@ function te(n, t, e, s = new c.Vector3()) {
|
|
|
942
942
|
(h * _ + d * p) * T
|
|
943
943
|
);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function Ce(n, t, e, s, i) {
|
|
946
946
|
for (const r of n) {
|
|
947
947
|
const a = (r.endX - r.startX + 1) * 2, o = (r.endZ - r.startZ + 1) * 2, h = e.length;
|
|
948
948
|
for (let l = 0, d = r.endX - r.startX; l < d; l++) {
|
|
@@ -978,7 +978,7 @@ function we(n, t, e, s, i) {
|
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function Te(n, t, e, s, i) {
|
|
982
982
|
const r = s * i;
|
|
983
983
|
let a = r * 2;
|
|
984
984
|
const o = new c.Vector3();
|
|
@@ -1007,10 +1007,10 @@ function Et(n, t, e, s, i, r) {
|
|
|
1007
1007
|
function Xt(n, t, e, s, i, r) {
|
|
1008
1008
|
wt(n, t, e, s, i), t += r, e += r, s += r, i += r, wt(n, t, e, s, i);
|
|
1009
1009
|
}
|
|
1010
|
-
function
|
|
1010
|
+
function Pe(n, t, e, s, i, r, a) {
|
|
1011
1011
|
Mt(n, e, s, i, r), e += a, s += a, i += a, r += a, wt(t, e, s, i, r);
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1013
|
+
function ve(n, t, e, s, i, r) {
|
|
1014
1014
|
const a = i.left * s.x, o = (1 - i.right) * s.x, h = i.down * s.y, u = (1 - i.up) * s.y, l = t.length, d = e.length;
|
|
1015
1015
|
if (r > 1)
|
|
1016
1016
|
for (let g = 0; g < d; g++)
|
|
@@ -1034,7 +1034,7 @@ function Mt(n, t, e, s, i) {
|
|
|
1034
1034
|
function wt(n, t, e, s, i) {
|
|
1035
1035
|
n.push(t), n.push(e), n.push(s), n.push(e), n.push(i), n.push(s);
|
|
1036
1036
|
}
|
|
1037
|
-
function
|
|
1037
|
+
function Se(n, t, e, s) {
|
|
1038
1038
|
const i = [];
|
|
1039
1039
|
for (let r = 0; r < e - 1; r++)
|
|
1040
1040
|
for (let a = 0; a < t - 1; a++) {
|
|
@@ -1043,7 +1043,7 @@ function Pe(n, t, e, s) {
|
|
|
1043
1043
|
}
|
|
1044
1044
|
return i;
|
|
1045
1045
|
}
|
|
1046
|
-
class
|
|
1046
|
+
class Wt {
|
|
1047
1047
|
get geometry() {
|
|
1048
1048
|
return this.m_Geometry;
|
|
1049
1049
|
}
|
|
@@ -1123,8 +1123,8 @@ class jt {
|
|
|
1123
1123
|
for (let m = 0; m < a - 1; m++) {
|
|
1124
1124
|
const _ = m + 1;
|
|
1125
1125
|
for (let p = 0; p < r - 1; p++) {
|
|
1126
|
-
const T = p + 1, b = m * r + p, M = m * r + T,
|
|
1127
|
-
Zt(k, Z, O, h), Zt(V, O, Z, u), l.addVectors(h, u), s[b].add(l), s[M].add(l), s[
|
|
1126
|
+
const T = p + 1, b = m * r + p, M = m * r + T, y = _ * r + p, v = _ * r + T, k = t[b], O = t[M], Z = t[y], V = t[v];
|
|
1127
|
+
Zt(k, Z, O, h), Zt(V, O, Z, u), l.addVectors(h, u), s[b].add(l), s[M].add(l), s[y].add(l), s[v].add(l);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
for (let m = 0; m < o; m++)
|
|
@@ -1137,7 +1137,7 @@ class jt {
|
|
|
1137
1137
|
const p = t[m];
|
|
1138
1138
|
e[m].copy(p).addScaledVector(_, d), e[m + o].copy(p).addScaledVector(_, -d);
|
|
1139
1139
|
}
|
|
1140
|
-
|
|
1140
|
+
Te(this.m_Pattern.borders, e, s, r, a);
|
|
1141
1141
|
const f = this.m_Geometry.getAttribute(
|
|
1142
1142
|
"position"
|
|
1143
1143
|
), g = this.m_Geometry.getAttribute(
|
|
@@ -1159,10 +1159,10 @@ class jt {
|
|
|
1159
1159
|
*/
|
|
1160
1160
|
drawWireframe(t) {
|
|
1161
1161
|
const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
|
|
1162
|
-
return
|
|
1162
|
+
return Se(this.m_Vertices, e, s, t);
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
-
class
|
|
1165
|
+
class ke {
|
|
1166
1166
|
constructor() {
|
|
1167
1167
|
this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
|
|
1168
1168
|
}
|
|
@@ -1181,7 +1181,7 @@ class ve {
|
|
|
1181
1181
|
this.m_Meshs.clear();
|
|
1182
1182
|
}
|
|
1183
1183
|
}
|
|
1184
|
-
class
|
|
1184
|
+
class Be {
|
|
1185
1185
|
constructor(t) {
|
|
1186
1186
|
this.m_CreateMeshCollider = !1, this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
|
|
1187
1187
|
}
|
|
@@ -1193,7 +1193,7 @@ class Se {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
get(t) {
|
|
1195
1195
|
let e;
|
|
1196
|
-
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new
|
|
1196
|
+
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new Ie(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
|
|
1197
1197
|
}
|
|
1198
1198
|
recycle() {
|
|
1199
1199
|
for (const t of this.m_UsedRenderers)
|
|
@@ -1213,10 +1213,10 @@ class Se {
|
|
|
1213
1213
|
return t;
|
|
1214
1214
|
}
|
|
1215
1215
|
}
|
|
1216
|
-
let
|
|
1217
|
-
class
|
|
1216
|
+
let be = 1;
|
|
1217
|
+
class Ie {
|
|
1218
1218
|
constructor(t, e, s) {
|
|
1219
|
-
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id =
|
|
1219
|
+
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = be++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
|
|
1220
1220
|
new c.BufferGeometry(),
|
|
1221
1221
|
new c.MeshStandardMaterial()
|
|
1222
1222
|
), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
|
|
@@ -1320,20 +1320,20 @@ class Be {
|
|
|
1320
1320
|
e.dispose();
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
|
-
class
|
|
1323
|
+
class ze {
|
|
1324
1324
|
constructor(t, e, s = !1) {
|
|
1325
|
-
this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new
|
|
1325
|
+
this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Wt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
|
|
1326
1326
|
}
|
|
1327
1327
|
get() {
|
|
1328
|
-
return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new
|
|
1328
|
+
return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Wt(this.m_MeshFactory.get(), this.m_Pattern);
|
|
1329
1329
|
}
|
|
1330
1330
|
free(t) {
|
|
1331
1331
|
if (this.m_UseSharedData) throw new Error("Not implemented");
|
|
1332
1332
|
this.m_Stack.push(t);
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
|
-
var dt = /* @__PURE__ */ ((n) => (n[n.Next = 0] = "Next", n[n.Back = 1] = "Back", n))(dt || {}),
|
|
1336
|
-
class
|
|
1335
|
+
var dt = /* @__PURE__ */ ((n) => (n[n.Next = 0] = "Next", n[n.Back = 1] = "Back", n))(dt || {}), Re = /* @__PURE__ */ ((n) => (n[n.Surface = 0] = "Surface", n[n.Edge = 1] = "Edge", n))(Re || {}), Ve = /* @__PURE__ */ ((n) => (n[n.Constant = 0] = "Constant", n[n.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", n[n.Curve = 2] = "Curve", n[n.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", n))(Ve || {}), Ae = /* @__PURE__ */ ((n) => (n[n.PaperIndexTime = 0] = "PaperIndexTime", n[n.TurnIndexTime = 1] = "TurnIndexTime", n))(Ae || {});
|
|
1336
|
+
class De {
|
|
1337
1337
|
constructor(t) {
|
|
1338
1338
|
this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
|
|
1339
1339
|
}
|
|
@@ -1358,10 +1358,10 @@ class Ve {
|
|
|
1358
1358
|
function at(n, t, e) {
|
|
1359
1359
|
return Math.max(t, Math.min(e, n));
|
|
1360
1360
|
}
|
|
1361
|
-
function
|
|
1361
|
+
function He(n, t, e) {
|
|
1362
1362
|
return n === t ? 0 : at((e - n) / (t - n), 0, 1);
|
|
1363
1363
|
}
|
|
1364
|
-
function
|
|
1364
|
+
function jt(n, t) {
|
|
1365
1365
|
return n + Math.random() * (t - n);
|
|
1366
1366
|
}
|
|
1367
1367
|
class ot {
|
|
@@ -1432,12 +1432,12 @@ class ot {
|
|
|
1432
1432
|
getValue(t, e) {
|
|
1433
1433
|
if (this.m_Mode === 0) return this.m_Constant;
|
|
1434
1434
|
if (this.m_Mode === 1)
|
|
1435
|
-
return
|
|
1435
|
+
return jt(this.m_ConstantMin, this.m_ConstantMax);
|
|
1436
1436
|
const s = this.m_CurveTimeMode === 0 ? t : e;
|
|
1437
1437
|
if (this.m_Mode === 2)
|
|
1438
1438
|
return this.m_Curve.evaluate(s);
|
|
1439
1439
|
if (this.m_Mode === 3)
|
|
1440
|
-
return
|
|
1440
|
+
return jt(
|
|
1441
1441
|
this.m_CurveMin.evaluate(s),
|
|
1442
1442
|
this.m_CurveMax.evaluate(s)
|
|
1443
1443
|
);
|
|
@@ -1457,9 +1457,9 @@ class ot {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
for (let h = 0; h < r; h++) {
|
|
1459
1459
|
let u = i[h].time, l = i[h].value;
|
|
1460
|
-
u =
|
|
1460
|
+
u = He(a, o, u), l = at(l, e, s), i[h].time = u, i[h].value = l;
|
|
1461
1461
|
}
|
|
1462
|
-
return new
|
|
1462
|
+
return new De(i);
|
|
1463
1463
|
}
|
|
1464
1464
|
// ── Value-type clone ────────────────────────────────────────────────────
|
|
1465
1465
|
clone() {
|
|
@@ -1536,7 +1536,7 @@ const I = class I {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
};
|
|
1538
1538
|
I.kMinTwist = -1, I.kMaxTwist = 1, I.kMinBend = 0, I.kMaxBend = 1, I.kMinDuration = 0, I.kMaxDuration = 5;
|
|
1539
|
-
let ut = I,
|
|
1539
|
+
let ut = I, ds = class extends Error {
|
|
1540
1540
|
constructor() {
|
|
1541
1541
|
super(
|
|
1542
1542
|
"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."
|
|
@@ -1544,7 +1544,7 @@ let ut = I, us = class extends Error {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
};
|
|
1546
1546
|
var K;
|
|
1547
|
-
let
|
|
1547
|
+
let Fe = (K = class extends c.Group {
|
|
1548
1548
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
1549
1549
|
constructor(t) {
|
|
1550
1550
|
super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_CreateColliders = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new ct({
|
|
@@ -1812,9 +1812,9 @@ let Ae = (K = class extends c.Group {
|
|
|
1812
1812
|
// ── Build ─────────────────────────────────────────────────────────────
|
|
1813
1813
|
build() {
|
|
1814
1814
|
if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
|
|
1815
|
-
if (this.m_MeshFactory === null && (this.m_MeshFactory = new
|
|
1815
|
+
if (this.m_MeshFactory === null && (this.m_MeshFactory = new ke()), this.m_RendererFactory === null) {
|
|
1816
1816
|
const w = new c.Object3D();
|
|
1817
|
-
w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new
|
|
1817
|
+
w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new Be(this.m_Root);
|
|
1818
1818
|
}
|
|
1819
1819
|
this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
|
|
1820
1820
|
const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
|
|
@@ -1827,7 +1827,7 @@ let Ae = (K = class extends c.Group {
|
|
|
1827
1827
|
let u = 0, l = 0, d = 0;
|
|
1828
1828
|
this.m_Papers = new Array(o);
|
|
1829
1829
|
for (let w = 0; w < o; w++) {
|
|
1830
|
-
const z = this.m_HasCover && (w < h || w >= o - h), N = this.m_RendererFactory.get("Paper"), S = this.m_Papers[w] = new
|
|
1830
|
+
const z = this.m_HasCover && (w < h || w >= o - h), N = this.m_RendererFactory.get("Paper"), S = this.m_Papers[w] = new we(z, w, this, N);
|
|
1831
1831
|
S.renderer.castShadows = this.m_CastShadows, w < Math.round(c.MathUtils.lerp(0, o, a)) && (S.transform.scale.set(-1, 1, 1), S.setTime(1)), z ? (S.setContentData(i[l++], i[l++], w > h), S.setMaterialData(e), S.setPaperSetup(this.m_CoverPaperSetup)) : (S.setContentData(r[u++], r[u++]), S.setMaterialData(s), S.setPaperSetup(this.m_PagePaperSetup)), d += S.thickness;
|
|
1832
1832
|
}
|
|
1833
1833
|
this.m_TotalThickness = d;
|
|
@@ -1842,11 +1842,11 @@ let Ae = (K = class extends c.Group {
|
|
|
1842
1842
|
this.m_RendererFactory,
|
|
1843
1843
|
this.m_MeshFactory
|
|
1844
1844
|
), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
|
|
1845
|
-
const b = this.m_ReduceOverdraw && r.length > 0, M = this.m_ReduceSubMeshes,
|
|
1845
|
+
const b = this.m_ReduceOverdraw && r.length > 0, M = this.m_ReduceSubMeshes, y = 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(o / 2) - 1, L = V + 1, A = this.m_Bound.constructor.name.includes("Staple");
|
|
1846
1846
|
for (let w = 0; w < o; w++) {
|
|
1847
1847
|
const z = this.m_Papers[w];
|
|
1848
|
-
w !== 0 && (z.prev = this.m_Papers[w - 1]), w !== o - 1 && (z.next = this.m_Papers[w + 1]), z.noHole =
|
|
1849
|
-
|
|
1848
|
+
w !== 0 && (z.prev = this.m_Papers[w - 1]), w !== o - 1 && (z.next = this.m_Papers[w + 1]), z.noHole = A && (w === V || w === L), z.isCover ? z.setMeshData(O.get(), null, Z) : z.setMeshData(
|
|
1849
|
+
y.get(),
|
|
1850
1850
|
(v == null ? void 0 : v.get()) ?? null,
|
|
1851
1851
|
k
|
|
1852
1852
|
);
|
|
@@ -1868,7 +1868,7 @@ let Ae = (K = class extends c.Group {
|
|
|
1868
1868
|
i,
|
|
1869
1869
|
s
|
|
1870
1870
|
);
|
|
1871
|
-
return new
|
|
1871
|
+
return new ze(
|
|
1872
1872
|
this.m_MeshFactory,
|
|
1873
1873
|
a,
|
|
1874
1874
|
e && this.m_Bound.useSharedMeshDataForLowpoly
|
|
@@ -1922,10 +1922,10 @@ let Ae = (K = class extends c.Group {
|
|
|
1922
1922
|
s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
|
|
1923
1923
|
}
|
|
1924
1924
|
}, K.s_Instances = /* @__PURE__ */ new Set(), K);
|
|
1925
|
-
function
|
|
1926
|
-
const s = ht(null), [i, r] =
|
|
1927
|
-
return
|
|
1928
|
-
const a = new
|
|
1925
|
+
function Oe(n, t, e) {
|
|
1926
|
+
const s = ht(null), [i, r] = Jt(!1);
|
|
1927
|
+
return yt(() => {
|
|
1928
|
+
const a = new Fe(n);
|
|
1929
1929
|
s.current = a;
|
|
1930
1930
|
try {
|
|
1931
1931
|
a.init(), r(!0), t == null || t(a);
|
|
@@ -1940,26 +1940,26 @@ function Fe(n, t, e) {
|
|
|
1940
1940
|
(h = s.current) == null || h.update(o);
|
|
1941
1941
|
}), { bookRef: s, ready: i };
|
|
1942
1942
|
}
|
|
1943
|
-
const kt =
|
|
1943
|
+
const kt = oe(null);
|
|
1944
1944
|
function _t() {
|
|
1945
|
-
return
|
|
1945
|
+
return te(kt);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1948
|
-
const n =
|
|
1947
|
+
function fs() {
|
|
1948
|
+
const n = te(kt);
|
|
1949
1949
|
if (!n)
|
|
1950
1950
|
throw new Error("useRequiredBook() must be called inside a <Book> component.");
|
|
1951
1951
|
return n;
|
|
1952
1952
|
}
|
|
1953
|
-
const
|
|
1954
|
-
const { bookRef: a, ready: o } =
|
|
1955
|
-
return
|
|
1956
|
-
/* @__PURE__ */
|
|
1953
|
+
const gs = he(function({ onBuilt: t, onError: e, children: s, ...i }, r) {
|
|
1954
|
+
const { bookRef: a, ready: o } = Oe(i, t, e);
|
|
1955
|
+
return le(r, () => a.current, [o]), !o || !a.current ? null : /* @__PURE__ */ re(kt.Provider, { value: a.current, children: [
|
|
1956
|
+
/* @__PURE__ */ ae("primitive", { object: a.current }),
|
|
1957
1957
|
s
|
|
1958
1958
|
] });
|
|
1959
1959
|
});
|
|
1960
|
-
function
|
|
1961
|
-
const { gl: s, camera: i } =
|
|
1962
|
-
o.current = t,
|
|
1960
|
+
function Ze(n, { enabled: t = !0, orbitControlsRef: e } = {}) {
|
|
1961
|
+
const { gl: s, camera: i } = ue(), r = ht(!1), a = ht(null), o = ht(t);
|
|
1962
|
+
o.current = t, yt(() => {
|
|
1963
1963
|
const h = s.domElement, u = new c.Raycaster(), l = new c.Vector2(), d = (_) => {
|
|
1964
1964
|
const p = h.getBoundingClientRect();
|
|
1965
1965
|
return l.set(
|
|
@@ -1981,11 +1981,11 @@ function He(n, { enabled: t = !0, orbitControlsRef: e } = {}) {
|
|
|
1981
1981
|
};
|
|
1982
1982
|
}, [s, i, n, e]);
|
|
1983
1983
|
}
|
|
1984
|
-
function
|
|
1984
|
+
function ps({ bookRef: n, enabled: t = !0, orbitControlsRef: e }) {
|
|
1985
1985
|
const s = _t(), i = ht(null);
|
|
1986
|
-
return i.current = (n == null ? void 0 : n.current) ?? s,
|
|
1986
|
+
return i.current = (n == null ? void 0 : n.current) ?? s, Ze(i, { enabled: t, orbitControlsRef: e }), null;
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1988
|
+
function xs(n) {
|
|
1989
1989
|
const t = _t(), e = rt(
|
|
1990
1990
|
(r) => {
|
|
1991
1991
|
var a;
|
|
@@ -2007,7 +2007,7 @@ function gs(n) {
|
|
|
2007
2007
|
);
|
|
2008
2008
|
return { setOpenProgress: e, setOpenProgressByIndex: s, stopTurning: i };
|
|
2009
2009
|
}
|
|
2010
|
-
function
|
|
2010
|
+
function Ms(n) {
|
|
2011
2011
|
const t = _t(), e = () => (n == null ? void 0 : n.current) ?? t, s = rt(
|
|
2012
2012
|
(h) => {
|
|
2013
2013
|
var u;
|
|
@@ -2046,7 +2046,7 @@ function ps(n) {
|
|
|
2046
2046
|
);
|
|
2047
2047
|
return { turnNext: s, turnPrev: i, turnAll: r, startAutoTurning: a, cancelPendingAutoTurns: o };
|
|
2048
2048
|
}
|
|
2049
|
-
const
|
|
2049
|
+
const Le = {
|
|
2050
2050
|
isBuilt: !1,
|
|
2051
2051
|
isTurning: !1,
|
|
2052
2052
|
isFalling: !1,
|
|
@@ -2057,7 +2057,7 @@ const Oe = {
|
|
|
2057
2057
|
coverPaperCount: 0,
|
|
2058
2058
|
pagePaperCount: 0
|
|
2059
2059
|
};
|
|
2060
|
-
function
|
|
2060
|
+
function Ne(n) {
|
|
2061
2061
|
return {
|
|
2062
2062
|
isBuilt: n.isBuilt,
|
|
2063
2063
|
isTurning: n.isTurning,
|
|
@@ -2070,32 +2070,32 @@ function Ze(n) {
|
|
|
2070
2070
|
pagePaperCount: n.pagePaperCount
|
|
2071
2071
|
};
|
|
2072
2072
|
}
|
|
2073
|
-
function
|
|
2073
|
+
function Ue(n, t) {
|
|
2074
2074
|
return n.isBuilt === t.isBuilt && n.isTurning === t.isTurning && n.isFalling === t.isFalling && n.isIdle === t.isIdle && n.isAutoTurning === t.isAutoTurning && n.hasPendingAutoTurns === t.hasPendingAutoTurns && n.paperCount === t.paperCount && n.coverPaperCount === t.coverPaperCount && n.pagePaperCount === t.pagePaperCount;
|
|
2075
2075
|
}
|
|
2076
|
-
function
|
|
2077
|
-
const t = _t(), [e, s] =
|
|
2076
|
+
function ws(n) {
|
|
2077
|
+
const t = _t(), [e, s] = Jt(Le);
|
|
2078
2078
|
return Pt(() => {
|
|
2079
2079
|
const i = (n == null ? void 0 : n.current) ?? t;
|
|
2080
2080
|
if (!i) return;
|
|
2081
|
-
const r =
|
|
2082
|
-
s((a) =>
|
|
2081
|
+
const r = Ne(i);
|
|
2082
|
+
s((a) => Ue(a, r) ? a : r);
|
|
2083
2083
|
}), e;
|
|
2084
2084
|
}
|
|
2085
|
-
function
|
|
2085
|
+
function Ee(n) {
|
|
2086
2086
|
return [...n.covers, ...n.pages].filter((e) => e instanceof c.Texture);
|
|
2087
2087
|
}
|
|
2088
|
-
function
|
|
2089
|
-
const e = ht([]), s =
|
|
2088
|
+
function ys(n, t) {
|
|
2089
|
+
const e = ht([]), s = ce(() => {
|
|
2090
2090
|
for (const r of e.current) r.dispose();
|
|
2091
2091
|
const i = n();
|
|
2092
|
-
return e.current =
|
|
2092
|
+
return e.current = Ee(i), i;
|
|
2093
2093
|
}, t);
|
|
2094
|
-
return
|
|
2094
|
+
return yt(() => () => {
|
|
2095
2095
|
for (const i of e.current) i.dispose();
|
|
2096
2096
|
}, []), s;
|
|
2097
2097
|
}
|
|
2098
|
-
class
|
|
2098
|
+
class se {
|
|
2099
2099
|
constructor(t) {
|
|
2100
2100
|
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;
|
|
2101
2101
|
}
|
|
@@ -2160,10 +2160,10 @@ class Ue {
|
|
|
2160
2160
|
t.restore();
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
|
-
function
|
|
2163
|
+
function Xe(n) {
|
|
2164
2164
|
return n.map instanceof c.Texture;
|
|
2165
2165
|
}
|
|
2166
|
-
class
|
|
2166
|
+
class We {
|
|
2167
2167
|
constructor(t) {
|
|
2168
2168
|
this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
|
|
2169
2169
|
const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
|
|
@@ -2187,7 +2187,7 @@ class Xe {
|
|
|
2187
2187
|
}
|
|
2188
2188
|
// ── Text API ─────────────────────────────────────────────────────────────
|
|
2189
2189
|
addText(t) {
|
|
2190
|
-
const e = new
|
|
2190
|
+
const e = new se(t);
|
|
2191
2191
|
return this.texts.push(e), e;
|
|
2192
2192
|
}
|
|
2193
2193
|
removeText(t) {
|
|
@@ -2223,7 +2223,7 @@ class Xe {
|
|
|
2223
2223
|
if (!e.isMesh) return;
|
|
2224
2224
|
const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
|
|
2225
2225
|
for (const r of i)
|
|
2226
|
-
|
|
2226
|
+
Xe(r) && r.map.image === this.canvas && (r.map.needsUpdate = !0);
|
|
2227
2227
|
});
|
|
2228
2228
|
}
|
|
2229
2229
|
// ── IPageContent ─────────────────────────────────────────────────────────
|
|
@@ -2238,13 +2238,13 @@ class Xe {
|
|
|
2238
2238
|
this._texture.dispose();
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
|
-
function
|
|
2241
|
+
function Cs(n) {
|
|
2242
2242
|
const t = ht(null);
|
|
2243
|
-
t.current || (t.current = new
|
|
2243
|
+
t.current || (t.current = new We(n));
|
|
2244
2244
|
const e = t.current, s = _t();
|
|
2245
2245
|
return Pt(() => {
|
|
2246
2246
|
e.update(s ?? void 0);
|
|
2247
|
-
}),
|
|
2247
|
+
}), yt(() => () => {
|
|
2248
2248
|
e.dispose();
|
|
2249
2249
|
}, [e]), e;
|
|
2250
2250
|
}
|
|
@@ -2259,7 +2259,7 @@ function je(n, t, e, s, i, r, a) {
|
|
|
2259
2259
|
n.drawImage(t, e + (i - l) * 0.5, s + (r - d) * 0.5, l, d);
|
|
2260
2260
|
}
|
|
2261
2261
|
const Gt = 256;
|
|
2262
|
-
function
|
|
2262
|
+
function Ts(n, t, e, s, i, r, a) {
|
|
2263
2263
|
const o = r ? Math.round(r * Gt) : 512, h = a ? Math.round(a * Gt) : 512, u = document.createElement("canvas");
|
|
2264
2264
|
u.width = o, u.height = h;
|
|
2265
2265
|
const l = u.getContext("2d");
|
|
@@ -2274,7 +2274,7 @@ function Cs(n, t, e, s, i, r, a) {
|
|
|
2274
2274
|
const d = new c.CanvasTexture(u);
|
|
2275
2275
|
return d.colorSpace = c.SRGBColorSpace, d;
|
|
2276
2276
|
}
|
|
2277
|
-
async function
|
|
2277
|
+
async function Ps(n) {
|
|
2278
2278
|
if (!n) return null;
|
|
2279
2279
|
const t = URL.createObjectURL(n), e = new Image();
|
|
2280
2280
|
e.decoding = "async", e.src = t;
|
|
@@ -2286,7 +2286,7 @@ async function ys(n) {
|
|
|
2286
2286
|
return URL.revokeObjectURL(t), console.error(s), null;
|
|
2287
2287
|
}
|
|
2288
2288
|
}
|
|
2289
|
-
class
|
|
2289
|
+
class vs {
|
|
2290
2290
|
constructor() {
|
|
2291
2291
|
this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
|
|
2292
2292
|
}
|
|
@@ -2339,7 +2339,7 @@ class qt {
|
|
|
2339
2339
|
setActive(t) {
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
|
-
class
|
|
2342
|
+
class Ss {
|
|
2343
2343
|
constructor() {
|
|
2344
2344
|
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;
|
|
2345
2345
|
}
|
|
@@ -2440,9 +2440,9 @@ class Ps {
|
|
|
2440
2440
|
return !this.isCoverPaperSideIndex(t);
|
|
2441
2441
|
}
|
|
2442
2442
|
}
|
|
2443
|
-
class
|
|
2443
|
+
class Ge {
|
|
2444
2444
|
}
|
|
2445
|
-
class
|
|
2445
|
+
class ks {
|
|
2446
2446
|
constructor(t, e) {
|
|
2447
2447
|
this.m_Book = t, this.m_Root = e;
|
|
2448
2448
|
}
|
|
@@ -2458,28 +2458,28 @@ function Qt(n, t, e, s) {
|
|
|
2458
2458
|
function $t(n, t) {
|
|
2459
2459
|
return n++, n === t ? 0 : n;
|
|
2460
2460
|
}
|
|
2461
|
-
function
|
|
2461
|
+
function qe(n, t) {
|
|
2462
2462
|
return n === 0 ? t - 1 : n - 1;
|
|
2463
2463
|
}
|
|
2464
|
-
class
|
|
2464
|
+
class Qe {
|
|
2465
2465
|
constructor() {
|
|
2466
2466
|
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;
|
|
2467
2467
|
}
|
|
2468
2468
|
}
|
|
2469
|
-
const
|
|
2469
|
+
const $e = 0.01, Ye = 0.1, Ke = 0.04, Je = 0.4, ts = 2, es = 10, ss = 0, is = 5;
|
|
2470
2470
|
function st(n, t, e) {
|
|
2471
2471
|
return Math.max(t, Math.min(e, n));
|
|
2472
2472
|
}
|
|
2473
|
-
function
|
|
2473
|
+
function ie(n) {
|
|
2474
2474
|
return Math.max(0, Math.min(1, n));
|
|
2475
2475
|
}
|
|
2476
|
-
function
|
|
2476
|
+
function F(n, t, e) {
|
|
2477
2477
|
return n + (t - n) * e;
|
|
2478
2478
|
}
|
|
2479
2479
|
function Yt(n, t, e) {
|
|
2480
|
-
return n === t ? 0 :
|
|
2480
|
+
return n === t ? 0 : ie((e - n) / (t - n));
|
|
2481
2481
|
}
|
|
2482
|
-
function
|
|
2482
|
+
function ns(n, t) {
|
|
2483
2483
|
const e = n.clone().normalize();
|
|
2484
2484
|
if (e.lengthSq() === 0) return new c.Quaternion();
|
|
2485
2485
|
let s = new c.Vector3().crossVectors(t, e);
|
|
@@ -2492,7 +2492,7 @@ function is(n, t) {
|
|
|
2492
2492
|
return new c.Quaternion().setFromRotationMatrix(r);
|
|
2493
2493
|
}
|
|
2494
2494
|
const et = Math.PI / 180, nt = 180 / Math.PI;
|
|
2495
|
-
class
|
|
2495
|
+
class rs {
|
|
2496
2496
|
constructor() {
|
|
2497
2497
|
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;
|
|
2498
2498
|
}
|
|
@@ -2512,43 +2512,43 @@ class ns {
|
|
|
2512
2512
|
return this._thickness;
|
|
2513
2513
|
}
|
|
2514
2514
|
set thickness(t) {
|
|
2515
|
-
this._thickness = st(t,
|
|
2515
|
+
this._thickness = st(t, $e, Ye);
|
|
2516
2516
|
}
|
|
2517
2517
|
get margin() {
|
|
2518
2518
|
return this._margin;
|
|
2519
2519
|
}
|
|
2520
2520
|
set margin(t) {
|
|
2521
|
-
this._margin =
|
|
2521
|
+
this._margin = ie(t);
|
|
2522
2522
|
}
|
|
2523
2523
|
get crown() {
|
|
2524
2524
|
return this._crown;
|
|
2525
2525
|
}
|
|
2526
2526
|
set crown(t) {
|
|
2527
|
-
this._crown = st(t,
|
|
2527
|
+
this._crown = st(t, Ke, Je);
|
|
2528
2528
|
}
|
|
2529
2529
|
get count() {
|
|
2530
2530
|
return this._count;
|
|
2531
2531
|
}
|
|
2532
2532
|
set count(t) {
|
|
2533
|
-
this._count = st(t,
|
|
2533
|
+
this._count = st(t, ts, es);
|
|
2534
2534
|
}
|
|
2535
2535
|
get quality() {
|
|
2536
2536
|
return this._quality;
|
|
2537
2537
|
}
|
|
2538
2538
|
set quality(t) {
|
|
2539
|
-
this._quality = st(t,
|
|
2539
|
+
this._quality = st(t, ss, is);
|
|
2540
2540
|
}
|
|
2541
2541
|
}
|
|
2542
|
-
class
|
|
2542
|
+
class as extends Error {
|
|
2543
2543
|
constructor() {
|
|
2544
2544
|
super("Book height is too large relative to paper width."), this.name = "BookHeightException";
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
2547
|
-
class
|
|
2547
|
+
class os {
|
|
2548
2548
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
2549
2549
|
constructor(t, e, s, i, r) {
|
|
2550
2550
|
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)
|
|
2551
|
-
throw new
|
|
2551
|
+
throw new as();
|
|
2552
2552
|
const a = this.m_Book.coverPaperSetup, o = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
|
|
2553
2553
|
this.updateStapleMesh(e, h);
|
|
2554
2554
|
const u = r ?? new c.MeshStandardMaterial({
|
|
@@ -2570,7 +2570,7 @@ class as {
|
|
|
2570
2570
|
this.updateRootPosition();
|
|
2571
2571
|
}
|
|
2572
2572
|
get binderRenderer() {
|
|
2573
|
-
return this._binderRendererAdapter || (this._binderRendererAdapter = new
|
|
2573
|
+
return this._binderRendererAdapter || (this._binderRendererAdapter = new hs(this.stapleMesh)), this._binderRendererAdapter;
|
|
2574
2574
|
}
|
|
2575
2575
|
// ── updateStapleMesh ──────────────────────────────────────────────────
|
|
2576
2576
|
updateStapleMesh(t, e) {
|
|
@@ -2581,144 +2581,144 @@ class as {
|
|
|
2581
2581
|
this.m_Book.minPaperHeight / 2 - s - i,
|
|
2582
2582
|
i
|
|
2583
2583
|
);
|
|
2584
|
-
this.m_StapleMargin =
|
|
2584
|
+
this.m_StapleMargin = F(i, r, t.margin);
|
|
2585
2585
|
const a = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
|
|
2586
2586
|
let o = t.count, h = (a - s * o) / (o - 1);
|
|
2587
2587
|
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && o > 2; )
|
|
2588
2588
|
o--, h = (a - s * o) / (o - 1), h = Math.max(h, 0);
|
|
2589
|
-
const u = t.quality / 5, l = Math.floor(
|
|
2589
|
+
const u = t.quality / 5, l = Math.floor(F(4, 20, u)), d = Math.floor(F(4, 10, u)), f = Math.floor(F(3, 10, u)), g = this.m_StapleThickness / 2, m = g * 2.5, _ = 0.9, p = g * 1;
|
|
2590
2590
|
let T = s / 2 * _;
|
|
2591
2591
|
T = Math.max(T, p * 2);
|
|
2592
2592
|
let b = 0;
|
|
2593
2593
|
b += this.m_Book.totalThickness / 2, b += g;
|
|
2594
|
-
const M = -(this.m_Book.papers[0].thickness / 2 + g),
|
|
2594
|
+
const M = -(this.m_Book.papers[0].thickness / 2 + g), y = [];
|
|
2595
2595
|
{
|
|
2596
2596
|
for (let R = 0; R < d; R++) {
|
|
2597
|
-
const E = R / (d - 1), q =
|
|
2597
|
+
const E = R / (d - 1), q = F(-90, -180, E) * et, C = new c.Vector3(
|
|
2598
2598
|
p * Math.sin(q),
|
|
2599
2599
|
0,
|
|
2600
2600
|
p * Math.cos(q)
|
|
2601
2601
|
);
|
|
2602
|
-
|
|
2602
|
+
C.x += p, C.z += p, C.x += M, y.push(C);
|
|
2603
2603
|
}
|
|
2604
|
-
const x = new c.Vector3(b, 0, 0),
|
|
2604
|
+
const x = new c.Vector3(b, 0, 0), H = new c.Vector3(b + m * 0.75, 0, 0), P = new c.Vector3(b - g * 0.5, 0, T);
|
|
2605
2605
|
for (let R = 0; R < f; R++) {
|
|
2606
|
-
const E = R / (f - 1), G = Qt(x,
|
|
2607
|
-
G.x += M,
|
|
2606
|
+
const E = R / (f - 1), G = Qt(x, H, P, E);
|
|
2607
|
+
G.x += M, y.push(G);
|
|
2608
2608
|
}
|
|
2609
|
-
|
|
2609
|
+
y.reverse();
|
|
2610
2610
|
}
|
|
2611
2611
|
const v = new Array(l);
|
|
2612
2612
|
for (let x = 0; x < l; x++) {
|
|
2613
2613
|
const P = (90 - x * (360 / l)) * et;
|
|
2614
2614
|
v[x] = new c.Vector3(Math.cos(P), Math.sin(P), 0), v[x].x *= 0.75;
|
|
2615
2615
|
}
|
|
2616
|
-
const k =
|
|
2616
|
+
const k = y.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), L = new Array(
|
|
2617
2617
|
(O * 2 - 1) * l * 2 * 3
|
|
2618
2618
|
);
|
|
2619
2619
|
for (let x = 0; x < O * 2; x++)
|
|
2620
2620
|
Z[x] = new c.Vector3(), V[x] = new c.Vector3();
|
|
2621
|
-
let
|
|
2621
|
+
let A = 0;
|
|
2622
2622
|
for (let x = 0; x < k; x++) {
|
|
2623
|
-
const
|
|
2623
|
+
const H = y[qe(x, k)], P = y[x], R = y[$t(x, k)];
|
|
2624
2624
|
let E;
|
|
2625
2625
|
if (x === 0)
|
|
2626
2626
|
E = new c.Vector3(1, 0, -2).normalize();
|
|
2627
2627
|
else if (x === k - 1)
|
|
2628
2628
|
E = new c.Vector3(0, 0, 1);
|
|
2629
2629
|
else {
|
|
2630
|
-
const J = P.clone().sub(
|
|
2630
|
+
const J = P.clone().sub(H).normalize(), tt = R.clone().sub(P).normalize();
|
|
2631
2631
|
E = J.add(tt).multiplyScalar(0.5);
|
|
2632
2632
|
}
|
|
2633
|
-
const G = new c.Vector3(0, 1, 0), q =
|
|
2633
|
+
const G = new c.Vector3(0, 1, 0), q = ns(E, G), C = A;
|
|
2634
2634
|
let B = Yt(0, f / 4, x);
|
|
2635
|
-
B =
|
|
2635
|
+
B = F(0.1, 1, B), B = Math.sqrt(B);
|
|
2636
2636
|
for (let J = 0; J < l; J++) {
|
|
2637
2637
|
const tt = v[J].clone().applyQuaternion(q).multiplyScalar(B), ft = P.clone().add(tt.clone().multiplyScalar(g));
|
|
2638
|
-
Z[
|
|
2638
|
+
Z[A] = ft, V[A] = tt.clone();
|
|
2639
2639
|
const lt = P.clone().add(tt.clone().multiplyScalar(g));
|
|
2640
2640
|
lt.z = s - lt.z;
|
|
2641
|
-
const
|
|
2642
|
-
Z[Bt] = lt, V[Bt] = tt.clone(),
|
|
2641
|
+
const ne = C + l - J - 1, Bt = O * 2 - ne - 1;
|
|
2642
|
+
Z[Bt] = lt, V[Bt] = tt.clone(), A++;
|
|
2643
2643
|
}
|
|
2644
2644
|
}
|
|
2645
2645
|
let w = 0;
|
|
2646
|
-
const z =
|
|
2646
|
+
const z = y.length * 2;
|
|
2647
2647
|
for (let x = 0; x < z - 1; x++) {
|
|
2648
|
-
const
|
|
2648
|
+
const H = x * l, P = (x + 1) * l;
|
|
2649
2649
|
for (let R = 0; R < l; R++) {
|
|
2650
|
-
const E = $t(R, l), G =
|
|
2651
|
-
L[w++] = G, L[w++] = B, L[w++] = q, L[w++] = q, L[w++] = B, L[w++] =
|
|
2650
|
+
const E = $t(R, l), G = H + R, q = H + E, C = P + E, B = P + R;
|
|
2651
|
+
L[w++] = G, L[w++] = B, L[w++] = q, L[w++] = q, L[w++] = B, L[w++] = C;
|
|
2652
2652
|
}
|
|
2653
2653
|
}
|
|
2654
|
-
const N = [...Z], S = [...V], Q = [...L],
|
|
2654
|
+
const N = [...Z], S = [...V], Q = [...L], j = Z.map((x) => x.clone()), $ = [...L];
|
|
2655
2655
|
for (let x = 0; x < o - 1; x++) {
|
|
2656
|
-
const
|
|
2656
|
+
const H = j.length;
|
|
2657
2657
|
for (let P = 0; P < $.length; P++)
|
|
2658
|
-
$[P] +=
|
|
2659
|
-
for (let P = 0; P <
|
|
2660
|
-
|
|
2661
|
-
N.push(...
|
|
2658
|
+
$[P] += H;
|
|
2659
|
+
for (let P = 0; P < j.length; P++)
|
|
2660
|
+
j[P].z += h + s;
|
|
2661
|
+
N.push(...j.map((P) => P.clone())), S.push(...V.map((P) => P.clone())), Q.push(...$);
|
|
2662
2662
|
}
|
|
2663
|
-
const
|
|
2663
|
+
const W = new Float32Array(N.length * 3), D = new Float32Array(S.length * 3);
|
|
2664
2664
|
for (let x = 0; x < N.length; x++)
|
|
2665
|
-
|
|
2665
|
+
W[x * 3] = N[x].x, W[x * 3 + 1] = N[x].y, W[x * 3 + 2] = N[x].z, D[x * 3] = S[x].x, D[x * 3 + 1] = S[x].y, D[x * 3 + 2] = S[x].z;
|
|
2666
2666
|
e.setAttribute(
|
|
2667
2667
|
"position",
|
|
2668
|
-
new c.BufferAttribute(
|
|
2668
|
+
new c.BufferAttribute(W, 3)
|
|
2669
2669
|
), e.setAttribute(
|
|
2670
2670
|
"normal",
|
|
2671
|
-
new c.BufferAttribute(
|
|
2671
|
+
new c.BufferAttribute(D, 3)
|
|
2672
2672
|
), e.setIndex(Q);
|
|
2673
2673
|
}
|
|
2674
2674
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2675
2675
|
createPaperPattern(t, e, s, i, r, a) {
|
|
2676
|
-
const o = new
|
|
2676
|
+
const o = new Qe();
|
|
2677
2677
|
o.size = e, o.thickness = s;
|
|
2678
2678
|
const h = this.m_BindingRadius;
|
|
2679
2679
|
o.baseXOffset = -h;
|
|
2680
2680
|
const u = this.m_Quality + 1;
|
|
2681
2681
|
this.m_BindingVertexCount = u;
|
|
2682
2682
|
const l = t / 5, d = Math.min(e.x, e.y) / 60, f = Math.floor(
|
|
2683
|
-
|
|
2684
|
-
), g = Math.floor(
|
|
2683
|
+
F(0, (e.x - h) / d, l)
|
|
2684
|
+
), g = Math.floor(F(0, e.y / d, l));
|
|
2685
2685
|
let m = 2 + f + 1 + u, _ = 2 + g;
|
|
2686
2686
|
const p = new it(0);
|
|
2687
2687
|
let T = p;
|
|
2688
2688
|
const b = h / u;
|
|
2689
2689
|
let M = 0;
|
|
2690
|
-
for (let
|
|
2690
|
+
for (let C = 1; C < u + 1; C++)
|
|
2691
2691
|
T = T.createNext(M), M += b;
|
|
2692
|
-
const
|
|
2693
|
-
for (let
|
|
2694
|
-
T = T.createNext(M), M +=
|
|
2692
|
+
const y = (e.x - h) / (f + 1);
|
|
2693
|
+
for (let C = u + 1; C < m; C++)
|
|
2694
|
+
T = T.createNext(M), M += y;
|
|
2695
2695
|
const v = new it(0);
|
|
2696
2696
|
let k = v;
|
|
2697
2697
|
const O = e.y / (_ - 1);
|
|
2698
2698
|
let Z = 0;
|
|
2699
|
-
for (let
|
|
2699
|
+
for (let C = 0; C < _ - 1; C++)
|
|
2700
2700
|
Z += O, k = k.createNext(Z);
|
|
2701
|
-
const V = [], L = [],
|
|
2701
|
+
const V = [], L = [], A = i.clone();
|
|
2702
2702
|
if (r) {
|
|
2703
|
-
let
|
|
2704
|
-
this.m_Book.hasCover && (
|
|
2703
|
+
let C = 0;
|
|
2704
|
+
this.m_Book.hasCover && (C = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2705
2705
|
const B = Math.max(0.01, s);
|
|
2706
|
-
|
|
2706
|
+
A.left = 0, A.right = (this.getPX(C + 1, s) - this.getPX(C, s) + B) / e.x, A.down = B / e.y, A.up = B / e.y;
|
|
2707
2707
|
}
|
|
2708
|
-
const w = new
|
|
2708
|
+
const w = new ye(o, A, !1);
|
|
2709
2709
|
w.insert(p, v, V, L), p.updateIndex(0), v.updateIndex(0), Lt(V, o.xSeams), Lt(L, o.zSeams);
|
|
2710
2710
|
const z = this.m_BindingVertexCount + 2, N = new Array(z);
|
|
2711
2711
|
o.xNoneSeamIndexes = N, T = p;
|
|
2712
|
-
for (let
|
|
2713
|
-
N[
|
|
2712
|
+
for (let C = 0; C < z; C++) {
|
|
2713
|
+
N[C] = T.index;
|
|
2714
2714
|
do
|
|
2715
2715
|
T = T.next;
|
|
2716
2716
|
while (T.seam);
|
|
2717
2717
|
}
|
|
2718
2718
|
const S = p.getValues(), Q = v.getValues();
|
|
2719
2719
|
m = S.length, _ = Q.length;
|
|
2720
|
-
const
|
|
2721
|
-
|
|
2720
|
+
const j = m * _, $ = [], W = new Array(j).fill(0), D = [], x = [], H = [], P = [];
|
|
2721
|
+
ve(
|
|
2722
2722
|
$,
|
|
2723
2723
|
S,
|
|
2724
2724
|
Q,
|
|
@@ -2729,27 +2729,27 @@ class as {
|
|
|
2729
2729
|
const R = w.leftNode.index, E = w.downNode.index;
|
|
2730
2730
|
let G = w.rightNode.index, q = w.upNode.index;
|
|
2731
2731
|
G === 0 && (G = m - 1), q === 0 && (q = _ - 1);
|
|
2732
|
-
for (let
|
|
2732
|
+
for (let C = 0; C < _ - 1; C++)
|
|
2733
2733
|
for (let B = 0; B < m - 1; B++) {
|
|
2734
|
-
if (r &&
|
|
2734
|
+
if (r && C >= E && C < q && B >= R && B < G)
|
|
2735
2735
|
continue;
|
|
2736
|
-
const J =
|
|
2737
|
-
|
|
2738
|
-
|
|
2736
|
+
const J = C * m + B, tt = C * m + (B + 1), ft = (C + 1) * m + B, lt = (C + 1) * m + (B + 1);
|
|
2737
|
+
W[J] += 2, W[tt] += 2, W[ft] += 2, W[lt] += 2, Pe(
|
|
2738
|
+
D,
|
|
2739
2739
|
x,
|
|
2740
2740
|
J,
|
|
2741
2741
|
tt,
|
|
2742
2742
|
ft,
|
|
2743
2743
|
lt,
|
|
2744
|
-
|
|
2744
|
+
j
|
|
2745
2745
|
);
|
|
2746
2746
|
}
|
|
2747
|
-
if (P.push(new St(0, 0, m - 1, _ - 1, !1, !1)),
|
|
2747
|
+
if (P.push(new St(0, 0, m - 1, _ - 1, !1, !1)), Ce(P, H, $, m, _), o.baseXArray = S, o.baseZArray = Q, o.baseVertexCount = j, o.vertexCount = $.length, o.texcoords = $, o.weights = W, a) {
|
|
2748
2748
|
o.subMeshCount = 1;
|
|
2749
|
-
const
|
|
2750
|
-
|
|
2749
|
+
const C = [];
|
|
2750
|
+
C.push(...D), C.push(...H), C.push(...x), o.triangles = C;
|
|
2751
2751
|
} else
|
|
2752
|
-
o.subMeshCount = 3, o.frontTriangles =
|
|
2752
|
+
o.subMeshCount = 3, o.frontTriangles = D, o.backTriangles = x, o.borderTriangles = H;
|
|
2753
2753
|
return o.borders = P, o;
|
|
2754
2754
|
}
|
|
2755
2755
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
@@ -2764,14 +2764,14 @@ class as {
|
|
|
2764
2764
|
let i = 0;
|
|
2765
2765
|
const r = e.length / 2 - 1, a = e.length / 2;
|
|
2766
2766
|
for (let M = 0; M < s; M++) {
|
|
2767
|
-
const
|
|
2768
|
-
|
|
2769
|
-
const v =
|
|
2767
|
+
const y = e[M];
|
|
2768
|
+
y.updateTime();
|
|
2769
|
+
const v = y.zTime, k = y.thickness;
|
|
2770
2770
|
i += v * k, M === r && (i += v * this.m_BindingMidSpace / 2), M === a && (i += v * this.m_BindingMidSpace / 2);
|
|
2771
2771
|
}
|
|
2772
2772
|
let o = this.getStackHeight(t.index) - t.thickness / 2;
|
|
2773
2773
|
const h = this.getStackZ(o), u = 180 + h;
|
|
2774
|
-
let l = t.isFlipped ? 1 : 0, d =
|
|
2774
|
+
let l = t.isFlipped ? 1 : 0, d = F(h, u, l);
|
|
2775
2775
|
const f = d * et, g = new c.Vector3(
|
|
2776
2776
|
Math.cos(f) * this.m_BindingRadius,
|
|
2777
2777
|
Math.sin(f) * this.m_BindingRadius,
|
|
@@ -2783,18 +2783,18 @@ class as {
|
|
|
2783
2783
|
let M = 0;
|
|
2784
2784
|
if (this.m_Book.alignToGround) {
|
|
2785
2785
|
m = e[0].size.x;
|
|
2786
|
-
const
|
|
2787
|
-
_ = st(i, 0,
|
|
2786
|
+
const y = this.m_StackHeight / 2;
|
|
2787
|
+
_ = st(i, 0, y) - y, p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2788
2788
|
}
|
|
2789
|
-
d =
|
|
2789
|
+
d = F(T, -M, l);
|
|
2790
2790
|
} else {
|
|
2791
2791
|
let M = 0;
|
|
2792
2792
|
if (this.m_Book.alignToGround) {
|
|
2793
2793
|
m = e[0].size.x;
|
|
2794
|
-
const
|
|
2795
|
-
_ =
|
|
2794
|
+
const y = this.m_StackHeight / 2;
|
|
2795
|
+
_ = y - st(i, y, y * 2), p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2796
2796
|
}
|
|
2797
|
-
d =
|
|
2797
|
+
d = F(M, -T, l);
|
|
2798
2798
|
}
|
|
2799
2799
|
t.transform.position.copy(g), t.transform.quaternion.setFromEuler(
|
|
2800
2800
|
new c.Euler(0, 0, d * et)
|
|
@@ -2807,7 +2807,7 @@ class as {
|
|
|
2807
2807
|
const a = s.length / 2 - 1, o = s.length / 2;
|
|
2808
2808
|
for (let _ = 0; _ < i; _++)
|
|
2809
2809
|
r += 0 * e, _ === a && (r += 0 * this.m_BindingMidSpace / 2), _ === o && (r += 0 * this.m_BindingMidSpace / 2);
|
|
2810
|
-
const h = this.getStackHeight(t) - e / 2, u = this.getStackZ(h), l = 180 + u, g =
|
|
2810
|
+
const h = this.getStackHeight(t) - e / 2, u = this.getStackZ(h), l = 180 + u, g = F(u, l, 0) * et;
|
|
2811
2811
|
return new c.Vector3(
|
|
2812
2812
|
Math.cos(g) * this.m_BindingRadius,
|
|
2813
2813
|
Math.sin(g) * this.m_BindingRadius,
|
|
@@ -2820,13 +2820,13 @@ class as {
|
|
|
2820
2820
|
let i = 0;
|
|
2821
2821
|
const r = e.length / 2 - 1, a = e.length / 2;
|
|
2822
2822
|
for (let M = 0; M < s; M++) {
|
|
2823
|
-
const
|
|
2824
|
-
|
|
2825
|
-
const v =
|
|
2823
|
+
const y = e[M];
|
|
2824
|
+
y.updateTime();
|
|
2825
|
+
const v = y.zTime, k = y.thickness;
|
|
2826
2826
|
i += v * k, M === r && (i += v * this.m_BindingMidSpace / 2), M === a && (i += v * this.m_BindingMidSpace / 2);
|
|
2827
2827
|
}
|
|
2828
2828
|
const o = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(o + i), u = 180 + this.getStackZ(o + i - this.m_StackHeight);
|
|
2829
|
-
let l = t.zTime, d =
|
|
2829
|
+
let l = t.zTime, d = F(h, u, l);
|
|
2830
2830
|
const f = d * et, g = new c.Vector3(
|
|
2831
2831
|
Math.cos(f) * this.m_BindingRadius,
|
|
2832
2832
|
Math.sin(f) * this.m_BindingRadius,
|
|
@@ -2838,18 +2838,18 @@ class as {
|
|
|
2838
2838
|
let M = 0;
|
|
2839
2839
|
if (this.m_Book.alignToGround) {
|
|
2840
2840
|
m = e[0].size.x;
|
|
2841
|
-
const
|
|
2842
|
-
_ = st(i, 0,
|
|
2841
|
+
const y = this.m_StackHeight / 2;
|
|
2842
|
+
_ = st(i, 0, y) - y, p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2843
2843
|
}
|
|
2844
|
-
d =
|
|
2844
|
+
d = F(T, -M, l);
|
|
2845
2845
|
} else {
|
|
2846
2846
|
let M = 0;
|
|
2847
2847
|
if (this.m_Book.alignToGround) {
|
|
2848
2848
|
m = e[0].size.x;
|
|
2849
|
-
const
|
|
2850
|
-
_ =
|
|
2849
|
+
const y = this.m_StackHeight / 2;
|
|
2850
|
+
_ = y - st(i, y, y * 2), p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2851
2851
|
}
|
|
2852
|
-
d =
|
|
2852
|
+
d = F(M, -T, l);
|
|
2853
2853
|
}
|
|
2854
2854
|
t.transform.position.copy(g), t.transform.quaternion.setFromEuler(
|
|
2855
2855
|
new c.Euler(0, 0, d * et)
|
|
@@ -2886,19 +2886,19 @@ class as {
|
|
|
2886
2886
|
let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
|
|
2887
2887
|
const r = this.m_StapleThickness * 0.5, a = t[0].thickness, o = this.m_Root.matrixWorld.clone(), h = t.length;
|
|
2888
2888
|
for (let u = 0; u < h; u++) {
|
|
2889
|
-
const l = t[u], d = l.transform, f = l.meshData.pattern, g = l.meshData.baseVertices, m = f.baseXArray, _ = f.baseZArray, p = m.length, T = _.length, b = this.m_BindingVertexCount + 1, M = l.thickness,
|
|
2889
|
+
const l = t[u], d = l.transform, f = l.meshData.pattern, g = l.meshData.baseVertices, m = f.baseXArray, _ = f.baseZArray, p = m.length, T = _.length, b = this.m_BindingVertexCount + 1, M = l.thickness, y = f.xNoneSeamIndexes, v = d.position.clone();
|
|
2890
2890
|
let k = u, O = r;
|
|
2891
2891
|
u >= Math.floor(h / 2) && (k = h - u - 1, O *= -1);
|
|
2892
2892
|
const Z = (a + M) * 0.5 + M * (k - 1), V = d.matrixWorld.clone().invert().multiply(o), L = k / (h / 2);
|
|
2893
|
-
i = this.m_BindingRadius *
|
|
2894
|
-
for (let
|
|
2895
|
-
const w = _[
|
|
2893
|
+
i = this.m_BindingRadius * F(0.45, 0.65, 1 - L);
|
|
2894
|
+
for (let A = 0; A < T; A++) {
|
|
2895
|
+
const w = _[A], z = new c.Vector3(0, 0, v.z + w), N = v.clone();
|
|
2896
2896
|
N.z += w;
|
|
2897
2897
|
const S = l.getDirection(w).multiplyScalar(i).add(N.clone());
|
|
2898
|
-
if (u === 0 &&
|
|
2899
|
-
const
|
|
2900
|
-
|
|
2901
|
-
const P =
|
|
2898
|
+
if (u === 0 && A === 0) {
|
|
2899
|
+
const D = t[h - 1], H = D.transform.position.clone().clone();
|
|
2900
|
+
H.z += w;
|
|
2901
|
+
const P = D.getDirection(w).multiplyScalar(i).add(H);
|
|
2902
2902
|
s = S.clone().sub(P).normalize(), e = new c.Vector3(
|
|
2903
2903
|
-s.y,
|
|
2904
2904
|
s.x,
|
|
@@ -2908,16 +2908,16 @@ class as {
|
|
|
2908
2908
|
this.stapleMesh.rotation.set(0, 0, R * et);
|
|
2909
2909
|
}
|
|
2910
2910
|
k > 0 && z.add(e.clone().multiplyScalar(Z));
|
|
2911
|
-
const Q =
|
|
2911
|
+
const Q = A * p;
|
|
2912
2912
|
g[Q] = z.clone().applyMatrix4(V), z.add(s.clone().multiplyScalar(O));
|
|
2913
|
-
const
|
|
2914
|
-
g[Q +
|
|
2915
|
-
for (let
|
|
2916
|
-
const x = Yt(1, b,
|
|
2917
|
-
g[Q +
|
|
2918
|
-
W,
|
|
2919
|
-
$,
|
|
2913
|
+
const j = z.clone().applyMatrix4(V), $ = S.clone().applyMatrix4(V), W = N.clone().applyMatrix4(V);
|
|
2914
|
+
g[Q + y[1]] = j;
|
|
2915
|
+
for (let D = 2; D < b; D++) {
|
|
2916
|
+
const x = Yt(1, b, D);
|
|
2917
|
+
g[Q + y[D]] = Qt(
|
|
2920
2918
|
j,
|
|
2919
|
+
$,
|
|
2920
|
+
W,
|
|
2921
2921
|
x
|
|
2922
2922
|
);
|
|
2923
2923
|
}
|
|
@@ -2947,7 +2947,7 @@ class as {
|
|
|
2947
2947
|
return this.m_StapleThickness;
|
|
2948
2948
|
}
|
|
2949
2949
|
}
|
|
2950
|
-
class
|
|
2950
|
+
class hs {
|
|
2951
2951
|
constructor(t) {
|
|
2952
2952
|
this.mesh = t;
|
|
2953
2953
|
}
|
|
@@ -2973,12 +2973,12 @@ class os {
|
|
|
2973
2973
|
return this.mesh;
|
|
2974
2974
|
}
|
|
2975
2975
|
}
|
|
2976
|
-
class
|
|
2976
|
+
class Bs extends Ge {
|
|
2977
2977
|
constructor() {
|
|
2978
|
-
super(...arguments), this.quality = 3, this.stapleSetup = new
|
|
2978
|
+
super(...arguments), this.quality = 3, this.stapleSetup = new rs();
|
|
2979
2979
|
}
|
|
2980
2980
|
createBound(t, e, s, i) {
|
|
2981
|
-
return new
|
|
2981
|
+
return new os(
|
|
2982
2982
|
this.quality,
|
|
2983
2983
|
this.stapleSetup,
|
|
2984
2984
|
t,
|
|
@@ -2986,56 +2986,147 @@ class Ss extends We {
|
|
|
2986
2986
|
);
|
|
2987
2987
|
}
|
|
2988
2988
|
}
|
|
2989
|
+
function ls(n) {
|
|
2990
|
+
return n.map instanceof c.Texture;
|
|
2991
|
+
}
|
|
2992
|
+
class Kt {
|
|
2993
|
+
constructor(t, e) {
|
|
2994
|
+
this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
|
|
2995
|
+
}
|
|
2996
|
+
get texture() {
|
|
2997
|
+
return this._spread.texture;
|
|
2998
|
+
}
|
|
2999
|
+
get textureST() {
|
|
3000
|
+
return this._textureST;
|
|
3001
|
+
}
|
|
3002
|
+
isPointOverUI(t) {
|
|
3003
|
+
return !1;
|
|
3004
|
+
}
|
|
3005
|
+
init(t) {
|
|
3006
|
+
}
|
|
3007
|
+
setActive(t) {
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
function bs(n) {
|
|
3011
|
+
const t = [];
|
|
3012
|
+
for (let e = 1; e + 1 < n; e += 2)
|
|
3013
|
+
t.push(e);
|
|
3014
|
+
return t;
|
|
3015
|
+
}
|
|
3016
|
+
class Is {
|
|
3017
|
+
constructor(t) {
|
|
3018
|
+
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;
|
|
3019
|
+
const e = this.canvas.getContext("2d");
|
|
3020
|
+
if (!e) throw new Error("SpreadContent: could not get 2D context");
|
|
3021
|
+
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 Kt(this, "left"), this.right = new Kt(this, "right");
|
|
3022
|
+
}
|
|
3023
|
+
get texture() {
|
|
3024
|
+
return this._texture;
|
|
3025
|
+
}
|
|
3026
|
+
/** The base layer drawn beneath text blocks (full spread width). */
|
|
3027
|
+
get source() {
|
|
3028
|
+
return this._source;
|
|
3029
|
+
}
|
|
3030
|
+
set source(t) {
|
|
3031
|
+
this._source = t;
|
|
3032
|
+
}
|
|
3033
|
+
// ── Text API ─────────────────────────────────────────────────────────────
|
|
3034
|
+
addText(t) {
|
|
3035
|
+
const e = new se(t);
|
|
3036
|
+
return this.texts.push(e), e;
|
|
3037
|
+
}
|
|
3038
|
+
removeText(t) {
|
|
3039
|
+
const e = this.texts.indexOf(t);
|
|
3040
|
+
e !== -1 && this.texts.splice(e, 1);
|
|
3041
|
+
}
|
|
3042
|
+
/** Update a text block by index. Only provided fields are changed. */
|
|
3043
|
+
updateText(t, e) {
|
|
3044
|
+
const s = this.texts[t];
|
|
3045
|
+
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));
|
|
3046
|
+
}
|
|
3047
|
+
// ── Per-frame update ─────────────────────────────────────────────────────
|
|
3048
|
+
/**
|
|
3049
|
+
* Re-composite the canvas: source layer + text blocks.
|
|
3050
|
+
* Call every frame (or when content changes).
|
|
3051
|
+
*
|
|
3052
|
+
* @param root Optional THREE.Object3D to traverse for texture sync
|
|
3053
|
+
* (needed because three-book clones material textures).
|
|
3054
|
+
*/
|
|
3055
|
+
update(t) {
|
|
3056
|
+
const { ctx: e, canvas: s } = this, i = s.width, r = s.height;
|
|
3057
|
+
e.clearRect(0, 0, i, r), this._source && e.drawImage(this._source, 0, 0, i, r);
|
|
3058
|
+
for (const a of this.texts) a.draw(e);
|
|
3059
|
+
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
3060
|
+
}
|
|
3061
|
+
/**
|
|
3062
|
+
* Traverse `root` and set `needsUpdate = true` on every material map whose
|
|
3063
|
+
* source image is this spread's canvas.
|
|
3064
|
+
*/
|
|
3065
|
+
syncMaterials(t) {
|
|
3066
|
+
t.traverse((e) => {
|
|
3067
|
+
if (!e.isMesh) return;
|
|
3068
|
+
const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
|
|
3069
|
+
for (const r of i)
|
|
3070
|
+
ls(r) && r.map.image === this.canvas && (r.map.needsUpdate = !0);
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
3074
|
+
dispose() {
|
|
3075
|
+
this._texture.dispose();
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
2989
3078
|
export {
|
|
2990
|
-
|
|
3079
|
+
De as AnimationCurve,
|
|
2991
3080
|
dt as AutoTurnDirection,
|
|
2992
|
-
|
|
3081
|
+
Re as AutoTurnMode,
|
|
2993
3082
|
ot as AutoTurnSetting,
|
|
2994
|
-
|
|
2995
|
-
|
|
3083
|
+
Ae as AutoTurnSettingCurveTimeMode,
|
|
3084
|
+
Ve as AutoTurnSettingMode,
|
|
2996
3085
|
ut as AutoTurnSettings,
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3086
|
+
gs as Book,
|
|
3087
|
+
Ge as BookBinding,
|
|
3088
|
+
ks as BookBound,
|
|
3089
|
+
Ss as BookContent,
|
|
3001
3090
|
kt as BookContext,
|
|
3002
3091
|
X as BookDirection,
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3092
|
+
ds as BookHeightException,
|
|
3093
|
+
ps as BookInteraction,
|
|
3094
|
+
Ie as BookRenderer,
|
|
3006
3095
|
pt as Cylinder,
|
|
3007
|
-
|
|
3096
|
+
ke as MeshFactory,
|
|
3008
3097
|
Gt as PX_PER_UNIT,
|
|
3009
|
-
|
|
3010
|
-
|
|
3098
|
+
vs as PageContent,
|
|
3099
|
+
we as Paper,
|
|
3011
3100
|
St as PaperBorder,
|
|
3012
3101
|
Ot as PaperMaterialData,
|
|
3013
|
-
|
|
3014
|
-
|
|
3102
|
+
Wt as PaperMeshData,
|
|
3103
|
+
ze as PaperMeshDataPool,
|
|
3015
3104
|
it as PaperNode,
|
|
3016
|
-
|
|
3017
|
-
|
|
3105
|
+
ye as PaperNodeMargin,
|
|
3106
|
+
Qe as PaperPattern,
|
|
3018
3107
|
vt as PaperSeam,
|
|
3019
3108
|
ct as PaperSetup,
|
|
3020
3109
|
Tt as PaperUVMargin,
|
|
3021
|
-
|
|
3110
|
+
Be as RendererFactory,
|
|
3111
|
+
Is as SpreadContent,
|
|
3022
3112
|
qt as SpritePageContent2,
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3113
|
+
Bs as StapleBookBinding,
|
|
3114
|
+
os as StapleBookBound,
|
|
3115
|
+
rs as StapleSetup,
|
|
3116
|
+
se as TextBlock,
|
|
3117
|
+
We as TextOverlayContent,
|
|
3118
|
+
Fe as ThreeBook,
|
|
3119
|
+
Ts as createPageTexture,
|
|
3030
3120
|
je as drawImageWithFit,
|
|
3031
|
-
|
|
3032
|
-
|
|
3121
|
+
bs as getSpreadPairs,
|
|
3122
|
+
Ps as loadImage,
|
|
3123
|
+
Ms as useAutoTurn,
|
|
3033
3124
|
_t as useBook,
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3125
|
+
ys as useBookContent,
|
|
3126
|
+
xs as useBookControls,
|
|
3127
|
+
Oe as useBookRef,
|
|
3128
|
+
ws as useBookState,
|
|
3129
|
+
Ze as usePageTurning,
|
|
3130
|
+
fs as useRequiredBook,
|
|
3131
|
+
Cs as useTextOverlay
|
|
3041
3132
|
};
|