There’s not a public API for either, but in v2 p5Canvas.states.curCamera is the equivalent of what you’re doing. So you could do something like this if you wanted to make yourself a function that works in both:
I noticed that my canvasGUI library examples using WEBGL worked with p5js V1 but failed with V2 . I narrowed the problem down to accessing the current camera hence my question.
So @davepagurek thanks for your reply I have successfully incorporated the idea into canvasGUI.
I created a class attribute to get the major version number -
// Remember major version number of p5js for camera selection
this._p5MajorVersion = Number(p.VERSION.split('.')[0]);
I did this to avoid the string comparison since I have to access the camera every frame.