text
text(text : Text) : Fn<vec3>TSL function for creating a TextNode.
TextNode implements vertex shader logic for Text rendering.
It transforms positionLocal based on glyph bounds and SDF atlas data.
This node should be used in material.setupVertex to handle text geometry transformation.
Uses textGlyphTransform with uniform-based parameters for single Text instances.
Parameters
Returns
Fn<vec3> — A callable TSL function that returns the transformed positionExample
import { Text, text } from '@three-blocks/core';
import {
subBuild,
positionLocal,
cameraProjectionMatrix,
modelViewMatrix,
vec4,
Fn
} from 'three/tsl';
const myText = new Text();
myText.text = 'Custom Vertex';
const material = myText.material;
material.setupVertex = (builder) => {
// Build TextNode first - this computes text position and sets up varyings
const textPosition = subBuild(text(builder.object), 'POSITION', 'vec3');
// Start with text position
let finalPosition = textPosition;
// If user has positionNode, assign textPosition to positionLocal first
// so their positionNode can read it, then apply their transformation
if (material.positionNode !== null) {
positionLocal.assign(textPosition);
finalPosition = subBuild(material.positionNode, 'POSITION', 'vec3');
}
// Assign final position to positionLocal for any other code that might need it
positionLocal.assign(finalPosition);
// Build custom MVP using computed position
const mvp = cameraProjectionMatrix
.mul(modelViewMatrix)
.mul(vec4(finalPosition, 1.0));
return mvp;
};