Browse Source

Added quads support to VTKLoader2

Mr.doob 13 years ago
parent
commit
288ac07b28
1 changed files with 19 additions and 1 deletions
  1. 19 1
      examples/js/loaders/VTKLoader2.js

+ 19 - 1
examples/js/loaders/VTKLoader2.js

@@ -51,6 +51,12 @@ THREE.VTKLoader2.prototype.parse = function ( data ) {
 
 	}
 
+	function face4( a, b, c, d ) {
+
+		geometry.faces.push( new THREE.Face4( a, b, c, d ) );
+
+	}
+
 	var pattern, result;
 
 	// float float float
@@ -67,7 +73,7 @@ THREE.VTKLoader2.prototype.parse = function ( data ) {
 
 	// 3 int int int
 
-	pattern = /3 ([\d]+) ([\d]+) ([\d]+) /g;
+	pattern = /3 ([\d]+) ([\d]+) ([\d]+)/g;
 
 	while ( ( result = pattern.exec( data ) ) != null ) {
 
@@ -77,6 +83,18 @@ THREE.VTKLoader2.prototype.parse = function ( data ) {
 
 	}
 
+	// 4 int int int int
+
+	pattern = /4 ([\d]+) ([\d]+) ([\d]+) ([\d]+)/g;
+
+	while ( ( result = pattern.exec( data ) ) != null ) {
+
+		// ["4 1 2 3 4", "1", "2", "3", "4"]
+
+		face4( parseInt( result[ 1 ] ), parseInt( result[ 2 ] ), parseInt( result[ 3 ] ), parseInt( result[ 4 ] ) );
+
+	}
+
 	geometry.computeCentroids();
 	geometry.computeFaceNormals();
 	geometry.computeVertexNormals();