How to get correct rotation value from pickinfo.getnormal()

@Vijayxd totally agree: too many complications going on here. Initially I assumed the geometry is bad so I scolded the 3D artist, well, actually I checked the vertex normals in Inspector. Geometry is ok.

So I checked the src code of getNormal and found the normal is negated in some cases, like this:

        // Flip the normal if the picking ray is in the same direction.
        if (this.ray && Vector3.Dot(result, this.ray.direction) > 0) {
            result.negateInPlace();
        }

I guess this is why the doc for getNormal says “Note that the returned normal will always point towards the picking ray.”. I fail to see the reason for this.

Anyway, the wrong normal can be flipped back like this:

      let norm = pickinfo.getNormal(true);
      if(pickinfo.ray) {
        let dd = BABYLON.Vector3.Dot(norm, pickinfo.ray.direction)
        if(dd > 0) norm.negateInPlace();
      }

Now all normals will be as expected.