I'm trying to create a cube with a different image on each side using CubeTextureLoader. My process is:
- Load a cube texture using
new THREE.CubeTextureLoader() - Create a new material using the cube texture
- Create a cube using this material
- Draw the cube
The relevant code is below. I can draw a cube with a single material for all faces fine using THREE.TextureLoader(), but when I use CubeTextureLoader I get nothing onscreen or any console errors.
var textureLoader = new THREE.CubeTextureLoader();
textureLoader.load([
'textures/face-1.jpg',
'textures/face-2.jpg',
'textures/face-3.jpg',
'textures/face-4.jpg',
'textures/face-5.jpg',
'textures/face-6.jpg'
], function (texture) {
var material = new THREE.MeshBasicMaterial({
color: 0xffffff,
map: texture
});
var cube = new THREE.Mesh(
new THREE.BoxGeometry(20, 20, 20),
material
);
// add & draw calls happen after all this
});
I'm guessing I'm using the wrong Material type or Mesh but can't find any info or examples on how to do this correctly. Any ideas?