-
Notifications
You must be signed in to change notification settings - Fork 0
/
webgl.html
52 lines (33 loc) · 1.24 KB
/
webgl.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
<!doctype html><script src="js/three.min.js"></script>
<script>// <![CDATA[
// Our 3D code will go here...
var scene, camera, renderer;
var geometry, material, mesh, sphereGeometry, sphereMesh, sphereMaterial;
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 1000;
geometry = new THREE.BoxGeometry( 200, 200, 200 );
sphereGeometry = new THREE.SphereGeometry( 50, 64, 64);
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
sphereMaterial = new THREE.MeshBasicMaterial( { color: 0x00ff00, wirefame: false} );
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
sphereMesh = new THREE.Mesh( sphereGeometry, sphereMaterial);
scene.add(sphereMesh);
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
}
function animate() {
requestAnimationFrame( animate );
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
sphereMesh.position.x += 0.05;
//camera.position.x += 1;
camera.lookAt(mesh.position);
renderer.render( scene, camera );
}
// ]]></script>