From e2b19bf556f90146759f41504d9294abf1c41b67 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Thu, 20 May 2021 20:21:56 -0700 Subject: [PATCH 1/6] Fix distance checks for zone audio sources --- src/components/avatar-audio-source.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/avatar-audio-source.js b/src/components/avatar-audio-source.js index 86cc294b02..2f565bb59b 100644 --- a/src/components/avatar-audio-source.js +++ b/src/components/avatar-audio-source.js @@ -165,6 +165,8 @@ function createWhiteNoise(audioContext, gain) { return whiteNoise; } +const tmpWorldPos = new THREE.Vector3(); + /** * @component zone-audio-source * This component looks for audio sources that get near it, keeping track @@ -220,8 +222,9 @@ AFRAME.registerComponent("zone-audio-source", { }, tick() { + this.el.object3D.getWorldPosition(tmpWorldPos); if (this.trackingEl) { - const distanceSquared = this.trackingEl.object3D.position.distanceToSquared(this.el.object3D.position); + const distanceSquared = this.trackingEl.object3D.position.distanceToSquared(tmpWorldPos); if (distanceSquared > this.boundingRadiusSquared) { this.trackingEl = null; this.setInput(this.whiteNoise); @@ -234,7 +237,7 @@ AFRAME.registerComponent("zone-audio-source", { if (this.data.onlyMods && !playerInfo.isOwner) continue; - const distanceSquared = avatar.object3D.position.distanceToSquared(this.el.object3D.position); + const distanceSquared = avatar.object3D.position.distanceToSquared(tmpWorldPos); if (distanceSquared < this.boundingRadiusSquared) { this.trackingEl = avatar; if (this.data.muteSelf && this.trackingEl.id === "avatar-rig") { From 0ac553cf36f83e049ffa42246aeec517bb332d86 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Thu, 20 May 2021 20:27:03 -0700 Subject: [PATCH 2/6] Fix incorrect array concat in hub-channel perms --- src/utils/hub-channel.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/hub-channel.js b/src/utils/hub-channel.js index 45e680f001..cddb4a5def 100644 --- a/src/utils/hub-channel.js +++ b/src/utils/hub-channel.js @@ -24,9 +24,15 @@ const HUB_CREATOR_PERMISSIONS = [ "mute_users", "kick_users" ]; -const VALID_PERMISSIONS = - HUB_CREATOR_PERMISSIONS + - ["tweet", "spawn_camera", "spawn_drawing", "spawn_and_move_media", "pin_objects", "spawn_emoji", "fly"]; +const VALID_PERMISSIONS = HUB_CREATOR_PERMISSIONS.concat([ + "tweet", + "spawn_camera", + "spawn_drawing", + "spawn_and_move_media", + "pin_objects", + "spawn_emoji", + "fly" +]); export default class HubChannel extends EventTarget { constructor(store, hubId) { From 05ebdbb01027210c83e6df6a06b1a63e185e8674 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Thu, 20 May 2021 20:29:15 -0700 Subject: [PATCH 3/6] Use amplify_audio perm for zone audio source --- src/components/avatar-audio-source.js | 2 +- src/components/player-info.js | 4 ++++ src/utils/hub-channel.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/avatar-audio-source.js b/src/components/avatar-audio-source.js index 2f565bb59b..a074b1dce8 100644 --- a/src/components/avatar-audio-source.js +++ b/src/components/avatar-audio-source.js @@ -235,7 +235,7 @@ AFRAME.registerComponent("zone-audio-source", { const playerInfo = playerInfos[i]; const avatar = playerInfo.el; - if (this.data.onlyMods && !playerInfo.isOwner) continue; + if (this.data.onlyMods && !playerInfo.can("amplify_audio")) continue; const distanceSquared = avatar.object3D.position.distanceToSquared(tmpWorldPos); if (distanceSquared < this.boundingRadiusSquared) { diff --git a/src/components/player-info.js b/src/components/player-info.js index 374c046e5a..5ac2c8bc61 100644 --- a/src/components/player-info.js +++ b/src/components/player-info.js @@ -120,12 +120,16 @@ AFRAME.registerComponent("player-info", { this.updateDisplayNameFromPresenceMeta(e.detail); }, updateDisplayNameFromPresenceMeta(presenceMeta) { + this.permissions = presenceMeta.permissions; this.displayName = presenceMeta.profile.displayName; this.identityName = presenceMeta.profile.identityName; this.isRecording = !!(presenceMeta.streaming || presenceMeta.recording); this.isOwner = !!(presenceMeta.roles && presenceMeta.roles.owner); this.applyDisplayName(); }, + can(perm) { + return !!this.permissiosn[perm]; + }, applyDisplayName() { const store = window.APP.store; diff --git a/src/utils/hub-channel.js b/src/utils/hub-channel.js index cddb4a5def..00dca9582d 100644 --- a/src/utils/hub-channel.js +++ b/src/utils/hub-channel.js @@ -22,7 +22,8 @@ const HUB_CREATOR_PERMISSIONS = [ "update_roles", "close_hub", "mute_users", - "kick_users" + "kick_users", + "amplify_audio" ]; const VALID_PERMISSIONS = HUB_CREATOR_PERMISSIONS.concat([ "tweet", From 35b605dfcbc74d6268484c0ddedc681d6ce92842 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Thu, 20 May 2021 20:58:28 -0700 Subject: [PATCH 4/6] Fix potential race condition in permissions checks --- src/components/player-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/player-info.js b/src/components/player-info.js index 5ac2c8bc61..569f2d4b0b 100644 --- a/src/components/player-info.js +++ b/src/components/player-info.js @@ -128,7 +128,7 @@ AFRAME.registerComponent("player-info", { this.applyDisplayName(); }, can(perm) { - return !!this.permissiosn[perm]; + return !!this.permissions && this.permissiosn[perm]; }, applyDisplayName() { const store = window.APP.store; From 568f901574e140622d76ad65bccf83aa72561fa7 Mon Sep 17 00:00:00 2001 From: Dominick D'Aniello Date: Mon, 24 May 2021 11:54:10 -0700 Subject: [PATCH 5/6] Update src/components/player-info.js Co-authored-by: Brian Peiris --- src/components/player-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/player-info.js b/src/components/player-info.js index 5ac2c8bc61..e1168ad8ca 100644 --- a/src/components/player-info.js +++ b/src/components/player-info.js @@ -128,7 +128,7 @@ AFRAME.registerComponent("player-info", { this.applyDisplayName(); }, can(perm) { - return !!this.permissiosn[perm]; + return !!this.permissions[perm]; }, applyDisplayName() { const store = window.APP.store; From aff978a2341e80686ecb5c216b753389655e8825 Mon Sep 17 00:00:00 2001 From: netpro2k Date: Mon, 24 May 2021 13:21:11 -0700 Subject: [PATCH 6/6] PR feedback --- src/components/player-info.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/player-info.js b/src/components/player-info.js index 7de0765a3c..8f8b0bd796 100644 --- a/src/components/player-info.js +++ b/src/components/player-info.js @@ -62,7 +62,7 @@ AFRAME.registerComponent("player-info", { this.playerSessionId = NAF.utils.getCreator(networkedEntity); const playerPresence = window.APP.hubChannel.presence.state[this.playerSessionId]; if (playerPresence) { - this.updateDisplayNameFromPresenceMeta(playerPresence.metas[0]); + this.updateFromPresenceMeta(playerPresence.metas[0]); } }); } @@ -117,9 +117,9 @@ AFRAME.registerComponent("player-info", { if (!this.playerSessionId) return; if (this.playerSessionId !== e.detail.sessionId) return; - this.updateDisplayNameFromPresenceMeta(e.detail); + this.updateFromPresenceMeta(e.detail); }, - updateDisplayNameFromPresenceMeta(presenceMeta) { + updateFromPresenceMeta(presenceMeta) { this.permissions = presenceMeta.permissions; this.displayName = presenceMeta.profile.displayName; this.identityName = presenceMeta.profile.identityName;