vasturiano / globe.gl

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

Ability to adjust the map on window resize event #195

Closed WilliamSoler closed 3 months ago

WilliamSoler commented 3 months ago

Currently, if you try to resize the browser window after loading results on the following:

image

Empty spaces when increasing the window size. My attempt to auto-resize the globe to screen resulted in the following:

` window.addEventListener('resize', onWindowResize, false);

    function onWindowResize() {
       // Update camera aspect ratio and projection matrix
        camera = world.camera()
        renderer = world.renderer()
        controls = world.controls()

        camera.aspect = window.innerWidth / window.innerHeight;
        camera.updateProjectionMatrix();

        // // Update renderer size
        renderer.setSize(window.innerWidth, window.innerHeight);

    }

` But results on an offset of the cursor with the globe:

image

Is there any way to achieve this resize without this cursor offset?

vasturiano commented 3 months ago

@WilliamSoler all you should need to do is invoke .width(...) and .height(...) directly on your globe component. The rest is taken care of internally by the component.

WilliamSoler commented 3 months ago

@vasturiano Thank you very much it works 🙏🏼

WilliamSoler commented 3 months ago

I will close it then. Maybe to avoid this kind of questions on the Bug/Features of Github. You could enable GitHub discussions.

ralyodio commented 2 months ago

this doesn't work for me using .width('100vw');