I created a skybox on a Three.js canvas like this:
var urls = [
'pos-x.jpg',
'neg-x.jpg',
'pos-y.jpg',
'neg-y.jpg',
'pos-z.jpg',
'neg-z.jpg'
]
window.cubemap = THREE.ImageUtils.loadTextureCube(urls);
cubemap.format = THREE.RGBFormat;
window.shader = THREE.ShaderLib['cube'];
shader.uniforms['tCube'].value = cubemap;
window.skyBoxMaterial = new THREE.ShaderMaterial( {
fragmentShader: shader.fragmentShader,
vertexShader: shader.vertexShader,
uniforms: shader.uniforms,
depthWrite: false,
side: THREE.BackSide
});
window.skybox = new THREE.Mesh(
new THREE.BoxGeometry(1000, 1000, 1000),
skyBoxMaterial
);
skybox.position.set(0, 0, 0);
scene.add(skybox);
My problem is that any 'div' I try to add above the canvas is hidden behind the skybox whatever z-index I give it. They show up if I do not add the skybox. Does anybody know why and how to fix it?
I add the divs after the Three.js canvas tag in the HTML body and it worked.