three-text 0.2.19 → 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 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, // Tighter tolerance for smoother curves
363
- angleTolerance: 0.1, // Sharper angle preservation
355
+ distanceTolerance: 0.2,
356
+ angleTolerance: 0.1,
364
357
  },
365
358
  });
366
359
  ```
@@ -562,13 +555,15 @@ For shader-based animations and interactive effects, the library can generate pe
562
555
  const text = await Text.create({
563
556
  text: 'Sample text',
564
557
  font: '/fonts/Font.ttf',
565
- separateGlyphsWithAttributes: true,
558
+ perGlyphAttributes: true,
566
559
  });
567
560
 
568
561
  // Geometry includes these vertex attributes:
569
562
  // - glyphCenter (vec3): center point of each glyph
570
563
  // - glyphIndex (float): sequential glyph index
571
564
  // - glyphLineIndex (float): line number
565
+ // - glyphProgress (float): normalized position (0..1) along text run
566
+ // - glyphBaselineY (float): Y coordinate of glyph baseline
572
567
  ```
573
568
 
574
569
  This option bypasses overlap-based clustering and adds vertex attributes suitable for per-character manipulation in vertex shaders. Each unique glyph is still tessellated only once and cached for reuse. The tradeoff is potential visual artifacts where glyphs actually overlap (tight kerning, cursive scripts)
@@ -712,7 +707,7 @@ mesh.geometry.dispose();
712
707
  mesh.geometry = updated.geometry;
713
708
  ```
714
709
 
715
- The method preserves custom cache instances if `maxCacheSizeMB` was specified. For most use cases, this is primarily an API convenience
710
+ For most use cases, this is primarily an API convenience over calling `create()` again
716
711
 
717
712
  Options merge at the top level - to remove a nested property like `layout.width`, pass `{ layout: { width: undefined } }`
718
713
 
@@ -761,9 +756,8 @@ interface TextOptions {
761
756
  fontVariations?: { [key: string]: number }; // Variable font axis settings
762
757
  fontFeatures?: { [tag: string]: boolean | number }; // OpenType feature settings
763
758
  removeOverlaps?: boolean; // Override default overlap removal (auto-enabled for VF only)
764
- separateGlyphsWithAttributes?: boolean; // Force individual glyph tessellation and add shader attributes
759
+ perGlyphAttributes?: boolean; // Keep per-glyph identity and add per-glyph shader attributes
765
760
  color?: [number, number, number] | ColorOptions; // Text coloring (simple or complex)
766
- // Configuration for geometry generation and layout
767
761
  curveFidelity?: CurveFidelityConfig;
768
762
  geometryOptimization?: GeometryOptimizationOptions;
769
763
  layout?: LayoutOptions;
@@ -842,6 +836,8 @@ interface TextGeometryInfo {
842
836
  glyphCenter: Float32Array;
843
837
  glyphIndex: Float32Array;
844
838
  glyphLineIndex: Float32Array;
839
+ glyphProgress: Float32Array;
840
+ glyphBaselineY: Float32Array;
845
841
  };
846
842
  glyphs: GlyphGeometryInfo[];
847
843
  planeBounds: {
@@ -898,30 +894,9 @@ interface TextRange {
898
894
 
899
895
  ## Memory management
900
896
 
901
- `three-text` manages memory in two ways: a shared glyph cache for all text, and instance-specific resources for each piece of text you create
902
-
903
- 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
904
-
905
- ```javascript
906
- const text = await Text.create({
907
- text: 'Hello world',
908
- font: '/fonts/font.ttf',
909
- size: 72,
910
- maxCacheSizeMB: 1024, // Custom cache size in MB
911
- });
912
-
913
- // Check cache performance
914
- const stats = text.getCacheStatistics();
915
- console.log('Cache Statistics:', {
916
- hitRate: stats.hitRate, // Cache hit percentage
917
- memoryUsageMB: stats.memoryUsageMB, // Memory used in MB
918
- size: stats.size, // Entries in cache
919
- hits: stats.hits, // Cache hits
920
- misses: stats.misses // Cache misses
921
- });
922
- ```
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
923
898
 
924
- Fonts are cached internally and persist for the application lifetime. The glyph geometry cache uses an LRU eviction policy, so memory usage is bounded by `maxCacheSizeMB`. When a text mesh is no longer needed, dispose of its geometry as you would any Three.js `BufferGeometry`:
899
+ When a text mesh is no longer needed, dispose of its geometry as you would any Three.js `BufferGeometry`:
925
900
 
926
901
  ```javascript
927
902
  textMesh.geometry.dispose();