-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
77 lines (58 loc) · 1.86 KB
/
index.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
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset=UTF-8 />
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<script src="three.min.js"></script>
<script src="GLTFLoader.js"></script>
<script src="OrbitControls.js"></script>
<script>
let scene, camera, render
function init() {
scene = new THREE.Scene()
scene.background = new THREE.Color(0xdddddd)
camera = new THREE.PerspectiveCamera(25, window.innerWidth/window.innerHeight,0.1,50)
//camera.rotation.y = 45/180*Math.PI
camera.position.x = -1
camera.position.y = 1
camera.position.z = 1
hlight = new THREE.AmbientLight(0x404040, 0.5)
scene.add(hlight)
directionalLight = new THREE.DirectionalLight(0xffffff, 1.8)
directionalLight.position.set(0,1,0)
directionalLight.castShadow = true
scene.add(directionalLight)
light = new THREE.PointLight(0xc4c4cc4, 1)
light.position.set(0, -500, 0)
scene.add(light)
/*light2 = new THREE.PointLight(0xc4c4cc4, 1)
light.position.set(500, 100, 0)
scene.add(light2)
light3 = new THREE.PointLight(0xc4c4cc4, 1)
light.position.set(0, 100, -500)
scene.add(light3)
light4 = new THREE.PointLight(0xc4c4cc4, 1)
light.position.set(-5000, 300, 0)
scene.add(light4)*/
renderer = new THREE.WebGLRenderer({antialias: true})
renderer.setSize(window.innerWidth, window.innerHeight)
controls = new THREE.OrbitControls(camera, renderer.domElement);
document.body.appendChild(renderer.domElement)
let loader = new THREE.GLTFLoader()
loader.load('scene.gltf', function(gltf){
car = gltf.scene.children[0]
car.scale.set(3, 3, 3)
scene.add(gltf.scene)
animate();
})
}
function animate() {
renderer.render(scene,camera);
requestAnimationFrame(animate);
}
init();
</script>
</body>
</html>