-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskybox.html
More file actions
68 lines (58 loc) · 2.49 KB
/
skybox.html
File metadata and controls
68 lines (58 loc) · 2.49 KB
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>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<style>
body {
width: 100vw;
height: 100vh;
margin: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script>
let scene, camera, renderer, controls;
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 45, 30000);
camera.position.set(-900, -200, -900);
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.minDistance = 500;
controls.maxDistance = 1500;
controls.update();
let materialArray = [];
let texture_ft = new THREE.TextureLoader().load('/skyboxmaps/dust_ft.jpg');
let texture_bk = new THREE.TextureLoader().load('/skyboxmaps/dust_bk.jpg');
let texture_up = new THREE.TextureLoader().load('/skyboxmaps/dust_up.jpg');
let texture_dn = new THREE.TextureLoader().load('/skyboxmaps/dust_dn.jpg');
let texture_rt = new THREE.TextureLoader().load('/skyboxmaps/dust_rt.jpg');
let texture_lf = new THREE.TextureLoader().load('/skyboxmaps/dust_lf.jpg');
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_ft }));
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_bk }));
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_up }));
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_dn }));
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_rt }));
materialArray.push(new THREE.MeshBasicMaterial({ map: texture_lf }));
for (let i = 0; i < 6; i++) materialArray[i].side = THREE.BackSide;
let skyboxGeo = new THREE.BoxGeometry(10000, 10000, 10000);
let skybox = new THREE.Mesh(skyboxGeo, materialArray);
scene.add(skybox);
animate();
}
function animate() {
controls.update();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
init();
</script>
</body>
</html>