From 33cc130652f0441640251bf4208a41dabc16f8ed Mon Sep 17 00:00:00 2001 From: Syed Hussain Ather Date: Fri, 7 Mar 2025 11:45:26 -0500 Subject: [PATCH 1/3] safeguard incldued --- src/components/gltf-model-plus.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index c668615aa4..3867ce5756 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -595,15 +595,17 @@ class GLTFHubsComponentsExtension { // Note: For some reason this was not supported for PDFs. Not sure if it's random or if there is a reason. if (shouldUseNewLoader()) { if (Object.prototype.hasOwnProperty.call(ext, "link")) { - if (["image", "video", "model"].includes(componentName)) { + if (["image", "video", "model"].includes(componentName)) { + if (!ext.link || !ext.link.href) { + console.warn("Warning: Attempted to load a link but the href is missing!", ext); + } else { ext["media-link"] = { - src: ext.link.href - }; - delete ext.link; - } - } - } - + src: ext.link.href + }; + delete ext.link; + } + } + } const value = props[propName]; const type = value?.__mhc_link_type; if (type && value.index !== undefined) { From cbd813a4d85e7694d27937e2a0f45dcc6120873c Mon Sep 17 00:00:00 2001 From: Syed Hussain Ather Date: Fri, 7 Mar 2025 12:00:04 -0500 Subject: [PATCH 2/3] Improved link validation and debugging in gltf-model-plus.js --- src/components/gltf-model-plus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index 3867ce5756..9aaae7b9db 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -597,7 +597,7 @@ class GLTFHubsComponentsExtension { if (Object.prototype.hasOwnProperty.call(ext, "link")) { if (["image", "video", "model"].includes(componentName)) { if (!ext.link || !ext.link.href) { - console.warn("Warning: Attempted to load a link but the href is missing!", ext); + console.warn("Warning: Attempted to load a link but the href is missing! Component : ${componentName}", ext); } else { ext["media-link"] = { src: ext.link.href From 5a1ce81cbf343c322e72fc4cae4e4487c6adb379 Mon Sep 17 00:00:00 2001 From: Doug Reeder Date: Thu, 24 Apr 2025 10:52:27 -0400 Subject: [PATCH 3/3] adds back closing brace and fixes indentation --- src/components/gltf-model-plus.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/gltf-model-plus.js b/src/components/gltf-model-plus.js index 9aaae7b9db..f15d171c68 100644 --- a/src/components/gltf-model-plus.js +++ b/src/components/gltf-model-plus.js @@ -595,17 +595,18 @@ class GLTFHubsComponentsExtension { // Note: For some reason this was not supported for PDFs. Not sure if it's random or if there is a reason. if (shouldUseNewLoader()) { if (Object.prototype.hasOwnProperty.call(ext, "link")) { - if (["image", "video", "model"].includes(componentName)) { + if (["image", "video", "model"].includes(componentName)) { if (!ext.link || !ext.link.href) { - console.warn("Warning: Attempted to load a link but the href is missing! Component : ${componentName}", ext); - } else { - ext["media-link"] = { - src: ext.link.href - }; - delete ext.link; - } - } - } + console.warn("Warning: Attempted to load a link but the href is missing! Component : ${componentName}", ext); + } else { + ext["media-link"] = { + src: ext.link.href + }; + delete ext.link; + } + } + } + } const value = props[propName]; const type = value?.__mhc_link_type; if (type && value.index !== undefined) {