-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrubik.html
57 lines (38 loc) · 1.32 KB
/
rubik.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
<script src="three.js/build/Three.js"></script>
<body>
</body>
<script>
var camera, scene, renderer,
geometry, material, mesh;
init();
animate();
function init() {
scene = new THREE.Scene();
loader = new THREE.JSONLoader();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene.add( camera );
geometry = new THREE.CubeGeometry( 200, 200, 200 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
// mesh = new THREE.Mesh( geometry, material );
//scene.add( mesh );
loader.load('rubik_center.obj', function(geo) {
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.1;
mesh.rotation.y += 0.1;
mesh.rotation.z += 0.1;
renderer.render( scene, camera );
}
</script>