Skip to content

Commit 3653a82

Browse files
committed
Updated builds.
1 parent 19cb79c commit 3653a82

File tree

2 files changed

+454
-458
lines changed

2 files changed

+454
-458
lines changed

build/three.js

Lines changed: 121 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -24492,9 +24492,6 @@
2449224492
*
2449324493
* Creates a tube which extrudes along a 3d spline.
2449424494
*
24495-
* Uses parallel transport frames as described in:
24496-
*
24497-
* http://www.cs.indiana.edu/pub/techreports/TR425.pdf
2449824495
*/
2449924496

2450024497
function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) {
@@ -24516,7 +24513,7 @@
2451624513
radialSegments = radialSegments || 8;
2451724514
closed = closed || false;
2451824515

24519-
var frames = new FrenetFrames( path, tubularSegments, closed );
24516+
var frames = path.computeFrenetFrames( tubularSegments, closed );
2452024517

2452124518
// expose internals
2452224519

@@ -24663,123 +24660,6 @@
2466324660
TubeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
2466424661
TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
2466524662

24666-
// For computing of Frenet frames, exposing the tangents, normals and binormals the spline
24667-
24668-
function FrenetFrames( path, segments, closed ) {
24669-
24670-
var normal = new Vector3();
24671-
24672-
var tangents = [];
24673-
var normals = [];
24674-
var binormals = [];
24675-
24676-
var vec = new Vector3();
24677-
var mat = new Matrix4();
24678-
24679-
var i, u, theta;
24680-
24681-
// expose internals
24682-
24683-
this.tangents = tangents;
24684-
this.normals = normals;
24685-
this.binormals = binormals;
24686-
24687-
// compute the tangent vectors for each segment on the path
24688-
24689-
for ( i = 0; i <= segments; i ++ ) {
24690-
24691-
u = i / segments;
24692-
24693-
tangents[ i ] = path.getTangentAt( u );
24694-
tangents[ i ].normalize();
24695-
24696-
}
24697-
24698-
// select an initial normal vector perpendicular to the first tangent vector,
24699-
// and in the direction of the minimum tangent xyz component
24700-
24701-
normals[ 0 ] = new Vector3();
24702-
binormals[ 0 ] = new Vector3();
24703-
var min = Number.MAX_VALUE;
24704-
var tx = Math.abs( tangents[ 0 ].x );
24705-
var ty = Math.abs( tangents[ 0 ].y );
24706-
var tz = Math.abs( tangents[ 0 ].z );
24707-
24708-
if ( tx <= min ) {
24709-
24710-
min = tx;
24711-
normal.set( 1, 0, 0 );
24712-
24713-
}
24714-
24715-
if ( ty <= min ) {
24716-
24717-
min = ty;
24718-
normal.set( 0, 1, 0 );
24719-
24720-
}
24721-
24722-
if ( tz <= min ) {
24723-
24724-
normal.set( 0, 0, 1 );
24725-
24726-
}
24727-
24728-
vec.crossVectors( tangents[ 0 ], normal ).normalize();
24729-
24730-
normals[ 0 ].crossVectors( tangents[ 0 ], vec );
24731-
binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] );
24732-
24733-
24734-
// compute the slowly-varying normal and binormal vectors for each segment on the path
24735-
24736-
for ( i = 1; i <= segments; i ++ ) {
24737-
24738-
normals[ i ] = normals[ i - 1 ].clone();
24739-
24740-
binormals[ i ] = binormals[ i - 1 ].clone();
24741-
24742-
vec.crossVectors( tangents[ i - 1 ], tangents[ i ] );
24743-
24744-
if ( vec.length() > Number.EPSILON ) {
24745-
24746-
vec.normalize();
24747-
24748-
theta = Math.acos( exports.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
24749-
24750-
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
24751-
24752-
}
24753-
24754-
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
24755-
24756-
}
24757-
24758-
// if the curve is closed, postprocess the vectors so the first and last normal vectors are the same
24759-
24760-
if ( closed ) {
24761-
24762-
theta = Math.acos( exports.Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
24763-
theta /= segments;
24764-
24765-
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
24766-
24767-
theta = - theta;
24768-
24769-
}
24770-
24771-
for ( i = 1; i <= segments; i ++ ) {
24772-
24773-
// twist a little...
24774-
normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );
24775-
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
24776-
24777-
}
24778-
24779-
}
24780-
24781-
}
24782-
2478324663
/**
2478424664
* @author oosmoxiecode / https://github.com/oosmoxiecode
2478524665
* @author WestLangley / https://github.com/WestLangley
@@ -24804,7 +24684,7 @@
2480424684
closed: closed
2480524685
};
2480624686

24807-
if( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
24687+
if ( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
2480824688

2480924689
var bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
2481024690

@@ -25955,7 +25835,7 @@
2595525835
* bevelSegments: <int>, // number of bevel layers
2595625836
*
2595725837
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
25958-
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
25838+
* frames: <Object> // containing arrays of tangents, normals, binormals
2595925839
*
2596025840
* uvGenerator: <Object> // object that provides UV generator functions
2596125841
*
@@ -26037,10 +25917,9 @@
2603725917

2603825918
// SETUP TNB variables
2603925919

26040-
// Reuse TNB from TubeGeomtry for now.
2604125920
// TODO1 - have a .isClosed in spline?
2604225921

26043-
splineTube = options.frames !== undefined ? options.frames : new TubeGeometry.FrenetFrames( extrudePath, steps, false );
25922+
splineTube = options.frames !== undefined ? options.frames : extrudePath.computeFrenetFrames( steps, false );
2604425923

2604525924
// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
2604625925

@@ -33677,6 +33556,123 @@
3367733556
var t = this.getUtoTmapping( u );
3367833557
return this.getTangent( t );
3367933558

33559+
},
33560+
33561+
computeFrenetFrames: function ( segments, closed ) {
33562+
33563+
// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf
33564+
33565+
var normal = new Vector3();
33566+
33567+
var tangents = [];
33568+
var normals = [];
33569+
var binormals = [];
33570+
33571+
var vec = new Vector3();
33572+
var mat = new Matrix4();
33573+
33574+
var i, u, theta;
33575+
33576+
// compute the tangent vectors for each segment on the curve
33577+
33578+
for ( i = 0; i <= segments; i ++ ) {
33579+
33580+
u = i / segments;
33581+
33582+
tangents[ i ] = this.getTangentAt( u );
33583+
tangents[ i ].normalize();
33584+
33585+
}
33586+
33587+
// select an initial normal vector perpendicular to the first tangent vector,
33588+
// and in the direction of the minimum tangent xyz component
33589+
33590+
normals[ 0 ] = new Vector3();
33591+
binormals[ 0 ] = new Vector3();
33592+
var min = Number.MAX_VALUE;
33593+
var tx = Math.abs( tangents[ 0 ].x );
33594+
var ty = Math.abs( tangents[ 0 ].y );
33595+
var tz = Math.abs( tangents[ 0 ].z );
33596+
33597+
if ( tx <= min ) {
33598+
33599+
min = tx;
33600+
normal.set( 1, 0, 0 );
33601+
33602+
}
33603+
33604+
if ( ty <= min ) {
33605+
33606+
min = ty;
33607+
normal.set( 0, 1, 0 );
33608+
33609+
}
33610+
33611+
if ( tz <= min ) {
33612+
33613+
normal.set( 0, 0, 1 );
33614+
33615+
}
33616+
33617+
vec.crossVectors( tangents[ 0 ], normal ).normalize();
33618+
33619+
normals[ 0 ].crossVectors( tangents[ 0 ], vec );
33620+
binormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] );
33621+
33622+
33623+
// compute the slowly-varying normal and binormal vectors for each segment on the curve
33624+
33625+
for ( i = 1; i <= segments; i ++ ) {
33626+
33627+
normals[ i ] = normals[ i - 1 ].clone();
33628+
33629+
binormals[ i ] = binormals[ i - 1 ].clone();
33630+
33631+
vec.crossVectors( tangents[ i - 1 ], tangents[ i ] );
33632+
33633+
if ( vec.length() > Number.EPSILON ) {
33634+
33635+
vec.normalize();
33636+
33637+
theta = Math.acos( exports.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
33638+
33639+
normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
33640+
33641+
}
33642+
33643+
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
33644+
33645+
}
33646+
33647+
// if the curve is closed, postprocess the vectors so the first and last normal vectors are the same
33648+
33649+
if ( closed === true ) {
33650+
33651+
theta = Math.acos( exports.Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
33652+
theta /= segments;
33653+
33654+
if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
33655+
33656+
theta = - theta;
33657+
33658+
}
33659+
33660+
for ( i = 1; i <= segments; i ++ ) {
33661+
33662+
// twist a little...
33663+
normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );
33664+
binormals[ i ].crossVectors( tangents[ i ], normals[ i ] );
33665+
33666+
}
33667+
33668+
}
33669+
33670+
return {
33671+
tangents: tangents,
33672+
normals: normals,
33673+
binormals: binormals
33674+
};
33675+
3368033676
}
3368133677

3368233678
};

0 commit comments

Comments
 (0)