three-text 0.2.18 → 0.3.0
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 +14 -10
- package/dist/index.cjs +215 -350
- package/dist/index.d.ts +27 -50
- package/dist/index.js +215 -350
- package/dist/index.min.cjs +704 -723
- package/dist/index.min.js +705 -724
- package/dist/index.umd.js +215 -350
- package/dist/index.umd.min.js +710 -729
- package/dist/three/index.cjs +4 -1
- package/dist/three/index.d.ts +2 -1
- package/dist/three/index.js +4 -1
- package/dist/three/react.cjs +2 -1
- package/dist/three/react.d.ts +15 -17
- package/dist/three/react.js +2 -1
- package/dist/types/core/Text.d.ts +1 -5
- package/dist/types/core/cache/GlyphGeometryBuilder.d.ts +4 -7
- package/dist/types/core/cache/sharedCaches.d.ts +6 -7
- package/dist/types/core/geometry/Extruder.d.ts +0 -1
- package/dist/types/core/shaping/TextShaper.d.ts +1 -4
- package/dist/types/core/types.d.ts +10 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/three/index.d.ts +2 -1
- package/dist/types/three/react.d.ts +1 -0
- package/dist/types/utils/Cache.d.ts +14 -0
- package/dist/types/webgl/index.d.ts +12 -0
- package/dist/types/webgpu/index.d.ts +10 -0
- package/dist/webgl/index.cjs +18 -0
- package/dist/webgl/index.d.ts +12 -0
- package/dist/webgl/index.js +18 -0
- package/dist/webgpu/index.cjs +80 -1
- package/dist/webgpu/index.d.ts +10 -0
- package/dist/webgpu/index.js +80 -1
- package/package.json +22 -6
package/dist/webgpu/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// WebGPU adapter - lightweight utility to create GPU buffers from core geometry
|
|
2
2
|
function createWebGPUBuffers(device, textGeometry) {
|
|
3
|
-
const { vertices, normals, indices, colors } = textGeometry;
|
|
3
|
+
const { vertices, normals, indices, colors, glyphAttributes } = textGeometry;
|
|
4
4
|
const indexCount = indices.length;
|
|
5
5
|
const indexFormat = indices instanceof Uint16Array ? 'uint16' : 'uint32';
|
|
6
6
|
// Interleave position and normal data for better cache coherency
|
|
@@ -81,6 +81,75 @@ function createWebGPUBuffers(device, textGeometry) {
|
|
|
81
81
|
buffers.color = colorBuffer;
|
|
82
82
|
layout.color = colorLayout;
|
|
83
83
|
}
|
|
84
|
+
// Optional glyph attribute buffers
|
|
85
|
+
let glyphCenterBuffer;
|
|
86
|
+
let glyphIndexBuffer;
|
|
87
|
+
let glyphLineIndexBuffer;
|
|
88
|
+
let glyphProgressBuffer;
|
|
89
|
+
let glyphBaselineYBuffer;
|
|
90
|
+
if (glyphAttributes) {
|
|
91
|
+
let nextShaderLocation = colors ? 3 : 2;
|
|
92
|
+
glyphCenterBuffer = device.createBuffer({
|
|
93
|
+
size: glyphAttributes.glyphCenter.byteLength,
|
|
94
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
95
|
+
mappedAtCreation: true
|
|
96
|
+
});
|
|
97
|
+
new Float32Array(glyphCenterBuffer.getMappedRange()).set(glyphAttributes.glyphCenter);
|
|
98
|
+
glyphCenterBuffer.unmap();
|
|
99
|
+
buffers.glyphCenter = glyphCenterBuffer;
|
|
100
|
+
layout.glyphCenter = {
|
|
101
|
+
arrayStride: 12,
|
|
102
|
+
attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32x3' }]
|
|
103
|
+
};
|
|
104
|
+
glyphIndexBuffer = device.createBuffer({
|
|
105
|
+
size: glyphAttributes.glyphIndex.byteLength,
|
|
106
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
107
|
+
mappedAtCreation: true
|
|
108
|
+
});
|
|
109
|
+
new Float32Array(glyphIndexBuffer.getMappedRange()).set(glyphAttributes.glyphIndex);
|
|
110
|
+
glyphIndexBuffer.unmap();
|
|
111
|
+
buffers.glyphIndex = glyphIndexBuffer;
|
|
112
|
+
layout.glyphIndex = {
|
|
113
|
+
arrayStride: 4,
|
|
114
|
+
attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
|
|
115
|
+
};
|
|
116
|
+
glyphLineIndexBuffer = device.createBuffer({
|
|
117
|
+
size: glyphAttributes.glyphLineIndex.byteLength,
|
|
118
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
119
|
+
mappedAtCreation: true
|
|
120
|
+
});
|
|
121
|
+
new Float32Array(glyphLineIndexBuffer.getMappedRange()).set(glyphAttributes.glyphLineIndex);
|
|
122
|
+
glyphLineIndexBuffer.unmap();
|
|
123
|
+
buffers.glyphLineIndex = glyphLineIndexBuffer;
|
|
124
|
+
layout.glyphLineIndex = {
|
|
125
|
+
arrayStride: 4,
|
|
126
|
+
attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
|
|
127
|
+
};
|
|
128
|
+
glyphProgressBuffer = device.createBuffer({
|
|
129
|
+
size: glyphAttributes.glyphProgress.byteLength,
|
|
130
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
131
|
+
mappedAtCreation: true
|
|
132
|
+
});
|
|
133
|
+
new Float32Array(glyphProgressBuffer.getMappedRange()).set(glyphAttributes.glyphProgress);
|
|
134
|
+
glyphProgressBuffer.unmap();
|
|
135
|
+
buffers.glyphProgress = glyphProgressBuffer;
|
|
136
|
+
layout.glyphProgress = {
|
|
137
|
+
arrayStride: 4,
|
|
138
|
+
attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
|
|
139
|
+
};
|
|
140
|
+
glyphBaselineYBuffer = device.createBuffer({
|
|
141
|
+
size: glyphAttributes.glyphBaselineY.byteLength,
|
|
142
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
143
|
+
mappedAtCreation: true
|
|
144
|
+
});
|
|
145
|
+
new Float32Array(glyphBaselineYBuffer.getMappedRange()).set(glyphAttributes.glyphBaselineY);
|
|
146
|
+
glyphBaselineYBuffer.unmap();
|
|
147
|
+
buffers.glyphBaselineY = glyphBaselineYBuffer;
|
|
148
|
+
layout.glyphBaselineY = {
|
|
149
|
+
arrayStride: 4,
|
|
150
|
+
attributes: [{ shaderLocation: nextShaderLocation++, offset: 0, format: 'float32' }]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
84
153
|
return {
|
|
85
154
|
buffers,
|
|
86
155
|
layout,
|
|
@@ -91,6 +160,16 @@ function createWebGPUBuffers(device, textGeometry) {
|
|
|
91
160
|
indexBuffer.destroy();
|
|
92
161
|
if (colorBuffer)
|
|
93
162
|
colorBuffer.destroy();
|
|
163
|
+
if (glyphCenterBuffer)
|
|
164
|
+
glyphCenterBuffer.destroy();
|
|
165
|
+
if (glyphIndexBuffer)
|
|
166
|
+
glyphIndexBuffer.destroy();
|
|
167
|
+
if (glyphLineIndexBuffer)
|
|
168
|
+
glyphLineIndexBuffer.destroy();
|
|
169
|
+
if (glyphProgressBuffer)
|
|
170
|
+
glyphProgressBuffer.destroy();
|
|
171
|
+
if (glyphBaselineYBuffer)
|
|
172
|
+
glyphBaselineYBuffer.destroy();
|
|
94
173
|
}
|
|
95
174
|
};
|
|
96
175
|
}
|
package/package.json
CHANGED
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-text",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "3D font
|
|
5
|
-
"main": "dist/index.cjs",
|
|
6
|
-
"module": "dist/index.js",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "3D mesh font geometry and text layout engine for the web",
|
|
5
|
+
"main": "dist/three/index.cjs",
|
|
6
|
+
"module": "dist/three/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
8
|
+
"types": "dist/three/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/three/index.d.ts",
|
|
12
|
+
"import": "./dist/three/index.js",
|
|
13
|
+
"require": "./dist/three/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./core": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
11
17
|
"import": "./dist/index.js",
|
|
12
18
|
"require": "./dist/index.cjs"
|
|
13
19
|
},
|
|
14
20
|
"./three": {
|
|
21
|
+
"types": "./dist/three/index.d.ts",
|
|
15
22
|
"import": "./dist/three/index.js",
|
|
16
23
|
"require": "./dist/three/index.cjs"
|
|
17
24
|
},
|
|
18
25
|
"./three/react": {
|
|
26
|
+
"types": "./dist/three/react.d.ts",
|
|
19
27
|
"import": "./dist/three/react.js",
|
|
20
28
|
"require": "./dist/three/react.cjs"
|
|
21
29
|
},
|
|
22
30
|
"./webgl": {
|
|
31
|
+
"types": "./dist/webgl/index.d.ts",
|
|
23
32
|
"import": "./dist/webgl/index.js",
|
|
24
33
|
"require": "./dist/webgl/index.cjs"
|
|
25
34
|
},
|
|
26
35
|
"./webgpu": {
|
|
36
|
+
"types": "./dist/webgpu/index.d.ts",
|
|
27
37
|
"import": "./dist/webgpu/index.js",
|
|
28
38
|
"require": "./dist/webgpu/index.cjs"
|
|
29
39
|
},
|
|
30
40
|
"./p5": {
|
|
41
|
+
"types": "./dist/p5/index.d.ts",
|
|
31
42
|
"import": "./dist/p5/index.js",
|
|
32
43
|
"require": "./dist/p5/index.cjs"
|
|
33
44
|
},
|
|
34
|
-
"./patterns/*":
|
|
45
|
+
"./patterns/*": {
|
|
46
|
+
"types": "./dist/patterns/*.d.ts",
|
|
47
|
+
"import": "./dist/patterns/*.js",
|
|
48
|
+
"require": "./dist/patterns/*.cjs"
|
|
49
|
+
}
|
|
35
50
|
},
|
|
36
51
|
"files": [
|
|
37
52
|
"dist",
|
|
@@ -95,6 +110,7 @@
|
|
|
95
110
|
"libtess": "^1.2.2"
|
|
96
111
|
},
|
|
97
112
|
"devDependencies": {
|
|
113
|
+
"@webgpu/types": "^0.1.64",
|
|
98
114
|
"@react-three/fiber": ">=8.0.0",
|
|
99
115
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
100
116
|
"@rollup/plugin-node-resolve": "^15.0.0",
|