Răsfoiți Sursa

added circle and ellipse nodes

Jonathan Brandel 7 ani în urmă
părinte
comite
4416d9eea9
1 a modificat fișierele cu 37 adăugiri și 0 ștergeri
  1. 37 0
      examples/js/loaders/SVGLoader.js

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

@@ -66,6 +66,14 @@ THREE.SVGLoader.prototype = {
 					paths.push( parsePolylineNode( node ) );
 					break;
 
+				case 'circle':
+					paths.push( parseCircleNode( node ) );
+					break;
+
+				case 'ellipse':
+					paths.push( parseEllipseNode( node ) );
+					break;
+
 				default:
 					console.log( node );
 
@@ -385,6 +393,35 @@ THREE.SVGLoader.prototype = {
 
 		}
 
+		function parseCircleNode( node ) {
+
+			var x = parseFloat( node.getAttribute( 'cx' ) );
+			var y = parseFloat( node.getAttribute( 'cy' ) );
+			var r = parseFloat( node.getAttribute( 'r' ) );
+
+			var path = new THREE.ShapePath();
+
+			path.currentPath.absarc( x, y, r, 0, Math.PI * 2 );
+
+			return path;
+
+		}
+
+		function parseEllipseNode( node ) {
+
+			var x = parseFloat( node.getAttribute( 'cx' ) );
+			var y = parseFloat( node.getAttribute( 'cy' ) );
+			var rx parseFloat( node.getAttribute( 'rx' ) );
+			var ry = parseFloat( node.getAttribute( 'ry' ) );
+
+			var path = new THREE.ShapePath();
+
+			path.currentPath.absellipse( x, y, rx, ry, 0, Math.PI * 2 );
+
+			return path;
+
+		}
+
 		// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
 
 		function getReflection( a, b ) {