Skip to content

Text 3d

Updated

Extruded 3D text.

Type
ent-text-3d
Script class
Text3DEntity
Family
Media

A Text 3D entity turns words into solid letters with depth and bevelled edges. Unlike a flat Text, it is lit by the scene’s lights, and with a Shadow component it casts shadows. Use it for titles, logos, room names and big signs that should feel like real objects.

Every change other than colour builds new geometry for the whole string. The old letters stay visible until the new ones are ready, so the text never blinks, but the cost makes Text 3D best for short strings that rarely change.

Pick a sibling when it fits better: Text for scores, timers, names and paragraphs, or a UI Label for text inside a UI panel.

The props that matter most, on its Text 3D component (Text3DComponent in scripts):

  • text: the string extruded.
  • size: the letter size in metres.
  • depth: how deep the letters are, in metres.
  • bevelEnabled, bevelThickness and bevelSize: round the front edges. Turn the bevel off for long strings or many copies.
  • color: the colour of the lit letters. Changing it only recolours, without rebuilding.
  • center: place the letters around the entity’s position instead of starting from it.

font and fontWeight choose a font family and weight, as for Text.

  1. Add a Text 3D entity to the scene and name it, such as Title.
  2. Type its text, and set size and depth.
  3. Turn center on so the title sits around its position, which makes it easier to place and rotate.
  4. Set color, and optionally a font and fontWeight.
  5. Make sure the scene has lights, since the letters are lit. Add a Shadow component to let them cast shadows.

Show the current round in large solid letters.

RoundTitle.jx
#pragma lifecycle(startup)
// Scene: a Text 3D entity "Title". Other scripts emit 'round/start' with { round }.
let title;
function startup() {
title = findEntity('Title').getComponent(Text3DComponent);
on('round/start', (data) => {
title.setProps({ text: `ROUND ${data.round}`, color: '#22d3ee' });
});
}

How it works:

  • getComponent(Text3DComponent) reaches the letters’ settings.
  • setProps({ text }) builds new geometry; the previous title stays on screen until it is ready.

Change the colour of a 3D sign while the pointer is over it.

SignHover.jx
#pragma lifecycle(startup)
// Scene: a Text 3D entity "Exit Sign" with a Selectable and a
// Signal Emitter on the signal 'exit-sign'.
let sign;
let baseColor;
function startup() {
sign = findEntity('Exit Sign').getComponent(Text3DComponent);
baseColor = sign.props.color;
on('exit-sign', (event) => {
if (event.eventType === EventType.Selectable.Hover) sign.setProps({ color: '#facc15' });
if (event.eventType === EventType.Selectable.Leave) sign.setProps({ color: baseColor });
if (event.eventType === EventType.Selectable.Select) {
findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again
emit('scene/exit');
}
});
}

How it works:

  • A Selectable sends hover and leave as the pointer moves over the sign, and select on a click.
  • A color change only recolours the material, so it is cheap to do on every hover.
  • A click raises the script’s own scene/exit signal for another script to handle.

Animate a title into place when the scene starts.

TitleDrop.jx
#pragma lifecycle(startup)
// Scene: a Text 3D entity "Title" with center: true.
function startup() {
const title = findEntity('Title');
const y = title.position.y;
title.setPosition(title.position.x, y + 2, title.position.z);
Tween.to(title.position, { y: y }, { duration: 1.2, ease: Ease.OutBounce });
}

How it works:

  • The script lifts the title two metres above where it was placed, then tweens its position.y back down.
  • Tween.to(target, values, options) moves the listed numbers of target over duration seconds; Ease.OutBounce makes it land with a bounce.
  • Moving the entity never rebuilds the letters, so animating its transform is cheap.
  • Lower curveSegments and turn off the bevel for long strings or many copies: both multiply the triangle count.
  • Only Latin letters with accents, punctuation, currency signs, arrows and a few marks are extruded; other characters are not drawn.
  • A dark scene makes dark letters: Text 3D is lit, unlike Text.

What a new Text 3d is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.

Component Type Role Per entity What it does
Layer comp-layer Required One Puts the entity on a render/raycast layer so cameras and rays can include or skip it.
Lock comp-lock Required One Editor-only flag that stops the entity from being selected or moved.
Enable comp-enable Required One Turns the entity and its children on or off: hides them and stops their behavior.
Transform comp-transform Required One Position, rotation and scale of the entity, with optional editor-only per-axis locks.
Text 3d comp-text-3d Required One Extruded 3D text.

You can also add 17 optional components, such as Animation Graph, Animation Timeline, Attribution, Contact Shadow, Enable On Signal, Follow Target.

The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).

Prop Default Range
text "Text"
size 1 0.001 ≤ x ≤ 10000
depth 0.2 0 ≤ x ≤ 10000
curveSegments 12 1 ≤ x ≤ 64
bevelEnabled true
bevelThickness 0.03 0 ≤ x ≤ 100
bevelSize 0.02 0 ≤ x ≤ 100
bevelOffset 0 -100 ≤ x ≤ 100
letterSpacing 0 -10000 ≤ x ≤ 10000
lineHeight 1 -10 ≤ x ≤ 10
color "#ffffff"
center false

With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.

It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.

Run it in the browser, read its scripts, and download it as an XR Creator project.

Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My Text 3d.

Text3DEntity.jx
#pragma lifecycle(startup)
function startup() {
// Find the entity by the name it has in the Hierarchy.
const entity = findEntity('My Text 3d');
if (!(entity instanceof Text3DEntity)) return;
// Its Text 3d component holds the settings listed under Props.
const component = entity.getComponent(Text3DComponent);
log('size is', component.props.size);
component.setProps({ size: 1.5 });
}