Why did I not succeed in changing the position of the camera like this?

export const setCameraImmediately = (cameraCoordinates: CameraCoordinates) => {
  const scene = Engine.LastCreatedScene;
  const camera = scene.activeCamera as ArcRotateCamera;
  camera.target = new Vector3(
    cameraCoordinates.target.x,
    cameraCoordinates.target.y,
    cameraCoordinates.target.z
  );
  camera.alpha = cameraCoordinates.alpha;
  camera.beta = cameraCoordinates.beta;
  camera.radius = cameraCoordinates.radius;
  camera.update();
};

:sob::sob:

Hmm, it works when I use this function in the playground… Can you post more code or ideally PG to show how you’re setting the scene up and calling the function? :slight_smile: :beers:
https://playground.babylonjs.com/#9WUJN#1614

2 Likes

@haoguang_shen please create a repro in the playground so that it is easier to help you.

1 Like

Thank you, It’s my fault. :stuck_out_tongue_winking_eye:

1 Like