Skip to content

Commit 5fd3b5c

Browse files
authored
Merge pull request #18000 from Mugen87/dev39
OBJLoader: Better handle "usemap" identifier.
2 parents ef17d6e + c37b5ca commit 5fd3b5c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

examples/js/loaders/OBJLoader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ THREE.OBJLoader = ( function () {
1010
var material_library_pattern = /^mtllib /;
1111
// usemtl material_name
1212
var material_use_pattern = /^usemtl /;
13+
// usemap map_name
14+
var map_use_pattern = /^usemap /;
1315

1416
function ParserState() {
1517

@@ -570,6 +572,13 @@ THREE.OBJLoader = ( function () {
570572

571573
state.materialLibraries.push( line.substring( 7 ).trim() );
572574

575+
} else if ( map_use_pattern.test( line ) ) {
576+
577+
// the line is parsed but ignored since the loader assumes textures are defined MTL files
578+
// (according to https://www.okino.com/conv/imp_wave.htm, 'usemap' is the old-style Wavefront texture reference method)
579+
580+
console.warn( 'THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.' );
581+
573582
} else if ( lineFirstChar === 's' ) {
574583

575584
result = line.split( ' ' );

examples/jsm/loaders/OBJLoader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ var OBJLoader = ( function () {
2727
var material_library_pattern = /^mtllib /;
2828
// usemtl material_name
2929
var material_use_pattern = /^usemtl /;
30+
// usemap map_name
31+
var map_use_pattern = /^usemap /;
3032

3133
function ParserState() {
3234

@@ -587,6 +589,13 @@ var OBJLoader = ( function () {
587589

588590
state.materialLibraries.push( line.substring( 7 ).trim() );
589591

592+
} else if ( map_use_pattern.test( line ) ) {
593+
594+
// the line is parsed but ignored since the loader assumes textures are defined MTL files
595+
// (according to https://www.okino.com/conv/imp_wave.htm, 'usemap' is the old-style Wavefront texture reference method)
596+
597+
console.warn( 'THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.' );
598+
590599
} else if ( lineFirstChar === 's' ) {
591600

592601
result = line.split( ' ' );

0 commit comments

Comments
 (0)