From 501bd1362e9c9b303b5a8659e7dae73177b5133e Mon Sep 17 00:00:00 2001 From: Robert Long <robert@robertlong.me> Date: Fri, 6 Apr 2018 10:57:10 -0700 Subject: [PATCH] Made requested PR changes. --- src/components/gltf-model-plus.js | 14 ++------------ src/vendor/GLTFLoader.js | 5 ++--- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index 812b6953f..3864f9327 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 f8149bee1..25e397ce9 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; } -- GitLab