Browse Source

Deprecated THREE.Spline

Mugen87 8 years ago
parent
commit
17f44a84d0

+ 3 - 0
docs/api/deprecated/DeprecatedList.html

@@ -385,6 +385,9 @@
 		<h3>[page:Vertex]</h3>
 		<h3>[page:Vertex]</h3>
 		<div>Vertex has been removed. Use [page:Vector3] instead.</div>
 		<div>Vertex has been removed. Use [page:Vector3] instead.</div>
 
 
+		<h3>[page:Spline]</h3>
+		<div>Spline has been removed. Use [page:CatmullRomCurve3] instead.</div>
+
 
 
 
 
 
 

+ 0 - 101
docs/api/math/Spline.html

@@ -1,101 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="utf-8" />
-		<base href="../../" />
-		<script src="list.js"></script>
-		<script src="page.js"></script>
-		<link type="text/css" rel="stylesheet" href="page.css" />
-	</head>
-	<body>
-		<h1>[name]</h1>
-
-		<div class="desc">
-			Class representing a [link:https://en.wikipedia.org/wiki/Spline_(mathematics) spline].<br /><br />
-		</div>
-
-		<h2>Examples</h2>
-		<div>
-			[example:webgl_lines_splines WebGL / lines / splines]<br />
-			[example:webgl_lines_dashed WebGL / lines / dashed]<br />
-			[example:software_sandbox Software / sandbox]<br />
-			[example:canvas_lines_dashed Canvas / lines / dashed]
-		</div>
-
-
-		<h2>Constructor</h2>
-
-		<h3>[name]( [page:Array points] )</h3>
-
-		<div>
-			Initialises the spline with [page:Array points], which are the [page:Vector3 Vector3s]
-			 through which the spline will pass.
-		 </div>
-
-
-		<h2>Properties</h2>
-
-		<h3>[property:Array points]</h3>
-
-
-		<h2>Methods</h2>
-
-		<h3>[method:Array getControlPointsArray]( )</h3>
-		<div>
-			Returns an array with triplets of [ x, y, z ] coordinates that correspond to the
-			current control points.
-		</div>
-
-		<h3>[method:Vector3 getPoint]( [page:Integer k] )</h3>
-		<div>
-			[page:Integer k] — point index<br /><br />
-
-			Return the interpolated point at [page:Integer k].
-		</div>
-
-		<h3>[method:Object getLength]( [page:Integer nSubDivisions] )</h3>
-		<div>
-			[page:Integer nSubDivisions] — number of subdivisions between control points. Default is *100*.<br /><br />
-
-
-			Returns an object with the two properties. The property <strong>[page:Number total]</strong> contains
-			the length of the spline when using [page:Integer nSubDivisions]. The property [page:Array chunkLength]
-			contains an array with the total length from the beginning of the spline to the end of that chunk.
-		</div>
-
-		<h3>[method:null initFromArray]( [page:Array a] )</h3>
-		<div>
-			[page:Array a] — array of the form
-			<code>
-				var a = [ [x1, y1, z1], [x2, y2, z2], ...  ];
-			</code>
-			from which to initialise the points array.<br /><br />
-
-			Initialises using the data in the array as a series of points. Each value in *a* must
-				be another array with three values, where a[n] is v, the value for the *nth* point,
-				and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively.
-		</div>
-
-		<h3>[method:Vector3 interpolate]( p0, p1, p2, p3, t, t2, t3 )</h3>
-		<div>
-
-		</div>
-
-		<h3>[method:null reparametrizeByArcLength]( [page:Float samplingCoef] )</h3>
-		<div>
-			[page:Float samplingCoef] — how many intermediate values to use between spline points<br /><br />
-
-			Modifies the spline so that it looks similar to the original but has its points distributed
-			in such way that moving along the spline it's done at a more or less constant speed.
-			The points should also appear more uniformly spread along the curve.
-			This is done by resampling the original spline, with the density of sampling controlled by [page:Float samplingCoef].
-			Here it's interesting to note that denser sampling is not necessarily better:
-			if sampling is too high, you may get weird kinks in curvature.
-		</div>
-
-
-		<h2>Source</h2>
-
-		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
-	</body>
-</html>

+ 0 - 1
docs/list.js

@@ -252,7 +252,6 @@ var list = {
 			[ "Ray", "api/math/Ray" ],
 			[ "Ray", "api/math/Ray" ],
 			[ "Sphere", "api/math/Sphere" ],
 			[ "Sphere", "api/math/Sphere" ],
 			[ "Spherical", "api/math/Spherical" ],
 			[ "Spherical", "api/math/Spherical" ],
-			[ "Spline", "api/math/Spline" ],
 			[ "Triangle", "api/math/Triangle" ],
 			[ "Triangle", "api/math/Triangle" ],
 			[ "Vector2", "api/math/Vector2" ],
 			[ "Vector2", "api/math/Vector2" ],
 			[ "Vector3", "api/math/Vector3" ],
 			[ "Vector3", "api/math/Vector3" ],

+ 0 - 28
editor/js/libs/tern-threejs/threejs.js

@@ -4215,34 +4215,6 @@
       "!doc": "A geometric sphere defined by a center position and radius.",
       "!doc": "A geometric sphere defined by a center position and radius.",
       "!type": "fn(center: +THREE.Vector3, radius: number)"
       "!type": "fn(center: +THREE.Vector3, radius: number)"
     },
     },
-    "Spline": {
-      "!url": "http://threejs.org/docs/#Reference/math/Spline",
-      "prototype": {
-        "points": "[]",
-        "initFromArray": {
-          "!type": "fn(a: [])",
-          "!doc": "Initialises using the data in the array as a series of points. Each value in *a* must be another array with three values, where a[n] is v, the value for the *nth* point, and v[0], v[1] and v[2] are the x, y and z coordinates of that point n, respectively."
-        },
-        "getPoint": {
-          "!type": "fn(k: number) -> +THREE.Vector3",
-          "!doc": "Return the interpolated point at *k*."
-        },
-        "getControlPointsArray": {
-          "!type": "fn() -> []",
-          "!doc": "Returns an array with triplets of x, y, z coordinates that correspond to the current control points."
-        },
-        "getLength": {
-          "!type": "fn(nSubDivisions: number) -> object",
-          "!doc": "Returns an object with the two properties. The property .[page:Number total] contains\n\t\t\tthe length of the spline when using nSubDivisions. The property .[page:Array chunkLength]\n\t\t\tcontains an array with the total length from the beginning of the spline to the end of that chunk."
-        },
-        "reparametrizeByArcLength": {
-          "!type": "fn(samplingCoef: number)",
-          "!doc": "This is done by resampling the original spline, with the density of sampling controlled by *samplingCoef*. Here it's interesting to note that denser sampling is not necessarily better: if sampling is too high, you may get weird kinks in curvature."
-        }
-      },
-      "!doc": "Represents a spline.",
-      "!type": "fn(points: [])"
-    },
     "Triangle": {
     "Triangle": {
       "!url": "http://threejs.org/docs/#Reference/math/Triangle",
       "!url": "http://threejs.org/docs/#Reference/math/Triangle",
       "prototype": {
       "prototype": {

+ 1 - 1
examples/canvas_lines_dashed.html

@@ -71,7 +71,7 @@
 
 
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
 
 
-				var spline = new THREE.Spline( points );
+				var spline = new THREE.CatmullRomCurve3( points );
 				var geometrySpline = new THREE.Geometry();
 				var geometrySpline = new THREE.Geometry();
 
 
 				for ( var i = 0; i < points.length * subdivisions; i ++ ) {
 				for ( var i = 0; i < points.length * subdivisions; i ++ ) {

+ 1 - 1
examples/software_lines_splines.html

@@ -94,7 +94,7 @@
 
 
 				var position, index;
 				var position, index;
 
 
-				var spline = new THREE.Spline( points );
+				var spline = new THREE.CatmullRomCurve3( points );
 
 
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
 
 

+ 1 - 1
examples/software_sandbox.html

@@ -102,7 +102,7 @@
 
 
 				// Line
 				// Line
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 );
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 );
-				var spline = new THREE.Spline( points );
+				var spline = new THREE.CatmullRomCurve3( points );
 				var n_sub = 6, colors = [], line;
 				var n_sub = 6, colors = [], line;
 				var lineGeometry = new THREE.Geometry();
 				var lineGeometry = new THREE.Geometry();
 
 

+ 1 - 1
examples/webgl_lines_dashed.html

@@ -68,7 +68,7 @@
 
 
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
 				var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 25.0, recursion, 0, 1, 2, 3, 4, 5, 6, 7 );
 
 
-				var spline = new THREE.Spline( points );
+				var spline = new THREE.CatmullRomCurve3( points );
 				var geometrySpline = new THREE.Geometry();
 				var geometrySpline = new THREE.Geometry();
 
 
 				for ( var i = 0; i < points.length * subdivisions; i ++ ) {
 				for ( var i = 0; i < points.length * subdivisions; i ++ ) {

+ 1 - 1
examples/webgl_lines_splines.html

@@ -92,7 +92,7 @@
 
 
 				var position, index;
 				var position, index;
 
 
-				var spline = new THREE.Spline( points );
+				var spline = new THREE.CatmullRomCurve3( points );
 
 
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
 
 

+ 33 - 0
src/Three.Legacy.js

@@ -233,6 +233,39 @@ export function SplineCurve3( points ) {
 
 
 SplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );
 SplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );
 
 
+//
+
+export function Spline( points ) {
+
+	console.warn( 'THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.' );
+
+	CatmullRomCurve3.call( this, points );
+	this.type = 'catmullrom';
+
+}
+
+Spline.prototype = Object.create( CatmullRomCurve3.prototype );
+
+Object.assign( Spline.prototype, {
+
+	initFromArray: function ( a ) {
+
+		console.warn( 'THREE.Spline: .initFromArray() has been removed.' );
+
+	},
+	getControlPointsArray: function ( optionalTarget ) {
+
+		console.warn( 'THREE.Spline: .getControlPointsArray() has been removed.' );
+
+	},
+	reparametrizeByArcLength: function ( samplingCoef ) {
+
+		console.warn( 'THREE.Spline: .reparametrizeByArcLength() has been removed.' );
+
+	}
+
+} );
+
 //
 //
 export function BoundingBoxHelper( object, color ) {
 export function BoundingBoxHelper( object, color ) {
 
 

+ 0 - 1
src/Three.js

@@ -100,7 +100,6 @@ export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js'
 export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
 export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
 export { Interpolant } from './math/Interpolant.js';
 export { Interpolant } from './math/Interpolant.js';
 export { Triangle } from './math/Triangle.js';
 export { Triangle } from './math/Triangle.js';
-export { Spline } from './math/Spline.js';
 export { _Math as Math } from './math/Math.js';
 export { _Math as Math } from './math/Math.js';
 export { Spherical } from './math/Spherical.js';
 export { Spherical } from './math/Spherical.js';
 export { Cylindrical } from './math/Cylindrical.js';
 export { Cylindrical } from './math/Cylindrical.js';

+ 0 - 181
src/math/Spline.js

@@ -1,181 +0,0 @@
-import { Vector3 } from './Vector3';
-
-/**
- * Spline from Tween.js, slightly optimized (and trashed)
- * http://sole.github.com/tween.js/examples/05_spline.html
- *
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- */
-
-function Spline( points ) {
-
-	this.points = points;
-
-	var c = [], v3 = { x: 0, y: 0, z: 0 },
-	point, intPoint, weight, w2, w3,
-	pa, pb, pc, pd;
-
-	this.initFromArray = function ( a ) {
-
-		this.points = [];
-
-		for ( var i = 0; i < a.length; i ++ ) {
-
-			this.points[ i ] = { x: a[ i ][ 0 ], y: a[ i ][ 1 ], z: a[ i ][ 2 ] };
-
-		}
-
-	};
-
-	this.getPoint = function ( k ) {
-
-		point = ( this.points.length - 1 ) * k;
-		intPoint = Math.floor( point );
-		weight = point - intPoint;
-
-		c[ 0 ] = intPoint === 0 ? intPoint : intPoint - 1;
-		c[ 1 ] = intPoint;
-		c[ 2 ] = intPoint  > this.points.length - 2 ? this.points.length - 1 : intPoint + 1;
-		c[ 3 ] = intPoint  > this.points.length - 3 ? this.points.length - 1 : intPoint + 2;
-
-		pa = this.points[ c[ 0 ] ];
-		pb = this.points[ c[ 1 ] ];
-		pc = this.points[ c[ 2 ] ];
-		pd = this.points[ c[ 3 ] ];
-
-		w2 = weight * weight;
-		w3 = weight * w2;
-
-		v3.x = interpolate( pa.x, pb.x, pc.x, pd.x, weight, w2, w3 );
-		v3.y = interpolate( pa.y, pb.y, pc.y, pd.y, weight, w2, w3 );
-		v3.z = interpolate( pa.z, pb.z, pc.z, pd.z, weight, w2, w3 );
-
-		return v3;
-
-	};
-
-	this.getControlPointsArray = function () {
-
-		var i, p, l = this.points.length,
-			coords = [];
-
-		for ( i = 0; i < l; i ++ ) {
-
-			p = this.points[ i ];
-			coords[ i ] = [ p.x, p.y, p.z ];
-
-		}
-
-		return coords;
-
-	};
-
-	// approximate length by summing linear segments
-
-	this.getLength = function ( nSubDivisions ) {
-
-		var i, index, nSamples, position,
-			point = 0, intPoint = 0, oldIntPoint = 0,
-			oldPosition = new Vector3(),
-			tmpVec = new Vector3(),
-			chunkLengths = [],
-			totalLength = 0;
-
-		// first point has 0 length
-
-		chunkLengths[ 0 ] = 0;
-
-		if ( ! nSubDivisions ) nSubDivisions = 100;
-
-		nSamples = this.points.length * nSubDivisions;
-
-		oldPosition.copy( this.points[ 0 ] );
-
-		for ( i = 1; i < nSamples; i ++ ) {
-
-			index = i / nSamples;
-
-			position = this.getPoint( index );
-			tmpVec.copy( position );
-
-			totalLength += tmpVec.distanceTo( oldPosition );
-
-			oldPosition.copy( position );
-
-			point = ( this.points.length - 1 ) * index;
-			intPoint = Math.floor( point );
-
-			if ( intPoint !== oldIntPoint ) {
-
-				chunkLengths[ intPoint ] = totalLength;
-				oldIntPoint = intPoint;
-
-			}
-
-		}
-
-		// last point ends with total length
-
-		chunkLengths[ chunkLengths.length ] = totalLength;
-
-		return { chunks: chunkLengths, total: totalLength };
-
-	};
-
-	this.reparametrizeByArcLength = function ( samplingCoef ) {
-
-		var i, j,
-			index, indexCurrent, indexNext,
-			realDistance,
-			sampling, position,
-			newpoints = [],
-			tmpVec = new Vector3(),
-			sl = this.getLength();
-
-		newpoints.push( tmpVec.copy( this.points[ 0 ] ).clone() );
-
-		for ( i = 1; i < this.points.length; i ++ ) {
-
-			//tmpVec.copy( this.points[ i - 1 ] );
-			//linearDistance = tmpVec.distanceTo( this.points[ i ] );
-
-			realDistance = sl.chunks[ i ] - sl.chunks[ i - 1 ];
-
-			sampling = Math.ceil( samplingCoef * realDistance / sl.total );
-
-			indexCurrent = ( i - 1 ) / ( this.points.length - 1 );
-			indexNext = i / ( this.points.length - 1 );
-
-			for ( j = 1; j < sampling - 1; j ++ ) {
-
-				index = indexCurrent + j * ( 1 / sampling ) * ( indexNext - indexCurrent );
-
-				position = this.getPoint( index );
-				newpoints.push( tmpVec.copy( position ).clone() );
-
-			}
-
-			newpoints.push( tmpVec.copy( this.points[ i ] ).clone() );
-
-		}
-
-		this.points = newpoints;
-
-	};
-
-	// Catmull-Rom
-
-	function interpolate( p0, p1, p2, p3, t, t2, t3 ) {
-
-		var v0 = ( p2 - p0 ) * 0.5,
-			v1 = ( p3 - p1 ) * 0.5;
-
-		return ( 2 * ( p1 - p2 ) + v0 + v1 ) * t3 + ( - 3 * ( p1 - p2 ) - 2 * v0 - v1 ) * t2 + v0 * t + p1;
-
-	}
-
-}
-
-
-export { Spline };