diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index d2c9fdc05a..f62acb985a 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -27,7 +27,7 @@ Script.include("/~/system/libraries/controllers.js"); // add lines where the hand ray picking is happening // var WANT_DEBUG = false; -var WANT_DEBUG_STATE = false; +var WANT_DEBUG_STATE = true; var WANT_DEBUG_SEARCH_NAME = null; var FORCE_IGNORE_IK = false; @@ -53,6 +53,13 @@ var HAPTIC_TEXTURE_DISTANCE = 0.002; var HAPTIC_DEQUIP_STRENGTH = 0.75; var HAPTIC_DEQUIP_DURATION = 50.0; +// triggered when stylus presses a web overlay/entity +var HAPTIC_STYLUS_STRENGTH = 1.0; +var HAPTIC_STYLUS_DURATION = 20.0; + +// triggerd when ui laser presses a web overlay/entity +var HAPTIC_LASER_UI_STRENGTH = 1.0; +var HAPTIC_LASER_UI_DURATION = 20.0; var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only use head for search/move. @@ -122,7 +129,6 @@ var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS; var GRAB_POINT_SPHERE_COLOR = { red: 240, green: 240, blue: 240 }; var GRAB_POINT_SPHERE_ALPHA = 0.85; - // // other constants // @@ -1248,7 +1254,7 @@ function MyController(hand) { if (homeButton === hmdHomeButton) { if (this.homeButtonTouched === false) { this.homeButtonTouched = true; - Controller.triggerHapticPulse(1, 20, this.hand); + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); Messages.sendLocalMessage("home", homeButton); } } else { @@ -1266,7 +1272,7 @@ function MyController(hand) { if (homeButton === hmdHomeButton) { if (this.homeButtonTouched === false) { this.homeButtonTouched = true; - Controller.triggerHapticPulse(1, 20, this.hand); + Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); Messages.sendLocalMessage("home", homeButton); } } else { @@ -1754,7 +1760,6 @@ function MyController(hand) { Entities.sendHoverOverEntity(entity, pointerEvent); } - this.grabbedEntity = entity; this.setState(STATE_ENTITY_STYLUS_TOUCHING, "begin touching entity '" + name + "'"); return true; @@ -1775,11 +1780,6 @@ function MyController(hand) { var pointerEvent; if (rayPickInfo.overlayID) { var overlay = rayPickInfo.overlayID; - - if (!this.homeButtonTouched) { - Controller.triggerHapticPulse(1, 20, this.hand); - } - if (Overlays.keyboardFocusOverlay != overlay) { Entities.keyboardFocusEntity = null; Overlays.keyboardFocusOverlay = overlay; @@ -2710,6 +2710,12 @@ function MyController(hand) { 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 } + + if (this.state == STATE_ENTITY_STYLUS_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); + } else if (this.state == STATE_ENTITY_LASER_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + } }; this.entityTouchingExit = function() { @@ -2829,6 +2835,12 @@ function MyController(hand) { 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 } + + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); + } else if (this.state == STATE_OVERLAY_LASER_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + } }; this.overlayTouchingExit = function () {