three-text 0.2.2 → 0.2.3

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
@@ -26,11 +26,8 @@ Under the hood, three-text relies on [HarfBuzz](https://github.com/harfbuzz/harf
26
26
  - [Overview](#overview)
27
27
  - [Getting started](#getting-started)
28
28
  - [Three.js](#threejs)
29
- - [p5.js](#p5js)
30
29
  - [React Three Fiber](#react-three-fiber)
31
- - [WebGL](#webgl)
32
- - [WebGPU](#webgpu)
33
- - [Core](#core)
30
+ - [p5.js](#p5js)
34
31
  - [Development and examples](#development-and-examples)
35
32
  - [Architecture](#architecture)
36
33
  - [Why three-text?](#why-three-text)
@@ -94,6 +91,26 @@ const mesh = new THREE.Mesh(result.geometry, material);
94
91
  scene.add(mesh);
95
92
  ```
96
93
 
94
+ #### React Three Fiber
95
+
96
+ ```jsx
97
+ import { Canvas } from '@react-three/fiber';
98
+ import { Text } from 'three-text/three/react';
99
+
100
+ Text.setHarfBuzzPath('/hb/hb.wasm');
101
+
102
+ function App() {
103
+ return (
104
+ <Canvas>
105
+ <ambientLight />
106
+ <Text font="/fonts/Font.woff" size={72} depth={10}>
107
+ Hello React
108
+ </Text>
109
+ </Canvas>
110
+ );
111
+ }
112
+ ```
113
+
97
114
  #### p5.js
98
115
 
99
116
  ```javascript
@@ -123,6 +140,9 @@ function draw() {
123
140
  }
124
141
  ```
125
142
 
143
+ `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
+
145
+
126
146
  ### Setup
127
147
 
128
148
  The library bundles harfbuzzjs but requires the WASM binary to be available at runtime. You have two options for providing it:
@@ -969,7 +989,7 @@ The build generates multiple module formats for core and all adapters:
969
989
 
970
990
  ## Acknowledgements
971
991
 
972
- `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
992
+ `three-text` is built on HarfBuzz and TeX, and started as a Three.js project; 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 the advice on graphics
973
993
 
974
994
  ## License
975
995
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * three-text v0.2.2
2
+ * three-text v0.2.3
3
3
  * Copyright (C) 2025 Countertype LLC
4
4
  *
5
5
  * This program is free software: you can redistribute it and/or modify
@@ -19,8 +19,8 @@ class Text {
19
19
  const geometry = new three.BufferGeometry();
20
20
  geometry.setAttribute('position', new three.Float32BufferAttribute(coreResult.vertices, 3));
21
21
  geometry.setAttribute('normal', new three.Float32BufferAttribute(coreResult.normals, 3));
22
- geometry.setIndex(Array.from(coreResult.indices));
23
- // Add optional attributes
22
+ geometry.setIndex(new three.Uint32BufferAttribute(coreResult.indices, 1));
23
+ // Add optional color attribute (only if provided)
24
24
  if (coreResult.colors) {
25
25
  geometry.setAttribute('color', new three.Float32BufferAttribute(coreResult.colors, 3));
26
26
  }
@@ -1,4 +1,4 @@
1
- import { BufferGeometry, Float32BufferAttribute } from 'three';
1
+ import { BufferGeometry, Float32BufferAttribute, Uint32BufferAttribute } from 'three';
2
2
  import { Text as Text$1 } from '../index.js';
3
3
 
4
4
  // Three.js adapter - wraps core text processing and returns BufferGeometry
@@ -17,8 +17,8 @@ class Text {
17
17
  const geometry = new BufferGeometry();
18
18
  geometry.setAttribute('position', new Float32BufferAttribute(coreResult.vertices, 3));
19
19
  geometry.setAttribute('normal', new Float32BufferAttribute(coreResult.normals, 3));
20
- geometry.setIndex(Array.from(coreResult.indices));
21
- // Add optional attributes
20
+ geometry.setIndex(new Uint32BufferAttribute(coreResult.indices, 1));
21
+ // Add optional color attribute (only if provided)
22
22
  if (coreResult.colors) {
23
23
  geometry.setAttribute('color', new Float32BufferAttribute(coreResult.colors, 3));
24
24
  }
@@ -72,13 +72,6 @@ const Text$1 = react.forwardRef(function Text(props, ref) {
72
72
  font,
73
73
  ...memoizedTextOptions,
74
74
  });
75
- if (text.geometry &&
76
- !text.geometry.attributes.color &&
77
- vertexColors) {
78
- const vertexCount = text.geometry.attributes.position.count;
79
- const colors = new Float32Array(vertexCount * 3).fill(1.0);
80
- text.geometry.setAttribute("color", new THREE__namespace.BufferAttribute(colors, 3));
81
- }
82
75
  if (!cancelled) {
83
76
  setGeometry(text.geometry);
84
77
  if (onLoad)
@@ -51,13 +51,6 @@ const Text$1 = forwardRef(function Text(props, ref) {
51
51
  font,
52
52
  ...memoizedTextOptions,
53
53
  });
54
- if (text.geometry &&
55
- !text.geometry.attributes.color &&
56
- vertexColors) {
57
- const vertexCount = text.geometry.attributes.position.count;
58
- const colors = new Float32Array(vertexCount * 3).fill(1.0);
59
- text.geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
60
- }
61
54
  if (!cancelled) {
62
55
  setGeometry(text.geometry);
63
56
  if (onLoad)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-text",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "3D font rendering and text layout engine for the web",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",