0

I have to script to show a normal line on a mesh. On a minimal script, everything is working fine. If I use the same model in the one of my existing application, eveything is wrong. In front of the camera, the normal detection seems correct, but as soon as I rotate the mesh, the normal detection is not good. In both scripts, I am using raycaster to get the intersection and I use:

                var p = intersects[ 0 ].point;
                intersection.point.copy( p );
                var n = intersects[ 0 ].face.normal.clone();
                n.multiplyScalar( 100 );
                n.add( intersects[ 0 ].point );
                intersection.normal.copy( intersects[ 0 ].face.normal );

                line.geometry.vertices[ 0 ].copy( intersection.point );
                line.geometry.vertices[ 1 ].copy( n );
                line.geometry.verticesNeedUpdate = true;

to get the normal.

What could cause this difference, as I am using the same mesh and the same commands for the normal in both scripts to get the normals?

1
  • Ha, that's funny I just posted this as an issue on their github.
    – Hobbes
    Jan 2, 2015 at 2:51

1 Answer 1

1

I found out the origin of the problem:

  • in the working script, I was using Orbitcontrols to transform the mesh;

  • in the non-working script, I was transforming the mesh myself and it seems the normals were not updated. What happened is that the origin point was correct but the normal orientation was the same as before any transformation of the mesh. The transformations were not applied to the normals. I did not dig up further and switched to OrbitControls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.