代码
var startX,endX;
var isDown = false; var changeBefore = 0; function addTouchListener() { document.onmousedown = function (event) { startX = event.clientX; isDown = true; }; document.onmouseup = function(event){ isDown = false; }; document.onmousemove = function (event) { if (isDown) { if(changeBefore != 0){ if(changeBefore > event.clientX){ mesh.rotation.y = mesh.rotation.y + 0.1; }else{ mesh.rotation.y = mesh.rotation.y - 0.1; } } endX = event.clientX; changeBefore = endX; } }; }
mesh改成自己的几何体,页面用
requestAnimationFrame( animate );
刷新