diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index 812b6953f23d977e8fb62fb42a615e853a7ac8ab..3864f9327c92ce63deddf8f08766a9316cf4a3da 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -197,7 +197,7 @@ AFRAME.registerComponent("gltf-model-plus", { schema: { src: { type: "string" }, inflate: { default: false }, - preferredTechnique: { type: "string" } + preferredTechnique: { default: AFRAME.utils.device.isMobile() ? "KHR_materials_unlit" : "pbrMetallicRoughness" } }, init() { @@ -218,15 +218,6 @@ AFRAME.registerComponent("gltf-model-plus", { ); }, - getPreferredTechnique() { - if (this.data.preferredTechnique) { - return this.data.preferredTechnique; - } else if (AFRAME.utils.device.isMobile()) { - return "KHR_materials_unlit"; - } - return "pbrMetallicRoughness"; - }, - async applySrc(src) { try { // If the src attribute is a selector, get the url from the asset item. @@ -257,8 +248,7 @@ AFRAME.registerComponent("gltf-model-plus", { return; } - const preferredTechnique = this.getPreferredTechnique(); - const model = await cachedLoadGLTF(src, preferredTechnique); + const model = await cachedLoadGLTF(src, this.data.preferredTechnique); // If we started loading something else already // TODO: there should be a way to cancel loading instead diff --git a/src/vendor/GLTFLoader.js b/src/vendor/GLTFLoader.js index f8149bee1ec4d8c1223eda232bfe5c4730feb312..25e397ce98c7ebc2be929195c6863338154c01bc 100644 --- a/src/vendor/GLTFLoader.js +++ b/src/vendor/GLTFLoader.js @@ -892,9 +892,9 @@ THREE.GLTFLoader = ( function () { MOZAltMaterialsExtension.prototype.getAltMaterial = function ( materialDef, materials ) { - if ( materialDef.extensions && materialDef.extensions[ EXTENSIONS.MOZ_ALT_MATERIALS ]) { + var mamExtension = materialDef.extensions && materialDef.extensions[ EXTENSIONS.MOZ_ALT_MATERIALS ]; - var mamExtension = materialDef.extensions[ EXTENSIONS.MOZ_ALT_MATERIALS ]; + if ( mamExtension ) { if ( this.preferredTechnique && mamExtension[ this.preferredTechnique ] !== undefined ) { @@ -903,7 +903,6 @@ THREE.GLTFLoader = ( function () { } - return materialDef; }