Comments (4)
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.
@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.
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:
I don't see anything obvious that would limit it there.
from three-globe.
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)
- Bug: component destructor leaves animationFrame running HOT 2
- [Question] How to position camera base on the first Lat and Long? HOT 2
- Bug: FrameTicker doesn't get disposed HOT 1
- Bug: destructor cleanup HOT 2
- Passing Arc Data as prop to the globe doesn't work on remount HOT 4
- Overriding createGlowMesh to be a flat colour instead of glowing effect? HOT 3
- able to add texture/materials to lines (or line-like things)
- Webpack error with your latest version 2.25.5 HOT 4
- How to Use an Image for Hex Materials on the Globe
- Import error message for '@tweenjs/tween.js' while using typescript. HOT 10
- Examples don't work "Error resolving module specifier “three”." HOT 2
- Globe view as plane view. HOT 1
- "Window is not defined" error when extending on NextJS. HOT 2
- changing globe image HOT 1
- arcColor: Color replication issue since 2.29.0 HOT 5
- Attach Clouds to initial Globe animation HOT 5
- select a polygon HOT 2
- Is it possible to to easily get the position of the mesh representing the satellite HOT 9
- Arcs disappear when parts of globe is out of frame when inside PMDRS/Drei Portal View HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three-globe.