lhx880619 Posted June 4, 2017 Share Posted June 4, 2017 hi all, i'm trying to calculate the boundingbox of a parent mesh, so that i may get a good camera asprect. but failed to get the boundingbox size of the parent. are there any tricks there? pg http://www.babylonjs-playground.com/#QVIDL9 // Our built-in 'sphere' shape. Params: name, subdivs, size, scene var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); // Move the sphere upward 1/2 its height sphere.position.y = 1; // Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene); var parent = new BABYLON.Mesh("parent",scene); sphere.parent = parent; ground.parent=parent; parent.showBoundingBox =true; Quote Link to comment Share on other sites More sharing options...
Gijs Posted June 4, 2017 Share Posted June 4, 2017 You could add the child bounding boxes together like this: http://www.babylonjs-playground.com/#QVIDL9#1 Quote Link to comment Share on other sites More sharing options...
lhx880619 Posted June 4, 2017 Author Share Posted June 4, 2017 @Gijs it means we should calculate the boxinfo manually? i suppose there's something like updateBoundingbox() function for parent mesh to auto update the boundingbox. Quote Link to comment Share on other sites More sharing options...
Gijs Posted June 4, 2017 Share Posted June 4, 2017 I seems that the bounding box is only calculated for the parent mesh and its submeshes, so for the children you have to do it manually. But you can put the code away in a function you replace refreshBoundingInfo with: http://www.babylonjs-playground.com/#QVIDL9#3 Quote Link to comment Share on other sites More sharing options...
adam Posted June 4, 2017 Share Posted June 4, 2017 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.