-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiment3.html
More file actions
86 lines (76 loc) · 2.02 KB
/
experiment3.html
File metadata and controls
86 lines (76 loc) · 2.02 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
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
<html>
<head>
<title>My first three.js app</title>
<style>
body {
margin: 0;
}
canvas {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<script src="js/three.js"></script>
<script src="js/OrbitControls.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
2000
);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var animate = function() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
};
animate();
// adding controls
controls = new THREE.OrbitControls(camera, renderer.domElement);
// adding a simple cube
var geometry = new THREE.BoxGeometry(100, 100, 100);
// adding a list of materials for cube faces
var cubeMaterials = [
new THREE.MeshBasicMaterial({
color: 0xffffff,
wireframe: false,
side: THREE.DoubleSide
}),
new THREE.MeshBasicMaterial({
color: 0x00ffff,
wireframe: false,
side: THREE.DoubleSide
}),
new THREE.MeshBasicMaterial({
color: 0xff00ff,
wireframe: false,
side: THREE.DoubleSide
}),
new THREE.MeshBasicMaterial({
color: 0xffff00,
wireframe: false,
side: THREE.DoubleSide
}),
new THREE.MeshBasicMaterial({
color: 0x00ff00,
wireframe: false,
side: THREE.DoubleSide
}),
new THREE.MeshBasicMaterial({
color: 0xff0000,
wireframe: false,
side: THREE.DoubleSide
})
];
var cube = new THREE.Mesh(geometry, cubeMaterials);
scene.add(cube);
// move back camera
camera.position.z = 50;
</script>
</body>
</html>