Move the camera along a different orbit with ModelViewer #7747
Unanswered
pechiang66
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi.
I am using the ModelViewer to show a model and take advantage of the gesture detection so that the camera can move around the model.
Below is a sample model. The pivot is around the center of the model. In other words, the camera would move on the surface of a sphere where the origin of the sphere is the pivot:
The Manipulator for the ModelViewer is instantiated as below:
What I am trying to do is embedding a point (called a hotspot) within the model and when the user clicks on that point, the camera would move on an orbit to a position and look at the hotspot. Please see the video below:
Screen_recording_20240410_140048.mp4
I am doing this by:
(0.0f, 0.0f, -4.0f)
, i.e. thetargetPosition
specified when the manipulator was created. The angles are calculated by doing the inverse of what is done herecamera.lookAt
calls from the cameraManipulator. Thus, even if different values are passed tocamera.lookAt
outside the ModelViewer, camera would be re-positioned according to what cameraManipulator.getLookAt returns after every frame. Essentially, we are simulating a series of gesture movements.Question:
This looks ok so far. Because
hotspot1
is above the pivot in the y-axis, the camera would be looking down the hot spot at an angle. Now, instead of this angle, we want the camera to move along a different orbit so that the end state would look something like this:It looks like to achieve this, we will need to somehow move the pivot to somewhere else. I know the
panning
motion can achieve this, but unlike rotation or zooming, it's a little difficult to simulate and animate the panning motion. Is there a way, we can achieve this without touching the pivot?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions