Hello,
I have added code for TextureLoader with loading manager. I was using local images for texture and it was working fine. Now i have moved all resources to S3 buket and cause of it TextureLoader is not loading images. Below is code for same.
var manager = new THREE.LoadingManager();
manager.onLoad = function () {}
var textureLoader = new THREE.TextureLoader(manager);
var mat_map = "https://planova3d.s3.eu-central-1.amazonaws.com/wp-content/uploads/2020/10/26043628/heather-texture.jpg";
textureLoader.load(mat_map, function (texture) {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.flipY = false;
texture.repeat = new THREE.Vector2(mat_repeat, mat_repeat);
texture.encoding = THREE.sRGBEncoding;
texture.needsUpdate = true;
mat.map = texture;
if(mat.normalMap){
mat.normalMap = mat.normalMap;
if(mat_normal == 'on'){
mat.normalScale = new THREE.Vector2( 0.2, 0.2);
} else {
mat.normalScale = new THREE.Vector2( 0, 0 );
}
}
mat.needsUpdate = true;
});
I also have AWS cors config setup properly. Below is code of webconfig for it.
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"Etag"
],
"MaxAgeSeconds": 3000
}
]
Below list works fine with above s3 settings.
- GLTFLoader - loading gltf model from s3 bucket.
- RGBELoader - loading HDR file for environment
- Image showing in img tag - above texture jpeg image loads fine in img tag
Not working:
TextureLoader: not loading same image and showing cors issue.
I checked console request / response in network tab.
All Working list contains, request header
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
And contain Response Header
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Etag
Access-Control-Max-Age: 3000
While In Texture loader, both request and response header is missing.
Chrome Version: 87.0.4280.141
Threejs Version: r124
When i see three.js file i think textureLoader function missing requestheader part like its there in GLTF loader. Below code is there in GLTFLoader but not in TextureLoader. I also tried adding it but not working though. Still putting it here.
loader.setRequestHeader( this.requestHeader );
loader.setWithCredentials( this.withCredentials );
Let me know if anyone have solved something like above and help me to solve issue.
Thanks in advance,
Rishi Mehta