I am passing a camera name (cam: string) to a method called switchCameraTo(cam){} and at one point, I would like to write something like:
switchCameraTo(cam){
this.UniCamera.attachControl(this.canvas, true);
this.scene.activeCamera = this.UniCamera;
}
This works, but if I replace "this.UniCamera" by "cam" to pass the argument, it fails. "this.cam" won't work either. Note that "this.UniCamera" was declared in the constructor of the class where the method is located.
The argument "cam", contains the string "UniCamera".
Is there an solution to this problem? I think it might be a type error but I'm not sure how to fix this. Any help will be welcome!
Thank you!