Javascript 动态观察控件跟随鼠标而不单击three.js
是否有人有代码强制three.js中的orbit控件在mousemove上移动场景,而不是单击+mousemove?我已经尝试使用此线程中的答案: 但不幸的是,它抛出了一个错误“最大调用堆栈大小超过了错误”,我只得到了一个黑色画布,里面什么都没有 我也试着改变Javascript 动态观察控件跟随鼠标而不单击three.js,javascript,three.js,Javascript,Three.js,是否有人有代码强制three.js中的orbit控件在mousemove上移动场景,而不是单击+mousemove?我已经尝试使用此线程中的答案: 但不幸的是,它抛出了一个错误“最大调用堆栈大小超过了错误”,我只得到了一个黑色画布,里面什么都没有 我也试着改变 scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); 到 在OrbitControls.js文件中,但在移动时似乎会冻结,并不时停止 有人设法解决了这
scope.domElement.addEventListener( 'mousedown', onMouseDown, false );
到
在OrbitControls.js文件中,但在移动时似乎会冻结,并不时停止
有人设法解决了这个问题吗?
提前谢谢 这个怎么样
使用充当摄影机轴的Object3D。它随着鼠标移动而旋转。这个怎么样
使用充当摄影机轴的Object3D。它随鼠标移动而旋转。您不能像本例中那样使用
firstPersonControl
?还有一件事是光标在窗口边缘停止移动。。(但是你可以用pointerlock来解决这个问题)你不能像在这个例子中那样使用firstPersonControl
?还有一件事是光标在窗口边缘停止移动。。(但是你可以用pointerlock来解决这个问题)。我最终编辑了OrbitControls.js,并用一个厚颜无耻的鼠标悬停在listener上的函数替换了mouse down函数。我最终编辑了OrbitControls.js,并用一个厚颜无耻的鼠标悬停在listener上的函数替换了mouse down函数
scope.domElement.addEventListener( 'mousemove', onMouseDown, false );
document.addEventListener('mousemove', function(e){
let scale = -0.01;
orbit.rotateY( e.movementX * scale );
orbit.rotateX( e.movementY * scale );
orbit.rotation.z = 0; //this is important to keep the camera level..
})
//the camera rotation pivot
orbit = new THREE.Object3D();
orbit.rotation.order = "YXZ"; //this is important to keep level, so Z should be the last axis to rotate in order...
orbit.position.copy( mesh.position );
scene.add(orbit );
//offset the camera and add it to the pivot
//you could adapt the code so that you can 'zoom' by changing the z value in camera.position in a mousewheel event..
let cameraDistance = 1;
camera.position.z = cameraDistance;
orbit.add( camera );