Skip to content

Commit dfecb86

Browse files
committed
commit wip
1 parent aea155e commit dfecb86

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/examples/22_3d_text.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
# 3D Text in Vuer
3+
4+
This example demonstrates how to create and customize 3D text in Vuer using the Text3D component.
5+
The Text3D component renders 3D text using ThreeJS's TextGeometry.
6+
7+
![3D Text Example](figures/22_3d_text.png)
8+
9+
```python
10+
from asyncio import sleep
11+
12+
from vuer import Vuer
13+
from vuer.schemas import (
14+
Text3D,
15+
Center,
16+
DefaultScene,
17+
Group,
18+
Box,
19+
AmbientLight,
20+
DirectionalLight,
21+
)
22+
23+
app = Vuer()
24+
25+
@app.spawn(start=True)
26+
async def show_3d_text(session):
27+
# Create a scene with some basic elements
28+
session.set @ DefaultScene(
29+
# Basic 3D text example
30+
Center(
31+
Text3D(
32+
"Hello Vuer!",
33+
font="https://threejs.org/examples/fonts/helvetiker_regular.typeface.json",
34+
smooth=1,
35+
position=[0, 1, 0],
36+
color="blue",
37+
scale=0.2,
38+
),
39+
key="centered-text",
40+
),
41+
# Customized 3D text with different parameters
42+
Group(
43+
Text3D(
44+
"Custom Text",
45+
font="https://threejs.org/examples/fonts/helvetiker_bold.typeface.json",
46+
smooth=0.5,
47+
lineHeight=0.5,
48+
letterSpacing=-0.025,
49+
position=[0, 0, 0],
50+
color="red",
51+
scale=0.15,
52+
),
53+
position=[0, -0.5, 0],
54+
key="custom-text",
55+
),
56+
# A small platform below the text
57+
Box(
58+
width=3,
59+
height=0.1,
60+
depth=1,
61+
position=[0, -1, 0],
62+
color="#888888",
63+
),
64+
# Add lighting to make the text visible
65+
AmbientLight(intensity=0.5, key="ambient_light"),
66+
DirectionalLight(intensity=1, position=[1, 2, 2], key="directional_light"),
67+
)
68+
await sleep(0.1)
69+
70+
# Demo of rotating text
71+
angle = 0
72+
while True:
73+
angle += 0.1
74+
session.update @ Group(rotation=[0, angle, 0], key="custom-text")
75+
await sleep(0.05)
76+
```

0 commit comments

Comments
 (0)