vasturiano / globe.gl

UI component for Globe Data Visualization using ThreeJS/WebGL
https://vasturiano.github.io/globe.gl/example/world-population/
MIT License
2.15k stars 312 forks source link

Zoom Speed gets overwritten #126

Open mikeg0 opened 2 years ago

mikeg0 commented 2 years ago

Describe the bug After initializing a Globe, I am attempting to set the Zoom Speed property. E.g., myGlobe.controls().zoomSpeed = 0.6; The Zoom Speed gets overwritten due to the change listener here ... https://github.com/vasturiano/globe.gl/blob/master/src/globe.js#L364

To Reproduce

            var myGlobe = Globe()
                .globeImageUrl('//unpkg.com/three-globe/example/img/earth-night.jpg')
                .backgroundImageUrl('//unpkg.com/three-globe/example/img/night-sky.png')
            (document.getElementById('the-globe'));

            myGlobe.controls().zoomSpeed = 0.6;

Zoom Speed gets set to something other than 0.6 on mouse scroll.

Expected behavior I should be able to override the Zoom Speed property

Screenshots image

Desktop (please complete the following information):

Additional context I attempted to modify the zoom level by setting the pointOfView({ lat, lng, altitude }) via the onZoom(fn) callback, but the callback does not have a parameter indicating whether we are zooming in or zooming out.

mikeg0 commented 2 years ago

For what it's worth, I found this kludgy workaround ...

            myGlobe.controls().domElement.addEventListener('wheel', function (event) {
                myGlobe.pointOfView({altitude: myGlobe.pointOfView().altitude + event.deltaY / 1000})
            })
vasturiano commented 2 years ago

@mikeg0 thanks for reaching out.

The orbit controls on this component are calibrated dynamically to optimize the rotation and zooming of the globe. Essentially the closer you are to the surface, the more level of detail there is, thus the smaller the steps should be. This means the component is constantly adjusting (and overriding) the zoom speeds based on camera altitude changes.

If you'd like to use a different logic for this, I would suggest to import instead the lower level component three-globe. With that one you are responsible for setting up the full scaffolding of camera, scene, renderer etc, but with that comes great flexibility to set it precisely as you intend it, including all the controls configuration.

alcaroff commented 10 months ago

Same problem here, would be nice to have a way to disable lib zoomSpeed overwrite 👀