Change camera outside of createScene

is it possible to change a camera outside of the createScene function?

Yes you can. As long as you have reference to scene, you have access to the cameras.

E.g. if you created a camera with name ‘myCamera’ inside createScene:

const camera = new BABYLON.ArcRotateCamera(
  "myCamera",
  1.05,
  1.05,
  600,
  new BABYLON.Vector3(0, 0, 0),
  scene
);

You can access the camera and then update the position for example
const camera = scene.getCameraByName(“myCamera”);
camera.setPosition(…);

1 Like