I've been working on designing a map and I'm trying to achieve a specific functionality. When I select any geometry, I want the object to be positioned at the center of the viewport with the camera looking directly at it. Despite searching extensively online, I haven't been able to find a solution yet. It's important to note that I don't want to rotate the object, just update the camera. I'm aiming for a similar effect to the example shown in this link where clicking on a number brings it to the center:
Here is my attempted solution that has been the closest to achieving the desired output:
`camera.position.x = select.position.x;
camera.position.y = select.position.y;
camera.position.z = select.position.z;
camera.Translate(0,0,-1);
camera.updateProjectionMatrix ();`
The 'select' variable contains the selected object. While the above code does change the camera position, it does not make the camera look at the selected object as intended.
I also tested lookAT(select.position)
but that did not yield the desired results either.
I would greatly appreciate any assistance with this issue.