Browse Source

SVGLoader: Fixed Zz case crash.

Mr.doob 7 years ago
parent
commit
64346d5663
1 changed files with 17 additions and 15 deletions
  1. 17 15
      examples/js/loaders/SVGLoader.js

+ 17 - 15
examples/js/loaders/SVGLoader.js

@@ -373,22 +373,24 @@ THREE.SVGLoader.prototype = {
 					case 'Z':
 					case 'z':
 						path.currentPath.autoClose = true;
-						// Reset point to beginning of Path
-						var curve = path.currentPath.curves[ 0 ];
-						if ( curve.isLineCurve ) {
-							point.x = curve.v1.x;
-							point.y = curve.v1.y;
-						} else if ( curve.isEllipseCurve || curve.isArcCurve ) {
-							point.x = curve.aX;
-							point.y = curve.aY;
-						} else if ( curve.isCubicBezierCurve || curve.isQuadraticBezierCurve ) {
-							point.x = curve.v0.x;
-							point.y = curve.v0.y;
-						} else if ( curve.isSplineCurve ) {
-							point.x = curve.points[ 0 ].x;
-							point.y = curve.points[ 0 ].y;
+						if ( path.currentPath.curves.length > 0 ) {
+							// Reset point to beginning of Path
+							var curve = path.currentPath.curves[ 0 ];
+							if ( curve.isLineCurve ) {
+								point.x = curve.v1.x;
+								point.y = curve.v1.y;
+							} else if ( curve.isEllipseCurve || curve.isArcCurve ) {
+								point.x = curve.aX;
+								point.y = curve.aY;
+							} else if ( curve.isCubicBezierCurve || curve.isQuadraticBezierCurve ) {
+								point.x = curve.v0.x;
+								point.y = curve.v0.y;
+							} else if ( curve.isSplineCurve ) {
+								point.x = curve.points[ 0 ].x;
+								point.y = curve.points[ 0 ].y;
+							}
+							path.currentPath.currentPoint.copy( point );
 						}
-						path.currentPath.currentPoint.copy( point );
 						break;
 
 					default: