ultra-text 1.0.2 → 1.0.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.
Files changed (206) hide show
  1. package/README.md +193 -115
  2. package/dist/assets/{cpuSdf.worker--X1Qpmdp.js → cpuSdf.worker-Dy4P5_TI.js} +98 -43
  3. package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
  4. package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
  5. package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
  6. package/dist/atlas/appendAtlas.js +35 -11
  7. package/dist/atlas/appendAtlas.js.map +1 -1
  8. package/dist/atlas/buildAtlas.js +1 -1
  9. package/dist/atlas/buildAtlas.js.map +1 -1
  10. package/dist/atlas/colorGlyphs.d.ts +0 -10
  11. package/dist/atlas/colorGlyphs.js +97 -155
  12. package/dist/atlas/colorGlyphs.js.map +1 -1
  13. package/dist/atlas/colorTexture.d.ts +1 -0
  14. package/dist/atlas/colorTexture.js +64 -0
  15. package/dist/atlas/colorTexture.js.map +1 -0
  16. package/dist/atlas/cpuAtlas.js +8 -3
  17. package/dist/atlas/cpuAtlas.js.map +1 -1
  18. package/dist/atlas/cpuSdf.d.ts +1 -1
  19. package/dist/atlas/cpuSdf.js +97 -42
  20. package/dist/atlas/cpuSdf.js.map +1 -1
  21. package/dist/atlas/cpuWorker.d.ts +10 -4
  22. package/dist/atlas/cpuWorker.js +99 -49
  23. package/dist/atlas/cpuWorker.js.map +1 -1
  24. package/dist/atlas/gpuAtlas.js +133 -56
  25. package/dist/atlas/gpuAtlas.js.map +1 -1
  26. package/dist/atlas/gpuCommon.d.ts +140 -18
  27. package/dist/atlas/gpuCommon.js +726 -104
  28. package/dist/atlas/gpuCommon.js.map +1 -1
  29. package/dist/atlas/jfaWgsl.d.ts +1 -1
  30. package/dist/atlas/jfaWgsl.js +232 -61
  31. package/dist/atlas/jfaWgsl.js.map +1 -1
  32. package/dist/atlas/rasterize.d.ts +22 -0
  33. package/dist/atlas/rasterize.js +237 -111
  34. package/dist/atlas/rasterize.js.map +1 -1
  35. package/dist/atlas/vanillaCore.js +156 -103
  36. package/dist/atlas/vanillaCore.js.map +1 -1
  37. package/dist/atlas/vanillaCpuAtlas.js +37 -52
  38. package/dist/atlas/vanillaCpuAtlas.js.map +1 -1
  39. package/dist/atlas/vanillaExtras.js +91 -90
  40. package/dist/atlas/vanillaExtras.js.map +1 -1
  41. package/dist/atlas/vanillaGpuHelpers.d.ts +70 -7
  42. package/dist/atlas/vanillaGpuHelpers.js +262 -27
  43. package/dist/atlas/vanillaGpuHelpers.js.map +1 -1
  44. package/dist/dom/DomSdf.js +85 -79
  45. package/dist/dom/DomSdf.js.map +1 -1
  46. package/dist/dom/DomSlug.js +23 -18
  47. package/dist/dom/DomSlug.js.map +1 -1
  48. package/dist/dom/Text.d.ts +4 -1
  49. package/dist/dom/Text.js +5 -1
  50. package/dist/dom/Text.js.map +1 -1
  51. package/dist/dom/browserShaping.js +31 -14
  52. package/dist/dom/browserShaping.js.map +1 -1
  53. package/dist/dom/clusters.js +13 -2
  54. package/dist/dom/clusters.js.map +1 -1
  55. package/dist/dom/cssEffects.d.ts +4 -0
  56. package/dist/dom/cssEffects.js +72 -0
  57. package/dist/dom/cssEffects.js.map +1 -0
  58. package/dist/dom/domAnalytic.d.ts +1 -2
  59. package/dist/dom/domAnalytic.js +1 -1
  60. package/dist/dom/domAnalytic.js.map +1 -1
  61. package/dist/dom/fontCanvas.d.ts +16 -0
  62. package/dist/dom/fontCanvas.js +4 -4
  63. package/dist/dom/fontCanvas.js.map +1 -1
  64. package/dist/dom/layoutSignature.js +28 -12
  65. package/dist/dom/layoutSignature.js.map +1 -1
  66. package/dist/dom/markup.d.ts +10 -0
  67. package/dist/dom/markup.js +16 -1
  68. package/dist/dom/markup.js.map +1 -1
  69. package/dist/dom/pretextLayout.js +27 -19
  70. package/dist/dom/pretextLayout.js.map +1 -1
  71. package/dist/dom/snapshot.d.ts +4 -0
  72. package/dist/dom/snapshot.js +747 -505
  73. package/dist/dom/snapshot.js.map +1 -1
  74. package/dist/dom/snapshotsEqual.d.ts +7 -0
  75. package/dist/dom/snapshotsEqual.js +68 -0
  76. package/dist/dom/snapshotsEqual.js.map +1 -0
  77. package/dist/dom/svgCapture.js +30 -27
  78. package/dist/dom/svgCapture.js.map +1 -1
  79. package/dist/dom/textTransform.d.ts +13 -1
  80. package/dist/dom/textTransform.js +31 -13
  81. package/dist/dom/textTransform.js.map +1 -1
  82. package/dist/dom/tone.js +15 -8
  83. package/dist/dom/tone.js.map +1 -1
  84. package/dist/slug/SlugMaterial.d.ts +6 -0
  85. package/dist/slug/SlugMaterial.js +48 -20
  86. package/dist/slug/SlugMaterial.js.map +1 -1
  87. package/dist/slug/cff.d.ts +5 -0
  88. package/dist/slug/cff.js +780 -0
  89. package/dist/slug/cff.js.map +1 -0
  90. package/dist/slug/coverage.d.ts +3 -3
  91. package/dist/slug/coverage.js +283 -101
  92. package/dist/slug/coverage.js.map +1 -1
  93. package/dist/slug/preprocessCore.d.ts +1 -1
  94. package/dist/slug/preprocessCore.js +100 -80
  95. package/dist/slug/preprocessCore.js.map +1 -1
  96. package/dist/slug/runtime.js +32 -39
  97. package/dist/slug/runtime.js.map +1 -1
  98. package/dist/slug/standaloneRuntime.js +47 -37
  99. package/dist/slug/standaloneRuntime.js.map +1 -1
  100. package/dist/slug/truetype.d.ts +14 -6
  101. package/dist/slug/truetype.js +190 -62
  102. package/dist/slug/truetype.js.map +1 -1
  103. package/dist/slug/vanillaCore.d.ts +74 -4
  104. package/dist/slug/vanillaCore.js +226 -217
  105. package/dist/slug/vanillaCore.js.map +1 -1
  106. package/dist/slug-vanilla.d.ts +1 -1
  107. package/dist/slug-vanilla.js +5 -4
  108. package/dist/slug.d.ts +1 -1
  109. package/dist/slug.js +3 -3
  110. package/dist/text/GlyphTextMaterial.d.ts +5 -0
  111. package/dist/text/GlyphTextMaterial.js +11 -7
  112. package/dist/text/GlyphTextMaterial.js.map +1 -1
  113. package/dist/text/RectMaterial.js +6 -10
  114. package/dist/text/RectMaterial.js.map +1 -1
  115. package/dist/text/SdfTextMaterial.d.ts +9 -3
  116. package/dist/text/SdfTextMaterial.js +122 -37
  117. package/dist/text/SdfTextMaterial.js.map +1 -1
  118. package/dist/text/decorations.d.ts +7 -2
  119. package/dist/text/decorations.js +187 -96
  120. package/dist/text/decorations.js.map +1 -1
  121. package/dist/text/geometryUtils.d.ts +5 -0
  122. package/dist/text/geometryUtils.js +63 -9
  123. package/dist/text/geometryUtils.js.map +1 -1
  124. package/dist/text/glyphGeometry.d.ts +1 -1
  125. package/dist/text/glyphGeometry.js +281 -200
  126. package/dist/text/glyphGeometry.js.map +1 -1
  127. package/dist/text/rectGeometry.js +46 -42
  128. package/dist/text/rectGeometry.js.map +1 -1
  129. package/dist/text/reflow.d.ts +5 -0
  130. package/dist/text/reflow.js +127 -68
  131. package/dist/text/reflow.js.map +1 -1
  132. package/dist/text/snap.d.ts +15 -1
  133. package/dist/text/snap.js +1 -1
  134. package/dist/text/snap.js.map +1 -1
  135. package/dist/text/tone.js +2 -2
  136. package/dist/text/tone.js.map +1 -1
  137. package/dist/types.d.ts +23 -7
  138. package/dist/vanilla.js +1 -1
  139. package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
  140. package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
  141. package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
  142. package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
  143. package/dist/windfoil/WindfoilMaterial.js +71 -8
  144. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  145. package/dist/windfoil/compositeGeometry.js +12 -5
  146. package/dist/windfoil/compositeGeometry.js.map +1 -1
  147. package/dist/windfoil/coverage.d.ts +10 -2
  148. package/dist/windfoil/coverage.js +147 -59
  149. package/dist/windfoil/coverage.js.map +1 -1
  150. package/dist/windfoil/geometry.d.ts +15 -0
  151. package/dist/windfoil/geometry.js +154 -64
  152. package/dist/windfoil/geometry.js.map +1 -1
  153. package/dist/windfoil/layerGrid.js +8 -8
  154. package/dist/windfoil/layerGrid.js.map +1 -1
  155. package/dist/windfoil/mixed.js +13 -4
  156. package/dist/windfoil/mixed.js.map +1 -1
  157. package/dist/windfoil/preprocess.js +2 -2
  158. package/dist/windfoil/preprocessCore.d.ts +1 -0
  159. package/dist/windfoil/preprocessCore.js +63 -36
  160. package/dist/windfoil/preprocessCore.js.map +1 -1
  161. package/dist/windfoil/requests.d.ts +1 -1
  162. package/dist/windfoil/requests.js +11 -4
  163. package/dist/windfoil/requests.js.map +1 -1
  164. package/dist/windfoil/resolveOutline.d.ts +9 -0
  165. package/dist/windfoil/resolveOutline.js +20 -0
  166. package/dist/windfoil/resolveOutline.js.map +1 -0
  167. package/dist/windfoil/runtime.d.ts +1 -0
  168. package/dist/windfoil/runtime.js +8 -24
  169. package/dist/windfoil/runtime.js.map +1 -1
  170. package/dist/windfoil/shapeGeometry.js +80 -34
  171. package/dist/windfoil/shapeGeometry.js.map +1 -1
  172. package/dist/windfoil/sizeSwitch.d.ts +1 -1
  173. package/dist/windfoil/sizeSwitch.js +13 -8
  174. package/dist/windfoil/sizeSwitch.js.map +1 -1
  175. package/dist/windfoil/storage.d.ts +23 -9
  176. package/dist/windfoil/storage.js +49 -30
  177. package/dist/windfoil/storage.js.map +1 -1
  178. package/dist/windfoil/svg/curves.d.ts +20 -0
  179. package/dist/windfoil/svg/curves.js +145 -42
  180. package/dist/windfoil/svg/curves.js.map +1 -1
  181. package/dist/windfoil/svg/document.js +10 -1
  182. package/dist/windfoil/svg/document.js.map +1 -1
  183. package/dist/windfoil/svg/pathConverter.js +66 -50
  184. package/dist/windfoil/svg/pathConverter.js.map +1 -1
  185. package/dist/windfoil/svg/pathData.d.ts +9 -0
  186. package/dist/windfoil/svg/pathData.js +142 -109
  187. package/dist/windfoil/svg/pathData.js.map +1 -1
  188. package/dist/windfoil/svg/winding.js +34 -10
  189. package/dist/windfoil/svg/winding.js.map +1 -1
  190. package/dist/windfoil/trace/contours.js +120 -50
  191. package/dist/windfoil/trace/contours.js.map +1 -1
  192. package/dist/windfoil/trace/fit.js +578 -224
  193. package/dist/windfoil/trace/fit.js.map +1 -1
  194. package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
  195. package/dist/windfoil/trace/traceWorker.d.ts +13 -0
  196. package/dist/windfoil/trace/traceWorker.js +192 -0
  197. package/dist/windfoil/trace/traceWorker.js.map +1 -0
  198. package/dist/windfoil/tracedOutlines.d.ts +2 -0
  199. package/dist/windfoil/tracedOutlines.js +335 -70
  200. package/dist/windfoil/tracedOutlines.js.map +1 -1
  201. package/package.json +48 -29
  202. package/skills/ultra-text/SKILL.md +9 -10
  203. package/skills/ultra-text/references/frameworks.md +46 -2
  204. package/skills/ultra-text/references/three-tsl.md +26 -24
  205. package/skills/ultra-text/references/vanilla-webgpu.md +3 -1
  206. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +0 -1
@@ -1,40 +1,101 @@
1
- import { DataTexture, LinearFilter, LinearMipmapLinearFilter, RGBAFormat, SRGBColorSpace, UnsignedByteType } from "three/webgpu";
2
1
  // src/atlas/colorGlyphs.ts
2
+ /** @internal Probe a glyph without constructing a colour band. */
3
+ function slotHasColor(white, black, width, slot) {
4
+ const rowBytes = width * 4;
5
+ const slotBytes = slot.width * 4;
6
+ const start = (slot.y * width + slot.x) * 4;
7
+ const end = start + slot.height * rowBytes;
8
+ for (let row = start; row < end; row += rowBytes) for (let at = row; at < row + slotBytes; at += 4) {
9
+ if (white[at + 3] < 128) continue;
10
+ if (white[at] - black[at] < 128 || white[at + 1] - black[at + 1] < 128 || white[at + 2] - black[at + 2] < 128) return true;
11
+ }
12
+ return false;
13
+ }
14
+ var scratchDistances = /* @__PURE__ */ new Uint16Array(0);
3
15
  /**
4
- * @internal Classify fillStyle-invariant ink and label every empty texel by its nearest ink:
5
- * colour carries its colour and full alpha on, foreground ink leaves the texel clear. The
6
- * alpha of the band is then 1 around colour and 0 around text that shares a slot with it,
7
- * whatever the distance. A `pxRange` of 0 only classifies.
16
+ * The nearest Manhattan-distance seed, with ties going to the first seed in raster order.
17
+ * First find the nearest seed in each row (left wins ties), then compare rows (top wins ties).
8
18
  */
9
- var scratchState = /* @__PURE__ */ new Uint8Array(0);
10
- var scratchQueue = /* @__PURE__ */ new Uint32Array(0);
11
- var scratchQueueX = /* @__PURE__ */ new Int32Array(0);
19
+ function spreadColors(words, white, width, firstInk, lastInk) {
20
+ const top = Math.floor(firstInk / width) * width;
21
+ const bottom = (Math.floor(lastInk / width) + 1) * width;
22
+ const count = bottom - top;
23
+ const far = width + count / width;
24
+ let distances;
25
+ if (far > 65535) distances = new Float64Array(count);
26
+ else if (count > 65536) distances = new Uint16Array(count);
27
+ else {
28
+ if (scratchDistances.length < count) scratchDistances = new Uint16Array(count);
29
+ distances = scratchDistances;
30
+ }
31
+ const fillSpan = (start, end, horizontal, step, word) => {
32
+ for (let pixel = start; pixel < end; pixel++, horizontal += step) {
33
+ const i = pixel - top;
34
+ const above = i >= width ? distances[i - width] + 1 : far;
35
+ if (above <= horizontal) {
36
+ distances[i] = above;
37
+ words[pixel] = words[pixel - width];
38
+ } else {
39
+ distances[i] = horizontal;
40
+ words[pixel] = word;
41
+ }
42
+ }
43
+ };
44
+ for (let row = top; row < bottom; row += width) {
45
+ const end = row + width;
46
+ let left = row - 1;
47
+ let leftWord = 0;
48
+ for (let pixel = row; pixel < end; pixel++) {
49
+ if (white[pixel * 4 + 3] < 128) continue;
50
+ const word = words[pixel];
51
+ if (pixel > left + 1) {
52
+ const middle = left < row ? left : left + Math.floor((pixel - left) / 2);
53
+ fillSpan(left + 1, middle + 1, 1, 1, leftWord);
54
+ fillSpan(middle + 1, pixel, pixel - middle - 1, -1, word);
55
+ }
56
+ distances[pixel - top] = 0;
57
+ left = pixel;
58
+ leftWord = word;
59
+ }
60
+ if (left < row) {
61
+ words.copyWithin(row, row - width, row);
62
+ for (let i = row - top; i < end - top; i++) distances[i] = distances[i - width] + 1;
63
+ } else fillSpan(left + 1, end, 1, 1, leftWord);
64
+ }
65
+ for (let pixel = bottom - width - 1; pixel >= top; pixel--) {
66
+ const i = pixel - top;
67
+ const below = distances[i + width] + 1;
68
+ if (below < distances[i]) {
69
+ distances[i] = below;
70
+ words[pixel] = words[pixel + width];
71
+ }
72
+ }
73
+ for (let row = 0; row < top; row += width) words.copyWithin(row, top, top + width);
74
+ for (let row = bottom; row < words.length; row += width) words.copyWithin(row, bottom - width, bottom);
75
+ }
76
+ /** @internal Classify fill-invariant ink and extend its colour (or foreground transparency). */
12
77
  function encodeColorBand(white, black, width, height, pxRange, slots) {
13
78
  const count = width * height;
14
79
  const data = new Uint8Array(count * 4);
15
- const packed = new Uint32Array(data.buffer);
16
- if (scratchState.length < count) scratchState = new Uint8Array(count);
17
- const state = scratchState;
18
- state.fill(0, 0, count);
80
+ const words = new Uint32Array(data.buffer);
81
+ const light = new DataView(white.buffer, white.byteOffset, white.byteLength);
82
+ const dark = new DataView(black.buffer, black.byteOffset, black.byteLength);
83
+ const result = new DataView(data.buffer);
84
+ let first = 0;
85
+ let last = count - 1;
86
+ while (first <= last && white[first * 4 + 3] < 128) first++;
87
+ while (last >= first && white[last * 4 + 3] < 128) last--;
88
+ let inkCount = 0;
19
89
  let hasColor = false;
20
- let firstInkIndex = -1;
21
- let lastInkIndex = -1;
22
- for (let index = 0, at = 0; index < count; index++, at += 4) {
23
- if (white[at + 3] < 128) continue;
24
- if (firstInkIndex < 0) firstInkIndex = index;
25
- lastInkIndex = index;
26
- const b0 = black[at];
27
- const b1 = black[at + 1];
28
- const b2 = black[at + 2];
29
- if (white[at] - b0 >= 128 && white[at + 1] - b1 >= 128 && white[at + 2] - b2 >= 128) {
30
- state[index] = 255;
31
- continue;
32
- }
33
- data[at] = b0;
34
- data[at + 1] = b1;
35
- data[at + 2] = b2;
36
- data[at + 3] = 255;
37
- state[index] = 1;
90
+ for (let index = first; index <= last; index++) {
91
+ const at = index * 4;
92
+ const w = light.getInt32(at, true);
93
+ if (w >= 0) continue;
94
+ inkCount++;
95
+ const b = dark.getInt32(at, true);
96
+ const highBits = 8421504;
97
+ if ((w & ~b & highBits) === highBits && (w - b & highBits) === highBits) continue;
98
+ result.setInt32(at, b | 4278190080, true);
38
99
  hasColor = true;
39
100
  }
40
101
  const colored = slots.map((slot) => {
@@ -43,139 +104,20 @@ function encodeColorBand(white, black, width, height, pxRange, slots) {
43
104
  const yEnd = slot.y + slot.height;
44
105
  for (let y = slot.y; y < yEnd; y++) {
45
106
  const row = y * width;
46
- for (let x = slot.x; x < xEnd; x++) if (state[row + x] === 1) return true;
107
+ for (let x = slot.x; x < xEnd; x++) if (words[row + x]) return true;
47
108
  }
48
109
  return false;
49
110
  });
50
- if (pxRange <= 0 || !hasColor) {
51
- if (scratchState.length > 65536) scratchState = /* @__PURE__ */ new Uint8Array(0);
52
- return {
53
- data,
54
- colored
55
- };
56
- }
57
- if (scratchQueue.length < count) {
58
- scratchQueue = new Uint32Array(count);
59
- scratchQueueX = new Int32Array(count);
60
- }
61
- const queue = scratchQueue;
62
- const queueX = scratchQueueX;
63
- let tail = 0;
64
- const minInkY = firstInkIndex / width | 0;
65
- const maxInkY = lastInkIndex / width | 0;
66
- for (let y = minInkY; y <= maxInkY; y++) {
67
- const row = y * width;
68
- for (let x = 0; x < width; x++) {
69
- const index = row + x;
70
- if (state[index] === 0) continue;
71
- if (x > 0 && state[index - 1] === 0 || x + 1 < width && state[index + 1] === 0 || y > 0 && state[index - width] === 0 || y + 1 < height && state[index + width] === 0) {
72
- queueX[tail] = x;
73
- queue[tail++] = index;
74
- }
75
- }
76
- }
77
- for (let head = 0; head < tail; head++) {
78
- const index = queue[head];
79
- const x = queueX[head];
80
- if (state[index] === 1) {
81
- const colorWord = packed[index];
82
- if (x > 0) {
83
- const next = index - 1;
84
- if (state[next] === 0) {
85
- state[next] = 1;
86
- packed[next] = colorWord;
87
- queueX[tail] = x - 1;
88
- queue[tail++] = next;
89
- }
90
- }
91
- if (x + 1 < width) {
92
- const next = index + 1;
93
- if (state[next] === 0) {
94
- state[next] = 1;
95
- packed[next] = colorWord;
96
- queueX[tail] = x + 1;
97
- queue[tail++] = next;
98
- }
99
- }
100
- if (index >= width) {
101
- const next = index - width;
102
- if (state[next] === 0) {
103
- state[next] = 1;
104
- packed[next] = colorWord;
105
- queueX[tail] = x;
106
- queue[tail++] = next;
107
- }
108
- }
109
- if (index + width < count) {
110
- const next = index + width;
111
- if (state[next] === 0) {
112
- state[next] = 1;
113
- packed[next] = colorWord;
114
- queueX[tail] = x;
115
- queue[tail++] = next;
116
- }
117
- }
118
- } else {
119
- if (x > 0) {
120
- const next = index - 1;
121
- if (state[next] === 0) {
122
- state[next] = 2;
123
- queueX[tail] = x - 1;
124
- queue[tail++] = next;
125
- }
126
- }
127
- if (x + 1 < width) {
128
- const next = index + 1;
129
- if (state[next] === 0) {
130
- state[next] = 2;
131
- queueX[tail] = x + 1;
132
- queue[tail++] = next;
133
- }
134
- }
135
- if (index >= width) {
136
- const next = index - width;
137
- if (state[next] === 0) {
138
- state[next] = 2;
139
- queueX[tail] = x;
140
- queue[tail++] = next;
141
- }
142
- }
143
- if (index + width < count) {
144
- const next = index + width;
145
- if (state[next] === 0) {
146
- state[next] = 2;
147
- queueX[tail] = x;
148
- queue[tail++] = next;
149
- }
150
- }
151
- }
152
- }
153
- if (scratchState.length > 65536) scratchState = /* @__PURE__ */ new Uint8Array(0);
154
- if (scratchQueue.length > 65536) {
155
- scratchQueue = /* @__PURE__ */ new Uint32Array(0);
156
- scratchQueueX = /* @__PURE__ */ new Int32Array(0);
157
- }
158
- return {
111
+ if (pxRange <= 0 || !hasColor || inkCount === count) return {
159
112
  data,
160
113
  colored
161
114
  };
162
- }
163
- /** @internal Upload-ready colour band; ownership transfers to its atlas wrapper. */
164
- function createColorLayer(band, width, options, maxAnisotropy) {
165
- const texture = new DataTexture(band.data, width, band.height, RGBAFormat, UnsignedByteType);
166
- texture.colorSpace = SRGBColorSpace;
167
- texture.flipY = false;
168
- texture.generateMipmaps = options.mipmaps ?? false;
169
- texture.minFilter = texture.generateMipmaps ? LinearMipmapLinearFilter : LinearFilter;
170
- texture.magFilter = LinearFilter;
171
- texture.anisotropy = Math.max(1, Math.min(options.anisotropy ?? 1, maxAnisotropy));
172
- texture.needsUpdate = true;
115
+ spreadColors(words, white, width, first, last);
173
116
  return {
174
- texture,
175
- top: band.top,
176
- height: band.height
117
+ data,
118
+ colored
177
119
  };
178
120
  }
179
- export { createColorLayer, encodeColorBand };
121
+ export { encodeColorBand, slotHasColor };
180
122
 
181
123
  //# sourceMappingURL=colorGlyphs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colorGlyphs.js","names":[],"sources":["../../src/atlas/colorGlyphs.ts"],"sourcesContent":["import {\n DataTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n RGBAFormat,\n SRGBColorSpace,\n UnsignedByteType,\n} from 'three/webgpu'\nimport type { BuildSdfAtlasOptions, RasterColorBand, SdfColorLayer } from '../types.js'\n\ninterface ColorSlot {\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\n/**\n * @internal Classify fillStyle-invariant ink and label every empty texel by its nearest ink:\n * colour carries its colour and full alpha on, foreground ink leaves the texel clear. The\n * alpha of the band is then 1 around colour and 0 around text that shares a slot with it,\n * whatever the distance. A `pxRange` of 0 only classifies.\n */\nlet scratchState = new Uint8Array(0)\nlet scratchQueue = new Uint32Array(0)\nlet scratchQueueX = new Int32Array(0)\n\nexport function encodeColorBand(\n white: Uint8ClampedArray,\n black: Uint8ClampedArray,\n width: number,\n height: number,\n pxRange: number,\n slots: readonly ColorSlot[],\n): { data: Uint8Array; colored: boolean[] } {\n const count = width * height\n const data = new Uint8Array(count * 4)\n // Whole-pixel copies preserve byte order on either endian architecture.\n const packed = new Uint32Array(data.buffer)\n // 0 = empty, 1 = colour or nearest to it, 2 = nearest to foreground, 255 = solid foreground.\n if (scratchState.length < count) scratchState = new Uint8Array(count)\n const state = scratchState\n state.fill(0, 0, count)\n let hasColor = false\n let firstInkIndex = -1\n let lastInkIndex = -1\n for (let index = 0, at = 0; index < count; index++, at += 4) {\n if (white[at + 3]! < 128) continue\n if (firstInkIndex < 0) firstInkIndex = index\n lastInkIndex = index\n const b0 = black[at]!\n const b1 = black[at + 1]!\n const b2 = black[at + 2]!\n if (white[at]! - b0 >= 128 && white[at + 1]! - b1 >= 128 && white[at + 2]! - b2 >= 128) {\n state[index] = 255\n continue\n }\n data[at] = b0\n data[at + 1] = b1\n data[at + 2] = b2\n data[at + 3] = 255\n state[index] = 1\n hasColor = true\n }\n const colored = slots.map((slot) => {\n if (!hasColor) return false\n const xEnd = slot.x + slot.width\n const yEnd = slot.y + slot.height\n for (let y = slot.y; y < yEnd; y++) {\n const row = y * width\n for (let x = slot.x; x < xEnd; x++) {\n if (state[row + x] === 1) return true\n }\n }\n return false\n })\n if (pxRange <= 0 || !hasColor) {\n if (scratchState.length > 65536) scratchState = new Uint8Array(0)\n return { data, colored }\n }\n if (scratchQueue.length < count) {\n scratchQueue = new Uint32Array(count)\n scratchQueueX = new Int32Array(count)\n }\n const queue = scratchQueue\n const queueX = scratchQueueX\n let tail = 0\n const minInkY = (firstInkIndex / width) | 0\n const maxInkY = (lastInkIndex / width) | 0\n // Interior seeds cannot reach empty pixels directly. Keeping only boundary\n // seeds preserves their raster-order tie breaking and avoids four visits per\n // interior texel. The waves below are breadth-first, from both kinds of ink at once.\n for (let y = minInkY; y <= maxInkY; y++) {\n const row = y * width\n for (let x = 0; x < width; x++) {\n const index = row + x\n if (state[index] === 0) continue\n if (\n (x > 0 && state[index - 1] === 0) ||\n (x + 1 < width && state[index + 1] === 0) ||\n (y > 0 && state[index - width] === 0) ||\n (y + 1 < height && state[index + width] === 0)\n ) {\n queueX[tail] = x\n queue[tail++] = index\n }\n }\n }\n for (let head = 0; head < tail; head++) {\n const index = queue[head]!\n const x = queueX[head]!\n if (state[index] === 1) {\n const colorWord = packed[index]!\n if (x > 0) {\n const next = index - 1\n if (state[next] === 0) {\n state[next] = 1\n packed[next] = colorWord\n queueX[tail] = x - 1\n queue[tail++] = next\n }\n }\n if (x + 1 < width) {\n const next = index + 1\n if (state[next] === 0) {\n state[next] = 1\n packed[next] = colorWord\n queueX[tail] = x + 1\n queue[tail++] = next\n }\n }\n if (index >= width) {\n const next = index - width\n if (state[next] === 0) {\n state[next] = 1\n packed[next] = colorWord\n queueX[tail] = x\n queue[tail++] = next\n }\n }\n if (index + width < count) {\n const next = index + width\n if (state[next] === 0) {\n state[next] = 1\n packed[next] = colorWord\n queueX[tail] = x\n queue[tail++] = next\n }\n }\n } else {\n if (x > 0) {\n const next = index - 1\n if (state[next] === 0) {\n state[next] = 2\n queueX[tail] = x - 1\n queue[tail++] = next\n }\n }\n if (x + 1 < width) {\n const next = index + 1\n if (state[next] === 0) {\n state[next] = 2\n queueX[tail] = x + 1\n queue[tail++] = next\n }\n }\n if (index >= width) {\n const next = index - width\n if (state[next] === 0) {\n state[next] = 2\n queueX[tail] = x\n queue[tail++] = next\n }\n }\n if (index + width < count) {\n const next = index + width\n if (state[next] === 0) {\n state[next] = 2\n queueX[tail] = x\n queue[tail++] = next\n }\n }\n }\n }\n if (scratchState.length > 65536) scratchState = new Uint8Array(0)\n if (scratchQueue.length > 65536) {\n scratchQueue = new Uint32Array(0)\n scratchQueueX = new Int32Array(0)\n }\n return { data, colored }\n}\n\n/** @internal Upload-ready colour band; ownership transfers to its atlas wrapper. */\nexport function createColorLayer(\n band: RasterColorBand,\n width: number,\n options: BuildSdfAtlasOptions,\n maxAnisotropy: number,\n): SdfColorLayer {\n const texture = new DataTexture(band.data, width, band.height, RGBAFormat, UnsignedByteType)\n texture.colorSpace = SRGBColorSpace\n texture.flipY = false\n texture.generateMipmaps = options.mipmaps ?? false\n texture.minFilter = texture.generateMipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = Math.max(1, Math.min(options.anisotrop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A,OAAO;EAAE;EAAM;CAAQ;AACzB;;AAGA,SAAgB,iBACd,MACA,OACA,SACA,eACe;CACf,MAAM,UAAU,IAAI,YAAY,KAAK,MAAM,OAAO,KAAK,QAAQ,YAAY,gBAAgB;CAC3F,QAAQ,aAAa;CACrB,QAAQ,QAAQ;CAChB,QAAQ,kBAAkB,QAAQ,WAAW;CAC7C,QAAQ,YAAY,QAAQ,kBAAkB,2BAA2B;CACzE,QAAQ,YAAY;CACpB,QAAQ,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,cAAc,GAAG,aAAa,CAAC;CACjF,QAAQ,cAAc;CACtB,OAAO;EAAE;EAAS,KAAK,KAAK;EAAK,QAAQ,KAAK;CAAO;AACvD"}
1
+ {"version":3,"file":"colorGlyphs.js","names":[],"sources":["../../src/atlas/colorGlyphs.ts"],"sourcesContent":["interface ColorSlot {\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\n\n/** @internal Probe a glyph without constructing a colour band. */\nexport function slotHasColor(\n white: Uint8ClampedArray,\n black: Uint8ClampedArray,\n width: number,\n slot: ColorSlot,\n): boolean {\n const rowBytes = width * 4\n const slotBytes = slot.width * 4\n const start = (slot.y * width + slot.x) * 4\n const end = start + slot.height * rowBytes\n for (let row = start; row < end; row += rowBytes) {\n for (let at = row; at < row + slotBytes; at += 4) {\n if (white[at + 3]! < 128) continue\n if (\n white[at]! - black[at]! < 128 ||\n white[at + 1]! - black[at + 1]! < 128 ||\n white[at + 2]! - black[at + 2]! < 128\n ) {\n return true\n }\n }\n }\n return false\n}\n\nlet scratchDistances = new Uint16Array(0)\n\n/**\n * The nearest Manhattan-distance seed, with ties going to the first seed in raster order.\n * First find the nearest seed in each row (left wins ties), then compare rows (top wins ties).\n */\nfunction spreadColors(\n words: Uint32Array,\n white: Uint8ClampedArray,\n width: number,\n firstInk: number,\n lastInk: number,\n): void {\n const top = Math.floor(firstInk / width) * width\n const bottom = (Math.floor(lastInk / width) + 1) * width\n const count = bottom - top\n const far = width + count / width\n let distances: Uint16Array | Float64Array\n if (far > 0xffff) distances = new Float64Array(count)\n else if (count > 65536) distances = new Uint16Array(count)\n else {\n if (scratchDistances.length < count) scratchDistances = new Uint16Array(count)\n distances = scratchDistances\n }\n\n // Write an empty row span using its nearest horizontal seed and the previous row's result.\n const fillSpan = (\n start: number,\n end: number,\n horizontal: number,\n step: number,\n word: number,\n ): void => {\n for (let pixel = start; pixel < end; pixel++, horizontal += step) {\n const i = pixel - top\n const above = i >= width ? distances[i - width]! + 1 : far\n if (above <= horizontal) {\n distances[i] = above\n words[pixel] = words[pixel - width]!\n } else {\n distances[i] = horizontal\n words[pixel] = word\n }\n }\n }\n\n for (let row = top; row < bottom; row += width) {\n const end = row + width\n let left = row - 1\n let leftWord = 0\n for (let pixel = row; pixel < end; pixel++) {\n if (white[pixel * 4 + 3]! < 128) continue\n const word = words[pixel]!\n if (pixel > left + 1) {\n const middle = left < row ? left : left + Math.floor((pixel - left) / 2)\n fillSpan(left + 1, middle + 1, 1, 1, leftWord)\n fillSpan(middle + 1, pixel, pixel - middle - 1, -1, word)\n }\n distances[pixel - top] = 0\n left = pixel\n leftWord = word\n }\n if (left < row) {\n words.copyWithin(row, row - width, row)\n for (let i = row - top; i < end - top; i++) distances[i] = distances[i - width]! + 1\n } else {\n fillSpan(left + 1, end, 1, 1, leftWord)\n }\n }\n\n for (let pixel = bottom - width - 1; pixel >= top; pixel--) {\n const i = pixel - top\n const below = distances[i + width]! + 1\n if (below < distances[i]!) {\n distances[i] = below\n words[pixel] = words[pixel + width]!\n }\n }\n // Beyond the outermost ink rows, every seed is equally many extra rows away.\n for (let row = 0; row < top; row += width) words.copyWithin(row, top, top + width)\n for (let row = bottom; row < words.length; row += width)\n words.copyWithin(row, bottom - width, bottom)\n}\n\n/** @internal Classify fill-invariant ink and extend its colour (or foreground transparency). */\nexport function encodeColorBand(\n white: Uint8ClampedArray,\n black: Uint8ClampedArray,\n width: number,\n height: number,\n pxRange: number,\n slots: readonly ColorSlot[],\n): { data: Uint8Array; colored: boolean[] } {\n const count = width * height\n const data = new Uint8Array(count * 4)\n const words = new Uint32Array(data.buffer)\n const light = new DataView(white.buffer, white.byteOffset, white.byteLength)\n const dark = new DataView(black.buffer, black.byteOffset, black.byteLength)\n const result = new DataView(data.buffer)\n let first = 0\n let last = count - 1\n while (first <= last && white[first * 4 + 3]! < 128) first++\n while (last >= first && white[last * 4 + 3]! < 128) last--\n\n let inkCount = 0\n let hasColor = false\n for (let index = first; index <= last; index++) {\n const at = index * 4\n const w = light.getInt32(at, true)\n if (w >= 0) continue // Little-endian RGBA has its alpha high bit in the sign bit.\n inkCount++\n const b = dark.getInt32(at, true)\n // Each light channel must be >= 128 and its dark channel < 128 for their\n // difference to reach 128. The subtraction then cannot borrow across channels.\n const highBits = 0x808080\n if ((w & ~b & highBits) === highBits && ((w - b) & highBits) === highBits) continue\n result.setInt32(at, b | 0xff000000, true)\n hasColor = true\n }\n const colored = slots.map((slot) => {\n if (!hasColor) return false\n const xEnd = slot.x + slot.width\n const yEnd = slot.y + slot.height\n for (let y = slot.y; y < yEnd; y++) {\n const row = y * width\n for (let x = slot.x; x < xEnd; x++) {\n if (words[row + x]) return true\n }\n }\n return false\n })\n if (pxRange <= 0 || !hasColor || inkCount === count) return { data, colored }\n spreadColors(words, white, width, first, last)\n return { data, colored }\n}\n"],"mappings":";;AAQA,SAAgB,aACd,OACA,OACA,OACA,MACS;CACT,MAAM,WAAW,QAAQ;CACzB,MAAM,YAAY,KAAK,QAAQ;CAC/B,MAAM,SAAS,KAAK,IAAI,QAAQ,KAAK,KAAK;CAC1C,MAAM,MAAM,QAAQ,KAAK,SAAS;CAClC,KAAK,IAAI,MAAM,OAAO,MAAM,KAAK,OAAO,UACtC,KAAK,IAAI,KAAK,KAAK,KAAK,MAAM,WAAW,MAAM,GAAG;EAChD,IAAI,MAAM,KAAK,KAAM,KAAK;EAC1B,IACE,MAAM,MAAO,MAAM,MAAO,OAC1B,MAAM,KAAK,KA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OAAO,QAAQ,SAAS,MAAM,OAAO,IAAI,KAAM,KAAK;CAEpD,IAAI,WAAW;CACf,IAAI,WAAW;CACf,KAAK,IAAI,QAAQ,OAAO,SAAS,MAAM,SAAS;EAC9C,MAAM,KAAK,QAAQ;EACnB,MAAM,IAAI,MAAM,SAAS,IAAI,IAAI;EACjC,IAAI,KAAK,GAAG;EACZ;EACA,MAAM,IAAI,KAAK,SAAS,IAAI,IAAI;EAGhC,MAAM,WAAW;EACjB,KAAK,IAAI,CAAC,IAAI,cAAc,aAAc,IAAI,IAAK,cAAc,UAAU;EAC3E,OAAO,SAAS,IAAI,IAAI,YAAY,IAAI;EACxC,WAAW;CACb;CACA,MAAM,UAAU,MAAM,KAAK,SAAS;EAClC,IAAI,CAAC,UAAU,OAAO;EACtB,MAAM,OAAO,KAAK,IAAI,KAAK;EAC3B,MAAM,OAAO,KAAK,IAAI,KAAK;EAC3B,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,MAAM,KAAK;GAClC,MAAM,MAAM,IAAI;GAChB,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,MAAM,KAC7B,IAAI,MAAM,MAAM,IAAI,OAAO;EAE/B;EACA,OAAO;CACT,CAAC;CACD,IAAI,WAAW,KAAK,CAAC,YAAY,aAAa,OAAO,OAAO;EAAE;EAAM;CAAQ;CAC5E,aAAa,OAAO,OAAO,OAAO,OAAO,IAAI;CAC7C,OAAO;EAAE;EAAM;CAAQ;AACzB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ import { DataTexture, ExternalTexture, LinearFilter, LinearMipmapLinearFilter, RGBAFormat, SRGBColorSpace, UnsignedByteType } from "three/webgpu";
2
+ // src/atlas/colorTexture.ts
3
+ var COLOR_BLEED_STATE_KEY = Symbol.for("ultra-text.gpuColorBleed");
4
+ function colorBleedRegistry() {
5
+ return globalThis[COLOR_BLEED_STATE_KEY];
6
+ }
7
+ /** @internal Upload-ready colour band; ownership transfers to its atlas wrapper. */
8
+ function createColorLayer(band, width, options, maxAnisotropy) {
9
+ const reg = colorBleedRegistry();
10
+ const gpuTexture = reg?.ready.get(band.data);
11
+ if (gpuTexture) {
12
+ reg.ready.delete(band.data);
13
+ const mipmaps = options.mipmaps ?? false;
14
+ const texture = new ExternalTexture(gpuTexture);
15
+ const baseDispose = texture.dispose.bind(texture);
16
+ let disposed = false;
17
+ texture.dispose = () => {
18
+ if (disposed) return;
19
+ disposed = true;
20
+ try {
21
+ baseDispose();
22
+ } finally {
23
+ gpuTexture.destroy();
24
+ }
25
+ };
26
+ texture.image = {
27
+ width,
28
+ height: band.height
29
+ };
30
+ texture.colorSpace = SRGBColorSpace;
31
+ texture.flipY = false;
32
+ texture.format = RGBAFormat;
33
+ texture.generateMipmaps = false;
34
+ texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter;
35
+ texture.magFilter = LinearFilter;
36
+ texture.anisotropy = Math.max(1, Math.min(options.anisotropy ?? 1, maxAnisotropy));
37
+ return {
38
+ texture,
39
+ top: band.top,
40
+ height: band.height
41
+ };
42
+ }
43
+ const deferred = reg?.bleeds.get(band.data);
44
+ if (deferred) {
45
+ reg.bleeds.delete(band.data);
46
+ deferred.applyCpu();
47
+ }
48
+ const texture = new DataTexture(band.data, width, band.height, RGBAFormat, UnsignedByteType);
49
+ texture.colorSpace = SRGBColorSpace;
50
+ texture.flipY = false;
51
+ texture.generateMipmaps = options.mipmaps ?? false;
52
+ texture.minFilter = texture.generateMipmaps ? LinearMipmapLinearFilter : LinearFilter;
53
+ texture.magFilter = LinearFilter;
54
+ texture.anisotropy = Math.max(1, Math.min(options.anisotropy ?? 1, maxAnisotropy));
55
+ texture.needsUpdate = true;
56
+ return {
57
+ texture,
58
+ top: band.top,
59
+ height: band.height
60
+ };
61
+ }
62
+ export { createColorLayer };
63
+
64
+ //# sourceMappingURL=colorTexture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorTexture.js","names":[],"sources":["../../src/atlas/colorTexture.ts"],"sourcesContent":["import {\n DataTexture,\n ExternalTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n RGBAFormat,\n SRGBColorSpace,\n UnsignedByteType,\n type Texture,\n} from 'three/webgpu'\nimport type { BuildSdfAtlasOptions, RasterColorBand, SdfColorLayer } from '../types.js'\n\ninterface DeferredColorBleedState {\n readonly bleeds: WeakMap<Uint8Array, { readonly applyCpu: () => void }>\n readonly ready: WeakMap<Uint8Array, { destroy(): void }>\n}\n\nconst COLOR_BLEED_STATE_KEY = Symbol.for('ultra-text.gpuColorBleed')\n\nfunction colorBleedRegistry(): DeferredColorBleedState | undefined {\n return (globalThis as Record<symbol, DeferredColorBleedState | undefined>)[COLOR_BLEED_STATE_KEY]\n}\n\n/** @internal Upload-ready colour band; ownership transfers to its atlas wrapper. */\nexport function createColorLayer(\n band: RasterColorBand,\n width: number,\n options: BuildSdfAtlasOptions,\n maxAnisotropy: number,\n): SdfColorLayer {\n const reg = colorBleedRegistry()\n const gpuTexture = reg?.ready.get(band.data)\n if (gpuTexture) {\n reg!.ready.delete(band.data)\n const mipmaps = options.mipmaps ?? false\n const texture: Texture = new ExternalTexture(gpuTexture)\n const baseDispose = texture.dispose.bind(texture)\n let disposed = false\n texture.dispose = () => {\n if (disposed) return\n disposed = true\n try {\n baseDispose()\n } finally {\n gpuTexture.destroy()\n }\n }\n ;(texture as { image: unknown }).image = { width, height: band.height }\n texture.colorSpace = SRGBColorSpace\n texture.flipY = false\n texture.format = RGBAFormat\n texture.generateMipmaps = false\n texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = Math.max(1, Math.min(options.anisotropy ?? 1, maxAnisotropy))\n return { texture, top: band.top, height: band.height }\n }\n const deferred = reg?.bleeds.get(band.data)\n if (deferred) {\n reg!.bleeds.delete(band.data)\n deferred.applyCpu()\n }\n const texture = new DataTexture(band.data, width, band.height, RGBAFormat, UnsignedByteType)\n texture.colorSpace = SRGBColorSpace\n texture.flipY = false\n texture.generateMipmaps = options.mipmaps ?? false\n texture.minFilter = texture.generateMipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = Math.max(1, Math.min(options.anisotropy ?? 1, maxAnisotropy))\n texture.needsUpdate = true\n return { texture, top: band.top, height: band.height }\n}\n"],"mappings":";;AAiBA,IAAM,wBAAwB,OAAO,IAAI,0BAA0B;AAEnE,SAAS,qBAA0D;CACjE,OAAQ,WAAmE;AAC7E;;AAGA,SAAgB,iBACd,MACA,OACA,SACA,eACe;CACf,MAAM,MAAM,mBAAmB;CAC/B,MAAM,aAAa,KAAK,MAAM,IAAI,KAAK,IAAI;CAC3C,IAAI,YAAY;EACd,IAAK,MAAM,OAAO,KAAK,IAAI;EAC3B,MAAM,UAAU,QAAQ,WAAW;EACnC,MAAM,UAAmB,IAAI,gBAAgB,UAAU;EACvD,MAAM,cAAc,QAAQ,QAAQ,KAAK,OAAO;EAChD,IAAI,WAAW;EACf,QAAQ,gBAAgB;GACtB,IAAI,UAAU;GACd,WAAW;GACX,IAAI;IACF,YAAY;GACd,UAAU;IACR,WAAW,QAAQ;GACrB;EACF;EACC,QAAgC,QAAQ;GAAE;GAAO,QAAQ,KAAK;EAAO;EACtE,QAAQ,aAAa;EACrB,QAAQ,QAAQ;EAChB,QAAQ,SAAS;EACjB,QAAQ,kBAAkB;EAC1B,QAAQ,YAAY,UAAU,2BAA2B;EACzD,QAAQ,YAAY;EACpB,QAAQ,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,cAAc,GAAG,aAAa,CAAC;EACjF,OAAO;GAAE;GAAS,KAAK,KAAK;GAAK,QAAQ,KAAK;EAAO;CACvD;CACA,MAAM,WAAW,KAAK,OAAO,IAAI,KAAK,IAAI;CAC1C,IAAI,UAAU;EACZ,IAAK,OAAO,OAAO,KAAK,IAAI;EAC5B,SAAS,SAAS;CACpB;CACA,MAAM,UAAU,IAAI,YAAY,KAAK,MAAM,OAAO,KAAK,QAAQ,YAAY,gBAAgB;CAC3F,QAAQ,aAAa;CACrB,QAAQ,QAAQ;CAChB,QAAQ,kBAAkB,QAAQ,WAAW;CAC7C,QAAQ,YAAY,QAAQ,kBAAkB,2BAA2B;CACzE,QAAQ,YAAY;CACpB,QAAQ,aAAa,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,cAAc,GAAG,aAAa,CAAC;CACjF,QAAQ,cAAc;CACtB,OAAO;EAAE;EAAS,KAAK,KAAK;EAAK,QAAQ,KAAK;CAAO;AACvD"}
@@ -1,6 +1,7 @@
1
- import { encodeSdfFromRgba } from "./cpuSdf.js";
2
1
  import { DataTexture, LinearFilter, LinearMipmapLinearFilter, NoColorSpace, RedFormat, UnsignedByteType } from "three/webgpu";
3
2
  // src/atlas/cpuAtlas.ts
3
+ /** @internal Overlap the main-thread encoder import with an intentional CPU capture. */
4
+ var loadCpuEncoder = () => import("./cpuSdf.js");
4
5
  function readPixels(raster) {
5
6
  const context = raster.canvas.getContext("2d", { willReadFrequently: true });
6
7
  if (!context) throw new Error("buildCpuSdfAtlas: Canvas 2D is unavailable");
@@ -22,7 +23,11 @@ async function buildCpuSdfAtlas(raster, options = {}, preparedWorker) {
22
23
  }
23
24
  else preparedWorker?.dispose();
24
25
  signal?.throwIfAborted();
25
- sdf ??= encodeSdfFromRgba(rgba, width, height, pxRange);
26
+ if (!sdf) {
27
+ const { encodeSdfFromRgba } = await loadCpuEncoder();
28
+ signal?.throwIfAborted();
29
+ sdf = encodeSdfFromRgba(rgba, width, height, pxRange);
30
+ }
26
31
  const texture = new DataTexture(sdf, width, height, RedFormat, UnsignedByteType);
27
32
  texture.name = "ultra-text runtime SDF atlas (CPU EDT)";
28
33
  texture.colorSpace = NoColorSpace;
@@ -49,6 +54,6 @@ async function buildCpuSdfAtlas(raster, options = {}, preparedWorker) {
49
54
  }
50
55
  };
51
56
  }
52
- export { buildCpuSdfAtlas };
57
+ export { buildCpuSdfAtlas, loadCpuEncoder };
53
58
 
54
59
  //# sourceMappingURL=cpuAtlas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cpuAtlas.js","names":[],"sources":["../../src/atlas/cpuAtlas.ts"],"sourcesContent":["import {\n DataTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n NoColorSpace,\n RedFormat,\n UnsignedByteType,\n} from 'three/webgpu'\n\nimport type { BuildSdfAtlasOptions, RasterAtlas, SdfAtlas } from '../types.js'\nimport { encodeSdfFromRgba } from './cpuSdf.js'\nimport type { PreparedCpuWorker } from './cpuWorker.js'\nimport type { ShapeRows } from './rasterize.js'\n\nfunction readPixels(raster: RasterAtlas): Uint8ClampedArray {\n const context = raster.canvas.getContext('2d', { willReadFrequently: true })\n if (!context) throw new Error('buildCpuSdfAtlas: Canvas 2D is unavailable')\n return context.getImageData(0, 0, raster.width, raster.height).data\n}\n\nexport async function buildCpuSdfAtlas(\n raster: RasterAtlas,\n options: Omit<BuildSdfAtlasOptions, 'mode'> = {},\n /** @internal */\n preparedWorker?: PreparedCpuWorker | null,\n): Promise<SdfAtlas> {\n const { width, height, pxRange, bakeSize, glyphs, shapeTop } = raster as RasterAtlas & ShapeRows\n const { signal, mipmaps = false, anisotropy = 1, cpuWorker } = options\n signal?.throwIfAborted()\n const useWorker = cpuWorker !== false && typeof Worker !== 'undefined'\n const workerImport = useWorker ? import('./cpuWorker.js') : undefined\n let rgba = readPixels(raster)\n let sdf: Uint8Array | undefined\n if (workerImport) {\n try {\n const { encodeInWorker } = await workerImport\n // The worker takes the alpha out of the pixels directly via encodeSdfFromRgba.\n sdf = await encodeInWorker(rgba, width, height, pxRange, signal, preparedWorker)\n } catch {\n signal?.throwIfAborted()\n // A worker can fail to load under CSP or an older bundler. Its transferred\n // input may already be detached, so recapture before the synchronous fallback.\n if (rgba.byteLength === 0) rgba = readPixels(raster)\n }\n } else {\n preparedWorker?.dispose()\n }\n signal?.throwIfAborted()\n sdf ??= encodeSdfFromRgba(rgba, width, height, pxRange)\n const texture = new DataTexture(sdf, width, height, RedFormat, UnsignedByteType)\n texture.name = 'ultra-text runtime SDF atlas (CPU EDT)'\n texture.colorSpace = NoColorSpace\n texture.flipY = false\n texture.generateMipmaps = mipmaps\n texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = mipmaps ? Math.max(1, anisotropy) : 1\n texture.needsUpdate = true\n\n let disposed = false\n return {\n ...(shapeTop === undefined ? {} : { shapeTop }),\n texture,\n width,\n height,\n pxRange,\n bakeSize,\n glyphs,\n mode: 'cpu',\n dispose(): void {\n if (disposed) return\n disposed = true\n texture.dispose()\n },\n }\n}\n"],"mappings":";;;AAcA,SAAS,WAAW,QAAwC;CAC1D,MAAM,UAAU,OAAO,OAAO,WAAW,MAAM,EAAE,oBAAoB,KAAK,CAAC;CAC3E,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,4CAA4C;CAC1E,OAAO,QAAQ,aAAa,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC;AACjE;AAEA,eAAsB,iBACpB,QACA,UAA8C,CAAC,GAE/C,gBACmB;CACnB,MAAM,EAAE,OAAO,QAAQ,SAAS,UAAU,QAAQ,aAAa;CAC/D,MAAM,EAAE,QAAQ,UAAU,OAAO,aAAa,GAAG,cAAc;CAC/D,QAAQ,eAAe;CAEvB,MAAM,eADY,cAAc,SAAS,OAAO,WAAW,cAC1B,OAAO,oBAAoB,KAAA;CAC5D,IAAI,OAAO,WAAW,MAAM;CAC5B,IAAI;CACJ,IAAI,cACF,IAAI;EACF,MAAM,EAAE,mBAAmB,MAAM;EAEjC,MAAM,MAAM,eAAe,MAAM,OAAO,QAAQ,SAAS,QAAQ,cAAc;CACjF,QAAQ;EACN,QAAQ,eAAe;EAGvB,IAAI,KAAK,eAAe,GAAG,OAAO,WAAW,MAAM;CACrD;MAEA,gBAAgB,QAAQ;CAE1B,QAAQ,eAAe;CACvB,QAAQ,kBAAkB,MAAM,OAAO,QAAQ,OAAO;CACtD,MAAM,UAAU,IAAI,YAAY,KAAK,OAAO,QAAQ,WAAW,gBAAgB;CAC/E,QAAQ,OAAO;CACf,QAAQ,aAAa;CACrB,QAAQ,QAAQ;CAChB,QAAQ,kBAAkB;CAC1B,QAAQ,YAAY,UAAU,2BAA2B;CACzD,QAAQ,YAAY;CACpB,QAAQ,aAAa,UAAU,KAAK,IAAI,GAAG,UAAU,IAAI;CACzD,QAAQ,cAAc;CAEtB,IAAI,WAAW;CACf,OAAO;EACL,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN,UAAgB;GACd,IAAI,UAAU;GACd,WAAW;GACX,QAAQ,QAAQ;EAClB;CACF;AACF"}
1
+ {"version":3,"file":"cpuAtlas.js","names":[],"sources":["../../src/atlas/cpuAtlas.ts"],"sourcesContent":["import {\n DataTexture,\n LinearFilter,\n LinearMipmapLinearFilter,\n NoColorSpace,\n RedFormat,\n UnsignedByteType,\n} from 'three/webgpu'\n\nimport type { BuildSdfAtlasOptions, RasterAtlas, SdfAtlas } from '../types.js'\nimport type { PreparedCpuWorker } from './cpuWorker.js'\nimport type { ShapeRows } from './rasterize.js'\n\n/** @internal Overlap the main-thread encoder import with an intentional CPU capture. */\nexport const loadCpuEncoder = () => import('./cpuSdf.js')\n\nfunction readPixels(raster: RasterAtlas): Uint8ClampedArray {\n const context = raster.canvas.getContext('2d', { willReadFrequently: true })\n if (!context) throw new Error('buildCpuSdfAtlas: Canvas 2D is unavailable')\n return context.getImageData(0, 0, raster.width, raster.height).data\n}\n\nexport async function buildCpuSdfAtlas(\n raster: RasterAtlas,\n options: Omit<BuildSdfAtlasOptions, 'mode'> = {},\n /** @internal */\n preparedWorker?: PreparedCpuWorker | null,\n): Promise<SdfAtlas> {\n const { width, height, pxRange, bakeSize, glyphs, shapeTop } = raster as RasterAtlas & ShapeRows\n const { signal, mipmaps = false, anisotropy = 1, cpuWorker } = options\n signal?.throwIfAborted()\n const useWorker = cpuWorker !== false && typeof Worker !== 'undefined'\n const workerImport = useWorker ? import('./cpuWorker.js') : undefined\n let rgba = readPixels(raster)\n let sdf: Uint8Array | undefined\n if (workerImport) {\n try {\n const { encodeInWorker } = await workerImport\n // The worker takes the alpha out of the pixels directly via encodeSdfFromRgba.\n sdf = await encodeInWorker(rgba, width, height, pxRange, signal, preparedWorker)\n } catch {\n signal?.throwIfAborted()\n // A worker can fail to load under CSP or an older bundler. Its transferred\n // input may already be detached, so recapture before the synchronous fallback.\n if (rgba.byteLength === 0) rgba = readPixels(raster)\n }\n } else {\n preparedWorker?.dispose()\n }\n signal?.throwIfAborted()\n if (!sdf) {\n const { encodeSdfFromRgba } = await loadCpuEncoder()\n signal?.throwIfAborted()\n sdf = encodeSdfFromRgba(rgba, width, height, pxRange)\n }\n const texture = new DataTexture(sdf, width, height, RedFormat, UnsignedByteType)\n texture.name = 'ultra-text runtime SDF atlas (CPU EDT)'\n texture.colorSpace = NoColorSpace\n texture.flipY = false\n texture.generateMipmaps = mipmaps\n texture.minFilter = mipmaps ? LinearMipmapLinearFilter : LinearFilter\n texture.magFilter = LinearFilter\n texture.anisotropy = mipmaps ? Math.max(1, anisotropy) : 1\n texture.needsUpdate = true\n\n let disposed = false\n return {\n ...(shapeTop === undefined ? {} : { shapeTop }),\n texture,\n width,\n height,\n pxRange,\n bakeSize,\n glyphs,\n mode: 'cpu',\n dispose(): void {\n if (disposed) return\n disposed = true\n texture.dispose()\n },\n }\n}\n"],"mappings":";;;AAcA,IAAa,uBAAuB,OAAO;AAE3C,SAAS,WAAW,QAAwC;CAC1D,MAAM,UAAU,OAAO,OAAO,WAAW,MAAM,EAAE,oBAAoB,KAAK,CAAC;CAC3E,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,4CAA4C;CAC1E,OAAO,QAAQ,aAAa,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC;AACjE;AAEA,eAAsB,iBACpB,QACA,UAA8C,CAAC,GAE/C,gBACmB;CACnB,MAAM,EAAE,OAAO,QAAQ,SAAS,UAAU,QAAQ,aAAa;CAC/D,MAAM,EAAE,QAAQ,UAAU,OAAO,aAAa,GAAG,cAAc;CAC/D,QAAQ,eAAe;CAEvB,MAAM,eADY,cAAc,SAAS,OAAO,WAAW,cAC1B,OAAO,oBAAoB,KAAA;CAC5D,IAAI,OAAO,WAAW,MAAM;CAC5B,IAAI;CACJ,IAAI,cACF,IAAI;EACF,MAAM,EAAE,mBAAmB,MAAM;EAEjC,MAAM,MAAM,eAAe,MAAM,OAAO,QAAQ,SAAS,QAAQ,cAAc;CACjF,QAAQ;EACN,QAAQ,eAAe;EAGvB,IAAI,KAAK,eAAe,GAAG,OAAO,WAAW,MAAM;CACrD;MAEA,gBAAgB,QAAQ;CAE1B,QAAQ,eAAe;CACvB,IAAI,CAAC,KAAK;EACR,MAAM,EAAE,sBAAsB,MAAM,eAAe;EACnD,QAAQ,eAAe;EACvB,MAAM,kBAAkB,MAAM,OAAO,QAAQ,OAAO;CACtD;CACA,MAAM,UAAU,IAAI,YAAY,KAAK,OAAO,QAAQ,WAAW,gBAAgB;CAC/E,QAAQ,OAAO;CACf,QAAQ,aAAa;CACrB,QAAQ,QAAQ;CAChB,QAAQ,kBAAkB;CAC1B,QAAQ,YAAY,UAAU,2BAA2B;CACzD,QAAQ,YAAY;CACpB,QAAQ,aAAa,UAAU,KAAK,IAAI,GAAG,UAAU,IAAI;CACzD,QAAQ,cAAc;CAEtB,IAAI,WAAW;CACf,OAAO;EACL,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;EACN,UAAgB;GACd,IAAI,UAAU;GACd,WAAW;GACX,QAAQ,QAAQ;EAClB;CACF;AACF"}
@@ -13,7 +13,7 @@ export declare function alphaOfRgba(rgba: Uint8ClampedArray, pixelCount: number)
13
13
  *
14
14
  * Fractional source alpha is retained as a sub-pixel seed cost rather than
15
15
  * thresholded away. The two exact Euclidean distance transforms are O(width *
16
- * height); temporary storage is one grid plus O(height) scratch.
16
+ * height); temporary storage is one active row band plus O(height) scratch.
17
17
  */
18
18
  export declare function encodeSdfFromAlpha(alpha: AlphaPixels, width: number, height: number, pxRange: number): Uint8Array;
19
19
  export {};