| 31694 | } |
| 31695 | |
| 31696 | function initialNormal3() { |
| 31697 | // select an initial normal vector perpenicular to the first tangent vector, |
| 31698 | // and in the direction of the smallest tangent xyz component |
| 31699 | |
| 31700 | normals[ 0 ] = new THREE.Vector3(); |
| 31701 | binormals[ 0 ] = new THREE.Vector3(); |
| 31702 | smallest = Number.MAX_VALUE; |
| 31703 | tx = Math.abs( tangents[ 0 ].x ); |
| 31704 | ty = Math.abs( tangents[ 0 ].y ); |
| 31705 | tz = Math.abs( tangents[ 0 ].z ); |
| 31706 | |
| 31707 | if ( tx <= smallest ) { |
| 31708 | smallest = tx; |
| 31709 | normal.set( 1, 0, 0 ); |
| 31710 | } |
| 31711 | |
| 31712 | if ( ty <= smallest ) { |
| 31713 | smallest = ty; |
| 31714 | normal.set( 0, 1, 0 ); |
| 31715 | } |
| 31716 | |
| 31717 | if ( tz <= smallest ) { |
| 31718 | normal.set( 0, 0, 1 ); |
| 31719 | } |
| 31720 | |
| 31721 | vec.cross( tangents[ 0 ], normal ).normalize(); |
| 31722 | |
| 31723 | normals[ 0 ].cross( tangents[ 0 ], vec ); |
| 31724 | binormals[ 0 ].cross( tangents[ 0 ], normals[ 0 ] ); |
| 31725 | } |
| 31726 | |
| 31727 | |
| 31728 | // compute the slowly-varying normal and binormal vectors for each segment on the path |