My latest project involves creating a reflection cube with randomly changing images on each side every time the site is reloaded. Here is the code I have written:
var imgAr = [
'sources/instagram2/image1.jpg',
'sources/instagram2/image2.jpg',
'sources/instagram2/image3.jpg',
'sources/instagram2/image4.jpg',
'sources/instagram2/image5.jpg',
'sources/instagram2/image6.jpg',
'sources/instagram2/image7.jpg',
'sources/instagram2/image8.jpg',
'sources/instagram2/image9.jpg',
'sources/instagram2/image10.jpg'
];
var urls = imgAr.sort(function(){return .6 - Math.random()}).slice(0,6);
var reflectionCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeReflectionMapping );
However, I encountered a challenge when trying to filter images based on file names ending with a number. I attempted the following code, but it didn't work as expected:
var nrString = "000";
images = [
'sources/instagram2/image' + nrString + ".jpg",
'sources/instagram2/image' + nrString + ".jpg",
'sources/instagram2/image' + nrString + ".jpg",
'sources/instagram2/image' + nrString + ".jpg",
'sources/instagram2/image' + nrString + ".jpg",
'sources/instagram2/image' + nrString + ".jpg"
];
var urls = images.sort(function(){return .6 - Math.random()}).slice(0,6);
var reflectionCube = THREE.ImageUtils.loadTextureCube( urls, THREE.CubeReflectionMapping );
If anyone has a solution or suggestions, I would greatly appreciate the help. I've been struggling with this for days now.