@objectifthunes/three-book 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Book.d.ts +14 -0
- package/dist/Book.d.ts.map +1 -1
- package/dist/index.js +356 -308
- package/package.json +30 -31
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ class ut {
|
|
|
30
30
|
* 3. Rotate by Y degrees around Y-axis.
|
|
31
31
|
*/
|
|
32
32
|
eulerRotateVector(t, e, s) {
|
|
33
|
-
const i = s * Math.PI / 180, n = e * Math.PI / 180,
|
|
33
|
+
const i = s * Math.PI / 180, n = e * Math.PI / 180, o = Math.cos(i), a = Math.sin(i), h = t * o, m = t * a, l = 0, d = Math.cos(n), g = Math.sin(n), _ = h * d + l * g, u = m, f = -h * g + l * d;
|
|
34
34
|
return new c.Vector3(_, u, f);
|
|
35
35
|
}
|
|
36
36
|
roll(t) {
|
|
@@ -68,24 +68,24 @@ class ut {
|
|
|
68
68
|
}
|
|
69
69
|
function gt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
|
|
70
70
|
s = Math.max(s, 1e-4);
|
|
71
|
-
const
|
|
71
|
+
const o = 2 / s, a = o * n, h = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
|
|
72
72
|
let m = r - t;
|
|
73
73
|
const l = t, d = i * s;
|
|
74
74
|
m = c.MathUtils.clamp(m, -d, d), t = r - m;
|
|
75
|
-
const g = (e +
|
|
76
|
-
e = (e -
|
|
75
|
+
const g = (e + o * m) * n;
|
|
76
|
+
e = (e - o * g) * h;
|
|
77
77
|
let _ = t + (m + g) * h;
|
|
78
78
|
return l - r > 0 == _ > l && (_ = l, e = (_ - l) / n), { value: _, velocity: e };
|
|
79
79
|
}
|
|
80
80
|
function ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
|
|
81
|
-
const
|
|
81
|
+
const o = gt(
|
|
82
82
|
r.x,
|
|
83
83
|
t.x,
|
|
84
84
|
e.x,
|
|
85
85
|
s.x,
|
|
86
86
|
i,
|
|
87
87
|
n
|
|
88
|
-
),
|
|
88
|
+
), a = gt(
|
|
89
89
|
r.y,
|
|
90
90
|
t.y,
|
|
91
91
|
e.y,
|
|
@@ -100,7 +100,7 @@ function ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
|
|
|
100
100
|
i,
|
|
101
101
|
n
|
|
102
102
|
);
|
|
103
|
-
return e.set(
|
|
103
|
+
return e.set(o.velocity, a.velocity, h.velocity), new c.Vector3(o.value, a.value, h.value);
|
|
104
104
|
}
|
|
105
105
|
function ne(r) {
|
|
106
106
|
return new c.Vector3(r.x, 0, r.y);
|
|
@@ -108,7 +108,7 @@ function ne(r) {
|
|
|
108
108
|
function re(r) {
|
|
109
109
|
return new c.Vector3(r.x, r.z, 0);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function St(r, t, e) {
|
|
112
112
|
const s = t * t - 4 * r * e;
|
|
113
113
|
if (s < 0)
|
|
114
114
|
return { rootCount: 0, root0: 0, root1: 0 };
|
|
@@ -124,36 +124,36 @@ function vt(r, t, e) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
function kt(r, t, e) {
|
|
127
|
-
return
|
|
127
|
+
return oe(r, t, e) ? r.clone() : ae(
|
|
128
128
|
new c.Vector2(r.x, t.y),
|
|
129
129
|
r,
|
|
130
130
|
t,
|
|
131
131
|
e
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function oe(r, t, e) {
|
|
135
135
|
const s = r.x - t.x;
|
|
136
136
|
let i = r.y - t.y;
|
|
137
137
|
return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
const i = e.x, n = e.y,
|
|
141
|
-
if (Math.abs(
|
|
142
|
-
if (
|
|
143
|
-
const u =
|
|
139
|
+
function ae(r, t, e, s) {
|
|
140
|
+
const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, d = s.y, g = 1 / (l * l), _ = 1 / (d * d);
|
|
141
|
+
if (Math.abs(o - h) < 1e-5) {
|
|
142
|
+
if (o >= i - l && o <= i + l) {
|
|
143
|
+
const u = St(
|
|
144
144
|
_,
|
|
145
145
|
-2 * _ * n,
|
|
146
|
-
g * (
|
|
146
|
+
g * (o * o - 2 * i * o + i * i) + _ * n * n - 1
|
|
147
147
|
);
|
|
148
148
|
if (u.rootCount === 1)
|
|
149
|
-
return new c.Vector2(
|
|
149
|
+
return new c.Vector2(o, u.root0);
|
|
150
150
|
if (u.rootCount === 2) {
|
|
151
151
|
let f = u.root0, p = u.root1;
|
|
152
|
-
return
|
|
152
|
+
return a < m && ([f, p] = [p, f]), new c.Vector2(o, p);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
} else {
|
|
156
|
-
const u = (m -
|
|
156
|
+
const u = (m - a) / (h - o), f = a - u * o, p = f - n, P = St(
|
|
157
157
|
g + _ * u * u,
|
|
158
158
|
2 * p * u * _ - 2 * i * g,
|
|
159
159
|
i * i * g + p * p * _ - 1
|
|
@@ -162,7 +162,7 @@ function oe(r, t, e, s) {
|
|
|
162
162
|
return new c.Vector2(P.root0, u * P.root0 + f);
|
|
163
163
|
if (P.rootCount === 2) {
|
|
164
164
|
let B = P.root0, M = P.root1;
|
|
165
|
-
return
|
|
165
|
+
return o < h && ([B, M] = [M, B]), new c.Vector2(M, u * M + f);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
return r.clone();
|
|
@@ -320,7 +320,7 @@ class me {
|
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
startTurning(t) {
|
|
323
|
-
var n,
|
|
323
|
+
var n, o;
|
|
324
324
|
const e = t.clone();
|
|
325
325
|
t = bt(
|
|
326
326
|
t,
|
|
@@ -331,17 +331,17 @@ class me {
|
|
|
331
331
|
);
|
|
332
332
|
const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
|
|
333
333
|
if (t.intersectPlane(s, i) !== null) {
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(
|
|
337
|
-
this.m_HandleOffset.set(
|
|
334
|
+
const a = i;
|
|
335
|
+
if (a.x > 0 && a.x < this.m_Size.x && a.z > 0 && a.z < this.m_Size.y) {
|
|
336
|
+
if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(a), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), a.x < this.m_Size.x * 0.9) {
|
|
337
|
+
this.m_HandleOffset.set(a.x - this.m_Size.x, 0, 0);
|
|
338
338
|
const h = this.m_Transform.scale;
|
|
339
339
|
h.x *= -1;
|
|
340
340
|
}
|
|
341
341
|
return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
|
|
342
342
|
0
|
|
343
343
|
/* Highpoly */
|
|
344
|
-
), (n = this.m_Prev) == null || n.trySwitchMeshData(1), (
|
|
344
|
+
), (n = this.m_Prev) == null || n.trySwitchMeshData(1), (o = this.m_Next) == null || o.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
return !1;
|
|
@@ -493,16 +493,16 @@ class me {
|
|
|
493
493
|
this.m_Book.direction > 1 ? s = le(s) : s = he(s);
|
|
494
494
|
const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
|
|
495
495
|
if (t === 3) {
|
|
496
|
-
let
|
|
497
|
-
this.m_Transform.scale.x === -1 && (
|
|
496
|
+
let o = 0, a = 1;
|
|
497
|
+
this.m_Transform.scale.x === -1 && (o = 1, a = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
|
|
498
498
|
this.m_MaterialData.propertyBlock,
|
|
499
|
-
|
|
499
|
+
o
|
|
500
500
|
), this.m_UseBackContentForSides || this.m_Renderer.setPropertyBlock(
|
|
501
501
|
this.m_MaterialData.propertyBlock,
|
|
502
502
|
2
|
|
503
503
|
), this.m_MaterialData.updatePropertyBlock(n, s), this.m_Renderer.setPropertyBlock(
|
|
504
504
|
this.m_MaterialData.propertyBlock,
|
|
505
|
-
|
|
505
|
+
a
|
|
506
506
|
), this.m_UseBackContentForSides && this.m_Renderer.setPropertyBlock(
|
|
507
507
|
this.m_MaterialData.propertyBlock,
|
|
508
508
|
2
|
|
@@ -537,11 +537,11 @@ class me {
|
|
|
537
537
|
Math.max(t, e),
|
|
538
538
|
0.9
|
|
539
539
|
);
|
|
540
|
-
const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, n = this.rollPoint(new c.Vector3(s[1], 0, 0)),
|
|
540
|
+
const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, n = this.rollPoint(new c.Vector3(s[1], 0, 0)), o = this.rollPoint(new c.Vector3(s[2], 0, 0)), a = this.rollPoint(
|
|
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 =
|
|
544
|
+
), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), d = Rt * Math.atan2(m.y, m.x), g = Rt * Math.atan2(l.y, l.x), _ = (d + g) / 2;
|
|
545
545
|
this.m_ZTime = _ / 180;
|
|
546
546
|
} else
|
|
547
547
|
this.m_XTime = 0, this.m_ZTime = 0;
|
|
@@ -551,13 +551,13 @@ class me {
|
|
|
551
551
|
}
|
|
552
552
|
clampHandle() {
|
|
553
553
|
this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
|
|
554
|
-
const t = this.m_CurrentHandle.clone(), e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle),
|
|
554
|
+
const t = this.m_CurrentHandle.clone(), e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), o = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), h = this.m_StartHandle.z, m = new c.Vector2(
|
|
555
555
|
0,
|
|
556
|
-
h + (e.z - h) * (
|
|
556
|
+
h + (e.z - h) * (o / i)
|
|
557
557
|
), l = new c.Vector2(
|
|
558
558
|
0,
|
|
559
|
-
h + (s.z - h) * (
|
|
560
|
-
), d = new c.Vector2(i,
|
|
559
|
+
h + (s.z - h) * (a / n)
|
|
560
|
+
), d = new c.Vector2(i, o), g = new c.Vector2(n, a);
|
|
561
561
|
t.x = It(t.x, -this.m_Size.x, this.m_Size.x);
|
|
562
562
|
const _ = re(t), u = kt(
|
|
563
563
|
new c.Vector2(_.x, _.y),
|
|
@@ -579,17 +579,17 @@ class me {
|
|
|
579
579
|
s.clone().multiplyScalar(
|
|
580
580
|
this.m_Size.x * 2 + this.m_TurningRadius * Math.PI
|
|
581
581
|
)
|
|
582
|
-
), n = t.clone(),
|
|
583
|
-
|
|
582
|
+
), n = t.clone(), o = new ut();
|
|
583
|
+
o.radius = this.m_TurningRadius, o.direction = new c.Vector3(
|
|
584
584
|
-s.z,
|
|
585
585
|
0,
|
|
586
586
|
s.x
|
|
587
587
|
);
|
|
588
|
-
for (let
|
|
589
|
-
|
|
590
|
-
const h =
|
|
588
|
+
for (let a = 0; a < 100; a++) {
|
|
589
|
+
o.position = i.clone().add(n).multiplyScalar(0.5), this.m_Cylinder = o, this.m_Book.bound.updatePaperPosition(this);
|
|
590
|
+
const h = o.rollPoint(t.clone());
|
|
591
591
|
if (Math.abs(e.x - h.x) < 1e-4) break;
|
|
592
|
-
h.x > e.x ? n.copy(
|
|
592
|
+
h.x > e.x ? n.copy(o.position) : i.copy(o.position);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
rollPoint(t) {
|
|
@@ -607,10 +607,10 @@ class me {
|
|
|
607
607
|
0
|
|
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
|
-
const n = this.m_Size.x,
|
|
610
|
+
const n = this.m_Size.x, o = this.m_Size.y;
|
|
611
611
|
e = It(e, -0.99, 0.99);
|
|
612
|
-
const
|
|
613
|
-
this.m_StartHandle.set(n, 0,
|
|
612
|
+
const a = Vt(0.5, 1, e), h = Vt(0.5, 0, e);
|
|
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.) ----
|
|
616
616
|
get cylinder() {
|
|
@@ -796,12 +796,12 @@ class At {
|
|
|
796
796
|
}
|
|
797
797
|
}
|
|
798
798
|
function Ht(r, t, e, s = new c.Vector3()) {
|
|
799
|
-
let i = t.x - r.x, n = t.y - r.y,
|
|
800
|
-
i *=
|
|
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
|
+
i *= a, n *= a, o *= a;
|
|
801
801
|
let h = e.x - r.x, m = e.y - r.y, l = e.z - r.z;
|
|
802
|
-
|
|
803
|
-
const d = n * l -
|
|
804
|
-
return
|
|
802
|
+
a = 1 / Math.sqrt(h * h + m * m + l * l), h *= a, m *= a, l *= a;
|
|
803
|
+
const d = n * l - o * m, g = o * h - i * l, _ = i * m - n * h;
|
|
804
|
+
return a = 1 / Math.sqrt(d * d + g * g + _ * _), s.set(d * a, g * a, _ * a);
|
|
805
805
|
}
|
|
806
806
|
class st {
|
|
807
807
|
constructor(t, e = !1, s = !1) {
|
|
@@ -870,8 +870,8 @@ class Pt {
|
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
872
|
class Tt {
|
|
873
|
-
constructor(t, e, s, i, n,
|
|
874
|
-
this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left =
|
|
873
|
+
constructor(t, e, s, i, n, o = !0) {
|
|
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
877
|
return new Tt(
|
|
@@ -900,24 +900,24 @@ function lt(r, t, e) {
|
|
|
900
900
|
}
|
|
901
901
|
function xt(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),
|
|
904
|
-
t.push(
|
|
903
|
+
const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new Pt(s.index, e.index, i.index, n);
|
|
904
|
+
t.push(o);
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
907
|
function Mt(r, t, e, s, i) {
|
|
908
908
|
for (const n of r) {
|
|
909
909
|
if (!n.active) return;
|
|
910
|
-
for (let
|
|
911
|
-
const
|
|
910
|
+
for (let o = 0; o < s; o++) {
|
|
911
|
+
const a = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[o * e + h], d = t[o * e + n.index];
|
|
912
912
|
i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
-
function
|
|
916
|
+
function Ct(r, t, e, s, i) {
|
|
917
917
|
for (const n of r) {
|
|
918
918
|
if (!n.active) return;
|
|
919
|
-
for (let
|
|
920
|
-
const
|
|
919
|
+
for (let o = 0; o < e; o++) {
|
|
920
|
+
const a = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[h * e + o], d = t[n.index * e + o];
|
|
921
921
|
i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
|
|
922
922
|
}
|
|
923
923
|
}
|
|
@@ -926,34 +926,34 @@ function qt(r, t, e, s = new c.Vector3()) {
|
|
|
926
926
|
const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
|
|
927
927
|
if (i === 0 || n === 0)
|
|
928
928
|
return s.copy(r).lerp(t, e);
|
|
929
|
-
const
|
|
930
|
-
let g =
|
|
929
|
+
const o = r.x / i, a = r.y / i, h = r.z / i, m = t.x / n, l = t.y / n, d = t.z / n;
|
|
930
|
+
let g = o * m + a * l + h * d;
|
|
931
931
|
g = Math.max(-1, Math.min(1, g));
|
|
932
932
|
const _ = Math.acos(g);
|
|
933
933
|
if (_ < 1e-6)
|
|
934
934
|
return s.copy(r).lerp(t, e);
|
|
935
935
|
const u = Math.sin(_), f = Math.sin((1 - e) * _) / u, p = Math.sin(e * _) / u, P = i + (n - i) * e;
|
|
936
936
|
return s.set(
|
|
937
|
-
(
|
|
938
|
-
(
|
|
937
|
+
(o * f + m * p) * P,
|
|
938
|
+
(a * f + l * p) * P,
|
|
939
939
|
(h * f + d * p) * P
|
|
940
940
|
);
|
|
941
941
|
}
|
|
942
942
|
function Qt(r, t, e, s, i) {
|
|
943
943
|
for (const n of r) {
|
|
944
|
-
const
|
|
944
|
+
const o = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, h = e.length;
|
|
945
945
|
for (let l = 0, d = n.endX - n.startX; l < d; l++) {
|
|
946
946
|
const g = h + l * 2 + 0, _ = h + l * 2 + 1, u = h + l * 2 + 2, f = h + l * 2 + 3;
|
|
947
|
-
n.flip ? Ot(t, g, _, u, f,
|
|
947
|
+
n.flip ? Ot(t, g, _, u, f, o) : Ft(t, g, _, u, f, o);
|
|
948
948
|
}
|
|
949
949
|
if (n.left)
|
|
950
950
|
for (let l = 0, d = n.endZ - n.startZ; l < d; l++) {
|
|
951
|
-
const g = h + l * 2 + 0 +
|
|
952
|
-
n.flip ? Ot(t, g, _, u, f,
|
|
951
|
+
const g = h + l * 2 + 0 + o * 2, _ = h + l * 2 + 1 + o * 2, u = h + l * 2 + 2 + o * 2, f = h + l * 2 + 3 + o * 2;
|
|
952
|
+
n.flip ? Ot(t, g, _, u, f, a) : Ft(t, g, _, u, f, a);
|
|
953
953
|
}
|
|
954
954
|
else
|
|
955
955
|
for (let l = 0, d = n.endZ - n.startZ; l < d; l++) {
|
|
956
|
-
const g = h + l * 2 + 0 +
|
|
956
|
+
const g = h + l * 2 + 0 + o * 2 + a, _ = h + l * 2 + 1 + o * 2 + a, u = h + l * 2 + 2 + o * 2 + a, f = h + l * 2 + 3 + o * 2 + a;
|
|
957
957
|
n.flip ? ft(t, g, _, u, f) : _t(t, g, _, u, f);
|
|
958
958
|
}
|
|
959
959
|
const m = s * i;
|
|
@@ -977,44 +977,44 @@ function Qt(r, t, e, s, i) {
|
|
|
977
977
|
}
|
|
978
978
|
function $t(r, t, e, s, i) {
|
|
979
979
|
const n = s * i;
|
|
980
|
-
let
|
|
981
|
-
const
|
|
980
|
+
let o = n * 2;
|
|
981
|
+
const a = new c.Vector3();
|
|
982
982
|
for (const h of r) {
|
|
983
983
|
for (let m = h.startX; m <= h.endX; m++) {
|
|
984
984
|
const l = m + h.startZ * s, d = t[l], g = t[l + s];
|
|
985
|
-
|
|
985
|
+
a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l + n]);
|
|
986
986
|
}
|
|
987
987
|
for (let m = h.startX; m <= h.endX; m++) {
|
|
988
988
|
const l = m + h.endZ * s, d = t[l + n], g = t[l + n - s];
|
|
989
|
-
|
|
989
|
+
a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l]);
|
|
990
990
|
}
|
|
991
991
|
for (let m = h.startZ; m <= h.endZ; m++) {
|
|
992
992
|
const l = m * s + h.startX, d = t[l + n], g = t[l + n + 1];
|
|
993
|
-
|
|
993
|
+
a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l]);
|
|
994
994
|
}
|
|
995
995
|
for (let m = h.startZ; m <= h.endZ; m++) {
|
|
996
996
|
const l = m * s + h.endX, d = t[l], g = t[l - 1];
|
|
997
|
-
|
|
997
|
+
a.subVectors(d, g).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(d), e[o].copy(a), t[o++].copy(t[l + n]);
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
function de(r, t, e, s, i) {
|
|
1002
1002
|
const n = [];
|
|
1003
|
-
for (const
|
|
1004
|
-
for (let
|
|
1005
|
-
const h =
|
|
1003
|
+
for (const o of r) {
|
|
1004
|
+
for (let a = o.startX; a < o.endX; a++) {
|
|
1005
|
+
const h = a + o.startZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
|
|
1006
1006
|
n.push([m, l]);
|
|
1007
1007
|
}
|
|
1008
|
-
for (let
|
|
1009
|
-
const h =
|
|
1008
|
+
for (let a = o.startX; a < o.endX; a++) {
|
|
1009
|
+
const h = a + o.endZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
|
|
1010
1010
|
n.push([m, l]);
|
|
1011
1011
|
}
|
|
1012
|
-
for (let
|
|
1013
|
-
const h =
|
|
1012
|
+
for (let a = o.startZ; a < o.endZ; a++) {
|
|
1013
|
+
const h = a * e + o.startX, m = (a + 1) * e + o.startX, l = t[h].clone().applyMatrix4(i), d = t[m].clone().applyMatrix4(i);
|
|
1014
1014
|
n.push([l, d]);
|
|
1015
1015
|
}
|
|
1016
|
-
for (let
|
|
1017
|
-
const h =
|
|
1016
|
+
for (let a = o.startZ; a < o.endZ; a++) {
|
|
1017
|
+
const h = a * e + o.endX, m = (a + 1) * e + o.endX, l = t[h].clone().applyMatrix4(i), d = t[m].clone().applyMatrix4(i);
|
|
1018
1018
|
n.push([l, d]);
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
@@ -1026,21 +1026,21 @@ function Ft(r, t, e, s, i, n) {
|
|
|
1026
1026
|
function Ot(r, t, e, s, i, n) {
|
|
1027
1027
|
ft(r, t, e, s, i), t += n, e += n, s += n, i += n, ft(r, t, e, s, i);
|
|
1028
1028
|
}
|
|
1029
|
-
function Yt(r, t, e, s, i, n,
|
|
1030
|
-
_t(r, e, s, i, n), e +=
|
|
1029
|
+
function Yt(r, t, e, s, i, n, o) {
|
|
1030
|
+
_t(r, e, s, i, n), e += o, s += o, i += o, n += o, ft(t, e, s, i, n);
|
|
1031
1031
|
}
|
|
1032
1032
|
function Kt(r, t, e, s, i, n) {
|
|
1033
|
-
const
|
|
1033
|
+
const o = i.left * s.x, a = (1 - i.right) * s.x, h = i.down * s.y, m = (1 - i.up) * s.y, l = t.length, d = e.length;
|
|
1034
1034
|
if (n > 1)
|
|
1035
1035
|
for (let _ = 0; _ < d; _++)
|
|
1036
1036
|
for (let u = 0; u < l; u++) {
|
|
1037
|
-
const f = lt(
|
|
1037
|
+
const f = lt(a, o, t[u]), p = lt(m, h, e[_]);
|
|
1038
1038
|
r.push(new c.Vector2(p, f));
|
|
1039
1039
|
}
|
|
1040
1040
|
else
|
|
1041
1041
|
for (let _ = 0; _ < d; _++)
|
|
1042
1042
|
for (let u = 0; u < l; u++) {
|
|
1043
|
-
const f = lt(
|
|
1043
|
+
const f = lt(o, a, t[u]), p = lt(m, h, e[_]);
|
|
1044
1044
|
r.push(new c.Vector2(f, p));
|
|
1045
1045
|
}
|
|
1046
1046
|
const g = r.length;
|
|
@@ -1056,9 +1056,9 @@ function ft(r, t, e, s, i) {
|
|
|
1056
1056
|
function Jt(r, t, e, s) {
|
|
1057
1057
|
const i = [];
|
|
1058
1058
|
for (let n = 0; n < e - 1; n++)
|
|
1059
|
-
for (let
|
|
1060
|
-
let
|
|
1061
|
-
|
|
1059
|
+
for (let o = 0; o < t - 1; o++) {
|
|
1060
|
+
let a = r[n * t + o].clone(), h = r[n * t + o + 1].clone(), m = r[(n + 1) * t + o].clone(), l = r[(n + 1) * t + o + 1].clone();
|
|
1061
|
+
a.applyMatrix4(s), h.applyMatrix4(s), m.applyMatrix4(s), l.applyMatrix4(s), i.push([a, h, m, l]);
|
|
1062
1062
|
}
|
|
1063
1063
|
return i;
|
|
1064
1064
|
}
|
|
@@ -1072,7 +1072,7 @@ const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
1072
1072
|
seamNodesToSeams: xt,
|
|
1073
1073
|
updateBorders: $t,
|
|
1074
1074
|
updateXSeams: Mt,
|
|
1075
|
-
updateZSeams:
|
|
1075
|
+
updateZSeams: Ct
|
|
1076
1076
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1077
1077
|
class Zt {
|
|
1078
1078
|
get geometry() {
|
|
@@ -1086,25 +1086,25 @@ class Zt {
|
|
|
1086
1086
|
}
|
|
1087
1087
|
constructor(t, e) {
|
|
1088
1088
|
this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
|
|
1089
|
-
for (let
|
|
1090
|
-
this.m_BaseVertices[
|
|
1089
|
+
for (let o = 0; o < e.baseVertexCount; o++)
|
|
1090
|
+
this.m_BaseVertices[o] = new c.Vector3();
|
|
1091
1091
|
this.m_Vertices = new Array(e.vertexCount);
|
|
1092
|
-
for (let
|
|
1093
|
-
this.m_Vertices[
|
|
1092
|
+
for (let o = 0; o < e.vertexCount; o++)
|
|
1093
|
+
this.m_Vertices[o] = new c.Vector3();
|
|
1094
1094
|
this.m_Normals = new Array(e.vertexCount);
|
|
1095
|
-
for (let
|
|
1096
|
-
this.m_Normals[
|
|
1095
|
+
for (let o = 0; o < e.vertexCount; o++)
|
|
1096
|
+
this.m_Normals[o] = new c.Vector3();
|
|
1097
1097
|
if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
|
|
1098
|
-
const
|
|
1099
|
-
this.m_Geometry.setIndex(new c.BufferAttribute(
|
|
1098
|
+
const o = new Uint32Array(e.triangles);
|
|
1099
|
+
this.m_Geometry.setIndex(new c.BufferAttribute(o, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
|
|
1100
1100
|
} else {
|
|
1101
|
-
const
|
|
1101
|
+
const o = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(o);
|
|
1102
1102
|
let h = 0;
|
|
1103
|
-
|
|
1103
|
+
a.set(e.frontTriangles, h), this.m_Geometry.addGroup(h, e.frontTriangles.length, 0), h += e.frontTriangles.length, a.set(e.backTriangles, h), this.m_Geometry.addGroup(h, e.backTriangles.length, 1), h += e.backTriangles.length, a.set(e.borderTriangles, h), this.m_Geometry.addGroup(h, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(a, 1));
|
|
1104
1104
|
}
|
|
1105
1105
|
const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
|
|
1106
|
-
for (let
|
|
1107
|
-
n[
|
|
1106
|
+
for (let o = 0; o < e.texcoords.length; o++)
|
|
1107
|
+
n[o * 2] = e.texcoords[o].x, n[o * 2 + 1] = e.texcoords[o].y;
|
|
1108
1108
|
this.m_Geometry.setAttribute(
|
|
1109
1109
|
"position",
|
|
1110
1110
|
new c.BufferAttribute(s, 3)
|
|
@@ -1124,11 +1124,11 @@ class Zt {
|
|
|
1124
1124
|
* Ported from lines ~2167-2183.
|
|
1125
1125
|
*/
|
|
1126
1126
|
updateBaseVertices() {
|
|
1127
|
-
const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length,
|
|
1128
|
-
let
|
|
1129
|
-
for (let h = 0; h <
|
|
1127
|
+
const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, o = s.length;
|
|
1128
|
+
let a = 0;
|
|
1129
|
+
for (let h = 0; h < o; h++)
|
|
1130
1130
|
for (let m = 0; m < n; m++)
|
|
1131
|
-
t[
|
|
1131
|
+
t[a++].set(e[m] + i, 0, s[h]);
|
|
1132
1132
|
}
|
|
1133
1133
|
// ── UpdateMesh ─────────────────────────────────────────────────────────
|
|
1134
1134
|
/**
|
|
@@ -1147,28 +1147,28 @@ class Zt {
|
|
|
1147
1147
|
* Ported from lines ~2185-2255.
|
|
1148
1148
|
*/
|
|
1149
1149
|
updateMesh() {
|
|
1150
|
-
const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length,
|
|
1151
|
-
for (let u = 0; u <
|
|
1150
|
+
const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, o = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, h = new c.Vector3(), m = new c.Vector3(), l = new c.Vector3();
|
|
1151
|
+
for (let u = 0; u < a; u++)
|
|
1152
1152
|
s[u].set(0, 0, 0);
|
|
1153
|
-
Mt(this.m_Pattern.xSeams, t, n,
|
|
1154
|
-
for (let u = 0; u <
|
|
1153
|
+
Mt(this.m_Pattern.xSeams, t, n, o, !1), Ct(this.m_Pattern.zSeams, t, n, o, !1);
|
|
1154
|
+
for (let u = 0; u < o - 1; u++) {
|
|
1155
1155
|
const f = u + 1;
|
|
1156
1156
|
for (let p = 0; p < n - 1; p++) {
|
|
1157
|
-
const P = p + 1, B = u * n + p, M = u * n + P,
|
|
1158
|
-
Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[
|
|
1157
|
+
const P = p + 1, B = u * n + p, M = u * n + P, w = f * n + p, v = f * n + P, k = t[B], O = t[M], Z = t[w], V = t[v];
|
|
1158
|
+
Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[w].add(l), s[v].add(l);
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
-
for (let u = 0; u <
|
|
1161
|
+
for (let u = 0; u < a; u++)
|
|
1162
1162
|
s[u].divideScalar(i[u]).normalize();
|
|
1163
|
-
Mt(this.m_Pattern.xSeams, s, n,
|
|
1163
|
+
Mt(this.m_Pattern.xSeams, s, n, o, !0), Ct(this.m_Pattern.zSeams, s, n, o, !0);
|
|
1164
1164
|
const d = this.m_Pattern.thickness / 2;
|
|
1165
|
-
for (let u = 0; u <
|
|
1165
|
+
for (let u = 0; u < a; u++) {
|
|
1166
1166
|
const f = s[u];
|
|
1167
|
-
s[u +
|
|
1167
|
+
s[u + a].copy(f).negate();
|
|
1168
1168
|
const p = t[u];
|
|
1169
|
-
e[u].copy(p).addScaledVector(f, d), e[u +
|
|
1169
|
+
e[u].copy(p).addScaledVector(f, d), e[u + a].copy(p).addScaledVector(f, -d);
|
|
1170
1170
|
}
|
|
1171
|
-
$t(this.m_Pattern.borders, e, s, n,
|
|
1171
|
+
$t(this.m_Pattern.borders, e, s, n, o);
|
|
1172
1172
|
const g = this.m_Geometry.getAttribute(
|
|
1173
1173
|
"position"
|
|
1174
1174
|
), _ = this.m_Geometry.getAttribute(
|
|
@@ -1320,16 +1320,16 @@ class pe {
|
|
|
1320
1320
|
return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
|
|
1321
1321
|
}
|
|
1322
1322
|
applyTextureProperty(t, e, s, i) {
|
|
1323
|
-
const n = this.getSTKey(i),
|
|
1324
|
-
if (
|
|
1325
|
-
t.map !==
|
|
1323
|
+
const n = this.getSTKey(i), o = this.m_MaterialTextures.get(e);
|
|
1324
|
+
if (o && o.source === s && o.stKey === n) {
|
|
1325
|
+
t.map !== o.texture && (t.map = o.texture, t.needsUpdate = !0);
|
|
1326
1326
|
return;
|
|
1327
1327
|
}
|
|
1328
1328
|
this.clearManagedTexture(e);
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1329
|
+
const a = s.clone();
|
|
1330
|
+
a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = c.RepeatWrapping, a.wrapT = c.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
|
|
1331
1331
|
source: s,
|
|
1332
|
-
texture:
|
|
1332
|
+
texture: a,
|
|
1333
1333
|
stKey: n
|
|
1334
1334
|
});
|
|
1335
1335
|
}
|
|
@@ -1363,8 +1363,8 @@ class xe {
|
|
|
1363
1363
|
this.m_Stack.push(t);
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
|
-
var
|
|
1367
|
-
class
|
|
1366
|
+
var wt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(wt || {}), Me = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(Me || {}), Ce = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(Ce || {}), we = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(we || {});
|
|
1367
|
+
class ye {
|
|
1368
1368
|
constructor(t) {
|
|
1369
1369
|
this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
|
|
1370
1370
|
}
|
|
@@ -1481,16 +1481,16 @@ class rt {
|
|
|
1481
1481
|
clampCurve(t, e, s) {
|
|
1482
1482
|
if (this.m_Curve === null || t === null) return null;
|
|
1483
1483
|
const i = t.keys.map((h) => ({ time: h.time, value: h.value })), n = i.length;
|
|
1484
|
-
let
|
|
1484
|
+
let o = 1 / 0, a = -1 / 0;
|
|
1485
1485
|
for (let h = 0; h < n; h++) {
|
|
1486
1486
|
const m = i[h].time;
|
|
1487
|
-
|
|
1487
|
+
o = Math.min(o, m), a = Math.max(a, m);
|
|
1488
1488
|
}
|
|
1489
1489
|
for (let h = 0; h < n; h++) {
|
|
1490
1490
|
let m = i[h].time, l = i[h].value;
|
|
1491
|
-
m = Pe(
|
|
1491
|
+
m = Pe(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
|
|
1492
1492
|
}
|
|
1493
|
-
return new
|
|
1493
|
+
return new ye(i);
|
|
1494
1494
|
}
|
|
1495
1495
|
// ── Value-type clone ────────────────────────────────────────────────────
|
|
1496
1496
|
clone() {
|
|
@@ -1574,7 +1574,7 @@ let Lt = R, Xe = class extends Error {
|
|
|
1574
1574
|
);
|
|
1575
1575
|
}
|
|
1576
1576
|
};
|
|
1577
|
-
const
|
|
1577
|
+
const ot = class ot extends c.Group {
|
|
1578
1578
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
1579
1579
|
constructor(t) {
|
|
1580
1580
|
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 ht({
|
|
@@ -1603,10 +1603,10 @@ const at = class at extends c.Group {
|
|
|
1603
1603
|
thickness: t.pagePaperSetup.thickness ?? 0.02,
|
|
1604
1604
|
stiffness: t.pagePaperSetup.stiffness ?? 0.2,
|
|
1605
1605
|
material: t.pagePaperSetup.material ?? null
|
|
1606
|
-
}))),
|
|
1606
|
+
}))), ot.s_Instances.add(this);
|
|
1607
1607
|
}
|
|
1608
1608
|
static get instances() {
|
|
1609
|
-
return [...
|
|
1609
|
+
return [...ot.s_Instances];
|
|
1610
1610
|
}
|
|
1611
1611
|
// ── Internal accessors ─────────────────────────────────────────────────
|
|
1612
1612
|
get minPaperWidth() {
|
|
@@ -1731,15 +1731,15 @@ const at = class at 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 === X.RightToLeft, s = this.m_Papers.length, i = (n,
|
|
1735
|
-
let
|
|
1736
|
-
|
|
1734
|
+
const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
|
|
1735
|
+
let a = n * 2;
|
|
1736
|
+
o && a++, e && (a = s * 2 - a - 1), t.includes(a) || t.push(a);
|
|
1737
1737
|
};
|
|
1738
1738
|
for (let n = 0; n < s; n++) {
|
|
1739
|
-
const
|
|
1740
|
-
if (
|
|
1739
|
+
const o = this.m_Papers[n];
|
|
1740
|
+
if (o.isFalling || o.isTurning)
|
|
1741
1741
|
n > 0 && i(n - 1, !0), i(n, !1), i(n, !0), n < s - 1 && i(n + 1, !1);
|
|
1742
|
-
else if (
|
|
1742
|
+
else if (o.isOnRightStack) {
|
|
1743
1743
|
n > 0 && i(n - 1, !0), i(n, !1);
|
|
1744
1744
|
break;
|
|
1745
1745
|
}
|
|
@@ -1767,8 +1767,8 @@ const at = class at extends c.Group {
|
|
|
1767
1767
|
this.cancelPendingAutoTurns();
|
|
1768
1768
|
const n = typeof i == "number" ? new rt(i) : i;
|
|
1769
1769
|
if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
|
|
1770
|
-
for (let
|
|
1771
|
-
const
|
|
1770
|
+
for (let o = 0; o < s && this.canAutoTurn(t); o++) {
|
|
1771
|
+
const a = o / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = o > 0 ? n.getValue(h, a) : 0, l = e.getModeValue(), d = e.getTwistValue(h, a), g = e.getBendValue(h, a), _ = e.getDurationValue(h, a);
|
|
1772
1772
|
this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: d, bend: g, duration: _, delay: m });
|
|
1773
1773
|
}
|
|
1774
1774
|
return this.m_AutoTurnTimer = 0, !0;
|
|
@@ -1797,7 +1797,7 @@ const at = class at extends c.Group {
|
|
|
1797
1797
|
if (this.isTurning) return null;
|
|
1798
1798
|
const e = this.getFrontPapers();
|
|
1799
1799
|
if (e.length > 0) {
|
|
1800
|
-
const s = t ===
|
|
1800
|
+
const s = t === wt.Next, i = e[s ? e.length - 1 : 0];
|
|
1801
1801
|
if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
|
|
1802
1802
|
return i;
|
|
1803
1803
|
}
|
|
@@ -1807,7 +1807,7 @@ const at = class at extends c.Group {
|
|
|
1807
1807
|
const e = this.getAutoTurnPaper(t);
|
|
1808
1808
|
if (e === null) return 0;
|
|
1809
1809
|
let s = 1;
|
|
1810
|
-
return t ===
|
|
1810
|
+
return t === wt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
|
|
1811
1811
|
}
|
|
1812
1812
|
canAutoTurn(t) {
|
|
1813
1813
|
return this.getAutoTurnPaper(t) !== null;
|
|
@@ -1822,7 +1822,7 @@ const at = class at extends c.Group {
|
|
|
1822
1822
|
* Equivalent to Unity's Start/Awake.
|
|
1823
1823
|
*/
|
|
1824
1824
|
init() {
|
|
1825
|
-
|
|
1825
|
+
ot.s_Instances.add(this), this.hardClear(), this.m_BuildOnAwake && this.build();
|
|
1826
1826
|
}
|
|
1827
1827
|
/**
|
|
1828
1828
|
* Call every frame with delta time.
|
|
@@ -1837,47 +1837,47 @@ const at = class at extends c.Group {
|
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
1839
|
dispose() {
|
|
1840
|
-
|
|
1840
|
+
ot.s_Instances.delete(this), this.hardClear();
|
|
1841
1841
|
}
|
|
1842
1842
|
// ── Build ─────────────────────────────────────────────────────────────
|
|
1843
1843
|
build() {
|
|
1844
1844
|
if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
|
|
1845
1845
|
if (this.m_MeshFactory === null && (this.m_MeshFactory = new _e()), this.m_RendererFactory === null) {
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1846
|
+
const C = new c.Object3D();
|
|
1847
|
+
C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new fe(this.m_Root);
|
|
1848
1848
|
}
|
|
1849
1849
|
this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
|
|
1850
1850
|
const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
|
|
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
1852
|
const e = new At(this.m_CoverPaperSetup), s = new At(this.m_PagePaperSetup);
|
|
1853
1853
|
this.m_Content.init(this);
|
|
1854
|
-
let i = this.m_Content.coverContents, n = this.m_Content.pageContents,
|
|
1855
|
-
this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(),
|
|
1856
|
-
const
|
|
1854
|
+
let i = this.m_Content.coverContents, n = this.m_Content.pageContents, o = this.m_InitialOpenProgress;
|
|
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);
|
|
1856
|
+
const a = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
|
|
1857
1857
|
let m = 0, l = 0, d = 0;
|
|
1858
|
-
this.m_Papers = new Array(
|
|
1859
|
-
for (let
|
|
1860
|
-
const I = this.m_HasCover && (
|
|
1861
|
-
|
|
1858
|
+
this.m_Papers = new Array(a);
|
|
1859
|
+
for (let C = 0; C < a; C++) {
|
|
1860
|
+
const I = this.m_HasCover && (C < h || C >= a - h), L = this.m_RendererFactory.get("Paper"), S = this.m_Papers[C] = new me(I, C, this, L);
|
|
1861
|
+
S.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (S.transform.scale.set(-1, 1, 1), S.setTime(1)), I ? (S.setContentData(i[l++], i[l++], C > h), S.setMaterialData(e), S.setPaperSetup(this.m_CoverPaperSetup)) : (S.setContentData(n[m++], n[m++]), S.setMaterialData(s), S.setPaperSetup(this.m_PagePaperSetup)), d += S.thickness;
|
|
1862
1862
|
}
|
|
1863
1863
|
this.m_TotalThickness = d;
|
|
1864
|
-
const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(
|
|
1864
|
+
const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(a / 2)].thickness;
|
|
1865
1865
|
this.m_MinPaperThickness = Math.min(g, _), this.m_MaxPaperThickness = Math.max(g, _);
|
|
1866
|
-
const u = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(
|
|
1866
|
+
const u = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(a / 2)].size.x;
|
|
1867
1867
|
this.m_MinPaperWidth = Math.min(u, f);
|
|
1868
|
-
const p = this.m_Papers[0].size.y, P = this.m_Papers[Math.floor(
|
|
1868
|
+
const p = this.m_Papers[0].size.y, P = this.m_Papers[Math.floor(a / 2)].size.y;
|
|
1869
1869
|
this.m_MinPaperHeight = Math.min(p, P), this.m_Bound = this.m_Binding.createBound(
|
|
1870
1870
|
this,
|
|
1871
1871
|
this.m_Root,
|
|
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, M = this.m_ReduceSubMeshes,
|
|
1876
|
-
for (let
|
|
1877
|
-
const I = this.m_Papers[
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
(
|
|
1875
|
+
const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), v = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), V = Math.floor(a / 2) - 1, U = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
|
|
1876
|
+
for (let C = 0; C < a; C++) {
|
|
1877
|
+
const I = this.m_Papers[C];
|
|
1878
|
+
C !== 0 && (I.prev = this.m_Papers[C - 1]), C !== a - 1 && (I.next = this.m_Papers[C + 1]), I.noHole = D && (C === V || C === U), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
|
|
1879
|
+
w.get(),
|
|
1880
|
+
(v == null ? void 0 : v.get()) ?? null,
|
|
1881
1881
|
k
|
|
1882
1882
|
);
|
|
1883
1883
|
}
|
|
@@ -1890,7 +1890,7 @@ const at = class at extends c.Group {
|
|
|
1890
1890
|
this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_Root !== null && (this.remove(this.m_Root), this.m_Root = null), this.m_MeshFactory !== null && (this.m_MeshFactory.destroy(), this.m_MeshFactory = null), this.m_RendererFactory !== null && (this.m_RendererFactory.destroy(), this.m_RendererFactory = null);
|
|
1891
1891
|
}
|
|
1892
1892
|
createPaperMeshDataPool(t, e, s = !1, i = !1) {
|
|
1893
|
-
const n = e ? 0 : t.quality,
|
|
1893
|
+
const n = e ? 0 : t.quality, o = this.m_Bound.createPaperPattern(
|
|
1894
1894
|
n,
|
|
1895
1895
|
t.size,
|
|
1896
1896
|
t.thickness,
|
|
@@ -1900,7 +1900,7 @@ const at = class at extends c.Group {
|
|
|
1900
1900
|
);
|
|
1901
1901
|
return new xe(
|
|
1902
1902
|
this.m_MeshFactory,
|
|
1903
|
-
|
|
1903
|
+
o,
|
|
1904
1904
|
e && this.m_Bound.useSharedMeshDataForLowpoly
|
|
1905
1905
|
);
|
|
1906
1906
|
}
|
|
@@ -1935,6 +1935,54 @@ const at = class at extends c.Group {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
return null;
|
|
1937
1937
|
}
|
|
1938
|
+
// ── Real-time content updates ──────────────────────────────────────
|
|
1939
|
+
/**
|
|
1940
|
+
* Hot-swap page/cover content without rebuilding geometry.
|
|
1941
|
+
* Preserves open progress, turning state, and animations.
|
|
1942
|
+
* If the new content has a different page/cover structure, falls back
|
|
1943
|
+
* to a full rebuild with state preservation.
|
|
1944
|
+
*/
|
|
1945
|
+
updateContent(t) {
|
|
1946
|
+
if (!this.m_IsBuilt) {
|
|
1947
|
+
this.m_Content = t;
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
const e = this.getCurrentOpenProgress();
|
|
1951
|
+
this.m_Content = t, this.m_Content.init(this), this.refreshContent() || (this.build(), this.setOpenProgress(e));
|
|
1952
|
+
}
|
|
1953
|
+
/**
|
|
1954
|
+
* Re-apply all page/cover textures from the current BookContent
|
|
1955
|
+
* to existing papers without rebuilding geometry.
|
|
1956
|
+
* Returns false if a structural rebuild is needed (page count changed).
|
|
1957
|
+
*/
|
|
1958
|
+
refreshContent() {
|
|
1959
|
+
if (!this.m_IsBuilt || !this.m_Content) return !1;
|
|
1960
|
+
let t = this.m_Content.coverContents, e = this.m_Content.pageContents;
|
|
1961
|
+
const s = Math.floor(t.length / 2), i = Math.floor(e.length / 2);
|
|
1962
|
+
if (s !== this.m_CoverPaperCount || i !== this.m_PagePaperCount)
|
|
1963
|
+
return !1;
|
|
1964
|
+
this.m_Content.direction % 2 !== 0 && (t = [...t].reverse(), e = [...e].reverse());
|
|
1965
|
+
const n = this.m_Papers.length, o = Math.floor(t.length / 4);
|
|
1966
|
+
let a = 0, h = 0;
|
|
1967
|
+
for (let m = 0; m < n; m++) {
|
|
1968
|
+
const l = this.m_Papers[m];
|
|
1969
|
+
this.m_HasCover && (m < o || m >= n - o) ? l.setContentData(
|
|
1970
|
+
t[h++],
|
|
1971
|
+
t[h++],
|
|
1972
|
+
m > o
|
|
1973
|
+
) : l.setContentData(e[a++], e[a++]), l.updateMaterials();
|
|
1974
|
+
}
|
|
1975
|
+
return this.m_WasIdle = !1, !0;
|
|
1976
|
+
}
|
|
1977
|
+
getCurrentOpenProgress() {
|
|
1978
|
+
const t = this.m_Papers.length;
|
|
1979
|
+
if (t === 0) return this.m_InitialOpenProgress;
|
|
1980
|
+
let e = 0;
|
|
1981
|
+
for (const i of this.m_Papers)
|
|
1982
|
+
i.isOnRightStack || e++;
|
|
1983
|
+
let s = e / t;
|
|
1984
|
+
return this.m_Content && this.m_Content.direction % 2 !== 0 && (s = 1 - s), s;
|
|
1985
|
+
}
|
|
1938
1986
|
// ── Live Pages ────────────────────────────────────────────────────────
|
|
1939
1987
|
updateLivePages() {
|
|
1940
1988
|
const t = /* @__PURE__ */ new Set(), e = this.m_Papers.length;
|
|
@@ -1952,8 +2000,8 @@ const at = class at extends c.Group {
|
|
|
1952
2000
|
s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
|
|
1953
2001
|
}
|
|
1954
2002
|
};
|
|
1955
|
-
|
|
1956
|
-
let
|
|
2003
|
+
ot.s_Instances = /* @__PURE__ */ new Set();
|
|
2004
|
+
let yt = ot;
|
|
1957
2005
|
class Te {
|
|
1958
2006
|
constructor() {
|
|
1959
2007
|
this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
|
|
@@ -2051,8 +2099,8 @@ class Ge {
|
|
|
2051
2099
|
let i = this.nextMultipleOf4(s);
|
|
2052
2100
|
e && (i = Math.min(i, 4));
|
|
2053
2101
|
const n = new Array(i);
|
|
2054
|
-
for (let
|
|
2055
|
-
n[
|
|
2102
|
+
for (let o = 0; o < i; o++)
|
|
2103
|
+
n[o] = this.getContent(o < s ? t[o] : null);
|
|
2056
2104
|
return n;
|
|
2057
2105
|
}
|
|
2058
2106
|
nextMultipleOf4(t) {
|
|
@@ -2120,9 +2168,9 @@ class qe {
|
|
|
2120
2168
|
if (!this.enabled || s.button !== 0) return;
|
|
2121
2169
|
this.m_IsPointerDown = !0;
|
|
2122
2170
|
const i = this.m_GetRay(s);
|
|
2123
|
-
for (const
|
|
2124
|
-
if (
|
|
2125
|
-
this.m_SelectedBook =
|
|
2171
|
+
for (const o of yt.instances)
|
|
2172
|
+
if (o.startTurning(i)) {
|
|
2173
|
+
this.m_SelectedBook = o, (n = this.onTurnStart) == null || n.call(this, o);
|
|
2126
2174
|
break;
|
|
2127
2175
|
}
|
|
2128
2176
|
}, this.m_OnPointerMove = (s) => {
|
|
@@ -2140,7 +2188,7 @@ class qe {
|
|
|
2140
2188
|
return this.m_Mouse.x = (t.clientX - e.left) / e.width * 2 - 1, this.m_Mouse.y = -((t.clientY - e.top) / e.height) * 2 + 1, this.m_Raycaster.setFromCamera(this.m_Mouse, this.m_Camera), this.m_Raycaster.ray;
|
|
2141
2189
|
}
|
|
2142
2190
|
}
|
|
2143
|
-
class
|
|
2191
|
+
class ve {
|
|
2144
2192
|
}
|
|
2145
2193
|
class Qe {
|
|
2146
2194
|
constructor(t, e) {
|
|
@@ -2158,7 +2206,7 @@ function Et(r, t, e, s) {
|
|
|
2158
2206
|
function Xt(r, t) {
|
|
2159
2207
|
return r++, r === t ? 0 : r;
|
|
2160
2208
|
}
|
|
2161
|
-
function
|
|
2209
|
+
function Se(r, t) {
|
|
2162
2210
|
return r === 0 ? t - 1 : r - 1;
|
|
2163
2211
|
}
|
|
2164
2212
|
const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4, Ie = 2, ze = 10, Ve = 0, De = 5;
|
|
@@ -2179,8 +2227,8 @@ function Ae(r, t) {
|
|
|
2179
2227
|
if (e.lengthSq() === 0) return new c.Quaternion();
|
|
2180
2228
|
let s = new c.Vector3().crossVectors(t, e);
|
|
2181
2229
|
if (s.lengthSq() === 0) {
|
|
2182
|
-
const
|
|
2183
|
-
s = new c.Vector3().crossVectors(
|
|
2230
|
+
const o = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
|
|
2231
|
+
s = new c.Vector3().crossVectors(o, e);
|
|
2184
2232
|
}
|
|
2185
2233
|
s.normalize();
|
|
2186
2234
|
const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
|
|
@@ -2244,7 +2292,7 @@ class Oe {
|
|
|
2244
2292
|
constructor(t, e, s, i, n) {
|
|
2245
2293
|
if (this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Book = s, this.m_Root = i, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
|
|
2246
2294
|
throw new Fe();
|
|
2247
|
-
const
|
|
2295
|
+
const o = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
|
|
2248
2296
|
this.updateStapleMesh(e, h);
|
|
2249
2297
|
const m = n ?? new c.MeshStandardMaterial({
|
|
2250
2298
|
color: e.color,
|
|
@@ -2254,9 +2302,9 @@ class Oe {
|
|
|
2254
2302
|
this.stapleMesh = new c.Mesh(h, m), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
|
|
2255
2303
|
0,
|
|
2256
2304
|
0,
|
|
2257
|
-
this.m_StapleMargin +
|
|
2305
|
+
this.m_StapleMargin + a.margin + o.margin
|
|
2258
2306
|
);
|
|
2259
|
-
let l =
|
|
2307
|
+
let l = o.thickness;
|
|
2260
2308
|
l = Math.max(this.m_BindingRadius, l);
|
|
2261
2309
|
for (const d of this.m_Book.papers) {
|
|
2262
2310
|
const g = d.size.clone();
|
|
@@ -2277,45 +2325,45 @@ class Oe {
|
|
|
2277
2325
|
i
|
|
2278
2326
|
);
|
|
2279
2327
|
this.m_StapleMargin = F(i, n, t.margin);
|
|
2280
|
-
const
|
|
2281
|
-
let
|
|
2282
|
-
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 &&
|
|
2283
|
-
|
|
2328
|
+
const o = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
|
|
2329
|
+
let a = t.count, h = (o - s * a) / (a - 1);
|
|
2330
|
+
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && a > 2; )
|
|
2331
|
+
a--, h = (o - s * a) / (a - 1), h = Math.max(h, 0);
|
|
2284
2332
|
const m = t.quality / 5, l = Math.floor(F(4, 20, m)), d = Math.floor(F(4, 10, m)), g = Math.floor(F(3, 10, m)), _ = this.m_StapleThickness / 2, u = _ * 2.5, f = 0.9, p = _ * 1;
|
|
2285
2333
|
let P = s / 2 * f;
|
|
2286
2334
|
P = Math.max(P, p * 2);
|
|
2287
2335
|
let B = 0;
|
|
2288
2336
|
B += this.m_Book.totalThickness / 2, B += _;
|
|
2289
|
-
const M = -(this.m_Book.papers[0].thickness / 2 + _),
|
|
2337
|
+
const M = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
|
|
2290
2338
|
{
|
|
2291
2339
|
for (let z = 0; z < d; z++) {
|
|
2292
|
-
const E = z / (d - 1), q = F(-90, -180, E) * tt,
|
|
2340
|
+
const E = z / (d - 1), q = F(-90, -180, E) * tt, y = new c.Vector3(
|
|
2293
2341
|
p * Math.sin(q),
|
|
2294
2342
|
0,
|
|
2295
2343
|
p * Math.cos(q)
|
|
2296
2344
|
);
|
|
2297
|
-
|
|
2345
|
+
y.x += p, y.z += p, y.x += M, w.push(y);
|
|
2298
2346
|
}
|
|
2299
2347
|
const x = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - _ * 0.5, 0, P);
|
|
2300
2348
|
for (let z = 0; z < g; z++) {
|
|
2301
2349
|
const E = z / (g - 1), G = Et(x, H, T, E);
|
|
2302
|
-
G.x += M,
|
|
2350
|
+
G.x += M, w.push(G);
|
|
2303
2351
|
}
|
|
2304
|
-
|
|
2352
|
+
w.reverse();
|
|
2305
2353
|
}
|
|
2306
|
-
const
|
|
2354
|
+
const v = new Array(l);
|
|
2307
2355
|
for (let x = 0; x < l; x++) {
|
|
2308
2356
|
const T = (90 - x * (360 / l)) * tt;
|
|
2309
|
-
|
|
2357
|
+
v[x] = new c.Vector3(Math.cos(T), Math.sin(T), 0), v[x].x *= 0.75;
|
|
2310
2358
|
}
|
|
2311
|
-
const k =
|
|
2359
|
+
const k = w.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), U = new Array(
|
|
2312
2360
|
(O * 2 - 1) * l * 2 * 3
|
|
2313
2361
|
);
|
|
2314
2362
|
for (let x = 0; x < O * 2; x++)
|
|
2315
2363
|
Z[x] = new c.Vector3(), V[x] = new c.Vector3();
|
|
2316
2364
|
let D = 0;
|
|
2317
2365
|
for (let x = 0; x < k; x++) {
|
|
2318
|
-
const H =
|
|
2366
|
+
const H = w[Se(x, k)], T = w[x], z = w[Xt(x, k)];
|
|
2319
2367
|
let E;
|
|
2320
2368
|
if (x === 0)
|
|
2321
2369
|
E = new c.Vector3(1, 0, -2).normalize();
|
|
@@ -2325,39 +2373,39 @@ class Oe {
|
|
|
2325
2373
|
const K = T.clone().sub(H).normalize(), J = z.clone().sub(T).normalize();
|
|
2326
2374
|
E = K.add(J).multiplyScalar(0.5);
|
|
2327
2375
|
}
|
|
2328
|
-
const G = new c.Vector3(0, 1, 0), q = Ae(E, G),
|
|
2376
|
+
const G = new c.Vector3(0, 1, 0), q = Ae(E, G), y = D;
|
|
2329
2377
|
let b = Wt(0, g / 4, x);
|
|
2330
2378
|
b = F(0.1, 1, b), b = Math.sqrt(b);
|
|
2331
2379
|
for (let K = 0; K < l; K++) {
|
|
2332
|
-
const J =
|
|
2380
|
+
const J = v[K].clone().applyQuaternion(q).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(_));
|
|
2333
2381
|
Z[D] = ct, V[D] = J.clone();
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
const se =
|
|
2337
|
-
Z[
|
|
2382
|
+
const at = T.clone().add(J.clone().multiplyScalar(_));
|
|
2383
|
+
at.z = s - at.z;
|
|
2384
|
+
const se = y + l - K - 1, vt = O * 2 - se - 1;
|
|
2385
|
+
Z[vt] = at, V[vt] = J.clone(), D++;
|
|
2338
2386
|
}
|
|
2339
2387
|
}
|
|
2340
|
-
let
|
|
2341
|
-
const I =
|
|
2388
|
+
let C = 0;
|
|
2389
|
+
const I = w.length * 2;
|
|
2342
2390
|
for (let x = 0; x < I - 1; x++) {
|
|
2343
2391
|
const H = x * l, T = (x + 1) * l;
|
|
2344
2392
|
for (let z = 0; z < l; z++) {
|
|
2345
|
-
const E = Xt(z, l), G = H + z, q = H + E,
|
|
2346
|
-
U[
|
|
2393
|
+
const E = Xt(z, l), G = H + z, q = H + E, y = T + E, b = T + z;
|
|
2394
|
+
U[C++] = G, U[C++] = b, U[C++] = q, U[C++] = q, U[C++] = b, U[C++] = y;
|
|
2347
2395
|
}
|
|
2348
2396
|
}
|
|
2349
|
-
const L = [...Z],
|
|
2350
|
-
for (let x = 0; x <
|
|
2397
|
+
const L = [...Z], S = [...V], Q = [...U], j = Z.map((x) => x.clone()), $ = [...U];
|
|
2398
|
+
for (let x = 0; x < a - 1; x++) {
|
|
2351
2399
|
const H = j.length;
|
|
2352
2400
|
for (let T = 0; T < $.length; T++)
|
|
2353
2401
|
$[T] += H;
|
|
2354
2402
|
for (let T = 0; T < j.length; T++)
|
|
2355
2403
|
j[T].z += h + s;
|
|
2356
|
-
L.push(...j.map((T) => T.clone())),
|
|
2404
|
+
L.push(...j.map((T) => T.clone())), S.push(...V.map((T) => T.clone())), Q.push(...$);
|
|
2357
2405
|
}
|
|
2358
|
-
const W = new Float32Array(L.length * 3), A = new Float32Array(
|
|
2406
|
+
const W = new Float32Array(L.length * 3), A = new Float32Array(S.length * 3);
|
|
2359
2407
|
for (let x = 0; x < L.length; x++)
|
|
2360
|
-
W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] =
|
|
2408
|
+
W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] = S[x].x, A[x * 3 + 1] = S[x].y, A[x * 3 + 2] = S[x].z;
|
|
2361
2409
|
e.setAttribute(
|
|
2362
2410
|
"position",
|
|
2363
2411
|
new c.BufferAttribute(W, 3)
|
|
@@ -2367,11 +2415,11 @@ class Oe {
|
|
|
2367
2415
|
), e.setIndex(Q);
|
|
2368
2416
|
}
|
|
2369
2417
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2370
|
-
createPaperPattern(t, e, s, i, n,
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2418
|
+
createPaperPattern(t, e, s, i, n, o) {
|
|
2419
|
+
const a = new Te();
|
|
2420
|
+
a.size = e, a.thickness = s;
|
|
2373
2421
|
const h = this.m_BindingRadius;
|
|
2374
|
-
|
|
2422
|
+
a.baseXOffset = -h;
|
|
2375
2423
|
const m = this.m_Quality + 1;
|
|
2376
2424
|
this.m_BindingVertexCount = m;
|
|
2377
2425
|
const l = t / 5, d = Math.min(e.x, e.y) / 60, g = Math.floor(
|
|
@@ -2382,70 +2430,70 @@ class Oe {
|
|
|
2382
2430
|
let P = p;
|
|
2383
2431
|
const B = h / m;
|
|
2384
2432
|
let M = 0;
|
|
2385
|
-
for (let
|
|
2433
|
+
for (let y = 1; y < m + 1; y++)
|
|
2386
2434
|
P = P.createNext(M), M += B;
|
|
2387
|
-
const
|
|
2388
|
-
for (let
|
|
2389
|
-
P = P.createNext(M), M +=
|
|
2390
|
-
const
|
|
2391
|
-
let k =
|
|
2435
|
+
const w = (e.x - h) / (g + 1);
|
|
2436
|
+
for (let y = m + 1; y < u; y++)
|
|
2437
|
+
P = P.createNext(M), M += w;
|
|
2438
|
+
const v = new st(0);
|
|
2439
|
+
let k = v;
|
|
2392
2440
|
const O = e.y / (f - 1);
|
|
2393
2441
|
let Z = 0;
|
|
2394
|
-
for (let
|
|
2442
|
+
for (let y = 0; y < f - 1; y++)
|
|
2395
2443
|
Z += O, k = k.createNext(Z);
|
|
2396
2444
|
const V = [], U = [], D = i.clone();
|
|
2397
2445
|
if (n) {
|
|
2398
|
-
let
|
|
2399
|
-
this.m_Book.hasCover && (
|
|
2446
|
+
let y = 0;
|
|
2447
|
+
this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2400
2448
|
const b = Math.max(0.01, s);
|
|
2401
|
-
D.left = 0, D.right = (this.getPX(
|
|
2449
|
+
D.left = 0, D.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
|
|
2402
2450
|
}
|
|
2403
|
-
const
|
|
2404
|
-
|
|
2451
|
+
const C = new ue(a, D, !1);
|
|
2452
|
+
C.insert(p, v, V, U), p.updateIndex(0), v.updateIndex(0), xt(V, a.xSeams), xt(U, a.zSeams);
|
|
2405
2453
|
const I = this.m_BindingVertexCount + 2, L = new Array(I);
|
|
2406
|
-
|
|
2407
|
-
for (let
|
|
2408
|
-
L[
|
|
2454
|
+
a.xNoneSeamIndexes = L, P = p;
|
|
2455
|
+
for (let y = 0; y < I; y++) {
|
|
2456
|
+
L[y] = P.index;
|
|
2409
2457
|
do
|
|
2410
2458
|
P = P.next;
|
|
2411
2459
|
while (P.seam);
|
|
2412
2460
|
}
|
|
2413
|
-
const
|
|
2414
|
-
u =
|
|
2461
|
+
const S = p.getValues(), Q = v.getValues();
|
|
2462
|
+
u = S.length, f = Q.length;
|
|
2415
2463
|
const j = u * f, $ = [], W = new Array(j).fill(0), A = [], x = [], H = [], T = [];
|
|
2416
2464
|
Kt(
|
|
2417
2465
|
$,
|
|
2418
|
-
|
|
2466
|
+
S,
|
|
2419
2467
|
Q,
|
|
2420
2468
|
e,
|
|
2421
2469
|
i,
|
|
2422
2470
|
this.m_Book.direction
|
|
2423
2471
|
);
|
|
2424
|
-
const z =
|
|
2425
|
-
let G =
|
|
2472
|
+
const z = C.leftNode.index, E = C.downNode.index;
|
|
2473
|
+
let G = C.rightNode.index, q = C.upNode.index;
|
|
2426
2474
|
G === 0 && (G = u - 1), q === 0 && (q = f - 1);
|
|
2427
|
-
for (let
|
|
2475
|
+
for (let y = 0; y < f - 1; y++)
|
|
2428
2476
|
for (let b = 0; b < u - 1; b++) {
|
|
2429
|
-
if (n &&
|
|
2477
|
+
if (n && y >= E && y < q && b >= z && b < G)
|
|
2430
2478
|
continue;
|
|
2431
|
-
const K =
|
|
2432
|
-
W[K] += 2, W[J] += 2, W[ct] += 2, W[
|
|
2479
|
+
const K = y * u + b, J = y * u + (b + 1), ct = (y + 1) * u + b, at = (y + 1) * u + (b + 1);
|
|
2480
|
+
W[K] += 2, W[J] += 2, W[ct] += 2, W[at] += 2, Yt(
|
|
2433
2481
|
A,
|
|
2434
2482
|
x,
|
|
2435
2483
|
K,
|
|
2436
2484
|
J,
|
|
2437
2485
|
ct,
|
|
2438
|
-
|
|
2486
|
+
at,
|
|
2439
2487
|
j
|
|
2440
2488
|
);
|
|
2441
2489
|
}
|
|
2442
|
-
if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), Qt(T, H, $, u, f),
|
|
2443
|
-
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2490
|
+
if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), Qt(T, H, $, u, f), a.baseXArray = S, a.baseZArray = Q, a.baseVertexCount = j, a.vertexCount = $.length, a.texcoords = $, a.weights = W, o) {
|
|
2491
|
+
a.subMeshCount = 1;
|
|
2492
|
+
const y = [];
|
|
2493
|
+
y.push(...A), y.push(...H), y.push(...x), a.triangles = y;
|
|
2446
2494
|
} else
|
|
2447
|
-
|
|
2448
|
-
return
|
|
2495
|
+
a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = x, a.borderTriangles = H;
|
|
2496
|
+
return a.borders = T, a;
|
|
2449
2497
|
}
|
|
2450
2498
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
2451
2499
|
updateRootPosition() {
|
|
@@ -2457,15 +2505,15 @@ class Oe {
|
|
|
2457
2505
|
resetPaperPosition(t) {
|
|
2458
2506
|
const e = this.m_Book.papers, s = e.length;
|
|
2459
2507
|
let i = 0;
|
|
2460
|
-
const n = e.length / 2 - 1,
|
|
2508
|
+
const n = e.length / 2 - 1, o = e.length / 2;
|
|
2461
2509
|
for (let M = 0; M < s; M++) {
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2464
|
-
const
|
|
2465
|
-
i +=
|
|
2510
|
+
const w = e[M];
|
|
2511
|
+
w.updateTime();
|
|
2512
|
+
const v = w.zTime, k = w.thickness;
|
|
2513
|
+
i += v * k, M === n && (i += v * this.m_BindingMidSpace / 2), M === o && (i += v * this.m_BindingMidSpace / 2);
|
|
2466
2514
|
}
|
|
2467
|
-
let
|
|
2468
|
-
const h = this.getStackZ(
|
|
2515
|
+
let a = this.getStackHeight(t.index) - t.thickness / 2;
|
|
2516
|
+
const h = this.getStackZ(a), m = 180 + h;
|
|
2469
2517
|
let l = t.isFlipped ? 1 : 0, d = F(h, m, l);
|
|
2470
2518
|
const g = d * tt, _ = new c.Vector3(
|
|
2471
2519
|
Math.cos(g) * this.m_BindingRadius,
|
|
@@ -2478,16 +2526,16 @@ class Oe {
|
|
|
2478
2526
|
let M = 0;
|
|
2479
2527
|
if (this.m_Book.alignToGround) {
|
|
2480
2528
|
u = e[0].size.x;
|
|
2481
|
-
const
|
|
2482
|
-
f = et(i, 0,
|
|
2529
|
+
const w = this.m_StackHeight / 2;
|
|
2530
|
+
f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2483
2531
|
}
|
|
2484
2532
|
d = F(P, -M, l);
|
|
2485
2533
|
} else {
|
|
2486
2534
|
let M = 0;
|
|
2487
2535
|
if (this.m_Book.alignToGround) {
|
|
2488
2536
|
u = e[0].size.x;
|
|
2489
|
-
const
|
|
2490
|
-
f =
|
|
2537
|
+
const w = this.m_StackHeight / 2;
|
|
2538
|
+
f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2491
2539
|
}
|
|
2492
2540
|
d = F(M, -P, l);
|
|
2493
2541
|
}
|
|
@@ -2499,9 +2547,9 @@ class Oe {
|
|
|
2499
2547
|
getPX(t, e) {
|
|
2500
2548
|
const s = this.m_Book.papers, i = s.length;
|
|
2501
2549
|
let n = 0;
|
|
2502
|
-
const
|
|
2550
|
+
const o = s.length / 2 - 1, a = s.length / 2;
|
|
2503
2551
|
for (let f = 0; f < i; f++)
|
|
2504
|
-
n += 0 * e, f ===
|
|
2552
|
+
n += 0 * e, f === o && (n += 0 * this.m_BindingMidSpace / 2), f === a && (n += 0 * this.m_BindingMidSpace / 2);
|
|
2505
2553
|
const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, _ = F(m, l, 0) * tt;
|
|
2506
2554
|
return new c.Vector3(
|
|
2507
2555
|
Math.cos(_) * this.m_BindingRadius,
|
|
@@ -2513,14 +2561,14 @@ class Oe {
|
|
|
2513
2561
|
updatePaperPosition(t) {
|
|
2514
2562
|
const e = this.m_Book.papers, s = e.length;
|
|
2515
2563
|
let i = 0;
|
|
2516
|
-
const n = e.length / 2 - 1,
|
|
2564
|
+
const n = e.length / 2 - 1, o = e.length / 2;
|
|
2517
2565
|
for (let M = 0; M < s; M++) {
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
const
|
|
2521
|
-
i +=
|
|
2566
|
+
const w = e[M];
|
|
2567
|
+
w.updateTime();
|
|
2568
|
+
const v = w.zTime, k = w.thickness;
|
|
2569
|
+
i += v * k, M === n && (i += v * this.m_BindingMidSpace / 2), M === o && (i += v * this.m_BindingMidSpace / 2);
|
|
2522
2570
|
}
|
|
2523
|
-
const
|
|
2571
|
+
const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
|
|
2524
2572
|
let l = t.zTime, d = F(h, m, l);
|
|
2525
2573
|
const g = d * tt, _ = new c.Vector3(
|
|
2526
2574
|
Math.cos(g) * this.m_BindingRadius,
|
|
@@ -2533,16 +2581,16 @@ class Oe {
|
|
|
2533
2581
|
let M = 0;
|
|
2534
2582
|
if (this.m_Book.alignToGround) {
|
|
2535
2583
|
u = e[0].size.x;
|
|
2536
|
-
const
|
|
2537
|
-
f = et(i, 0,
|
|
2584
|
+
const w = this.m_StackHeight / 2;
|
|
2585
|
+
f = et(i, 0, w) - w, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2538
2586
|
}
|
|
2539
2587
|
d = F(P, -M, l);
|
|
2540
2588
|
} else {
|
|
2541
2589
|
let M = 0;
|
|
2542
2590
|
if (this.m_Book.alignToGround) {
|
|
2543
2591
|
u = e[0].size.x;
|
|
2544
|
-
const
|
|
2545
|
-
f =
|
|
2592
|
+
const w = this.m_StackHeight / 2;
|
|
2593
|
+
f = w - et(i, w, w * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2546
2594
|
}
|
|
2547
2595
|
d = F(M, -P, l);
|
|
2548
2596
|
}
|
|
@@ -2579,22 +2627,22 @@ class Oe {
|
|
|
2579
2627
|
updateBindingVertices() {
|
|
2580
2628
|
const t = this.m_Book.papers;
|
|
2581
2629
|
let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
|
|
2582
|
-
const n = this.m_StapleThickness * 0.5,
|
|
2630
|
+
const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
|
|
2583
2631
|
for (let m = 0; m < h; m++) {
|
|
2584
|
-
const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, M = l.thickness,
|
|
2632
|
+
const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, M = l.thickness, w = g.xNoneSeamIndexes, v = d.position.clone();
|
|
2585
2633
|
let k = m, O = n;
|
|
2586
2634
|
m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
|
|
2587
|
-
const Z = (
|
|
2635
|
+
const Z = (o + M) * 0.5 + M * (k - 1), V = d.matrixWorld.clone().invert().multiply(a), U = k / (h / 2);
|
|
2588
2636
|
i = this.m_BindingRadius * F(0.45, 0.65, 1 - U);
|
|
2589
2637
|
for (let D = 0; D < P; D++) {
|
|
2590
|
-
const
|
|
2591
|
-
L.z +=
|
|
2592
|
-
const
|
|
2638
|
+
const C = f[D], I = new c.Vector3(0, 0, v.z + C), L = v.clone();
|
|
2639
|
+
L.z += C;
|
|
2640
|
+
const S = l.getDirection(C).multiplyScalar(i).add(L.clone());
|
|
2593
2641
|
if (m === 0 && D === 0) {
|
|
2594
2642
|
const A = t[h - 1], H = A.transform.position.clone().clone();
|
|
2595
|
-
H.z +=
|
|
2596
|
-
const T = A.getDirection(
|
|
2597
|
-
s =
|
|
2643
|
+
H.z += C;
|
|
2644
|
+
const T = A.getDirection(C).multiplyScalar(i).add(H);
|
|
2645
|
+
s = S.clone().sub(T).normalize(), e = new c.Vector3(
|
|
2598
2646
|
-s.y,
|
|
2599
2647
|
s.x,
|
|
2600
2648
|
0
|
|
@@ -2605,11 +2653,11 @@ class Oe {
|
|
|
2605
2653
|
k > 0 && I.add(e.clone().multiplyScalar(Z));
|
|
2606
2654
|
const Q = D * p;
|
|
2607
2655
|
_[Q] = I.clone().applyMatrix4(V), I.add(s.clone().multiplyScalar(O));
|
|
2608
|
-
const j = I.clone().applyMatrix4(V), $ =
|
|
2609
|
-
_[Q +
|
|
2656
|
+
const j = I.clone().applyMatrix4(V), $ = S.clone().applyMatrix4(V), W = L.clone().applyMatrix4(V);
|
|
2657
|
+
_[Q + w[1]] = j;
|
|
2610
2658
|
for (let A = 2; A < B; A++) {
|
|
2611
2659
|
const x = Wt(1, B, A);
|
|
2612
|
-
_[Q +
|
|
2660
|
+
_[Q + w[A]] = Et(
|
|
2613
2661
|
j,
|
|
2614
2662
|
$,
|
|
2615
2663
|
W,
|
|
@@ -2668,7 +2716,7 @@ class Ze {
|
|
|
2668
2716
|
return this.mesh;
|
|
2669
2717
|
}
|
|
2670
2718
|
}
|
|
2671
|
-
class $e extends
|
|
2719
|
+
class $e extends ve {
|
|
2672
2720
|
constructor() {
|
|
2673
2721
|
super(...arguments), this.quality = 3, this.stapleSetup = new He();
|
|
2674
2722
|
}
|
|
@@ -2705,9 +2753,9 @@ class ee {
|
|
|
2705
2753
|
}
|
|
2706
2754
|
const i = s.split(/\s+/);
|
|
2707
2755
|
let n = "";
|
|
2708
|
-
for (const
|
|
2709
|
-
const
|
|
2710
|
-
t.measureText(
|
|
2756
|
+
for (const o of i) {
|
|
2757
|
+
const a = n ? `${n} ${o}` : o;
|
|
2758
|
+
t.measureText(a).width > this.width && n ? (e.push(n), n = o) : n = a;
|
|
2711
2759
|
}
|
|
2712
2760
|
n && e.push(n);
|
|
2713
2761
|
}
|
|
@@ -2721,8 +2769,8 @@ class ee {
|
|
|
2721
2769
|
hitTest(t, e, s) {
|
|
2722
2770
|
const i = this.wrapLines(t);
|
|
2723
2771
|
if (i.length === 0) return !1;
|
|
2724
|
-
const n = i.length * this.fontSize * this.lineHeight,
|
|
2725
|
-
return e >= this.x && e <= this.x +
|
|
2772
|
+
const n = i.length * this.fontSize * this.lineHeight, o = this.width > 0 ? this.width : this._maxLineWidth(t, i);
|
|
2773
|
+
return e >= this.x && e <= this.x + o && s >= this.y && s <= this.y + n;
|
|
2726
2774
|
}
|
|
2727
2775
|
_maxLineWidth(t, e) {
|
|
2728
2776
|
t.font = this._font();
|
|
@@ -2740,8 +2788,8 @@ class ee {
|
|
|
2740
2788
|
t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top", this.shadowColor && this.shadowBlur > 0 && (t.shadowColor = this.shadowColor, t.shadowBlur = this.shadowBlur);
|
|
2741
2789
|
const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
|
|
2742
2790
|
for (let n = 0; n < e.length; n++) {
|
|
2743
|
-
let
|
|
2744
|
-
this.textAlign === "center" ?
|
|
2791
|
+
let o = this.x;
|
|
2792
|
+
this.textAlign === "center" ? o = this.x + (i - t.measureText(e[n]).width) / 2 : this.textAlign === "right" && (o = this.x + i - t.measureText(e[n]).width), t.fillText(e[n], o, this.y + n * s);
|
|
2745
2793
|
}
|
|
2746
2794
|
t.restore();
|
|
2747
2795
|
}
|
|
@@ -2797,7 +2845,7 @@ class Ye {
|
|
|
2797
2845
|
update(t) {
|
|
2798
2846
|
const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
|
|
2799
2847
|
e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
|
|
2800
|
-
for (const
|
|
2848
|
+
for (const o of this.texts) o.draw(e);
|
|
2801
2849
|
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
2802
2850
|
}
|
|
2803
2851
|
/**
|
|
@@ -2893,7 +2941,7 @@ class Je {
|
|
|
2893
2941
|
update(t) {
|
|
2894
2942
|
const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
|
|
2895
2943
|
e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
|
|
2896
|
-
for (const
|
|
2944
|
+
for (const o of this.texts) o.draw(e);
|
|
2897
2945
|
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
2898
2946
|
}
|
|
2899
2947
|
/**
|
|
@@ -2914,27 +2962,27 @@ class Je {
|
|
|
2914
2962
|
}
|
|
2915
2963
|
}
|
|
2916
2964
|
const Gt = 256;
|
|
2917
|
-
function Ne(r, t, e, s, i, n,
|
|
2918
|
-
const
|
|
2919
|
-
if (
|
|
2920
|
-
if (
|
|
2965
|
+
function Ne(r, t, e, s, i, n, o) {
|
|
2966
|
+
const a = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
|
|
2967
|
+
if (a <= 0 || h <= 0) return;
|
|
2968
|
+
if (o === "fill") {
|
|
2921
2969
|
r.drawImage(t, e, s, i, n);
|
|
2922
2970
|
return;
|
|
2923
2971
|
}
|
|
2924
|
-
const m =
|
|
2972
|
+
const m = o === "contain" ? Math.min(i / a, n / h) : Math.max(i / a, n / h), l = a * m, d = h * m;
|
|
2925
2973
|
r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
|
|
2926
2974
|
}
|
|
2927
|
-
function ts(r, t, e, s, i, n,
|
|
2928
|
-
const
|
|
2929
|
-
m.width =
|
|
2975
|
+
function ts(r, t, e, s, i, n, o) {
|
|
2976
|
+
const a = n ? Math.round(n * Gt) : 512, h = o ? Math.round(o * Gt) : 512, m = document.createElement("canvas");
|
|
2977
|
+
m.width = a, m.height = h;
|
|
2930
2978
|
const l = m.getContext("2d");
|
|
2931
|
-
if (l.fillStyle = r, l.fillRect(0, 0,
|
|
2932
|
-
const g = i ? 0 : Math.round(Math.min(
|
|
2933
|
-
Ne(l, e, g, g,
|
|
2979
|
+
if (l.fillStyle = r, l.fillRect(0, 0, a, h), e) {
|
|
2980
|
+
const g = i ? 0 : Math.round(Math.min(a, h) * 0.11);
|
|
2981
|
+
Ne(l, e, g, g, a - g * 2, h - g * 2, s);
|
|
2934
2982
|
} else {
|
|
2935
2983
|
l.fillStyle = "#333";
|
|
2936
|
-
const g = Math.round(Math.min(
|
|
2937
|
-
l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t,
|
|
2984
|
+
const g = Math.round(Math.min(a, h) * 0.094);
|
|
2985
|
+
l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, a / 2, h / 2);
|
|
2938
2986
|
}
|
|
2939
2987
|
const d = new c.CanvasTexture(m);
|
|
2940
2988
|
return d.colorSpace = c.SRGBColorSpace, d;
|
|
@@ -2952,15 +3000,15 @@ async function es(r) {
|
|
|
2952
3000
|
}
|
|
2953
3001
|
}
|
|
2954
3002
|
export {
|
|
2955
|
-
|
|
2956
|
-
|
|
3003
|
+
ye as AnimationCurve,
|
|
3004
|
+
wt as AutoTurnDirection,
|
|
2957
3005
|
Me as AutoTurnMode,
|
|
2958
3006
|
rt as AutoTurnSetting,
|
|
2959
|
-
|
|
2960
|
-
|
|
3007
|
+
we as AutoTurnSettingCurveTimeMode,
|
|
3008
|
+
Ce as AutoTurnSettingMode,
|
|
2961
3009
|
Lt as AutoTurnSettings,
|
|
2962
|
-
|
|
2963
|
-
|
|
3010
|
+
yt as Book,
|
|
3011
|
+
ve as BookBinding,
|
|
2964
3012
|
Qe as BookBound,
|
|
2965
3013
|
Ge as BookContent,
|
|
2966
3014
|
X as BookDirection,
|