New here:
I am trying to use the following link as a reference for my model to have mouse movements for the model rotation which works well for some models but for some reason, the rotation looks strange as shown in the attached movie:
Video:
Can anyone please help understand why? And how do I set the center of the model as the center of rotation?
I am using camera.target = mesh
and my mesh is a SPS mesh.
Thank you.
I made changes to the example, you can go to line 30/31 to check it out and make changes to your code.
The center point of the model’s wraparound box and the origin of the model’s position don’t coincide, and to visually rotate the camera around the model, you need to set the camera target to the center point of the camera model’s wraparound box.
Thanks for the response, @xiehangyun
Changing the camera.target = center
results in gimbal lock in the rotation and to avoid that, I have my camera.target = mesh
which allows freeform rotation and also the main reason, I’m not using camera default mouse inputs but using canvas.addEventListeners
Can you please help with how we can avoid that?
Thank you.
Sorry, I didn’t look closely before to see that your example rotates the model and not the camera.
This case is more complicated compared to rotating the camera, but you can simplify the process by creating a parent node.
Please see my modified example line 17- 21
1 Like