@objectifthunes/three-book 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Book.d.ts +18 -9
- package/dist/Book.d.ts.map +1 -1
- package/dist/index.js +223 -169
- package/package.json +30 -31
package/dist/Book.d.ts
CHANGED
|
@@ -84,6 +84,9 @@ export declare class Book extends THREE.Group {
|
|
|
84
84
|
private m_MaxPaperThickness;
|
|
85
85
|
private m_RendererIds;
|
|
86
86
|
private m_WasIdle;
|
|
87
|
+
private m_ContentDirty;
|
|
88
|
+
private m_StructuralDirty;
|
|
89
|
+
private m_AppliedDirection;
|
|
87
90
|
get minPaperWidth(): number;
|
|
88
91
|
get minPaperHeight(): number;
|
|
89
92
|
get minPaperThickness(): number;
|
|
@@ -93,10 +96,21 @@ export declare class Book extends THREE.Group {
|
|
|
93
96
|
get castShadowsFlag(): boolean;
|
|
94
97
|
/** Alias matching IBookOwner interface expected by Paper.ts */
|
|
95
98
|
get castShadows(): boolean;
|
|
99
|
+
set castShadows(value: boolean);
|
|
96
100
|
get alignToGround(): boolean;
|
|
101
|
+
set alignToGround(value: boolean);
|
|
102
|
+
get hideBinder(): boolean;
|
|
103
|
+
set hideBinder(value: boolean);
|
|
97
104
|
get reduceShadows(): boolean;
|
|
105
|
+
set reduceShadows(value: boolean);
|
|
106
|
+
get reduceSubMeshes(): boolean;
|
|
107
|
+
set reduceSubMeshes(value: boolean);
|
|
108
|
+
get reduceOverdraw(): boolean;
|
|
109
|
+
set reduceOverdraw(value: boolean);
|
|
98
110
|
get coverPaperSetup(): PaperSetup;
|
|
111
|
+
set coverPaperSetup(value: Partial<PaperSetupInit>);
|
|
99
112
|
get pagePaperSetup(): PaperSetup;
|
|
113
|
+
set pagePaperSetup(value: Partial<PaperSetupInit>);
|
|
100
114
|
get bound(): BookBound | null;
|
|
101
115
|
get papers(): Paper[];
|
|
102
116
|
get rendererIds(): number[];
|
|
@@ -117,6 +131,8 @@ export declare class Book extends THREE.Group {
|
|
|
117
131
|
get isAutoTurning(): boolean;
|
|
118
132
|
get hasPendingAutoTurns(): boolean;
|
|
119
133
|
get autoTurningEndTime(): number;
|
|
134
|
+
/** Current open progress (0–1), read from actual paper positions. */
|
|
135
|
+
get openProgress(): number;
|
|
120
136
|
constructor(options?: BookOptions);
|
|
121
137
|
startTurning(ray: THREE.Ray): boolean;
|
|
122
138
|
updateTurning(ray: THREE.Ray): void;
|
|
@@ -142,26 +158,19 @@ export declare class Book extends THREE.Group {
|
|
|
142
158
|
*/
|
|
143
159
|
update(dt: number): void;
|
|
144
160
|
dispose(): void;
|
|
145
|
-
build
|
|
161
|
+
private build;
|
|
146
162
|
clear(): this;
|
|
147
163
|
private hardClear;
|
|
148
164
|
private createPaperMeshDataPool;
|
|
149
165
|
private getFrontPapers;
|
|
150
166
|
getAverageTime(): number;
|
|
151
167
|
bookRaycast(ray: THREE.Ray): BookRaycastHit | null;
|
|
152
|
-
/**
|
|
153
|
-
* Hot-swap page/cover content without rebuilding geometry.
|
|
154
|
-
* Preserves open progress, turning state, and animations.
|
|
155
|
-
* If the new content has a different page/cover structure, falls back
|
|
156
|
-
* to a full rebuild with state preservation.
|
|
157
|
-
*/
|
|
158
|
-
updateContent(newContent: BookContent): void;
|
|
159
168
|
/**
|
|
160
169
|
* Re-apply all page/cover textures from the current BookContent
|
|
161
170
|
* to existing papers without rebuilding geometry.
|
|
162
171
|
* Returns false if a structural rebuild is needed (page count changed).
|
|
163
172
|
*/
|
|
164
|
-
refreshContent
|
|
173
|
+
private refreshContent;
|
|
165
174
|
private getCurrentOpenProgress;
|
|
166
175
|
private updateLivePages;
|
|
167
176
|
}
|
package/dist/Book.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Book.d.ts","sourceRoot":"","sources":["../src/Book.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B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B,OAAO,CAAC,sBAAsB;IAoB9B,OAAO,CAAC,eAAe;CA2BxB"}
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function ne(r) {
|
|
|
108
108
|
function re(r) {
|
|
109
109
|
return new c.Vector3(r.x, r.z, 0);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function vt(r, t, e) {
|
|
112
112
|
const s = t * t - 4 * r * e;
|
|
113
113
|
if (s < 0)
|
|
114
114
|
return { rootCount: 0, root0: 0, root1: 0 };
|
|
@@ -140,7 +140,7 @@ function ae(r, t, e, s) {
|
|
|
140
140
|
const i = e.x, n = e.y, o = r.x, a = r.y, h = t.x, m = t.y, l = s.x, d = s.y, g = 1 / (l * l), _ = 1 / (d * d);
|
|
141
141
|
if (Math.abs(o - h) < 1e-5) {
|
|
142
142
|
if (o >= i - l && o <= i + l) {
|
|
143
|
-
const u =
|
|
143
|
+
const u = vt(
|
|
144
144
|
_,
|
|
145
145
|
-2 * _ * n,
|
|
146
146
|
g * (o * o - 2 * i * o + i * i) + _ * n * n - 1
|
|
@@ -153,7 +153,7 @@ function ae(r, t, e, s) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
} else {
|
|
156
|
-
const u = (m - a) / (h - o), f = a - u * o, p = f - n, P =
|
|
156
|
+
const u = (m - a) / (h - o), f = a - u * o, p = f - n, P = vt(
|
|
157
157
|
g + _ * u * u,
|
|
158
158
|
2 * p * u * _ - 2 * i * g,
|
|
159
159
|
i * i * g + p * p * _ - 1
|
|
@@ -182,19 +182,19 @@ const Bt = Math.PI / 180, Rt = 180 / Math.PI, ce = 1192093e-13;
|
|
|
182
182
|
function dt(r) {
|
|
183
183
|
return r < 0 ? 0 : r > 1 ? 1 : r;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function Dt(r, t, e) {
|
|
186
186
|
return r < t ? t : r > e ? e : r;
|
|
187
187
|
}
|
|
188
188
|
function mt(r, t, e) {
|
|
189
189
|
return r !== t ? dt((e - r) / (t - r)) : 0;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function It(r, t, e) {
|
|
192
192
|
return r + (t - r) * e;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function zt(r, t, e) {
|
|
195
195
|
return r + (t - r) * e;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Vt(r, t, e) {
|
|
198
198
|
return e = dt((e - r) / (t - r)), e * e * (3 - 2 * e);
|
|
199
199
|
}
|
|
200
200
|
class me {
|
|
@@ -351,7 +351,7 @@ class me {
|
|
|
351
351
|
const t = new c.Vector3(0, 0, 0);
|
|
352
352
|
for (const e of this.m_HandleVelocities)
|
|
353
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 =
|
|
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 = It(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
355
|
}
|
|
356
356
|
/**
|
|
357
357
|
* Called each frame while the user is dragging.
|
|
@@ -376,7 +376,7 @@ class me {
|
|
|
376
376
|
let e = !1;
|
|
377
377
|
if (this.m_IsAutoTurning) {
|
|
378
378
|
let n = dt(this.m_FallTime / this.m_FallDuration);
|
|
379
|
-
n =
|
|
379
|
+
n = Vt(0, 1, n), n = Vt(0, 1, n), this.m_CurrentHandle.lerpVectors(
|
|
380
380
|
this.m_StartHandle,
|
|
381
381
|
this.m_EndHandle,
|
|
382
382
|
this.m_IsFallingLeft ? n : 1 - n
|
|
@@ -532,7 +532,7 @@ class me {
|
|
|
532
532
|
const t = this.findTime(new c.Vector3(this.m_Size.x, 0, 0)), e = this.findTime(
|
|
533
533
|
new c.Vector3(this.m_Size.x, 0, this.m_Size.y)
|
|
534
534
|
);
|
|
535
|
-
this.m_XTime =
|
|
535
|
+
this.m_XTime = It(
|
|
536
536
|
Math.min(t, e),
|
|
537
537
|
Math.max(t, e),
|
|
538
538
|
0.9
|
|
@@ -558,7 +558,7 @@ class me {
|
|
|
558
558
|
0,
|
|
559
559
|
h + (s.z - h) * (a / n)
|
|
560
560
|
), d = new c.Vector2(i, o), g = new c.Vector2(n, a);
|
|
561
|
-
t.x =
|
|
561
|
+
t.x = Dt(t.x, -this.m_Size.x, this.m_Size.x);
|
|
562
562
|
const _ = re(t), u = kt(
|
|
563
563
|
new c.Vector2(_.x, _.y),
|
|
564
564
|
m,
|
|
@@ -608,8 +608,8 @@ class me {
|
|
|
608
608
|
/* Highpoly */
|
|
609
609
|
), (m = this.m_Prev) == null || m.trySwitchMeshData(1), (l = this.m_Next) == null || l.trySwitchMeshData(1), this.m_IsFallingLeft = t === 1, this.m_IsTurning = !1, this.m_IsFalling = !0, this.m_FallTime = 0, this.m_FallDuration = i;
|
|
610
610
|
const n = this.m_Size.x, o = this.m_Size.y;
|
|
611
|
-
e =
|
|
612
|
-
const a =
|
|
611
|
+
e = Dt(e, -0.99, 0.99);
|
|
612
|
+
const a = zt(0.5, 1, e), h = zt(0.5, 0, e);
|
|
613
613
|
this.m_StartHandle.set(n, 0, o * a), this.m_EndHandle.set(-n, 0, o * h), this.m_IsAutoTurning = !0;
|
|
614
614
|
}
|
|
615
615
|
// ---- Public getter for the cylinder (used by BookBound etc.) ----
|
|
@@ -758,7 +758,7 @@ const N = class N {
|
|
|
758
758
|
}
|
|
759
759
|
};
|
|
760
760
|
N.kMinSize = 1, N.kMinThickness = 1e-4, N.kMinQuality = 1, N.kMaxQuality = 5;
|
|
761
|
-
let
|
|
761
|
+
let nt = N;
|
|
762
762
|
class At {
|
|
763
763
|
constructor(t) {
|
|
764
764
|
this.m_Texture = null, this.m_TextureST = new c.Vector4(1, 1, 0, 0);
|
|
@@ -869,12 +869,12 @@ class Pt {
|
|
|
869
869
|
return t.active = this.active, t;
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
|
-
class
|
|
872
|
+
class St {
|
|
873
873
|
constructor(t, e, s, i, n, o = !0) {
|
|
874
874
|
this.startX = t, this.startZ = e, this.endX = s, this.endZ = i, this.flip = n, this.left = o;
|
|
875
875
|
}
|
|
876
876
|
clone() {
|
|
877
|
-
return new
|
|
877
|
+
return new St(
|
|
878
878
|
this.startX,
|
|
879
879
|
this.startZ,
|
|
880
880
|
this.endX,
|
|
@@ -1154,8 +1154,8 @@ class Zt {
|
|
|
1154
1154
|
for (let u = 0; u < o - 1; u++) {
|
|
1155
1155
|
const f = u + 1;
|
|
1156
1156
|
for (let p = 0; p < n - 1; p++) {
|
|
1157
|
-
const P = p + 1, B = u * n + p, M = u * n + P, w = f * n + p,
|
|
1158
|
-
Ht(k, Z, O, h), Ht(
|
|
1157
|
+
const P = p + 1, B = u * n + p, M = u * n + P, w = f * n + p, T = f * n + P, k = t[B], O = t[M], Z = t[w], z = t[T];
|
|
1158
|
+
Ht(k, Z, O, h), Ht(z, O, Z, m), l.addVectors(h, m), s[B].add(l), s[M].add(l), s[w].add(l), s[T].add(l);
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
1161
|
for (let u = 0; u < a; u++)
|
|
@@ -1386,16 +1386,16 @@ class ye {
|
|
|
1386
1386
|
return e[s - 1].value;
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
|
-
function
|
|
1389
|
+
function rt(r, t, e) {
|
|
1390
1390
|
return Math.max(t, Math.min(e, r));
|
|
1391
1391
|
}
|
|
1392
1392
|
function Pe(r, t, e) {
|
|
1393
|
-
return r === t ? 0 :
|
|
1393
|
+
return r === t ? 0 : rt((e - r) / (t - r), 0, 1);
|
|
1394
1394
|
}
|
|
1395
1395
|
function Ut(r, t) {
|
|
1396
1396
|
return r + Math.random() * (t - r);
|
|
1397
1397
|
}
|
|
1398
|
-
class
|
|
1398
|
+
class ot {
|
|
1399
1399
|
constructor(t, e) {
|
|
1400
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
1401
|
}
|
|
@@ -1450,12 +1450,12 @@ class rt {
|
|
|
1450
1450
|
}
|
|
1451
1451
|
/** A value based on a curve. */
|
|
1452
1452
|
static fromCurve(t, e) {
|
|
1453
|
-
const s = new
|
|
1453
|
+
const s = new ot();
|
|
1454
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
1455
|
}
|
|
1456
1456
|
/** A random value generated between two curves. */
|
|
1457
1457
|
static fromCurveRange(t, e, s) {
|
|
1458
|
-
const i = new
|
|
1458
|
+
const i = new ot();
|
|
1459
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
1460
|
}
|
|
1461
1461
|
// ── Internal API ────────────────────────────────────────────────────────
|
|
@@ -1476,7 +1476,7 @@ class rt {
|
|
|
1476
1476
|
}
|
|
1477
1477
|
/** @internal */
|
|
1478
1478
|
clampValues(t, e) {
|
|
1479
|
-
return this.m_Constant =
|
|
1479
|
+
return this.m_Constant = rt(this.m_Constant, t, e), this.m_ConstantMin = rt(this.m_ConstantMin, t, e), this.m_ConstantMax = rt(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
1480
|
}
|
|
1481
1481
|
clampCurve(t, e, s) {
|
|
1482
1482
|
if (this.m_Curve === null || t === null) return null;
|
|
@@ -1488,19 +1488,19 @@ class rt {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
for (let h = 0; h < n; h++) {
|
|
1490
1490
|
let m = i[h].time, l = i[h].value;
|
|
1491
|
-
m = Pe(o, a, m), l =
|
|
1491
|
+
m = Pe(o, a, m), l = rt(l, e, s), i[h].time = m, i[h].value = l;
|
|
1492
1492
|
}
|
|
1493
1493
|
return new ye(i);
|
|
1494
1494
|
}
|
|
1495
1495
|
// ── Value-type clone ────────────────────────────────────────────────────
|
|
1496
1496
|
clone() {
|
|
1497
|
-
const t = new
|
|
1497
|
+
const t = new ot();
|
|
1498
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
1499
|
}
|
|
1500
1500
|
}
|
|
1501
1501
|
const R = class R {
|
|
1502
1502
|
constructor() {
|
|
1503
|
-
this.m_Mode = 0, this.m_Twist = new
|
|
1503
|
+
this.m_Mode = 0, this.m_Twist = new ot(), this.m_Bend = new ot(1), this.m_Duration = new ot(0.5);
|
|
1504
1504
|
}
|
|
1505
1505
|
// ── Properties ──────────────────────────────────────────────────────────
|
|
1506
1506
|
get mode() {
|
|
@@ -1543,7 +1543,7 @@ const R = class R {
|
|
|
1543
1543
|
}
|
|
1544
1544
|
/** @internal */
|
|
1545
1545
|
getBendValue(t, e) {
|
|
1546
|
-
return
|
|
1546
|
+
return rt(
|
|
1547
1547
|
this.m_Bend.getValue(t, e),
|
|
1548
1548
|
R.kMinBend,
|
|
1549
1549
|
R.kMaxBend
|
|
@@ -1551,7 +1551,7 @@ const R = class R {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
/** @internal */
|
|
1553
1553
|
getDurationValue(t, e) {
|
|
1554
|
-
return
|
|
1554
|
+
return rt(
|
|
1555
1555
|
this.m_Duration.getValue(t, e),
|
|
1556
1556
|
R.kMinDuration,
|
|
1557
1557
|
R.kMaxDuration
|
|
@@ -1559,7 +1559,7 @@ const R = class R {
|
|
|
1559
1559
|
}
|
|
1560
1560
|
/** @internal */
|
|
1561
1561
|
getTwistValue(t, e) {
|
|
1562
|
-
return
|
|
1562
|
+
return rt(
|
|
1563
1563
|
this.m_Twist.getValue(t, e),
|
|
1564
1564
|
R.kMinTwist,
|
|
1565
1565
|
R.kMaxTwist
|
|
@@ -1574,39 +1574,39 @@ let Lt = R, Xe = class extends Error {
|
|
|
1574
1574
|
);
|
|
1575
1575
|
}
|
|
1576
1576
|
};
|
|
1577
|
-
const
|
|
1577
|
+
const at = class at extends c.Group {
|
|
1578
1578
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
1579
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
|
|
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 nt({
|
|
1581
1581
|
color: new c.Color(1, 0, 0),
|
|
1582
1582
|
width: 2.1,
|
|
1583
1583
|
height: 3.1,
|
|
1584
1584
|
thickness: 0.04,
|
|
1585
1585
|
stiffness: 0.5
|
|
1586
|
-
}), this.m_PagePaperSetup = new
|
|
1586
|
+
}), this.m_PagePaperSetup = new nt({
|
|
1587
1587
|
color: new c.Color(1, 1, 1),
|
|
1588
1588
|
width: 2,
|
|
1589
1589
|
height: 3,
|
|
1590
1590
|
thickness: 0.02,
|
|
1591
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 = X.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, t && (t.content && (this.m_Content = t.content), t.binding && (this.m_Binding = t.binding), t.initialOpenProgress !== void 0 && (this.m_InitialOpenProgress = c.MathUtils.clamp(t.initialOpenProgress, 0, 1)), t.buildOnAwake !== void 0 && (this.m_BuildOnAwake = t.buildOnAwake), t.castShadows !== void 0 && (this.m_CastShadows = t.castShadows), t.alignToGround !== void 0 && (this.m_AlignToGround = t.alignToGround), t.hideBinder !== void 0 && (this.m_HideBinder = t.hideBinder), t.createColliders !== void 0 && (this.m_CreateColliders = t.createColliders), t.reduceShadows !== void 0 && (this.m_ReduceShadows = t.reduceShadows), t.reduceSubMeshes !== void 0 && (this.m_ReduceSubMeshes = t.reduceSubMeshes), t.reduceOverdraw !== void 0 && (this.m_ReduceOverdraw = t.reduceOverdraw), t.coverPaperSetup && (this.m_CoverPaperSetup = new
|
|
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 = X.LeftToRight, this.m_AutoTurnQueue = [], this.m_AutoTurnTimer = 0, this.m_AutoTurningEndTime = -1, this.m_CurrentTime = 0, this.m_CoverPaperCount = 0, this.m_PagePaperCount = 0, this.m_TotalThickness = 0, this.m_MinPaperWidth = 0, this.m_MinPaperHeight = 0, this.m_MinPaperThickness = 0, this.m_MaxPaperThickness = 0, this.m_RendererIds = [], this.m_WasIdle = !1, this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = void 0, 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 nt({
|
|
1593
1593
|
color: t.coverPaperSetup.color ?? new c.Color(1, 0, 0),
|
|
1594
1594
|
width: t.coverPaperSetup.width ?? 2.1,
|
|
1595
1595
|
height: t.coverPaperSetup.height ?? 3.1,
|
|
1596
1596
|
thickness: t.coverPaperSetup.thickness ?? 0.04,
|
|
1597
1597
|
stiffness: t.coverPaperSetup.stiffness ?? 0.5,
|
|
1598
1598
|
material: t.coverPaperSetup.material ?? null
|
|
1599
|
-
})), t.pagePaperSetup && (this.m_PagePaperSetup = new
|
|
1599
|
+
})), t.pagePaperSetup && (this.m_PagePaperSetup = new nt({
|
|
1600
1600
|
color: t.pagePaperSetup.color ?? new c.Color(1, 1, 1),
|
|
1601
1601
|
width: t.pagePaperSetup.width ?? 2,
|
|
1602
1602
|
height: t.pagePaperSetup.height ?? 3,
|
|
1603
1603
|
thickness: t.pagePaperSetup.thickness ?? 0.02,
|
|
1604
1604
|
stiffness: t.pagePaperSetup.stiffness ?? 0.2,
|
|
1605
1605
|
material: t.pagePaperSetup.material ?? null
|
|
1606
|
-
}))),
|
|
1606
|
+
}))), at.s_Instances.add(this);
|
|
1607
1607
|
}
|
|
1608
1608
|
static get instances() {
|
|
1609
|
-
return [...
|
|
1609
|
+
return [...at.s_Instances];
|
|
1610
1610
|
}
|
|
1611
1611
|
// ── Internal accessors ─────────────────────────────────────────────────
|
|
1612
1612
|
get minPaperWidth() {
|
|
@@ -1634,18 +1634,67 @@ const ot = class ot extends c.Group {
|
|
|
1634
1634
|
get castShadows() {
|
|
1635
1635
|
return this.m_CastShadows;
|
|
1636
1636
|
}
|
|
1637
|
+
set castShadows(t) {
|
|
1638
|
+
this.m_CastShadows !== t && (this.m_CastShadows = t, this.m_StructuralDirty = !0);
|
|
1639
|
+
}
|
|
1637
1640
|
get alignToGround() {
|
|
1638
1641
|
return this.m_AlignToGround;
|
|
1639
1642
|
}
|
|
1643
|
+
set alignToGround(t) {
|
|
1644
|
+
this.m_AlignToGround !== t && (this.m_AlignToGround = t, this.m_StructuralDirty = !0);
|
|
1645
|
+
}
|
|
1646
|
+
get hideBinder() {
|
|
1647
|
+
return this.m_HideBinder;
|
|
1648
|
+
}
|
|
1649
|
+
set hideBinder(t) {
|
|
1650
|
+
this.m_HideBinder !== t && (this.m_HideBinder = t, this.m_StructuralDirty = !0);
|
|
1651
|
+
}
|
|
1640
1652
|
get reduceShadows() {
|
|
1641
1653
|
return this.m_ReduceShadows;
|
|
1642
1654
|
}
|
|
1655
|
+
set reduceShadows(t) {
|
|
1656
|
+
this.m_ReduceShadows !== t && (this.m_ReduceShadows = t, this.m_StructuralDirty = !0);
|
|
1657
|
+
}
|
|
1658
|
+
get reduceSubMeshes() {
|
|
1659
|
+
return this.m_ReduceSubMeshes;
|
|
1660
|
+
}
|
|
1661
|
+
set reduceSubMeshes(t) {
|
|
1662
|
+
this.m_ReduceSubMeshes !== t && (this.m_ReduceSubMeshes = t, this.m_StructuralDirty = !0);
|
|
1663
|
+
}
|
|
1664
|
+
get reduceOverdraw() {
|
|
1665
|
+
return this.m_ReduceOverdraw;
|
|
1666
|
+
}
|
|
1667
|
+
set reduceOverdraw(t) {
|
|
1668
|
+
this.m_ReduceOverdraw !== t && (this.m_ReduceOverdraw = t, this.m_StructuralDirty = !0);
|
|
1669
|
+
}
|
|
1643
1670
|
get coverPaperSetup() {
|
|
1644
1671
|
return this.m_CoverPaperSetup;
|
|
1645
1672
|
}
|
|
1673
|
+
set coverPaperSetup(t) {
|
|
1674
|
+
const e = this.m_CoverPaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, o = t.stiffness ?? e.stiffness;
|
|
1675
|
+
e.width === s && e.height === i && e.thickness === n && e.stiffness === o || (this.m_CoverPaperSetup = new nt({
|
|
1676
|
+
color: t.color ?? e.color,
|
|
1677
|
+
width: s,
|
|
1678
|
+
height: i,
|
|
1679
|
+
thickness: n,
|
|
1680
|
+
stiffness: o,
|
|
1681
|
+
material: t.material !== void 0 ? t.material : e.material
|
|
1682
|
+
}), this.m_StructuralDirty = !0);
|
|
1683
|
+
}
|
|
1646
1684
|
get pagePaperSetup() {
|
|
1647
1685
|
return this.m_PagePaperSetup;
|
|
1648
1686
|
}
|
|
1687
|
+
set pagePaperSetup(t) {
|
|
1688
|
+
const e = this.m_PagePaperSetup, s = t.width ?? e.width, i = t.height ?? e.height, n = t.thickness ?? e.thickness, o = t.stiffness ?? e.stiffness;
|
|
1689
|
+
e.width === s && e.height === i && e.thickness === n && e.stiffness === o || (this.m_PagePaperSetup = new nt({
|
|
1690
|
+
color: t.color ?? e.color,
|
|
1691
|
+
width: s,
|
|
1692
|
+
height: i,
|
|
1693
|
+
thickness: n,
|
|
1694
|
+
stiffness: o,
|
|
1695
|
+
material: t.material !== void 0 ? t.material : e.material
|
|
1696
|
+
}), this.m_StructuralDirty = !0);
|
|
1697
|
+
}
|
|
1649
1698
|
get bound() {
|
|
1650
1699
|
return this.m_Bound;
|
|
1651
1700
|
}
|
|
@@ -1663,13 +1712,13 @@ const ot = class ot extends c.Group {
|
|
|
1663
1712
|
return this.m_Binding;
|
|
1664
1713
|
}
|
|
1665
1714
|
set binding(t) {
|
|
1666
|
-
this.m_Binding !== t && (this.m_Binding = t, this.
|
|
1715
|
+
this.m_Binding !== t && (this.m_Binding = t, this.m_StructuralDirty = !0);
|
|
1667
1716
|
}
|
|
1668
1717
|
get content() {
|
|
1669
1718
|
return this.m_Content;
|
|
1670
1719
|
}
|
|
1671
1720
|
set content(t) {
|
|
1672
|
-
this.m_Content !== t && (this.m_Content = t, this.
|
|
1721
|
+
this.m_Content !== t && (this.m_Content = t, this.m_ContentDirty = !0);
|
|
1673
1722
|
}
|
|
1674
1723
|
get initialOpenProgress() {
|
|
1675
1724
|
return this.m_InitialOpenProgress;
|
|
@@ -1709,6 +1758,10 @@ const ot = class ot extends c.Group {
|
|
|
1709
1758
|
get autoTurningEndTime() {
|
|
1710
1759
|
return this.m_AutoTurningEndTime;
|
|
1711
1760
|
}
|
|
1761
|
+
/** Current open progress (0–1), read from actual paper positions. */
|
|
1762
|
+
get openProgress() {
|
|
1763
|
+
return this.getCurrentOpenProgress();
|
|
1764
|
+
}
|
|
1712
1765
|
// ── Public API (methods) ───────────────────────────────────────────────
|
|
1713
1766
|
startTurning(t) {
|
|
1714
1767
|
if (!this.m_IsBuilt || this.isTurning) return !1;
|
|
@@ -1765,7 +1818,7 @@ const ot = class ot extends c.Group {
|
|
|
1765
1818
|
startAutoTurning(t, e, s = 1, i = 0) {
|
|
1766
1819
|
if (!this.m_IsBuilt) return !1;
|
|
1767
1820
|
this.cancelPendingAutoTurns();
|
|
1768
|
-
const n = typeof i == "number" ? new
|
|
1821
|
+
const n = typeof i == "number" ? new ot(i) : i;
|
|
1769
1822
|
if (s = Math.min(s, this.getMaxAutoTurnCount(t)), s === 0) return !1;
|
|
1770
1823
|
for (let o = 0; o < s && this.canAutoTurn(t); o++) {
|
|
1771
1824
|
const a = o / (s - 1 || 1), h = this.getAutoTurnPaperIndexTime(t), m = o > 0 ? n.getValue(h, a) : 0, l = e.getModeValue(), d = e.getTwistValue(h, a), g = e.getBendValue(h, a), _ = e.getDurationValue(h, a);
|
|
@@ -1822,22 +1875,38 @@ const ot = class ot extends c.Group {
|
|
|
1822
1875
|
* Equivalent to Unity's Start/Awake.
|
|
1823
1876
|
*/
|
|
1824
1877
|
init() {
|
|
1825
|
-
|
|
1878
|
+
var t;
|
|
1879
|
+
at.s_Instances.add(this), this.hardClear(), this.m_BuildOnAwake && (this.build(), this.m_ContentDirty = !1, this.m_StructuralDirty = !1, this.m_AppliedDirection = (t = this.m_Content) == null ? void 0 : t.direction);
|
|
1826
1880
|
}
|
|
1827
1881
|
/**
|
|
1828
1882
|
* Call every frame with delta time.
|
|
1829
1883
|
* Equivalent to Unity's LateUpdate.
|
|
1830
1884
|
*/
|
|
1831
1885
|
update(t) {
|
|
1832
|
-
|
|
1886
|
+
var e;
|
|
1887
|
+
if (this.m_CurrentTime += t, this.m_IsBuilt) {
|
|
1888
|
+
if (this.m_StructuralDirty) {
|
|
1889
|
+
this.m_StructuralDirty = !1, this.m_ContentDirty = !1;
|
|
1890
|
+
const s = this.getCurrentOpenProgress();
|
|
1891
|
+
this.build(), this.setOpenProgress(s), this.m_AppliedDirection = (e = this.m_Content) == null ? void 0 : e.direction;
|
|
1892
|
+
} else if (this.m_ContentDirty && (this.m_ContentDirty = !1, this.m_Content)) {
|
|
1893
|
+
this.m_Content.init(this);
|
|
1894
|
+
const s = this.m_Content.direction !== this.m_AppliedDirection;
|
|
1895
|
+
if (this.m_AppliedDirection = this.m_Content.direction, s || !this.refreshContent()) {
|
|
1896
|
+
const i = this.getCurrentOpenProgress();
|
|
1897
|
+
this.build(), this.setOpenProgress(i);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
if (this.m_IsBuilt && this.m_Papers.length !== 0 && this.m_Bound !== null && (this.processAutoTurnQueue(t), !(this.m_WasIdle && this.isIdle))) {
|
|
1833
1902
|
this.m_WasIdle = this.isIdle;
|
|
1834
|
-
for (const
|
|
1835
|
-
|
|
1903
|
+
for (const s of this.m_Papers)
|
|
1904
|
+
s.isFalling && s.updateFalling(t);
|
|
1836
1905
|
this.updateLivePages(), this.m_Bound.onLateUpdate();
|
|
1837
1906
|
}
|
|
1838
1907
|
}
|
|
1839
1908
|
dispose() {
|
|
1840
|
-
|
|
1909
|
+
at.s_Instances.delete(this), this.hardClear();
|
|
1841
1910
|
}
|
|
1842
1911
|
// ── Build ─────────────────────────────────────────────────────────────
|
|
1843
1912
|
build() {
|
|
@@ -1857,8 +1926,8 @@ const ot = class ot extends c.Group {
|
|
|
1857
1926
|
let m = 0, l = 0, d = 0;
|
|
1858
1927
|
this.m_Papers = new Array(a);
|
|
1859
1928
|
for (let C = 0; C < a; C++) {
|
|
1860
|
-
const
|
|
1861
|
-
|
|
1929
|
+
const D = this.m_HasCover && (C < h || C >= a - h), L = this.m_RendererFactory.get("Paper"), v = this.m_Papers[C] = new me(D, C, this, L);
|
|
1930
|
+
v.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, o)) && (v.transform.scale.set(-1, 1, 1), v.setTime(1)), D ? (v.setContentData(i[l++], i[l++], C > h), v.setMaterialData(e), v.setPaperSetup(this.m_CoverPaperSetup)) : (v.setContentData(n[m++], n[m++]), v.setMaterialData(s), v.setPaperSetup(this.m_PagePaperSetup)), d += v.thickness;
|
|
1862
1931
|
}
|
|
1863
1932
|
this.m_TotalThickness = d;
|
|
1864
1933
|
const g = this.m_Papers[0].thickness, _ = this.m_Papers[Math.floor(a / 2)].thickness;
|
|
@@ -1872,12 +1941,12 @@ const ot = class ot extends c.Group {
|
|
|
1872
1941
|
this.m_RendererFactory,
|
|
1873
1942
|
this.m_MeshFactory
|
|
1874
1943
|
), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
|
|
1875
|
-
const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M),
|
|
1944
|
+
const B = this.m_ReduceOverdraw && n.length > 0, M = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M), T = B ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, M, !0) : null, k = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), O = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, U = z + 1, V = this.m_Bound.constructor.name.includes("Staple");
|
|
1876
1945
|
for (let C = 0; C < a; C++) {
|
|
1877
|
-
const
|
|
1878
|
-
C !== 0 && (
|
|
1946
|
+
const D = this.m_Papers[C];
|
|
1947
|
+
C !== 0 && (D.prev = this.m_Papers[C - 1]), C !== a - 1 && (D.next = this.m_Papers[C + 1]), D.noHole = V && (C === z || C === U), D.isCover ? D.setMeshData(O.get(), null, Z) : D.setMeshData(
|
|
1879
1948
|
w.get(),
|
|
1880
|
-
(
|
|
1949
|
+
(T == null ? void 0 : T.get()) ?? null,
|
|
1881
1950
|
k
|
|
1882
1951
|
);
|
|
1883
1952
|
}
|
|
@@ -1935,21 +2004,6 @@ const ot = class ot extends c.Group {
|
|
|
1935
2004
|
}
|
|
1936
2005
|
return null;
|
|
1937
2006
|
}
|
|
1938
|
-
// ── Real-time content updates ──────────────────────────────────────
|
|
1939
|
-
/**
|
|
1940
|
-
* Hot-swap page/cover content without rebuilding geometry.
|
|
1941
|
-
* Preserves open progress, turning state, and animations.
|
|
1942
|
-
* If the new content has a different page/cover structure, falls back
|
|
1943
|
-
* to a full rebuild with state preservation.
|
|
1944
|
-
*/
|
|
1945
|
-
updateContent(t) {
|
|
1946
|
-
if (!this.m_IsBuilt) {
|
|
1947
|
-
this.m_Content = t;
|
|
1948
|
-
return;
|
|
1949
|
-
}
|
|
1950
|
-
const e = this.getCurrentOpenProgress();
|
|
1951
|
-
this.m_Content = t, this.m_Content.init(this), this.refreshContent() || (this.build(), this.setOpenProgress(e));
|
|
1952
|
-
}
|
|
1953
2007
|
/**
|
|
1954
2008
|
* Re-apply all page/cover textures from the current BookContent
|
|
1955
2009
|
* to existing papers without rebuilding geometry.
|
|
@@ -2000,14 +2054,14 @@ const ot = class ot extends c.Group {
|
|
|
2000
2054
|
s.frontContent.setActive(t.has(s.frontContent)), s.backContent.setActive(t.has(s.backContent));
|
|
2001
2055
|
}
|
|
2002
2056
|
};
|
|
2003
|
-
|
|
2004
|
-
let yt =
|
|
2005
|
-
class
|
|
2057
|
+
at.s_Instances = /* @__PURE__ */ new Set();
|
|
2058
|
+
let yt = at;
|
|
2059
|
+
class Se {
|
|
2006
2060
|
constructor() {
|
|
2007
2061
|
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;
|
|
2008
2062
|
}
|
|
2009
2063
|
}
|
|
2010
|
-
class
|
|
2064
|
+
class Ge {
|
|
2011
2065
|
constructor() {
|
|
2012
2066
|
this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
|
|
2013
2067
|
}
|
|
@@ -2060,7 +2114,7 @@ class Nt {
|
|
|
2060
2114
|
setActive(t) {
|
|
2061
2115
|
}
|
|
2062
2116
|
}
|
|
2063
|
-
class
|
|
2117
|
+
class je {
|
|
2064
2118
|
constructor() {
|
|
2065
2119
|
this.m_Direction = X.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null;
|
|
2066
2120
|
}
|
|
@@ -2188,7 +2242,7 @@ class qe {
|
|
|
2188
2242
|
return this.m_Mouse.x = (t.clientX - e.left) / e.width * 2 - 1, this.m_Mouse.y = -((t.clientY - e.top) / e.height) * 2 + 1, this.m_Raycaster.setFromCamera(this.m_Mouse, this.m_Camera), this.m_Raycaster.ray;
|
|
2189
2243
|
}
|
|
2190
2244
|
}
|
|
2191
|
-
class
|
|
2245
|
+
class Te {
|
|
2192
2246
|
}
|
|
2193
2247
|
class Qe {
|
|
2194
2248
|
constructor(t, e) {
|
|
@@ -2206,10 +2260,10 @@ function Et(r, t, e, s) {
|
|
|
2206
2260
|
function Xt(r, t) {
|
|
2207
2261
|
return r++, r === t ? 0 : r;
|
|
2208
2262
|
}
|
|
2209
|
-
function
|
|
2263
|
+
function ve(r, t) {
|
|
2210
2264
|
return r === 0 ? t - 1 : r - 1;
|
|
2211
2265
|
}
|
|
2212
|
-
const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4,
|
|
2266
|
+
const ke = 0.01, be = 0.1, Be = 0.04, Re = 0.4, De = 2, Ie = 10, ze = 0, Ve = 5;
|
|
2213
2267
|
function et(r, t, e) {
|
|
2214
2268
|
return Math.max(t, Math.min(e, r));
|
|
2215
2269
|
}
|
|
@@ -2273,13 +2327,13 @@ class He {
|
|
|
2273
2327
|
return this._count;
|
|
2274
2328
|
}
|
|
2275
2329
|
set count(t) {
|
|
2276
|
-
this._count = et(t,
|
|
2330
|
+
this._count = et(t, De, Ie);
|
|
2277
2331
|
}
|
|
2278
2332
|
get quality() {
|
|
2279
2333
|
return this._quality;
|
|
2280
2334
|
}
|
|
2281
2335
|
set quality(t) {
|
|
2282
|
-
this._quality = et(t,
|
|
2336
|
+
this._quality = et(t, ze, Ve);
|
|
2283
2337
|
}
|
|
2284
2338
|
}
|
|
2285
2339
|
class Fe extends Error {
|
|
@@ -2336,76 +2390,76 @@ class Oe {
|
|
|
2336
2390
|
B += this.m_Book.totalThickness / 2, B += _;
|
|
2337
2391
|
const M = -(this.m_Book.papers[0].thickness / 2 + _), w = [];
|
|
2338
2392
|
{
|
|
2339
|
-
for (let
|
|
2340
|
-
const E =
|
|
2393
|
+
for (let I = 0; I < d; I++) {
|
|
2394
|
+
const E = I / (d - 1), q = F(-90, -180, E) * tt, y = new c.Vector3(
|
|
2341
2395
|
p * Math.sin(q),
|
|
2342
2396
|
0,
|
|
2343
2397
|
p * Math.cos(q)
|
|
2344
2398
|
);
|
|
2345
2399
|
y.x += p, y.z += p, y.x += M, w.push(y);
|
|
2346
2400
|
}
|
|
2347
|
-
const x = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0),
|
|
2348
|
-
for (let
|
|
2349
|
-
const E =
|
|
2350
|
-
|
|
2401
|
+
const x = new c.Vector3(B, 0, 0), H = new c.Vector3(B + u * 0.75, 0, 0), S = new c.Vector3(B - _ * 0.5, 0, P);
|
|
2402
|
+
for (let I = 0; I < g; I++) {
|
|
2403
|
+
const E = I / (g - 1), j = Et(x, H, S, E);
|
|
2404
|
+
j.x += M, w.push(j);
|
|
2351
2405
|
}
|
|
2352
2406
|
w.reverse();
|
|
2353
2407
|
}
|
|
2354
|
-
const
|
|
2408
|
+
const T = new Array(l);
|
|
2355
2409
|
for (let x = 0; x < l; x++) {
|
|
2356
|
-
const
|
|
2357
|
-
|
|
2410
|
+
const S = (90 - x * (360 / l)) * tt;
|
|
2411
|
+
T[x] = new c.Vector3(Math.cos(S), Math.sin(S), 0), T[x].x *= 0.75;
|
|
2358
2412
|
}
|
|
2359
|
-
const k = w.length, O = k * l, Z = new Array(O * 2),
|
|
2413
|
+
const k = w.length, O = k * l, Z = new Array(O * 2), z = new Array(O * 2), U = new Array(
|
|
2360
2414
|
(O * 2 - 1) * l * 2 * 3
|
|
2361
2415
|
);
|
|
2362
2416
|
for (let x = 0; x < O * 2; x++)
|
|
2363
|
-
Z[x] = new c.Vector3(),
|
|
2364
|
-
let
|
|
2417
|
+
Z[x] = new c.Vector3(), z[x] = new c.Vector3();
|
|
2418
|
+
let V = 0;
|
|
2365
2419
|
for (let x = 0; x < k; x++) {
|
|
2366
|
-
const H = w[
|
|
2420
|
+
const H = w[ve(x, k)], S = w[x], I = w[Xt(x, k)];
|
|
2367
2421
|
let E;
|
|
2368
2422
|
if (x === 0)
|
|
2369
2423
|
E = new c.Vector3(1, 0, -2).normalize();
|
|
2370
2424
|
else if (x === k - 1)
|
|
2371
2425
|
E = new c.Vector3(0, 0, 1);
|
|
2372
2426
|
else {
|
|
2373
|
-
const K =
|
|
2427
|
+
const K = S.clone().sub(H).normalize(), J = I.clone().sub(S).normalize();
|
|
2374
2428
|
E = K.add(J).multiplyScalar(0.5);
|
|
2375
2429
|
}
|
|
2376
|
-
const
|
|
2430
|
+
const j = new c.Vector3(0, 1, 0), q = Ae(E, j), y = V;
|
|
2377
2431
|
let b = Wt(0, g / 4, x);
|
|
2378
2432
|
b = F(0.1, 1, b), b = Math.sqrt(b);
|
|
2379
2433
|
for (let K = 0; K < l; K++) {
|
|
2380
|
-
const J =
|
|
2381
|
-
Z[
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2384
|
-
const se = y + l - K - 1,
|
|
2385
|
-
Z[
|
|
2434
|
+
const J = T[K].clone().applyQuaternion(q).multiplyScalar(b), ct = S.clone().add(J.clone().multiplyScalar(_));
|
|
2435
|
+
Z[V] = ct, z[V] = J.clone();
|
|
2436
|
+
const ht = S.clone().add(J.clone().multiplyScalar(_));
|
|
2437
|
+
ht.z = s - ht.z;
|
|
2438
|
+
const se = y + l - K - 1, Tt = O * 2 - se - 1;
|
|
2439
|
+
Z[Tt] = ht, z[Tt] = J.clone(), V++;
|
|
2386
2440
|
}
|
|
2387
2441
|
}
|
|
2388
2442
|
let C = 0;
|
|
2389
|
-
const
|
|
2390
|
-
for (let x = 0; x <
|
|
2391
|
-
const H = x * l,
|
|
2392
|
-
for (let
|
|
2393
|
-
const E = Xt(
|
|
2394
|
-
U[C++] =
|
|
2443
|
+
const D = w.length * 2;
|
|
2444
|
+
for (let x = 0; x < D - 1; x++) {
|
|
2445
|
+
const H = x * l, S = (x + 1) * l;
|
|
2446
|
+
for (let I = 0; I < l; I++) {
|
|
2447
|
+
const E = Xt(I, l), j = H + I, q = H + E, y = S + E, b = S + I;
|
|
2448
|
+
U[C++] = j, U[C++] = b, U[C++] = q, U[C++] = q, U[C++] = b, U[C++] = y;
|
|
2395
2449
|
}
|
|
2396
2450
|
}
|
|
2397
|
-
const L = [...Z],
|
|
2451
|
+
const L = [...Z], v = [...z], Q = [...U], G = Z.map((x) => x.clone()), $ = [...U];
|
|
2398
2452
|
for (let x = 0; x < a - 1; x++) {
|
|
2399
|
-
const H =
|
|
2400
|
-
for (let
|
|
2401
|
-
$[
|
|
2402
|
-
for (let
|
|
2403
|
-
|
|
2404
|
-
L.push(...
|
|
2405
|
-
}
|
|
2406
|
-
const W = new Float32Array(L.length * 3), A = new Float32Array(
|
|
2453
|
+
const H = G.length;
|
|
2454
|
+
for (let S = 0; S < $.length; S++)
|
|
2455
|
+
$[S] += H;
|
|
2456
|
+
for (let S = 0; S < G.length; S++)
|
|
2457
|
+
G[S].z += h + s;
|
|
2458
|
+
L.push(...G.map((S) => S.clone())), v.push(...z.map((S) => S.clone())), Q.push(...$);
|
|
2459
|
+
}
|
|
2460
|
+
const W = new Float32Array(L.length * 3), A = new Float32Array(v.length * 3);
|
|
2407
2461
|
for (let x = 0; x < L.length; x++)
|
|
2408
|
-
W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] =
|
|
2462
|
+
W[x * 3] = L[x].x, W[x * 3 + 1] = L[x].y, W[x * 3 + 2] = L[x].z, A[x * 3] = v[x].x, A[x * 3 + 1] = v[x].y, A[x * 3 + 2] = v[x].z;
|
|
2409
2463
|
e.setAttribute(
|
|
2410
2464
|
"position",
|
|
2411
2465
|
new c.BufferAttribute(W, 3)
|
|
@@ -2416,7 +2470,7 @@ class Oe {
|
|
|
2416
2470
|
}
|
|
2417
2471
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2418
2472
|
createPaperPattern(t, e, s, i, n, o) {
|
|
2419
|
-
const a = new
|
|
2473
|
+
const a = new Se();
|
|
2420
2474
|
a.size = e, a.thickness = s;
|
|
2421
2475
|
const h = this.m_BindingRadius;
|
|
2422
2476
|
a.baseXOffset = -h;
|
|
@@ -2435,65 +2489,65 @@ class Oe {
|
|
|
2435
2489
|
const w = (e.x - h) / (g + 1);
|
|
2436
2490
|
for (let y = m + 1; y < u; y++)
|
|
2437
2491
|
P = P.createNext(M), M += w;
|
|
2438
|
-
const
|
|
2439
|
-
let k =
|
|
2492
|
+
const T = new st(0);
|
|
2493
|
+
let k = T;
|
|
2440
2494
|
const O = e.y / (f - 1);
|
|
2441
2495
|
let Z = 0;
|
|
2442
2496
|
for (let y = 0; y < f - 1; y++)
|
|
2443
2497
|
Z += O, k = k.createNext(Z);
|
|
2444
|
-
const
|
|
2498
|
+
const z = [], U = [], V = i.clone();
|
|
2445
2499
|
if (n) {
|
|
2446
2500
|
let y = 0;
|
|
2447
2501
|
this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2448
2502
|
const b = Math.max(0.01, s);
|
|
2449
|
-
|
|
2503
|
+
V.left = 0, V.right = (this.getPX(y + 1, s) - this.getPX(y, s) + b) / e.x, V.down = b / e.y, V.up = b / e.y;
|
|
2450
2504
|
}
|
|
2451
|
-
const C = new ue(a,
|
|
2452
|
-
C.insert(p,
|
|
2453
|
-
const
|
|
2505
|
+
const C = new ue(a, V, !1);
|
|
2506
|
+
C.insert(p, T, z, U), p.updateIndex(0), T.updateIndex(0), xt(z, a.xSeams), xt(U, a.zSeams);
|
|
2507
|
+
const D = this.m_BindingVertexCount + 2, L = new Array(D);
|
|
2454
2508
|
a.xNoneSeamIndexes = L, P = p;
|
|
2455
|
-
for (let y = 0; y <
|
|
2509
|
+
for (let y = 0; y < D; y++) {
|
|
2456
2510
|
L[y] = P.index;
|
|
2457
2511
|
do
|
|
2458
2512
|
P = P.next;
|
|
2459
2513
|
while (P.seam);
|
|
2460
2514
|
}
|
|
2461
|
-
const
|
|
2462
|
-
u =
|
|
2463
|
-
const
|
|
2515
|
+
const v = p.getValues(), Q = T.getValues();
|
|
2516
|
+
u = v.length, f = Q.length;
|
|
2517
|
+
const G = u * f, $ = [], W = new Array(G).fill(0), A = [], x = [], H = [], S = [];
|
|
2464
2518
|
Kt(
|
|
2465
2519
|
$,
|
|
2466
|
-
|
|
2520
|
+
v,
|
|
2467
2521
|
Q,
|
|
2468
2522
|
e,
|
|
2469
2523
|
i,
|
|
2470
2524
|
this.m_Book.direction
|
|
2471
2525
|
);
|
|
2472
|
-
const
|
|
2473
|
-
let
|
|
2474
|
-
|
|
2526
|
+
const I = C.leftNode.index, E = C.downNode.index;
|
|
2527
|
+
let j = C.rightNode.index, q = C.upNode.index;
|
|
2528
|
+
j === 0 && (j = u - 1), q === 0 && (q = f - 1);
|
|
2475
2529
|
for (let y = 0; y < f - 1; y++)
|
|
2476
2530
|
for (let b = 0; b < u - 1; b++) {
|
|
2477
|
-
if (n && y >= E && y < q && b >=
|
|
2531
|
+
if (n && y >= E && y < q && b >= I && b < j)
|
|
2478
2532
|
continue;
|
|
2479
|
-
const K = y * u + b, J = y * u + (b + 1), ct = (y + 1) * u + b,
|
|
2480
|
-
W[K] += 2, W[J] += 2, W[ct] += 2, W[
|
|
2533
|
+
const K = y * u + b, J = y * u + (b + 1), ct = (y + 1) * u + b, ht = (y + 1) * u + (b + 1);
|
|
2534
|
+
W[K] += 2, W[J] += 2, W[ct] += 2, W[ht] += 2, Yt(
|
|
2481
2535
|
A,
|
|
2482
2536
|
x,
|
|
2483
2537
|
K,
|
|
2484
2538
|
J,
|
|
2485
2539
|
ct,
|
|
2486
|
-
|
|
2487
|
-
|
|
2540
|
+
ht,
|
|
2541
|
+
G
|
|
2488
2542
|
);
|
|
2489
2543
|
}
|
|
2490
|
-
if (
|
|
2544
|
+
if (S.push(new St(0, 0, u - 1, f - 1, !1, !1)), Qt(S, H, $, u, f), a.baseXArray = v, a.baseZArray = Q, a.baseVertexCount = G, a.vertexCount = $.length, a.texcoords = $, a.weights = W, o) {
|
|
2491
2545
|
a.subMeshCount = 1;
|
|
2492
2546
|
const y = [];
|
|
2493
2547
|
y.push(...A), y.push(...H), y.push(...x), a.triangles = y;
|
|
2494
2548
|
} else
|
|
2495
2549
|
a.subMeshCount = 3, a.frontTriangles = A, a.backTriangles = x, a.borderTriangles = H;
|
|
2496
|
-
return a.borders =
|
|
2550
|
+
return a.borders = S, a;
|
|
2497
2551
|
}
|
|
2498
2552
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
2499
2553
|
updateRootPosition() {
|
|
@@ -2509,8 +2563,8 @@ class Oe {
|
|
|
2509
2563
|
for (let M = 0; M < s; M++) {
|
|
2510
2564
|
const w = e[M];
|
|
2511
2565
|
w.updateTime();
|
|
2512
|
-
const
|
|
2513
|
-
i +=
|
|
2566
|
+
const T = w.zTime, k = w.thickness;
|
|
2567
|
+
i += T * k, M === n && (i += T * this.m_BindingMidSpace / 2), M === o && (i += T * this.m_BindingMidSpace / 2);
|
|
2514
2568
|
}
|
|
2515
2569
|
let a = this.getStackHeight(t.index) - t.thickness / 2;
|
|
2516
2570
|
const h = this.getStackZ(a), m = 180 + h;
|
|
@@ -2565,8 +2619,8 @@ class Oe {
|
|
|
2565
2619
|
for (let M = 0; M < s; M++) {
|
|
2566
2620
|
const w = e[M];
|
|
2567
2621
|
w.updateTime();
|
|
2568
|
-
const
|
|
2569
|
-
i +=
|
|
2622
|
+
const T = w.zTime, k = w.thickness;
|
|
2623
|
+
i += T * k, M === n && (i += T * this.m_BindingMidSpace / 2), M === o && (i += T * this.m_BindingMidSpace / 2);
|
|
2570
2624
|
}
|
|
2571
2625
|
const a = this.getStackHeight(t.index) - t.thickness / 2, h = this.getStackZ(a + i), m = 180 + this.getStackZ(a + i - this.m_StackHeight);
|
|
2572
2626
|
let l = t.zTime, d = F(h, m, l);
|
|
@@ -2629,36 +2683,36 @@ class Oe {
|
|
|
2629
2683
|
let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
|
|
2630
2684
|
const n = this.m_StapleThickness * 0.5, o = t[0].thickness, a = this.m_Root.matrixWorld.clone(), h = t.length;
|
|
2631
2685
|
for (let m = 0; m < h; m++) {
|
|
2632
|
-
const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, M = l.thickness, w = g.xNoneSeamIndexes,
|
|
2686
|
+
const l = t[m], d = l.transform, g = l.meshData.pattern, _ = l.meshData.baseVertices, u = g.baseXArray, f = g.baseZArray, p = u.length, P = f.length, B = this.m_BindingVertexCount + 1, M = l.thickness, w = g.xNoneSeamIndexes, T = d.position.clone();
|
|
2633
2687
|
let k = m, O = n;
|
|
2634
2688
|
m >= Math.floor(h / 2) && (k = h - m - 1, O *= -1);
|
|
2635
|
-
const Z = (o + M) * 0.5 + M * (k - 1),
|
|
2689
|
+
const Z = (o + M) * 0.5 + M * (k - 1), z = d.matrixWorld.clone().invert().multiply(a), U = k / (h / 2);
|
|
2636
2690
|
i = this.m_BindingRadius * F(0.45, 0.65, 1 - U);
|
|
2637
|
-
for (let
|
|
2638
|
-
const C = f[
|
|
2691
|
+
for (let V = 0; V < P; V++) {
|
|
2692
|
+
const C = f[V], D = new c.Vector3(0, 0, T.z + C), L = T.clone();
|
|
2639
2693
|
L.z += C;
|
|
2640
|
-
const
|
|
2641
|
-
if (m === 0 &&
|
|
2694
|
+
const v = l.getDirection(C).multiplyScalar(i).add(L.clone());
|
|
2695
|
+
if (m === 0 && V === 0) {
|
|
2642
2696
|
const A = t[h - 1], H = A.transform.position.clone().clone();
|
|
2643
2697
|
H.z += C;
|
|
2644
|
-
const
|
|
2645
|
-
s =
|
|
2698
|
+
const S = A.getDirection(C).multiplyScalar(i).add(H);
|
|
2699
|
+
s = v.clone().sub(S).normalize(), e = new c.Vector3(
|
|
2646
2700
|
-s.y,
|
|
2647
2701
|
s.x,
|
|
2648
2702
|
0
|
|
2649
2703
|
).normalize().negate();
|
|
2650
|
-
const
|
|
2651
|
-
this.stapleMesh.rotation.set(0, 0,
|
|
2704
|
+
const I = Math.atan2(e.y, e.x) * it;
|
|
2705
|
+
this.stapleMesh.rotation.set(0, 0, I * tt);
|
|
2652
2706
|
}
|
|
2653
|
-
k > 0 &&
|
|
2654
|
-
const Q =
|
|
2655
|
-
_[Q] =
|
|
2656
|
-
const
|
|
2657
|
-
_[Q + w[1]] =
|
|
2707
|
+
k > 0 && D.add(e.clone().multiplyScalar(Z));
|
|
2708
|
+
const Q = V * p;
|
|
2709
|
+
_[Q] = D.clone().applyMatrix4(z), D.add(s.clone().multiplyScalar(O));
|
|
2710
|
+
const G = D.clone().applyMatrix4(z), $ = v.clone().applyMatrix4(z), W = L.clone().applyMatrix4(z);
|
|
2711
|
+
_[Q + w[1]] = G;
|
|
2658
2712
|
for (let A = 2; A < B; A++) {
|
|
2659
2713
|
const x = Wt(1, B, A);
|
|
2660
2714
|
_[Q + w[A]] = Et(
|
|
2661
|
-
|
|
2715
|
+
G,
|
|
2662
2716
|
$,
|
|
2663
2717
|
W,
|
|
2664
2718
|
x
|
|
@@ -2716,7 +2770,7 @@ class Ze {
|
|
|
2716
2770
|
return this.mesh;
|
|
2717
2771
|
}
|
|
2718
2772
|
}
|
|
2719
|
-
class $e extends
|
|
2773
|
+
class $e extends Te {
|
|
2720
2774
|
constructor() {
|
|
2721
2775
|
super(...arguments), this.quality = 3, this.stapleSetup = new He();
|
|
2722
2776
|
}
|
|
@@ -2875,7 +2929,7 @@ class Ye {
|
|
|
2875
2929
|
function Le(r) {
|
|
2876
2930
|
return r.map instanceof c.Texture;
|
|
2877
2931
|
}
|
|
2878
|
-
class
|
|
2932
|
+
class Gt {
|
|
2879
2933
|
constructor(t, e) {
|
|
2880
2934
|
this._spread = t, this._textureST = e === "left" ? new c.Vector4(0.5, 1, 0, 0) : new c.Vector4(0.5, 1, 0.5, 0);
|
|
2881
2935
|
}
|
|
@@ -2904,7 +2958,7 @@ class Je {
|
|
|
2904
2958
|
this.texts = [], this.pageWidth = (t == null ? void 0 : t.pageWidth) ?? 512, this.pageHeight = (t == null ? void 0 : t.pageHeight) ?? 512, this.canvas = document.createElement("canvas"), this.canvas.width = this.pageWidth * 2, this.canvas.height = this.pageHeight;
|
|
2905
2959
|
const e = this.canvas.getContext("2d");
|
|
2906
2960
|
if (!e) throw new Error("SpreadContent: could not get 2D context");
|
|
2907
|
-
this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new
|
|
2961
|
+
this.ctx = e, this._source = (t == null ? void 0 : t.source) ?? null, this._texture = new c.CanvasTexture(this.canvas), this._texture.colorSpace = c.SRGBColorSpace, this.left = new Gt(this, "left"), this.right = new Gt(this, "right");
|
|
2908
2962
|
}
|
|
2909
2963
|
get texture() {
|
|
2910
2964
|
return this._texture;
|
|
@@ -2961,7 +3015,7 @@ class Je {
|
|
|
2961
3015
|
this._texture.dispose();
|
|
2962
3016
|
}
|
|
2963
3017
|
}
|
|
2964
|
-
const
|
|
3018
|
+
const jt = 256;
|
|
2965
3019
|
function Ne(r, t, e, s, i, n, o) {
|
|
2966
3020
|
const a = t.naturalWidth || t.width, h = t.naturalHeight || t.height;
|
|
2967
3021
|
if (a <= 0 || h <= 0) return;
|
|
@@ -2973,7 +3027,7 @@ function Ne(r, t, e, s, i, n, o) {
|
|
|
2973
3027
|
r.drawImage(t, e + (i - l) * 0.5, s + (n - d) * 0.5, l, d);
|
|
2974
3028
|
}
|
|
2975
3029
|
function ts(r, t, e, s, i, n, o) {
|
|
2976
|
-
const a = n ? Math.round(n *
|
|
3030
|
+
const a = n ? Math.round(n * jt) : 512, h = o ? Math.round(o * jt) : 512, m = document.createElement("canvas");
|
|
2977
3031
|
m.width = a, m.height = h;
|
|
2978
3032
|
const l = m.getContext("2d");
|
|
2979
3033
|
if (l.fillStyle = r, l.fillRect(0, 0, a, h), e) {
|
|
@@ -3003,33 +3057,33 @@ export {
|
|
|
3003
3057
|
ye as AnimationCurve,
|
|
3004
3058
|
wt as AutoTurnDirection,
|
|
3005
3059
|
Me as AutoTurnMode,
|
|
3006
|
-
|
|
3060
|
+
ot as AutoTurnSetting,
|
|
3007
3061
|
we as AutoTurnSettingCurveTimeMode,
|
|
3008
3062
|
Ce as AutoTurnSettingMode,
|
|
3009
3063
|
Lt as AutoTurnSettings,
|
|
3010
3064
|
yt as Book,
|
|
3011
|
-
|
|
3065
|
+
Te as BookBinding,
|
|
3012
3066
|
Qe as BookBound,
|
|
3013
|
-
|
|
3067
|
+
je as BookContent,
|
|
3014
3068
|
X as BookDirection,
|
|
3015
3069
|
Xe as BookHeightException,
|
|
3016
3070
|
qe as BookPointerInteraction,
|
|
3017
3071
|
pe as BookRenderer,
|
|
3018
3072
|
ut as Cylinder,
|
|
3019
3073
|
_e as MeshFactory,
|
|
3020
|
-
|
|
3021
|
-
|
|
3074
|
+
jt as PX_PER_UNIT,
|
|
3075
|
+
Ge as PageContent,
|
|
3022
3076
|
me as Paper,
|
|
3023
|
-
|
|
3077
|
+
St as PaperBorder,
|
|
3024
3078
|
At as PaperMaterialData,
|
|
3025
3079
|
Zt as PaperMeshData,
|
|
3026
3080
|
xe as PaperMeshDataPool,
|
|
3027
3081
|
Ee as PaperMeshUtility,
|
|
3028
3082
|
st as PaperNode,
|
|
3029
3083
|
ue as PaperNodeMargin,
|
|
3030
|
-
|
|
3084
|
+
Se as PaperPattern,
|
|
3031
3085
|
Pt as PaperSeam,
|
|
3032
|
-
|
|
3086
|
+
nt as PaperSetup,
|
|
3033
3087
|
pt as PaperUVMargin,
|
|
3034
3088
|
fe as RendererFactory,
|
|
3035
3089
|
Je as SpreadContent,
|
package/package.json
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@objectifthunes/three-book",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@objectifthunes/three-book",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"three": ">=0.150.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"three": "^0.172.0",
|
|
21
|
+
"@types/three": "^0.172.0",
|
|
22
|
+
"typescript": "^5.7.0",
|
|
23
|
+
"vite": "^6.0.0",
|
|
24
|
+
"vite-plugin-dts": "^4.0.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
}
|
|
30
|
+
}
|