Suppose I have a sphere with the center of the sphere in the new THREE. Vector3 (0,0,0), known mouse position and a point on the sphere corresponding to the position, the camera is always look at the center of the sphere, the distance of the camera from the center of the sphere is known, how to get the position of the camera?
The description is unclear or incomplete. Here is a picture of what I could understand:
If this is the case, then the position of the camera is camera.position
– i.e. each camera has a property called position
, which is the camera’s position. This is unrelated to the sphere, the distance to the sphere, the mouse pointer and that mysterious point on the sphere.
First of all, thank you for your reply.
Sorry, this question is a bit complicated, I’m not good at English. Let me explain this from the beginning, I was writing a 3D map library, and I found that if I determined the center point where the camera was facing the sphere, I could get the latitude and longitude of any position of the mouse. But I can’t seem to use the mouse position and the corresponding latitude and longitude to reverse the latitude and longitude of the center point corresponding to the current camera.
I’m not sure if this is possible now, I’m not good at math, and if it’s impossible, hopefully you’ll let me know and I’ll look for other ways. If this is possible, can you teach me how to calculate?
If my explanation is not detailed enough, I hope you can point it out.
Thanks again.
Below is the code for me to get the latitude and longitude corresponding to the mouse position by the latitude and longitude of the camera and the mouse position:
I’m sorry, I still cannot understand what is the problem.
Anyway, here is a small demo. You can rotate the Earth and find the geographical coordinates on its surface. Most likely this is not what you need. I hope that somebody else might be able to help you.
https://codepen.io/boytchev/full/poGowad
这是自动翻译:
抱歉,我还是不明白问题出在哪里。
无论如何,这是一个小演示。 您可以旋转地球并找到其表面的地理坐标。 这很可能不是您所需要的。 我希望其他人能够帮助你。
Thank you, perhaps this is an unsolvable problem. I will look for other workarounds.
I mean, I cannot understand your description of the problem. I hope the problem is solvable, but it is needed to first understand what is the problem. Maybe an illustration could help?!?
As shown in the figure below, when you know the latitude and longitude where the camera is currently located, you can easily get the latitude and longitude of any mouse position.
But my question is, if you know the latitude and longitude at the mouse position, how do you deduce the camera’s current latitude and longitude in reverse?
I’ve been working on this problem for a week and I’m not sure if it’s mathematically solvable.
You can cast a ray from the center of the screen (or from the camera position) to the sphere and get the latitude and longitude of the intersection point. You do not need the mouse screen position or geographical coordinates for this.
Sorry, you misunderstood me. I’ve found other workarounds and appreciate your reply