royibernthal Posted June 27, 2016 Share Posted June 27, 2016 I have an invisible mesh that is the parent of a few child boxes, ordered horizontally one near the other. I'm using the following line to figure out the size of a mesh: getBoundingInfo().boundingBox.extendSize.scale(2) When called on each of the child boxes, the vector returned is correct. When called on the parent mesh, (0, 0, 0) is returned. Is there a way to get the size of the parent, taking into account all of its children? Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted June 28, 2016 Share Posted June 28, 2016 I use this for getting size of meshes. It returns the right size even if it is set to NOT visible: selected_entity is the mesh (obj). function get_selected_mesh_size(selected_entity){ $("#selected_entity_mesh_size_x").html(selected_entity.getBoundingInfo().boundingBox.extendSize.x*2*selected_entity.scaling.x); $("#selected_entity_mesh_size_y").html(selected_entity.getBoundingInfo().boundingBox.extendSize.y*2*selected_entity.scaling.y); $("#selected_entity_mesh_size_z").html(selected_entity.getBoundingInfo().boundingBox.extendSize.z*2*selected_entity.scaling.z); } Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 28, 2016 Author Share Posted June 28, 2016 That's the same as what I'm doing just with a slightly different syntax, correct me if I'm wrong. Quote Link to comment Share on other sites More sharing options...
DigiHz Data Posted June 29, 2016 Share Posted June 29, 2016 Well our syntax is not the same. Did you try with my syntax? Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 29, 2016 Author Share Posted June 29, 2016 Like I said different syntax. You're calling the same functions and accessing the same arguments with a different syntax, please help me see how it'd change anything. I'd also like to emphasize that the problem is not invisibility of the mesh, but calculating its size while taking into account all of its children. Quote Link to comment Share on other sites More sharing options...
adam Posted June 29, 2016 Share Posted June 29, 2016 It would help if you created a PG of the issue. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 29, 2016 Author Share Posted June 29, 2016 http://www.babylonjs-playground.com/#QHMT1#10 Note that I'm not looking for a workaround to calculate this specific PG some other way (like the workaround example I wrote in the PG), this is a simplified case. I need to be able to get the size of a container mesh whatever children it contains and however they are placed and rotated - get the container's 3d boundaries box. Quote Link to comment Share on other sites More sharing options...
adam Posted June 29, 2016 Share Posted June 29, 2016 http://www.babylonjs-playground.com/#QHMT1#11 I'm not sure how it will work with rotated meshes that are not boxes. royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted June 29, 2016 Author Share Posted June 29, 2016 That was a bit more complex than I thought, I was certain there was going to be a built-in function that already does this, but apparently it's not a very popular thing to try to do. Thank you very much. Quote Link to comment Share on other sites More sharing options...
adam Posted June 29, 2016 Share Posted June 29, 2016 No problem. I looked at the function again and realized that I didn't end up using the part that computes the center. That can be removed. http://www.babylonjs-playground.com/#QHMT1#12 royibernthal 1 Quote Link to comment Share on other sites More sharing options...
adam Posted June 29, 2016 Share Posted June 29, 2016 It works when the boxes aren't rotated: http://www.babylonjs-playground.com/#QHMT1#15 but not when an outer box is rotated. The width is wrong: http://www.babylonjs-playground.com/#QHMT1#16 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted June 29, 2016 Share Posted June 29, 2016 any binding box solution like max x y z and min x y z of all BBx Quote Link to comment Share on other sites More sharing options...
adam Posted June 29, 2016 Share Posted June 29, 2016 I think I figured it out: http://www.babylonjs-playground.com/#QHMT1#18 There is a minimumWorld and maximumWorld in BoundingBox. servusdei and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
gamedev44 Posted January 17, 2019 Share Posted January 17, 2019 I had a problem when the combination of meshes were positioned -x,-y, or -z... I think I fixed it here: var min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); var max = new BABYLON.Vector3(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE); use instead: var min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE); var max = new BABYLON.Vector3(Number.MAX_VALUE*-1, Number.MAX_VALUE*-1, Number.MAX_VALUE*-1); Quote Link to comment Share on other sites More sharing options...
Guest Posted January 22, 2019 Share Posted January 22, 2019 We moved to a new forum: forum.babylonjs.com 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.