Explorar o código

OBJLoader: Better handle "usemap" identifier.

Mugen87 %!s(int64=5) %!d(string=hai) anos
pai
achega
c37b5cad3a
Modificáronse 2 ficheiros con 18 adicións e 0 borrados
  1. 9 0
      examples/js/loaders/OBJLoader.js
  2. 9 0
      examples/jsm/loaders/OBJLoader.js

+ 9 - 0
examples/js/loaders/OBJLoader.js

@@ -10,6 +10,8 @@ THREE.OBJLoader = ( function () {
 	var material_library_pattern = /^mtllib /;
 	var material_library_pattern = /^mtllib /;
 	// usemtl material_name
 	// usemtl material_name
 	var material_use_pattern = /^usemtl /;
 	var material_use_pattern = /^usemtl /;
+	// usemap map_name
+	var map_use_pattern = /^usemap /;
 
 
 	function ParserState() {
 	function ParserState() {
 
 
@@ -570,6 +572,13 @@ THREE.OBJLoader = ( function () {
 
 
 					state.materialLibraries.push( line.substring( 7 ).trim() );
 					state.materialLibraries.push( line.substring( 7 ).trim() );
 
 
+				} else if ( map_use_pattern.test( line ) ) {
+
+					// the line is parsed but ignored since the loader assumes textures are defined MTL files
+					// (according to https://www.okino.com/conv/imp_wave.htm, 'usemap' is the old-style Wavefront texture reference method)
+
+					console.warn( 'THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.' );
+
 				} else if ( lineFirstChar === 's' ) {
 				} else if ( lineFirstChar === 's' ) {
 
 
 					result = line.split( ' ' );
 					result = line.split( ' ' );

+ 9 - 0
examples/jsm/loaders/OBJLoader.js

@@ -27,6 +27,8 @@ var OBJLoader = ( function () {
 	var material_library_pattern = /^mtllib /;
 	var material_library_pattern = /^mtllib /;
 	// usemtl material_name
 	// usemtl material_name
 	var material_use_pattern = /^usemtl /;
 	var material_use_pattern = /^usemtl /;
+	// usemap map_name
+	var map_use_pattern = /^usemap /;
 
 
 	function ParserState() {
 	function ParserState() {
 
 
@@ -587,6 +589,13 @@ var OBJLoader = ( function () {
 
 
 					state.materialLibraries.push( line.substring( 7 ).trim() );
 					state.materialLibraries.push( line.substring( 7 ).trim() );
 
 
+				} else if ( map_use_pattern.test( line ) ) {
+
+					// the line is parsed but ignored since the loader assumes textures are defined MTL files
+					// (according to https://www.okino.com/conv/imp_wave.htm, 'usemap' is the old-style Wavefront texture reference method)
+
+					console.warn( 'THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.' );
+
 				} else if ( lineFirstChar === 's' ) {
 				} else if ( lineFirstChar === 's' ) {
 
 
 					result = line.split( ' ' );
 					result = line.split( ' ' );