Skip to content

Commit

Permalink
Merge pull request #135 from daniel86/develop
Browse files Browse the repository at this point in the history
Fixed mouse ray for touch events
  • Loading branch information
rctoris committed Jan 18, 2016
2 parents b5d9a3e + 3e8f0be commit b88d798
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/visualization/interaction/MouseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ ROS3D.MouseHandler.prototype.processDomEvent = function(domEvent) {
var pos_x, pos_y;

if(domEvent.type.indexOf('touch') !== -1) {
pos_x = domEvent.changedTouches[0].clientX;
pos_y = domEvent.changedTouches[0].clientY;
pos_x = 0;
pos_y = 0;
for(var i=0; i<domEvent.touches.length; ++i) {
pos_x += domEvent.touches[i].clientX;
pos_y += domEvent.touches[i].clientY;
}
pos_x /= domEvent.touches.length;
pos_y /= domEvent.touches.length;
}
else {
pos_x = domEvent.clientX;
Expand Down
3 changes: 3 additions & 0 deletions src/visualization/interaction/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ ROS3D.OrbitControls = function(options) {
rotateStart.set(event.touches[0].pageX - window.scrollX,
event.touches[0].pageY - window.scrollY);
}
else {
state = STATE.NONE;
}
}

// add event listeners
Expand Down

0 comments on commit b88d798

Please sign in to comment.