From e0f037211a05806dabc9e8baf9d32b0eab37c1fe Mon Sep 17 00:00:00 2001 From: Noeri Huisman <8823461+mrxz@users.noreply.github.com> Date: Sun, 17 Dec 2023 17:28:24 +0100 Subject: [PATCH] Check that model-loaded event originates from controls entity (#5415) Co-authored-by: Noeri Huisman --- src/components/oculus-go-controls.js | 2 +- src/components/oculus-touch-controls.js | 2 +- src/components/pico-controls.js | 2 +- src/components/valve-index-controls.js | 2 +- src/components/vive-controls.js | 2 +- src/components/vive-focus-controls.js | 2 +- src/components/windows-motion-controls.js | 2 ++ 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/oculus-go-controls.js b/src/components/oculus-go-controls.js index 29a4b516a13..1d876abb5b3 100644 --- a/src/components/oculus-go-controls.js +++ b/src/components/oculus-go-controls.js @@ -156,7 +156,7 @@ module.exports.Component = registerComponent('oculus-go-controls', { var controllerObject3D = evt.detail.model; var buttonMeshes; - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } buttonMeshes = this.buttonMeshes = {}; buttonMeshes.trigger = controllerObject3D.getObjectByName('oculus_go_button_trigger'); buttonMeshes.trackpad = controllerObject3D.getObjectByName('oculus_go_touchpad'); diff --git a/src/components/oculus-touch-controls.js b/src/components/oculus-touch-controls.js index b97b1a9e026..d74e39b2cff 100644 --- a/src/components/oculus-touch-controls.js +++ b/src/components/oculus-touch-controls.js @@ -383,7 +383,7 @@ module.exports.Component = registerComponent('oculus-touch-controls', { }, onModelLoaded: function (evt) { - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } if (this.isTouchV3orPROorPlus) { this.onTouchV3orPROorPlusModelLoaded(evt); } else { diff --git a/src/components/pico-controls.js b/src/components/pico-controls.js index cbfc8fcd354..77cb21ed81e 100644 --- a/src/components/pico-controls.js +++ b/src/components/pico-controls.js @@ -154,7 +154,7 @@ module.exports.Component = registerComponent('pico-controls', { }, onModelLoaded: function (evt) { - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } this.el.emit('controllermodelready', { name: 'pico-controls', diff --git a/src/components/valve-index-controls.js b/src/components/valve-index-controls.js index 644bed1158d..5992234f313 100644 --- a/src/components/valve-index-controls.js +++ b/src/components/valve-index-controls.js @@ -193,7 +193,7 @@ module.exports.Component = registerComponent('valve-index-controls', { var controllerObject3D = evt.detail.model; var self = this; - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } // Store button meshes object to be able to change their colors. buttonMeshes = this.buttonMeshes = {}; diff --git a/src/components/vive-controls.js b/src/components/vive-controls.js index 84ded7e5d6e..c07a9fb9edc 100644 --- a/src/components/vive-controls.js +++ b/src/components/vive-controls.js @@ -199,7 +199,7 @@ module.exports.Component = registerComponent('vive-controls', { var controllerObject3D = evt.detail.model; var self = this; - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } // Store button meshes object to be able to change their colors. buttonMeshes = this.buttonMeshes = {}; diff --git a/src/components/vive-focus-controls.js b/src/components/vive-focus-controls.js index e063b591ed1..cc2c8755abf 100644 --- a/src/components/vive-focus-controls.js +++ b/src/components/vive-focus-controls.js @@ -126,7 +126,7 @@ module.exports.Component = registerComponent('vive-focus-controls', { var controllerObject3D = evt.detail.model; var buttonMeshes; - if (!this.data.model) { return; } + if (evt.target !== this.el || !this.data.model) { return; } buttonMeshes = this.buttonMeshes = {}; buttonMeshes.trigger = controllerObject3D.getObjectByName('BumperKey'); buttonMeshes.triggerPressed = controllerObject3D.getObjectByName('BumperKey_Press'); diff --git a/src/components/windows-motion-controls.js b/src/components/windows-motion-controls.js index 5296b8c5156..c4dd87c9d19 100644 --- a/src/components/windows-motion-controls.js +++ b/src/components/windows-motion-controls.js @@ -276,6 +276,8 @@ module.exports.Component = registerComponent('windows-motion-controls', { var mesh; var meshInfo; + if (evt.target !== this.el) { return; } + debug('Processing model'); // Reset the caches