Open jeromeetienne opened 10 years ago
there is a nice converter of skybox image in webgl_shaders_ocean.html which convert skybox in 'cross' format into multi image ones (the one understood by three.js)
var loader = new THREE.ImageLoader(); loader.load( 'textures/skyboxsun25degtest.png', function ( image ) { var getSide = function ( x, y ) { var size = 1024; var canvas = document.createElement( 'canvas' ); canvas.width = size; canvas.height = size; var context = canvas.getContext( '2d' ); context.drawImage( image, - x * size, - y * size ); return canvas; }; cubeMap.image[ 0 ] = getSide( 2, 1 ); // px cubeMap.image[ 1 ] = getSide( 0, 1 ); // nx cubeMap.image[ 2 ] = getSide( 1, 0 ); // py cubeMap.image[ 3 ] = getSide( 1, 2 ); // ny cubeMap.image[ 4 ] = getSide( 1, 1 ); // pz cubeMap.image[ 5 ] = getSide( 3, 1 ); // nz cubeMap.needsUpdate = true; } ); var cubeShader = THREE.ShaderLib['cube']; cubeShader.uniforms['tCube'].value = cubeMap; var skyBoxMaterial = new THREE.ShaderMaterial( { fragmentShader: cubeShader.fragmentShader, vertexShader: cubeShader.vertexShader, uniforms: cubeShader.uniforms, depthWrite: false, side: THREE.BackSide }); var skyBox = new THREE.Mesh( new THREE.BoxGeometry( 1000000, 1000000, 1000000 ), skyBoxMaterial ); scene.add( skyBox );
It may be interesting to put that somewhere in the module
there is a nice converter of skybox image in webgl_shaders_ocean.html which convert skybox in 'cross' format into multi image ones (the one understood by three.js)