mpetroff / pannellum

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

Initial view in scenes does not work #1179

Closed dariocavada closed 4 months ago

dariocavada commented 1 year ago

I've tried with a simple example and it works: https://pannellum.org/documentation/examples/initial-view/

{
    "type": "equirectangular",
    "panorama": "https://pannellum.org/images/lascar.jpg",
    "pitch": 2.3,
    "yaw": -135.4,
    "hfov": 120
}

But if I put inside a scene for a virtual tour, the
"pitch": 2.3, "yaw": -135.4,

parameters are always set to 0, hfov instead works.

what I can do to overcame this ? Some workaround ?

mpetroff commented 1 year ago

How are you including the parameters in the tour?

The tour example includes initial view parameters.

vaccinemedia commented 4 months ago

I'm having the same issue and came here to comment. My implementation used to work perfectly fine when using the latest release but I have needed to use the master version instead due to wanting to use the draggable parameter. Since updating to the latest master version all of my panoramas are starting at 0,0. The only code which has changed is using the latest master version instead of 2.5.6 and adding the required libpannellum.js too (I'm assuming it's required because it was never in 2.5.2 and the tours do not work without it).

My implementation uses javascript where a variable called wpvtData is output on the footer of the page and then the scenes are built from it like so:

        var panoramas = wpvtData.panoramas;

        var scenes = {};
        var companyLogo = wpvtData.companyLogo;
        var companyWebsite = wpvtData.companyWebsite;
        var autoRotate = wpvtData.autoRotate;

        panoramas.forEach(function(panorama, index) {
            scenes['scene' + index] = {
                "title": panorama.title,
                "type": "equirectangular",
                "panorama": panorama.url,
                "autoLoad": true,
                "yaw": panorama.yaw,
                "pitch": panorama.pitch,
                "hotSpots": JSON.parse(panorama.hotspots) || []
            };

            if (companyLogo && companyWebsite) {
                scenes['scene' + index].hotSpots.push({
                    "pitch": -90,
                    "yaw": 0,
                    "type": "info",
                    "createTooltipFunc": function(hotSpotDiv) {
                        hotSpotDiv.classList.add('custom-logo-hotspot');
                        var link = document.createElement('a');
                        link.href = companyWebsite;
                        link.target = '_blank';
                        var img = document.createElement('img');
                        img.src = companyLogo;
                        img.classList.add('wpvt-company-logo');
                        link.appendChild(img);
                        hotSpotDiv.appendChild(link);
                    }
                });
            }
        });

        var viewer = pannellum.viewer('panorama', {
            "default": {
                "firstScene": "scene0",
                "author": wpvtData.author,
                "sceneFadeDuration": 1000,
                "autoRotate": autoRotate
            },
            "scenes": scenes
        });
vaccinemedia commented 4 months ago

I also have an editor which also used to work with simpler code and no scenes:

        window.viewer = pannellum.viewer('pannellum-container', {
            "type": "equirectangular",
            "panorama": url,
            "autoLoad": true,
            "showControls": false,
            "hfov": 160,
            "yaw": 50,
            "pitch": 50,
        });

In the example above I have set pitch and yaw to be 50 but the panorama viewer always starts at the initial 0 degrees pitch and yaw view. Version 2.5.2 does not have this issue.

vaccinemedia commented 4 months ago

Being that I need the draggable functionality to work I have gone through some of the earlier commits and seeing that one mentions default views, which already had been implemented I have downloaded the code from commit 7f2041c https://github.com/mpetroff/pannellum/tree/7f2041c9cfd2ff6f79a2f72bbaddca272563ce3b and it works :) Both the draggable hot spots and the default views work without having to change any of my existing code.

vaccinemedia commented 4 months ago

Confirming that the next commit by @Elbandi 1420819 https://github.com/mpetroff/pannellum/tree/14208198aa94c25a53aeb603132d02769128c089 breaks the default view if I use this commit instead.

mpetroff commented 4 months ago

@vaccinemedia There was a bug in the commit you referenced, which I just fixed in 011497a7bddf1dfd0e15f819bedf6aa0b27ef591.

@dariocavada Since you never replied with more information, I'm assuming you ran into the same bug, so I'm closing this issue as the bug has now been fixed.