xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Error: Cross origin image request #164

Closed csvurt closed 8 years ago

csvurt commented 8 years ago

For security reasons WebGL doesn't allow cross origin images or videos to be used as textures unless both sides (client and server) use proper Cross-Origin Resource Sharing (CORS).

XML3D automatically detects cross origin requests and sets the proper crossOrigin attribute, but the server also needs to allow the request by setting the Access-Control-Allow-Origin header in the response. If the server doesn't allow the request in this way then the texture can't be used because it would mark the WebGL context as "dirty", which severely restricts what can be done with it.

If you are seeing this error in the console then the source of the texture that you've used didn't set the proper CORS header in the response. In this case XML3D has no choice but to throw the texture away to avoid dirtying the WebGL context. To fix it, either serve the texture locally (from the same origin) or (if you can) reconfigure the server to send the proper Access-Control-Allow-Origin header in response to a cross-origin request.

This issue will be closed as it's meant to provide help only, but if you have any questions or tips for other users regarding this error please post them here!