three-text 0.1.1 → 0.2.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 +166 -156
- package/dist/index.cjs +368 -82
- package/dist/index.d.ts +46 -17
- package/dist/index.js +367 -81
- package/dist/index.min.cjs +2 -2
- package/dist/index.min.js +2 -2
- package/dist/index.umd.js +372 -84
- package/dist/index.umd.min.js +2 -2
- package/dist/p5/index.cjs +33 -0
- package/dist/p5/index.d.ts +19 -0
- package/dist/p5/index.js +31 -0
- package/dist/three/index.cjs +50 -0
- package/dist/three/index.d.ts +29 -0
- package/dist/three/index.js +48 -0
- package/dist/{react/index.cjs → three/react.cjs} +14 -4
- package/dist/three/react.d.ts +346 -0
- package/dist/{react/index.js → three/react.js} +14 -4
- package/dist/types/core/Text.d.ts +1 -1
- package/dist/types/core/cache/GlyphCache.d.ts +4 -4
- package/dist/types/core/cache/GlyphContourCollector.d.ts +2 -2
- package/dist/types/core/cache/GlyphGeometryBuilder.d.ts +3 -2
- package/dist/types/core/geometry/BoundaryClusterer.d.ts +2 -2
- package/dist/types/core/geometry/Polygonizer.d.ts +3 -3
- package/dist/types/core/layout/TextLayout.d.ts +1 -2
- package/dist/types/core/shaping/TextShaper.d.ts +1 -2
- package/dist/types/core/types.d.ts +13 -16
- package/dist/types/core/vectors.d.ts +75 -0
- package/dist/types/p5/index.d.ts +17 -0
- package/dist/types/{react → three}/ThreeText.d.ts +2 -2
- package/dist/types/three/index.d.ts +21 -0
- package/dist/types/three/react.d.ts +10 -0
- package/dist/types/webgl/index.d.ts +48 -0
- package/dist/types/webgpu/index.d.ts +16 -0
- package/dist/webgl/index.cjs +88 -0
- package/dist/webgl/index.d.ts +51 -0
- package/dist/webgl/index.js +86 -0
- package/dist/webgpu/index.cjs +99 -0
- package/dist/webgpu/index.d.ts +19 -0
- package/dist/webgpu/index.js +97 -0
- package/package.json +22 -6
- package/dist/react/index.d.ts +0 -18
- package/dist/types/react/index.d.ts +0 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
6
6
|
|
|
7
|
-
A high fidelity font renderer and text layout engine for
|
|
7
|
+
A high fidelity 3D font renderer and text layout engine for the web
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -15,15 +15,24 @@ A high fidelity font renderer and text layout engine for [Three.js](https://gith
|
|
|
15
15
|
> [!CAUTION]
|
|
16
16
|
> three-text is an alpha release and the API may break rapidly. This warning will last at least through the end of 2025. If API stability is important to you, consider pinning your version. Community feedback is encouraged; please open an issue if you have any suggestions or feedback, thank you
|
|
17
17
|
|
|
18
|
-
**three-text** renders and formats text from TTF, OTF, and WOFF font files
|
|
18
|
+
**three-text** renders and formats text from TTF, OTF, and WOFF font files as 3D geometry. It uses [TeX](https://en.wikipedia.org/wiki/TeX)-based parameters for breaking text into paragraphs across multiple lines, and turns font outlines into 3D shapes on the fly, caching their geometries for low CPU overhead in languages with lots of repeating glyphs. Variable fonts are supported as static instances at a given axis coordinate
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The library has a framework-agnostic core that returns raw vertex data, with lightweight adapters for Three.js, React Three Fiber, p5.js, WebGL, and WebGPU
|
|
21
|
+
|
|
22
|
+
Under the hood, three-text relies on [HarfBuzz](https://github.com/harfbuzz/harfbuzzjs) for text shaping, [Knuth-Plass](http://www.eprg.org/G53DOC/pdfs/knuth-plass-breaking.pdf) line breaking, [Liang](https://tug.org/docs/liang/liang-thesis.pdf) hyphenation, [libtess2](https://github.com/memononen/libtess2) (based on the [OpenGL Utility Library (GLU) tessellator](https://www.songho.ca/opengl/gl_tessellation.html) by Eric Veach) for removing overlaps and triangulation, bezier curve polygonization from Maxim Shemanarev's [Anti-Grain Geometry](https://web.archive.org/web/20060128212843/http://www.antigrain.com/research/adaptive_bezier/index.html), and [Visvalingam-Whyatt](https://hull-repository.worktribe.com/preview/376364/000870493786962263.pdf) [line simplification](https://bost.ocks.org/mike/simplify/).
|
|
21
23
|
|
|
22
24
|
## Table of contents
|
|
23
25
|
|
|
24
26
|
- [Overview](#overview)
|
|
25
27
|
- [Getting started](#getting-started)
|
|
28
|
+
- [Three.js](#threejs-usage)
|
|
29
|
+
- [React Three Fiber](#react-three-fiber-usage)
|
|
30
|
+
- [WebGL](#webgl-usage)
|
|
31
|
+
- [WebGPU](#webgpu-usage)
|
|
32
|
+
- [p5.js](#p5js-usage)
|
|
33
|
+
- [Core (framework-agnostic)](#core-usage)
|
|
26
34
|
- [Development and examples](#development-and-examples)
|
|
35
|
+
- [Architecture](#architecture)
|
|
27
36
|
- [Why three-text?](#why-three-text)
|
|
28
37
|
- [Library structure](#library-structure)
|
|
29
38
|
- [Key concepts and methods](#key-concepts-and-methods)
|
|
@@ -41,14 +50,78 @@ Under the hood, three-text relies on [HarfBuzz](https://github.com/harfbuzz/harf
|
|
|
41
50
|
|
|
42
51
|
## Getting started
|
|
43
52
|
|
|
44
|
-
|
|
53
|
+
```bash
|
|
54
|
+
npm install three-text
|
|
55
|
+
```
|
|
45
56
|
|
|
57
|
+
For Three.js projects, also install:
|
|
46
58
|
```bash
|
|
47
|
-
npm install three
|
|
59
|
+
npm install three
|
|
48
60
|
```
|
|
49
61
|
|
|
50
62
|
`harfbuzzjs` is a direct dependency and will be installed automatically
|
|
51
63
|
|
|
64
|
+
## Architecture
|
|
65
|
+
|
|
66
|
+
three-text has a framework-agnostic core that processes fonts and generates geometry data. Lightweight adapters convert this data to framework-specific formats:
|
|
67
|
+
|
|
68
|
+
- **`three-text`** - Core (returns raw arrays)
|
|
69
|
+
- **`three-text/three`** - Three.js (returns BufferGeometry)
|
|
70
|
+
- **`three-text/three/react`** - React Three Fiber component
|
|
71
|
+
- **`three-text/webgl`** - WebGL buffer utility
|
|
72
|
+
- **`three-text/webgpu`** - WebGPU buffer utility
|
|
73
|
+
- **`three-text/p5`** - p5.js geometry converter
|
|
74
|
+
|
|
75
|
+
Choose the import that matches your stack. Most users will use `three-text/three` or `three-text/p5`
|
|
76
|
+
|
|
77
|
+
### Basic Usage
|
|
78
|
+
|
|
79
|
+
#### Three.js
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { Text } from 'three-text/three';
|
|
83
|
+
import * as THREE from 'three';
|
|
84
|
+
|
|
85
|
+
Text.setHarfBuzzPath('/hb/hb.wasm');
|
|
86
|
+
|
|
87
|
+
const result = await Text.create({
|
|
88
|
+
text: 'Hello World',
|
|
89
|
+
font: '/fonts/Font.woff',
|
|
90
|
+
size: 72
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const mesh = new THREE.Mesh(result.geometry, material);
|
|
94
|
+
scene.add(mesh);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### p5.js
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
import { Text } from 'three-text';
|
|
101
|
+
import { createP5Geometry } from 'three-text/p5';
|
|
102
|
+
|
|
103
|
+
let textGeom;
|
|
104
|
+
|
|
105
|
+
async function setup() {
|
|
106
|
+
createCanvas(400, 400, WEBGL);
|
|
107
|
+
Text.setHarfBuzzPath('/hb/hb.wasm');
|
|
108
|
+
|
|
109
|
+
const data = await Text.create({
|
|
110
|
+
text: 'Hello p5!',
|
|
111
|
+
font: '/fonts/Font.woff',
|
|
112
|
+
size: 72
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
textGeom = createP5Geometry(window, data);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function draw() {
|
|
119
|
+
background(200);
|
|
120
|
+
lights();
|
|
121
|
+
model(textGeom);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
52
125
|
### Setup
|
|
53
126
|
|
|
54
127
|
The library bundles harfbuzzjs but requires the WASM binary to be available at runtime. You have two options for providing it:
|
|
@@ -63,32 +136,31 @@ Copy the WASM binary to a public directory:
|
|
|
63
136
|
cp node_modules/harfbuzzjs/hb.wasm public/hb/
|
|
64
137
|
```
|
|
65
138
|
|
|
66
|
-
Then, before any `Text.create()` calls,
|
|
139
|
+
Then, before any `Text.create()` calls, configure the path:
|
|
67
140
|
|
|
68
141
|
```javascript
|
|
69
|
-
import { Text } from 'three-text';
|
|
142
|
+
import { Text } from 'three-text/three';
|
|
70
143
|
Text.setHarfBuzzPath('/hb/hb.wasm');
|
|
71
144
|
```
|
|
72
145
|
|
|
146
|
+
The path configuration is shared across all adapters
|
|
147
|
+
|
|
73
148
|
#### Option 2: Buffer-based loading
|
|
74
149
|
|
|
75
150
|
This method is essential for applications that use Web Workers, as it is the only way to share a single fetched resource across multiple threads. It gives you full control over loading and prevents each worker from re-downloading the WASM binary
|
|
76
151
|
|
|
77
152
|
|
|
78
153
|
```javascript
|
|
79
|
-
import { Text } from 'three-text';
|
|
154
|
+
import { Text } from 'three-text/three';
|
|
80
155
|
|
|
81
|
-
//
|
|
156
|
+
// Main thread
|
|
82
157
|
const wasmResponse = await fetch('/hb/hb.wasm');
|
|
83
158
|
const wasmBuffer = await wasmResponse.arrayBuffer();
|
|
84
159
|
|
|
85
|
-
//
|
|
86
|
-
// provide it to the library before use.
|
|
87
|
-
// worker.js:
|
|
160
|
+
// worker.js
|
|
88
161
|
self.onmessage = (e) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// ... now you can call Text.create()
|
|
162
|
+
const { wasmBuffer } = e.data;
|
|
163
|
+
Text.setHarfBuzzBuffer(wasmBuffer);
|
|
92
164
|
};
|
|
93
165
|
```
|
|
94
166
|
|
|
@@ -100,7 +172,7 @@ The library will prioritize the buffer if both a path and a buffer have been set
|
|
|
100
172
|
|
|
101
173
|
```javascript
|
|
102
174
|
import enUs from 'three-text/patterns/en-us';
|
|
103
|
-
import { Text } from 'three-text';
|
|
175
|
+
import { Text } from 'three-text/three';
|
|
104
176
|
|
|
105
177
|
Text.registerPattern('en-us', enUs);
|
|
106
178
|
```
|
|
@@ -111,106 +183,6 @@ Text.registerPattern('en-us', enUs);
|
|
|
111
183
|
cp -r node_modules/three-text/dist/patterns public/patterns/
|
|
112
184
|
```
|
|
113
185
|
|
|
114
|
-
### Basic usage
|
|
115
|
-
|
|
116
|
-
For modern browsers that support ES Modules:
|
|
117
|
-
|
|
118
|
-
```html
|
|
119
|
-
<script type="module">
|
|
120
|
-
import { Text } from 'three-text';
|
|
121
|
-
import fr from 'three-text/patterns/fr';
|
|
122
|
-
|
|
123
|
-
// Configure once
|
|
124
|
-
Text.setHarfBuzzPath('/hb/hb.wasm');
|
|
125
|
-
Text.registerPattern('fr', fr);
|
|
126
|
-
|
|
127
|
-
const text = await Text.create({
|
|
128
|
-
text: 'Bonjour',
|
|
129
|
-
font: '/fonts/YourFont.woff', // or .ttf, .otf
|
|
130
|
-
size: 72,
|
|
131
|
-
layout: { width: 400, align: 'center', language: 'fr' },
|
|
132
|
-
});
|
|
133
|
-
</script>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### UMD (legacy browser) usage
|
|
137
|
-
|
|
138
|
-
```html
|
|
139
|
-
<!-- Load Three.js and three-text -->
|
|
140
|
-
<script src="three-text/dist/index.umd.js"></script>
|
|
141
|
-
|
|
142
|
-
<!-- Load hyphenation patterns as needed (auto-registers) -->
|
|
143
|
-
<script src="/patterns/fr.umd.js"></script>
|
|
144
|
-
|
|
145
|
-
<script>
|
|
146
|
-
const { Text } = window.ThreeText;
|
|
147
|
-
|
|
148
|
-
// Configure once
|
|
149
|
-
Text.setHarfBuzzPath('/hb/hb.wasm');
|
|
150
|
-
|
|
151
|
-
const text = await Text.create({
|
|
152
|
-
text: 'Bonjour',
|
|
153
|
-
font: '/fonts/YourFont.woff', // or .ttf, .otf
|
|
154
|
-
size: 72,
|
|
155
|
-
layout: { width: 400, align: 'center', language: 'fr' }
|
|
156
|
-
});
|
|
157
|
-
</script>
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Patterns loaded via script tags automatically register themselves this way
|
|
161
|
-
|
|
162
|
-
### React Three Fiber usage
|
|
163
|
-
|
|
164
|
-
For `react-three-fiber` projects, use the `<ThreeText>` component which manages font loading, geometry creation, and React's lifecycle:
|
|
165
|
-
|
|
166
|
-
```jsx
|
|
167
|
-
import { ThreeText } from 'three-text/react';
|
|
168
|
-
|
|
169
|
-
function Scene() {
|
|
170
|
-
return (
|
|
171
|
-
<ThreeText
|
|
172
|
-
font="/fonts/Font-Regular.woff"
|
|
173
|
-
size={72}
|
|
174
|
-
depth={100}
|
|
175
|
-
layout={{
|
|
176
|
-
hyphenate: true,
|
|
177
|
-
language: 'fr',
|
|
178
|
-
}}
|
|
179
|
-
onLoad={(geometry, info) => console.log('Text loaded!', info)}
|
|
180
|
-
>
|
|
181
|
-
Hello world
|
|
182
|
-
</ThreeText>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
All `TextOptions` flow through as props, alongside standard Three.js mesh properties:
|
|
188
|
-
|
|
189
|
-
```jsx
|
|
190
|
-
<ThreeText
|
|
191
|
-
font="/fonts/MyFont.woff"
|
|
192
|
-
size={100}
|
|
193
|
-
depth={100}
|
|
194
|
-
lineHeight={1.2}
|
|
195
|
-
letterSpacing={0.02}
|
|
196
|
-
fontVariations={{ wght: 500, wdth: 100 }}
|
|
197
|
-
layout={{
|
|
198
|
-
width: 800,
|
|
199
|
-
align: 'justify',
|
|
200
|
-
language: 'en-us',
|
|
201
|
-
}}
|
|
202
|
-
position={[0, 0, 0]}
|
|
203
|
-
rotation={[0, Math.PI / 4, 0]}
|
|
204
|
-
material={customMaterial}
|
|
205
|
-
vertexColors={true} // Default: true
|
|
206
|
-
onLoad={(geometry, info) => {}}
|
|
207
|
-
onError={(error) => {}}
|
|
208
|
-
>
|
|
209
|
-
Your text content here
|
|
210
|
-
</ThreeText>
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
Vertex colors are included by default for maximum compatibility with custom materials. Set `vertexColors={false}` to disable them
|
|
214
186
|
|
|
215
187
|
## Development and examples
|
|
216
188
|
|
|
@@ -242,36 +214,41 @@ Then navigate to `http://localhost:3000`
|
|
|
242
214
|
|
|
243
215
|
## Why three-text?
|
|
244
216
|
|
|
245
|
-
|
|
246
|
-
Three.js scenes
|
|
217
|
+
three-text generates high-fidelity 3D mesh geometry from font files. Unlike texture-based approaches, it produces true geometry that can be lit, shaded, and manipulated like any 3D model.
|
|
247
218
|
|
|
248
|
-
Existing
|
|
219
|
+
Existing solutions take different approaches:
|
|
249
220
|
|
|
250
221
|
- **Three.js native TextGeometry** uses fonts converted by facetype.js to JSON format. It creates 3D text by extruding flat 2D character outlines. While this produces true 3D geometry with depth, there is no support for real fonts or OpenType features needed for many of the world's scripts
|
|
251
|
-
- **three-bmfont-text** is a 2D approach, using pre-rendered bitmap fonts with SDF support. Texture atlases are generated at specific sizes, and artifacts are apparent up close
|
|
222
|
+
- **three-bmfont-text** is a 2D approach for Three.js, using pre-rendered bitmap fonts with SDF support. Texture atlases are generated at specific sizes, and artifacts are apparent up close
|
|
252
223
|
- **troika-three-text** uses MSDF, which improves quality, and like three-text, it is built on HarfBuzz, which provides substantial language coverage, but is ultimately a 2D technique in image space. For flat text that does not need formatting or extrusion, and where artifacts are acceptable up close, troika works well
|
|
253
224
|
|
|
254
|
-
|
|
225
|
+
three-text generates true 3D geometry from font files via HarfBuzz. It is sharper at close distances than bitmap approaches when flat, and produces real mesh data that can be used with any rendering system. The library caches tessellated glyphs, so a paragraph of 1000 words might only require 50 tessellations depending on the language. This makes it well-suited to longer texts. In addition to performance considerations, three-text provides control over typesetting and paragraph justification via TeX-based parameters
|
|
255
226
|
|
|
256
227
|
## Library structure
|
|
257
228
|
|
|
258
229
|
```
|
|
259
230
|
three-text/
|
|
260
231
|
├── src/
|
|
261
|
-
│ ├── core/ #
|
|
262
|
-
│ │ ├── Text.ts #
|
|
263
|
-
│ │ ├──
|
|
232
|
+
│ ├── core/ # Framework-agnostic text engine
|
|
233
|
+
│ │ ├── Text.ts # Core API (returns raw arrays)
|
|
234
|
+
│ │ ├── vectors.ts # Vec2, Vec3, Box3Core
|
|
235
|
+
│ │ ├── types.ts # TypeScript interfaces
|
|
264
236
|
│ │ ├── cache/ # Glyph caching system
|
|
265
237
|
│ │ ├── font/ # Font loading and metrics
|
|
266
238
|
│ │ ├── shaping/ # HarfBuzz text shaping
|
|
267
239
|
│ │ ├── layout/ # Line breaking and text layout
|
|
268
240
|
│ │ └── geometry/ # Tessellation and geometry processing
|
|
269
|
-
│ ├──
|
|
241
|
+
│ ├── three/ # Three.js adapter
|
|
242
|
+
│ │ ├── index.ts # BufferGeometry wrapper
|
|
243
|
+
│ │ ├── react.tsx # React component export
|
|
244
|
+
│ │ └── ThreeText.tsx # React Three Fiber component
|
|
245
|
+
│ ├── webgl/ # WebGL buffer utility
|
|
246
|
+
│ ├── webgpu/ # WebGPU buffer utility
|
|
247
|
+
│ ├── p5/ # p5.js geometry converter
|
|
270
248
|
│ ├── hyphenation/ # Language-specific hyphenation patterns
|
|
271
249
|
│ └── utils/ # Performance logging, data structures
|
|
272
|
-
├──
|
|
273
|
-
|
|
274
|
-
└── dist/ # Built library (ESM, CJS, UMD) including patterns
|
|
250
|
+
├── examples/ # Demos for all adapters
|
|
251
|
+
└── dist/ # Built library (ESM, CJS, UMD)
|
|
275
252
|
```
|
|
276
253
|
|
|
277
254
|
## Key concepts and methods
|
|
@@ -632,23 +609,30 @@ Text matching occurs after layout processing, so patterns like "connection" will
|
|
|
632
609
|
|
|
633
610
|
The library's full TypeScript definitions are the most complete source of truth for the API. The core data structures and configuration options can be found in `src/core/types.ts`
|
|
634
611
|
|
|
635
|
-
###
|
|
612
|
+
### Core API
|
|
636
613
|
|
|
637
|
-
####
|
|
614
|
+
#### `Text.create(options: TextOptions): Promise<TextGeometryInfo>`
|
|
638
615
|
|
|
639
|
-
|
|
616
|
+
Creates text geometry with automatic font loading and HarfBuzz initialization.
|
|
640
617
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
- `
|
|
644
|
-
- `
|
|
618
|
+
**Core (`three-text`) returns:**
|
|
619
|
+
- `vertices: Float32Array` - Vertex positions
|
|
620
|
+
- `normals: Float32Array` - Vertex normals
|
|
621
|
+
- `indices: Uint32Array` - Triangle indices
|
|
622
|
+
- `colors?: Float32Array` - Vertex colors (if color option used)
|
|
623
|
+
- `glyphAttributes?` - Per-glyph shader attributes (if requested)
|
|
624
|
+
- `glyphs: GlyphGeometryInfo[]` - Per-glyph metadata
|
|
645
625
|
- `planeBounds` - Overall text bounds
|
|
646
626
|
- `stats` - Performance and optimization statistics
|
|
647
627
|
- `query(options)` - Method to find text ranges
|
|
648
|
-
- `getLoadedFont()` - Access to font metadata
|
|
649
|
-
- `getCacheStatistics()` -
|
|
650
|
-
- `clearCache()` - Clear the glyph
|
|
651
|
-
- `measureTextWidth(text, letterSpacing?)` - Measure text width
|
|
628
|
+
- `getLoadedFont()` - Access to font metadata
|
|
629
|
+
- `getCacheStatistics()` - Cache performance data
|
|
630
|
+
- `clearCache()` - Clear the glyph cache
|
|
631
|
+
- `measureTextWidth(text, letterSpacing?)` - Measure text width
|
|
632
|
+
|
|
633
|
+
**Three.js adapter (`three-text/three`) returns:**
|
|
634
|
+
- `geometry: BufferGeometry` - Three.js geometry
|
|
635
|
+
- Plus all the above except vertices/normals/indices/colors/glyphAttributes
|
|
652
636
|
|
|
653
637
|
##### `Text.setHarfBuzzPath(path: string): void`
|
|
654
638
|
|
|
@@ -759,25 +743,42 @@ interface GeometryOptimizationOptions {
|
|
|
759
743
|
}
|
|
760
744
|
````
|
|
761
745
|
|
|
762
|
-
#### TextGeometryInfo
|
|
746
|
+
#### TextGeometryInfo (Core)
|
|
763
747
|
|
|
764
748
|
```typescript
|
|
765
749
|
interface TextGeometryInfo {
|
|
766
|
-
|
|
767
|
-
|
|
750
|
+
vertices: Float32Array;
|
|
751
|
+
normals: Float32Array;
|
|
752
|
+
indices: Uint32Array;
|
|
753
|
+
colors?: Float32Array;
|
|
754
|
+
glyphAttributes?: {
|
|
755
|
+
glyphCenter: Float32Array;
|
|
756
|
+
glyphIndex: Float32Array;
|
|
757
|
+
glyphLineIndex: Float32Array;
|
|
758
|
+
};
|
|
759
|
+
glyphs: GlyphGeometryInfo[];
|
|
768
760
|
planeBounds: {
|
|
769
761
|
min: { x: number; y: number; z: number };
|
|
770
762
|
max: { x: number; y: number; z: number };
|
|
771
763
|
};
|
|
772
764
|
stats: {
|
|
773
|
-
trianglesGenerated: number;
|
|
774
|
-
verticesGenerated: number;
|
|
775
|
-
pointsRemovedByVisvalingam: number;
|
|
776
|
-
pointsRemovedByColinear: number;
|
|
777
|
-
originalPointCount: number;
|
|
765
|
+
trianglesGenerated: number;
|
|
766
|
+
verticesGenerated: number;
|
|
767
|
+
pointsRemovedByVisvalingam: number;
|
|
768
|
+
pointsRemovedByColinear: number;
|
|
769
|
+
originalPointCount: number;
|
|
778
770
|
};
|
|
779
|
-
query(options: TextQueryOptions): TextRange[];
|
|
780
|
-
coloredRanges?: ColoredRange[];
|
|
771
|
+
query(options: TextQueryOptions): TextRange[];
|
|
772
|
+
coloredRanges?: ColoredRange[];
|
|
773
|
+
}
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
#### ThreeTextGeometryInfo (Three.js Adapter)
|
|
777
|
+
|
|
778
|
+
```typescript
|
|
779
|
+
interface ThreeTextGeometryInfo {
|
|
780
|
+
geometry: BufferGeometry; // Three.js geometry
|
|
781
|
+
// Plus glyphs, planeBounds, stats, query, coloredRanges, utility methods
|
|
781
782
|
}
|
|
782
783
|
```
|
|
783
784
|
|
|
@@ -947,18 +948,27 @@ The script then processes the TeX hyphenation data into optimized trie structure
|
|
|
947
948
|
|
|
948
949
|
## Build outputs
|
|
949
950
|
|
|
950
|
-
The build generates multiple module formats:
|
|
951
|
+
The build generates multiple module formats for core and all adapters:
|
|
952
|
+
|
|
953
|
+
**Core:**
|
|
954
|
+
- `dist/index.js` (ESM)
|
|
955
|
+
- `dist/index.cjs` (CommonJS)
|
|
956
|
+
- `dist/index.umd.js` (UMD)
|
|
957
|
+
- `dist/index.d.ts` (TypeScript)
|
|
951
958
|
|
|
952
|
-
|
|
953
|
-
-
|
|
954
|
-
-
|
|
955
|
-
-
|
|
959
|
+
**Adapters:**
|
|
960
|
+
- `dist/three/` - Three.js adapter
|
|
961
|
+
- `dist/three/react.js` - React component
|
|
962
|
+
- `dist/webgl/` - WebGL utility
|
|
963
|
+
- `dist/webgpu/` - WebGPU utility
|
|
964
|
+
- `dist/p5/` - p5.js converter
|
|
956
965
|
|
|
957
|
-
|
|
966
|
+
**Patterns:**
|
|
967
|
+
- `dist/patterns/` - Hyphenation patterns (ESM and UMD)
|
|
958
968
|
|
|
959
969
|
## Acknowledgements
|
|
960
970
|
|
|
961
|
-
`three-text` is built on
|
|
971
|
+
`three-text` is built on HarfBuzz and TeX, and this library would not exist without the authors and communities who contribute to, support, and steward these projects. Thanks to Theo Honohan and Yasi Perera for advice on graphics
|
|
962
972
|
|
|
963
973
|
## License
|
|
964
974
|
|