@objectifthunes/react-three-book 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +132 -2
- package/dist/index.js +744 -583
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useFrame as
|
|
1
|
+
import { jsxs as ie, jsx as ne } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ht, useState as Kt, useEffect as Ct, createContext as re, useContext as Jt, forwardRef as ae, useImperativeHandle as oe, useCallback as rt, useMemo as he } from "react";
|
|
3
|
+
import { useFrame as Pt, useThree as le } from "@react-three/fiber";
|
|
4
4
|
import * as c from "three";
|
|
5
5
|
class pt {
|
|
6
6
|
constructor() {
|
|
@@ -33,7 +33,7 @@ class pt {
|
|
|
33
33
|
* 3. Rotate by Y degrees around Y-axis.
|
|
34
34
|
*/
|
|
35
35
|
eulerRotateVector(t, e, s) {
|
|
36
|
-
const i = s * Math.PI / 180, r = e * Math.PI / 180,
|
|
36
|
+
const i = s * Math.PI / 180, r = e * Math.PI / 180, a = Math.cos(i), o = Math.sin(i), h = t * a, u = t * o, l = 0, d = Math.cos(r), f = Math.sin(r), g = h * d + l * f, m = u, _ = -h * f + l * d;
|
|
37
37
|
return new c.Vector3(g, m, _);
|
|
38
38
|
}
|
|
39
39
|
roll(t) {
|
|
@@ -69,33 +69,33 @@ class pt {
|
|
|
69
69
|
return t.m_PositionX = this.m_PositionX, t.m_PositionZ = this.m_PositionZ, t.m_DirectionX = this.m_DirectionX, t.m_DirectionZ = this.m_DirectionZ, t.m_EulerY = this.m_EulerY, t.m_Radius = this.m_Radius, t;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function yt(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
73
73
|
s = Math.max(s, 1e-4);
|
|
74
|
-
const
|
|
74
|
+
const a = 2 / s, o = a * r, h = 1 / (1 + o + 0.48 * o * o + 0.235 * o * o * o);
|
|
75
75
|
let u = n - t;
|
|
76
76
|
const l = t, d = i * s;
|
|
77
77
|
u = c.MathUtils.clamp(u, -d, d), t = n - u;
|
|
78
|
-
const
|
|
79
|
-
e = (e -
|
|
80
|
-
let g = t + (u +
|
|
78
|
+
const f = (e + a * u) * r;
|
|
79
|
+
e = (e - a * f) * h;
|
|
80
|
+
let g = t + (u + f) * h;
|
|
81
81
|
return l - n > 0 == g > l && (g = l, e = (g - l) / r), { value: g, velocity: e };
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
83
|
+
function ce(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
84
|
+
const a = yt(
|
|
85
85
|
n.x,
|
|
86
86
|
t.x,
|
|
87
87
|
e.x,
|
|
88
88
|
s.x,
|
|
89
89
|
i,
|
|
90
90
|
r
|
|
91
|
-
),
|
|
91
|
+
), o = yt(
|
|
92
92
|
n.y,
|
|
93
93
|
t.y,
|
|
94
94
|
e.y,
|
|
95
95
|
s.y,
|
|
96
96
|
i,
|
|
97
97
|
r
|
|
98
|
-
), h =
|
|
98
|
+
), h = yt(
|
|
99
99
|
n.z,
|
|
100
100
|
t.z,
|
|
101
101
|
e.z,
|
|
@@ -103,15 +103,15 @@ function le(n, t, e, s, i = 1 / 0, r = 1 / 60) {
|
|
|
103
103
|
i,
|
|
104
104
|
r
|
|
105
105
|
);
|
|
106
|
-
return e.set(
|
|
106
|
+
return e.set(a.velocity, o.velocity, h.velocity), new c.Vector3(a.value, o.value, h.value);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function ue(n) {
|
|
109
109
|
return new c.Vector3(n.x, 0, n.y);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function me(n) {
|
|
112
112
|
return new c.Vector3(n.x, n.z, 0);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function bt(n, t, e) {
|
|
115
115
|
const s = t * t - 4 * n * e;
|
|
116
116
|
if (s < 0)
|
|
117
117
|
return { rootCount: 0, root0: 0, root1: 0 };
|
|
@@ -126,55 +126,55 @@ function Bt(n, t, e) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
129
|
+
function It(n, t, e) {
|
|
130
|
+
return de(n, t, e) ? n.clone() : _e(
|
|
131
131
|
new c.Vector2(n.x, t.y),
|
|
132
132
|
n,
|
|
133
133
|
t,
|
|
134
134
|
e
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function de(n, t, e) {
|
|
138
138
|
const s = n.x - t.x;
|
|
139
139
|
let i = n.y - t.y;
|
|
140
140
|
return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
143
|
-
const i = e.x, r = e.y,
|
|
144
|
-
if (Math.abs(
|
|
145
|
-
if (
|
|
146
|
-
const m =
|
|
142
|
+
function _e(n, t, e, s) {
|
|
143
|
+
const i = e.x, r = e.y, a = n.x, o = n.y, h = t.x, u = t.y, l = s.x, d = s.y, f = 1 / (l * l), g = 1 / (d * d);
|
|
144
|
+
if (Math.abs(a - h) < 1e-5) {
|
|
145
|
+
if (a >= i - l && a <= i + l) {
|
|
146
|
+
const m = bt(
|
|
147
147
|
g,
|
|
148
148
|
-2 * g * r,
|
|
149
|
-
|
|
149
|
+
f * (a * a - 2 * i * a + i * i) + g * r * r - 1
|
|
150
150
|
);
|
|
151
151
|
if (m.rootCount === 1)
|
|
152
|
-
return new c.Vector2(
|
|
152
|
+
return new c.Vector2(a, m.root0);
|
|
153
153
|
if (m.rootCount === 2) {
|
|
154
|
-
let _ = m.root0,
|
|
155
|
-
return
|
|
154
|
+
let _ = m.root0, p = m.root1;
|
|
155
|
+
return o < u && ([_, p] = [p, _]), new c.Vector2(a, p);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
} else {
|
|
159
|
-
const m = (u -
|
|
160
|
-
|
|
161
|
-
2 *
|
|
162
|
-
i * i *
|
|
159
|
+
const m = (u - o) / (h - a), _ = o - m * a, p = _ - r, T = bt(
|
|
160
|
+
f + g * m * m,
|
|
161
|
+
2 * p * m * g - 2 * i * f,
|
|
162
|
+
i * i * f + p * p * g - 1
|
|
163
163
|
);
|
|
164
164
|
if (T.rootCount === 1)
|
|
165
165
|
return new c.Vector2(T.root0, m * T.root0 + _);
|
|
166
166
|
if (T.rootCount === 2) {
|
|
167
|
-
let b = T.root0,
|
|
168
|
-
return
|
|
167
|
+
let b = T.root0, M = T.root1;
|
|
168
|
+
return a < h && ([b, M] = [M, b]), new c.Vector2(M, m * M + _);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
return n.clone();
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function zt(n, t) {
|
|
174
174
|
const e = n.origin.clone().applyMatrix4(t), s = n.origin.clone().add(n.direction).applyMatrix4(t);
|
|
175
175
|
return new c.Ray(e, s.sub(e));
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function fe(n) {
|
|
178
178
|
return new c.Vector4(-n.x, n.y, n.z + n.x, n.w);
|
|
179
179
|
}
|
|
180
180
|
function ge(n) {
|
|
@@ -182,25 +182,25 @@ function ge(n) {
|
|
|
182
182
|
}
|
|
183
183
|
var X = /* @__PURE__ */ ((n) => (n[n.LeftToRight = 0] = "LeftToRight", n[n.RightToLeft = 1] = "RightToLeft", n[n.UpToDown = 2] = "UpToDown", n[n.DownToUp = 3] = "DownToUp", n))(X || {});
|
|
184
184
|
const Rt = Math.PI / 180, Vt = 180 / Math.PI, pe = 1192093e-13;
|
|
185
|
-
function
|
|
185
|
+
function xt(n) {
|
|
186
186
|
return n < 0 ? 0 : n > 1 ? 1 : n;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function Dt(n, t, e) {
|
|
189
189
|
return n < t ? t : n > e ? e : n;
|
|
190
190
|
}
|
|
191
191
|
function gt(n, t, e) {
|
|
192
|
-
return n !== t ?
|
|
193
|
-
}
|
|
194
|
-
function Dt(n, t, e) {
|
|
195
|
-
return n + (t - n) * e;
|
|
192
|
+
return n !== t ? xt((e - n) / (t - n)) : 0;
|
|
196
193
|
}
|
|
197
194
|
function At(n, t, e) {
|
|
198
195
|
return n + (t - n) * e;
|
|
199
196
|
}
|
|
200
197
|
function Ft(n, t, e) {
|
|
201
|
-
return
|
|
198
|
+
return n + (t - n) * e;
|
|
199
|
+
}
|
|
200
|
+
function Ht(n, t, e) {
|
|
201
|
+
return e = xt((e - n) / (t - n)), e * e * (3 - 2 * e);
|
|
202
202
|
}
|
|
203
|
-
class
|
|
203
|
+
class xe {
|
|
204
204
|
// ---- Constructor ----
|
|
205
205
|
constructor(t, e, s, i) {
|
|
206
206
|
this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new pt(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
|
|
@@ -316,16 +316,16 @@ class fe {
|
|
|
316
316
|
this.m_MinTurningRadius = t;
|
|
317
317
|
}
|
|
318
318
|
updateTurningRadius(t = 1) {
|
|
319
|
-
let e = Math.max(this.m_Stiffness, 1 -
|
|
319
|
+
let e = Math.max(this.m_Stiffness, 1 - xt(t));
|
|
320
320
|
e <= 0.5 ? this.m_TurningRadius = gt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - gt(0.5, 1, e)), 5) * Rt), this.m_TurningRadius = Math.max(
|
|
321
321
|
this.m_TurningRadius,
|
|
322
322
|
this.m_MinTurningRadius
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
startTurning(t) {
|
|
326
|
-
var r,
|
|
326
|
+
var r, a;
|
|
327
327
|
const e = t.clone();
|
|
328
|
-
t =
|
|
328
|
+
t = zt(
|
|
329
329
|
t,
|
|
330
330
|
this.m_Transform.matrixWorld.clone().invert()
|
|
331
331
|
), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
|
|
@@ -334,17 +334,17 @@ class fe {
|
|
|
334
334
|
);
|
|
335
335
|
const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
|
|
336
336
|
if (t.intersectPlane(s, i) !== null) {
|
|
337
|
-
const
|
|
338
|
-
if (
|
|
339
|
-
if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(
|
|
340
|
-
this.m_HandleOffset.set(
|
|
337
|
+
const o = i;
|
|
338
|
+
if (o.x > 0 && o.x < this.m_Size.x && o.z > 0 && o.z < this.m_Size.y) {
|
|
339
|
+
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) {
|
|
340
|
+
this.m_HandleOffset.set(o.x - this.m_Size.x, 0, 0);
|
|
341
341
|
const h = this.m_Transform.scale;
|
|
342
342
|
h.x *= -1;
|
|
343
343
|
}
|
|
344
344
|
return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
|
|
345
345
|
0
|
|
346
346
|
/* Highpoly */
|
|
347
|
-
), (r = this.m_Prev) == null || r.trySwitchMeshData(1), (
|
|
347
|
+
), (r = this.m_Prev) == null || r.trySwitchMeshData(1), (a = this.m_Next) == null || a.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
return !1;
|
|
@@ -354,7 +354,7 @@ class fe {
|
|
|
354
354
|
const t = new c.Vector3(0, 0, 0);
|
|
355
355
|
for (const e of this.m_HandleVelocities)
|
|
356
356
|
t.add(e);
|
|
357
|
-
t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime =
|
|
357
|
+
t.divideScalar(this.m_HandleVelocities.length), t.length() > 0.1 ? this.m_IsFallingLeft = t.x < 0 : this.m_IsFallingLeft = this.m_XTime > 0.5 && this.m_ZTime > 0.1, this.m_IsFallingLeft ? this.m_FallTime = 1 - this.m_XTime : this.m_FallTime = this.m_XTime, this.m_FallTime = At(0.1, 0.2, this.m_FallTime), this.m_EndHandle.copy(this.m_StartHandle), this.m_IsFallingLeft && (this.m_EndHandle.x = -this.m_Size.x);
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
360
|
* Called each frame while the user is dragging.
|
|
@@ -378,8 +378,8 @@ class fe {
|
|
|
378
378
|
var s, i;
|
|
379
379
|
let e = !1;
|
|
380
380
|
if (this.m_IsAutoTurning) {
|
|
381
|
-
let r =
|
|
382
|
-
r =
|
|
381
|
+
let r = xt(this.m_FallTime / this.m_FallDuration);
|
|
382
|
+
r = Ht(0, 1, r), r = Ht(0, 1, r), this.m_CurrentHandle.lerpVectors(
|
|
383
383
|
this.m_StartHandle,
|
|
384
384
|
this.m_EndHandle,
|
|
385
385
|
this.m_IsFallingLeft ? r : 1 - r
|
|
@@ -390,7 +390,7 @@ class fe {
|
|
|
390
390
|
0,
|
|
391
391
|
this.m_FallTime * 0.75
|
|
392
392
|
);
|
|
393
|
-
this.m_CurrentHandle =
|
|
393
|
+
this.m_CurrentHandle = ce(
|
|
394
394
|
this.m_CurrentHandle,
|
|
395
395
|
this.m_EndHandle,
|
|
396
396
|
this.m_HandleVelocity,
|
|
@@ -454,7 +454,7 @@ class fe {
|
|
|
454
454
|
* Returns the local-space hit point, or null if no hit / out of bounds.
|
|
455
455
|
*/
|
|
456
456
|
raycastLocal(t, e = !1) {
|
|
457
|
-
t =
|
|
457
|
+
t = zt(
|
|
458
458
|
t,
|
|
459
459
|
this.m_Transform.matrixWorld.clone().invert()
|
|
460
460
|
);
|
|
@@ -493,19 +493,19 @@ class fe {
|
|
|
493
493
|
), this.m_SubMeshCount = t);
|
|
494
494
|
const e = this.m_FrontContent.textureST.clone();
|
|
495
495
|
let s = this.m_BackContent.textureST.clone();
|
|
496
|
-
this.m_Book.direction > 1 ? s = ge(s) : s =
|
|
496
|
+
this.m_Book.direction > 1 ? s = ge(s) : s = fe(s);
|
|
497
497
|
const i = this.m_FrontContent.texture, r = this.m_BackContent.texture;
|
|
498
498
|
if (t === 3) {
|
|
499
|
-
let
|
|
500
|
-
this.m_Transform.scale.x === -1 && (
|
|
499
|
+
let a = 0, o = 1;
|
|
500
|
+
this.m_Transform.scale.x === -1 && (a = 1, o = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
|
|
501
501
|
this.m_MaterialData.propertyBlock,
|
|
502
|
-
|
|
502
|
+
a
|
|
503
503
|
), this.m_UseBackContentForSides || this.m_Renderer.setPropertyBlock(
|
|
504
504
|
this.m_MaterialData.propertyBlock,
|
|
505
505
|
2
|
|
506
506
|
), this.m_MaterialData.updatePropertyBlock(r, s), this.m_Renderer.setPropertyBlock(
|
|
507
507
|
this.m_MaterialData.propertyBlock,
|
|
508
|
-
|
|
508
|
+
o
|
|
509
509
|
), this.m_UseBackContentForSides && this.m_Renderer.setPropertyBlock(
|
|
510
510
|
this.m_MaterialData.propertyBlock,
|
|
511
511
|
2
|
|
@@ -535,16 +535,16 @@ class fe {
|
|
|
535
535
|
const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
|
|
536
536
|
new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
|
|
537
537
|
);
|
|
538
|
-
this.m_XTime =
|
|
538
|
+
this.m_XTime = At(
|
|
539
539
|
Math.min(t, e),
|
|
540
540
|
Math.max(t, e),
|
|
541
541
|
0.9
|
|
542
542
|
);
|
|
543
|
-
const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, r = this.rollPoint(new c.Vector3(s[1], 0, 0)),
|
|
543
|
+
const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, r = this.rollPoint(new c.Vector3(s[1], 0, 0)), a = this.rollPoint(new c.Vector3(s[2], 0, 0)), o = this.rollPoint(
|
|
544
544
|
new c.Vector3(s[1], 0, i[i.length - 1])
|
|
545
545
|
), h = this.rollPoint(
|
|
546
546
|
new c.Vector3(s[2], 0, i[i.length - 1])
|
|
547
|
-
), u =
|
|
547
|
+
), u = a.clone().sub(r).normalize(), l = h.clone().sub(o).normalize(), d = Vt * Math.atan2(u.y, u.x), f = Vt * Math.atan2(l.y, l.x), g = (d + f) / 2;
|
|
548
548
|
this.m_ZTime = g / 180;
|
|
549
549
|
} else
|
|
550
550
|
this.m_XTime = 0, this.m_ZTime = 0;
|
|
@@ -554,26 +554,26 @@ class fe {
|
|
|
554
554
|
}
|
|
555
555
|
clampHandle() {
|
|
556
556
|
this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
|
|
557
|
-
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), r = s.distanceTo(this.m_StartHandle),
|
|
557
|
+
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), r = s.distanceTo(this.m_StartHandle), a = Math.max(i - this.m_TurningRadius, 0.01), o = Math.max(r - this.m_TurningRadius, 0.01), h = this.m_StartHandle.z, u = new c.Vector2(
|
|
558
558
|
0,
|
|
559
|
-
h + (e.z - h) * (
|
|
559
|
+
h + (e.z - h) * (a / i)
|
|
560
560
|
), l = new c.Vector2(
|
|
561
561
|
0,
|
|
562
|
-
h + (s.z - h) * (
|
|
563
|
-
), d = new c.Vector2(i,
|
|
564
|
-
t.x =
|
|
565
|
-
const g =
|
|
562
|
+
h + (s.z - h) * (o / r)
|
|
563
|
+
), d = new c.Vector2(i, a), f = new c.Vector2(r, o);
|
|
564
|
+
t.x = Dt(t.x, -this.m_Size.x, this.m_Size.x);
|
|
565
|
+
const g = me(t), m = It(
|
|
566
566
|
new c.Vector2(g.x, g.y),
|
|
567
567
|
u,
|
|
568
568
|
d
|
|
569
|
-
), _ =
|
|
569
|
+
), _ = It(
|
|
570
570
|
new c.Vector2(m.x, m.y),
|
|
571
571
|
l,
|
|
572
|
-
|
|
573
|
-
),
|
|
572
|
+
f
|
|
573
|
+
), p = ue(
|
|
574
574
|
new c.Vector3(_.x, _.y, 0)
|
|
575
575
|
);
|
|
576
|
-
this.m_CurrentHandle.copy(
|
|
576
|
+
this.m_CurrentHandle.copy(p);
|
|
577
577
|
}
|
|
578
578
|
updateCylinder() {
|
|
579
579
|
const t = this.m_StartHandle.clone(), e = this.m_CurrentHandle.clone(), s = t.clone().sub(e).normalize();
|
|
@@ -582,17 +582,17 @@ class fe {
|
|
|
582
582
|
s.clone().multiplyScalar(
|
|
583
583
|
this.m_Size.x * 2 + this.m_TurningRadius * Math.PI
|
|
584
584
|
)
|
|
585
|
-
), r = t.clone(),
|
|
586
|
-
|
|
585
|
+
), r = t.clone(), a = new pt();
|
|
586
|
+
a.radius = this.m_TurningRadius, a.direction = new c.Vector3(
|
|
587
587
|
-s.z,
|
|
588
588
|
0,
|
|
589
589
|
s.x
|
|
590
590
|
);
|
|
591
|
-
for (let
|
|
592
|
-
|
|
593
|
-
const h =
|
|
591
|
+
for (let o = 0; o < 100; o++) {
|
|
592
|
+
a.position = i.clone().add(r).multiplyScalar(0.5), this.m_Cylinder = a, this.m_Book.bound.updatePaperPosition(this);
|
|
593
|
+
const h = a.rollPoint(t.clone());
|
|
594
594
|
if (Math.abs(e.x - h.x) < 1e-4) break;
|
|
595
|
-
h.x > e.x ? r.copy(
|
|
595
|
+
h.x > e.x ? r.copy(a.position) : i.copy(a.position);
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
rollPoint(t) {
|
|
@@ -610,10 +610,10 @@ class fe {
|
|
|
610
610
|
0
|
|
611
611
|
/* Highpoly */
|
|
612
612
|
), (u = this.m_Prev) == null || u.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === 1, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
|
|
613
|
-
const r = this.m_Size.x,
|
|
614
|
-
e =
|
|
615
|
-
const
|
|
616
|
-
this.m_StartHandle.set(r, 0,
|
|
613
|
+
const r = this.m_Size.x, a = this.m_Size.y;
|
|
614
|
+
e = Dt(e, -0.99, 0.99);
|
|
615
|
+
const o = Ft(0.5, 1, e), h = Ft(0.5, 0, e);
|
|
616
|
+
this.m_StartHandle.set(r, 0, a * o), this.m_EndHandle.set(-r, 0, a * h), this.m_IsAutoTurning = !0;
|
|
617
617
|
}
|
|
618
618
|
// ---- Public getter for the cylinder (used by BookBound etc.) ----
|
|
619
619
|
get cylinder() {
|
|
@@ -699,10 +699,10 @@ const Y = class Y {
|
|
|
699
699
|
}
|
|
700
700
|
};
|
|
701
701
|
Y.kMin = 0, Y.kMax = 0.25;
|
|
702
|
-
let
|
|
702
|
+
let Tt = Y;
|
|
703
703
|
const U = class U {
|
|
704
704
|
constructor(t) {
|
|
705
|
-
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
|
|
705
|
+
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 Tt(), this.margin = 0, this.bookDirection = X.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? U.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? U.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? U.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
|
|
706
706
|
}
|
|
707
707
|
// ── Properties ────────────────────────────────────────────────────────
|
|
708
708
|
get material() {
|
|
@@ -761,8 +761,8 @@ const U = class U {
|
|
|
761
761
|
}
|
|
762
762
|
};
|
|
763
763
|
U.kMinSize = 1, U.kMinThickness = 1e-4, U.kMinQuality = 1, U.kMaxQuality = 5;
|
|
764
|
-
let
|
|
765
|
-
class
|
|
764
|
+
let ct = U;
|
|
765
|
+
class Ot {
|
|
766
766
|
constructor(t) {
|
|
767
767
|
this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
|
|
768
768
|
const e = t.material ?? new c.MeshStandardMaterial();
|
|
@@ -798,13 +798,13 @@ class Ht {
|
|
|
798
798
|
this.m_Texture = t, this.m_TextureST.copy(e);
|
|
799
799
|
}
|
|
800
800
|
}
|
|
801
|
-
function
|
|
802
|
-
let i = t.x - n.x, r = t.y - n.y,
|
|
803
|
-
i *=
|
|
801
|
+
function Zt(n, t, e, s = new c.Vector3()) {
|
|
802
|
+
let i = t.x - n.x, r = t.y - n.y, a = t.z - n.z, o = 1 / Math.sqrt(i * i + r * r + a * a);
|
|
803
|
+
i *= o, r *= o, a *= o;
|
|
804
804
|
let h = e.x - n.x, u = e.y - n.y, l = e.z - n.z;
|
|
805
|
-
|
|
806
|
-
const d = r * l -
|
|
807
|
-
return
|
|
805
|
+
o = 1 / Math.sqrt(h * h + u * u + l * l), h *= o, u *= o, l *= o;
|
|
806
|
+
const d = r * l - a * u, f = a * h - i * l, g = i * u - r * h;
|
|
807
|
+
return o = 1 / Math.sqrt(d * d + f * f + g * g), s.set(d * o, f * o, g * o);
|
|
808
808
|
}
|
|
809
809
|
class it {
|
|
810
810
|
constructor(t, e = !1, s = !1) {
|
|
@@ -863,18 +863,18 @@ class it {
|
|
|
863
863
|
t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
class
|
|
866
|
+
class vt {
|
|
867
867
|
constructor(t, e, s, i) {
|
|
868
868
|
this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
|
|
869
869
|
}
|
|
870
870
|
clone() {
|
|
871
|
-
const t = new
|
|
871
|
+
const t = new vt(this.prevIndex, this.index, this.nextIndex, this.time);
|
|
872
872
|
return t.active = this.active, t;
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
875
|
class St {
|
|
876
|
-
constructor(t, e, s, i, r,
|
|
877
|
-
this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = r, this.left =
|
|
876
|
+
constructor(t, e, s, i, r, a = !0) {
|
|
877
|
+
this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = r, this.left = a;
|
|
878
878
|
}
|
|
879
879
|
clone() {
|
|
880
880
|
return new St(
|
|
@@ -901,63 +901,63 @@ function mt(n, t, e) {
|
|
|
901
901
|
const s = (e - n) / (t - n);
|
|
902
902
|
return Math.max(0, Math.min(1, s));
|
|
903
903
|
}
|
|
904
|
-
function
|
|
904
|
+
function Lt(n, t) {
|
|
905
905
|
for (const e of n) {
|
|
906
|
-
const s = e.prevNoneSeam, i = e.nextNoneSeam, r = mt(s.value, i.value, e.value),
|
|
907
|
-
t.push(
|
|
906
|
+
const s = e.prevNoneSeam, i = e.nextNoneSeam, r = mt(s.value, i.value, e.value), a = new vt(s.index, e.index, i.index, r);
|
|
907
|
+
t.push(a);
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
910
|
function Nt(n, t, e, s, i) {
|
|
911
911
|
for (const r of n) {
|
|
912
912
|
if (!r.active) return;
|
|
913
|
-
for (let
|
|
914
|
-
const
|
|
915
|
-
i ?
|
|
913
|
+
for (let a = 0; a < s; a++) {
|
|
914
|
+
const o = r.prevIndex, h = r.nextIndex, u = t[a * e + o], l = t[a * e + h], d = t[a * e + r.index];
|
|
915
|
+
i ? te(u, l, r.time, d) : d.copy(u).lerp(l, r.time);
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
|
-
function
|
|
919
|
+
function Ut(n, t, e, s, i) {
|
|
920
920
|
for (const r of n) {
|
|
921
921
|
if (!r.active) return;
|
|
922
|
-
for (let
|
|
923
|
-
const
|
|
924
|
-
i ?
|
|
922
|
+
for (let a = 0; a < e; a++) {
|
|
923
|
+
const o = r.prevIndex, h = r.nextIndex, u = t[o * e + a], l = t[h * e + a], d = t[r.index * e + a];
|
|
924
|
+
i ? te(u, l, r.time, d) : d.copy(u).lerp(l, r.time);
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
-
function
|
|
928
|
+
function te(n, t, e, s = new c.Vector3()) {
|
|
929
929
|
const i = Math.sqrt(n.x * n.x + n.y * n.y + n.z * n.z), r = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
|
|
930
930
|
if (i === 0 || r === 0)
|
|
931
931
|
return s.copy(n).lerp(t, e);
|
|
932
|
-
const
|
|
933
|
-
let
|
|
934
|
-
|
|
935
|
-
const g = Math.acos(
|
|
932
|
+
const a = n.x / i, o = n.y / i, h = n.z / i, u = t.x / r, l = t.y / r, d = t.z / r;
|
|
933
|
+
let f = a * u + o * l + h * d;
|
|
934
|
+
f = Math.max(-1, Math.min(1, f));
|
|
935
|
+
const g = Math.acos(f);
|
|
936
936
|
if (g < 1e-6)
|
|
937
937
|
return s.copy(n).lerp(t, e);
|
|
938
|
-
const m = Math.sin(g), _ = Math.sin((1 - e) * g) / m,
|
|
938
|
+
const m = Math.sin(g), _ = Math.sin((1 - e) * g) / m, p = Math.sin(e * g) / m, T = i + (r - i) * e;
|
|
939
939
|
return s.set(
|
|
940
|
-
(
|
|
941
|
-
(
|
|
942
|
-
(h * _ + d *
|
|
940
|
+
(a * _ + u * p) * T,
|
|
941
|
+
(o * _ + l * p) * T,
|
|
942
|
+
(h * _ + d * p) * T
|
|
943
943
|
);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function we(n, t, e, s, i) {
|
|
946
946
|
for (const r of n) {
|
|
947
|
-
const
|
|
947
|
+
const a = (r.endX - r.startX + 1) * 2, o = (r.endZ - r.startZ + 1) * 2, h = e.length;
|
|
948
948
|
for (let l = 0, d = r.endX - r.startX; l < d; l++) {
|
|
949
|
-
const
|
|
950
|
-
r.flip ?
|
|
949
|
+
const f = h + l * 2 + 0, g = h + l * 2 + 1, m = h + l * 2 + 2, _ = h + l * 2 + 3;
|
|
950
|
+
r.flip ? Xt(t, f, g, m, _, a) : Et(t, f, g, m, _, a);
|
|
951
951
|
}
|
|
952
952
|
if (r.left)
|
|
953
953
|
for (let l = 0, d = r.endZ - r.startZ; l < d; l++) {
|
|
954
|
-
const
|
|
955
|
-
r.flip ?
|
|
954
|
+
const f = h + l * 2 + 0 + a * 2, g = h + l * 2 + 1 + a * 2, m = h + l * 2 + 2 + a * 2, _ = h + l * 2 + 3 + a * 2;
|
|
955
|
+
r.flip ? Xt(t, f, g, m, _, o) : Et(t, f, g, m, _, o);
|
|
956
956
|
}
|
|
957
957
|
else
|
|
958
958
|
for (let l = 0, d = r.endZ - r.startZ; l < d; l++) {
|
|
959
|
-
const
|
|
960
|
-
r.flip ?
|
|
959
|
+
const f = h + l * 2 + 0 + a * 2 + o, g = h + l * 2 + 1 + a * 2 + o, m = h + l * 2 + 2 + a * 2 + o, _ = h + l * 2 + 3 + a * 2 + o;
|
|
960
|
+
r.flip ? wt(t, f, g, m, _) : Mt(t, f, g, m, _);
|
|
961
961
|
}
|
|
962
962
|
const u = s * i;
|
|
963
963
|
for (let l = r.startX; l <= r.endX; l++) {
|
|
@@ -980,70 +980,70 @@ function xe(n, t, e, s, i) {
|
|
|
980
980
|
}
|
|
981
981
|
function Ce(n, t, e, s, i) {
|
|
982
982
|
const r = s * i;
|
|
983
|
-
let
|
|
984
|
-
const
|
|
983
|
+
let a = r * 2;
|
|
984
|
+
const o = new c.Vector3();
|
|
985
985
|
for (const h of n) {
|
|
986
986
|
for (let u = h.startX; u <= h.endX; u++) {
|
|
987
|
-
const l = u + h.startZ * s, d = t[l],
|
|
988
|
-
|
|
987
|
+
const l = u + h.startZ * s, d = t[l], f = t[l + s];
|
|
988
|
+
o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].copy(t[l + r]);
|
|
989
989
|
}
|
|
990
990
|
for (let u = h.startX; u <= h.endX; u++) {
|
|
991
|
-
const l = u + h.endZ * s, d = t[l + r],
|
|
992
|
-
|
|
991
|
+
const l = u + h.endZ * s, d = t[l + r], f = t[l + r - s];
|
|
992
|
+
o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].copy(t[l]);
|
|
993
993
|
}
|
|
994
994
|
for (let u = h.startZ; u <= h.endZ; u++) {
|
|
995
|
-
const l = u * s + h.startX, d = t[l + r],
|
|
996
|
-
|
|
995
|
+
const l = u * s + h.startX, d = t[l + r], f = t[l + r + 1];
|
|
996
|
+
o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].copy(t[l]);
|
|
997
997
|
}
|
|
998
998
|
for (let u = h.startZ; u <= h.endZ; u++) {
|
|
999
|
-
const l = u * s + h.endX, d = t[l],
|
|
1000
|
-
|
|
999
|
+
const l = u * s + h.endX, d = t[l], f = t[l - 1];
|
|
1000
|
+
o.subVectors(d, f).normalize(), h.flip && o.multiplyScalar(-1), e[a].copy(o), t[a++].copy(d), e[a].copy(o), t[a++].copy(t[l + r]);
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
1003
|
}
|
|
1004
|
-
function
|
|
1004
|
+
function Et(n, t, e, s, i, r) {
|
|
1005
1005
|
Mt(n, t, e, s, i), t += r, e += r, s += r, i += r, Mt(n, t, e, s, i);
|
|
1006
1006
|
}
|
|
1007
|
-
function
|
|
1008
|
-
|
|
1007
|
+
function Xt(n, t, e, s, i, r) {
|
|
1008
|
+
wt(n, t, e, s, i), t += r, e += r, s += r, i += r, wt(n, t, e, s, i);
|
|
1009
1009
|
}
|
|
1010
|
-
function
|
|
1011
|
-
Mt(n, e, s, i, r), e +=
|
|
1010
|
+
function ye(n, t, e, s, i, r, a) {
|
|
1011
|
+
Mt(n, e, s, i, r), e += a, s += a, i += a, r += a, wt(t, e, s, i, r);
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1013
|
+
function Te(n, t, e, s, i, r) {
|
|
1014
|
+
const a = i.left * s.x, o = (1 - i.right) * s.x, h = i.down * s.y, u = (1 - i.up) * s.y, l = t.length, d = e.length;
|
|
1015
1015
|
if (r > 1)
|
|
1016
1016
|
for (let g = 0; g < d; g++)
|
|
1017
1017
|
for (let m = 0; m < l; m++) {
|
|
1018
|
-
const _ = mt(
|
|
1019
|
-
n.push(new c.Vector2(
|
|
1018
|
+
const _ = mt(o, a, t[m]), p = mt(u, h, e[g]);
|
|
1019
|
+
n.push(new c.Vector2(p, _));
|
|
1020
1020
|
}
|
|
1021
1021
|
else
|
|
1022
1022
|
for (let g = 0; g < d; g++)
|
|
1023
1023
|
for (let m = 0; m < l; m++) {
|
|
1024
|
-
const _ = mt(
|
|
1025
|
-
n.push(new c.Vector2(_,
|
|
1024
|
+
const _ = mt(a, o, t[m]), p = mt(u, h, e[g]);
|
|
1025
|
+
n.push(new c.Vector2(_, p));
|
|
1026
1026
|
}
|
|
1027
|
-
const
|
|
1028
|
-
for (let g = 0; g <
|
|
1027
|
+
const f = n.length;
|
|
1028
|
+
for (let g = 0; g < f; g++)
|
|
1029
1029
|
n.push(n[g].clone());
|
|
1030
1030
|
}
|
|
1031
1031
|
function Mt(n, t, e, s, i) {
|
|
1032
1032
|
n.push(t), n.push(s), n.push(e), n.push(e), n.push(s), n.push(i);
|
|
1033
1033
|
}
|
|
1034
|
-
function
|
|
1034
|
+
function wt(n, t, e, s, i) {
|
|
1035
1035
|
n.push(t), n.push(e), n.push(s), n.push(e), n.push(i), n.push(s);
|
|
1036
1036
|
}
|
|
1037
|
-
function
|
|
1037
|
+
function Pe(n, t, e, s) {
|
|
1038
1038
|
const i = [];
|
|
1039
1039
|
for (let r = 0; r < e - 1; r++)
|
|
1040
|
-
for (let
|
|
1041
|
-
let
|
|
1042
|
-
|
|
1040
|
+
for (let a = 0; a < t - 1; a++) {
|
|
1041
|
+
let o = n[r * t + a].clone(), h = n[r * t + a + 1].clone(), u = n[(r + 1) * t + a].clone(), l = n[(r + 1) * t + a + 1].clone();
|
|
1042
|
+
o.applyMatrix4(s), h.applyMatrix4(s), u.applyMatrix4(s), l.applyMatrix4(s), i.push([o, h, u, l]);
|
|
1043
1043
|
}
|
|
1044
1044
|
return i;
|
|
1045
1045
|
}
|
|
1046
|
-
class
|
|
1046
|
+
class jt {
|
|
1047
1047
|
get geometry() {
|
|
1048
1048
|
return this.m_Geometry;
|
|
1049
1049
|
}
|
|
@@ -1055,25 +1055,25 @@ class Xt {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
constructor(t, e) {
|
|
1057
1057
|
this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
|
|
1058
|
-
for (let
|
|
1059
|
-
this.m_BaseVertices[
|
|
1058
|
+
for (let a = 0; a < e.baseVertexCount; a++)
|
|
1059
|
+
this.m_BaseVertices[a] = new c.Vector3();
|
|
1060
1060
|
this.m_Vertices = new Array(e.vertexCount);
|
|
1061
|
-
for (let
|
|
1062
|
-
this.m_Vertices[
|
|
1061
|
+
for (let a = 0; a < e.vertexCount; a++)
|
|
1062
|
+
this.m_Vertices[a] = new c.Vector3();
|
|
1063
1063
|
this.m_Normals = new Array(e.vertexCount);
|
|
1064
|
-
for (let
|
|
1065
|
-
this.m_Normals[
|
|
1064
|
+
for (let a = 0; a < e.vertexCount; a++)
|
|
1065
|
+
this.m_Normals[a] = new c.Vector3();
|
|
1066
1066
|
if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
|
|
1067
|
-
const
|
|
1068
|
-
this.m_Geometry.setIndex(new c.BufferAttribute(
|
|
1067
|
+
const a = new Uint32Array(e.triangles);
|
|
1068
|
+
this.m_Geometry.setIndex(new c.BufferAttribute(a, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
|
|
1069
1069
|
} else {
|
|
1070
|
-
const
|
|
1070
|
+
const a = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, o = new Uint32Array(a);
|
|
1071
1071
|
let h = 0;
|
|
1072
|
-
|
|
1072
|
+
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));
|
|
1073
1073
|
}
|
|
1074
1074
|
const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), r = new Float32Array(e.vertexCount * 2);
|
|
1075
|
-
for (let
|
|
1076
|
-
r[
|
|
1075
|
+
for (let a = 0; a < e.texcoords.length; a++)
|
|
1076
|
+
r[a * 2] = e.texcoords[a].x, r[a * 2 + 1] = e.texcoords[a].y;
|
|
1077
1077
|
this.m_Geometry.setAttribute(
|
|
1078
1078
|
"position",
|
|
1079
1079
|
new c.BufferAttribute(s, 3)
|
|
@@ -1093,11 +1093,11 @@ class Xt {
|
|
|
1093
1093
|
* Ported from lines ~2167-2183.
|
|
1094
1094
|
*/
|
|
1095
1095
|
updateBaseVertices() {
|
|
1096
|
-
const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, r = e.length,
|
|
1097
|
-
let
|
|
1098
|
-
for (let h = 0; h <
|
|
1096
|
+
const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, r = e.length, a = s.length;
|
|
1097
|
+
let o = 0;
|
|
1098
|
+
for (let h = 0; h < a; h++)
|
|
1099
1099
|
for (let u = 0; u < r; u++)
|
|
1100
|
-
t[
|
|
1100
|
+
t[o++].set(e[u] + i, 0, s[h]);
|
|
1101
1101
|
}
|
|
1102
1102
|
// ── UpdateMesh ─────────────────────────────────────────────────────────
|
|
1103
1103
|
/**
|
|
@@ -1116,40 +1116,40 @@ class Xt {
|
|
|
1116
1116
|
* Ported from lines ~2185-2255.
|
|
1117
1117
|
*/
|
|
1118
1118
|
updateMesh() {
|
|
1119
|
-
const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, r = this.m_Pattern.baseXArray.length,
|
|
1120
|
-
for (let m = 0; m <
|
|
1119
|
+
const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, r = this.m_Pattern.baseXArray.length, a = this.m_Pattern.baseZArray.length, o = this.m_Pattern.baseVertexCount, h = new c.Vector3(), u = new c.Vector3(), l = new c.Vector3();
|
|
1120
|
+
for (let m = 0; m < o; m++)
|
|
1121
1121
|
s[m].set(0, 0, 0);
|
|
1122
|
-
Nt(this.m_Pattern.xSeams, t, r,
|
|
1123
|
-
for (let m = 0; m <
|
|
1122
|
+
Nt(this.m_Pattern.xSeams, t, r, a, !1), Ut(this.m_Pattern.zSeams, t, r, a, !1);
|
|
1123
|
+
for (let m = 0; m < a - 1; m++) {
|
|
1124
1124
|
const _ = m + 1;
|
|
1125
|
-
for (let
|
|
1126
|
-
const T =
|
|
1127
|
-
|
|
1125
|
+
for (let p = 0; p < r - 1; p++) {
|
|
1126
|
+
const T = p + 1, b = m * r + p, M = m * r + T, C = _ * r + p, v = _ * r + T, k = t[b], O = t[M], Z = t[C], V = t[v];
|
|
1127
|
+
Zt(k, Z, O, h), Zt(V, O, Z, u), l.addVectors(h, u), s[b].add(l), s[M].add(l), s[C].add(l), s[v].add(l);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
|
-
for (let m = 0; m <
|
|
1130
|
+
for (let m = 0; m < o; m++)
|
|
1131
1131
|
s[m].divideScalar(i[m]).normalize();
|
|
1132
|
-
Nt(this.m_Pattern.xSeams, s, r,
|
|
1132
|
+
Nt(this.m_Pattern.xSeams, s, r, a, !0), Ut(this.m_Pattern.zSeams, s, r, a, !0);
|
|
1133
1133
|
const d = this.m_Pattern.thickness / 2;
|
|
1134
|
-
for (let m = 0; m <
|
|
1134
|
+
for (let m = 0; m < o; m++) {
|
|
1135
1135
|
const _ = s[m];
|
|
1136
|
-
s[m +
|
|
1137
|
-
const
|
|
1138
|
-
e[m].copy(
|
|
1136
|
+
s[m + o].copy(_).negate();
|
|
1137
|
+
const p = t[m];
|
|
1138
|
+
e[m].copy(p).addScaledVector(_, d), e[m + o].copy(p).addScaledVector(_, -d);
|
|
1139
1139
|
}
|
|
1140
|
-
Ce(this.m_Pattern.borders, e, s, r,
|
|
1141
|
-
const
|
|
1140
|
+
Ce(this.m_Pattern.borders, e, s, r, a);
|
|
1141
|
+
const f = this.m_Geometry.getAttribute(
|
|
1142
1142
|
"position"
|
|
1143
1143
|
), g = this.m_Geometry.getAttribute(
|
|
1144
1144
|
"normal"
|
|
1145
1145
|
);
|
|
1146
1146
|
for (let m = 0; m < e.length; m++) {
|
|
1147
1147
|
const _ = e[m];
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
g.setXYZ(m,
|
|
1148
|
+
f.setXYZ(m, _.x, _.y, _.z);
|
|
1149
|
+
const p = s[m];
|
|
1150
|
+
g.setXYZ(m, p.x, p.y, p.z);
|
|
1151
1151
|
}
|
|
1152
|
-
|
|
1152
|
+
f.needsUpdate = !0, g.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
|
|
1153
1153
|
}
|
|
1154
1154
|
// ── DrawWireframe (debug) ──────────────────────────────────────────────
|
|
1155
1155
|
/**
|
|
@@ -1159,10 +1159,10 @@ class Xt {
|
|
|
1159
1159
|
*/
|
|
1160
1160
|
drawWireframe(t) {
|
|
1161
1161
|
const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
|
|
1162
|
-
return
|
|
1162
|
+
return Pe(this.m_Vertices, e, s, t);
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
|
-
class
|
|
1165
|
+
class ve {
|
|
1166
1166
|
constructor() {
|
|
1167
1167
|
this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
|
|
1168
1168
|
}
|
|
@@ -1193,7 +1193,7 @@ class Se {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
get(t) {
|
|
1195
1195
|
let e;
|
|
1196
|
-
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new
|
|
1196
|
+
return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new Be(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
|
|
1197
1197
|
}
|
|
1198
1198
|
recycle() {
|
|
1199
1199
|
for (const t of this.m_UsedRenderers)
|
|
@@ -1213,10 +1213,10 @@ class Se {
|
|
|
1213
1213
|
return t;
|
|
1214
1214
|
}
|
|
1215
1215
|
}
|
|
1216
|
-
let
|
|
1217
|
-
class
|
|
1216
|
+
let ke = 1;
|
|
1217
|
+
class Be {
|
|
1218
1218
|
constructor(t, e, s) {
|
|
1219
|
-
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id =
|
|
1219
|
+
this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = ke++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
|
|
1220
1220
|
new c.BufferGeometry(),
|
|
1221
1221
|
new c.MeshStandardMaterial()
|
|
1222
1222
|
), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
|
|
@@ -1289,16 +1289,16 @@ class ke {
|
|
|
1289
1289
|
return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
|
|
1290
1290
|
}
|
|
1291
1291
|
applyTextureProperty(t, e, s, i) {
|
|
1292
|
-
const r = this.getSTKey(i),
|
|
1293
|
-
if (
|
|
1294
|
-
t.map !==
|
|
1292
|
+
const r = this.getSTKey(i), a = this.m_MaterialTextures.get(e);
|
|
1293
|
+
if (a && a.source === s && a.stKey === r) {
|
|
1294
|
+
t.map !== a.texture && (t.map = a.texture, t.needsUpdate = !0);
|
|
1295
1295
|
return;
|
|
1296
1296
|
}
|
|
1297
1297
|
this.clearManagedTexture(e);
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1298
|
+
const o = s.clone();
|
|
1299
|
+
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, {
|
|
1300
1300
|
source: s,
|
|
1301
|
-
texture:
|
|
1301
|
+
texture: o,
|
|
1302
1302
|
stKey: r
|
|
1303
1303
|
});
|
|
1304
1304
|
}
|
|
@@ -1320,19 +1320,19 @@ class ke {
|
|
|
1320
1320
|
e.dispose();
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
|
-
class
|
|
1323
|
+
class be {
|
|
1324
1324
|
constructor(t, e, s = !1) {
|
|
1325
|
-
this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new
|
|
1325
|
+
this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new jt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
|
|
1326
1326
|
}
|
|
1327
1327
|
get() {
|
|
1328
|
-
return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new
|
|
1328
|
+
return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new jt(this.m_MeshFactory.get(), this.m_Pattern);
|
|
1329
1329
|
}
|
|
1330
1330
|
free(t) {
|
|
1331
1331
|
if (this.m_UseSharedData) throw new Error("Not implemented");
|
|
1332
1332
|
this.m_Stack.push(t);
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
|
-
var dt = /* @__PURE__ */ ((n) => (n[n.Next = 0] = "Next", n[n.Back = 1] = "Back", n))(dt || {}),
|
|
1335
|
+
var dt = /* @__PURE__ */ ((n) => (n[n.Next = 0] = "Next", n[n.Back = 1] = "Back", n))(dt || {}), Ie = /* @__PURE__ */ ((n) => (n[n.Surface = 0] = "Surface", n[n.Edge = 1] = "Edge", n))(Ie || {}), ze = /* @__PURE__ */ ((n) => (n[n.Constant = 0] = "Constant", n[n.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", n[n.Curve = 2] = "Curve", n[n.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", n))(ze || {}), Re = /* @__PURE__ */ ((n) => (n[n.PaperIndexTime = 0] = "PaperIndexTime", n[n.TurnIndexTime = 1] = "TurnIndexTime", n))(Re || {});
|
|
1336
1336
|
class Ve {
|
|
1337
1337
|
constructor(t) {
|
|
1338
1338
|
this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
|
|
@@ -1355,16 +1355,16 @@ class Ve {
|
|
|
1355
1355
|
return e[s - 1].value;
|
|
1356
1356
|
}
|
|
1357
1357
|
}
|
|
1358
|
-
function
|
|
1358
|
+
function at(n, t, e) {
|
|
1359
1359
|
return Math.max(t, Math.min(e, n));
|
|
1360
1360
|
}
|
|
1361
|
-
function
|
|
1362
|
-
return n === t ? 0 :
|
|
1361
|
+
function De(n, t, e) {
|
|
1362
|
+
return n === t ? 0 : at((e - n) / (t - n), 0, 1);
|
|
1363
1363
|
}
|
|
1364
|
-
function
|
|
1364
|
+
function Wt(n, t) {
|
|
1365
1365
|
return n + Math.random() * (t - n);
|
|
1366
1366
|
}
|
|
1367
|
-
class
|
|
1367
|
+
class ot {
|
|
1368
1368
|
constructor(t, e) {
|
|
1369
1369
|
this.m_Mode = 0, this.m_Constant = 0, this.m_ConstantMin = 0, this.m_ConstantMax = 0, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_CurveTimeMode = 0, t !== void 0 && (e === void 0 ? (this.m_Constant = t, this.m_ConstantMin = t, this.m_ConstantMax = t, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_Mode = 0, this.m_CurveTimeMode = 0) : (this.m_Constant = 0, this.m_ConstantMin = t, this.m_ConstantMax = e, this.m_Curve = null, this.m_CurveMin = null, this.m_CurveMax = null, this.m_Mode = 1, this.m_CurveTimeMode = 0));
|
|
1370
1370
|
}
|
|
@@ -1419,12 +1419,12 @@ class at {
|
|
|
1419
1419
|
}
|
|
1420
1420
|
/** A value based on a curve. */
|
|
1421
1421
|
static fromCurve(t, e) {
|
|
1422
|
-
const s = new
|
|
1422
|
+
const s = new ot();
|
|
1423
1423
|
return s.m_Constant = 0, s.m_ConstantMin = 0, s.m_ConstantMax = 0, s.m_Curve = t, s.m_CurveMin = null, s.m_CurveMax = null, s.m_Mode = 2, s.m_CurveTimeMode = e, s;
|
|
1424
1424
|
}
|
|
1425
1425
|
/** A random value generated between two curves. */
|
|
1426
1426
|
static fromCurveRange(t, e, s) {
|
|
1427
|
-
const i = new
|
|
1427
|
+
const i = new ot();
|
|
1428
1428
|
return i.m_Constant = 0, i.m_ConstantMin = 0, i.m_ConstantMax = 0, i.m_Curve = null, i.m_CurveMin = t, i.m_CurveMax = e, i.m_Mode = 3, i.m_CurveTimeMode = s, i;
|
|
1429
1429
|
}
|
|
1430
1430
|
// ── Internal API ────────────────────────────────────────────────────────
|
|
@@ -1432,12 +1432,12 @@ class at {
|
|
|
1432
1432
|
getValue(t, e) {
|
|
1433
1433
|
if (this.m_Mode === 0) return this.m_Constant;
|
|
1434
1434
|
if (this.m_Mode === 1)
|
|
1435
|
-
return
|
|
1435
|
+
return Wt(this.m_ConstantMin, this.m_ConstantMax);
|
|
1436
1436
|
const s = this.m_CurveTimeMode === 0 ? t : e;
|
|
1437
1437
|
if (this.m_Mode === 2)
|
|
1438
1438
|
return this.m_Curve.evaluate(s);
|
|
1439
1439
|
if (this.m_Mode === 3)
|
|
1440
|
-
return
|
|
1440
|
+
return Wt(
|
|
1441
1441
|
this.m_CurveMin.evaluate(s),
|
|
1442
1442
|
this.m_CurveMax.evaluate(s)
|
|
1443
1443
|
);
|
|
@@ -1445,31 +1445,31 @@ class at {
|
|
|
1445
1445
|
}
|
|
1446
1446
|
/** @internal */
|
|
1447
1447
|
clampValues(t, e) {
|
|
1448
|
-
return this.m_Constant =
|
|
1448
|
+
return this.m_Constant = at(this.m_Constant, t, e), this.m_ConstantMin = at(this.m_ConstantMin, t, e), this.m_ConstantMax = at(this.m_ConstantMax, t, e), this.m_Curve = this.clampCurve(this.m_Curve, t, e), this.m_CurveMin = this.clampCurve(this.m_CurveMin, t, e), this.m_CurveMax = this.clampCurve(this.m_CurveMax, t, e), this;
|
|
1449
1449
|
}
|
|
1450
1450
|
clampCurve(t, e, s) {
|
|
1451
1451
|
if (this.m_Curve === null || t === null) return null;
|
|
1452
1452
|
const i = t.keys.map((h) => ({ time: h.time, value: h.value })), r = i.length;
|
|
1453
|
-
let
|
|
1453
|
+
let a = 1 / 0, o = -1 / 0;
|
|
1454
1454
|
for (let h = 0; h < r; h++) {
|
|
1455
1455
|
const u = i[h].time;
|
|
1456
|
-
|
|
1456
|
+
a = Math.min(a, u), o = Math.max(o, u);
|
|
1457
1457
|
}
|
|
1458
1458
|
for (let h = 0; h < r; h++) {
|
|
1459
1459
|
let u = i[h].time, l = i[h].value;
|
|
1460
|
-
u =
|
|
1460
|
+
u = De(a, o, u), l = at(l, e, s), i[h].time = u, i[h].value = l;
|
|
1461
1461
|
}
|
|
1462
1462
|
return new Ve(i);
|
|
1463
1463
|
}
|
|
1464
1464
|
// ── Value-type clone ────────────────────────────────────────────────────
|
|
1465
1465
|
clone() {
|
|
1466
|
-
const t = new
|
|
1466
|
+
const t = new ot();
|
|
1467
1467
|
return t.m_Mode = this.m_Mode, t.m_Constant = this.m_Constant, t.m_ConstantMin = this.m_ConstantMin, t.m_ConstantMax = this.m_ConstantMax, t.m_Curve = this.m_Curve, t.m_CurveMin = this.m_CurveMin, t.m_CurveMax = this.m_CurveMax, t.m_CurveTimeMode = this.m_CurveTimeMode, t;
|
|
1468
1468
|
}
|
|
1469
1469
|
}
|
|
1470
1470
|
const I = class I {
|
|
1471
1471
|
constructor() {
|
|
1472
|
-
this.m_Mode = 0, this.m_Twist = new
|
|
1472
|
+
this.m_Mode = 0, this.m_Twist = new ot(), this.m_Bend = new ot(1), this.m_Duration = new ot(0.5);
|
|
1473
1473
|
}
|
|
1474
1474
|
// ── Properties ──────────────────────────────────────────────────────────
|
|
1475
1475
|
get mode() {
|
|
@@ -1512,7 +1512,7 @@ const I = class I {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
/** @internal */
|
|
1514
1514
|
getBendValue(t, e) {
|
|
1515
|
-
return
|
|
1515
|
+
return at(
|
|
1516
1516
|
this.m_Bend.getValue(t, e),
|
|
1517
1517
|
I.kMinBend,
|
|
1518
1518
|
I.kMaxBend
|
|
@@ -1520,7 +1520,7 @@ const I = class I {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
/** @internal */
|
|
1522
1522
|
getDurationValue(t, e) {
|
|
1523
|
-
return
|
|
1523
|
+
return at(
|
|
1524
1524
|
this.m_Duration.getValue(t, e),
|
|
1525
1525
|
I.kMinDuration,
|
|
1526
1526
|
I.kMaxDuration
|
|
@@ -1528,7 +1528,7 @@ const I = class I {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
/** @internal */
|
|
1530
1530
|
getTwistValue(t, e) {
|
|
1531
|
-
return
|
|
1531
|
+
return at(
|
|
1532
1532
|
this.m_Twist.getValue(t, e),
|
|
1533
1533
|
I.kMinTwist,
|
|
1534
1534
|
I.kMaxTwist
|
|
@@ -1536,7 +1536,7 @@ const I = class I {
|
|
|
1536
1536
|
}
|
|
1537
1537
|
};
|
|
1538
1538
|
I.kMinTwist = -1, I.kMaxTwist = 1, I.kMinBend = 0, I.kMaxBend = 1, I.kMinDuration = 0, I.kMaxDuration = 5;
|
|
1539
|
-
let
|
|
1539
|
+
let ut = I, us = class extends Error {
|
|
1540
1540
|
constructor() {
|
|
1541
1541
|
super(
|
|
1542
1542
|
"The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
|
|
@@ -1544,29 +1544,29 @@ let ct = I, as = class extends Error {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
};
|
|
1546
1546
|
var K;
|
|
1547
|
-
let
|
|
1547
|
+
let Ae = (K = class extends c.Group {
|
|
1548
1548
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
1549
1549
|
constructor(t) {
|
|
1550
|
-
super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_CreateColliders = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new
|
|
1550
|
+
super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_CreateColliders = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new ct({
|
|
1551
1551
|
color: new c.Color(1, 0, 0),
|
|
1552
1552
|
width: 2.1,
|
|
1553
1553
|
height: 3.1,
|
|
1554
1554
|
thickness: 0.04,
|
|
1555
1555
|
stiffness: 0.5
|
|
1556
|
-
}), this.m_PagePaperSetup = new
|
|
1556
|
+
}), this.m_PagePaperSetup = new ct({
|
|
1557
1557
|
color: new c.Color(1, 1, 1),
|
|
1558
1558
|
width: 2,
|
|
1559
1559
|
height: 3,
|
|
1560
1560
|
thickness: 0.02,
|
|
1561
1561
|
stiffness: 0.2
|
|
1562
|
-
}), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = X.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new
|
|
1562
|
+
}), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = X.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new ct({
|
|
1563
1563
|
color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
|
|
1564
1564
|
width: t.coverPaperSetup.width ?? 2.1,
|
|
1565
1565
|
height: t.coverPaperSetup.height ?? 3.1,
|
|
1566
1566
|
thickness: t.coverPaperSetup.thickness ?? 0.04,
|
|
1567
1567
|
stiffness: t.coverPaperSetup.stiffness ?? 0.5,
|
|
1568
1568
|
material: t.coverPaperSetup.material ?? null
|
|
1569
|
-
})), t.pagePaperSetup && (this.m_PagePaperSetup = new
|
|
1569
|
+
})), t.pagePaperSetup && (this.m_PagePaperSetup = new ct({
|
|
1570
1570
|
color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
|
|
1571
1571
|
width: t.pagePaperSetup.width ?? 2,
|
|
1572
1572
|
height: t.pagePaperSetup.height ?? 3,
|
|
@@ -1701,15 +1701,15 @@ let De = (K = class extends c.Group {
|
|
|
1701
1701
|
}
|
|
1702
1702
|
getActivePaperSideIndices(t) {
|
|
1703
1703
|
if (t.length = 0, !this.m_IsBuilt) return;
|
|
1704
|
-
const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (r,
|
|
1705
|
-
let
|
|
1706
|
-
|
|
1704
|
+
const e = this.m_Content.direction === X.RightToLeft, s = this.m_Papers.length, i = (r, a) => {
|
|
1705
|
+
let o = r * 2;
|
|
1706
|
+
a && o++, e && (o = s * 2 - o - 1), t.includes(o) || t.push(o);
|
|
1707
1707
|
};
|
|
1708
1708
|
for (let r = 0; r < s; r++) {
|
|
1709
|
-
const
|
|
1710
|
-
if (
|
|
1709
|
+
const a = this.m_Papers[r];
|
|
1710
|
+
if (a.isFalling || a.isTurning)
|
|
1711
1711
|
r > 0 && i(r - 1, !0), i(r, !1), i(r, !0), r < s - 1 && i(r + 1, !1);
|
|
1712
|
-
else if (
|
|
1712
|
+
else if (a.isOnRightStack) {
|
|
1713
1713
|
r > 0 && i(r - 1, !0), i(r, !1);
|
|
1714
1714
|
break;
|
|
1715
1715
|
}
|
|
@@ -1735,11 +1735,11 @@ let De = (K = class extends c.Group {
|
|
|
1735
1735
|
startAutoTurning(t, e, s = 1, i = 0) {
|
|
1736
1736
|
if (!this.m_IsBuilt) return !1;
|
|
1737
1737
|
this.cancelPendingAutoTurns();
|
|
1738
|
-
const r = typeof i == "number" ? new
|
|
1738
|
+
const r = typeof i == "number" ? new ot(i) : i;
|
|
1739
1739
|
if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
|
|
1740
|
-
for (let
|
|
1741
|
-
const
|
|
1742
|
-
this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: d, bend:
|
|
1740
|
+
for (let a = 0; a < s && this.canAutoTurn(t); a++) {
|
|
1741
|
+
const o = a / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), u = a > 0 ? r.getValue(h, o) : 0, l = e.getModeValue(), d = e.getTwistValue(h, o), f = e.getBendValue(h, o), g = e.getDurationValue(h, o);
|
|
1742
|
+
this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: d, bend: f, duration: g, delay: u });
|
|
1743
1743
|
}
|
|
1744
1744
|
return this.m_AutoTurnTimer = 0, !0;
|
|
1745
1745
|
}
|
|
@@ -1812,42 +1812,42 @@ let De = (K = class extends c.Group {
|
|
|
1812
1812
|
// ── Build ─────────────────────────────────────────────────────────────
|
|
1813
1813
|
build() {
|
|
1814
1814
|
if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
|
|
1815
|
-
if (this.m_MeshFactory === null && (this.m_MeshFactory = new
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1815
|
+
if (this.m_MeshFactory === null && (this.m_MeshFactory = new ve()), this.m_RendererFactory === null) {
|
|
1816
|
+
const w = new c.Object3D();
|
|
1817
|
+
w.name = "Root", this.add(w), this.m_Root = w, this.m_RendererFactory = new Se(this.m_Root);
|
|
1818
1818
|
}
|
|
1819
1819
|
this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
|
|
1820
1820
|
const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
|
|
1821
1821
|
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);
|
|
1822
|
-
const e = new
|
|
1822
|
+
const e = new Ot(this.m_CoverPaperSetup), s = new Ot(this.m_PagePaperSetup);
|
|
1823
1823
|
this.m_Content.init(this);
|
|
1824
|
-
let i = this.m_Content.coverContents, r = this.m_Content.pageContents,
|
|
1825
|
-
this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), r = [...r].reverse(),
|
|
1826
|
-
const
|
|
1824
|
+
let i = this.m_Content.coverContents, r = this.m_Content.pageContents, a = this.m_InitialOpenProgress;
|
|
1825
|
+
this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), r = [...r].reverse(), a = 1 - a), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(r.length / 2);
|
|
1826
|
+
const o = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
|
|
1827
1827
|
let u = 0, l = 0, d = 0;
|
|
1828
|
-
this.m_Papers = new Array(
|
|
1829
|
-
for (let
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1828
|
+
this.m_Papers = new Array(o);
|
|
1829
|
+
for (let w = 0; w < o; w++) {
|
|
1830
|
+
const z = this.m_HasCover && (w < h || w >= o - h), N = this.m_RendererFactory.get("Paper"), S = this.m_Papers[w] = new xe(z, w, this, N);
|
|
1831
|
+
S.renderer.castShadows = this.m_CastShadows, w < Math.round(c.MathUtils.lerp(0, o, a)) && (S.transform.scale.set(-1, 1, 1), S.setTime(1)), z ? (S.setContentData(i[l++], i[l++], w > h), S.setMaterialData(e), S.setPaperSetup(this.m_CoverPaperSetup)) : (S.setContentData(r[u++], r[u++]), S.setMaterialData(s), S.setPaperSetup(this.m_PagePaperSetup)), d += S.thickness;
|
|
1832
1832
|
}
|
|
1833
1833
|
this.m_TotalThickness = d;
|
|
1834
|
-
const
|
|
1835
|
-
this.m_MinPaperThickness = Math.min(
|
|
1836
|
-
const m = this.m_Papers[0].size.x, _ = this.m_Papers[Math.floor(
|
|
1834
|
+
const f = this.m_Papers[0].thickness, g = this.m_Papers[Math.floor(o / 2)].thickness;
|
|
1835
|
+
this.m_MinPaperThickness = Math.min(f, g), this.m_MaxPaperThickness = Math.max(f, g);
|
|
1836
|
+
const m = this.m_Papers[0].size.x, _ = this.m_Papers[Math.floor(o / 2)].size.x;
|
|
1837
1837
|
this.m_MinPaperWidth = Math.min(m, _);
|
|
1838
|
-
const
|
|
1839
|
-
this.m_MinPaperHeight = Math.min(
|
|
1838
|
+
const p = this.m_Papers[0].size.y, T = this.m_Papers[Math.floor(o / 2)].size.y;
|
|
1839
|
+
this.m_MinPaperHeight = Math.min(p, T), this.m_Bound = this.m_Binding.createBound(
|
|
1840
1840
|
this,
|
|
1841
1841
|
this.m_Root,
|
|
1842
1842
|
this.m_RendererFactory,
|
|
1843
1843
|
this.m_MeshFactory
|
|
1844
1844
|
), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
|
|
1845
|
-
const b = this.m_ReduceOverdraw && r.length > 0,
|
|
1846
|
-
for (let
|
|
1847
|
-
const
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
(
|
|
1845
|
+
const b = this.m_ReduceOverdraw && r.length > 0, M = this.m_ReduceSubMeshes, C = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), v = b ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), V = Math.floor(o / 2) - 1, L = V + 1, D = this.m_Bound.constructor.name.includes("Staple");
|
|
1846
|
+
for (let w = 0; w < o; w++) {
|
|
1847
|
+
const z = this.m_Papers[w];
|
|
1848
|
+
w !== 0 && (z.prev = this.m_Papers[w - 1]), w !== o - 1 && (z.next = this.m_Papers[w + 1]), z.noHole = D && (w === V || w === L), z.isCover ? z.setMeshData(O.get(), null, Z) : z.setMeshData(
|
|
1849
|
+
C.get(),
|
|
1850
|
+
(v == null ? void 0 : v.get()) ?? null,
|
|
1851
1851
|
k
|
|
1852
1852
|
);
|
|
1853
1853
|
}
|
|
@@ -1860,7 +1860,7 @@ let De = (K = class extends c.Group {
|
|
|
1860
1860
|
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);
|
|
1861
1861
|
}
|
|
1862
1862
|
createPaperMeshDataPool(t, e, s = !1, i = !1) {
|
|
1863
|
-
const r = e ? 0 : t.quality,
|
|
1863
|
+
const r = e ? 0 : t.quality, a = this.m_Bound.createPaperPattern(
|
|
1864
1864
|
r,
|
|
1865
1865
|
t.size,
|
|
1866
1866
|
t.thickness,
|
|
@@ -1868,9 +1868,9 @@ let De = (K = class extends c.Group {
|
|
|
1868
1868
|
i,
|
|
1869
1869
|
s
|
|
1870
1870
|
);
|
|
1871
|
-
return new
|
|
1871
|
+
return new be(
|
|
1872
1872
|
this.m_MeshFactory,
|
|
1873
|
-
|
|
1873
|
+
a,
|
|
1874
1874
|
e && this.m_Bound.useSharedMeshDataForLowpoly
|
|
1875
1875
|
);
|
|
1876
1876
|
}
|
|
@@ -1922,80 +1922,80 @@ let De = (K = class extends c.Group {
|
|
|
1922
1922
|
s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
|
|
1923
1923
|
}
|
|
1924
1924
|
}, K.s_Instances = /* @__PURE__ */ new Set(), K);
|
|
1925
|
-
function
|
|
1926
|
-
const s =
|
|
1927
|
-
return
|
|
1928
|
-
const
|
|
1929
|
-
s.current =
|
|
1925
|
+
function Fe(n, t, e) {
|
|
1926
|
+
const s = ht(null), [i, r] = Kt(!1);
|
|
1927
|
+
return Ct(() => {
|
|
1928
|
+
const a = new Ae(n);
|
|
1929
|
+
s.current = a;
|
|
1930
1930
|
try {
|
|
1931
|
-
|
|
1932
|
-
} catch (
|
|
1933
|
-
e == null || e(
|
|
1931
|
+
a.init(), r(!0), t == null || t(a);
|
|
1932
|
+
} catch (o) {
|
|
1933
|
+
e == null || e(o);
|
|
1934
1934
|
}
|
|
1935
1935
|
return () => {
|
|
1936
|
-
|
|
1936
|
+
a.dispose(), s.current = null, r(!1);
|
|
1937
1937
|
};
|
|
1938
|
-
}, []),
|
|
1938
|
+
}, []), Pt((a, o) => {
|
|
1939
1939
|
var h;
|
|
1940
|
-
(h = s.current) == null || h.update(
|
|
1940
|
+
(h = s.current) == null || h.update(o);
|
|
1941
1941
|
}), { bookRef: s, ready: i };
|
|
1942
1942
|
}
|
|
1943
|
-
const
|
|
1944
|
-
function
|
|
1945
|
-
return
|
|
1943
|
+
const kt = re(null);
|
|
1944
|
+
function _t() {
|
|
1945
|
+
return Jt(kt);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1948
|
-
const n =
|
|
1947
|
+
function ds() {
|
|
1948
|
+
const n = Jt(kt);
|
|
1949
1949
|
if (!n)
|
|
1950
1950
|
throw new Error("useRequiredBook() must be called inside a <Book> component.");
|
|
1951
1951
|
return n;
|
|
1952
1952
|
}
|
|
1953
|
-
const
|
|
1954
|
-
const { bookRef:
|
|
1955
|
-
return oe(r, () =>
|
|
1956
|
-
/* @__PURE__ */
|
|
1953
|
+
const _s = ae(function({ onBuilt: t, onError: e, children: s, ...i }, r) {
|
|
1954
|
+
const { bookRef: a, ready: o } = Fe(i, t, e);
|
|
1955
|
+
return oe(r, () => a.current, [o]), !o || !a.current ? null : /* @__PURE__ */ ie(kt.Provider, { value: a.current, children: [
|
|
1956
|
+
/* @__PURE__ */ ne("primitive", { object: a.current }),
|
|
1957
1957
|
s
|
|
1958
1958
|
] });
|
|
1959
1959
|
});
|
|
1960
|
-
function
|
|
1961
|
-
const { gl: s, camera: i } =
|
|
1962
|
-
|
|
1960
|
+
function He(n, { enabled: t = !0, orbitControlsRef: e } = {}) {
|
|
1961
|
+
const { gl: s, camera: i } = le(), r = ht(!1), a = ht(null), o = ht(t);
|
|
1962
|
+
o.current = t, Ct(() => {
|
|
1963
1963
|
const h = s.domElement, u = new c.Raycaster(), l = new c.Vector2(), d = (_) => {
|
|
1964
|
-
const
|
|
1964
|
+
const p = h.getBoundingClientRect();
|
|
1965
1965
|
return l.set(
|
|
1966
|
-
(_.clientX -
|
|
1967
|
-
-((_.clientY -
|
|
1966
|
+
(_.clientX - p.left) / p.width * 2 - 1,
|
|
1967
|
+
-((_.clientY - p.top) / p.height) * 2 + 1
|
|
1968
1968
|
), u.setFromCamera(l, i), u.ray;
|
|
1969
|
-
},
|
|
1970
|
-
if (!
|
|
1969
|
+
}, f = (_) => {
|
|
1970
|
+
if (!o.current || _.button !== 0) return;
|
|
1971
1971
|
r.current = !0;
|
|
1972
|
-
const
|
|
1973
|
-
|
|
1972
|
+
const p = n.current;
|
|
1973
|
+
p && p.startTurning(d(_)) && (a.current = p, e != null && e.current && (e.current.enabled = !1));
|
|
1974
1974
|
}, g = (_) => {
|
|
1975
|
-
!r.current || !
|
|
1975
|
+
!r.current || !a.current || a.current.updateTurning(d(_));
|
|
1976
1976
|
}, m = () => {
|
|
1977
|
-
r.current = !1,
|
|
1977
|
+
r.current = !1, a.current && (a.current.stopTurning(), a.current = null, e != null && e.current && (e.current.enabled = !0));
|
|
1978
1978
|
};
|
|
1979
|
-
return h.addEventListener("pointerdown",
|
|
1980
|
-
h.removeEventListener("pointerdown",
|
|
1979
|
+
return h.addEventListener("pointerdown", f), h.addEventListener("pointermove", g), h.addEventListener("pointerup", m), () => {
|
|
1980
|
+
h.removeEventListener("pointerdown", f), h.removeEventListener("pointermove", g), h.removeEventListener("pointerup", m);
|
|
1981
1981
|
};
|
|
1982
1982
|
}, [s, i, n, e]);
|
|
1983
1983
|
}
|
|
1984
|
-
function
|
|
1985
|
-
const s =
|
|
1986
|
-
return i.current = (n == null ? void 0 : n.current) ?? s,
|
|
1984
|
+
function fs({ bookRef: n, enabled: t = !0, orbitControlsRef: e }) {
|
|
1985
|
+
const s = _t(), i = ht(null);
|
|
1986
|
+
return i.current = (n == null ? void 0 : n.current) ?? s, He(i, { enabled: t, orbitControlsRef: e }), null;
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1989
|
-
const t =
|
|
1988
|
+
function gs(n) {
|
|
1989
|
+
const t = _t(), e = rt(
|
|
1990
1990
|
(r) => {
|
|
1991
|
-
var
|
|
1992
|
-
return (
|
|
1991
|
+
var a;
|
|
1992
|
+
return (a = (n == null ? void 0 : n.current) ?? t) == null ? void 0 : a.setOpenProgress(r);
|
|
1993
1993
|
},
|
|
1994
1994
|
[n, t]
|
|
1995
1995
|
), s = rt(
|
|
1996
1996
|
(r) => {
|
|
1997
|
-
var
|
|
1998
|
-
return (
|
|
1997
|
+
var a;
|
|
1998
|
+
return (a = (n == null ? void 0 : n.current) ?? t) == null ? void 0 : a.setOpenProgressByIndex(r);
|
|
1999
1999
|
},
|
|
2000
2000
|
[n, t]
|
|
2001
2001
|
), i = rt(
|
|
@@ -2007,36 +2007,36 @@ function ms(n) {
|
|
|
2007
2007
|
);
|
|
2008
2008
|
return { setOpenProgress: e, setOpenProgressByIndex: s, stopTurning: i };
|
|
2009
2009
|
}
|
|
2010
|
-
function
|
|
2011
|
-
const t =
|
|
2010
|
+
function ps(n) {
|
|
2011
|
+
const t = _t(), e = () => (n == null ? void 0 : n.current) ?? t, s = rt(
|
|
2012
2012
|
(h) => {
|
|
2013
2013
|
var u;
|
|
2014
|
-
return ((u = e()) == null ? void 0 : u.startAutoTurning(dt.Next, h ?? new
|
|
2014
|
+
return ((u = e()) == null ? void 0 : u.startAutoTurning(dt.Next, h ?? new ut(), 1)) ?? !1;
|
|
2015
2015
|
},
|
|
2016
2016
|
[n, t]
|
|
2017
2017
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
2018
2018
|
), i = rt(
|
|
2019
2019
|
(h) => {
|
|
2020
2020
|
var u;
|
|
2021
|
-
return ((u = e()) == null ? void 0 : u.startAutoTurning(dt.Back, h ?? new
|
|
2021
|
+
return ((u = e()) == null ? void 0 : u.startAutoTurning(dt.Back, h ?? new ut(), 1)) ?? !1;
|
|
2022
2022
|
},
|
|
2023
2023
|
[n, t]
|
|
2024
2024
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
2025
2025
|
), r = rt(
|
|
2026
2026
|
(h, u) => {
|
|
2027
2027
|
const l = e();
|
|
2028
|
-
return l ? l.startAutoTurning(h, u ?? new
|
|
2028
|
+
return l ? l.startAutoTurning(h, u ?? new ut(), l.paperCount) : !1;
|
|
2029
2029
|
},
|
|
2030
2030
|
[n, t]
|
|
2031
2031
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
2032
|
-
),
|
|
2033
|
-
(h, u = new
|
|
2034
|
-
var
|
|
2035
|
-
return ((
|
|
2032
|
+
), a = rt(
|
|
2033
|
+
(h, u = new ut(), l = 1, d = 0) => {
|
|
2034
|
+
var f;
|
|
2035
|
+
return ((f = e()) == null ? void 0 : f.startAutoTurning(h, u, l, d)) ?? !1;
|
|
2036
2036
|
},
|
|
2037
2037
|
[n, t]
|
|
2038
2038
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
2039
|
-
),
|
|
2039
|
+
), o = rt(
|
|
2040
2040
|
() => {
|
|
2041
2041
|
var h;
|
|
2042
2042
|
return (h = e()) == null ? void 0 : h.cancelPendingAutoTurns();
|
|
@@ -2044,9 +2044,9 @@ function ds(n) {
|
|
|
2044
2044
|
[n, t]
|
|
2045
2045
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
2046
2046
|
);
|
|
2047
|
-
return { turnNext: s, turnPrev: i, turnAll: r, startAutoTurning:
|
|
2047
|
+
return { turnNext: s, turnPrev: i, turnAll: r, startAutoTurning: a, cancelPendingAutoTurns: o };
|
|
2048
2048
|
}
|
|
2049
|
-
const
|
|
2049
|
+
const Oe = {
|
|
2050
2050
|
isBuilt: !1,
|
|
2051
2051
|
isTurning: !1,
|
|
2052
2052
|
isFalling: !1,
|
|
@@ -2057,7 +2057,7 @@ const He = {
|
|
|
2057
2057
|
coverPaperCount: 0,
|
|
2058
2058
|
pagePaperCount: 0
|
|
2059
2059
|
};
|
|
2060
|
-
function
|
|
2060
|
+
function Ze(n) {
|
|
2061
2061
|
return {
|
|
2062
2062
|
isBuilt: n.isBuilt,
|
|
2063
2063
|
isTurning: n.isTurning,
|
|
@@ -2070,54 +2070,211 @@ function Oe(n) {
|
|
|
2070
2070
|
pagePaperCount: n.pagePaperCount
|
|
2071
2071
|
};
|
|
2072
2072
|
}
|
|
2073
|
-
function
|
|
2073
|
+
function Le(n, t) {
|
|
2074
2074
|
return n.isBuilt === t.isBuilt && n.isTurning === t.isTurning && n.isFalling === t.isFalling && n.isIdle === t.isIdle && n.isAutoTurning === t.isAutoTurning && n.hasPendingAutoTurns === t.hasPendingAutoTurns && n.paperCount === t.paperCount && n.coverPaperCount === t.coverPaperCount && n.pagePaperCount === t.pagePaperCount;
|
|
2075
2075
|
}
|
|
2076
|
-
function
|
|
2077
|
-
const t =
|
|
2078
|
-
return
|
|
2076
|
+
function xs(n) {
|
|
2077
|
+
const t = _t(), [e, s] = Kt(Oe);
|
|
2078
|
+
return Pt(() => {
|
|
2079
2079
|
const i = (n == null ? void 0 : n.current) ?? t;
|
|
2080
2080
|
if (!i) return;
|
|
2081
|
-
const r =
|
|
2082
|
-
s((
|
|
2081
|
+
const r = Ze(i);
|
|
2082
|
+
s((a) => Le(a, r) ? a : r);
|
|
2083
2083
|
}), e;
|
|
2084
2084
|
}
|
|
2085
2085
|
function Ne(n) {
|
|
2086
2086
|
return [...n.covers, ...n.pages].filter((e) => e instanceof c.Texture);
|
|
2087
2087
|
}
|
|
2088
|
-
function
|
|
2089
|
-
const e =
|
|
2088
|
+
function Ms(n, t) {
|
|
2089
|
+
const e = ht([]), s = he(() => {
|
|
2090
2090
|
for (const r of e.current) r.dispose();
|
|
2091
2091
|
const i = n();
|
|
2092
2092
|
return e.current = Ne(i), i;
|
|
2093
2093
|
}, t);
|
|
2094
|
-
return
|
|
2094
|
+
return Ct(() => () => {
|
|
2095
2095
|
for (const i of e.current) i.dispose();
|
|
2096
2096
|
}, []), s;
|
|
2097
2097
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2098
|
+
class Ue {
|
|
2099
|
+
constructor(t) {
|
|
2100
|
+
this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0;
|
|
2101
|
+
}
|
|
2102
|
+
_font() {
|
|
2103
|
+
return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px ${this.fontFamily}`;
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Word-wrap `text` into lines that fit within `width` pixels.
|
|
2107
|
+
* Respects explicit newlines.
|
|
2108
|
+
*/
|
|
2109
|
+
wrapLines(t) {
|
|
2110
|
+
if (!this.text) return [];
|
|
2111
|
+
if (t.font = this._font(), this.width <= 0) return this.text.split(`
|
|
2112
|
+
`);
|
|
2113
|
+
const e = [];
|
|
2114
|
+
for (const s of this.text.split(`
|
|
2115
|
+
`)) {
|
|
2116
|
+
if (s === "") {
|
|
2117
|
+
e.push("");
|
|
2118
|
+
continue;
|
|
2119
|
+
}
|
|
2120
|
+
const i = s.split(/\s+/);
|
|
2121
|
+
let r = "";
|
|
2122
|
+
for (const a of i) {
|
|
2123
|
+
const o = r ? `${r} ${a}` : a;
|
|
2124
|
+
t.measureText(o).width > this.width && r ? (e.push(r), r = a) : r = o;
|
|
2125
|
+
}
|
|
2126
|
+
r && e.push(r);
|
|
2127
|
+
}
|
|
2128
|
+
return e;
|
|
2129
|
+
}
|
|
2130
|
+
/** Total rendered height in canvas pixels. */
|
|
2131
|
+
measureHeight(t) {
|
|
2132
|
+
return this.wrapLines(t).length * this.fontSize * this.lineHeight;
|
|
2133
|
+
}
|
|
2134
|
+
/** Returns true if the point (px, py) is within the text bounding box. */
|
|
2135
|
+
hitTest(t, e, s) {
|
|
2136
|
+
const i = this.wrapLines(t);
|
|
2137
|
+
if (i.length === 0) return !1;
|
|
2138
|
+
const r = i.length * this.fontSize * this.lineHeight, a = this.width > 0 ? this.width : this._maxLineWidth(t, i);
|
|
2139
|
+
return e >= this.x && e <= this.x + a && s >= this.y && s <= this.y + r;
|
|
2140
|
+
}
|
|
2141
|
+
_maxLineWidth(t, e) {
|
|
2142
|
+
t.font = this._font();
|
|
2143
|
+
let s = 0;
|
|
2144
|
+
for (const i of e) {
|
|
2145
|
+
const r = t.measureText(i).width;
|
|
2146
|
+
r > s && (s = r);
|
|
2147
|
+
}
|
|
2148
|
+
return s;
|
|
2149
|
+
}
|
|
2150
|
+
draw(t) {
|
|
2151
|
+
if (!this.text || this.opacity <= 0) return;
|
|
2152
|
+
const e = this.wrapLines(t);
|
|
2153
|
+
if (e.length === 0) return;
|
|
2154
|
+
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);
|
|
2155
|
+
const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
|
|
2156
|
+
for (let r = 0; r < e.length; r++) {
|
|
2157
|
+
let a = this.x;
|
|
2158
|
+
this.textAlign === "center" ? a = this.x + (i - t.measureText(e[r]).width) / 2 : this.textAlign === "right" && (a = this.x + i - t.measureText(e[r]).width), t.fillText(e[r], a, this.y + r * s);
|
|
2159
|
+
}
|
|
2160
|
+
t.restore();
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
function Ee(n) {
|
|
2164
|
+
return n.map instanceof c.Texture;
|
|
2165
|
+
}
|
|
2166
|
+
class Xe {
|
|
2167
|
+
constructor(t) {
|
|
2168
|
+
this.texts = [], this._textureST = new c.Vector4(1, 1, 0, 0);
|
|
2169
|
+
const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
|
|
2170
|
+
this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
|
|
2171
|
+
const i = this.canvas.getContext("2d");
|
|
2172
|
+
if (!i) throw new Error("TextOverlayContent: could not get 2D context");
|
|
2173
|
+
this.ctx = i, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace;
|
|
2174
|
+
}
|
|
2175
|
+
get texture() {
|
|
2176
|
+
return this._texture;
|
|
2177
|
+
}
|
|
2178
|
+
get textureST() {
|
|
2179
|
+
return this._textureST;
|
|
2180
|
+
}
|
|
2181
|
+
/** The base layer drawn beneath text blocks. */
|
|
2182
|
+
get source() {
|
|
2183
|
+
return this._source;
|
|
2184
|
+
}
|
|
2185
|
+
set source(t) {
|
|
2186
|
+
this._source = t;
|
|
2187
|
+
}
|
|
2188
|
+
// ── Text API ─────────────────────────────────────────────────────────────
|
|
2189
|
+
addText(t) {
|
|
2190
|
+
const e = new Ue(t);
|
|
2191
|
+
return this.texts.push(e), e;
|
|
2192
|
+
}
|
|
2193
|
+
removeText(t) {
|
|
2194
|
+
const e = this.texts.indexOf(t);
|
|
2195
|
+
e !== -1 && this.texts.splice(e, 1);
|
|
2196
|
+
}
|
|
2197
|
+
/** Update a text block by index. Only provided fields are changed. */
|
|
2198
|
+
updateText(t, e) {
|
|
2199
|
+
const s = this.texts[t];
|
|
2200
|
+
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));
|
|
2201
|
+
}
|
|
2202
|
+
// ── Per-frame update ─────────────────────────────────────────────────────
|
|
2203
|
+
/**
|
|
2204
|
+
* Re-composite the canvas: source layer + text blocks.
|
|
2205
|
+
* Call every frame (or when content changes).
|
|
2206
|
+
*
|
|
2207
|
+
* @param root Optional THREE.Object3D to traverse for texture sync
|
|
2208
|
+
* (same pattern as SpriteScene — needed because three-book
|
|
2209
|
+
* clones material textures).
|
|
2210
|
+
*/
|
|
2211
|
+
update(t) {
|
|
2212
|
+
const { ctx: e, canvas: s } = this, i = s.width, r = s.height;
|
|
2213
|
+
e.clearRect(0, 0, i, r), this._source && e.drawImage(this._source, 0, 0, i, r);
|
|
2214
|
+
for (const a of this.texts) a.draw(e);
|
|
2215
|
+
this._texture.needsUpdate = !0, t && this.syncMaterials(t);
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Traverse `root` and set `needsUpdate = true` on every material map whose
|
|
2219
|
+
* source image is this overlay's canvas.
|
|
2220
|
+
*/
|
|
2221
|
+
syncMaterials(t) {
|
|
2222
|
+
t.traverse((e) => {
|
|
2223
|
+
if (!e.isMesh) return;
|
|
2224
|
+
const s = e, i = Array.isArray(s.material) ? s.material : [s.material];
|
|
2225
|
+
for (const r of i)
|
|
2226
|
+
Ee(r) && r.map.image === this.canvas && (r.map.needsUpdate = !0);
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
// ── IPageContent ─────────────────────────────────────────────────────────
|
|
2230
|
+
isPointOverUI(t) {
|
|
2231
|
+
return !1;
|
|
2232
|
+
}
|
|
2233
|
+
init(t) {
|
|
2234
|
+
}
|
|
2235
|
+
setActive(t) {
|
|
2236
|
+
}
|
|
2237
|
+
dispose() {
|
|
2238
|
+
this._texture.dispose();
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
function ws(n) {
|
|
2242
|
+
const t = ht(null);
|
|
2243
|
+
t.current || (t.current = new Xe(n));
|
|
2244
|
+
const e = t.current, s = _t();
|
|
2245
|
+
return Pt(() => {
|
|
2246
|
+
e.update(s ?? void 0);
|
|
2247
|
+
}), Ct(() => () => {
|
|
2248
|
+
e.dispose();
|
|
2249
|
+
}, [e]), e;
|
|
2250
|
+
}
|
|
2251
|
+
function je(n, t, e, s, i, r, a) {
|
|
2252
|
+
const o = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
|
|
2253
|
+
if (o <= 0 || h <= 0) return;
|
|
2254
|
+
if (a === "fill") {
|
|
2102
2255
|
n.drawImage(t, e, s, i, r);
|
|
2103
2256
|
return;
|
|
2104
2257
|
}
|
|
2105
|
-
const u =
|
|
2258
|
+
const u = a === "contain" ? Math.min(i / o, r / h) : Math.max(i / o, r / h), l = o * u, d = h * u;
|
|
2106
2259
|
n.drawImage(t, e + (i - l) * 0.5, s + (r - d) * 0.5, l, d);
|
|
2107
2260
|
}
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
r.
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2261
|
+
const Gt = 256;
|
|
2262
|
+
function Cs(n, t, e, s, i, r, a) {
|
|
2263
|
+
const o = r ? Math.round(r * Gt) : 512, h = a ? Math.round(a * Gt) : 512, u = document.createElement("canvas");
|
|
2264
|
+
u.width = o, u.height = h;
|
|
2265
|
+
const l = u.getContext("2d");
|
|
2266
|
+
if (l.fillStyle = n, l.fillRect(0, 0, o, h), e) {
|
|
2267
|
+
const f = i ? 0 : Math.round(Math.min(o, h) * 0.11);
|
|
2268
|
+
je(l, e, f, f, o - f * 2, h - f * 2, s);
|
|
2269
|
+
} else {
|
|
2270
|
+
l.fillStyle = "#333";
|
|
2271
|
+
const f = Math.round(Math.min(o, h) * 0.094);
|
|
2272
|
+
l.font = `bold ${f}px Arial`, l.textAlign = "center", l.textBaseline = "middle", l.fillText(t, o / 2, h / 2);
|
|
2273
|
+
}
|
|
2274
|
+
const d = new c.CanvasTexture(u);
|
|
2275
|
+
return d.colorSpace = c.SRGBColorSpace, d;
|
|
2276
|
+
}
|
|
2277
|
+
async function ys(n) {
|
|
2121
2278
|
if (!n) return null;
|
|
2122
2279
|
const t = URL.createObjectURL(n), e = new Image();
|
|
2123
2280
|
e.decoding = "async", e.src = t;
|
|
@@ -2129,7 +2286,7 @@ async function fs(n) {
|
|
|
2129
2286
|
return URL.revokeObjectURL(t), console.error(s), null;
|
|
2130
2287
|
}
|
|
2131
2288
|
}
|
|
2132
|
-
class
|
|
2289
|
+
class Ts {
|
|
2133
2290
|
constructor() {
|
|
2134
2291
|
this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
|
|
2135
2292
|
}
|
|
@@ -2182,7 +2339,7 @@ class qt {
|
|
|
2182
2339
|
setActive(t) {
|
|
2183
2340
|
}
|
|
2184
2341
|
}
|
|
2185
|
-
class
|
|
2342
|
+
class Ps {
|
|
2186
2343
|
constructor() {
|
|
2187
2344
|
this.m_Direction = X.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
|
|
2188
2345
|
}
|
|
@@ -2221,8 +2378,8 @@ class xs {
|
|
|
2221
2378
|
let i = this.nextMultipleOf4(s);
|
|
2222
2379
|
e && (i = Math.min(i, 4));
|
|
2223
2380
|
const r = new Array(i);
|
|
2224
|
-
for (let
|
|
2225
|
-
r[
|
|
2381
|
+
for (let a = 0; a < i; a++)
|
|
2382
|
+
r[a] = this.getContent(a < s ? t[a] : null);
|
|
2226
2383
|
return r;
|
|
2227
2384
|
}
|
|
2228
2385
|
nextMultipleOf4(t) {
|
|
@@ -2283,14 +2440,14 @@ class xs {
|
|
|
2283
2440
|
return !this.isCoverPaperSideIndex(t);
|
|
2284
2441
|
}
|
|
2285
2442
|
}
|
|
2286
|
-
class
|
|
2443
|
+
class We {
|
|
2287
2444
|
}
|
|
2288
|
-
class
|
|
2445
|
+
class vs {
|
|
2289
2446
|
constructor(t, e) {
|
|
2290
2447
|
this.m_Book = t, this.m_Root = e;
|
|
2291
2448
|
}
|
|
2292
2449
|
}
|
|
2293
|
-
function
|
|
2450
|
+
function Qt(n, t, e, s) {
|
|
2294
2451
|
const i = 1 - s;
|
|
2295
2452
|
return new c.Vector3(
|
|
2296
2453
|
i * i * n.x + 2 * i * s * t.x + s * s * e.x,
|
|
@@ -2298,44 +2455,44 @@ function Gt(n, t, e, s) {
|
|
|
2298
2455
|
i * i * n.z + 2 * i * s * t.z + s * s * e.z
|
|
2299
2456
|
);
|
|
2300
2457
|
}
|
|
2301
|
-
function
|
|
2458
|
+
function $t(n, t) {
|
|
2302
2459
|
return n++, n === t ? 0 : n;
|
|
2303
2460
|
}
|
|
2304
|
-
function
|
|
2461
|
+
function Ge(n, t) {
|
|
2305
2462
|
return n === 0 ? t - 1 : n - 1;
|
|
2306
2463
|
}
|
|
2307
|
-
class
|
|
2464
|
+
class qe {
|
|
2308
2465
|
constructor() {
|
|
2309
2466
|
this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
|
|
2310
2467
|
}
|
|
2311
2468
|
}
|
|
2312
|
-
const
|
|
2469
|
+
const Qe = 0.01, $e = 0.1, Ye = 0.04, Ke = 0.4, Je = 2, ts = 10, es = 0, ss = 5;
|
|
2313
2470
|
function st(n, t, e) {
|
|
2314
2471
|
return Math.max(t, Math.min(e, n));
|
|
2315
2472
|
}
|
|
2316
|
-
function
|
|
2473
|
+
function ee(n) {
|
|
2317
2474
|
return Math.max(0, Math.min(1, n));
|
|
2318
2475
|
}
|
|
2319
2476
|
function H(n, t, e) {
|
|
2320
2477
|
return n + (t - n) * e;
|
|
2321
2478
|
}
|
|
2322
|
-
function
|
|
2323
|
-
return n === t ? 0 :
|
|
2479
|
+
function Yt(n, t, e) {
|
|
2480
|
+
return n === t ? 0 : ee((e - n) / (t - n));
|
|
2324
2481
|
}
|
|
2325
|
-
function
|
|
2482
|
+
function is(n, t) {
|
|
2326
2483
|
const e = n.clone().normalize();
|
|
2327
2484
|
if (e.lengthSq() === 0) return new c.Quaternion();
|
|
2328
2485
|
let s = new c.Vector3().crossVectors(t, e);
|
|
2329
2486
|
if (s.lengthSq() === 0) {
|
|
2330
|
-
const
|
|
2331
|
-
s = new c.Vector3().crossVectors(
|
|
2487
|
+
const a = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
|
|
2488
|
+
s = new c.Vector3().crossVectors(a, e);
|
|
2332
2489
|
}
|
|
2333
2490
|
s.normalize();
|
|
2334
2491
|
const i = new c.Vector3().crossVectors(e, s).normalize(), r = new c.Matrix4().makeBasis(s, i, e);
|
|
2335
2492
|
return new c.Quaternion().setFromRotationMatrix(r);
|
|
2336
2493
|
}
|
|
2337
2494
|
const et = Math.PI / 180, nt = 180 / Math.PI;
|
|
2338
|
-
class
|
|
2495
|
+
class ns {
|
|
2339
2496
|
constructor() {
|
|
2340
2497
|
this._material = null, this._color = new c.Color(1, 1, 1), this._thickness = 0.05, this._crown = 0.2, this._margin = 0.1, this._count = 4, this._quality = 3;
|
|
2341
2498
|
}
|
|
@@ -2355,44 +2512,44 @@ class ts {
|
|
|
2355
2512
|
return this._thickness;
|
|
2356
2513
|
}
|
|
2357
2514
|
set thickness(t) {
|
|
2358
|
-
this._thickness = st(t,
|
|
2515
|
+
this._thickness = st(t, Qe, $e);
|
|
2359
2516
|
}
|
|
2360
2517
|
get margin() {
|
|
2361
2518
|
return this._margin;
|
|
2362
2519
|
}
|
|
2363
2520
|
set margin(t) {
|
|
2364
|
-
this._margin =
|
|
2521
|
+
this._margin = ee(t);
|
|
2365
2522
|
}
|
|
2366
2523
|
get crown() {
|
|
2367
2524
|
return this._crown;
|
|
2368
2525
|
}
|
|
2369
2526
|
set crown(t) {
|
|
2370
|
-
this._crown = st(t,
|
|
2527
|
+
this._crown = st(t, Ye, Ke);
|
|
2371
2528
|
}
|
|
2372
2529
|
get count() {
|
|
2373
2530
|
return this._count;
|
|
2374
2531
|
}
|
|
2375
2532
|
set count(t) {
|
|
2376
|
-
this._count = st(t,
|
|
2533
|
+
this._count = st(t, Je, ts);
|
|
2377
2534
|
}
|
|
2378
2535
|
get quality() {
|
|
2379
2536
|
return this._quality;
|
|
2380
2537
|
}
|
|
2381
2538
|
set quality(t) {
|
|
2382
|
-
this._quality = st(t,
|
|
2539
|
+
this._quality = st(t, es, ss);
|
|
2383
2540
|
}
|
|
2384
2541
|
}
|
|
2385
|
-
class
|
|
2542
|
+
class rs extends Error {
|
|
2386
2543
|
constructor() {
|
|
2387
2544
|
super("Book height is too large relative to paper width."), this.name = "BookHeightException";
|
|
2388
2545
|
}
|
|
2389
2546
|
}
|
|
2390
|
-
class
|
|
2547
|
+
class as {
|
|
2391
2548
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
2392
2549
|
constructor(t, e, s, i, r) {
|
|
2393
2550
|
if (this.m_StapleMargin = 0, this.m_StapleThickness = 0, this.m_BindingRadius = 0, this.m_BindingMidSpace = 0, this.m_StackHeight = 0, this.m_BindingVertexCount = 0, this.useSharedMeshDataForLowpoly = !1, this._binderRendererAdapter = null, this.m_Book = s, this.m_Root = i, this.m_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
|
|
2394
|
-
throw new
|
|
2395
|
-
const
|
|
2551
|
+
throw new rs();
|
|
2552
|
+
const a = this.m_Book.coverPaperSetup, o = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
|
|
2396
2553
|
this.updateStapleMesh(e, h);
|
|
2397
2554
|
const u = r ?? new c.MeshStandardMaterial({
|
|
2398
2555
|
color: e.color,
|
|
@@ -2402,18 +2559,18 @@ class ss {
|
|
|
2402
2559
|
this.stapleMesh = new c.Mesh(h, u), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
|
|
2403
2560
|
0,
|
|
2404
2561
|
0,
|
|
2405
|
-
this.m_StapleMargin +
|
|
2562
|
+
this.m_StapleMargin + o.margin + a.margin
|
|
2406
2563
|
);
|
|
2407
|
-
let l =
|
|
2564
|
+
let l = a.thickness;
|
|
2408
2565
|
l = Math.max(this.m_BindingRadius, l);
|
|
2409
2566
|
for (const d of this.m_Book.papers) {
|
|
2410
|
-
const
|
|
2411
|
-
|
|
2567
|
+
const f = d.size.clone();
|
|
2568
|
+
f.x -= this.m_BindingRadius, d.sizeXOffset = this.m_BindingRadius, d.size = f, d.setMinTurningRadius(l), d.updateTurningRadius(), this.updatePaperPosition(d);
|
|
2412
2569
|
}
|
|
2413
2570
|
this.updateRootPosition();
|
|
2414
2571
|
}
|
|
2415
2572
|
get binderRenderer() {
|
|
2416
|
-
return this._binderRendererAdapter || (this._binderRendererAdapter = new
|
|
2573
|
+
return this._binderRendererAdapter || (this._binderRendererAdapter = new os(this.stapleMesh)), this._binderRendererAdapter;
|
|
2417
2574
|
}
|
|
2418
2575
|
// ── updateStapleMesh ──────────────────────────────────────────────────
|
|
2419
2576
|
updateStapleMesh(t, e) {
|
|
@@ -2425,87 +2582,87 @@ class ss {
|
|
|
2425
2582
|
i
|
|
2426
2583
|
);
|
|
2427
2584
|
this.m_StapleMargin = H(i, r, t.margin);
|
|
2428
|
-
const
|
|
2429
|
-
let
|
|
2430
|
-
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 &&
|
|
2431
|
-
|
|
2432
|
-
const u = t.quality / 5, l = Math.floor(H(4, 20, u)), d = Math.floor(H(4, 10, u)),
|
|
2585
|
+
const a = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
|
|
2586
|
+
let o = t.count, h = (a - s * o) / (o - 1);
|
|
2587
|
+
for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && o > 2; )
|
|
2588
|
+
o--, h = (a - s * o) / (o - 1), h = Math.max(h, 0);
|
|
2589
|
+
const u = t.quality / 5, l = Math.floor(H(4, 20, u)), d = Math.floor(H(4, 10, u)), f = Math.floor(H(3, 10, u)), g = this.m_StapleThickness / 2, m = g * 2.5, _ = 0.9, p = g * 1;
|
|
2433
2590
|
let T = s / 2 * _;
|
|
2434
|
-
T = Math.max(T,
|
|
2591
|
+
T = Math.max(T, p * 2);
|
|
2435
2592
|
let b = 0;
|
|
2436
2593
|
b += this.m_Book.totalThickness / 2, b += g;
|
|
2437
|
-
const
|
|
2594
|
+
const M = -(this.m_Book.papers[0].thickness / 2 + g), C = [];
|
|
2438
2595
|
{
|
|
2439
|
-
for (let
|
|
2440
|
-
const E =
|
|
2441
|
-
|
|
2596
|
+
for (let R = 0; R < d; R++) {
|
|
2597
|
+
const E = R / (d - 1), q = H(-90, -180, E) * et, y = new c.Vector3(
|
|
2598
|
+
p * Math.sin(q),
|
|
2442
2599
|
0,
|
|
2443
|
-
|
|
2600
|
+
p * Math.cos(q)
|
|
2444
2601
|
);
|
|
2445
|
-
y.x +=
|
|
2602
|
+
y.x += p, y.z += p, y.x += M, C.push(y);
|
|
2446
2603
|
}
|
|
2447
|
-
const
|
|
2448
|
-
for (let
|
|
2449
|
-
const E =
|
|
2450
|
-
G.x +=
|
|
2604
|
+
const x = new c.Vector3(b, 0, 0), F = new c.Vector3(b + m * 0.75, 0, 0), P = new c.Vector3(b - g * 0.5, 0, T);
|
|
2605
|
+
for (let R = 0; R < f; R++) {
|
|
2606
|
+
const E = R / (f - 1), G = Qt(x, F, P, E);
|
|
2607
|
+
G.x += M, C.push(G);
|
|
2451
2608
|
}
|
|
2452
|
-
|
|
2609
|
+
C.reverse();
|
|
2453
2610
|
}
|
|
2454
|
-
const
|
|
2455
|
-
for (let
|
|
2456
|
-
const
|
|
2457
|
-
|
|
2611
|
+
const v = new Array(l);
|
|
2612
|
+
for (let x = 0; x < l; x++) {
|
|
2613
|
+
const P = (90 - x * (360 / l)) * et;
|
|
2614
|
+
v[x] = new c.Vector3(Math.cos(P), Math.sin(P), 0), v[x].x *= 0.75;
|
|
2458
2615
|
}
|
|
2459
|
-
const k =
|
|
2616
|
+
const k = C.length, O = k * l, Z = new Array(O * 2), V = new Array(O * 2), L = new Array(
|
|
2460
2617
|
(O * 2 - 1) * l * 2 * 3
|
|
2461
2618
|
);
|
|
2462
|
-
for (let
|
|
2463
|
-
Z[
|
|
2619
|
+
for (let x = 0; x < O * 2; x++)
|
|
2620
|
+
Z[x] = new c.Vector3(), V[x] = new c.Vector3();
|
|
2464
2621
|
let D = 0;
|
|
2465
|
-
for (let
|
|
2466
|
-
const F =
|
|
2622
|
+
for (let x = 0; x < k; x++) {
|
|
2623
|
+
const F = C[Ge(x, k)], P = C[x], R = C[$t(x, k)];
|
|
2467
2624
|
let E;
|
|
2468
|
-
if (
|
|
2625
|
+
if (x === 0)
|
|
2469
2626
|
E = new c.Vector3(1, 0, -2).normalize();
|
|
2470
|
-
else if (
|
|
2627
|
+
else if (x === k - 1)
|
|
2471
2628
|
E = new c.Vector3(0, 0, 1);
|
|
2472
2629
|
else {
|
|
2473
|
-
const J =
|
|
2630
|
+
const J = P.clone().sub(F).normalize(), tt = R.clone().sub(P).normalize();
|
|
2474
2631
|
E = J.add(tt).multiplyScalar(0.5);
|
|
2475
2632
|
}
|
|
2476
|
-
const G = new c.Vector3(0, 1, 0),
|
|
2477
|
-
let B =
|
|
2633
|
+
const G = new c.Vector3(0, 1, 0), q = is(E, G), y = D;
|
|
2634
|
+
let B = Yt(0, f / 4, x);
|
|
2478
2635
|
B = H(0.1, 1, B), B = Math.sqrt(B);
|
|
2479
2636
|
for (let J = 0; J < l; J++) {
|
|
2480
|
-
const tt =
|
|
2481
|
-
Z[D] =
|
|
2482
|
-
const
|
|
2483
|
-
|
|
2484
|
-
const
|
|
2485
|
-
Z[
|
|
2637
|
+
const tt = v[J].clone().applyQuaternion(q).multiplyScalar(B), ft = P.clone().add(tt.clone().multiplyScalar(g));
|
|
2638
|
+
Z[D] = ft, V[D] = tt.clone();
|
|
2639
|
+
const lt = P.clone().add(tt.clone().multiplyScalar(g));
|
|
2640
|
+
lt.z = s - lt.z;
|
|
2641
|
+
const se = y + l - J - 1, Bt = O * 2 - se - 1;
|
|
2642
|
+
Z[Bt] = lt, V[Bt] = tt.clone(), D++;
|
|
2486
2643
|
}
|
|
2487
2644
|
}
|
|
2488
|
-
let
|
|
2489
|
-
const
|
|
2490
|
-
for (let
|
|
2491
|
-
const F =
|
|
2492
|
-
for (let
|
|
2493
|
-
const E =
|
|
2494
|
-
|
|
2645
|
+
let w = 0;
|
|
2646
|
+
const z = C.length * 2;
|
|
2647
|
+
for (let x = 0; x < z - 1; x++) {
|
|
2648
|
+
const F = x * l, P = (x + 1) * l;
|
|
2649
|
+
for (let R = 0; R < l; R++) {
|
|
2650
|
+
const E = $t(R, l), G = F + R, q = F + E, y = P + E, B = P + R;
|
|
2651
|
+
L[w++] = G, L[w++] = B, L[w++] = q, L[w++] = q, L[w++] = B, L[w++] = y;
|
|
2495
2652
|
}
|
|
2496
2653
|
}
|
|
2497
|
-
const
|
|
2498
|
-
for (let
|
|
2499
|
-
const F =
|
|
2500
|
-
for (let
|
|
2501
|
-
$[
|
|
2502
|
-
for (let
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
}
|
|
2506
|
-
const j = new Float32Array(
|
|
2507
|
-
for (let
|
|
2508
|
-
j[
|
|
2654
|
+
const N = [...Z], S = [...V], Q = [...L], W = Z.map((x) => x.clone()), $ = [...L];
|
|
2655
|
+
for (let x = 0; x < o - 1; x++) {
|
|
2656
|
+
const F = W.length;
|
|
2657
|
+
for (let P = 0; P < $.length; P++)
|
|
2658
|
+
$[P] += F;
|
|
2659
|
+
for (let P = 0; P < W.length; P++)
|
|
2660
|
+
W[P].z += h + s;
|
|
2661
|
+
N.push(...W.map((P) => P.clone())), S.push(...V.map((P) => P.clone())), Q.push(...$);
|
|
2662
|
+
}
|
|
2663
|
+
const j = new Float32Array(N.length * 3), A = new Float32Array(S.length * 3);
|
|
2664
|
+
for (let x = 0; x < N.length; x++)
|
|
2665
|
+
j[x * 3] = N[x].x, j[x * 3 + 1] = N[x].y, j[x * 3 + 2] = N[x].z, A[x * 3] = S[x].x, A[x * 3 + 1] = S[x].y, A[x * 3 + 2] = S[x].z;
|
|
2509
2666
|
e.setAttribute(
|
|
2510
2667
|
"position",
|
|
2511
2668
|
new c.BufferAttribute(j, 3)
|
|
@@ -2515,85 +2672,85 @@ class ss {
|
|
|
2515
2672
|
), e.setIndex(Q);
|
|
2516
2673
|
}
|
|
2517
2674
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2518
|
-
createPaperPattern(t, e, s, i, r,
|
|
2519
|
-
const
|
|
2520
|
-
|
|
2675
|
+
createPaperPattern(t, e, s, i, r, a) {
|
|
2676
|
+
const o = new qe();
|
|
2677
|
+
o.size = e, o.thickness = s;
|
|
2521
2678
|
const h = this.m_BindingRadius;
|
|
2522
|
-
|
|
2679
|
+
o.baseXOffset = -h;
|
|
2523
2680
|
const u = this.m_Quality + 1;
|
|
2524
2681
|
this.m_BindingVertexCount = u;
|
|
2525
|
-
const l = t / 5, d = Math.min(e.x, e.y) / 60,
|
|
2682
|
+
const l = t / 5, d = Math.min(e.x, e.y) / 60, f = Math.floor(
|
|
2526
2683
|
H(0, (e.x - h) / d, l)
|
|
2527
2684
|
), g = Math.floor(H(0, e.y / d, l));
|
|
2528
|
-
let m = 2 +
|
|
2529
|
-
const
|
|
2530
|
-
let T =
|
|
2685
|
+
let m = 2 + f + 1 + u, _ = 2 + g;
|
|
2686
|
+
const p = new it(0);
|
|
2687
|
+
let T = p;
|
|
2531
2688
|
const b = h / u;
|
|
2532
|
-
let
|
|
2689
|
+
let M = 0;
|
|
2533
2690
|
for (let y = 1; y < u + 1; y++)
|
|
2534
|
-
T = T.createNext(
|
|
2535
|
-
const
|
|
2691
|
+
T = T.createNext(M), M += b;
|
|
2692
|
+
const C = (e.x - h) / (f + 1);
|
|
2536
2693
|
for (let y = u + 1; y < m; y++)
|
|
2537
|
-
T = T.createNext(
|
|
2538
|
-
const
|
|
2539
|
-
let k =
|
|
2694
|
+
T = T.createNext(M), M += C;
|
|
2695
|
+
const v = new it(0);
|
|
2696
|
+
let k = v;
|
|
2540
2697
|
const O = e.y / (_ - 1);
|
|
2541
2698
|
let Z = 0;
|
|
2542
2699
|
for (let y = 0; y < _ - 1; y++)
|
|
2543
2700
|
Z += O, k = k.createNext(Z);
|
|
2544
|
-
const
|
|
2701
|
+
const V = [], L = [], D = i.clone();
|
|
2545
2702
|
if (r) {
|
|
2546
2703
|
let y = 0;
|
|
2547
2704
|
this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2548
2705
|
const B = Math.max(0.01, s);
|
|
2549
2706
|
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;
|
|
2550
2707
|
}
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2553
|
-
const
|
|
2554
|
-
|
|
2555
|
-
for (let y = 0; y <
|
|
2556
|
-
|
|
2708
|
+
const w = new Me(o, D, !1);
|
|
2709
|
+
w.insert(p, v, V, L), p.updateIndex(0), v.updateIndex(0), Lt(V, o.xSeams), Lt(L, o.zSeams);
|
|
2710
|
+
const z = this.m_BindingVertexCount + 2, N = new Array(z);
|
|
2711
|
+
o.xNoneSeamIndexes = N, T = p;
|
|
2712
|
+
for (let y = 0; y < z; y++) {
|
|
2713
|
+
N[y] = T.index;
|
|
2557
2714
|
do
|
|
2558
2715
|
T = T.next;
|
|
2559
2716
|
while (T.seam);
|
|
2560
2717
|
}
|
|
2561
|
-
const
|
|
2562
|
-
m =
|
|
2563
|
-
const
|
|
2564
|
-
|
|
2718
|
+
const S = p.getValues(), Q = v.getValues();
|
|
2719
|
+
m = S.length, _ = Q.length;
|
|
2720
|
+
const W = m * _, $ = [], j = new Array(W).fill(0), A = [], x = [], F = [], P = [];
|
|
2721
|
+
Te(
|
|
2565
2722
|
$,
|
|
2566
|
-
|
|
2723
|
+
S,
|
|
2567
2724
|
Q,
|
|
2568
2725
|
e,
|
|
2569
2726
|
i,
|
|
2570
2727
|
this.m_Book.direction
|
|
2571
2728
|
);
|
|
2572
|
-
const
|
|
2573
|
-
let G =
|
|
2574
|
-
G === 0 && (G = m - 1),
|
|
2729
|
+
const R = w.leftNode.index, E = w.downNode.index;
|
|
2730
|
+
let G = w.rightNode.index, q = w.upNode.index;
|
|
2731
|
+
G === 0 && (G = m - 1), q === 0 && (q = _ - 1);
|
|
2575
2732
|
for (let y = 0; y < _ - 1; y++)
|
|
2576
2733
|
for (let B = 0; B < m - 1; B++) {
|
|
2577
|
-
if (r && y >= E && y <
|
|
2734
|
+
if (r && y >= E && y < q && B >= R && B < G)
|
|
2578
2735
|
continue;
|
|
2579
|
-
const J = y * m + B, tt = y * m + (B + 1),
|
|
2580
|
-
j[J] += 2, j[tt] += 2, j[
|
|
2736
|
+
const J = y * m + B, tt = y * m + (B + 1), ft = (y + 1) * m + B, lt = (y + 1) * m + (B + 1);
|
|
2737
|
+
j[J] += 2, j[tt] += 2, j[ft] += 2, j[lt] += 2, ye(
|
|
2581
2738
|
A,
|
|
2582
|
-
|
|
2739
|
+
x,
|
|
2583
2740
|
J,
|
|
2584
2741
|
tt,
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2742
|
+
ft,
|
|
2743
|
+
lt,
|
|
2744
|
+
W
|
|
2588
2745
|
);
|
|
2589
2746
|
}
|
|
2590
|
-
if (
|
|
2591
|
-
|
|
2747
|
+
if (P.push(new St(0, 0, m - 1, _ - 1, !1, !1)), we(P, F, $, m, _), o.baseXArray = S, o.baseZArray = Q, o.baseVertexCount = W, o.vertexCount = $.length, o.texcoords = $, o.weights = j, a) {
|
|
2748
|
+
o.subMeshCount = 1;
|
|
2592
2749
|
const y = [];
|
|
2593
|
-
y.push(...A), y.push(...F), y.push(...
|
|
2750
|
+
y.push(...A), y.push(...F), y.push(...x), o.triangles = y;
|
|
2594
2751
|
} else
|
|
2595
|
-
|
|
2596
|
-
return
|
|
2752
|
+
o.subMeshCount = 3, o.frontTriangles = A, o.backTriangles = x, o.borderTriangles = F;
|
|
2753
|
+
return o.borders = P, o;
|
|
2597
2754
|
}
|
|
2598
2755
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
2599
2756
|
updateRootPosition() {
|
|
@@ -2605,39 +2762,39 @@ class ss {
|
|
|
2605
2762
|
resetPaperPosition(t) {
|
|
2606
2763
|
const e = this.m_Book.papers, s = e.length;
|
|
2607
2764
|
let i = 0;
|
|
2608
|
-
const r = e.length / 2 - 1,
|
|
2609
|
-
for (let
|
|
2610
|
-
const
|
|
2611
|
-
|
|
2612
|
-
const
|
|
2613
|
-
i +=
|
|
2614
|
-
}
|
|
2615
|
-
let
|
|
2616
|
-
const h = this.getStackZ(
|
|
2765
|
+
const r = e.length / 2 - 1, a = e.length / 2;
|
|
2766
|
+
for (let M = 0; M < s; M++) {
|
|
2767
|
+
const C = e[M];
|
|
2768
|
+
C.updateTime();
|
|
2769
|
+
const v = C.zTime, k = C.thickness;
|
|
2770
|
+
i += v * k, M === r && (i += v * this.m_BindingMidSpace / 2), M === a && (i += v * this.m_BindingMidSpace / 2);
|
|
2771
|
+
}
|
|
2772
|
+
let o = this.getStackHeight(t.index) - t.thickness / 2;
|
|
2773
|
+
const h = this.getStackZ(o), u = 180 + h;
|
|
2617
2774
|
let l = t.isFlipped ? 1 : 0, d = H(h, u, l);
|
|
2618
|
-
const
|
|
2619
|
-
Math.cos(
|
|
2620
|
-
Math.sin(
|
|
2775
|
+
const f = d * et, g = new c.Vector3(
|
|
2776
|
+
Math.cos(f) * this.m_BindingRadius,
|
|
2777
|
+
Math.sin(f) * this.m_BindingRadius,
|
|
2621
2778
|
0
|
|
2622
2779
|
);
|
|
2623
2780
|
g.z = t.margin;
|
|
2624
|
-
let m = e[Math.floor(s / 2)].size.x, _ = this.m_BindingMidSpace,
|
|
2781
|
+
let m = e[Math.floor(s / 2)].size.x, _ = this.m_BindingMidSpace, p = Math.sqrt(m * m - _ * _), T = Math.asin(p / m) * nt - 90;
|
|
2625
2782
|
if (t.index < Math.floor(s / 2)) {
|
|
2626
|
-
let
|
|
2783
|
+
let M = 0;
|
|
2627
2784
|
if (this.m_Book.alignToGround) {
|
|
2628
2785
|
m = e[0].size.x;
|
|
2629
|
-
const
|
|
2630
|
-
_ = st(i, 0,
|
|
2786
|
+
const C = this.m_StackHeight / 2;
|
|
2787
|
+
_ = st(i, 0, C) - C, p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2631
2788
|
}
|
|
2632
|
-
d = H(T, -
|
|
2789
|
+
d = H(T, -M, l);
|
|
2633
2790
|
} else {
|
|
2634
|
-
let
|
|
2791
|
+
let M = 0;
|
|
2635
2792
|
if (this.m_Book.alignToGround) {
|
|
2636
2793
|
m = e[0].size.x;
|
|
2637
|
-
const
|
|
2638
|
-
_ =
|
|
2794
|
+
const C = this.m_StackHeight / 2;
|
|
2795
|
+
_ = C - st(i, C, C * 2), p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2639
2796
|
}
|
|
2640
|
-
d = H(
|
|
2797
|
+
d = H(M, -T, l);
|
|
2641
2798
|
}
|
|
2642
2799
|
t.transform.position.copy(g), t.transform.quaternion.setFromEuler(
|
|
2643
2800
|
new c.Euler(0, 0, d * et)
|
|
@@ -2647,9 +2804,9 @@ class ss {
|
|
|
2647
2804
|
getPX(t, e) {
|
|
2648
2805
|
const s = this.m_Book.papers, i = s.length;
|
|
2649
2806
|
let r = 0;
|
|
2650
|
-
const
|
|
2807
|
+
const a = s.length / 2 - 1, o = s.length / 2;
|
|
2651
2808
|
for (let _ = 0; _ < i; _++)
|
|
2652
|
-
r += 0 * e, _ ===
|
|
2809
|
+
r += 0 * e, _ === a && (r += 0 * this.m_BindingMidSpace / 2), _ === o && (r += 0 * this.m_BindingMidSpace / 2);
|
|
2653
2810
|
const h = this.getStackHeight(t) - e / 2, u = this.getStackZ(h), l = 180 + u, g = H(u, l, 0) * et;
|
|
2654
2811
|
return new c.Vector3(
|
|
2655
2812
|
Math.cos(g) * this.m_BindingRadius,
|
|
@@ -2661,38 +2818,38 @@ class ss {
|
|
|
2661
2818
|
updatePaperPosition(t) {
|
|
2662
2819
|
const e = this.m_Book.papers, s = e.length;
|
|
2663
2820
|
let i = 0;
|
|
2664
|
-
const r = e.length / 2 - 1,
|
|
2665
|
-
for (let
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2668
|
-
const
|
|
2669
|
-
i +=
|
|
2670
|
-
}
|
|
2671
|
-
const
|
|
2821
|
+
const r = e.length / 2 - 1, a = e.length / 2;
|
|
2822
|
+
for (let M = 0; M < s; M++) {
|
|
2823
|
+
const C = e[M];
|
|
2824
|
+
C.updateTime();
|
|
2825
|
+
const v = C.zTime, k = C.thickness;
|
|
2826
|
+
i += v * k, M === r && (i += v * this.m_BindingMidSpace / 2), M === a && (i += v * this.m_BindingMidSpace / 2);
|
|
2827
|
+
}
|
|
2828
|
+
const o = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(o + i), u = 180 + this.getStackZ(o + i - this.m_StackHeight);
|
|
2672
2829
|
let l = t.zTime, d = H(h, u, l);
|
|
2673
|
-
const
|
|
2674
|
-
Math.cos(
|
|
2675
|
-
Math.sin(
|
|
2830
|
+
const f = d * et, g = new c.Vector3(
|
|
2831
|
+
Math.cos(f) * this.m_BindingRadius,
|
|
2832
|
+
Math.sin(f) * this.m_BindingRadius,
|
|
2676
2833
|
0
|
|
2677
2834
|
);
|
|
2678
2835
|
g.z = t.margin;
|
|
2679
|
-
let m = e[Math.floor(s / 2)].size.x, _ = this.m_BindingMidSpace,
|
|
2836
|
+
let m = e[Math.floor(s / 2)].size.x, _ = this.m_BindingMidSpace, p = Math.sqrt(m * m - _ * _), T = Math.asin(p / m) * nt - 90;
|
|
2680
2837
|
if (t.index < Math.floor(s / 2)) {
|
|
2681
|
-
let
|
|
2838
|
+
let M = 0;
|
|
2682
2839
|
if (this.m_Book.alignToGround) {
|
|
2683
2840
|
m = e[0].size.x;
|
|
2684
|
-
const
|
|
2685
|
-
_ = st(i, 0,
|
|
2841
|
+
const C = this.m_StackHeight / 2;
|
|
2842
|
+
_ = st(i, 0, C) - C, p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2686
2843
|
}
|
|
2687
|
-
d = H(T, -
|
|
2844
|
+
d = H(T, -M, l);
|
|
2688
2845
|
} else {
|
|
2689
|
-
let
|
|
2846
|
+
let M = 0;
|
|
2690
2847
|
if (this.m_Book.alignToGround) {
|
|
2691
2848
|
m = e[0].size.x;
|
|
2692
|
-
const
|
|
2693
|
-
_ =
|
|
2849
|
+
const C = this.m_StackHeight / 2;
|
|
2850
|
+
_ = C - st(i, C, C * 2), p = Math.sqrt(m * m - _ * _), M = (Math.asin(p / m) * nt - 90) * 2;
|
|
2694
2851
|
}
|
|
2695
|
-
d = H(
|
|
2852
|
+
d = H(M, -T, l);
|
|
2696
2853
|
}
|
|
2697
2854
|
t.transform.position.copy(g), t.transform.quaternion.setFromEuler(
|
|
2698
2855
|
new c.Euler(0, 0, d * et)
|
|
@@ -2727,41 +2884,41 @@ class ss {
|
|
|
2727
2884
|
updateBindingVertices() {
|
|
2728
2885
|
const t = this.m_Book.papers;
|
|
2729
2886
|
let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
|
|
2730
|
-
const r = this.m_StapleThickness * 0.5,
|
|
2887
|
+
const r = this.m_StapleThickness * 0.5, a = t[0].thickness, o = this.m_Root.matrixWorld.clone(), h = t.length;
|
|
2731
2888
|
for (let u = 0; u < h; u++) {
|
|
2732
|
-
const l = t[u], d = l.transform,
|
|
2889
|
+
const l = t[u], d = l.transform, f = l.meshData.pattern, g = l.meshData.baseVertices, m = f.baseXArray, _ = f.baseZArray, p = m.length, T = _.length, b = this.m_BindingVertexCount + 1, M = l.thickness, C = f.xNoneSeamIndexes, v = d.position.clone();
|
|
2733
2890
|
let k = u, O = r;
|
|
2734
2891
|
u >= Math.floor(h / 2) && (k = h - u - 1, O *= -1);
|
|
2735
|
-
const Z = (
|
|
2736
|
-
i = this.m_BindingRadius * H(0.45, 0.65, 1 -
|
|
2892
|
+
const Z = (a + M) * 0.5 + M * (k - 1), V = d.matrixWorld.clone().invert().multiply(o), L = k / (h / 2);
|
|
2893
|
+
i = this.m_BindingRadius * H(0.45, 0.65, 1 - L);
|
|
2737
2894
|
for (let D = 0; D < T; D++) {
|
|
2738
|
-
const
|
|
2739
|
-
|
|
2740
|
-
const
|
|
2895
|
+
const w = _[D], z = new c.Vector3(0, 0, v.z + w), N = v.clone();
|
|
2896
|
+
N.z += w;
|
|
2897
|
+
const S = l.getDirection(w).multiplyScalar(i).add(N.clone());
|
|
2741
2898
|
if (u === 0 && D === 0) {
|
|
2742
2899
|
const A = t[h - 1], F = A.transform.position.clone().clone();
|
|
2743
|
-
F.z +=
|
|
2744
|
-
const
|
|
2745
|
-
s =
|
|
2900
|
+
F.z += w;
|
|
2901
|
+
const P = A.getDirection(w).multiplyScalar(i).add(F);
|
|
2902
|
+
s = S.clone().sub(P).normalize(), e = new c.Vector3(
|
|
2746
2903
|
-s.y,
|
|
2747
2904
|
s.x,
|
|
2748
2905
|
0
|
|
2749
2906
|
).normalize().negate();
|
|
2750
|
-
const
|
|
2751
|
-
this.stapleMesh.rotation.set(0, 0,
|
|
2907
|
+
const R = Math.atan2(e.y, e.x) * nt;
|
|
2908
|
+
this.stapleMesh.rotation.set(0, 0, R * et);
|
|
2752
2909
|
}
|
|
2753
|
-
k > 0 &&
|
|
2754
|
-
const Q = D *
|
|
2755
|
-
g[Q] =
|
|
2756
|
-
const
|
|
2757
|
-
g[Q +
|
|
2910
|
+
k > 0 && z.add(e.clone().multiplyScalar(Z));
|
|
2911
|
+
const Q = D * p;
|
|
2912
|
+
g[Q] = z.clone().applyMatrix4(V), z.add(s.clone().multiplyScalar(O));
|
|
2913
|
+
const W = z.clone().applyMatrix4(V), $ = S.clone().applyMatrix4(V), j = N.clone().applyMatrix4(V);
|
|
2914
|
+
g[Q + C[1]] = W;
|
|
2758
2915
|
for (let A = 2; A < b; A++) {
|
|
2759
|
-
const
|
|
2760
|
-
g[Q +
|
|
2761
|
-
|
|
2916
|
+
const x = Yt(1, b, A);
|
|
2917
|
+
g[Q + C[A]] = Qt(
|
|
2918
|
+
W,
|
|
2762
2919
|
$,
|
|
2763
2920
|
j,
|
|
2764
|
-
|
|
2921
|
+
x
|
|
2765
2922
|
);
|
|
2766
2923
|
}
|
|
2767
2924
|
}
|
|
@@ -2790,7 +2947,7 @@ class ss {
|
|
|
2790
2947
|
return this.m_StapleThickness;
|
|
2791
2948
|
}
|
|
2792
2949
|
}
|
|
2793
|
-
class
|
|
2950
|
+
class os {
|
|
2794
2951
|
constructor(t) {
|
|
2795
2952
|
this.mesh = t;
|
|
2796
2953
|
}
|
|
@@ -2816,12 +2973,12 @@ class is {
|
|
|
2816
2973
|
return this.mesh;
|
|
2817
2974
|
}
|
|
2818
2975
|
}
|
|
2819
|
-
class
|
|
2976
|
+
class Ss extends We {
|
|
2820
2977
|
constructor() {
|
|
2821
|
-
super(...arguments), this.quality = 3, this.stapleSetup = new
|
|
2978
|
+
super(...arguments), this.quality = 3, this.stapleSetup = new ns();
|
|
2822
2979
|
}
|
|
2823
2980
|
createBound(t, e, s, i) {
|
|
2824
|
-
return new
|
|
2981
|
+
return new as(
|
|
2825
2982
|
this.quality,
|
|
2826
2983
|
this.stapleSetup,
|
|
2827
2984
|
t,
|
|
@@ -2832,49 +2989,53 @@ class Ps extends Ue {
|
|
|
2832
2989
|
export {
|
|
2833
2990
|
Ve as AnimationCurve,
|
|
2834
2991
|
dt as AutoTurnDirection,
|
|
2835
|
-
|
|
2836
|
-
|
|
2992
|
+
Ie as AutoTurnMode,
|
|
2993
|
+
ot as AutoTurnSetting,
|
|
2837
2994
|
Re as AutoTurnSettingCurveTimeMode,
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2995
|
+
ze as AutoTurnSettingMode,
|
|
2996
|
+
ut as AutoTurnSettings,
|
|
2997
|
+
_s as Book,
|
|
2998
|
+
We as BookBinding,
|
|
2999
|
+
vs as BookBound,
|
|
3000
|
+
Ps as BookContent,
|
|
3001
|
+
kt as BookContext,
|
|
2845
3002
|
X as BookDirection,
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
3003
|
+
us as BookHeightException,
|
|
3004
|
+
fs as BookInteraction,
|
|
3005
|
+
Be as BookRenderer,
|
|
2849
3006
|
pt as Cylinder,
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
3007
|
+
ve as MeshFactory,
|
|
3008
|
+
Gt as PX_PER_UNIT,
|
|
3009
|
+
Ts as PageContent,
|
|
3010
|
+
xe as Paper,
|
|
2853
3011
|
St as PaperBorder,
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
3012
|
+
Ot as PaperMaterialData,
|
|
3013
|
+
jt as PaperMeshData,
|
|
3014
|
+
be as PaperMeshDataPool,
|
|
2857
3015
|
it as PaperNode,
|
|
2858
3016
|
Me as PaperNodeMargin,
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
3017
|
+
qe as PaperPattern,
|
|
3018
|
+
vt as PaperSeam,
|
|
3019
|
+
ct as PaperSetup,
|
|
3020
|
+
Tt as PaperUVMargin,
|
|
2863
3021
|
Se as RendererFactory,
|
|
2864
3022
|
qt as SpritePageContent2,
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
Fe as
|
|
2879
|
-
|
|
3023
|
+
Ss as StapleBookBinding,
|
|
3024
|
+
as as StapleBookBound,
|
|
3025
|
+
ns as StapleSetup,
|
|
3026
|
+
Ue as TextBlock,
|
|
3027
|
+
Xe as TextOverlayContent,
|
|
3028
|
+
Ae as ThreeBook,
|
|
3029
|
+
Cs as createPageTexture,
|
|
3030
|
+
je as drawImageWithFit,
|
|
3031
|
+
ys as loadImage,
|
|
3032
|
+
ps as useAutoTurn,
|
|
3033
|
+
_t as useBook,
|
|
3034
|
+
Ms as useBookContent,
|
|
3035
|
+
gs as useBookControls,
|
|
3036
|
+
Fe as useBookRef,
|
|
3037
|
+
xs as useBookState,
|
|
3038
|
+
He as usePageTurning,
|
|
3039
|
+
ds as useRequiredBook,
|
|
3040
|
+
ws as useTextOverlay
|
|
2880
3041
|
};
|