Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api/extras/core/Curve.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ <h3>[method:Object computeFrenetFrames]( [page:Integer segments], [page:Boolean
Generates the Frenet Frames. Used in geometries like [page:TubeGeometry] or [page:ExtrudeGeometry].
</div>

<h3>[method:Curve clone]()</h3>
<div>Creates a clone of this curve.</div>

<h3>[method:Curve copy]( [page:Curve source] )</h3>
<div>Copies another curve to this instance.</div>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
Expand Down
19 changes: 11 additions & 8 deletions docs/api/extras/curves/CatmullRomCurve3.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ <h3>[example:webgl_geometry_extrude_splines geometry / extrude / splines]</h3>

<h2>Constructor</h2>

<h3>[name]( [page:Array points] )</h3>
<div>points – An array of [page:Vector3] points</div>


<h3>[name]( [page:Array points], [page:Boolean closed], [page:String curveType], [page:Float tension] )</h3>
<div>
points – An array of [page:Vector3] points<br/>
closed – Whether the curve is closed. Default is *false*.<br/>
curveType – Type of the curve. Default is *centripetal*.<br/>
tension – Tension of the curve. Default is *0.5*.
</div>


<h2>Properties</h2>
Expand All @@ -58,16 +61,16 @@ <h3>[property:Boolean isCatmullRomCurve3]</h3>
</div>

<h3>[property:Array points]</h3>
<div>The array of array of [page:Vector3] points that define the curve.</div>
<div>The array of [page:Vector3] points that define the curve. It needs at least two entries.</div>

<h3>[property:Boolean closed]</h3>
<div>The curve will loop back onto itself when this is true. False by default</div>
<div>The curve will loop back onto itself when this is true.</div>

<h3>[property:String curveType]</h3>
<div>Possible values are `centripetal` (default), `chordal` and `catmullrom`.</div>
<div>Possible values are *centripetal*, *chordal* and *catmullrom*.</div>

<h3>[property:float tension]</h3>
<div>When [page:.type] is `catmullrom`, defines catmullrom's tension. Defaults is *0.5*.</div>
<div>When [page:.type] is *catmullrom*, defines catmullrom's tension.</div>


<h2>Methods</h2>
Expand Down
14 changes: 7 additions & 7 deletions docs/api/extras/curves/EllipseCurve.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ <h2>Constructor</h2>

<h3>[name]( [page:Float aX], [page:Float aY], [page:Float xRadius], [page:Float yRadius], [page:Radians aStartAngle], [page:Radians aEndAngle], [page:Boolean aClockwise], [page:Radians aRotation] )</h3>
<div>
[page:Float aX] – The X center of the ellipse.<br/>
[page:Float aY] – The Y center of the ellipse.<br/>
[page:Float xRadius] – The radius of the ellipse in the x direction.<br/>
[page:Float yRadius] – The radius of the ellipse in the y direction.<br/>
[page:Radians aStartAngle] – The start angle of the curve in radians starting from the middle right side.<br/>
[page:Radians aEndAngle] – The end angle of the curve in radians starting from the middle right side.<br/>
[page:Boolean aClockwise] – Whether the ellipse is drawn clockwise.<br/>
[page:Float aX] – The X center of the ellipse. Default is *0*.<br/>
[page:Float aY] – The Y center of the ellipse. Default is *0*.<br/>
[page:Float xRadius] – The radius of the ellipse in the x direction. Default is *1*.<br/>
[page:Float yRadius] – The radius of the ellipse in the y direction. Default is *1*.<br/>
[page:Radians aStartAngle] – The start angle of the curve in radians starting from the middle right side. Default is *0*.<br/>
[page:Radians aEndAngle] – The end angle of the curve in radians starting from the middle right side. Default is *2 x Math.PI*.<br/>
[page:Boolean aClockwise] – Whether the ellipse is drawn clockwise. Default is *false*.<br/>
[page:Radians aRotation] – The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional). Default is *0*.<br/><br/>

<em>Note:</em> When going clockwise it's best to set the start angle to (Math.PI * 2) and then work towards lower numbers.
Expand Down
14 changes: 14 additions & 0 deletions src/extras/core/Curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ Object.assign( Curve.prototype, {
binormals: binormals
};

},

clone: function () {

return new this.constructor().copy( this );

},

copy: function ( source ) {

this.arcLengthDivisions = source.arcLengthDivisions;

return this;

}

} );
Expand Down
38 changes: 29 additions & 9 deletions src/extras/curves/CatmullRomCurve3.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,16 @@ function CubicPoly() {
var tmp = new Vector3();
var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();

function CatmullRomCurve3( points ) {
function CatmullRomCurve3( points, closed, curveType, tension ) {

Curve.call( this );

this.type = 'CatmullRomCurve3';

if ( points.length < 2 ) console.warn( 'THREE.CatmullRomCurve3: Points array needs at least two entries.' );

this.points = points || [];
this.closed = false;
this.curveType = 'centripetal';
this.closed = closed || false;
this.curveType = curveType || 'centripetal';
this.tension = tension || 0.5;

}

Expand Down Expand Up @@ -172,10 +171,9 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {

} else if ( this.curveType === 'catmullrom' ) {

var tension = this.tension !== undefined ? this.tension : 0.5;
px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, tension );
py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, tension );
pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, tension );
px.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension );
py.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension );
pz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension );

}

Expand All @@ -189,5 +187,27 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {

};

CatmullRomCurve3.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.points = [];

for ( var i = 0, l = source.points.length; i < l; i ++ ) {

var point = source.points[ i ];

this.points.push( point.clone() );

}

this.closed = source.closed;
this.curveType = source.curveType;
this.tension = source.tension;

return this;

};


export { CatmullRomCurve3 };
21 changes: 17 additions & 4 deletions src/extras/curves/CubicBezierCurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function CubicBezierCurve( v0, v1, v2, v3 ) {

this.type = 'CubicBezierCurve';

this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v0 = v0 || new Vector2();
this.v1 = v1 || new Vector2();
this.v2 = v2 || new Vector2();
this.v3 = v3 || new Vector2();

}

Expand All @@ -36,5 +36,18 @@ CubicBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {

};

CubicBezierCurve.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v0.copy( source.v0 );
this.v1.copy( source.v1 );
this.v2.copy( source.v2 );
this.v3.copy( source.v3 );

return this;

};


export { CubicBezierCurve };
21 changes: 17 additions & 4 deletions src/extras/curves/CubicBezierCurve3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function CubicBezierCurve3( v0, v1, v2, v3 ) {

this.type = 'CubicBezierCurve3';

this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.v0 = v0 || new Vector3();
this.v1 = v1 || new Vector3();
this.v2 = v2 || new Vector3();
this.v3 = v3 || new Vector3();

}

Expand All @@ -37,5 +37,18 @@ CubicBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {

};

CubicBezierCurve3.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v0.copy( source.v0 );
this.v1.copy( source.v1 );
this.v2.copy( source.v2 );
this.v3.copy( source.v3 );

return this;

};


export { CubicBezierCurve3 };
35 changes: 28 additions & 7 deletions src/extras/curves/EllipseCurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ function EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockw

this.type = 'EllipseCurve';

this.aX = aX;
this.aY = aY;
this.aX = aX || 0;
this.aY = aY || 0;

this.xRadius = xRadius;
this.yRadius = yRadius;
this.xRadius = xRadius || 1;
this.yRadius = yRadius || 1;

this.aStartAngle = aStartAngle;
this.aEndAngle = aEndAngle;
this.aStartAngle = aStartAngle || 0;
this.aEndAngle = aEndAngle || 2 * Math.PI;

this.aClockwise = aClockwise;
this.aClockwise = aClockwise || false;

this.aRotation = aRotation || 0;

Expand Down Expand Up @@ -90,5 +90,26 @@ EllipseCurve.prototype.getPoint = function ( t, optionalTarget ) {

};

EllipseCurve.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.aX = source.aX;
this.aY = source.aY;

this.xRadius = source.xRadius;
this.yRadius = source.yRadius;

this.aStartAngle = source.aStartAngle;
this.aEndAngle = source.aEndAngle;

this.aClockwise = source.aClockwise;

this.aRotation = source.aRotation;

return this;

};


export { EllipseCurve };
15 changes: 13 additions & 2 deletions src/extras/curves/LineCurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function LineCurve( v1, v2 ) {

this.type = 'LineCurve';

this.v1 = v1;
this.v2 = v2;
this.v1 = v1 || new Vector2();
this.v2 = v2 || new Vector2();

}

Expand Down Expand Up @@ -53,5 +53,16 @@ LineCurve.prototype.getTangent = function ( /* t */ ) {

};

LineCurve.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v1.copy( source.v1 );
this.v2.copy( source.v2 );

return this;

};


export { LineCurve };
15 changes: 13 additions & 2 deletions src/extras/curves/LineCurve3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function LineCurve3( v1, v2 ) {

this.type = 'LineCurve3';

this.v1 = v1;
this.v2 = v2;
this.v1 = v1 || new Vector3();
this.v2 = v2 || new Vector3();

}

Expand Down Expand Up @@ -45,5 +45,16 @@ LineCurve3.prototype.getPointAt = function ( u, optionalTarget ) {

};

LineCurve3.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v1.copy( source.v1 );
this.v2.copy( source.v2 );

return this;

};


export { LineCurve3 };
18 changes: 15 additions & 3 deletions src/extras/curves/QuadraticBezierCurve.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function QuadraticBezierCurve( v0, v1, v2 ) {

this.type = 'QuadraticBezierCurve';

this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.v0 = v0 || new Vector2();
this.v1 = v1 || new Vector2();
this.v2 = v2 || new Vector2();

}

Expand All @@ -35,5 +35,17 @@ QuadraticBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {

};

QuadraticBezierCurve.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v0.copy( source.v0 );
this.v1.copy( source.v1 );
this.v2.copy( source.v2 );

return this;

};


export { QuadraticBezierCurve };
18 changes: 15 additions & 3 deletions src/extras/curves/QuadraticBezierCurve3.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ function QuadraticBezierCurve3( v0, v1, v2 ) {

this.type = 'QuadraticBezierCurve3';

this.v0 = v0;
this.v1 = v1;
this.v2 = v2;
this.v0 = v0 || new Vector3();
this.v1 = v1 || new Vector3();
this.v2 = v2 || new Vector3();

}

Expand All @@ -36,5 +36,17 @@ QuadraticBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {

};

QuadraticBezierCurve3.prototype.copy = function ( source ) {

Curve.prototype.copy.call( this, source );

this.v0.copy( source.v0 );
this.v1.copy( source.v1 );
this.v2.copy( source.v2 );

return this;

};


export { QuadraticBezierCurve3 };
Loading