Browse Source

"g" line match like "o" lines in OBJ parser

Objects are created when an "o" or a "g" are encountered. Not sure if this is correct behaviour, but the "obj_mtl" example does not work correctly without it.
Daniel Hritzkiv 9 years ago
parent
commit
30729c2fa9
1 changed files with 5 additions and 5 deletions
  1. 5 5
      examples/js/loaders/OBJLoader.js

+ 5 - 5
examples/js/loaders/OBJLoader.js

@@ -215,7 +215,7 @@ THREE.OBJLoader.prototype = {
 		// f vertex//normal vertex//normal vertex//normal ...
 		var face_pattern4 = /^f\s+((-?\d+)\/\/(-?\d+))\s+((-?\d+)\/\/(-?\d+))\s+((-?\d+)\/\/(-?\d+))(?:\s+((-?\d+)\/\/(-?\d+)))?/;
 		
-		var object_pattern = /^o\s+(.+)/;
+		var object_pattern = /^[og]\s+(.+)/;
 		
 		var smoothing_pattern = /^s\s+([01]|on|off)/;
 
@@ -302,6 +302,10 @@ THREE.OBJLoader.prototype = {
 
 			} else if ( ( result = object_pattern.exec( line ) ) !== null ) {
 				
+				// o object_name
+				// or
+				// g group_name
+				
 				var name = result[1].trim();
 				
 				if ( foundObjects === false ) {
@@ -315,10 +319,6 @@ THREE.OBJLoader.prototype = {
 					
 				}
 
-			} else if ( /^g /.test( line ) ) {
-
-				// group
-
 			} else if ( /^usemtl /.test( line ) ) {
 
 				// material