/** * textGlyphTransform - Core TSL function for glyph geometry transformation. * * This is the shared logic used by both TextNode (single Text) and BatchedTextNode * (BatchedText). It computes glyph position from bounds, handles clipping, and * calculates atlas UV coordinates. * * The function is parameterized to work with either: * - Uniforms (for single Text via TextNode) * - Per-member storage buffers (for BatchedText via BatchedTextNode) * * @module textGlyphTransform */ import type { TSLFloatNode, TSLFunction, TSLVec2Node, TSLVec3Node, TSLVec4Node } from '../types/tsl.js'; export interface TextGlyphTransformParameters { glyphBounds: TSLVec4Node; atlasIndex: TSLFloatNode; letterId: TSLFloatNode; wordId: TSLFloatNode; clipRect: TSLVec4Node; posOffset: TSLVec2Node; distanceOffset: TSLFloatNode; blurRadius: TSLFloatNode; totalBounds: TSLVec4Node; sdfTextureSize: TSLVec2Node; sdfGlyphSize: TSLFloatNode; } /** * Core glyph transformation function. * * Takes glyph bounds and text parameters, computes: * 1. Clipped glyph position in local space * 2. Atlas UV coordinates for SDF lookup * 3. Glyph dimensions and texture channel * * Sets up varyings for fragment shader compatibility: * - vTextPacked0: vec4(textUV.xy, glyphUV.xy) * - vTextPacked1: vec4(glyphDims.xy, texChannel, letterId) * - vTextTextureUVBounds: vec4(atlasStart.xy, atlasEnd.xy) * - vTextWordId: float (word/member index) * * @tsl * @param {Object} params - Transformation parameters * @param {ShaderNode} params.glyphBounds - vec4(minX, minY, maxX, maxY) glyph bounds * @param {ShaderNode} params.atlasIndex - float atlas glyph index * @param {ShaderNode} params.letterId - float letter index within text * @param {ShaderNode} params.wordId - float word/member index (0 for single Text) * @param {ShaderNode} params.clipRect - vec4(minX, minY, maxX, maxY) clip rectangle * @param {ShaderNode} params.posOffset - vec2(offsetX, offsetY) position offset * @param {ShaderNode} params.distanceOffset - float SDF distance offset (outline) * @param {ShaderNode} params.blurRadius - float SDF blur radius * @param {ShaderNode} params.totalBounds - vec4(minX, minY, maxX, maxY) text block bounds * @param {ShaderNode} params.sdfTextureSize - vec2(width, height) SDF atlas size * @param {ShaderNode} params.sdfGlyphSize - float glyph tile size in atlas * @returns {Fn} TSL function that returns the transformed position (vec3) * * @tags WebGPU, WebGL * @category Text * @private */ export declare function textGlyphTransform({ glyphBounds, atlasIndex, letterId, wordId, clipRect, posOffset, distanceOffset, blurRadius, totalBounds, sdfTextureSize, sdfGlyphSize, }: TextGlyphTransformParameters): TSLFunction<[], TSLVec3Node>;