-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (45 loc) · 1.39 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
<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>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container = document.getElementById("container")
document.body.appendChild( renderer.domElement );
var material = new THREE.MeshLambertMaterial( { color: 0x00ff00 } );
var sphere = THREE.Mesh( new THREE.SphereGeometry(20,16,16),material);
scene.add( sphere );
camera.position.z = 5;
// (color, intensity)
var light = new THREE.PointLight(0xff55ff, 1.2);
light.position.set(0,0,6);
scene.add(light);
var render = function () {
requestAnimationFrame( render );
animate();
renderer.render(scene, camera);
};
var lastTime = 0;
var rx; var ry;
function animate() {
var timeNow = new Date().getTime();
if (lastTime != 0) {
var elapsed = timeNow - lastTime;
cube.rotation.x += (1 * elapsed) / 1000.0;
cube.rotation.y -= (1 * elapsed) / 1000.0;
}
lastTime = timeNow;
}
render();
</script>
</body>
</html>