Sfoglia il codice sorgente

Merge pull request #15922 from BTEVC/dev

SVGLoader: Added fill-opacity style support.
Mr.doob 6 anni fa
parent
commit
00337d96b2
2 ha cambiato i file con 11 aggiunte e 2 eliminazioni
  1. 8 1
      examples/js/loaders/SVGLoader.js
  2. 3 1
      examples/webgl_loader_svg.html

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

@@ -99,6 +99,7 @@ THREE.SVGLoader.prototype = {
 				transformPath( path, currentTransform );
 
 				paths.push( path );
+				path.userData = { node: node, style: style };
 
 			}
 
@@ -694,6 +695,9 @@ THREE.SVGLoader.prototype = {
 			if ( node.hasAttribute( 'fill' ) ) style.fill = node.getAttribute( 'fill' );
 			if ( node.style.fill !== '' ) style.fill = node.style.fill;
 
+			if ( node.hasAttribute( 'fill-opacity' ) ) style.fillOpacity = node.getAttribute( 'fill-opacity' );
+			if ( node.style.fillOpacity !== '' ) style.fillOpacity = node.style.fillOpacity;
+
 			return style;
 
 		}
@@ -1012,13 +1016,16 @@ THREE.SVGLoader.prototype = {
 		console.time( 'THREE.SVGLoader: Parse' );
 
 		parseNode( xml.documentElement, { fill: '#000' } );
+		
+		var data = { paths: paths, xml: xml.documentElement };
 
 		// console.log( paths );
 
 
 		console.timeEnd( 'THREE.SVGLoader: Parse' );
 
-		return paths;
+
+		return data;
 
 	}
 

+ 3 - 1
examples/webgl_loader_svg.html

@@ -149,7 +149,9 @@
 				//
 
 				var loader = new THREE.SVGLoader();
-				loader.load( url, function ( paths ) {
+				loader.load( url, function ( data ) {
+
+					var paths = data.paths;
 
 					var group = new THREE.Group();
 					group.scale.multiplyScalar( 0.25 );