Skip to content

Commit 4961a55

Browse files
Utopiahdmarcos
authored andcommitted
added a reverseTouchDrag parameter (#3761)
Equivalent to reverseMouseDrag for mobile and tablet.
1 parent cd07260 commit 4961a55

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎src/components/look-controls.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports.Component = registerComponent('look-controls', {
2121
hmdEnabled: {default: true},
2222
pointerLockEnabled: {default: false},
2323
reverseMouseDrag: {default: false},
24+
reverseTouchDrag: {default: false},
2425
touchEnabled: {default: true}
2526
},
2627

@@ -282,6 +283,7 @@ module.exports.Component = registerComponent('look-controls', {
282283
* Translate touch move to Y-axis rotation.
283284
*/
284285
onTouchMove: function (evt) {
286+
var direction;
285287
var canvas = this.el.sceneEl.canvas;
286288
var deltaY;
287289
var yawObject = this.yawObject;
@@ -290,8 +292,9 @@ module.exports.Component = registerComponent('look-controls', {
290292

291293
deltaY = 2 * Math.PI * (evt.touches[0].pageX - this.touchStart.x) / canvas.clientWidth;
292294

295+
direction = this.data.reverseTouchDrag ? 1 : -1;
293296
// Limit touch orientaion to to yaw (y axis).
294-
yawObject.rotation.y -= deltaY * 0.5;
297+
yawObject.rotation.y -= deltaY * 0.5 * direction;
295298
this.touchStart = {
296299
x: evt.touches[0].pageX,
297300
y: evt.touches[0].pageY

0 commit comments

Comments
 (0)