|
@@ -11,351 +11,343 @@
|
|
|
* http://www.mi.sanu.ac.rs/vismath/taylorapril2011/Taylor.pdf
|
|
|
* https://prideout.net/blog/old/blog/index.html@p=44.html
|
|
|
*/
|
|
|
+ // GrannyKnot
|
|
|
|
|
|
- var Curves = function () {
|
|
|
+ class GrannyKnot extends THREE.Curve {
|
|
|
|
|
|
- // GrannyKnot
|
|
|
- function GrannyKnot() {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
+ const point = optionalTarget;
|
|
|
+ t = 2 * Math.PI * t;
|
|
|
+ const x = - 0.22 * Math.cos( t ) - 1.28 * Math.sin( t ) - 0.44 * Math.cos( 3 * t ) - 0.78 * Math.sin( 3 * t );
|
|
|
+ const 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 );
|
|
|
+ const z = 0.7 * Math.cos( 3 * t ) - 0.4 * Math.sin( 3 * t );
|
|
|
+ return point.set( x, y, z ).multiplyScalar( 20 );
|
|
|
|
|
|
}
|
|
|
|
|
|
- GrannyKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- GrannyKnot.prototype.constructor = GrannyKnot;
|
|
|
+ } // HeartCurve
|
|
|
|
|
|
- GrannyKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- t = 2 * Math.PI * t;
|
|
|
- var x = - 0.22 * Math.cos( t ) - 1.28 * Math.sin( t ) - 0.44 * Math.cos( 3 * t ) - 0.78 * Math.sin( 3 * 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 );
|
|
|
- return point.set( x, y, z ).multiplyScalar( 20 );
|
|
|
+ class HeartCurve extends THREE.Curve {
|
|
|
|
|
|
- }; // HeartCurve
|
|
|
+ constructor( scale = 5 ) {
|
|
|
|
|
|
-
|
|
|
- function HeartCurve( scale ) {
|
|
|
-
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 5 : scale;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
- HeartCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- HeartCurve.prototype.constructor = HeartCurve;
|
|
|
-
|
|
|
- HeartCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t *= 2 * Math.PI;
|
|
|
- var x = 16 * Math.pow( Math.sin( t ), 3 );
|
|
|
- var y = 13 * Math.cos( t ) - 5 * Math.cos( 2 * t ) - 2 * Math.cos( 3 * t ) - Math.cos( 4 * t );
|
|
|
- var z = 0;
|
|
|
+ const x = 16 * Math.pow( Math.sin( t ), 3 );
|
|
|
+ const y = 13 * Math.cos( t ) - 5 * Math.cos( 2 * t ) - 2 * Math.cos( 3 * t ) - Math.cos( 4 * t );
|
|
|
+ const z = 0;
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // Viviani's THREE.Curve
|
|
|
+ }
|
|
|
|
|
|
+ } // Viviani's THREE.Curve
|
|
|
|
|
|
- function VivianiCurve( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 70 : scale;
|
|
|
+ class VivianiCurve extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 70 ) {
|
|
|
|
|
|
- VivianiCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- VivianiCurve.prototype.constructor = VivianiCurve;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- VivianiCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t = t * 4 * Math.PI; // normalized to 0..1
|
|
|
|
|
|
- var a = this.scale / 2;
|
|
|
- var x = a * ( 1 + Math.cos( t ) );
|
|
|
- var y = a * Math.sin( t );
|
|
|
- var z = 2 * a * Math.sin( t / 2 );
|
|
|
+ const a = this.scale / 2;
|
|
|
+ const x = a * ( 1 + Math.cos( t ) );
|
|
|
+ const y = a * Math.sin( t );
|
|
|
+ const z = 2 * a * Math.sin( t / 2 );
|
|
|
return point.set( x, y, z );
|
|
|
|
|
|
- }; // KnotCurve
|
|
|
-
|
|
|
-
|
|
|
- function KnotCurve() {
|
|
|
+ }
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
+ } // KnotCurve
|
|
|
|
|
|
- }
|
|
|
|
|
|
- KnotCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- KnotCurve.prototype.constructor = KnotCurve;
|
|
|
+ class KnotCurve extends THREE.Curve {
|
|
|
|
|
|
- KnotCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t *= 2 * Math.PI;
|
|
|
- var R = 10;
|
|
|
- var s = 50;
|
|
|
- var x = s * Math.sin( t );
|
|
|
- var y = Math.cos( t ) * ( R + s * Math.cos( t ) );
|
|
|
- var z = Math.sin( t ) * ( R + s * Math.cos( t ) );
|
|
|
+ const R = 10;
|
|
|
+ const s = 50;
|
|
|
+ const x = s * Math.sin( t );
|
|
|
+ const y = Math.cos( t ) * ( R + s * Math.cos( t ) );
|
|
|
+ const z = Math.sin( t ) * ( R + s * Math.cos( t ) );
|
|
|
return point.set( x, y, z );
|
|
|
|
|
|
- }; // HelixCurve
|
|
|
+ }
|
|
|
|
|
|
+ } // HelixCurve
|
|
|
|
|
|
- function HelixCurve() {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
+ class HelixCurve extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- HelixCurve.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- HelixCurve.prototype.constructor = HelixCurve;
|
|
|
+ const point = optionalTarget;
|
|
|
+ const a = 30; // radius
|
|
|
|
|
|
- HelixCurve.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ const b = 150; // height
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var a = 30; // radius
|
|
|
+ const t2 = 2 * Math.PI * t * b / 30;
|
|
|
+ const x = Math.cos( t2 ) * a;
|
|
|
+ const y = Math.sin( t2 ) * a;
|
|
|
+ const z = b * t;
|
|
|
+ return point.set( x, y, z );
|
|
|
|
|
|
- var b = 150; // height
|
|
|
+ }
|
|
|
|
|
|
- var t2 = 2 * Math.PI * t * b / 30;
|
|
|
- var x = Math.cos( t2 ) * a;
|
|
|
- var y = Math.sin( t2 ) * a;
|
|
|
- var z = b * t;
|
|
|
- return point.set( x, y, z );
|
|
|
+ } // TrefoilKnot
|
|
|
|
|
|
- }; // TrefoilKnot
|
|
|
|
|
|
+ class TrefoilKnot extends THREE.Curve {
|
|
|
|
|
|
- function TrefoilKnot( scale ) {
|
|
|
+ constructor( scale = 10 ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 10 : scale;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
}
|
|
|
|
|
|
- TrefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- TrefoilKnot.prototype.constructor = TrefoilKnot;
|
|
|
-
|
|
|
- TrefoilKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t *= Math.PI * 2;
|
|
|
- var x = ( 2 + Math.cos( 3 * t ) ) * Math.cos( 2 * t );
|
|
|
- var y = ( 2 + Math.cos( 3 * t ) ) * Math.sin( 2 * t );
|
|
|
- var z = Math.sin( 3 * t );
|
|
|
+ const x = ( 2 + Math.cos( 3 * t ) ) * Math.cos( 2 * t );
|
|
|
+ const y = ( 2 + Math.cos( 3 * t ) ) * Math.sin( 2 * t );
|
|
|
+ const z = Math.sin( 3 * t );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // TorusKnot
|
|
|
+ }
|
|
|
|
|
|
+ } // TorusKnot
|
|
|
|
|
|
- function TorusKnot( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 10 : scale;
|
|
|
+ class TorusKnot extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 10 ) {
|
|
|
|
|
|
- TorusKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- TorusKnot.prototype.constructor = TorusKnot;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- TorusKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var p = 3;
|
|
|
- var q = 4;
|
|
|
+ const point = optionalTarget;
|
|
|
+ const p = 3;
|
|
|
+ const q = 4;
|
|
|
t *= Math.PI * 2;
|
|
|
- var x = ( 2 + Math.cos( q * t ) ) * Math.cos( p * t );
|
|
|
- var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
|
- var z = Math.sin( q * t );
|
|
|
+ const x = ( 2 + Math.cos( q * t ) ) * Math.cos( p * t );
|
|
|
+ const y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
|
+ const z = Math.sin( q * t );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // CinquefoilKnot
|
|
|
+ }
|
|
|
|
|
|
+ } // CinquefoilKnot
|
|
|
|
|
|
- function CinquefoilKnot( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 10 : scale;
|
|
|
+ class CinquefoilKnot extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 10 ) {
|
|
|
|
|
|
- CinquefoilKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- CinquefoilKnot.prototype.constructor = CinquefoilKnot;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- CinquefoilKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ }
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var p = 2;
|
|
|
- var q = 5;
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
+
|
|
|
+ const point = optionalTarget;
|
|
|
+ const p = 2;
|
|
|
+ const q = 5;
|
|
|
t *= Math.PI * 2;
|
|
|
- var x = ( 2 + Math.cos( q * t ) ) * Math.cos( p * t );
|
|
|
- var y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
|
- var z = Math.sin( q * t );
|
|
|
+ const x = ( 2 + Math.cos( q * t ) ) * Math.cos( p * t );
|
|
|
+ const y = ( 2 + Math.cos( q * t ) ) * Math.sin( p * t );
|
|
|
+ const z = Math.sin( q * t );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // TrefoilPolynomialKnot
|
|
|
+ }
|
|
|
|
|
|
+ } // TrefoilPolynomialKnot
|
|
|
|
|
|
- function TrefoilPolynomialKnot( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 10 : scale;
|
|
|
+ class TrefoilPolynomialKnot extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 10 ) {
|
|
|
|
|
|
- TrefoilPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- TrefoilPolynomialKnot.prototype.constructor = TrefoilPolynomialKnot;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- TrefoilPolynomialKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ }
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
+
|
|
|
+ const point = optionalTarget;
|
|
|
t = t * 4 - 2;
|
|
|
- var x = Math.pow( t, 3 ) - 3 * t;
|
|
|
- var y = Math.pow( t, 4 ) - 4 * t * t;
|
|
|
- var z = 1 / 5 * Math.pow( t, 5 ) - 2 * t;
|
|
|
+ const x = Math.pow( t, 3 ) - 3 * t;
|
|
|
+ const y = Math.pow( t, 4 ) - 4 * t * t;
|
|
|
+ const z = 1 / 5 * Math.pow( t, 5 ) - 2 * t;
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- var scaleTo = function ( x, y, t ) {
|
|
|
+ }
|
|
|
|
|
|
- var r = y - x;
|
|
|
- return t * r + x;
|
|
|
+ function scaleTo( x, y, t ) {
|
|
|
|
|
|
- }; // FigureEightPolynomialKnot
|
|
|
+ const r = y - x;
|
|
|
+ return t * r + x;
|
|
|
|
|
|
+ } // FigureEightPolynomialKnot
|
|
|
|
|
|
- function FigureEightPolynomialKnot( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 1 : scale;
|
|
|
+ class FigureEightPolynomialKnot extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 1 ) {
|
|
|
|
|
|
- FigureEightPolynomialKnot.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- FigureEightPolynomialKnot.prototype.constructor = FigureEightPolynomialKnot;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- FigureEightPolynomialKnot.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ }
|
|
|
+
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t = scaleTo( - 4, 4, t );
|
|
|
- var x = 2 / 5 * t * ( t * t - 7 ) * ( t * t - 10 );
|
|
|
- var y = Math.pow( t, 4 ) - 13 * t * t;
|
|
|
- var z = 1 / 10 * t * ( t * t - 4 ) * ( t * t - 9 ) * ( t * t - 12 );
|
|
|
+ const x = 2 / 5 * t * ( t * t - 7 ) * ( t * t - 10 );
|
|
|
+ const y = Math.pow( t, 4 ) - 13 * t * t;
|
|
|
+ const z = 1 / 10 * t * ( t * t - 4 ) * ( t * t - 9 ) * ( t * t - 12 );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // DecoratedTorusKnot4a
|
|
|
+ }
|
|
|
|
|
|
+ } // DecoratedTorusKnot4a
|
|
|
|
|
|
- function DecoratedTorusKnot4a( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 40 : scale;
|
|
|
+ class DecoratedTorusKnot4a extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 40 ) {
|
|
|
|
|
|
- DecoratedTorusKnot4a.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- DecoratedTorusKnot4a.prototype.constructor = DecoratedTorusKnot4a;
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- DecoratedTorusKnot4a.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ }
|
|
|
+
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
+ const point = optionalTarget;
|
|
|
t *= Math.PI * 2;
|
|
|
- var x = Math.cos( 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 );
|
|
|
+ const x = Math.cos( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) );
|
|
|
+ const y = Math.sin( 2 * t ) * ( 1 + 0.6 * ( Math.cos( 5 * t ) + 0.75 * Math.cos( 10 * t ) ) );
|
|
|
+ const z = 0.35 * Math.sin( 5 * t );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // DecoratedTorusKnot4b
|
|
|
+ }
|
|
|
|
|
|
+ } // DecoratedTorusKnot4b
|
|
|
|
|
|
- function DecoratedTorusKnot4b( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 40 : scale;
|
|
|
+ class DecoratedTorusKnot4b extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 40 ) {
|
|
|
+
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- DecoratedTorusKnot4b.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- DecoratedTorusKnot4b.prototype.constructor = DecoratedTorusKnot4b;
|
|
|
+ }
|
|
|
|
|
|
- DecoratedTorusKnot4b.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var fi = t * Math.PI * 2;
|
|
|
- var x = Math.cos( 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 );
|
|
|
+ const point = optionalTarget;
|
|
|
+ const fi = t * Math.PI * 2;
|
|
|
+ const x = Math.cos( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) );
|
|
|
+ const y = Math.sin( 2 * fi ) * ( 1 + 0.45 * Math.cos( 3 * fi ) + 0.4 * Math.cos( 9 * fi ) );
|
|
|
+ const z = 0.2 * Math.sin( 9 * fi );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // DecoratedTorusKnot5a
|
|
|
+ }
|
|
|
|
|
|
+ } // DecoratedTorusKnot5a
|
|
|
|
|
|
- function DecoratedTorusKnot5a( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 40 : scale;
|
|
|
+ class DecoratedTorusKnot5a extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 40 ) {
|
|
|
+
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- DecoratedTorusKnot5a.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- DecoratedTorusKnot5a.prototype.constructor = DecoratedTorusKnot5a;
|
|
|
+ }
|
|
|
|
|
|
- DecoratedTorusKnot5a.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var fi = t * Math.PI * 2;
|
|
|
- var x = Math.cos( 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 );
|
|
|
+ const point = optionalTarget;
|
|
|
+ const fi = t * Math.PI * 2;
|
|
|
+ const x = Math.cos( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) );
|
|
|
+ const y = Math.sin( 3 * fi ) * ( 1 + 0.3 * Math.cos( 5 * fi ) + 0.5 * Math.cos( 10 * fi ) );
|
|
|
+ const z = 0.2 * Math.sin( 20 * fi );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- }; // DecoratedTorusKnot5c
|
|
|
+ }
|
|
|
|
|
|
+ } // DecoratedTorusKnot5c
|
|
|
|
|
|
- function DecoratedTorusKnot5c( scale ) {
|
|
|
|
|
|
- THREE.Curve.call( this );
|
|
|
- this.scale = scale === undefined ? 40 : scale;
|
|
|
+ class DecoratedTorusKnot5c extends THREE.Curve {
|
|
|
|
|
|
- }
|
|
|
+ constructor( scale = 40 ) {
|
|
|
+
|
|
|
+ super();
|
|
|
+ this.scale = scale;
|
|
|
|
|
|
- DecoratedTorusKnot5c.prototype = Object.create( THREE.Curve.prototype );
|
|
|
- DecoratedTorusKnot5c.prototype.constructor = DecoratedTorusKnot5c;
|
|
|
+ }
|
|
|
|
|
|
- DecoratedTorusKnot5c.prototype.getPoint = function ( t, optionalTarget ) {
|
|
|
+ getPoint( t, optionalTarget = new THREE.Vector3() ) {
|
|
|
|
|
|
- var point = optionalTarget || new THREE.Vector3();
|
|
|
- var fi = t * Math.PI * 2;
|
|
|
- var x = Math.cos( 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 );
|
|
|
+ const point = optionalTarget;
|
|
|
+ const fi = t * Math.PI * 2;
|
|
|
+ const x = Math.cos( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) );
|
|
|
+ const y = Math.sin( 4 * fi ) * ( 1 + 0.5 * ( Math.cos( 5 * fi ) + 0.4 * Math.cos( 20 * fi ) ) );
|
|
|
+ const z = 0.35 * Math.sin( 15 * fi );
|
|
|
return point.set( x, y, z ).multiplyScalar( this.scale );
|
|
|
|
|
|
- };
|
|
|
-
|
|
|
- return {
|
|
|
- GrannyKnot: GrannyKnot,
|
|
|
- HeartCurve: HeartCurve,
|
|
|
- VivianiCurve: VivianiCurve,
|
|
|
- KnotCurve: KnotCurve,
|
|
|
- HelixCurve: HelixCurve,
|
|
|
- TrefoilKnot: TrefoilKnot,
|
|
|
- TorusKnot: TorusKnot,
|
|
|
- CinquefoilKnot: CinquefoilKnot,
|
|
|
- TrefoilPolynomialKnot: TrefoilPolynomialKnot,
|
|
|
- FigureEightPolynomialKnot: FigureEightPolynomialKnot,
|
|
|
- DecoratedTorusKnot4a: DecoratedTorusKnot4a,
|
|
|
- DecoratedTorusKnot4b: DecoratedTorusKnot4b,
|
|
|
- DecoratedTorusKnot5a: DecoratedTorusKnot5a,
|
|
|
- DecoratedTorusKnot5c: DecoratedTorusKnot5c
|
|
|
- };
|
|
|
-
|
|
|
- }();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const Curves = {
|
|
|
+ GrannyKnot: GrannyKnot,
|
|
|
+ HeartCurve: HeartCurve,
|
|
|
+ VivianiCurve: VivianiCurve,
|
|
|
+ KnotCurve: KnotCurve,
|
|
|
+ HelixCurve: HelixCurve,
|
|
|
+ TrefoilKnot: TrefoilKnot,
|
|
|
+ TorusKnot: TorusKnot,
|
|
|
+ CinquefoilKnot: CinquefoilKnot,
|
|
|
+ TrefoilPolynomialKnot: TrefoilPolynomialKnot,
|
|
|
+ FigureEightPolynomialKnot: FigureEightPolynomialKnot,
|
|
|
+ DecoratedTorusKnot4a: DecoratedTorusKnot4a,
|
|
|
+ DecoratedTorusKnot4b: DecoratedTorusKnot4b,
|
|
|
+ DecoratedTorusKnot5a: DecoratedTorusKnot5a,
|
|
|
+ DecoratedTorusKnot5c: DecoratedTorusKnot5c
|
|
|
+ };
|
|
|
|
|
|
THREE.Curves = Curves;
|
|
|
|