Jump to content

Implemenation of Zoom All


Rajkumar
 Share

Recommended Posts

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

Link to comment
Share on other sites

Hi R!  Apparently you puzzled everyone.  :)  Sorry for slow replies.  I will think about this (which could cause problem to get worse)  :D

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.  :)

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

  • 2 weeks later...

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 by Rajkumar
adding additional info
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...