Point ArcRotateCamera at position?

I’d like to, when I click, center the camera on the clicked sphere in this playground.
Not target the sphere, but position the camera such that the sphere is between the camera and the target.

https://www.babylonjs-playground.com/#RPF0N0

Thanks c:

camera.target = {positionVector}
or
camera.setTarget({positionVector})
probably

or maybe .position somewhere along the line from the center through the sphere

2 Likes

The target of the camera is the point it rotates around. I want to still be rotating about the center of the scene while looking at the clicked mesh. As though I manually left-click-dragged the screen to place the mesh in the center.

As for position, you can’t set the position of an ArcRotateCamera. If I could find the alpha and beta of a mesh relative to a target I could set that instead, but I’m not sure that’s possible.

https://doc.babylonjs.com/api/classes/babylon.arcrotatecamera#setposition
No?
Somewhere along the circle or sphere?

Might have to get creative or end up in quaternion territory.

1 Like

Oh you’re right, my bad. I was trying to set the position itself; didn’t realize setPosition was a thing.

Thanks~

1 Like