From b5ec79fd6db48c5317759a7f355173e1873349ea Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 23 Feb 2016 09:53:20 -0800 Subject: [PATCH] marker only draws when equipped and held down --- .../whiteboardV2/markerEntityScript.js | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/homeContent/whiteboardV2/markerEntityScript.js b/examples/homeContent/whiteboardV2/markerEntityScript.js index 155077af9c..d19e09bb34 100644 --- a/examples/homeContent/whiteboardV2/markerEntityScript.js +++ b/examples/homeContent/whiteboardV2/markerEntityScript.js @@ -13,9 +13,12 @@ (function() { Script.include("../../libraries/utils.js"); - + var TRIGGER_CONTROLS = [ + Controller.Standard.LT, + Controller.Standard.RT, + ]; var MAX_POINTS_PER_STROKE = 40; -var _this; + var _this; MarkerTip = function() { _this = this; _this.MARKER_TEXTURE_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/textures/markerStroke.png"; @@ -30,21 +33,25 @@ var _this; MarkerTip.prototype = { - continueNearGrab: function() { - - _this.continueHolding(); + startEquip: function(id, params) { + _this.equipped = true; + _this.hand = params[0] == "left" ? 0 : 1; }, - continueEquip: function() { - _this.continueHolding(); + this.triggerValue = Controller.getValue(TRIGGER_CONTROLS[_this.hand]); + if (_this.triggerValue > 0.2) { + print("EBL PAINZT"); + _this.continueHolding(); + } else { + _this.currentStroke = null; + } }, + continueHolding: function() { // cast a ray from marker and see if it hits anything - var markerProps = Entities.getEntityProperties(_this.entityID, ["position", "rotation"]); - var pickRay = { origin: markerProps.position, direction: Quat.getFront(markerProps.rotation) @@ -87,7 +94,7 @@ var _this; if (_this.oldPosition) { basePosition = _this.oldPosition; } - _this.newStroke(basePosition); + _this.newStroke(basePosition); } var localPoint = Vec3.subtract(basePosition, this.strokeBasePosition); @@ -95,7 +102,7 @@ var _this; // _this.strokeForwardOffset += _this.STROKE_FORWARD_OFFSET_INCRERMENT; if (_this.linePoints.length > 0) { - var distance = Vec3.distance(localPoint, _this.linePoints[_this.linePoints.length-1]); + var distance = Vec3.distance(localPoint, _this.linePoints[_this.linePoints.length - 1]); if (distance < _this.MIN_DISTANCE_BETWEEN_POINTS) { return; } @@ -119,7 +126,7 @@ var _this; preload: function(entityID) { this.entityID = entityID; - + }, setProperties: function(myId, data) {