three.js - Rotation of Y axis (on Marker Based AR) only goes up to 90 degrees
问题描述
I'm using AR.js with A-Frame trying to make my character (on the local access) rotate and play and animation based on the rotation of the markers Y-axis rotation. The character is a child of the marker entity. Think of a character which is moving to face the camera. I have some code to detect the angle between the camera and marker, then I play the gltf animation and add rotation to it.
See here in inside the AFrame register component, I added this to detect the difference between the two angles:
if (this.marker.rotation.y > this.el.object3D.rotation.y + 30*(Math.PI/180)) {
console.log("rotate");
this.el.setAttribute('animation-mixer', {
clip: 'turning-right',
loop: 'once',
crossFadeDuration: 0.4,
});
this.el.object3D.rotation.y += 30*(Math.PI/180);
}
But my issue is that I cant accurately detect the angle of the marker, as it goes from 90 to 0 to -90.
I used this line to print out the rotation, and the value of the Y rotation of the marker is 0, the same from the front, as it is from the back.
console.log(this.marker.rotation.y)
My expectation would be that it would rotate from 0 to 360 or 180 to -180. This would allow me to detect if the character is looking away/turning his back from the camera. At the moment, the character will have his back turned because once I go behind the marker theres no telling if its in the infront or back.
Is there a way that I can change the angle mode, or tell if im behind? Ive tried to change the Euler order from XYZ to YXZ but I still get the same issue.
If you would like to recreate this issue, in A-Frame just track a Hiro marker and then console.log the rotation on the Y axis.
Thanks.
解决方案
推荐阅读
- reactjs - 使用 sp-rest-proxy / node-sp-auth 进行身份验证
- php - 用大括号将字符串转换为数组
- reactjs - 如何使用 React-Redux 从另一个类调用函数?
- xslt - 如何使用 Apache Camel 在 XSLT 中为每个组申请
- css - 在图像上旋转晕影
- reactjs - React App:Tiny MCE 不会像我在编辑时那样在保存后突出显示代码
- java - 尝试通过 OAuth2 SMTP 发送 Gmail 电子邮件时出现 AuthenticationFailedException
- java - 为什么引用指向一个由java中的concat()方法返回的SCP区域对象?
- python - 无法将小部件添加到框架
- if-statement - 让椭圆大小改变