Improved stylus and laser input deadspot

This commit is contained in:
Anthony J. Thibault 2017-01-18 18:23:00 -08:00
parent 49d8a644c3
commit 2fd691d844

View file

@ -2676,6 +2676,11 @@ function MyController(hand) {
this.touchingEnterPointerEvent = pointerEvent; this.touchingEnterPointerEvent = pointerEvent;
this.touchingEnterPointerEvent.button = "None"; this.touchingEnterPointerEvent.button = "None";
this.deadspotExpired = false; this.deadspotExpired = false;
var LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.026; // radians ~ 1.2 degrees
var STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.314; // radians ~ 18 degrees
var theta = this.state === STATE_ENTITY_STYLUS_TOUCHING ? STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE : LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE;
this.deadspotRadius = Math.tan(theta) * intersectInfo.distance; // dead spot radius in meters
} }
}; };
@ -2748,11 +2753,9 @@ function MyController(hand) {
isPrimaryHeld: true isPrimaryHeld: true
}; };
var POINTER_PRESS_TO_MOVE_DELAY = 0.15; // seconds var POINTER_PRESS_TO_MOVE_DELAY = 0.25; // seconds
var POINTER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.05; // radians ~ 3 degrees
if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY || if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY ||
angleBetween(pointerEvent.direction, Vec3.distance(intersectInfo.point, this.touchingEnterPointerEvent.pos3D) > this.deadspotRadius) {
this.touchingEnterPointerEvent.direction) > POINTER_PRESS_TO_MOVE_DEADSPOT_ANGLE) {
Entities.sendMouseMoveOnEntity(this.grabbedEntity, pointerEvent); Entities.sendMouseMoveOnEntity(this.grabbedEntity, pointerEvent);
Entities.sendHoldingClickOnEntity(this.grabbedEntity, pointerEvent); Entities.sendHoldingClickOnEntity(this.grabbedEntity, pointerEvent);
this.deadspotExpired = true; this.deadspotExpired = true;
@ -2786,13 +2789,17 @@ function MyController(hand) {
isPrimaryHeld: true isPrimaryHeld: true
}; };
Overlays.sendMousePressOnOverlay(this.grabbedOverlay, pointerEvent); Overlays.sendMousePressOnOverlay(this.grabbedOverlay, pointerEvent);
this.touchingEnterTimer = 0; this.touchingEnterTimer = 0;
this.touchingEnterPointerEvent = pointerEvent; this.touchingEnterPointerEvent = pointerEvent;
this.touchingEnterPointerEvent.button = "None"; this.touchingEnterPointerEvent.button = "None";
this.deadspotExpired = false; this.deadspotExpired = false;
var LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.026; // radians ~ 1.2 degrees
var STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.314; // radians ~ 18 degrees
var theta = this.state === STATE_OVERLAY_STYLUS_TOUCHING ? STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE : LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE;
this.deadspotRadius = Math.tan(theta) * intersectInfo.distance; // dead spot radius in meters
} }
}; };
@ -2867,11 +2874,9 @@ function MyController(hand) {
isPrimaryHeld: true isPrimaryHeld: true
}; };
var POINTER_PRESS_TO_MOVE_DELAY = 0.15; // seconds var POINTER_PRESS_TO_MOVE_DELAY = 0.25; // seconds
var POINTER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.05; // radians ~ 3 degrees
if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY || if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY ||
angleBetween(pointerEvent.direction, Vec3.distance(intersectInfo.point, this.touchingEnterPointerEvent.pos3D) > this.deadspotRadius) {
this.touchingEnterPointerEvent.direction) > POINTER_PRESS_TO_MOVE_DEADSPOT_ANGLE) {
Overlays.sendMouseMoveOnOverlay(this.grabbedOverlay, pointerEvent); Overlays.sendMouseMoveOnOverlay(this.grabbedOverlay, pointerEvent);
this.deadspotExpired = true; this.deadspotExpired = true;
} }