I am getting cors
when I try to load image from server. Normally I can load/display the image with using img
tag but when I try to load it with THREE.TextureLoader()
; it returns cors error.
I tried to handle it like below.
const loader = new THREE.TextureLoader();
loader.setCrossOrigin("anonymous");
let texture = loader.load(src,
function ( texture ) {},
function ( progress ) {},
// error drops as cors
function ( error ) {console.log(error)});
let material = new THREE.MeshBasicMaterial({map: texture});
let mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
Many answer says crossOrigin = ""
fixes the issue but it doesn't. Is there any workaround for cors
handling with textureloader?
access-control-allow-origin: *
as part of the image's response headers? It's something that you'll need to do on the server-side. Source: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/…