-
Notifications
You must be signed in to change notification settings - Fork 0
/
3d_glb_colour.html
72 lines (62 loc) · 2.54 KB
/
3d_glb_colour.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
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Viez - 3D Kelter</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/img/icons/faviconOrange/original-orange.png" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/icons/faviconOrange/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/img/icons/faviconOrange/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/img/icons/faviconOrange/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<script src="https://threejs.org/build/three.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src="https://threejs.org/examples/js/loaders/GLTFLoader.js"></script>
<script>
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xf8f9fa)
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
const loader = new THREE.GLTFLoader()
loader.load('assets/3d/kelter_colour.glb', function(gltf) {
console.log(gltf)
const root = gltf.scene;
root.scale.set(18,18, 18)
scene.add(root);
}, function(xhr) {
console.log((xhr.loaded / xhr.total * 100) + '% loaded')
}, function(error) {
console.log('An error occured')
})
const light = new THREE.DirectionalLight(0xffffff, 1)
//const light = new THREE.HemisphereLight(0xffffff, 0xdddddd, 1);
light.position.set(1, 1, 2)
//light.position.x = 0;
//ight.position.y = 2;
//light.position.z = 8;
scene.add(light)
const controls = new THREE.OrbitControls(camera, renderer.domElement);
camera.position.x = -2;
camera.position.y = -0.8;
camera.position.z = 6;
controls.update();
const animate = function() {
requestAnimationFrame(animate);
controls.update();
renderer.render(scene, camera);
};
animate();
</script>
</body>
</html>