Despite searching extensively and reading through all available resources, I am unable to find a solution to my issue.
I am currently running this code on a local server (IIS). My objective is to load an image from imgur and utilize it as a texture for an object using the following code:
var savedImage = /[^?]*$/.exec(location.search)[0];
if (savedImage != "") { savedImageLoad("http://i.imgur.com/" + savedImage + ".jpg"); };
function savedImageLoad(image) {
var mapOverlay = new THREE.ImageUtils.loadTexture(image);
sphere.material = new THREE.MeshBasicMaterial({map: mapOverlay, needsUpdate: true});;
sphere.geometry.buffersNeedUpdate = true;
sphere.geometry.uvsNeedUpdate = true;
}
However, an error stating:
Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at http://i.imgur.com/uBD0g95.jpg may not be loaded.
Several attempts were made by adding
THREE.ImageUtils.crossOrigin = "anonymous";
to different parts of the code, but to no avail. Even with the inclusion of a web.config file containing:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
The problem persists. It is worth noting that the issue also occurs on a site hosted on bitbucket.org, indicating a potential flaw in the coding process.
The error seems to originate from the line
sphere.material = new THREE.MeshBasicMaterial({map: mapOverlay, needsUpdate: true});;
, which highlights a failure to update the mesh despite preventing the error by commenting out the line.
I am unsure of what steps to take next and would appreciate any guidance or assistance offered. Thank you.