In my project, I have a set of checkbox booleans that trigger the loading of different textures onto a sphere using three.js.
However, I am facing an issue where these images are not loading quickly enough, causing a performance lag. I believe I need to preload them, but I'm unsure of the best approach to do so. I have also included my current code below, in case there is a more efficient solution or unnecessary code present.
function showPoliticalMap(){
var world = scene.getObjectByName("world").children[1],
cloud = scene.getObjectByName("cloud"),
uri = world.material.map.image.baseURI;
scene.remove(cloud);
spotlight.intensity = 0;
ambientLight.intensity = 1;
world.material.map.image.currentSrc = uri + "img/earthmapoutlineblue_optimized.jpg";
world.material.map.image.src = uri + "img/earthmapoutlineblue_optimized.jpg";
world.material.map.needsUpdate = true;
world.material.needsUpdate = true;
}