Hi,
How can I get the normal (using PickingInfo) of a custom imported mesh? It does work on any of the primitives created with MeshBuilder. But I don’t get proper normals on imported meshes.
Here’s an example. The Normal should be [0, 0.899144, -0.437652]
. Instead I get [0, -1, 0]
.
Ok, so when I started to debug this inside my project I realised I actually have to wrap the ray casting into one of the scene render hooks, eg:
scene.registerBeforeRender(() => {
const ray = new BABYLON.Ray(new BABYLON.Vector3(0, 3, 0), BABYLON.Vector3.Down(), 3);
const rayHelper = new BABYLON.RayHelper(ray);
rayHelper.show(scene, new BABYLON.Color3(1, 0, 0));
const pick = ray.intersectsMesh(ground);
const normal = pick.getNormal();
console.log('Normal:', normal);
})
Solved!
1 Like