mistic100 / Photo-Sphere-Viewer

A JavaScript library to display 360° sphere panoramas.
https://photo-sphere-viewer.js.org
MIT License
1.87k stars 677 forks source link

API Documentation and NPM Install #134

Closed topherbuckley closed 7 years ago

topherbuckley commented 7 years ago

PSV: 3.2.3 ThreeJS: npm package three@0.86.0 Web Browser: Chromium 58.0.3029.110 Built on Ubuntu , running on Ubuntu 16.04 (64-bit)

I just picked up my omnitone+PSV project again today and noticed that the API documentation looks quite different compared to the last time I looked. Is this getting a complete overhaul or am I completely confused?

A few examples of differences I noticed between the examples here and the API docs here:

In the example, a PhotoSphereViewer object is created and along with assigning things to the the container and panorama attributes even though the API states that the container attribute is readonly, and the panorama attribute doesn't even seem to exist, but the images might now be set through a method setPanorama().

<script>
  var viewer = PhotoSphereViewer({
    container: 'container-id',
    panorama: 'path/to/panorama.jpg'
  });
</script>

The demo I created a few weeks back is still not throwing any errors even after updating the photo-sphere-viewer npm package, and I am using syntax similar to above. Here is my initialization code:

viewer = new PhotoSphereViewer({
  container: 'photosphere',
  panorama: '/src/images/2.jpg',
  navbar: [
    'autorotate',
    'zoom',
    {
      id: 'my-button',
      title: 'Hello world',
      className: 'custom-button',
      content: 'Custom',
      onClick: function() {
       alert('Hello from custom button');
      }
    },
    'caption',
    'fullscreen'
  ]
});

So my main question is, which version of the code corresponds with the API documentation? According to the main page it should be the same as mine 3.2.3, but I'm seeing a lot of the above discontinuity, so getting confused on how to proceed.

If the API is correct for 3.2.3, then could you help me understand how to find syntax for things like the panorama attribute for the PhotoSphereViewer class? Although that particular syntax is quite easy to understand, I don't see the "panorama" attribute as a member of the PhotoSphereViewer class, so without the example on the main page, I wouldn't have guessed this was the right way to assign the panorama image to the PhotoSphereViewer object.

Let me know if you need further details.

mistic100 commented 7 years ago

You are totally overthinking things... Nothing changed, I just added the automatic generated doc from JavaScript comments.

First of all you are mixing the options object (init configuration) and the actual properties of the PSV object (container exists in both but it's not the same thing). The one and only reference for options is http://photo-sphere-viewer.js.org/#options (which is linked from the API doc).

So from here I cannot tell you why your viewer is not working, the config is good. Setup a online demo if you want further help.

topherbuckley commented 7 years ago

Ahh ok. I get it now. Thanks for pointing out the options object. Yes, that confused me.

My viewer is working just fine, I was just confused why the "options" I was specifying were not mentioned in the PSV object API docs, but you explained that. Thanks! I'm trying to have a prettier working demo live by mid this week, so I'll keep you posted.

Thanks for the quick and helpful reply!