Search code examples
javascripttriggersaframewebvr

Aframe - call aframe function from another javascript file


I'm trying to turn positional tracking off, and I believe that this function in the aframe code is what I'm after:

checkHasPositionalTracking();

However, in my second js file (which is defined AFTER aframe.js), if I try to call that function, I receive this error:

Uncaught ReferenceError: checkHasPositionalTracking is not defined


Solution

  • You need to call it with full reference to the window.AFRAME browser global, so use AFRAME.utils.device.checkHasPositionalTracking () in your code to access it.