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/6] 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/6] 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/6] 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) { From cf5782be22811687b0aa41edce6fbee9ecb47cfb Mon Sep 17 00:00:00 2001 From: Syed Hussain Ather Date: Tue, 3 Jun 2025 14:01:53 -0400 Subject: [PATCH 4/6] Fix camera interaction bug by enforcing network authority --- src/components/camera.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/components/camera.js diff --git a/src/components/camera.js b/src/components/camera.js new file mode 100644 index 0000000000..32ac57b936 --- /dev/null +++ b/src/components/camera.js @@ -0,0 +1,23 @@ +AFRAME.registerComponent("stabilize-camera", { + init() { + if (!this.el.hasAttribute("networked")) return; + + const checkOwnership = () => NAF && NAF.utils.isMine(this.el); + + this.el.addEventListener("grab-start", () => { + if (!checkOwnership()) { + // Prevent others from manipulating the camera + console.warn("[Camera] Grab blocked - not owned by this user."); + this.el.setAttribute("body", "type: static"); // Or disable interactivity + } + }); + + this.el.addEventListener("grab-end", () => { + if (!checkOwnership()) { + // Restore original behavior if needed + this.el.setAttribute("body", "type: dynamic"); + } + }); + } +}); + From 54bdd9f74c3ec81635cb98496870fd0d5ced5f8a Mon Sep 17 00:00:00 2001 From: Syed Hussain Ather Date: Tue, 3 Jun 2025 14:06:55 -0400 Subject: [PATCH 5/6] Add stabilize-camera component to fix #6544 --- src/components/camera.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/camera.js b/src/components/camera.js index 32ac57b936..f69525b38e 100644 --- a/src/components/camera.js +++ b/src/components/camera.js @@ -1,21 +1,24 @@ AFRAME.registerComponent("stabilize-camera", { - init() { - if (!this.el.hasAttribute("networked")) return; - - const checkOwnership = () => NAF && NAF.utils.isMine(this.el); + init: function () { + this.el.addEventListener("grab-start", (evt) => { + if (!NAF.utils.isMine(this.el)) { + console.warn("Cannot interact: you do not own this camera."); + evt.stopImmediatePropagation(); + evt.preventDefault(); + } + }); - this.el.addEventListener("grab-start", () => { - if (!checkOwnership()) { - // Prevent others from manipulating the camera - console.warn("[Camera] Grab blocked - not owned by this user."); - this.el.setAttribute("body", "type: static"); // Or disable interactivity + this.el.addEventListener("grab-move", (evt) => { + if (!NAF.utils.isMine(this.el)) { + evt.stopImmediatePropagation(); + evt.preventDefault(); } }); - this.el.addEventListener("grab-end", () => { - if (!checkOwnership()) { - // Restore original behavior if needed - this.el.setAttribute("body", "type: dynamic"); + this.el.addEventListener("grab-end", (evt) => { + if (!NAF.utils.isMine(this.el)) { + evt.stopImmediatePropagation(); + evt.preventDefault(); } }); } From 9fd1a30eb20350227147a3548dd8b01d3f81d4b8 Mon Sep 17 00:00:00 2001 From: Syed Hussain Ather Date: Tue, 3 Jun 2025 14:19:13 -0400 Subject: [PATCH 6/6] Refactor webpack.config.js: remove unused addons, fix runtimeChunk, and clean up aliases --- webpack.config.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 0a3f660491..666ff84cbd 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -285,9 +285,6 @@ module.exports = async (env, argv) => { // .replaceAll("connect-src", "connect-src https://example.com"); } - const addonsConfigFilePath = "./addons.json"; - const addonsConfig = JSON.parse(fs.readFileSync(addonsConfigFilePath, "utf-8")); - const internalHostname = process.env.INTERNAL_HOSTNAME || "hubs.local"; return { cache: { @@ -306,9 +303,7 @@ module.exports = async (env, argv) => { "three/examples/js/libs/basis/basis_transcoder.js": basisTranscoderPath, "three/examples/js/libs/draco/gltf/draco_wasm_wrapper.js": dracoWasmWrapperPath, "three/examples/js/libs/basis/basis_transcoder.wasm": basisWasmPath, - "three/examples/js/libs/draco/gltf/draco_decoder.wasm": dracoWasmPath, - - hubs$: path.resolve(__dirname, "./src/hubs.js") + "three/examples/js/libs/draco/gltf/draco_decoder.wasm": dracoWasmPath }, // Allows using symlinks in node_modules symlinks: false, @@ -325,7 +320,7 @@ module.exports = async (env, argv) => { entry: { support: path.join(__dirname, "src", "support.js"), index: path.join(__dirname, "src", "index.js"), - hub: [path.join(__dirname, "src", "hub.js"), ...addonsConfig.addons], + hub: path.join(__dirname, "src", "hub.js"), scene: path.join(__dirname, "src", "scene.js"), avatar: path.join(__dirname, "src", "avatar.js"), link: path.join(__dirname, "src", "link.js"), @@ -341,9 +336,6 @@ module.exports = async (env, argv) => { filename: "assets/js/[name]-[chunkhash].js", publicPath: process.env.BASE_ASSETS_PATH || "" }, - optimization: { - minimize: argv.mode === "production" ? true : false - }, target: ["web", "es5"], // use es5 for webpack runtime to maximize compatibility devtool: argv.mode === "production" ? "source-map" : "inline-source-map", devServer: { @@ -633,6 +625,9 @@ module.exports = async (env, argv) => { priority: 10 } } + }, + runtimeChunk: { + name: "runtime" } }, plugins: [