-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskybox.js
51 lines (43 loc) · 1.56 KB
/
skybox.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
function nightBox(scene){
var imagePrefix = "assets/textures/general/skybox/powderpeaknight_";
var directions = ["right", "left", "top", "top", "front", "back"];
var imageSuffix = ".jpg";
var skyGeometry = new THREE.BoxGeometry( 100, 100, 100 );
var materialArray = [];
for (var i = 0; i < 6; i++)
materialArray.push( new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture( imagePrefix + directions[i] + imageSuffix ),
side: THREE.BackSide
}));
var skyMaterial = new THREE.MeshFaceMaterial( materialArray );
night_skyBox = new THREE.Mesh( skyGeometry, skyMaterial );
scene.add( night_skyBox );
night_skyBox.position.set(0,25,0);
}
function dayBox(scene){
var imagePrefix = "assets/textures/general/skybox/powderpeak_";
var directions = ["right", "left", "top", "top", "front", "back"];
var imageSuffix = ".jpg";
var skyGeometry = new THREE.BoxGeometry( 100, 100, 100 );
var materialArray = [];
for (var i = 0; i < 6; i++)
materialArray.push( new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture( imagePrefix + directions[i] + imageSuffix ),
side: THREE.BackSide
}));
var skyMaterial = new THREE.MeshFaceMaterial( materialArray );
day_skyBox = new THREE.Mesh( skyGeometry, skyMaterial );
day_skyBox.position.set(0,25,0);
scene.add(day_skyBox );
}
function updateSkybox(scene){
if (sphereLightMesh.position.y <= 0){
scene.add(night_skyBox);
scene.remove(day_skyBox);
box = night_skyBox;
} else {
scene.add(day_skyBox);
scene.remove(night_skyBox);
box = day_skyBox;
}
}