three-text 0.2.15 → 0.2.17
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 +21 -4
- package/dist/index.cjs +422 -230
- package/dist/index.js +422 -230
- package/dist/index.min.cjs +632 -618
- package/dist/index.min.js +624 -610
- package/dist/index.umd.js +422 -230
- package/dist/index.umd.min.js +632 -618
- package/dist/types/core/cache/GlyphGeometryBuilder.d.ts +1 -0
- package/dist/types/core/geometry/Tessellator.d.ts +3 -2
- package/dist/types/core/layout/LineBreak.d.ts +2 -1
- package/dist/types/core/layout/TextLayout.d.ts +15 -0
- package/dist/types/core/shaping/TextMeasurer.d.ts +1 -0
- package/dist/types/webgpu/index.d.ts +1 -0
- package/dist/webgpu/index.cjs +4 -2
- package/dist/webgpu/index.d.ts +1 -0
- package/dist/webgpu/index.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,21 +15,26 @@ A high fidelity 3D font renderer and text layout engine for the web
|
|
|
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
|
-
|
|
18
|
+
|
|
19
|
+
text: `three-text is a 3D font geometry and text layout library for the web. Its supports TTF, OTF, and WOFF font files. For layout, it uses Tex-based parameters for breaking text into paragraphs across multiple lines and supports CJK and RTL scripts. three-text caches the geometries it generates for low CPU overhead in languages with lots of repeating glyphs. Variable fonts are supported as static instances at a given axis coordinate, and can be animated by re-drawing each frame with new coordinates. 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. Under the hood, three-text relies on HarfBuzz for text shaping, Knuth-Plass line breaking, Liang hyphenation, libtess by Eric Veach for tessellation, curve polygonization from Maxim Shemanarev's Anti-Grain Geometry, and Visvalingam-Whyatt line simplification`,
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
**three-text** is a 3D font geometry and text layout library for the web. It supports TTF, OTF, and WOFF font files. For layout, it uses [TeX](https://en.wikipedia.org/wiki/TeX)-based parameters for breaking text into paragraphs across multiple lines and supports CJK and RTL scripts. three-text caches the geometries it generates for low CPU overhead in languages with lots of repeating glyphs. Variable fonts are supported as static instances at a given axis coordinate, and can be animated by re-drawing each frame with new coordinates
|
|
19
23
|
|
|
20
24
|
The library has a framework-agnostic core that returns raw vertex data, with lightweight adapters for [Three.js](https://threejs.org), [React Three Fiber](https://docs.pmnd.rs/react-three-fiber), [p5.js](https://p5js.org), [WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API), and [WebGPU](https://developer.mozilla.org/en-US/docs/Web/API/WebGPU_API)
|
|
21
25
|
|
|
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, [libtess](https://github.com/brendankenny/libtess.js) (based on the [GLU tessellator](https://www.songho.ca/opengl/gl_tessellation.html) by Eric Veach) for removing overlaps and triangulation, 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/)
|
|
26
|
+
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, [libtess.js](https://github.com/brendankenny/libtess.js) (based on the [GLU tessellator](https://www.songho.ca/opengl/gl_tessellation.html) by Eric Veach) for removing overlaps and triangulation, 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/)
|
|
23
27
|
|
|
24
28
|
## Table of contents
|
|
25
29
|
|
|
26
30
|
- [Overview](#overview)
|
|
27
31
|
- [Getting started](#getting-started)
|
|
32
|
+
- [Architecture](#architecture)
|
|
28
33
|
- [Three.js](#threejs)
|
|
29
34
|
- [React Three Fiber](#react-three-fiber)
|
|
30
35
|
- [p5.js](#p5js)
|
|
36
|
+
- [Coordinate systems](#coordinate-systems)
|
|
31
37
|
- [Development and examples](#development-and-examples)
|
|
32
|
-
- [Architecture](#architecture)
|
|
33
38
|
- [Why three-text?](#why-three-text)
|
|
34
39
|
- [Library structure](#library-structure)
|
|
35
40
|
- [Key concepts and methods](#key-concepts-and-methods)
|
|
@@ -142,6 +147,13 @@ function draw() {
|
|
|
142
147
|
|
|
143
148
|
`createThreeTextGeometry()` accepts all the same options as Three.js (`layout`, `fontVariations`, `depth`, etc.) and returns `{ geometry, planeBounds, glyphs }`. Use `planeBounds` to center the text
|
|
144
149
|
|
|
150
|
+
### Coordinate systems
|
|
151
|
+
|
|
152
|
+
The core library uses a right-handed coordinate system with +Y down. Text extrudes from z=0 toward positive Z
|
|
153
|
+
|
|
154
|
+
**Three.js, WebGL, WebGPU:** Geometry is used as-is. Front cap normals point +Z
|
|
155
|
+
|
|
156
|
+
**p5.js:** The adapter flips Y coordinates (p5 uses +Y up) but preserves Z. When using `directionalLight(r, g, b, x, y, z)`, note that p5 negates the direction vector internally
|
|
145
157
|
|
|
146
158
|
### Setup
|
|
147
159
|
|
|
@@ -322,7 +334,10 @@ For text with tight tracking, connected scripts, or complex kerning pairs, indiv
|
|
|
322
334
|
|
|
323
335
|
#### Flat geometry mode
|
|
324
336
|
|
|
325
|
-
When `depth` is 0, the library generates single-sided geometry
|
|
337
|
+
When `depth` is 0, the library generates single-sided geometry, reducing triangles by approximately 50%
|
|
338
|
+
|
|
339
|
+
- Use `THREE.DoubleSide` for flat text so it remains visible from both sides
|
|
340
|
+
- For extruded text, `THREE.FrontSide` is typical since front and back faces are separate geometry
|
|
326
341
|
|
|
327
342
|
|
|
328
343
|
## Configuration
|
|
@@ -1003,6 +1018,8 @@ This runs a Node/Vitest scenario that:
|
|
|
1003
1018
|
|
|
1004
1019
|
Use this to compare changes locally; it is meant as a sanity check on real work rather than a reliable micro-benchmark
|
|
1005
1020
|
|
|
1021
|
+
Synthetic component benchmarks for tessellation, extrusion, and layout are available in `bench/` and can be run directly with node, e.g. `node bench/benchTessellator.mjs --runs 5`
|
|
1022
|
+
|
|
1006
1023
|
## Build system
|
|
1007
1024
|
|
|
1008
1025
|
### Development
|