three.js 相机跟随鼠标移动
作者:互联网
相机跟随鼠标移动
代码
var startY,endY; var isDown = false; var changeBefore = 0; function addTouchListener() { document.onmousedown = function (event) { startY = event.clientY; isDown = true; }; document.onmouseup = function(event){ isDown = false; }; document.onmousemove = function (event) { if (isDown) { if(changeBefore != 0){ if(changeBefore > event.clientY){ camera.position.y = camera.position.y + 20; }else{ camera.position.y = camera.position.y - 20; } } endY = event.clientY; changeBefore = endY; } }; }
标签:function,鼠标,changeBefore,three,camera,position,isDown,js,event 来源: https://www.cnblogs.com/chenyi4/p/12465743.html