Sky Box add can make the scene of the model is very beautiful, and its principle is very simple, I believe that after reading the code below can understand.
When it comes to the two methods of the sky box, it is more like two ways of writing, respectively, using the two methods of texture loading: loadtexture and Loadtexturecube.
Special Note: The order of the pictures
"Method One"
var imageprefix = "images/";
var directions = ["Posx", "negx", "Posy", "Negy", "Posz", "Negz"];
var imagesuffix = ". jpg";
var skygeometry = new three. Cubegeometry (80000, 40000, 80000);
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);
var skybox = new three. Mesh (Skygeometry, skymaterial);
Scene.add (Skybox);
"Method Two"
var r = "Textures/cloud/";
var URLs = [r + "Posx.jpg", R + "Negx.jpg",
R + "Posy.jpg", R + "Negy.jpg",
R + "Posz.jpg", R + "Negz.jpg"];
Texturecube = three. Imageutils.loadtexturecube (URLs); Defining a square box texture path
= = = Shader = = =
var shader = three. shaderlib["Cube"];
shader.uniforms["Tcube"].value = Texturecube;
var material = new three. Shadermaterial ({
FragmentShader:shader.fragmentShader,
VertexShader:shader.vertexShader,
Uniforms:shader.uniforms,
Depthwrite:false,
Side:three. Backside
}),
Mesh = new three. Mesh (new three. Cubegeometry (+, +), material); Create a square box and add the box scene
Scenecube.add (mesh);
Two ways to add a sky box in WebGL