[{"Owner":"ozRocker","Date":"2017-06-30T02:03:16Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tI_t_m wondering if there_t_s a way I can determine the Y position of a camera so the mesh its looking at completely fills the viewport.  Basically I have a camera above the ground which is looking down to the ground at a 45 degree angle and is focusing on certain objects on the ground.  Is this possible?\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Wingnut","Date":"2017-06-30T03:10:57Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tHi Oz.  Not sure if this will help_co_ but check out _lt_a href_eq__qt_http_dd_//www.html5gamedevs.com/topic/30860-calculate-camera-position-to-fit-mesh-size/_qt_ rel_eq__qt__qt__gt_this thread_lt_/a_gt__co_ and its final playground link.  No promises.  _lt_img alt_eq__qt__dd_)_qt_ data-emoticon_eq__qt__qt_ height_eq__qt_20_qt_ src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ title_eq__qt__dd_)_qt_ width_eq__qt_20_qt_ /_gt__lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"sable","Date":"2017-06-30T03:29:48Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\t_lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#GQWGC0%233_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#GQWGC0#3_lt_/a_gt_ is what I_t_ve used before_co_ which I adapted from _lt_a href_eq__qt_https_dd_//www.opengl.org/discussion_boards/showthread.php/169865-Zoom-to-fit-screen/page2_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//www.opengl.org/discussion_boards/showthread.php/169865-Zoom-to-fit-screen/page2_lt_/a_gt_\n_lt_/p_gt_\n\n_lt_p_gt_\n\tLooks like a similar solution to the one at the end of the thread _lt_span_gt__lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/5733-wingnut/?do_eq_hovercard_qt_ data-mentionid_eq__qt_5733_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/5733-wingnut/_qt_ rel_eq__qt__qt__gt_@Wingnut_lt_/a_gt_ posted._lt_/span_gt_\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-06-30T03:57:56Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tWow!  Thanks so much fellas! This is super useful.  I tried searching the forums before but couldn_t_t find anything\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-06-30T04:08:38Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tThis is weird.  Both of those examples use mesh.getBoundingInfo().boundingBox.extendSizeWorld\n_lt_/p_gt_\n\n_lt_p_gt_\n\tMy mesh doesn_t_t have extendSizeWorld_co_ it only has extendSize.  I_t_m using a merged mesh for this.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-06-30T04:12:10Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tI figured it out.  the latest babylon.js preview has _qt_extendSizeWorld_qt_.  I_t_ve been reluctant to use the preview version cos the inspector is completely broken _dd_/ \n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"sable","Date":"2017-06-30T04:15:15Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tMy example uses boundingSphere instead_co_ which I think should exist in 2.5 as well.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tUsing the sphere means that any rotation of the mesh you_t_re focusing on should fit in the viewport.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-07-03T01:01:10Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_blockquote class_eq__qt_ipsQuote_qt_ data-ipsquote_eq__qt__qt_ data-ipsquote-contentapp_eq__qt_forums_qt_ data-ipsquote-contentclass_eq__qt_forums_Topic_qt_ data-ipsquote-contentcommentid_eq__qt_180220_qt_ data-ipsquote-contentid_eq__qt_31367_qt_ data-ipsquote-contenttype_eq__qt_forums_qt_ data-ipsquote-timestamp_eq__qt_1498796115_qt_ data-ipsquote-userid_eq__qt_24742_qt_ data-ipsquote-username_eq__qt_sable_qt__gt_\n\t_lt_div class_eq__qt_ipsQuote_citation_qt__gt_\n\t\tOn 30/06/2017 at 2_dd_15 PM_co_ sable said_dd_\n\t_lt_/div_gt_\n\n\t_lt_div class_eq__qt_ipsQuote_contents_qt__gt_\n\t\t_lt_p_gt_\n\t\t\tMy example uses boundingSphere instead_co_ which I think should exist in 2.5 as well.\n\t\t_lt_/p_gt_\n\n\t\t_lt_p_gt_\n\t\t\tUsing the sphere means that any rotation of the mesh you_t_re focusing on should fit in the viewport.\n\t\t_lt_/p_gt_\n\t_lt_/div_gt_\n_lt_/blockquote_gt_\n\n_lt_p_gt_\n\tThank you!  I couldn_t_t get it working then I realised that mesh scale needs to be 1_co_ so once I got that sorted it worked perfectly _lt_img alt_eq__qt__dd_)_qt_ data-emoticon_eq__qt__qt_ height_eq__qt_20_qt_ src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ title_eq__qt__dd_)_qt_ width_eq__qt_20_qt_ /_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"sable","Date":"2017-07-03T01:29:56Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tHadn_t_t thought about scaling. You could use\n_lt_/p_gt_\n\n_lt_pre_gt_\n_lt_code_gt_let radius _eq_ mesh.getBoundingInfo().boundingSphere.radiusWorld_sm__lt_/code_gt__lt_/pre_gt_\n\n_lt_p_gt_\n\tto get it working for any scale.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-07-04T00:35:25Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tI have a mesh that only rotates around the Y-axis so I found that boundingSphere is too restrictive because it checks on every axis.  Is there a way to use a bounding sphere (or maybe bounding cylinder) for this kind of situation.  At the moment the mesh ends up a bit too small with some space around it\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Pryme8","Date":"2017-07-04T01:14:58Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tUse a bounding box instead of a sphere then_co_ find the axis with the longest measurement.  \n_lt_/p_gt_\n\n_lt_p_gt_\n\tWhen I get home I_t_ll show you the way I did it for a client.  This is fairly simple to do without the preview version of bjs\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"ozRocker","Date":"2017-07-04T01:44:05Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_blockquote class_eq__qt_ipsQuote_qt_ data-ipsquote_eq__qt__qt_ data-ipsquote-contentapp_eq__qt_forums_qt_ data-ipsquote-contentclass_eq__qt_forums_Topic_qt_ data-ipsquote-contentcommentid_eq__qt_180568_qt_ data-ipsquote-contentid_eq__qt_31367_qt_ data-ipsquote-contenttype_eq__qt_forums_qt_ data-ipsquote-timestamp_eq__qt_1499130898_qt_ data-ipsquote-userid_eq__qt_19199_qt_ data-ipsquote-username_eq__qt_Pryme8_qt__gt_\n\t_lt_div class_eq__qt_ipsQuote_citation_qt__gt_\n\t\t24 minutes ago_co_ Pryme8 said_dd_\n\t_lt_/div_gt_\n\n\t_lt_div class_eq__qt_ipsQuote_contents_qt__gt_\n\t\t_lt_p_gt_\n\t\t\tUse a bounding box instead of a sphere then_co_ find the axis with the longest measurement.  \n\t\t_lt_/p_gt_\n\n\t\t_lt_p_gt_\n\t\t\tWhen I get home I_t_ll show you the way I did it for kirakira.  This is fairly simple to do without the preview version of bjs\n\t\t_lt_/p_gt_\n\t_lt_/div_gt_\n_lt_/blockquote_gt_\n\n_lt_p_gt_\n\tI_t_m trying to steer clear of the preview version _t_cos of the broken inspector but I_t_ll use it if I absolutely have to.\n_lt_/p_gt_\n\n_lt_p_gt_\n\tBut I_t_m wondering if a bounding box will work.  The point of the bounding sphere was that it works on all rotations.  A bounding box calculation will cause the mesh to go out of the viewport on its diagonals like in this example _lt_a href_eq__qt_https_dd_//www.babylonjs-playground.com/#P6JAWE%236_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//www.babylonjs-playground.com/#P6JAWE#6_lt_/a_gt_ (if you rotate by hand the diagonals will bust out of the viewport)\n_lt_/p_gt_\n\n_lt_p_gt_\n\tA bounding cylinder would be perfect because that would calculate only on the Y-axis rotation.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Pryme8","Date":"2017-07-04T03:34:14Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t_lt_p_gt_\n\tI thought I had it then I ran tests_co_ give me a second._lt_br /_gt__lt_a href_eq__qt_https_dd_//www.babylonjs-playground.com/#P6JAWE%237_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//www.babylonjs-playground.com/#P6JAWE#7_lt_/a_gt__lt_br /_gt__lt_br /_gt_\n\tthis does not work fully yet_co_ I did not have much time to look at it though._lt_br /_gt__lt_br /_gt__lt_a href_eq__qt_https_dd_//www.babylonjs-playground.com/#P6JAWE%239_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//www.babylonjs-playground.com/#P6JAWE#9_lt_/a_gt__lt_br /_gt_\n\tthere we go I think this may work..._lt_br /_gt__lt_a contenteditable_eq__qt_false_qt_ data-ipshover_eq__qt__qt_ data-ipshover-target_eq__qt_http_dd_//www.html5gamedevs.com/profile/12544-ozrocker/?do_eq_hovercard_qt_ data-mentionid_eq__qt_12544_qt_ href_eq__qt_http_dd_//www.html5gamedevs.com/profile/12544-ozrocker/_qt_ rel_eq__qt__qt__gt_@ozRocker_lt_/a_gt__lt_br /_gt__lt_br /_gt__lt_a href_eq__qt_https_dd_//www.babylonjs-playground.com/#P6JAWE%2310_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//www.babylonjs-playground.com/#P6JAWE#10_lt_/a_gt__lt_br /_gt__lt_br /_gt_\n\tThis shows it pushed to the extreme_co_ I tried both orientations and it seems to work have not tested any with y height yet. maybe switch from a ground to a cube.\n_lt_/p_gt_\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2017-07-04T04:35:32Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\ttan(fov * 0.5)  _eq_ visual height / distance to the camera\n_lt_/p_gt_\n\n_lt_p_gt_\n\tvisual width _eq_ visual height * aspectRatio\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"}]