浏览代码

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

alteredq 13 年之前
父节点
当前提交
d4df952181

+ 7 - 0
doc/api/extras/core/Curve.rst

@@ -0,0 +1,7 @@
+Curve - Extensible curve object
+------------------------
+
+.. js:class:: Curve()
+
+    Extensible curve object
+    

+ 7 - 0
doc/api/extras/core/CurvePath.rst

@@ -0,0 +1,7 @@
+CurvePath - Path with connected curves
+------------------------
+
+.. js:class:: CurvePath()
+
+    A Path made with connected set of curves
+    

+ 7 - 0
doc/api/extras/core/Path.rst

@@ -0,0 +1,7 @@
+Path - A CurvePath with a Drawing API
+------------------------
+
+.. js:class:: Path()
+
+    A CurvePath with convenience Drawing methods 
+    

+ 7 - 0
doc/api/extras/core/Shape.rst

@@ -0,0 +1,7 @@
+Shape - A closed 2d path with holes
+------------------------
+
+.. js:class:: Shape()
+
+    A closed 2d Path with holes
+    

+ 7 - 0
doc/api/extras/core/TextPath.rst

@@ -0,0 +1,7 @@
+TextPath - Class for turning Text to Shapes
+------------------------
+
+.. js:class:: TextPath()
+
+    Class for turning Text to Shapes
+    

+ 9 - 0
doc/api/extras/core/index.rst

@@ -0,0 +1,9 @@
+Core Classes
+============
+
+.. toctree::
+    Curve
+    CurvePath
+    Path
+    Shape
+    TextPath

+ 15 - 5
src/extras/core/CurvePath.js

@@ -12,7 +12,8 @@ THREE.CurvePath = function () {
 
 	this.curves = [];
 	this.bends = [];
-
+	
+	this.autoClose = false; // Automatically closes the path
 };
 
 THREE.CurvePath.prototype = new THREE.Curve();
@@ -25,13 +26,22 @@ THREE.CurvePath.prototype.add = function ( curve ) {
 };
 
 THREE.CurvePath.prototype.checkConnection = function() {
-
+	// TODO
+	// If the ending of curve is not connected to the starting
+	// or the next curve, then, this is not a real path
 };
 
-// Add a line curve  if start and end of lines are not connected
-
 THREE.CurvePath.prototype.closePath = function() {
-
+	// TODO Test
+	// and verify for vector3 (needs to implement equals)
+	// Add a line curve if start and end of lines are not connected
+	var startPoint = this.curves[0].getPoint(0);
+	var endPoint = this.curves[this.curves.length-1].getPoint(1);
+	
+	if (!startPoint.equals(endPoint)) {
+		this.curves.push( new THREE.LineCurve(endPoint, startPoint) );
+	}
+	
 };
 
 // To get accurate point with reference to