Skip to content

Commit dc3e8f4

Browse files
committed
1.2.1
1 parent e7f5d9d commit dc3e8f4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Chapter1/1.2.1.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2+
<html>
3+
<head>
4+
<script type="text/javascript" src="../lib/three.js"></script>
5+
6+
<script type="text/javascript">
7+
function init() {
8+
// renderer
9+
var renderer = new THREE.WebGLRenderer({
10+
canvas: document.getElementById('mainCanvas')
11+
});
12+
renderer.setClearColor(0x000000); // black
13+
14+
// scene
15+
var scene = new THREE.Scene();
16+
17+
// camera
18+
var camera = new THREE.PerspectiveCamera(45, 4 / 3, 1, 1000);
19+
camera.position.set(0, 0, 5);
20+
scene.add(camera);
21+
22+
// a cube in the scene
23+
var cube = new THREE.Mesh(new THREE.CubeGeometry(1, 2, 3),
24+
new THREE.MeshBasicMaterial({
25+
color: 0xff0000
26+
})
27+
);
28+
scene.add(cube);
29+
30+
// render
31+
renderer.render(scene, camera);
32+
}
33+
</script>
34+
</head>
35+
36+
<body onload="init()">
37+
<canvas id="mainCanvas" width="400px" height="300px" ></canvas>
38+
</body>
39+
</html>

0 commit comments

Comments
 (0)