【问题标题】:Babylonjs, get the mesh that the point (x,y,z) point to one of it's facesBabylonjs,获取点 (x,y,z) 指向其中一个面的网格
【发布时间】:2017-03-20 16:58:35
【问题描述】:

我有一个 3D 点,我需要知道这个点是否在我的场景中的任何网格中。

我找到了:

var pickResult = scene.pick(scene.pointerX, scene.pointerY);

但我需要传递 3D 点而不是指针位置。

【问题讨论】:

    标签: 3d babylonjs


    【解决方案1】:

    据我所知,您需要保留一个数组,其中包含您需要检查的所有网格。

    var meshList = []; // List Containing all your meshes you want to check if the point is in
    var point = new BABYLON.Vector3(x,y,z); // Where x,y,z are replaced with your coordinates
    
    for(i=0; i<meshList.length; i++){
        if(meshList[i].intersectsPoint(point)){
            console.log("Your point is in a mesh");
        }
    }
    

    【讨论】:

      【解决方案2】:

      你可以使用scene.pickWithRay:

      var rayPick1 = new BABYLON.Ray(origin, direction);
      var meshFound1 = scene.pickWithRay(rayPick1, function (item) {
      
      });
      

      【讨论】:

        猜你喜欢
        • 2019-05-26
        • 1970-01-01
        • 1970-01-01
        • 2013-02-26
        • 1970-01-01
        • 2011-06-20
        • 2019-09-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多