@objectifthunes/three-book 0.2.0 → 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/SpreadContent.d.ts +72 -0
- package/dist/SpreadContent.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +532 -441
- package/package.json +1 -1
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, a = Math.cos(i), o = Math.sin(i), h = t * a, m = t * o, 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 a = 2 / s, o = a * n, h = 1 / (1 + o + 0.48 * o * o + 0.235 * o * o * o);
|
|
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 + a * m) * n;
|
|
76
|
+
e = (e - a * 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
|
-
function
|
|
81
|
-
const
|
|
80
|
+
function ie(r, t, e, s, i = 1 / 0, n = 1 / 60) {
|
|
81
|
+
const a = 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
|
+
), o = gt(
|
|
89
89
|
r.y,
|
|
90
90
|
t.y,
|
|
91
91
|
e.y,
|
|
@@ -100,12 +100,12 @@ function ee(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(a.velocity, o.velocity, h.velocity), new c.Vector3(a.value, o.value, h.value);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function ne(r) {
|
|
106
106
|
return new c.Vector3(r.x, 0, r.y);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function re(r) {
|
|
109
109
|
return new c.Vector3(r.x, r.z, 0);
|
|
110
110
|
}
|
|
111
111
|
function vt(r, t, e) {
|
|
@@ -124,36 +124,36 @@ function vt(r, t, e) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
function kt(r, t, e) {
|
|
127
|
-
return
|
|
127
|
+
return ae(r, t, e) ? r.clone() : oe(
|
|
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 ae(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 (
|
|
139
|
+
function oe(r, t, e, s) {
|
|
140
|
+
const i = e.x, n = e.y, a = r.x, o = 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(a - h) < 1e-5) {
|
|
142
|
+
if (a >= i - l && a <= i + l) {
|
|
143
143
|
const u = vt(
|
|
144
144
|
_,
|
|
145
145
|
-2 * _ * n,
|
|
146
|
-
g * (
|
|
146
|
+
g * (a * a - 2 * i * a + i * i) + _ * n * n - 1
|
|
147
147
|
);
|
|
148
148
|
if (u.rootCount === 1)
|
|
149
|
-
return new c.Vector2(
|
|
149
|
+
return new c.Vector2(a, u.root0);
|
|
150
150
|
if (u.rootCount === 2) {
|
|
151
151
|
let f = u.root0, p = u.root1;
|
|
152
|
-
return
|
|
152
|
+
return o < m && ([f, p] = [p, f]), new c.Vector2(a, p);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
} else {
|
|
156
|
-
const u = (m -
|
|
156
|
+
const u = (m - o) / (h - a), f = o - u * a, p = f - n, P = vt(
|
|
157
157
|
g + _ * u * u,
|
|
158
158
|
2 * p * u * _ - 2 * i * g,
|
|
159
159
|
i * i * g + p * p * _ - 1
|
|
@@ -161,8 +161,8 @@ function re(r, t, e, s) {
|
|
|
161
161
|
if (P.rootCount === 1)
|
|
162
162
|
return new c.Vector2(P.root0, u * P.root0 + f);
|
|
163
163
|
if (P.rootCount === 2) {
|
|
164
|
-
let B = P.root0,
|
|
165
|
-
return
|
|
164
|
+
let B = P.root0, M = P.root1;
|
|
165
|
+
return a < h && ([B, M] = [M, B]), new c.Vector2(M, u * M + f);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
return r.clone();
|
|
@@ -171,14 +171,14 @@ function bt(r, t) {
|
|
|
171
171
|
const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
|
|
172
172
|
return new c.Ray(e, s.sub(e));
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function he(r) {
|
|
175
175
|
return new c.Vector4(-r.x, r.y, r.z + r.x, r.w);
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function le(r) {
|
|
178
178
|
return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
|
|
179
179
|
}
|
|
180
180
|
var X = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(X || {});
|
|
181
|
-
const Bt = Math.PI / 180, Rt = 180 / Math.PI,
|
|
181
|
+
const Bt = Math.PI / 180, Rt = 180 / Math.PI, ce = 1192093e-13;
|
|
182
182
|
function dt(r) {
|
|
183
183
|
return r < 0 ? 0 : r > 1 ? 1 : r;
|
|
184
184
|
}
|
|
@@ -197,7 +197,7 @@ function Vt(r, t, e) {
|
|
|
197
197
|
function Dt(r, t, e) {
|
|
198
198
|
return e = dt((e - r) / (t - r)), e * e * (3 - 2 * e);
|
|
199
199
|
}
|
|
200
|
-
class
|
|
200
|
+
class me {
|
|
201
201
|
// ---- Constructor ----
|
|
202
202
|
constructor(t, e, s, i) {
|
|
203
203
|
this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new ut(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
|
|
@@ -320,7 +320,7 @@ class le {
|
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
startTurning(t) {
|
|
323
|
-
var n,
|
|
323
|
+
var n, a;
|
|
324
324
|
const e = t.clone();
|
|
325
325
|
t = bt(
|
|
326
326
|
t,
|
|
@@ -331,17 +331,17 @@ class le {
|
|
|
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 o = i;
|
|
335
|
+
if (o.x > 0 && o.x < this.m_Size.x && o.z > 0 && o.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(o), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), o.x < this.m_Size.x * 0.9) {
|
|
337
|
+
this.m_HandleOffset.set(o.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), (a = this.m_Next) == null || a.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
return !1;
|
|
@@ -380,14 +380,14 @@ class le {
|
|
|
380
380
|
this.m_StartHandle,
|
|
381
381
|
this.m_EndHandle,
|
|
382
382
|
this.m_IsFallingLeft ? n : 1 - n
|
|
383
|
-
), this.m_FallTime += t, e = Math.abs(n - 1) <
|
|
383
|
+
), this.m_FallTime += t, e = Math.abs(n - 1) < ce;
|
|
384
384
|
} else {
|
|
385
385
|
const n = new c.Vector3(
|
|
386
386
|
this.m_FallTime,
|
|
387
387
|
0,
|
|
388
388
|
this.m_FallTime * 0.75
|
|
389
389
|
);
|
|
390
|
-
this.m_CurrentHandle =
|
|
390
|
+
this.m_CurrentHandle = ie(
|
|
391
391
|
this.m_CurrentHandle,
|
|
392
392
|
this.m_EndHandle,
|
|
393
393
|
this.m_HandleVelocity,
|
|
@@ -490,19 +490,19 @@ class le {
|
|
|
490
490
|
), this.m_SubMeshCount = t);
|
|
491
491
|
const e = this.m_FrontContent.textureST.clone();
|
|
492
492
|
let s = this.m_BackContent.textureST.clone();
|
|
493
|
-
this.m_Book.direction > 1 ? s =
|
|
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 a = 0, o = 1;
|
|
497
|
+
this.m_Transform.scale.x === -1 && (a = 1, o = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
|
|
498
498
|
this.m_MaterialData.propertyBlock,
|
|
499
|
-
|
|
499
|
+
a
|
|
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
|
+
o
|
|
506
506
|
), this.m_UseBackContentForSides && this.m_Renderer.setPropertyBlock(
|
|
507
507
|
this.m_MaterialData.propertyBlock,
|
|
508
508
|
2
|
|
@@ -537,11 +537,11 @@ class le {
|
|
|
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)), a = this.rollPoint(new c.Vector3(s[2], 0, 0)), o = 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 = a.clone().sub(n).normalize(), l = h.clone().sub(o).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,15 +551,15 @@ class le {
|
|
|
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), a = Math.max(i - this.m_TurningRadius, 0.01), o = 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) * (a / 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) * (o / n)
|
|
560
|
+
), d = new c.Vector2(i, a), g = new c.Vector2(n, o);
|
|
561
561
|
t.x = It(t.x, -this.m_Size.x, this.m_Size.x);
|
|
562
|
-
const _ =
|
|
562
|
+
const _ = re(t), u = kt(
|
|
563
563
|
new c.Vector2(_.x, _.y),
|
|
564
564
|
m,
|
|
565
565
|
d
|
|
@@ -567,7 +567,7 @@ class le {
|
|
|
567
567
|
new c.Vector2(u.x, u.y),
|
|
568
568
|
l,
|
|
569
569
|
g
|
|
570
|
-
), p =
|
|
570
|
+
), p = ne(
|
|
571
571
|
new c.Vector3(f.x, f.y, 0)
|
|
572
572
|
);
|
|
573
573
|
this.m_CurrentHandle.copy(p);
|
|
@@ -579,17 +579,17 @@ class le {
|
|
|
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(), a = new ut();
|
|
583
|
+
a.radius = this.m_TurningRadius, a.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 o = 0; o < 100; o++) {
|
|
589
|
+
a.position = i.clone().add(n).multiplyScalar(0.5), this.m_Cylinder = a, this.m_Book.bound.updatePaperPosition(this);
|
|
590
|
+
const h = a.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(a.position) : i.copy(a.position);
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
rollPoint(t) {
|
|
@@ -607,10 +607,10 @@ class le {
|
|
|
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, a = this.m_Size.y;
|
|
611
611
|
e = It(e, -0.99, 0.99);
|
|
612
|
-
const
|
|
613
|
-
this.m_StartHandle.set(n, 0,
|
|
612
|
+
const o = Vt(0.5, 1, e), h = Vt(0.5, 0, e);
|
|
613
|
+
this.m_StartHandle.set(n, 0, a * o), this.m_EndHandle.set(-n, 0, a * h), this.m_IsAutoTurning = !0;
|
|
614
614
|
}
|
|
615
615
|
// ---- Public getter for the cylinder (used by BookBound etc.) ----
|
|
616
616
|
get cylinder() {
|
|
@@ -697,9 +697,9 @@ const Y = class Y {
|
|
|
697
697
|
};
|
|
698
698
|
Y.kMin = 0, Y.kMax = 0.25;
|
|
699
699
|
let pt = Y;
|
|
700
|
-
const
|
|
700
|
+
const N = class N {
|
|
701
701
|
constructor(t) {
|
|
702
|
-
this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new pt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ??
|
|
702
|
+
this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new pt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? N.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? N.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? N.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
|
|
703
703
|
}
|
|
704
704
|
// ── Properties ────────────────────────────────────────────────────────
|
|
705
705
|
get material() {
|
|
@@ -718,19 +718,19 @@ const U = class U {
|
|
|
718
718
|
return this.bookDirection > 1 ? this.m_Height : this.m_Width;
|
|
719
719
|
}
|
|
720
720
|
set width(t) {
|
|
721
|
-
this.m_Width = Math.max(t,
|
|
721
|
+
this.m_Width = Math.max(t, N.kMinSize);
|
|
722
722
|
}
|
|
723
723
|
get height() {
|
|
724
724
|
return this.bookDirection > 1 ? this.m_Width : this.m_Height;
|
|
725
725
|
}
|
|
726
726
|
set height(t) {
|
|
727
|
-
this.m_Height = Math.max(t,
|
|
727
|
+
this.m_Height = Math.max(t, N.kMinSize);
|
|
728
728
|
}
|
|
729
729
|
get thickness() {
|
|
730
730
|
return this.m_Thickness;
|
|
731
731
|
}
|
|
732
732
|
set thickness(t) {
|
|
733
|
-
this.m_Thickness = Math.max(t,
|
|
733
|
+
this.m_Thickness = Math.max(t, N.kMinThickness);
|
|
734
734
|
}
|
|
735
735
|
get stiffness() {
|
|
736
736
|
return this.m_Stiffness;
|
|
@@ -743,8 +743,8 @@ const U = class U {
|
|
|
743
743
|
}
|
|
744
744
|
set quality(t) {
|
|
745
745
|
this.m_Quality = Math.max(
|
|
746
|
-
|
|
747
|
-
Math.min(t,
|
|
746
|
+
N.kMinQuality,
|
|
747
|
+
Math.min(t, N.kMaxQuality)
|
|
748
748
|
);
|
|
749
749
|
}
|
|
750
750
|
get uvMargin() {
|
|
@@ -757,8 +757,8 @@ const U = class U {
|
|
|
757
757
|
return new c.Vector2(this.width, this.height);
|
|
758
758
|
}
|
|
759
759
|
};
|
|
760
|
-
|
|
761
|
-
let ht =
|
|
760
|
+
N.kMinSize = 1, N.kMinThickness = 1e-4, N.kMinQuality = 1, N.kMaxQuality = 5;
|
|
761
|
+
let ht = N;
|
|
762
762
|
class At {
|
|
763
763
|
constructor(t) {
|
|
764
764
|
this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
|
|
@@ -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, a = t.z - r.z, o = 1 / Math.sqrt(i * i + n * n + a * a);
|
|
800
|
+
i *= o, n *= o, a *= o;
|
|
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
|
+
o = 1 / Math.sqrt(h * h + m * m + l * l), h *= o, m *= o, l *= o;
|
|
803
|
+
const d = n * l - a * m, g = a * h - i * l, _ = i * m - n * h;
|
|
804
|
+
return o = 1 / Math.sqrt(d * d + g * g + _ * _), s.set(d * o, g * o, _ * o);
|
|
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, a = !0) {
|
|
874
|
+
this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = a;
|
|
875
875
|
}
|
|
876
876
|
clone() {
|
|
877
877
|
return new Tt(
|
|
@@ -884,7 +884,7 @@ class Tt {
|
|
|
884
884
|
);
|
|
885
885
|
}
|
|
886
886
|
}
|
|
887
|
-
class
|
|
887
|
+
class ue {
|
|
888
888
|
constructor(t, e, s) {
|
|
889
889
|
const i = t.size;
|
|
890
890
|
this.leftNode = new st(e.left * i.x, s, !0), this.rightNode = new st((1 - e.right) * i.x, s, !0), this.downNode = new st(e.down * i.y, s, !0), this.upNode = new st((1 - e.up) * i.y, s, !0);
|
|
@@ -898,62 +898,62 @@ function lt(r, t, e) {
|
|
|
898
898
|
const s = (e - r) / (t - r);
|
|
899
899
|
return Math.max(0, Math.min(1, s));
|
|
900
900
|
}
|
|
901
|
-
function
|
|
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), a = new Pt(s.index, e.index, i.index, n);
|
|
904
|
+
t.push(a);
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
|
-
function
|
|
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
|
|
912
|
-
i ?
|
|
910
|
+
for (let a = 0; a < s; a++) {
|
|
911
|
+
const o = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[a * e + h], d = t[a * e + n.index];
|
|
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 wt(r, t, e, s, i) {
|
|
917
917
|
for (const n of r) {
|
|
918
918
|
if (!n.active) return;
|
|
919
|
-
for (let
|
|
920
|
-
const
|
|
921
|
-
i ?
|
|
919
|
+
for (let a = 0; a < e; a++) {
|
|
920
|
+
const o = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[h * e + a], d = t[n.index * e + a];
|
|
921
|
+
i ? qt(m, l, n.time, d) : d.copy(m).lerp(l, n.time);
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
|
-
function
|
|
925
|
+
function qt(r, t, e, s = new c.Vector3()) {
|
|
926
926
|
const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
|
|
927
927
|
if (i === 0 || n === 0)
|
|
928
928
|
return s.copy(r).lerp(t, e);
|
|
929
|
-
const
|
|
930
|
-
let g =
|
|
929
|
+
const a = r.x / i, o = r.y / i, h = r.z / i, m = t.x / n, l = t.y / n, d = t.z / n;
|
|
930
|
+
let g = a * m + o * 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
|
+
(a * f + m * p) * P,
|
|
938
|
+
(o * f + l * p) * P,
|
|
939
939
|
(h * f + d * p) * P
|
|
940
940
|
);
|
|
941
941
|
}
|
|
942
|
-
function
|
|
942
|
+
function Qt(r, t, e, s, i) {
|
|
943
943
|
for (const n of r) {
|
|
944
|
-
const
|
|
944
|
+
const a = (n.endX - n.startX + 1) * 2, o = (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, a) : Ft(t, g, _, u, f, a);
|
|
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 + a * 2, _ = h + l * 2 + 1 + a * 2, u = h + l * 2 + 2 + a * 2, f = h + l * 2 + 3 + a * 2;
|
|
952
|
+
n.flip ? Ot(t, g, _, u, f, o) : Ft(t, g, _, u, f, o);
|
|
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 + a * 2 + o, _ = h + l * 2 + 1 + a * 2 + o, u = h + l * 2 + 2 + a * 2 + o, f = h + l * 2 + 3 + a * 2 + o;
|
|
957
957
|
n.flip ? ft(t, g, _, u, f) : _t(t, g, _, u, f);
|
|
958
958
|
}
|
|
959
959
|
const m = s * i;
|
|
@@ -975,46 +975,46 @@ function qt(r, t, e, s, i) {
|
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
|
-
function
|
|
978
|
+
function $t(r, t, e, s, i) {
|
|
979
979
|
const n = s * i;
|
|
980
|
-
let
|
|
981
|
-
const
|
|
980
|
+
let a = n * 2;
|
|
981
|
+
const o = 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
|
+
o.subVectors(d, g).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].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
|
+
o.subVectors(d, g).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].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
|
+
o.subVectors(d, g).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].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
|
+
o.subVectors(d, g).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].copy(t[l + n]);
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
|
-
function
|
|
1001
|
+
function de(r, t, e, s, i) {
|
|
1002
1002
|
const n = [];
|
|
1003
|
-
for (const
|
|
1004
|
-
for (let
|
|
1005
|
-
const h =
|
|
1003
|
+
for (const a of r) {
|
|
1004
|
+
for (let o = a.startX; o < a.endX; o++) {
|
|
1005
|
+
const h = o + a.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 o = a.startX; o < a.endX; o++) {
|
|
1009
|
+
const h = o + a.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 o = a.startZ; o < a.endZ; o++) {
|
|
1013
|
+
const h = o * e + a.startX, m = (o + 1) * e + a.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 o = a.startZ; o < a.endZ; o++) {
|
|
1017
|
+
const h = o * e + a.endX, m = (o + 1) * e + a.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
|
|
1030
|
-
_t(r, e, s, i, n), e +=
|
|
1029
|
+
function Yt(r, t, e, s, i, n, a) {
|
|
1030
|
+
_t(r, e, s, i, n), e += a, s += a, i += a, n += a, ft(t, e, s, i, n);
|
|
1031
1031
|
}
|
|
1032
|
-
function
|
|
1033
|
-
const
|
|
1032
|
+
function Kt(r, t, e, s, i, n) {
|
|
1033
|
+
const a = i.left * s.x, o = (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(o, a, 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(a, o, t[u]), p = lt(m, h, e[_]);
|
|
1044
1044
|
r.push(new c.Vector2(f, p));
|
|
1045
1045
|
}
|
|
1046
1046
|
const g = r.length;
|
|
@@ -1053,26 +1053,26 @@ function _t(r, t, e, s, i) {
|
|
|
1053
1053
|
function ft(r, t, e, s, i) {
|
|
1054
1054
|
r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
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 a = 0; a < t - 1; a++) {
|
|
1060
|
+
let o = r[n * t + a].clone(), h = r[n * t + a + 1].clone(), m = r[(n + 1) * t + a].clone(), l = r[(n + 1) * t + a + 1].clone();
|
|
1061
|
+
o.applyMatrix4(s), h.applyMatrix4(s), m.applyMatrix4(s), l.applyMatrix4(s), i.push([o, h, m, l]);
|
|
1062
1062
|
}
|
|
1063
1063
|
return i;
|
|
1064
1064
|
}
|
|
1065
|
-
const
|
|
1065
|
+
const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1066
1066
|
__proto__: null,
|
|
1067
|
-
addBorders:
|
|
1068
|
-
addFrontAndBackFaces:
|
|
1069
|
-
addFrontAndBackTexcoords:
|
|
1070
|
-
debugDrawBorders:
|
|
1071
|
-
drawWireframe:
|
|
1072
|
-
seamNodesToSeams:
|
|
1073
|
-
updateBorders:
|
|
1074
|
-
updateXSeams:
|
|
1075
|
-
updateZSeams:
|
|
1067
|
+
addBorders: Qt,
|
|
1068
|
+
addFrontAndBackFaces: Yt,
|
|
1069
|
+
addFrontAndBackTexcoords: Kt,
|
|
1070
|
+
debugDrawBorders: de,
|
|
1071
|
+
drawWireframe: Jt,
|
|
1072
|
+
seamNodesToSeams: xt,
|
|
1073
|
+
updateBorders: $t,
|
|
1074
|
+
updateXSeams: Mt,
|
|
1075
|
+
updateZSeams: wt
|
|
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 a = 0; a < e.baseVertexCount; a++)
|
|
1090
|
+
this.m_BaseVertices[a] = new c.Vector3();
|
|
1091
1091
|
this.m_Vertices = new Array(e.vertexCount);
|
|
1092
|
-
for (let
|
|
1093
|
-
this.m_Vertices[
|
|
1092
|
+
for (let a = 0; a < e.vertexCount; a++)
|
|
1093
|
+
this.m_Vertices[a] = new c.Vector3();
|
|
1094
1094
|
this.m_Normals = new Array(e.vertexCount);
|
|
1095
|
-
for (let
|
|
1096
|
-
this.m_Normals[
|
|
1095
|
+
for (let a = 0; a < e.vertexCount; a++)
|
|
1096
|
+
this.m_Normals[a] = 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 a = new Uint32Array(e.triangles);
|
|
1099
|
+
this.m_Geometry.setIndex(new c.BufferAttribute(a, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
|
|
1100
1100
|
} else {
|
|
1101
|
-
const
|
|
1101
|
+
const a = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, o = new Uint32Array(a);
|
|
1102
1102
|
let h = 0;
|
|
1103
|
-
|
|
1103
|
+
o.set(e.frontTriangles, h), this.m_Geometry.addGroup(h, e.frontTriangles.length, 0), h += e.frontTriangles.length, o.set(e.backTriangles, h), this.m_Geometry.addGroup(h, e.backTriangles.length, 1), h += e.backTriangles.length, o.set(e.borderTriangles, h), this.m_Geometry.addGroup(h, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(o, 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 a = 0; a < e.texcoords.length; a++)
|
|
1107
|
+
n[a * 2] = e.texcoords[a].x, n[a * 2 + 1] = e.texcoords[a].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, a = s.length;
|
|
1128
|
+
let o = 0;
|
|
1129
|
+
for (let h = 0; h < a; h++)
|
|
1130
1130
|
for (let m = 0; m < n; m++)
|
|
1131
|
-
t[
|
|
1131
|
+
t[o++].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, a = this.m_Pattern.baseZArray.length, o = this.m_Pattern.baseVertexCount, h = new c.Vector3(), m = new c.Vector3(), l = new c.Vector3();
|
|
1151
|
+
for (let u = 0; u < o; u++)
|
|
1152
1152
|
s[u].set(0, 0, 0);
|
|
1153
|
-
|
|
1154
|
-
for (let u = 0; u <
|
|
1153
|
+
Mt(this.m_Pattern.xSeams, t, n, a, !1), wt(this.m_Pattern.zSeams, t, n, a, !1);
|
|
1154
|
+
for (let u = 0; u < a - 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,
|
|
1158
|
-
Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[
|
|
1157
|
+
const P = p + 1, B = u * n + p, M = u * n + P, y = f * n + p, S = f * n + P, k = t[B], O = t[M], Z = t[y], V = t[S];
|
|
1158
|
+
Ht(k, Z, O, h), Ht(V, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[y].add(l), s[S].add(l);
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
-
for (let u = 0; u <
|
|
1161
|
+
for (let u = 0; u < o; u++)
|
|
1162
1162
|
s[u].divideScalar(i[u]).normalize();
|
|
1163
|
-
|
|
1163
|
+
Mt(this.m_Pattern.xSeams, s, n, a, !0), wt(this.m_Pattern.zSeams, s, n, a, !0);
|
|
1164
1164
|
const d = this.m_Pattern.thickness / 2;
|
|
1165
|
-
for (let u = 0; u <
|
|
1165
|
+
for (let u = 0; u < o; u++) {
|
|
1166
1166
|
const f = s[u];
|
|
1167
|
-
s[u +
|
|
1167
|
+
s[u + o].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 + o].copy(p).addScaledVector(f, -d);
|
|
1170
1170
|
}
|
|
1171
|
-
|
|
1171
|
+
$t(this.m_Pattern.borders, e, s, n, a);
|
|
1172
1172
|
const g = this.m_Geometry.getAttribute(
|
|
1173
1173
|
"position"
|
|
1174
1174
|
), _ = this.m_Geometry.getAttribute(
|
|
@@ -1190,10 +1190,10 @@ class Zt {
|
|
|
1190
1190
|
*/
|
|
1191
1191
|
drawWireframe(t) {
|
|
1192
1192
|
const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
|
|
1193
|
-
return
|
|
1193
|
+
return Jt(this.m_Vertices, e, s, t);
|
|
1194
1194
|
}
|
|
1195
1195
|
}
|
|
1196
|
-
class
|
|
1196
|
+
class _e {
|
|
1197
1197
|
constructor() {
|
|
1198
1198
|
this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
|
|
1199
1199
|
}
|
|
@@ -1212,7 +1212,7 @@ class ue {
|
|
|
1212
1212
|
this.m_Meshs.clear();
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
|
-
class
|
|
1215
|
+
class fe {
|
|
1216
1216
|
constructor(t) {
|
|
1217
1217
|
this.m_CreateMeshCollider = !1, this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
|
|
1218
1218
|
}
|
|
@@ -1224,7 +1224,7 @@ class de {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
get(t) {
|
|
1226
1226
|
let e;
|
|
1227
|
-
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new
|
|
1227
|
+
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new pe(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
|
|
1228
1228
|
}
|
|
1229
1229
|
recycle() {
|
|
1230
1230
|
for (const t of this.m_UsedRenderers)
|
|
@@ -1244,10 +1244,10 @@ class de {
|
|
|
1244
1244
|
return t;
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
|
-
let
|
|
1248
|
-
class
|
|
1247
|
+
let ge = 1;
|
|
1248
|
+
class pe {
|
|
1249
1249
|
constructor(t, e, s) {
|
|
1250
|
-
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id =
|
|
1250
|
+
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ge++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
|
|
1251
1251
|
new c.BufferGeometry(),
|
|
1252
1252
|
new c.MeshStandardMaterial()
|
|
1253
1253
|
), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
|
|
@@ -1320,16 +1320,16 @@ class fe {
|
|
|
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), a = this.m_MaterialTextures.get(e);
|
|
1324
|
+
if (a && a.source === s && a.stKey === n) {
|
|
1325
|
+
t.map !== a.texture && (t.map = a.texture, t.needsUpdate = !0);
|
|
1326
1326
|
return;
|
|
1327
1327
|
}
|
|
1328
1328
|
this.clearManagedTexture(e);
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1329
|
+
const o = s.clone();
|
|
1330
|
+
o.needsUpdate = !0, i && (o.repeat.set(i.x, i.y), o.offset.set(i.z, i.w), o.wrapS = c.RepeatWrapping, o.wrapT = c.RepeatWrapping), t.map = o, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
|
|
1331
1331
|
source: s,
|
|
1332
|
-
texture:
|
|
1332
|
+
texture: o,
|
|
1333
1333
|
stKey: n
|
|
1334
1334
|
});
|
|
1335
1335
|
}
|
|
@@ -1351,7 +1351,7 @@ class fe {
|
|
|
1351
1351
|
e.dispose();
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
|
-
class
|
|
1354
|
+
class xe {
|
|
1355
1355
|
constructor(t, e, s = !1) {
|
|
1356
1356
|
this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Zt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
|
|
1357
1357
|
}
|
|
@@ -1363,8 +1363,8 @@ class ge {
|
|
|
1363
1363
|
this.m_Stack.push(t);
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
|
-
var
|
|
1367
|
-
class
|
|
1366
|
+
var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), Me = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(Me || {}), we = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(we || {}), ye = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(ye || {});
|
|
1367
|
+
class Ce {
|
|
1368
1368
|
constructor(t) {
|
|
1369
1369
|
this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
|
|
1370
1370
|
}
|
|
@@ -1389,10 +1389,10 @@ class ye {
|
|
|
1389
1389
|
function nt(r, t, e) {
|
|
1390
1390
|
return Math.max(t, Math.min(e, r));
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1392
|
+
function Pe(r, t, e) {
|
|
1393
1393
|
return r === t ? 0 : nt((e - r) / (t - r), 0, 1);
|
|
1394
1394
|
}
|
|
1395
|
-
function
|
|
1395
|
+
function Ut(r, t) {
|
|
1396
1396
|
return r + Math.random() * (t - r);
|
|
1397
1397
|
}
|
|
1398
1398
|
class rt {
|
|
@@ -1463,12 +1463,12 @@ class rt {
|
|
|
1463
1463
|
getValue(t, e) {
|
|
1464
1464
|
if (this.m_Mode === 0) return this.m_Constant;
|
|
1465
1465
|
if (this.m_Mode === 1)
|
|
1466
|
-
return
|
|
1466
|
+
return Ut(this.m_ConstantMin, this.m_ConstantMax);
|
|
1467
1467
|
const s = this.m_CurveTimeMode === 0 ? t : e;
|
|
1468
1468
|
if (this.m_Mode === 2)
|
|
1469
1469
|
return this.m_Curve.evaluate(s);
|
|
1470
1470
|
if (this.m_Mode === 3)
|
|
1471
|
-
return
|
|
1471
|
+
return Ut(
|
|
1472
1472
|
this.m_CurveMin.evaluate(s),
|
|
1473
1473
|
this.m_CurveMax.evaluate(s)
|
|
1474
1474
|
);
|
|
@@ -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 a = 1 / 0, o = -1 / 0;
|
|
1485
1485
|
for (let h = 0; h < n; h++) {
|
|
1486
1486
|
const m = i[h].time;
|
|
1487
|
-
|
|
1487
|
+
a = Math.min(a, m), o = Math.max(o, 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 =
|
|
1491
|
+
m = Pe(a, o, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
|
|
1492
1492
|
}
|
|
1493
|
-
return new
|
|
1493
|
+
return new Ce(i);
|
|
1494
1494
|
}
|
|
1495
1495
|
// ── Value-type clone ────────────────────────────────────────────────────
|
|
1496
1496
|
clone() {
|
|
@@ -1567,14 +1567,14 @@ const R = class R {
|
|
|
1567
1567
|
}
|
|
1568
1568
|
};
|
|
1569
1569
|
R.kMinTwist = -1, R.kMaxTwist = 1, R.kMinBend = 0, R.kMaxBend = 1, R.kMinDuration = 0, R.kMaxDuration = 5;
|
|
1570
|
-
let
|
|
1570
|
+
let Lt = R, Xe = class extends Error {
|
|
1571
1571
|
constructor() {
|
|
1572
1572
|
super(
|
|
1573
1573
|
"The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
|
|
1574
1574
|
);
|
|
1575
1575
|
}
|
|
1576
1576
|
};
|
|
1577
|
-
const
|
|
1577
|
+
const at = class at 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 ot = class ot 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
|
+
}))), at.s_Instances.add(this);
|
|
1607
1607
|
}
|
|
1608
1608
|
static get instances() {
|
|
1609
|
-
return [...
|
|
1609
|
+
return [...at.s_Instances];
|
|
1610
1610
|
}
|
|
1611
1611
|
// ── Internal accessors ─────────────────────────────────────────────────
|
|
1612
1612
|
get minPaperWidth() {
|
|
@@ -1731,15 +1731,15 @@ const ot = class ot extends c.Group {
|
|
|
1731
1731
|
}
|
|
1732
1732
|
getActivePaperSideIndices(t) {
|
|
1733
1733
|
if (t.length = 0, !this.m_IsBuilt) return;
|
|
1734
|
-
const e = this.m_Content.direction === 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, a) => {
|
|
1735
|
+
let o = n * 2;
|
|
1736
|
+
a && o++, e && (o = s * 2 - o - 1), t.includes(o) || t.push(o);
|
|
1737
1737
|
};
|
|
1738
1738
|
for (let n = 0; n < s; n++) {
|
|
1739
|
-
const
|
|
1740
|
-
if (
|
|
1739
|
+
const a = this.m_Papers[n];
|
|
1740
|
+
if (a.isFalling || a.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 (a.isOnRightStack) {
|
|
1743
1743
|
n > 0 && i(n - 1, !0), i(n, !1);
|
|
1744
1744
|
break;
|
|
1745
1745
|
}
|
|
@@ -1767,8 +1767,8 @@ const ot = class ot 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 a = 0; a < s && this.canAutoTurn(t); a++) {
|
|
1771
|
+
const o = a / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = a > 0 ? n.getValue(h, o) : 0, l = e.getModeValue(), d = e.getTwistValue(h, o), g = e.getBendValue(h, o), _ = e.getDurationValue(h, o);
|
|
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 ot = class ot 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 === yt.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 ot = class ot 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 === yt.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 ot = class ot extends c.Group {
|
|
|
1822
1822
|
* Equivalent to Unity's Start/Awake.
|
|
1823
1823
|
*/
|
|
1824
1824
|
init() {
|
|
1825
|
-
|
|
1825
|
+
at.s_Instances.add(this), this.hardClear(), this.m_BuildOnAwake && this.build();
|
|
1826
1826
|
}
|
|
1827
1827
|
/**
|
|
1828
1828
|
* Call every frame with delta time.
|
|
@@ -1837,46 +1837,46 @@ const ot = class ot extends c.Group {
|
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
1839
|
dispose() {
|
|
1840
|
-
|
|
1840
|
+
at.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
|
-
if (this.m_MeshFactory === null && (this.m_MeshFactory = new
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1845
|
+
if (this.m_MeshFactory === null && (this.m_MeshFactory = new _e()), this.m_RendererFactory === null) {
|
|
1846
|
+
const w = new c.Object3D();
|
|
1847
|
+
w.name = "Root", this.add(w), this.m_Root = w, 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, a = this.m_InitialOpenProgress;
|
|
1855
|
+
this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), a = 1 - a), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
|
|
1856
|
+
const o = 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
|
-
v.renderer.castShadows = this.m_CastShadows,
|
|
1858
|
+
this.m_Papers = new Array(o);
|
|
1859
|
+
for (let w = 0; w < o; w++) {
|
|
1860
|
+
const I = this.m_HasCover && (w < h || w >= o - h), L = this.m_RendererFactory.get("Paper"), v = this.m_Papers[w] = new me(I, w, this, L);
|
|
1861
|
+
v.renderer.castShadows = this.m_CastShadows, w < Math.round(c.MathUtils.lerp(0, o, a)) && (v.transform.scale.set(-1, 1, 1), v.setTime(1)), I ? (v.setContentData(i[l++], i[l++], w > h), v.setMaterialData(e), v.setPaperSetup(this.m_CoverPaperSetup)) : (v.setContentData(n[m++], n[m++]), v.setMaterialData(s), v.setPaperSetup(this.m_PagePaperSetup)), d += v.thickness;
|
|
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(o / 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(o / 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(o / 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,
|
|
1876
|
-
for (let
|
|
1877
|
-
const I = this.m_Papers[
|
|
1878
|
-
|
|
1879
|
-
|
|
1875
|
+
const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, y = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), S = 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, U = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
|
|
1876
|
+
for (let w = 0; w < o; w++) {
|
|
1877
|
+
const I = this.m_Papers[w];
|
|
1878
|
+
w !== 0 && (I.prev = this.m_Papers[w - 1]), w !== o - 1 && (I.next = this.m_Papers[w + 1]), I.noHole = D && (w === V || w === U), I.isCover ? I.setMeshData(O.get(), null, Z) : I.setMeshData(
|
|
1879
|
+
y.get(),
|
|
1880
1880
|
(S == null ? void 0 : S.get()) ?? null,
|
|
1881
1881
|
k
|
|
1882
1882
|
);
|
|
@@ -1890,7 +1890,7 @@ const ot = class ot 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, a = this.m_Bound.createPaperPattern(
|
|
1894
1894
|
n,
|
|
1895
1895
|
t.size,
|
|
1896
1896
|
t.thickness,
|
|
@@ -1898,9 +1898,9 @@ const ot = class ot extends c.Group {
|
|
|
1898
1898
|
i,
|
|
1899
1899
|
s
|
|
1900
1900
|
);
|
|
1901
|
-
return new
|
|
1901
|
+
return new xe(
|
|
1902
1902
|
this.m_MeshFactory,
|
|
1903
|
-
|
|
1903
|
+
a,
|
|
1904
1904
|
e && this.m_Bound.useSharedMeshDataForLowpoly
|
|
1905
1905
|
);
|
|
1906
1906
|
}
|
|
@@ -1952,14 +1952,14 @@ const ot = class ot extends c.Group {
|
|
|
1952
1952
|
s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
|
|
1953
1953
|
}
|
|
1954
1954
|
};
|
|
1955
|
-
|
|
1956
|
-
let Ct =
|
|
1957
|
-
class
|
|
1955
|
+
at.s_Instances = /* @__PURE__ */ new Set();
|
|
1956
|
+
let Ct = at;
|
|
1957
|
+
class Te {
|
|
1958
1958
|
constructor() {
|
|
1959
1959
|
this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
|
-
class
|
|
1962
|
+
class je {
|
|
1963
1963
|
constructor() {
|
|
1964
1964
|
this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
|
|
1965
1965
|
}
|
|
@@ -1994,7 +1994,7 @@ class Xe {
|
|
|
1994
1994
|
this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
|
|
1995
1995
|
}
|
|
1996
1996
|
}
|
|
1997
|
-
class
|
|
1997
|
+
class Nt {
|
|
1998
1998
|
constructor(t, e) {
|
|
1999
1999
|
this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
|
|
2000
2000
|
}
|
|
@@ -2012,7 +2012,7 @@ class Ut {
|
|
|
2012
2012
|
setActive(t) {
|
|
2013
2013
|
}
|
|
2014
2014
|
}
|
|
2015
|
-
class
|
|
2015
|
+
class Ge {
|
|
2016
2016
|
constructor() {
|
|
2017
2017
|
this.m_Direction = X.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
|
|
2018
2018
|
}
|
|
@@ -2051,8 +2051,8 @@ class je {
|
|
|
2051
2051
|
let i = this.nextMultipleOf4(s);
|
|
2052
2052
|
e && (i = Math.min(i, 4));
|
|
2053
2053
|
const n = new Array(i);
|
|
2054
|
-
for (let
|
|
2055
|
-
n[
|
|
2054
|
+
for (let a = 0; a < i; a++)
|
|
2055
|
+
n[a] = this.getContent(a < s ? t[a] : null);
|
|
2056
2056
|
return n;
|
|
2057
2057
|
}
|
|
2058
2058
|
nextMultipleOf4(t) {
|
|
@@ -2061,11 +2061,11 @@ class je {
|
|
|
2061
2061
|
getContent(t) {
|
|
2062
2062
|
if (t !== null) {
|
|
2063
2063
|
if (t instanceof c.Texture)
|
|
2064
|
-
return new
|
|
2064
|
+
return new Nt(t);
|
|
2065
2065
|
if (typeof t.init == "function")
|
|
2066
2066
|
return t;
|
|
2067
2067
|
}
|
|
2068
|
-
return new
|
|
2068
|
+
return new Nt(null);
|
|
2069
2069
|
}
|
|
2070
2070
|
init(t) {
|
|
2071
2071
|
this.m_Book = t;
|
|
@@ -2113,16 +2113,16 @@ class je {
|
|
|
2113
2113
|
return !this.isCoverPaperSideIndex(t);
|
|
2114
2114
|
}
|
|
2115
2115
|
}
|
|
2116
|
-
class
|
|
2116
|
+
class qe {
|
|
2117
2117
|
constructor(t, e) {
|
|
2118
2118
|
this.enabled = !0, this.m_Raycaster = new c.Raycaster(), this.m_Mouse = new c.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
|
|
2119
2119
|
var n;
|
|
2120
2120
|
if (!this.enabled || s.button !== 0) return;
|
|
2121
2121
|
this.m_IsPointerDown = !0;
|
|
2122
2122
|
const i = this.m_GetRay(s);
|
|
2123
|
-
for (const
|
|
2124
|
-
if (
|
|
2125
|
-
this.m_SelectedBook =
|
|
2123
|
+
for (const a of Ct.instances)
|
|
2124
|
+
if (a.startTurning(i)) {
|
|
2125
|
+
this.m_SelectedBook = a, (n = this.onTurnStart) == null || n.call(this, a);
|
|
2126
2126
|
break;
|
|
2127
2127
|
}
|
|
2128
2128
|
}, this.m_OnPointerMove = (s) => {
|
|
@@ -2140,9 +2140,9 @@ class Ge {
|
|
|
2140
2140
|
return this.m_Mouse.x = (t.clientX - e.left) / e.width * 2 - 1, this.m_Mouse.y = -((t.clientY - e.top) / e.height) * 2 + 1, this.m_Raycaster.setFromCamera(this.m_Mouse, this.m_Camera), this.m_Raycaster.ray;
|
|
2141
2141
|
}
|
|
2142
2142
|
}
|
|
2143
|
-
class
|
|
2143
|
+
class Se {
|
|
2144
2144
|
}
|
|
2145
|
-
class
|
|
2145
|
+
class Qe {
|
|
2146
2146
|
constructor(t, e) {
|
|
2147
2147
|
this.m_Book = t, this.m_Root = e;
|
|
2148
2148
|
}
|
|
@@ -2158,36 +2158,36 @@ function Et(r, t, e, s) {
|
|
|
2158
2158
|
function Xt(r, t) {
|
|
2159
2159
|
return r++, r === t ? 0 : r;
|
|
2160
2160
|
}
|
|
2161
|
-
function
|
|
2161
|
+
function ve(r, t) {
|
|
2162
2162
|
return r === 0 ? t - 1 : r - 1;
|
|
2163
2163
|
}
|
|
2164
|
-
const
|
|
2164
|
+
const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4, Ie = 2, ze = 10, Ve = 0, De = 5;
|
|
2165
2165
|
function et(r, t, e) {
|
|
2166
2166
|
return Math.max(t, Math.min(e, r));
|
|
2167
2167
|
}
|
|
2168
|
-
function
|
|
2168
|
+
function te(r) {
|
|
2169
2169
|
return Math.max(0, Math.min(1, r));
|
|
2170
2170
|
}
|
|
2171
2171
|
function F(r, t, e) {
|
|
2172
2172
|
return r + (t - r) * e;
|
|
2173
2173
|
}
|
|
2174
|
-
function
|
|
2175
|
-
return r === t ? 0 :
|
|
2174
|
+
function Wt(r, t, e) {
|
|
2175
|
+
return r === t ? 0 : te((e - r) / (t - r));
|
|
2176
2176
|
}
|
|
2177
|
-
function
|
|
2177
|
+
function Ae(r, t) {
|
|
2178
2178
|
const e = r.clone().normalize();
|
|
2179
2179
|
if (e.lengthSq() === 0) return new c.Quaternion();
|
|
2180
2180
|
let s = new c.Vector3().crossVectors(t, e);
|
|
2181
2181
|
if (s.lengthSq() === 0) {
|
|
2182
|
-
const
|
|
2183
|
-
s = new c.Vector3().crossVectors(
|
|
2182
|
+
const a = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
|
|
2183
|
+
s = new c.Vector3().crossVectors(a, e);
|
|
2184
2184
|
}
|
|
2185
2185
|
s.normalize();
|
|
2186
2186
|
const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
|
|
2187
2187
|
return new c.Quaternion().setFromRotationMatrix(n);
|
|
2188
2188
|
}
|
|
2189
2189
|
const tt = Math.PI / 180, it = 180 / Math.PI;
|
|
2190
|
-
class
|
|
2190
|
+
class He {
|
|
2191
2191
|
constructor() {
|
|
2192
2192
|
this._material = null, this._color = new c.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
|
|
2193
2193
|
}
|
|
@@ -2207,44 +2207,44 @@ class De {
|
|
|
2207
2207
|
return this._thickness;
|
|
2208
2208
|
}
|
|
2209
2209
|
set thickness(t) {
|
|
2210
|
-
this._thickness = et(t,
|
|
2210
|
+
this._thickness = et(t, ke, be);
|
|
2211
2211
|
}
|
|
2212
2212
|
get margin() {
|
|
2213
2213
|
return this._margin;
|
|
2214
2214
|
}
|
|
2215
2215
|
set margin(t) {
|
|
2216
|
-
this._margin =
|
|
2216
|
+
this._margin = te(t);
|
|
2217
2217
|
}
|
|
2218
2218
|
get crown() {
|
|
2219
2219
|
return this._crown;
|
|
2220
2220
|
}
|
|
2221
2221
|
set crown(t) {
|
|
2222
|
-
this._crown = et(t,
|
|
2222
|
+
this._crown = et(t, Be, Re);
|
|
2223
2223
|
}
|
|
2224
2224
|
get count() {
|
|
2225
2225
|
return this._count;
|
|
2226
2226
|
}
|
|
2227
2227
|
set count(t) {
|
|
2228
|
-
this._count = et(t,
|
|
2228
|
+
this._count = et(t, Ie, ze);
|
|
2229
2229
|
}
|
|
2230
2230
|
get quality() {
|
|
2231
2231
|
return this._quality;
|
|
2232
2232
|
}
|
|
2233
2233
|
set quality(t) {
|
|
2234
|
-
this._quality = et(t,
|
|
2234
|
+
this._quality = et(t, Ve, De);
|
|
2235
2235
|
}
|
|
2236
2236
|
}
|
|
2237
|
-
class
|
|
2237
|
+
class Fe extends Error {
|
|
2238
2238
|
constructor() {
|
|
2239
2239
|
super("Book height is too large relative to paper width."), this.name = "BookHeightException";
|
|
2240
2240
|
}
|
|
2241
2241
|
}
|
|
2242
|
-
class
|
|
2242
|
+
class Oe {
|
|
2243
2243
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
2244
2244
|
constructor(t, e, s, i, n) {
|
|
2245
2245
|
if (this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Book = s, this.m_Root = i, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
|
|
2246
|
-
throw new
|
|
2247
|
-
const
|
|
2246
|
+
throw new Fe();
|
|
2247
|
+
const a = this.m_Book.coverPaperSetup, o = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
|
|
2248
2248
|
this.updateStapleMesh(e, h);
|
|
2249
2249
|
const m = n ?? new c.MeshStandardMaterial({
|
|
2250
2250
|
color: e.color,
|
|
@@ -2254,9 +2254,9 @@ class He {
|
|
|
2254
2254
|
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
2255
|
0,
|
|
2256
2256
|
0,
|
|
2257
|
-
this.m_StapleMargin +
|
|
2257
|
+
this.m_StapleMargin + o.margin + a.margin
|
|
2258
2258
|
);
|
|
2259
|
-
let l =
|
|
2259
|
+
let l = a.thickness;
|
|
2260
2260
|
l = Math.max(this.m_BindingRadius, l);
|
|
2261
2261
|
for (const d of this.m_Book.papers) {
|
|
2262
2262
|
const g = d.size.clone();
|
|
@@ -2265,7 +2265,7 @@ class He {
|
|
|
2265
2265
|
this.updateRootPosition();
|
|
2266
2266
|
}
|
|
2267
2267
|
get binderRenderer() {
|
|
2268
|
-
return this._binderRendererAdapter || (this._binderRendererAdapter = new
|
|
2268
|
+
return this._binderRendererAdapter || (this._binderRendererAdapter = new Ze(this.stapleMesh)), this._binderRendererAdapter;
|
|
2269
2269
|
}
|
|
2270
2270
|
// ── updateStapleMesh ──────────────────────────────────────────────────
|
|
2271
2271
|
updateStapleMesh(t, e) {
|
|
@@ -2277,16 +2277,16 @@ class He {
|
|
|
2277
2277
|
i
|
|
2278
2278
|
);
|
|
2279
2279
|
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
|
-
|
|
2280
|
+
const a = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
|
|
2281
|
+
let o = t.count, h = (a - s * o) / (o - 1);
|
|
2282
|
+
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && o > 2; )
|
|
2283
|
+
o--, h = (a - s * o) / (o - 1), h = Math.max(h, 0);
|
|
2284
2284
|
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
2285
|
let P = s / 2 * f;
|
|
2286
2286
|
P = Math.max(P, p * 2);
|
|
2287
2287
|
let B = 0;
|
|
2288
2288
|
B += this.m_Book.totalThickness / 2, B += _;
|
|
2289
|
-
const
|
|
2289
|
+
const M = -(this.m_Book.papers[0].thickness / 2 + _), y = [];
|
|
2290
2290
|
{
|
|
2291
2291
|
for (let z = 0; z < d; z++) {
|
|
2292
2292
|
const E = z / (d - 1), q = F(-90, -180, E) * tt, C = new c.Vector3(
|
|
@@ -2294,84 +2294,84 @@ class He {
|
|
|
2294
2294
|
0,
|
|
2295
2295
|
p * Math.cos(q)
|
|
2296
2296
|
);
|
|
2297
|
-
C.x += p, C.z += p, C.x +=
|
|
2297
|
+
C.x += p, C.z += p, C.x += M, y.push(C);
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2299
|
+
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
2300
|
for (let z = 0; z < g; z++) {
|
|
2301
|
-
const E = z / (g - 1),
|
|
2302
|
-
|
|
2301
|
+
const E = z / (g - 1), G = Et(x, H, T, E);
|
|
2302
|
+
G.x += M, y.push(G);
|
|
2303
2303
|
}
|
|
2304
|
-
|
|
2304
|
+
y.reverse();
|
|
2305
2305
|
}
|
|
2306
2306
|
const S = new Array(l);
|
|
2307
|
-
for (let
|
|
2308
|
-
const T = (90 -
|
|
2309
|
-
S[
|
|
2307
|
+
for (let x = 0; x < l; x++) {
|
|
2308
|
+
const T = (90 - x * (360 / l)) * tt;
|
|
2309
|
+
S[x] = new c.Vector3(Math.cos(T), Math.sin(T), 0), S[x].x *= 0.75;
|
|
2310
2310
|
}
|
|
2311
|
-
const k =
|
|
2311
|
+
const k = y.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), U = new Array(
|
|
2312
2312
|
(O * 2 - 1) * l * 2 * 3
|
|
2313
2313
|
);
|
|
2314
|
-
for (let
|
|
2315
|
-
Z[
|
|
2314
|
+
for (let x = 0; x < O * 2; x++)
|
|
2315
|
+
Z[x] = new c.Vector3(), V[x] = new c.Vector3();
|
|
2316
2316
|
let D = 0;
|
|
2317
|
-
for (let
|
|
2318
|
-
const H =
|
|
2317
|
+
for (let x = 0; x < k; x++) {
|
|
2318
|
+
const H = y[ve(x, k)], T = y[x], z = y[Xt(x, k)];
|
|
2319
2319
|
let E;
|
|
2320
|
-
if (
|
|
2320
|
+
if (x === 0)
|
|
2321
2321
|
E = new c.Vector3(1, 0, -2).normalize();
|
|
2322
|
-
else if (
|
|
2322
|
+
else if (x === k - 1)
|
|
2323
2323
|
E = new c.Vector3(0, 0, 1);
|
|
2324
2324
|
else {
|
|
2325
2325
|
const K = T.clone().sub(H).normalize(), J = z.clone().sub(T).normalize();
|
|
2326
2326
|
E = K.add(J).multiplyScalar(0.5);
|
|
2327
2327
|
}
|
|
2328
|
-
const
|
|
2329
|
-
let b =
|
|
2328
|
+
const G = new c.Vector3(0, 1, 0), q = Ae(E, G), C = D;
|
|
2329
|
+
let b = Wt(0, g / 4, x);
|
|
2330
2330
|
b = F(0.1, 1, b), b = Math.sqrt(b);
|
|
2331
2331
|
for (let K = 0; K < l; K++) {
|
|
2332
2332
|
const J = S[K].clone().applyQuaternion(q).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(_));
|
|
2333
2333
|
Z[D] = ct, V[D] = J.clone();
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
const
|
|
2337
|
-
Z[St] =
|
|
2334
|
+
const ot = T.clone().add(J.clone().multiplyScalar(_));
|
|
2335
|
+
ot.z = s - ot.z;
|
|
2336
|
+
const se = C + l - K - 1, St = O * 2 - se - 1;
|
|
2337
|
+
Z[St] = ot, V[St] = J.clone(), D++;
|
|
2338
2338
|
}
|
|
2339
2339
|
}
|
|
2340
|
-
let
|
|
2341
|
-
const I =
|
|
2342
|
-
for (let
|
|
2343
|
-
const H =
|
|
2340
|
+
let w = 0;
|
|
2341
|
+
const I = y.length * 2;
|
|
2342
|
+
for (let x = 0; x < I - 1; x++) {
|
|
2343
|
+
const H = x * l, T = (x + 1) * l;
|
|
2344
2344
|
for (let z = 0; z < l; z++) {
|
|
2345
|
-
const E = Xt(z, l),
|
|
2346
|
-
|
|
2345
|
+
const E = Xt(z, l), G = H + z, q = H + E, C = T + E, b = T + z;
|
|
2346
|
+
U[w++] = G, U[w++] = b, U[w++] = q, U[w++] = q, U[w++] = b, U[w++] = C;
|
|
2347
2347
|
}
|
|
2348
2348
|
}
|
|
2349
|
-
const
|
|
2350
|
-
for (let
|
|
2351
|
-
const H =
|
|
2349
|
+
const L = [...Z], v = [...V], Q = [...U], j = Z.map((x) => x.clone()), $ = [...U];
|
|
2350
|
+
for (let x = 0; x < o - 1; x++) {
|
|
2351
|
+
const H = j.length;
|
|
2352
2352
|
for (let T = 0; T < $.length; T++)
|
|
2353
2353
|
$[T] += H;
|
|
2354
|
-
for (let T = 0; T <
|
|
2355
|
-
|
|
2356
|
-
|
|
2354
|
+
for (let T = 0; T < j.length; T++)
|
|
2355
|
+
j[T].z += h + s;
|
|
2356
|
+
L.push(...j.map((T) => T.clone())), v.push(...V.map((T) => T.clone())), Q.push(...$);
|
|
2357
2357
|
}
|
|
2358
|
-
const
|
|
2359
|
-
for (let
|
|
2360
|
-
|
|
2358
|
+
const W = new Float32Array(L.length * 3), A = new Float32Array(v.length * 3);
|
|
2359
|
+
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] = v[x].x, A[x * 3 + 1] = v[x].y, A[x * 3 + 2] = v[x].z;
|
|
2361
2361
|
e.setAttribute(
|
|
2362
2362
|
"position",
|
|
2363
|
-
new c.BufferAttribute(
|
|
2363
|
+
new c.BufferAttribute(W, 3)
|
|
2364
2364
|
), e.setAttribute(
|
|
2365
2365
|
"normal",
|
|
2366
2366
|
new c.BufferAttribute(A, 3)
|
|
2367
2367
|
), e.setIndex(Q);
|
|
2368
2368
|
}
|
|
2369
2369
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2370
|
-
createPaperPattern(t, e, s, i, n,
|
|
2371
|
-
const
|
|
2372
|
-
|
|
2370
|
+
createPaperPattern(t, e, s, i, n, a) {
|
|
2371
|
+
const o = new Te();
|
|
2372
|
+
o.size = e, o.thickness = s;
|
|
2373
2373
|
const h = this.m_BindingRadius;
|
|
2374
|
-
|
|
2374
|
+
o.baseXOffset = -h;
|
|
2375
2375
|
const m = this.m_Quality + 1;
|
|
2376
2376
|
this.m_BindingVertexCount = m;
|
|
2377
2377
|
const l = t / 5, d = Math.min(e.x, e.y) / 60, g = Math.floor(
|
|
@@ -2381,39 +2381,39 @@ class He {
|
|
|
2381
2381
|
const p = new st(0);
|
|
2382
2382
|
let P = p;
|
|
2383
2383
|
const B = h / m;
|
|
2384
|
-
let
|
|
2384
|
+
let M = 0;
|
|
2385
2385
|
for (let C = 1; C < m + 1; C++)
|
|
2386
|
-
P = P.createNext(
|
|
2387
|
-
const
|
|
2386
|
+
P = P.createNext(M), M += B;
|
|
2387
|
+
const y = (e.x - h) / (g + 1);
|
|
2388
2388
|
for (let C = m + 1; C < u; C++)
|
|
2389
|
-
P = P.createNext(
|
|
2389
|
+
P = P.createNext(M), M += y;
|
|
2390
2390
|
const S = new st(0);
|
|
2391
2391
|
let k = S;
|
|
2392
2392
|
const O = e.y / (f - 1);
|
|
2393
2393
|
let Z = 0;
|
|
2394
2394
|
for (let C = 0; C < f - 1; C++)
|
|
2395
2395
|
Z += O, k = k.createNext(Z);
|
|
2396
|
-
const V = [],
|
|
2396
|
+
const V = [], U = [], D = i.clone();
|
|
2397
2397
|
if (n) {
|
|
2398
2398
|
let C = 0;
|
|
2399
2399
|
this.m_Book.hasCover && (C = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2400
2400
|
const b = Math.max(0.01, s);
|
|
2401
2401
|
D.left = 0, D.right = (this.getPX(C + 1, s) - this.getPX(C, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
|
|
2402
2402
|
}
|
|
2403
|
-
const
|
|
2404
|
-
|
|
2405
|
-
const I = this.m_BindingVertexCount + 2,
|
|
2406
|
-
|
|
2403
|
+
const w = new ue(o, D, !1);
|
|
2404
|
+
w.insert(p, S, V, U), p.updateIndex(0), S.updateIndex(0), xt(V, o.xSeams), xt(U, o.zSeams);
|
|
2405
|
+
const I = this.m_BindingVertexCount + 2, L = new Array(I);
|
|
2406
|
+
o.xNoneSeamIndexes = L, P = p;
|
|
2407
2407
|
for (let C = 0; C < I; C++) {
|
|
2408
|
-
|
|
2408
|
+
L[C] = P.index;
|
|
2409
2409
|
do
|
|
2410
2410
|
P = P.next;
|
|
2411
2411
|
while (P.seam);
|
|
2412
2412
|
}
|
|
2413
2413
|
const v = p.getValues(), Q = S.getValues();
|
|
2414
2414
|
u = v.length, f = Q.length;
|
|
2415
|
-
const
|
|
2416
|
-
|
|
2415
|
+
const j = u * f, $ = [], W = new Array(j).fill(0), A = [], x = [], H = [], T = [];
|
|
2416
|
+
Kt(
|
|
2417
2417
|
$,
|
|
2418
2418
|
v,
|
|
2419
2419
|
Q,
|
|
@@ -2421,31 +2421,31 @@ class He {
|
|
|
2421
2421
|
i,
|
|
2422
2422
|
this.m_Book.direction
|
|
2423
2423
|
);
|
|
2424
|
-
const z =
|
|
2425
|
-
let
|
|
2426
|
-
|
|
2424
|
+
const z = w.leftNode.index, E = w.downNode.index;
|
|
2425
|
+
let G = w.rightNode.index, q = w.upNode.index;
|
|
2426
|
+
G === 0 && (G = u - 1), q === 0 && (q = f - 1);
|
|
2427
2427
|
for (let C = 0; C < f - 1; C++)
|
|
2428
2428
|
for (let b = 0; b < u - 1; b++) {
|
|
2429
|
-
if (n && C >= E && C < q && b >= z && b <
|
|
2429
|
+
if (n && C >= E && C < q && b >= z && b < G)
|
|
2430
2430
|
continue;
|
|
2431
|
-
const K = C * u + b, J = C * u + (b + 1), ct = (C + 1) * u + b,
|
|
2432
|
-
|
|
2431
|
+
const K = C * u + b, J = C * u + (b + 1), ct = (C + 1) * u + b, ot = (C + 1) * u + (b + 1);
|
|
2432
|
+
W[K] += 2, W[J] += 2, W[ct] += 2, W[ot] += 2, Yt(
|
|
2433
2433
|
A,
|
|
2434
|
-
|
|
2434
|
+
x,
|
|
2435
2435
|
K,
|
|
2436
2436
|
J,
|
|
2437
2437
|
ct,
|
|
2438
|
-
|
|
2439
|
-
|
|
2438
|
+
ot,
|
|
2439
|
+
j
|
|
2440
2440
|
);
|
|
2441
2441
|
}
|
|
2442
|
-
if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)),
|
|
2443
|
-
|
|
2442
|
+
if (T.push(new Tt(0, 0, u - 1, f - 1, !1, !1)), Qt(T, H, $, u, f), o.baseXArray = v, o.baseZArray = Q, o.baseVertexCount = j, o.vertexCount = $.length, o.texcoords = $, o.weights = W, a) {
|
|
2443
|
+
o.subMeshCount = 1;
|
|
2444
2444
|
const C = [];
|
|
2445
|
-
C.push(...A), C.push(...H), C.push(...
|
|
2445
|
+
C.push(...A), C.push(...H), C.push(...x), o.triangles = C;
|
|
2446
2446
|
} else
|
|
2447
|
-
|
|
2448
|
-
return
|
|
2447
|
+
o.subMeshCount = 3, o.frontTriangles = A, o.backTriangles = x, o.borderTriangles = H;
|
|
2448
|
+
return o.borders = T, o;
|
|
2449
2449
|
}
|
|
2450
2450
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
2451
2451
|
updateRootPosition() {
|
|
@@ -2457,15 +2457,15 @@ class He {
|
|
|
2457
2457
|
resetPaperPosition(t) {
|
|
2458
2458
|
const e = this.m_Book.papers, s = e.length;
|
|
2459
2459
|
let i = 0;
|
|
2460
|
-
const n = e.length / 2 - 1,
|
|
2461
|
-
for (let
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2464
|
-
const S =
|
|
2465
|
-
i += S * k,
|
|
2466
|
-
}
|
|
2467
|
-
let
|
|
2468
|
-
const h = this.getStackZ(
|
|
2460
|
+
const n = e.length / 2 - 1, a = e.length / 2;
|
|
2461
|
+
for (let M = 0; M < s; M++) {
|
|
2462
|
+
const y = e[M];
|
|
2463
|
+
y.updateTime();
|
|
2464
|
+
const S = y.zTime, k = y.thickness;
|
|
2465
|
+
i += S * k, M === n && (i += S * this.m_BindingMidSpace / 2), M === a && (i += S * this.m_BindingMidSpace / 2);
|
|
2466
|
+
}
|
|
2467
|
+
let o = this.getStackHeight(t.index) - t.thickness / 2;
|
|
2468
|
+
const h = this.getStackZ(o), m = 180 + h;
|
|
2469
2469
|
let l = t.isFlipped ? 1 : 0, d = F(h, m, l);
|
|
2470
2470
|
const g = d * tt, _ = new c.Vector3(
|
|
2471
2471
|
Math.cos(g) * this.m_BindingRadius,
|
|
@@ -2475,21 +2475,21 @@ class He {
|
|
|
2475
2475
|
_.z = t.margin;
|
|
2476
2476
|
let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
|
|
2477
2477
|
if (t.index < Math.floor(s / 2)) {
|
|
2478
|
-
let
|
|
2478
|
+
let M = 0;
|
|
2479
2479
|
if (this.m_Book.alignToGround) {
|
|
2480
2480
|
u = e[0].size.x;
|
|
2481
|
-
const
|
|
2482
|
-
f = et(i, 0,
|
|
2481
|
+
const y = this.m_StackHeight / 2;
|
|
2482
|
+
f = et(i, 0, y) - y, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2483
2483
|
}
|
|
2484
|
-
d = F(P, -
|
|
2484
|
+
d = F(P, -M, l);
|
|
2485
2485
|
} else {
|
|
2486
|
-
let
|
|
2486
|
+
let M = 0;
|
|
2487
2487
|
if (this.m_Book.alignToGround) {
|
|
2488
2488
|
u = e[0].size.x;
|
|
2489
|
-
const
|
|
2490
|
-
f =
|
|
2489
|
+
const y = this.m_StackHeight / 2;
|
|
2490
|
+
f = y - et(i, y, y * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2491
2491
|
}
|
|
2492
|
-
d = F(
|
|
2492
|
+
d = F(M, -P, l);
|
|
2493
2493
|
}
|
|
2494
2494
|
t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
|
|
2495
2495
|
new c.Euler(0, 0, d * tt)
|
|
@@ -2499,9 +2499,9 @@ class He {
|
|
|
2499
2499
|
getPX(t, e) {
|
|
2500
2500
|
const s = this.m_Book.papers, i = s.length;
|
|
2501
2501
|
let n = 0;
|
|
2502
|
-
const
|
|
2502
|
+
const a = s.length / 2 - 1, o = s.length / 2;
|
|
2503
2503
|
for (let f = 0; f < i; f++)
|
|
2504
|
-
n += 0 * e, f ===
|
|
2504
|
+
n += 0 * e, f === a && (n += 0 * this.m_BindingMidSpace / 2), f === o && (n += 0 * this.m_BindingMidSpace / 2);
|
|
2505
2505
|
const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, _ = F(m, l, 0) * tt;
|
|
2506
2506
|
return new c.Vector3(
|
|
2507
2507
|
Math.cos(_) * this.m_BindingRadius,
|
|
@@ -2513,14 +2513,14 @@ class He {
|
|
|
2513
2513
|
updatePaperPosition(t) {
|
|
2514
2514
|
const e = this.m_Book.papers, s = e.length;
|
|
2515
2515
|
let i = 0;
|
|
2516
|
-
const n = e.length / 2 - 1,
|
|
2517
|
-
for (let
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
const S =
|
|
2521
|
-
i += S * k,
|
|
2522
|
-
}
|
|
2523
|
-
const
|
|
2516
|
+
const n = e.length / 2 - 1, a = e.length / 2;
|
|
2517
|
+
for (let M = 0; M < s; M++) {
|
|
2518
|
+
const y = e[M];
|
|
2519
|
+
y.updateTime();
|
|
2520
|
+
const S = y.zTime, k = y.thickness;
|
|
2521
|
+
i += S * k, M === n && (i += S * this.m_BindingMidSpace / 2), M === a && (i += S * this.m_BindingMidSpace / 2);
|
|
2522
|
+
}
|
|
2523
|
+
const o = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(o + i), m = 180 + this.getStackZ(o + i - this.m_StackHeight);
|
|
2524
2524
|
let l = t.zTime, d = F(h, m, l);
|
|
2525
2525
|
const g = d * tt, _ = new c.Vector3(
|
|
2526
2526
|
Math.cos(g) * this.m_BindingRadius,
|
|
@@ -2530,21 +2530,21 @@ class He {
|
|
|
2530
2530
|
_.z = t.margin;
|
|
2531
2531
|
let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, p = Math.sqrt(u * u - f * f), P = Math.asin(p / u) * it - 90;
|
|
2532
2532
|
if (t.index < Math.floor(s / 2)) {
|
|
2533
|
-
let
|
|
2533
|
+
let M = 0;
|
|
2534
2534
|
if (this.m_Book.alignToGround) {
|
|
2535
2535
|
u = e[0].size.x;
|
|
2536
|
-
const
|
|
2537
|
-
f = et(i, 0,
|
|
2536
|
+
const y = this.m_StackHeight / 2;
|
|
2537
|
+
f = et(i, 0, y) - y, p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2538
2538
|
}
|
|
2539
|
-
d = F(P, -
|
|
2539
|
+
d = F(P, -M, l);
|
|
2540
2540
|
} else {
|
|
2541
|
-
let
|
|
2541
|
+
let M = 0;
|
|
2542
2542
|
if (this.m_Book.alignToGround) {
|
|
2543
2543
|
u = e[0].size.x;
|
|
2544
|
-
const
|
|
2545
|
-
f =
|
|
2544
|
+
const y = this.m_StackHeight / 2;
|
|
2545
|
+
f = y - et(i, y, y * 2), p = Math.sqrt(u * u - f * f), M = (Math.asin(p / u) * it - 90) * 2;
|
|
2546
2546
|
}
|
|
2547
|
-
d = F(
|
|
2547
|
+
d = F(M, -P, l);
|
|
2548
2548
|
}
|
|
2549
2549
|
t.transform.position.copy(_), t.transform.quaternion.setFromEuler(
|
|
2550
2550
|
new c.Euler(0, 0, d * tt)
|
|
@@ -2579,21 +2579,21 @@ class He {
|
|
|
2579
2579
|
updateBindingVertices() {
|
|
2580
2580
|
const t = this.m_Book.papers;
|
|
2581
2581
|
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,
|
|
2582
|
+
const n = this.m_StapleThickness * 0.5, a = t[0].thickness, o = this.m_Root.matrixWorld.clone(), h = t.length;
|
|
2583
2583
|
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,
|
|
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, y = g.xNoneSeamIndexes, S = d.position.clone();
|
|
2585
2585
|
let k = m, O = n;
|
|
2586
2586
|
m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
|
|
2587
|
-
const Z = (
|
|
2588
|
-
i = this.m_BindingRadius * F(0.45, 0.65, 1 -
|
|
2587
|
+
const Z = (a + M) * 0.5 + M * (k - 1), V = d.matrixWorld.clone().invert().multiply(o), U = k / (h / 2);
|
|
2588
|
+
i = this.m_BindingRadius * F(0.45, 0.65, 1 - U);
|
|
2589
2589
|
for (let D = 0; D < P; D++) {
|
|
2590
|
-
const
|
|
2591
|
-
|
|
2592
|
-
const v = l.getDirection(
|
|
2590
|
+
const w = f[D], I = new c.Vector3(0, 0, S.z + w), L = S.clone();
|
|
2591
|
+
L.z += w;
|
|
2592
|
+
const v = l.getDirection(w).multiplyScalar(i).add(L.clone());
|
|
2593
2593
|
if (m === 0 && D === 0) {
|
|
2594
2594
|
const A = t[h - 1], H = A.transform.position.clone().clone();
|
|
2595
|
-
H.z +=
|
|
2596
|
-
const T = A.getDirection(
|
|
2595
|
+
H.z += w;
|
|
2596
|
+
const T = A.getDirection(w).multiplyScalar(i).add(H);
|
|
2597
2597
|
s = v.clone().sub(T).normalize(), e = new c.Vector3(
|
|
2598
2598
|
-s.y,
|
|
2599
2599
|
s.x,
|
|
@@ -2605,15 +2605,15 @@ class He {
|
|
|
2605
2605
|
k > 0 && I.add(e.clone().multiplyScalar(Z));
|
|
2606
2606
|
const Q = D * p;
|
|
2607
2607
|
_[Q] = I.clone().applyMatrix4(V), I.add(s.clone().multiplyScalar(O));
|
|
2608
|
-
const
|
|
2609
|
-
_[Q +
|
|
2608
|
+
const j = I.clone().applyMatrix4(V), $ = v.clone().applyMatrix4(V), W = L.clone().applyMatrix4(V);
|
|
2609
|
+
_[Q + y[1]] = j;
|
|
2610
2610
|
for (let A = 2; A < B; A++) {
|
|
2611
|
-
const
|
|
2612
|
-
_[Q +
|
|
2613
|
-
G,
|
|
2614
|
-
$,
|
|
2611
|
+
const x = Wt(1, B, A);
|
|
2612
|
+
_[Q + y[A]] = Et(
|
|
2615
2613
|
j,
|
|
2616
|
-
|
|
2614
|
+
$,
|
|
2615
|
+
W,
|
|
2616
|
+
x
|
|
2617
2617
|
);
|
|
2618
2618
|
}
|
|
2619
2619
|
}
|
|
@@ -2642,7 +2642,7 @@ class He {
|
|
|
2642
2642
|
return this.m_StapleThickness;
|
|
2643
2643
|
}
|
|
2644
2644
|
}
|
|
2645
|
-
class
|
|
2645
|
+
class Ze {
|
|
2646
2646
|
constructor(t) {
|
|
2647
2647
|
this.mesh = t;
|
|
2648
2648
|
}
|
|
@@ -2668,12 +2668,12 @@ class Fe {
|
|
|
2668
2668
|
return this.mesh;
|
|
2669
2669
|
}
|
|
2670
2670
|
}
|
|
2671
|
-
class
|
|
2671
|
+
class $e extends Se {
|
|
2672
2672
|
constructor() {
|
|
2673
|
-
super(...arguments), this.quality = 3, this.stapleSetup = new
|
|
2673
|
+
super(...arguments), this.quality = 3, this.stapleSetup = new He();
|
|
2674
2674
|
}
|
|
2675
2675
|
createBound(t, e, s, i) {
|
|
2676
|
-
return new
|
|
2676
|
+
return new Oe(
|
|
2677
2677
|
this.quality,
|
|
2678
2678
|
this.stapleSetup,
|
|
2679
2679
|
t,
|
|
@@ -2681,7 +2681,7 @@ class qe extends Pe {
|
|
|
2681
2681
|
);
|
|
2682
2682
|
}
|
|
2683
2683
|
}
|
|
2684
|
-
class
|
|
2684
|
+
class ee {
|
|
2685
2685
|
constructor(t) {
|
|
2686
2686
|
this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0;
|
|
2687
2687
|
}
|
|
@@ -2705,9 +2705,9 @@ class Oe {
|
|
|
2705
2705
|
}
|
|
2706
2706
|
const i = s.split(/\s+/);
|
|
2707
2707
|
let n = "";
|
|
2708
|
-
for (const
|
|
2709
|
-
const
|
|
2710
|
-
t.measureText(
|
|
2708
|
+
for (const a of i) {
|
|
2709
|
+
const o = n ? `${n} ${a}` : a;
|
|
2710
|
+
t.measureText(o).width > this.width && n ? (e.push(n), n = a) : n = o;
|
|
2711
2711
|
}
|
|
2712
2712
|
n && e.push(n);
|
|
2713
2713
|
}
|
|
@@ -2721,8 +2721,8 @@ class Oe {
|
|
|
2721
2721
|
hitTest(t, e, s) {
|
|
2722
2722
|
const i = this.wrapLines(t);
|
|
2723
2723
|
if (i.length === 0) return !1;
|
|
2724
|
-
const n = i.length * this.fontSize * this.lineHeight,
|
|
2725
|
-
return e >= this.x && e <= this.x +
|
|
2724
|
+
const n = i.length * this.fontSize * this.lineHeight, a = this.width > 0 ? this.width : this._maxLineWidth(t, i);
|
|
2725
|
+
return e >= this.x && e <= this.x + a && s >= this.y && s <= this.y + n;
|
|
2726
2726
|
}
|
|
2727
2727
|
_maxLineWidth(t, e) {
|
|
2728
2728
|
t.font = this._font();
|
|
@@ -2740,16 +2740,16 @@ class Oe {
|
|
|
2740
2740
|
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
2741
|
const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
|
|
2742
2742
|
for (let n = 0; n < e.length; n++) {
|
|
2743
|
-
let
|
|
2744
|
-
this.textAlign === "center" ?
|
|
2743
|
+
let a = this.x;
|
|
2744
|
+
this.textAlign === "center" ? a = this.x + (i - t.measureText(e[n]).width) / 2 : this.textAlign === "right" && (a = this.x + i - t.measureText(e[n]).width), t.fillText(e[n], a, this.y + n * s);
|
|
2745
2745
|
}
|
|
2746
2746
|
t.restore();
|
|
2747
2747
|
}
|
|
2748
2748
|
}
|
|
2749
|
-
function
|
|
2749
|
+
function Ue(r) {
|
|
2750
2750
|
return r.map instanceof c.Texture;
|
|
2751
2751
|
}
|
|
2752
|
-
class
|
|
2752
|
+
class Ye {
|
|
2753
2753
|
constructor(t) {
|
|
2754
2754
|
this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
|
|
2755
2755
|
const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
|
|
@@ -2773,7 +2773,7 @@ class Qe {
|
|
|
2773
2773
|
}
|
|
2774
2774
|
// ── Text API ─────────────────────────────────────────────────────────────
|
|
2775
2775
|
addText(t) {
|
|
2776
|
-
const e = new
|
|
2776
|
+
const e = new ee(t);
|
|
2777
2777
|
return this.texts.push(e), e;
|
|
2778
2778
|
}
|
|
2779
2779
|
removeText(t) {
|
|
@@ -2797,7 +2797,7 @@ class Qe {
|
|
|
2797
2797
|
update(t) {
|
|
2798
2798
|
const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
|
|
2799
2799
|
e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
|
|
2800
|
-
for (const
|
|
2800
|
+
for (const a of this.texts) a.draw(e);
|
|
2801
2801
|
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
2802
2802
|
}
|
|
2803
2803
|
/**
|
|
@@ -2809,7 +2809,7 @@ class Qe {
|
|
|
2809
2809
|
if (!e.isMesh) return;
|
|
2810
2810
|
const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
|
|
2811
2811
|
for (const n of i)
|
|
2812
|
-
|
|
2812
|
+
Ue(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
|
|
2813
2813
|
});
|
|
2814
2814
|
}
|
|
2815
2815
|
// ── IPageContent ─────────────────────────────────────────────────────────
|
|
@@ -2824,33 +2824,122 @@ class Qe {
|
|
|
2824
2824
|
this._texture.dispose();
|
|
2825
2825
|
}
|
|
2826
2826
|
}
|
|
2827
|
+
function Le(r) {
|
|
2828
|
+
return r.map instanceof c.Texture;
|
|
2829
|
+
}
|
|
2830
|
+
class jt {
|
|
2831
|
+
constructor(t, e) {
|
|
2832
|
+
this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
|
|
2833
|
+
}
|
|
2834
|
+
get texture() {
|
|
2835
|
+
return this._spread.texture;
|
|
2836
|
+
}
|
|
2837
|
+
get textureST() {
|
|
2838
|
+
return this._textureST;
|
|
2839
|
+
}
|
|
2840
|
+
isPointOverUI(t) {
|
|
2841
|
+
return !1;
|
|
2842
|
+
}
|
|
2843
|
+
init(t) {
|
|
2844
|
+
}
|
|
2845
|
+
setActive(t) {
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
function Ke(r) {
|
|
2849
|
+
const t = [];
|
|
2850
|
+
for (let e = 1; e + 1 < r; e += 2)
|
|
2851
|
+
t.push(e);
|
|
2852
|
+
return t;
|
|
2853
|
+
}
|
|
2854
|
+
class Je {
|
|
2855
|
+
constructor(t) {
|
|
2856
|
+
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;
|
|
2857
|
+
const e = this.canvas.getContext("2d");
|
|
2858
|
+
if (!e) throw new Error("SpreadContent: could not get 2D context");
|
|
2859
|
+
this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new jt(this, "left"), this.right = new jt(this, "right");
|
|
2860
|
+
}
|
|
2861
|
+
get texture() {
|
|
2862
|
+
return this._texture;
|
|
2863
|
+
}
|
|
2864
|
+
/** The base layer drawn beneath text blocks (full spread width). */
|
|
2865
|
+
get source() {
|
|
2866
|
+
return this._source;
|
|
2867
|
+
}
|
|
2868
|
+
set source(t) {
|
|
2869
|
+
this._source = t;
|
|
2870
|
+
}
|
|
2871
|
+
// ── Text API ─────────────────────────────────────────────────────────────
|
|
2872
|
+
addText(t) {
|
|
2873
|
+
const e = new ee(t);
|
|
2874
|
+
return this.texts.push(e), e;
|
|
2875
|
+
}
|
|
2876
|
+
removeText(t) {
|
|
2877
|
+
const e = this.texts.indexOf(t);
|
|
2878
|
+
e !== -1 && this.texts.splice(e, 1);
|
|
2879
|
+
}
|
|
2880
|
+
/** Update a text block by index. Only provided fields are changed. */
|
|
2881
|
+
updateText(t, e) {
|
|
2882
|
+
const s = this.texts[t];
|
|
2883
|
+
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));
|
|
2884
|
+
}
|
|
2885
|
+
// ── Per-frame update ─────────────────────────────────────────────────────
|
|
2886
|
+
/**
|
|
2887
|
+
* Re-composite the canvas: source layer + text blocks.
|
|
2888
|
+
* Call every frame (or when content changes).
|
|
2889
|
+
*
|
|
2890
|
+
* @param root Optional THREE.Object3D to traverse for texture sync
|
|
2891
|
+
* (needed because three-book clones material textures).
|
|
2892
|
+
*/
|
|
2893
|
+
update(t) {
|
|
2894
|
+
const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
|
|
2895
|
+
e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
|
|
2896
|
+
for (const a of this.texts) a.draw(e);
|
|
2897
|
+
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
2898
|
+
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Traverse `root` and set `needsUpdate = true` on every material map whose
|
|
2901
|
+
* source image is this spread's canvas.
|
|
2902
|
+
*/
|
|
2903
|
+
syncMaterials(t) {
|
|
2904
|
+
t.traverse((e) => {
|
|
2905
|
+
if (!e.isMesh) return;
|
|
2906
|
+
const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
|
|
2907
|
+
for (const n of i)
|
|
2908
|
+
Le(n) && n.map.image === this.canvas && (n.map.needsUpdate = !0);
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
2912
|
+
dispose() {
|
|
2913
|
+
this._texture.dispose();
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2827
2916
|
const Gt = 256;
|
|
2828
|
-
function
|
|
2829
|
-
const
|
|
2830
|
-
if (
|
|
2831
|
-
if (
|
|
2917
|
+
function Ne(r, t, e, s, i, n, a) {
|
|
2918
|
+
const o = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
|
|
2919
|
+
if (o <= 0 || h <= 0) return;
|
|
2920
|
+
if (a === "fill") {
|
|
2832
2921
|
r.drawImage(t, e, s, i, n);
|
|
2833
2922
|
return;
|
|
2834
2923
|
}
|
|
2835
|
-
const m =
|
|
2924
|
+
const m = a === "contain" ? Math.min(i / o, n / h) : Math.max(i / o, n / h), l = o * m, d = h * m;
|
|
2836
2925
|
r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
|
|
2837
2926
|
}
|
|
2838
|
-
function
|
|
2839
|
-
const
|
|
2840
|
-
m.width =
|
|
2927
|
+
function ts(r, t, e, s, i, n, a) {
|
|
2928
|
+
const o = n ? Math.round(n * Gt) : 512, h = a ? Math.round(a * Gt) : 512, m = document.createElement("canvas");
|
|
2929
|
+
m.width = o, m.height = h;
|
|
2841
2930
|
const l = m.getContext("2d");
|
|
2842
|
-
if (l.fillStyle = r, l.fillRect(0, 0,
|
|
2843
|
-
const g = i ? 0 : Math.round(Math.min(
|
|
2844
|
-
|
|
2931
|
+
if (l.fillStyle = r, l.fillRect(0, 0, o, h), e) {
|
|
2932
|
+
const g = i ? 0 : Math.round(Math.min(o, h) * 0.11);
|
|
2933
|
+
Ne(l, e, g, g, o - g * 2, h - g * 2, s);
|
|
2845
2934
|
} else {
|
|
2846
2935
|
l.fillStyle = "#333";
|
|
2847
|
-
const g = Math.round(Math.min(
|
|
2848
|
-
l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t,
|
|
2936
|
+
const g = Math.round(Math.min(o, h) * 0.094);
|
|
2937
|
+
l.font = `bold ${g}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, o / 2, h / 2);
|
|
2849
2938
|
}
|
|
2850
2939
|
const d = new c.CanvasTexture(m);
|
|
2851
2940
|
return d.colorSpace = c.SRGBColorSpace, d;
|
|
2852
2941
|
}
|
|
2853
|
-
async function
|
|
2942
|
+
async function es(r) {
|
|
2854
2943
|
if (!r) return null;
|
|
2855
2944
|
const t = URL.createObjectURL(r), e = new Image();
|
|
2856
2945
|
e.decoding = "async", e.src = t;
|
|
@@ -2863,45 +2952,47 @@ async function Ye(r) {
|
|
|
2863
2952
|
}
|
|
2864
2953
|
}
|
|
2865
2954
|
export {
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2955
|
+
Ce as AnimationCurve,
|
|
2956
|
+
yt as AutoTurnDirection,
|
|
2957
|
+
Me as AutoTurnMode,
|
|
2869
2958
|
rt as AutoTurnSetting,
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2959
|
+
ye as AutoTurnSettingCurveTimeMode,
|
|
2960
|
+
we as AutoTurnSettingMode,
|
|
2961
|
+
Lt as AutoTurnSettings,
|
|
2873
2962
|
Ct as Book,
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2963
|
+
Se as BookBinding,
|
|
2964
|
+
Qe as BookBound,
|
|
2965
|
+
Ge as BookContent,
|
|
2877
2966
|
X as BookDirection,
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2967
|
+
Xe as BookHeightException,
|
|
2968
|
+
qe as BookPointerInteraction,
|
|
2969
|
+
pe as BookRenderer,
|
|
2881
2970
|
ut as Cylinder,
|
|
2882
|
-
|
|
2971
|
+
_e as MeshFactory,
|
|
2883
2972
|
Gt as PX_PER_UNIT,
|
|
2884
|
-
|
|
2885
|
-
|
|
2973
|
+
je as PageContent,
|
|
2974
|
+
me as Paper,
|
|
2886
2975
|
Tt as PaperBorder,
|
|
2887
2976
|
At as PaperMaterialData,
|
|
2888
2977
|
Zt as PaperMeshData,
|
|
2889
|
-
|
|
2890
|
-
|
|
2978
|
+
xe as PaperMeshDataPool,
|
|
2979
|
+
Ee as PaperMeshUtility,
|
|
2891
2980
|
st as PaperNode,
|
|
2892
|
-
|
|
2893
|
-
|
|
2981
|
+
ue as PaperNodeMargin,
|
|
2982
|
+
Te as PaperPattern,
|
|
2894
2983
|
Pt as PaperSeam,
|
|
2895
2984
|
ht as PaperSetup,
|
|
2896
2985
|
pt as PaperUVMargin,
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2986
|
+
fe as RendererFactory,
|
|
2987
|
+
Je as SpreadContent,
|
|
2988
|
+
Nt as SpritePageContent2,
|
|
2989
|
+
$e as StapleBookBinding,
|
|
2990
|
+
Oe as StapleBookBound,
|
|
2991
|
+
He as StapleSetup,
|
|
2992
|
+
ee as TextBlock,
|
|
2993
|
+
Ye as TextOverlayContent,
|
|
2994
|
+
ts as createPageTexture,
|
|
2995
|
+
Ne as drawImageWithFit,
|
|
2996
|
+
Ke as getSpreadPairs,
|
|
2997
|
+
es as loadImage
|
|
2907
2998
|
};
|