0

I am working with Panolens.js to get a basic 3d image viewer up and running. I am working off the example provided in the documentation, but I am having console errors when loading. This is my first time working with equirectangular photography and Panolens/ThreeJS.

I have included the code:

var panorama, viewer;

panorama = new PANOLENS.ImagePanorama('http://via.placeholder.com/720x360');

viewer = new PANOLENS.Viewer({
  output: 'console'
});
viewer.add(panorama);
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
}

a:link,
a:visited {
  color: #bdc3c7;
}

.credit {
  position: absolute;
  text-align: center;
  width: 100%;
  padding: 20px 0;
  color: #fff;
}
<script src="https://pchen66.github.io/js/three/three.min.js"></script>
<script src="https://pchen66.github.io/js/panolens/panolens.min.js"></script>
<div class="credit"><a href="https://github.com/pchen66/panolens.js">Panolens.js</a> image panorama example. Image from <a href="http://adaptivesamples.com/tag/equirectangular/">Adaptive Samples</a></div>

The console is giving me this error message:

Failed to load file:///Volumes/Nifty/DoVR%20Media/demo_v1/test.jpg: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

The image I am using is in the same directory. I also tried loading the image from imgur, but that is also giving me an error.

sgerbhctim
  • 3,420
  • 7
  • 38
  • 60

2 Answers2

0

The reason why you got this error is that you open your index.html page as a local page in browser. In address bar you could see file://path_to_your_file.

Some useful details are described in this issue

To avoid this error you should launch some web-server. For example if you have installed python you could launch simple web-server which is embedded in it. Also see details in the issue above.

Another alternative to install VSCode and install Live Server extension. Then open folder by VSCode and click on Go Live button.enter image description here enter image description here

As you could see I launch your code in VSCode with LiveServer and all is working.

0

If the panorama image which you included is on other server then the server should be secure with SSL(https). You have to change http to https: https://via.placeholder.com/720x360

kjain
  • 69
  • 1
  • 7