I have a ThreeJS scene and I'd like to provide the option of seeing all models in different modes (with or without textures) in the skybox. I used Two kind of function 'getSkyTexture' and 'getSkyColor'. It should work in separately but first, I called getSkyColor
function my background sky color change
after I called getSkyTexture
function my background sky texture change
again I called getskyTexture
is not worked texture. therefore I reset/ remove my skybox map material. How can do this?
function getSkyTexture(id, objMaterial){ //here objMaterial Texture image
console.log('sky texture');
// skyMaterial.map = null;
// skyMaterial.needsUpdate = true;
// skyBox.material.map = null;
// skyBox.material.needsUpdate = true;
var imagePrefix = objMaterial;
var directions = ["xpos","xneg","ypos","yneg","zpos","zneg"];
var imageSuffix = ".png";
materialArray = [];
for (var i = 0; i < 6; i++)
materialArray.push( new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture( imagePrefix + directions[i] + imageSuffix ),
side: THREE.BackSide /*depthWrite: false, fog: false*/
}));
var skyGeometry = new THREE.CubeGeometry( 1000, 1000, 1000);
skyMaterial = new THREE.MeshFaceMaterial( materialArray );
skyBox = new THREE.Mesh( skyGeometry, skyMaterial );
scene3D.add( skyBox );
}
function getSkyColor(id, objMaterial){ //here objMaterial color
console.log('sky color');
/*Here remove/reset my skybox map texture.but not working*/
// renderer3D.autoClear = false;
// materialArray.map =null;
// materialArray.needsUpdate = true;
// skyBox.map = null;
// skyBox.needsUpdate = true;
// skyBox.material.map = null;
// skyBox.material.needsUpdate = true;
// skyMaterial.map = null;
// skyMaterial.needsUpdate = true;
// scene3D.remove(skyMaterial);
// skyBox.MeshFaceMaterial = null;
// skyBox.needsUpdate = true;
// skyMaterial = objMaterial;
var skyGeometry = new THREE.CubeGeometry( 1000, 1000,1000);
skyMaterial = new THREE.MeshBasicMaterial({color: objMaterial, side: THREE.BackSide});
skyBox = new THREE.Mesh( skyGeometry, skyMaterial);
scene3D.add(skyBox);
//renderer3D.setClearColor(objMaterial);
}