|
@@ -6,10 +6,8 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
import {
|
|
import {
|
|
- ArrowHelper,
|
|
|
|
Curve,
|
|
Curve,
|
|
Geometry,
|
|
Geometry,
|
|
- Object3D,
|
|
|
|
ParametricGeometry,
|
|
ParametricGeometry,
|
|
Vector3
|
|
Vector3
|
|
} from "../../../build/three.module.js";
|
|
} from "../../../build/three.module.js";
|
|
@@ -105,14 +103,13 @@ var ParametricGeometries = {
|
|
*
|
|
*
|
|
*********************************************/
|
|
*********************************************/
|
|
|
|
|
|
-ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsRadius, closed, debug ) {
|
|
|
|
|
|
+ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsRadius, closed ) {
|
|
|
|
|
|
this.path = path;
|
|
this.path = path;
|
|
this.segments = segments || 64;
|
|
this.segments = segments || 64;
|
|
this.radius = radius || 1;
|
|
this.radius = radius || 1;
|
|
this.segmentsRadius = segmentsRadius || 8;
|
|
this.segmentsRadius = segmentsRadius || 8;
|
|
this.closed = closed || false;
|
|
this.closed = closed || false;
|
|
- if ( debug ) this.debug = new Object3D();
|
|
|
|
|
|
|
|
var scope = this, numpoints = this.segments + 1;
|
|
var scope = this, numpoints = this.segments + 1;
|
|
|
|
|
|
@@ -127,6 +124,8 @@ ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsR
|
|
this.normals = normals;
|
|
this.normals = normals;
|
|
this.binormals = binormals;
|
|
this.binormals = binormals;
|
|
|
|
|
|
|
|
+ var position = new Vector3();
|
|
|
|
+
|
|
var ParametricTube = function ( u, v, target ) {
|
|
var ParametricTube = function ( u, v, target ) {
|
|
|
|
|
|
v *= 2 * Math.PI;
|
|
v *= 2 * Math.PI;
|
|
@@ -134,28 +133,19 @@ ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsR
|
|
var i = u * ( numpoints - 1 );
|
|
var i = u * ( numpoints - 1 );
|
|
i = Math.floor( i );
|
|
i = Math.floor( i );
|
|
|
|
|
|
- var pos = path.getPointAt( u );
|
|
|
|
|
|
+ path.getPointAt( u, position );
|
|
|
|
|
|
- var tangent = tangents[ i ];
|
|
|
|
var normal = normals[ i ];
|
|
var normal = normals[ i ];
|
|
var binormal = binormals[ i ];
|
|
var binormal = binormals[ i ];
|
|
|
|
|
|
- if ( scope.debug ) {
|
|
|
|
-
|
|
|
|
- scope.debug.add( new ArrowHelper( tangent, pos, radius, 0x0000ff ) );
|
|
|
|
- scope.debug.add( new ArrowHelper( normal, pos, radius, 0xff0000 ) );
|
|
|
|
- scope.debug.add( new ArrowHelper( binormal, pos, radius, 0x00ff00 ) );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
var cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
|
|
var cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
|
|
var cy = scope.radius * Math.sin( v );
|
|
var cy = scope.radius * Math.sin( v );
|
|
|
|
|
|
- pos.x += cx * normal.x + cy * binormal.x;
|
|
|
|
- pos.y += cx * normal.y + cy * binormal.y;
|
|
|
|
- pos.z += cx * normal.z + cy * binormal.z;
|
|
|
|
|
|
+ position.x += cx * normal.x + cy * binormal.x;
|
|
|
|
+ position.y += cx * normal.y + cy * binormal.y;
|
|
|
|
+ position.z += cx * normal.z + cy * binormal.z;
|
|
|
|
|
|
- target.copy( pos );
|
|
|
|
|
|
+ target.copy( position );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|