An issue has been discovered with the THREE.TextureLoader() function, as it seems to load the same assets multiple times (often 20 times or more) in an unexpected and erroneous manner.
The screenshot below from the browser console illustrates this behavior:
https://i.sstatic.net/Bdhg9.jpg
See the code snippet below that is used to load and apply textures:
Element.prototype.createShaderMaterial = function (uniforms, vertexShader, fragmentShader) {
var loader = new THREE.TextureLoader();
uniforms.texture.value = loader.load(this.texture);
return new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
wireframe: true
});
};
A live preview of the issue can be found at: and the game's code is available here: https://github.com/alexprut/earth-defender/tree/master/client/js
What could be causing this behavior? Why is the same image being loaded multiple times?