@objectifthunes/three-book 0.4.2 → 0.5.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/TextOverlayContent.d.ts +3 -0
- package/dist/TextOverlayContent.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/package.json +31 -30
|
@@ -40,11 +40,14 @@ export declare class TextOverlayContent implements IPageContent {
|
|
|
40
40
|
private readonly _texture;
|
|
41
41
|
private readonly _textureST;
|
|
42
42
|
private _source;
|
|
43
|
+
private _dirty;
|
|
43
44
|
get texture(): THREE.Texture;
|
|
44
45
|
get textureST(): THREE.Vector4;
|
|
45
46
|
/** The base layer drawn beneath text blocks. */
|
|
46
47
|
get source(): HTMLCanvasElement | HTMLImageElement | null;
|
|
47
48
|
set source(v: HTMLCanvasElement | HTMLImageElement | null);
|
|
49
|
+
/** Mark the overlay as needing a re-composite on the next update(). */
|
|
50
|
+
markDirty(): void;
|
|
48
51
|
constructor(options?: TextOverlayContentOptions);
|
|
49
52
|
addText(options?: TextBlockOptions): TextBlock;
|
|
50
53
|
removeText(text: TextBlock): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextOverlayContent.d.ts","sourceRoot":"","sources":["../src/TextOverlayContent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,MAAM,WAAW,yBAAyB;IACxC,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC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AAC,UAAU,CAAiC;IAC5D,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,MAAM,CAAQ;IAEtB,IAAI,OAAO,IAAI,KAAK,CAAC,OAAO,CAA0B;IACtD,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAA4B;IAE1D,gDAAgD;IAChD,IAAI,MAAM,IAAI,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,CAAyB;IAClF,IAAI,MAAM,CAAC,CAAC,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,EAA2C;IAEpG,uEAAuE;IACvE,SAAS,IAAI,IAAI;gBAEL,OAAO,CAAC,EAAE,yBAAyB;IAmB/C,OAAO,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS;IAO9C,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAKjC,sEAAsE;IACtE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI;IASnE;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI;IAsBnC;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI;IAMzC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,GAAG,OAAO;IAIpD,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,IAAI;IAErC,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAEjC,OAAO,IAAI,IAAI;CAKhB"}
|
package/dist/index.js
CHANGED
|
@@ -2814,7 +2814,7 @@ function Jt(r, t) {
|
|
|
2814
2814
|
}
|
|
2815
2815
|
class Le {
|
|
2816
2816
|
constructor(t) {
|
|
2817
|
-
this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0);
|
|
2817
|
+
this.texts = [], this._textureST = new l.Vector4(1, 1, 0, 0), this._dirty = !0;
|
|
2818
2818
|
const e = (t == null ? void 0 : t.width) ?? 512, s = (t == null ? void 0 : t.height) ?? 512;
|
|
2819
2819
|
this.canvas = document.createElement("canvas"), this.canvas.width = e, this.canvas.height = s;
|
|
2820
2820
|
const i = this.canvas.getContext("2d");
|
|
@@ -2832,21 +2832,25 @@ class Le {
|
|
|
2832
2832
|
return this._source;
|
|
2833
2833
|
}
|
|
2834
2834
|
set source(t) {
|
|
2835
|
-
this._source = t;
|
|
2835
|
+
this._source = t, this._dirty = !0;
|
|
2836
|
+
}
|
|
2837
|
+
/** Mark the overlay as needing a re-composite on the next update(). */
|
|
2838
|
+
markDirty() {
|
|
2839
|
+
this._dirty = !0;
|
|
2836
2840
|
}
|
|
2837
2841
|
// ── Text API ─────────────────────────────────────────────────────────────
|
|
2838
2842
|
addText(t) {
|
|
2839
2843
|
const e = new Yt(t);
|
|
2840
|
-
return this.texts.push(e), e;
|
|
2844
|
+
return this.texts.push(e), this._dirty = !0, e;
|
|
2841
2845
|
}
|
|
2842
2846
|
removeText(t) {
|
|
2843
2847
|
const e = this.texts.indexOf(t);
|
|
2844
|
-
e !== -1 && this.texts.splice(e, 1);
|
|
2848
|
+
e !== -1 && (this.texts.splice(e, 1), this._dirty = !0);
|
|
2845
2849
|
}
|
|
2846
2850
|
/** Update a text block by index. Only provided fields are changed. */
|
|
2847
2851
|
updateText(t, e) {
|
|
2848
2852
|
const s = this.texts[t];
|
|
2849
|
-
s && Jt(s, e);
|
|
2853
|
+
s && (Jt(s, e), this._dirty = !0);
|
|
2850
2854
|
}
|
|
2851
2855
|
// ── Per-frame update ─────────────────────────────────────────────────────
|
|
2852
2856
|
/**
|
|
@@ -2858,6 +2862,8 @@ class Le {
|
|
|
2858
2862
|
* clones material textures).
|
|
2859
2863
|
*/
|
|
2860
2864
|
update(t) {
|
|
2865
|
+
if (!this._dirty && !this._source) return;
|
|
2866
|
+
this._dirty = !1;
|
|
2861
2867
|
const { ctx: e, canvas: s } = this, i = s.width, n = s.height;
|
|
2862
2868
|
e.clearRect(0, 0, i, n), this._source && e.drawImage(this._source, 0, 0, i, n);
|
|
2863
2869
|
for (const h of this.texts) h.draw(e);
|
package/package.json
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
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
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@objectifthunes/three-book",
|
|
3
|
+
"version": "0.5.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
|
+
"scripts": {
|
|
17
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
18
|
+
"typecheck": "tsc --noEmit",
|
|
19
|
+
"prepack": "pnpm run build"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"three": ">=0.150.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"three": "^0.172.0",
|
|
26
|
+
"@types/three": "^0.172.0",
|
|
27
|
+
"typescript": "^5.7.0",
|
|
28
|
+
"vite": "^6.0.0",
|
|
29
|
+
"vite-plugin-dts": "^4.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|