mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.

Home Page:https://pannellum.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Initial view in scenes does not work

dariocavada opened this issue · comments

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 ?

How are you including the parameters in the tour?

The tour example includes initial view parameters.

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
        });

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.

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.

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.

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

@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.