I’m new to this whole 3D Webgl thingy and i have some questions
I’m currently playing arround with this demo project here: Babylon.js - Planet demo
And i want to place a moving space ship with coordinates on that planet how can i accomplish that?
I already have some data to use but i dont know how to begin etc. ->
“ship1”: {
“x”: 2907841.670722,
“y”: -99048538.95104,
“z”: -942307.1750178
}
I don’t know the “best” way to do this, but I have an idea:
-just keeping repositioning the ship mesh position from earth position (center) to a distance pre calculated:
//here update the ship position after moving
//now move the ship to some local axis… and afetr move, use this code to set ship
//position on some distance from earth
let aux = ship.position.subtract(earth.position);
let distance = 5;//5 units of distance from earth.position
aux.normalize().scale(distance).add(earth.position);
ship.position.set(aux.x,aux.y,aux.z);
NOTE: this not rotate the ship, so it will with the rotation wrong relatives to the earth. You must update the rotation of ship after repositioning it with the code above.