three-text 0.2.17 → 0.2.19
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/README.md +8 -8
- package/dist/index.cjs +133 -105
- package/dist/index.d.ts +48 -43
- package/dist/index.js +133 -105
- package/dist/index.min.cjs +259 -251
- package/dist/index.min.js +319 -311
- package/dist/index.umd.js +133 -105
- package/dist/index.umd.min.js +295 -287
- package/dist/three/index.cjs +1 -0
- package/dist/three/index.d.ts +13 -1
- package/dist/three/index.js +1 -0
- package/dist/three/react.cjs +2 -1
- package/dist/three/react.d.ts +18 -12
- package/dist/three/react.js +2 -1
- package/dist/types/core/Text.d.ts +0 -1
- package/dist/types/core/geometry/Extruder.d.ts +1 -0
- package/dist/types/core/types.d.ts +10 -3
- package/dist/types/three/index.d.ts +6 -1
- package/dist/types/three/react.d.ts +1 -0
- package/package.json +14 -3
package/dist/three/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ class Text {
|
|
|
47
47
|
static { this.init = Text$1.Text.init; }
|
|
48
48
|
static { this.registerPattern = Text$1.Text.registerPattern; }
|
|
49
49
|
static { this.preloadPatterns = Text$1.Text.preloadPatterns; }
|
|
50
|
+
static { this.setMaxFontCacheMemoryMB = Text$1.Text.setMaxFontCacheMemoryMB; }
|
|
50
51
|
// Main API - wraps core result in BufferGeometry
|
|
51
52
|
static async create(options) {
|
|
52
53
|
const coreResult = await Text$1.Text.create(options);
|
package/dist/three/index.d.ts
CHANGED
|
@@ -10,10 +10,21 @@ interface HyphenationTrieNode {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
interface CacheStats {
|
|
14
|
+
hits: number;
|
|
15
|
+
misses: number;
|
|
16
|
+
evictions: number;
|
|
17
|
+
size: number;
|
|
18
|
+
memoryUsage: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
interface ThreeTextGeometryInfo extends Omit<TextGeometryInfo, 'vertices' | 'normals' | 'indices' | 'colors' | 'glyphAttributes'> {
|
|
14
22
|
geometry: BufferGeometry;
|
|
15
23
|
getLoadedFont(): LoadedFont | undefined;
|
|
16
|
-
getCacheStatistics():
|
|
24
|
+
getCacheStatistics(): (CacheStats & {
|
|
25
|
+
hitRate: number;
|
|
26
|
+
memoryUsageMB: number;
|
|
27
|
+
}) | null;
|
|
17
28
|
clearCache(): void;
|
|
18
29
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
19
30
|
update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
|
|
@@ -24,6 +35,7 @@ declare class Text {
|
|
|
24
35
|
static init: typeof Text$1.init;
|
|
25
36
|
static registerPattern: typeof Text$1.registerPattern;
|
|
26
37
|
static preloadPatterns: typeof Text$1.preloadPatterns;
|
|
38
|
+
static setMaxFontCacheMemoryMB: typeof Text$1.setMaxFontCacheMemoryMB;
|
|
27
39
|
static create(options: TextOptions): Promise<ThreeTextGeometryInfo>;
|
|
28
40
|
}
|
|
29
41
|
|
package/dist/three/index.js
CHANGED
|
@@ -45,6 +45,7 @@ class Text {
|
|
|
45
45
|
static { this.init = Text$1.init; }
|
|
46
46
|
static { this.registerPattern = Text$1.registerPattern; }
|
|
47
47
|
static { this.preloadPatterns = Text$1.preloadPatterns; }
|
|
48
|
+
static { this.setMaxFontCacheMemoryMB = Text$1.setMaxFontCacheMemoryMB; }
|
|
48
49
|
// Main API - wraps core result in BufferGeometry
|
|
49
50
|
static async create(options) {
|
|
50
51
|
const coreResult = await Text$1.create(options);
|
package/dist/three/react.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var THREE = require('three');
|
|
6
|
-
var index = require('./index');
|
|
6
|
+
var index = require('./index.cjs');
|
|
7
7
|
|
|
8
8
|
function _interopNamespaceDefault(e) {
|
|
9
9
|
var n = Object.create(null);
|
|
@@ -142,6 +142,7 @@ const Text = Object.assign(Text$1, {
|
|
|
142
142
|
init: index.Text.init,
|
|
143
143
|
registerPattern: index.Text.registerPattern,
|
|
144
144
|
preloadPatterns: index.Text.preloadPatterns,
|
|
145
|
+
setMaxFontCacheMemoryMB: index.Text.setMaxFontCacheMemoryMB,
|
|
145
146
|
create: index.Text.create
|
|
146
147
|
});
|
|
147
148
|
|
package/dist/three/react.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ interface HyphenationTrieNode {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
interface CacheStats {
|
|
13
|
+
hits: number;
|
|
14
|
+
misses: number;
|
|
15
|
+
evictions: number;
|
|
16
|
+
size: number;
|
|
17
|
+
memoryUsage: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
interface BoundingBox {
|
|
13
21
|
min: {
|
|
14
22
|
x: number;
|
|
@@ -183,13 +191,19 @@ interface TextGeometryInfo {
|
|
|
183
191
|
pointsRemovedByVisvalingam: number;
|
|
184
192
|
pointsRemovedByColinear: number;
|
|
185
193
|
originalPointCount: number;
|
|
186
|
-
}
|
|
194
|
+
} & Partial<CacheStats & {
|
|
195
|
+
hitRate: number;
|
|
196
|
+
memoryUsageMB: number;
|
|
197
|
+
}>;
|
|
187
198
|
query(options: TextQueryOptions): TextRange[];
|
|
188
199
|
coloredRanges?: ColoredRange[];
|
|
189
200
|
}
|
|
190
201
|
interface TextHandle extends TextGeometryInfo {
|
|
191
202
|
getLoadedFont(): LoadedFont | undefined;
|
|
192
|
-
getCacheStatistics():
|
|
203
|
+
getCacheStatistics(): (CacheStats & {
|
|
204
|
+
hitRate: number;
|
|
205
|
+
memoryUsageMB: number;
|
|
206
|
+
}) | null;
|
|
193
207
|
clearCache(): void;
|
|
194
208
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
195
209
|
update(options: Partial<TextOptions>): Promise<TextHandle>;
|
|
@@ -228,7 +242,7 @@ interface ColoredRange {
|
|
|
228
242
|
}
|
|
229
243
|
interface TextOptions {
|
|
230
244
|
text: string;
|
|
231
|
-
font
|
|
245
|
+
font: string | ArrayBuffer;
|
|
232
246
|
size?: number;
|
|
233
247
|
depth?: number;
|
|
234
248
|
lineHeight?: number;
|
|
@@ -329,7 +343,6 @@ declare class Text$1 {
|
|
|
329
343
|
getFontMetrics(): FontMetrics;
|
|
330
344
|
static preloadPatterns(languages: string[], patternsPath?: string): Promise<void>;
|
|
331
345
|
static registerPattern(language: string, pattern: HyphenationTrieNode): void;
|
|
332
|
-
static clearFontCache(): void;
|
|
333
346
|
static setMaxFontCacheMemoryMB(limitMB: number): void;
|
|
334
347
|
getLoadedFont(): LoadedFont | undefined;
|
|
335
348
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
@@ -343,14 +356,6 @@ declare class Text$1 {
|
|
|
343
356
|
destroy(): void;
|
|
344
357
|
}
|
|
345
358
|
|
|
346
|
-
interface CacheStats {
|
|
347
|
-
hits: number;
|
|
348
|
-
misses: number;
|
|
349
|
-
evictions: number;
|
|
350
|
-
size: number;
|
|
351
|
-
memoryUsage: number;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
359
|
interface ThreeTextProps extends Omit<TextOptions$1, 'text'> {
|
|
355
360
|
children: string;
|
|
356
361
|
font: string | ArrayBuffer;
|
|
@@ -369,6 +374,7 @@ declare const Text: react.ForwardRefExoticComponent<ThreeTextProps & react.RefAt
|
|
|
369
374
|
init: typeof Text$1.init;
|
|
370
375
|
registerPattern: typeof Text$1.registerPattern;
|
|
371
376
|
preloadPatterns: typeof Text$1.preloadPatterns;
|
|
377
|
+
setMaxFontCacheMemoryMB: typeof Text$1.setMaxFontCacheMemoryMB;
|
|
372
378
|
create: typeof Text$2.create;
|
|
373
379
|
};
|
|
374
380
|
|
package/dist/three/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef, useState, useRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
|
-
import { Text as Text$2 } from './index';
|
|
4
|
+
import { Text as Text$2 } from './index.js';
|
|
5
5
|
|
|
6
6
|
function deepEqual(a, b) {
|
|
7
7
|
if (a === b)
|
|
@@ -121,6 +121,7 @@ const Text = Object.assign(Text$1, {
|
|
|
121
121
|
init: Text$2.init,
|
|
122
122
|
registerPattern: Text$2.registerPattern,
|
|
123
123
|
preloadPatterns: Text$2.preloadPatterns,
|
|
124
|
+
setMaxFontCacheMemoryMB: Text$2.setMaxFontCacheMemoryMB,
|
|
124
125
|
create: Text$2.create
|
|
125
126
|
});
|
|
126
127
|
|
|
@@ -43,7 +43,6 @@ export declare class Text {
|
|
|
43
43
|
getFontMetrics(): FontMetrics;
|
|
44
44
|
static preloadPatterns(languages: string[], patternsPath?: string): Promise<void>;
|
|
45
45
|
static registerPattern(language: string, pattern: HyphenationTrieNode): void;
|
|
46
|
-
static clearFontCache(): void;
|
|
47
46
|
static setMaxFontCacheMemoryMB(limitMB: number): void;
|
|
48
47
|
getLoadedFont(): LoadedFont | undefined;
|
|
49
48
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HyphenationTrieNode } from '../hyphenation';
|
|
2
|
+
import type { CacheStats } from '../utils/LRUCache';
|
|
2
3
|
import type { Vec2, Vec3, BoundingBox } from './vectors';
|
|
3
4
|
export type { HyphenationTrieNode };
|
|
4
5
|
export interface Path {
|
|
@@ -249,13 +250,19 @@ export interface TextGeometryInfo {
|
|
|
249
250
|
pointsRemovedByVisvalingam: number;
|
|
250
251
|
pointsRemovedByColinear: number;
|
|
251
252
|
originalPointCount: number;
|
|
252
|
-
}
|
|
253
|
+
} & Partial<CacheStats & {
|
|
254
|
+
hitRate: number;
|
|
255
|
+
memoryUsageMB: number;
|
|
256
|
+
}>;
|
|
253
257
|
query(options: TextQueryOptions): TextRange[];
|
|
254
258
|
coloredRanges?: ColoredRange[];
|
|
255
259
|
}
|
|
256
260
|
export interface TextHandle extends TextGeometryInfo {
|
|
257
261
|
getLoadedFont(): LoadedFont | undefined;
|
|
258
|
-
getCacheStatistics():
|
|
262
|
+
getCacheStatistics(): (CacheStats & {
|
|
263
|
+
hitRate: number;
|
|
264
|
+
memoryUsageMB: number;
|
|
265
|
+
}) | null;
|
|
259
266
|
clearCache(): void;
|
|
260
267
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
261
268
|
update(options: Partial<TextOptions>): Promise<TextHandle>;
|
|
@@ -294,7 +301,7 @@ export interface ColoredRange {
|
|
|
294
301
|
}
|
|
295
302
|
export interface TextOptions {
|
|
296
303
|
text: string;
|
|
297
|
-
font
|
|
304
|
+
font: string | ArrayBuffer;
|
|
298
305
|
size?: number;
|
|
299
306
|
depth?: number;
|
|
300
307
|
lineHeight?: number;
|
|
@@ -2,10 +2,14 @@ import { BufferGeometry } from 'three';
|
|
|
2
2
|
import { Text as TextCore } from '../core/Text';
|
|
3
3
|
import type { TextOptions, TextGeometryInfo as CoreTextGeometryInfo, LoadedFont } from '../core/types';
|
|
4
4
|
import type { HyphenationTrieNode } from '../hyphenation';
|
|
5
|
+
import type { CacheStats } from '../utils/LRUCache';
|
|
5
6
|
export interface ThreeTextGeometryInfo extends Omit<CoreTextGeometryInfo, 'vertices' | 'normals' | 'indices' | 'colors' | 'glyphAttributes'> {
|
|
6
7
|
geometry: BufferGeometry;
|
|
7
8
|
getLoadedFont(): LoadedFont | undefined;
|
|
8
|
-
getCacheStatistics():
|
|
9
|
+
getCacheStatistics(): (CacheStats & {
|
|
10
|
+
hitRate: number;
|
|
11
|
+
memoryUsageMB: number;
|
|
12
|
+
}) | null;
|
|
9
13
|
clearCache(): void;
|
|
10
14
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
11
15
|
update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
|
|
@@ -16,6 +20,7 @@ export declare class Text {
|
|
|
16
20
|
static init: typeof TextCore.init;
|
|
17
21
|
static registerPattern: typeof TextCore.registerPattern;
|
|
18
22
|
static preloadPatterns: typeof TextCore.preloadPatterns;
|
|
23
|
+
static setMaxFontCacheMemoryMB: typeof TextCore.setMaxFontCacheMemoryMB;
|
|
19
24
|
static create(options: TextOptions): Promise<ThreeTextGeometryInfo>;
|
|
20
25
|
}
|
|
21
26
|
export type { TextOptions, ThreeTextGeometryInfo as TextGeometryInfo, LoadedFont };
|
|
@@ -6,5 +6,6 @@ export declare const Text: import("react").ForwardRefExoticComponent<import("./T
|
|
|
6
6
|
init: typeof import("..").Text.init;
|
|
7
7
|
registerPattern: typeof import("..").Text.registerPattern;
|
|
8
8
|
preloadPatterns: typeof import("..").Text.preloadPatterns;
|
|
9
|
+
setMaxFontCacheMemoryMB: typeof import("..").Text.setMaxFontCacheMemoryMB;
|
|
9
10
|
create: typeof ThreeTextCore.create;
|
|
10
11
|
};
|
package/package.json
CHANGED
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-text",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "3D font
|
|
3
|
+
"version": "0.2.19",
|
|
4
|
+
"description": "3D mesh font geometry and text layout engine for the web",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/index.js",
|
|
12
13
|
"require": "./dist/index.cjs"
|
|
13
14
|
},
|
|
14
15
|
"./three": {
|
|
16
|
+
"types": "./dist/three/index.d.ts",
|
|
15
17
|
"import": "./dist/three/index.js",
|
|
16
18
|
"require": "./dist/three/index.cjs"
|
|
17
19
|
},
|
|
18
20
|
"./three/react": {
|
|
21
|
+
"types": "./dist/three/react.d.ts",
|
|
19
22
|
"import": "./dist/three/react.js",
|
|
20
23
|
"require": "./dist/three/react.cjs"
|
|
21
24
|
},
|
|
22
25
|
"./webgl": {
|
|
26
|
+
"types": "./dist/webgl/index.d.ts",
|
|
23
27
|
"import": "./dist/webgl/index.js",
|
|
24
28
|
"require": "./dist/webgl/index.cjs"
|
|
25
29
|
},
|
|
26
30
|
"./webgpu": {
|
|
31
|
+
"types": "./dist/webgpu/index.d.ts",
|
|
27
32
|
"import": "./dist/webgpu/index.js",
|
|
28
33
|
"require": "./dist/webgpu/index.cjs"
|
|
29
34
|
},
|
|
30
35
|
"./p5": {
|
|
36
|
+
"types": "./dist/p5/index.d.ts",
|
|
31
37
|
"import": "./dist/p5/index.js",
|
|
32
38
|
"require": "./dist/p5/index.cjs"
|
|
33
39
|
},
|
|
34
|
-
"./patterns/*":
|
|
40
|
+
"./patterns/*": {
|
|
41
|
+
"types": "./dist/patterns/*.d.ts",
|
|
42
|
+
"import": "./dist/patterns/*.js",
|
|
43
|
+
"require": "./dist/patterns/*.cjs"
|
|
44
|
+
}
|
|
35
45
|
},
|
|
36
46
|
"files": [
|
|
37
47
|
"dist",
|
|
@@ -95,6 +105,7 @@
|
|
|
95
105
|
"libtess": "^1.2.2"
|
|
96
106
|
},
|
|
97
107
|
"devDependencies": {
|
|
108
|
+
"@webgpu/types": "^0.1.64",
|
|
98
109
|
"@react-three/fiber": ">=8.0.0",
|
|
99
110
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
100
111
|
"@rollup/plugin-node-resolve": "^15.0.0",
|