Giter Site home page Giter Site logo

Comments (4)

pescew avatar pescew commented on June 22, 2024 1

instead of rotating the globe I rotate the camera

    // Start camera over São Paulo
    const latitude = -23.533773;
    const longitude = -46.62529;
    // altitude in globe radius units
    let altitude = camera.position.z / Globe.getGlobeRadius();
    let { x, y } = Globe.getCoords(latitude, longitude, altitude);
    camera.position.x = x;
    camera.position.y = y;

https://codesandbox.io/s/786twk?file=/src/NewGlobe.jsx

from three-globe.

Udith-Gayan avatar Udith-Gayan commented on June 22, 2024

@pescew You code works. To get the exact location to the front I had to do a small change as well.

  let { x, y, z } = Globe.getCoords(latitude, longitude, altitude);
 camera.position.z = z;

I have got an issue even without my change. The above code limits the zoom-in level of the globe. Once it hits a zoom-in level, it starts zooming out. Any fix for that ?

from three-globe.

pescew avatar pescew commented on June 22, 2024

it sounds like there's a minimum zoom being enforced somewhere

are you using three js OrbitControls with minDistance/minZoom set?

the getCoords function ends up calling this internal function:

function polar2Cartesian(lat, lng, relAltitude = 0) {

I don't see anything obvious that would limit it there.

from three-globe.

iaruso avatar iaruso commented on June 22, 2024

I was working on a personal project and encountered a need to adjust the camera upon selecting a country. Since I reload the globe due to the utilization of hexPolygons and their alteration, the suggested solution helped me. However, it resulted in the camera being overly zoomed in. Despite having predefined constraints:

controls.minDistance = 150;
controls.maxDistance = 300;

The resolution to the zoom issue involved maintaining the camera.position.z as it was and repurposing it for altitude:

camera.position.z = 400; // with this value, at least for me it was zoomed out
// Initiate camera positioning over São Paulo (using your example)
const latitude = -23.533773;
const longitude = -46.62529;
let altitude = camera.position.z / globe.getGlobeRadius();
let { x, y, z } = globe.getCoords(latitude, longitude, altitude);
camera.position.z = z;
camera.position.x = x;
camera.position.y = y;
scene.add(camera);

from three-globe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.