-
Notifications
You must be signed in to change notification settings - Fork 0
/
texts.html
202 lines (186 loc) · 5.97 KB
/
texts.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<title>Texts | Three.JS Tinkerspace</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css"
/>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.167.1/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.167.1/examples/jsm/"
}
}
</script>
</head>
<body>
<script type="module">
import {
isSupported,
setBackground,
setResponsive,
renderText,
} from "/functions.js";
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
if (isSupported()) {
const scene = new THREE.Scene();
const clock = new THREE.Clock();
const camera = new THREE.PerspectiveCamera(
50,
window.innerWidth / window.innerHeight,
1,
1500
);
const light = new THREE.DirectionalLight(0xffffff, 10);
const light2 = new THREE.DirectionalLight(0xffffff, 1);
const renderer = new THREE.WebGLRenderer({
alpha: true,
antialias: true,
});
const canvas = renderer.domElement;
const controls = new OrbitControls(camera, canvas);
setBackground({ dark: 0x2b2b2b, light: 0xf5f7ff, scene });
camera.position.set(0, 0, 300);
camera.lookAt(0, 0, 0);
light.position.set(0, 0, 25);
light.target.position.set(0, 0, 0);
light2.position.set(0, 0, -200);
light2.target.position.set(0, 0, 0);
scene.add(light);
scene.add(light.target);
scene.add(light2);
scene.add(light2.target);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
controls.listenToKeyEvents(window);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.screenSpacePanning = false;
controls.minDistance = 100;
controls.maxDistance = 500;
controls.maxPolarAngle = Math.PI / 2;
await renderText({
text: "Gentilis",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: 100,
scene,
});
await renderText({
text: "Waltz, bad nymph, for quick jigs vex.",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/gentilis_regular.typeface.json",
color: 0xff0000,
posY: 85,
scene,
});
await renderText({
text: "Helvetiker (bevel size 0.75, thickness 0.5)",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: 65,
scene,
});
await renderText({
text: "Glib jocks quiz nymph to vex dwarf.",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/helvetiker_regular.typeface.json",
bevelEnabled: true,
bevelThickness: 0.5,
bevelSize: 0.75,
color: 0x00ff00,
posY: 50,
scene,
});
await renderText({
text: "Optimer",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: 30,
scene,
});
await renderText({
text: "Sphinx of black quartz, judge my vow.",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/optimer_regular.typeface.json",
color: 0x0000ff,
posY: 15,
scene,
});
await renderText({
text: "Droid Serif (bevel size 0.25, thickness 0.75)",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: -5,
scene,
});
await renderText({
text: "How quickly daft jumping zebras vex!",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/droid/droid_serif_regular.typeface.json",
bevelEnabled: true,
bevelThickness: 0.75,
bevelSize: 0.25,
color: 0xffff00,
posY: -20,
scene,
});
await renderText({
text: "Droid Sans",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: -40,
scene,
});
await renderText({
text: "The five boxing wizards jump quickly.",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/droid/droid_sans_regular.typeface.json",
color: 0xff00ff,
posY: -55,
scene,
});
await renderText({
text: "Droid Sans Mono (bevel size 0.1, thickness 0.25)",
font: "/fonts/sono_regular.json",
size: 5,
flat: true,
color: 0xaaaaaa,
posY: -75,
scene,
});
await renderText({
text: "Mr. Jock, TV quiz PhD, bags few lynx.",
font: "https://raw.githubusercontent.com/mrdoob/three.js/master/examples/fonts/droid/droid_sans_mono_regular.typeface.json",
bevelEnabled: true,
bevelThickness: 0.25,
bevelSize: 0.1,
color: 0xffffff,
posY: -90,
scene,
});
function render(time) {
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(render);
}
document.body.appendChild(canvas);
requestAnimationFrame(render);
setResponsive({ canvas, renderer, camera });
}
</script>
</body>
</html>