From 33155151cd64bcac5797fec5c3cd856bd32048f5 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sun, 14 Feb 2021 22:59:32 -0800 Subject: [PATCH 1/4] fix webp extension with no handler --- examples/js/loaders/GLTFLoader.js | 14 +++++++++++++- examples/jsm/loaders/GLTFLoader.js | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index e69a77d03646a2..b40bfcc65c19d6 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -763,7 +763,19 @@ THREE.GLTFLoader = ( function () { var extension = textureDef.extensions[ name ]; var source = json.images[ extension.source ]; - var loader = source.uri ? parser.options.manager.getHandler( source.uri ) : parser.textureLoader; + + var loader; + if ( source.uri ) { + + loader = parser.options.getHandler( source.uri ); + + } + + if ( ! loader ) { + + loader = parser.textureLoader; + + } return this.detectSupport().then( function ( isSupported ) { diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 72bd9bd68fc222..fe4ce5079cfa9d 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -828,7 +828,19 @@ var GLTFLoader = ( function () { var extension = textureDef.extensions[ name ]; var source = json.images[ extension.source ]; - var loader = source.uri ? parser.options.manager.getHandler( source.uri ) : parser.textureLoader; + + var loader; + if ( source.uri ) { + + loader = parser.options.getHandler( source.uri ); + + } + + if ( ! loader ) { + + loader = parser.textureLoader; + + } return this.detectSupport().then( function ( isSupported ) { From 697b459769b7dfa00161ee2ec3b99558a071d6d1 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sun, 14 Feb 2021 23:30:03 -0800 Subject: [PATCH 2/4] Add "manager" --- examples/js/loaders/GLTFLoader.js | 2 +- examples/jsm/loaders/GLTFLoader.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index b40bfcc65c19d6..98fffaa5b7de35 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -767,7 +767,7 @@ THREE.GLTFLoader = ( function () { var loader; if ( source.uri ) { - loader = parser.options.getHandler( source.uri ); + loader = parser.options.manager.getHandler( source.uri ); } diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index fe4ce5079cfa9d..a4f140c7118a3c 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -832,7 +832,7 @@ var GLTFLoader = ( function () { var loader; if ( source.uri ) { - loader = parser.options.getHandler( source.uri ); + loader = parser.options.manager.getHandler( source.uri ); } From da06eb3ad08d2c07274df00044879a311d5522af Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Mon, 15 Feb 2021 12:39:43 -0800 Subject: [PATCH 3/4] Adjust code style --- examples/js/loaders/GLTFLoader.js | 26 ++++++++------------------ examples/jsm/loaders/GLTFLoader.js | 26 ++++++++------------------ 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index 98fffaa5b7de35..9185a2225abfaa 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -764,16 +764,11 @@ THREE.GLTFLoader = ( function () { var extension = textureDef.extensions[ name ]; var source = json.images[ extension.source ]; - var loader; + var loader = parser.textureLoader; if ( source.uri ) { - loader = parser.options.manager.getHandler( source.uri ); - - } - - if ( ! loader ) { - - loader = parser.textureLoader; + var handler = parser.options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; } @@ -2409,19 +2404,14 @@ THREE.GLTFLoader = ( function () { } - var loader; + var loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] + ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader + : this.textureLoader; if ( source.uri ) { - loader = options.manager.getHandler( source.uri ); - - } - - if ( ! loader ) { - - loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] - ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader - : this.textureLoader; + var handler = options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; } diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index a4f140c7118a3c..fc9a50c5ab3419 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -829,16 +829,11 @@ var GLTFLoader = ( function () { var extension = textureDef.extensions[ name ]; var source = json.images[ extension.source ]; - var loader; + var loader = parser.textureLoader; if ( source.uri ) { - loader = parser.options.manager.getHandler( source.uri ); - - } - - if ( ! loader ) { - - loader = parser.textureLoader; + var handler = parser.options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; } @@ -2474,19 +2469,14 @@ var GLTFLoader = ( function () { } - var loader; + var loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] + ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader + : this.textureLoader; if ( source.uri ) { - loader = options.manager.getHandler( source.uri ); - - } - - if ( ! loader ) { - - loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] - ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader - : this.textureLoader; + var handler = options.manager.getHandler( source.uri ); + if ( handler !== null ) loader = handler; } From 3d06022caca7a34f695cb352c3f2ba2c5058dde3 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Mon, 15 Feb 2021 15:47:49 -0800 Subject: [PATCH 4/4] Fix bad merge resolve --- examples/js/loaders/GLTFLoader.js | 13 ++----------- examples/jsm/loaders/GLTFLoader.js | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index fd87533c8dbd98..44097b2e38f6bc 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -2364,21 +2364,12 @@ THREE.GLTFLoader = ( function () { */ GLTFParser.prototype.loadTexture = function ( textureIndex ) { - var parser = this; var json = this.json; var options = this.options; - var textureDef = json.textures[ textureIndex ]; + var source = json.images[ textureDef.source ]; - var textureExtensions = textureDef.extensions || {}; - - var source; - - source = json.images[ textureDef.source ]; - - var loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] - ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader - : this.textureLoader; + var loader = this.textureLoader; if ( source.uri ) { diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index 1ac7f7def613dd..77eeb456eae9c0 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -2429,21 +2429,12 @@ var GLTFLoader = ( function () { */ GLTFParser.prototype.loadTexture = function ( textureIndex ) { - var parser = this; var json = this.json; var options = this.options; - var textureDef = json.textures[ textureIndex ]; + var source = json.images[ textureDef.source ]; - var textureExtensions = textureDef.extensions || {}; - - var source; - - source = json.images[ textureDef.source ]; - - var loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] - ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader - : this.textureLoader; + var loader = this.textureLoader; if ( source.uri ) {