|
@@ -11,7 +11,7 @@
|
|
* http://www.cs.indiana.edu/pub/techreports/TR425.pdf
|
|
* http://www.cs.indiana.edu/pub/techreports/TR425.pdf
|
|
*/
|
|
*/
|
|
|
|
|
|
-THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed, debug ) {
|
|
|
|
|
|
+THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed ) {
|
|
|
|
|
|
THREE.Geometry.call( this );
|
|
THREE.Geometry.call( this );
|
|
|
|
|
|
@@ -21,8 +21,6 @@ THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed, d
|
|
this.radialSegments = radialSegments || 8;
|
|
this.radialSegments = radialSegments || 8;
|
|
this.closed = closed || false;
|
|
this.closed = closed || false;
|
|
|
|
|
|
- if ( debug ) this.debug = new THREE.Object3D();
|
|
|
|
-
|
|
|
|
this.grid = [];
|
|
this.grid = [];
|
|
|
|
|
|
var scope = this,
|
|
var scope = this,
|
|
@@ -75,14 +73,6 @@ THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed, d
|
|
normal = normals[ i ];
|
|
normal = normals[ i ];
|
|
binormal = binormals[ i ];
|
|
binormal = binormals[ i ];
|
|
|
|
|
|
- if ( this.debug ) {
|
|
|
|
-
|
|
|
|
- this.debug.add( new THREE.ArrowHelper(tangent, pos, radius, 0x0000ff ) );
|
|
|
|
- this.debug.add( new THREE.ArrowHelper(normal, pos, radius, 0xff0000 ) );
|
|
|
|
- this.debug.add( new THREE.ArrowHelper(binormal, pos, radius, 0x00ff00 ) );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
for ( j = 0; j < this.radialSegments; j++ ) {
|
|
for ( j = 0; j < this.radialSegments; j++ ) {
|
|
|
|
|
|
v = j / this.radialSegments * 2 * Math.PI;
|
|
v = j / this.radialSegments * 2 * Math.PI;
|
|
@@ -244,7 +234,7 @@ THREE.TubeGeometry.FrenetFrames = function(path, segments, closed) {
|
|
|
|
|
|
vec.normalize();
|
|
vec.normalize();
|
|
|
|
|
|
- theta = Math.acos( tangents[ i-1 ].dot( tangents[ i ] ) );
|
|
|
|
|
|
+ theta = Math.acos( THREE.Math.clamp( tangents[ i-1 ].dot( tangents[ i ] ), -1, 1 ) ); // clamp for floating pt errors
|
|
|
|
|
|
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
|
|
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
|
|
|
|
|
|
@@ -259,7 +249,7 @@ THREE.TubeGeometry.FrenetFrames = function(path, segments, closed) {
|
|
|
|
|
|
if ( closed ) {
|
|
if ( closed ) {
|
|
|
|
|
|
- theta = Math.acos( normals[ 0 ].dot( normals[ numpoints-1 ] ) );
|
|
|
|
|
|
+ theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints-1 ] ), -1, 1 ) );
|
|
theta /= ( numpoints - 1 );
|
|
theta /= ( numpoints - 1 );
|
|
|
|
|
|
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints-1 ] ) ) > 0 ) {
|
|
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints-1 ] ) ) > 0 ) {
|