Rajkumar Posted April 15, 2016 Share Posted April 15, 2016 Hi, I am trying to implement a feature where in, the meshes need to be fit to say 80% of the canvas size. Created a playground in order to try this, when I double click, I try to zoom all. http://www.babylonjs-playground.com/#RXUCB#0 I require help in finding a relation between bounding info of mesh, with the width and height of canvas so that 1. the mesh should be centered in the canvas 2. the mesh should fit 80% area of the canvas. I am not sure if this was asked in older posts, please help. Regards Rajkumar Quote Link to comment Share on other sites More sharing options...
Wingnut Posted April 18, 2016 Share Posted April 18, 2016 Hi R! Apparently you puzzled everyone. Sorry for slow replies. I will think about this (which could cause problem to get worse) You want a "see all mesh" button/command. No matter mesh positions, you want a camera to auto-move (and maybe auto-FOV - field of view)... so that all scene mesh are in-view (with 10% space on all sides). Yup, good idea. This seems like a very handy function for everyone. Automatic find of best wide angle view. Perhaps, we need to "sum" all the bounding boxes of all the mesh of the scene. Then try to get that sum-group bounding area to be centered and well-fit into the active camera frustum (cone of view). (Am I stating the obvious?) Ok, camera and space experts... let's see who can help Raj design a "Fit All" button/command for any camera type. Good challenge. I'm scared. Quote Link to comment Share on other sites More sharing options...
simon_bg Posted April 19, 2016 Share Posted April 19, 2016 Hi, this could be useful to you: http://stackoverflow.com/questions/14614252/how-to-fit-camera-to-object Also, I don't know which type of camera you're using, but there's a zoomOn function and a zoomOnFactor parameter for the ArcRotateCamera. I think it is related to the distance from camera to the object and not to the canvas size, but you may want to take a look at it anyway. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Rajkumar Posted April 30, 2016 Author Share Posted April 30, 2016 (edited) Hi, thank you for pointing me to some help on this. I am using an ArcRotateCamera in orthographic mode. I tried out an implementation http://www.babylonjs-playground.com/#RXUCB#22 However, if my cube is tilted in an angle, the real bounding box is not considered. What do I need to modify so that the view specific bounding box is considered ? Regards Rajkumar Edited April 30, 2016 by Rajkumar adding additional info Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.