2

I'm trying to load texture with PlayCanvas webGL library from an Amazon S3 bucket but an error happens after loading:

Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at --- may not be loaded.

launched by playcanvas-stable.js at line

gl.texImage2D(gl.TEXTURE_2D, mipLevel, texture._glInternalFormat, texture._glFormat, texture._glPixelType, mipObject);

I made a redirect from 'example.example.com' to 'resources.example.com'. The redirect URL (resources.example.com) is the address of Amazon S3 bucket where texture are stored.

I see many similar errors, so I set the Amazon S3 bucket CORS in this way:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>

But nothing changes...

Is there something I can fix?

Have you found similar issues?

Thanks.

gman
  • 100,619
  • 31
  • 269
  • 393
ar099968
  • 6,963
  • 12
  • 64
  • 127
  • Have you configured playcanvas to request CORS permissions for your images? It most likely does not happen by default because it takes longer to download images with CORS than without. Though I have no idea as I have not used playcanvas – gman Mar 03 '17 at 19:30
  • This example shows loading an image with CORS permissions https://playcanvas.com/editor/code/420164/texture.js – gman Mar 03 '17 at 19:38

0 Answers0