|
@@ -36,7 +36,7 @@ THREE.ParametricGeometries = {
|
|
|
|
|
|
plane: function ( width, height ) {
|
|
|
|
|
|
- return function( u, v, optionalTarget ) {
|
|
|
+ return function ( u, v, optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new THREE.Vector3();
|
|
|
|
|
@@ -50,7 +50,7 @@ THREE.ParametricGeometries = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- mobius: function( u, t, optionalTarget ) {
|
|
|
+ mobius: function ( u, t, optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new THREE.Vector3();
|
|
|
|
|
@@ -71,7 +71,7 @@ THREE.ParametricGeometries = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- mobius3d: function( u, t, optionalTarget ) {
|
|
|
+ mobius3d: function ( u, t, optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new THREE.Vector3();
|
|
|
|
|
@@ -104,7 +104,7 @@ THREE.ParametricGeometries = {
|
|
|
*
|
|
|
*********************************************/
|
|
|
|
|
|
-THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, debug ) {
|
|
|
+THREE.ParametricGeometries.TubeGeometry = function ( path, segments, radius, segmentsRadius, closed, debug ) {
|
|
|
|
|
|
this.path = path;
|
|
|
this.segments = segments || 64;
|
|
@@ -113,17 +113,7 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
|
|
|
this.closed = closed || false;
|
|
|
if ( debug ) this.debug = new THREE.Object3D();
|
|
|
|
|
|
-
|
|
|
- var scope = this,
|
|
|
-
|
|
|
- tangent, normal, binormal,
|
|
|
-
|
|
|
- numpoints = this.segments + 1,
|
|
|
-
|
|
|
- x, y, z, tx, ty, tz, u, v,
|
|
|
-
|
|
|
- cx, cy, pos,
|
|
|
- i, j, ip, jp, a, b, c, d, uva, uvb, uvc, uvd;
|
|
|
+ var scope = this, numpoints = this.segments + 1;
|
|
|
|
|
|
var frames = path.computeFrenetFrames( segments, closed ),
|
|
|
tangents = frames.tangents,
|
|
@@ -131,26 +121,25 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
|
|
|
binormals = frames.binormals;
|
|
|
|
|
|
// proxy internals
|
|
|
+
|
|
|
this.tangents = tangents;
|
|
|
this.normals = normals;
|
|
|
this.binormals = binormals;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- var ParametricTube = function( u, v, optionalTarget ) {
|
|
|
+ var ParametricTube = function ( u, v, optionalTarget ) {
|
|
|
|
|
|
var result = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
v *= 2 * Math.PI;
|
|
|
|
|
|
- i = u * ( numpoints - 1 );
|
|
|
+ var i = u * ( numpoints - 1 );
|
|
|
i = Math.floor( i );
|
|
|
|
|
|
- pos = path.getPointAt( u );
|
|
|
+ var pos = path.getPointAt( u );
|
|
|
|
|
|
- tangent = tangents[ i ];
|
|
|
- normal = normals[ i ];
|
|
|
- binormal = binormals[ i ];
|
|
|
+ var tangent = tangents[ i ];
|
|
|
+ var normal = normals[ i ];
|
|
|
+ var binormal = binormals[ i ];
|
|
|
|
|
|
if ( scope.debug ) {
|
|
|
|
|
@@ -160,8 +149,8 @@ THREE.ParametricGeometries.TubeGeometry = function( path, segments, radius, segm
|
|
|
|
|
|
}
|
|
|
|
|
|
- cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
|
|
|
- cy = scope.radius * Math.sin( v );
|
|
|
+ var cx = - scope.radius * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
|
|
|
+ var cy = scope.radius * Math.sin( v );
|
|
|
|
|
|
pos.x += cx * normal.x + cy * binormal.x;
|
|
|
pos.y += cx * normal.y + cy * binormal.y;
|
|
@@ -179,15 +168,13 @@ THREE.ParametricGeometries.TubeGeometry.prototype = Object.create( THREE.Geometr
|
|
|
THREE.ParametricGeometries.TubeGeometry.prototype.constructor = THREE.ParametricGeometries.TubeGeometry;
|
|
|
|
|
|
|
|
|
- /*********************************************
|
|
|
+/*********************************************
|
|
|
*
|
|
|
* Parametric Replacement for TorusKnotGeometry
|
|
|
*
|
|
|
*********************************************/
|
|
|
THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segmentsT, segmentsR, p, q ) {
|
|
|
|
|
|
- var scope = this;
|
|
|
-
|
|
|
this.radius = radius || 200;
|
|
|
this.tube = tube || 40;
|
|
|
this.segmentsT = segmentsT || 64;
|
|
@@ -204,7 +191,7 @@ THREE.ParametricGeometries.TorusKnotGeometry = function ( radius, tube, segments
|
|
|
TorusKnotCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
|
TorusKnotCurve.prototype.constructor = TorusKnotCurve;
|
|
|
|
|
|
- TorusKnotCurve.prototype.getPoint = function( t ){
|
|
|
+ TorusKnotCurve.prototype.getPoint = function ( t ) {
|
|
|
|
|
|
t *= Math.PI * 2;
|
|
|
|
|
@@ -230,12 +217,12 @@ THREE.ParametricGeometries.TorusKnotGeometry.prototype = Object.create( THREE.Ge
|
|
|
THREE.ParametricGeometries.TorusKnotGeometry.prototype.constructor = THREE.ParametricGeometries.TorusKnotGeometry;
|
|
|
|
|
|
|
|
|
- /*********************************************
|
|
|
+/*********************************************
|
|
|
*
|
|
|
* Parametric Replacement for SphereGeometry
|
|
|
*
|
|
|
*********************************************/
|
|
|
-THREE.ParametricGeometries.SphereGeometry = function( size, u, v ) {
|
|
|
+THREE.ParametricGeometries.SphereGeometry = function ( size, u, v ) {
|
|
|
|
|
|
function sphere( u, v, optionalTarget ) {
|
|
|
|
|
@@ -260,13 +247,13 @@ THREE.ParametricGeometries.SphereGeometry.prototype = Object.create( THREE.Geome
|
|
|
THREE.ParametricGeometries.SphereGeometry.prototype.constructor = THREE.ParametricGeometries.SphereGeometry;
|
|
|
|
|
|
|
|
|
- /*********************************************
|
|
|
+/*********************************************
|
|
|
*
|
|
|
* Parametric Replacement for PlaneGeometry
|
|
|
*
|
|
|
*********************************************/
|
|
|
|
|
|
-THREE.ParametricGeometries.PlaneGeometry = function( width, depth, segmentsWidth, segmentsDepth ) {
|
|
|
+THREE.ParametricGeometries.PlaneGeometry = function ( width, depth, segmentsWidth, segmentsDepth ) {
|
|
|
|
|
|
function plane( u, v, optionalTarget ) {
|
|
|
|