【发布时间】:2018-12-14 05:10:23
【问题描述】:
我有一个设置在实体上的组件,应该在鼠标按下事件上旋转:
AFRAME.registerComponent('spin', {
init: function () {
var self = this;
this.mouse_down = false;
// assuming only one controller for now
this.laser = document.querySelectorAll('.laser-controls')[0];
this.el.addEventListener('mousedown', function (e) {
self.mouse_down = true;
});
this.el.addEventListener('mouseup', function (e) {
self.mouse_down = false;
});
},
tick: function() {
if (this.mouse_down) {
var el = this.el;
var rotationTmp = this.rotationTmp = this.rotationTmp || {x: 0, y: 0, z: 0};
var rotation = el.getAttribute('rotation');
rotationTmp.y = (this.laser.object3D.getWorldRotation()._y / (Math.PI / 180));
el.setAttribute('rotation', rotationTmp);
}
}
});
但它没有正确旋转(在 Gear VR 中测试)。我想要的是:按住任何控制器按钮并旋转实体,直到释放控制器按钮。谢谢!
【问题讨论】:
标签: aframe