Skip to content

Commit b017e21

Browse files
committed
2.3.1 Orthographic Camera
1 parent dc3e8f4 commit b017e21

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Chapter2/2.3.1.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
var renderer = new THREE.WebGLRenderer({
9+
canvas: document.getElementById('mainCanvas')
10+
});
11+
renderer.setClearColor(0x000000);
12+
var scene = new THREE.Scene();
13+
14+
// camera
15+
// canvas size is 400x300
16+
var camera = new THREE.OrthographicCamera(-2, 2, 1.5, -1.5, 1, 10);
17+
camera.position.set(0, 0, 5);
18+
scene.add(camera);
19+
20+
// a cube in the scene
21+
var cube = new THREE.Mesh(new THREE.CubeGeometry(1, 1, 1),
22+
new THREE.MeshBasicMaterial({
23+
color: 0xff0000
24+
})
25+
);
26+
scene.add(cube);
27+
28+
// render
29+
renderer.render(scene, camera);
30+
}
31+
</script>
32+
</head>
33+
34+
<body onload="init()">
35+
<canvas id="mainCanvas" width="400px" height="300px" ></canvas>
36+
</body>
37+
</html>

0 commit comments

Comments
 (0)