Embarking on my coding journey with JavaScript, I have also been exploring the world of Three.js, a webgl library.
After watching tutorials and conducting experiments, I am proud to share my latest creation: .
In my code, you'll notice that the object reflects a random selection from a folder containing 13 images, out of which 6 are displayed.
var numberOfImages = 13, images = [];
for (var i = 1; i <= numberOfImages; i++) {
images.push('sources/instagram/image' + i + ".jpg");
}
var urls = images.sort(function(){return .6 - Math.random()}).slice(0,6);
var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
reflectionCube.format = THREE.RGBFormat;
As I add new Instagram pictures to the folder, they are automatically included in the rotation.
However, updating the number of images in the code manually can be tedious. I'm seeking a more dynamic solution using regular expressions or other methods to adjust the code automatically based on the images uploaded.
I've come across references to regular expressions as a potential solution. Is this the best approach? Should I invest time in mastering regular expressions for this problem?
If you have any suggestions or alternative solutions, I would greatly appreciate your insights. Whether it's a simple adjustment to the code or a more complex language to learn, I want to ensure I tackle this challenge effectively.