mpetroff / pannellum

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

autoRotateInactivityDelay without autoRotate causes it to lookAt on scene start #1222

Open aproni34f opened 6 days ago

aproni34f commented 6 days ago

I am not sure if I got this correctly.

I start / stop autoRotate manually on button using Viewer.startAutoRotate / stopAutoRotate.

I still want to have autoRotateInactivityDelay set in settings.

This causes viewer on start to look at even if autoRotate is not set in scene options, for example:

pannellum.viewer('panorama', {
    "type": "equirectangular",
    "panorama": "blah.jpg",
    "autoRotateInactivityDelay": 1000,
});

I dont want this to happen.

If I look into pannellum.js it seems this code is running on start:

        animating = false;
        prevTime = undefined;
        var autoRotateStartTime = config.autoRotateInactivityDelay -
            (Date.now() - latestInteraction);
        if (autoRotateStartTime > 0) {
            autoRotateStart = setTimeout(function() {
                config.autoRotate = autoRotateSpeed;
                _this.lookAt(origPitch, undefined, origHfov, 3000);
                animateInit();
            }, autoRotateStartTime);
        }

If this is the case, how can I manually use Viewer.startAutoRotate and still have autoRotateInactivityDelay option?

mpetroff commented 6 days ago

This causes viewer on start to look at even if autoRotate is not set in scene options

The autoRotateInactivityDelay option isn't meant to be used if the autoRotate option is not used. Despite this, I made a change in 83084e892cc3dc0bedc53307fabe6db6acc93937 to prevent it from doing anything.

how can I manually use Viewer.startAutoRotate and still have autoRotateInactivityDelay option?

The startAutoRotate method has an optional inactivityDelay parameter, which needs to be set if you want an inactivity delay when using the method. Regardless of the initial configuration, the stopAutoRotate method will remove any existing inactivity delay settings, so even if one existed originally, you'd still need to set it when calling startAutoRotate.

aproni34f commented 6 days ago

According to documentation:

startAutoRotate() Parameters: speed pitch

Where is inactivityDelay (should it be autoRotateInactivityDelay )?

mpetroff commented 6 days ago

Sorry, it was added in a84fc56596106dce3766e4fd06708d04ad2359d5 and is not in the v2.5.6 release, which is what the documentation on pannellum.org corresponds to. You can look at the docstring in src/js/pannellum.js.