-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSimpleRotatingBox.html
More file actions
59 lines (41 loc) · 1.3 KB
/
SimpleRotatingBox.html
File metadata and controls
59 lines (41 loc) · 1.3 KB
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Simple Rotating Box</title>
<script src="lib/three.min.js" type="text/javascript"></script>
</head>
<body>
<script>
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 1000;
scene.add(camera);
var side = 400;
geometry = new THREE.CubeGeometry(side, side, side);
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
renderer = new THREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function animate() {
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame(animate);
render();
}
function render() {
mesh.rotation.x += 0.006;
mesh.rotation.y += 0.00525;
mesh.rotation.z += 0.00475;
renderer.render(scene, camera);
}
</script>
</body>
</html>