From 1ba6bfa2e010a06a702a91b0b99dba1ec74ae2dc Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 30 Nov 2015 18:58:53 -0800 Subject: [PATCH 1/3] lazers --- examples/controllers/handControllerGrab.js | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 0812dc8980..28e52e0dee 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -318,6 +318,34 @@ function MyController(hand) { }); } + this.overlayLineOn = function(color) { + + var handPosition = this.getHandPosition(); + var distantPickRay = { + origin: handPosition, + direction: Quat.getUp(this.getHandRotation()), + length: PICK_MAX_DISTANCE + }; + + var end = Vec3.Sum(handPosition, Vec3.multiply(distantPickRay.direction, NEAR_PICK_MAX_DISTANCE)); + + var lineProperties = { + lineWidth: 5, + //get palm position + start: distantPickRay.origin, + end: end, + color: color || { + red: 255, + green: 0, + blue: 255 + }, + ignoreRayIntersection: true, // always ignore this + visible: true, + }; + + this.pointerOverlay = Overlays.addOverlay("line3d", lineProperties); + } + this.lineOn = function(closePoint, farPoint, color) { // draw a line if (this.pointer === null) { From 25422084b9eec57b00fd2a98688ef8d5f30ed901 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 1 Dec 2015 13:02:40 -0800 Subject: [PATCH 2/3] make it so that only you can see your beams until youre grabbing something --- examples/controllers/handControllerGrab.js | 67 ++++++++++++++-------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 28e52e0dee..703ac8dffd 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -200,6 +200,7 @@ function entityIsGrabbedByOther(entityID) { return false; } + function MyController(hand) { this.hand = hand; if (this.hand === RIGHT_HAND) { @@ -223,6 +224,8 @@ function MyController(hand) { this.rawTriggerValue = 0; this.rawBumperValue = 0; + this.overlayLine = null; + this.offsetPosition = { x: 0.0, y: 0.0, @@ -318,32 +321,35 @@ function MyController(hand) { }); } - this.overlayLineOn = function(color) { + this.overlayLineOn = function(closePoint, farPoint, color) { + if (this.overlayLine === null) { + print('creating handline') - var handPosition = this.getHandPosition(); - var distantPickRay = { - origin: handPosition, - direction: Quat.getUp(this.getHandRotation()), - length: PICK_MAX_DISTANCE - }; + var lineProperties = { + lineWidth: 5, + start: closePoint, + end: farPoint, + color: color, + ignoreRayIntersection: true, // always ignore this + visible: true, + alpha: 1 + }; - var end = Vec3.Sum(handPosition, Vec3.multiply(distantPickRay.direction, NEAR_PICK_MAX_DISTANCE)); + this.overlayLine = Overlays.addOverlay("line3d", lineProperties); - var lineProperties = { - lineWidth: 5, - //get palm position - start: distantPickRay.origin, - end: end, - color: color || { - red: 255, - green: 0, - blue: 255 - }, - ignoreRayIntersection: true, // always ignore this - visible: true, - }; + } else { + print('editing handline' + this.overlayLine) + var success = Overlays.editOverlay(this.overlayLine, { + lineWidth: 5, + start: closePoint, + end: farPoint, + color: color, + visible: true, + ignoreRayIntersection: true, // always ignore this + alpha: 1 + }); + } - this.pointerOverlay = Overlays.addOverlay("line3d", lineProperties); } this.lineOn = function(closePoint, farPoint, color) { @@ -384,6 +390,13 @@ function MyController(hand) { this.pointer = null; }; + this.overlayLineOff = function() { + if (this.overlayLine !== null) { + Overlays.deleteOverlay(this.overlayLine); + } + this.overlayLine = null; + }; + this.triggerPress = function(value) { _this.rawTriggerValue = value; }; @@ -626,7 +639,8 @@ function MyController(hand) { } } - this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); + //this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); + this.overlayLineOn(distantPickRay.origin, Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH)), NO_INTERSECT_COLOR); }; this.distanceHolding = function() { @@ -672,6 +686,9 @@ function MyController(hand) { this.currentAvatarPosition = MyAvatar.position; this.currentAvatarOrientation = MyAvatar.orientation; + this.overlayLineOff(); + + }; this.continueDistanceHolding = function() { @@ -779,6 +796,7 @@ function MyController(hand) { } this.lineOff(); + this.overlayLineOff(); var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES); this.activateEntity(this.grabbedEntity, grabbedProperties); @@ -918,6 +936,7 @@ function MyController(hand) { this.pullTowardEquipPosition = function() { this.lineOff(); + this.overlayLineOff(); var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES); var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA); @@ -1121,7 +1140,7 @@ function MyController(hand) { this.release = function() { this.lineOff(); - + this.overlayLineOff(); if (this.grabbedEntity !== null) { if (this.actionID !== null) { Entities.deleteAction(this.grabbedEntity, this.actionID); From 31d2f6463f262998c504565829b69ee3e5aa2a6a Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 1 Dec 2015 13:03:51 -0800 Subject: [PATCH 3/3] cleanup --- examples/controllers/handControllerGrab.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 703ac8dffd..6bf18d154f 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -323,8 +323,6 @@ function MyController(hand) { this.overlayLineOn = function(closePoint, farPoint, color) { if (this.overlayLine === null) { - print('creating handline') - var lineProperties = { lineWidth: 5, start: closePoint, @@ -338,7 +336,6 @@ function MyController(hand) { this.overlayLine = Overlays.addOverlay("line3d", lineProperties); } else { - print('editing handline' + this.overlayLine) var success = Overlays.editOverlay(this.overlayLine, { lineWidth: 5, start: closePoint, @@ -349,7 +346,6 @@ function MyController(hand) { alpha: 1 }); } - } this.lineOn = function(closePoint, farPoint, color) {