Hi there, I have a program that essentially creates a range of sizes of rectangular prisms.
A new rectangular prism is created each time the user presses a button.
Each time a new prism loads I try to center the camera on the object, which is tricky because of all the different sizes. Here is how I currently do it:
camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 400, new BABYLON.Vector3(0, 0, 0), scene);
var xc = 1.5*rectangularPrism.sel_x_size;
var yc = 1.5*rectangularPrism.sel_y_size;
var zc = 2*rectangularPrism.sel_z_size;
camera.setPosition(new BABYLON.Vector3( xc, yc, zc));
This works OK, but there are still end cases for example with really tall rectangular prisms where the camera does not position well and the prism is very tiny on the screen.
The second issue I am having is I would a second button which rotates the camera somewhere randomly around the object.
I was thinking I would have to calculate a circle or sphere around the rectangular prism and then choose a random point on it to set the camera position?
Thank you