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.
- package/README.md +193 -115
- package/dist/assets/{cpuSdf.worker--X1Qpmdp.js → cpuSdf.worker-Dy4P5_TI.js} +98 -43
- package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
- package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
- package/dist/atlas/appendAtlas.js +35 -11
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +1 -1
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/colorGlyphs.d.ts +0 -10
- package/dist/atlas/colorGlyphs.js +97 -155
- package/dist/atlas/colorGlyphs.js.map +1 -1
- package/dist/atlas/colorTexture.d.ts +1 -0
- package/dist/atlas/colorTexture.js +64 -0
- package/dist/atlas/colorTexture.js.map +1 -0
- package/dist/atlas/cpuAtlas.js +8 -3
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.d.ts +1 -1
- package/dist/atlas/cpuSdf.js +97 -42
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +10 -4
- package/dist/atlas/cpuWorker.js +99 -49
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +133 -56
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +140 -18
- package/dist/atlas/gpuCommon.js +726 -104
- package/dist/atlas/gpuCommon.js.map +1 -1
- package/dist/atlas/jfaWgsl.d.ts +1 -1
- package/dist/atlas/jfaWgsl.js +232 -61
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.d.ts +22 -0
- package/dist/atlas/rasterize.js +237 -111
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/vanillaCore.js +156 -103
- package/dist/atlas/vanillaCore.js.map +1 -1
- package/dist/atlas/vanillaCpuAtlas.js +37 -52
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -1
- package/dist/atlas/vanillaExtras.js +91 -90
- package/dist/atlas/vanillaExtras.js.map +1 -1
- package/dist/atlas/vanillaGpuHelpers.d.ts +70 -7
- package/dist/atlas/vanillaGpuHelpers.js +262 -27
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -1
- package/dist/dom/DomSdf.js +85 -79
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +23 -18
- package/dist/dom/DomSlug.js.map +1 -1
- package/dist/dom/Text.d.ts +4 -1
- package/dist/dom/Text.js +5 -1
- package/dist/dom/Text.js.map +1 -1
- package/dist/dom/browserShaping.js +31 -14
- package/dist/dom/browserShaping.js.map +1 -1
- package/dist/dom/clusters.js +13 -2
- package/dist/dom/clusters.js.map +1 -1
- package/dist/dom/cssEffects.d.ts +4 -0
- package/dist/dom/cssEffects.js +72 -0
- package/dist/dom/cssEffects.js.map +1 -0
- package/dist/dom/domAnalytic.d.ts +1 -2
- package/dist/dom/domAnalytic.js +1 -1
- package/dist/dom/domAnalytic.js.map +1 -1
- package/dist/dom/fontCanvas.d.ts +16 -0
- package/dist/dom/fontCanvas.js +4 -4
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +28 -12
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/markup.d.ts +10 -0
- package/dist/dom/markup.js +16 -1
- package/dist/dom/markup.js.map +1 -1
- package/dist/dom/pretextLayout.js +27 -19
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.d.ts +4 -0
- package/dist/dom/snapshot.js +747 -505
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/snapshotsEqual.d.ts +7 -0
- package/dist/dom/snapshotsEqual.js +68 -0
- package/dist/dom/snapshotsEqual.js.map +1 -0
- package/dist/dom/svgCapture.js +30 -27
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/textTransform.d.ts +13 -1
- package/dist/dom/textTransform.js +31 -13
- package/dist/dom/textTransform.js.map +1 -1
- package/dist/dom/tone.js +15 -8
- package/dist/dom/tone.js.map +1 -1
- package/dist/slug/SlugMaterial.d.ts +6 -0
- package/dist/slug/SlugMaterial.js +48 -20
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/cff.d.ts +5 -0
- package/dist/slug/cff.js +780 -0
- package/dist/slug/cff.js.map +1 -0
- package/dist/slug/coverage.d.ts +3 -3
- package/dist/slug/coverage.js +283 -101
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +1 -1
- package/dist/slug/preprocessCore.js +100 -80
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.js +32 -39
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.js +47 -37
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.d.ts +14 -6
- package/dist/slug/truetype.js +190 -62
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +74 -4
- package/dist/slug/vanillaCore.js +226 -217
- package/dist/slug/vanillaCore.js.map +1 -1
- package/dist/slug-vanilla.d.ts +1 -1
- package/dist/slug-vanilla.js +5 -4
- package/dist/slug.d.ts +1 -1
- package/dist/slug.js +3 -3
- package/dist/text/GlyphTextMaterial.d.ts +5 -0
- package/dist/text/GlyphTextMaterial.js +11 -7
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/RectMaterial.js +6 -10
- package/dist/text/RectMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.d.ts +9 -3
- package/dist/text/SdfTextMaterial.js +122 -37
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.d.ts +7 -2
- package/dist/text/decorations.js +187 -96
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometryUtils.d.ts +5 -0
- package/dist/text/geometryUtils.js +63 -9
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +1 -1
- package/dist/text/glyphGeometry.js +281 -200
- package/dist/text/glyphGeometry.js.map +1 -1
- package/dist/text/rectGeometry.js +46 -42
- package/dist/text/rectGeometry.js.map +1 -1
- package/dist/text/reflow.d.ts +5 -0
- package/dist/text/reflow.js +127 -68
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +15 -1
- package/dist/text/snap.js +1 -1
- package/dist/text/snap.js.map +1 -1
- package/dist/text/tone.js +2 -2
- package/dist/text/tone.js.map +1 -1
- package/dist/types.d.ts +23 -7
- package/dist/vanilla.js +1 -1
- package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
- package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
- package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
- package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
- package/dist/windfoil/WindfoilMaterial.js +71 -8
- package/dist/windfoil/WindfoilMaterial.js.map +1 -1
- package/dist/windfoil/compositeGeometry.js +12 -5
- package/dist/windfoil/compositeGeometry.js.map +1 -1
- package/dist/windfoil/coverage.d.ts +10 -2
- package/dist/windfoil/coverage.js +147 -59
- package/dist/windfoil/coverage.js.map +1 -1
- package/dist/windfoil/geometry.d.ts +15 -0
- package/dist/windfoil/geometry.js +154 -64
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/layerGrid.js +8 -8
- package/dist/windfoil/layerGrid.js.map +1 -1
- package/dist/windfoil/mixed.js +13 -4
- 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 +63 -36
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/requests.d.ts +1 -1
- package/dist/windfoil/requests.js +11 -4
- package/dist/windfoil/requests.js.map +1 -1
- package/dist/windfoil/resolveOutline.d.ts +9 -0
- package/dist/windfoil/resolveOutline.js +20 -0
- package/dist/windfoil/resolveOutline.js.map +1 -0
- package/dist/windfoil/runtime.d.ts +1 -0
- package/dist/windfoil/runtime.js +8 -24
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/shapeGeometry.js +80 -34
- package/dist/windfoil/shapeGeometry.js.map +1 -1
- package/dist/windfoil/sizeSwitch.d.ts +1 -1
- package/dist/windfoil/sizeSwitch.js +13 -8
- package/dist/windfoil/sizeSwitch.js.map +1 -1
- package/dist/windfoil/storage.d.ts +23 -9
- package/dist/windfoil/storage.js +49 -30
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/svg/curves.d.ts +20 -0
- package/dist/windfoil/svg/curves.js +145 -42
- package/dist/windfoil/svg/curves.js.map +1 -1
- package/dist/windfoil/svg/document.js +10 -1
- package/dist/windfoil/svg/document.js.map +1 -1
- package/dist/windfoil/svg/pathConverter.js +66 -50
- package/dist/windfoil/svg/pathConverter.js.map +1 -1
- package/dist/windfoil/svg/pathData.d.ts +9 -0
- package/dist/windfoil/svg/pathData.js +142 -109
- package/dist/windfoil/svg/pathData.js.map +1 -1
- package/dist/windfoil/svg/winding.js +34 -10
- package/dist/windfoil/svg/winding.js.map +1 -1
- package/dist/windfoil/trace/contours.js +120 -50
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.js +578 -224
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
- package/dist/windfoil/trace/traceWorker.d.ts +13 -0
- package/dist/windfoil/trace/traceWorker.js +192 -0
- package/dist/windfoil/trace/traceWorker.js.map +1 -0
- package/dist/windfoil/tracedOutlines.d.ts +2 -0
- package/dist/windfoil/tracedOutlines.js +335 -70
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +48 -29
- package/skills/ultra-text/SKILL.md +9 -10
- package/skills/ultra-text/references/frameworks.md +46 -2
- package/skills/ultra-text/references/three-tsl.md +26 -24
- package/skills/ultra-text/references/vanilla-webgpu.md +3 -1
- package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +0 -1
package/dist/slug.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveDomTextTone, resolveTextTone } from "./dom/tone.js";
|
|
2
2
|
import { collectDomSnapshot } from "./dom/snapshot.js";
|
|
3
|
-
import { layoutSignatureOf } from "./dom/layoutSignature.js";
|
|
4
3
|
import { createRectMaterial } from "./text/RectMaterial.js";
|
|
5
4
|
import { createRectGeometry } from "./text/rectGeometry.js";
|
|
6
5
|
import { reflowSnapshot } from "./text/reflow.js";
|
|
7
6
|
import { windfoilOutlineFromSvgPaths } from "./windfoil/svg/pathConverter.js";
|
|
8
7
|
import { svgToWindfoilOutlines } from "./windfoil/svg/convert.js";
|
|
9
8
|
import { createSvgEmojiOutlineProvider } from "./windfoil/emoji.js";
|
|
9
|
+
import { layoutSignatureOf } from "./dom/layoutSignature.js";
|
|
10
10
|
import { createWindfoilGlyphGeometry, updateWindfoilGlyphGeometry, windfoilContentFits } from "./windfoil/geometry.js";
|
|
11
11
|
import { createSlugStorage } from "./windfoil/storage.js";
|
|
12
12
|
import { preprocessSlugGlyphs } from "./slug/preprocessCore.js";
|
|
@@ -14,6 +14,6 @@ import { SlugMaterial } from "./slug/SlugMaterial.js";
|
|
|
14
14
|
import { buildStandaloneSlugBackend } from "./slug/standaloneRuntime.js";
|
|
15
15
|
import { DomSlug } from "./dom/DomSlug.js";
|
|
16
16
|
import { SlugText } from "./dom/SlugText.js";
|
|
17
|
-
import { createTrueTypeOutlineProvider, parseTrueTypeFont } from "./slug/truetype.js";
|
|
17
|
+
import { createFontOutlineProvider, createTrueTypeOutlineProvider, parseFont, parseTrueTypeFont } from "./slug/truetype.js";
|
|
18
18
|
import { createTracedOutlineProvider } from "./windfoil/tracedOutlines.js";
|
|
19
|
-
export { DomSlug, DomSlug as DomText, SlugMaterial, SlugText, SlugText as Text, buildStandaloneSlugBackend, collectDomSnapshot, createRectGeometry, createRectMaterial, createWindfoilGlyphGeometry as createSlugGlyphGeometry, createSlugStorage, createSvgEmojiOutlineProvider, createTracedOutlineProvider, createTrueTypeOutlineProvider, layoutSignatureOf, parseTrueTypeFont, preprocessSlugGlyphs, reflowSnapshot, resolveDomTextTone, resolveTextTone, windfoilContentFits as slugContentFits, svgToWindfoilOutlines, updateWindfoilGlyphGeometry as updateSlugGlyphGeometry, windfoilOutlineFromSvgPaths };
|
|
19
|
+
export { DomSlug, DomSlug as DomText, SlugMaterial, SlugText, SlugText as Text, buildStandaloneSlugBackend, collectDomSnapshot, createFontOutlineProvider, createRectGeometry, createRectMaterial, createWindfoilGlyphGeometry as createSlugGlyphGeometry, createSlugStorage, createSvgEmojiOutlineProvider, createTracedOutlineProvider, createTrueTypeOutlineProvider, layoutSignatureOf, parseFont, parseTrueTypeFont, preprocessSlugGlyphs, reflowSnapshot, resolveDomTextTone, resolveTextTone, windfoilContentFits as slugContentFits, svgToWindfoilOutlines, updateWindfoilGlyphGeometry as updateSlugGlyphGeometry, windfoilOutlineFromSvgPaths };
|
|
@@ -38,6 +38,11 @@ export type GlyphMotionSource = Node<'float'> | {
|
|
|
38
38
|
export type GlyphVertexExtension = (quad: Node<'vec2'>, rect: Node<'vec4'>, position: Node<'vec2'>, depth: Node<'float'>, motionScale: Node<'float'>, fillUv: Node<'vec2'> | null) => Node<'vec2'> | void;
|
|
39
39
|
/** Per-glyph keep test for the size switch; see `GlyphTextMaterialOptions.keepGlyph`. */
|
|
40
40
|
export type GlyphKeepHook = (anchor: Node<'vec2'>, meta: Node<'vec3'>) => Node<'bool'>;
|
|
41
|
+
/** Fragment paint hook, evaluated before the caller's custom fill. */
|
|
42
|
+
export type GlyphPaintExtension = (cssColor: Node<'vec3'>) => {
|
|
43
|
+
readonly rgb: Node<'vec3'>;
|
|
44
|
+
readonly weight: Node<'float'>;
|
|
45
|
+
};
|
|
41
46
|
/** Convert normalized DOM sRGB attributes into Three's working colour space. */
|
|
42
47
|
export declare function srgbAttributeToWorking(node: Node<'vec3'>): Node<'vec3'>;
|
|
43
48
|
/** `beauty`, giving way to `shadow` in the pass three derives for a shadow map. */
|
|
@@ -32,7 +32,7 @@ var PassNode = class extends Node {
|
|
|
32
32
|
this.shadowNode = shadowNode;
|
|
33
33
|
}
|
|
34
34
|
generateNodeType(builder) {
|
|
35
|
-
return this.beautyNode.getNodeType(builder);
|
|
35
|
+
return (builder.material.isShadowPassMaterial ? this.shadowNode : this.beautyNode).getNodeType(builder);
|
|
36
36
|
}
|
|
37
37
|
setup(builder) {
|
|
38
38
|
return builder.material.isShadowPassMaterial ? this.shadowNode : this.beautyNode;
|
|
@@ -172,12 +172,12 @@ var GlyphTextMaterial = class extends MeshBasicNodeMaterial {
|
|
|
172
172
|
const fillIndex = options.fill ? varying((keepGlyph ? runMotion?.z ?? source?.index : source?.index) ?? float(instanceIndex), "vUltraFillIndex").setInterpolation("flat", "either") : null;
|
|
173
173
|
const motionCenter = () => (runMotion?.xy ?? source?.center ?? glyphRect.xy.add(glyphRect.zw).mul(.5)).toConst();
|
|
174
174
|
const basePositionOf = (quad) => glyphRect.xy.add(glyphRect.zw.sub(glyphRect.xy).mul(quad)).toConst();
|
|
175
|
-
const finishVertex = (quad, center, position, motionScale, glyphIndex) => {
|
|
175
|
+
const finishVertex = (quad, center, position, motionScale, glyphIndex, builder) => {
|
|
176
176
|
const uv = fillUv ?? (options.vertex ? vec2(quad).toVar() : null);
|
|
177
177
|
const extendedPosition = extendVertex?.(quad, glyphRect, position, glyphMeta.y, motionScale, uv) ?? position;
|
|
178
178
|
const keep = center && keepGlyph?.(center, glyphMeta);
|
|
179
179
|
const drawnPosition = keep ? vec2(keep.select(extendedPosition, center)).toConst() : extendedPosition;
|
|
180
|
-
localVarying.assign(drawnPosition);
|
|
180
|
+
if (!builder || this.needsLocalVarying(builder)) localVarying.assign(drawnPosition);
|
|
181
181
|
const localPosition = vec3(drawnPosition, glyphMeta.y);
|
|
182
182
|
if (!options.vertex) return localPosition;
|
|
183
183
|
const displaced = options.vertex({
|
|
@@ -191,13 +191,13 @@ var GlyphTextMaterial = class extends MeshBasicNodeMaterial {
|
|
|
191
191
|
});
|
|
192
192
|
return keep ? vec3(keep.select(displaced, vec3(center, glyphMeta.y))) : displaced;
|
|
193
193
|
};
|
|
194
|
-
const staticPosition = () => {
|
|
194
|
+
const staticPosition = (builder) => {
|
|
195
195
|
const quad = positionGeometry.xy;
|
|
196
196
|
fillUv?.assign(quad);
|
|
197
197
|
const center = keepGlyph || options.vertex ? motionCenter() : null;
|
|
198
|
-
return finishVertex(quad, center, basePositionOf(quad), float(1));
|
|
198
|
+
return finishVertex(quad, center, basePositionOf(quad), float(1), void 0, builder);
|
|
199
199
|
};
|
|
200
|
-
const animatedPosition = () => {
|
|
200
|
+
const animatedPosition = (builder) => {
|
|
201
201
|
const quad = positionGeometry.xy;
|
|
202
202
|
fillUv?.assign(quad);
|
|
203
203
|
const center = motionCenter();
|
|
@@ -242,7 +242,7 @@ var GlyphTextMaterial = class extends MeshBasicNodeMaterial {
|
|
|
242
242
|
const finalPosition = vec2(animationEnabled.select(animated, basePosition)).toConst();
|
|
243
243
|
const animatedAlpha = isOpacity.select(float(.25).add(pulse.mul(.75)), isAll.select(float(.55).add(pulse.mul(.45)), float(1)));
|
|
244
244
|
const motionScale = animationEnabled.select(scale, 1);
|
|
245
|
-
const drawnPosition = finishVertex(quad, center, finalPosition, motionScale, glyphIndex);
|
|
245
|
+
const drawnPosition = finishVertex(quad, center, finalPosition, motionScale, glyphIndex, builder);
|
|
246
246
|
this.#av.assign(animationEnabled.select(animatedAlpha, 1));
|
|
247
247
|
return drawnPosition;
|
|
248
248
|
};
|
|
@@ -262,6 +262,10 @@ var GlyphTextMaterial = class extends MeshBasicNodeMaterial {
|
|
|
262
262
|
this.#ic = outsideWireframe(localVarying.x.greaterThanEqual(clipVarying.x).and(localVarying.y.greaterThanEqual(clipVarying.y)).and(localVarying.x.lessThanEqual(clipVarying.z)).and(localVarying.y.lessThanEqual(clipVarying.w)), () => bool(true));
|
|
263
263
|
if (options.motion !== false) this.setMotion(options.motion ?? {});
|
|
264
264
|
}
|
|
265
|
+
/** @internal Whether the vertex stage needs to emit `vUltraTextLocal` for this build. */
|
|
266
|
+
needsLocalVarying(_builder) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
265
269
|
/** @internal The ink's alpha: the CSS colour's, times the motion's for animated text. */
|
|
266
270
|
inkAlpha() {
|
|
267
271
|
return this.animated ? this.colorVarying.a.mul(this.#av) : this.colorVarying.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlyphTextMaterial.js","names":[],"sources":["../../src/text/GlyphTextMaterial.ts"],"sourcesContent":["import {\n DoubleSide,\n FrontSide,\n Material,\n MeshBasicNodeMaterial,\n Node,\n SRGBColorSpace,\n type NodeBuilder,\n type Side,\n type UniformNode,\n} from 'three/webgpu'\nimport {\n Fn,\n attribute,\n bool,\n clamp,\n colorSpaceToWorking,\n cos,\n float,\n instanceIndex,\n int,\n luminance,\n max,\n min,\n mix,\n mod,\n positionGeometry,\n sin,\n time,\n uniform,\n varying,\n varyingProperty,\n vec2,\n vec3,\n vec4,\n} from 'three/tsl'\n\nimport type {\n SdfAnimationMode,\n SdfMotionOptions,\n TextFill,\n TextToneOptions,\n TextVertex,\n} from '../types.js'\nimport { resolveTextTone, TextTone, type ResolvedTextTone } from './tone.js'\n\n/** Shared construction options for the retained SDF and Windfoil text materials. */\nexport interface GlyphTextMaterialOptions {\n /** Match a snapshot captured with browser shaping; enables shared run motion. */\n textShaping?: 'none' | 'browser'\n /** Share motion centres and ordinals supplied by geometry. */\n runMotion?: boolean\n /** Custom linear-color TSL fill; opacity is multiplied by glyph coverage and DOM opacity. */\n fill?: TextFill | undefined\n /** Custom TSL vertex position in capture-local coordinates. */\n vertex?: TextVertex | undefined\n /** Face culling side. Defaults to `FrontSide`. */\n side?: Side | undefined\n /**\n * Initial motion state; adjustable later through `setMotion()`. `false` builds static text:\n * the vertex stage has no motion graph (no clock, waves or slide timeline) and the fragment\n * no motion alpha, `animated` is false, and `setMotion()` throws. Draws like motion with\n * mode `'none'`.\n */\n motion?: SdfMotionOptions | false\n /** Largest per-line stagger index in the geometry. Defaults to `0`. */\n maxSequence?: number\n /**\n * Shows text ink at the weight a browser gives it; see `TextToneOptions`. There is no\n * source element here: an `'auto'` model is the exact outline, and an `'auto'` backdrop is\n * unknown, which tones dark ink against white and keeps light ink at its exact coverage\n * whatever the model. Name the `backdrop` colour the scene shows behind the text for the\n * full conversion. `false` leaves the conversion out of the shader graph. Defaults to on.\n */\n tone?: TextToneOptions | ResolvedTextTone | false\n /**\n * @internal Size switch. Decides from per-instance data and per-pass uniforms only, so a\n * quad's four vertices agree; `false` collapses the quad onto its motion anchor, which\n * rasterizes nothing in beauty or shadow passes. Requires `sdfMeta` as\n * (sequence, depth, switch em).\n */\n keepGlyph?: GlyphKeepHook\n}\n\nexport type GlyphMotionSource =\n Node<'float'> | { readonly index: Node<'float'>; readonly center: Node<'vec2'> }\n\nexport type GlyphVertexExtension = (\n quad: Node<'vec2'>,\n rect: Node<'vec4'>,\n position: Node<'vec2'>,\n depth: Node<'float'>,\n motionScale: Node<'float'>,\n fillUv: Node<'vec2'> | null,\n // A coverage backend may only attach varyings and intentionally return nothing.\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n) => Node<'vec2'> | void\n\n/** Per-glyph keep test for the size switch; see `GlyphTextMaterialOptions.keepGlyph`. */\nexport type GlyphKeepHook = (anchor: Node<'vec2'>, meta: Node<'vec3'>) => Node<'bool'>\n\n/** @internal Fragment paint hook, evaluated before the caller's custom fill. */\nexport type GlyphPaintExtension = (cssColor: Node<'vec3'>) => {\n readonly rgb: Node<'vec3'>\n readonly weight: Node<'float'>\n}\n\nconst MODE_CODES: Readonly<Record<SdfAnimationMode, number>> = Object.freeze({\n none: 0,\n opacity: 1,\n scale: 2,\n offset: 3,\n 'slide-up': 4,\n 'slide-down': 5,\n 'slide-left': 6,\n 'slide-right': 7,\n all: 8,\n})\n\n/** @internal Whether this motion state needs the motion graph: any mode but `'none'`. */\nexport function isAnimatedMotion(motion: SdfMotionOptions | false | undefined): boolean {\n return motion !== false && motion?.mode !== 'none'\n}\n\n/** Convert normalized DOM sRGB attributes into Three's working colour space. */\nexport function srgbAttributeToWorking(node: Node<'vec3'>): Node<'vec3'> {\n // ColorSpaceNode reports vec4 in r185, so truncate with a real conversion.\n return vec3(colorSpaceToWorking(node, SRGBColorSpace) as unknown as Node<'vec3'>)\n}\n\nclass PassNode extends Node {\n static readonly type: string = 'UltraTextPassNode'\n\n constructor(\n readonly beautyNode: Node,\n readonly shadowNode: Node,\n ) {\n super()\n }\n\n // generateNodeType, not getNodeType: three caches the result per builder.\n override generateNodeType(builder: NodeBuilder): string {\n return this.beautyNode.getNodeType(builder)\n }\n\n override setup(builder: NodeBuilder): Node {\n return (builder.material as { isShadowPassMaterial?: boolean }).isShadowPassMaterial\n ? this.shadowNode\n : this.beautyNode\n }\n}\n\n/** `beauty`, giving way to `shadow` in the pass three derives for a shadow map. */\nexport function outsideShadowPass<T extends Node>(beauty: T, shadow: T): T {\n return new PassNode(beauty, shadow) as Node as T\n}\n\nclass WireframeNode extends Node {\n static readonly type = 'UltraTextWireframeNode'\n readonly #s: Node\n readonly #ml: () => Node\n #l: Node | null = null\n\n constructor(solid: Node, makeLines: () => Node) {\n super()\n this.#s = solid\n this.#ml = makeLines\n }\n\n override generateNodeType(builder: NodeBuilder): string {\n return this.#s.getNodeType(builder)\n }\n\n override setup(builder: NodeBuilder): Node {\n const m = builder.material as { wireframe?: boolean; isShadowPassMaterial?: boolean }\n return m.wireframe === true && !m.isShadowPassMaterial ? (this.#l ??= this.#ml()) : this.#s\n }\n\n override getChildren(): Node[] {\n return this.#l ? [this.#s, this.#l] : [this.#s]\n }\n}\n\nconst WIREFRAME_LINE_LUMINANCE = 0.4\n\n/** `solid`, giving way to `lines` when the material draws wireframe. */\nfunction outsideWireframe<T extends Node>(solid: T, makeLines: () => T): T {\n return new WireframeNode(solid, makeLines) as Node as T\n}\n\n/**\n * Shared retained-glyph vertex, motion, clipping, colour, and shadow plumbing.\n *\n * The two text backends differ only in how they produce coverage. Keeping the\n * rest in one graph makes switching backend preserve layout and animation\n * semantics, and avoids shipping the motion graph twice.\n */\nexport class GlyphTextMaterial extends MeshBasicNodeMaterial {\n /** Uniforms of the tone conversion; null when the material was built with `tone: false`. */\n readonly tone: TextTone | null\n /**\n * False for static text, built with `motion: false`: its shader has no motion graph, its\n * motion uniforms read as disabled, and `setMotion()` throws.\n */\n readonly animated: boolean\n\n #me: UniformNode<'float', number> | null\n #mm: UniformNode<'int', number> | null\n #mstr: UniformNode<'float', number> | null\n #mspd: UniformNode<'float', number> | null\n #mstg: UniformNode<'float', number> | null\n readonly #maxSeq: UniformNode<'float', number> = uniform(0)\n readonly #cv: Node<'vec4'>\n readonly #ic: Node<'bool'>\n readonly #fn: Node<'vec4'> | null\n readonly #bc: Node<'vec3'>\n readonly #cw: Node<'float'>\n #av = varyingProperty('float', 'vUltraTextMotionAlpha')\n #gt: Node<'vec3'> | null\n #rm: (motion?: SdfMotionOptions) => this\n\n get motionEnabled(): UniformNode<'float', number> {\n return (this.#me ??= uniform(0))\n }\n get motionMode(): UniformNode<'int', number> {\n return (this.#mm ??= uniform(MODE_CODES.none, 'int'))\n }\n get motionStrength(): UniformNode<'float', number> {\n return (this.#mstr ??= uniform(18))\n }\n get motionSpeed(): UniformNode<'float', number> {\n return (this.#mspd ??= uniform(1.35))\n }\n get motionStagger(): UniformNode<'float', number> {\n return (this.#mstg ??= uniform(0.045))\n }\n get maxSequence(): UniformNode<'float', number> {\n return this.#maxSeq\n }\n protected get colorVarying() {\n return this.#cv\n }\n protected get insideClip(): Node<'bool'> {\n return this.#ic\n }\n protected get fillNode(): Node<'vec4'> | null {\n return this.#fn\n }\n protected get baseColor(): Node<'vec3'> {\n return this.#bc\n }\n protected get colorWeight(): Node<'float'> {\n return this.#cw\n }\n\n constructor(\n options: GlyphTextMaterialOptions,\n extendVertex?: GlyphVertexExtension,\n motionIndex?: GlyphMotionSource,\n paint?: GlyphPaintExtension,\n ) {\n super()\n this.#rm = (motion) =>\n new (\n this.constructor as new (\n remakeOptions: GlyphTextMaterialOptions,\n remakeExtension?: GlyphVertexExtension,\n remakeIndex?: GlyphMotionSource,\n remakePaint?: GlyphPaintExtension,\n ) => this\n )(motion ? { ...options, motion } : options, extendVertex, motionIndex, paint)\n const animated = (this.animated = options.motion !== false)\n if (animated) {\n this.#me = uniform(1)\n this.#mm = uniform(MODE_CODES['slide-up'], 'int')\n this.#mstr = uniform(18)\n this.#mspd = uniform(1.35)\n this.#mstg = uniform(0.045)\n } else {\n this.#me = this.#mm = this.#mstr = this.#mspd = this.#mstg = null\n }\n this.lights = false\n this.transparent = true\n this.depthWrite = false\n this.depthTest = true\n this.side = options.side ?? FrontSide\n this.shadowSide = this.side\n this.forceSinglePass = this.side === DoubleSide\n this.toneMapped = false\n this.maxSequence.value = options.maxSequence ?? 0\n const tone = resolveTextTone(options.tone)\n this.tone = tone && new TextTone(tone)\n\n const localVarying = varyingProperty('vec2', 'vUltraTextLocal')\n const glyphRect = attribute<'vec4'>('sdfRect', 'vec4')\n const glyphClip = attribute<'vec4'>('sdfClip', 'vec4')\n const glyphColor = attribute<'vec4'>('sdfColor', 'vec4')\n const workingColor = srgbAttributeToWorking(vec3(glyphColor.rgb)).toConst()\n const clipVarying = varying(glyphClip, 'vUltraTextClip').setInterpolation('flat', 'either')\n this.#cv = varying(vec4(workingColor, glyphColor.a), 'vUltraTextColor').setInterpolation(\n 'flat',\n 'either',\n )\n this.#gt =\n this.tone &&\n varying(this.tone.inkTerms(workingColor), 'vUltraTextTone').setInterpolation('flat', 'either')\n // Sequence and depth are the only per-glyph metadata. The compacted draw's\n // global index is already supplied by the GPU, including after blank glyphs.\n const keepGlyph = options.keepGlyph\n const glyphMeta = keepGlyph\n ? attribute<'vec3'>('sdfMeta', 'vec3')\n : attribute<'vec2'>('sdfMeta', 'vec2')\n const runMotion =\n (options.runMotion ?? options.textShaping === 'browser')\n ? attribute<'vec3'>('sdfRunMotion', 'vec3')\n : null\n const source = motionIndex && 'index' in motionIndex ? motionIndex : null\n const indexSource = source?.index ?? (motionIndex as Node<'float'> | undefined)\n const fillUv = options.fill ? varyingProperty('vec2', 'vUltraFillUv') : null\n // Switched batches share global ordinals, so glyphIndex stays continuous across a switch.\n // Fills truncate it to read per-glyph data. Interpolated, an instance's constant can arrive\n // a hair under itself (Safari's relaxed math on Apple GPUs) and read the previous glyph's\n // entry: flat keeps it exact.\n const fillIndex = options.fill\n ? varying(\n (keepGlyph ? (runMotion?.z ?? source?.index) : source?.index) ?? float(instanceIndex),\n 'vUltraFillIndex',\n ).setInterpolation('flat', 'either')\n : null\n\n // The anchor motion scales about, and the size switch's anchor.\n const motionCenter = (): Node<'vec2'> =>\n (runMotion?.xy ?? source?.center ?? glyphRect.xy.add(glyphRect.zw).mul(0.5)).toConst()\n const basePositionOf = (quad: Node<'vec2'>): Node<'vec2'> =>\n glyphRect.xy.add(glyphRect.zw.sub(glyphRect.xy).mul(quad)).toConst()\n // What both graphs do with the moved position: the backend's extension, the size switch\n // and the shared varyings. Returns the drawn position.\n const finishVertex = (\n quad: Node<'vec2'>,\n center: Node<'vec2'> | null,\n position: Node<'vec2'>,\n motionScale: Node<'float'>,\n glyphIndex?: Node<'float'>,\n ): Node<'vec3'> => {\n const uv = fillUv ?? (options.vertex ? vec2(quad).toVar() : null)\n const extendedPosition =\n extendVertex?.(quad, glyphRect, position, glyphMeta.y, motionScale, uv) ?? position\n // The un-animated anchor and the unscaled em decide, so motion never moves a glyph\n // between the two batches of a size switch.\n const keep = center && keepGlyph?.(center, glyphMeta as unknown as Node<'vec3'>)\n const drawnPosition = keep\n ? vec2(keep.select(extendedPosition, center)).toConst()\n : extendedPosition\n localVarying.assign(drawnPosition)\n const localPosition = vec3(drawnPosition, glyphMeta.y)\n if (!options.vertex) return localPosition\n const displaced = options.vertex({\n position: localPosition,\n center: center!,\n uv: uv!,\n glyphIndex: glyphIndex ?? (runMotion?.z ?? indexSource ?? float(instanceIndex)).toConst(),\n sequence: glyphMeta.x,\n rect: glyphRect,\n clip: glyphClip,\n })\n return keep ? vec3(keep.select(displaced, vec3(center, glyphMeta.y))) : displaced\n }\n\n // Static text: the motion graph's disabled branch alone, without its clock, waves and\n // slide timeline. Only the size switch or a custom vertex hook reads the anchor.\n const staticPosition = (): Node<'vec3'> => {\n const quad = positionGeometry.xy\n fillUv?.assign(quad)\n const center = keepGlyph || options.vertex ? motionCenter() : null\n return finishVertex(quad, center, basePositionOf(quad), float(1))\n }\n // Reused expressions need shader locals as well as shared JavaScript nodes;\n // otherwise the motion/clip expressions expand repeatedly in generated WGSL.\n // Immutable intermediates use toConst(); only the accumulated position mutates.\n const animatedPosition = (): Node<'vec3'> => {\n const quad = positionGeometry.xy\n fillUv?.assign(quad)\n const center = motionCenter()\n const basePosition = basePositionOf(quad)\n const sequence = glyphMeta.x\n const glyphIndex = (runMotion?.z ?? indexSource ?? float(instanceIndex)).toConst()\n const clock = time.mul(this.motionSpeed).toConst()\n const wave = sin(\n clock.mul(Math.PI * 2).sub(glyphIndex.mul(this.motionStagger).mul(Math.PI * 2)),\n )\n const pulse = wave.mul(0.5).add(0.5).toConst()\n\n const mode = (code: number) => int(this.motionMode).equal(code)\n const isOpacity = mode(MODE_CODES.opacity)\n const isScale = mode(MODE_CODES.scale)\n const isOffset = mode(MODE_CODES.offset)\n const isSlideUp = mode(MODE_CODES['slide-up'])\n const isSlideDown = mode(MODE_CODES['slide-down'])\n const isSlideLeft = mode(MODE_CODES['slide-left'])\n const isSlideRight = mode(MODE_CODES['slide-right'])\n const isAll = mode(MODE_CODES.all).toConst()\n\n const scale = isScale\n .select(\n float(0.86).add(pulse.mul(0.22)),\n isAll.select(float(0.94).add(pulse.mul(0.08)), float(1)),\n )\n .toConst()\n const animated = vec2(center.add(basePosition.sub(center).mul(scale))).toVar()\n const offsetX = sin(clock.mul(3.1).add(glyphIndex.mul(0.55)))\n .mul(this.motionStrength)\n .mul(0.32)\n const offsetY = cos(clock.mul(2.7).add(glyphIndex.mul(0.45)))\n .mul(this.motionStrength)\n .mul(0.18)\n animated.x.addAssign(isOffset.select(offsetX, 0))\n animated.y.addAssign(\n isOffset.select(\n offsetY,\n isAll.select(\n sin(clock.mul(2.5).add(glyphIndex.mul(0.35)))\n .mul(this.motionStrength)\n .mul(0.16),\n 0,\n ),\n ),\n )\n\n const enterDuration = 0.58\n const holdDuration = 1.15\n const exitDuration = 0.24\n const sequenceSpan = this.maxSequence.mul(this.motionStagger).toConst()\n const cycle = max(\n sequenceSpan.add(enterDuration + holdDuration + exitDuration),\n 0.001,\n ).toConst()\n const slidePhase = mod(clock, cycle).toConst()\n const localPhase = slidePhase.sub(sequence.mul(this.motionStagger)).toConst()\n const enterT = clamp(localPhase.div(enterDuration), 0, 1)\n const inverseEnter = float(1).sub(enterT).toConst()\n const easeOut = float(1).sub(inverseEnter.mul(inverseEnter).mul(inverseEnter))\n const exitStart = sequenceSpan.add(enterDuration + holdDuration).toConst()\n const exitT = clamp(slidePhase.sub(exitStart).div(exitDuration), 0, 1).toConst()\n const travelRatio = localPhase\n .lessThan(0)\n .select(\n float(1),\n localPhase\n .lessThan(enterDuration)\n .select(\n float(1).sub(easeOut),\n slidePhase.lessThan(exitStart).select(float(0), exitT.mul(exitT).mul(exitT).negate()),\n ),\n )\n .toConst()\n const clipSize = glyphClip.zw.sub(glyphClip.xy).toConst()\n const verticalTravel = max(this.motionStrength, clipSize.y.mul(1.18))\n .mul(travelRatio)\n .toConst()\n const horizontalTravel = max(this.motionStrength, clipSize.x.mul(1.18))\n .mul(travelRatio)\n .toConst()\n animated.x.addAssign(\n isSlideLeft.select(horizontalTravel, isSlideRight.select(horizontalTravel.negate(), 0)),\n )\n animated.y.addAssign(\n isSlideUp.select(verticalTravel.negate(), isSlideDown.select(verticalTravel, 0)),\n )\n\n const animationEnabled = this.motionEnabled\n .greaterThan(0.5)\n .and(int(this.motionMode).notEqual(MODE_CODES.none))\n .toConst()\n const finalPosition = vec2(animationEnabled.select(animated, basePosition)).toConst()\n const animatedAlpha = isOpacity.select(\n float(0.25).add(pulse.mul(0.75)),\n isAll.select(float(0.55).add(pulse.mul(0.45)), float(1)),\n )\n\n const motionScale = animationEnabled.select(scale, 1)\n const drawnPosition = finishVertex(quad, center, finalPosition, motionScale, glyphIndex)\n this.#av.assign(animationEnabled.select(animatedAlpha, 1))\n return drawnPosition\n }\n const positionNode = Fn<Node<'vec3'>>(animated ? animatedPosition : staticPosition)()\n this.positionNode = positionNode\n this.castShadowPositionNode = positionNode\n const painted = paint?.(this.colorVarying.rgb)\n this.#bc = painted?.rgb ?? this.colorVarying.rgb\n this.#cw = painted?.weight ?? float(0)\n this.#fn =\n options.fill && fillUv && fillIndex\n ? options.fill({\n uv: fillUv,\n position: localVarying,\n color: this.baseColor,\n colorWeight: this.colorWeight,\n glyphIndex: fillIndex,\n })\n : null\n\n // A quad's padding reaches past its block, so the clip would cut its wireframe's edges.\n this.#ic = outsideWireframe(\n localVarying.x\n .greaterThanEqual(clipVarying.x)\n .and(localVarying.y.greaterThanEqual(clipVarying.y))\n .and(localVarying.x.lessThanEqual(clipVarying.z))\n .and(localVarying.y.lessThanEqual(clipVarying.w)),\n () => bool(true),\n )\n if (options.motion !== false) this.setMotion(options.motion ?? {})\n }\n\n /** @internal The ink's alpha: the CSS colour's, times the motion's for animated text. */\n protected inkAlpha(): Node<'float'> {\n return this.animated ? this.colorVarying.a.mul(this.#av) : this.colorVarying.a\n }\n\n /**\n * Attach one backend's beauty and shadow coverage to the shared graph. `folded` says the\n * beauty coverage holds the factor `toned()` returns for the ink's own alpha.\n */\n protected applyCoverage(\n coverage: Node<'float'>,\n shadowCoverage: Node<'float'>,\n shadowCutoff: Node<'float'>,\n paint?: Node<'vec4'>,\n folded = false,\n ): void {\n const fill = this.fillNode\n const paintedAlpha = paint?.a ?? (fill ? coverage.mul(clamp(fill.a, 0, 1)) : coverage)\n const castCoverage = fill && !paint ? shadowCoverage.mul(clamp(fill.a, 0, 1)) : shadowCoverage\n const inked = (covered: Node<'float'>): Node<'float'> => {\n const ink = covered.mul(this.colorVarying.a)\n return this.animated ? ink.mul(this.#av) : ink\n }\n // A folded factor times the ink's alpha is the converted coverage, clamped as one.\n // Shadow passes keep the exact product.\n const alpha = (\n folded\n ? outsideShadowPass(min(1, inked(paintedAlpha)), inked(castCoverage))\n : inked(outsideShadowPass(paintedAlpha, castCoverage))\n ).toConst()\n // Wireframe lines take the ink with none of the coverage, which is zero along a quad's\n // edges. A paint's colour means nothing outside its shape, so lines keep the CSS colour,\n // lifted toward white until it reaches the line floor. Built lazily on first wireframe use.\n let wire: { readonly color: Node<'vec4'>; readonly alpha: Node<'float'> } | null = null\n const getWire = () => {\n if (!wire) {\n const lineAlpha = this.inkAlpha().toConst()\n const lineInk = vec3(fill?.rgb ?? this.baseColor).toConst()\n const lineInkLuminance = luminance(lineInk).toConst()\n const lineLift = clamp(\n float(WIREFRAME_LINE_LUMINANCE)\n .sub(lineInkLuminance)\n .div(max(float(1).sub(lineInkLuminance), 1e-4)),\n 0,\n 1,\n )\n wire = {\n color: vec4(mix(lineInk, vec3(1), lineLift), lineAlpha),\n alpha: lineAlpha,\n }\n }\n return wire\n }\n this.colorNode = outsideWireframe(\n vec4(outsideShadowPass(paint?.rgb ?? fill?.rgb ?? this.baseColor, vec3(0)), alpha),\n () => getWire().color,\n )\n this.maskNode = this.insideClip.and(\n outsideWireframe(alpha, () => getWire().alpha).greaterThan(0.001),\n )\n this.maskShadowNode = this.insideClip\n .and(castCoverage.greaterThan(shadowCutoff))\n .and(this.inkAlpha().greaterThan(shadowCutoff))\n }\n\n /**\n * Beauty coverage of text ink as a browser would show it, or the same node when the\n * material has no tone. The ink is the instance colour, whose terms reach the fragment\n * through one flat varying, unless a fill graph supplies the colour per fragment.\n * `tableGate` is for a model whose table stops at a size. Shadow masks, colour layers and\n * shape paint must keep the exact coverage.\n *\n * The ink's own alpha is part of the mask a browser blends: the CSS colour's alpha and\n * opacity, the motion's, a fill's. The result is the factor that `applyCoverage` multiplies\n * by that alpha, so the caller passes it `folded`. `fold` false converts as for opaque ink,\n * for a caller that composes the result with other coverages first.\n */\n protected toned(\n coverage: Node<'float'>,\n ink?: Node<'vec3'>,\n tableGate?: Node<'float'>,\n fold = true,\n ): Node<'float'> {\n const tone = this.tone\n if (!tone) return coverage\n let opacity: Node<'float'> | undefined\n if (fold) {\n opacity = this.inkAlpha()\n if (this.fillNode) opacity = opacity.mul(clamp(this.fillNode.a, 0, 1))\n }\n return tone.apply(coverage, ink ? tone.inkTerms(ink).toConst() : this.#gt!, tableGate, opacity)\n }\n\n /**\n * Follows a recaptured tone through the uniforms. False means this material was built for\n * a tone of another kind, because the conversion or a model's extra nodes would have to\n * appear or go: the caller rebuilds the material.\n */\n setTone(tone: ResolvedTextTone | null): boolean {\n const current = this.tone\n if (!current || !tone || !current.fits(tone)) return !current && !tone\n current.update(tone)\n return true\n }\n\n /**\n * Rebuilds an equivalent material from this one's original construction options.\n *\n * Three's `Material.clone()` constructs the concrete class with **no arguments** and\n * copies properties across. This graph cannot survive that: it closes over required\n * options — an atlas and its metrics on the SDF backend, outline tables on Windfoil —\n * so the argument-less twin threw before `copy()` ever ran, and three's generic node\n * property copy would hand the twin a graph still wired to the *source's* uniforms,\n * leaving its own knobs connected to nothing. {@link remake} re-runs the constructor\n * with the stored options instead, rebuilding a private graph over the same shared\n * resources (the atlas texture is shared on purpose); the loop then carries the current\n * value of every numeric uniform knob — this class's and any subclass's, discovered as\n * own properties — into the twin's own uniforms, and the classic scalar-flag copy brings\n * side, opacity, blending, visibility, wireframe and friends. The tone's uniforms live on\n * its own object, so its current values are handed over whole. The one non-numeric uniform\n * in the family, the SDF unit range, is derived from the options and already correct in\n * the twin. Hand edits made to the node graph after construction are deliberately not\n * carried, and subclasses inherit all of this untouched because each passes its own\n * options object through `super()`. A static material's clone is static.\n */\n override clone(): this {\n return this.withMotion()\n }\n\n /** @internal */\n protected copySubclassUniforms?(target: this): void\n\n /**\n * @internal The animated twin of a static material: rebuilt like `clone()` with the\n * motion graph and `motion`, carrying every other state. Motion knobs `motion` leaves out\n * take their defaults.\n */\n withMotion(motion?: SdfMotionOptions): this {\n const twin = this.#rm(motion)\n // The classic fixed-list scalar copy — side, opacity, blending, visibility and friends —\n // not NodeMaterial's generic property pass, which would re-wire this rebuilt graph back\n // into the source's nodes. Wireframe sits above the base list, so it rides separately.\n Material.prototype.copy.call(twin, this)\n twin.wireframe = this.wireframe\n twin.maxSequence.value = this.#maxSeq.value\n if (!motion) {\n if (this.#me !== null) twin.motionEnabled.value = this.#me.value\n if (this.#mm !== null) twin.motionMode.value = this.#mm.value\n if (this.#mstr !== null) twin.motionStrength.value = this.#mstr.value\n if (this.#mspd !== null) twin.motionSpeed.value = this.#mspd.value\n if (this.#mstg !== null) twin.motionStagger.value = this.#mstg.value\n }\n this.copySubclassUniforms?.(twin)\n for (const key in twin) {\n const target = twin[key as keyof this] as { isUniformNode?: boolean; value: unknown } | null\n if (\n target?.isUniformNode &&\n typeof target.value === 'number' &&\n !(motion && key.startsWith('motion'))\n ) {\n target.value = (this[key as keyof this] as { value: number }).value\n }\n }\n if (this.tone) twin.tone?.update(this.tone.resolved)\n return twin\n }\n\n /**\n * Writes the given motion fields into the uniforms; safe to call every frame. Throws on a\n * static material (`motion: false`), which has no motion graph to drive.\n */\n setMotion(options: SdfMotionOptions): this {\n if (!this.animated) throw new Error('ultra-text: setMotion() cannot run with motion: false')\n if (options.enabled !== undefined) this.motionEnabled.value = options.enabled ? 1 : 0\n if (options.mode !== undefined) this.motionMode.value = MODE_CODES[options.mode]\n if (options.strength !== undefined) this.motionStrength.value = Math.max(0, options.strength)\n if (options.speed !== undefined) this.motionSpeed.value = Math.max(0, options.speed)\n if (options.stagger !== undefined) this.motionStagger.value = Math.max(0, options.stagger)\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U,MAAM,IAAI,MAAM,uDAAuD;EAC3F,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,cAAc,QAAQ,QAAQ,UAAU,IAAI;EACpF,IAAI,QAAQ,SAAS,KAAA,GAAW,KAAK,WAAW,QAAQ,WAAW,QAAQ;EAC3E,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,eAAe,QAAQ,KAAK,IAAI,GAAG,QAAQ,QAAQ;EAC5F,IAAI,QAAQ,UAAU,KAAA,GAAW,KAAK,YAAY,QAAQ,KAAK,IAAI,GAAG,QAAQ,KAAK;EACnF,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,cAAc,QAAQ,KAAK,IAAI,GAAG,QAAQ,OAAO;EACzF,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"GlyphTextMaterial.js","names":[],"sources":["../../src/text/GlyphTextMaterial.ts"],"sourcesContent":["import {\n DoubleSide,\n FrontSide,\n Material,\n MeshBasicNodeMaterial,\n Node,\n SRGBColorSpace,\n type NodeBuilder,\n type Side,\n type UniformNode,\n} from 'three/webgpu'\nimport {\n Fn,\n attribute,\n bool,\n clamp,\n colorSpaceToWorking,\n cos,\n float,\n instanceIndex,\n int,\n luminance,\n max,\n min,\n mix,\n mod,\n positionGeometry,\n sin,\n time,\n uniform,\n varying,\n varyingProperty,\n vec2,\n vec3,\n vec4,\n} from 'three/tsl'\n\nimport type {\n SdfAnimationMode,\n SdfMotionOptions,\n TextFill,\n TextToneOptions,\n TextVertex,\n} from '../types.js'\nimport { resolveTextTone, TextTone, type ResolvedTextTone } from './tone.js'\n\n/** Shared construction options for the retained SDF and Windfoil text materials. */\nexport interface GlyphTextMaterialOptions {\n /** Match a snapshot captured with browser shaping; enables shared run motion. */\n textShaping?: 'none' | 'browser'\n /** Share motion centres and ordinals supplied by geometry. */\n runMotion?: boolean\n /** Custom linear-color TSL fill; opacity is multiplied by glyph coverage and DOM opacity. */\n fill?: TextFill | undefined\n /** Custom TSL vertex position in capture-local coordinates. */\n vertex?: TextVertex | undefined\n /** Face culling side. Defaults to `FrontSide`. */\n side?: Side | undefined\n /**\n * Initial motion state; adjustable later through `setMotion()`. `false` builds static text:\n * the vertex stage has no motion graph (no clock, waves or slide timeline) and the fragment\n * no motion alpha, `animated` is false, and `setMotion()` throws. Draws like motion with\n * mode `'none'`.\n */\n motion?: SdfMotionOptions | false\n /** Largest per-line stagger index in the geometry. Defaults to `0`. */\n maxSequence?: number\n /**\n * Shows text ink at the weight a browser gives it; see `TextToneOptions`. There is no\n * source element here: an `'auto'` model is the exact outline, and an `'auto'` backdrop is\n * unknown, which tones dark ink against white and keeps light ink at its exact coverage\n * whatever the model. Name the `backdrop` colour the scene shows behind the text for the\n * full conversion. `false` leaves the conversion out of the shader graph. Defaults to on.\n */\n tone?: TextToneOptions | ResolvedTextTone | false\n /**\n * @internal Size switch. Decides from per-instance data and per-pass uniforms only, so a\n * quad's four vertices agree; `false` collapses the quad onto its motion anchor, which\n * rasterizes nothing in beauty or shadow passes. Requires `sdfMeta` as\n * (sequence, depth, switch em).\n */\n keepGlyph?: GlyphKeepHook\n}\n\nexport type GlyphMotionSource =\n Node<'float'> | { readonly index: Node<'float'>; readonly center: Node<'vec2'> }\n\nexport type GlyphVertexExtension = (\n quad: Node<'vec2'>,\n rect: Node<'vec4'>,\n position: Node<'vec2'>,\n depth: Node<'float'>,\n motionScale: Node<'float'>,\n fillUv: Node<'vec2'> | null,\n // A coverage backend may only attach varyings and intentionally return nothing.\n // eslint-disable-next-line @typescript-eslint/no-invalid-void-type\n) => Node<'vec2'> | void\n\n/** Per-glyph keep test for the size switch; see `GlyphTextMaterialOptions.keepGlyph`. */\nexport type GlyphKeepHook = (anchor: Node<'vec2'>, meta: Node<'vec3'>) => Node<'bool'>\n\n/** Fragment paint hook, evaluated before the caller's custom fill. */\nexport type GlyphPaintExtension = (cssColor: Node<'vec3'>) => {\n readonly rgb: Node<'vec3'>\n readonly weight: Node<'float'>\n}\n\nconst MODE_CODES: Readonly<Record<SdfAnimationMode, number>> = Object.freeze({\n none: 0,\n opacity: 1,\n scale: 2,\n offset: 3,\n 'slide-up': 4,\n 'slide-down': 5,\n 'slide-left': 6,\n 'slide-right': 7,\n all: 8,\n})\n\n/** @internal Whether this motion state needs the motion graph: any mode but `'none'`. */\nexport function isAnimatedMotion(motion: SdfMotionOptions | false | undefined): boolean {\n return motion !== false && motion?.mode !== 'none'\n}\n\n/** Convert normalized DOM sRGB attributes into Three's working colour space. */\nexport function srgbAttributeToWorking(node: Node<'vec3'>): Node<'vec3'> {\n // ColorSpaceNode reports vec4 in r185, so truncate with a real conversion.\n return vec3(colorSpaceToWorking(node, SRGBColorSpace) as unknown as Node<'vec3'>)\n}\n\nclass PassNode extends Node {\n static readonly type: string = 'UltraTextPassNode'\n\n constructor(\n readonly beautyNode: Node,\n readonly shadowNode: Node,\n ) {\n super()\n }\n\n // generateNodeType, not getNodeType: three caches the result per builder.\n override generateNodeType(builder: NodeBuilder): string {\n return (\n (builder.material as { isShadowPassMaterial?: boolean }).isShadowPassMaterial\n ? this.shadowNode\n : this.beautyNode\n ).getNodeType(builder)\n }\n\n override setup(builder: NodeBuilder): Node {\n return (builder.material as { isShadowPassMaterial?: boolean }).isShadowPassMaterial\n ? this.shadowNode\n : this.beautyNode\n }\n}\n\n/** `beauty`, giving way to `shadow` in the pass three derives for a shadow map. */\nexport function outsideShadowPass<T extends Node>(beauty: T, shadow: T): T {\n return new PassNode(beauty, shadow) as Node as T\n}\n\nclass WireframeNode extends Node {\n static readonly type = 'UltraTextWireframeNode'\n readonly #s: Node\n readonly #ml: () => Node\n #l: Node | null = null\n\n constructor(solid: Node, makeLines: () => Node) {\n super()\n this.#s = solid\n this.#ml = makeLines\n }\n\n override generateNodeType(builder: NodeBuilder): string {\n return this.#s.getNodeType(builder)\n }\n\n override setup(builder: NodeBuilder): Node {\n const m = builder.material as { wireframe?: boolean; isShadowPassMaterial?: boolean }\n return m.wireframe === true && !m.isShadowPassMaterial ? (this.#l ??= this.#ml()) : this.#s\n }\n\n override getChildren(): Node[] {\n return this.#l ? [this.#s, this.#l] : [this.#s]\n }\n}\n\nconst WIREFRAME_LINE_LUMINANCE = 0.4\n\n/** `solid`, giving way to `lines` when the material draws wireframe. */\nfunction outsideWireframe<T extends Node>(solid: T, makeLines: () => T): T {\n return new WireframeNode(solid, makeLines) as Node as T\n}\n\n/**\n * Shared retained-glyph vertex, motion, clipping, colour, and shadow plumbing.\n *\n * The two text backends differ only in how they produce coverage. Keeping the\n * rest in one graph makes switching backend preserve layout and animation\n * semantics, and avoids shipping the motion graph twice.\n */\nexport class GlyphTextMaterial extends MeshBasicNodeMaterial {\n /** Uniforms of the tone conversion; null when the material was built with `tone: false`. */\n readonly tone: TextTone | null\n /**\n * False for static text, built with `motion: false`: its shader has no motion graph, its\n * motion uniforms read as disabled, and `setMotion()` throws.\n */\n readonly animated: boolean\n\n #me: UniformNode<'float', number> | null\n #mm: UniformNode<'int', number> | null\n #mstr: UniformNode<'float', number> | null\n #mspd: UniformNode<'float', number> | null\n #mstg: UniformNode<'float', number> | null\n readonly #maxSeq: UniformNode<'float', number> = uniform(0)\n readonly #cv: Node<'vec4'>\n readonly #ic: Node<'bool'>\n readonly #fn: Node<'vec4'> | null\n readonly #bc: Node<'vec3'>\n readonly #cw: Node<'float'>\n #av = varyingProperty('float', 'vUltraTextMotionAlpha')\n #gt: Node<'vec3'> | null\n #rm: (motion?: SdfMotionOptions) => this\n\n get motionEnabled(): UniformNode<'float', number> {\n return (this.#me ??= uniform(0))\n }\n get motionMode(): UniformNode<'int', number> {\n return (this.#mm ??= uniform(MODE_CODES.none, 'int'))\n }\n get motionStrength(): UniformNode<'float', number> {\n return (this.#mstr ??= uniform(18))\n }\n get motionSpeed(): UniformNode<'float', number> {\n return (this.#mspd ??= uniform(1.35))\n }\n get motionStagger(): UniformNode<'float', number> {\n return (this.#mstg ??= uniform(0.045))\n }\n get maxSequence(): UniformNode<'float', number> {\n return this.#maxSeq\n }\n protected get colorVarying() {\n return this.#cv\n }\n protected get insideClip(): Node<'bool'> {\n return this.#ic\n }\n protected get fillNode(): Node<'vec4'> | null {\n return this.#fn\n }\n protected get baseColor(): Node<'vec3'> {\n return this.#bc\n }\n protected get colorWeight(): Node<'float'> {\n return this.#cw\n }\n\n constructor(\n options: GlyphTextMaterialOptions,\n extendVertex?: GlyphVertexExtension,\n motionIndex?: GlyphMotionSource,\n paint?: GlyphPaintExtension,\n ) {\n super()\n this.#rm = (motion) =>\n new (\n this.constructor as new (\n remakeOptions: GlyphTextMaterialOptions,\n remakeExtension?: GlyphVertexExtension,\n remakeIndex?: GlyphMotionSource,\n remakePaint?: GlyphPaintExtension,\n ) => this\n )(motion ? { ...options, motion } : options, extendVertex, motionIndex, paint)\n const animated = (this.animated = options.motion !== false)\n if (animated) {\n this.#me = uniform(1)\n this.#mm = uniform(MODE_CODES['slide-up'], 'int')\n this.#mstr = uniform(18)\n this.#mspd = uniform(1.35)\n this.#mstg = uniform(0.045)\n } else {\n this.#me = this.#mm = this.#mstr = this.#mspd = this.#mstg = null\n }\n this.lights = false\n this.transparent = true\n this.depthWrite = false\n this.depthTest = true\n this.side = options.side ?? FrontSide\n this.shadowSide = this.side\n this.forceSinglePass = this.side === DoubleSide\n this.toneMapped = false\n this.maxSequence.value = options.maxSequence ?? 0\n const tone = resolveTextTone(options.tone)\n this.tone = tone && new TextTone(tone)\n\n const localVarying = varyingProperty('vec2', 'vUltraTextLocal')\n const glyphRect = attribute<'vec4'>('sdfRect', 'vec4')\n const glyphClip = attribute<'vec4'>('sdfClip', 'vec4')\n const glyphColor = attribute<'vec4'>('sdfColor', 'vec4')\n const workingColor = srgbAttributeToWorking(vec3(glyphColor.rgb)).toConst()\n const clipVarying = varying(glyphClip, 'vUltraTextClip').setInterpolation('flat', 'either')\n this.#cv = varying(vec4(workingColor, glyphColor.a), 'vUltraTextColor').setInterpolation(\n 'flat',\n 'either',\n )\n this.#gt =\n this.tone &&\n varying(this.tone.inkTerms(workingColor), 'vUltraTextTone').setInterpolation('flat', 'either')\n // Sequence and depth are the only per-glyph metadata. The compacted draw's\n // global index is already supplied by the GPU, including after blank glyphs.\n const keepGlyph = options.keepGlyph\n const glyphMeta = keepGlyph\n ? attribute<'vec3'>('sdfMeta', 'vec3')\n : attribute<'vec2'>('sdfMeta', 'vec2')\n const runMotion =\n (options.runMotion ?? options.textShaping === 'browser')\n ? attribute<'vec3'>('sdfRunMotion', 'vec3')\n : null\n const source = motionIndex && 'index' in motionIndex ? motionIndex : null\n const indexSource = source?.index ?? (motionIndex as Node<'float'> | undefined)\n const fillUv = options.fill ? varyingProperty('vec2', 'vUltraFillUv') : null\n // Switched batches share global ordinals, so glyphIndex stays continuous across a switch.\n // Fills truncate it to read per-glyph data. Interpolated, an instance's constant can arrive\n // a hair under itself (Safari's relaxed math on Apple GPUs) and read the previous glyph's\n // entry: flat keeps it exact.\n const fillIndex = options.fill\n ? varying(\n (keepGlyph ? (runMotion?.z ?? source?.index) : source?.index) ?? float(instanceIndex),\n 'vUltraFillIndex',\n ).setInterpolation('flat', 'either')\n : null\n\n // The anchor motion scales about, and the size switch's anchor.\n const motionCenter = (): Node<'vec2'> =>\n (runMotion?.xy ?? source?.center ?? glyphRect.xy.add(glyphRect.zw).mul(0.5)).toConst()\n const basePositionOf = (quad: Node<'vec2'>): Node<'vec2'> =>\n glyphRect.xy.add(glyphRect.zw.sub(glyphRect.xy).mul(quad)).toConst()\n // What both graphs do with the moved position: the backend's extension, the size switch\n // and the shared varyings. Returns the drawn position.\n const finishVertex = (\n quad: Node<'vec2'>,\n center: Node<'vec2'> | null,\n position: Node<'vec2'>,\n motionScale: Node<'float'>,\n glyphIndex?: Node<'float'>,\n builder?: NodeBuilder,\n ): Node<'vec3'> => {\n const uv = fillUv ?? (options.vertex ? vec2(quad).toVar() : null)\n const extendedPosition =\n extendVertex?.(quad, glyphRect, position, glyphMeta.y, motionScale, uv) ?? position\n // The un-animated anchor and the unscaled em decide, so motion never moves a glyph\n // between the two batches of a size switch.\n const keep = center && keepGlyph?.(center, glyphMeta as unknown as Node<'vec3'>)\n const drawnPosition = keep\n ? vec2(keep.select(extendedPosition, center)).toConst()\n : extendedPosition\n if (!builder || this.needsLocalVarying(builder)) localVarying.assign(drawnPosition)\n const localPosition = vec3(drawnPosition, glyphMeta.y)\n if (!options.vertex) return localPosition\n const displaced = options.vertex({\n position: localPosition,\n center: center!,\n uv: uv!,\n glyphIndex: glyphIndex ?? (runMotion?.z ?? indexSource ?? float(instanceIndex)).toConst(),\n sequence: glyphMeta.x,\n rect: glyphRect,\n clip: glyphClip,\n })\n return keep ? vec3(keep.select(displaced, vec3(center, glyphMeta.y))) : displaced\n }\n\n // Static text: the motion graph's disabled branch alone, without its clock, waves and\n // slide timeline. Only the size switch or a custom vertex hook reads the anchor.\n const staticPosition = (builder?: NodeBuilder): Node<'vec3'> => {\n const quad = positionGeometry.xy\n fillUv?.assign(quad)\n const center = keepGlyph || options.vertex ? motionCenter() : null\n return finishVertex(quad, center, basePositionOf(quad), float(1), undefined, builder)\n }\n // Reused expressions need shader locals as well as shared JavaScript nodes;\n // otherwise the motion/clip expressions expand repeatedly in generated WGSL.\n // Immutable intermediates use toConst(); only the accumulated position mutates.\n const animatedPosition = (builder?: NodeBuilder): Node<'vec3'> => {\n const quad = positionGeometry.xy\n fillUv?.assign(quad)\n const center = motionCenter()\n const basePosition = basePositionOf(quad)\n const sequence = glyphMeta.x\n const glyphIndex = (runMotion?.z ?? indexSource ?? float(instanceIndex)).toConst()\n const clock = time.mul(this.motionSpeed).toConst()\n const wave = sin(\n clock.mul(Math.PI * 2).sub(glyphIndex.mul(this.motionStagger).mul(Math.PI * 2)),\n )\n const pulse = wave.mul(0.5).add(0.5).toConst()\n\n const mode = (code: number) => int(this.motionMode).equal(code)\n const isOpacity = mode(MODE_CODES.opacity)\n const isScale = mode(MODE_CODES.scale)\n const isOffset = mode(MODE_CODES.offset)\n const isSlideUp = mode(MODE_CODES['slide-up'])\n const isSlideDown = mode(MODE_CODES['slide-down'])\n const isSlideLeft = mode(MODE_CODES['slide-left'])\n const isSlideRight = mode(MODE_CODES['slide-right'])\n const isAll = mode(MODE_CODES.all).toConst()\n\n const scale = isScale\n .select(\n float(0.86).add(pulse.mul(0.22)),\n isAll.select(float(0.94).add(pulse.mul(0.08)), float(1)),\n )\n .toConst()\n const animated = vec2(center.add(basePosition.sub(center).mul(scale))).toVar()\n const offsetX = sin(clock.mul(3.1).add(glyphIndex.mul(0.55)))\n .mul(this.motionStrength)\n .mul(0.32)\n const offsetY = cos(clock.mul(2.7).add(glyphIndex.mul(0.45)))\n .mul(this.motionStrength)\n .mul(0.18)\n animated.x.addAssign(isOffset.select(offsetX, 0))\n animated.y.addAssign(\n isOffset.select(\n offsetY,\n isAll.select(\n sin(clock.mul(2.5).add(glyphIndex.mul(0.35)))\n .mul(this.motionStrength)\n .mul(0.16),\n 0,\n ),\n ),\n )\n\n const enterDuration = 0.58\n const holdDuration = 1.15\n const exitDuration = 0.24\n const sequenceSpan = this.maxSequence.mul(this.motionStagger).toConst()\n const cycle = max(\n sequenceSpan.add(enterDuration + holdDuration + exitDuration),\n 0.001,\n ).toConst()\n const slidePhase = mod(clock, cycle).toConst()\n const localPhase = slidePhase.sub(sequence.mul(this.motionStagger)).toConst()\n const enterT = clamp(localPhase.div(enterDuration), 0, 1)\n const inverseEnter = float(1).sub(enterT).toConst()\n const easeOut = float(1).sub(inverseEnter.mul(inverseEnter).mul(inverseEnter))\n const exitStart = sequenceSpan.add(enterDuration + holdDuration).toConst()\n const exitT = clamp(slidePhase.sub(exitStart).div(exitDuration), 0, 1).toConst()\n const travelRatio = localPhase\n .lessThan(0)\n .select(\n float(1),\n localPhase\n .lessThan(enterDuration)\n .select(\n float(1).sub(easeOut),\n slidePhase.lessThan(exitStart).select(float(0), exitT.mul(exitT).mul(exitT).negate()),\n ),\n )\n .toConst()\n const clipSize = glyphClip.zw.sub(glyphClip.xy).toConst()\n const verticalTravel = max(this.motionStrength, clipSize.y.mul(1.18))\n .mul(travelRatio)\n .toConst()\n const horizontalTravel = max(this.motionStrength, clipSize.x.mul(1.18))\n .mul(travelRatio)\n .toConst()\n animated.x.addAssign(\n isSlideLeft.select(horizontalTravel, isSlideRight.select(horizontalTravel.negate(), 0)),\n )\n animated.y.addAssign(\n isSlideUp.select(verticalTravel.negate(), isSlideDown.select(verticalTravel, 0)),\n )\n\n const animationEnabled = this.motionEnabled\n .greaterThan(0.5)\n .and(int(this.motionMode).notEqual(MODE_CODES.none))\n .toConst()\n const finalPosition = vec2(animationEnabled.select(animated, basePosition)).toConst()\n const animatedAlpha = isOpacity.select(\n float(0.25).add(pulse.mul(0.75)),\n isAll.select(float(0.55).add(pulse.mul(0.45)), float(1)),\n )\n\n const motionScale = animationEnabled.select(scale, 1)\n const drawnPosition = finishVertex(\n quad,\n center,\n finalPosition,\n motionScale,\n glyphIndex,\n builder,\n )\n this.#av.assign(animationEnabled.select(animatedAlpha, 1))\n return drawnPosition\n }\n const positionNode = Fn<Node<'vec3'>>(animated ? animatedPosition : staticPosition)()\n this.positionNode = positionNode\n this.castShadowPositionNode = positionNode\n const painted = paint?.(this.colorVarying.rgb)\n this.#bc = painted?.rgb ?? this.colorVarying.rgb\n this.#cw = painted?.weight ?? float(0)\n this.#fn =\n options.fill && fillUv && fillIndex\n ? options.fill({\n uv: fillUv,\n position: localVarying,\n color: this.baseColor,\n colorWeight: this.colorWeight,\n glyphIndex: fillIndex,\n })\n : null\n\n // A quad's padding reaches past its block, so the clip would cut its wireframe's edges.\n this.#ic = outsideWireframe(\n localVarying.x\n .greaterThanEqual(clipVarying.x)\n .and(localVarying.y.greaterThanEqual(clipVarying.y))\n .and(localVarying.x.lessThanEqual(clipVarying.z))\n .and(localVarying.y.lessThanEqual(clipVarying.w)),\n () => bool(true),\n )\n if (options.motion !== false) this.setMotion(options.motion ?? {})\n }\n\n /** @internal Whether the vertex stage needs to emit `vUltraTextLocal` for this build. */\n protected needsLocalVarying(_builder: NodeBuilder): boolean {\n return true\n }\n\n /** @internal The ink's alpha: the CSS colour's, times the motion's for animated text. */\n protected inkAlpha(): Node<'float'> {\n return this.animated ? this.colorVarying.a.mul(this.#av) : this.colorVarying.a\n }\n\n /**\n * Attach one backend's beauty and shadow coverage to the shared graph. `folded` says the\n * beauty coverage holds the factor `toned()` returns for the ink's own alpha.\n */\n protected applyCoverage(\n coverage: Node<'float'>,\n shadowCoverage: Node<'float'>,\n shadowCutoff: Node<'float'>,\n paint?: Node<'vec4'>,\n folded = false,\n ): void {\n const fill = this.fillNode\n const paintedAlpha = paint?.a ?? (fill ? coverage.mul(clamp(fill.a, 0, 1)) : coverage)\n const castCoverage = fill && !paint ? shadowCoverage.mul(clamp(fill.a, 0, 1)) : shadowCoverage\n const inked = (covered: Node<'float'>): Node<'float'> => {\n const ink = covered.mul(this.colorVarying.a)\n return this.animated ? ink.mul(this.#av) : ink\n }\n // A folded factor times the ink's alpha is the converted coverage, clamped as one.\n // Shadow passes keep the exact product.\n const alpha = (\n folded\n ? outsideShadowPass(min(1, inked(paintedAlpha)), inked(castCoverage))\n : inked(outsideShadowPass(paintedAlpha, castCoverage))\n ).toConst()\n // Wireframe lines take the ink with none of the coverage, which is zero along a quad's\n // edges. A paint's colour means nothing outside its shape, so lines keep the CSS colour,\n // lifted toward white until it reaches the line floor. Built lazily on first wireframe use.\n let wire: { readonly color: Node<'vec4'>; readonly alpha: Node<'float'> } | null = null\n const getWire = () => {\n if (!wire) {\n const lineAlpha = this.inkAlpha().toConst()\n const lineInk = vec3(fill?.rgb ?? this.baseColor).toConst()\n const lineInkLuminance = luminance(lineInk).toConst()\n const lineLift = clamp(\n float(WIREFRAME_LINE_LUMINANCE)\n .sub(lineInkLuminance)\n .div(max(float(1).sub(lineInkLuminance), 1e-4)),\n 0,\n 1,\n )\n wire = {\n color: vec4(mix(lineInk, vec3(1), lineLift), lineAlpha),\n alpha: lineAlpha,\n }\n }\n return wire\n }\n this.colorNode = outsideWireframe(\n vec4(outsideShadowPass(paint?.rgb ?? fill?.rgb ?? this.baseColor, vec3(0)), alpha),\n () => getWire().color,\n )\n this.maskNode = this.insideClip.and(\n outsideWireframe(alpha, () => getWire().alpha).greaterThan(0.001),\n )\n this.maskShadowNode = this.insideClip\n .and(castCoverage.greaterThan(shadowCutoff))\n .and(this.inkAlpha().greaterThan(shadowCutoff))\n }\n\n /**\n * Beauty coverage of text ink as a browser would show it, or the same node when the\n * material has no tone. The ink is the instance colour, whose terms reach the fragment\n * through one flat varying, unless a fill graph supplies the colour per fragment.\n * `tableGate` is for a model whose table stops at a size. Shadow masks, colour layers and\n * shape paint must keep the exact coverage.\n *\n * The ink's own alpha is part of the mask a browser blends: the CSS colour's alpha and\n * opacity, the motion's, a fill's. The result is the factor that `applyCoverage` multiplies\n * by that alpha, so the caller passes it `folded`. `fold` false converts as for opaque ink,\n * for a caller that composes the result with other coverages first.\n */\n protected toned(\n coverage: Node<'float'>,\n ink?: Node<'vec3'>,\n tableGate?: Node<'float'>,\n fold = true,\n ): Node<'float'> {\n const tone = this.tone\n if (!tone) return coverage\n let opacity: Node<'float'> | undefined\n if (fold) {\n opacity = this.inkAlpha()\n if (this.fillNode) opacity = opacity.mul(clamp(this.fillNode.a, 0, 1))\n }\n return tone.apply(coverage, ink ? tone.inkTerms(ink).toConst() : this.#gt!, tableGate, opacity)\n }\n\n /**\n * Follows a recaptured tone through the uniforms. False means this material was built for\n * a tone of another kind, because the conversion or a model's extra nodes would have to\n * appear or go: the caller rebuilds the material.\n */\n setTone(tone: ResolvedTextTone | null): boolean {\n const current = this.tone\n if (!current || !tone || !current.fits(tone)) return !current && !tone\n current.update(tone)\n return true\n }\n\n /**\n * Rebuilds an equivalent material from this one's original construction options.\n *\n * Three's `Material.clone()` constructs the concrete class with **no arguments** and\n * copies properties across. This graph cannot survive that: it closes over required\n * options — an atlas and its metrics on the SDF backend, outline tables on Windfoil —\n * so the argument-less twin threw before `copy()` ever ran, and three's generic node\n * property copy would hand the twin a graph still wired to the *source's* uniforms,\n * leaving its own knobs connected to nothing. {@link remake} re-runs the constructor\n * with the stored options instead, rebuilding a private graph over the same shared\n * resources (the atlas texture is shared on purpose); the loop then carries the current\n * value of every numeric uniform knob — this class's and any subclass's, discovered as\n * own properties — into the twin's own uniforms, and the classic scalar-flag copy brings\n * side, opacity, blending, visibility, wireframe and friends. The tone's uniforms live on\n * its own object, so its current values are handed over whole. The one non-numeric uniform\n * in the family, the SDF unit range, is derived from the options and already correct in\n * the twin. Hand edits made to the node graph after construction are deliberately not\n * carried, and subclasses inherit all of this untouched because each passes its own\n * options object through `super()`. A static material's clone is static.\n */\n override clone(): this {\n return this.withMotion()\n }\n\n /** @internal */\n protected copySubclassUniforms?(target: this): void\n\n /**\n * @internal The animated twin of a static material: rebuilt like `clone()` with the\n * motion graph and `motion`, carrying every other state. Motion knobs `motion` leaves out\n * take their defaults.\n */\n withMotion(motion?: SdfMotionOptions): this {\n const twin = this.#rm(motion)\n // The classic fixed-list scalar copy — side, opacity, blending, visibility and friends —\n // not NodeMaterial's generic property pass, which would re-wire this rebuilt graph back\n // into the source's nodes. Wireframe sits above the base list, so it rides separately.\n Material.prototype.copy.call(twin, this)\n twin.wireframe = this.wireframe\n twin.maxSequence.value = this.#maxSeq.value\n if (!motion) {\n if (this.#me !== null) twin.motionEnabled.value = this.#me.value\n if (this.#mm !== null) twin.motionMode.value = this.#mm.value\n if (this.#mstr !== null) twin.motionStrength.value = this.#mstr.value\n if (this.#mspd !== null) twin.motionSpeed.value = this.#mspd.value\n if (this.#mstg !== null) twin.motionStagger.value = this.#mstg.value\n }\n this.copySubclassUniforms?.(twin)\n for (const key in twin) {\n const target = twin[key as keyof this] as { isUniformNode?: boolean; value: unknown } | null\n if (\n target?.isUniformNode &&\n typeof target.value === 'number' &&\n !(motion && key.startsWith('motion'))\n ) {\n target.value = (this[key as keyof this] as { value: number }).value\n }\n }\n if (this.tone) twin.tone?.update(this.tone.resolved)\n return twin\n }\n\n /**\n * Writes the given motion fields into the uniforms; safe to call every frame. Throws on a\n * static material (`motion: false`), which has no motion graph to drive.\n */\n setMotion(options: SdfMotionOptions): this {\n if (!this.animated) throw new Error('ultra-text: setMotion() cannot run with motion: false')\n if (options.enabled !== undefined) this.motionEnabled.value = options.enabled ? 1 : 0\n if (options.mode !== undefined) this.motionMode.value = MODE_CODES[options.mode]\n if (options.strength !== undefined) this.motionStrength.value = Math.max(0, options.strength)\n if (options.speed !== undefined) this.motionSpeed.value = Math.max(0, options.speed)\n if (options.stagger !== undefined) this.motionStagger.value = Math.max(0, options.stagger)\n return this\n }\n}\n"],"mappings":";;;;;AA2GA,IAAM,aAAyD,OAAO,OAAO;CAC3E,MAAM;CACN,SAAS;CACT,OAAO;CACP,QAAQ;CACR,YAAY;CACZ,cAAc;CACd,cAAc;CACd,eAAe;CACf,KAAK;AACP,CAAC;;AAGD,SAAgB,iBAAiB,QAAuD;CACtF,OAAO,WAAW,SAAS,QAAQ,SAAS;AAC9C;;AAGA,SAAgB,uBAAuB,MAAkC;CAEvE,OAAO,KAAK,oBAAoB,MAAM,cAAc,CAA4B;AAClF;AAEA,IAAM,WAAN,cAAuB,KAAK;CAIf;CACA;CAJX,OAAgB,OAAe;CAE/B,YACE,YACA,YACA;EACA,MAAM;EAHG,KAAA,aAAA;EACA,KAAA,aAAA;CAGX;CAGA,iBAA0B,SAA8B;EACtD,QACG,QAAQ,SAAgD,uBACrD,KAAK,aACL,KAAK,WAAA,CACT,YAAY,OAAO;CACvB;CAEA,MAAe,SAA4B;EACzC,OAAQ,QAAQ,SAAgD,uBAC5D,KAAK,aACL,KAAK;CACX;AACF;;AAGA,SAAgB,kBAAkC,QAAW,QAAc;CACzE,OAAO,IAAI,SAAS,QAAQ,MAAM;AACpC;AAEA,IAAM,gBAAN,cAA4B,KAAK;CAC/B,OAAgB,OAAO;CACvB;CACA;CACA,KAAkB;CAElB,YAAY,OAAa,WAAuB;EAC9C,MAAM;EACN,KAAK,KAAK;EACV,KAAK,MAAM;CACb;CAEA,iBAA0B,SAA8B;EACtD,O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Q,KAAK,MAAM;GAChE,IAAI,KAAK,UAAU,MAAM,KAAK,YAAY,QAAQ,KAAK,MAAM;GAC7D,IAAI,KAAK,UAAU,MAAM,KAAK,cAAc,QAAQ,KAAK,MAAM;EACjE;EACA,KAAK,uBAAuB,IAAI;EAChC,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,SAAS,KAAK;GACpB,IACE,QAAQ,iBACR,OAAO,OAAO,UAAU,YACxB,EAAE,UAAU,IAAI,WAAW,QAAQ,IAEnC,OAAO,QAAS,KAAK,IAAkB,CAAuB;EAElE;EACA,IAAI,KAAK,MAAM,KAAK,MAAM,OAAO,KAAK,KAAK,QAAQ;EACnD,OAAO;CACT;;;;;CAMA,UAAU,SAAiC;EACzC,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,MAAM,uDAAuD;EAC3F,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,cAAc,QAAQ,QAAQ,UAAU,IAAI;EACpF,IAAI,QAAQ,SAAS,KAAA,GAAW,KAAK,WAAW,QAAQ,WAAW,QAAQ;EAC3E,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,eAAe,QAAQ,KAAK,IAAI,GAAG,QAAQ,QAAQ;EAC5F,IAAI,QAAQ,UAAU,KAAA,GAAW,KAAK,YAAY,QAAQ,KAAK,IAAI,GAAG,QAAQ,KAAK;EACnF,IAAI,QAAQ,YAAY,KAAA,GAAW,KAAK,cAAc,QAAQ,KAAK,IAAI,GAAG,QAAQ,OAAO;EACzF,OAAO;CACT;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { srgbAttributeToWorking } from "./GlyphTextMaterial.js";
|
|
2
2
|
import { FrontSide, LightingModel, MeshBasicNodeMaterial, NodeMaterial } from "three/webgpu";
|
|
3
|
-
import { Fn, abs, attribute, diffuseColor, float, fwidth, length, max, min, mix, positionGeometry, smoothstep, uniform, varyingProperty, vec3, vec4 } from "three/tsl";
|
|
3
|
+
import { Fn, abs, attribute, diffuseColor, float, fwidth, length, max, min, mix, positionGeometry, smoothstep, uniform, varying, varyingProperty, vec3, vec4 } from "three/tsl";
|
|
4
4
|
// src/text/RectMaterial.ts
|
|
5
5
|
var CssShadowLightingModel = class extends LightingModel {
|
|
6
6
|
f;
|
|
@@ -57,19 +57,15 @@ function createRectMaterial(lit, shadowFloor = .24) {
|
|
|
57
57
|
const radius = attribute("sdfRadius", "float");
|
|
58
58
|
const z = attribute("sdfZ", "float");
|
|
59
59
|
const localUv = varyingProperty("vec2", "vUltraRectUv");
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
60
|
+
const halfSizeExpr = rect.zw.sub(rect.xy).toConst().mul(.5).toConst();
|
|
61
|
+
const clampedRadiusExpr = min(radius, min(halfSizeExpr.x, halfSizeExpr.y)).toConst();
|
|
62
|
+
const sizeVarying = varying(halfSizeExpr.sub(clampedRadiusExpr), "vUltraRectSize").setInterpolation("flat", "either");
|
|
63
|
+
const colorVarying = varying(vec4(srgbAttributeToWorking(vec3(color.rgb)), color.a), "vUltraRectColor").setInterpolation("flat", "either");
|
|
64
|
+
const radiusVarying = varying(clampedRadiusExpr, "vUltraRectRadius").setInterpolation("flat", "either");
|
|
63
65
|
material.positionNode = Fn(() => {
|
|
64
66
|
const quad = positionGeometry.xy;
|
|
65
67
|
const size = rect.zw.sub(rect.xy).toConst();
|
|
66
|
-
const halfSize = size.mul(.5).toConst();
|
|
67
|
-
const linearRgb = srgbAttributeToWorking(vec3(color.rgb)).toConst();
|
|
68
|
-
const clampedRadius = min(radius, min(halfSize.x, halfSize.y)).toConst();
|
|
69
68
|
localUv.assign(quad.sub(.5).mul(size));
|
|
70
|
-
sizeVarying.assign(halfSize.sub(clampedRadius));
|
|
71
|
-
colorVarying.assign(vec4(linearRgb, color.a));
|
|
72
|
-
radiusVarying.assign(clampedRadius);
|
|
73
69
|
const transformed = rect.xy.add(size.mul(quad));
|
|
74
70
|
return vec3(transformed, z);
|
|
75
71
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RectMaterial.js","names":[],"sources":["../../src/text/RectMaterial.ts"],"sourcesContent":["import {\n FrontSide,\n LightingModel,\n MeshBasicNodeMaterial,\n NodeMaterial,\n type LightingModelDirectInput,\n type Node,\n type NodeBuilder,\n type UniformNode,\n} from 'three/webgpu'\nimport {\n Fn,\n abs,\n attribute,\n diffuseColor,\n float,\n fwidth,\n length,\n max,\n min,\n mix,\n positionGeometry,\n smoothstep,\n uniform,\n varyingProperty,\n vec3,\n vec4,\n} from 'three/tsl'\n\nimport { srgbAttributeToWorking } from './GlyphTextMaterial.js'\n\nclass CssShadowLightingModel extends LightingModel {\n readonly v = float(1).toVar('ultraSdfShadowVisibility')\n\n constructor(readonly f: Node<'float'>) {\n super()\n }\n\n override direct({ lightNode }: LightingModelDirectInput): void {\n const shadowNode = (\n lightNode as unknown as {\n readonly shadowNode: Node<'float'> | null\n }\n ).shadowNode\n if (shadowNode) this.v.mulAssign(shadowNode)\n }\n\n override finish(builder: NodeBuilder): void {\n const { outgoingLight } = builder.context as {\n readonly outgoingLight: Node<'vec3'>\n }\n outgoingLight.assign(diffuseColor.rgb.mul(mix(this.f, float(1), this.v)))\n }\n}\n\nclass CssShadowNodeMaterial extends NodeMaterial {\n readonly shadowFloor: UniformNode<'float', number>\n\n // Defaulted so `Material.clone()` — which constructs with no arguments before copying —\n // gets a real number instead of clamping `undefined` into NaN.\n constructor(shadowFloor = 0.24) {\n super()\n this.lights = true\n this.shadowFloor = uniform(Math.min(1, Math.max(0, shadowFloor)))\n }\n\n // The uniform is this class's own state; the base copy only knows node properties.\n override copy(source: this): this {\n super.copy(source)\n this.shadowFloor.value = source.shadowFloor.value\n return this\n }\n\n override setupOutgoingLight(): Node<'vec3'> {\n return diffuseColor.rgb\n }\n\n override setupLightingModel(): LightingModel {\n return new CssShadowLightingModel(this.shadowFloor)\n }\n}\n\n/**\n * Instanced rounded-rectangle material for copied DOM backgrounds. `lit`\n * receivers darken to `shadowFloor` where the shadow map covers them; unlit\n * rectangles reproduce their CSS colour exactly.\n */\nexport function createRectMaterial(lit: boolean, shadowFloor = 0.24): NodeMaterial {\n const material = lit ? new CssShadowNodeMaterial(shadowFloor) : new MeshBasicNodeMaterial()\n material.name = lit ? 'ultra-text TSL rounded shadow receiver' : 'ultra-text TSL rounded DOM rect'\n // Unlit rects keep their CSS colour, so the scene's lights stay out of their shader.\n material.lights = lit\n material.transparent = true\n material.depthWrite = true\n material.depthTest = true\n material.side = FrontSide\n // A flat rect shows one face at a time: set DoubleSide, it draws once without culling\n // instead of a back pass and a front pass.\n material.forceSinglePass = true\n material.toneMapped = false\n\n const rect = attribute<'vec4'>('sdfRect', 'vec4')\n const color = attribute<'vec4'>('sdfColor', 'vec4')\n const radius = attribute<'float'>('sdfRadius', 'float')\n const z = attribute<'float'>('sdfZ', 'float')\n const localUv = varyingProperty('vec2', 'vUltraRectUv')\n const sizeVarying =
|
|
1
|
+
{"version":3,"file":"RectMaterial.js","names":[],"sources":["../../src/text/RectMaterial.ts"],"sourcesContent":["import {\n FrontSide,\n LightingModel,\n MeshBasicNodeMaterial,\n NodeMaterial,\n type LightingModelDirectInput,\n type Node,\n type NodeBuilder,\n type UniformNode,\n} from 'three/webgpu'\nimport {\n Fn,\n abs,\n attribute,\n diffuseColor,\n float,\n fwidth,\n length,\n max,\n min,\n mix,\n positionGeometry,\n smoothstep,\n uniform,\n varying,\n varyingProperty,\n vec3,\n vec4,\n} from 'three/tsl'\n\nimport { srgbAttributeToWorking } from './GlyphTextMaterial.js'\n\nclass CssShadowLightingModel extends LightingModel {\n readonly v = float(1).toVar('ultraSdfShadowVisibility')\n\n constructor(readonly f: Node<'float'>) {\n super()\n }\n\n override direct({ lightNode }: LightingModelDirectInput): void {\n const shadowNode = (\n lightNode as unknown as {\n readonly shadowNode: Node<'float'> | null\n }\n ).shadowNode\n if (shadowNode) this.v.mulAssign(shadowNode)\n }\n\n override finish(builder: NodeBuilder): void {\n const { outgoingLight } = builder.context as {\n readonly outgoingLight: Node<'vec3'>\n }\n outgoingLight.assign(diffuseColor.rgb.mul(mix(this.f, float(1), this.v)))\n }\n}\n\nclass CssShadowNodeMaterial extends NodeMaterial {\n readonly shadowFloor: UniformNode<'float', number>\n\n // Defaulted so `Material.clone()` — which constructs with no arguments before copying —\n // gets a real number instead of clamping `undefined` into NaN.\n constructor(shadowFloor = 0.24) {\n super()\n this.lights = true\n this.shadowFloor = uniform(Math.min(1, Math.max(0, shadowFloor)))\n }\n\n // The uniform is this class's own state; the base copy only knows node properties.\n override copy(source: this): this {\n super.copy(source)\n this.shadowFloor.value = source.shadowFloor.value\n return this\n }\n\n override setupOutgoingLight(): Node<'vec3'> {\n return diffuseColor.rgb\n }\n\n override setupLightingModel(): LightingModel {\n return new CssShadowLightingModel(this.shadowFloor)\n }\n}\n\n/**\n * Instanced rounded-rectangle material for copied DOM backgrounds. `lit`\n * receivers darken to `shadowFloor` where the shadow map covers them; unlit\n * rectangles reproduce their CSS colour exactly.\n */\nexport function createRectMaterial(lit: boolean, shadowFloor = 0.24): NodeMaterial {\n const material = lit ? new CssShadowNodeMaterial(shadowFloor) : new MeshBasicNodeMaterial()\n material.name = lit ? 'ultra-text TSL rounded shadow receiver' : 'ultra-text TSL rounded DOM rect'\n // Unlit rects keep their CSS colour, so the scene's lights stay out of their shader.\n material.lights = lit\n material.transparent = true\n material.depthWrite = true\n material.depthTest = true\n material.side = FrontSide\n // A flat rect shows one face at a time: set DoubleSide, it draws once without culling\n // instead of a back pass and a front pass.\n material.forceSinglePass = true\n material.toneMapped = false\n\n const rect = attribute<'vec4'>('sdfRect', 'vec4')\n const color = attribute<'vec4'>('sdfColor', 'vec4')\n const radius = attribute<'float'>('sdfRadius', 'float')\n const z = attribute<'float'>('sdfZ', 'float')\n const localUv = varyingProperty('vec2', 'vUltraRectUv')\n const sizeExpr = rect.zw.sub(rect.xy).toConst()\n const halfSizeExpr = sizeExpr.mul(0.5).toConst()\n const clampedRadiusExpr = min(radius, min(halfSizeExpr.x, halfSizeExpr.y)).toConst()\n const sizeVarying = varying(\n halfSizeExpr.sub(clampedRadiusExpr),\n 'vUltraRectSize',\n ).setInterpolation('flat', 'either')\n const colorVarying = varying(\n vec4(srgbAttributeToWorking(vec3(color.rgb)), color.a),\n 'vUltraRectColor',\n ).setInterpolation('flat', 'either')\n const radiusVarying = varying(clampedRadiusExpr, 'vUltraRectRadius').setInterpolation(\n 'flat',\n 'either',\n )\n\n material.positionNode = Fn<Node<'vec3'>>((): Node<'vec3'> => {\n const quad = positionGeometry.xy\n const size = rect.zw.sub(rect.xy).toConst()\n localUv.assign(quad.sub(0.5).mul(size))\n const transformed = rect.xy.add(size.mul(quad))\n return vec3(transformed, z)\n })()\n\n const point = abs(localUv).sub(sizeVarying).toConst()\n const outside = length(point.max(0))\n const inside = min(max(point.x, point.y), 0)\n const distance = outside.add(inside).sub(radiusVarying).toConst()\n const antialias = max(fwidth(distance), 1e-4).toConst()\n const coverage = smoothstep(antialias, antialias.negate(), distance)\n const alpha = colorVarying.a.mul(coverage)\n material.colorNode = vec4(colorVarying.rgb, alpha)\n material.maskNode = alpha.greaterThan(0.001)\n material.maskShadowNode = coverage.greaterThan(0.5).and(colorVarying.a.greaterThan(0.5))\n\n return material\n}\n"],"mappings":";;;;AAgCA,IAAM,yBAAN,cAAqC,cAAc;CAG5B;CAFrB,IAAa,MAAM,CAAC,CAAC,CAAC,MAAM,0BAA0B;CAEtD,YAAY,GAA2B;EACrC,MAAM;EADa,KAAA,IAAA;CAErB;CAEA,OAAgB,EAAE,aAA6C;EAC7D,MAAM,aACJ,UAGA;EACF,IAAI,YAAY,KAAK,EAAE,UAAU,UAAU;CAC7C;CAEA,OAAgB,SAA4B;EAC1C,MAAM,EAAE,kBAAkB,QAAQ;EAGlC,cAAc,OAAO,aAAa,IAAI,IAAI,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;CAC1E;AACF;AAEA,IAAM,wBAAN,cAAoC,aAAa;C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AAQ;CACnC,MAAM,gBAAgB,QAAQ,mBAAmB,kBAAkB,CAAC,CAAC,iBACnE,QACA,QACF;CAEA,SAAS,eAAe,SAAqC;EAC3D,MAAM,OAAO,iBAAiB;EAC9B,MAAM,OAAO,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,QAAQ;EAC1C,QAAQ,OAAO,KAAK,IAAI,EAAG,CAAC,CAAC,IAAI,IAAI,CAAC;EACtC,MAAM,cAAc,KAAK,GAAG,IAAI,KAAK,IAAI,IAAI,CAAC;EAC9C,OAAO,KAAK,aAAa,CAAC;CAC5B,CAAC,CAAC,CAAC;CAEH,MAAM,QAAQ,IAAI,OAAO,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,QAAQ;CACpD,MAAM,UAAU,OAAO,MAAM,IAAI,CAAC,CAAC;CACnC,MAAM,SAAS,IAAI,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC;CAC3C,MAAM,WAAW,QAAQ,IAAI,MAAM,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,QAAQ;CAChE,MAAM,YAAY,IAAI,OAAO,QAAQ,GAAG,IAAI,CAAC,CAAC,QAAQ;CACtD,MAAM,WAAW,WAAW,WAAW,UAAU,OAAO,GAAG,QAAQ;CACnE,MAAM,QAAQ,aAAa,EAAE,IAAI,QAAQ;CACzC,SAAS,YAAY,KAAK,aAAa,KAAK,KAAK;CACjD,SAAS,WAAW,MAAM,YAAY,IAAK;CAC3C,SAAS,iBAAiB,SAAS,YAAY,EAAG,CAAC,CAAC,IAAI,aAAa,EAAE,YAAY,EAAG,CAAC;CAEvF,OAAO;AACT"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Vector2, type Texture, type UniformNode } from 'three/webgpu';
|
|
1
|
+
import { Vector2, type NodeBuilder, type Texture, type UniformNode } from 'three/webgpu';
|
|
2
2
|
import type { SdfColorLayer, SdfDropShadowOptions, SdfOutlineOptions, SdfTextQuality } from '../types.js';
|
|
3
3
|
import { GlyphTextMaterial, type GlyphTextMaterialOptions } from './GlyphTextMaterial.js';
|
|
4
4
|
export interface SdfTextMaterialOptions extends GlyphTextMaterialOptions {
|
|
5
5
|
/** Companion colour band from SdfAtlas; omitted keeps the original shader graph. */
|
|
6
6
|
colorLayer?: SdfColorLayer;
|
|
7
|
-
outline?: SdfOutlineOptions;
|
|
8
|
-
dropShadow?: SdfDropShadowOptions;
|
|
7
|
+
outline?: SdfOutlineOptions | undefined;
|
|
8
|
+
dropShadow?: SdfDropShadowOptions | undefined;
|
|
9
9
|
/** The single-channel distance-field texture, from `SdfAtlas.texture`. */
|
|
10
10
|
atlas: Texture;
|
|
11
11
|
/** Atlas width in texels, from `SdfAtlas.width`. */
|
|
@@ -41,5 +41,11 @@ export declare class SdfTextMaterial extends GlyphTextMaterial {
|
|
|
41
41
|
get shadowCutoff(): UniformNode<'float', number>;
|
|
42
42
|
get stemDarkening(): UniformNode<'float', number>;
|
|
43
43
|
get unitRange(): UniformNode<'vec2', Vector2>;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps beauty alpha-blended draws discard-free on TBDR GPUs (`insideClip` gates `colorNode.a`
|
|
46
|
+
* to 0 unless already clipped in vertex), while depth-writing, wireframe, and shadow passes
|
|
47
|
+
* keep `maskNode` early discard.
|
|
48
|
+
*/
|
|
49
|
+
setupDiffuseColor(builder: NodeBuilder): void;
|
|
44
50
|
constructor(options: SdfTextMaterialOptions);
|
|
45
51
|
}
|