-
Notifications
You must be signed in to change notification settings - Fork 69
/
text-3D.html
85 lines (70 loc) · 1.79 KB
/
text-3D.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html>
<head>
<title>A-Frame - 3D Text</title>
<script src="js/aframe-master.1.0.4.min.js"></script>
<script src="js/aframe-text-geometry-component.min.js"></script>
</head>
<body>
<script>
AFRAME.registerComponent('updater', {
init: function()
{
// apply material to this.el.object3d
},
tick: function (time, timeDelta)
{
let t = Math.round(time/1000);
let newText = "Seconds: " + t;
let currentText = this.el.getAttribute("text-geometry")["value"];
// only update if newText is different than current text displayed.
if (newText != currentText)
{
this.el.setAttribute("text-geometry", "value", newText)
}
}
});
</script>
<a-scene>
<a-assets>
<img id="grid" src="images/border.png" />
<img id="sky" src="images/stars.jpg" />
<img id="hexagons" src="images/hexagons.png" />
<a-asset-item id="customFont" src="fonts/helvetiker_regular.typeface.json"></a-asset-item>
</a-assets>
<a-sky
rotation = "0 0 0"
color = "#FFFFFF"
material = "src: #sky">
</a-sky>
<a-plane
width="100" height="100"
position=" 0.00 0.00 0.00"
rotation="-90 0 0"
color="#888888"
material="src: #grid; repeat:100 100; transparent: true; opacity: 0.75"
shadow="cast: false; receive: true">
</a-plane>
<--
uses the text-geometry component:
https://github.com/supermedium/superframe/tree/master/components/text-geometry
see also:
https://threejs.org/docs/#api/en/geometries/TextGeometry
height: depth of text
-->
<a-entity
id="textArea"
position="-1.5 2 -3"
text-geometry="font: #customFont;
size: 0.5;
height: 0.1;
bevelEnabled: true;
bevelSize: 0.02;
bevelThickness: 0.02;
value: Seconds: ?"
material="color: #AAAAFF; src: #hexagons; repeat: 20 20;"
updater>
</a-entity>
</a-scene>
</body>
</html>