How to change camera type without creating new camera and using detachcontrol

Hello guys,
I want to switch from arcRotateCamera to UniversalCamera by toggled switch, I want to use the same var camera and not creating a second one and detachcontrol the first and attach the second.

thank you

Anes

The scene has two functions that could help you:
setActiveCameraByName and setActiveCameraByID, so you can create two cameras and switch between them.

this is using detachcontrol and then make scene.activeCamera , me I want to use the same camera and then with the toggled function I switch between them.

Maybe something along these lines:

var switchCamera = function () {
    var camera = new BABYLON.FreeCamera("newCamera", scene.activeCamera.position, scene);
    if (scene.activeCamera.rotation) {
        camera.rotation = scene.activeCamera.rotation.clone();
    }
    camera.fov = scene.activeCamera.fov;
    camera.minZ = scene.activeCamera.minZ;
    camera.maxZ = scene.activeCamera.maxZ;

    scene.activeCamera = camera;

    scene.activeCamera.attachControl(canvas);
};

Couldn’t you trigger the setActiveCamera function in the toggled function?
So, you have, for example, HTML Button with a click function attached to it, and the event is firing the camera switch.