History

get ready for highlighting

Seth Alves committed 9 years ago

Commit 327bc231 parent e7437d67 files · +250 −141Browse files

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

Unified · Split

5 files
  1. scripts/system/controllers/controllerModules/farActionGrabEntity.js +24 −13
  2. scripts/system/controllers/controllerModules/nearActionGrabEntity.js +74 −54
  3. scripts/system/controllers/controllerModules/nearParentGrabEntity.js +83 −45
  4. scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +21 −10
  5. scripts/system/controllers/controllerModules/tabletStylusInput.js +13 −6
scripts/system/controllers/controllerModules/farActionGrabEntity.js+24−13
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 /*jslint bitwise: true */
99
1010 /* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND,
11− getGrabPointSphereOffset, entityIsGrabbable,
11+ getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues,
1212 enableDispatcherModule, disableDispatcherModule,
1313 makeDispatcherModuleParameters,
1414 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
@@ -135,8 +135,8 @@ Script.include("/~/system/libraries/controllers.js"); · 120 unmodified lines
135135 };
136136
137137 this.laserPointerOff = function() {
138− var laserPointerID = PICK_WITH_HAND_RAY ? this.laserPointer : this.headLaserPointer;
139− LaserPointers.disableLaserPointer(laserPointerID);
138+ LaserPointers.disableLaserPointer(this.laserPointer);
139+ LaserPointers.disableLaserPointer(this.headLaserPointer);
140140 };
141141
142142
@@ -145,38 +145,49 @@ Script.include("/~/system/libraries/controllers.js"); · 2 unmodified lines
145145 };
146146
147147 this.isReady = function (controllerData) {
148+
148149 if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE) {
149150 this.updateLaserPointer(controllerData, false, false);
150− return true;
151+ return makeRunningValues(true, [], []);
151152 } else {
152− return false;
153+ return makeRunningValues(false, [], []);
153154 }
154155 };
155156
156157 this.run = function (controllerData) {
157158 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE) {
158159 this.laserPointerOff();
159− return false;
160+ return makeRunningValues(false, [], []);
160161 }
161162
163+ // gather up the readiness of the near-grab modules
164+ var nearGrabNames = [
165+ this.hand === RIGHT_HAND ? "RightNearActionGrabEntity" : "LeftNearActionGrabEntity",
166+ this.hand === RIGHT_HAND ? "RightNearParentingGrabEntity" : "LeftNearParentingGrabEntity",
167+ this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay"
168+ ];
169+ var nearGrabReadiness = [];
170+ for (var i = 0; i < nearGrabNames.length; i++) {
171+ var nearGrabModule = getEnabledModuleByName(nearGrabNames[i]);
172+ var ready = nearGrabModule ? nearGrabModule.isReady(controllerData) : makeRunningValues(false, [], []);
173+ nearGrabReadiness.push(ready);
174+ }
162175
163176 // if we are doing a distance search and this controller moves into a position
164177 // where it could near-grab something, stop searching.
165− var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
166− for (var i = 0; i < nearbyEntityProperties.length; i++) {
167− var props = nearbyEntityProperties[i];
168− if (entityIsGrabbable(props)) {
178+ for (var j = 0; j < nearGrabReadiness.length; j++) {
179+ if (nearGrabReadiness[j].active) {
169180 this.laserPointerOff();
170− return false;
181+ return makeRunningValues(false, [], []);
171182 }
172183 }
173−
184+
174185 // this.updateLaserPointer(controllerData, false, false);
175186
176187 // var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
177188 // Entities.callEntityMethod(this.grabbedThingID, "continueFarGrab", args);
178189
179− return true;
190+ return makeRunningValues(true, [], []);
180191 };
181192
182193 this.cleanup = function () {
scripts/system/controllers/controllerModules/nearActionGrabEntity.js+74−54
@@ -8,7 +8,8 @@ · 7 unmodified lines
88 /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
99 getControllerJointIndex, getGrabbableData, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
1010 propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
11− Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters
11+ Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
12+ TRIGGER_OFF_VALUE
1213 */
1314
1415 Script.include("/~/system/controllers/controllerDispatcherUtils.js");
@@ -18,7 +19,7 @@ Script.include("/~/system/libraries/controllers.js"); · 3 unmodified lines
1819
1920 function NearActionGrabEntity(hand) {
2021 this.hand = hand;
21− this.grabbedThingID = null;
22+ this.targetEntityID = null;
2223 this.actionID = null; // action this script created...
2324
2425 this.parameters = makeDispatcherModuleParameters(
@@ -54,10 +55,10 @@ Script.include("/~/system/libraries/controllers.js"); · 29 unmodified lines
5455 };
5556
5657
57− this.startNearGrabAction = function (controllerData, grabbedProperties) {
58+ this.startNearGrabAction = function (controllerData, targetProps) {
5859 Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
5960
60− var grabbableData = getGrabbableData(grabbedProperties);
61+ var grabbableData = getGrabbableData(targetProps);
6162 this.ignoreIK = grabbableData.ignoreIK;
6263 this.kinematicGrab = grabbableData.kinematicGrab;
6364
@@ -74,10 +75,10 @@ Script.include("/~/system/libraries/controllers.js"); · 10 unmodified lines
7475 handPosition = this.getHandPosition();
7576 }
7677
77− var objectRotation = grabbedProperties.rotation;
78+ var objectRotation = targetProps.rotation;
7879 this.offsetRotation = Quat.multiply(Quat.inverse(handRotation), objectRotation);
7980
80− var currentObjectPosition = grabbedProperties.position;
81+ var currentObjectPosition = targetProps.position;
8182 var offset = Vec3.subtract(currentObjectPosition, handPosition);
8283 this.offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, this.offsetRotation)), offset);
8384
@@ -85,9 +86,9 @@ Script.include("/~/system/libraries/controllers.js"); · 1 unmodified line
8586 this.actionTimeout = now + (ACTION_TTL * MSECS_PER_SEC);
8687
8788 if (this.actionID) {
88− Entities.deleteAction(this.grabbedThingID, this.actionID);
89+ Entities.deleteAction(this.targetEntityID, this.actionID);
8990 }
90− this.actionID = Entities.addAction("hold", this.grabbedThingID, {
91+ this.actionID = Entities.addAction("hold", this.targetEntityID, {
9192 hand: this.hand === RIGHT_HAND ? "right" : "left",
9293 timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
9394 relativePosition: this.offsetPosition,
@@ -104,25 +105,17 @@ Script.include("/~/system/libraries/controllers.js"); · 10 unmodified lines
104105
105106 Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
106107 action: 'grab',
107− grabbedEntity: this.grabbedThingID,
108+ grabbedEntity: this.targetEntityID,
108109 joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
109110 }));
110111 };
111112
112− // this is for when the action creation failed, before
113− this.restartNearGrabAction = function (controllerData) {
114− var props = Entities.getEntityProperties(this.grabbedThingID, ["position", "rotation", "userData"]);
115− if (props && entityIsGrabbable(props)) {
116− this.startNearGrabAction(controllerData, props);
117− }
118− };
119−
120113 // this is for when the action is going to time-out
121114 this.refreshNearGrabAction = function (controllerData) {
122115 var now = Date.now();
123116 if (this.actionID && this.actionTimeout - now < ACTION_TTL_REFRESH * MSECS_PER_SEC) {
124117 // if less than a 5 seconds left, refresh the actions ttl
125− var success = Entities.updateAction(this.grabbedThingID, this.actionID, {
118+ var success = Entities.updateAction(this.targetEntityID, this.actionID, {
126119 hand: this.hand === RIGHT_HAND ? "right" : "left",
127120 timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
128121 relativePosition: this.offsetPosition,
@@ -134,74 +127,101 @@ Script.include("/~/system/libraries/controllers.js"); · 5 unmodified lines
134127 });
135128 if (success) {
136129 this.actionTimeout = now + (ACTION_TTL * MSECS_PER_SEC);
137− } else {
138− print("continueNearGrabbing -- updateAction failed");
139− this.restartNearGrabAction(controllerData);
140130 }
141131 }
142132 };
143133
144− this.endNearGrabAction = function (controllerData) {
134+ this.endNearGrabAction = function () {
145135 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
146− Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args);
136+ Entities.callEntityMethod(this.targetEntityID, "releaseGrab", args);
147137
148− Entities.deleteAction(this.grabbedThingID, this.actionID);
138+ Entities.deleteAction(this.targetEntityID, this.actionID);
149139 this.actionID = null;
150140
151− this.grabbedThingID = null;
141+ this.targetEntityID = null;
152142 };
153143
154− this.isReady = function (controllerData) {
155− if (controllerData.triggerClicks[this.hand] == 0) {
156− return false;
157− }
158−
159− var grabbedProperties = null;
160− // nearbyEntityProperties is already sorted by length from controller
144+ this.getTargetProps = function (controllerData) {
145+ // nearbyEntityProperties is already sorted by distance from controller
161146 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
162147 for (var i = 0; i < nearbyEntityProperties.length; i++) {
163148 var props = nearbyEntityProperties[i];
164149 if (entityIsGrabbable(props)) {
165− grabbedProperties = props;
166− break;
150+ return props;
167151 }
168152 }
153+ return null;
154+ };
155+
156+ this.isReady = function (controllerData) {
157+ this.targetEntityID = null;
169158
170− if (grabbedProperties) {
171− if (!propsArePhysical(grabbedProperties)) {
172− return false; // let nearParentGrabEntity handle it
159+ if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE) {
160+ makeRunningValues(false, [], []);
161+ }
162+
163+ var targetProps = this.getTargetProps(controllerData);
164+ if (targetProps) {
165+ if (!propsArePhysical(targetProps)) {
166+ // XXX make sure no highlights are enabled from this module
167+ return makeRunningValues(false, [], []); // let nearParentGrabEntity handle it
168+ } else {
169+ this.targetEntityID = targetProps.id;
170+ // XXX highlight this.targetEntityID here
171+ return makeRunningValues(true, [this.targetEntityID], []);
173172 }
174− this.grabbedThingID = grabbedProperties.id;
175− this.startNearGrabAction(controllerData, grabbedProperties);
176− return true;
177173 } else {
178− return false;
174+ // XXX make sure no highlights are enabled from this module
175+ return makeRunningValues(false, [], []);
179176 }
180177 };
181178
182179 this.run = function (controllerData) {
183− if (controllerData.triggerClicks[this.hand] == 0) {
184− this.endNearGrabAction(controllerData);
185− return false;
186− }
180+ if (this.actionID) {
181+ if (controllerData.triggerClicks[this.hand] == 0) {
182+ this.endNearGrabAction();
183+ return makeRunningValues(false, [], []);
184+ }
187185
188− if (!this.actionID) {
189− this.restartNearGrabAction(controllerData);
190− }
186+ this.refreshNearGrabAction(controllerData);
191187
192− this.refreshNearGrabAction(controllerData);
188+ var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
189+ Entities.callEntityMethod(this.targetEntityID, "continueNearGrab", args);
190+ } else {
191+ // still searching / highlighting
192+ var readiness = this.isReady (controllerData);
193+ if (!readiness.active) {
194+ return readiness;
195+ }
196+ if (controllerData.triggerClicks[this.hand] == 1) {
197+ // stop highlighting, switch to grabbing
198+ // XXX stop highlight here
199+ var targetProps = this.getTargetProps(controllerData);
200+ if (targetProps) {
201+ this.startNearGrabAction(controllerData, targetProps);
202+ }
203+ }
204+ }
193205
194− var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
195− Entities.callEntityMethod(this.grabbedThingID, "continueNearGrab", args);
206+ return makeRunningValues(true, [this.targetEntityID], []);
207+ };
196208
197− return true;
209+ this.cleanup = function () {
210+ if (this.targetEntityID) {
211+ this.endNearGrabAction();
212+ }
198213 };
199214 }
200215
201− enableDispatcherModule("LeftNearActionGrabEntity", new NearActionGrabEntity(LEFT_HAND));
202− enableDispatcherModule("RightNearActionGrabEntity", new NearActionGrabEntity(RIGHT_HAND));
216+ var leftNearActionGrabEntity = new NearActionGrabEntity(LEFT_HAND);
217+ var rightNearActionGrabEntity = new NearActionGrabEntity(RIGHT_HAND);
218+
219+ enableDispatcherModule("LeftNearActionGrabEntity", leftNearActionGrabEntity);
220+ enableDispatcherModule("RightNearActionGrabEntity", rightNearActionGrabEntity);
203221
204222 this.cleanup = function () {
223+ leftNearActionGrabEntity.cleanup();
224+ rightNearActionGrabEntity.cleanup();
205225 disableDispatcherModule("LeftNearActionGrabEntity");
206226 disableDispatcherModule("RightNearActionGrabEntity");
207227 };
scripts/system/controllers/controllerModules/nearParentGrabEntity.js+83−45
@@ -8,8 +8,8 @@ · 7 unmodified lines
88
99 /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,
1010 getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
11− propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
12− makeDispatcherModuleParameters, entityIsGrabbable
11+ propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,
12+ makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues
1313 */
1414
1515 Script.include("/~/system/controllers/controllerDispatcherUtils.js");
@@ -21,7 +21,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 5 unmodified lines
2121
2222 function NearParentingGrabEntity(hand) {
2323 this.hand = hand;
24− this.grabbedThingID = null;
24+ this.targetEntityID = null;
25+ this.grabbing = false;
2526 this.previousParentID = {};
2627 this.previousParentJointIndex = {};
2728 this.previouslyUnhooked = {};
@@ -62,7 +63,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 34 unmodified lines
6263 return false;
6364 };
6465
65− this.startNearParentingGrabEntity = function (controllerData, grabbedProperties) {
66+ this.startNearParentingGrabEntity = function (controllerData, targetProps) {
6667 Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
6768
6869 var handJointIndex;
@@ -74,7 +75,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 5 unmodified lines
7475 handJointIndex = this.controllerJointIndex;
7576
7677 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
77− Entities.callEntityMethod(this.grabbedThingID, "startNearGrab", args);
78+ Entities.callEntityMethod(targetProps.id, "startNearGrab", args);
7879
7980 var reparentProps = {
8081 parentID: AVATAR_SELF_ID,
@@ -83,90 +84,127 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 2 unmodified lines
8384 angularVelocity: {x: 0, y: 0, z: 0}
8485 };
8586
86− if (this.thisHandIsParent(grabbedProperties)) {
87+ if (this.thisHandIsParent(targetProps)) {
8788 // this should never happen, but if it does, don't set previous parent to be this hand.
88− // this.previousParentID[this.grabbedThingID] = NULL;
89− // this.previousParentJointIndex[this.grabbedThingID] = -1;
89+ // this.previousParentID[targetProps.id] = NULL;
90+ // this.previousParentJointIndex[targetProps.id] = -1;
9091 } else {
91− this.previousParentID[this.grabbedThingID] = grabbedProperties.parentID;
92− this.previousParentJointIndex[this.grabbedThingID] = grabbedProperties.parentJointIndex;
92+ this.previousParentID[targetProps.id] = targetProps.parentID;
93+ this.previousParentJointIndex[targetProps.id] = targetProps.parentJointIndex;
9394 }
94− Entities.editEntity(this.grabbedThingID, reparentProps);
95+ Entities.editEntity(targetProps.id, reparentProps);
9596
9697 Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
9798 action: 'grab',
98− grabbedEntity: this.grabbedThingID,
99+ grabbedEntity: targetProps.id,
99100 joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
100101 }));
101102 };
102103
103− this.endNearParentingGrabEntity = function (controllerData) {
104− if (this.previousParentID[this.grabbedThingID] === NULL_UUID) {
105− Entities.editEntity(this.grabbedThingID, {
106− parentID: this.previousParentID[this.grabbedThingID],
107− parentJointIndex: this.previousParentJointIndex[this.grabbedThingID]
104+ this.endNearParentingGrabEntity = function () {
105+ if (this.previousParentID[this.targetEntityID] === NULL_UUID) {
106+ Entities.editEntity(this.targetEntityID, {
107+ parentID: this.previousParentID[this.targetEntityID],
108+ parentJointIndex: this.previousParentJointIndex[this.targetEntityID]
108109 });
109110 } else {
110111 // we're putting this back as a child of some other parent, so zero its velocity
111− Entities.editEntity(this.grabbedThingID, {
112− parentID: this.previousParentID[this.grabbedThingID],
113− parentJointIndex: this.previousParentJointIndex[this.grabbedThingID],
112+ Entities.editEntity(this.targetEntityID, {
113+ parentID: this.previousParentID[this.targetEntityID],
114+ parentJointIndex: this.previousParentJointIndex[this.targetEntityID],
114115 velocity: {x: 0, y: 0, z: 0},
115116 angularVelocity: {x: 0, y: 0, z: 0}
116117 });
117118 }
118119
119120 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
120− Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args);
121+ Entities.callEntityMethod(this.targetEntityID, "releaseGrab", args);
121122
122− this.grabbedThingID = null;
123+ this.grabbing = false;
124+ this.targetEntityID = null;
123125 };
124126
125− this.isReady = function (controllerData) {
126− if (controllerData.triggerClicks[this.hand] == 0) {
127− return false;
128− }
129−
130− var grabbedProperties = null;
127+ this.getTargetProps = function (controllerData) {
131128 // nearbyEntityProperties is already sorted by length from controller
132129 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
133130 for (var i = 0; i < nearbyEntityProperties.length; i++) {
134131 var props = nearbyEntityProperties[i];
135132 if (entityIsGrabbable(props)) {
136− grabbedProperties = props;
137− break;
133+ return props;
138134 }
139135 }
136+ return null;
137+ };
140138
141− if (grabbedProperties) {
142− if (propsArePhysical(grabbedProperties)) {
143− return false; // let nearActionGrabEntity handle it
139+ this.isReady = function (controllerData) {
140+ this.targetEntityID = null;
141+ this.grabbing = false;
142+
143+ if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE) {
144+ makeRunningValues(false, [], []);
145+ }
146+
147+ var targetProps = this.getTargetProps(controllerData);
148+ if (targetProps) {
149+ if (propsArePhysical(targetProps)) {
150+ // XXX make sure no highlights are enabled from this module
151+ return makeRunningValues(false, [], []); // let nearActionGrabEntity handle it
152+ } else {
153+ this.targetEntityID = targetProps.id;
154+ // XXX highlight this.targetEntityID here
155+ return makeRunningValues(true, [this.targetEntityID], []);
144156 }
145− this.grabbedThingID = grabbedProperties.id;
146− this.startNearParentingGrabEntity(controllerData, grabbedProperties);
147− return true;
148157 } else {
149− return false;
158+ // XXX make sure no highlights are enabled from this module
159+ return makeRunningValues(false, [], []);
150160 }
151161 };
152162
153163 this.run = function (controllerData) {
154− if (controllerData.triggerClicks[this.hand] == 0) {
155− this.endNearParentingGrabEntity(controllerData);
156− return false;
164+ if (this.grabbing) {
165+ if (controllerData.triggerClicks[this.hand] == 0) {
166+ this.endNearParentingGrabEntity();
167+ return makeRunningValues(false, [], []);
168+ }
169+
170+ var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
171+ Entities.callEntityMethod(this.targetEntityID, "continueNearGrab", args);
172+ } else {
173+ // still searching / highlighting
174+ var readiness = this.isReady (controllerData);
175+ if (!readiness.active) {
176+ return readiness;
177+ }
178+ if (controllerData.triggerClicks[this.hand] == 1) {
179+ // stop highlighting, switch to grabbing
180+ // XXX stop highlight here
181+ var targetProps = this.getTargetProps(controllerData);
182+ if (targetProps) {
183+ this.grabbing = true;
184+ this.startNearParentingGrabEntity(controllerData, targetProps);
185+ }
186+ }
157187 }
158188
159− var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
160− Entities.callEntityMethod(this.grabbedThingID, "continueNearGrab", args);
189+ return makeRunningValues(true, [this.targetEntityID], []);
190+ };
161191
162− return true;
192+ this.cleanup = function () {
193+ if (this.targetEntityID) {
194+ this.endNearParentingGrabEntity();
195+ }
163196 };
164197 }
165198
166− enableDispatcherModule("LeftNearParentingGrabEntity", new NearParentingGrabEntity(LEFT_HAND));
167− enableDispatcherModule("RightNearParentingGrabEntity", new NearParentingGrabEntity(RIGHT_HAND));
199+ var leftNearParentingGrabEntity = new NearParentingGrabEntity(LEFT_HAND);
200+ var rightNearParentingGrabEntity = new NearParentingGrabEntity(RIGHT_HAND);
201+
202+ enableDispatcherModule("LeftNearParentingGrabEntity", leftNearParentingGrabEntity);
203+ enableDispatcherModule("RightNearParentingGrabEntity", rightNearParentingGrabEntity);
168204
169205 this.cleanup = function () {
206+ leftNearParentingGrabEntity.cleanup();
207+ rightNearParentingGrabEntity.cleanup();
170208 disableDispatcherModule("LeftNearParentingGrabEntity");
171209 disableDispatcherModule("RightNearParentingGrabEntity");
172210 };
scripts/system/controllers/controllerModules/nearParentGrabOverlay.js+21−10
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 /* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,
1010 getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
1111 Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
12− makeDispatcherModuleParameters, Overlays
12+ makeDispatcherModuleParameters, Overlays, makeRunningValues
1313 */
1414
1515 Script.include("/~/system/controllers/controllerDispatcherUtils.js");
@@ -106,7 +106,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 90 unmodified lines
106106 }));
107107 };
108108
109− this.endNearParentingGrabOverlay = function (controllerData) {
109+ this.endNearParentingGrabOverlay = function () {
110110 if (this.previousParentID[this.grabbedThingID] === NULL_UUID) {
111111 Overlays.editOverlay(this.grabbedThingID, {
112112 parentID: NULL_UUID,
@@ -125,7 +125,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 12 unmodified lines
125125
126126 this.isReady = function (controllerData) {
127127 if (controllerData.triggerClicks[this.hand] == 0) {
128− return false;
128+ return makeRunningValues(false, [], []);
129129 }
130130
131131 this.grabbedThingID = null;
@@ -138,26 +138,37 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js"); · 6 unmodified lines
138138 if (grabbableOverlays.length > 0) {
139139 this.grabbedThingID = grabbableOverlays[0];
140140 this.startNearParentingGrabOverlay(controllerData);
141− return true;
141+ return makeRunningValues(true, [this.grabbedThingID], []);
142142 } else {
143− return false;
143+ return makeRunningValues(false, [], []);
144144 }
145145 };
146146
147147 this.run = function (controllerData) {
148148 if (controllerData.triggerClicks[this.hand] == 0) {
149− this.endNearParentingGrabOverlay(controllerData);
150− return false;
149+ this.endNearParentingGrabOverlay();
150+ return makeRunningValues(false, [], []);
151151 } else {
152− return true;
152+ return makeRunningValues(true, [this.grabbedThingID], []);
153+ }
154+ };
155+
156+ this.cleanup = function () {
157+ if (this.grabbedThingID) {
158+ this.endNearParentingGrabOverlay();
153159 }
154160 };
155161 }
156162
157− enableDispatcherModule("LeftNearParentingGrabOverlay", new NearParentingGrabOverlay(LEFT_HAND));
158− enableDispatcherModule("RightNearParentingGrabOverlay", new NearParentingGrabOverlay(RIGHT_HAND));
163+ var leftNearParentingGrabOverlay = new NearParentingGrabOverlay(LEFT_HAND);
164+ var rightNearParentingGrabOverlay = new NearParentingGrabOverlay(RIGHT_HAND);
165+
166+ enableDispatcherModule("LeftNearParentingGrabOverlay", leftNearParentingGrabOverlay);
167+ enableDispatcherModule("RightNearParentingGrabOverlay", rightNearParentingGrabOverlay);
159168
160169 this.cleanup = function () {
170+ leftNearParentingGrabOverlay.cleanup();
171+ rightNearParentingGrabOverlay.cleanup();
161172 disableDispatcherModule("LeftNearParentingGrabOverlay");
162173 disableDispatcherModule("RightNearParentingGrabOverlay");
163174 };
scripts/system/controllers/controllerModules/tabletStylusInput.js+13−6
@@ -6,7 +6,7 @@ · 5 unmodified lines
66 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
77
88 /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
9− NULL_UUID, enableDispatcherModule, disableDispatcherModule,
9+ NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues,
1010 Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,
1111 AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset
1212 */
@@ -643,7 +643,11 @@ Script.include("/~/system/libraries/controllers.js"); · 630 unmodified lines
643643 };
644644
645645 this.isReady = function (controllerData) {
646− return this.processStylus(controllerData);
646+ if (this.processStylus(controllerData)) {
647+ return makeRunningValues(true, [], []);
648+ } else {
649+ return makeRunningValues(false, [], []);
650+ }
647651 };
648652
649653 this.run = function (controllerData, deltaTime) {
@@ -660,7 +664,11 @@ Script.include("/~/system/libraries/controllers.js"); · 10 unmodified lines
660664 if (this.stylusTouchingTarget) {
661665 this.stylusTouching(controllerData, deltaTime);
662666 }
663− return this.processStylus(controllerData);
667+ if (this.processStylus(controllerData)) {
668+ return makeRunningValues(true, [], []);
669+ } else {
670+ return makeRunningValues(false, [], []);
671+ }
664672 };
665673
666674 this.cleanup = function () {
@@ -674,12 +682,11 @@ Script.include("/~/system/libraries/controllers.js"); · 7 unmodified lines
674682 enableDispatcherModule("LeftTabletStylusInput", leftTabletStylusInput);
675683 enableDispatcherModule("RightTabletStylusInput", rightTabletStylusInput);
676684
677−
678685 this.cleanup = function () {
679− disableDispatcherModule("LeftTabletStylusInput");
680− disableDispatcherModule("RightTabletStylusInput");
681686 leftTabletStylusInput.cleanup();
682687 rightTabletStylusInput.cleanup();
688+ disableDispatcherModule("LeftTabletStylusInput");
689+ disableDispatcherModule("RightTabletStylusInput");
683690 };
684691 Script.scriptEnding.connect(this.cleanup);
685692 }());

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t