-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
68 lines (56 loc) · 1.57 KB
/
index.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
<html><head><title>"3js Scene yo! LOVIN IT!<3"</title></head>
<body>
<script src="three.js"></script>
<script>
div = document.createElement("div")
div.innerHTML = "check it out yo!"
div.setAttribute("style","color:white;font-family:lucida;font-size:30px")
document.body.append(div)
document.body.style.backgroundColor = "black"
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight,
0.1,1000
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial({color:0x00ff00});
const cube = new THREE.Mesh(geometry,material);
const geo2 = new TextGeometry( 'Hello three.js!', {
font: "verdana",
size: 80,
height: 5,
curveSegments: 12,
bevelEnabled: true,
bevelThickness: 10,
bevelSize: 8,
bevelOffset: 0,
bevelSegments: 5
} );
const cube2 = new THREE.Mesh(geo2,material)
scene.add(cube2);
camera.position.z = 5;
camera.position.x = 1;
renderer.render(scene, camera);
window.addEventListener("keypress",(event)=>{
if(event.key=="w"){
camera.position.z-=.1
renderer.render(scene, camera);
}
if(event.key=="s"){
camera.position.z+=.1
renderer.render(scene, camera);
}
if(event.key=="a"){
camera.rotation.y-=.01
renderer.render(scene, camera);
}
if(event.key=="d"){
camera.rotation.y+=.01
renderer.render(scene, camera);
}
})
</script>
</body>
</html>