mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.17k stars 714 forks source link

haov & vaov change #862

Open eltonjothi opened 4 years ago

eltonjothi commented 4 years ago

Hello, i am looking to change the haov and vaov or the Pannellum Viewer. is there any API already available ? like myPannellum.sethaov(360);

truszko1 commented 4 years ago

These two values are mostly used during the initial rendering. Can you explain your use case? Maybe there is another way to accomplish what you need.

mpetroff commented 4 years ago

Yes, they're only configurable when a scene is added because they are intrinsic to the panorama being displayed. I can't think of any reason why they would need to be changed after a panorama is loaded. The hfov however, is a viewer parameter that sets the effective zoom, which is why it's configurable from the API.

eltonjothi commented 4 years ago

i am trying to make a tour editor, where a user can choose the tour to be a partial panorama or a 360 view, and the user can adjust the width and height if its a partial panorama. Here's a video: https://youtu.be/5Eo5b1_pP7Q

NiHoel commented 4 years ago

Vaov and haov are passed as glUniform parameters to the fragment shader. Adding a way to handle it dynamically would require changes along the call stack to the actual rendering method. I would suggest caching the image (e.g. relying on browser cache) and dynamically create new scenes.

What is the scope of your editor? I'm also writing on a panorama tour editor (only as a hobby):

Editor: https://nihoel.github.io/cirspecte/edit.html Demo Viewer: https://nihoel.github.io/cirspecte/index.html?tour=demo%2Ftour.json Repository: https://github.com/NiHoel/cirspecte

At the moment I'm transforming it into a native application (Windows and Android) for better filesystem interaction.

In case you need tips for dynamic scene loading, dragging hotsposts or tiling equirectangular images, just ask me.

mpetroff commented 4 years ago

Needing to adjust these parameters is unusual, and, as @NiHoel pointed out, it's a non-trivial change, which has (small) performance implications for the standard use case. Furthermore, most panorama stitching software supports Google Photo Sphere XMP data, so manually setting the haov and vaov often isn't necessary. Even if it is, it should really be set using the numbers from the stitching software, not by eye.

What I would recommend doing is setting dynamic: true and using a <canvas> as a full panorama. You could then redraw the image onto the <canvas> as a partial panorama when the haov and vaov are changed.