three-text 0.5.0 → 0.5.2
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 +15 -16
- package/dist/index.cjs +66 -20
- package/dist/index.d.ts +6 -0
- package/dist/index.js +66 -20
- package/dist/index.min.cjs +310 -307
- package/dist/index.min.js +265 -262
- package/dist/index.umd.js +68 -21
- package/dist/index.umd.min.js +268 -265
- package/dist/three/index.cjs +2 -1
- package/dist/three/index.d.ts +1 -0
- package/dist/three/index.js +2 -1
- package/dist/three/react.cjs +35 -17
- package/dist/three/react.d.ts +6 -0
- package/dist/three/react.js +35 -17
- package/dist/types/core/Text.d.ts +6 -0
- package/dist/types/three/index.d.ts +1 -0
- package/dist/types/vector/core.d.ts +27 -0
- package/dist/types/vector/index.d.ts +30 -24
- package/dist/types/vector/loopBlinnTSL.d.ts +14 -3
- package/dist/types/vector/react.d.ts +4 -6
- package/dist/vector/all.cjs +21 -0
- package/dist/vector/all.d.ts +134 -0
- package/dist/vector/all.js +2 -0
- package/dist/vector/core.cjs +1310 -0
- package/dist/vector/core.d.ts +112 -0
- package/dist/vector/core.js +1306 -0
- package/dist/vector/index.cjs +41 -1265
- package/dist/vector/index.d.ts +335 -20
- package/dist/vector/index.js +28 -1239
- package/dist/vector/loopBlinnTSL.cjs +229 -0
- package/dist/vector/loopBlinnTSL.d.ts +69 -0
- package/dist/vector/loopBlinnTSL.js +207 -0
- package/dist/vector/react.cjs +45 -60
- package/dist/vector/react.d.ts +9 -3
- package/dist/vector/react.js +46 -42
- package/dist/vector/webgl/index.cjs +3 -1
- package/dist/vector/webgl/index.js +3 -1
- package/package.json +1 -1
package/dist/three/index.cjs
CHANGED
|
@@ -55,7 +55,8 @@ function buildThreeResult(layoutHandle, meshPipeline, options) {
|
|
|
55
55
|
getCacheSize: () => meshPipeline.getCacheSize(),
|
|
56
56
|
clearCache: () => meshPipeline.clearCache(),
|
|
57
57
|
measureTextWidth: (text, letterSpacing) => layoutHandle.measureTextWidth(text, letterSpacing),
|
|
58
|
-
update
|
|
58
|
+
update,
|
|
59
|
+
dispose: () => layoutHandle.dispose()
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
class Text {
|
package/dist/three/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface ThreeTextGeometryInfo extends Omit<TextGeometryInfo, 'vertices' | 'nor
|
|
|
17
17
|
clearCache(): void;
|
|
18
18
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
19
19
|
update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
|
|
20
|
+
dispose(): void;
|
|
20
21
|
}
|
|
21
22
|
declare class Text {
|
|
22
23
|
static setHarfBuzzPath: typeof Text$1.setHarfBuzzPath;
|
package/dist/three/index.js
CHANGED
|
@@ -53,7 +53,8 @@ function buildThreeResult(layoutHandle, meshPipeline, options) {
|
|
|
53
53
|
getCacheSize: () => meshPipeline.getCacheSize(),
|
|
54
54
|
clearCache: () => meshPipeline.clearCache(),
|
|
55
55
|
measureTextWidth: (text, letterSpacing) => layoutHandle.measureTextWidth(text, letterSpacing),
|
|
56
|
-
update
|
|
56
|
+
update,
|
|
57
|
+
dispose: () => layoutHandle.dispose()
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
class Text {
|
package/dist/three/react.cjs
CHANGED
|
@@ -69,7 +69,12 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
|
|
|
69
69
|
const { children, font, material, position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1], onLoad, onError, vertexColors = true, ...restOptions } = props;
|
|
70
70
|
const [geometry, setGeometry] = react.useState(null);
|
|
71
71
|
const [error, setError] = react.useState(null);
|
|
72
|
-
const
|
|
72
|
+
const textRef = react.useRef(null);
|
|
73
|
+
const opRef = react.useRef(Promise.resolve(null));
|
|
74
|
+
const onLoadRef = react.useRef(onLoad);
|
|
75
|
+
const onErrorRef = react.useRef(onError);
|
|
76
|
+
onLoadRef.current = onLoad;
|
|
77
|
+
onErrorRef.current = onError;
|
|
73
78
|
const defaultMaterial = react.useMemo(() => {
|
|
74
79
|
return new THREE__namespace.MeshBasicMaterial({
|
|
75
80
|
color: 0xffffff,
|
|
@@ -86,29 +91,42 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
|
|
|
86
91
|
setError(null);
|
|
87
92
|
if (cancelled)
|
|
88
93
|
return;
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
const textPromise = opRef.current.catch(() => null).then(() => {
|
|
95
|
+
if (cancelled)
|
|
96
|
+
return null;
|
|
97
|
+
return textRef.current
|
|
98
|
+
? textRef.current.update({
|
|
99
|
+
text: children,
|
|
100
|
+
font,
|
|
101
|
+
...memoizedTextOptions
|
|
102
|
+
})
|
|
103
|
+
: index.Text.create({
|
|
104
|
+
text: children,
|
|
105
|
+
font,
|
|
106
|
+
...memoizedTextOptions
|
|
107
|
+
});
|
|
93
108
|
});
|
|
109
|
+
opRef.current = textPromise.catch(() => null);
|
|
110
|
+
const text = await textPromise;
|
|
111
|
+
if (!text)
|
|
112
|
+
return;
|
|
94
113
|
if (cancelled) {
|
|
95
|
-
|
|
96
|
-
text.geometry.dispose();
|
|
114
|
+
text.dispose();
|
|
97
115
|
return;
|
|
98
116
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
geometryRef.current = text.geometry;
|
|
117
|
+
const prev = textRef.current;
|
|
118
|
+
textRef.current = text;
|
|
102
119
|
setGeometry(text.geometry);
|
|
103
|
-
if (
|
|
104
|
-
|
|
120
|
+
if (onLoadRef.current)
|
|
121
|
+
onLoadRef.current(text.geometry, text);
|
|
122
|
+
requestAnimationFrame(() => prev?.dispose());
|
|
105
123
|
}
|
|
106
124
|
catch (err) {
|
|
107
125
|
const error = err;
|
|
108
126
|
if (!cancelled) {
|
|
109
127
|
setError(error);
|
|
110
|
-
if (
|
|
111
|
-
|
|
128
|
+
if (onErrorRef.current)
|
|
129
|
+
onErrorRef.current(error);
|
|
112
130
|
else
|
|
113
131
|
console.error('ThreeText error:', error);
|
|
114
132
|
}
|
|
@@ -118,12 +136,12 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
|
|
|
118
136
|
return () => {
|
|
119
137
|
cancelled = true;
|
|
120
138
|
};
|
|
121
|
-
}, [font, children, memoizedTextOptions
|
|
139
|
+
}, [font, children, memoizedTextOptions]);
|
|
122
140
|
// Cleanup geometry on unmount
|
|
123
141
|
react.useEffect(() => {
|
|
124
142
|
return () => {
|
|
125
|
-
|
|
126
|
-
|
|
143
|
+
textRef.current?.dispose();
|
|
144
|
+
textRef.current = null;
|
|
127
145
|
};
|
|
128
146
|
}, []);
|
|
129
147
|
// Cleanup default material when it changes or on unmount
|
package/dist/three/react.d.ts
CHANGED
|
@@ -255,6 +255,8 @@ declare class Text$1 {
|
|
|
255
255
|
private static patternCache;
|
|
256
256
|
private static hbInitPromise;
|
|
257
257
|
private static fontCache;
|
|
258
|
+
private static fontLoadPromises;
|
|
259
|
+
private static fontRefCounts;
|
|
258
260
|
private static fontCacheMemoryBytes;
|
|
259
261
|
private static maxFontCacheMemoryBytes;
|
|
260
262
|
private static fontIdCounter;
|
|
@@ -263,6 +265,7 @@ declare class Text$1 {
|
|
|
263
265
|
private fontLoader;
|
|
264
266
|
private loadedFont?;
|
|
265
267
|
private currentFontId;
|
|
268
|
+
private currentFontCacheKey?;
|
|
266
269
|
private textShaper?;
|
|
267
270
|
private textLayout?;
|
|
268
271
|
private constructor();
|
|
@@ -270,6 +273,8 @@ declare class Text$1 {
|
|
|
270
273
|
static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
|
|
271
274
|
static init(): Promise<HarfBuzzInstance>;
|
|
272
275
|
static create(options: TextOptions): Promise<TextLayoutHandle>;
|
|
276
|
+
private static retainFont;
|
|
277
|
+
private static releaseFont;
|
|
273
278
|
private static resolveFont;
|
|
274
279
|
private static loadAndCacheFont;
|
|
275
280
|
private static trackFontCacheAdd;
|
|
@@ -277,6 +282,7 @@ declare class Text$1 {
|
|
|
277
282
|
private static enforceFontCacheMemoryLimit;
|
|
278
283
|
private static generateFontContentHash;
|
|
279
284
|
private setLoadedFont;
|
|
285
|
+
private releaseCurrentFont;
|
|
280
286
|
private loadFont;
|
|
281
287
|
private createLayout;
|
|
282
288
|
private prepareHyphenation;
|
package/dist/three/react.js
CHANGED
|
@@ -48,7 +48,12 @@ const Text$1 = forwardRef(function Text(props, ref) {
|
|
|
48
48
|
const { children, font, material, position = [0, 0, 0], rotation = [0, 0, 0], scale = [1, 1, 1], onLoad, onError, vertexColors = true, ...restOptions } = props;
|
|
49
49
|
const [geometry, setGeometry] = useState(null);
|
|
50
50
|
const [error, setError] = useState(null);
|
|
51
|
-
const
|
|
51
|
+
const textRef = useRef(null);
|
|
52
|
+
const opRef = useRef(Promise.resolve(null));
|
|
53
|
+
const onLoadRef = useRef(onLoad);
|
|
54
|
+
const onErrorRef = useRef(onError);
|
|
55
|
+
onLoadRef.current = onLoad;
|
|
56
|
+
onErrorRef.current = onError;
|
|
52
57
|
const defaultMaterial = useMemo(() => {
|
|
53
58
|
return new THREE.MeshBasicMaterial({
|
|
54
59
|
color: 0xffffff,
|
|
@@ -65,29 +70,42 @@ const Text$1 = forwardRef(function Text(props, ref) {
|
|
|
65
70
|
setError(null);
|
|
66
71
|
if (cancelled)
|
|
67
72
|
return;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
const textPromise = opRef.current.catch(() => null).then(() => {
|
|
74
|
+
if (cancelled)
|
|
75
|
+
return null;
|
|
76
|
+
return textRef.current
|
|
77
|
+
? textRef.current.update({
|
|
78
|
+
text: children,
|
|
79
|
+
font,
|
|
80
|
+
...memoizedTextOptions
|
|
81
|
+
})
|
|
82
|
+
: Text$2.create({
|
|
83
|
+
text: children,
|
|
84
|
+
font,
|
|
85
|
+
...memoizedTextOptions
|
|
86
|
+
});
|
|
72
87
|
});
|
|
88
|
+
opRef.current = textPromise.catch(() => null);
|
|
89
|
+
const text = await textPromise;
|
|
90
|
+
if (!text)
|
|
91
|
+
return;
|
|
73
92
|
if (cancelled) {
|
|
74
|
-
|
|
75
|
-
text.geometry.dispose();
|
|
93
|
+
text.dispose();
|
|
76
94
|
return;
|
|
77
95
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
geometryRef.current = text.geometry;
|
|
96
|
+
const prev = textRef.current;
|
|
97
|
+
textRef.current = text;
|
|
81
98
|
setGeometry(text.geometry);
|
|
82
|
-
if (
|
|
83
|
-
|
|
99
|
+
if (onLoadRef.current)
|
|
100
|
+
onLoadRef.current(text.geometry, text);
|
|
101
|
+
requestAnimationFrame(() => prev?.dispose());
|
|
84
102
|
}
|
|
85
103
|
catch (err) {
|
|
86
104
|
const error = err;
|
|
87
105
|
if (!cancelled) {
|
|
88
106
|
setError(error);
|
|
89
|
-
if (
|
|
90
|
-
|
|
107
|
+
if (onErrorRef.current)
|
|
108
|
+
onErrorRef.current(error);
|
|
91
109
|
else
|
|
92
110
|
console.error('ThreeText error:', error);
|
|
93
111
|
}
|
|
@@ -97,12 +115,12 @@ const Text$1 = forwardRef(function Text(props, ref) {
|
|
|
97
115
|
return () => {
|
|
98
116
|
cancelled = true;
|
|
99
117
|
};
|
|
100
|
-
}, [font, children, memoizedTextOptions
|
|
118
|
+
}, [font, children, memoizedTextOptions]);
|
|
101
119
|
// Cleanup geometry on unmount
|
|
102
120
|
useEffect(() => {
|
|
103
121
|
return () => {
|
|
104
|
-
|
|
105
|
-
|
|
122
|
+
textRef.current?.dispose();
|
|
123
|
+
textRef.current = null;
|
|
106
124
|
};
|
|
107
125
|
}, []);
|
|
108
126
|
// Cleanup default material when it changes or on unmount
|
|
@@ -10,6 +10,8 @@ export declare class Text {
|
|
|
10
10
|
private static patternCache;
|
|
11
11
|
private static hbInitPromise;
|
|
12
12
|
private static fontCache;
|
|
13
|
+
private static fontLoadPromises;
|
|
14
|
+
private static fontRefCounts;
|
|
13
15
|
private static fontCacheMemoryBytes;
|
|
14
16
|
private static maxFontCacheMemoryBytes;
|
|
15
17
|
private static fontIdCounter;
|
|
@@ -18,6 +20,7 @@ export declare class Text {
|
|
|
18
20
|
private fontLoader;
|
|
19
21
|
private loadedFont?;
|
|
20
22
|
private currentFontId;
|
|
23
|
+
private currentFontCacheKey?;
|
|
21
24
|
private textShaper?;
|
|
22
25
|
private textLayout?;
|
|
23
26
|
private constructor();
|
|
@@ -25,6 +28,8 @@ export declare class Text {
|
|
|
25
28
|
static setHarfBuzzBuffer(wasmBuffer: ArrayBuffer): void;
|
|
26
29
|
static init(): Promise<HarfBuzzInstance>;
|
|
27
30
|
static create(options: TextOptions): Promise<TextLayoutHandle>;
|
|
31
|
+
private static retainFont;
|
|
32
|
+
private static releaseFont;
|
|
28
33
|
private static resolveFont;
|
|
29
34
|
private static loadAndCacheFont;
|
|
30
35
|
private static trackFontCacheAdd;
|
|
@@ -32,6 +37,7 @@ export declare class Text {
|
|
|
32
37
|
private static enforceFontCacheMemoryLimit;
|
|
33
38
|
private static generateFontContentHash;
|
|
34
39
|
private setLoadedFont;
|
|
40
|
+
private releaseCurrentFont;
|
|
35
41
|
private loadFont;
|
|
36
42
|
private createLayout;
|
|
37
43
|
private prepareHyphenation;
|
|
@@ -9,6 +9,7 @@ export interface ThreeTextGeometryInfo extends Omit<CoreTextGeometryInfo, 'verti
|
|
|
9
9
|
clearCache(): void;
|
|
10
10
|
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
11
11
|
update(options: Partial<TextOptions>): Promise<ThreeTextGeometryInfo>;
|
|
12
|
+
dispose(): void;
|
|
12
13
|
}
|
|
13
14
|
export declare class Text {
|
|
14
15
|
static setHarfBuzzPath: typeof TextCore.setHarfBuzzPath;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Text as TextCore } from '../core/Text';
|
|
2
|
+
import type { TextOptions, VectorGlyphInfo, LoadedFont, TextQueryOptions, TextRange } from '../core/types';
|
|
3
|
+
import type { VectorGeometryData } from './LoopBlinnGeometry';
|
|
4
|
+
import type { HyphenationTrieNode } from '../hyphenation';
|
|
5
|
+
export interface VectorTextResult {
|
|
6
|
+
glyphs: VectorGlyphInfo[];
|
|
7
|
+
geometryData: VectorGeometryData;
|
|
8
|
+
query(options: TextQueryOptions): TextRange[];
|
|
9
|
+
getLoadedFont(): LoadedFont | undefined;
|
|
10
|
+
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
11
|
+
update(options: Partial<TextOptions>): Promise<VectorTextResult>;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class Text {
|
|
15
|
+
static setHarfBuzzPath: typeof TextCore.setHarfBuzzPath;
|
|
16
|
+
static setHarfBuzzBuffer: typeof TextCore.setHarfBuzzBuffer;
|
|
17
|
+
static init: typeof TextCore.init;
|
|
18
|
+
static registerPattern: typeof TextCore.registerPattern;
|
|
19
|
+
static preloadPatterns: typeof TextCore.preloadPatterns;
|
|
20
|
+
static setMaxFontCacheMemoryMB: typeof TextCore.setMaxFontCacheMemoryMB;
|
|
21
|
+
static enableWoff2: typeof TextCore.enableWoff2;
|
|
22
|
+
static create(options: TextOptions): Promise<VectorTextResult>;
|
|
23
|
+
}
|
|
24
|
+
export type { TextOptions, VectorTextResult as TextGeometryInfo, VectorGlyphInfo, LoadedFont };
|
|
25
|
+
export type { HyphenationTrieNode };
|
|
26
|
+
export { buildVectorGeometry, extractContours } from './LoopBlinnGeometry';
|
|
27
|
+
export type { VectorGeometryData, VectorGlyphAttributes, GlyphRange, VectorContour, LoopBlinnInput, LoopBlinnGlyphInput, QuadraticSegment } from './LoopBlinnGeometry';
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { type VectorTextResult } from './core';
|
|
2
|
+
import { createVectorMeshes, loopBlinnFragment, type VectorMeshes, type VectorMeshOptions } from './loopBlinnTSL';
|
|
3
|
+
import type { TextOptions } from '../core/types';
|
|
4
|
+
export interface VectorTextOptions extends TextOptions {
|
|
5
|
+
color?: any;
|
|
6
|
+
positionNode?: any;
|
|
7
|
+
colorNode?: any;
|
|
8
|
+
center?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface VectorResult extends VectorTextResult {
|
|
11
|
+
group: import('three').Group;
|
|
12
|
+
interiorGeometry: import('three').BufferGeometry;
|
|
13
|
+
curveGeometry: import('three').BufferGeometry;
|
|
14
|
+
fillGeometry: import('three').BufferGeometry;
|
|
15
|
+
updateMaterials(options?: VectorMeshOptions): void;
|
|
16
|
+
update(newOptions: Partial<VectorTextOptions>): Promise<VectorResult>;
|
|
13
17
|
}
|
|
14
18
|
export declare class Text {
|
|
15
|
-
static setHarfBuzzPath: typeof
|
|
16
|
-
static setHarfBuzzBuffer: typeof
|
|
17
|
-
static init: typeof
|
|
18
|
-
static registerPattern: typeof
|
|
19
|
-
static preloadPatterns: typeof
|
|
20
|
-
static setMaxFontCacheMemoryMB: typeof
|
|
21
|
-
static enableWoff2: typeof
|
|
22
|
-
static create(options:
|
|
19
|
+
static setHarfBuzzPath: typeof import("..").Text.setHarfBuzzPath;
|
|
20
|
+
static setHarfBuzzBuffer: typeof import("..").Text.setHarfBuzzBuffer;
|
|
21
|
+
static init: typeof import("..").Text.init;
|
|
22
|
+
static registerPattern: typeof import("..").Text.registerPattern;
|
|
23
|
+
static preloadPatterns: typeof import("..").Text.preloadPatterns;
|
|
24
|
+
static setMaxFontCacheMemoryMB: typeof import("..").Text.setMaxFontCacheMemoryMB;
|
|
25
|
+
static enableWoff2: typeof import("..").Text.enableWoff2;
|
|
26
|
+
static create(options: VectorTextOptions): Promise<VectorResult>;
|
|
23
27
|
}
|
|
24
|
-
export
|
|
25
|
-
export type {
|
|
28
|
+
export { createVectorMeshes, loopBlinnFragment };
|
|
29
|
+
export type { VectorMeshes, VectorMeshOptions };
|
|
30
|
+
export type { VectorTextResult } from './core';
|
|
26
31
|
export { buildVectorGeometry, extractContours } from './LoopBlinnGeometry';
|
|
32
|
+
export type { TextOptions } from '../core/types';
|
|
27
33
|
export type { VectorGeometryData, VectorGlyphAttributes, GlyphRange, VectorContour, LoopBlinnInput, LoopBlinnGlyphInput, QuadraticSegment } from './LoopBlinnGeometry';
|
|
28
|
-
export {
|
|
29
|
-
export type {
|
|
34
|
+
export type { VectorGlyphInfo, LoadedFont } from '../core/types';
|
|
35
|
+
export type { HyphenationTrieNode } from '../hyphenation';
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import type { VectorGeometryData } from './LoopBlinnGeometry';
|
|
3
|
+
export interface VectorMeshOptions {
|
|
4
|
+
color?: THREE.ColorRepresentation;
|
|
5
|
+
positionNode?: any;
|
|
6
|
+
colorNode?: any;
|
|
7
|
+
center?: boolean;
|
|
8
|
+
}
|
|
3
9
|
export interface VectorMeshes {
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
group: THREE.Group;
|
|
11
|
+
interiorMesh: THREE.Object3D;
|
|
12
|
+
curveMesh: THREE.Object3D;
|
|
6
13
|
fillMesh: THREE.Mesh;
|
|
14
|
+
interiorGeometry: THREE.BufferGeometry;
|
|
15
|
+
curveGeometry: THREE.BufferGeometry;
|
|
16
|
+
fillGeometry: THREE.BufferGeometry;
|
|
7
17
|
setOffset(x: number, y: number, z?: number): void;
|
|
18
|
+
updateMaterials(options?: VectorMeshOptions): void;
|
|
8
19
|
dispose(): void;
|
|
9
20
|
}
|
|
10
21
|
export declare const loopBlinnFragment: any;
|
|
11
|
-
export declare function createVectorMeshes(data: VectorGeometryData,
|
|
22
|
+
export declare function createVectorMeshes(data: VectorGeometryData, options?: VectorMeshOptions | THREE.ColorRepresentation): VectorMeshes;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { Text as
|
|
3
|
-
|
|
4
|
-
import type { TextOptions } from '../core/types';
|
|
5
|
-
export interface TextProps extends Omit<TextOptions, 'text' | 'color'> {
|
|
2
|
+
import { Text as VectorText, type VectorResult, type VectorTextOptions } from './index';
|
|
3
|
+
export interface TextProps extends Omit<VectorTextOptions, 'text' | 'color'> {
|
|
6
4
|
children: string;
|
|
7
5
|
font: string | ArrayBuffer;
|
|
8
6
|
fillColor?: THREE.ColorRepresentation;
|
|
9
7
|
position?: [number, number, number];
|
|
10
8
|
rotation?: [number, number, number];
|
|
11
9
|
scale?: [number, number, number];
|
|
12
|
-
onLoad?: (result:
|
|
10
|
+
onLoad?: (result: VectorResult) => void;
|
|
13
11
|
onError?: (error: Error) => void;
|
|
14
12
|
}
|
|
15
13
|
export declare const Text: import("react").ForwardRefExoticComponent<TextProps & import("react").RefAttributes<THREE.Group<THREE.Object3DEventMap>>> & {
|
|
@@ -20,5 +18,5 @@ export declare const Text: import("react").ForwardRefExoticComponent<TextProps &
|
|
|
20
18
|
preloadPatterns: typeof import("..").Text.preloadPatterns;
|
|
21
19
|
setMaxFontCacheMemoryMB: typeof import("..").Text.setMaxFontCacheMemoryMB;
|
|
22
20
|
enableWoff2: typeof import("..").Text.enableWoff2;
|
|
23
|
-
create: typeof
|
|
21
|
+
create: typeof VectorText.create;
|
|
24
22
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index.cjs');
|
|
4
|
+
var loopBlinnTSL = require('./loopBlinnTSL.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, 'createVectorMeshes', {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return loopBlinnTSL.createVectorMeshes; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, 'loopBlinnFragment', {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return loopBlinnTSL.loopBlinnFragment; }
|
|
15
|
+
});
|
|
16
|
+
Object.keys(index).forEach(function (k) {
|
|
17
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return index[k]; }
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Text as Text$1 } from '../core/Text';
|
|
2
|
+
import { VectorGlyphInfo, TextQueryOptions, TextRange, LoadedFont, TextOptions } from '../core/types';
|
|
3
|
+
export { LoadedFont, TextOptions, VectorGlyphInfo } from '../core/types';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
|
|
6
|
+
interface BoundingBox {
|
|
7
|
+
min: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
};
|
|
12
|
+
max: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
z: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface QuadraticSegment {
|
|
20
|
+
p0x: number;
|
|
21
|
+
p0y: number;
|
|
22
|
+
p1x: number;
|
|
23
|
+
p1y: number;
|
|
24
|
+
p2x: number;
|
|
25
|
+
p2y: number;
|
|
26
|
+
}
|
|
27
|
+
interface ContourVertex {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}
|
|
31
|
+
interface VectorContour {
|
|
32
|
+
vertices: ContourVertex[];
|
|
33
|
+
segments: QuadraticSegment[];
|
|
34
|
+
}
|
|
35
|
+
interface VectorGlyphAttributes {
|
|
36
|
+
glyphCenter: Float32Array;
|
|
37
|
+
glyphIndex: Float32Array;
|
|
38
|
+
glyphProgress: Float32Array;
|
|
39
|
+
glyphLineIndex: Float32Array;
|
|
40
|
+
glyphBaselineY: Float32Array;
|
|
41
|
+
}
|
|
42
|
+
interface GlyphRange {
|
|
43
|
+
interiorIndexStart: number;
|
|
44
|
+
interiorIndexCount: number;
|
|
45
|
+
curveVertexStart: number;
|
|
46
|
+
curveVertexCount: number;
|
|
47
|
+
}
|
|
48
|
+
interface VectorGeometryData {
|
|
49
|
+
interiorPositions: Float32Array;
|
|
50
|
+
interiorIndices: Uint32Array;
|
|
51
|
+
curvePositions: Float32Array;
|
|
52
|
+
fillPositions: Float32Array;
|
|
53
|
+
fillIndices: Uint32Array;
|
|
54
|
+
glyphRanges: GlyphRange[];
|
|
55
|
+
interiorGlyphAttrs?: VectorGlyphAttributes;
|
|
56
|
+
curveGlyphAttrs?: VectorGlyphAttributes;
|
|
57
|
+
fillGlyphAttrs?: VectorGlyphAttributes;
|
|
58
|
+
planeBounds: BoundingBox;
|
|
59
|
+
stats: {
|
|
60
|
+
glyphCount: number;
|
|
61
|
+
contourCount: number;
|
|
62
|
+
interiorTriangleCount: number;
|
|
63
|
+
curveTriangleCount: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
interface LoopBlinnGlyphInput {
|
|
67
|
+
offsetX: number;
|
|
68
|
+
offsetY: number;
|
|
69
|
+
segments: QuadraticSegment[];
|
|
70
|
+
bounds: {
|
|
71
|
+
minX: number;
|
|
72
|
+
minY: number;
|
|
73
|
+
maxX: number;
|
|
74
|
+
maxY: number;
|
|
75
|
+
};
|
|
76
|
+
lineIndex: number;
|
|
77
|
+
baselineY: number;
|
|
78
|
+
}
|
|
79
|
+
interface LoopBlinnInput {
|
|
80
|
+
glyphs: LoopBlinnGlyphInput[];
|
|
81
|
+
planeBounds: BoundingBox;
|
|
82
|
+
}
|
|
83
|
+
declare function extractContours(segments: QuadraticSegment[]): VectorContour[];
|
|
84
|
+
declare function buildVectorGeometry(input: LoopBlinnInput): VectorGeometryData;
|
|
85
|
+
|
|
86
|
+
interface HyphenationTrieNode {
|
|
87
|
+
patterns: number[] | null;
|
|
88
|
+
children: {
|
|
89
|
+
[char: string]: HyphenationTrieNode;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface VectorTextResult {
|
|
94
|
+
glyphs: VectorGlyphInfo[];
|
|
95
|
+
geometryData: VectorGeometryData;
|
|
96
|
+
query(options: TextQueryOptions): TextRange[];
|
|
97
|
+
getLoadedFont(): LoadedFont | undefined;
|
|
98
|
+
measureTextWidth(text: string, letterSpacing?: number): number;
|
|
99
|
+
update(options: Partial<TextOptions>): Promise<VectorTextResult>;
|
|
100
|
+
dispose(): void;
|
|
101
|
+
}
|
|
102
|
+
declare class Text {
|
|
103
|
+
static setHarfBuzzPath: typeof Text$1.setHarfBuzzPath;
|
|
104
|
+
static setHarfBuzzBuffer: typeof Text$1.setHarfBuzzBuffer;
|
|
105
|
+
static init: typeof Text$1.init;
|
|
106
|
+
static registerPattern: typeof Text$1.registerPattern;
|
|
107
|
+
static preloadPatterns: typeof Text$1.preloadPatterns;
|
|
108
|
+
static setMaxFontCacheMemoryMB: typeof Text$1.setMaxFontCacheMemoryMB;
|
|
109
|
+
static enableWoff2: typeof Text$1.enableWoff2;
|
|
110
|
+
static create(options: TextOptions): Promise<VectorTextResult>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface VectorMeshOptions {
|
|
114
|
+
color?: THREE.ColorRepresentation;
|
|
115
|
+
positionNode?: any;
|
|
116
|
+
colorNode?: any;
|
|
117
|
+
center?: boolean;
|
|
118
|
+
}
|
|
119
|
+
interface VectorMeshes {
|
|
120
|
+
group: THREE.Group;
|
|
121
|
+
interiorMesh: THREE.Object3D;
|
|
122
|
+
curveMesh: THREE.Object3D;
|
|
123
|
+
fillMesh: THREE.Mesh;
|
|
124
|
+
interiorGeometry: THREE.BufferGeometry;
|
|
125
|
+
curveGeometry: THREE.BufferGeometry;
|
|
126
|
+
fillGeometry: THREE.BufferGeometry;
|
|
127
|
+
setOffset(x: number, y: number, z?: number): void;
|
|
128
|
+
updateMaterials(options?: VectorMeshOptions): void;
|
|
129
|
+
dispose(): void;
|
|
130
|
+
}
|
|
131
|
+
declare const loopBlinnFragment: any;
|
|
132
|
+
declare function createVectorMeshes(data: VectorGeometryData, options?: VectorMeshOptions | THREE.ColorRepresentation): VectorMeshes;
|
|
133
|
+
|
|
134
|
+
export { GlyphRange, HyphenationTrieNode, LoopBlinnGlyphInput, LoopBlinnInput, QuadraticSegment, Text, VectorTextResult as TextGeometryInfo, VectorContour, VectorGeometryData, VectorGlyphAttributes, VectorMeshOptions, VectorMeshes, VectorTextResult, buildVectorGeometry, createVectorMeshes, extractContours, loopBlinnFragment };
|