Jump to content

Help updating from 2.5 to 3.0.7. Something changed with merged mesh position?


gamefan
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...