@objectifthunes/three-book 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/AutoTurn.d.ts +162 -0
  2. package/dist/AutoTurn.d.ts.map +1 -0
  3. package/dist/Book.d.ts +154 -0
  4. package/dist/Book.d.ts.map +1 -0
  5. package/dist/BookBinding.d.ts +26 -0
  6. package/dist/BookBinding.d.ts.map +1 -0
  7. package/dist/BookContent.d.ts +44 -0
  8. package/dist/BookContent.d.ts.map +1 -0
  9. package/dist/BookDirection.d.ts +10 -0
  10. package/dist/BookDirection.d.ts.map +1 -0
  11. package/dist/Cylinder.d.ts +40 -0
  12. package/dist/Cylinder.d.ts.map +1 -0
  13. package/dist/PageContent.d.ts +44 -0
  14. package/dist/PageContent.d.ts.map +1 -0
  15. package/dist/Paper.d.ts +191 -0
  16. package/dist/Paper.d.ts.map +1 -0
  17. package/dist/PaperMaterialData.d.ts +29 -0
  18. package/dist/PaperMaterialData.d.ts.map +1 -0
  19. package/dist/PaperMeshData.d.ts +43 -0
  20. package/dist/PaperMeshData.d.ts.map +1 -0
  21. package/dist/PaperMeshUtility.d.ts +72 -0
  22. package/dist/PaperMeshUtility.d.ts.map +1 -0
  23. package/dist/PaperNode.d.ts +31 -0
  24. package/dist/PaperNode.d.ts.map +1 -0
  25. package/dist/PaperPattern.d.ts +30 -0
  26. package/dist/PaperPattern.d.ts.map +1 -0
  27. package/dist/PaperSetup.d.ts +52 -0
  28. package/dist/PaperSetup.d.ts.map +1 -0
  29. package/dist/PaperStructs.d.ts +43 -0
  30. package/dist/PaperStructs.d.ts.map +1 -0
  31. package/dist/PaperUVMargin.d.ts +40 -0
  32. package/dist/PaperUVMargin.d.ts.map +1 -0
  33. package/dist/Renderer.d.ts +82 -0
  34. package/dist/Renderer.d.ts.map +1 -0
  35. package/dist/StapleBinding.d.ts +132 -0
  36. package/dist/StapleBinding.d.ts.map +1 -0
  37. package/dist/index.d.ts +22 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +2692 -0
  40. package/dist/utils/BezierUtility.d.ts +8 -0
  41. package/dist/utils/BezierUtility.d.ts.map +1 -0
  42. package/dist/utils/EllipseUtility.d.ts +8 -0
  43. package/dist/utils/EllipseUtility.d.ts.map +1 -0
  44. package/dist/utils/LoopUtility.d.ts +14 -0
  45. package/dist/utils/LoopUtility.d.ts.map +1 -0
  46. package/dist/utils/MatrixUtility.d.ts +13 -0
  47. package/dist/utils/MatrixUtility.d.ts.map +1 -0
  48. package/dist/utils/TextureUtility.d.ts +17 -0
  49. package/dist/utils/TextureUtility.d.ts.map +1 -0
  50. package/dist/utils/TriangleUtility.d.ts +11 -0
  51. package/dist/utils/TriangleUtility.d.ts.map +1 -0
  52. package/dist/utils/VectorUtility.d.ts +29 -0
  53. package/dist/utils/VectorUtility.d.ts.map +1 -0
  54. package/dist/utils/index.d.ts +8 -0
  55. package/dist/utils/index.d.ts.map +1 -0
  56. package/package.json +30 -0
package/dist/index.js ADDED
@@ -0,0 +1,2692 @@
1
+ import * as c from "three";
2
+ class ut {
3
+ constructor() {
4
+ this.m_PositionX = 0, this.m_PositionZ = 0, this.m_DirectionX = 0, this.m_DirectionZ = 0, this.m_EulerY = 0, this.m_Radius = 0;
5
+ }
6
+ // ── Properties ────────────────────────────────────────────────────────
7
+ get position() {
8
+ return new c.Vector3(this.m_PositionX, 0, this.m_PositionZ);
9
+ }
10
+ set position(t) {
11
+ this.m_PositionX = t.x, this.m_PositionZ = t.z;
12
+ }
13
+ set direction(t) {
14
+ this.m_DirectionX = t.x, this.m_DirectionZ = t.z, this.m_EulerY = Math.atan2(this.m_DirectionX, this.m_DirectionZ) * (180 / Math.PI);
15
+ }
16
+ set radius(t) {
17
+ this.m_Radius = t;
18
+ }
19
+ // ── Public API ────────────────────────────────────────────────────────
20
+ rollPoint(t) {
21
+ return this.roll(t.clone()).sub(this.getOffset(t.clone()));
22
+ }
23
+ // ── Private helpers ───────────────────────────────────────────────────
24
+ /**
25
+ * Apply Quaternion.Euler(0, eulerY, z) * Vector3(x, 0, 0) manually.
26
+ *
27
+ * Unity Euler convention (ZXY intrinsic, i.e. applied Z then X then Y):
28
+ * 1. Rotate (x, 0, 0) by Z degrees around Z-axis.
29
+ * 2. Rotate by X degrees around X-axis (X = 0 here, so skip).
30
+ * 3. Rotate by Y degrees around Y-axis.
31
+ */
32
+ eulerRotateVector(t, e, s) {
33
+ const i = s * Math.PI / 180, n = e * Math.PI / 180, o = Math.cos(i), a = Math.sin(i), h = t * o, m = t * a, l = 0, _ = Math.cos(n), p = Math.sin(n), d = h * _ + l * p, u = m, f = -h * p + l * _;
34
+ return new c.Vector3(d, u, f);
35
+ }
36
+ roll(t) {
37
+ if (this.getSide(t) >= 0) return t;
38
+ const e = this.getClosestPoint(t.clone());
39
+ let s = t.distanceTo(e);
40
+ if (s > Math.PI * this.m_Radius) {
41
+ s = s - Math.PI * this.m_Radius;
42
+ const i = this.eulerRotateVector(-s, this.m_EulerY, 0);
43
+ t.copy(i.add(e)), t.y += this.m_Radius * 2;
44
+ } else {
45
+ const i = 180 / Math.PI * (s / this.m_Radius) - 90, n = this.eulerRotateVector(this.m_Radius, this.m_EulerY, i);
46
+ t.copy(n.add(e)), t.y += this.m_Radius;
47
+ }
48
+ return t;
49
+ }
50
+ getOffset(t) {
51
+ t.x = 0;
52
+ const e = this.roll(t.clone());
53
+ return e.z -= t.z, e;
54
+ }
55
+ getClosestPoint(t) {
56
+ const e = t.x - this.m_PositionX, s = t.z - this.m_PositionZ, i = e * this.m_DirectionX + s * this.m_DirectionZ;
57
+ return t.x = this.m_PositionX + this.m_DirectionX * i, t.z = this.m_PositionZ + this.m_DirectionZ * i, t;
58
+ }
59
+ getSide(t) {
60
+ const e = t.x - this.m_PositionX;
61
+ return (t.z - this.m_PositionZ) * this.m_DirectionX - e * this.m_DirectionZ;
62
+ }
63
+ // ── Value-type clone ──────────────────────────────────────────────────
64
+ clone() {
65
+ const t = new ut();
66
+ 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;
67
+ }
68
+ }
69
+ function pt(r, t, e, s, i = 1 / 0, n = 1 / 60) {
70
+ s = Math.max(s, 1e-4);
71
+ const o = 2 / s, a = o * n, h = 1 / (1 + a + 0.48 * a * a + 0.235 * a * a * a);
72
+ let m = r - t;
73
+ const l = t, _ = i * s;
74
+ m = c.MathUtils.clamp(m, -_, _), t = r - m;
75
+ const p = (e + o * m) * n;
76
+ e = (e - o * p) * h;
77
+ let d = t + (m + p) * h;
78
+ return l - r > 0 == d > l && (d = l, e = (d - l) / n), { value: d, velocity: e };
79
+ }
80
+ function te(r, t, e, s, i = 1 / 0, n = 1 / 60) {
81
+ const o = pt(
82
+ r.x,
83
+ t.x,
84
+ e.x,
85
+ s.x,
86
+ i,
87
+ n
88
+ ), a = pt(
89
+ r.y,
90
+ t.y,
91
+ e.y,
92
+ s.y,
93
+ i,
94
+ n
95
+ ), h = pt(
96
+ r.z,
97
+ t.z,
98
+ e.z,
99
+ s.z,
100
+ i,
101
+ n
102
+ );
103
+ return e.set(o.velocity, a.velocity, h.velocity), new c.Vector3(o.value, a.value, h.value);
104
+ }
105
+ function ee(r) {
106
+ return new c.Vector3(r.x, 0, r.y);
107
+ }
108
+ function se(r) {
109
+ return new c.Vector3(r.x, r.z, 0);
110
+ }
111
+ function St(r, t, e) {
112
+ const s = t * t - 4 * r * e;
113
+ if (s < 0)
114
+ return { rootCount: 0, root0: 0, root1: 0 };
115
+ if (s === 0)
116
+ return { rootCount: 1, root0: -t / 2 * r, root1: 0 };
117
+ {
118
+ const i = Math.sqrt(s);
119
+ return {
120
+ rootCount: 2,
121
+ root0: (-t + i) / (2 * r),
122
+ root1: (-t - i) / (2 * r)
123
+ };
124
+ }
125
+ }
126
+ function kt(r, t, e) {
127
+ return ie(r, t, e) ? r.clone() : ne(
128
+ new c.Vector2(r.x, t.y),
129
+ r,
130
+ t,
131
+ e
132
+ );
133
+ }
134
+ function ie(r, t, e) {
135
+ const s = r.x - t.x;
136
+ let i = r.y - t.y;
137
+ return i *= e.x / e.y, Math.sqrt(s * s + i * i) < e.x;
138
+ }
139
+ function ne(r, t, e, s) {
140
+ const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, _ = s.y, p = 1 / (l * l), d = 1 / (_ * _);
141
+ if (Math.abs(o - h) < 1e-5) {
142
+ if (o >= i - l && o <= i + l) {
143
+ const u = St(
144
+ d,
145
+ -2 * d * n,
146
+ p * (o * o - 2 * i * o + i * i) + d * n * n - 1
147
+ );
148
+ if (u.rootCount === 1)
149
+ return new c.Vector2(o, u.root0);
150
+ if (u.rootCount === 2) {
151
+ let f = u.root0, g = u.root1;
152
+ return a < m && ([f, g] = [g, f]), new c.Vector2(o, g);
153
+ }
154
+ }
155
+ } else {
156
+ const u = (m - a) / (h - o), f = a - u * o, g = f - n, w = St(
157
+ p + d * u * u,
158
+ 2 * g * u * d - 2 * i * p,
159
+ i * i * p + g * g * d - 1
160
+ );
161
+ if (w.rootCount === 1)
162
+ return new c.Vector2(w.root0, u * w.root0 + f);
163
+ if (w.rootCount === 2) {
164
+ let B = w.root0, x = w.root1;
165
+ return o < h && ([B, x] = [x, B]), new c.Vector2(x, u * x + f);
166
+ }
167
+ }
168
+ return r.clone();
169
+ }
170
+ function vt(r, t) {
171
+ const e = r.origin.clone().applyMatrix4(t), s = r.origin.clone().add(r.direction).applyMatrix4(t);
172
+ return new c.Ray(e, s.sub(e));
173
+ }
174
+ function re(r) {
175
+ return new c.Vector4(-r.x, r.y, r.z + r.x, r.w);
176
+ }
177
+ function oe(r) {
178
+ return new c.Vector4(r.x, -r.y, r.z, r.w + r.y);
179
+ }
180
+ var E = /* @__PURE__ */ ((r) => (r[r.LeftToRight = 0] = "LeftToRight", r[r.RightToLeft = 1] = "RightToLeft", r[r.UpToDown = 2] = "UpToDown", r[r.DownToUp = 3] = "DownToUp", r))(E || {});
181
+ const bt = Math.PI / 180, Bt = 180 / Math.PI, ae = 1192093e-13;
182
+ function _t(r) {
183
+ return r < 0 ? 0 : r > 1 ? 1 : r;
184
+ }
185
+ function Rt(r, t, e) {
186
+ return r < t ? t : r > e ? e : r;
187
+ }
188
+ function mt(r, t, e) {
189
+ return r !== t ? _t((e - r) / (t - r)) : 0;
190
+ }
191
+ function Vt(r, t, e) {
192
+ return r + (t - r) * e;
193
+ }
194
+ function It(r, t, e) {
195
+ return r + (t - r) * e;
196
+ }
197
+ function zt(r, t, e) {
198
+ return e = _t((e - r) / (t - r)), e * e * (3 - 2 * e);
199
+ }
200
+ class he {
201
+ // ---- Constructor ----
202
+ constructor(t, e, s, i) {
203
+ this.m_UseBackContentForSides = !1, this.m_Prev = null, this.m_Next = null, this.m_NoHole = !1, this.m_Size = new c.Vector2(), this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Margin = 0, this.m_MeshDataType = 1, this.m_Cylinder = new ut(), this.m_IsRolling = !1, this.m_IsAutoTurning = !1, this.m_WorldPlane = new c.Plane(), this.m_StartHandle = new c.Vector3(), this.m_CurrentHandle = new c.Vector3(), this.m_EndHandle = new c.Vector3(), this.m_PrevHandle = new c.Vector3(), this.m_HandleOffset = new c.Vector3(), this.m_HandleVelocity = new c.Vector3(), this.m_HandleVelocities = [], this.m_SubMeshCount = -1, this.m_MinTurningRadius = 0, this.m_TurningRadius = 0, this.m_FallDuration = 0, this.m_FallTime = 0.2, this.m_XTime = 0, this.m_ZTime = 0, this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsFallingLeft = !1, this.m_isMeshChanged = !1, this.sizeXOffset = 0, this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
204
+ }
205
+ // ---- Properties (mirrors C#) ----
206
+ get isMeshChanged() {
207
+ return this.m_isMeshChanged;
208
+ }
209
+ set isMeshChanged(t) {
210
+ this.m_isMeshChanged = t;
211
+ }
212
+ get isCover() {
213
+ return this.m_IsCover;
214
+ }
215
+ get index() {
216
+ return this.m_Index;
217
+ }
218
+ get transform() {
219
+ return this.m_Transform;
220
+ }
221
+ get renderer() {
222
+ return this.m_Renderer;
223
+ }
224
+ get meshData() {
225
+ return this.m_MeshData;
226
+ }
227
+ get size() {
228
+ return this.m_Size;
229
+ }
230
+ set size(t) {
231
+ this.m_Size.copy(t);
232
+ }
233
+ get thickness() {
234
+ return this.m_Thickness;
235
+ }
236
+ get margin() {
237
+ return this.m_Margin;
238
+ }
239
+ get zTime() {
240
+ return this.m_IsFalling || this.m_IsTurning ? this.m_Transform.scale.x === -1 ? 1 - this.m_ZTime : this.m_ZTime : this.m_Transform.scale.x === -1 ? 1 : 0;
241
+ }
242
+ get direction() {
243
+ const e = this.zTime * 180 * bt, s = Math.cos(e), i = Math.sin(e);
244
+ return new c.Vector3(-s, -i, 0);
245
+ }
246
+ get isTurning() {
247
+ return this.m_IsTurning;
248
+ }
249
+ get isFalling() {
250
+ return this.m_IsFalling;
251
+ }
252
+ get isFlipped() {
253
+ return this.m_Transform.scale.x === -1;
254
+ }
255
+ get isOnRightStack() {
256
+ return this.m_IsFalling ? this.m_Transform.scale.x === -1 ? this.m_IsFallingLeft : !this.m_IsFallingLeft : this.m_Transform.scale.x !== -1;
257
+ }
258
+ get frontContent() {
259
+ return this.m_FrontContent;
260
+ }
261
+ get backContent() {
262
+ return this.m_BackContent;
263
+ }
264
+ get currentContent() {
265
+ return this.isOnRightStack ? this.m_FrontContent : this.m_BackContent;
266
+ }
267
+ get needHole() {
268
+ if (this.m_NoHole || this.m_Prev === null || this.m_Next === null || this.m_IsTurning || this.m_IsAutoTurning || this.m_IsFalling || this.m_Prev.isCover || this.m_Next.isCover) return !1;
269
+ const t = this.m_Prev.isOnRightStack, e = this.isOnRightStack, s = this.m_Next.isOnRightStack;
270
+ return t === e && e === s;
271
+ }
272
+ set prev(t) {
273
+ this.m_Prev = t;
274
+ }
275
+ set next(t) {
276
+ this.m_Next = t;
277
+ }
278
+ set noHole(t) {
279
+ this.m_NoHole = t;
280
+ }
281
+ get isIdle() {
282
+ return !this.m_IsFalling && !this.m_IsTurning;
283
+ }
284
+ get isInMiddelOfStack() {
285
+ return this.m_Prev === null || this.m_Next === null ? !1 : this.isIdle && this.m_Prev.isIdle && this.m_Next.isIdle && this.m_Prev.isOnRightStack === this.m_Next.isOnRightStack;
286
+ }
287
+ // ---- Methods (faithful port, same order as C#) ----
288
+ setTime(t) {
289
+ this.m_XTime = t, this.m_ZTime = t;
290
+ }
291
+ setMeshData(t, e, s) {
292
+ this.m_MeshDataType = this.needHole && e != null ? 2 : 1, this.m_MeshData = this.m_MeshDataType === 2 ? e : t, this.m_LowpolyMeshData = t, this.m_LowpolyHoleMeshData = e, this.m_HighpolyMeshDataPool = s, this.m_Renderer.mesh = this.m_MeshData.geometry, this.m_Renderer.castShadows = this.m_Book.castShadows && !this.m_Book.reduceShadows, this.updateMaterials(), this.m_isMeshChanged = !0;
293
+ }
294
+ restState(t) {
295
+ this.m_IsTurning = !1, this.m_IsFalling = !1, this.m_IsAutoTurning = !1, this.m_Transform.scale.set(t ? 1 : -1, 1, 1), this.m_Book.bound.resetPaperPosition(this);
296
+ }
297
+ restMesh() {
298
+ this.switchMeshData(
299
+ this.needHole ? 2 : 1
300
+ /* Lowpoly */
301
+ ), this.updateMaterials();
302
+ }
303
+ setMaterialData(t) {
304
+ this.m_MaterialData = t;
305
+ }
306
+ setPaperSetup(t) {
307
+ this.m_Size.set(t.size.x, t.size.y), this.m_Thickness = t.thickness, this.m_Stiffness = t.stiffness, this.m_Margin = t.margin, this.m_UVMargin = t.uvMargin;
308
+ }
309
+ setContentData(t, e, s = !1) {
310
+ this.m_FrontContent = t, this.m_BackContent = e, this.m_UseBackContentForSides = s;
311
+ }
312
+ setMinTurningRadius(t) {
313
+ this.m_MinTurningRadius = t;
314
+ }
315
+ updateTurningRadius(t = 1) {
316
+ let e = Math.max(this.m_Stiffness, 1 - _t(t));
317
+ e <= 0.5 ? this.m_TurningRadius = mt(0, 0.5, e) * this.m_Size.x / Math.PI : this.m_TurningRadius = this.m_Size.x / (Math.max(180 * (1 - mt(0.5, 1, e)), 5) * bt), this.m_TurningRadius = Math.max(
318
+ this.m_TurningRadius,
319
+ this.m_MinTurningRadius
320
+ );
321
+ }
322
+ startTurning(t) {
323
+ var n, o;
324
+ const e = t.clone();
325
+ t = vt(
326
+ t,
327
+ this.m_Transform.matrixWorld.clone().invert()
328
+ ), this.m_WorldPlane.setFromNormalAndCoplanarPoint(
329
+ new c.Vector3(0, 1, 0).applyQuaternion(this.m_Transform.quaternion),
330
+ this.m_Transform.position
331
+ );
332
+ const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
333
+ if (t.intersectPlane(s, i) !== null) {
334
+ const a = i;
335
+ if (a.x > 0 && a.x < this.m_Size.x && a.z > 0 && a.z < this.m_Size.y) {
336
+ if (this.m_IsRolling = !0, this.m_IsTurning = !0, this.m_IsFalling = !1, this.m_HandleOffset.set(0, 0, 0), this.m_StartHandle.copy(a), this.m_StartHandle.x = this.m_Size.x, this.m_CurrentHandle.copy(this.m_StartHandle), a.x < this.m_Size.x * 0.9) {
337
+ this.m_HandleOffset.set(a.x - this.m_Size.x, 0, 0);
338
+ const h = this.m_Transform.scale;
339
+ h.x *= -1;
340
+ }
341
+ return this.m_HandleVelocity.set(0, 0, 0), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_HandleVelocities.length = 0, this.switchMeshData(
342
+ 0
343
+ /* Highpoly */
344
+ ), (n = this.m_Prev) == null || n.trySwitchMeshData(1), (o = this.m_Next) == null || o.trySwitchMeshData(1), this.updateTurning(e), this.clampHandle(), this.updateCylinder(), !0;
345
+ }
346
+ }
347
+ return !1;
348
+ }
349
+ stopTurning() {
350
+ this.clampHandle(), this.m_IsTurning = !1, this.m_IsFalling = !0;
351
+ const t = new c.Vector3(0, 0, 0);
352
+ for (const e of this.m_HandleVelocities)
353
+ t.add(e);
354
+ 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 = Vt(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);
355
+ }
356
+ /**
357
+ * Called each frame while the user is dragging.
358
+ * `dt` replaces Time.deltaTime.
359
+ */
360
+ updateTurning(t, e = 1 / 60) {
361
+ const s = new c.Vector3();
362
+ if (t.intersectPlane(this.m_WorldPlane, s) !== null) {
363
+ const i = s;
364
+ this.m_Book.bound.resetPaperPosition(this), this.m_CurrentHandle.copy(
365
+ this.m_Transform.worldToLocal(i.clone())
366
+ ), this.m_CurrentHandle.y = 0, this.m_CurrentHandle.add(this.m_HandleOffset), this.m_HandleVelocity.copy(this.m_CurrentHandle).sub(this.m_PrevHandle).divideScalar(e), this.m_HandleVelocities.length === 5 && this.m_HandleVelocities.shift(), this.m_HandleVelocities.push(this.m_HandleVelocity.clone()), this.m_PrevHandle.copy(this.m_CurrentHandle);
367
+ }
368
+ this.updateBaseVertices();
369
+ }
370
+ /**
371
+ * Called each frame while the page is falling back into place.
372
+ * `dt` replaces Time.deltaTime.
373
+ */
374
+ updateFalling(t = 1 / 60) {
375
+ var s, i;
376
+ let e = !1;
377
+ if (this.m_IsAutoTurning) {
378
+ let n = _t(this.m_FallTime / this.m_FallDuration);
379
+ n = zt(0, 1, n), n = zt(0, 1, n), this.m_CurrentHandle.lerpVectors(
380
+ this.m_StartHandle,
381
+ this.m_EndHandle,
382
+ this.m_IsFallingLeft ? n : 1 - n
383
+ ), this.m_FallTime += t, e = Math.abs(n - 1) < ae;
384
+ } else {
385
+ const n = new c.Vector3(
386
+ this.m_FallTime,
387
+ 0,
388
+ this.m_FallTime * 0.75
389
+ );
390
+ this.m_CurrentHandle = te(
391
+ this.m_CurrentHandle,
392
+ this.m_EndHandle,
393
+ this.m_HandleVelocity,
394
+ n,
395
+ 1 / 0,
396
+ t
397
+ ), e = Math.abs(this.m_EndHandle.x - this.m_CurrentHandle.x) < 1e-4;
398
+ }
399
+ if (e) {
400
+ if (this.m_IsFallingLeft) {
401
+ const n = this.m_Transform.scale;
402
+ n.x *= -1, this.m_IsRolling = !1, this.m_IsFallingLeft = !1, this.m_IsFalling = !1, this.switchMeshData(
403
+ 1
404
+ /* Lowpoly */
405
+ ), this.m_ZTime = this.m_Transform.scale.x === -1 ? 1 : 0, this.m_Book.bound.updatePaperPosition(this), this.updateMaterials();
406
+ } else
407
+ this.m_ZTime = this.m_Transform.scale.x === -1 ? 1 : 0, this.m_IsRolling = !1, this.m_IsFallingLeft = !1, this.m_IsFalling = !1, this.switchMeshData(
408
+ 1
409
+ /* Lowpoly */
410
+ ), this.updateMaterials();
411
+ this.isOnRightStack ? (s = this.m_Next) == null || s.trySwitchMeshData(2) : (i = this.m_Prev) == null || i.trySwitchMeshData(2), this.m_IsAutoTurning && this.updateTurningRadius(), this.m_IsAutoTurning = !1;
412
+ return;
413
+ }
414
+ this.updateBaseVertices();
415
+ }
416
+ getTextureCoordinate(t) {
417
+ const e = this.raycastLocal(t, !0);
418
+ return e !== null ? this.hit2UV(e) : new c.Vector2(0, 0);
419
+ }
420
+ raycast(t) {
421
+ const e = {
422
+ point: new c.Vector3(),
423
+ textureCoordinate: new c.Vector2(),
424
+ pageContent: null,
425
+ paperIndex: 0,
426
+ pageIndex: 0
427
+ };
428
+ if (!this.isFalling && !this.isTurning) {
429
+ const s = this.raycastLocal(t);
430
+ if (s !== null)
431
+ return e.pageContent = this.isOnRightStack ? this.m_FrontContent : this.m_BackContent, e.point = this.m_Transform.localToWorld(s.clone()), e.textureCoordinate = this.hit2UV(s), e.paperIndex = this.index, { hit: !0, hitInfo: e };
432
+ }
433
+ return { hit: !1, hitInfo: e };
434
+ }
435
+ hit2UV(t) {
436
+ const e = new c.Vector2(
437
+ mt(-this.sizeXOffset, this.m_Size.x, t.x),
438
+ t.z / this.m_Size.y
439
+ );
440
+ this.m_UVMargin.fixUV(e);
441
+ const s = this.m_Book.direction;
442
+ if (s === E.UpToDown || s === E.DownToUp) {
443
+ const i = e.x;
444
+ e.x = e.y, e.y = i, this.isOnRightStack && (e.y = 1 - e.y);
445
+ } else
446
+ this.isOnRightStack || (e.x = 1 - e.x);
447
+ return e;
448
+ }
449
+ /**
450
+ * Internal raycast against the paper plane in local space.
451
+ * Returns the local-space hit point, or null if no hit / out of bounds.
452
+ */
453
+ raycastLocal(t, e = !1) {
454
+ t = vt(
455
+ t,
456
+ this.m_Transform.matrixWorld.clone().invert()
457
+ );
458
+ const s = new c.Plane(new c.Vector3(0, 1, 0), 0), i = new c.Vector3();
459
+ if (t.intersectPlane(s, i) !== null) {
460
+ const n = i;
461
+ if (n.x > 0 && n.x < this.m_Size.x && n.z > 0 && n.z < this.m_Size.y || e)
462
+ return n;
463
+ }
464
+ return null;
465
+ }
466
+ trySwitchMeshData(t) {
467
+ this.m_IsFalling || this.m_IsTurning || (this.switchMeshData(t), this.updateMaterials());
468
+ }
469
+ switchMeshData(t) {
470
+ if (t === 2 && (this.m_LowpolyHoleMeshData == null || this.m_NoHole) && (t = 1), this.m_MeshDataType === t) return;
471
+ this.m_MeshDataType === 0 && this.m_HighpolyMeshDataPool.free(this.m_MeshData);
472
+ let e = this.m_Book.castShadows;
473
+ switch (this.m_Book.reduceShadows && t !== 0 && (e = !1), this.m_Renderer.castShadows = e, this.m_MeshDataType = t, t) {
474
+ case 0:
475
+ this.m_MeshData = this.m_HighpolyMeshDataPool.get();
476
+ break;
477
+ case 1:
478
+ this.m_MeshData = this.m_LowpolyMeshData;
479
+ break;
480
+ case 2:
481
+ this.m_MeshData = this.m_LowpolyHoleMeshData;
482
+ break;
483
+ }
484
+ this.m_Renderer.mesh = this.m_MeshData.geometry, this.m_isMeshChanged = !0;
485
+ }
486
+ updateMaterials() {
487
+ const t = this.m_MeshData.pattern.subMeshCount;
488
+ this.m_SubMeshCount !== t && (this.m_Renderer.setMaterials(
489
+ t === 1 ? this.m_MaterialData.materials1 : this.m_MaterialData.materials3
490
+ ), this.m_SubMeshCount = t);
491
+ const e = this.m_FrontContent.textureST.clone();
492
+ let s = this.m_BackContent.textureST.clone();
493
+ this.m_Book.direction > 1 ? s = oe(s) : s = re(s);
494
+ const i = this.m_FrontContent.texture, n = this.m_BackContent.texture;
495
+ if (t === 3) {
496
+ let o = 0, a = 1;
497
+ this.m_Transform.scale.x === -1 && (o = 1, a = 0), this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
498
+ this.m_MaterialData.propertyBlock,
499
+ o
500
+ ), this.m_UseBackContentForSides || this.m_Renderer.setPropertyBlock(
501
+ this.m_MaterialData.propertyBlock,
502
+ 2
503
+ ), this.m_MaterialData.updatePropertyBlock(n, s), this.m_Renderer.setPropertyBlock(
504
+ this.m_MaterialData.propertyBlock,
505
+ a
506
+ ), this.m_UseBackContentForSides && this.m_Renderer.setPropertyBlock(
507
+ this.m_MaterialData.propertyBlock,
508
+ 2
509
+ );
510
+ } else
511
+ this.m_Transform.scale.x === -1 ? this.m_MaterialData.updatePropertyBlock(n, s) : this.m_MaterialData.updatePropertyBlock(i, e), this.m_Renderer.setPropertyBlock(
512
+ this.m_MaterialData.propertyBlock,
513
+ 0
514
+ );
515
+ }
516
+ updateBaseVertices() {
517
+ if (this.clampHandle(), this.updateCylinder(), this.updateTime(), !this.m_IsRolling) return;
518
+ this.m_MeshData.updateBaseVertices();
519
+ const t = this.m_MeshData.baseVertices, e = this.m_Cylinder, s = t.length;
520
+ for (let i = 0; i < s; i++)
521
+ t[i] = e.rollPoint(t[i]);
522
+ }
523
+ updateMesh() {
524
+ this.updateMaterials(), this.m_MeshData.updateMesh(), this.m_isMeshChanged = !0;
525
+ }
526
+ getDirection(t) {
527
+ let e = new c.Vector3(0, 0, t), s = new c.Vector3(0.1, 0, t);
528
+ return e = this.rollPoint(e), s = this.rollPoint(s), e = this.m_Transform.localToWorld(e), s = this.m_Transform.localToWorld(s), this.m_Transform.parent && (e = this.m_Transform.parent.worldToLocal(e), s = this.m_Transform.parent.worldToLocal(s)), e.sub(s).normalize();
529
+ }
530
+ updateTime() {
531
+ if (this.isTurning || this.isFalling) {
532
+ const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
533
+ new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
534
+ );
535
+ this.m_XTime = Vt(
536
+ Math.min(t, e),
537
+ Math.max(t, e),
538
+ 0.9
539
+ );
540
+ const s = this.m_MeshData.pattern.baseXArray, i = this.m_MeshData.pattern.baseZArray, n = this.rollPoint(new c.Vector3(s[1], 0, 0)), o = this.rollPoint(new c.Vector3(s[2], 0, 0)), a = this.rollPoint(
541
+ new c.Vector3(s[1], 0, i[i.length - 1])
542
+ ), h = this.rollPoint(
543
+ new c.Vector3(s[2], 0, i[i.length - 1])
544
+ ), m = o.clone().sub(n).normalize(), l = h.clone().sub(a).normalize(), _ = Bt * Math.atan2(m.y, m.x), p = Bt * Math.atan2(l.y, l.x), d = (_ + p) / 2;
545
+ this.m_ZTime = d / 180;
546
+ } else
547
+ this.m_XTime = 0, this.m_ZTime = 0;
548
+ }
549
+ findTime(t) {
550
+ return t = this.rollPoint(t), mt(this.m_Size.x, -this.m_Size.x, t.x);
551
+ }
552
+ clampHandle() {
553
+ this.m_StartHandle.y = 0, this.m_CurrentHandle.y = 0;
554
+ const t = this.m_CurrentHandle.clone(), e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, this.m_Size.y), i = e.distanceTo(this.m_StartHandle), n = s.distanceTo(this.m_StartHandle), o = Math.max(i - this.m_TurningRadius, 0.01), a = Math.max(n - this.m_TurningRadius, 0.01), h = this.m_StartHandle.z, m = new c.Vector2(
555
+ 0,
556
+ h + (e.z - h) * (o / i)
557
+ ), l = new c.Vector2(
558
+ 0,
559
+ h + (s.z - h) * (a / n)
560
+ ), _ = new c.Vector2(i, o), p = new c.Vector2(n, a);
561
+ t.x = Rt(t.x, -this.m_Size.x, this.m_Size.x);
562
+ const d = se(t), u = kt(
563
+ new c.Vector2(d.x, d.y),
564
+ m,
565
+ _
566
+ ), f = kt(
567
+ new c.Vector2(u.x, u.y),
568
+ l,
569
+ p
570
+ ), g = ee(
571
+ new c.Vector3(f.x, f.y, 0)
572
+ );
573
+ this.m_CurrentHandle.copy(g);
574
+ }
575
+ updateCylinder() {
576
+ const t = this.m_StartHandle.clone(), e = this.m_CurrentHandle.clone(), s = t.clone().sub(e).normalize();
577
+ s.length() === 0 && s.set(1, 0, 0);
578
+ const i = t.clone().sub(
579
+ s.clone().multiplyScalar(
580
+ this.m_Size.x * 2 + this.m_TurningRadius * Math.PI
581
+ )
582
+ ), n = t.clone(), o = new ut();
583
+ o.radius = this.m_TurningRadius, o.direction = new c.Vector3(
584
+ -s.z,
585
+ 0,
586
+ s.x
587
+ );
588
+ for (let a = 0; a < 100; a++) {
589
+ o.position = i.clone().add(n).multiplyScalar(0.5), this.m_Cylinder = o, this.m_Book.bound.updatePaperPosition(this);
590
+ const h = o.rollPoint(t.clone());
591
+ if (Math.abs(e.x - h.x) < 1e-4) break;
592
+ h.x > e.x ? n.copy(o.position) : i.copy(o.position);
593
+ }
594
+ }
595
+ rollPoint(t) {
596
+ return this.m_IsRolling ? this.m_Cylinder.rollPoint(t) : t;
597
+ }
598
+ drawWireframe(t) {
599
+ }
600
+ startAutoTurning(t, e, s, i) {
601
+ var m, l;
602
+ if (this.updateTurningRadius(s), this.m_PrevHandle.copy(this.m_CurrentHandle), this.m_IsRolling = !0, this.m_HandleOffset.set(0, 0, 0), t === 0) {
603
+ const _ = this.m_Transform.scale;
604
+ _.x *= -1;
605
+ }
606
+ this.switchMeshData(
607
+ 0
608
+ /* Highpoly */
609
+ ), (m = this.m_Prev) == null || m.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === 1, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
610
+ const n = this.m_Size.x, o = this.m_Size.y;
611
+ e = Rt(e, -0.99, 0.99);
612
+ const a = It(0.5, 1, e), h = It(0.5, 0, e);
613
+ this.m_StartHandle.set(n, 0, o * a), this.m_EndHandle.set(-n, 0, o * h), this.m_IsAutoTurning = !0;
614
+ }
615
+ // ---- Public getter for the cylinder (used by BookBound etc.) ----
616
+ get cylinder() {
617
+ return this.m_Cylinder;
618
+ }
619
+ }
620
+ const Y = class Y {
621
+ constructor() {
622
+ this.m_Left = 0, this.m_Right = 0, this.m_Down = 0, this.m_Up = 0;
623
+ }
624
+ // ── Properties ────────────────────────────────────────────────────────
625
+ get left() {
626
+ return this.m_Left;
627
+ }
628
+ set left(t) {
629
+ this.m_Left = this.clamp(t);
630
+ }
631
+ get right() {
632
+ return this.m_Right;
633
+ }
634
+ set right(t) {
635
+ this.m_Right = this.clamp(t);
636
+ }
637
+ get down() {
638
+ return this.m_Down;
639
+ }
640
+ set down(t) {
641
+ this.m_Down = this.clamp(t);
642
+ }
643
+ get up() {
644
+ return this.m_Up;
645
+ }
646
+ set up(t) {
647
+ this.m_Up = this.clamp(t);
648
+ }
649
+ // ── Helpers ───────────────────────────────────────────────────────────
650
+ clamp(t) {
651
+ return Math.max(Y.kMin, Math.min(t, Y.kMax));
652
+ }
653
+ // ── Transform ─────────────────────────────────────────────────────────
654
+ /**
655
+ * Returns a new PaperUVMargin with margins remapped according to the
656
+ * book direction.
657
+ */
658
+ transform(t) {
659
+ const e = new Y();
660
+ switch (t) {
661
+ case E.LeftToRight:
662
+ e.m_Left = this.m_Left, e.m_Right = this.m_Right, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
663
+ break;
664
+ case E.RightToLeft:
665
+ e.m_Left = this.m_Right, e.m_Right = this.m_Left, e.m_Down = this.m_Down, e.m_Up = this.m_Up;
666
+ break;
667
+ case E.UpToDown:
668
+ e.m_Left = this.m_Up, e.m_Right = this.m_Down, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
669
+ break;
670
+ case E.DownToUp:
671
+ default:
672
+ e.m_Left = this.m_Down, e.m_Right = this.m_Up, e.m_Down = this.m_Left, e.m_Up = this.m_Right;
673
+ break;
674
+ }
675
+ return e;
676
+ }
677
+ // ── FixUV ─────────────────────────────────────────────────────────────
678
+ /**
679
+ * Remap a UV coordinate so that (0,0) and (1,1) correspond to the
680
+ * content area inside the margins.
681
+ *
682
+ * Unity's `Mathf.InverseLerp(a, b, v)` = `(v - a) / (b - a)` clamped to [0,1].
683
+ */
684
+ fixUV(t) {
685
+ return t.x = Y.inverseLerp(this.m_Left, 1 - this.m_Right, t.x), t.y = Y.inverseLerp(this.m_Down, 1 - this.m_Up, t.y), t;
686
+ }
687
+ static inverseLerp(t, e, s) {
688
+ if (t === e) return 0;
689
+ const i = (s - t) / (e - t);
690
+ return Math.max(0, Math.min(1, i));
691
+ }
692
+ // ── Value-type clone ──────────────────────────────────────────────────
693
+ clone() {
694
+ const t = new Y();
695
+ return t.m_Left = this.m_Left, t.m_Right = this.m_Right, t.m_Down = this.m_Down, t.m_Up = this.m_Up, t;
696
+ }
697
+ };
698
+ Y.kMin = 0, Y.kMax = 0.25;
699
+ let gt = Y;
700
+ const L = class L {
701
+ constructor(t) {
702
+ this.m_Material = null, this.m_Color = new c.Color(1, 1, 1), this.m_Width = 0, this.m_Height = 0, this.m_Thickness = 0, this.m_Stiffness = 0, this.m_Quality = 0, this.m_UVMargin = new gt(), this.margin = 0, this.bookDirection = E.LeftToRight, this.color = (t == null ? void 0 : t.color) ?? new c.Color(1, 1, 1), this.width = (t == null ? void 0 : t.width) ?? L.kMinSize * 2, this.height = (t == null ? void 0 : t.height) ?? L.kMinSize * 2, this.thickness = (t == null ? void 0 : t.thickness) ?? L.kMinThickness * 2, this.stiffness = (t == null ? void 0 : t.stiffness) ?? 0.1, this.quality = (t == null ? void 0 : t.quality) ?? 3, (t == null ? void 0 : t.material) !== void 0 && (this.m_Material = t.material);
703
+ }
704
+ // ── Properties ────────────────────────────────────────────────────────
705
+ get material() {
706
+ return this.m_Material;
707
+ }
708
+ set material(t) {
709
+ this.m_Material = t;
710
+ }
711
+ get color() {
712
+ return this.m_Color;
713
+ }
714
+ set color(t) {
715
+ this.m_Color = t;
716
+ }
717
+ get width() {
718
+ return this.bookDirection > 1 ? this.m_Height : this.m_Width;
719
+ }
720
+ set width(t) {
721
+ this.m_Width = Math.max(t, L.kMinSize);
722
+ }
723
+ get height() {
724
+ return this.bookDirection > 1 ? this.m_Width : this.m_Height;
725
+ }
726
+ set height(t) {
727
+ this.m_Height = Math.max(t, L.kMinSize);
728
+ }
729
+ get thickness() {
730
+ return this.m_Thickness;
731
+ }
732
+ set thickness(t) {
733
+ this.m_Thickness = Math.max(t, L.kMinThickness);
734
+ }
735
+ get stiffness() {
736
+ return this.m_Stiffness;
737
+ }
738
+ set stiffness(t) {
739
+ this.m_Stiffness = Math.max(0, Math.min(1, t));
740
+ }
741
+ get quality() {
742
+ return this.m_Quality;
743
+ }
744
+ set quality(t) {
745
+ this.m_Quality = Math.max(
746
+ L.kMinQuality,
747
+ Math.min(t, L.kMaxQuality)
748
+ );
749
+ }
750
+ get uvMargin() {
751
+ return this.m_UVMargin.transform(this.bookDirection);
752
+ }
753
+ set uvMargin(t) {
754
+ this.m_UVMargin = t;
755
+ }
756
+ get size() {
757
+ return new c.Vector2(this.width, this.height);
758
+ }
759
+ };
760
+ L.kMinSize = 1, L.kMinThickness = 1e-4, L.kMinQuality = 1, L.kMaxQuality = 5;
761
+ let ht = L;
762
+ class Dt {
763
+ constructor(t) {
764
+ this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
765
+ const e = t.material ?? new c.MeshStandardMaterial();
766
+ this.m_Materials1 = [e.clone()], this.m_Materials3 = [e.clone(), e.clone(), e.clone()], this.m_Color = t.color.clone();
767
+ }
768
+ get materials1() {
769
+ return this.m_Materials1;
770
+ }
771
+ get materials3() {
772
+ return this.m_Materials3;
773
+ }
774
+ get color() {
775
+ return this.m_Color;
776
+ }
777
+ get texture() {
778
+ return this.m_Texture;
779
+ }
780
+ get textureST() {
781
+ return this.m_TextureST;
782
+ }
783
+ /**
784
+ * Mirrors Unity's MaterialPropertyBlock: stores color, texture, and textureST.
785
+ * Paper.ts reads this after calling updatePropertyBlock.
786
+ */
787
+ get propertyBlock() {
788
+ return {
789
+ color: this.m_Color.clone(),
790
+ map: this.m_Texture,
791
+ textureST: this.m_TextureST.clone()
792
+ };
793
+ }
794
+ updatePropertyBlock(t, e) {
795
+ this.m_Texture = t, this.m_TextureST.copy(e);
796
+ }
797
+ }
798
+ function At(r, t, e, s = new c.Vector3()) {
799
+ let i = t.x - r.x, n = t.y - r.y, o = t.z - r.z, a = 1 / Math.sqrt(i * i + n * n + o * o);
800
+ i *= a, n *= a, o *= a;
801
+ let h = e.x - r.x, m = e.y - r.y, l = e.z - r.z;
802
+ a = 1 / Math.sqrt(h * h + m * m + l * l), h *= a, m *= a, l *= a;
803
+ const _ = n * l - o * m, p = o * h - i * l, d = i * m - n * h;
804
+ return a = 1 / Math.sqrt(_ * _ + p * p + d * d), s.set(_ * a, p * a, d * a);
805
+ }
806
+ class st {
807
+ constructor(t, e = !1, s = !1) {
808
+ this.prev = null, this.next = null, this.index = 0, this.value = t, this.hole = e, this.seam = s;
809
+ }
810
+ // ── Navigation properties ─────────────────────────────────────────────
811
+ get prevNoneSeam() {
812
+ return this.prev.seam ? this.prev.prevNoneSeam : this.prev;
813
+ }
814
+ get nextNoneSeam() {
815
+ return this.next.seam ? this.next.nextNoneSeam : this.next;
816
+ }
817
+ get prevNoneHole() {
818
+ return this.prev.hole ? this.prev.prevNoneHole : this.prev;
819
+ }
820
+ get nextNoneHole() {
821
+ return this.next.hole ? this.next.nextNoneHole : this.next;
822
+ }
823
+ // ── Factory helpers ───────────────────────────────────────────────────
824
+ createNext(t, e = !1, s = !1) {
825
+ const i = new st(t, e, s);
826
+ return i.prev = this, this.next = i, i;
827
+ }
828
+ // C# had a double overload — in TS numbers are already IEEE 754 doubles.
829
+ // Keeping a separate method for parity; it simply casts to number.
830
+ createNextFromDouble(t, e = !1, s = !1) {
831
+ const i = new st(t, e, s);
832
+ return i.prev = this, this.next = i, i;
833
+ }
834
+ // ── Insertion (sorted linked-list insert) ─────────────────────────────
835
+ insert(t) {
836
+ return this.value >= t.value || this.next === null ? !1 : this.next.value > t.value ? Math.abs(this.value - t.value) < 1e-4 || Math.abs(this.next.value - t.value) < 1e-4 ? !1 : (this.next.prev = t, t.next = this.next, t.prev = this, this.next = t, t.hole = this.hole, !0) : this.next.insert(t);
837
+ }
838
+ // ── Index assignment (recursive) ──────────────────────────────────────
839
+ updateIndex(t) {
840
+ this.index = t, this.next !== null && this.next.updateIndex(t + 1);
841
+ }
842
+ getValues(t) {
843
+ if (t === void 0) {
844
+ const e = [];
845
+ return this._getValuesRecursive(e), e;
846
+ }
847
+ this._getValuesRecursive(t);
848
+ }
849
+ _getValuesRecursive(t) {
850
+ t.push(this.value), this.next !== null && this.next._getValuesRecursive(t);
851
+ }
852
+ getHoles(t) {
853
+ if (t === void 0) {
854
+ const e = [];
855
+ return this._getHolesRecursive(e), e;
856
+ }
857
+ this._getHolesRecursive(t);
858
+ }
859
+ _getHolesRecursive(t) {
860
+ t.push(this.hole), this.next !== null && this.next._getHolesRecursive(t);
861
+ }
862
+ }
863
+ class Pt {
864
+ constructor(t, e, s, i) {
865
+ this.active = !0, this.prevIndex = t, this.index = e, this.nextIndex = s, this.time = i;
866
+ }
867
+ clone() {
868
+ const t = new Pt(this.prevIndex, this.index, this.nextIndex, this.time);
869
+ return t.active = this.active, t;
870
+ }
871
+ }
872
+ class wt {
873
+ constructor(t, e, s, i, n, o = !0) {
874
+ this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = o;
875
+ }
876
+ clone() {
877
+ return new wt(
878
+ this.startX,
879
+ this.startZ,
880
+ this.endX,
881
+ this.endZ,
882
+ this.flip,
883
+ this.left
884
+ );
885
+ }
886
+ }
887
+ class le {
888
+ constructor(t, e, s) {
889
+ const i = t.size;
890
+ this.leftNode = new st(e.left * i.x, s, !0), this.rightNode = new st((1 - e.right) * i.x, s, !0), this.downNode = new st(e.down * i.y, s, !0), this.upNode = new st((1 - e.up) * i.y, s, !0);
891
+ }
892
+ insert(t, e, s, i) {
893
+ t.insert(this.leftNode) && s.push(this.leftNode), t.insert(this.rightNode) && s.push(this.rightNode), e.insert(this.downNode) && i.push(this.downNode), e.insert(this.upNode) && i.push(this.upNode);
894
+ }
895
+ }
896
+ function lt(r, t, e) {
897
+ if (r === t) return 0;
898
+ const s = (e - r) / (t - r);
899
+ return Math.max(0, Math.min(1, s));
900
+ }
901
+ function Mt(r, t) {
902
+ for (const e of r) {
903
+ const s = e.prevNoneSeam, i = e.nextNoneSeam, n = lt(s.value, i.value, e.value), o = new Pt(s.index, e.index, i.index, n);
904
+ t.push(o);
905
+ }
906
+ }
907
+ function xt(r, t, e, s, i) {
908
+ for (const n of r) {
909
+ if (!n.active) return;
910
+ for (let o = 0; o < s; o++) {
911
+ const a = n.prevIndex, h = n.nextIndex, m = t[o * e + a], l = t[o * e + h], _ = t[o * e + n.index];
912
+ i ? Gt(m, l, n.time, _) : _.copy(m).lerp(l, n.time);
913
+ }
914
+ }
915
+ }
916
+ function Ct(r, t, e, s, i) {
917
+ for (const n of r) {
918
+ if (!n.active) return;
919
+ for (let o = 0; o < e; o++) {
920
+ const a = n.prevIndex, h = n.nextIndex, m = t[a * e + o], l = t[h * e + o], _ = t[n.index * e + o];
921
+ i ? Gt(m, l, n.time, _) : _.copy(m).lerp(l, n.time);
922
+ }
923
+ }
924
+ }
925
+ function Gt(r, t, e, s = new c.Vector3()) {
926
+ const i = Math.sqrt(r.x * r.x + r.y * r.y + r.z * r.z), n = Math.sqrt(t.x * t.x + t.y * t.y + t.z * t.z);
927
+ if (i === 0 || n === 0)
928
+ return s.copy(r).lerp(t, e);
929
+ const o = r.x / i, a = r.y / i, h = r.z / i, m = t.x / n, l = t.y / n, _ = t.z / n;
930
+ let p = o * m + a * l + h * _;
931
+ p = Math.max(-1, Math.min(1, p));
932
+ const d = Math.acos(p);
933
+ if (d < 1e-6)
934
+ return s.copy(r).lerp(t, e);
935
+ const u = Math.sin(d), f = Math.sin((1 - e) * d) / u, g = Math.sin(e * d) / u, w = i + (n - i) * e;
936
+ return s.set(
937
+ (o * f + m * g) * w,
938
+ (a * f + l * g) * w,
939
+ (h * f + _ * g) * w
940
+ );
941
+ }
942
+ function qt(r, t, e, s, i) {
943
+ for (const n of r) {
944
+ const o = (n.endX - n.startX + 1) * 2, a = (n.endZ - n.startZ + 1) * 2, h = e.length;
945
+ for (let l = 0, _ = n.endX - n.startX; l < _; l++) {
946
+ const p = h + l * 2 + 0, d = h + l * 2 + 1, u = h + l * 2 + 2, f = h + l * 2 + 3;
947
+ n.flip ? Ft(t, p, d, u, f, o) : Ht(t, p, d, u, f, o);
948
+ }
949
+ if (n.left)
950
+ for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
951
+ const p = h + l * 2 + 0 + o * 2, d = h + l * 2 + 1 + o * 2, u = h + l * 2 + 2 + o * 2, f = h + l * 2 + 3 + o * 2;
952
+ n.flip ? Ft(t, p, d, u, f, a) : Ht(t, p, d, u, f, a);
953
+ }
954
+ else
955
+ for (let l = 0, _ = n.endZ - n.startZ; l < _; l++) {
956
+ const p = h + l * 2 + 0 + o * 2 + a, d = h + l * 2 + 1 + o * 2 + a, u = h + l * 2 + 2 + o * 2 + a, f = h + l * 2 + 3 + o * 2 + a;
957
+ n.flip ? ft(t, p, d, u, f) : dt(t, p, d, u, f);
958
+ }
959
+ const m = s * i;
960
+ for (let l = n.startX; l <= n.endX; l++) {
961
+ const _ = n.startZ * s + l;
962
+ e.push(e[_].clone()), e.push(e[_ + m].clone());
963
+ }
964
+ for (let l = n.startX; l <= n.endX; l++) {
965
+ const _ = l + n.endZ * s;
966
+ e.push(e[_ + m].clone()), e.push(e[_].clone());
967
+ }
968
+ for (let l = n.startZ; l <= n.endZ; l++) {
969
+ const _ = n.startX + l * s;
970
+ e.push(e[_ + m].clone()), e.push(e[_].clone());
971
+ }
972
+ for (let l = n.startZ; l <= n.endZ; l++) {
973
+ const _ = l * s + n.endX;
974
+ e.push(e[_].clone()), e.push(e[_ + m].clone());
975
+ }
976
+ }
977
+ }
978
+ function Wt(r, t, e, s, i) {
979
+ const n = s * i;
980
+ let o = n * 2;
981
+ const a = new c.Vector3();
982
+ for (const h of r) {
983
+ for (let m = h.startX; m <= h.endX; m++) {
984
+ const l = m + h.startZ * s, _ = t[l], p = t[l + s];
985
+ a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l + n]);
986
+ }
987
+ for (let m = h.startX; m <= h.endX; m++) {
988
+ const l = m + h.endZ * s, _ = t[l + n], p = t[l + n - s];
989
+ a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l]);
990
+ }
991
+ for (let m = h.startZ; m <= h.endZ; m++) {
992
+ const l = m * s + h.startX, _ = t[l + n], p = t[l + n + 1];
993
+ a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l]);
994
+ }
995
+ for (let m = h.startZ; m <= h.endZ; m++) {
996
+ const l = m * s + h.endX, _ = t[l], p = t[l - 1];
997
+ a.subVectors(_, p).normalize(), h.flip && a.multiplyScalar(-1), e[o].copy(a), t[o++].copy(_), e[o].copy(a), t[o++].copy(t[l + n]);
998
+ }
999
+ }
1000
+ }
1001
+ function ce(r, t, e, s, i) {
1002
+ const n = [];
1003
+ for (const o of r) {
1004
+ for (let a = o.startX; a < o.endX; a++) {
1005
+ const h = a + o.startZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
1006
+ n.push([m, l]);
1007
+ }
1008
+ for (let a = o.startX; a < o.endX; a++) {
1009
+ const h = a + o.endZ * e, m = t[h].clone().applyMatrix4(i), l = t[h + 1].clone().applyMatrix4(i);
1010
+ n.push([m, l]);
1011
+ }
1012
+ for (let a = o.startZ; a < o.endZ; a++) {
1013
+ const h = a * e + o.startX, m = (a + 1) * e + o.startX, l = t[h].clone().applyMatrix4(i), _ = t[m].clone().applyMatrix4(i);
1014
+ n.push([l, _]);
1015
+ }
1016
+ for (let a = o.startZ; a < o.endZ; a++) {
1017
+ const h = a * e + o.endX, m = (a + 1) * e + o.endX, l = t[h].clone().applyMatrix4(i), _ = t[m].clone().applyMatrix4(i);
1018
+ n.push([l, _]);
1019
+ }
1020
+ }
1021
+ return n;
1022
+ }
1023
+ function Ht(r, t, e, s, i, n) {
1024
+ dt(r, t, e, s, i), t += n, e += n, s += n, i += n, dt(r, t, e, s, i);
1025
+ }
1026
+ function Ft(r, t, e, s, i, n) {
1027
+ ft(r, t, e, s, i), t += n, e += n, s += n, i += n, ft(r, t, e, s, i);
1028
+ }
1029
+ function Qt(r, t, e, s, i, n, o) {
1030
+ dt(r, e, s, i, n), e += o, s += o, i += o, n += o, ft(t, e, s, i, n);
1031
+ }
1032
+ function $t(r, t, e, s, i, n) {
1033
+ const o = i.left * s.x, a = (1 - i.right) * s.x, h = i.down * s.y, m = (1 - i.up) * s.y, l = t.length, _ = e.length;
1034
+ if (n > 1)
1035
+ for (let d = 0; d < _; d++)
1036
+ for (let u = 0; u < l; u++) {
1037
+ const f = lt(a, o, t[u]), g = lt(m, h, e[d]);
1038
+ r.push(new c.Vector2(g, f));
1039
+ }
1040
+ else
1041
+ for (let d = 0; d < _; d++)
1042
+ for (let u = 0; u < l; u++) {
1043
+ const f = lt(o, a, t[u]), g = lt(m, h, e[d]);
1044
+ r.push(new c.Vector2(f, g));
1045
+ }
1046
+ const p = r.length;
1047
+ for (let d = 0; d < p; d++)
1048
+ r.push(r[d].clone());
1049
+ }
1050
+ function dt(r, t, e, s, i) {
1051
+ r.push(t), r.push(s), r.push(e), r.push(e), r.push(s), r.push(i);
1052
+ }
1053
+ function ft(r, t, e, s, i) {
1054
+ r.push(t), r.push(e), r.push(s), r.push(e), r.push(i), r.push(s);
1055
+ }
1056
+ function Yt(r, t, e, s) {
1057
+ const i = [];
1058
+ for (let n = 0; n < e - 1; n++)
1059
+ for (let o = 0; o < t - 1; o++) {
1060
+ let a = r[n * t + o].clone(), h = r[n * t + o + 1].clone(), m = r[(n + 1) * t + o].clone(), l = r[(n + 1) * t + o + 1].clone();
1061
+ a.applyMatrix4(s), h.applyMatrix4(s), m.applyMatrix4(s), l.applyMatrix4(s), i.push([a, h, m, l]);
1062
+ }
1063
+ return i;
1064
+ }
1065
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1066
+ __proto__: null,
1067
+ addBorders: qt,
1068
+ addFrontAndBackFaces: Qt,
1069
+ addFrontAndBackTexcoords: $t,
1070
+ debugDrawBorders: ce,
1071
+ drawWireframe: Yt,
1072
+ seamNodesToSeams: Mt,
1073
+ updateBorders: Wt,
1074
+ updateXSeams: xt,
1075
+ updateZSeams: Ct
1076
+ }, Symbol.toStringTag, { value: "Module" }));
1077
+ class Zt {
1078
+ get geometry() {
1079
+ return this.m_Geometry;
1080
+ }
1081
+ get pattern() {
1082
+ return this.m_Pattern;
1083
+ }
1084
+ get baseVertices() {
1085
+ return this.m_BaseVertices;
1086
+ }
1087
+ constructor(t, e) {
1088
+ this.m_Pattern = e, this.m_BaseVertices = new Array(e.baseVertexCount);
1089
+ for (let o = 0; o < e.baseVertexCount; o++)
1090
+ this.m_BaseVertices[o] = new c.Vector3();
1091
+ this.m_Vertices = new Array(e.vertexCount);
1092
+ for (let o = 0; o < e.vertexCount; o++)
1093
+ this.m_Vertices[o] = new c.Vector3();
1094
+ this.m_Normals = new Array(e.vertexCount);
1095
+ for (let o = 0; o < e.vertexCount; o++)
1096
+ this.m_Normals[o] = new c.Vector3();
1097
+ if (this.m_Geometry = t, this.m_Pattern.subMeshCount === 1) {
1098
+ const o = new Uint32Array(e.triangles);
1099
+ this.m_Geometry.setIndex(new c.BufferAttribute(o, 1)), this.m_Geometry.addGroup(0, e.triangles.length, 0);
1100
+ } else {
1101
+ const o = e.frontTriangles.length + e.backTriangles.length + e.borderTriangles.length, a = new Uint32Array(o);
1102
+ let h = 0;
1103
+ a.set(e.frontTriangles, h), this.m_Geometry.addGroup(h, e.frontTriangles.length, 0), h += e.frontTriangles.length, a.set(e.backTriangles, h), this.m_Geometry.addGroup(h, e.backTriangles.length, 1), h += e.backTriangles.length, a.set(e.borderTriangles, h), this.m_Geometry.addGroup(h, e.borderTriangles.length, 2), this.m_Geometry.setIndex(new c.BufferAttribute(a, 1));
1104
+ }
1105
+ const s = new Float32Array(e.vertexCount * 3), i = new Float32Array(e.vertexCount * 3), n = new Float32Array(e.vertexCount * 2);
1106
+ for (let o = 0; o < e.texcoords.length; o++)
1107
+ n[o * 2] = e.texcoords[o].x, n[o * 2 + 1] = e.texcoords[o].y;
1108
+ this.m_Geometry.setAttribute(
1109
+ "position",
1110
+ new c.BufferAttribute(s, 3)
1111
+ ), this.m_Geometry.setAttribute(
1112
+ "normal",
1113
+ new c.BufferAttribute(i, 3)
1114
+ ), this.m_Geometry.setAttribute(
1115
+ "uv",
1116
+ new c.BufferAttribute(n, 2)
1117
+ ), this.updateBaseVertices();
1118
+ }
1119
+ // ── UpdateBaseVertices ──────────────────────────────────────────────────
1120
+ /**
1121
+ * Recalculates base vertex positions from the pattern's X/Z arrays
1122
+ * and offset.
1123
+ *
1124
+ * Ported from lines ~2167-2183.
1125
+ */
1126
+ updateBaseVertices() {
1127
+ const t = this.m_BaseVertices, e = this.m_Pattern.baseXArray, s = this.m_Pattern.baseZArray, i = this.m_Pattern.baseXOffset, n = e.length, o = s.length;
1128
+ let a = 0;
1129
+ for (let h = 0; h < o; h++)
1130
+ for (let m = 0; m < n; m++)
1131
+ t[a++].set(e[m] + i, 0, s[h]);
1132
+ }
1133
+ // ── UpdateMesh ─────────────────────────────────────────────────────────
1134
+ /**
1135
+ * Recomputes all vertex positions and normals.
1136
+ *
1137
+ * Algorithm:
1138
+ * 1. Clear normals for all base vertices.
1139
+ * 2. Interpolate seam positions in X and Z.
1140
+ * 3. Accumulate face normals per quad onto each vertex.
1141
+ * 4. Normalise by dividing by weight and re-normalising.
1142
+ * 5. Interpolate seam normals (with slerp).
1143
+ * 6. Offset front/back by +/- halfThickness along normal.
1144
+ * 7. Update border vertex positions and normals.
1145
+ * 8. Push data into BufferGeometry attributes.
1146
+ *
1147
+ * Ported from lines ~2185-2255.
1148
+ */
1149
+ updateMesh() {
1150
+ const t = this.m_BaseVertices, e = this.m_Vertices, s = this.m_Normals, i = this.m_Pattern.weights, n = this.m_Pattern.baseXArray.length, o = this.m_Pattern.baseZArray.length, a = this.m_Pattern.baseVertexCount, h = new c.Vector3(), m = new c.Vector3(), l = new c.Vector3();
1151
+ for (let u = 0; u < a; u++)
1152
+ s[u].set(0, 0, 0);
1153
+ xt(this.m_Pattern.xSeams, t, n, o, !1), Ct(this.m_Pattern.zSeams, t, n, o, !1);
1154
+ for (let u = 0; u < o - 1; u++) {
1155
+ const f = u + 1;
1156
+ for (let g = 0; g < n - 1; g++) {
1157
+ const w = g + 1, B = u * n + g, x = u * n + w, y = f * n + g, S = f * n + w, v = t[B], Z = t[x], O = t[y], z = t[S];
1158
+ At(v, O, Z, h), At(z, Z, O, m), l.addVectors(h, m), s[B].add(l), s[x].add(l), s[y].add(l), s[S].add(l);
1159
+ }
1160
+ }
1161
+ for (let u = 0; u < a; u++)
1162
+ s[u].divideScalar(i[u]).normalize();
1163
+ xt(this.m_Pattern.xSeams, s, n, o, !0), Ct(this.m_Pattern.zSeams, s, n, o, !0);
1164
+ const _ = this.m_Pattern.thickness / 2;
1165
+ for (let u = 0; u < a; u++) {
1166
+ const f = s[u];
1167
+ s[u + a].copy(f).negate();
1168
+ const g = t[u];
1169
+ e[u].copy(g).addScaledVector(f, _), e[u + a].copy(g).addScaledVector(f, -_);
1170
+ }
1171
+ Wt(this.m_Pattern.borders, e, s, n, o);
1172
+ const p = this.m_Geometry.getAttribute(
1173
+ "position"
1174
+ ), d = this.m_Geometry.getAttribute(
1175
+ "normal"
1176
+ );
1177
+ for (let u = 0; u < e.length; u++) {
1178
+ const f = e[u];
1179
+ p.setXYZ(u, f.x, f.y, f.z);
1180
+ const g = s[u];
1181
+ d.setXYZ(u, g.x, g.y, g.z);
1182
+ }
1183
+ p.needsUpdate = !0, d.needsUpdate = !0, this.m_Geometry.computeBoundingBox(), this.m_Geometry.computeBoundingSphere();
1184
+ }
1185
+ // ── DrawWireframe (debug) ──────────────────────────────────────────────
1186
+ /**
1187
+ * Returns wireframe quad data for debug visualisation.
1188
+ *
1189
+ * Ported from lines ~2257-2262.
1190
+ */
1191
+ drawWireframe(t) {
1192
+ const e = this.m_Pattern.baseXArray.length, s = this.m_Pattern.baseZArray.length;
1193
+ return Yt(this.m_Vertices, e, s, t);
1194
+ }
1195
+ }
1196
+ class me {
1197
+ constructor() {
1198
+ this.m_UsedMeshs = [], this.m_FreeMeshs = [], this.m_Meshs = /* @__PURE__ */ new Set();
1199
+ }
1200
+ get() {
1201
+ let t;
1202
+ return this.m_FreeMeshs.length > 0 ? t = this.m_FreeMeshs.pop() : (t = new c.BufferGeometry(), this.m_Meshs.add(t)), this.m_UsedMeshs.push(t), t;
1203
+ }
1204
+ recycle() {
1205
+ for (const t of this.m_UsedMeshs)
1206
+ t.deleteAttribute("position"), t.deleteAttribute("normal"), t.deleteAttribute("uv"), t.setIndex(null), t.clearGroups(), this.m_FreeMeshs.push(t);
1207
+ this.m_UsedMeshs.length = 0;
1208
+ }
1209
+ destroy() {
1210
+ for (const t of this.m_Meshs)
1211
+ t.dispose();
1212
+ this.m_Meshs.clear();
1213
+ }
1214
+ }
1215
+ class ue {
1216
+ constructor(t) {
1217
+ this.m_CreateMeshCollider = !1, this.m_UsedRenderers = [], this.m_FreeRenderers = [], this.m_Renderers = /* @__PURE__ */ new Set(), this.m_Ids = [], this.m_Root = t;
1218
+ }
1219
+ set createColliders(t) {
1220
+ this.m_CreateMeshCollider = t;
1221
+ }
1222
+ get ids() {
1223
+ return [...this.m_Ids];
1224
+ }
1225
+ get(t) {
1226
+ let e;
1227
+ return this.m_FreeRenderers.length > 0 ? (e = this.m_FreeRenderers.pop(), e.createCollider = this.m_CreateMeshCollider, e.reset(t)) : (e = new de(this.m_Root, t, this.m_CreateMeshCollider), this.m_Renderers.add(e)), this.m_UsedRenderers.push(e), this.m_Ids.push(e.id), e;
1228
+ }
1229
+ recycle() {
1230
+ for (const t of this.m_UsedRenderers)
1231
+ t.clear(), this.m_FreeRenderers.push(t);
1232
+ this.m_UsedRenderers.length = 0, this.m_Ids.length = 0;
1233
+ }
1234
+ destroy() {
1235
+ for (const t of this.m_Renderers)
1236
+ t.destroy();
1237
+ this.m_Renderers.clear();
1238
+ }
1239
+ getBounds() {
1240
+ const t = new c.Box3();
1241
+ let e = !0;
1242
+ for (const s of this.m_UsedRenderers)
1243
+ e ? (t.copy(s.bounds), e = !1) : t.union(s.bounds);
1244
+ return t;
1245
+ }
1246
+ }
1247
+ let _e = 1;
1248
+ class de {
1249
+ constructor(t, e, s) {
1250
+ this.m_Visibility = !0, this.m_PropertyBlocks = /* @__PURE__ */ new Map(), this.m_MaterialTextures = /* @__PURE__ */ new Map(), this.m_Id = _e++, this.m_Object3D = new c.Object3D(), this.m_Object3D.name = e, this.m_Mesh = new c.Mesh(
1251
+ new c.BufferGeometry(),
1252
+ new c.MeshStandardMaterial()
1253
+ ), this.m_Object3D.add(this.m_Mesh), t.add(this.m_Object3D), this.m_CreateCollider = s;
1254
+ }
1255
+ get createCollider() {
1256
+ return this.m_CreateCollider;
1257
+ }
1258
+ set createCollider(t) {
1259
+ this.m_CreateCollider = t;
1260
+ }
1261
+ get bounds() {
1262
+ const t = new c.Box3();
1263
+ return this.m_Mesh.geometry && (this.m_Mesh.geometry.computeBoundingBox(), this.m_Mesh.geometry.boundingBox && (t.copy(this.m_Mesh.geometry.boundingBox), t.applyMatrix4(this.m_Mesh.matrixWorld))), t;
1264
+ }
1265
+ get id() {
1266
+ return this.m_Id;
1267
+ }
1268
+ get transform() {
1269
+ return this.m_Object3D;
1270
+ }
1271
+ get visibility() {
1272
+ return this.m_Visibility;
1273
+ }
1274
+ set castShadows(t) {
1275
+ this.m_Mesh.castShadow = t;
1276
+ }
1277
+ set mesh(t) {
1278
+ t && (this.m_Mesh.geometry = t);
1279
+ }
1280
+ get meshObject() {
1281
+ return this.m_Mesh;
1282
+ }
1283
+ setMaterials(t) {
1284
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), Array.isArray(t) ? t.length === 0 ? this.m_Mesh.material = new c.MeshStandardMaterial() : t.length === 1 ? this.m_Mesh.material = t[0].clone() : this.m_Mesh.material = t.map((e) => e.clone()) : this.m_Mesh.material = t.clone(), this.m_PropertyBlocks.clear();
1285
+ }
1286
+ setPropertyBlock(t, e) {
1287
+ this.m_PropertyBlocks.set(e, t);
1288
+ const s = this.getMaterial(e);
1289
+ s && (this.isMapCapable(s) && (t.map instanceof c.Texture ? this.applyTextureProperty(
1290
+ s,
1291
+ e,
1292
+ t.map,
1293
+ t.textureST
1294
+ ) : this.clearMaterialTexture(e, s)), this.isColorCapable(s) && t.color instanceof c.Color && s.color.copy(t.color));
1295
+ }
1296
+ reset(t) {
1297
+ this.m_Object3D.name = t, this.setVisibility(!0), this.m_Mesh.geometry = new c.BufferGeometry(), this.setMaterials([]);
1298
+ }
1299
+ clear() {
1300
+ this.m_Object3D.name = "", this.m_Mesh.geometry = new c.BufferGeometry(), this.m_PropertyBlocks.clear(), this.setVisibility(!1), this.m_Object3D.position.set(0, 0, 0), this.m_Object3D.rotation.set(0, 0, 0), this.m_Object3D.scale.set(1, 1, 1);
1301
+ }
1302
+ destroy() {
1303
+ this.disposeManagedTextures(), this.disposeCurrentMaterials(), this.m_Mesh.geometry && this.m_Mesh.geometry.dispose(), this.m_Object3D.parent && this.m_Object3D.parent.remove(this.m_Object3D);
1304
+ }
1305
+ setVisibility(t) {
1306
+ this.m_Visibility !== t && (this.m_Visibility = t, this.m_Object3D.visible = t);
1307
+ }
1308
+ updateCollider() {
1309
+ }
1310
+ getMaterial(t) {
1311
+ return Array.isArray(this.m_Mesh.material) ? this.m_Mesh.material[t] ?? null : this.m_Mesh.material;
1312
+ }
1313
+ isMapCapable(t) {
1314
+ return "map" in t;
1315
+ }
1316
+ isColorCapable(t) {
1317
+ return "color" in t && t.color instanceof c.Color;
1318
+ }
1319
+ getSTKey(t) {
1320
+ return t ? `${t.x.toFixed(6)},${t.y.toFixed(6)},${t.z.toFixed(6)},${t.w.toFixed(6)}` : "1,1,0,0";
1321
+ }
1322
+ applyTextureProperty(t, e, s, i) {
1323
+ const n = this.getSTKey(i), o = this.m_MaterialTextures.get(e);
1324
+ if (o && o.source === s && o.stKey === n) {
1325
+ t.map !== o.texture && (t.map = o.texture, t.needsUpdate = !0);
1326
+ return;
1327
+ }
1328
+ this.clearManagedTexture(e);
1329
+ const a = s.clone();
1330
+ a.needsUpdate = !0, i && (a.repeat.set(i.x, i.y), a.offset.set(i.z, i.w), a.wrapS = c.RepeatWrapping, a.wrapT = c.RepeatWrapping), t.map = a, t.needsUpdate = !0, this.m_MaterialTextures.set(e, {
1331
+ source: s,
1332
+ texture: a,
1333
+ stKey: n
1334
+ });
1335
+ }
1336
+ clearMaterialTexture(t, e) {
1337
+ this.clearManagedTexture(t), e.map !== null && (e.map = null, e.needsUpdate = !0);
1338
+ }
1339
+ clearManagedTexture(t) {
1340
+ const e = this.m_MaterialTextures.get(t);
1341
+ e && (e.texture.dispose(), this.m_MaterialTextures.delete(t));
1342
+ }
1343
+ disposeManagedTextures() {
1344
+ for (const t of this.m_MaterialTextures.values())
1345
+ t.texture.dispose();
1346
+ this.m_MaterialTextures.clear();
1347
+ }
1348
+ disposeCurrentMaterials() {
1349
+ const t = Array.isArray(this.m_Mesh.material) ? this.m_Mesh.material : [this.m_Mesh.material];
1350
+ for (const e of t)
1351
+ e.dispose();
1352
+ }
1353
+ }
1354
+ class fe {
1355
+ constructor(t, e, s = !1) {
1356
+ this.m_Stack = [], this.m_SharedData = null, this.m_MeshFactory = t, this.m_Pattern = e, (this.m_UseSharedData = s) && (this.m_SharedData = new Zt(this.m_MeshFactory.get(), this.m_Pattern), this.m_SharedData.updateMesh());
1357
+ }
1358
+ get() {
1359
+ return this.m_UseSharedData ? this.m_SharedData : this.m_Stack.length > 0 ? this.m_Stack.pop() : new Zt(this.m_MeshFactory.get(), this.m_Pattern);
1360
+ }
1361
+ free(t) {
1362
+ if (this.m_UseSharedData) throw new Error("Not implemented");
1363
+ this.m_Stack.push(t);
1364
+ }
1365
+ }
1366
+ var yt = /* @__PURE__ */ ((r) => (r[r.Next = 0] = "Next", r[r.Back = 1] = "Back", r))(yt || {}), pe = /* @__PURE__ */ ((r) => (r[r.Surface = 0] = "Surface", r[r.Edge = 1] = "Edge", r))(pe || {}), ge = /* @__PURE__ */ ((r) => (r[r.Constant = 0] = "Constant", r[r.RandomBetweenTwoConstants = 1] = "RandomBetweenTwoConstants", r[r.Curve = 2] = "Curve", r[r.RandomBetweenTwoCurves = 3] = "RandomBetweenTwoCurves", r))(ge || {}), Me = /* @__PURE__ */ ((r) => (r[r.PaperIndexTime = 0] = "PaperIndexTime", r[r.TurnIndexTime = 1] = "TurnIndexTime", r))(Me || {});
1367
+ class xe {
1368
+ constructor(t) {
1369
+ this.keys = t ? t.map((e) => ({ time: e.time, value: e.value })) : [];
1370
+ }
1371
+ /**
1372
+ * Evaluate the curve at parameter `t`.
1373
+ * Linear interpolation between keyframes (Unity default is cubic,
1374
+ * but the exact tangent data is not available here).
1375
+ */
1376
+ evaluate(t) {
1377
+ const e = this.keys, s = e.length;
1378
+ if (s === 0) return 0;
1379
+ if (s === 1 || t <= e[0].time) return e[0].value;
1380
+ if (t >= e[s - 1].time) return e[s - 1].value;
1381
+ for (let i = 0; i < s - 1; i++)
1382
+ if (t >= e[i].time && t <= e[i + 1].time) {
1383
+ const n = (t - e[i].time) / (e[i + 1].time - e[i].time);
1384
+ return e[i].value + (e[i + 1].value - e[i].value) * n;
1385
+ }
1386
+ return e[s - 1].value;
1387
+ }
1388
+ }
1389
+ function nt(r, t, e) {
1390
+ return Math.max(t, Math.min(e, r));
1391
+ }
1392
+ function Ce(r, t, e) {
1393
+ return r === t ? 0 : nt((e - r) / (t - r), 0, 1);
1394
+ }
1395
+ function Ot(r, t) {
1396
+ return r + Math.random() * (t - r);
1397
+ }
1398
+ class rt {
1399
+ constructor(t, e) {
1400
+ 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));
1401
+ }
1402
+ // ── Properties ──────────────────────────────────────────────────────────
1403
+ get mode() {
1404
+ return this.m_Mode;
1405
+ }
1406
+ set mode(t) {
1407
+ this.m_Mode = t;
1408
+ }
1409
+ get constant() {
1410
+ return this.m_Constant;
1411
+ }
1412
+ set constant(t) {
1413
+ this.m_Constant = t;
1414
+ }
1415
+ get constantMin() {
1416
+ return this.m_ConstantMin;
1417
+ }
1418
+ set constantMin(t) {
1419
+ this.m_ConstantMin = t;
1420
+ }
1421
+ get constantMax() {
1422
+ return this.m_ConstantMax;
1423
+ }
1424
+ set constantMax(t) {
1425
+ this.m_ConstantMax = t;
1426
+ }
1427
+ get curve() {
1428
+ return this.m_Curve;
1429
+ }
1430
+ set curve(t) {
1431
+ this.m_Curve = t;
1432
+ }
1433
+ get curveMin() {
1434
+ return this.m_CurveMin;
1435
+ }
1436
+ set curveMin(t) {
1437
+ this.m_CurveMin = t;
1438
+ }
1439
+ get curveMax() {
1440
+ return this.m_CurveMax;
1441
+ }
1442
+ set curveMax(t) {
1443
+ this.m_CurveMax = t;
1444
+ }
1445
+ get curveTimeMode() {
1446
+ return this.m_CurveTimeMode;
1447
+ }
1448
+ set curveTimeMode(t) {
1449
+ this.m_CurveTimeMode = t;
1450
+ }
1451
+ /** A value based on a curve. */
1452
+ static fromCurve(t, e) {
1453
+ const s = new rt();
1454
+ 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;
1455
+ }
1456
+ /** A random value generated between two curves. */
1457
+ static fromCurveRange(t, e, s) {
1458
+ const i = new rt();
1459
+ 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;
1460
+ }
1461
+ // ── Internal API ────────────────────────────────────────────────────────
1462
+ /** @internal */
1463
+ getValue(t, e) {
1464
+ if (this.m_Mode === 0) return this.m_Constant;
1465
+ if (this.m_Mode === 1)
1466
+ return Ot(this.m_ConstantMin, this.m_ConstantMax);
1467
+ const s = this.m_CurveTimeMode === 0 ? t : e;
1468
+ if (this.m_Mode === 2)
1469
+ return this.m_Curve.evaluate(s);
1470
+ if (this.m_Mode === 3)
1471
+ return Ot(
1472
+ this.m_CurveMin.evaluate(s),
1473
+ this.m_CurveMax.evaluate(s)
1474
+ );
1475
+ throw new Error("AutoTurnSettingMode not implemented");
1476
+ }
1477
+ /** @internal */
1478
+ clampValues(t, e) {
1479
+ return this.m_Constant = nt(this.m_Constant, t, e), this.m_ConstantMin = nt(this.m_ConstantMin, t, e), this.m_ConstantMax = nt(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;
1480
+ }
1481
+ clampCurve(t, e, s) {
1482
+ if (this.m_Curve === null || t === null) return null;
1483
+ const i = t.keys.map((h) => ({ time: h.time, value: h.value })), n = i.length;
1484
+ let o = 1 / 0, a = -1 / 0;
1485
+ for (let h = 0; h < n; h++) {
1486
+ const m = i[h].time;
1487
+ o = Math.min(o, m), a = Math.max(a, m);
1488
+ }
1489
+ for (let h = 0; h < n; h++) {
1490
+ let m = i[h].time, l = i[h].value;
1491
+ m = Ce(o, a, m), l = nt(l, e, s), i[h].time = m, i[h].value = l;
1492
+ }
1493
+ return new xe(i);
1494
+ }
1495
+ // ── Value-type clone ────────────────────────────────────────────────────
1496
+ clone() {
1497
+ const t = new rt();
1498
+ 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;
1499
+ }
1500
+ }
1501
+ const R = class R {
1502
+ constructor() {
1503
+ this.m_Mode = 0, this.m_Twist = new rt(), this.m_Bend = new rt(1), this.m_Duration = new rt(0.5);
1504
+ }
1505
+ // ── Properties ──────────────────────────────────────────────────────────
1506
+ get mode() {
1507
+ return this.m_Mode;
1508
+ }
1509
+ set mode(t) {
1510
+ this.m_Mode = t;
1511
+ }
1512
+ get twist() {
1513
+ return this.m_Twist;
1514
+ }
1515
+ set twist(t) {
1516
+ this.m_Twist = t.clampValues(
1517
+ R.kMinTwist,
1518
+ R.kMaxTwist
1519
+ );
1520
+ }
1521
+ get bend() {
1522
+ return this.m_Bend;
1523
+ }
1524
+ set bend(t) {
1525
+ this.m_Bend = t.clampValues(
1526
+ R.kMinBend,
1527
+ R.kMaxBend
1528
+ );
1529
+ }
1530
+ get duration() {
1531
+ return this.m_Duration;
1532
+ }
1533
+ set duration(t) {
1534
+ this.m_Duration = t.clampValues(
1535
+ R.kMinDuration,
1536
+ R.kMaxDuration
1537
+ );
1538
+ }
1539
+ // ── Internal API ────────────────────────────────────────────────────────
1540
+ /** @internal */
1541
+ getModeValue() {
1542
+ return this.m_Mode;
1543
+ }
1544
+ /** @internal */
1545
+ getBendValue(t, e) {
1546
+ return nt(
1547
+ this.m_Bend.getValue(t, e),
1548
+ R.kMinBend,
1549
+ R.kMaxBend
1550
+ );
1551
+ }
1552
+ /** @internal */
1553
+ getDurationValue(t, e) {
1554
+ return nt(
1555
+ this.m_Duration.getValue(t, e),
1556
+ R.kMinDuration,
1557
+ R.kMaxDuration
1558
+ );
1559
+ }
1560
+ /** @internal */
1561
+ getTwistValue(t, e) {
1562
+ return nt(
1563
+ this.m_Twist.getValue(t, e),
1564
+ R.kMinTwist,
1565
+ R.kMaxTwist
1566
+ );
1567
+ }
1568
+ };
1569
+ R.kMinTwist = -1, R.kMaxTwist = 1, R.kMinBend = 0, R.kMaxBend = 1, R.kMinDuration = 0, R.kMaxDuration = 5;
1570
+ let Nt = R, Ze = class extends Error {
1571
+ constructor() {
1572
+ super(
1573
+ "The book's height exceeds the maximum limit. Please consider using thinner paper, increasing the width of the paper, or reducing the number of pages."
1574
+ );
1575
+ }
1576
+ };
1577
+ const ot = class ot extends c.Group {
1578
+ // ── Constructor ────────────────────────────────────────────────────────
1579
+ constructor(t) {
1580
+ super(), this.m_Content = null, this.m_Binding = null, this.m_InitialOpenProgress = 0, this.m_BuildOnAwake = !0, this.m_CastShadows = !0, this.m_AlignToGround = !1, this.m_HideBinder = !1, this.m_CreateColliders = !1, this.m_ReduceShadows = !1, this.m_ReduceSubMeshes = !1, this.m_ReduceOverdraw = !1, this.m_CoverPaperSetup = new ht({
1581
+ color: new c.Color(1, 0, 0),
1582
+ width: 2.1,
1583
+ height: 3.1,
1584
+ thickness: 0.04,
1585
+ stiffness: 0.5
1586
+ }), this.m_PagePaperSetup = new ht({
1587
+ color: new c.Color(1, 1, 1),
1588
+ width: 2,
1589
+ height: 3,
1590
+ thickness: 0.02,
1591
+ stiffness: 0.2
1592
+ }), this.m_Root = null, this.m_IsBuilt = !1, this.m_HasCover = !1, this.m_RendererFactory = null, this.m_MeshFactory = null, this.m_Bound = null, this.m_Papers = [], this.m_SelectedPaper = null, this.m_Direction = E.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new ht({
1593
+ color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
1594
+ width: t.coverPaperSetup.width ?? 2.1,
1595
+ height: t.coverPaperSetup.height ?? 3.1,
1596
+ thickness: t.coverPaperSetup.thickness ?? 0.04,
1597
+ stiffness: t.coverPaperSetup.stiffness ?? 0.5,
1598
+ material: t.coverPaperSetup.material ?? null
1599
+ })), t.pagePaperSetup && (this.m_PagePaperSetup = new ht({
1600
+ color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
1601
+ width: t.pagePaperSetup.width ?? 2,
1602
+ height: t.pagePaperSetup.height ?? 3,
1603
+ thickness: t.pagePaperSetup.thickness ?? 0.02,
1604
+ stiffness: t.pagePaperSetup.stiffness ?? 0.2,
1605
+ material: t.pagePaperSetup.material ?? null
1606
+ }))), ot.s_Instances.add(this);
1607
+ }
1608
+ static get instances() {
1609
+ return [...ot.s_Instances];
1610
+ }
1611
+ // ── Internal accessors ─────────────────────────────────────────────────
1612
+ get minPaperWidth() {
1613
+ return this.m_MinPaperWidth;
1614
+ }
1615
+ get minPaperHeight() {
1616
+ return this.m_MinPaperHeight;
1617
+ }
1618
+ get minPaperThickness() {
1619
+ return this.m_MinPaperThickness;
1620
+ }
1621
+ get maxPaperThickness() {
1622
+ return this.m_MaxPaperThickness;
1623
+ }
1624
+ get totalThickness() {
1625
+ return this.m_TotalThickness;
1626
+ }
1627
+ get hasCover() {
1628
+ return this.m_HasCover;
1629
+ }
1630
+ get castShadowsFlag() {
1631
+ return this.m_CastShadows;
1632
+ }
1633
+ /** Alias matching IBookOwner interface expected by Paper.ts */
1634
+ get castShadows() {
1635
+ return this.m_CastShadows;
1636
+ }
1637
+ get alignToGround() {
1638
+ return this.m_AlignToGround;
1639
+ }
1640
+ get reduceShadows() {
1641
+ return this.m_ReduceShadows;
1642
+ }
1643
+ get coverPaperSetup() {
1644
+ return this.m_CoverPaperSetup;
1645
+ }
1646
+ get pagePaperSetup() {
1647
+ return this.m_PagePaperSetup;
1648
+ }
1649
+ get bound() {
1650
+ return this.m_Bound;
1651
+ }
1652
+ get papers() {
1653
+ return this.m_Papers;
1654
+ }
1655
+ get rendererIds() {
1656
+ return this.m_RendererIds;
1657
+ }
1658
+ get direction() {
1659
+ return this.m_Direction;
1660
+ }
1661
+ // ── Public API (properties) ────────────────────────────────────────────
1662
+ get binding() {
1663
+ return this.m_Binding;
1664
+ }
1665
+ set binding(t) {
1666
+ this.m_Binding !== t && (this.m_Binding = t, this.clear());
1667
+ }
1668
+ get content() {
1669
+ return this.m_Content;
1670
+ }
1671
+ set content(t) {
1672
+ this.m_Content !== t && (this.m_Content = t, this.clear());
1673
+ }
1674
+ get initialOpenProgress() {
1675
+ return this.m_InitialOpenProgress;
1676
+ }
1677
+ set initialOpenProgress(t) {
1678
+ this.m_InitialOpenProgress = c.MathUtils.clamp(t, 0, 1);
1679
+ }
1680
+ get isBuilt() {
1681
+ return this.m_IsBuilt;
1682
+ }
1683
+ get paperCount() {
1684
+ return this.m_CoverPaperCount + this.m_PagePaperCount;
1685
+ }
1686
+ get coverPaperCount() {
1687
+ return this.m_CoverPaperCount;
1688
+ }
1689
+ get pagePaperCount() {
1690
+ return this.m_PagePaperCount;
1691
+ }
1692
+ get isTurning() {
1693
+ return this.m_SelectedPaper !== null && this.m_SelectedPaper.isTurning;
1694
+ }
1695
+ get isFalling() {
1696
+ for (const t of this.m_Papers)
1697
+ if (t.isFalling) return !0;
1698
+ return !1;
1699
+ }
1700
+ get isIdle() {
1701
+ return !this.isTurning && !this.isFalling && !this.isAutoTurning;
1702
+ }
1703
+ get isAutoTurning() {
1704
+ return this.m_AutoTurningEndTime > this.m_CurrentTime;
1705
+ }
1706
+ get hasPendingAutoTurns() {
1707
+ return this.m_AutoTurnQueue.length > 0;
1708
+ }
1709
+ get autoTurningEndTime() {
1710
+ return this.m_AutoTurningEndTime;
1711
+ }
1712
+ // ── Public API (methods) ───────────────────────────────────────────────
1713
+ startTurning(t) {
1714
+ if (!this.m_IsBuilt || this.isTurning) return !1;
1715
+ const e = this.getFrontPapers();
1716
+ for (const s of e) {
1717
+ const i = s.raycast(t);
1718
+ if (i.hit && i.hitInfo.pageContent.isPointOverUI(i.hitInfo.textureCoordinate))
1719
+ return !1;
1720
+ }
1721
+ for (const s of e)
1722
+ if (!s.isFalling && s.startTurning(t))
1723
+ return this.m_SelectedPaper = s, !0;
1724
+ return !1;
1725
+ }
1726
+ updateTurning(t) {
1727
+ this.m_IsBuilt && this.m_SelectedPaper !== null && this.m_SelectedPaper.updateTurning(t);
1728
+ }
1729
+ stopTurning() {
1730
+ this.m_IsBuilt && this.m_SelectedPaper !== null && (this.m_SelectedPaper.stopTurning(), this.m_SelectedPaper = null);
1731
+ }
1732
+ getActivePaperSideIndices(t) {
1733
+ if (t.length = 0, !this.m_IsBuilt) return;
1734
+ const e = this.m_Content.direction === E.RightToLeft, s = this.m_Papers.length, i = (n, o) => {
1735
+ let a = n * 2;
1736
+ o && a++, e && (a = s * 2 - a - 1), t.includes(a) || t.push(a);
1737
+ };
1738
+ for (let n = 0; n < s; n++) {
1739
+ const o = this.m_Papers[n];
1740
+ if (o.isFalling || o.isTurning)
1741
+ n > 0 && i(n - 1, !0), i(n, !1), i(n, !0), n < s - 1 && i(n + 1, !1);
1742
+ else if (o.isOnRightStack) {
1743
+ n > 0 && i(n - 1, !0), i(n, !1);
1744
+ break;
1745
+ }
1746
+ }
1747
+ t.length === 0 && i(this.m_Papers.length - 1, !0), e && t.reverse();
1748
+ }
1749
+ setOpenProgress(t) {
1750
+ this.cancelPendingAutoTurns(), this.m_Content.direction % 2 !== 0 && (t = 1 - t);
1751
+ const e = this.m_Papers.length, s = Math.round(c.MathUtils.lerp(0, e, t));
1752
+ for (let i = 0; i < e; i++) {
1753
+ const n = i >= s;
1754
+ this.m_Papers[i].restState(n);
1755
+ }
1756
+ for (let i = 0; i < e; i++)
1757
+ this.m_Papers[i].restMesh();
1758
+ this.m_WasIdle = !1;
1759
+ }
1760
+ setOpenProgressByIndex(t) {
1761
+ const e = this.m_Content.convertPaperSideIndexToOpenProgress(t);
1762
+ this.setOpenProgress(e);
1763
+ }
1764
+ // ── Auto Turning ──────────────────────────────────────────────────────
1765
+ startAutoTurning(t, e, s = 1, i = 0) {
1766
+ if (!this.m_IsBuilt) return !1;
1767
+ this.cancelPendingAutoTurns();
1768
+ const n = typeof i == "number" ? new rt(i) : i;
1769
+ if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
1770
+ for (let o = 0; o < s && this.canAutoTurn(t); o++) {
1771
+ const a = o / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = o > 0 ? n.getValue(h, a) : 0, l = e.getModeValue(), _ = e.getTwistValue(h, a), p = e.getBendValue(h, a), d = e.getDurationValue(h, a);
1772
+ this.m_AutoTurnQueue.push({ direction: t, mode: l, twist: _, bend: p, duration: d, delay: m });
1773
+ }
1774
+ return this.m_AutoTurnTimer = 0, !0;
1775
+ }
1776
+ cancelPendingAutoTurns() {
1777
+ this.m_AutoTurnQueue.length = 0;
1778
+ }
1779
+ processAutoTurnQueue(t) {
1780
+ if (this.m_AutoTurnQueue.length === 0 || (this.m_AutoTurnTimer -= t, this.m_AutoTurnTimer > 0)) return;
1781
+ const e = this.m_AutoTurnQueue[0];
1782
+ if (!this.canAutoTurn(e.direction)) {
1783
+ this.m_AutoTurnQueue.length = 0;
1784
+ return;
1785
+ }
1786
+ const s = this.getAutoTurnPaper(e.direction);
1787
+ if (s === null) {
1788
+ this.m_AutoTurnQueue.length = 0;
1789
+ return;
1790
+ }
1791
+ s.startAutoTurning(e.mode, e.twist, e.bend, e.duration), this.m_AutoTurningEndTime = Math.max(
1792
+ this.m_AutoTurningEndTime,
1793
+ this.m_CurrentTime + e.duration
1794
+ ), this.m_AutoTurnQueue.shift(), this.m_AutoTurnQueue.length > 0 && (this.m_AutoTurnTimer = this.m_AutoTurnQueue[0].delay);
1795
+ }
1796
+ getAutoTurnPaper(t) {
1797
+ if (this.isTurning) return null;
1798
+ const e = this.getFrontPapers();
1799
+ if (e.length > 0) {
1800
+ const s = t === yt.Next, i = e[s ? e.length - 1 : 0];
1801
+ if (!i.isTurning && !i.isFalling && s === i.isOnRightStack)
1802
+ return i;
1803
+ }
1804
+ return null;
1805
+ }
1806
+ getMaxAutoTurnCount(t) {
1807
+ const e = this.getAutoTurnPaper(t);
1808
+ if (e === null) return 0;
1809
+ let s = 1;
1810
+ return t === yt.Next ? s += this.m_Papers.length - e.index - 1 : s += e.index, s;
1811
+ }
1812
+ canAutoTurn(t) {
1813
+ return this.getAutoTurnPaper(t) !== null;
1814
+ }
1815
+ getAutoTurnPaperIndexTime(t) {
1816
+ const e = this.getAutoTurnPaper(t);
1817
+ return e === null ? 0 : e.index / (this.m_Papers.length - 1 || 1);
1818
+ }
1819
+ // ── Lifecycle ─────────────────────────────────────────────────────────
1820
+ /**
1821
+ * Initialize the book. Call this after adding to scene.
1822
+ * Equivalent to Unity's Start/Awake.
1823
+ */
1824
+ init() {
1825
+ ot.s_Instances.add(this), this.hardClear(), this.m_BuildOnAwake && this.build();
1826
+ }
1827
+ /**
1828
+ * Call every frame with delta time.
1829
+ * Equivalent to Unity's LateUpdate.
1830
+ */
1831
+ update(t) {
1832
+ if (this.m_CurrentTime += t, !!this.m_IsBuilt && this.m_Papers.length !== 0 && this.m_Bound !== null && (this.processAutoTurnQueue(t), !(this.m_WasIdle && this.isIdle))) {
1833
+ this.m_WasIdle = this.isIdle;
1834
+ for (const e of this.m_Papers)
1835
+ e.isFalling && e.updateFalling(t);
1836
+ this.updateLivePages(), this.m_Bound.onLateUpdate();
1837
+ }
1838
+ }
1839
+ dispose() {
1840
+ ot.s_Instances.delete(this), this.hardClear();
1841
+ }
1842
+ // ── Build ─────────────────────────────────────────────────────────────
1843
+ build() {
1844
+ if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
1845
+ if (this.m_MeshFactory === null && (this.m_MeshFactory = new me()), this.m_RendererFactory === null) {
1846
+ const C = new c.Object3D();
1847
+ C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new ue(this.m_Root);
1848
+ }
1849
+ this.m_RendererFactory.createColliders = this.m_CreateColliders, this.m_Direction = this.m_Content.direction;
1850
+ const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
1851
+ this.m_Root.rotation.set(0, t, 0), this.m_CoverPaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.bookDirection = this.m_Content.direction, this.m_PagePaperSetup.height < this.m_CoverPaperSetup.height ? (this.m_CoverPaperSetup.margin = 0, this.m_PagePaperSetup.margin = (this.m_CoverPaperSetup.height - this.m_PagePaperSetup.height) / 2) : (this.m_CoverPaperSetup.margin = (this.m_PagePaperSetup.height - this.m_CoverPaperSetup.height) / 2, this.m_PagePaperSetup.margin = 0);
1852
+ const e = new Dt(this.m_CoverPaperSetup), s = new Dt(this.m_PagePaperSetup);
1853
+ this.m_Content.init(this);
1854
+ let i = this.m_Content.coverContents, n = this.m_Content.pageContents, o = this.m_InitialOpenProgress;
1855
+ this.m_Content.direction % 2 !== 0 && (i = [...i].reverse(), n = [...n].reverse(), o = 1 - o), this.m_HasCover = i.length > 0, this.m_CoverPaperCount = Math.floor(i.length / 2), this.m_PagePaperCount = Math.floor(n.length / 2);
1856
+ const a = this.m_CoverPaperCount + this.m_PagePaperCount, h = Math.floor(i.length / 4);
1857
+ let m = 0, l = 0, _ = 0;
1858
+ this.m_Papers = new Array(a);
1859
+ for (let C = 0; C < a; C++) {
1860
+ const V = this.m_HasCover && (C < h || C >= a - h), U = this.m_RendererFactory.get("Paper"), k = this.m_Papers[C] = new he(V, C, this, U);
1861
+ k.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (k.transform.scale.set(-1, 1, 1), k.setTime(1)), V ? (k.setContentData(i[l++], i[l++], C > h), k.setMaterialData(e), k.setPaperSetup(this.m_CoverPaperSetup)) : (k.setContentData(n[m++], n[m++]), k.setMaterialData(s), k.setPaperSetup(this.m_PagePaperSetup)), _ += k.thickness;
1862
+ }
1863
+ this.m_TotalThickness = _;
1864
+ const p = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
1865
+ this.m_MinPaperThickness = Math.min(p, d), this.m_MaxPaperThickness = Math.max(p, d);
1866
+ const u = this.m_Papers[0].size.x, f = this.m_Papers[Math.floor(a / 2)].size.x;
1867
+ this.m_MinPaperWidth = Math.min(u, f);
1868
+ const g = this.m_Papers[0].size.y, w = this.m_Papers[Math.floor(a / 2)].size.y;
1869
+ this.m_MinPaperHeight = Math.min(g, w), this.m_Bound = this.m_Binding.createBound(
1870
+ this,
1871
+ this.m_Root,
1872
+ this.m_RendererFactory,
1873
+ this.m_MeshFactory
1874
+ ), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
1875
+ const B = this.m_ReduceOverdraw && n.length > 0, x = this.m_ReduceSubMeshes, y = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x), S = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, x, !0) : null, v = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, N = z + 1, D = this.m_Bound.constructor.name.includes("Staple");
1876
+ for (let C = 0; C < a; C++) {
1877
+ const V = this.m_Papers[C];
1878
+ C !== 0 && (V.prev = this.m_Papers[C - 1]), C !== a - 1 && (V.next = this.m_Papers[C + 1]), V.noHole = D && (C === z || C === N), V.isCover ? V.setMeshData(Z.get(), null, O) : V.setMeshData(
1879
+ y.get(),
1880
+ (S == null ? void 0 : S.get()) ?? null,
1881
+ v
1882
+ );
1883
+ }
1884
+ this.m_IsBuilt = !0, this.m_RendererIds = this.m_RendererFactory.ids, this.update(0), this.m_Bound.binderRenderer.updateCollider(), this.m_CoverPaperSetup.bookDirection = E.LeftToRight, this.m_PagePaperSetup.bookDirection = E.LeftToRight;
1885
+ }
1886
+ clear() {
1887
+ return this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_MeshFactory !== null && this.m_MeshFactory.recycle(), this.m_RendererFactory !== null && this.m_RendererFactory.recycle(), this;
1888
+ }
1889
+ hardClear() {
1890
+ this.m_CoverPaperCount = this.m_PagePaperCount = 0, this.m_IsBuilt = !1, this.m_WasIdle = !1, this.m_Bound = null, this.m_Root !== null && (this.remove(this.m_Root), this.m_Root = null), this.m_MeshFactory !== null && (this.m_MeshFactory.destroy(), this.m_MeshFactory = null), this.m_RendererFactory !== null && (this.m_RendererFactory.destroy(), this.m_RendererFactory = null);
1891
+ }
1892
+ createPaperMeshDataPool(t, e, s = !1, i = !1) {
1893
+ const n = e ? 0 : t.quality, o = this.m_Bound.createPaperPattern(
1894
+ n,
1895
+ t.size,
1896
+ t.thickness,
1897
+ t.uvMargin,
1898
+ i,
1899
+ s
1900
+ );
1901
+ return new fe(
1902
+ this.m_MeshFactory,
1903
+ o,
1904
+ e && this.m_Bound.useSharedMeshDataForLowpoly
1905
+ );
1906
+ }
1907
+ // ── Query methods ─────────────────────────────────────────────────────
1908
+ getFrontPapers() {
1909
+ const t = [];
1910
+ if (this.m_SelectedPaper !== null) {
1911
+ const e = this.m_SelectedPaper.index;
1912
+ e > 0 && t.push(this.m_Papers[e - 1]), t.push(this.m_SelectedPaper), e < this.m_Papers.length - 1 && t.push(this.m_Papers[e + 1]);
1913
+ } else {
1914
+ for (let e = 0; e < this.m_Papers.length; e++)
1915
+ if (this.m_Papers[e].isOnRightStack) {
1916
+ e > 0 && t.push(this.m_Papers[e - 1]), t.push(this.m_Papers[e]);
1917
+ break;
1918
+ }
1919
+ t.length === 0 && t.push(this.m_Papers[this.m_Papers.length - 1]);
1920
+ }
1921
+ return t;
1922
+ }
1923
+ getAverageTime() {
1924
+ const t = this.m_Papers.length;
1925
+ let e = 0;
1926
+ for (const s of this.m_Papers)
1927
+ s.updateTime(), e += s.zTime;
1928
+ return e /= t, e;
1929
+ }
1930
+ bookRaycast(t) {
1931
+ const e = this.getFrontPapers();
1932
+ for (const s of e) {
1933
+ const i = s.raycast(t);
1934
+ if (i.hit) return i.hitInfo;
1935
+ }
1936
+ return null;
1937
+ }
1938
+ // ── Live Pages ────────────────────────────────────────────────────────
1939
+ updateLivePages() {
1940
+ const t = /* @__PURE__ */ new Set(), e = this.m_Papers.length;
1941
+ for (let s = 0; s < e; s++) {
1942
+ const i = this.m_Papers[s];
1943
+ if (i.isFalling || i.isTurning)
1944
+ s > 0 && t.add(this.m_Papers[s - 1].backContent), t.add(i.frontContent), t.add(i.backContent), s < e - 1 && t.add(this.m_Papers[s + 1].frontContent);
1945
+ else if (i.isOnRightStack) {
1946
+ s > 0 && t.add(this.m_Papers[s - 1].backContent), t.add(i.frontContent);
1947
+ break;
1948
+ }
1949
+ }
1950
+ t.size === 0 && t.add(this.m_Papers[this.m_Papers.length - 1].backContent);
1951
+ for (const s of this.m_Papers)
1952
+ s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
1953
+ }
1954
+ };
1955
+ ot.s_Instances = /* @__PURE__ */ new Set();
1956
+ let Ut = ot;
1957
+ class ye {
1958
+ constructor() {
1959
+ this.baseXArray = [], this.baseZArray = [], this.baseXOffset = 0, this.baseVertexCount = 0, this.xSeams = [], this.zSeams = [], this.xNoneSeamIndexes = [], this.borders = [], this.texcoords = [], this.weights = [], this.triangles = [], this.frontTriangles = [], this.backTriangles = [], this.borderTriangles = [], this.vertexCount = 0, this.subMeshCount = 0, this.size = new c.Vector2(), this.thickness = 0;
1960
+ }
1961
+ }
1962
+ class Ne {
1963
+ constructor() {
1964
+ this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
1965
+ }
1966
+ get bookContent() {
1967
+ return this.m_BookContent;
1968
+ }
1969
+ get isActive() {
1970
+ return this.m_IsActive;
1971
+ }
1972
+ get textureST() {
1973
+ return new c.Vector4(1, 1, 0, 0);
1974
+ }
1975
+ get isShareable() {
1976
+ return !0;
1977
+ }
1978
+ onInit() {
1979
+ }
1980
+ onActiveChanged() {
1981
+ }
1982
+ onIsPointOverUI(t) {
1983
+ return !1;
1984
+ }
1985
+ isPointOverUI(t) {
1986
+ return this.onIsPointOverUI(t);
1987
+ }
1988
+ init(t) {
1989
+ var e;
1990
+ !this.isShareable && this.m_BookContent !== null && this.m_BookContent !== t && (console.error("The page content is already in use. It can only be assigned to one book content."), (e = this.m_BookContent.book) == null || e.clear()), this.m_BookContent = t, this.m_IsActive = !1, this.onInit();
1991
+ }
1992
+ setActive(t) {
1993
+ var e;
1994
+ this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
1995
+ }
1996
+ }
1997
+ class Lt {
1998
+ constructor(t, e) {
1999
+ this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
2000
+ }
2001
+ get texture() {
2002
+ return this.m_Texture;
2003
+ }
2004
+ get textureST() {
2005
+ return this.m_Texture ? this.m_TextureST : new c.Vector4(1, 1, 0, 0);
2006
+ }
2007
+ isPointOverUI(t) {
2008
+ return !1;
2009
+ }
2010
+ init(t) {
2011
+ }
2012
+ setActive(t) {
2013
+ }
2014
+ }
2015
+ class Ue {
2016
+ constructor() {
2017
+ this.m_Direction = E.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
2018
+ }
2019
+ get coverCount4() {
2020
+ return this.nextMultipleOf4(this.m_Covers.length);
2021
+ }
2022
+ get pageCount4() {
2023
+ return this.nextMultipleOf4(this.m_Pages.length);
2024
+ }
2025
+ get book() {
2026
+ return this.m_Book;
2027
+ }
2028
+ get covers() {
2029
+ return this.m_Covers;
2030
+ }
2031
+ get pages() {
2032
+ return this.m_Pages;
2033
+ }
2034
+ get isEmpty() {
2035
+ return this.m_Covers.length === 0 && this.m_Pages.length === 0;
2036
+ }
2037
+ get direction() {
2038
+ return this.m_Direction;
2039
+ }
2040
+ set direction(t) {
2041
+ this.m_Direction = t;
2042
+ }
2043
+ get coverContents() {
2044
+ return this.getContents(this.m_Covers, !1);
2045
+ }
2046
+ get pageContents() {
2047
+ return this.getContents(this.m_Pages, !1);
2048
+ }
2049
+ getContents(t, e) {
2050
+ const s = t.length;
2051
+ let i = this.nextMultipleOf4(s);
2052
+ e && (i = Math.min(i, 4));
2053
+ const n = new Array(i);
2054
+ for (let o = 0; o < i; o++)
2055
+ n[o] = this.getContent(o < s ? t[o] : null);
2056
+ return n;
2057
+ }
2058
+ nextMultipleOf4(t) {
2059
+ return Math.ceil(t / 4) * 4;
2060
+ }
2061
+ getContent(t) {
2062
+ if (t !== null) {
2063
+ if (t instanceof c.Texture)
2064
+ return new Lt(t);
2065
+ if (typeof t.init == "function")
2066
+ return t;
2067
+ }
2068
+ return new Lt(null);
2069
+ }
2070
+ init(t) {
2071
+ this.m_Book = t;
2072
+ for (const e of this.coverContents)
2073
+ e.init(this);
2074
+ for (const e of this.pageContents)
2075
+ e.init(this);
2076
+ }
2077
+ // ── Index conversion methods ───────────────────────────────────────────
2078
+ convertCoverIndexToPaperSideIndex(t) {
2079
+ if (this.m_Covers.length === 0)
2080
+ throw new Error("Check covers.length > 0 before calling this method.");
2081
+ return this.m_Pages.length === 0 || t < this.coverCount4 / 2 ? t : t + this.pageCount4;
2082
+ }
2083
+ convertPageIndexToPaperSideIndex(t) {
2084
+ if (this.m_Pages.length === 0)
2085
+ throw new Error("Check pages.length > 0 before calling this method.");
2086
+ return this.m_Covers.length === 0 ? t : t + this.coverCount4 / 2;
2087
+ }
2088
+ convertPaperSideIndexToCoverIndex(t) {
2089
+ if (this.m_Covers.length === 0)
2090
+ throw new Error("Check covers.length > 0 before calling this method.");
2091
+ if (this.isPagePaperSideIndex(t))
2092
+ throw new Error("Check isCoverPaperSideIndex before calling this method.");
2093
+ return t > this.coverCount4 / 2 ? t - this.pageCount4 : t;
2094
+ }
2095
+ convertPaperSideIndexToPageIndex(t) {
2096
+ if (this.m_Pages.length === 0)
2097
+ throw new Error("Check pages.length > 0 before calling this method.");
2098
+ if (this.isCoverPaperSideIndex(t))
2099
+ throw new Error("Check isPagePaperSideIndex before calling this method.");
2100
+ return t - this.coverCount4 / 2;
2101
+ }
2102
+ convertPaperSideIndexToOpenProgress(t) {
2103
+ return t / (this.coverCount4 + this.pageCount4 - 1);
2104
+ }
2105
+ isCoverPaperSideIndex(t) {
2106
+ const e = this.coverCount4 / 2, s = this.pageCount4 / 2;
2107
+ if (e === 0) return !1;
2108
+ if (s === 0) return !0;
2109
+ const i = e, n = e + s * 2 - 1;
2110
+ return t < i || t > n;
2111
+ }
2112
+ isPagePaperSideIndex(t) {
2113
+ return !this.isCoverPaperSideIndex(t);
2114
+ }
2115
+ }
2116
+ class Pe {
2117
+ }
2118
+ class Le {
2119
+ constructor(t, e) {
2120
+ this.m_Book = t, this.m_Root = e;
2121
+ }
2122
+ }
2123
+ function Xt(r, t, e, s) {
2124
+ const i = 1 - s;
2125
+ return new c.Vector3(
2126
+ i * i * r.x + 2 * i * s * t.x + s * s * e.x,
2127
+ i * i * r.y + 2 * i * s * t.y + s * s * e.y,
2128
+ i * i * r.z + 2 * i * s * t.z + s * s * e.z
2129
+ );
2130
+ }
2131
+ function Et(r, t) {
2132
+ return r++, r === t ? 0 : r;
2133
+ }
2134
+ function we(r, t) {
2135
+ return r === 0 ? t - 1 : r - 1;
2136
+ }
2137
+ const Te = 0.01, Se = 0.1, ke = 0.04, ve = 0.4, be = 2, Be = 10, Re = 0, Ve = 5;
2138
+ function et(r, t, e) {
2139
+ return Math.max(t, Math.min(e, r));
2140
+ }
2141
+ function Kt(r) {
2142
+ return Math.max(0, Math.min(1, r));
2143
+ }
2144
+ function F(r, t, e) {
2145
+ return r + (t - r) * e;
2146
+ }
2147
+ function jt(r, t, e) {
2148
+ return r === t ? 0 : Kt((e - r) / (t - r));
2149
+ }
2150
+ function Ie(r, t) {
2151
+ const e = r.clone().normalize();
2152
+ if (e.lengthSq() === 0) return new c.Quaternion();
2153
+ let s = new c.Vector3().crossVectors(t, e);
2154
+ if (s.lengthSq() === 0) {
2155
+ const o = Math.abs(e.y) < 0.999 ? new c.Vector3(0, 1, 0) : new c.Vector3(1, 0, 0);
2156
+ s = new c.Vector3().crossVectors(o, e);
2157
+ }
2158
+ s.normalize();
2159
+ const i = new c.Vector3().crossVectors(e, s).normalize(), n = new c.Matrix4().makeBasis(s, i, e);
2160
+ return new c.Quaternion().setFromRotationMatrix(n);
2161
+ }
2162
+ const tt = Math.PI / 180, it = 180 / Math.PI;
2163
+ class ze {
2164
+ constructor() {
2165
+ 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;
2166
+ }
2167
+ get material() {
2168
+ return this._material;
2169
+ }
2170
+ set material(t) {
2171
+ this._material = t;
2172
+ }
2173
+ get color() {
2174
+ return this._color;
2175
+ }
2176
+ set color(t) {
2177
+ this._color = t;
2178
+ }
2179
+ get thickness() {
2180
+ return this._thickness;
2181
+ }
2182
+ set thickness(t) {
2183
+ this._thickness = et(t, Te, Se);
2184
+ }
2185
+ get margin() {
2186
+ return this._margin;
2187
+ }
2188
+ set margin(t) {
2189
+ this._margin = Kt(t);
2190
+ }
2191
+ get crown() {
2192
+ return this._crown;
2193
+ }
2194
+ set crown(t) {
2195
+ this._crown = et(t, ke, ve);
2196
+ }
2197
+ get count() {
2198
+ return this._count;
2199
+ }
2200
+ set count(t) {
2201
+ this._count = et(t, be, Be);
2202
+ }
2203
+ get quality() {
2204
+ return this._quality;
2205
+ }
2206
+ set quality(t) {
2207
+ this._quality = et(t, Re, Ve);
2208
+ }
2209
+ }
2210
+ class De extends Error {
2211
+ constructor() {
2212
+ super("Book height is too large relative to paper width."), this.name = "BookHeightException";
2213
+ }
2214
+ }
2215
+ class Ae {
2216
+ // ── Constructor ────────────────────────────────────────────────────────
2217
+ constructor(t, e, s, i, n) {
2218
+ 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)
2219
+ throw new De();
2220
+ const o = this.m_Book.coverPaperSetup, a = this.m_Book.pagePaperSetup, h = new c.BufferGeometry();
2221
+ this.updateStapleMesh(e, h);
2222
+ const m = n ?? new c.MeshStandardMaterial({
2223
+ color: e.color,
2224
+ metalness: 0.9,
2225
+ roughness: 0.3
2226
+ });
2227
+ this.stapleMesh = new c.Mesh(h, m), this.stapleMesh.name = "Staple", this.stapleMesh.castShadow = this.m_Book.castShadows, i.add(this.stapleMesh), this.stapleMesh.position.set(
2228
+ 0,
2229
+ 0,
2230
+ this.m_StapleMargin + a.margin + o.margin
2231
+ );
2232
+ let l = o.thickness;
2233
+ l = Math.max(this.m_BindingRadius, l);
2234
+ for (const _ of this.m_Book.papers) {
2235
+ const p = _.size.clone();
2236
+ p.x -= this.m_BindingRadius, _.sizeXOffset = this.m_BindingRadius, _.size = p, _.setMinTurningRadius(l), _.updateTurningRadius(), this.updatePaperPosition(_);
2237
+ }
2238
+ this.updateRootPosition();
2239
+ }
2240
+ get binderRenderer() {
2241
+ return this._binderRendererAdapter || (this._binderRendererAdapter = new He(this.stapleMesh)), this._binderRendererAdapter;
2242
+ }
2243
+ // ── updateStapleMesh ──────────────────────────────────────────────────
2244
+ updateStapleMesh(t, e) {
2245
+ this.m_StapleThickness = t.thickness, this.m_StackHeight = this.m_Book.totalThickness, this.m_BindingMidSpace = this.m_StapleThickness * 1.75, this.m_BindingRadius = (this.m_StackHeight + this.m_BindingMidSpace) / 2 / Math.sin(45 * tt), this.m_StackHeight += this.m_BindingMidSpace;
2246
+ let s = t.crown;
2247
+ s = Math.max(s, this.m_StapleThickness * 4);
2248
+ const i = this.m_StapleThickness * 0.5, n = Math.max(
2249
+ this.m_Book.minPaperHeight / 2 - s - i,
2250
+ i
2251
+ );
2252
+ this.m_StapleMargin = F(i, n, t.margin);
2253
+ const o = this.m_Book.minPaperHeight - this.m_StapleMargin * 2;
2254
+ let a = t.count, h = (o - s * a) / (a - 1);
2255
+ for (h = Math.max(h, 0); h < this.m_StapleThickness * 2 && a > 2; )
2256
+ a--, h = (o - s * a) / (a - 1), h = Math.max(h, 0);
2257
+ const m = t.quality / 5, l = Math.floor(F(4, 20, m)), _ = Math.floor(F(4, 10, m)), p = Math.floor(F(3, 10, m)), d = this.m_StapleThickness / 2, u = d * 2.5, f = 0.9, g = d * 1;
2258
+ let w = s / 2 * f;
2259
+ w = Math.max(w, g * 2);
2260
+ let B = 0;
2261
+ B += this.m_Book.totalThickness / 2, B += d;
2262
+ const x = -(this.m_Book.papers[0].thickness / 2 + d), y = [];
2263
+ {
2264
+ for (let I = 0; I < _; I++) {
2265
+ const X = I / (_ - 1), W = F(-90, -180, X) * tt, P = new c.Vector3(
2266
+ g * Math.sin(W),
2267
+ 0,
2268
+ g * Math.cos(W)
2269
+ );
2270
+ P.x += g, P.z += g, P.x += x, y.push(P);
2271
+ }
2272
+ const M = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), T = new c.Vector3(B - d * 0.5, 0, w);
2273
+ for (let I = 0; I < p; I++) {
2274
+ const X = I / (p - 1), q = Xt(M, H, T, X);
2275
+ q.x += x, y.push(q);
2276
+ }
2277
+ y.reverse();
2278
+ }
2279
+ const S = new Array(l);
2280
+ for (let M = 0; M < l; M++) {
2281
+ const T = (90 - M * (360 / l)) * tt;
2282
+ S[M] = new c.Vector3(Math.cos(T), Math.sin(T), 0), S[M].x *= 0.75;
2283
+ }
2284
+ const v = y.length, Z = v * l, O = new Array(Z * 2), z = new Array(Z * 2), N = new Array(
2285
+ (Z * 2 - 1) * l * 2 * 3
2286
+ );
2287
+ for (let M = 0; M < Z * 2; M++)
2288
+ O[M] = new c.Vector3(), z[M] = new c.Vector3();
2289
+ let D = 0;
2290
+ for (let M = 0; M < v; M++) {
2291
+ const H = y[we(M, v)], T = y[M], I = y[Et(M, v)];
2292
+ let X;
2293
+ if (M === 0)
2294
+ X = new c.Vector3(1, 0, -2).normalize();
2295
+ else if (M === v - 1)
2296
+ X = new c.Vector3(0, 0, 1);
2297
+ else {
2298
+ const K = T.clone().sub(H).normalize(), J = I.clone().sub(T).normalize();
2299
+ X = K.add(J).multiplyScalar(0.5);
2300
+ }
2301
+ const q = new c.Vector3(0, 1, 0), W = Ie(X, q), P = D;
2302
+ let b = jt(0, p / 4, M);
2303
+ b = F(0.1, 1, b), b = Math.sqrt(b);
2304
+ for (let K = 0; K < l; K++) {
2305
+ const J = S[K].clone().applyQuaternion(W).multiplyScalar(b), ct = T.clone().add(J.clone().multiplyScalar(d));
2306
+ O[D] = ct, z[D] = J.clone();
2307
+ const at = T.clone().add(J.clone().multiplyScalar(d));
2308
+ at.z = s - at.z;
2309
+ const Jt = P + l - K - 1, Tt = Z * 2 - Jt - 1;
2310
+ O[Tt] = at, z[Tt] = J.clone(), D++;
2311
+ }
2312
+ }
2313
+ let C = 0;
2314
+ const V = y.length * 2;
2315
+ for (let M = 0; M < V - 1; M++) {
2316
+ const H = M * l, T = (M + 1) * l;
2317
+ for (let I = 0; I < l; I++) {
2318
+ const X = Et(I, l), q = H + I, W = H + X, P = T + X, b = T + I;
2319
+ N[C++] = q, N[C++] = b, N[C++] = W, N[C++] = W, N[C++] = b, N[C++] = P;
2320
+ }
2321
+ }
2322
+ const U = [...O], k = [...z], Q = [...N], G = O.map((M) => M.clone()), $ = [...N];
2323
+ for (let M = 0; M < a - 1; M++) {
2324
+ const H = G.length;
2325
+ for (let T = 0; T < $.length; T++)
2326
+ $[T] += H;
2327
+ for (let T = 0; T < G.length; T++)
2328
+ G[T].z += h + s;
2329
+ U.push(...G.map((T) => T.clone())), k.push(...z.map((T) => T.clone())), Q.push(...$);
2330
+ }
2331
+ const j = new Float32Array(U.length * 3), A = new Float32Array(k.length * 3);
2332
+ for (let M = 0; M < U.length; M++)
2333
+ j[M * 3] = U[M].x, j[M * 3 + 1] = U[M].y, j[M * 3 + 2] = U[M].z, A[M * 3] = k[M].x, A[M * 3 + 1] = k[M].y, A[M * 3 + 2] = k[M].z;
2334
+ e.setAttribute(
2335
+ "position",
2336
+ new c.BufferAttribute(j, 3)
2337
+ ), e.setAttribute(
2338
+ "normal",
2339
+ new c.BufferAttribute(A, 3)
2340
+ ), e.setIndex(Q);
2341
+ }
2342
+ // ── createPaperPattern ────────────────────────────────────────────────
2343
+ createPaperPattern(t, e, s, i, n, o) {
2344
+ const a = new ye();
2345
+ a.size = e, a.thickness = s;
2346
+ const h = this.m_BindingRadius;
2347
+ a.baseXOffset = -h;
2348
+ const m = this.m_Quality + 1;
2349
+ this.m_BindingVertexCount = m;
2350
+ const l = t / 5, _ = Math.min(e.x, e.y) / 60, p = Math.floor(
2351
+ F(0, (e.x - h) / _, l)
2352
+ ), d = Math.floor(F(0, e.y / _, l));
2353
+ let u = 2 + p + 1 + m, f = 2 + d;
2354
+ const g = new st(0);
2355
+ let w = g;
2356
+ const B = h / m;
2357
+ let x = 0;
2358
+ for (let P = 1; P < m + 1; P++)
2359
+ w = w.createNext(x), x += B;
2360
+ const y = (e.x - h) / (p + 1);
2361
+ for (let P = m + 1; P < u; P++)
2362
+ w = w.createNext(x), x += y;
2363
+ const S = new st(0);
2364
+ let v = S;
2365
+ const Z = e.y / (f - 1);
2366
+ let O = 0;
2367
+ for (let P = 0; P < f - 1; P++)
2368
+ O += Z, v = v.createNext(O);
2369
+ const z = [], N = [], D = i.clone();
2370
+ if (n) {
2371
+ let P = 0;
2372
+ this.m_Book.hasCover && (P = Math.floor(this.m_Book.coverPaperCount / 2));
2373
+ const b = Math.max(0.01, s);
2374
+ D.left = 0, D.right = (this.getPX(P + 1, s) - this.getPX(P, s) + b) / e.x, D.down = b / e.y, D.up = b / e.y;
2375
+ }
2376
+ const C = new le(a, D, !1);
2377
+ C.insert(g, S, z, N), g.updateIndex(0), S.updateIndex(0), Mt(z, a.xSeams), Mt(N, a.zSeams);
2378
+ const V = this.m_BindingVertexCount + 2, U = new Array(V);
2379
+ a.xNoneSeamIndexes = U, w = g;
2380
+ for (let P = 0; P < V; P++) {
2381
+ U[P] = w.index;
2382
+ do
2383
+ w = w.next;
2384
+ while (w.seam);
2385
+ }
2386
+ const k = g.getValues(), Q = S.getValues();
2387
+ u = k.length, f = Q.length;
2388
+ const G = u * f, $ = [], j = new Array(G).fill(0), A = [], M = [], H = [], T = [];
2389
+ $t(
2390
+ $,
2391
+ k,
2392
+ Q,
2393
+ e,
2394
+ i,
2395
+ this.m_Book.direction
2396
+ );
2397
+ const I = C.leftNode.index, X = C.downNode.index;
2398
+ let q = C.rightNode.index, W = C.upNode.index;
2399
+ q === 0 && (q = u - 1), W === 0 && (W = f - 1);
2400
+ for (let P = 0; P < f - 1; P++)
2401
+ for (let b = 0; b < u - 1; b++) {
2402
+ if (n && P >= X && P < W && b >= I && b < q)
2403
+ continue;
2404
+ const K = P * u + b, J = P * u + (b + 1), ct = (P + 1) * u + b, at = (P + 1) * u + (b + 1);
2405
+ j[K] += 2, j[J] += 2, j[ct] += 2, j[at] += 2, Qt(
2406
+ A,
2407
+ M,
2408
+ K,
2409
+ J,
2410
+ ct,
2411
+ at,
2412
+ G
2413
+ );
2414
+ }
2415
+ if (T.push(new wt(0, 0, u - 1, f - 1, !1, !1)), qt(T, H, $, u, f), a.baseXArray = k, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = j, o) {
2416
+ a.subMeshCount = 1;
2417
+ const P = [];
2418
+ P.push(...A), P.push(...H), P.push(...M), a.triangles = P;
2419
+ } else
2420
+ a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = M, a.borderTriangles = H;
2421
+ return a.borders = T, a;
2422
+ }
2423
+ // ── updateRootPosition ────────────────────────────────────────────────
2424
+ updateRootPosition() {
2425
+ const t = this.m_Book.papers, e = t[0].transform.position.y, s = t[t.length - 1].transform.position.y;
2426
+ let i = -Math.min(e, s);
2427
+ i += t[0].thickness / 2, this.m_Root.position.set(0, i, this.m_Root.position.z);
2428
+ }
2429
+ // ── resetPaperPosition ────────────────────────────────────────────────
2430
+ resetPaperPosition(t) {
2431
+ const e = this.m_Book.papers, s = e.length;
2432
+ let i = 0;
2433
+ const n = e.length / 2 - 1, o = e.length / 2;
2434
+ for (let x = 0; x < s; x++) {
2435
+ const y = e[x];
2436
+ y.updateTime();
2437
+ const S = y.zTime, v = y.thickness;
2438
+ i += S * v, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2439
+ }
2440
+ let a = this.getStackHeight(t.index) - t.thickness / 2;
2441
+ const h = this.getStackZ(a), m = 180 + h;
2442
+ let l = t.isFlipped ? 1 : 0, _ = F(h, m, l);
2443
+ const p = _ * tt, d = new c.Vector3(
2444
+ Math.cos(p) * this.m_BindingRadius,
2445
+ Math.sin(p) * this.m_BindingRadius,
2446
+ 0
2447
+ );
2448
+ d.z = t.margin;
2449
+ let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, g = Math.sqrt(u * u - f * f), w = Math.asin(g / u) * it - 90;
2450
+ if (t.index < Math.floor(s / 2)) {
2451
+ let x = 0;
2452
+ if (this.m_Book.alignToGround) {
2453
+ u = e[0].size.x;
2454
+ const y = this.m_StackHeight / 2;
2455
+ f = et(i, 0, y) - y, g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2456
+ }
2457
+ _ = F(w, -x, l);
2458
+ } else {
2459
+ let x = 0;
2460
+ if (this.m_Book.alignToGround) {
2461
+ u = e[0].size.x;
2462
+ const y = this.m_StackHeight / 2;
2463
+ f = y - et(i, y, y * 2), g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2464
+ }
2465
+ _ = F(x, -w, l);
2466
+ }
2467
+ t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2468
+ new c.Euler(0, 0, _ * tt)
2469
+ );
2470
+ }
2471
+ // ── getPX (private helper) ───────────────────────────────────────────
2472
+ getPX(t, e) {
2473
+ const s = this.m_Book.papers, i = s.length;
2474
+ let n = 0;
2475
+ const o = s.length / 2 - 1, a = s.length / 2;
2476
+ for (let f = 0; f < i; f++)
2477
+ n += 0 * e, f === o && (n += 0 * this.m_BindingMidSpace / 2), f === a && (n += 0 * this.m_BindingMidSpace / 2);
2478
+ const h = this.getStackHeight(t) - e / 2, m = this.getStackZ(h), l = 180 + m, d = F(m, l, 0) * tt;
2479
+ return new c.Vector3(
2480
+ Math.cos(d) * this.m_BindingRadius,
2481
+ Math.sin(d) * this.m_BindingRadius,
2482
+ 0
2483
+ ).x;
2484
+ }
2485
+ // ── updatePaperPosition ───────────────────────────────────────────────
2486
+ updatePaperPosition(t) {
2487
+ const e = this.m_Book.papers, s = e.length;
2488
+ let i = 0;
2489
+ const n = e.length / 2 - 1, o = e.length / 2;
2490
+ for (let x = 0; x < s; x++) {
2491
+ const y = e[x];
2492
+ y.updateTime();
2493
+ const S = y.zTime, v = y.thickness;
2494
+ i += S * v, x === n && (i += S * this.m_BindingMidSpace / 2), x === o && (i += S * this.m_BindingMidSpace / 2);
2495
+ }
2496
+ const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
2497
+ let l = t.zTime, _ = F(h, m, l);
2498
+ const p = _ * tt, d = new c.Vector3(
2499
+ Math.cos(p) * this.m_BindingRadius,
2500
+ Math.sin(p) * this.m_BindingRadius,
2501
+ 0
2502
+ );
2503
+ d.z = t.margin;
2504
+ let u = e[Math.floor(s / 2)].size.x, f = this.m_BindingMidSpace, g = Math.sqrt(u * u - f * f), w = Math.asin(g / u) * it - 90;
2505
+ if (t.index < Math.floor(s / 2)) {
2506
+ let x = 0;
2507
+ if (this.m_Book.alignToGround) {
2508
+ u = e[0].size.x;
2509
+ const y = this.m_StackHeight / 2;
2510
+ f = et(i, 0, y) - y, g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2511
+ }
2512
+ _ = F(w, -x, l);
2513
+ } else {
2514
+ let x = 0;
2515
+ if (this.m_Book.alignToGround) {
2516
+ u = e[0].size.x;
2517
+ const y = this.m_StackHeight / 2;
2518
+ f = y - et(i, y, y * 2), g = Math.sqrt(u * u - f * f), x = (Math.asin(g / u) * it - 90) * 2;
2519
+ }
2520
+ _ = F(x, -w, l);
2521
+ }
2522
+ t.transform.position.copy(d), t.transform.quaternion.setFromEuler(
2523
+ new c.Euler(0, 0, _ * tt)
2524
+ );
2525
+ }
2526
+ // ── getStackHeight ────────────────────────────────────────────────────
2527
+ getStackHeight(t) {
2528
+ const e = this.m_Book.papers;
2529
+ let s = 0;
2530
+ const i = e.length;
2531
+ for (let n = t; n < i; n++)
2532
+ s += e[n].thickness;
2533
+ return t < Math.floor(i / 2) && (s += this.m_BindingMidSpace), s;
2534
+ }
2535
+ // ── getStackZ ─────────────────────────────────────────────────────────
2536
+ getStackZ(t) {
2537
+ t = et(t, 0, this.m_StackHeight);
2538
+ const e = t - this.m_StackHeight * 0.5;
2539
+ return Math.asin(e / this.m_BindingRadius) * it;
2540
+ }
2541
+ // ── onLateUpdate ──────────────────────────────────────────────────────
2542
+ onLateUpdate() {
2543
+ const t = this.m_Book.papers;
2544
+ for (const e of t)
2545
+ this.updatePaperPosition(e);
2546
+ this.m_Root.updateMatrixWorld(!0), this.updateBindingVertices();
2547
+ for (const e of t)
2548
+ e.updateMesh();
2549
+ this.updateRootPosition();
2550
+ }
2551
+ // ── updateBindingVertices ─────────────────────────────────────────────
2552
+ updateBindingVertices() {
2553
+ const t = this.m_Book.papers;
2554
+ let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
2555
+ const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
2556
+ for (let m = 0; m < h; m++) {
2557
+ const l = t[m], _ = l.transform, p = l.meshData.pattern, d = l.meshData.baseVertices, u = p.baseXArray, f = p.baseZArray, g = u.length, w = f.length, B = this.m_BindingVertexCount + 1, x = l.thickness, y = p.xNoneSeamIndexes, S = _.position.clone();
2558
+ let v = m, Z = n;
2559
+ m >= Math.floor(h / 2) && (v = h - m - 1, Z *= -1);
2560
+ const O = (o + x) * 0.5 + x * (v - 1), z = _.matrixWorld.clone().invert().multiply(a), N = v / (h / 2);
2561
+ i = this.m_BindingRadius * F(0.45, 0.65, 1 - N);
2562
+ for (let D = 0; D < w; D++) {
2563
+ const C = f[D], V = new c.Vector3(0, 0, S.z + C), U = S.clone();
2564
+ U.z += C;
2565
+ const k = l.getDirection(C).multiplyScalar(i).add(U.clone());
2566
+ if (m === 0 && D === 0) {
2567
+ const A = t[h - 1], H = A.transform.position.clone().clone();
2568
+ H.z += C;
2569
+ const T = A.getDirection(C).multiplyScalar(i).add(H);
2570
+ s = k.clone().sub(T).normalize(), e = new c.Vector3(
2571
+ -s.y,
2572
+ s.x,
2573
+ 0
2574
+ ).normalize().negate();
2575
+ const I = Math.atan2(e.y, e.x) * it;
2576
+ this.stapleMesh.rotation.set(0, 0, I * tt);
2577
+ }
2578
+ v > 0 && V.add(e.clone().multiplyScalar(O));
2579
+ const Q = D * g;
2580
+ d[Q] = V.clone().applyMatrix4(z), V.add(s.clone().multiplyScalar(Z));
2581
+ const G = V.clone().applyMatrix4(z), $ = k.clone().applyMatrix4(z), j = U.clone().applyMatrix4(z);
2582
+ d[Q + y[1]] = G;
2583
+ for (let A = 2; A < B; A++) {
2584
+ const M = jt(1, B, A);
2585
+ d[Q + y[A]] = Xt(
2586
+ G,
2587
+ $,
2588
+ j,
2589
+ M
2590
+ );
2591
+ }
2592
+ }
2593
+ }
2594
+ }
2595
+ // ── Getters for binding parameters (useful for external code) ─────────
2596
+ get bindingRadius() {
2597
+ return this.m_BindingRadius;
2598
+ }
2599
+ get bindingMidSpace() {
2600
+ return this.m_BindingMidSpace;
2601
+ }
2602
+ get stackHeight() {
2603
+ return this.m_StackHeight;
2604
+ }
2605
+ get bindingVertexCount() {
2606
+ return this.m_BindingVertexCount;
2607
+ }
2608
+ get quality() {
2609
+ return this.m_Quality;
2610
+ }
2611
+ get stapleMargin() {
2612
+ return this.m_StapleMargin;
2613
+ }
2614
+ get stapleThickness() {
2615
+ return this.m_StapleThickness;
2616
+ }
2617
+ }
2618
+ class He {
2619
+ constructor(t) {
2620
+ this.mesh = t;
2621
+ }
2622
+ setVisibility(t) {
2623
+ this.mesh.visible = t;
2624
+ }
2625
+ updateCollider() {
2626
+ }
2627
+ get castShadows() {
2628
+ return this.mesh.castShadow;
2629
+ }
2630
+ set castShadows(t) {
2631
+ this.mesh.castShadow = t;
2632
+ }
2633
+ get bounds() {
2634
+ const t = new c.Box3();
2635
+ return this.mesh.geometry && (this.mesh.geometry.computeBoundingBox(), this.mesh.geometry.boundingBox && (t.copy(this.mesh.geometry.boundingBox), t.applyMatrix4(this.mesh.matrixWorld))), t;
2636
+ }
2637
+ get transform() {
2638
+ return this.mesh;
2639
+ }
2640
+ get meshObject() {
2641
+ return this.mesh;
2642
+ }
2643
+ }
2644
+ class Xe extends Pe {
2645
+ constructor() {
2646
+ super(...arguments), this.quality = 3, this.stapleSetup = new ze();
2647
+ }
2648
+ createBound(t, e, s, i) {
2649
+ return new Ae(
2650
+ this.quality,
2651
+ this.stapleSetup,
2652
+ t,
2653
+ e
2654
+ );
2655
+ }
2656
+ }
2657
+ export {
2658
+ xe as AnimationCurve,
2659
+ yt as AutoTurnDirection,
2660
+ pe as AutoTurnMode,
2661
+ rt as AutoTurnSetting,
2662
+ Me as AutoTurnSettingCurveTimeMode,
2663
+ ge as AutoTurnSettingMode,
2664
+ Nt as AutoTurnSettings,
2665
+ Ut as Book,
2666
+ Pe as BookBinding,
2667
+ Le as BookBound,
2668
+ Ue as BookContent,
2669
+ E as BookDirection,
2670
+ Ze as BookHeightException,
2671
+ de as BookRenderer,
2672
+ ut as Cylinder,
2673
+ me as MeshFactory,
2674
+ Ne as PageContent,
2675
+ he as Paper,
2676
+ wt as PaperBorder,
2677
+ Dt as PaperMaterialData,
2678
+ Zt as PaperMeshData,
2679
+ fe as PaperMeshDataPool,
2680
+ Fe as PaperMeshUtility,
2681
+ st as PaperNode,
2682
+ le as PaperNodeMargin,
2683
+ ye as PaperPattern,
2684
+ Pt as PaperSeam,
2685
+ ht as PaperSetup,
2686
+ gt as PaperUVMargin,
2687
+ ue as RendererFactory,
2688
+ Lt as SpritePageContent2,
2689
+ Xe as StapleBookBinding,
2690
+ Ae as StapleBookBound,
2691
+ ze as StapleSetup
2692
+ };