bugfix: reversed 2D/XR eventlisteners
This commit is contained in:
parent
e2f801dc47
commit
41a365200d
|
@ -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) => {
|
||||||
|
@ -262,7 +263,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
btn.addEventListener('click', (e) => toggle() )
|
btn.addEventListener('click', (e) => toggle() )
|
||||||
document.body.appendChild(btn)
|
document.body.appendChild(btn)
|
||||||
|
|
||||||
document.querySelector('a-scene').addEventListener('enter-vr', () => toggle(true) )
|
document.querySelector('a-scene').addEventListener('enter-vr',() => toggle(true) )
|
||||||
document.querySelector('a-scene').addEventListener('exit-vr', () => toggle(false) )
|
document.querySelector('a-scene').addEventListener('exit-vr', () => toggle(false) )
|
||||||
document.querySelector('a-scene').addEventListener('loaded', () => {
|
document.querySelector('a-scene').addEventListener('loaded', () => {
|
||||||
let VRbtn = document.querySelector('a-scene .a-enter-vr')
|
let VRbtn = document.querySelector('a-scene .a-enter-vr')
|
||||||
|
|
Loading…
Reference in New Issue