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

Request Function - Moon to orbit Earth #109

Open pfeifferch opened 2 years ago

pfeifferch commented 2 years ago

Hi

I've just recreated the project and am trying to make the moon https://pfeiffer.world/ or the planets https://pfeiffer.world/solarsystem.html orbit the earth/sun.

Isn't that possible with globe.gl and do I have to use three.js for this? Or am I not seeing the solution?

( Translated with Google, unfortunately my English is even worse )

Hallo

Ich habe gerade das Projekt nachgebaut und Versuche, den Mond https://pfeiffer.world/ bzw die Planeten https://pfeiffer.world/solarsystem.html die Erde/Sonne umkreisen zu lassen.

Ist das mit globe.gl nicht möglich und ich muss hierzu three.js nehmen? Oder sehe ich die Lösung nicht? Isn't that possible with globe.gl and do I have to use three.js for this? Or am I not seeing the solution?

vasturiano commented 2 years ago

@pfeifferch thanks for reaching out.

Looks like you've gotten quite far already in representing the various planets, great work. 🥇 Assuming that each planet is added as a 3D object layer of the central globe (like the sun), to make them orbit, you should just need to keep updating their coordinates via the objectLat and objectLng properties, representing the coordinates projected the central globe where they are directly at zenith.

pfeifferch commented 2 years ago

Hello again. Unfortunately, it exceeds my understanding and I unfortunately had no success in many hundreds of attempts. Is there an example for this purpose?

Hallo nochmal. Leider überschreitet es mein Verständnis und ich hatte in vielen hunderten Versuchen leider keinen Erfolg.

Gibt es ein Beispiel für diesen Zweck?

vasturiano commented 2 years ago

The satellites example is one that is perhaps closer to the logic you're looking for.

You can see in this section how the position of the different bodies (satellites or in your case planets/moon) are iteratively modified: https://github.com/vasturiano/globe.gl/blob/7dc68f5a3338efea883b5a64fcbc4ab5668a68f1/example/satellites/index.html#L73-L83