瀏覽代碼

CurvePath: Remove factory methods

Mugen87 7 年之前
父節點
當前提交
9a889e195e

+ 0 - 23
docs/api/extras/core/CurvePath.html

@@ -49,29 +49,6 @@
 		<h3>[method:null closePath]()</h3>
 		<div>Adds a [page:LineCurve lineCurve] to close the path.</div>
 
-		<h3>[method:Geometry createGeometry]( [page:Vector3 points] )</h3>
-		<div>
-		points -- An array of [page:Vector3 Vector3s]<br /><br />
-
-		Creates a geometry from points
-		</div>
-
-		<h3>[method:Geometry createPointsGeometry]( [page:Integer divisions] )</h3>
-		<div>
-		divisions -- How many segments to create. Defaults to *12*.<br /><br />
-
-		Creates a [page:Geometry] object comprised of [page:Vector3 Vector3s], for example
-		to be used with [page:Line] or [page:Points]. Uses [page:Curve.getPoints]() for the division.
-		</div>
-
-		<h3>[method:Geometry createSpacedPointsGeometry]( [page:Integer divisions] )</h3>
-		<div>
-		divisions -- How many segments to create. Defaults to *12*.<br /><br />
-
-		Creates a [page:Geometry] object comprised of [page:Vector3]s that are equidistant, for example
-		to be used with [page:Line] or [page:Points].	Uses [page:Curve.getSpacedPoints]() for the division.
-		</div>
-
 		<h3>[method:Float getCurveLengths]()</h3>
 		<div>Adds together the lengths of the curves in the [page:.curves] array.</div>
 

+ 9 - 2
examples/canvas_geometry_shapes.html

@@ -82,8 +82,15 @@
 
 					// line
 
-					var geometry = shape.createPointsGeometry();
-					geometry.vertices.push( geometry.vertices[ 0 ].clone() );
+					var geometry = new THREE.Geometry();
+					var points = shape.getPoints();
+
+					for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+						var point = points[ i ];
+						geometry.vertices.push( new THREE.Vector3( point.x, point.y, 0 ) );
+
+					}
 
 					var material = new THREE.LineBasicMaterial( { linewidth: 10, color: 0x333333, transparent: true } );
 

+ 35 - 6
examples/webgl_geometry_shapes.html

@@ -111,15 +111,44 @@
 
 				function addLineShape( shape, color, x, y, z, rx, ry, rz, s ) {
 
+					var geometryPoints = new THREE.BufferGeometry();
+					var geometrySpacedPoints = new THREE.BufferGeometry();
+
 					// lines
 
 					shape.autoClose = true;
-					var points = shape.createPointsGeometry();
-					var spacedPoints = shape.createSpacedPointsGeometry( 50 );
+					var points = shape.getPoints();
+					var spacedPoints = shape.getSpacedPoints( 50 );
+
+					// points
+
+					var position = [];
+
+					for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+						var point = points[ i ];
+						position.push( point.x, point.y, 0 );
+
+					}
+
+					geometryPoints.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );
+
+					// spaced points
+
+					position = [];
+
+					for ( var i = 0, l = spacedPoints.length; i < l; i ++ ) {
+
+						var point = spacedPoints[ i ];
+						position.push( point.x, point.y, 0 );
+
+					}
+
+					geometrySpacedPoints.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );
 
 					// solid line
 
-					var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
+					var line = new THREE.Line( geometryPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
 					line.position.set( x, y, z - 25 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
@@ -127,7 +156,7 @@
 
 					// line from equidistance sampled points
 
-					var line = new THREE.Line( spacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
+					var line = new THREE.Line( geometrySpacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) );
 					line.position.set( x, y, z + 25 );
 					line.rotation.set( rx, ry, rz );
 					line.scale.set( s, s, s );
@@ -135,7 +164,7 @@
 
 					// vertices from real points
 
-					var particles = new THREE.Points( points, new THREE.PointsMaterial( { color: color, size: 4 } ) );
+					var particles = new THREE.Points( geometryPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
 					particles.position.set( x, y, z + 75 );
 					particles.rotation.set( rx, ry, rz );
 					particles.scale.set( s, s, s );
@@ -143,7 +172,7 @@
 
 					// equidistance sampled points
 
-					var particles = new THREE.Points( spacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
+					var particles = new THREE.Points( geometrySpacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) );
 					particles.position.set( x, y, z + 125 );
 					particles.rotation.set( rx, ry, rz );
 					particles.scale.set( s, s, s );

+ 13 - 3
examples/webgl_geometry_text_shapes.html

@@ -115,12 +115,22 @@
 					for ( var i = 0; i < shapes.length; i ++ ) {
 
 						var shape = shapes[ i ];
+						var points = shape.getPoints();
 
-						var lineGeometry = shape.createPointsGeometry();
+						var geometry = new THREE.BufferGeometry();
+						var position = [];
 
-						lineGeometry.translate( xMid, 0, 0 );
+						for ( var j = 0; j < points.length; j ++ ) {
 
-						var lineMesh = new THREE.Line( lineGeometry, matDark );
+							var point = points[ j ];
+							position.push( point.x, point.y, 0 );
+
+						}
+
+						geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( position, 3 ) );
+						geometry.translate( xMid, 0, 0 );
+
+						var lineMesh = new THREE.Line( geometry, matDark );
 						lineText.add( lineMesh );
 
 					}

+ 46 - 0
src/Three.Legacy.js

@@ -24,6 +24,7 @@ import { Geometry } from './core/Geometry.js';
 import { Object3D } from './core/Object3D.js';
 import { Uniform } from './core/Uniform.js';
 import { Curve } from './extras/core/Curve.js';
+import { CurvePath } from './extras/core/CurvePath.js';
 import { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js';
 import { AxesHelper } from './helpers/AxesHelper.js';
 import { BoxHelper } from './helpers/BoxHelper.js';
@@ -242,6 +243,51 @@ Curve.create = function ( construct, getPoint ) {
 
 //
 
+Object.assign( CurvePath.prototype, {
+
+	createPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createPointsGeometry() has been removed.' );
+
+		// generate geometry from path points (for Line or Points objects)
+
+		var pts = this.getPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createSpacedPointsGeometry: function ( divisions ) {
+
+		console.warn( 'THREE.CurvePath: .createSpacedPointsGeometry() has been removed.' );
+
+		// generate geometry from equidistant sampling along the path
+
+		var pts = this.getSpacedPoints( divisions );
+		return this.createGeometry( pts );
+
+	},
+
+	createGeometry: function ( points ) {
+
+		console.warn( 'THREE.CurvePath: .createGeometry() has been removed.' );
+
+		var geometry = new Geometry();
+
+		for ( var i = 0, l = points.length; i < l; i ++ ) {
+
+			var point = points[ i ];
+			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
+
+		}
+
+		return geometry;
+
+	}
+
+} );
+
+//
+
 export function ClosedSplineCurve3( points ) {
 
 	console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );

+ 0 - 39
src/extras/core/CurvePath.js

@@ -1,6 +1,4 @@
 import { Curve } from './Curve.js';
-import { Vector3 } from '../../math/Vector3.js';
-import { Geometry } from '../../core/Geometry.js';
 import { LineCurve } from '../curves/LineCurve.js';
 
 /**
@@ -198,43 +196,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		return points;
 
-	},
-
-	/**************************************************************
-	 *	Create Geometries Helpers
-	 **************************************************************/
-
-	/// Generate geometry from path points (for Line or Points objects)
-
-	createPointsGeometry: function ( divisions ) {
-
-		var pts = this.getPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	// Generate geometry from equidistant sampling along the path
-
-	createSpacedPointsGeometry: function ( divisions ) {
-
-		var pts = this.getSpacedPoints( divisions );
-		return this.createGeometry( pts );
-
-	},
-
-	createGeometry: function ( points ) {
-
-		var geometry = new Geometry();
-
-		for ( var i = 0, l = points.length; i < l; i ++ ) {
-
-			var point = points[ i ];
-			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
-
-		}
-
-		return geometry;
-
 	}
 
 } );