Browse Source

SVGRenderer also working.

Mr.doob 14 years ago
parent
commit
64df690cc0
5 changed files with 34 additions and 51 deletions
  1. 0 0
      build/Three.js
  2. 0 0
      build/ThreeDebug.js
  3. 2 2
      examples/geometry/Qrcode.js
  4. 1 1
      examples/test.html
  5. 31 48
      src/renderers/SVGRenderer.js

File diff suppressed because it is too large
+ 0 - 0
build/Three.js


File diff suppressed because it is too large
+ 0 - 0
build/ThreeDebug.js


+ 2 - 2
examples/geometry/Qrcode.js

@@ -3,8 +3,8 @@ var Qrcode = function () {
 	THREE.Geometry.call( this );
 
 	var scope = this,
-	m1 = new THREE.MeshBasicMaterial( { color: 0x000000 } ),
-	m2 = new THREE.MeshBasicMaterial( { color: 0xc0c0c0 } );
+	m1 = new THREE.MeshLambertMaterial( { color: 0x000000 } ),
+	m2 = new THREE.MeshLambertMaterial( { color: 0xc0c0c0 } );
 
 	v(-54,134,58);
 	v(-54,146,58);

+ 1 - 1
examples/test.html

@@ -174,7 +174,7 @@
 				geometry.computeNormals();
 				geometry.computeCentroids();
 
-				mesh = new THREE.Mesh( geometry, [ new THREE.MeshFaceMaterial(), new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, linewidth: 10 } ) ] );
+				mesh = new THREE.Mesh( geometry, [ new THREE.MeshFaceMaterial(), new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, wireframe: true, wireframe_linewidth: 10 } ) ] );
 				mesh.doubleSided = true;
 				mesh.scale.x = mesh.scale.y = mesh.scale.z = 2;
 				scene.addObject( mesh );

+ 31 - 48
src/renderers/SVGRenderer.js

@@ -95,8 +95,7 @@ THREE.SVGRenderer = function () {
 				for ( m = 0, ml = element.material.length; m < ml; m++ ) {
 
 					material = element.material[ m ];
-
-					renderParticle( v1x, v1y, element, material, scene );
+					material && renderParticle( v1x, v1y, element, material, scene );
 
 				}
 
@@ -133,8 +132,7 @@ THREE.SVGRenderer = function () {
 						while ( fm < fml ) {
 
 							material = element.faceMaterial[ fm ++ ];
-
-							renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
+							material && renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
 
 						}
 
@@ -142,7 +140,7 @@ THREE.SVGRenderer = function () {
 
 					}
 
-					renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
+					material && renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
 
 				}
 
@@ -177,8 +175,7 @@ THREE.SVGRenderer = function () {
 						while ( fm < fml ) {
 
 							material = element.faceMaterial[ fm ++ ];
-
-							renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
+							material && renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
 
 						}
 
@@ -186,7 +183,7 @@ THREE.SVGRenderer = function () {
 
 					}
 
-					renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
+					material && renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
 
 				}
 
@@ -316,21 +313,25 @@ THREE.SVGRenderer = function () {
 		_svg.appendChild( _svgNode );
 
 	}
-	
+
 	/*
 	function renderLine ( ) {
-	
+
 		
-	
+
 	}
 	*/
-	
+
 	function renderFace3 ( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene ) {
 
 		_svgNode = getPathNode( _pathCount ++ );
 		_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + 'z' );
 
-		if ( material instanceof THREE.MeshColorFillMaterial ) {
+		if ( material instanceof THREE.MeshBasicMaterial ) {
+
+			_color.__styleString = material.color.__styleString;
+
+		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
 			if ( _enableLighting ) {
 
@@ -343,30 +344,19 @@ THREE.SVGRenderer = function () {
 
 			} else {
 
-				_color = material.color;
+				_color.__styleString = material.color.__styleString;
 
 			}
 
-			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
-
-		} else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
+		}
 
-			if ( _enableLighting ) {
+		if ( material.wireframe ) {
 
-				_light.copyRGB( _ambientLight );
-				calculateFaceLight( scene, element, _light );
+			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframe_linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: round; stroke-linejoin: round' );
 
-				_color.copyRGBA( material.color );
-				_color.multiplySelfRGB( _light );
-				_color.updateStyleString();
+		} else {
 
-			} else {
-
-				_color = material.color;
-
-			}
-
-			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' );
+			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity );
 
 		}
 
@@ -379,7 +369,11 @@ THREE.SVGRenderer = function () {
 		_svgNode = getPathNode( _pathCount ++ );
 		_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + ' L ' + v4x + ',' + v4y + 'z' );
 
-		if ( material instanceof THREE.MeshColorFillMaterial ) {
+		if ( material instanceof THREE.MeshBasicMaterial ) {
+
+			_color.__styleString = material.color.__styleString;
+
+		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
 			if ( _enableLighting ) {
 
@@ -392,30 +386,19 @@ THREE.SVGRenderer = function () {
 
 			} else {
 
-				_color = material.color;
+				_color.__styleString = material.color.__styleString;
 
 			}
 
-			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
-
-		} else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
-
-			if ( _enableLighting ) {
-
-				_light.copyRGB( _ambientLight );
-				calculateFaceLight( scene, element, _light );
-
-				_color.copyRGBA( material.color );
-				_color.multiplySelfRGB( _light );
-				_color.updateStyleString();
+		}
 
-			} else {
+		if ( material.wireframe ) {
 
-				_color = material.color;
+			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.wireframe_linewidth + '; stroke-opacity: ' + material.opacity + '; stroke-linecap: round; stroke-linejoin: round' );
 
-			}
+		} else {
 
-			_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' );
+			_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString + '; fill-opacity: ' + material.opacity );
 
 		}
 

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