Browse Source

SVGLoader: Remove paths with a length less than 2 points. (#21752)

* SVGLOADER remove paths with a length less than 2 points.

* added extra test
Tom Valkeneers 4 years ago
parent
commit
06333e4823

+ 1 - 1
examples/js/loaders/SVGLoader.js

@@ -1873,7 +1873,7 @@
 				};
 
 			} );
-			simplePaths = simplePaths.filter( sp => sp.points.length > 0 ); // check if path is solid or a hole
+			simplePaths = simplePaths.filter( sp => sp.points.length > 1 ); // check if path is solid or a hole
 
 			const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule ) );
 			const shapesToReturn = [];

+ 1 - 1
examples/jsm/loaders/SVGLoader.js

@@ -2047,7 +2047,7 @@ class SVGLoader extends Loader {
 
 		} );
 
-		simplePaths = simplePaths.filter( sp => sp.points.length > 0 );
+		simplePaths = simplePaths.filter( sp => sp.points.length > 1 );
 
 		// check if path is solid or a hole
 		const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData.style.fillRule ) );

File diff suppressed because it is too large
+ 0 - 0
examples/models/svg/energy.svg


+ 1 - 0
examples/webgl_loader_svg.html

@@ -92,6 +92,7 @@
 					"Three.js": 'models/svg/threejs.svg',
 					"Joins and caps": 'models/svg/lineJoinsAndCaps.svg',
 					"Hexagon": 'models/svg/hexagon.svg',
+					"Energy": 'models/svg/energy.svg',
 					"Test 1": 'models/svg/tests/1.svg',
 					"Test 2": 'models/svg/tests/2.svg',
 					"Test 3": 'models/svg/tests/3.svg',

Some files were not shown because too many files changed in this diff