Aframe-从另一个JavaScript文件调用aframe函数 [英] Aframe - call aframe function from another javascript file

查看:94
本文介绍了Aframe-从另一个JavaScript文件调用aframe函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试关闭位置跟踪,并且我相信aframe代码中的此功能正是我所追求的:

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

checkHasPositionalTracking();

checkHasPositionalTracking();

但是,在我的第二个js文件(在aframe.js之后定义)中,如果我尝试调用该函数,则会收到此错误:

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

未捕获的ReferenceError:未定义checkHasPositionalTracking

Uncaught ReferenceError: checkHasPositionalTracking is not defined

推荐答案

您需要在引用完整的情况下调用它window.AFRAME浏览器是全局浏览器,因此请在代码中使用 AFRAME.utils.device.checkHasPositionalTracking()进行访问。

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.

这篇关于Aframe-从另一个JavaScript文件调用aframe函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆