Hello everyone
I want to get the thickness of the layers (which are planes in my model) with the aid of the ray cast.
here is my code for using ray cast to get the thickness, but it’s not working :
const ray = new BABYLON.Ray(new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(0, 0, -1), 60);
scene.onPointerObservable.add((evt, pickInfo) => {
if (evt.pickInfo.hit) {
let b1 = ray.intersectsMesh(box);
let b2 = ray.intersectsMesh(box2);
let b3 = ray.intersectsMesh(box3);
let b4 = ray.intersectsMesh(box4);
let d1 = BABYLON.Vector3.Distance(evt.pickInfo.pickedPoint, b1.pickedPoint);
let d2 = BABYLON.Vector3.Distance(evt.pickInfo.pickedPoint, b2.pickedPoint);
let d3 = BABYLON.Vector3.Distance(evt.pickInfo.pickedPoint, b3.pickedPoint);
let d4 = BABYLON.Vector3.Distance(evt.pickInfo.pickedPoint, b4.pickedPoint);
console.log("Dis", d1,d2,d3,d4)
gsap.to(camera.target, 1, { x: evt.pickInfo.pickedPoint.x, y: evt.pickInfo.pickedPoint.y, z: evt.pickInfo.pickedPoint.z })
console.log("G", evt.pickInfo.pickedPoint);
impact.position = evt.pickInfo.pickedPoint;
}
}, BABYLON.PointerEventTypes.POINTERDOUBLETAP);
actually I am trying to build something like the following app:
which is showing the thickness of the layers and showing them on the left chart.
how can I get the thickness of the planes when they are sticking together with just give the location on the top plane ?
and here is my PG: https://playground.babylonjs.com/#XB49NT#14