-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstep1.html
More file actions
65 lines (57 loc) · 1.64 KB
/
Copy pathstep1.html
File metadata and controls
65 lines (57 loc) · 1.64 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Three.js codelab step 1</title>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style type="text/css">
body {
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script src="js/three.min.js"></script>
<script>
var camera, scene, renderer;
var geometry, material, mesh;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
camera.position = new THREE.Vector3(0, 0, 1000);
scene = new THREE.Scene();
// Create a Geometry
geometry = new THREE.CubeGeometry(200, 200, 200);
// Create a Material
material = new THREE.MeshLambertMaterial({
color : 0xffffff,
});
// Create a Mesh with the Geometry and the Material
mesh = new THREE.Mesh(geometry, material);
// Add it to the Scene
scene.add(mesh);
// Create a Point Light
pointLight = new THREE.PointLight( 0xffffff );
// Set the point light position
pointLight.position = new THREE.Vector3(1000, 1000, 0);
// Add the light to the scene
scene.add( pointLight );
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function animate() {
// Ask for the next frame
requestAnimationFrame(animate);
// Rotate Cube
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
// Render Frame
renderer.render(scene, camera);
}
</script>
</body>
</html>