-
Notifications
You must be signed in to change notification settings - Fork 119
/
hello_world.html
37 lines (31 loc) · 1.03 KB
/
hello_world.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
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/92/three.js"></script>
<script>
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 1, 1500);
camera.position.set(0, 4, 7);
camera.lookAt(new THREE.Vector3());
fov = camera.fov;
scene = new THREE.Scene();
scene.background = new THREE.Color(0x3B3961);
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(800, 800);
container.appendChild(renderer.domElement);
}
function animate() {
renderer.state.reset();
camera.fov = fov;
camera.aspect = window.innerWidth / window.innerHeight;
renderer.render(scene, camera);
camera.updateProjectionMatrix();
requestAnimationFrame(animate);
}
init();
animate();
</script>
</body>
</html>