-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
68 lines (48 loc) · 1.36 KB
/
example.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
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<style>canvas { width: 100%; height: 100%;}</style>
</head>
<body>
<script src="./three.min.js"></script>
<script>
var camera, scene, renderer;
var mesh, animation;
var init = function () {
// Scene
scene = new THREE.Scene();
// Mesh
var loader = new THREE.JSONLoader(true);
loader.load( "./horse.js", function(geometry) {
var material = new THREE.MeshLambertMaterial({ color: 0x606060, morphTargets: true });
mesh = new THREE.Mesh(geometry, material);
mesh.scale.set(1.5, 1.5, 1.5);
scene.add(mesh);
});
// Camera
camera = new THREE.PerspectiveCamera(30, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.y = 150;
camera.position.x = 400;
camera.position.z = 800;
camera.target = new THREE.Vector3(0, 150, 0);
// Light
var light = new THREE.DirectionalLight(0xffffff, 2);
light.position.set(1, 1, 1).normalize();
scene.add(light);
// Renderer
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xffffff);
// Put stuff in DOM
document.body.appendChild(renderer.domElement);
}
var render = function () {
camera.lookAt(camera.target);
renderer.render(scene, camera);
requestAnimationFrame(render);
};
init();
render();
</script>
</body>
</html>