Like is there a way or function to check a specific coordinate if it has a mesh?
This may help - Check When a Point is Inside a Mesh | Babylon.js Documentation
1 Like
@labris Sorry I didnt mean any specific mesh
I meant to check if any mesh is in that position
This is what I reached so far but idk how to make it so it checks for any mesh:
function checkForMesh(position) {
let found = false
const point = BABYLON.Vector3(position.x, position.y, position.z)
const sphere = BABYLON.MeshBuilder.CreateSphere(`meshCheck_${position.x}${position.y}${position.z}`, { segments: 1, diameter: 0.1, }, scene);
// code here to check if the point is inside any mesh, if found a mesh in that position set 'found' to true
return found;
};
I think you want to use?
found = sphere.intersectsPoint(point) // or loop through all scene.meshes?
Docs of intersectsPoint
:
3 Likes
Thanks
Earlier I was trying to make a sphere, put it in that position, and loop through all meshes and see if it intersects any mesh, but for some reason that wasnt working
This one worked tho, again thanks