bugfix: reversed 2D/XR eventlisteners

This commit is contained in:
Leon van Kammen 2024-01-08 15:21:51 +00:00
parent e2f801dc47
commit 41a365200d
1 changed files with 5 additions and 4 deletions

View File

@ -167,6 +167,7 @@ AFRAME.AComponent.prototype.updateProperties = function(updateProperties){
setupListeners: () => { setupListeners: () => {
this.scene.addEventListener('apps:2D', () => this.el.setAttribute('visible', false) ) this.scene.addEventListener('apps:2D', () => this.el.setAttribute('visible', false) )
this.scene.addEventListener('apps:XR', () => { this.scene.addEventListener('apps:XR', () => {
console.log("JAXR")
this.el.setAttribute('visible', true) this.el.setAttribute('visible', true)
this.el.setAttribute("html",`html:#${this.el.uid}; cursor:#cursor`) this.el.setAttribute("html",`html:#${this.el.uid}; cursor:#cursor`)
}) })
@ -250,9 +251,9 @@ document.head.innerHTML += `
// draw a button so we can toggle apps between 2D / XR // draw a button so we can toggle apps between 2D / XR
let toggle = (state) => { let toggle = (state) => {
state = state || document.body.className.match(/XR/) state = state || !document.body.className.match(/XR/)
document.body.classList[ state ? 'remove' : 'add'](['XR']) document.body.classList[ state ? 'add' : 'remove'](['XR'])
AFRAME.scenes[0].emit( state ? 'apps:2D' : 'apps:XR') AFRAME.scenes[0].emit( state ? 'apps:XR' : 'apps:2D')
} }
document.addEventListener("DOMContentLoaded", (event) => { document.addEventListener("DOMContentLoaded", (event) => {