googlearchive / vrview

Library for embedding immersive media into traditional websites.
http://developers.google.com/cardboard/vrview
Apache License 2.0
1.71k stars 1.09k forks source link

Render: Unable to load texture #269

Closed mdelclaro closed 6 years ago

mdelclaro commented 6 years ago

I've downloaded the project with the built js. When I try to run the example, it gives me this error: "Render: Unable to load texture from" + the file name.

I've tried to change the file, even putting an URL, and it gives me the same error.

"Not allowed to load local resource:" from the console. How can I fix it?

mdelclaro commented 6 years ago

Ok, I setted up a local web server with XAMPP, and now it's working... Just to be sure, there is no way to work fully local with this, right? With no webserver, even if it's a local webserver... Because of the CORS.

sukima commented 6 years ago

Please reopen. Here is proof this does not work!

https://sandbox.tritarget.org/test.html

sukima commented 6 years ago

Never mind. For future readers the fix:

  1. You must enable CORS at the server level, vrview does fancy iframe stuff and browser get real pissy about it unless you have CORS enabled to quell the demons.
  2. You have to load the scripts in the right order. The order in the README is 100% wrong

Quell the Demons

I added this to my .htaccess running Apache:

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin,x-requested-with,content-type"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"

The Correct Order

I have this in my HTML above the actual JS to load the pano:

<script src="https://googlevr.github.io/vrview/build/three.min.js"></script>
<script src="https://googlevr.github.io/vrview/build/vrview.min.js"></script>
<script src="https://googlevr.github.io/vrview/build/embed.min.js"></script>
<script src="https://googlevr.github.io/vrview/build/device-motion-sender.min.js"></script>
<script>
  window.addEventListener('load', onVrViewLoad);
  function onVrViewLoad() {
    // Do the actual VRView.Player stuff here
  }
</script>