From 1f92b57bf257d1b1beef79cc60d2a36d78722e7c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 18 Jan 2017 10:46:18 -0800 Subject: [PATCH 1/2] switch to model stylus --- .../system/controllers/handControllerGrab.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index ca5bc08c7e..bd3042b1da 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -65,7 +65,8 @@ var WEB_STYLUS_COLOR = { red: 0, green: 240, blue: 0 }; var WEB_STYLUS_TIP_COLOR = { red: 0, green: 0, blue: 240 }; var WEB_STYLUS_ALPHA = 1.0; var WEB_DISPLAY_STYLUS_DISTANCE = 0.5; -var WEB_TOUCH_DISTANCE = 0.2; +var WEB_STYLUS_LENGTH = 0.2; +var WEB_TOUCH_Y_OFFSET = 0.05; // how far forward (or back with a negative number) to slide stylus in hand // // distant manipulation @@ -958,11 +959,13 @@ function MyController(hand) { var stylusProperties = { // url: Script.resourcesPath() + "meshes/tablet-stylus-skinny.fbx", url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", - localPosition: Vec3.sum({ x: 0.0, y: WEB_TOUCH_DISTANCE / 2.0, z: 0.0 }, + localPosition: Vec3.sum({ x: 0.0, + y: WEB_TOUCH_Y_OFFSET, + z: 0.0 }, getGrabPointSphereOffset(this.handToController())), // localRotation: { x: 0, y: 0, z: 0, w: 1 }, localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }), - // dimensions: { x: 0.01, y: WEB_TOUCH_DISTANCE - WEB_TOUCH_SPHERE_RADIUS, z: 0.01 }, + dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }, solid: true, visible: true, ignoreRayIntersection: true, @@ -984,7 +987,7 @@ function MyController(hand) { return; } var stylusTipProperties = { - localPosition: Vec3.sum({ x: 0, y: WEB_TOUCH_DISTANCE - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 }, + localPosition: Vec3.sum({ x: 0, y: WEB_STYLUS_LENGTH - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 }, getGrabPointSphereOffset(this.handToController())), localRotation: { x: 0, y: 0, z: 0, w: 1 }, dimensions: WEB_TOUCH_SPHERE_RADIUS, @@ -1002,10 +1005,10 @@ function MyController(hand) { this.stylusTip = Overlays.addOverlay("sphere", stylusTipProperties); var stylusProperties = { - localPosition: Vec3.sum({ x: 0.0, y: WEB_TOUCH_DISTANCE / 2.0, z: 0.0 }, + localPosition: Vec3.sum({ x: 0.0, y: WEB_STYLUS_LENGTH / 2.0, z: 0.0 }, getGrabPointSphereOffset(this.handToController())), localRotation: { x: 0, y: 0, z: 0, w: 1 }, - dimensions: { x: 0.01, y: WEB_TOUCH_DISTANCE - WEB_TOUCH_SPHERE_RADIUS, z: 0.01 }, + dimensions: { x: 0.01, y: WEB_STYLUS_LENGTH + WEB_TOUCH_SPHERE_RADIUS, z: 0.01 }, color: WEB_STYLUS_COLOR, alpha: WEB_STYLUS_ALPHA, solid: true, @@ -1021,8 +1024,8 @@ function MyController(hand) { }; this.showStylus = function() { - return this.showPrimStylus(); - // return this.showModelStylus(); + // return this.showPrimStylus(); + return this.showModelStylus(); }; this.hideStylus = function() { @@ -1263,7 +1266,7 @@ function MyController(hand) { if (nearWeb) { this.showStylus(); var rayPickInfo = this.calcRayPickInfo(this.hand); - if (rayPickInfo.distance < WEB_TOUCH_DISTANCE) { + if (rayPickInfo.distance < WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { if (this.handleStylusOnWebEntity(rayPickInfo)) { return; } @@ -1662,7 +1665,7 @@ function MyController(hand) { } } - if (rayPickInfo.distance >= WEB_TOUCH_DISTANCE) { + if (rayPickInfo.distance >= WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { if (this.handleLaserOnWebEntity(rayPickInfo)) { return; } @@ -2761,7 +2764,8 @@ function MyController(hand) { getControllerWorldLocation(this.handToController(), true)); if (intersectInfo) { - if (this.state == STATE_ENTITY_STYLUS_TOUCHING && intersectInfo.distance > WEB_TOUCH_DISTANCE) { + if (this.state == STATE_ENTITY_STYLUS_TOUCHING && + intersectInfo.distance > WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { this.grabbedEntity = null; this.setState(STATE_OFF, "pulled away from web entity"); return; @@ -2879,7 +2883,8 @@ function MyController(hand) { handLaserIntersectOverlay(this.grabbedOverlay, getControllerWorldLocation(this.handToController(), true)); if (intersectInfo) { - if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && intersectInfo.distance > WEB_TOUCH_DISTANCE) { + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && + intersectInfo.distance > WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET) { this.grabbedEntity = null; this.setState(STATE_OFF, "pulled away from overlay"); return; From a8038ce64ef90b05a276bb6cfb6b051af6b7091c Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 18 Jan 2017 10:50:02 -0800 Subject: [PATCH 2/2] cleanups --- .../system/controllers/handControllerGrab.js | 56 +------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index bd3042b1da..b9b5b5f7a8 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -948,7 +948,7 @@ function MyController(hand) { } }; - this.showModelStylus = function() { + this.showStylus = function() { if (this.stylus) { return; } @@ -957,15 +957,13 @@ function MyController(hand) { } var stylusProperties = { - // url: Script.resourcesPath() + "meshes/tablet-stylus-skinny.fbx", url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", localPosition: Vec3.sum({ x: 0.0, y: WEB_TOUCH_Y_OFFSET, z: 0.0 }, getGrabPointSphereOffset(this.handToController())), - // localRotation: { x: 0, y: 0, z: 0, w: 1 }, localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }), - dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }, + dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }, solid: true, visible: true, ignoreRayIntersection: true, @@ -978,56 +976,6 @@ function MyController(hand) { this.stylus = Overlays.addOverlay("model", stylusProperties); }; - - this.showPrimStylus = function() { - if (this.stylus) { - return; - } - if (!MyAvatar.sessionUUID) { - return; - } - var stylusTipProperties = { - localPosition: Vec3.sum({ x: 0, y: WEB_STYLUS_LENGTH - (WEB_TOUCH_SPHERE_RADIUS / 2.0), z: 0 }, - getGrabPointSphereOffset(this.handToController())), - localRotation: { x: 0, y: 0, z: 0, w: 1 }, - dimensions: WEB_TOUCH_SPHERE_RADIUS, - color: WEB_STYLUS_TIP_COLOR, - alpha: WEB_STYLUS_ALPHA, - solid: true, - visible: true, - ignoreRayIntersection: true, - drawInFront: false, - parentID: MyAvatar.sessionUUID, - parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? - "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : - "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") - }; - this.stylusTip = Overlays.addOverlay("sphere", stylusTipProperties); - - var stylusProperties = { - localPosition: Vec3.sum({ x: 0.0, y: WEB_STYLUS_LENGTH / 2.0, z: 0.0 }, - getGrabPointSphereOffset(this.handToController())), - localRotation: { x: 0, y: 0, z: 0, w: 1 }, - dimensions: { x: 0.01, y: WEB_STYLUS_LENGTH + WEB_TOUCH_SPHERE_RADIUS, z: 0.01 }, - color: WEB_STYLUS_COLOR, - alpha: WEB_STYLUS_ALPHA, - solid: true, - visible: true, - ignoreRayIntersection: true, - drawInFront: false, - parentID: MyAvatar.sessionUUID, - parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? - "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : - "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") - }; - this.stylus = Overlays.addOverlay("cube", stylusProperties); - }; - - this.showStylus = function() { - // return this.showPrimStylus(); - return this.showModelStylus(); - }; - this.hideStylus = function() { if (!this.stylus) { return;