From 1ba6bfa2e010a06a702a91b0b99dba1ec74ae2dc Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 30 Nov 2015 18:58:53 -0800 Subject: [PATCH] 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) {