简体   繁体   中英

How to get mesh center in babylonjs?

After double clicking on a mesh I need to find out what is the centre of the mesh regarding to its boundary box

    window.addEventListener("dblclick", function (event) {
        var pickResult = scene.pick(scene.pointerX, scene.pointerY);
        var mesh = pickResult.pickedMesh;
        //var centerPosition = mesh.GetCenter(); <-- what is the center             
    });

Once you have the mesh, you can call mesh.getBoundingInfo

On a bounding info object you have a bounding box and a bounding sphere. The sphere provides the mesh center in local and world coordinates

http://doc.babylonjs.com/api/classes/babylon.boundinginfo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM