@objectifthunes/three-book 0.5.7 → 0.5.8
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/demo-kit/dist/index.d.ts +15 -0
- package/demo-kit/dist/index.js +75 -70
- package/dist/TextBlock.d.ts +35 -1
- package/dist/TextBlock.d.ts.map +1 -1
- package/dist/index.js +185 -141
- package/dist/textContentUtils.d.ts.map +1 -1
- package/package.json +2 -1
package/demo-kit/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,21 @@ declare class Cylinder {
|
|
|
554
554
|
clone(): Cylinder;
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
/** Default font size chosen by demos. TextBlock defaults to 24. */
|
|
558
|
+
export declare const DEFAULT_FONT_SIZE = 22;
|
|
559
|
+
|
|
560
|
+
/** Mirrors the TextBlock default line-height; used by demos for measurement. */
|
|
561
|
+
export declare const DEFAULT_LINE_HEIGHT = 1.4;
|
|
562
|
+
|
|
563
|
+
/** Default text color chosen by demos. TextBlock defaults to '#222'. */
|
|
564
|
+
export declare const DEFAULT_TEXT_COLOR = "#1a1a1a";
|
|
565
|
+
|
|
566
|
+
/** Shadow blur radius used by demos. TextBlock defaults to 0. */
|
|
567
|
+
export declare const DEMO_SHADOW_BLUR = 3;
|
|
568
|
+
|
|
569
|
+
/** Shadow color used by demos when rendering TextBlocks. TextBlock defaults to no shadow. */
|
|
570
|
+
export declare const DEMO_SHADOW_COLOR = "rgba(255,255,255,0.6)";
|
|
571
|
+
|
|
557
572
|
export declare interface DemoPanel {
|
|
558
573
|
root: HTMLElement;
|
|
559
574
|
toggleBtn: HTMLElement;
|
package/demo-kit/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BookDirection as y, BookPointerInteraction as
|
|
2
|
-
import { PX_PER_UNIT as
|
|
1
|
+
import { BookDirection as y, BookPointerInteraction as L, getSpreadPairs as k, computeDefaultImageRect as N, loadImage as S, drawImageWithFit as I } from "@objectifthunes/three-book";
|
|
2
|
+
import { PX_PER_UNIT as oe, createPageTexture as de, drawImageWithFit as ce, loadImage as le } from "@objectifthunes/three-book";
|
|
3
3
|
import * as E from "three";
|
|
4
|
-
import { OrbitControls as
|
|
5
|
-
const
|
|
4
|
+
import { OrbitControls as T } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
const O = "rgba(255,255,255,0.6)", F = 3, _ = 1.4, R = 22, U = "#1a1a1a", H = [
|
|
6
6
|
"Georgia",
|
|
7
7
|
"Times New Roman",
|
|
8
8
|
"Garamond",
|
|
@@ -16,21 +16,21 @@ const j = [
|
|
|
16
16
|
"Lucida Console",
|
|
17
17
|
"Comic Sans MS"
|
|
18
18
|
];
|
|
19
|
-
function
|
|
19
|
+
function A(n, o) {
|
|
20
20
|
return {
|
|
21
21
|
text: "Your text here",
|
|
22
22
|
x: Math.round(n * 0.06),
|
|
23
23
|
y: Math.round(o * 0.55),
|
|
24
24
|
width: Math.round(n * 0.88),
|
|
25
25
|
fontFamily: "",
|
|
26
|
-
fontSize:
|
|
26
|
+
fontSize: R,
|
|
27
27
|
fontWeight: "normal",
|
|
28
28
|
fontStyle: "normal",
|
|
29
|
-
color:
|
|
29
|
+
color: U,
|
|
30
30
|
textAlign: "left"
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function W(n) {
|
|
34
34
|
switch (n) {
|
|
35
35
|
case "right-to-left":
|
|
36
36
|
return y.RightToLeft;
|
|
@@ -43,7 +43,7 @@ function F(n) {
|
|
|
43
43
|
return y.LeftToRight;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function $() {
|
|
47
47
|
return {
|
|
48
48
|
image: null,
|
|
49
49
|
objectUrl: null,
|
|
@@ -56,7 +56,7 @@ function H() {
|
|
|
56
56
|
function M(n) {
|
|
57
57
|
n.objectUrl && URL.revokeObjectURL(n.objectUrl), n.objectUrl = null, n.image = null, n.useImage = !1, n.imageRect = null;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function z(n, o, e) {
|
|
60
60
|
const d = document.createElement("div");
|
|
61
61
|
d.className = "demo-section-title", d.style.cursor = "pointer", d.style.display = "flex", d.style.justifyContent = "space-between", d.style.alignItems = "center", d.style.userSelect = "none";
|
|
62
62
|
const t = document.createElement("span");
|
|
@@ -69,11 +69,11 @@ function O(n, o, e) {
|
|
|
69
69
|
c.style.display = r ? "none" : "block", a.textContent = r ? "▾" : "▴";
|
|
70
70
|
}), { header: d, body: c };
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function G(n, o) {
|
|
73
73
|
const e = document.createElement("div");
|
|
74
74
|
return e.textContent = o, e.className = "demo-section-title", n.appendChild(e), e;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function X(n, o, e, d, t, a, c) {
|
|
77
77
|
const r = document.createElement("label");
|
|
78
78
|
r.className = "demo-field";
|
|
79
79
|
const i = document.createElement("div");
|
|
@@ -88,7 +88,7 @@ function $(n, o, e, d, t, a, c) {
|
|
|
88
88
|
l.textContent = b.toFixed(f), c(b);
|
|
89
89
|
}), i.appendChild(h), i.appendChild(l), r.appendChild(i), r.appendChild(m), n.appendChild(r), m;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function Y(n, o, e, d) {
|
|
92
92
|
const t = document.createElement("label");
|
|
93
93
|
t.className = "demo-field";
|
|
94
94
|
const a = document.createElement("div");
|
|
@@ -102,7 +102,7 @@ function z(n, o, e, d) {
|
|
|
102
102
|
r.textContent = i.value, d(i.value);
|
|
103
103
|
}), a.appendChild(c), a.appendChild(r), t.appendChild(a), t.appendChild(i), n.appendChild(t), i;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function Z(n, o, e, d) {
|
|
106
106
|
const t = document.createElement("label");
|
|
107
107
|
t.className = "demo-checkbox-field";
|
|
108
108
|
const a = document.createElement("span");
|
|
@@ -112,7 +112,7 @@ function A(n, o, e, d) {
|
|
|
112
112
|
d(c.checked);
|
|
113
113
|
}), t.appendChild(a), t.appendChild(c), n.appendChild(t), c;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function V(n, o, e, d, t) {
|
|
116
116
|
const a = document.createElement("label");
|
|
117
117
|
a.className = "demo-field";
|
|
118
118
|
const c = document.createElement("div");
|
|
@@ -129,7 +129,7 @@ function G(n, o, e, d, t) {
|
|
|
129
129
|
t(i.value);
|
|
130
130
|
}), c.appendChild(r), a.appendChild(c), a.appendChild(i), n.appendChild(a), i;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function q() {
|
|
133
133
|
const n = new E.Scene();
|
|
134
134
|
n.background = new E.Color(1710638);
|
|
135
135
|
const o = new E.PerspectiveCamera(
|
|
@@ -145,7 +145,7 @@ function _() {
|
|
|
145
145
|
n.add(d);
|
|
146
146
|
const t = new E.DirectionalLight(16777215, 1.2);
|
|
147
147
|
t.position.set(5, 10, 5), t.castShadow = !0, t.shadow.mapSize.set(2048, 2048), n.add(t);
|
|
148
|
-
const a = new
|
|
148
|
+
const a = new T(o, e.domElement);
|
|
149
149
|
a.enableDamping = !0, a.dampingFactor = 0.05, a.target.set(0, 0.5, 0);
|
|
150
150
|
const c = new E.PlaneGeometry(20, 20), r = new E.MeshStandardMaterial({ color: 2763338 }), i = new E.Mesh(c, r);
|
|
151
151
|
i.rotation.x = -Math.PI / 2, i.position.y = -0.01, i.receiveShadow = !0, n.add(i);
|
|
@@ -156,15 +156,15 @@ function _() {
|
|
|
156
156
|
o.aspect = window.innerWidth / window.innerHeight, o.updateProjectionMatrix(), e.setSize(window.innerWidth, window.innerHeight);
|
|
157
157
|
}), { scene: n, camera: o, renderer: e, controls: a, ambientLight: d, dirLight: t, syncLights: h };
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
const t = new
|
|
159
|
+
function J(n, o, e, d) {
|
|
160
|
+
const t = new L(n, o);
|
|
161
161
|
return t.enabled = d, t.onTurnStart = () => {
|
|
162
162
|
e.enabled = !1;
|
|
163
163
|
}, t.onTurnEnd = () => {
|
|
164
164
|
e.enabled = !0;
|
|
165
165
|
}, t;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
167
|
+
function K(n) {
|
|
168
168
|
const { title: o, subtitle: e, tabs: d } = n, t = document.createElement("div");
|
|
169
169
|
t.className = "demo-panel", t.style.left = "10px", t.style.width = "min(92vw, 380px)", t.addEventListener("pointerdown", (p) => p.stopPropagation());
|
|
170
170
|
const a = document.createElement("div");
|
|
@@ -180,7 +180,7 @@ function Y(n) {
|
|
|
180
180
|
const f = document.createElement("div");
|
|
181
181
|
f.className = "demo-tab-bar";
|
|
182
182
|
const m = [], b = [];
|
|
183
|
-
function
|
|
183
|
+
function g(p) {
|
|
184
184
|
for (let s = 0; s < d.length; s++) {
|
|
185
185
|
const u = d[s].key === p;
|
|
186
186
|
b[s].style.display = u ? "block" : "none", m[s].className = u ? "demo-tab demo-tab--active" : "demo-tab";
|
|
@@ -188,34 +188,34 @@ function Y(n) {
|
|
|
188
188
|
}
|
|
189
189
|
for (let p = 0; p < d.length; p++) {
|
|
190
190
|
const s = d[p], u = document.createElement("button");
|
|
191
|
-
u.textContent = s.label, u.className = p === 0 ? "demo-tab demo-tab--active" : "demo-tab", u.addEventListener("click", () =>
|
|
191
|
+
u.textContent = s.label, u.className = p === 0 ? "demo-tab demo-tab--active" : "demo-tab", u.addEventListener("click", () => g(s.key)), m.push(u), f.appendChild(u), s.content.style.display = p === 0 ? "block" : "none", b.push(s.content);
|
|
192
192
|
}
|
|
193
193
|
t.appendChild(f);
|
|
194
194
|
for (const p of b) t.appendChild(p);
|
|
195
|
-
const
|
|
196
|
-
return
|
|
197
|
-
t.style.display = "none",
|
|
198
|
-
}),
|
|
199
|
-
t.style.display = "",
|
|
200
|
-
}), document.body.appendChild(t), document.body.appendChild(
|
|
195
|
+
const C = document.createElement("button");
|
|
196
|
+
return C.textContent = "☰ Panel", C.className = "demo-toggle-btn", C.style.display = "none", h.addEventListener("click", () => {
|
|
197
|
+
t.style.display = "none", C.style.display = "block";
|
|
198
|
+
}), C.addEventListener("click", () => {
|
|
199
|
+
t.style.display = "", C.style.display = "none";
|
|
200
|
+
}), document.body.appendChild(t), document.body.appendChild(C), {
|
|
201
201
|
root: t,
|
|
202
|
-
toggleBtn:
|
|
202
|
+
toggleBtn: C,
|
|
203
203
|
statusEl: l,
|
|
204
204
|
setStatus(p) {
|
|
205
205
|
l.textContent = p;
|
|
206
206
|
},
|
|
207
|
-
switchTab:
|
|
207
|
+
switchTab: g
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function B(n, o, e) {
|
|
211
211
|
const t = o.has(n - 1) ? n - 1 : Math.min(n, e - 1), a = o.has(t);
|
|
212
212
|
return { effectiveIdx: t, isSpread: a };
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function Q(n) {
|
|
215
215
|
const o = document.createElement("div");
|
|
216
216
|
function e(d) {
|
|
217
217
|
o.innerHTML = "";
|
|
218
|
-
const { pageCount: t, currentPage: a, spreadPages: c, onPageChange: r, onSpreadToggle: i } = d, h = new Set(
|
|
218
|
+
const { pageCount: t, currentPage: a, spreadPages: c, onPageChange: r, onSpreadToggle: i } = d, h = new Set(k(t)), { effectiveIdx: l, isSpread: f } = B(a, c, t);
|
|
219
219
|
if (h.has(l)) {
|
|
220
220
|
const s = document.createElement("label");
|
|
221
221
|
s.className = "demo-spread-toggle";
|
|
@@ -230,13 +230,13 @@ function V(n) {
|
|
|
230
230
|
m.className = "demo-page-nav";
|
|
231
231
|
const b = document.createElement("button");
|
|
232
232
|
b.textContent = "←", b.className = "demo-btn", b.disabled = l <= 0, b.addEventListener("click", () => r(l - 1));
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
const s = Math.max(1, Math.min(t, parseInt(
|
|
233
|
+
const g = document.createElement("input");
|
|
234
|
+
g.type = "number", g.min = "1", g.max = String(t), g.value = String(l + 1), g.className = "demo-input--page", g.addEventListener("change", () => {
|
|
235
|
+
const s = Math.max(1, Math.min(t, parseInt(g.value, 10) || 1)) - 1;
|
|
236
236
|
r(s);
|
|
237
237
|
});
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
238
|
+
const C = document.createElement("span");
|
|
239
|
+
if (C.className = "demo-page-count", C.textContent = `/ ${t}`, m.appendChild(b), m.appendChild(g), m.appendChild(C), f) {
|
|
240
240
|
const s = document.createElement("span");
|
|
241
241
|
s.className = "demo-spread-label", s.textContent = `(Spread ${l + 1}–${l + 2})`, m.appendChild(s);
|
|
242
242
|
}
|
|
@@ -250,7 +250,7 @@ function V(n) {
|
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function D(n, o, e = 64, d = 64) {
|
|
254
254
|
const t = document.createElement("canvas");
|
|
255
255
|
t.width = 128, t.height = 128;
|
|
256
256
|
const a = t.getContext("2d");
|
|
@@ -260,17 +260,17 @@ function U(n, o, e = 64, d = 64) {
|
|
|
260
260
|
}
|
|
261
261
|
return t.className = "demo-thumb", t.style.width = `${e}px`, t.style.height = `${d}px`, t;
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function ee(n) {
|
|
264
264
|
const { label: o, slot: e, bgColor: d, showFitControls: t, canvasWidth: a, canvasHeight: c, onChanged: r } = n, i = a ?? 512, h = c ?? 512, l = document.createElement("div");
|
|
265
265
|
l.className = "demo-card";
|
|
266
266
|
const f = document.createElement("div");
|
|
267
|
-
f.className = "demo-card-row", f.appendChild(
|
|
267
|
+
f.className = "demo-card-row", f.appendChild(D(e, d));
|
|
268
268
|
const m = document.createElement("div");
|
|
269
269
|
m.className = "demo-card-body";
|
|
270
270
|
const b = document.createElement("div");
|
|
271
271
|
b.className = "demo-card-label", b.textContent = o, m.appendChild(b);
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
272
|
+
const g = document.createElement("div");
|
|
273
|
+
if (g.className = "demo-card-controls", t) {
|
|
274
274
|
const s = document.createElement("select");
|
|
275
275
|
s.className = "demo-select demo-select--mini";
|
|
276
276
|
for (const w of ["contain", "cover", "fill"]) {
|
|
@@ -279,18 +279,18 @@ function Z(n) {
|
|
|
279
279
|
}
|
|
280
280
|
s.addEventListener("change", () => {
|
|
281
281
|
e.fitMode = s.value, e.image && (e.imageRect = N(e.image, i, h, e.fitMode, e.fullBleed)), r();
|
|
282
|
-
}),
|
|
282
|
+
}), g.appendChild(s);
|
|
283
283
|
const u = document.createElement("label");
|
|
284
284
|
u.className = "demo-inline-label";
|
|
285
285
|
const v = document.createElement("input");
|
|
286
286
|
v.type = "checkbox", v.checked = e.fullBleed, v.className = "demo-checkbox--sm", v.addEventListener("change", () => {
|
|
287
287
|
e.fullBleed = v.checked, e.image && (e.imageRect = N(e.image, i, h, e.fitMode, e.fullBleed)), r();
|
|
288
|
-
}), u.appendChild(v), u.appendChild(document.createTextNode("Bleed")),
|
|
288
|
+
}), u.appendChild(v), u.appendChild(document.createTextNode("Bleed")), g.appendChild(u);
|
|
289
289
|
}
|
|
290
|
-
const
|
|
291
|
-
|
|
290
|
+
const C = document.createElement("button");
|
|
291
|
+
C.type = "button", C.textContent = "Clear", C.className = "demo-btn", C.addEventListener("click", () => {
|
|
292
292
|
M(e), r();
|
|
293
|
-
}),
|
|
293
|
+
}), g.appendChild(C), m.appendChild(g);
|
|
294
294
|
const p = document.createElement("input");
|
|
295
295
|
return p.type = "file", p.accept = "image/*", p.className = "demo-file-input", p.addEventListener("change", () => {
|
|
296
296
|
var s;
|
|
@@ -299,33 +299,38 @@ function Z(n) {
|
|
|
299
299
|
});
|
|
300
300
|
}), m.appendChild(p), f.appendChild(m), l.appendChild(f), l;
|
|
301
301
|
}
|
|
302
|
-
async function
|
|
302
|
+
async function te(n, o) {
|
|
303
303
|
if (!o) return;
|
|
304
304
|
n.objectUrl && URL.revokeObjectURL(n.objectUrl);
|
|
305
305
|
const e = await S(o);
|
|
306
306
|
e && (n.objectUrl = e.objectUrl, n.image = e.image, n.useImage = !0);
|
|
307
307
|
}
|
|
308
308
|
export {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
309
|
+
R as DEFAULT_FONT_SIZE,
|
|
310
|
+
_ as DEFAULT_LINE_HEIGHT,
|
|
311
|
+
U as DEFAULT_TEXT_COLOR,
|
|
312
|
+
F as DEMO_SHADOW_BLUR,
|
|
313
|
+
O as DEMO_SHADOW_COLOR,
|
|
314
|
+
H as FONT_OPTIONS,
|
|
315
|
+
oe as PX_PER_UNIT,
|
|
316
|
+
Z as addCheckbox,
|
|
317
|
+
z as addCollapseToggle,
|
|
318
|
+
Y as addColor,
|
|
319
|
+
G as addSectionTitle,
|
|
320
|
+
V as addSelect,
|
|
321
|
+
X as addSlider,
|
|
317
322
|
M as clearImageSlot,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
A as createDefaultTextBlock,
|
|
324
|
+
J as createDemoInteraction,
|
|
325
|
+
K as createDemoPanel,
|
|
326
|
+
q as createDemoScene,
|
|
327
|
+
$ as createImageSlot,
|
|
328
|
+
ee as createImageSlotCard,
|
|
329
|
+
Q as createPageNavigation,
|
|
330
|
+
de as createPageTexture,
|
|
331
|
+
ce as drawImageWithFit,
|
|
332
|
+
le as loadImage,
|
|
333
|
+
te as loadImageFromFile,
|
|
334
|
+
B as resolvePageIndex,
|
|
335
|
+
W as toBookDirection
|
|
331
336
|
};
|
package/dist/TextBlock.d.ts
CHANGED
|
@@ -33,6 +33,26 @@ export interface TextBlockOptions {
|
|
|
33
33
|
shadowColor?: string;
|
|
34
34
|
/** Shadow blur radius in pixels (default 0). */
|
|
35
35
|
shadowBlur?: number;
|
|
36
|
+
/** Horizontal shadow offset in pixels (default 0). */
|
|
37
|
+
shadowOffsetX?: number;
|
|
38
|
+
/** Vertical shadow offset in pixels (default 0). */
|
|
39
|
+
shadowOffsetY?: number;
|
|
40
|
+
/** Text case transformation (default 'none'). */
|
|
41
|
+
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
42
|
+
/** Text decoration (default 'none'). */
|
|
43
|
+
textDecoration?: 'none' | 'underline' | 'strikethrough';
|
|
44
|
+
/** Background fill color behind text (default '' = none). */
|
|
45
|
+
background?: string;
|
|
46
|
+
/** Padding around text for background box in pixels (default 0). */
|
|
47
|
+
backgroundPadding?: number;
|
|
48
|
+
/** Maximum visible lines, 0 = unlimited (default 0). Truncated with '…'. */
|
|
49
|
+
maxLines?: number;
|
|
50
|
+
/** Container height for vertical alignment, 0 = auto (default 0). */
|
|
51
|
+
height?: number;
|
|
52
|
+
/** Vertical alignment within height (default 'top'). */
|
|
53
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
54
|
+
/** Rotation in radians around text block center (default 0). */
|
|
55
|
+
rotation?: number;
|
|
36
56
|
}
|
|
37
57
|
export declare class TextBlock {
|
|
38
58
|
x: number;
|
|
@@ -49,6 +69,16 @@ export declare class TextBlock {
|
|
|
49
69
|
opacity: number;
|
|
50
70
|
shadowColor: string;
|
|
51
71
|
shadowBlur: number;
|
|
72
|
+
shadowOffsetX: number;
|
|
73
|
+
shadowOffsetY: number;
|
|
74
|
+
textTransform: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
75
|
+
textDecoration: 'none' | 'underline' | 'strikethrough';
|
|
76
|
+
background: string;
|
|
77
|
+
backgroundPadding: number;
|
|
78
|
+
maxLines: number;
|
|
79
|
+
height: number;
|
|
80
|
+
verticalAlign: 'top' | 'middle' | 'bottom';
|
|
81
|
+
rotation: number;
|
|
52
82
|
constructor(options?: TextBlockOptions);
|
|
53
83
|
private _font;
|
|
54
84
|
/**
|
|
@@ -56,9 +86,13 @@ export declare class TextBlock {
|
|
|
56
86
|
* Respects explicit newlines.
|
|
57
87
|
*/
|
|
58
88
|
wrapLines(ctx: CanvasRenderingContext2D): string[];
|
|
89
|
+
private _applyMaxLines;
|
|
59
90
|
/** Total rendered height in canvas pixels. */
|
|
60
91
|
measureHeight(ctx: CanvasRenderingContext2D): number;
|
|
61
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Returns true if the point (px, py) is within the text bounding box.
|
|
94
|
+
* Note: rotation is not accounted for — the hit area is always axis-aligned.
|
|
95
|
+
*/
|
|
62
96
|
hitTest(ctx: CanvasRenderingContext2D, px: number, py: number): boolean;
|
|
63
97
|
private _maxLineWidth;
|
|
64
98
|
draw(ctx: CanvasRenderingContext2D): void;
|
package/dist/TextBlock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlock.d.ts","sourceRoot":"","sources":["../src/TextBlock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC/B,qCAAqC;IACrC,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TextBlock.d.ts","sourceRoot":"","sources":["../src/TextBlock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,UAAU,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC/B,qCAAqC;IACrC,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAChC,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;IAClE,wCAAwC;IACxC,cAAc,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,eAAe,CAAC;IACxD,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,aAAa,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC5C,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,SAAS;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;IACjE,cAAc,EAAE,MAAM,GAAG,WAAW,GAAG,eAAe,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;gBAEL,OAAO,CAAC,EAAE,gBAAgB;IA2BtC,OAAO,CAAC,KAAK;IAIb;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,wBAAwB,GAAG,MAAM,EAAE;IAqClD,OAAO,CAAC,cAAc;IAatB,8CAA8C;IAC9C,aAAa,CAAC,GAAG,EAAE,wBAAwB,GAAG,MAAM;IAQpD;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,wBAAwB,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IASvE,OAAO,CAAC,aAAa;IAUrB,IAAI,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;CA+F1C"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as c from "three";
|
|
2
|
-
class
|
|
2
|
+
class Ct {
|
|
3
3
|
constructor() {
|
|
4
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, this._positionOut = new c.Vector3(), this._scratchRP1 = new c.Vector3(), this._scratchRP2 = new c.Vector3(), this._scratchRollClosest = new c.Vector3(), this._scratchRollEuler = new c.Vector3(), this._scratchOffsetRoll = new c.Vector3();
|
|
5
5
|
}
|
|
@@ -78,7 +78,7 @@ class wt {
|
|
|
78
78
|
}
|
|
79
79
|
// ── Value-type clone ──────────────────────────────────────────────────
|
|
80
80
|
clone() {
|
|
81
|
-
const t = new
|
|
81
|
+
const t = new Ct();
|
|
82
82
|
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;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -173,15 +173,15 @@ function ne(r, t, e, s, i) {
|
|
|
173
173
|
if (T.rootCount === 1)
|
|
174
174
|
return i.set(T.root0, g * T.root0 + p);
|
|
175
175
|
if (T.rootCount === 2) {
|
|
176
|
-
let P = T.root0,
|
|
177
|
-
return a < u && ([P,
|
|
176
|
+
let P = T.root0, w = T.root1;
|
|
177
|
+
return a < u && ([P, w] = [w, P]), i.set(w, g * w + p);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return i.copy(r);
|
|
181
181
|
}
|
|
182
|
-
const ft = new c.Vector3(),
|
|
182
|
+
const ft = new c.Vector3(), bt = new c.Vector3(), Rt = new c.Ray();
|
|
183
183
|
function Dt(r, t) {
|
|
184
|
-
return ft.copy(r.origin).applyMatrix4(t),
|
|
184
|
+
return ft.copy(r.origin).applyMatrix4(t), bt.copy(r.origin).add(r.direction).applyMatrix4(t), Rt.set(ft, bt.sub(ft).normalize()), Rt;
|
|
185
185
|
}
|
|
186
186
|
function re(r) {
|
|
187
187
|
const t = r.x;
|
|
@@ -216,7 +216,7 @@ function Vt(r, t, e) {
|
|
|
216
216
|
class oe {
|
|
217
217
|
// ---- Constructor ----
|
|
218
218
|
constructor(t, e, s, i) {
|
|
219
|
-
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
|
|
219
|
+
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 Ct(), 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._ucStartHandle = new c.Vector3(), this._ucCurrentHandle = new c.Vector3(), this._ucHandleDir = new c.Vector3(), this._ucA = new c.Vector3(), this._ucB = new c.Vector3(), this._ucMid = new c.Vector3(), this._ucRollResult = new c.Vector3(), this._ucCylDir = new c.Vector3(), this._utV1 = new c.Vector3(), this._utV2 = new c.Vector3(), this._utV3 = new c.Vector3(), this._utV4 = new c.Vector3(), this._chP = new c.Vector3(), this._chA = new c.Vector3(), this._chC = new c.Vector3(), this._chEllipseCenter1 = new c.Vector2(), this._chEllipseCenter2 = new c.Vector2(), this._chEllipseSize1 = new c.Vector2(), this._chEllipseSize2 = new c.Vector2(), this._chP2 = new c.Vector2(), this._dirResult = new c.Vector3(), this._gdA = new c.Vector3(), this._gdB = new c.Vector3(), this._rlMatrix = new c.Matrix4(), this._rlPlane = new c.Plane(new c.Vector3(0, 1, 0), 0), this._rlTarget = new c.Vector3(), this._rlNormal = new c.Vector3(), this._utTarget = new c.Vector3(), this._ufSmoothTime = new c.Vector3(), this._umFrontST = new c.Vector4(), this._umBackST = new c.Vector4(), this._h2uResult = new c.Vector2(), this.m_IsCover = t, this.m_Book = s, this.m_Index = e, this.m_Renderer = i, this.m_Transform = i.transform;
|
|
220
220
|
}
|
|
221
221
|
// ---- Properties (mirrors C#) ----
|
|
222
222
|
get isMeshChanged() {
|
|
@@ -1103,8 +1103,8 @@ class Ot {
|
|
|
1103
1103
|
for (let _ = 0; _ < h - 1; _++) {
|
|
1104
1104
|
const g = _ + 1;
|
|
1105
1105
|
for (let p = 0; p < n - 1; p++) {
|
|
1106
|
-
const M = p + 1, T = _ * n + p, P = _ * n + M,
|
|
1107
|
-
At(I,
|
|
1106
|
+
const M = p + 1, T = _ * n + p, P = _ * n + M, w = g * n + p, k = g * n + M, I = t[T], Z = t[P], U = t[w], z = t[k];
|
|
1107
|
+
At(I, U, Z, o), At(z, Z, U, u), l.addVectors(o, u), s[T].add(l), s[P].add(l), s[w].add(l), s[k].add(l);
|
|
1108
1108
|
}
|
|
1109
1109
|
}
|
|
1110
1110
|
for (let _ = 0; _ < a; _++)
|
|
@@ -1320,7 +1320,7 @@ class pe {
|
|
|
1320
1320
|
return e[s - 1].value;
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
|
-
function
|
|
1323
|
+
function Lt(r, t) {
|
|
1324
1324
|
return r + Math.random() * (t - r);
|
|
1325
1325
|
}
|
|
1326
1326
|
class at {
|
|
@@ -1391,12 +1391,12 @@ class at {
|
|
|
1391
1391
|
getValue(t, e) {
|
|
1392
1392
|
if (this.m_Mode === 0) return this.m_Constant;
|
|
1393
1393
|
if (this.m_Mode === 1)
|
|
1394
|
-
return
|
|
1394
|
+
return Lt(this.m_ConstantMin, this.m_ConstantMax);
|
|
1395
1395
|
const s = this.m_CurveTimeMode === 0 ? t : e;
|
|
1396
1396
|
if (this.m_Mode === 2)
|
|
1397
1397
|
return this.m_Curve.evaluate(s);
|
|
1398
1398
|
if (this.m_Mode === 3)
|
|
1399
|
-
return
|
|
1399
|
+
return Lt(
|
|
1400
1400
|
this.m_CurveMin.evaluate(s),
|
|
1401
1401
|
this.m_CurveMax.evaluate(s)
|
|
1402
1402
|
);
|
|
@@ -1495,7 +1495,7 @@ const D = class D {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
};
|
|
1497
1497
|
D.kMinTwist = -1, D.kMaxTwist = 1, D.kMinBend = 0, D.kMaxBend = 1, D.kMinDuration = 0, D.kMaxDuration = 5;
|
|
1498
|
-
let
|
|
1498
|
+
let Zt = D;
|
|
1499
1499
|
class xe extends Error {
|
|
1500
1500
|
constructor() {
|
|
1501
1501
|
super(
|
|
@@ -1862,8 +1862,8 @@ const W = class W extends c.Group {
|
|
|
1862
1862
|
var B;
|
|
1863
1863
|
if (this.clear(), this.m_Content === null || this.m_Content.isEmpty || this.m_Binding === null) return;
|
|
1864
1864
|
if (this.m_MeshFactory === null && (this.m_MeshFactory = new ce()), this.m_RendererFactory === null) {
|
|
1865
|
-
const
|
|
1866
|
-
|
|
1865
|
+
const C = new c.Object3D();
|
|
1866
|
+
C.name = "Root", this.add(C), this.m_Root = C, this.m_RendererFactory = new ue(this.m_Root);
|
|
1867
1867
|
}
|
|
1868
1868
|
this.m_Direction = this.m_Content.direction;
|
|
1869
1869
|
const t = this.m_Direction > 1 ? Math.PI / 2 : 0;
|
|
@@ -1875,9 +1875,9 @@ const W = class W extends c.Group {
|
|
|
1875
1875
|
const a = this.m_CoverPaperCount + this.m_PagePaperCount, o = Math.floor(i.length / 4);
|
|
1876
1876
|
let u = 0, l = 0, m = 0;
|
|
1877
1877
|
this.m_Papers = new Array(a);
|
|
1878
|
-
for (let
|
|
1879
|
-
const v = this.m_HasCover && (
|
|
1880
|
-
|
|
1878
|
+
for (let C = 0; C < a; C++) {
|
|
1879
|
+
const v = this.m_HasCover && (C < o || C >= a - o), N = this.m_RendererFactory.get("Paper"), b = this.m_Papers[C] = new oe(v, C, this, N);
|
|
1880
|
+
b.renderer.castShadows = this.m_CastShadows, C < Math.round(c.MathUtils.lerp(0, a, h)) && (b.transform.scale.set(-1, 1, 1), b.setTime(1)), v ? (b.setContentData(i[l++], i[l++], C > o), b.setMaterialData(e), b.setPaperSetup(this.m_CoverPaperSetup)) : (b.setContentData(n[u++], n[u++]), b.setMaterialData(s), b.setPaperSetup(this.m_PagePaperSetup)), m += b.thickness;
|
|
1881
1881
|
}
|
|
1882
1882
|
this.m_TotalThickness = m;
|
|
1883
1883
|
const f = this.m_Papers[0].thickness, d = this.m_Papers[Math.floor(a / 2)].thickness;
|
|
@@ -1891,11 +1891,11 @@ const W = class W extends c.Group {
|
|
|
1891
1891
|
this.m_RendererFactory,
|
|
1892
1892
|
this.m_MeshFactory
|
|
1893
1893
|
), this.m_Bound.binderRenderer.setVisibility(!this.m_HideBinder);
|
|
1894
|
-
const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes,
|
|
1895
|
-
for (let
|
|
1896
|
-
const v = this.m_Papers[
|
|
1897
|
-
|
|
1898
|
-
|
|
1894
|
+
const T = this.m_ReduceOverdraw && n.length > 0, P = this.m_ReduceSubMeshes, w = this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P), k = T ? this.createPaperMeshDataPool(this.m_PagePaperSetup, !0, P, !0) : null, I = this.createPaperMeshDataPool(this.m_PagePaperSetup, !1), Z = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !0), U = this.createPaperMeshDataPool(this.m_CoverPaperSetup, !1), z = Math.floor(a / 2) - 1, E = z + 1, A = ((B = this.m_Bound) == null ? void 0 : B.bindingType) === "staple";
|
|
1895
|
+
for (let C = 0; C < a; C++) {
|
|
1896
|
+
const v = this.m_Papers[C];
|
|
1897
|
+
C !== 0 && (v.prev = this.m_Papers[C - 1]), C !== a - 1 && (v.next = this.m_Papers[C + 1]), v.noHole = A && (C === z || C === E), v.isCover ? v.setMeshData(Z.get(), null, U) : v.setMeshData(
|
|
1898
|
+
w.get(),
|
|
1899
1899
|
(k == null ? void 0 : k.get()) ?? null,
|
|
1900
1900
|
I
|
|
1901
1901
|
);
|
|
@@ -2015,14 +2015,14 @@ const W = class W extends c.Group {
|
|
|
2015
2015
|
}
|
|
2016
2016
|
};
|
|
2017
2017
|
W.s_Instances = /* @__PURE__ */ new Set(), W.s_InstancesArray = null;
|
|
2018
|
-
let
|
|
2018
|
+
let wt = W;
|
|
2019
2019
|
class Me {
|
|
2020
2020
|
constructor() {
|
|
2021
2021
|
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;
|
|
2022
2022
|
}
|
|
2023
2023
|
}
|
|
2024
2024
|
const $t = Object.freeze(new c.Vector4(1, 1, 0, 0));
|
|
2025
|
-
class
|
|
2025
|
+
class Le {
|
|
2026
2026
|
constructor() {
|
|
2027
2027
|
this.m_BookContent = null, this.m_IsActive = !1, this.onActiveChangedCallback = null;
|
|
2028
2028
|
}
|
|
@@ -2057,7 +2057,7 @@ class Ze {
|
|
|
2057
2057
|
this.m_IsActive !== t && (this.m_IsActive = t, this.onActiveChanged(), (e = this.onActiveChangedCallback) == null || e.call(this));
|
|
2058
2058
|
}
|
|
2059
2059
|
}
|
|
2060
|
-
class
|
|
2060
|
+
class Ut {
|
|
2061
2061
|
constructor(t, e) {
|
|
2062
2062
|
this.m_Texture = t, this.m_TextureST = e ?? new c.Vector4(1, 1, 0, 0);
|
|
2063
2063
|
}
|
|
@@ -2075,7 +2075,7 @@ class Et {
|
|
|
2075
2075
|
setActive(t) {
|
|
2076
2076
|
}
|
|
2077
2077
|
}
|
|
2078
|
-
class
|
|
2078
|
+
class Ze {
|
|
2079
2079
|
constructor() {
|
|
2080
2080
|
this.m_Direction = j.LeftToRight, this.m_Covers = [null, null, null, null], this.m_Pages = [null, null, null, null, null, null, null, null], this.m_Book = null, this._cachedCovers = null, this._cachedPages = null;
|
|
2081
2081
|
}
|
|
@@ -2130,11 +2130,11 @@ class Ue {
|
|
|
2130
2130
|
getContent(t) {
|
|
2131
2131
|
if (t !== null) {
|
|
2132
2132
|
if (t instanceof c.Texture)
|
|
2133
|
-
return new
|
|
2133
|
+
return new Ut(t);
|
|
2134
2134
|
if (typeof t.init == "function")
|
|
2135
2135
|
return t;
|
|
2136
2136
|
}
|
|
2137
|
-
return new
|
|
2137
|
+
return new Ut(null);
|
|
2138
2138
|
}
|
|
2139
2139
|
init(t) {
|
|
2140
2140
|
this.m_Book = t, this._cachedCovers = null, this._cachedPages = null;
|
|
@@ -2182,14 +2182,14 @@ class Ue {
|
|
|
2182
2182
|
return !this.isCoverPaperSideIndex(t);
|
|
2183
2183
|
}
|
|
2184
2184
|
}
|
|
2185
|
-
class
|
|
2185
|
+
class Ue {
|
|
2186
2186
|
constructor(t, e) {
|
|
2187
2187
|
this.enabled = !0, this.m_Raycaster = new c.Raycaster(), this.m_Mouse = new c.Vector2(), this.m_SelectedBook = null, this.m_IsPointerDown = !1, this.m_OnPointerDown = (s) => {
|
|
2188
2188
|
var n;
|
|
2189
2189
|
if (!this.enabled || s.button !== 0) return;
|
|
2190
2190
|
this.m_IsPointerDown = !0;
|
|
2191
2191
|
const i = this.m_GetRay(s);
|
|
2192
|
-
for (const h of
|
|
2192
|
+
for (const h of wt.instances)
|
|
2193
2193
|
if (h.startTurning(i)) {
|
|
2194
2194
|
this.m_SelectedBook = h, (n = this.onTurnStart) == null || n.call(this, h);
|
|
2195
2195
|
break;
|
|
@@ -2211,7 +2211,7 @@ class Ee {
|
|
|
2211
2211
|
}
|
|
2212
2212
|
class ye {
|
|
2213
2213
|
}
|
|
2214
|
-
class
|
|
2214
|
+
class we {
|
|
2215
2215
|
constructor(t, e) {
|
|
2216
2216
|
this.bindingType = "", this.m_Book = t, this.m_Root = e;
|
|
2217
2217
|
}
|
|
@@ -2219,7 +2219,7 @@ class Ce {
|
|
|
2219
2219
|
dispose() {
|
|
2220
2220
|
}
|
|
2221
2221
|
}
|
|
2222
|
-
function
|
|
2222
|
+
function Et(r, t, e, s) {
|
|
2223
2223
|
const i = 1 - s;
|
|
2224
2224
|
return new c.Vector3(
|
|
2225
2225
|
i * i * r.x + 2 * i * s * t.x + s * s * e.x,
|
|
@@ -2230,10 +2230,10 @@ function Lt(r, t, e, s) {
|
|
|
2230
2230
|
function Nt(r, t) {
|
|
2231
2231
|
return r++, r === t ? 0 : r;
|
|
2232
2232
|
}
|
|
2233
|
-
function
|
|
2233
|
+
function Ce(r, t) {
|
|
2234
2234
|
return r === 0 ? t - 1 : r - 1;
|
|
2235
2235
|
}
|
|
2236
|
-
const Pe = 0.01, Te = 0.1, Se = 0.04, ve = 0.4, ke = 2, Be = 10,
|
|
2236
|
+
const Pe = 0.01, Te = 0.1, Se = 0.04, ve = 0.4, ke = 2, Be = 10, be = 0, Re = 5;
|
|
2237
2237
|
function De(r, t) {
|
|
2238
2238
|
const e = r.clone().normalize();
|
|
2239
2239
|
if (e.lengthSq() === 0) return new c.Quaternion();
|
|
@@ -2290,10 +2290,10 @@ class Ie {
|
|
|
2290
2290
|
return this._quality;
|
|
2291
2291
|
}
|
|
2292
2292
|
set quality(t) {
|
|
2293
|
-
this._quality = H(t,
|
|
2293
|
+
this._quality = H(t, be, Re);
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
|
-
class Ve extends
|
|
2296
|
+
class Ve extends we {
|
|
2297
2297
|
// ── Constructor ────────────────────────────────────────────────────────
|
|
2298
2298
|
constructor(t, e, s, i, n) {
|
|
2299
2299
|
if (super(s, i), this.bindingType = "staple", 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_Quality = t, s.totalThickness * 1.25 > s.minPaperWidth)
|
|
@@ -2340,7 +2340,7 @@ class Ve extends Ce {
|
|
|
2340
2340
|
M = Math.max(M, p * 2);
|
|
2341
2341
|
let T = 0;
|
|
2342
2342
|
T += this.m_Book.totalThickness / 2, T += d;
|
|
2343
|
-
const P = -(this.m_Book.papers[0].thickness / 2 + d),
|
|
2343
|
+
const P = -(this.m_Book.papers[0].thickness / 2 + d), w = [];
|
|
2344
2344
|
{
|
|
2345
2345
|
for (let V = 0; V < m; V++) {
|
|
2346
2346
|
const G = V / (m - 1), K = F(-90, -180, G) * J, y = new c.Vector3(
|
|
@@ -2348,66 +2348,66 @@ class Ve extends Ce {
|
|
|
2348
2348
|
0,
|
|
2349
2349
|
p * Math.cos(K)
|
|
2350
2350
|
);
|
|
2351
|
-
y.x += p, y.z += p, y.x += P,
|
|
2351
|
+
y.x += p, y.z += p, y.x += P, w.push(y);
|
|
2352
2352
|
}
|
|
2353
|
-
const x = new c.Vector3(T, 0, 0),
|
|
2353
|
+
const x = new c.Vector3(T, 0, 0), L = new c.Vector3(T + _ * 0.75, 0, 0), S = new c.Vector3(T - d * 0.5, 0, M);
|
|
2354
2354
|
for (let V = 0; V < f; V++) {
|
|
2355
|
-
const G = V / (f - 1), $ =
|
|
2356
|
-
$.x += P,
|
|
2355
|
+
const G = V / (f - 1), $ = Et(x, L, S, G);
|
|
2356
|
+
$.x += P, w.push($);
|
|
2357
2357
|
}
|
|
2358
|
-
|
|
2358
|
+
w.reverse();
|
|
2359
2359
|
}
|
|
2360
2360
|
const k = new Array(l);
|
|
2361
2361
|
for (let x = 0; x < l; x++) {
|
|
2362
2362
|
const S = (90 - x * (360 / l)) * J;
|
|
2363
2363
|
k[x] = new c.Vector3(Math.cos(S), Math.sin(S), 0), k[x].x *= 0.75;
|
|
2364
2364
|
}
|
|
2365
|
-
const I =
|
|
2366
|
-
(
|
|
2365
|
+
const I = w.length, Z = I * l, U = new Array(Z * 2), z = new Array(Z * 2), E = new Array(
|
|
2366
|
+
(Z * 2 - 1) * l * 2 * 3
|
|
2367
2367
|
);
|
|
2368
|
-
for (let x = 0; x <
|
|
2369
|
-
|
|
2368
|
+
for (let x = 0; x < Z * 2; x++)
|
|
2369
|
+
U[x] = new c.Vector3(), z[x] = new c.Vector3();
|
|
2370
2370
|
let A = 0;
|
|
2371
2371
|
for (let x = 0; x < I; x++) {
|
|
2372
|
-
const
|
|
2372
|
+
const L = w[Ce(x, I)], S = w[x], V = w[Nt(x, I)];
|
|
2373
2373
|
let G;
|
|
2374
2374
|
if (x === 0)
|
|
2375
2375
|
G = new c.Vector3(1, 0, -2).normalize();
|
|
2376
2376
|
else if (x === I - 1)
|
|
2377
2377
|
G = new c.Vector3(0, 0, 1);
|
|
2378
2378
|
else {
|
|
2379
|
-
const it = S.clone().sub(
|
|
2379
|
+
const it = S.clone().sub(L).normalize(), nt = V.clone().sub(S).normalize();
|
|
2380
2380
|
G = it.add(nt).multiplyScalar(0.5);
|
|
2381
2381
|
}
|
|
2382
2382
|
const $ = new c.Vector3(0, 1, 0), K = De(G, $), y = A;
|
|
2383
|
-
let
|
|
2384
|
-
|
|
2383
|
+
let R = Q(0, f / 4, x);
|
|
2384
|
+
R = F(0.1, 1, R), R = Math.sqrt(R);
|
|
2385
2385
|
for (let it = 0; it < l; it++) {
|
|
2386
|
-
const nt = k[it].clone().applyQuaternion(K).multiplyScalar(
|
|
2387
|
-
|
|
2386
|
+
const nt = k[it].clone().applyQuaternion(K).multiplyScalar(R), ct = S.clone().add(nt.clone().multiplyScalar(d));
|
|
2387
|
+
U[A] = ct, z[A] = nt.clone();
|
|
2388
2388
|
const ot = S.clone().add(nt.clone().multiplyScalar(d));
|
|
2389
2389
|
ot.z = s - ot.z;
|
|
2390
|
-
const ee = y + l - it - 1, St =
|
|
2391
|
-
|
|
2390
|
+
const ee = y + l - it - 1, St = Z * 2 - ee - 1;
|
|
2391
|
+
U[St] = ot, z[St] = nt.clone(), A++;
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
2394
2394
|
let B = 0;
|
|
2395
|
-
const
|
|
2396
|
-
for (let x = 0; x <
|
|
2397
|
-
const
|
|
2395
|
+
const C = w.length * 2;
|
|
2396
|
+
for (let x = 0; x < C - 1; x++) {
|
|
2397
|
+
const L = x * l, S = (x + 1) * l;
|
|
2398
2398
|
for (let V = 0; V < l; V++) {
|
|
2399
|
-
const G = Nt(V, l), $ =
|
|
2400
|
-
|
|
2399
|
+
const G = Nt(V, l), $ = L + V, K = L + G, y = S + G, R = S + V;
|
|
2400
|
+
E[B++] = $, E[B++] = R, E[B++] = K, E[B++] = K, E[B++] = R, E[B++] = y;
|
|
2401
2401
|
}
|
|
2402
2402
|
}
|
|
2403
|
-
const v = [...
|
|
2403
|
+
const v = [...U], N = [...z], b = [...E], Y = U.map((x) => x.clone()), tt = [...E];
|
|
2404
2404
|
for (let x = 0; x < a - 1; x++) {
|
|
2405
|
-
const
|
|
2405
|
+
const L = Y.length;
|
|
2406
2406
|
for (let S = 0; S < tt.length; S++)
|
|
2407
|
-
tt[S] +=
|
|
2407
|
+
tt[S] += L;
|
|
2408
2408
|
for (let S = 0; S < Y.length; S++)
|
|
2409
2409
|
Y[S].z += o + s;
|
|
2410
|
-
v.push(...Y.map((S) => S.clone())), N.push(...z.map((S) => S.clone())),
|
|
2410
|
+
v.push(...Y.map((S) => S.clone())), N.push(...z.map((S) => S.clone())), b.push(...tt);
|
|
2411
2411
|
}
|
|
2412
2412
|
const q = new Float32Array(v.length * 3), O = new Float32Array(N.length * 3);
|
|
2413
2413
|
for (let x = 0; x < v.length; x++)
|
|
@@ -2418,7 +2418,7 @@ class Ve extends Ce {
|
|
|
2418
2418
|
), e.setAttribute(
|
|
2419
2419
|
"normal",
|
|
2420
2420
|
new c.BufferAttribute(O, 3)
|
|
2421
|
-
), e.setIndex(
|
|
2421
|
+
), e.setIndex(b);
|
|
2422
2422
|
}
|
|
2423
2423
|
// ── createPaperPattern ────────────────────────────────────────────────
|
|
2424
2424
|
createPaperPattern(t, e, s, i, n, h) {
|
|
@@ -2438,39 +2438,39 @@ class Ve extends Ce {
|
|
|
2438
2438
|
let P = 0;
|
|
2439
2439
|
for (let y = 1; y < u + 1; y++)
|
|
2440
2440
|
M = M.createNext(P), P += T;
|
|
2441
|
-
const
|
|
2441
|
+
const w = (e.x - o) / (f + 1);
|
|
2442
2442
|
for (let y = u + 1; y < _; y++)
|
|
2443
|
-
M = M.createNext(P), P +=
|
|
2443
|
+
M = M.createNext(P), P += w;
|
|
2444
2444
|
const k = new ht(0);
|
|
2445
2445
|
let I = k;
|
|
2446
|
-
const
|
|
2447
|
-
let
|
|
2446
|
+
const Z = e.y / (g - 1);
|
|
2447
|
+
let U = 0;
|
|
2448
2448
|
for (let y = 0; y < g - 1; y++)
|
|
2449
|
-
|
|
2450
|
-
const z = [],
|
|
2449
|
+
U += Z, I = I.createNext(U);
|
|
2450
|
+
const z = [], E = [], A = i.clone();
|
|
2451
2451
|
if (n) {
|
|
2452
2452
|
let y = 0;
|
|
2453
2453
|
this.m_Book.hasCover && (y = Math.floor(this.m_Book.coverPaperCount / 2));
|
|
2454
|
-
const
|
|
2455
|
-
A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) +
|
|
2454
|
+
const R = Math.max(0.01, s);
|
|
2455
|
+
A.left = 0, A.right = (this.getPX(y + 1, s) - this.getPX(y, s) + R) / e.x, A.down = R / e.y, A.up = R / e.y;
|
|
2456
2456
|
}
|
|
2457
2457
|
const B = new le(a, A, !1);
|
|
2458
|
-
B.insert(p, k, z,
|
|
2459
|
-
const
|
|
2458
|
+
B.insert(p, k, z, E), p.updateIndex(0), k.updateIndex(0), pt(z, a.xSeams), pt(E, a.zSeams);
|
|
2459
|
+
const C = this.m_BindingVertexCount + 2, v = new Array(C);
|
|
2460
2460
|
a.xNoneSeamIndexes = v, M = p;
|
|
2461
|
-
for (let y = 0; y <
|
|
2461
|
+
for (let y = 0; y < C; y++) {
|
|
2462
2462
|
v[y] = M.index;
|
|
2463
2463
|
do
|
|
2464
2464
|
M = M.next;
|
|
2465
2465
|
while (M.seam);
|
|
2466
2466
|
}
|
|
2467
|
-
const N = p.getValues(),
|
|
2468
|
-
_ = N.length, g =
|
|
2469
|
-
const Y = _ * g, tt = [], q = new Array(Y).fill(0), O = [], x = [],
|
|
2467
|
+
const N = p.getValues(), b = k.getValues();
|
|
2468
|
+
_ = N.length, g = b.length;
|
|
2469
|
+
const Y = _ * g, tt = [], q = new Array(Y).fill(0), O = [], x = [], L = [], S = [];
|
|
2470
2470
|
Yt(
|
|
2471
2471
|
tt,
|
|
2472
2472
|
N,
|
|
2473
|
-
|
|
2473
|
+
b,
|
|
2474
2474
|
e,
|
|
2475
2475
|
i,
|
|
2476
2476
|
this.m_Book.direction
|
|
@@ -2479,10 +2479,10 @@ class Ve extends Ce {
|
|
|
2479
2479
|
let $ = B.rightNode.index, K = B.upNode.index;
|
|
2480
2480
|
$ === 0 && ($ = _ - 1), K === 0 && (K = g - 1);
|
|
2481
2481
|
for (let y = 0; y < g - 1; y++)
|
|
2482
|
-
for (let
|
|
2483
|
-
if (n && y >= G && y < K &&
|
|
2482
|
+
for (let R = 0; R < _ - 1; R++) {
|
|
2483
|
+
if (n && y >= G && y < K && R >= V && R < $)
|
|
2484
2484
|
continue;
|
|
2485
|
-
const it = y * _ +
|
|
2485
|
+
const it = y * _ + R, nt = y * _ + (R + 1), ct = (y + 1) * _ + R, ot = (y + 1) * _ + (R + 1);
|
|
2486
2486
|
q[it] += 2, q[nt] += 2, q[ct] += 2, q[ot] += 2, Qt(
|
|
2487
2487
|
O,
|
|
2488
2488
|
x,
|
|
@@ -2493,12 +2493,12 @@ class Ve extends Ce {
|
|
|
2493
2493
|
Y
|
|
2494
2494
|
);
|
|
2495
2495
|
}
|
|
2496
|
-
if (S.push(new Tt(0, 0, _ - 1, g - 1, !1, !1)), jt(S,
|
|
2496
|
+
if (S.push(new Tt(0, 0, _ - 1, g - 1, !1, !1)), jt(S, L, tt, _, g), a.baseXArray = N, a.baseZArray = b, a.baseVertexCount = Y, a.vertexCount = tt.length, a.texcoords = tt, a.weights = q, h) {
|
|
2497
2497
|
a.subMeshCount = 1;
|
|
2498
2498
|
const y = [];
|
|
2499
|
-
y.push(...O), y.push(...
|
|
2499
|
+
y.push(...O), y.push(...L), y.push(...x), a.triangles = y;
|
|
2500
2500
|
} else
|
|
2501
|
-
a.subMeshCount = 3, a.frontTriangles = O, a.backTriangles = x, a.borderTriangles =
|
|
2501
|
+
a.subMeshCount = 3, a.frontTriangles = O, a.backTriangles = x, a.borderTriangles = L;
|
|
2502
2502
|
return a.borders = S, a;
|
|
2503
2503
|
}
|
|
2504
2504
|
// ── updateRootPosition ────────────────────────────────────────────────
|
|
@@ -2513,9 +2513,9 @@ class Ve extends Ce {
|
|
|
2513
2513
|
let i = 0;
|
|
2514
2514
|
const n = e.length / 2 - 1, h = e.length / 2;
|
|
2515
2515
|
for (let P = 0; P < s; P++) {
|
|
2516
|
-
const
|
|
2517
|
-
|
|
2518
|
-
const k =
|
|
2516
|
+
const w = e[P];
|
|
2517
|
+
w.updateTime();
|
|
2518
|
+
const k = w.zTime, I = w.thickness;
|
|
2519
2519
|
i += k * I, P === n && (i += k * this.m_BindingMidSpace / 2), P === h && (i += k * this.m_BindingMidSpace / 2);
|
|
2520
2520
|
}
|
|
2521
2521
|
let a = this.getStackHeight(t.index) - t.thickness / 2;
|
|
@@ -2532,16 +2532,16 @@ class Ve extends Ce {
|
|
|
2532
2532
|
let P = 0;
|
|
2533
2533
|
if (this.m_Book.alignToGround) {
|
|
2534
2534
|
_ = e[0].size.x;
|
|
2535
|
-
const
|
|
2536
|
-
g = H(i, 0,
|
|
2535
|
+
const w = this.m_StackHeight / 2;
|
|
2536
|
+
g = H(i, 0, w) - w, p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
|
|
2537
2537
|
}
|
|
2538
2538
|
m = F(M, -P, l);
|
|
2539
2539
|
} else {
|
|
2540
2540
|
let P = 0;
|
|
2541
2541
|
if (this.m_Book.alignToGround) {
|
|
2542
2542
|
_ = e[0].size.x;
|
|
2543
|
-
const
|
|
2544
|
-
g =
|
|
2543
|
+
const w = this.m_StackHeight / 2;
|
|
2544
|
+
g = w - H(i, w, w * 2), p = Math.sqrt(_ * _ - g * g), P = (Math.asin(p / _) * et - 90) * 2;
|
|
2545
2545
|
}
|
|
2546
2546
|
m = F(P, -M, l);
|
|
2547
2547
|
}
|
|
@@ -2632,19 +2632,19 @@ class Ve extends Ce {
|
|
|
2632
2632
|
let e = new c.Vector3(0, 0, 0), s = new c.Vector3(0, 0, 0), i = this.m_BindingRadius * 0.6;
|
|
2633
2633
|
const n = this.m_StapleThickness * 0.5, h = t[0].thickness, a = this.m_Root.matrixWorld.clone(), o = t.length;
|
|
2634
2634
|
for (let u = 0; u < o; u++) {
|
|
2635
|
-
const l = t[u], m = l.transform, f = l.meshData.pattern, d = l.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = l.thickness,
|
|
2636
|
-
let I = u,
|
|
2637
|
-
u >= Math.floor(o / 2) && (I = o - u - 1,
|
|
2638
|
-
const
|
|
2639
|
-
i = this.m_BindingRadius * F(0.45, 0.65, 1 -
|
|
2635
|
+
const l = t[u], m = l.transform, f = l.meshData.pattern, d = l.meshData.baseVertices, _ = f.baseXArray, g = f.baseZArray, p = _.length, M = g.length, T = this.m_BindingVertexCount + 1, P = l.thickness, w = f.xNoneSeamIndexes, k = m.position.clone();
|
|
2636
|
+
let I = u, Z = n;
|
|
2637
|
+
u >= Math.floor(o / 2) && (I = o - u - 1, Z *= -1);
|
|
2638
|
+
const U = (h + P) * 0.5 + P * (I - 1), z = m.matrixWorld.clone().invert().multiply(a), E = I / (o / 2);
|
|
2639
|
+
i = this.m_BindingRadius * F(0.45, 0.65, 1 - E);
|
|
2640
2640
|
for (let A = 0; A < M; A++) {
|
|
2641
|
-
const B = g[A],
|
|
2641
|
+
const B = g[A], C = new c.Vector3(0, 0, k.z + B), v = k.clone();
|
|
2642
2642
|
v.z += B;
|
|
2643
2643
|
const N = l.getDirection(B).multiplyScalar(i).add(v.clone());
|
|
2644
2644
|
if (u === 0 && A === 0) {
|
|
2645
|
-
const O = t[o - 1],
|
|
2646
|
-
|
|
2647
|
-
const S = O.getDirection(B).multiplyScalar(i).add(
|
|
2645
|
+
const O = t[o - 1], L = O.transform.position.clone().clone();
|
|
2646
|
+
L.z += B;
|
|
2647
|
+
const S = O.getDirection(B).multiplyScalar(i).add(L);
|
|
2648
2648
|
s = N.clone().sub(S).normalize(), e = new c.Vector3(
|
|
2649
2649
|
-s.y,
|
|
2650
2650
|
s.x,
|
|
@@ -2653,14 +2653,14 @@ class Ve extends Ce {
|
|
|
2653
2653
|
const V = Math.atan2(e.y, e.x) * et;
|
|
2654
2654
|
this.stapleMesh.rotation.set(0, 0, V * J);
|
|
2655
2655
|
}
|
|
2656
|
-
I > 0 &&
|
|
2657
|
-
const
|
|
2658
|
-
d[
|
|
2659
|
-
const Y =
|
|
2660
|
-
d[
|
|
2656
|
+
I > 0 && C.add(e.clone().multiplyScalar(U));
|
|
2657
|
+
const b = A * p;
|
|
2658
|
+
d[b] = C.clone().applyMatrix4(z), C.add(s.clone().multiplyScalar(Z));
|
|
2659
|
+
const Y = C.clone().applyMatrix4(z), tt = N.clone().applyMatrix4(z), q = v.clone().applyMatrix4(z);
|
|
2660
|
+
d[b + w[1]] = Y;
|
|
2661
2661
|
for (let O = 2; O < T; O++) {
|
|
2662
2662
|
const x = Q(1, T, O);
|
|
2663
|
-
d[
|
|
2663
|
+
d[b + w[O]] = Et(
|
|
2664
2664
|
Y,
|
|
2665
2665
|
tt,
|
|
2666
2666
|
q,
|
|
@@ -2721,7 +2721,7 @@ class ze {
|
|
|
2721
2721
|
return this.mesh;
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
|
-
class
|
|
2724
|
+
class Ee extends ye {
|
|
2725
2725
|
constructor() {
|
|
2726
2726
|
super(...arguments), this.quality = 3, this.stapleSetup = new Ie();
|
|
2727
2727
|
}
|
|
@@ -2736,7 +2736,7 @@ class Le extends ye {
|
|
|
2736
2736
|
}
|
|
2737
2737
|
class Kt {
|
|
2738
2738
|
constructor(t) {
|
|
2739
|
-
this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0;
|
|
2739
|
+
this.x = (t == null ? void 0 : t.x) ?? 0, this.y = (t == null ? void 0 : t.y) ?? 0, this.width = (t == null ? void 0 : t.width) ?? 0, this.text = (t == null ? void 0 : t.text) ?? "", this.fontFamily = (t == null ? void 0 : t.fontFamily) ?? "Georgia", this.fontSize = (t == null ? void 0 : t.fontSize) ?? 24, this.fontWeight = (t == null ? void 0 : t.fontWeight) ?? "normal", this.fontStyle = (t == null ? void 0 : t.fontStyle) ?? "normal", this.color = (t == null ? void 0 : t.color) ?? "#222", this.lineHeight = (t == null ? void 0 : t.lineHeight) ?? 1.4, this.textAlign = (t == null ? void 0 : t.textAlign) ?? "left", this.opacity = (t == null ? void 0 : t.opacity) ?? 1, this.shadowColor = (t == null ? void 0 : t.shadowColor) ?? "", this.shadowBlur = (t == null ? void 0 : t.shadowBlur) ?? 0, this.shadowOffsetX = (t == null ? void 0 : t.shadowOffsetX) ?? 0, this.shadowOffsetY = (t == null ? void 0 : t.shadowOffsetY) ?? 0, this.textTransform = (t == null ? void 0 : t.textTransform) ?? "none", this.textDecoration = (t == null ? void 0 : t.textDecoration) ?? "none", this.background = (t == null ? void 0 : t.background) ?? "", this.backgroundPadding = (t == null ? void 0 : t.backgroundPadding) ?? 0, this.maxLines = (t == null ? void 0 : t.maxLines) ?? 0, this.height = (t == null ? void 0 : t.height) ?? 0, this.verticalAlign = (t == null ? void 0 : t.verticalAlign) ?? "top", this.rotation = (t == null ? void 0 : t.rotation) ?? 0;
|
|
2740
2740
|
}
|
|
2741
2741
|
_font() {
|
|
2742
2742
|
return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px ${this.fontFamily}`;
|
|
@@ -2747,35 +2747,53 @@ class Kt {
|
|
|
2747
2747
|
*/
|
|
2748
2748
|
wrapLines(t) {
|
|
2749
2749
|
if (!this.text) return [];
|
|
2750
|
-
|
|
2750
|
+
t.font = this._font();
|
|
2751
|
+
let e = this.text;
|
|
2752
|
+
if (this.textTransform === "uppercase" ? e = e.toUpperCase() : this.textTransform === "lowercase" ? e = e.toLowerCase() : this.textTransform === "capitalize" && (e = e.replace(/\b\w/g, (i) => i.toUpperCase())), this.width <= 0) {
|
|
2753
|
+
const i = e.split(`
|
|
2751
2754
|
`);
|
|
2752
|
-
|
|
2753
|
-
|
|
2755
|
+
return this._applyMaxLines(t, i);
|
|
2756
|
+
}
|
|
2757
|
+
const s = [];
|
|
2758
|
+
for (const i of e.split(`
|
|
2754
2759
|
`)) {
|
|
2755
|
-
if (
|
|
2756
|
-
|
|
2760
|
+
if (i === "") {
|
|
2761
|
+
s.push("");
|
|
2757
2762
|
continue;
|
|
2758
2763
|
}
|
|
2759
|
-
const
|
|
2760
|
-
let
|
|
2761
|
-
for (const
|
|
2762
|
-
const
|
|
2763
|
-
t.measureText(
|
|
2764
|
+
const n = i.split(/\s+/);
|
|
2765
|
+
let h = "";
|
|
2766
|
+
for (const a of n) {
|
|
2767
|
+
const o = h ? `${h} ${a}` : a;
|
|
2768
|
+
t.measureText(o).width > this.width && h ? (s.push(h), h = a) : h = o;
|
|
2764
2769
|
}
|
|
2765
|
-
|
|
2770
|
+
h && s.push(h);
|
|
2766
2771
|
}
|
|
2767
|
-
return
|
|
2772
|
+
return this._applyMaxLines(t, s);
|
|
2773
|
+
}
|
|
2774
|
+
_applyMaxLines(t, e) {
|
|
2775
|
+
if (this.maxLines <= 0 || e.length <= this.maxLines) return e;
|
|
2776
|
+
const s = e.slice(0, this.maxLines);
|
|
2777
|
+
let i = s[s.length - 1] + "…";
|
|
2778
|
+
if (this.width > 0)
|
|
2779
|
+
for (; t.measureText(i).width > this.width && i.length > 1; )
|
|
2780
|
+
i = i.slice(0, -2) + "…";
|
|
2781
|
+
return s[s.length - 1] = i, s;
|
|
2768
2782
|
}
|
|
2769
2783
|
/** Total rendered height in canvas pixels. */
|
|
2770
2784
|
measureHeight(t) {
|
|
2771
|
-
|
|
2785
|
+
const e = this.wrapLines(t);
|
|
2786
|
+
return (this.maxLines > 0 && e.length > this.maxLines ? this.maxLines : e.length) * this.fontSize * this.lineHeight;
|
|
2772
2787
|
}
|
|
2773
|
-
/**
|
|
2788
|
+
/**
|
|
2789
|
+
* Returns true if the point (px, py) is within the text bounding box.
|
|
2790
|
+
* Note: rotation is not accounted for — the hit area is always axis-aligned.
|
|
2791
|
+
*/
|
|
2774
2792
|
hitTest(t, e, s) {
|
|
2775
2793
|
const i = this.wrapLines(t);
|
|
2776
2794
|
if (i.length === 0) return !1;
|
|
2777
|
-
const n = i.length * this.fontSize * this.lineHeight, h = this.width > 0 ? this.width : this._maxLineWidth(t, i);
|
|
2778
|
-
return e >= this.x && e <= this.x +
|
|
2795
|
+
const n = i.length * this.fontSize * this.lineHeight, h = this.height > 0 ? this.height : n, a = this.width > 0 ? this.width : this._maxLineWidth(t, i);
|
|
2796
|
+
return e >= this.x && e <= this.x + a && s >= this.y && s <= this.y + h;
|
|
2779
2797
|
}
|
|
2780
2798
|
_maxLineWidth(t, e) {
|
|
2781
2799
|
t.font = this._font();
|
|
@@ -2790,11 +2808,37 @@ class Kt {
|
|
|
2790
2808
|
if (!this.text || this.opacity <= 0) return;
|
|
2791
2809
|
const e = this.wrapLines(t);
|
|
2792
2810
|
if (e.length === 0) return;
|
|
2793
|
-
t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top"
|
|
2794
|
-
const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e);
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2811
|
+
t.save(), t.globalAlpha = this.opacity, t.font = this._font(), t.fillStyle = this.color, t.textBaseline = "top";
|
|
2812
|
+
const s = this.fontSize * this.lineHeight, i = this.width > 0 ? this.width : this._maxLineWidth(t, e), n = e.length * s, h = this.height > 0 ? this.height : n;
|
|
2813
|
+
if (this.rotation !== 0) {
|
|
2814
|
+
const o = this.x + i / 2, u = this.y + h / 2;
|
|
2815
|
+
t.translate(o, u), t.rotate(this.rotation), t.translate(-o, -u);
|
|
2816
|
+
}
|
|
2817
|
+
this.background && (t.fillStyle = this.background, t.fillRect(
|
|
2818
|
+
this.x - this.backgroundPadding,
|
|
2819
|
+
this.y - this.backgroundPadding,
|
|
2820
|
+
i + this.backgroundPadding * 2,
|
|
2821
|
+
h + this.backgroundPadding * 2
|
|
2822
|
+
), t.fillStyle = this.color), this.shadowColor && this.shadowBlur > 0 && (t.shadowColor = this.shadowColor, t.shadowBlur = this.shadowBlur, t.shadowOffsetX = this.shadowOffsetX, t.shadowOffsetY = this.shadowOffsetY);
|
|
2823
|
+
let a = this.y;
|
|
2824
|
+
this.height > 0 && this.verticalAlign !== "top" && (this.verticalAlign === "middle" ? a = this.y + (this.height - n) / 2 : this.verticalAlign === "bottom" && (a = this.y + this.height - n));
|
|
2825
|
+
for (let o = 0; o < e.length; o++) {
|
|
2826
|
+
let u = this.x;
|
|
2827
|
+
this.textAlign === "center" ? u = this.x + (i - t.measureText(e[o]).width) / 2 : this.textAlign === "right" && (u = this.x + i - t.measureText(e[o]).width);
|
|
2828
|
+
const l = a + o * s;
|
|
2829
|
+
if (t.fillText(e[o], u, l), this.textDecoration !== "none") {
|
|
2830
|
+
const m = t.shadowColor, f = t.shadowBlur;
|
|
2831
|
+
t.shadowColor = "", t.shadowBlur = 0;
|
|
2832
|
+
const d = t.measureText(e[o]).width;
|
|
2833
|
+
if (t.beginPath(), t.strokeStyle = this.color, t.lineWidth = 1, this.textDecoration === "underline") {
|
|
2834
|
+
const _ = l + this.fontSize + 2;
|
|
2835
|
+
t.moveTo(u, _), t.lineTo(u + d, _);
|
|
2836
|
+
} else if (this.textDecoration === "strikethrough") {
|
|
2837
|
+
const _ = l + this.fontSize * 0.55;
|
|
2838
|
+
t.moveTo(u, _), t.lineTo(u + d, _);
|
|
2839
|
+
}
|
|
2840
|
+
t.stroke(), t.shadowColor = m, t.shadowBlur = f;
|
|
2841
|
+
}
|
|
2798
2842
|
}
|
|
2799
2843
|
t.restore();
|
|
2800
2844
|
}
|
|
@@ -2811,7 +2855,7 @@ function Jt(r, t) {
|
|
|
2811
2855
|
});
|
|
2812
2856
|
}
|
|
2813
2857
|
function te(r, t) {
|
|
2814
|
-
t.x !== void 0 && (r.x = t.x), t.y !== void 0 && (r.y = t.y), t.width !== void 0 && (r.width = t.width), t.text !== void 0 && (r.text = t.text), t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && (r.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (r.fontStyle = t.fontStyle), t.color !== void 0 && (r.color = t.color), t.lineHeight !== void 0 && (r.lineHeight = t.lineHeight), t.textAlign !== void 0 && (r.textAlign = t.textAlign), t.opacity !== void 0 && (r.opacity = t.opacity), t.shadowColor !== void 0 && (r.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (r.shadowBlur = t.shadowBlur);
|
|
2858
|
+
t.x !== void 0 && (r.x = t.x), t.y !== void 0 && (r.y = t.y), t.width !== void 0 && (r.width = t.width), t.text !== void 0 && (r.text = t.text), t.fontFamily !== void 0 && (r.fontFamily = t.fontFamily), t.fontSize !== void 0 && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && (r.fontWeight = t.fontWeight), t.fontStyle !== void 0 && (r.fontStyle = t.fontStyle), t.color !== void 0 && (r.color = t.color), t.lineHeight !== void 0 && (r.lineHeight = t.lineHeight), t.textAlign !== void 0 && (r.textAlign = t.textAlign), t.opacity !== void 0 && (r.opacity = t.opacity), t.shadowColor !== void 0 && (r.shadowColor = t.shadowColor), t.shadowBlur !== void 0 && (r.shadowBlur = t.shadowBlur), t.shadowOffsetX !== void 0 && (r.shadowOffsetX = t.shadowOffsetX), t.shadowOffsetY !== void 0 && (r.shadowOffsetY = t.shadowOffsetY), t.textTransform !== void 0 && (r.textTransform = t.textTransform), t.textDecoration !== void 0 && (r.textDecoration = t.textDecoration), t.background !== void 0 && (r.background = t.background), t.backgroundPadding !== void 0 && (r.backgroundPadding = t.backgroundPadding), t.maxLines !== void 0 && (r.maxLines = t.maxLines), t.height !== void 0 && (r.height = t.height), t.verticalAlign !== void 0 && (r.verticalAlign = t.verticalAlign), t.rotation !== void 0 && (r.rotation = t.rotation);
|
|
2815
2859
|
}
|
|
2816
2860
|
class Ne {
|
|
2817
2861
|
constructor(t) {
|
|
@@ -3040,19 +3084,19 @@ export {
|
|
|
3040
3084
|
at as AutoTurnSetting,
|
|
3041
3085
|
ge as AutoTurnSettingCurveTimeMode,
|
|
3042
3086
|
fe as AutoTurnSettingMode,
|
|
3043
|
-
|
|
3044
|
-
|
|
3087
|
+
Zt as AutoTurnSettings,
|
|
3088
|
+
wt as Book,
|
|
3045
3089
|
ye as BookBinding,
|
|
3046
|
-
|
|
3047
|
-
|
|
3090
|
+
we as BookBound,
|
|
3091
|
+
Ze as BookContent,
|
|
3048
3092
|
j as BookDirection,
|
|
3049
3093
|
xe as BookHeightException,
|
|
3050
|
-
|
|
3094
|
+
Ue as BookPointerInteraction,
|
|
3051
3095
|
_e as BookRenderer,
|
|
3052
|
-
|
|
3096
|
+
Ct as Cylinder,
|
|
3053
3097
|
ce as MeshFactory,
|
|
3054
3098
|
Wt as PX_PER_UNIT,
|
|
3055
|
-
|
|
3099
|
+
Le as PageContent,
|
|
3056
3100
|
oe as Paper,
|
|
3057
3101
|
Tt as PaperBorder,
|
|
3058
3102
|
zt as PaperMaterialData,
|
|
@@ -3067,8 +3111,8 @@ export {
|
|
|
3067
3111
|
gt as PaperUVMargin,
|
|
3068
3112
|
ue as RendererFactory,
|
|
3069
3113
|
We as SpreadContent,
|
|
3070
|
-
|
|
3071
|
-
|
|
3114
|
+
Ut as SpritePageContent2,
|
|
3115
|
+
Ee as StapleBookBinding,
|
|
3072
3116
|
Ve as StapleBookBound,
|
|
3073
3117
|
Ie as StapleSetup,
|
|
3074
3118
|
Kt as TextBlock,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textContentUtils.d.ts","sourceRoot":"","sources":["../src/textContentUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,GAAG;IAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAA;CAAE,CAAC;AAErE,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,GAAG,GAAG,IAAI,cAAc,CAEzE;AAID;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,MAAM,EAAE,iBAAiB,GACxB,IAAI,CAWN;AAID;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACjC,IAAI,
|
|
1
|
+
{"version":3,"file":"textContentUtils.d.ts","sourceRoot":"","sources":["../src/textContentUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,GAAG;IAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAA;CAAE,CAAC;AAErE,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,GAAG,GAAG,IAAI,cAAc,CAEzE;AAID;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,CAAC,QAAQ,EACpB,MAAM,EAAE,iBAAiB,GACxB,IAAI,CAWN;AAID;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GACjC,IAAI,CAyBN"}
|