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
87 return MyAvatar.getDominantHand() === "right" ? 1 : 0;87 return MyAvatar.getDominantHand() === "right" ? 1 : 0;
88 };88 };
89 89
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
90 this.isReady = function(controllerData) {96 this.isReady = function(controllerData) {
91 var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE97 var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE
92 && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;98 && controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
93 if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {99 if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {
94 this.updateAllwaysOn();100 this.updateAllwaysOn();
95 if (this.parameters.handLaser.allwaysOn || isTriggerPressed) {101 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
96 return makeRunningValues(true, [], []);115 return makeRunningValues(true, [], []);
97 }116 }
98 }117 }
118
119 this.hoverItem = null;
120 this.getOtherModule().parameters.handLaser.nonHoverItem = null;
121
99 return makeRunningValues(false, [], []);122 return makeRunningValues(false, [], []);
100 };123 };
101 124
102 this.run = function(controllerData, deltaTime) {125 this.run = function(controllerData, deltaTime) {
103 var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);126 var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);
104 if (!grabModuleNeedsToRun && (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE127 var isTriggerPressed = controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE;
105 || this.parameters.handLaser.allwaysOn128 if (!grabModuleNeedsToRun && (isTriggerPressed || this.parameters.handLaser.allwaysOn
106 && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) {129 && (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)))) {
107 this.running = true;130 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
108 return makeRunningValues(true, [], []);145 return makeRunningValues(true, [], []);
109 }146 }
110 this.deleteContextOverlay();147 this.deleteContextOverlay();
111 this.running = false;148 this.running = false;
149
150 this.hoverItem = null;
151 this.getOtherModule().parameters.handLaser.nonHoverItem = null;
152
112 return makeRunningValues(false, [], []);153 return makeRunningValues(false, [], []);
113 };154 };
114 }155 }