Vuer

Text

The Text component renders 2D text in 3D space using SDF (Signed Distance Field) rendering. This is ideal for:

  • Creating labels and annotations
  • Building HUD elements
  • Displaying readable text from any distance
  • Adding captions to 3D objects

Basic Usage

A minimal example that creates 2D text in 3D space:

python
import asyncio
from vuer import Vuer
from vuer.schemas import DefaultScene, Text, OrbitControls

app = Vuer()

@app.spawn(start=True)
async def main(session):
    session.set @ DefaultScene(
        Text(
            "Hello World!",
            key="label",
            color="green",
            fontSize=0.15,
            position=[0, 0.5, 0],
        ),
        bgChildren=[
            OrbitControls(key="OrbitControls")
        ],
    )

    while True:
        await asyncio.sleep(1.0)

Key Parameters

Basic Parameters

ParameterTypeDefaultDescription
keystr-Unique identifier for the text
childrenstr-The text content to render
colorstr-Text color (hex or named color)
fontSizefloat-Font size in world units
positionlist[0,0,0]Text position in world coordinates
rotationlist[0,0,0]Text rotation (Euler angles)
scalefloat1Text scale multiplier

Typography Parameters

ParameterTypeDefaultDescription
fontstr-Font URL or name
fontWeightint/str-Font weight (number or 'bold', 'normal', etc.)
fontStylestr-Font style: 'italic' or 'normal'
charactersstr-Restrict character set for glyph generation

Layout Parameters

ParameterTypeDefaultDescription
maxWidthfloat-Maximum width before text wrapping
lineHeightfloat-Line height as a multiple of fontSize
letterSpacingfloat-Additional spacing between letters
textAlignstr-Text alignment: 'left', 'right', 'center', 'justify'
anchorXfloat/str-Horizontal anchor: number or 'left', 'center', 'right'
anchorYfloat/str-Vertical anchor: 'top', 'top-baseline', 'middle', 'bottom-baseline', 'bottom'
directionstr-Text direction: 'auto', 'ltr', or 'rtl'
overflowWrapstr-Wrapping behavior: 'normal' or 'break-word'
whiteSpacestr-White space handling: 'normal', 'overflowWrap', 'nowrap'

Styling Parameters

ParameterTypeDefaultDescription
fillOpacityfloat-Fill opacity (0-1)
clipRectlist-Clipping rectangle [minX, minY, maxX, maxY]
depthOffsetfloat-Z-offset to avoid z-fighting

Outline Parameters

ParameterTypeDefaultDescription
outlineWidthfloat/str-Outline width (number or string like '2px')
outlineOffsetXfloat/str-Outline X offset
outlineOffsetYfloat/str-Outline Y offset
outlineBlurfloat/str-Outline blur radius
outlineColorstr-Outline color
outlineOpacityfloat-Outline opacity (0-1)

Stroke Parameters

ParameterTypeDefaultDescription
strokeWidthfloat/str-Stroke width (number or string)
strokeColorstr-Stroke color
strokeOpacityfloat-Stroke opacity (0-1)

Advanced Parameters

ParameterTypeDefaultDescription
sdfGlyphSizeint-SDF glyph size for rendering quality
debugSDFbool-Show SDF debug overlay
glyphGeometryDetailint-Level of detail for glyph geometry

Learn More

For detailed examples of using Text, see: