Pārlūkot izejas kodu

added line node

Jonathan Brandel 7 gadi atpakaļ
vecāks
revīzija
a38e937cc9
1 mainītis faili ar 20 papildinājumiem un 0 dzēšanām
  1. 20 0
      examples/js/loaders/SVGLoader.js

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

@@ -74,6 +74,10 @@ THREE.SVGLoader.prototype = {
 					paths.push( parseEllipseNode( node ) );
 					break;
 
+				case 'line':
+					paths.push( parseLineNode( node ) );
+					break;
+
 				default:
 					console.log( node );
 
@@ -422,6 +426,22 @@ THREE.SVGLoader.prototype = {
 
 		}
 
+		function parseLineNode( node ) {
+
+			var x1 = parseFloat( node.getAttribute( 'x1' ) );
+			var y1 = parseFloat( node.getAttribute( 'y1' ) );
+			var x2 = parseFloat( node.getAttribute( 'x2' ) );
+			var y2 = parseFloat( node.getAttribute( 'y2' ) );
+
+			var path = new THREE.ShapePath();
+			path.moveTo( x1, y1 );
+			path.lineTo( x2, y2 );
+			path.currentPath.autoClose = false;
+
+			return path;
+
+		}
+
 		// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
 
 		function getReflection( a, b ) {