three-text 0.3.0 → 0.3.1
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 +5 -34
- package/dist/index.cjs +2 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -6
- package/dist/index.min.cjs +324 -325
- package/dist/index.min.js +169 -170
- package/dist/index.umd.js +2 -6
- package/dist/index.umd.min.js +322 -323
- package/dist/three/react.d.ts +0 -1
- package/dist/types/core/types.d.ts +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -348,19 +348,12 @@ The library converts bezier curves into line segments by recursively subdividing
|
|
|
348
348
|
In general, this step helps more with time to first render than ongoing interactions in the scene
|
|
349
349
|
|
|
350
350
|
```javascript
|
|
351
|
-
// Using the default configuration
|
|
352
|
-
const text = await Text.create({
|
|
353
|
-
text: 'Sample text',
|
|
354
|
-
font: '/fonts/Font.ttf',
|
|
355
|
-
size: 72,
|
|
356
|
-
});
|
|
357
|
-
|
|
358
351
|
const text = await Text.create({
|
|
359
352
|
text: 'Sample text',
|
|
360
353
|
font: '/fonts/Font.ttf',
|
|
361
354
|
curveFidelity: {
|
|
362
|
-
distanceTolerance: 0.2,
|
|
363
|
-
angleTolerance: 0.1,
|
|
355
|
+
distanceTolerance: 0.2,
|
|
356
|
+
angleTolerance: 0.1,
|
|
364
357
|
},
|
|
365
358
|
});
|
|
366
359
|
```
|
|
@@ -714,7 +707,7 @@ mesh.geometry.dispose();
|
|
|
714
707
|
mesh.geometry = updated.geometry;
|
|
715
708
|
```
|
|
716
709
|
|
|
717
|
-
|
|
710
|
+
For most use cases, this is primarily an API convenience over calling `create()` again
|
|
718
711
|
|
|
719
712
|
Options merge at the top level - to remove a nested property like `layout.width`, pass `{ layout: { width: undefined } }`
|
|
720
713
|
|
|
@@ -765,7 +758,6 @@ interface TextOptions {
|
|
|
765
758
|
removeOverlaps?: boolean; // Override default overlap removal (auto-enabled for VF only)
|
|
766
759
|
perGlyphAttributes?: boolean; // Keep per-glyph identity and add per-glyph shader attributes
|
|
767
760
|
color?: [number, number, number] | ColorOptions; // Text coloring (simple or complex)
|
|
768
|
-
// Configuration for geometry generation and layout
|
|
769
761
|
curveFidelity?: CurveFidelityConfig;
|
|
770
762
|
geometryOptimization?: GeometryOptimizationOptions;
|
|
771
763
|
layout?: LayoutOptions;
|
|
@@ -902,30 +894,9 @@ interface TextRange {
|
|
|
902
894
|
|
|
903
895
|
## Memory management
|
|
904
896
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
The shared cache is handled automatically through an LRU (Least Recently Used) policy. The default cache size is 250MB, but you can configure it per text instance. Tessellated glyphs are cached to avoid expensive recomputation when the same characters (or clusters of overlapping characters) appear multiple times
|
|
908
|
-
|
|
909
|
-
```javascript
|
|
910
|
-
const text = await Text.create({
|
|
911
|
-
text: 'Hello world',
|
|
912
|
-
font: '/fonts/font.ttf',
|
|
913
|
-
size: 72,
|
|
914
|
-
maxCacheSizeMB: 1024, // Custom cache size in MB
|
|
915
|
-
});
|
|
916
|
-
|
|
917
|
-
// Check cache performance
|
|
918
|
-
const stats = text.getCacheStatistics();
|
|
919
|
-
console.log('Cache Statistics:', {
|
|
920
|
-
hitRate: stats.hitRate, // Cache hit percentage
|
|
921
|
-
memoryUsageMB: stats.memoryUsageMB, // Memory used in MB
|
|
922
|
-
size: stats.size, // Entries in cache
|
|
923
|
-
hits: stats.hits, // Cache hits
|
|
924
|
-
misses: stats.misses // Cache misses
|
|
925
|
-
});
|
|
926
|
-
```
|
|
897
|
+
Tessellated glyphs are cached in a shared global cache to avoid recomputation when the same characters appear multiple times. Fonts are also cached and persist for the application lifetime
|
|
927
898
|
|
|
928
|
-
|
|
899
|
+
When a text mesh is no longer needed, dispose of its geometry as you would any Three.js `BufferGeometry`:
|
|
929
900
|
|
|
930
901
|
```javascript
|
|
931
902
|
textMesh.geometry.dispose();
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.3.
|
|
2
|
+
* three-text v0.3.1
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -5278,7 +5278,6 @@ class Text {
|
|
|
5278
5278
|
const loadedFont = await Text.resolveFont(options);
|
|
5279
5279
|
const text = new Text();
|
|
5280
5280
|
text.setLoadedFont(loadedFont);
|
|
5281
|
-
// Pass full options so createGeometry honors maxCacheSizeMB etc
|
|
5282
5281
|
const result = await text.createGeometry(options);
|
|
5283
5282
|
// Recursive update function
|
|
5284
5283
|
const update = async (newOptions) => {
|
|
@@ -5459,10 +5458,7 @@ class Text {
|
|
|
5459
5458
|
options = updatedOptions;
|
|
5460
5459
|
this.updateFontVariations(options);
|
|
5461
5460
|
if (!this.geometryBuilder) {
|
|
5462
|
-
|
|
5463
|
-
? createGlyphCache()
|
|
5464
|
-
: globalGlyphCache;
|
|
5465
|
-
this.geometryBuilder = new GlyphGeometryBuilder(cache, this.loadedFont);
|
|
5461
|
+
this.geometryBuilder = new GlyphGeometryBuilder(globalGlyphCache, this.loadedFont);
|
|
5466
5462
|
this.geometryBuilder.setFontId(this.currentFontId);
|
|
5467
5463
|
}
|
|
5468
5464
|
this.geometryBuilder.setCurveFidelityConfig(options.curveFidelity);
|
package/dist/index.d.ts
CHANGED
|
@@ -304,7 +304,6 @@ interface TextOptions {
|
|
|
304
304
|
geometryOptimization?: GeometryOptimizationOptions;
|
|
305
305
|
layout?: LayoutOptions;
|
|
306
306
|
color?: [number, number, number] | ColorOptions;
|
|
307
|
-
maxCacheSizeMB?: number;
|
|
308
307
|
}
|
|
309
308
|
interface HyphenationPatternsMap {
|
|
310
309
|
[language: string]: HyphenationTrieNode;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* three-text v0.3.
|
|
2
|
+
* three-text v0.3.1
|
|
3
3
|
* Copyright (C) 2025 Countertype LLC
|
|
4
4
|
*
|
|
5
5
|
* This program is free software: you can redistribute it and/or modify
|
|
@@ -5275,7 +5275,6 @@ class Text {
|
|
|
5275
5275
|
const loadedFont = await Text.resolveFont(options);
|
|
5276
5276
|
const text = new Text();
|
|
5277
5277
|
text.setLoadedFont(loadedFont);
|
|
5278
|
-
// Pass full options so createGeometry honors maxCacheSizeMB etc
|
|
5279
5278
|
const result = await text.createGeometry(options);
|
|
5280
5279
|
// Recursive update function
|
|
5281
5280
|
const update = async (newOptions) => {
|
|
@@ -5456,10 +5455,7 @@ class Text {
|
|
|
5456
5455
|
options = updatedOptions;
|
|
5457
5456
|
this.updateFontVariations(options);
|
|
5458
5457
|
if (!this.geometryBuilder) {
|
|
5459
|
-
|
|
5460
|
-
? createGlyphCache()
|
|
5461
|
-
: globalGlyphCache;
|
|
5462
|
-
this.geometryBuilder = new GlyphGeometryBuilder(cache, this.loadedFont);
|
|
5458
|
+
this.geometryBuilder = new GlyphGeometryBuilder(globalGlyphCache, this.loadedFont);
|
|
5463
5459
|
this.geometryBuilder.setFontId(this.currentFontId);
|
|
5464
5460
|
}
|
|
5465
5461
|
this.geometryBuilder.setCurveFidelityConfig(options.curveFidelity);
|