setAbsolutePosition and getHierarchyBoundingVectors bug?

Hi and happy new year :slight_smile:

There is an issue here I do not understand. If I remove the getHierarchyBoundingVectors() the setAbsolutePosition does not behave correctly ?

Anyone can explain this for me ?

Look at this piece of code:

this.mgp_occupiedstands = new BABYLON.TransformNode("occupiedstands");
        this.mgp_occupiedstands.parent = this.mgp_rootmesh;
        this.mgp_rootmesh.getHierarchyBoundingVectors(); //Why is this required for the position to behave correctly ?
        blocks.forEach(t => {
            let bstand = stand.createInstance("stand");
            bstand.parent = this.mgp_occupiedstands;

            let _x = ((t[0]) * mgp_ocobj.mgp_gridsquaresize);
            let _y = ((t[1]) * mgp_ocobj.mgp_gridsquaresize / 4) + 0.15;
            let _z = ((t[2]) * mgp_ocobj.mgp_gridsquaresize);
            _x += mgp_ocobj.mgp_gridhalfsquaresize;
            _z += mgp_ocobj.mgp_gridhalfsquaresize;

            bstand.setAbsolutePosition(new BABYLON.Vector3(_x, _y, _z));


You will probably need to call this.mgp_occupiedstands.computeWorldMatrix(true) to be sure everything is ready when setting the position ? A playground would help to validate assumptions here.



You are correct. Forcing update of the world matrix for mgp_occupiedstands did the trick. I for some reason assumed the world matrix was updated when parent property was set.

Thanks for help :slight_smile: