[英]ar.js clicking works on pc but not on mobile
I am building a small application with ar.js and everything seems to work on pc but once I try it on my phone I can't seem to be able to click anymore.我正在用 ar.js 构建一个小应用程序,一切似乎都可以在 pc 上运行,但是一旦我在手机上尝试,我似乎无法再点击。 Everything also ends up being stretched or squashed depending on the rotation of the phone.
根据手机的旋转,一切最终也会被拉伸或压扁。
I think the not being able to press anything has to do with the stretching/squashing but I don't know how I should fix such an issue?我认为无法按下任何东西与拉伸/挤压有关,但我不知道我应该如何解决这样的问题?
Currently, the js looks like this目前,js 看起来像这样
AFRAME.registerComponent('interactable-object',
{
init: function ()
{
var el = this.el;
el.addEventListener('click', (e) =>
{
console.log("item pressed");
}
}
}
and the Html code like this:和这样的 Html 代码:
<a-entity id='3dmodel' interactable-object position="1 0 -2" scale="5 5 5"
obj-model=" obj: url(models/3dmodel.obj);
mtl: url(models/3dmaterial.mtl); ">
</a-entity>
I use cursor: rayOrigin: mouse;
我使用
cursor: rayOrigin: mouse;
in my a-marker;在我的标记中; I don't know if this is the correct one to use for mobile touch either?
我不知道这是否也适合用于移动触控? Am I doing something wrong or is there a way to make the object more responsive?
我做错了什么还是有办法使对象更具响应性?
I'm using ar.js 2.2.1 and aframe 0.9.2.我正在使用 ar.js 2.2.1 和 aframe 0.9.2。
As far as i know you need to listen to 'touchstart' also:据我所知,您还需要听“touchstart”:
el.addEventListener('touchstart', (e) =>
But the problem i'm facing now is that this doesn't work well on the edges of the screen, if someone knows a workaround let me know.但是我现在面临的问题是这在屏幕边缘效果不佳,如果有人知道解决方法,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.