gamefan Posted November 8, 2017 Share Posted November 8, 2017 Hi, We have been using babylon2.5 (oddly, an alpha release) in our projects because it served our purposes. Now we want to update to 3.0.7 for various reasons. We have lots of meshes that are imported into an existing scene that have to be logically combined under a parent based on a predefined config. I used this following code to arrive at combination's size and center. var getCombinationData = function(meshes) { var clones = []; for (var i = 0; i < meshes.length; i++) { clones.push(meshes[i].clone("clone" + i)); } var combinedMesh = BABYLON.Mesh.MergeMeshes(clones); var boundingBox = combinedMesh.getBoundingInfo().boundingBox; var size = boundingBox.extendSize.scaleInPlace(2); var center = boundingBox.center; //dispose off the clones; for (var k = clones.length; k > 0; k--) { clones[k - 1].dispose(); } combinedMesh.dispose(); return { size: size, center: center }; }; Using babylonjs 3.0.7, the boundingBox.center is different from that obtained using 2.5, which I am assuming is right , because a box made with size and center got from the above method, neatly encapsulated the meshes. Has anything changed since 2.5 or An easy fix to doing this? The meshes can have parents ( but not different ones). Thanks. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 8, 2017 Share Posted November 8, 2017 Hello, do you want the center in object space or in world space? If in world space you need to call boundingBox.centerWorld. Just in case, can you try to call combinedMesh.computeWorldMatrix(true) right after the merge? Quote Link to comment Share on other sites More sharing options...
gamefan Posted November 10, 2017 Author Share Posted November 10, 2017 Hi @Deltakosh, No luck with computeWorldMatrix. I already tried centerWorld, but using that also causes offsets. I would be needing the center in world space but sometimes the meshes that are combined have a parent, in that case the center should be relative to the parent. I will see if transforming worldCenter to parent space would work. And its strange because I tried my code in playground and it seems to work right. I guess there is something else. Quote Link to comment Share on other sites More sharing options...
gamefan Posted November 10, 2017 Author Share Posted November 10, 2017 I can confirm (with much relief) , that this is case with 3.0.7 but the current preview (3.1-beta2) renders correctly. I will have to check everything before continuing with this preview release, but it looks great. Moreover , we have nearly doubled the potential FPS. What a win!!!!. 1000 points to everyone. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 10, 2017 Share Posted November 10, 2017 Yeah we did a lot of work to boost the internal engine gamefan 1 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.