-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_2_Basic3D_scene.html
executable file
·57 lines (45 loc) · 1.03 KB
/
3_2_Basic3D_scene.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
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<script src="js/three.min.js"></script>
</head>
<body style="margin: 0; padding:0">
<script>
//global variables
var renderer;
var scene;
var camera;
function createRenderer() {
renderer = new THREE.WebGLRenderer();
renderer.setClearColor(0x000000, 1.0);
renderer.setSize(window.innerWidth, window.innerHeight);
}
function createCamera() {
camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
0.1, 1000);
camera.position.x = 15;
camera.position.y = 16;
camera.position.z = 13;
camera.lookAt(scene.position);
}
//init() gets executed once
function init() {
scene = new THREE.Scene();
createRenderer();
createCamera();
document.body.appendChild(renderer.domElement);
//render() gets called at end of init
//as it looped forever
render();
}
//infinite loop
function render() {
renderer.render(scene, camera);
requestAnimationFrame(render);
}
init();
</script>
</body>
</html>