Browse Source

move changes into js directory rather than jsm

Greg Zanchelli 4 years ago
parent
commit
66b7db927b
1 changed files with 12 additions and 0 deletions
  1. 12 0
      examples/js/loaders/SVGLoader.js

+ 12 - 0
examples/js/loaders/SVGLoader.js

@@ -386,6 +386,9 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 						var numbers = parseFloats( data );
 						var numbers = parseFloats( data );
 
 
 						for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) {
 						for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) {
+							
+							// skip command if start point == end point
+							if( numbers[ j + 5 ] == point.x && numbers[ j + 6 ] == point.y ) continue;
 
 
 							var start = point.clone();
 							var start = point.clone();
 							point.x = numbers[ j + 5 ];
 							point.x = numbers[ j + 5 ];
@@ -576,6 +579,9 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 
 
 						for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) {
 						for ( var j = 0, jl = numbers.length; j < jl; j += 7 ) {
 
 
+							// skip command if no displacement
+							if( numbers[ j + 5 ] == 0 && numbers[ j + 6 ] == 0 ) continue;
+
 							var start = point.clone();
 							var start = point.clone();
 							point.x += numbers[ j + 5 ];
 							point.x += numbers[ j + 5 ];
 							point.y += numbers[ j + 6 ];
 							point.y += numbers[ j + 6 ];
@@ -660,6 +666,12 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 
 
 		function parseArcCommand( path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end ) {
 		function parseArcCommand( path, rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, start, end ) {
 
 
+			if( rx == 0 || ry == 0 ) {
+				// draw a line if either of the radii == 0
+				path.lineTo( end.x, end.y );
+				return;
+			}
+
 			x_axis_rotation = x_axis_rotation * Math.PI / 180;
 			x_axis_rotation = x_axis_rotation * Math.PI / 180;
 
 
 			// Ensure radii are positive
 			// Ensure radii are positive