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.
- package/README.md +224 -1002
- package/dist/assets/{cpuSdf.worker-xS57yQbP.js → cpuSdf.worker--X1Qpmdp.js} +136 -47
- package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
- package/dist/atlas/appendAtlas.js +67 -25
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +3 -2
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/cpuAtlas.d.ts +4 -1
- package/dist/atlas/cpuAtlas.js +8 -6
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.js +152 -40
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +5 -3
- package/dist/atlas/cpuWorker.js +119 -12
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +100 -276
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +135 -0
- package/dist/atlas/gpuCommon.js +223 -0
- package/dist/atlas/gpuCommon.js.map +1 -0
- package/dist/atlas/jfaWgsl.js +47 -241
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.js +103 -58
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/shapeRaster.js +2 -1
- package/dist/atlas/shapeRaster.js.map +1 -1
- package/dist/atlas/vanillaBounds.d.ts +64 -0
- package/dist/atlas/vanillaBounds.js +42 -0
- package/dist/atlas/vanillaBounds.js.map +1 -0
- package/dist/atlas/vanillaCore.d.ts +100 -0
- package/dist/atlas/vanillaCore.js +1012 -0
- package/dist/atlas/vanillaCore.js.map +1 -0
- package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
- package/dist/atlas/vanillaCpuAtlas.js +87 -0
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
- package/dist/atlas/vanillaExtras.d.ts +8 -0
- package/dist/atlas/vanillaExtras.js +166 -0
- package/dist/atlas/vanillaExtras.js.map +1 -0
- package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
- package/dist/atlas/vanillaGpuHelpers.js +119 -0
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
- package/dist/dom/DomSdf.js +224 -284
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +75 -151
- package/dist/dom/DomSlug.js.map +1 -1
- package/dist/dom/domAnalytic.d.ts +54 -0
- package/dist/dom/domAnalytic.js +282 -0
- package/dist/dom/domAnalytic.js.map +1 -0
- package/dist/dom/domExtras.d.ts +27 -0
- package/dist/dom/domExtras.js +137 -0
- package/dist/dom/domExtras.js.map +1 -0
- package/dist/dom/fontCanvas.js +27 -9
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +150 -48
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/pretextLayout.js +55 -13
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.js +369 -204
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/svgCapture.d.ts +8 -1
- package/dist/dom/svgCapture.js +75 -1
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/tone.js +76 -36
- package/dist/dom/tone.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/slug/SlugMaterial.d.ts +11 -3
- package/dist/slug/SlugMaterial.js +54 -10
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/coverage.d.ts +16 -12
- package/dist/slug/coverage.js +194 -221
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +5 -1
- package/dist/slug/preprocessCore.js +118 -87
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.d.ts +1 -0
- package/dist/slug/runtime.js +90 -44
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.d.ts +3 -2
- package/dist/slug/standaloneRuntime.js +75 -40
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.js +166 -193
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +340 -0
- package/dist/slug/vanillaCore.js +1621 -0
- package/dist/slug/vanillaCore.js.map +1 -0
- package/dist/slug-vanilla.d.ts +13 -364
- package/dist/slug-vanilla.js +5 -1453
- package/dist/slug.d.ts +1 -1
- package/dist/slug.js +6 -6
- package/dist/text/GlyphTextMaterial.d.ts +1 -1
- package/dist/text/GlyphTextMaterial.js +5 -5
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.js +7 -5
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.js +36 -19
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometry.d.ts +3 -22
- package/dist/text/geometryUtils.d.ts +11 -1
- package/dist/text/geometryUtils.js +22 -1
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +9 -0
- package/dist/text/glyphGeometry.js +353 -0
- package/dist/text/glyphGeometry.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/rectGeometry.d.ts +13 -0
- package/dist/text/rectGeometry.js +97 -0
- package/dist/text/rectGeometry.js.map +1 -0
- package/dist/text/reflow.d.ts +18 -1
- package/dist/text/reflow.js +108 -38
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +1 -0
- package/dist/text/snap.js +26 -0
- package/dist/text/snap.js.map +1 -0
- package/dist/vanilla.d.ts +13 -363
- package/dist/vanilla.js +6 -1473
- package/dist/windfoil/geometry.d.ts +2 -2
- package/dist/windfoil/geometry.js +113 -40
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/mixed.d.ts +1 -0
- package/dist/windfoil/mixed.js +44 -25
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/preprocess.js +2 -2
- package/dist/windfoil/preprocessCore.d.ts +1 -0
- package/dist/windfoil/preprocessCore.js +9 -4
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/runtime.d.ts +3 -1
- package/dist/windfoil/runtime.js +62 -40
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/storage.d.ts +60 -2
- package/dist/windfoil/storage.js +142 -6
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/trace/contours.d.ts +5 -0
- package/dist/windfoil/trace/contours.js +167 -43
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.d.ts +3 -1
- package/dist/windfoil/trace/fit.js +471 -175
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/outline.js +55 -30
- package/dist/windfoil/trace/outline.js.map +1 -1
- package/dist/windfoil/trace/types.d.ts +10 -0
- package/dist/windfoil/tracedOutlines.js +59 -34
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +11 -11
- package/skills/ultra-text/references/three-tsl.md +2 -2
- package/skills/ultra-text/references/vanilla-webgpu.md +3 -2
- package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
- package/dist/slug-vanilla.js.map +0 -1
- package/dist/text/geometry.js +0 -348
- package/dist/text/geometry.js.map +0 -1
- package/dist/vanilla.js.map +0 -1
|
@@ -16,11 +16,11 @@ export interface MutableWindfoilAttributes {
|
|
|
16
16
|
export declare function fillWindfoilGlyphRect(glyph: GlyphLayout, header: WindfoilGlyphHeader, bbox?: WindfoilBoundingBox, out?: [number, number, number, number]): [number, number, number, number];
|
|
17
17
|
export declare function windfoilGlyphRect(glyph: GlyphLayout, header: WindfoilGlyphHeader, bbox?: WindfoilBoundingBox): readonly [number, number, number, number];
|
|
18
18
|
/** Shared by text and shape geometry; one layer adds only one vertex attribute. */
|
|
19
|
-
export declare function writeLayerInstance(glyph: GlyphLayout, header: WindfoilGlyphHeader, layer: WindfoilGlyphHeader | WindfoilLayerHeader, index: number, ordinal: number, attributes: MutableWindfoilAttributes, glyphRect?: readonly [number, number, number, number]): void;
|
|
19
|
+
export declare function writeLayerInstance(glyph: GlyphLayout, header: WindfoilGlyphHeader, layer: WindfoilGlyphHeader | WindfoilLayerHeader, index: number, ordinal: number, attributes: MutableWindfoilAttributes, glyphRect?: readonly [number, number, number, number], trackDirty?: boolean): void;
|
|
20
20
|
/** Ordinary outlines retain the original six instance attributes. */
|
|
21
21
|
export declare function createWindfoilGlyphGeometry(snapshot: DomLayoutSnapshot, glyphs: ReadonlyMap<string, WindfoilGlyphHeader>, motionPadding: number, layered?: boolean, ordinals?: Float32Array): {
|
|
22
22
|
geometry: InstancedBufferGeometry;
|
|
23
23
|
maxSequence: number;
|
|
24
24
|
};
|
|
25
25
|
export declare function windfoilContentFits(geometry: InstancedBufferGeometry, snapshot: DomLayoutSnapshot, glyphs: ReadonlyMap<string, WindfoilGlyphHeader>): boolean;
|
|
26
|
-
export declare function updateWindfoilGlyphGeometry(geometry: InstancedBufferGeometry, snapshot: DomLayoutSnapshot, glyphs: ReadonlyMap<string, WindfoilGlyphHeader>, motionPadding: number, ordinals?: Float32Array): number | null;
|
|
26
|
+
export declare function updateWindfoilGlyphGeometry(geometry: InstancedBufferGeometry, snapshot: DomLayoutSnapshot, glyphs: ReadonlyMap<string, WindfoilGlyphHeader>, motionPadding: number, ordinals?: Float32Array, checked?: boolean): number | null;
|
|
@@ -11,6 +11,68 @@ var ATTRIBUTES = [
|
|
|
11
11
|
"windfoilBand"
|
|
12
12
|
];
|
|
13
13
|
var LAYERED_ATTRIBUTES = [...ATTRIBUTES, "windfoilLayer"];
|
|
14
|
+
var SLOT_RECT = 0;
|
|
15
|
+
var SLOT_CLIP = 1;
|
|
16
|
+
var SLOT_COLOR = 2;
|
|
17
|
+
var SLOT_META = 3;
|
|
18
|
+
var SLOT_BOUNDS = 4;
|
|
19
|
+
var SLOT_BAND = 5;
|
|
20
|
+
var SLOT_LAYER = 6;
|
|
21
|
+
var DIRTY_UNSET = 2147483647;
|
|
22
|
+
var dirtyBounds = /* @__PURE__ */ new Int32Array(14);
|
|
23
|
+
function resetDirtyBounds() {
|
|
24
|
+
for (let slot = 0; slot < 7; slot++) {
|
|
25
|
+
const base = slot * 2;
|
|
26
|
+
dirtyBounds[base] = DIRTY_UNSET;
|
|
27
|
+
dirtyBounds[base + 1] = 0;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function recordDirty(slot, start, end) {
|
|
31
|
+
const base = slot * 2;
|
|
32
|
+
if (start < dirtyBounds[base]) dirtyBounds[base] = start;
|
|
33
|
+
if (end > dirtyBounds[base + 1]) dirtyBounds[base + 1] = end;
|
|
34
|
+
}
|
|
35
|
+
function flushAttributeUpdate(attribute, dirtyStart, dirtyEnd) {
|
|
36
|
+
if (attribute.version === 0) {
|
|
37
|
+
attribute.needsUpdate = true;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (dirtyEnd <= dirtyStart) return;
|
|
41
|
+
let start = dirtyStart;
|
|
42
|
+
let end = dirtyEnd;
|
|
43
|
+
for (const range of attribute.updateRanges) {
|
|
44
|
+
if (range.count < 0) {
|
|
45
|
+
start = 0;
|
|
46
|
+
end = attribute.array.length;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
if (range.start < start) start = range.start;
|
|
50
|
+
const rangeEnd = range.start + range.count;
|
|
51
|
+
if (rangeEnd > end) end = rangeEnd;
|
|
52
|
+
}
|
|
53
|
+
attribute.clearUpdateRanges();
|
|
54
|
+
attribute.addUpdateRange(start, end - start);
|
|
55
|
+
attribute.needsUpdate = true;
|
|
56
|
+
}
|
|
57
|
+
function writeFloat4(target, offset, a, b, c, d, trackDirty, slot) {
|
|
58
|
+
if (trackDirty) {
|
|
59
|
+
const fa = Math.fround(a);
|
|
60
|
+
const fb = Math.fround(b);
|
|
61
|
+
const fc = Math.fround(c);
|
|
62
|
+
const fd = Math.fround(d);
|
|
63
|
+
if (target[offset] === fa && target[offset + 1] === fb && target[offset + 2] === fc && target[offset + 3] === fd) return;
|
|
64
|
+
target[offset] = fa;
|
|
65
|
+
target[offset + 1] = fb;
|
|
66
|
+
target[offset + 2] = fc;
|
|
67
|
+
target[offset + 3] = fd;
|
|
68
|
+
recordDirty(slot, offset, offset + 4);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
target[offset] = a;
|
|
72
|
+
target[offset + 1] = b;
|
|
73
|
+
target[offset + 2] = c;
|
|
74
|
+
target[offset + 3] = d;
|
|
75
|
+
}
|
|
14
76
|
var scratchRect = [
|
|
15
77
|
0,
|
|
16
78
|
0,
|
|
@@ -34,55 +96,58 @@ function windfoilGlyphRect(glyph, header, bbox = header.bbox) {
|
|
|
34
96
|
0
|
|
35
97
|
]);
|
|
36
98
|
}
|
|
37
|
-
function writeInstance(glyph, header, layer, index, ordinal, attributes, c0, c1, c2, c3, glyphRect) {
|
|
99
|
+
function writeInstance(glyph, header, layer, index, ordinal, attributes, c0, c1, c2, c3, glyphRect, trackDirty = false) {
|
|
38
100
|
const offset = index * 4;
|
|
39
101
|
const scale = glyph.fontSize / header.unitsPerEm;
|
|
40
102
|
const baseline = glyph.lineBottom + (glyph.baselineOffset ?? -header.descent * scale);
|
|
41
103
|
const ox = glyph.originX;
|
|
42
104
|
const lBox = layer.bbox;
|
|
43
105
|
const b0 = lBox[0], b1 = lBox[1], b2 = lBox[2], b3 = lBox[3];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
rects[offset + 2] = ox + b2 * scale;
|
|
48
|
-
rects[offset + 3] = baseline + b3 * scale;
|
|
49
|
-
const clips = attributes.clips, clip = glyph.clip;
|
|
50
|
-
clips[offset] = clip[0];
|
|
51
|
-
clips[offset + 1] = clip[1];
|
|
52
|
-
clips[offset + 2] = clip[2];
|
|
53
|
-
clips[offset + 3] = clip[3];
|
|
106
|
+
writeFloat4(attributes.rects, offset, ox + b0 * scale, baseline + b1 * scale, ox + b2 * scale, baseline + b3 * scale, trackDirty, SLOT_RECT);
|
|
107
|
+
const clip = glyph.clip;
|
|
108
|
+
writeFloat4(attributes.clips, offset, clip[0], clip[1], clip[2], clip[3], trackDirty, SLOT_CLIP);
|
|
54
109
|
const colors = attributes.colors;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
110
|
+
if (trackDirty) {
|
|
111
|
+
if (colors[offset] !== c0 || colors[offset + 1] !== c1 || colors[offset + 2] !== c2 || colors[offset + 3] !== c3) {
|
|
112
|
+
colors[offset] = c0;
|
|
113
|
+
colors[offset + 1] = c1;
|
|
114
|
+
colors[offset + 2] = c2;
|
|
115
|
+
colors[offset + 3] = c3;
|
|
116
|
+
recordDirty(SLOT_COLOR, offset, offset + 4);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
colors[offset] = c0;
|
|
120
|
+
colors[offset + 1] = c1;
|
|
121
|
+
colors[offset + 2] = c2;
|
|
122
|
+
colors[offset + 3] = c3;
|
|
123
|
+
}
|
|
124
|
+
const metaSizeValue = attributes.metaSize ?? 2;
|
|
125
|
+
const metadata = attributes.metadata;
|
|
126
|
+
if (trackDirty) {
|
|
127
|
+
const mOffset = index * metaSizeValue;
|
|
128
|
+
const seq = Math.fround(glyph.sequence);
|
|
129
|
+
const gz = Math.fround(glyph.z);
|
|
130
|
+
const sw = metaSizeValue === 3 ? Math.fround(glyph.switchEm ?? 0) : 0;
|
|
131
|
+
if (metadata[mOffset] !== seq || metadata[mOffset + 1] !== gz || metaSizeValue === 3 && metadata[mOffset + 2] !== sw) {
|
|
132
|
+
writeMeta(metadata, index, metaSizeValue, glyph);
|
|
133
|
+
recordDirty(SLOT_META, mOffset, mOffset + metaSizeValue);
|
|
134
|
+
}
|
|
135
|
+
} else writeMeta(metadata, index, metaSizeValue, glyph);
|
|
136
|
+
writeFloat4(attributes.bounds, offset, b0, b1, b2, b3, trackDirty, SLOT_BOUNDS);
|
|
137
|
+
writeFloat4(attributes.bands, offset, layer.rowBase, layer.bandCount, layer.bandH, layer.invH, trackDirty, SLOT_BAND);
|
|
70
138
|
const layers = attributes.layers;
|
|
71
139
|
if (layers) {
|
|
72
140
|
const paint = "paintKind" in layer ? layer : null;
|
|
73
141
|
const rect = glyphRect ?? fillWindfoilGlyphRect(glyph, header, header.bbox, scratchRect);
|
|
74
142
|
const mo = glyph.motionOrigin;
|
|
75
|
-
layers
|
|
76
|
-
layers[offset + 1] = mo ? mo[1] : (rect[1] + rect[3]) / 2;
|
|
77
|
-
layers[offset + 2] = ordinal;
|
|
78
|
-
layers[offset + 3] = paint?.paintKind === 2 ? 2 + (paint.paintIndex ?? 0) : paint?.paintKind ?? 0;
|
|
143
|
+
writeFloat4(layers, offset, mo ? mo[0] : (rect[0] + rect[2]) / 2, mo ? mo[1] : (rect[1] + rect[3]) / 2, ordinal, paint?.paintKind === 2 ? 2 + (paint.paintIndex ?? 0) : paint?.paintKind ?? 0, trackDirty, SLOT_LAYER);
|
|
79
144
|
}
|
|
80
145
|
}
|
|
81
146
|
/** Shared by text and shape geometry; one layer adds only one vertex attribute. */
|
|
82
|
-
function writeLayerInstance(glyph, header, layer, index, ordinal, attributes, glyphRect) {
|
|
147
|
+
function writeLayerInstance(glyph, header, layer, index, ordinal, attributes, glyphRect, trackDirty = false) {
|
|
83
148
|
const paint = "paintKind" in layer ? layer : null;
|
|
84
149
|
const rgb = paint?.paintKind === 1 ? paint.rgba : glyph.color;
|
|
85
|
-
writeInstance(glyph, header, layer, index, ordinal, attributes, byte(rgb[0]), byte(rgb[1]), byte(rgb[2]), byte(glyph.color[3] * (paint ? paint.rgba[3] : 1)), glyphRect);
|
|
150
|
+
writeInstance(glyph, header, layer, index, ordinal, attributes, byte(rgb[0]), byte(rgb[1]), byte(rgb[2]), byte(glyph.color[3] * (paint ? paint.rgba[3] : 1)), glyphRect, trackDirty);
|
|
86
151
|
}
|
|
87
152
|
function countLayout(snapshot, glyphs, layered) {
|
|
88
153
|
let instances = 0, drawable = 0;
|
|
@@ -98,7 +163,7 @@ function countLayout(snapshot, glyphs, layered) {
|
|
|
98
163
|
drawable
|
|
99
164
|
};
|
|
100
165
|
}
|
|
101
|
-
function writeGeometry(snapshot, glyphs, attributes, ordinals) {
|
|
166
|
+
function writeGeometry(snapshot, glyphs, attributes, ordinals, trackDirty = false) {
|
|
102
167
|
let instance = 0, drawable = 0, maxSequence = 0, minZ = 0, maxZ = 0;
|
|
103
168
|
let prevKey;
|
|
104
169
|
let prevHeader;
|
|
@@ -122,13 +187,13 @@ function writeGeometry(snapshot, glyphs, attributes, ordinals) {
|
|
|
122
187
|
attributes.glyphRects[rectOffset + 2] = rect[2];
|
|
123
188
|
attributes.glyphRects[rectOffset + 3] = rect[3];
|
|
124
189
|
}
|
|
125
|
-
if (attributes.layers && header.layers) for (const layer of header.layers) writeLayerInstance(glyph, header, layer, instance++, ordinal, attributes, rect);
|
|
190
|
+
if (attributes.layers && header.layers) for (const layer of header.layers) writeLayerInstance(glyph, header, layer, instance++, ordinal, attributes, rect, trackDirty);
|
|
126
191
|
else {
|
|
127
192
|
const layer = header.layers?.[0] ?? header;
|
|
128
193
|
const paint = "paintKind" in layer ? layer : null;
|
|
129
194
|
if (paint) {
|
|
130
195
|
const rgb = paint.paintKind === 1 ? paint.rgba : glyph.color;
|
|
131
|
-
writeInstance(glyph, header, layer, instance++, ordinal, attributes, byte(rgb[0]), byte(rgb[1]), byte(rgb[2]), byte(glyph.color[3] * paint.rgba[3]), rect);
|
|
196
|
+
writeInstance(glyph, header, layer, instance++, ordinal, attributes, byte(rgb[0]), byte(rgb[1]), byte(rgb[2]), byte(glyph.color[3] * paint.rgba[3]), rect, trackDirty);
|
|
132
197
|
} else {
|
|
133
198
|
const color = glyph.color;
|
|
134
199
|
if (color !== prevColor) {
|
|
@@ -138,7 +203,7 @@ function writeGeometry(snapshot, glyphs, attributes, ordinals) {
|
|
|
138
203
|
pc2 = byte(color[2]);
|
|
139
204
|
pc3 = byte(color[3]);
|
|
140
205
|
}
|
|
141
|
-
writeInstance(glyph, header, layer, instance++, ordinal, attributes, pc0, pc1, pc2, pc3, rect);
|
|
206
|
+
writeInstance(glyph, header, layer, instance++, ordinal, attributes, pc0, pc1, pc2, pc3, rect, trackDirty);
|
|
142
207
|
}
|
|
143
208
|
}
|
|
144
209
|
drawable++;
|
|
@@ -279,10 +344,12 @@ function windfoilContentFits(geometry, snapshot, glyphs) {
|
|
|
279
344
|
}
|
|
280
345
|
return instances === geometry.instanceCount && (!layered || geometry.userData["ultraOwnGlyphRects"]?.length === drawable * 4);
|
|
281
346
|
}
|
|
282
|
-
function updateWindfoilGlyphGeometry(geometry, snapshot, glyphs, motionPadding, ordinals) {
|
|
283
|
-
if (!windfoilContentFits(geometry, snapshot, glyphs)) return null;
|
|
347
|
+
function updateWindfoilGlyphGeometry(geometry, snapshot, glyphs, motionPadding, ordinals, checked = false) {
|
|
348
|
+
if (!checked && !windfoilContentFits(geometry, snapshot, glyphs)) return null;
|
|
284
349
|
const array = (name) => geometry.getAttribute(name).array;
|
|
285
350
|
const layer = geometry.getAttribute("windfoilLayer");
|
|
351
|
+
const trackDirty = geometry.getAttribute("sdfRect").version > 0 || geometry.getAttribute("sdfClip").version > 0 || geometry.getAttribute("sdfColor").version > 0 || geometry.getAttribute("sdfMeta").version > 0 || geometry.getAttribute("windfoilBounds").version > 0 || geometry.getAttribute("windfoilBand").version > 0 || (layer?.version ?? 0) > 0;
|
|
352
|
+
if (trackDirty) resetDirtyBounds();
|
|
286
353
|
const result = writeGeometry(snapshot, glyphs, {
|
|
287
354
|
rects: array("sdfRect"),
|
|
288
355
|
clips: array("sdfClip"),
|
|
@@ -295,8 +362,14 @@ function updateWindfoilGlyphGeometry(geometry, snapshot, glyphs, motionPadding,
|
|
|
295
362
|
layers: layer.array,
|
|
296
363
|
glyphRects: geometry.userData["ultraOwnGlyphRects"]
|
|
297
364
|
} : {}
|
|
298
|
-
}, ordinals);
|
|
299
|
-
|
|
365
|
+
}, ordinals, trackDirty);
|
|
366
|
+
const list = layer ? LAYERED_ATTRIBUTES : ATTRIBUTES;
|
|
367
|
+
if (trackDirty) for (let i = 0; i < list.length; i++) {
|
|
368
|
+
const attribute = geometry.getAttribute(list[i]);
|
|
369
|
+
const base = i * 2;
|
|
370
|
+
flushAttributeUpdate(attribute, dirtyBounds[base], dirtyBounds[base + 1]);
|
|
371
|
+
}
|
|
372
|
+
else for (const name of list) geometry.getAttribute(name).needsUpdate = true;
|
|
300
373
|
setBounds(geometry, snapshot.width, snapshot.height, motionPadding, result.minZ, result.maxZ);
|
|
301
374
|
return result.maxSequence;
|
|
302
375
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","names":[],"sources":["../../src/windfoil/geometry.ts"],"sourcesContent":["import { InstancedBufferAttribute, InstancedBufferGeometry } from 'three/webgpu'\nimport { byte, metaSize, setBounds, setUnitQuad, writeMeta } from '../text/geometryUtils.js'\nimport { GLYPH_RECTS_KEY } from '../text/decorations.js'\nimport type { DomLayoutSnapshot, GlyphLayout, WindfoilBoundingBox } from '../types.js'\nimport type { WindfoilGlyphHeader, WindfoilLayerHeader } from './preprocess.js'\n\nconst ATTRIBUTES = [\n 'sdfRect',\n 'sdfClip',\n 'sdfColor',\n 'sdfMeta',\n 'windfoilBounds',\n 'windfoilBand',\n] as const\nconst LAYERED_ATTRIBUTES = [...ATTRIBUTES, 'windfoilLayer'] as const\n\nexport interface MutableWindfoilAttributes {\n readonly rects: Float32Array\n readonly clips: Float32Array\n readonly colors: Uint8Array\n readonly metadata: Float32Array\n /** Components per `sdfMeta` entry; `3` carries the size-switch em. Defaults to `2`. */\n readonly metaSize?: number\n readonly bounds: Float32Array\n readonly bands: Float32Array\n readonly layers?: Float32Array\n readonly glyphRects?: Float32Array\n}\n\nconst scratchRect: [number, number, number, number] = [0, 0, 0, 0]\n\nexport function fillWindfoilGlyphRect(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n bbox: WindfoilBoundingBox = header.bbox,\n out: [number, number, number, number] = scratchRect,\n): [number, number, number, number] {\n const scale = glyph.fontSize / header.unitsPerEm\n const baseline = glyph.lineBottom + (glyph.baselineOffset ?? -header.descent * scale)\n out[0] = glyph.originX + bbox[0] * scale\n out[1] = baseline + bbox[1] * scale\n out[2] = glyph.originX + bbox[2] * scale\n out[3] = baseline + bbox[3] * scale\n return out\n}\n\nexport function windfoilGlyphRect(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n bbox: WindfoilBoundingBox = header.bbox,\n): readonly [number, number, number, number] {\n return fillWindfoilGlyphRect(glyph, header, bbox, [0, 0, 0, 0])\n}\n\nfunction writeInstance(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n layer: WindfoilGlyphHeader | WindfoilLayerHeader,\n index: number,\n ordinal: number,\n attributes: MutableWindfoilAttributes,\n c0: number,\n c1: number,\n c2: number,\n c3: number,\n glyphRect?: readonly [number, number, number, number],\n): void {\n const offset = index * 4\n const scale = glyph.fontSize / header.unitsPerEm\n const baseline = glyph.lineBottom + (glyph.baselineOffset ?? -header.descent * scale)\n const ox = glyph.originX\n const lBox = layer.bbox\n const b0 = lBox[0],\n b1 = lBox[1],\n b2 = lBox[2],\n b3 = lBox[3]\n const rects = attributes.rects\n rects[offset] = ox + b0 * scale\n rects[offset + 1] = baseline + b1 * scale\n rects[offset + 2] = ox + b2 * scale\n rects[offset + 3] = baseline + b3 * scale\n const clips = attributes.clips,\n clip = glyph.clip\n clips[offset] = clip[0]\n clips[offset + 1] = clip[1]\n clips[offset + 2] = clip[2]\n clips[offset + 3] = clip[3]\n const colors = attributes.colors\n colors[offset] = c0\n colors[offset + 1] = c1\n colors[offset + 2] = c2\n colors[offset + 3] = c3\n writeMeta(attributes.metadata, index, attributes.metaSize ?? 2, glyph)\n const bounds = attributes.bounds\n bounds[offset] = b0\n bounds[offset + 1] = b1\n bounds[offset + 2] = b2\n bounds[offset + 3] = b3\n const bands = attributes.bands\n bands[offset] = layer.rowBase\n bands[offset + 1] = layer.bandCount\n bands[offset + 2] = layer.bandH\n bands[offset + 3] = layer.invH\n const layers = attributes.layers\n if (layers) {\n const paint = 'paintKind' in layer ? layer : null\n const rect = glyphRect ?? fillWindfoilGlyphRect(glyph, header, header.bbox, scratchRect)\n const mo = glyph.motionOrigin\n layers[offset] = mo ? mo[0] : (rect[0] + rect[2]) / 2\n layers[offset + 1] = mo ? mo[1] : (rect[1] + rect[3]) / 2\n layers[offset + 2] = ordinal\n layers[offset + 3] =\n paint?.paintKind === 2 ? 2 + (paint.paintIndex ?? 0) : (paint?.paintKind ?? 0)\n }\n}\n\n/** Shared by text and shape geometry; one layer adds only one vertex attribute. */\nexport function writeLayerInstance(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n layer: WindfoilGlyphHeader | WindfoilLayerHeader,\n index: number,\n ordinal: number,\n attributes: MutableWindfoilAttributes,\n glyphRect?: readonly [number, number, number, number],\n): void {\n const paint = 'paintKind' in layer ? layer : null\n const rgb = paint?.paintKind === 1 ? paint.rgba : glyph.color\n writeInstance(\n glyph,\n header,\n layer,\n index,\n ordinal,\n attributes,\n byte(rgb[0]),\n byte(rgb[1]),\n byte(rgb[2]),\n byte(glyph.color[3] * (paint ? paint.rgba[3] : 1)),\n glyphRect,\n )\n}\n\nfunction countLayout(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n layered: boolean,\n): { instances: number; drawable: number } {\n let instances = 0,\n drawable = 0\n for (const glyph of snapshot.glyphs) {\n const header = glyphs.get(glyph.glyphKey)\n if (header?.monotonePieceCount) {\n drawable++\n instances += layered ? (header.layers?.length ?? 1) : 1\n }\n }\n return { instances, drawable }\n}\n\nfunction writeGeometry(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n attributes: MutableWindfoilAttributes,\n ordinals?: Float32Array,\n): { instances: number; maxSequence: number; minZ: number; maxZ: number } {\n let instance = 0,\n drawable = 0,\n maxSequence = 0,\n minZ = 0,\n maxZ = 0\n let prevKey: string | undefined\n let prevHeader: WindfoilGlyphHeader | undefined\n let prevColor: GlyphLayout['color'] | undefined\n let pc0 = 0\n let pc1 = 0\n let pc2 = 0\n let pc3 = 0\n const glyphList = snapshot.glyphs\n for (let i = 0; i < glyphList.length; i++) {\n const glyph = glyphList[i]!\n const key = glyph.glyphKey\n const header = key === prevKey ? prevHeader : ((prevKey = key), (prevHeader = glyphs.get(key)))\n if (!header?.monotonePieceCount) continue\n const ordinal = ordinals?.[i] ?? glyph.motionOrigin?.[2] ?? drawable\n const rect =\n attributes.layers || attributes.glyphRects\n ? fillWindfoilGlyphRect(glyph, header, header.bbox, scratchRect)\n : undefined\n if (attributes.glyphRects && rect) {\n const rectOffset = drawable * 4\n attributes.glyphRects[rectOffset] = rect[0]\n attributes.glyphRects[rectOffset + 1] = rect[1]\n attributes.glyphRects[rectOffset + 2] = rect[2]\n attributes.glyphRects[rectOffset + 3] = rect[3]\n }\n if (attributes.layers && header.layers) {\n for (const layer of header.layers) {\n writeLayerInstance(glyph, header, layer, instance++, ordinal, attributes, rect)\n }\n } else {\n const layer = header.layers?.[0] ?? header\n const paint = 'paintKind' in layer ? layer : null\n if (paint) {\n const rgb = paint.paintKind === 1 ? paint.rgba : glyph.color\n writeInstance(\n glyph,\n header,\n layer,\n instance++,\n ordinal,\n attributes,\n byte(rgb[0]),\n byte(rgb[1]),\n byte(rgb[2]),\n byte(glyph.color[3] * paint.rgba[3]),\n rect,\n )\n } else {\n const color = glyph.color\n if (color !== prevColor) {\n prevColor = color\n pc0 = byte(color[0])\n pc1 = byte(color[1])\n pc2 = byte(color[2])\n pc3 = byte(color[3])\n }\n writeInstance(\n glyph,\n header,\n layer,\n instance++,\n ordinal,\n attributes,\n pc0,\n pc1,\n pc2,\n pc3,\n rect,\n )\n }\n }\n drawable++\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 { instances: instance, maxSequence, minZ, maxZ }\n}\n\n/** Ordinary outlines retain the original six instance attributes. */\nexport function createWindfoilGlyphGeometry(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n motionPadding: number,\n layered = false,\n ordinals?: Float32Array,\n): { geometry: InstancedBufferGeometry; maxSequence: number } {\n layered ||= !!ordinals || snapshot.glyphs.some((glyph) => !!glyph.motionOrigin)\n const meta = metaSize(snapshot)\n let count: number\n let rects: Float32Array\n let clips: Float32Array\n let colors: Uint8Array\n let metadata: Float32Array\n let bounds: Float32Array\n let bands: Float32Array\n let layers: Float32Array | undefined\n let glyphRects: Float32Array | undefined\n if (layered) {\n const counted = countLayout(snapshot, glyphs, true)\n count = counted.instances\n rects = new Float32Array(count * 4)\n clips = new Float32Array(count * 4)\n colors = new Uint8Array(count * 4)\n metadata = new Float32Array(count * meta)\n bounds = new Float32Array(count * 4)\n bands = new Float32Array(count * 4)\n layers = new Float32Array(count * 4)\n glyphRects = new Float32Array(counted.drawable * 4)\n } else {\n const total = snapshot.glyphs.length\n count = total\n rects = new Float32Array(total * 4)\n clips = new Float32Array(total * 4)\n colors = new Uint8Array(total * 4)\n metadata = new Float32Array(total * meta)\n bounds = new Float32Array(total * 4)\n bands = new Float32Array(total * 4)\n }\n const result = writeGeometry(\n snapshot,\n glyphs,\n {\n rects,\n clips,\n colors,\n metadata,\n metaSize: meta,\n bounds,\n bands,\n ...(layers && glyphRects ? { layers, glyphRects } : {}),\n },\n ordinals,\n )\n if (!layered && result.instances < count) {\n count = result.instances\n rects = rects.subarray(0, count * 4)\n clips = clips.subarray(0, count * 4)\n colors = colors.subarray(0, count * 4)\n metadata = metadata.subarray(0, count * meta)\n bounds = bounds.subarray(0, count * 4)\n bands = bands.subarray(0, count * 4)\n }\n const geometry = new InstancedBufferGeometry()\n geometry.name = 'ultra-text instanced Windfoil glyph quads'\n setUnitQuad(geometry)\n for (const [name, data, size, normalized] of [\n ['sdfRect', rects, 4, false],\n ['sdfClip', clips, 4, false],\n ['sdfColor', colors, 4, true],\n ['sdfMeta', metadata, meta, false],\n ['windfoilBounds', bounds, 4, false],\n ['windfoilBand', bands, 4, false],\n ] as const)\n geometry.setAttribute(name, new InstancedBufferAttribute(data, size, normalized))\n if (layers) {\n geometry.setAttribute('windfoilLayer', new InstancedBufferAttribute(layers, 4))\n geometry.userData[GLYPH_RECTS_KEY] = glyphRects\n geometry.userData['ultraOwnGlyphRects'] = glyphRects\n }\n geometry.instanceCount = count\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, result.minZ, result.maxZ)\n return { geometry, maxSequence: result.maxSequence }\n}\n\nexport function windfoilContentFits(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n): boolean {\n const layered =\n (geometry.getAttribute('windfoilLayer') as InstancedBufferAttribute | undefined) !== undefined\n const names = layered ? LAYERED_ATTRIBUTES : ATTRIBUTES\n for (const name of names) {\n if (\n (geometry.getAttribute(name) as InstancedBufferAttribute | undefined)?.count !==\n geometry.instanceCount\n )\n return false\n }\n if (\n (geometry.getAttribute('sdfMeta') as InstancedBufferAttribute).itemSize !== metaSize(snapshot)\n )\n return false\n let instances = 0,\n drawable = 0\n for (const glyph of snapshot.glyphs) {\n const header = glyphs.get(glyph.glyphKey)\n const layers = header?.layers?.length ?? 1\n if (!layered && (glyph.motionOrigin || layers > 1)) return false\n if (header?.monotonePieceCount) {\n drawable++\n instances += layered ? layers : 1\n }\n }\n return (\n instances === geometry.instanceCount &&\n (!layered ||\n (geometry.userData['ultraOwnGlyphRects'] as Float32Array | undefined)?.length ===\n drawable * 4)\n )\n}\n\nexport function updateWindfoilGlyphGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n motionPadding: number,\n ordinals?: Float32Array,\n): number | null {\n if (!windfoilContentFits(geometry, snapshot, glyphs)) return null\n const array = (name: string): Float32Array => geometry.getAttribute(name).array as Float32Array\n const layer = geometry.getAttribute('windfoilLayer') as InstancedBufferAttribute | undefined\n const result = writeGeometry(\n snapshot,\n glyphs,\n {\n rects: array('sdfRect'),\n clips: array('sdfClip'),\n colors: geometry.getAttribute('sdfColor').array as Uint8Array,\n metadata: array('sdfMeta'),\n metaSize: geometry.getAttribute('sdfMeta').itemSize,\n bounds: array('windfoilBounds'),\n bands: array('windfoilBand'),\n ...(layer\n ? {\n layers: layer.array as Float32Array,\n glyphRects: geometry.userData['ultraOwnGlyphRects'] as Float32Array,\n }\n : {}),\n },\n ordinals,\n )\n for (const name of layer ? LAYERED_ATTRIBUTES : ATTRIBUTES)\n (geometry.getAttribute(name) as InstancedBufferAttribute).needsUpdate = true\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, result.minZ, result.maxZ)\n return result.maxSequence\n}\n"],"mappings":";;;;AAMA,IAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;AACF;AACA,IAAM,qBAAqB,CAAC,GAAG,YAAY,eAAe;AAe1D,IAAM,cAAgD;CAAC;CAAG;CAAG;CAAG;AAAC;AAEjE,SAAgB,sBACd,OACA,QACA,OAA4B,OAAO,MACnC,MAAwC,aACN;CAClC,MAAM,QAAQ,MAAM,WAAW,OAAO;CACtC,MAAM,WAAW,MAAM,cAAc,MAAM,kBAAkB,CAAC,OAAO,UAAU;CAC/E,IAAI,KAAK,MAAM,UAAU,KAAK,KAAK;CACnC,IAAI,KAAK,WAAW,KAAK,KAAK;CAC9B,IAAI,KAAK,MAAM,UAAU,KAAK,KAAK;CACnC,IAAI,KAAK,WAAW,KAAK,KAAK;CAC9B,OAAO;AACT;AAEA,SAAgB,kBACd,OACA,QACA,OAA4B,OAAO,MACQ;CAC3C,OAAO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AAa,SAAS,CAAC,CAA8B,aAAa,SAAS,QAAQ,GAE7F,OAAO;CACT,IAAI,YAAY,GACd,WAAW;CACb,KAAK,MAAM,SAAS,SAAS,QAAQ;EACnC,MAAM,SAAS,OAAO,IAAI,MAAM,QAAQ;EACxC,MAAM,SAAS,QAAQ,QAAQ,UAAU;EACzC,IAAI,CAAC,YAAY,MAAM,gBAAgB,SAAS,IAAI,OAAO;EAC3D,IAAI,QAAQ,oBAAoB;GAC9B;GACA,aAAa,UAAU,SAAS;EAClC;CACF;CACA,OACE,cAAc,SAAS,kBACtB,CAAC,WACC,SAAS,SAAS,qBAAqB,EAA+B,WACrE,WAAW;AAEnB;AAEA,SAAgB,4BACd,UACA,UACA,QACA,eACA,UACe;CACf,IAAI,CAAC,oBAAoB,UAAU,UAAU,MAAM,GAAG,OAAO;CAC7D,MAAM,SAAS,SAA+B,SAAS,aAAa,IAAI,CAAC,CAAC;CAC1E,MAAM,QAAQ,SAAS,aAAa,eAAe;CACnD,MAAM,SAAS,cACb,UACA,QACA;EACE,OAAO,MAAM,SAAS;EACtB,OAAO,MAAM,SAAS;EACtB,QAAQ,SAAS,aAAa,UAAU,CAAC,CAAC;EAC1C,UAAU,MAAM,SAAS;EACzB,UAAU,SAAS,aAAa,SAAS,CAAC,CAAC;EAC3C,QAAQ,MAAM,gBAAgB;EAC9B,OAAO,MAAM,cAAc;EAC3B,GAAI,QACA;GACE,QAAQ,MAAM;GACd,YAAY,SAAS,SAAS;EAChC,IACA,CAAC;CACP,GACA,QACF;CACA,KAAK,MAAM,QAAQ,QAAQ,qBAAqB,YAC9C,SAAU,aAAa,IAAI,CAAC,CAA8B,cAAc;CAC1E,UAAU,UAAU,SAAS,OAAO,SAAS,QAAQ,eAAe,OAAO,MAAM,OAAO,IAAI;CAC5F,OAAO,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"geometry.js","names":[],"sources":["../../src/windfoil/geometry.ts"],"sourcesContent":["import { InstancedBufferAttribute, InstancedBufferGeometry } from 'three/webgpu'\nimport { byte, metaSize, setBounds, setUnitQuad, writeMeta } from '../text/geometryUtils.js'\nimport { GLYPH_RECTS_KEY } from '../text/decorations.js'\nimport type { DomLayoutSnapshot, GlyphLayout, WindfoilBoundingBox } from '../types.js'\nimport type { WindfoilGlyphHeader, WindfoilLayerHeader } from './preprocess.js'\n\nconst ATTRIBUTES = [\n 'sdfRect',\n 'sdfClip',\n 'sdfColor',\n 'sdfMeta',\n 'windfoilBounds',\n 'windfoilBand',\n] as const\nconst LAYERED_ATTRIBUTES = [...ATTRIBUTES, 'windfoilLayer'] as const\n\nconst SLOT_RECT = 0\nconst SLOT_CLIP = 1\nconst SLOT_COLOR = 2\nconst SLOT_META = 3\nconst SLOT_BOUNDS = 4\nconst SLOT_BAND = 5\nconst SLOT_LAYER = 6\nconst DIRTY_UNSET = 0x7fffffff\nconst dirtyBounds = new Int32Array(14)\n\nfunction resetDirtyBounds(): void {\n for (let slot = 0; slot < 7; slot++) {\n const base = slot * 2\n dirtyBounds[base] = DIRTY_UNSET\n dirtyBounds[base + 1] = 0\n }\n}\n\nfunction recordDirty(slot: number, start: number, end: number): void {\n const base = slot * 2\n if (start < dirtyBounds[base]!) dirtyBounds[base] = start\n if (end > dirtyBounds[base + 1]!) dirtyBounds[base + 1] = end\n}\n\nfunction flushAttributeUpdate(\n attribute: InstancedBufferAttribute,\n dirtyStart: number,\n dirtyEnd: number,\n): void {\n if (attribute.version === 0) {\n attribute.needsUpdate = true\n return\n }\n if (dirtyEnd <= dirtyStart) return\n let start = dirtyStart\n let end = dirtyEnd\n for (const range of attribute.updateRanges) {\n if (range.count < 0) {\n start = 0\n end = attribute.array.length\n break\n }\n if (range.start < start) start = range.start\n const rangeEnd = range.start + range.count\n if (rangeEnd > end) end = rangeEnd\n }\n attribute.clearUpdateRanges()\n attribute.addUpdateRange(start, end - start)\n attribute.needsUpdate = true\n}\n\nfunction writeFloat4(\n target: Float32Array,\n offset: number,\n a: number,\n b: number,\n c: number,\n d: number,\n trackDirty: boolean,\n slot: number,\n): void {\n if (trackDirty) {\n const fa = Math.fround(a)\n const fb = Math.fround(b)\n const fc = Math.fround(c)\n const fd = Math.fround(d)\n if (\n target[offset] === fa &&\n target[offset + 1] === fb &&\n target[offset + 2] === fc &&\n target[offset + 3] === fd\n ) {\n return\n }\n target[offset] = fa\n target[offset + 1] = fb\n target[offset + 2] = fc\n target[offset + 3] = fd\n recordDirty(slot, offset, offset + 4)\n return\n }\n target[offset] = a\n target[offset + 1] = b\n target[offset + 2] = c\n target[offset + 3] = d\n}\n\nexport interface MutableWindfoilAttributes {\n readonly rects: Float32Array\n readonly clips: Float32Array\n readonly colors: Uint8Array\n readonly metadata: Float32Array\n /** Components per `sdfMeta` entry; `3` carries the size-switch em. Defaults to `2`. */\n readonly metaSize?: number\n readonly bounds: Float32Array\n readonly bands: Float32Array\n readonly layers?: Float32Array\n readonly glyphRects?: Float32Array\n}\n\nconst scratchRect: [number, number, number, number] = [0, 0, 0, 0]\n\nexport function fillWindfoilGlyphRect(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n bbox: WindfoilBoundingBox = header.bbox,\n out: [number, number, number, number] = scratchRect,\n): [number, number, number, number] {\n const scale = glyph.fontSize / header.unitsPerEm\n const baseline = glyph.lineBottom + (glyph.baselineOffset ?? -header.descent * scale)\n out[0] = glyph.originX + bbox[0] * scale\n out[1] = baseline + bbox[1] * scale\n out[2] = glyph.originX + bbox[2] * scale\n out[3] = baseline + bbox[3] * scale\n return out\n}\n\nexport function windfoilGlyphRect(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n bbox: WindfoilBoundingBox = header.bbox,\n): readonly [number, number, number, number] {\n return fillWindfoilGlyphRect(glyph, header, bbox, [0, 0, 0, 0])\n}\n\nfunction writeInstance(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n layer: WindfoilGlyphHeader | WindfoilLayerHeader,\n index: number,\n ordinal: number,\n attributes: MutableWindfoilAttributes,\n c0: number,\n c1: number,\n c2: number,\n c3: number,\n glyphRect?: readonly [number, number, number, number],\n trackDirty = false,\n): void {\n const offset = index * 4\n const scale = glyph.fontSize / header.unitsPerEm\n const baseline = glyph.lineBottom + (glyph.baselineOffset ?? -header.descent * scale)\n const ox = glyph.originX\n const lBox = layer.bbox\n const b0 = lBox[0],\n b1 = lBox[1],\n b2 = lBox[2],\n b3 = lBox[3]\n writeFloat4(\n attributes.rects,\n offset,\n ox + b0 * scale,\n baseline + b1 * scale,\n ox + b2 * scale,\n baseline + b3 * scale,\n trackDirty,\n SLOT_RECT,\n )\n const clip = glyph.clip\n writeFloat4(attributes.clips, offset, clip[0], clip[1], clip[2], clip[3], trackDirty, SLOT_CLIP)\n const colors = attributes.colors\n if (trackDirty) {\n if (\n colors[offset] !== c0 ||\n colors[offset + 1] !== c1 ||\n colors[offset + 2] !== c2 ||\n colors[offset + 3] !== c3\n ) {\n colors[offset] = c0\n colors[offset + 1] = c1\n colors[offset + 2] = c2\n colors[offset + 3] = c3\n recordDirty(SLOT_COLOR, offset, offset + 4)\n }\n } else {\n colors[offset] = c0\n colors[offset + 1] = c1\n colors[offset + 2] = c2\n colors[offset + 3] = c3\n }\n const metaSizeValue = attributes.metaSize ?? 2\n const metadata = attributes.metadata\n if (trackDirty) {\n const mOffset = index * metaSizeValue\n const seq = Math.fround(glyph.sequence)\n const gz = Math.fround(glyph.z)\n const sw = metaSizeValue === 3 ? Math.fround(glyph.switchEm ?? 0) : 0\n if (\n metadata[mOffset] !== seq ||\n metadata[mOffset + 1] !== gz ||\n (metaSizeValue === 3 && metadata[mOffset + 2] !== sw)\n ) {\n writeMeta(metadata, index, metaSizeValue, glyph)\n recordDirty(SLOT_META, mOffset, mOffset + metaSizeValue)\n }\n } else {\n writeMeta(metadata, index, metaSizeValue, glyph)\n }\n writeFloat4(attributes.bounds, offset, b0, b1, b2, b3, trackDirty, SLOT_BOUNDS)\n writeFloat4(\n attributes.bands,\n offset,\n layer.rowBase,\n layer.bandCount,\n layer.bandH,\n layer.invH,\n trackDirty,\n SLOT_BAND,\n )\n const layers = attributes.layers\n if (layers) {\n const paint = 'paintKind' in layer ? layer : null\n const rect = glyphRect ?? fillWindfoilGlyphRect(glyph, header, header.bbox, scratchRect)\n const mo = glyph.motionOrigin\n writeFloat4(\n layers,\n offset,\n mo ? mo[0] : (rect[0] + rect[2]) / 2,\n mo ? mo[1] : (rect[1] + rect[3]) / 2,\n ordinal,\n paint?.paintKind === 2 ? 2 + (paint.paintIndex ?? 0) : (paint?.paintKind ?? 0),\n trackDirty,\n SLOT_LAYER,\n )\n }\n}\n\n/** Shared by text and shape geometry; one layer adds only one vertex attribute. */\nexport function writeLayerInstance(\n glyph: GlyphLayout,\n header: WindfoilGlyphHeader,\n layer: WindfoilGlyphHeader | WindfoilLayerHeader,\n index: number,\n ordinal: number,\n attributes: MutableWindfoilAttributes,\n glyphRect?: readonly [number, number, number, number],\n trackDirty = false,\n): void {\n const paint = 'paintKind' in layer ? layer : null\n const rgb = paint?.paintKind === 1 ? paint.rgba : glyph.color\n writeInstance(\n glyph,\n header,\n layer,\n index,\n ordinal,\n attributes,\n byte(rgb[0]),\n byte(rgb[1]),\n byte(rgb[2]),\n byte(glyph.color[3] * (paint ? paint.rgba[3] : 1)),\n glyphRect,\n trackDirty,\n )\n}\n\nfunction countLayout(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n layered: boolean,\n): { instances: number; drawable: number } {\n let instances = 0,\n drawable = 0\n for (const glyph of snapshot.glyphs) {\n const header = glyphs.get(glyph.glyphKey)\n if (header?.monotonePieceCount) {\n drawable++\n instances += layered ? (header.layers?.length ?? 1) : 1\n }\n }\n return { instances, drawable }\n}\n\nfunction writeGeometry(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n attributes: MutableWindfoilAttributes,\n ordinals?: Float32Array,\n trackDirty = false,\n): { instances: number; maxSequence: number; minZ: number; maxZ: number } {\n let instance = 0,\n drawable = 0,\n maxSequence = 0,\n minZ = 0,\n maxZ = 0\n let prevKey: string | undefined\n let prevHeader: WindfoilGlyphHeader | undefined\n let prevColor: GlyphLayout['color'] | undefined\n let pc0 = 0\n let pc1 = 0\n let pc2 = 0\n let pc3 = 0\n const glyphList = snapshot.glyphs\n for (let i = 0; i < glyphList.length; i++) {\n const glyph = glyphList[i]!\n const key = glyph.glyphKey\n const header = key === prevKey ? prevHeader : ((prevKey = key), (prevHeader = glyphs.get(key)))\n if (!header?.monotonePieceCount) continue\n const ordinal = ordinals?.[i] ?? glyph.motionOrigin?.[2] ?? drawable\n const rect =\n attributes.layers || attributes.glyphRects\n ? fillWindfoilGlyphRect(glyph, header, header.bbox, scratchRect)\n : undefined\n if (attributes.glyphRects && rect) {\n const rectOffset = drawable * 4\n attributes.glyphRects[rectOffset] = rect[0]\n attributes.glyphRects[rectOffset + 1] = rect[1]\n attributes.glyphRects[rectOffset + 2] = rect[2]\n attributes.glyphRects[rectOffset + 3] = rect[3]\n }\n if (attributes.layers && header.layers) {\n for (const layer of header.layers) {\n writeLayerInstance(glyph, header, layer, instance++, ordinal, attributes, rect, trackDirty)\n }\n } else {\n const layer = header.layers?.[0] ?? header\n const paint = 'paintKind' in layer ? layer : null\n if (paint) {\n const rgb = paint.paintKind === 1 ? paint.rgba : glyph.color\n writeInstance(\n glyph,\n header,\n layer,\n instance++,\n ordinal,\n attributes,\n byte(rgb[0]),\n byte(rgb[1]),\n byte(rgb[2]),\n byte(glyph.color[3] * paint.rgba[3]),\n rect,\n trackDirty,\n )\n } else {\n const color = glyph.color\n if (color !== prevColor) {\n prevColor = color\n pc0 = byte(color[0])\n pc1 = byte(color[1])\n pc2 = byte(color[2])\n pc3 = byte(color[3])\n }\n writeInstance(\n glyph,\n header,\n layer,\n instance++,\n ordinal,\n attributes,\n pc0,\n pc1,\n pc2,\n pc3,\n rect,\n trackDirty,\n )\n }\n }\n drawable++\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 { instances: instance, maxSequence, minZ, maxZ }\n}\n\n/** Ordinary outlines retain the original six instance attributes. */\nexport function createWindfoilGlyphGeometry(\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n motionPadding: number,\n layered = false,\n ordinals?: Float32Array,\n): { geometry: InstancedBufferGeometry; maxSequence: number } {\n layered ||= !!ordinals || snapshot.glyphs.some((glyph) => !!glyph.motionOrigin)\n const meta = metaSize(snapshot)\n let count: number\n let rects: Float32Array\n let clips: Float32Array\n let colors: Uint8Array\n let metadata: Float32Array\n let bounds: Float32Array\n let bands: Float32Array\n let layers: Float32Array | undefined\n let glyphRects: Float32Array | undefined\n if (layered) {\n const counted = countLayout(snapshot, glyphs, true)\n count = counted.instances\n rects = new Float32Array(count * 4)\n clips = new Float32Array(count * 4)\n colors = new Uint8Array(count * 4)\n metadata = new Float32Array(count * meta)\n bounds = new Float32Array(count * 4)\n bands = new Float32Array(count * 4)\n layers = new Float32Array(count * 4)\n glyphRects = new Float32Array(counted.drawable * 4)\n } else {\n const total = snapshot.glyphs.length\n count = total\n rects = new Float32Array(total * 4)\n clips = new Float32Array(total * 4)\n colors = new Uint8Array(total * 4)\n metadata = new Float32Array(total * meta)\n bounds = new Float32Array(total * 4)\n bands = new Float32Array(total * 4)\n }\n const result = writeGeometry(\n snapshot,\n glyphs,\n {\n rects,\n clips,\n colors,\n metadata,\n metaSize: meta,\n bounds,\n bands,\n ...(layers && glyphRects ? { layers, glyphRects } : {}),\n },\n ordinals,\n )\n if (!layered && result.instances < count) {\n count = result.instances\n rects = rects.subarray(0, count * 4)\n clips = clips.subarray(0, count * 4)\n colors = colors.subarray(0, count * 4)\n metadata = metadata.subarray(0, count * meta)\n bounds = bounds.subarray(0, count * 4)\n bands = bands.subarray(0, count * 4)\n }\n const geometry = new InstancedBufferGeometry()\n geometry.name = 'ultra-text instanced Windfoil glyph quads'\n setUnitQuad(geometry)\n for (const [name, data, size, normalized] of [\n ['sdfRect', rects, 4, false],\n ['sdfClip', clips, 4, false],\n ['sdfColor', colors, 4, true],\n ['sdfMeta', metadata, meta, false],\n ['windfoilBounds', bounds, 4, false],\n ['windfoilBand', bands, 4, false],\n ] as const)\n geometry.setAttribute(name, new InstancedBufferAttribute(data, size, normalized))\n if (layers) {\n geometry.setAttribute('windfoilLayer', new InstancedBufferAttribute(layers, 4))\n geometry.userData[GLYPH_RECTS_KEY] = glyphRects\n geometry.userData['ultraOwnGlyphRects'] = glyphRects\n }\n geometry.instanceCount = count\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, result.minZ, result.maxZ)\n return { geometry, maxSequence: result.maxSequence }\n}\n\nexport function windfoilContentFits(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n): boolean {\n const layered =\n (geometry.getAttribute('windfoilLayer') as InstancedBufferAttribute | undefined) !== undefined\n const names = layered ? LAYERED_ATTRIBUTES : ATTRIBUTES\n for (const name of names) {\n if (\n (geometry.getAttribute(name) as InstancedBufferAttribute | undefined)?.count !==\n geometry.instanceCount\n )\n return false\n }\n if (\n (geometry.getAttribute('sdfMeta') as InstancedBufferAttribute).itemSize !== metaSize(snapshot)\n )\n return false\n let instances = 0,\n drawable = 0\n for (const glyph of snapshot.glyphs) {\n const header = glyphs.get(glyph.glyphKey)\n const layers = header?.layers?.length ?? 1\n if (!layered && (glyph.motionOrigin || layers > 1)) return false\n if (header?.monotonePieceCount) {\n drawable++\n instances += layered ? layers : 1\n }\n }\n return (\n instances === geometry.instanceCount &&\n (!layered ||\n (geometry.userData['ultraOwnGlyphRects'] as Float32Array | undefined)?.length ===\n drawable * 4)\n )\n}\n\nexport function updateWindfoilGlyphGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n glyphs: ReadonlyMap<string, WindfoilGlyphHeader>,\n motionPadding: number,\n ordinals?: Float32Array,\n checked = false,\n): number | null {\n if (!checked && !windfoilContentFits(geometry, snapshot, glyphs)) return null\n const array = (name: string): Float32Array => geometry.getAttribute(name).array as Float32Array\n const layer = geometry.getAttribute('windfoilLayer') as InstancedBufferAttribute | undefined\n const trackDirty =\n (geometry.getAttribute('sdfRect') as InstancedBufferAttribute).version > 0 ||\n (geometry.getAttribute('sdfClip') as InstancedBufferAttribute).version > 0 ||\n (geometry.getAttribute('sdfColor') as InstancedBufferAttribute).version > 0 ||\n (geometry.getAttribute('sdfMeta') as InstancedBufferAttribute).version > 0 ||\n (geometry.getAttribute('windfoilBounds') as InstancedBufferAttribute).version > 0 ||\n (geometry.getAttribute('windfoilBand') as InstancedBufferAttribute).version > 0 ||\n (layer?.version ?? 0) > 0\n if (trackDirty) resetDirtyBounds()\n const result = writeGeometry(\n snapshot,\n glyphs,\n {\n rects: array('sdfRect'),\n clips: array('sdfClip'),\n colors: geometry.getAttribute('sdfColor').array as Uint8Array,\n metadata: array('sdfMeta'),\n metaSize: geometry.getAttribute('sdfMeta').itemSize,\n bounds: array('windfoilBounds'),\n bands: array('windfoilBand'),\n ...(layer\n ? {\n layers: layer.array as Float32Array,\n glyphRects: geometry.userData['ultraOwnGlyphRects'] as Float32Array,\n }\n : {}),\n },\n ordinals,\n trackDirty,\n )\n const list = layer ? LAYERED_ATTRIBUTES : ATTRIBUTES\n if (trackDirty) {\n for (let i = 0; i < list.length; i++) {\n const attribute = geometry.getAttribute(list[i]!) as InstancedBufferAttribute\n const base = i * 2\n flushAttributeUpdate(attribute, dirtyBounds[base]!, dirtyBounds[base + 1]!)\n }\n } else {\n for (const name of list)\n (geometry.getAttribute(name) as InstancedBufferAttribute).needsUpdate = true\n }\n setBounds(geometry, snapshot.width, snapshot.height, motionPadding, result.minZ, result.maxZ)\n return result.maxSequence\n}\n"],"mappings":";;;;AAMA,IAAM,aAAa;CACjB;CACA;CACA;CACA;CACA;CACA;AACF;AACA,IAAM,qBAAqB,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,MAAM;GACd,YAAY,SAAS,SAAS;EAChC,IACA,CAAC;CACP,GACA,UACA,UACF;CACA,MAAM,OAAO,QAAQ,qBAAqB;CAC1C,IAAI,YACF,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,YAAY,SAAS,aAAa,KAAK,EAAG;EAChD,MAAM,OAAO,IAAI;EACjB,qBAAqB,WAAW,YAAY,OAAQ,YAAY,OAAO,EAAG;CAC5E;MAEA,KAAK,MAAM,QAAQ,MACjB,SAAU,aAAa,IAAI,CAAC,CAA8B,cAAc;CAE5E,UAAU,UAAU,SAAS,OAAO,SAAS,QAAQ,eAAe,OAAO,MAAM,OAAO,IAAI;CAC5F,OAAO,OAAO;AAChB"}
|
package/dist/windfoil/mixed.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function createExtraTextParts(snapshot: DomLayoutSnapshot, backen
|
|
|
11
11
|
meshes: TextMesh[];
|
|
12
12
|
/** For animated parts; static ones are swapped whole (see DomSdf's bundle). */
|
|
13
13
|
setMotion(value: SdfMotionOptions): void;
|
|
14
|
+
fitsMotion(layout: DomLayoutSnapshot): boolean;
|
|
14
15
|
prepare(layout: DomLayoutSnapshot, padding: number): readonly (InstancedBufferGeometry | null)[];
|
|
15
16
|
commit(staged: readonly (InstancedBufferGeometry | null)[], layout: DomLayoutSnapshot, padding: number): void;
|
|
16
17
|
mergeRects(layout: DomLayoutSnapshot, primary: InstancedBufferGeometry): void;
|
package/dist/windfoil/mixed.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { isAnimatedMotion } from "../text/GlyphTextMaterial.js";
|
|
1
2
|
import { SdfTextMaterial } from "../text/SdfTextMaterial.js";
|
|
2
|
-
import { setBounds } from "../text/geometryUtils.js";
|
|
3
|
-
import { createGlyphGeometry, glyphContentFits, updateGlyphContent } from "../text/
|
|
3
|
+
import { needsRunMotion, setBounds } from "../text/geometryUtils.js";
|
|
4
|
+
import { createGlyphGeometry, glyphContentFits, updateGlyphContent } from "../text/glyphGeometry.js";
|
|
4
5
|
import { GLYPH_RECTS_KEY, glyphRectTable } from "../text/decorations.js";
|
|
5
6
|
import { windfoilGlyphRect } from "./geometry.js";
|
|
6
7
|
import { Mesh } from "three/webgpu";
|
|
@@ -11,8 +12,10 @@ import { Mesh } from "three/webgpu";
|
|
|
11
12
|
*/
|
|
12
13
|
function createExtraTextParts(snapshot, backend, options, motion, strength = (motion === false ? void 0 : motion.strength) ?? 18) {
|
|
13
14
|
const parts = [];
|
|
15
|
+
const hasMotion = isAnimatedMotion(motion);
|
|
16
|
+
const resolvedMotion = hasMotion ? motion : false;
|
|
14
17
|
const sequence = snapshot.glyphs.reduce((max, glyph) => Math.max(max, glyph.sequence), 0);
|
|
15
|
-
const add = (build, material, covers, fits, update, name, order, cast = true) => {
|
|
18
|
+
const add = (build, material, covers, fits, update, name, order, cast = true, fitsMotion = () => true) => {
|
|
16
19
|
const geometry = build(snapshot, strength);
|
|
17
20
|
let mesh;
|
|
18
21
|
try {
|
|
@@ -32,6 +35,7 @@ function createExtraTextParts(snapshot, backend, options, motion, strength = (mo
|
|
|
32
35
|
covers,
|
|
33
36
|
build,
|
|
34
37
|
fits: (layout) => fits(mesh.geometry, layout),
|
|
38
|
+
fitsMotion,
|
|
35
39
|
update: (layout, padding) => {
|
|
36
40
|
update(mesh.geometry, layout, padding);
|
|
37
41
|
}
|
|
@@ -41,34 +45,40 @@ function createExtraTextParts(snapshot, backend, options, motion, strength = (mo
|
|
|
41
45
|
const color = backend.color;
|
|
42
46
|
if (color) add((layout, padding) => color.createGeometry(layout, padding, backend.motionOrdinals(layout)).geometry, () => color.createMaterial({
|
|
43
47
|
...options,
|
|
44
|
-
motion,
|
|
48
|
+
motion: resolvedMotion,
|
|
45
49
|
maxSequence: sequence
|
|
46
50
|
}), (key) => !!color.glyphs.get(key)?.monotonePieceCount, (geometry, layout) => color.contentFits(geometry, layout), (geometry, layout, padding) => color.updateGeometry(geometry, layout, padding, backend.motionOrdinals(layout)), "ultra-text Windfoil colour glyphs", 2.25);
|
|
47
51
|
const atlas = backend.companion;
|
|
48
52
|
if (atlas) {
|
|
49
53
|
const sizeSwitch = backend.sizeSwitch;
|
|
50
54
|
const switched = (layout) => sizeSwitch?.layout(layout) ?? layout;
|
|
51
|
-
const addSdf = (subAtlas, matOpts, keepGlyph, name, order, layoutOf = switched, cast, bounds) =>
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
const addSdf = (subAtlas, matOpts, keepGlyph, name, order, layoutOf = switched, cast, bounds) => {
|
|
56
|
+
const partRunMotion = hasMotion || needsRunMotion(layoutOf(snapshot));
|
|
57
|
+
add((layout, padding) => {
|
|
58
|
+
const geometry = createGlyphGeometry(layoutOf(layout), subAtlas, padding, partRunMotion ? backend.motionOrdinals(layout) : void 0).geometry;
|
|
59
|
+
bounds?.(geometry, layout, padding);
|
|
60
|
+
return geometry;
|
|
61
|
+
}, () => new SdfTextMaterial({
|
|
62
|
+
...matOpts,
|
|
63
|
+
atlas: subAtlas.texture,
|
|
64
|
+
atlasWidth: subAtlas.width,
|
|
65
|
+
atlasHeight: subAtlas.height,
|
|
66
|
+
pxRange: subAtlas.pxRange,
|
|
67
|
+
bakeSize: subAtlas.bakeSize,
|
|
68
|
+
shapeTop: subAtlas.shapeTop,
|
|
69
|
+
motion: resolvedMotion,
|
|
70
|
+
runMotion: partRunMotion,
|
|
71
|
+
maxSequence: sequence,
|
|
72
|
+
...keepGlyph ? { keepGlyph } : {},
|
|
73
|
+
...subAtlas.colorLayer && (options.colorGlyphs !== "none" || snapshot.requests.some((request) => request.shape?.bitmap)) ? { colorLayer: subAtlas.colorLayer } : {}
|
|
74
|
+
}), (key) => subAtlas.glyphs.has(key), (geometry, layout) => {
|
|
75
|
+
const partLayout = layoutOf(layout);
|
|
76
|
+
return (partRunMotion || !needsRunMotion(partLayout)) && glyphContentFits(geometry, partLayout, subAtlas, partRunMotion ? backend.motionOrdinals(layout) : void 0);
|
|
77
|
+
}, (geometry, layout, padding) => {
|
|
78
|
+
updateGlyphContent(geometry, layoutOf(layout), subAtlas, padding, partRunMotion ? backend.motionOrdinals(layout) : void 0);
|
|
79
|
+
bounds?.(geometry, layout, padding);
|
|
80
|
+
}, name, order, cast, (layout) => partRunMotion || !needsRunMotion(layoutOf(layout)));
|
|
81
|
+
};
|
|
72
82
|
const effects = backend.effects;
|
|
73
83
|
if (effects) {
|
|
74
84
|
const anchors = /* @__PURE__ */ new WeakMap();
|
|
@@ -143,6 +153,9 @@ function createExtraTextParts(snapshot, backend, options, motion, strength = (mo
|
|
|
143
153
|
setMotion(value) {
|
|
144
154
|
for (const part of parts) part.mesh.material.setMotion(value);
|
|
145
155
|
},
|
|
156
|
+
fitsMotion(layout) {
|
|
157
|
+
return parts.every((part) => part.fitsMotion(layout));
|
|
158
|
+
},
|
|
146
159
|
prepare(layout, padding) {
|
|
147
160
|
const staged = [];
|
|
148
161
|
try {
|
|
@@ -166,6 +179,12 @@ function createExtraTextParts(snapshot, backend, options, motion, strength = (mo
|
|
|
166
179
|
});
|
|
167
180
|
},
|
|
168
181
|
mergeRects(layout, primary) {
|
|
182
|
+
if (parts.length === 0) {
|
|
183
|
+
const own = primary.userData["ultraOwnGlyphRects"];
|
|
184
|
+
if (own) primary.userData[GLYPH_RECTS_KEY] = own;
|
|
185
|
+
else Reflect.deleteProperty(primary.userData, GLYPH_RECTS_KEY);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
169
188
|
const sources = [primary.userData["ultraOwnGlyphRects"] ?? glyphRectTable(primary), ...parts.map((part) => glyphRectTable(part.mesh.geometry))];
|
|
170
189
|
const cursors = new Uint32Array(sources.length), result = new Float32Array(layout.glyphs.length * 4);
|
|
171
190
|
let target = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixed.js","names":[],"sources":["../../src/windfoil/mixed.ts"],"sourcesContent":["import { Mesh, type InstancedBufferGeometry } from 'three/webgpu'\nimport type { DomLayoutSnapshot, DomSdfOptions, SdfAtlas, SdfMotionOptions } from '../types.js'\nimport type { WindfoilBackend } from './runtime.js'\nimport type { GlyphTextMaterial, GlyphKeepHook } from '../text/GlyphTextMaterial.js'\nimport { createGlyphGeometry, glyphContentFits, updateGlyphContent } from '../text/geometry.js'\nimport { setBounds } from '../text/geometryUtils.js'\nimport { GLYPH_RECTS_KEY, glyphRectTable } from '../text/decorations.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport { windfoilGlyphRect } from './geometry.js'\n\ntype TextMesh = Mesh<InstancedBufferGeometry, GlyphTextMaterial>\ninterface Part {\n readonly mesh: TextMesh\n readonly covers: (key: string) => boolean\n readonly build: (snapshot: DomLayoutSnapshot, strength: number) => InstancedBufferGeometry\n readonly fits: (snapshot: DomLayoutSnapshot) => boolean\n readonly update: (snapshot: DomLayoutSnapshot, strength: number) => void\n}\n/**\n * Optional colour and SDF companions. Loaded only when a backend actually has extra parts.\n * `motion` false builds them static, like the primary; `strength` pads their bounds.\n */\nexport function createExtraTextParts(\n snapshot: DomLayoutSnapshot,\n backend: WindfoilBackend,\n options: DomSdfOptions,\n motion: SdfMotionOptions | false,\n strength = (motion === false ? undefined : motion.strength) ?? 18,\n) {\n const parts: Part[] = []\n const sequence = snapshot.glyphs.reduce((max, glyph) => Math.max(max, glyph.sequence), 0)\n const add = (\n build: Part['build'],\n material: () => GlyphTextMaterial,\n covers: Part['covers'],\n fits: (geometry: InstancedBufferGeometry, layout: DomLayoutSnapshot) => boolean,\n update: (\n geometry: InstancedBufferGeometry,\n layout: DomLayoutSnapshot,\n strength: number,\n ) => unknown,\n name: string,\n order: number,\n cast = true,\n ): void => {\n const geometry = build(snapshot, strength)\n let mesh: TextMesh\n try {\n mesh = new Mesh(geometry, material())\n } catch (error) {\n geometry.dispose()\n throw error\n }\n mesh.name = name\n mesh.renderOrder = order\n mesh.castShadow = cast && options.castShadow !== false\n mesh.frustumCulled = false\n mesh.matrixAutoUpdate = false\n mesh.updateMatrix()\n parts.push({\n mesh,\n covers,\n build,\n fits: (layout) => fits(mesh.geometry, layout),\n update: (layout, padding) => {\n update(mesh.geometry, layout, padding)\n },\n })\n }\n try {\n const color = backend.color\n if (color)\n add(\n (layout, padding) =>\n color.createGeometry(layout, padding, backend.motionOrdinals(layout)).geometry,\n () => color.createMaterial({ ...options, motion, maxSequence: sequence }),\n (key) => !!color.glyphs.get(key)?.monotonePieceCount,\n (geometry, layout) => color.contentFits(geometry, layout),\n (geometry, layout, padding) =>\n color.updateGeometry(geometry, layout, padding, backend.motionOrdinals(layout)),\n 'ultra-text Windfoil colour glyphs',\n 2.25,\n )\n const atlas = backend.companion\n if (atlas) {\n const sizeSwitch = backend.sizeSwitch\n // Size-switched glyphs share the primary's anchors and carry their switch em.\n const switched = (layout: DomLayoutSnapshot): DomLayoutSnapshot =>\n sizeSwitch?.layout(layout) ?? layout\n const addSdf = (\n subAtlas: SdfAtlas,\n matOpts: DomSdfOptions & { readonly underlay?: boolean },\n keepGlyph: GlyphKeepHook | undefined,\n name: string,\n order: number,\n layoutOf = switched,\n cast?: boolean,\n bounds?: (\n geometry: InstancedBufferGeometry,\n layout: DomLayoutSnapshot,\n padding: number,\n ) => void,\n ) =>\n add(\n (layout, padding) => {\n const geometry = createGlyphGeometry(\n layoutOf(layout),\n subAtlas,\n padding,\n backend.motionOrdinals(layout),\n ).geometry\n bounds?.(geometry, layout, padding)\n return geometry\n },\n () =>\n new SdfTextMaterial({\n ...matOpts,\n atlas: subAtlas.texture,\n atlasWidth: subAtlas.width,\n atlasHeight: subAtlas.height,\n pxRange: subAtlas.pxRange,\n bakeSize: subAtlas.bakeSize,\n shapeTop: subAtlas.shapeTop,\n motion,\n runMotion: true,\n maxSequence: sequence,\n ...(keepGlyph ? { keepGlyph } : {}),\n ...(subAtlas.colorLayer &&\n (options.colorGlyphs !== 'none' ||\n snapshot.requests.some((request) => request.shape?.bitmap))\n ? { colorLayer: subAtlas.colorLayer }\n : {}),\n }),\n (key) => subAtlas.glyphs.has(key),\n (geometry, layout) =>\n glyphContentFits(geometry, layoutOf(layout), subAtlas, backend.motionOrdinals(layout)),\n (geometry, layout, padding) => {\n updateGlyphContent(\n geometry,\n layoutOf(layout),\n subAtlas,\n padding,\n backend.motionOrdinals(layout),\n )\n bounds?.(geometry, layout, padding)\n },\n name,\n order,\n cast,\n )\n const effects = backend.effects\n if (effects) {\n // The underlay moves with the glyph it outlines: it scales about the primary's or the\n // colour part's anchor, with that part's ordinal, not about the centre of its SDF cell.\n const anchors = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n const anchored = (layout: DomLayoutSnapshot): DomLayoutSnapshot => {\n let result = anchors.get(layout)\n if (!result) {\n const base = switched(layout)\n const ordinals = backend.motionOrdinals(layout)\n result = {\n ...base,\n glyphs: base.glyphs.map((glyph, index) => {\n const composite = backend.color?.glyphs.get(glyph.glyphKey)\n const header = composite ?? backend.glyphs.get(glyph.glyphKey)\n if (glyph.motionOrigin || !header) return glyph\n const [x0, y0, x1, y1] = header.bbox\n const clip = composite?.clipBox\n const rect = windfoilGlyphRect(\n glyph,\n header,\n clip\n ? [\n Math.max(x0, clip[0]),\n Math.max(y0, clip[1]),\n Math.min(x1, clip[2]),\n Math.min(y1, clip[3]),\n ]\n : header.bbox,\n )\n return {\n ...glyph,\n motionOrigin: [\n (rect[0] + rect[2]) / 2,\n (rect[1] + rect[3]) / 2,\n ordinals[index]!,\n ],\n }\n }),\n }\n anchors.set(layout, result)\n }\n return result\n }\n // Glyphs that the primary or the colour part draws from outlines keep that exact fill,\n // over an underlay of their ring and shadow at the fill's render order. DomSdf makes it\n // before the fill, so that three draws it first at their shared depth while separate\n // texts still sort by depth. Glyphs without outlines, and size-switched ones while\n // small, stay whole SDF text, effects included.\n const { outline: _outline, dropShadow: _dropShadow, ...plain } = options\n const slots = [...atlas.glyphs]\n const underlaid = slots.filter(([key]) => backend.analyticCovers(key))\n const whole = slots.filter(([key]) => !backend.glyphs.has(key) || sizeSwitch?.keys.has(key))\n if (underlaid.length)\n addSdf(\n { ...atlas, glyphs: new Map(underlaid) },\n { ...plain, ...effects, underlay: true },\n sizeSwitch?.windfoil,\n 'ultra-text text effects',\n 2,\n anchored,\n // Shadow maps take the ring from the underlay, which casts its SDF fill with it so\n // that no crack opens along the ring's inner edge. A drop shadow alone adds nothing.\n !!effects.outline,\n // That shared depth is the projected centre of each geometry's bounding sphere, which\n // three compares before their age. The underlay also holds the colour part's glyphs,\n // which data-sdf-depth may lift or lower: it takes the text's bounds, those of the\n // glyphs the primary draws, so that the two always tie.\n (geometry, layout, padding) => {\n let minZ = 0,\n maxZ = 0\n for (const glyph of layout.glyphs)\n if (backend.primaryCovers(glyph.glyphKey)) {\n if (glyph.z < minZ) minZ = glyph.z\n if (glyph.z > maxZ) maxZ = glyph.z\n }\n setBounds(geometry, layout.width, layout.height, padding, minZ, maxZ)\n },\n )\n if (whole.length)\n addSdf(\n { ...atlas, glyphs: new Map(whole) },\n options,\n sizeSwitch?.sdf,\n 'ultra-text fallback glyphs',\n 2.5,\n )\n } else {\n addSdf(atlas, options, sizeSwitch?.sdf, 'ultra-text fallback glyphs', 2.5)\n }\n }\n } catch (error) {\n for (const part of parts) {\n part.mesh.geometry.dispose()\n part.mesh.material.dispose()\n }\n throw error\n }\n return {\n meshes: parts.map((part) => part.mesh),\n /** For animated parts; static ones are swapped whole (see DomSdf's bundle). */\n setMotion(value: SdfMotionOptions) {\n for (const part of parts) part.mesh.material.setMotion(value)\n },\n prepare(\n layout: DomLayoutSnapshot,\n padding: number,\n ): readonly (InstancedBufferGeometry | null)[] {\n const staged: (InstancedBufferGeometry | null)[] = []\n try {\n for (const part of parts)\n staged.push(part.fits(layout) ? null : part.build(layout, padding))\n return staged\n } catch (error) {\n for (const geometry of staged) geometry?.dispose()\n throw error\n }\n },\n commit(\n staged: readonly (InstancedBufferGeometry | null)[],\n layout: DomLayoutSnapshot,\n padding: number,\n ) {\n const max = layout.glyphs.reduce((value, glyph) => Math.max(value, glyph.sequence), 0)\n parts.forEach((part, index) => {\n const next = staged[index]\n if (next) {\n const old = part.mesh.geometry\n part.mesh.geometry = next\n old.dispose()\n } else part.update(layout, padding)\n part.mesh.material.maxSequence.value = max\n })\n },\n mergeRects(layout: DomLayoutSnapshot, primary: InstancedBufferGeometry) {\n const sources = [\n (primary.userData['ultraOwnGlyphRects'] as Float32Array | undefined) ??\n glyphRectTable(primary),\n ...parts.map((part) => glyphRectTable(part.mesh.geometry)),\n ]\n const cursors = new Uint32Array(sources.length),\n result = new Float32Array(layout.glyphs.length * 4)\n let target = 0\n for (const glyph of layout.glyphs) {\n // A size-switched glyph is held by the primary and the SDF companion: take the\n // primary's ink rect and advance every holder's row.\n let first = -1\n for (let source = 0; source < sources.length; source++) {\n const holds =\n source === 0\n ? backend.primaryCovers(glyph.glyphKey)\n : parts[source - 1]!.covers(glyph.glyphKey)\n if (!holds) continue\n const offset = cursors[source]!++ * 4\n if (first >= 0) continue\n first = source\n for (let c = 0; c < 4; c++) result[target + c] = sources[source]![offset + c]!\n }\n if (first >= 0) target += 4\n }\n primary.userData[GLYPH_RECTS_KEY] = result\n },\n }\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAgB,qBACd,UACA,SACA,SACA,QACA,YAAY,WAAW,QAAQ,KAAA,IAAY,OAAO,aAAa,IAC/D;CACA,MAAM,QAAgB,CAAC;CACvB,MAAM,WAAW,SAAS,OAAO,QAAQ,KAAK,UAAU,KAAK,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC;CACxF,MAAM,OACJ,OACA,UACA,QACA,MACA,QAKA,MACA,OACA,OAAO,SACE;EACT,MAAM,WAAW,MAAM,UAAU,Q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MAAM,SAAS,EAAE,CAAE,OAAO,MAAM,QAAQ,IAClC;KACZ,MAAM,SAAS,QAAQ,OAAO,KAAM;KACpC,IAAI,SAAS,GAAG;KAChB,QAAQ;KACR,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,OAAO,SAAS,KAAK,QAAQ,OAAO,CAAE,SAAS;IAC7E;IACA,IAAI,SAAS,GAAG,UAAU;GAC5B;GACA,QAAQ,SAAS,mBAAmB;EACtC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"mixed.js","names":[],"sources":["../../src/windfoil/mixed.ts"],"sourcesContent":["import { Mesh, type InstancedBufferGeometry } from 'three/webgpu'\nimport type { DomLayoutSnapshot, DomSdfOptions, SdfAtlas, SdfMotionOptions } from '../types.js'\nimport type { WindfoilBackend } from './runtime.js'\nimport type { GlyphTextMaterial, GlyphKeepHook } from '../text/GlyphTextMaterial.js'\nimport { isAnimatedMotion } from '../text/GlyphTextMaterial.js'\nimport {\n createGlyphGeometry,\n glyphContentFits,\n needsRunMotion,\n updateGlyphContent,\n} from '../text/geometry.js'\nimport { setBounds } from '../text/geometryUtils.js'\nimport { GLYPH_RECTS_KEY, glyphRectTable } from '../text/decorations.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport { windfoilGlyphRect } from './geometry.js'\n\ntype TextMesh = Mesh<InstancedBufferGeometry, GlyphTextMaterial>\ninterface Part {\n readonly mesh: TextMesh\n readonly covers: (key: string) => boolean\n readonly build: (snapshot: DomLayoutSnapshot, strength: number) => InstancedBufferGeometry\n readonly fits: (snapshot: DomLayoutSnapshot) => boolean\n readonly fitsMotion: (snapshot: DomLayoutSnapshot) => boolean\n readonly update: (snapshot: DomLayoutSnapshot, strength: number) => void\n}\n/**\n * Optional colour and SDF companions. Loaded only when a backend actually has extra parts.\n * `motion` false builds them static, like the primary; `strength` pads their bounds.\n */\nexport function createExtraTextParts(\n snapshot: DomLayoutSnapshot,\n backend: WindfoilBackend,\n options: DomSdfOptions,\n motion: SdfMotionOptions | false,\n strength = (motion === false ? undefined : motion.strength) ?? 18,\n) {\n const parts: Part[] = []\n const hasMotion = isAnimatedMotion(motion)\n const resolvedMotion = hasMotion ? motion : false\n const sequence = snapshot.glyphs.reduce((max, glyph) => Math.max(max, glyph.sequence), 0)\n const add = (\n build: Part['build'],\n material: () => GlyphTextMaterial,\n covers: Part['covers'],\n fits: (geometry: InstancedBufferGeometry, layout: DomLayoutSnapshot) => boolean,\n update: (\n geometry: InstancedBufferGeometry,\n layout: DomLayoutSnapshot,\n strength: number,\n ) => unknown,\n name: string,\n order: number,\n cast = true,\n fitsMotion: Part['fitsMotion'] = () => true,\n ): void => {\n const geometry = build(snapshot, strength)\n let mesh: TextMesh\n try {\n mesh = new Mesh(geometry, material())\n } catch (error) {\n geometry.dispose()\n throw error\n }\n mesh.name = name\n mesh.renderOrder = order\n mesh.castShadow = cast && options.castShadow !== false\n mesh.frustumCulled = false\n mesh.matrixAutoUpdate = false\n mesh.updateMatrix()\n parts.push({\n mesh,\n covers,\n build,\n fits: (layout) => fits(mesh.geometry, layout),\n fitsMotion,\n update: (layout, padding) => {\n update(mesh.geometry, layout, padding)\n },\n })\n }\n try {\n const color = backend.color\n if (color)\n add(\n (layout, padding) =>\n color.createGeometry(layout, padding, backend.motionOrdinals(layout)).geometry,\n () => color.createMaterial({ ...options, motion: resolvedMotion, maxSequence: sequence }),\n (key) => !!color.glyphs.get(key)?.monotonePieceCount,\n (geometry, layout) => color.contentFits(geometry, layout),\n (geometry, layout, padding) =>\n color.updateGeometry(geometry, layout, padding, backend.motionOrdinals(layout)),\n 'ultra-text Windfoil colour glyphs',\n 2.25,\n )\n const atlas = backend.companion\n if (atlas) {\n const sizeSwitch = backend.sizeSwitch\n // Size-switched glyphs share the primary's anchors and carry their switch em.\n const switched = (layout: DomLayoutSnapshot): DomLayoutSnapshot =>\n sizeSwitch?.layout(layout) ?? layout\n const addSdf = (\n subAtlas: SdfAtlas,\n matOpts: DomSdfOptions & { readonly underlay?: boolean },\n keepGlyph: GlyphKeepHook | undefined,\n name: string,\n order: number,\n layoutOf = switched,\n cast?: boolean,\n bounds?: (\n geometry: InstancedBufferGeometry,\n layout: DomLayoutSnapshot,\n padding: number,\n ) => void,\n ) => {\n const partRunMotion = hasMotion || needsRunMotion(layoutOf(snapshot))\n add(\n (layout, padding) => {\n const geometry = createGlyphGeometry(\n layoutOf(layout),\n subAtlas,\n padding,\n partRunMotion ? backend.motionOrdinals(layout) : undefined,\n ).geometry\n bounds?.(geometry, layout, padding)\n return geometry\n },\n () =>\n new SdfTextMaterial({\n ...matOpts,\n atlas: subAtlas.texture,\n atlasWidth: subAtlas.width,\n atlasHeight: subAtlas.height,\n pxRange: subAtlas.pxRange,\n bakeSize: subAtlas.bakeSize,\n shapeTop: subAtlas.shapeTop,\n motion: resolvedMotion,\n runMotion: partRunMotion,\n maxSequence: sequence,\n ...(keepGlyph ? { keepGlyph } : {}),\n ...(subAtlas.colorLayer &&\n (options.colorGlyphs !== 'none' ||\n snapshot.requests.some((request) => request.shape?.bitmap))\n ? { colorLayer: subAtlas.colorLayer }\n : {}),\n }),\n (key) => subAtlas.glyphs.has(key),\n (geometry, layout) => {\n const partLayout = layoutOf(layout)\n return (\n (partRunMotion || !needsRunMotion(partLayout)) &&\n glyphContentFits(\n geometry,\n partLayout,\n subAtlas,\n partRunMotion ? backend.motionOrdinals(layout) : undefined,\n )\n )\n },\n (geometry, layout, padding) => {\n updateGlyphContent(\n geometry,\n layoutOf(layout),\n subAtlas,\n padding,\n partRunMotion ? backend.motionOrdinals(layout) : undefined,\n )\n bounds?.(geometry, layout, padding)\n },\n name,\n order,\n cast,\n (layout) => partRunMotion || !needsRunMotion(layoutOf(layout)),\n )\n }\n const effects = backend.effects\n if (effects) {\n // The underlay moves with the glyph it outlines: it scales about the primary's or the\n // colour part's anchor, with that part's ordinal, not about the centre of its SDF cell.\n const anchors = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n const anchored = (layout: DomLayoutSnapshot): DomLayoutSnapshot => {\n let result = anchors.get(layout)\n if (!result) {\n const base = switched(layout)\n const ordinals = backend.motionOrdinals(layout)\n result = {\n ...base,\n glyphs: base.glyphs.map((glyph, index) => {\n const composite = backend.color?.glyphs.get(glyph.glyphKey)\n const header = composite ?? backend.glyphs.get(glyph.glyphKey)\n if (glyph.motionOrigin || !header) return glyph\n const [x0, y0, x1, y1] = header.bbox\n const clip = composite?.clipBox\n const rect = windfoilGlyphRect(\n glyph,\n header,\n clip\n ? [\n Math.max(x0, clip[0]),\n Math.max(y0, clip[1]),\n Math.min(x1, clip[2]),\n Math.min(y1, clip[3]),\n ]\n : header.bbox,\n )\n return {\n ...glyph,\n motionOrigin: [\n (rect[0] + rect[2]) / 2,\n (rect[1] + rect[3]) / 2,\n ordinals[index]!,\n ],\n }\n }),\n }\n anchors.set(layout, result)\n }\n return result\n }\n // Glyphs that the primary or the colour part draws from outlines keep that exact fill,\n // over an underlay of their ring and shadow at the fill's render order. DomSdf makes it\n // before the fill, so that three draws it first at their shared depth while separate\n // texts still sort by depth. Glyphs without outlines, and size-switched ones while\n // small, stay whole SDF text, effects included.\n const { outline: _outline, dropShadow: _dropShadow, ...plain } = options\n const slots = [...atlas.glyphs]\n const underlaid = slots.filter(([key]) => backend.analyticCovers(key))\n const whole = slots.filter(([key]) => !backend.glyphs.has(key) || sizeSwitch?.keys.has(key))\n if (underlaid.length)\n addSdf(\n { ...atlas, glyphs: new Map(underlaid) },\n { ...plain, ...effects, underlay: true },\n sizeSwitch?.windfoil,\n 'ultra-text text effects',\n 2,\n anchored,\n // Shadow maps take the ring from the underlay, which casts its SDF fill with it so\n // that no crack opens along the ring's inner edge. A drop shadow alone adds nothing.\n !!effects.outline,\n // That shared depth is the projected centre of each geometry's bounding sphere, which\n // three compares before their age. The underlay also holds the colour part's glyphs,\n // which data-sdf-depth may lift or lower: it takes the text's bounds, those of the\n // glyphs the primary draws, so that the two always tie.\n (geometry, layout, padding) => {\n let minZ = 0,\n maxZ = 0\n for (const glyph of layout.glyphs)\n if (backend.primaryCovers(glyph.glyphKey)) {\n if (glyph.z < minZ) minZ = glyph.z\n if (glyph.z > maxZ) maxZ = glyph.z\n }\n setBounds(geometry, layout.width, layout.height, padding, minZ, maxZ)\n },\n )\n if (whole.length)\n addSdf(\n { ...atlas, glyphs: new Map(whole) },\n options,\n sizeSwitch?.sdf,\n 'ultra-text fallback glyphs',\n 2.5,\n )\n } else {\n addSdf(atlas, options, sizeSwitch?.sdf, 'ultra-text fallback glyphs', 2.5)\n }\n }\n } catch (error) {\n for (const part of parts) {\n part.mesh.geometry.dispose()\n part.mesh.material.dispose()\n }\n throw error\n }\n return {\n meshes: parts.map((part) => part.mesh),\n /** For animated parts; static ones are swapped whole (see DomSdf's bundle). */\n setMotion(value: SdfMotionOptions) {\n for (const part of parts) part.mesh.material.setMotion(value)\n },\n fitsMotion(layout: DomLayoutSnapshot): boolean {\n return parts.every((part) => part.fitsMotion(layout))\n },\n prepare(\n layout: DomLayoutSnapshot,\n padding: number,\n ): readonly (InstancedBufferGeometry | null)[] {\n const staged: (InstancedBufferGeometry | null)[] = []\n try {\n for (const part of parts)\n staged.push(part.fits(layout) ? null : part.build(layout, padding))\n return staged\n } catch (error) {\n for (const geometry of staged) geometry?.dispose()\n throw error\n }\n },\n commit(\n staged: readonly (InstancedBufferGeometry | null)[],\n layout: DomLayoutSnapshot,\n padding: number,\n ) {\n const max = layout.glyphs.reduce((value, glyph) => Math.max(value, glyph.sequence), 0)\n parts.forEach((part, index) => {\n const next = staged[index]\n if (next) {\n const old = part.mesh.geometry\n part.mesh.geometry = next\n old.dispose()\n } else part.update(layout, padding)\n part.mesh.material.maxSequence.value = max\n })\n },\n mergeRects(layout: DomLayoutSnapshot, primary: InstancedBufferGeometry) {\n if (parts.length === 0) {\n const own = primary.userData['ultraOwnGlyphRects'] as Float32Array | undefined\n if (own) primary.userData[GLYPH_RECTS_KEY] = own\n else Reflect.deleteProperty(primary.userData, GLYPH_RECTS_KEY)\n return\n }\n const sources = [\n (primary.userData['ultraOwnGlyphRects'] as Float32Array | undefined) ??\n glyphRectTable(primary),\n ...parts.map((part) => glyphRectTable(part.mesh.geometry)),\n ]\n const cursors = new Uint32Array(sources.length),\n result = new Float32Array(layout.glyphs.length * 4)\n let target = 0\n for (const glyph of layout.glyphs) {\n // A size-switched glyph is held by the primary and the SDF companion: take the\n // primary's ink rect and advance every holder's row.\n let first = -1\n for (let source = 0; source < sources.length; source++) {\n const holds =\n source === 0\n ? backend.primaryCovers(glyph.glyphKey)\n : parts[source - 1]!.covers(glyph.glyphKey)\n if (!holds) continue\n const offset = cursors[source]!++ * 4\n if (first >= 0) continue\n first = source\n for (let c = 0; c < 4; c++) result[target + c] = sources[source]![offset + c]!\n }\n if (first >= 0) target += 4\n }\n primary.userData[GLYPH_RECTS_KEY] = result\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,qBACd,UACA,SACA,SACA,QACA,YAAY,WAAW,QAAQ,KAAA,IAAY,OAAO,aAAa,IAC/D;CACA,MAAM,QAAgB,CAAC;CACvB,MAAM,YAAY,iBAAiB,MAAM;CACzC,MAAM,iBAAiB,YAAY,SAAS;CAC5C,MAAM,WAAW,SAAS,OAAO,QAAQ,KAAK,UAAU,KAAK,IAAI,KAAK,MAAM,QAAQ,GAAG,CAAC;CACxF,MAAM,OACJ,OACA,UACA,QACA,MACA,QAKA,MACA,OACA,OAAO,MACP,mBAAuC,SAC9B;EACT,MAAM,WAAW,MAAM,UAAU,QAAQ;EACzC,IAAI;EACJ,IAAI;GACF,OAAO,IAAI,KAAK,UAAU,SAAS,CAAC;EACtC,SAAS,OAAO;GACd,SAAS,QAAQ;GACjB,MAAM;EACR;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;EACnB,KAAK,aAAa,QAAQ,QAAQ,eAAe;EACjD,KAAK,gBAAgB;EACrB,KAAK,mBAAmB;EACxB,KAAK,aAAa;EAClB,MAAM,KAAK;GACT;GACA;GACA;GACA,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ACpD,IAAI,SAAS;GACb,KAAK,MAAM,SAAS,OAAO,QAAQ;IAGjC,IAAI,QAAQ;IACZ,KAAK,IAAI,SAAS,GAAG,SAAS,QAAQ,QAAQ,UAAU;KAKtD,IAAI,EAHF,WAAW,IACP,QAAQ,cAAc,MAAM,QAAQ,IACpC,MAAM,SAAS,EAAE,CAAE,OAAO,MAAM,QAAQ,IAClC;KACZ,MAAM,SAAS,QAAQ,OAAO,KAAM;KACpC,IAAI,SAAS,GAAG;KAChB,QAAQ;KACR,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,OAAO,SAAS,KAAK,QAAQ,OAAO,CAAE,SAAS;IAC7E;IACA,IAAI,SAAS,GAAG,UAAU;GAC5B;GACA,QAAQ,SAAS,mBAAmB;EACtC;CACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readBox, readFiniteFloat32, readFlatCoordinates } from "./outlineValidation.js";
|
|
2
2
|
import { normalizeLayers } from "./layerNormalization.js";
|
|
3
|
-
import { preprocessWindfoilOutlines as preprocessWindfoilOutlines$1, validateWindfoilGlyphOutline as validateWindfoilGlyphOutline$1 } from "./preprocessCore.js";
|
|
3
|
+
import { preprocessWindfoilGlyphsBatch, preprocessWindfoilOutlines as preprocessWindfoilOutlines$1, validateWindfoilGlyphOutline as validateWindfoilGlyphOutline$1 } from "./preprocessCore.js";
|
|
4
4
|
// src/windfoil/preprocess.ts
|
|
5
5
|
function preprocessWindfoilOutlines(sources, options = {}) {
|
|
6
6
|
return preprocessWindfoilOutlines$1(sources, {
|
|
@@ -11,6 +11,6 @@ function preprocessWindfoilOutlines(sources, options = {}) {
|
|
|
11
11
|
function validateWindfoilGlyphOutline(outline) {
|
|
12
12
|
validateWindfoilGlyphOutline$1(outline, normalizeLayers);
|
|
13
13
|
}
|
|
14
|
-
export { preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, validateWindfoilGlyphOutline };
|
|
14
|
+
export { preprocessWindfoilGlyphsBatch, preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, validateWindfoilGlyphOutline };
|
|
15
15
|
|
|
16
16
|
//# sourceMappingURL=preprocess.js.map
|
|
@@ -19,6 +19,7 @@ export declare function splitQuadraticIntoMonotonePieces(quadratic: ArrayLike<nu
|
|
|
19
19
|
* Conflicting outlines under one key reject instead of making sharing order-dependent.
|
|
20
20
|
*/
|
|
21
21
|
export declare function preprocessWindfoilGlyphs(sources: readonly WindfoilGlyphSource[], options?: WindfoilPreprocessOptions): WindfoilPreprocessResult;
|
|
22
|
+
export declare function preprocessWindfoilGlyphsBatch(sources: readonly WindfoilGlyphSource[], options?: WindfoilPreprocessOptions, curveFloatOffset?: number, rowUintOffset?: number): WindfoilPreprocessResult;
|
|
22
23
|
/** Shared keyed-outline preprocessing for the shapes API. */
|
|
23
24
|
export declare function preprocessWindfoilOutlines(sources: readonly {
|
|
24
25
|
readonly key: string;
|