ultra-text 1.0.1 → 1.0.2

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.
Files changed (150) hide show
  1. package/README.md +224 -1002
  2. package/dist/assets/{cpuSdf.worker-xS57yQbP.js → cpuSdf.worker--X1Qpmdp.js} +136 -47
  3. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
  4. package/dist/atlas/appendAtlas.js +67 -25
  5. package/dist/atlas/appendAtlas.js.map +1 -1
  6. package/dist/atlas/buildAtlas.js +3 -2
  7. package/dist/atlas/buildAtlas.js.map +1 -1
  8. package/dist/atlas/cpuAtlas.d.ts +4 -1
  9. package/dist/atlas/cpuAtlas.js +8 -6
  10. package/dist/atlas/cpuAtlas.js.map +1 -1
  11. package/dist/atlas/cpuSdf.js +152 -40
  12. package/dist/atlas/cpuSdf.js.map +1 -1
  13. package/dist/atlas/cpuWorker.d.ts +5 -3
  14. package/dist/atlas/cpuWorker.js +119 -12
  15. package/dist/atlas/cpuWorker.js.map +1 -1
  16. package/dist/atlas/gpuAtlas.js +100 -276
  17. package/dist/atlas/gpuAtlas.js.map +1 -1
  18. package/dist/atlas/gpuCommon.d.ts +135 -0
  19. package/dist/atlas/gpuCommon.js +223 -0
  20. package/dist/atlas/gpuCommon.js.map +1 -0
  21. package/dist/atlas/jfaWgsl.js +47 -241
  22. package/dist/atlas/jfaWgsl.js.map +1 -1
  23. package/dist/atlas/rasterize.js +103 -58
  24. package/dist/atlas/rasterize.js.map +1 -1
  25. package/dist/atlas/shapeRaster.js +2 -1
  26. package/dist/atlas/shapeRaster.js.map +1 -1
  27. package/dist/atlas/vanillaBounds.d.ts +64 -0
  28. package/dist/atlas/vanillaBounds.js +42 -0
  29. package/dist/atlas/vanillaBounds.js.map +1 -0
  30. package/dist/atlas/vanillaCore.d.ts +100 -0
  31. package/dist/atlas/vanillaCore.js +1012 -0
  32. package/dist/atlas/vanillaCore.js.map +1 -0
  33. package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
  34. package/dist/atlas/vanillaCpuAtlas.js +87 -0
  35. package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
  36. package/dist/atlas/vanillaExtras.d.ts +8 -0
  37. package/dist/atlas/vanillaExtras.js +166 -0
  38. package/dist/atlas/vanillaExtras.js.map +1 -0
  39. package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
  40. package/dist/atlas/vanillaGpuHelpers.js +119 -0
  41. package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
  42. package/dist/dom/DomSdf.js +224 -284
  43. package/dist/dom/DomSdf.js.map +1 -1
  44. package/dist/dom/DomSlug.js +75 -151
  45. package/dist/dom/DomSlug.js.map +1 -1
  46. package/dist/dom/domAnalytic.d.ts +54 -0
  47. package/dist/dom/domAnalytic.js +282 -0
  48. package/dist/dom/domAnalytic.js.map +1 -0
  49. package/dist/dom/domExtras.d.ts +27 -0
  50. package/dist/dom/domExtras.js +137 -0
  51. package/dist/dom/domExtras.js.map +1 -0
  52. package/dist/dom/fontCanvas.js +27 -9
  53. package/dist/dom/fontCanvas.js.map +1 -1
  54. package/dist/dom/layoutSignature.js +150 -48
  55. package/dist/dom/layoutSignature.js.map +1 -1
  56. package/dist/dom/pretextLayout.js +55 -13
  57. package/dist/dom/pretextLayout.js.map +1 -1
  58. package/dist/dom/snapshot.js +369 -204
  59. package/dist/dom/snapshot.js.map +1 -1
  60. package/dist/dom/svgCapture.d.ts +8 -1
  61. package/dist/dom/svgCapture.js +75 -1
  62. package/dist/dom/svgCapture.js.map +1 -1
  63. package/dist/dom/tone.js +76 -36
  64. package/dist/dom/tone.js.map +1 -1
  65. package/dist/index.js +4 -3
  66. package/dist/slug/SlugMaterial.d.ts +11 -3
  67. package/dist/slug/SlugMaterial.js +54 -10
  68. package/dist/slug/SlugMaterial.js.map +1 -1
  69. package/dist/slug/coverage.d.ts +16 -12
  70. package/dist/slug/coverage.js +194 -221
  71. package/dist/slug/coverage.js.map +1 -1
  72. package/dist/slug/preprocessCore.d.ts +5 -1
  73. package/dist/slug/preprocessCore.js +118 -87
  74. package/dist/slug/preprocessCore.js.map +1 -1
  75. package/dist/slug/runtime.d.ts +1 -0
  76. package/dist/slug/runtime.js +90 -44
  77. package/dist/slug/runtime.js.map +1 -1
  78. package/dist/slug/standaloneRuntime.d.ts +3 -2
  79. package/dist/slug/standaloneRuntime.js +75 -40
  80. package/dist/slug/standaloneRuntime.js.map +1 -1
  81. package/dist/slug/truetype.js +166 -193
  82. package/dist/slug/truetype.js.map +1 -1
  83. package/dist/slug/vanillaCore.d.ts +340 -0
  84. package/dist/slug/vanillaCore.js +1621 -0
  85. package/dist/slug/vanillaCore.js.map +1 -0
  86. package/dist/slug-vanilla.d.ts +13 -364
  87. package/dist/slug-vanilla.js +5 -1453
  88. package/dist/slug.d.ts +1 -1
  89. package/dist/slug.js +6 -6
  90. package/dist/text/GlyphTextMaterial.d.ts +1 -1
  91. package/dist/text/GlyphTextMaterial.js +5 -5
  92. package/dist/text/GlyphTextMaterial.js.map +1 -1
  93. package/dist/text/SdfTextMaterial.js +7 -5
  94. package/dist/text/SdfTextMaterial.js.map +1 -1
  95. package/dist/text/decorations.js +36 -19
  96. package/dist/text/decorations.js.map +1 -1
  97. package/dist/text/geometry.d.ts +3 -22
  98. package/dist/text/geometryUtils.d.ts +11 -1
  99. package/dist/text/geometryUtils.js +22 -1
  100. package/dist/text/geometryUtils.js.map +1 -1
  101. package/dist/text/glyphGeometry.d.ts +9 -0
  102. package/dist/text/glyphGeometry.js +353 -0
  103. package/dist/text/glyphGeometry.js.map +1 -0
  104. package/dist/text/index.d.ts +2 -1
  105. package/dist/text/rectGeometry.d.ts +13 -0
  106. package/dist/text/rectGeometry.js +97 -0
  107. package/dist/text/rectGeometry.js.map +1 -0
  108. package/dist/text/reflow.d.ts +18 -1
  109. package/dist/text/reflow.js +108 -38
  110. package/dist/text/reflow.js.map +1 -1
  111. package/dist/text/snap.d.ts +1 -0
  112. package/dist/text/snap.js +26 -0
  113. package/dist/text/snap.js.map +1 -0
  114. package/dist/vanilla.d.ts +13 -363
  115. package/dist/vanilla.js +6 -1473
  116. package/dist/windfoil/geometry.d.ts +2 -2
  117. package/dist/windfoil/geometry.js +113 -40
  118. package/dist/windfoil/geometry.js.map +1 -1
  119. package/dist/windfoil/mixed.d.ts +1 -0
  120. package/dist/windfoil/mixed.js +44 -25
  121. package/dist/windfoil/mixed.js.map +1 -1
  122. package/dist/windfoil/preprocess.js +2 -2
  123. package/dist/windfoil/preprocessCore.d.ts +1 -0
  124. package/dist/windfoil/preprocessCore.js +9 -4
  125. package/dist/windfoil/preprocessCore.js.map +1 -1
  126. package/dist/windfoil/runtime.d.ts +3 -1
  127. package/dist/windfoil/runtime.js +62 -40
  128. package/dist/windfoil/runtime.js.map +1 -1
  129. package/dist/windfoil/storage.d.ts +60 -2
  130. package/dist/windfoil/storage.js +142 -6
  131. package/dist/windfoil/storage.js.map +1 -1
  132. package/dist/windfoil/trace/contours.d.ts +5 -0
  133. package/dist/windfoil/trace/contours.js +167 -43
  134. package/dist/windfoil/trace/contours.js.map +1 -1
  135. package/dist/windfoil/trace/fit.d.ts +3 -1
  136. package/dist/windfoil/trace/fit.js +471 -175
  137. package/dist/windfoil/trace/fit.js.map +1 -1
  138. package/dist/windfoil/trace/outline.js +55 -30
  139. package/dist/windfoil/trace/outline.js.map +1 -1
  140. package/dist/windfoil/trace/types.d.ts +10 -0
  141. package/dist/windfoil/tracedOutlines.js +59 -34
  142. package/dist/windfoil/tracedOutlines.js.map +1 -1
  143. package/package.json +11 -11
  144. package/skills/ultra-text/references/three-tsl.md +2 -2
  145. package/skills/ultra-text/references/vanilla-webgpu.md +3 -2
  146. package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
  147. package/dist/slug-vanilla.js.map +0 -1
  148. package/dist/text/geometry.js +0 -348
  149. package/dist/text/geometry.js.map +0 -1
  150. package/dist/vanilla.js.map +0 -1
@@ -1,348 +0,0 @@
1
- import { byte, metaSize, setBounds, setUnitQuad, writeMeta } from "./geometryUtils.js";
2
- import { InstancedBufferAttribute, InstancedBufferGeometry } from "three/webgpu";
3
- // src/text/geometry.ts
4
- /** Whether a snapshot needs shared animation centres and drawable ordinals. */
5
- function needsRunMotion(snapshot) {
6
- return snapshot.textShaping === "browser" || snapshot.glyphs.some((glyph) => glyph.motionOrigin !== void 0);
7
- }
8
- function shapeOrdinals(snapshot) {
9
- const glyphs = snapshot.glyphs;
10
- if (!glyphs.some((glyph) => glyph.shapeGroup !== void 0)) return void 0;
11
- const out = new Float32Array(glyphs.length);
12
- let ordinal = -1, previous;
13
- for (let index = 0; index < glyphs.length; index++) {
14
- const glyph = glyphs[index];
15
- if (glyph.shapeGroup === void 0 || glyph.shapeGroup !== previous) ordinal++;
16
- previous = glyph.shapeGroup;
17
- out[index] = glyph.motionOrigin?.[2] ?? ordinal;
18
- }
19
- return out;
20
- }
21
- /**
22
- * The atlas UV of a glyph's quad, in `sdfUvRect`'s order: (u0, v1, u1, v0), so that the
23
- * quad's corner 0 samples the first pair and corner 1 the second. Canvas atlases are
24
- * top-left-origin while Three.js UVs are bottom-left-origin.
25
- */
26
- function writeUvRect(target, offset, slot) {
27
- target[offset] = slot.u0 * 65535 + .5 | 0;
28
- target[offset + 1] = slot.v1 * 65535 + .5 | 0;
29
- target[offset + 2] = slot.u1 * 65535 + .5 | 0;
30
- target[offset + 3] = slot.v0 * 65535 + .5 | 0;
31
- }
32
- /** Four element stores: V8 inlines this, where `TypedArray.set` from a tuple is ~2x slower per glyph. */
33
- function put4(target, offset, source) {
34
- target[offset] = source[0];
35
- target[offset + 1] = source[1];
36
- target[offset + 2] = source[2];
37
- target[offset + 3] = source[3];
38
- }
39
- var clamp16 = (v) => Math.min(65535, Math.max(0, v));
40
- /**
41
- * The slot's support box in the same order and units, rounded outwards so the quad only grows;
42
- * a slot without one repeats its own UV rect, which draws the whole quad.
43
- */
44
- function writeTrim(target, offset, slot, uvRects) {
45
- const s = slot.support;
46
- target[offset] = s ? clamp16(Math.floor(s.u0 * 65535)) : uvRects[offset];
47
- target[offset + 1] = s ? clamp16(Math.ceil(s.v1 * 65535)) : uvRects[offset + 1];
48
- target[offset + 2] = s ? clamp16(Math.ceil(s.u1 * 65535)) : uvRects[offset + 2];
49
- target[offset + 3] = s ? clamp16(Math.floor(s.v0 * 65535)) : uvRects[offset + 3];
50
- }
51
- function writeGlyphRect(rects, offset, glyph, slot, invBakeSize, shaped) {
52
- const scale = glyph.fontSize * invBakeSize;
53
- const scaleX = shaped && slot.advance > 0 ? glyph.advance / slot.advance : scale;
54
- const baseline = glyph.lineBottom + (glyph.baselineOffset ?? slot.descent * scale);
55
- rects[offset] = glyph.originX + slot.planeX0 * scaleX;
56
- rects[offset + 1] = baseline + slot.planeY0 * scale;
57
- rects[offset + 2] = glyph.originX + slot.planeX1 * scaleX;
58
- rects[offset + 3] = baseline + slot.planeY1 * scale;
59
- }
60
- function writeRunMotion(runMotion, index, ordinal, glyph, rects, offset, motionOrdinals) {
61
- if (!runMotion) return;
62
- const rOffset = index * 3;
63
- const origin = glyph.motionOrigin;
64
- runMotion[rOffset] = origin ? origin[0] : (rects[offset] + rects[offset + 2]) * .5;
65
- runMotion[rOffset + 1] = origin ? origin[1] : (rects[offset + 1] + rects[offset + 3]) * .5;
66
- runMotion[rOffset + 2] = origin ? origin[2] : motionOrdinals?.[ordinal] ?? ordinal;
67
- }
68
- function writeGlyphBatch(snapshot, atlas, rects, clips, metadata, metaItemSize, runMotion, motionOrdinals, uvRects, trims, colors, maxCount = Infinity) {
69
- const glyphs = snapshot.glyphs;
70
- const total = glyphs.length;
71
- const shaped = snapshot.textShaping === "browser";
72
- const invBakeSize = 1 / atlas.bakeSize;
73
- const atlasGlyphs = atlas.glyphs;
74
- let count = 0;
75
- let maxSequence = 0;
76
- let minZ = 0;
77
- let maxZ = 0;
78
- let prevColor;
79
- let c0 = 0;
80
- let c1 = 0;
81
- let c2 = 0;
82
- let c3 = 0;
83
- for (let ordinal = 0; ordinal < total; ordinal++) {
84
- const glyph = glyphs[ordinal];
85
- const slot = atlasGlyphs.get(glyph.glyphKey);
86
- if (!slot) continue;
87
- if (count >= maxCount) return [
88
- -1,
89
- 0,
90
- 0,
91
- 0
92
- ];
93
- const index = count++;
94
- const offset = index * 4;
95
- writeGlyphRect(rects, offset, glyph, slot, invBakeSize, shaped);
96
- put4(clips, offset, glyph.clip);
97
- if (uvRects && colors) {
98
- writeUvRect(uvRects, offset, slot);
99
- if (trims) writeTrim(trims, offset, slot, uvRects);
100
- const color = glyph.color;
101
- if (color !== prevColor) {
102
- prevColor = color;
103
- c0 = byte(color[0]);
104
- c1 = byte(color[1]);
105
- c2 = byte(color[2]);
106
- c3 = byte(color[3]);
107
- }
108
- colors[offset] = c0;
109
- colors[offset + 1] = c1;
110
- colors[offset + 2] = c2;
111
- colors[offset + 3] = c3;
112
- writeMeta(metadata, index, metaItemSize, glyph);
113
- } else metadata[index * metaItemSize] = glyph.sequence;
114
- if (runMotion) writeRunMotion(runMotion, index, ordinal, glyph, rects, offset, motionOrdinals);
115
- if (glyph.sequence > maxSequence) maxSequence = glyph.sequence;
116
- if (glyph.z < minZ) minZ = glyph.z;
117
- if (glyph.z > maxZ) maxZ = glyph.z;
118
- }
119
- return [
120
- count,
121
- maxSequence,
122
- minZ,
123
- maxZ
124
- ];
125
- }
126
- var attrOf = (geometry, name) => geometry.getAttribute(name);
127
- function createGlyphGeometry(snapshot, atlas, motionPadding, motionOrdinals) {
128
- const hasRunMotion = needsRunMotion(snapshot);
129
- motionOrdinals ??= hasRunMotion ? shapeOrdinals(snapshot) : void 0;
130
- const total = snapshot.glyphs.length;
131
- const rects = new Float32Array(total * 4);
132
- const uvRects = new Uint16Array(total * 4);
133
- const clips = new Float32Array(total * 4);
134
- const colors = new Uint8Array(total * 4);
135
- const meta = metaSize(snapshot);
136
- const metadata = new Float32Array(total * meta);
137
- const runMotion = hasRunMotion || motionOrdinals ? new Float32Array(total * 3) : null;
138
- const trims = runMotion ? null : new Uint16Array(total * 4);
139
- const [count, maxSequence, minZ, maxZ] = writeGlyphBatch(snapshot, atlas, rects, clips, metadata, meta, runMotion, motionOrdinals, uvRects, trims, colors);
140
- const geometry = new InstancedBufferGeometry();
141
- geometry.name = "ultra-text instanced glyph quads";
142
- setUnitQuad(geometry);
143
- for (const [name, array, size, normalized] of [
144
- [
145
- "sdfRect",
146
- rects,
147
- 4,
148
- false
149
- ],
150
- [
151
- "sdfUvRect",
152
- uvRects,
153
- 4,
154
- true
155
- ],
156
- [
157
- "sdfClip",
158
- clips,
159
- 4,
160
- false
161
- ],
162
- [
163
- "sdfColor",
164
- colors,
165
- 4,
166
- true
167
- ],
168
- [
169
- "sdfMeta",
170
- metadata,
171
- meta,
172
- false
173
- ],
174
- [
175
- "sdfRunMotion",
176
- runMotion,
177
- 3,
178
- false
179
- ],
180
- [
181
- "sdfTrim",
182
- trims,
183
- 4,
184
- true
185
- ]
186
- ]) if (array) geometry.setAttribute(name, new InstancedBufferAttribute(count === total ? array : array.subarray(0, count * size), size, normalized));
187
- geometry.instanceCount = count;
188
- setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ);
189
- return {
190
- geometry,
191
- maxSequence
192
- };
193
- }
194
- function updateGlyphGeometry(geometry, snapshot, atlas, motionPadding, motionOrdinals) {
195
- const instanceCount = geometry.instanceCount;
196
- if (snapshot.glyphs.length < instanceCount) return null;
197
- const rectAttribute = attrOf(geometry, "sdfRect");
198
- const clipAttribute = attrOf(geometry, "sdfClip");
199
- const metaAttribute = attrOf(geometry, "sdfMeta");
200
- if (!rectAttribute || !clipAttribute || !metaAttribute) return null;
201
- motionOrdinals ??= needsRunMotion(snapshot) ? shapeOrdinals(snapshot) : void 0;
202
- const runAttribute = attrOf(geometry, "sdfRunMotion");
203
- const [count, maxSequence, minZ, maxZ] = writeGlyphBatch(snapshot, atlas, rectAttribute.array, clipAttribute.array, metaAttribute.array, metaAttribute.itemSize, runAttribute ? runAttribute.array : null, motionOrdinals, void 0, void 0, void 0, instanceCount);
204
- if (count !== instanceCount) return null;
205
- rectAttribute.needsUpdate = true;
206
- clipAttribute.needsUpdate = true;
207
- metaAttribute.needsUpdate = true;
208
- if (runAttribute) runAttribute.needsUpdate = true;
209
- setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ);
210
- return maxSequence;
211
- }
212
- function drawableGlyphCountMatches(snapshot, atlas, expectedCount) {
213
- let count = 0;
214
- for (const glyph of snapshot.glyphs) if (atlas.glyphs.has(glyph.glyphKey) && ++count > expectedCount) return false;
215
- return count === expectedCount;
216
- }
217
- function instanceAttribute(geometry, name, itemSize) {
218
- const attribute = attrOf(geometry, name);
219
- return attribute?.itemSize === itemSize && attribute.count === geometry.instanceCount;
220
- }
221
- function glyphContentFits(geometry, snapshot, atlas, motionOrdinals) {
222
- const instanceCount = geometry.instanceCount;
223
- if (snapshot.glyphs.length < instanceCount) return false;
224
- for (const name of [
225
- "sdfRect",
226
- "sdfUvRect",
227
- "sdfClip",
228
- "sdfColor"
229
- ]) if (!instanceAttribute(geometry, name, 4)) return false;
230
- if (!instanceAttribute(geometry, "sdfMeta", metaSize(snapshot))) return false;
231
- const run = attrOf(geometry, "sdfRunMotion");
232
- const wantsRun = needsRunMotion(snapshot) || !!motionOrdinals;
233
- const trim = attrOf(geometry, "sdfTrim");
234
- return (wantsRun ? run?.itemSize === 3 && run.count === instanceCount && trim === void 0 : run === void 0 && (trim === void 0 || instanceAttribute(geometry, "sdfTrim", 4))) && drawableGlyphCountMatches(snapshot, atlas, instanceCount);
235
- }
236
- function updateGlyphContent(geometry, snapshot, atlas, motionPadding, motionOrdinals, checked) {
237
- motionOrdinals ??= needsRunMotion(snapshot) ? shapeOrdinals(snapshot) : void 0;
238
- if (!checked && !glyphContentFits(geometry, snapshot, atlas, motionOrdinals)) return null;
239
- const trimAttribute = attrOf(geometry, "sdfTrim");
240
- const metaAttribute = attrOf(geometry, "sdfMeta");
241
- const runAttribute = attrOf(geometry, "sdfRunMotion");
242
- const [, maxSequence, minZ, maxZ] = writeGlyphBatch(snapshot, atlas, attrOf(geometry, "sdfRect").array, attrOf(geometry, "sdfClip").array, metaAttribute.array, metaAttribute.itemSize, runAttribute ? runAttribute.array : null, motionOrdinals, attrOf(geometry, "sdfUvRect").array, trimAttribute ? trimAttribute.array : null, attrOf(geometry, "sdfColor").array);
243
- for (const name of [
244
- "sdfRect",
245
- "sdfUvRect",
246
- "sdfClip",
247
- "sdfColor",
248
- "sdfMeta"
249
- ]) attrOf(geometry, name).needsUpdate = true;
250
- if (trimAttribute) trimAttribute.needsUpdate = true;
251
- if (runAttribute) runAttribute.needsUpdate = true;
252
- setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ);
253
- return maxSequence;
254
- }
255
- function rectCountFor(snapshot, receiveShadow) {
256
- let count = 0;
257
- for (const rect of snapshot.rects) if (rect.receiveShadow === receiveShadow) count++;
258
- return count;
259
- }
260
- function writeRectBatch(snapshot, receiveShadow, rects, colors, radii, depths) {
261
- let index = 0;
262
- let minZ = 0;
263
- let maxZ = 0;
264
- for (const item of snapshot.rects) {
265
- if (item.receiveShadow !== receiveShadow) continue;
266
- const offset = index * 4;
267
- put4(rects, offset, item.rect);
268
- colors[offset] = byte(item.color[0]);
269
- colors[offset + 1] = byte(item.color[1]);
270
- colors[offset + 2] = byte(item.color[2]);
271
- colors[offset + 3] = byte(item.color[3]);
272
- radii[index] = item.radius;
273
- depths[index] = item.z;
274
- if (item.z < minZ) minZ = item.z;
275
- if (item.z > maxZ) maxZ = item.z;
276
- index++;
277
- }
278
- return [minZ, maxZ];
279
- }
280
- /** True when a rectangle batch has the same instance count and attribute layout. */
281
- function rectContentFits(geometry, snapshot, receiveShadow) {
282
- if (snapshot.rects.length < geometry.instanceCount) return false;
283
- if (!instanceAttribute(geometry, "sdfRect", 4) || !instanceAttribute(geometry, "sdfColor", 4) || !instanceAttribute(geometry, "sdfRadius", 1) || !instanceAttribute(geometry, "sdfZ", 1)) return false;
284
- return rectCountFor(snapshot, receiveShadow) === geometry.instanceCount;
285
- }
286
- /** Rewrites a same-count rectangle batch. Returns false without writing when it does not fit. */
287
- function updateRectGeometry(geometry, snapshot, receiveShadow) {
288
- if (!rectContentFits(geometry, snapshot, receiveShadow)) return false;
289
- const [minZ, maxZ] = writeRectBatch(snapshot, receiveShadow, attrOf(geometry, "sdfRect").array, attrOf(geometry, "sdfColor").array, attrOf(geometry, "sdfRadius").array, attrOf(geometry, "sdfZ").array);
290
- for (const name of [
291
- "sdfRect",
292
- "sdfColor",
293
- "sdfRadius",
294
- "sdfZ"
295
- ]) attrOf(geometry, name).needsUpdate = true;
296
- setBounds(geometry, snapshot.width, snapshot.height, 0, minZ, maxZ);
297
- return true;
298
- }
299
- /**
300
- * Builds one instanced rectangle batch for a shadow-receiver state: pass
301
- * `receiveShadow: true` for the lit batch, `false` for the plain one.
302
- * Returns null when the snapshot has no rectangles in that bucket — callers
303
- * must handle the empty case instead of creating a zero-instance mesh.
304
- */
305
- function createRectGeometry(snapshot, receiveShadow) {
306
- const count = rectCountFor(snapshot, receiveShadow);
307
- if (count === 0) return null;
308
- const rects = new Float32Array(count * 4);
309
- const colors = new Uint8Array(count * 4);
310
- const radii = new Float32Array(count);
311
- const depths = new Float32Array(count);
312
- const [minZ, maxZ] = writeRectBatch(snapshot, receiveShadow, rects, colors, radii, depths);
313
- const geometry = new InstancedBufferGeometry();
314
- geometry.name = receiveShadow ? "ultra-text instanced shadow-receiving DOM rects" : "ultra-text instanced DOM rects";
315
- setUnitQuad(geometry);
316
- for (const [name, array, size, normalized] of [
317
- [
318
- "sdfRect",
319
- rects,
320
- 4,
321
- false
322
- ],
323
- [
324
- "sdfColor",
325
- colors,
326
- 4,
327
- true
328
- ],
329
- [
330
- "sdfRadius",
331
- radii,
332
- 1,
333
- false
334
- ],
335
- [
336
- "sdfZ",
337
- depths,
338
- 1,
339
- false
340
- ]
341
- ]) geometry.setAttribute(name, new InstancedBufferAttribute(array, size, normalized));
342
- geometry.instanceCount = count;
343
- setBounds(geometry, snapshot.width, snapshot.height, 0, minZ, maxZ);
344
- return geometry;
345
- }
346
- export { createGlyphGeometry, createRectGeometry, glyphContentFits, needsRunMotion, rectContentFits, updateGlyphContent, updateGlyphGeometry, updateRectGeometry };
347
-
348
- //# sourceMappingURL=geometry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geometry.js","names":[],"sources":["../../src/text/geometry.ts"],"sourcesContent":["import { InstancedBufferAttribute, InstancedBufferGeometry } from 'three/webgpu'\nimport { byte, metaSize, setBounds, setUnitQuad, writeMeta } from './geometryUtils.js'\n\nimport type { DomLayoutSnapshot, GlyphLayout, GlyphSlot, SdfAtlas } from '../types.js'\n\n/** Whether a snapshot needs shared animation centres and drawable ordinals. */\nexport function needsRunMotion(snapshot: DomLayoutSnapshot): boolean {\n return (\n snapshot.textShaping === 'browser' ||\n snapshot.glyphs.some((glyph) => glyph.motionOrigin !== undefined)\n )\n}\n\nfunction shapeOrdinals(snapshot: DomLayoutSnapshot): Float32Array | undefined {\n const glyphs = snapshot.glyphs\n if (!glyphs.some((glyph) => glyph.shapeGroup !== undefined)) return undefined\n const out = new Float32Array(glyphs.length)\n let ordinal = -1,\n previous: number | undefined\n for (let index = 0; index < glyphs.length; index++) {\n const glyph = glyphs[index]!\n if (glyph.shapeGroup === undefined || glyph.shapeGroup !== previous) ordinal++\n previous = glyph.shapeGroup\n out[index] = glyph.motionOrigin?.[2] ?? ordinal\n }\n return out\n}\n\n/**\n * The atlas UV of a glyph's quad, in `sdfUvRect`'s order: (u0, v1, u1, v0), so that the\n * quad's corner 0 samples the first pair and corner 1 the second. Canvas atlases are\n * top-left-origin while Three.js UVs are bottom-left-origin.\n */\nfunction writeUvRect(target: Uint16Array, offset: number, slot: GlyphSlot): void {\n target[offset] = (slot.u0 * 65535 + 0.5) | 0\n target[offset + 1] = (slot.v1 * 65535 + 0.5) | 0\n target[offset + 2] = (slot.u1 * 65535 + 0.5) | 0\n target[offset + 3] = (slot.v0 * 65535 + 0.5) | 0\n}\n\n/** Four element stores: V8 inlines this, where `TypedArray.set` from a tuple is ~2x slower per glyph. */\nfunction put4(target: Float32Array, offset: number, source: readonly number[]): void {\n target[offset] = source[0]!\n target[offset + 1] = source[1]!\n target[offset + 2] = source[2]!\n target[offset + 3] = source[3]!\n}\n\nconst clamp16 = (v: number): number => Math.min(65535, Math.max(0, v))\n\n/**\n * The slot's support box in the same order and units, rounded outwards so the quad only grows;\n * a slot without one repeats its own UV rect, which draws the whole quad.\n */\nfunction writeTrim(target: Uint16Array, offset: number, slot: GlyphSlot, uvRects: Uint16Array) {\n const s = slot.support\n target[offset] = s ? clamp16(Math.floor(s.u0 * 65535)) : uvRects[offset]!\n target[offset + 1] = s ? clamp16(Math.ceil(s.v1 * 65535)) : uvRects[offset + 1]!\n target[offset + 2] = s ? clamp16(Math.ceil(s.u1 * 65535)) : uvRects[offset + 2]!\n target[offset + 3] = s ? clamp16(Math.floor(s.v0 * 65535)) : uvRects[offset + 3]!\n}\n\nfunction writeGlyphRect(\n rects: Float32Array,\n offset: number,\n glyph: GlyphLayout,\n slot: GlyphSlot,\n invBakeSize: number,\n shaped: boolean,\n): void {\n const scale = glyph.fontSize * invBakeSize\n const scaleX = shaped && slot.advance > 0 ? glyph.advance / slot.advance : scale\n // Range.getBoundingClientRect() reports the text box, not the line box, so\n // lineBottom already sits on the descender line: adding half the CSS\n // leading back on top of it lifted every glyph off its baseline.\n const baseline = glyph.lineBottom + (glyph.baselineOffset ?? slot.descent * scale)\n rects[offset] = glyph.originX + slot.planeX0 * scaleX\n rects[offset + 1] = baseline + slot.planeY0 * scale\n rects[offset + 2] = glyph.originX + slot.planeX1 * scaleX\n rects[offset + 3] = baseline + slot.planeY1 * scale\n}\n\nfunction writeRunMotion(\n runMotion: Float32Array | null,\n index: number,\n ordinal: number,\n glyph: GlyphLayout,\n rects: Float32Array,\n offset: number,\n motionOrdinals: Float32Array | undefined,\n): void {\n if (!runMotion) return\n const rOffset = index * 3\n const origin = glyph.motionOrigin\n runMotion[rOffset] = origin ? origin[0] : (rects[offset]! + rects[offset + 2]!) * 0.5\n runMotion[rOffset + 1] = origin ? origin[1] : (rects[offset + 1]! + rects[offset + 3]!) * 0.5\n runMotion[rOffset + 2] = origin ? origin[2] : (motionOrdinals?.[ordinal] ?? ordinal)\n}\n\nfunction writeGlyphBatch(\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n rects: Float32Array,\n clips: Float32Array,\n metadata: Float32Array,\n metaItemSize: number,\n runMotion: Float32Array | null,\n motionOrdinals: Float32Array | undefined,\n uvRects?: Uint16Array,\n trims?: Uint16Array | null,\n colors?: Uint8Array,\n maxCount = Infinity,\n): [number, number, number, number] {\n const glyphs = snapshot.glyphs\n const total = glyphs.length\n const shaped = snapshot.textShaping === 'browser'\n const invBakeSize = 1 / atlas.bakeSize\n const atlasGlyphs = atlas.glyphs\n let count = 0\n let maxSequence = 0\n let minZ = 0\n let maxZ = 0\n let prevColor: GlyphLayout['color'] | undefined\n let c0 = 0\n let c1 = 0\n let c2 = 0\n let c3 = 0\n for (let ordinal = 0; ordinal < total; ordinal++) {\n const glyph = glyphs[ordinal]!\n const slot = atlasGlyphs.get(glyph.glyphKey)\n if (!slot) continue\n if (count >= maxCount) return [-1, 0, 0, 0]\n const index = count++\n const offset = index * 4\n writeGlyphRect(rects, offset, glyph, slot, invBakeSize, shaped)\n put4(clips, offset, glyph.clip)\n if (uvRects && colors) {\n writeUvRect(uvRects, offset, slot)\n if (trims) writeTrim(trims, offset, slot, uvRects)\n const color = glyph.color\n if (color !== prevColor) {\n prevColor = color\n c0 = byte(color[0])\n c1 = byte(color[1])\n c2 = byte(color[2])\n c3 = byte(color[3])\n }\n colors[offset] = c0\n colors[offset + 1] = c1\n colors[offset + 2] = c2\n colors[offset + 3] = c3\n writeMeta(metadata, index, metaItemSize, glyph)\n } else {\n metadata[index * metaItemSize] = glyph.sequence\n }\n if (runMotion) writeRunMotion(runMotion, index, ordinal, glyph, rects, offset, motionOrdinals)\n if (glyph.sequence > maxSequence) maxSequence = glyph.sequence\n if (glyph.z < minZ) minZ = glyph.z\n if (glyph.z > maxZ) maxZ = glyph.z\n }\n return [count, maxSequence, minZ, maxZ]\n}\n\nconst attrOf = <T extends Float32Array | Uint16Array | Uint8Array>(\n geometry: InstancedBufferGeometry,\n name: string,\n): (InstancedBufferAttribute & { array: T }) | undefined =>\n geometry.getAttribute(name) as (InstancedBufferAttribute & { array: T }) | undefined\n\nexport function createGlyphGeometry(\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n motionPadding: number,\n motionOrdinals?: Float32Array,\n): { geometry: InstancedBufferGeometry; maxSequence: number } {\n const hasRunMotion = needsRunMotion(snapshot)\n motionOrdinals ??= hasRunMotion ? shapeOrdinals(snapshot) : undefined\n const total = snapshot.glyphs.length\n const rects = new Float32Array(total * 4)\n const uvRects = new Uint16Array(total * 4)\n const clips = new Float32Array(total * 4)\n const colors = new Uint8Array(total * 4)\n const meta = metaSize(snapshot)\n const metadata = new Float32Array(total * meta)\n const runMotion = hasRunMotion || motionOrdinals ? new Float32Array(total * 3) : null\n const trims = runMotion ? null : new Uint16Array(total * 4)\n const [count, maxSequence, minZ, maxZ] = writeGlyphBatch(\n snapshot,\n atlas,\n rects,\n clips,\n metadata,\n meta,\n runMotion,\n motionOrdinals,\n uvRects,\n trims,\n colors,\n )\n\n const geometry = new InstancedBufferGeometry()\n geometry.name = 'ultra-text instanced glyph quads'\n setUnitQuad(geometry)\n for (const [name, array, size, normalized] of [\n ['sdfRect', rects, 4, false],\n ['sdfUvRect', uvRects, 4, true],\n ['sdfClip', clips, 4, false],\n ['sdfColor', colors, 4, true],\n ['sdfMeta', metadata, meta, false],\n ['sdfRunMotion', runMotion, 3, false],\n ['sdfTrim', trims, 4, true],\n ] as const) {\n if (array)\n geometry.setAttribute(\n name,\n new InstancedBufferAttribute(\n count === total ? array : array.subarray(0, count * size),\n size,\n normalized,\n ),\n )\n }\n geometry.instanceCount = count\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ)\n return { geometry, maxSequence }\n}\n\nexport function updateGlyphGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n motionPadding: number,\n motionOrdinals?: Float32Array,\n): number | null {\n const instanceCount = geometry.instanceCount\n if (snapshot.glyphs.length < instanceCount) return null\n const rectAttribute = attrOf<Float32Array>(geometry, 'sdfRect')\n const clipAttribute = attrOf<Float32Array>(geometry, 'sdfClip')\n const metaAttribute = attrOf<Float32Array>(geometry, 'sdfMeta')\n if (!rectAttribute || !clipAttribute || !metaAttribute) return null\n motionOrdinals ??= needsRunMotion(snapshot) ? shapeOrdinals(snapshot) : undefined\n const runAttribute = attrOf<Float32Array>(geometry, 'sdfRunMotion')\n const [count, maxSequence, minZ, maxZ] = writeGlyphBatch(\n snapshot,\n atlas,\n rectAttribute.array,\n clipAttribute.array,\n metaAttribute.array,\n metaAttribute.itemSize,\n runAttribute ? runAttribute.array : null,\n motionOrdinals,\n undefined,\n undefined,\n undefined,\n instanceCount,\n )\n if (count !== instanceCount) return null\n\n rectAttribute.needsUpdate = true\n clipAttribute.needsUpdate = true\n metaAttribute.needsUpdate = true\n if (runAttribute) runAttribute.needsUpdate = true\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ)\n return maxSequence\n}\n\nfunction drawableGlyphCountMatches(\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n expectedCount: number,\n): boolean {\n let count = 0\n for (const glyph of snapshot.glyphs) {\n if (atlas.glyphs.has(glyph.glyphKey) && ++count > expectedCount) return false\n }\n return count === expectedCount\n}\n\nfunction instanceAttribute(\n geometry: InstancedBufferGeometry,\n name: string,\n itemSize: number,\n): boolean {\n const attribute = attrOf(geometry, name)\n return attribute?.itemSize === itemSize && attribute.count === geometry.instanceCount\n}\n\nexport function glyphContentFits(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n motionOrdinals?: Float32Array,\n): boolean {\n const instanceCount = geometry.instanceCount\n if (snapshot.glyphs.length < instanceCount) return false\n for (const name of ['sdfRect', 'sdfUvRect', 'sdfClip', 'sdfColor']) {\n if (!instanceAttribute(geometry, name, 4)) return false\n }\n if (!instanceAttribute(geometry, 'sdfMeta', metaSize(snapshot))) return false\n const run = attrOf(geometry, 'sdfRunMotion')\n const wantsRun = needsRunMotion(snapshot) || !!motionOrdinals\n const trim = attrOf(geometry, 'sdfTrim')\n const layoutFits = wantsRun\n ? run?.itemSize === 3 && run.count === instanceCount && trim === undefined\n : run === undefined && (trim === undefined || instanceAttribute(geometry, 'sdfTrim', 4))\n return layoutFits && drawableGlyphCountMatches(snapshot, atlas, instanceCount)\n}\n\nexport function updateGlyphContent(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n atlas: SdfAtlas,\n motionPadding: number,\n motionOrdinals?: Float32Array,\n checked?: boolean,\n): number | null {\n motionOrdinals ??= needsRunMotion(snapshot) ? shapeOrdinals(snapshot) : undefined\n if (!checked && !glyphContentFits(geometry, snapshot, atlas, motionOrdinals)) return null\n const trimAttribute = attrOf<Uint16Array>(geometry, 'sdfTrim')\n const metaAttribute = attrOf<Float32Array>(geometry, 'sdfMeta')!\n const runAttribute = attrOf<Float32Array>(geometry, 'sdfRunMotion')\n const [, maxSequence, minZ, maxZ] = writeGlyphBatch(\n snapshot,\n atlas,\n attrOf<Float32Array>(geometry, 'sdfRect')!.array,\n attrOf<Float32Array>(geometry, 'sdfClip')!.array,\n metaAttribute.array,\n metaAttribute.itemSize,\n runAttribute ? runAttribute.array : null,\n motionOrdinals,\n attrOf<Uint16Array>(geometry, 'sdfUvRect')!.array,\n trimAttribute ? trimAttribute.array : null,\n attrOf<Uint8Array>(geometry, 'sdfColor')!.array,\n )\n for (const name of ['sdfRect', 'sdfUvRect', 'sdfClip', 'sdfColor', 'sdfMeta']) {\n attrOf(geometry, name)!.needsUpdate = true\n }\n if (trimAttribute) trimAttribute.needsUpdate = true\n if (runAttribute) runAttribute.needsUpdate = true\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, minZ, maxZ)\n return maxSequence\n}\n\nfunction rectCountFor(snapshot: DomLayoutSnapshot, receiveShadow: boolean): number {\n let count = 0\n for (const rect of snapshot.rects) if (rect.receiveShadow === receiveShadow) count++\n return count\n}\n\nfunction writeRectBatch(\n snapshot: DomLayoutSnapshot,\n receiveShadow: boolean,\n rects: Float32Array,\n colors: Uint8Array,\n radii: Float32Array,\n depths: Float32Array,\n): [number, number] {\n let index = 0\n let minZ = 0\n let maxZ = 0\n for (const item of snapshot.rects) {\n if (item.receiveShadow !== receiveShadow) continue\n const offset = index * 4\n put4(rects, offset, item.rect)\n colors[offset] = byte(item.color[0])\n colors[offset + 1] = byte(item.color[1])\n colors[offset + 2] = byte(item.color[2])\n colors[offset + 3] = byte(item.color[3])\n radii[index] = item.radius\n depths[index] = item.z\n if (item.z < minZ) minZ = item.z\n if (item.z > maxZ) maxZ = item.z\n index++\n }\n return [minZ, maxZ]\n}\n\n/** True when a rectangle batch has the same instance count and attribute layout. */\nexport function rectContentFits(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n receiveShadow: boolean,\n): boolean {\n if (snapshot.rects.length < geometry.instanceCount) return false\n if (\n !instanceAttribute(geometry, 'sdfRect', 4) ||\n !instanceAttribute(geometry, 'sdfColor', 4) ||\n !instanceAttribute(geometry, 'sdfRadius', 1) ||\n !instanceAttribute(geometry, 'sdfZ', 1)\n ) {\n return false\n }\n return rectCountFor(snapshot, receiveShadow) === geometry.instanceCount\n}\n\n/** Rewrites a same-count rectangle batch. Returns false without writing when it does not fit. */\nexport function updateRectGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n receiveShadow: boolean,\n): boolean {\n if (!rectContentFits(geometry, snapshot, receiveShadow)) return false\n const [minZ, maxZ] = writeRectBatch(\n snapshot,\n receiveShadow,\n attrOf<Float32Array>(geometry, 'sdfRect')!.array,\n attrOf<Uint8Array>(geometry, 'sdfColor')!.array,\n attrOf<Float32Array>(geometry, 'sdfRadius')!.array,\n attrOf<Float32Array>(geometry, 'sdfZ')!.array,\n )\n for (const name of ['sdfRect', 'sdfColor', 'sdfRadius', 'sdfZ']) {\n attrOf(geometry, name)!.needsUpdate = true\n }\n setBounds(geometry, snapshot.width, snapshot.height, 0, minZ, maxZ)\n return true\n}\n\n/**\n * Builds one instanced rectangle batch for a shadow-receiver state: pass\n * `receiveShadow: true` for the lit batch, `false` for the plain one.\n * Returns null when the snapshot has no rectangles in that bucket — callers\n * must handle the empty case instead of creating a zero-instance mesh.\n */\nexport function createRectGeometry(\n snapshot: DomLayoutSnapshot,\n receiveShadow: boolean,\n): InstancedBufferGeometry | null {\n const count = rectCountFor(snapshot, receiveShadow)\n if (count === 0) return null\n const rects = new Float32Array(count * 4)\n const colors = new Uint8Array(count * 4)\n const radii = new Float32Array(count)\n const depths = new Float32Array(count)\n const [minZ, maxZ] = writeRectBatch(snapshot, receiveShadow, rects, colors, radii, depths)\n\n const geometry = new InstancedBufferGeometry()\n geometry.name = receiveShadow\n ? 'ultra-text instanced shadow-receiving DOM rects'\n : 'ultra-text instanced DOM rects'\n setUnitQuad(geometry)\n for (const [name, array, size, normalized] of [\n ['sdfRect', rects, 4, false],\n ['sdfColor', colors, 4, true],\n ['sdfRadius', radii, 1, false],\n ['sdfZ', depths, 1, false],\n ] as const) {\n geometry.setAttribute(name, new InstancedBufferAttribute(array, size, normalized))\n }\n geometry.instanceCount = count\n setBounds(geometry, snapshot.width, snapshot.height, 0, minZ, maxZ)\n return geometry\n}\n"],"mappings":";;;;AAMA,SAAgB,eAAe,UAAsC;CACnE,OACE,SAAS,gBAAgB,aACzB,SAAS,OAAO,MAAM,UAAU,MAAM,iBAAiB,KAAA,CAAS;AAEpE;AAEA,SAAS,cAAc,UAAuD;CAC5E,MAAM,SAAS,SAAS;CACxB,IAAI,CAAC,OAA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