three-text 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -39
- package/dist/index.cjs +214 -98
- package/dist/index.d.ts +1 -3
- package/dist/index.js +214 -98
- package/dist/index.min.cjs +434 -417
- package/dist/index.min.js +402 -385
- package/dist/index.umd.js +214 -98
- package/dist/index.umd.min.js +487 -470
- package/dist/three/react.d.ts +1 -3
- package/dist/types/core/cache/GlyphContourCollector.d.ts +1 -0
- package/dist/types/core/cache/GlyphGeometryBuilder.d.ts +2 -0
- package/dist/types/core/cache/sharedCaches.d.ts +4 -0
- package/dist/types/core/geometry/PathOptimizer.d.ts +0 -4
- package/dist/types/core/geometry/Polygonizer.d.ts +5 -0
- package/dist/types/core/types.d.ts +1 -3
- package/package.json +3 -3
package/dist/three/react.d.ts
CHANGED
|
@@ -187,7 +187,6 @@ interface TextGeometryInfo {
|
|
|
187
187
|
trianglesGenerated: number;
|
|
188
188
|
verticesGenerated: number;
|
|
189
189
|
pointsRemovedByVisvalingam: number;
|
|
190
|
-
pointsRemovedByColinear: number;
|
|
191
190
|
originalPointCount: number;
|
|
192
191
|
} & Partial<CacheStats & {
|
|
193
192
|
hitRate: number;
|
|
@@ -251,6 +250,7 @@ interface TextOptions {
|
|
|
251
250
|
};
|
|
252
251
|
maxTextLength?: number;
|
|
253
252
|
removeOverlaps?: boolean;
|
|
253
|
+
curveSteps?: number;
|
|
254
254
|
curveFidelity?: CurveFidelityConfig;
|
|
255
255
|
geometryOptimization?: GeometryOptimizationOptions;
|
|
256
256
|
layout?: LayoutOptions;
|
|
@@ -266,8 +266,6 @@ interface CurveFidelityConfig {
|
|
|
266
266
|
interface GeometryOptimizationOptions {
|
|
267
267
|
enabled?: boolean;
|
|
268
268
|
areaThreshold?: number;
|
|
269
|
-
colinearThreshold?: number;
|
|
270
|
-
minSegmentLength?: number;
|
|
271
269
|
}
|
|
272
270
|
interface LayoutOptions {
|
|
273
271
|
width?: number;
|
|
@@ -32,6 +32,7 @@ export declare class GlyphContourCollector {
|
|
|
32
32
|
getTextIndices(): number[];
|
|
33
33
|
reset(): void;
|
|
34
34
|
setCurveFidelityConfig(config?: CurveFidelityConfig): void;
|
|
35
|
+
setCurveSteps(curveSteps?: number): void;
|
|
35
36
|
setGeometryOptimization(options?: GeometryOptimizationOptions): void;
|
|
36
37
|
getOptimizationStats(): OptimizationStats;
|
|
37
38
|
}
|
|
@@ -26,6 +26,7 @@ export declare class GlyphGeometryBuilder {
|
|
|
26
26
|
private fontId;
|
|
27
27
|
private cacheKeyPrefix;
|
|
28
28
|
private curveFidelityConfig?;
|
|
29
|
+
private curveSteps?;
|
|
29
30
|
private geometryOptimizationOptions?;
|
|
30
31
|
private clusterer;
|
|
31
32
|
private collector;
|
|
@@ -38,6 +39,7 @@ export declare class GlyphGeometryBuilder {
|
|
|
38
39
|
constructor(cache: Cache<string, GlyphData>, loadedFont: LoadedFont);
|
|
39
40
|
getOptimizationStats(): import("../geometry/PathOptimizer").OptimizationStats;
|
|
40
41
|
setCurveFidelityConfig(config?: CurveFidelityConfig): void;
|
|
42
|
+
setCurveSteps(curveSteps?: number): void;
|
|
41
43
|
setGeometryOptimization(options?: GeometryOptimizationOptions): void;
|
|
42
44
|
setFontId(fontId: string): void;
|
|
43
45
|
private updateCacheKeyPrefix;
|
|
@@ -7,5 +7,9 @@ export declare const globalContourCache: Cache<string, GlyphContours>;
|
|
|
7
7
|
export declare const globalWordCache: Cache<string, GlyphData>;
|
|
8
8
|
export declare const globalClusteringCache: Cache<string, {
|
|
9
9
|
glyphIds: number[];
|
|
10
|
+
positions: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}[];
|
|
10
14
|
groups: number[][];
|
|
11
15
|
}>;
|
|
@@ -2,12 +2,9 @@ import type { Path } from '../types';
|
|
|
2
2
|
export interface OptimizationConfig {
|
|
3
3
|
enabled: boolean;
|
|
4
4
|
areaThreshold: number;
|
|
5
|
-
colinearThreshold: number;
|
|
6
|
-
minSegmentLength: number;
|
|
7
5
|
}
|
|
8
6
|
export interface OptimizationStats {
|
|
9
7
|
pointsRemovedByVisvalingam: number;
|
|
10
|
-
pointsRemovedByColinear: number;
|
|
11
8
|
originalPointCount: number;
|
|
12
9
|
}
|
|
13
10
|
export declare const DEFAULT_OPTIMIZATION_CONFIG: OptimizationConfig;
|
|
@@ -18,7 +15,6 @@ export declare class PathOptimizer {
|
|
|
18
15
|
setConfig(config: OptimizationConfig): void;
|
|
19
16
|
optimizePath(path: Path): Path;
|
|
20
17
|
private simplifyPathVW;
|
|
21
|
-
private removeColinearPoints;
|
|
22
18
|
private calculateTriangleArea;
|
|
23
19
|
getStats(): OptimizationStats;
|
|
24
20
|
resetStats(): void;
|
|
@@ -41,10 +41,15 @@ export declare const DEFAULT_CURVE_FIDELITY: CurveFidelityConfig;
|
|
|
41
41
|
export declare const COLLINEARITY_EPSILON = 0.000001;
|
|
42
42
|
export declare class Polygonizer {
|
|
43
43
|
private curveFidelityConfig;
|
|
44
|
+
private curveSteps;
|
|
44
45
|
constructor(curveFidelityConfig?: CurveFidelityConfig);
|
|
45
46
|
setCurveFidelityConfig(curveFidelityConfig?: CurveFidelityConfig): void;
|
|
47
|
+
setCurveSteps(curveSteps?: number): void;
|
|
46
48
|
polygonizeQuadratic(start: Vec2, control: Vec2, end: Vec2): Vec2[];
|
|
47
49
|
polygonizeCubic(start: Vec2, control1: Vec2, control2: Vec2, end: Vec2): Vec2[];
|
|
50
|
+
private lerp;
|
|
51
|
+
private polygonizeQuadraticFixedSteps;
|
|
52
|
+
private polygonizeCubicFixedSteps;
|
|
48
53
|
private recursiveQuadratic;
|
|
49
54
|
private recursiveCubic;
|
|
50
55
|
private addPoint;
|
|
@@ -250,7 +250,6 @@ export interface TextGeometryInfo {
|
|
|
250
250
|
trianglesGenerated: number;
|
|
251
251
|
verticesGenerated: number;
|
|
252
252
|
pointsRemovedByVisvalingam: number;
|
|
253
|
-
pointsRemovedByColinear: number;
|
|
254
253
|
originalPointCount: number;
|
|
255
254
|
} & Partial<CacheStats & {
|
|
256
255
|
hitRate: number;
|
|
@@ -314,6 +313,7 @@ export interface TextOptions {
|
|
|
314
313
|
};
|
|
315
314
|
maxTextLength?: number;
|
|
316
315
|
removeOverlaps?: boolean;
|
|
316
|
+
curveSteps?: number;
|
|
317
317
|
curveFidelity?: CurveFidelityConfig;
|
|
318
318
|
geometryOptimization?: GeometryOptimizationOptions;
|
|
319
319
|
layout?: LayoutOptions;
|
|
@@ -329,8 +329,6 @@ export interface CurveFidelityConfig {
|
|
|
329
329
|
export interface GeometryOptimizationOptions {
|
|
330
330
|
enabled?: boolean;
|
|
331
331
|
areaThreshold?: number;
|
|
332
|
-
colinearThreshold?: number;
|
|
333
|
-
minSegmentLength?: number;
|
|
334
332
|
}
|
|
335
333
|
export interface LayoutOptions {
|
|
336
334
|
width?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-text",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "3D mesh font geometry and text layout engine for the web",
|
|
5
5
|
"main": "dist/three/index.cjs",
|
|
6
6
|
"module": "dist/three/index.js",
|
|
@@ -106,11 +106,10 @@
|
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
"dependencies": {
|
|
109
|
-
"harfbuzzjs": "^0.4.
|
|
109
|
+
"harfbuzzjs": "^0.4.15",
|
|
110
110
|
"libtess": "^1.2.2"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@webgpu/types": "^0.1.64",
|
|
114
113
|
"@react-three/fiber": ">=8.0.0",
|
|
115
114
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
116
115
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -120,6 +119,7 @@
|
|
|
120
119
|
"@types/libtess": "^1.2.0",
|
|
121
120
|
"@types/react": ">=17.0.0",
|
|
122
121
|
"@types/three": ">=0.175.0",
|
|
122
|
+
"@webgpu/types": "^0.1.64",
|
|
123
123
|
"http-server": "^14.1.1",
|
|
124
124
|
"jsdom": "^26.1.0",
|
|
125
125
|
"prettier": "^3.6.2",
|