History

Only first laser highlights

David Rowe committed 8 years ago

Commit 403dd3d1 parent 5878e362 files · +107 −2Browse files

Showing the changes to scripts/system/controllers/controllerModules (1 of 2 files). Show all

Unified · Split

scripts/system/controllers/controllerModules/webSurfaceLaserInput.js+43−2
@@ -87,28 +87,69 @@ Script.include("/~/system/libraries/controllers.js"); · 86 unmodified lines
8787 return MyAvatar.getDominantHand() === "right" ? 1 : 0;
8888 };
8989
90+ this.hoverItem = null;
91+
92+ this.isTabletID = function (uuid) {
93+ return [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID, HMD.homeButtonHightlightID].indexOf(uuid) !== -1;
94+ };
95+
9096 this.isReady = function(controllerData) {
9197 var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
9298 && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
9399 if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {
94100 this.updateAllwaysOn();
95101 if (this.parameters.handLaser.allwaysOn || isTriggerPressed) {
102+ var pointingAt = controllerData.rayPicks[this.hand].objectID;
103+ if (this.isTabletID(pointingAt)) {
104+ pointingAt = HMD.tabletID;
105+ }
106+
107+ if (pointingAt !== this.getOtherModule().hoverItem) {
108+ this.hoverItem = pointingAt;
109+ this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
110+ } else {
111+ this.hoverItem = null;
112+ this.getOtherModule().parameters.handLaser.nonHoverItem = null;
113+ }
114+
96115 return makeRunningValues(true, [], []);
97116 }
98117 }
118+
119+ this.hoverItem = null;
120+ this.getOtherModule().parameters.handLaser.nonHoverItem = null;
121+
99122 return makeRunningValues(false, [], []);
100123 };
101124
102125 this.run = function(controllerData, deltaTime) {
103126 var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);
104− if (!grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
105− || this.parameters.handLaser.allwaysOn
127+ var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
128+ if (!grabModuleNeedsToRun && (isTriggerPressed || this.parameters.handLaser.allwaysOn
106129 && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) {
107130 this.running = true;
131+
132+ var pointingAt = controllerData.rayPicks[this.hand].objectID;
133+ if (this.isTabletID(pointingAt)) {
134+ pointingAt = HMD.tabletID;
135+ }
136+
137+ if (pointingAt !== this.getOtherModule().hoverItem || isTriggerPressed) {
138+ this.hoverItem = pointingAt;
139+ this.getOtherModule().parameters.handLaser.nonHoverItem = pointingAt;
140+ } else {
141+ this.hoverItem = null;
142+ this.getOtherModule().parameters.handLaser.nonHoverItem = null;
143+ }
144+
108145 return makeRunningValues(true, [], []);
109146 }
110147 this.deleteContextOverlay();
111148 this.running = false;
149+
150+ this.hoverItem = null;
151+ this.getOtherModule().parameters.handLaser.nonHoverItem = null;
152+
112153 return makeRunningValues(false, [], []);
113154 };
114155 }