|
@@ -11,7 +11,7 @@
|
|
* http://prideout.net/blog/?p=44
|
|
* http://prideout.net/blog/?p=44
|
|
*/
|
|
*/
|
|
|
|
|
|
-( function( Curves ) {
|
|
|
|
|
|
+( function ( Curves ) {
|
|
|
|
|
|
// GrannyKnot
|
|
// GrannyKnot
|
|
|
|
|
|
@@ -24,7 +24,9 @@
|
|
GrannyKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
GrannyKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
GrannyKnot.prototype.constructor = GrannyKnot;
|
|
GrannyKnot.prototype.constructor = GrannyKnot;
|
|
|
|
|
|
- GrannyKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ GrannyKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t = 2 * Math.PI * t;
|
|
t = 2 * Math.PI * t;
|
|
|
|
|
|
@@ -32,7 +34,7 @@
|
|
var y = - 0.1 * Math.cos( 2 * t ) - 0.27 * Math.sin( 2 * t ) + 0.38 * Math.cos( 4 * t ) + 0.46 * Math.sin( 4 * t );
|
|
var y = - 0.1 * Math.cos( 2 * t ) - 0.27 * Math.sin( 2 * t ) + 0.38 * Math.cos( 4 * t ) + 0.46 * Math.sin( 4 * t );
|
|
var z = 0.7 * Math.cos( 3 * t ) - 0.4 * Math.sin( 3 * t );
|
|
var z = 0.7 * Math.cos( 3 * t ) - 0.4 * Math.sin( 3 * t );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( 20 );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( 20 );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -49,7 +51,9 @@
|
|
HeartCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
HeartCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
HeartCurve.prototype.constructor = HeartCurve;
|
|
HeartCurve.prototype.constructor = HeartCurve;
|
|
|
|
|
|
- HeartCurve.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ HeartCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t *= 2 * Math.PI;
|
|
t *= 2 * Math.PI;
|
|
|
|
|
|
@@ -57,7 +61,7 @@
|
|
var y = 13 * Math.cos( t ) - 5 * Math.cos( 2 * t ) - 2 * Math.cos( 3 * t ) - Math.cos( 4 * t );
|
|
var y = 13 * Math.cos( t ) - 5 * Math.cos( 2 * t ) - 2 * Math.cos( 3 * t ) - Math.cos( 4 * t );
|
|
var z = 0;
|
|
var z = 0;
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -74,7 +78,9 @@
|
|
VivianiCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
VivianiCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
VivianiCurve.prototype.constructor = VivianiCurve;
|
|
VivianiCurve.prototype.constructor = VivianiCurve;
|
|
|
|
|
|
- VivianiCurve.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ VivianiCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t = t * 4 * Math.PI; // normalized to 0..1
|
|
t = t * 4 * Math.PI; // normalized to 0..1
|
|
var a = this.radius / 2;
|
|
var a = this.radius / 2;
|
|
@@ -83,7 +89,7 @@
|
|
var y = a * Math.sin( t );
|
|
var y = a * Math.sin( t );
|
|
var z = 2 * a * Math.sin( t / 2 );
|
|
var z = 2 * a * Math.sin( t / 2 );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z );
|
|
|
|
|
|
+ return point.set( x, y, z );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -98,7 +104,9 @@
|
|
KnotCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
KnotCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
KnotCurve.prototype.constructor = KnotCurve;
|
|
KnotCurve.prototype.constructor = KnotCurve;
|
|
|
|
|
|
- KnotCurve.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ KnotCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t *= 2 * Math.PI;
|
|
t *= 2 * Math.PI;
|
|
|
|
|
|
@@ -109,7 +117,7 @@
|
|
var y = Math.cos( t ) * ( R + s * Math.cos( t ) );
|
|
var y = Math.cos( t ) * ( R + s * Math.cos( t ) );
|
|
var z = Math.sin( t ) * ( R + s * Math.cos( t ) );
|
|
var z = Math.sin( t ) * ( R + s * Math.cos( t ) );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z );
|
|
|
|
|
|
+ return point.set( x, y, z );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -124,7 +132,9 @@
|
|
HelixCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
HelixCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
HelixCurve.prototype.constructor = HelixCurve;
|
|
HelixCurve.prototype.constructor = HelixCurve;
|
|
|
|
|
|
- HelixCurve.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ HelixCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var a = 30; // radius
|
|
var a = 30; // radius
|
|
var b = 150; // height
|
|
var b = 150; // height
|
|
@@ -135,7 +145,7 @@
|
|
var y = Math.sin( t2 ) * a;
|
|
var y = Math.sin( t2 ) * a;
|
|
var z = b * t;
|
|
var z = b * t;
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z );
|
|
|
|
|
|
+ return point.set( x, y, z );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -152,7 +162,9 @@
|
|
TrefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TrefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TrefoilKnot.prototype.constructor = TrefoilKnot;
|
|
TrefoilKnot.prototype.constructor = TrefoilKnot;
|
|
|
|
|
|
- TrefoilKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ TrefoilKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t *= Math.PI * 2;
|
|
t *= Math.PI * 2;
|
|
|
|
|
|
@@ -160,7 +172,7 @@
|
|
var y = ( 2 + Math.cos( 3 * t ) ) * Math.sin( 2 * t );
|
|
var y = ( 2 + Math.cos( 3 * t ) ) * Math.sin( 2 * t );
|
|
var z = Math.sin( 3 * t );
|
|
var z = Math.sin( 3 * t );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -177,7 +189,9 @@
|
|
TorusKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TorusKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TorusKnot.prototype.constructor = TorusKnot;
|
|
TorusKnot.prototype.constructor = TorusKnot;
|
|
|
|
|
|
- TorusKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ TorusKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var p = 3;
|
|
var p = 3;
|
|
var q = 4;
|
|
var q = 4;
|
|
@@ -188,7 +202,7 @@
|
|
var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
var z = Math.sin( q * t );
|
|
var z = Math.sin( q * t );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -205,7 +219,9 @@
|
|
CinquefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
CinquefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
CinquefoilKnot.prototype.constructor = CinquefoilKnot;
|
|
CinquefoilKnot.prototype.constructor = CinquefoilKnot;
|
|
|
|
|
|
- CinquefoilKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ CinquefoilKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var p = 2;
|
|
var p = 2;
|
|
var q = 5;
|
|
var q = 5;
|
|
@@ -216,7 +232,7 @@
|
|
var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
var z = Math.sin( q * t );
|
|
var z = Math.sin( q * t );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -233,7 +249,9 @@
|
|
TrefoilPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TrefoilPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
TrefoilPolynomialKnot.prototype.constructor = TrefoilPolynomialKnot;
|
|
TrefoilPolynomialKnot.prototype.constructor = TrefoilPolynomialKnot;
|
|
|
|
|
|
- TrefoilPolynomialKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ TrefoilPolynomialKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t = t * 4 - 2;
|
|
t = t * 4 - 2;
|
|
|
|
|
|
@@ -241,11 +259,11 @@
|
|
var y = Math.pow( t, 4 ) - 4 * t * t;
|
|
var y = Math.pow( t, 4 ) - 4 * t * t;
|
|
var z = 1 / 5 * Math.pow( t, 5 ) - 2 * t;
|
|
var z = 1 / 5 * Math.pow( t, 5 ) - 2 * t;
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- var scaleTo = function( x, y, t ) {
|
|
|
|
|
|
+ var scaleTo = function ( x, y, t ) {
|
|
|
|
|
|
var r = y - x;
|
|
var r = y - x;
|
|
return t * r + x;
|
|
return t * r + x;
|
|
@@ -265,7 +283,9 @@
|
|
FigureEightPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
FigureEightPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
FigureEightPolynomialKnot.prototype.constructor = FigureEightPolynomialKnot;
|
|
FigureEightPolynomialKnot.prototype.constructor = FigureEightPolynomialKnot;
|
|
|
|
|
|
- FigureEightPolynomialKnot.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ FigureEightPolynomialKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t = scaleTo( - 4, 4, t );
|
|
t = scaleTo( - 4, 4, t );
|
|
|
|
|
|
@@ -273,7 +293,7 @@
|
|
var y = Math.pow( t, 4 ) - 13 * t * t;
|
|
var y = Math.pow( t, 4 ) - 13 * t * t;
|
|
var z = 1 / 10 * t * ( t * t - 4 ) * ( t * t - 9 ) * ( t * t - 12 );
|
|
var z = 1 / 10 * t * ( t * t - 4 ) * ( t * t - 9 ) * ( t * t - 12 );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -290,7 +310,9 @@
|
|
DecoratedTorusKnot4a.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot4a.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot4a.prototype.constructor = DecoratedTorusKnot4a;
|
|
DecoratedTorusKnot4a.prototype.constructor = DecoratedTorusKnot4a;
|
|
|
|
|
|
- DecoratedTorusKnot4a.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ DecoratedTorusKnot4a.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
t *= Math.PI * 2;
|
|
t *= Math.PI * 2;
|
|
|
|
|
|
@@ -298,7 +320,7 @@
|
|
var y = Math.sin( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) );
|
|
var y = Math.sin( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) );
|
|
var z = 0.35 * Math.sin( 5 * t );
|
|
var z = 0.35 * Math.sin( 5 * t );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -315,7 +337,9 @@
|
|
DecoratedTorusKnot4b.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot4b.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot4b.prototype.constructor = DecoratedTorusKnot4b;
|
|
DecoratedTorusKnot4b.prototype.constructor = DecoratedTorusKnot4b;
|
|
|
|
|
|
- DecoratedTorusKnot4b.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ DecoratedTorusKnot4b.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var fi = t * Math.PI * 2;
|
|
var fi = t * Math.PI * 2;
|
|
|
|
|
|
@@ -323,7 +347,7 @@
|
|
var y = Math.sin( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) );
|
|
var y = Math.sin( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) );
|
|
var z = 0.2 * Math.sin( 9 * fi );
|
|
var z = 0.2 * Math.sin( 9 * fi );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -340,7 +364,9 @@
|
|
DecoratedTorusKnot5a.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot5a.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot5a.prototype.constructor = DecoratedTorusKnot5a;
|
|
DecoratedTorusKnot5a.prototype.constructor = DecoratedTorusKnot5a;
|
|
|
|
|
|
- DecoratedTorusKnot5a.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ DecoratedTorusKnot5a.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var fi = t * Math.PI * 2;
|
|
var fi = t * Math.PI * 2;
|
|
|
|
|
|
@@ -348,7 +374,7 @@
|
|
var y = Math.sin( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) );
|
|
var y = Math.sin( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) );
|
|
var z = 0.2 * Math.sin( 20 * fi );
|
|
var z = 0.2 * Math.sin( 20 * fi );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -365,7 +391,9 @@
|
|
DecoratedTorusKnot5c.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot5c.prototype = Object.create( THREE.Curve.prototype );
|
|
DecoratedTorusKnot5c.prototype.constructor = DecoratedTorusKnot5c;
|
|
DecoratedTorusKnot5c.prototype.constructor = DecoratedTorusKnot5c;
|
|
|
|
|
|
- DecoratedTorusKnot5c.prototype.getPoint = function( t ) {
|
|
|
|
|
|
+ DecoratedTorusKnot5c.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
+
|
|
|
|
+ var point = optionalTarget || new THREE.Vector3();
|
|
|
|
|
|
var fi = t * Math.PI * 2;
|
|
var fi = t * Math.PI * 2;
|
|
|
|
|
|
@@ -373,7 +401,7 @@
|
|
var y = Math.sin( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) );
|
|
var y = Math.sin( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) );
|
|
var z = 0.35 * Math.sin( 15 * fi );
|
|
var z = 0.35 * Math.sin( 15 * fi );
|
|
|
|
|
|
- return new THREE.Vector3( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
+ return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
@@ -394,4 +422,4 @@
|
|
Curves.DecoratedTorusKnot5a = DecoratedTorusKnot5a;
|
|
Curves.DecoratedTorusKnot5a = DecoratedTorusKnot5a;
|
|
Curves.DecoratedTorusKnot5c = DecoratedTorusKnot5c;
|
|
Curves.DecoratedTorusKnot5c = DecoratedTorusKnot5c;
|
|
|
|
|
|
-} ) ( THREE.Curves = THREE.Curves || {} );
|
|
|
|
|
|
+} )( THREE.Curves = THREE.Curves || {} );
|