Commit 4c176e8a authored by amandaghassaei's avatar amandaghassaei

touch

parent 55092526
......@@ -34,9 +34,13 @@ function initGL() {
body = document.getElementsByTagName("body")[0];
canvas.onmousemove = onMouseMove;
canvas.ontouchmove = onTouchMove;
canvas.onmousedown = onMouseDown;
canvas.ontouchstart = onMouseDown;
canvas.onmouseup = onMouseUp;
canvas.ontouchend = onMouseUp;
canvas.onmouseout = onMouseUp;
canvas.ontouchcancel = onMouseUp;
window.onresize = onResize;
......@@ -250,6 +254,12 @@ function onMouseMove(e){
lastMouseCoordinates = mouseCoordinates;
mouseCoordinates = [e.clientX, actualHeight-e.clientY];
}
function onTouchMove(e){
e.preventDefault();
var touch = e.touches[0];
lastMouseCoordinates = mouseCoordinates;
mouseCoordinates = [touch.pageX, actualHeight-touch.pageY];
}
function onMouseDown(){
mouseEnable = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment