I'm getting "WebGL: INVALID_OPERATION: bindTexture: object not from this context" error while rendering the sky box using below lines of code. Due to that, the texture is not rendering, it give black color background.
This is not the case for all the times, sometimes it will render perfectly some times not. I've compared the geometry and material data while add to the scene, the results are same in both the case.
var urls = [
"img/bg/img-BACK.jpg",
"img/bg/img-FRONT.jpg",
"img/bg/img-TOP.jpg",
"img/bg/img-BOTTOM.jpg",
"img/bg/img-RIGHT.jpg",
"img/bg/img-LEFT.jpg"
],
textureCube = THREE.ImageUtils.loadTextureCube(urls); // load textures
textureCube.format = THREE.RGBFormat;
var shader = THREE.ShaderLib["cube"];
shader.uniforms["tCube"].value = textureCube;
var skyBoxMaterial = new THREE.ShaderMaterial({
fragmentShader: shader.fragmentShader,
vertexShader: shader.vertexShader,
uniforms: shader.uniforms,
depthWrite: false,
side: THREE.BackSide
});
skyBoxMaterial.needsUpdate = true;
var skybox = new THREE.Mesh(
new THREE.CubeGeometry(10000, 10000, 10000),
skyBoxMaterial
);
scene.add(skybox);
From the above screenshot, the point "1" is the output while I'm getting this error. The point "2" screen is with out any exception while rendering.
Appreciate your support to fix the issue.
skyBoxMaterial.needsUpdate = true;