Same Target camera rotate to different angle

Hi, I just need a help. Here is my playground link https://playground.babylonjs.com/#S0KJUA#21 . All i want to do is to rotate camera to angle where the point is placed, i’m attaching the video how it should go, for both freeCamera and arcRotateCamera, i tried to do it by changing alpha beta but it doesn’t work well.

If I understand you right, you want camera to look at pickedPoint? Then I would set pickedPoint as target of camera after sphere mesh position is set:

currentCamera.setTarget(pickInfo.pickedPoint);

PG:

This might help if you want animation

Thank you, but don’t want to change the camera target, just move the camera to the front/side of the sphere (as in the video) :thinking:.

It might need some testing and offset adjusts to your likings, but this could be what you wanted?

PG:

Adjust pivotOffset.y to i.e. -20 or -5

2 Likes

Hi, I faced another issue with the camera rotation angle, if i place any point inside mesh wall it is going opposite direction, if i place a point on right side wall it is going behind the wall, if i add point in bottom it is not taking camera to bottom, is there any way to get faceId from Vector3 poistion? https://playground.babylonjs.com/#S0KJUA#35 (function name rotateCameraToPoint)

I tried it, you can pick a point with a ray of length = 0:

var ray = new BABLYLON.Ray(yourPoint, direction, 0)
var pickInfo = scene.pickWithRay(ray)
// use pickInfo.faceId

Example PG:

You might also want to look into facets.

Here a PG with camera animation to face mesh sides:

Tried but getting pickedinfo null, direction set to up right still no data.

It seems that your sphere.position (center) is not overlapping your model. Maybe using a length (delta) depending on your model scaling will be enough. If you set length to like 0.0001 it works.