AhmadAli Posted December 9, 2016 Share Posted December 9, 2016 Hello guys, I made a viewer using babylon, my viewer is support .babylon and .obj and everything is good. but i have an issue: - the babylon file have scale 1 but it so small in scene - the obj file has the same scale but it so big in scene I need the same size for all model that i view. please help Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 9, 2016 Share Posted December 9, 2016 You can evaluate the size of each mesh using mesh.getBondingInfo().getBoundingSphere() Quote Link to comment Share on other sites More sharing options...
AhmadAli Posted December 9, 2016 Author Share Posted December 9, 2016 can you give me an example Quote Link to comment Share on other sites More sharing options...
Convergence Posted December 10, 2016 Share Posted December 10, 2016 7 hours ago, Deltakosh said: getBondingInfo() "It's complicated" Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 10, 2016 Share Posted December 10, 2016 lol Interesting mistake Test with this PG: http://www.babylonjs-playground.com/#2EERRU (Open the console to see the content of the boundingSphere) Quote Link to comment Share on other sites More sharing options...
AhmadAli Posted December 11, 2016 Author Share Posted December 11, 2016 guys i need the scale of model to be fit on my scene for all models unit! Quote Link to comment Share on other sites More sharing options...
X3MC2 Posted December 11, 2016 Share Posted December 11, 2016 The only way you can do it is by creating an invisible mesh parent which will hold the loaded obj models, since there are some obj models out there that contain more that one mesh, and often they do not have the same scaling factor. After that you should set the scaling of each mesh to : parent.getBoundingInfo().boundingBox.extendSize; Here is an example : var container = BABYLON.Mesh.CreateBox("ObjParent", 1, scene); container.position = new BABYLON.Vector3(myposZ,myposY,myposZ); container.rotation = new BABYLON.Vector3(0,0,0); container.scaling = new BABYLON.Vector3(myscalingX,myscalingY,myscalingZ); var OBJ = loader.addMeshTask("ObjLoader", "", "", "batman.obj"); OBJ.onSuccess = function (t) { t.loadedMeshes.forEach(function (m, i) { m.parent = container; m.scaling = container.getBoundingInfo().boundingBox.extendSize; m.position = new BABYLON.Vector3(0,0,0); // Put at the origin of the parent }); }; 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.