【发布时间】:2017-03-20 16:58:35
【问题描述】:
我有一个 3D 点,我需要知道这个点是否在我的场景中的任何网格中。
我找到了:
var pickResult = scene.pick(scene.pointerX, scene.pointerY);
但我需要传递 3D 点而不是指针位置。
【问题讨论】:
我有一个 3D 点,我需要知道这个点是否在我的场景中的任何网格中。
我找到了:
var pickResult = scene.pick(scene.pointerX, scene.pointerY);
但我需要传递 3D 点而不是指针位置。
【问题讨论】:
据我所知,您需要保留一个数组,其中包含您需要检查的所有网格。
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");
}
}
【讨论】:
你可以使用scene.pickWithRay:
var rayPick1 = new BABYLON.Ray(origin, direction);
var meshFound1 = scene.pickWithRay(rayPick1, function (item) {
});
【讨论】: