-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkyBox.js
More file actions
26 lines (22 loc) 路 970 Bytes
/
Copy pathSkyBox.js
File metadata and controls
26 lines (22 loc) 路 970 Bytes
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
//deels credit aan hindrik
class SkyBox extends THREE.Mesh {
constructor(scene, directory) {
let urls = [directory + 'posx.jpg', directory + 'negx.jpg', directory + 'posy.jpg', directory + 'negy.jpg', directory + 'posz.jpg', directory + 'negz.jpg'],
skyGeometry = new THREE.CubeGeometry(10000, 10000, 10000),
materialArray = [],
textureLoader = new THREE.TextureLoader();
for (let url of urls) {
materialArray.push(new THREE.MeshBasicMaterial({
map: textureLoader.load(url),
side: THREE.BackSide
}));
}
let skyMaterial = new THREE.MeshFaceMaterial(materialArray);
super(skyGeometry, skyMaterial);
scene.add(this);
let skyBox = this;
this.loop = scene.main.loop.add(function() {
skyBox.position.set(scene.camera.position.x, scene.camera.position.y, scene.camera.position.z);
});
}
}