Hello
as an example I have 4 boxes which build with the solid particle systems , I want to get the thickness of the boxes with the help of the raycast,
here is part of my code:
let SPS = new BABYLON.SolidParticleSystem("SPS", scene, {
isPickable: true,
updatable: true,
enableDepthSort: true,
particleIntersection: true,
});
....
const ray1 = new BABYLON.Ray(
new BABYLON.Vector3(impact.position.x, 3000, impact.position.z),
new BABYLON.Vector3(0, -1, 0),
10000
);
const ray2 = new BABYLON.Ray(
new BABYLON.Vector3(impact.position.x, -3000, impact.position.z),
new BABYLON.Vector3(0, 1, 0),
10000
);
for (let i = 1; i < SPS.particles.length; i++) {
bTop[i] = ray1.intersectsMesh(SPS.particles[i]);
bBottom[i] = ray2.intersectsMesh(SPS.particles[i]);
if (bTop[i].hit && bBottom[i].hit) {
let d = BABYLON.Vector3.Distance(
bTop[i].pickedPoint,
bBottom[i].pickedPoint
);
console.log(d)
} else {
console.log("dd", "no intersection");
}
}
but when I run my code I got an error which said that t.getWorldMatrix is not a function
, how can I solve this problem?
here is my PG: https://playground.babylonjs.com/#XB49NT#59