diff --git a/map.js b/map.js index 22a7c20..e9b813d 100644 --- a/map.js +++ b/map.js @@ -10,6 +10,7 @@ AFRAME.registerComponent("map", { init: function() { this.frame = 0; + this.XRStart = 0; this.playerTile = { x: 1000, y: 1000 }; this.playerAdjacentTileIds = []; this.tileOffset = 0.5 * this.data.tileSize; @@ -47,6 +48,14 @@ AFRAME.registerComponent("map", { if (model_name === 'Quest 3') { this.renderer.xr.setFoveation(0); } + + + this.XRStart = performance.now(); + }); + + document.querySelector('a-scene').addEventListener('exit-vr', function () { + gtag('event', 'exit-vr', { duration: Math.floor((performance.now() - this.XRStart)/1000) }); + this.XRStart = 0; }); this.throttledEmitComponentChanged = function emitChange () {};