当我在场景中单击并拖动鼠标时,需要两个全屏宽度才能进行360度旋转。
是否可以调整A帧场景的灵敏度?
万一有人好奇,这就是我正在使用的html:
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
</head>
<body>
<a-scene vr-mode-ui="enabled: false">
<a-assets>
<img id="image" crossorigin="anonymous" src="https://cdn.aframe.io/360-image-gallery-boilerplate/img/sechelt.jpg">
</a-assets>
<a-sky id="image-360" radius="10" src="#image"></a-sky>
</a-scene>
</body>
</html>
答案 0 :(得分:1)
<script type="text/javascript">
AFRAME.registerComponent('drag-rotate-component',{
schema : { speed : {default:1}},
init : function(){
this.ifMouseDown = false;
this.x_cord = 0;
this.y_cord = 0;
document.addEventListener('mousedown',this.OnDocumentMouseDown.bind(this));
document.addEventListener('mouseup',this.OnDocumentMouseUp.bind(this));
document.addEventListener('mousemove',this.OnDocumentMouseMove.bind(this));
},
OnDocumentMouseDown : function(event){
this.ifMouseDown = true;
this.x_cord = event.clientX;
this.y_cord = event.clientY;
},
OnDocumentMouseUp : function(){
this.ifMouseDown = false;
},
OnDocumentMouseMove : function(event)
{
if(this.ifMouseDown)
{
var temp_x = event.clientX-this.x_cord;
var temp_y = event.clientY-this.y_cord;
if(Math.abs(temp_y)<Math.abs(temp_x))
{
this.el.object3D.rotateY(temp_x*this.data.speed/100);
}
else
{
this.el.object3D.rotateX(temp_y*this.data.speed/100);
}
this.x_cord = event.clientX;
this.y_cord = event.clientY;
}
}
});
</script>
Source您可以调整速度,并在天空上方添加camera
组件
<a-entity camera drag-rotate-component></a-entity>
您只需要定义Y
答案 1 :(得分:0)
我制作了一个fork of aframe,其中包括外观控件的X和Y鼠标灵敏度