-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
70 lines (54 loc) · 1.76 KB
/
main.js
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
let scene, camera, renderer, controls, model, hemiLight, spotLight;
function init() {
scene = new THREE.Scene();
scene.background = new THREE.CubeTextureLoader()
.setPath( 'model/' )
.load( [
'posx.jpg',
'negx.jpg',
'posy.jpg',
'negy.jpg',
'posz.jpg',
'negz.jpg',
] );
camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 1, 5000);
camera.position.set(200, 155, 155);
camera.zoom = 0.5;
//scene.add(new THREE.AxesHelper(500));
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
controls = new THREE.OrbitControls(camera, renderer.domElement);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
//set up lights : hemispherical light
hemiLight = new THREE.HemisphereLight();
scene.add(hemiLight);
//set up lights : spot lights
spotLight = new THREE.SpotLight(0xffa95c, 18);
//spotLight.castShadow = true;
spotLight.position.set(-10, -10, -10);
scene.add(spotLight);
//tone mapping
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.0;
//model upload
renderer.shadowMap.enabled = true;
//add button listeners
new THREE.GLTFLoader().load(`model/model2/scene.gltf`, result => {
model = result.scene.children[0];
model.scale.setScalar(0.8);
model.position.set(0, 0, -35);
scene.add(model);
animate();
});
animate();
}
function animate() {
renderer.render(scene, camera);
spotLight.position.set(
camera.position.x + 10,
camera.position.y + 10,
camera.position.z + 10,
);
requestAnimationFrame(animate);
}
init();