History

Merge branch 'master' into vr-edit-a

David Rowe committed 9 years ago

Commit c56fda82 parents e788f69 a889ca180 files · +1247 −724Browse files

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

Unified · Split

14 files
  1. scripts/system/controllers/controllerModules/disableOtherModule.js +9 −10
  2. scripts/system/controllers/controllerModules/equipEntity.js +2 −5
  3. scripts/system/controllers/controllerModules/farActionGrabEntity.js +19 −11
  4. scripts/system/controllers/controllerModules/farTrigger.js +4 −8
  5. scripts/system/controllers/controllerModules/inEditMode.js +7 −8
  6. scripts/system/controllers/controllerModules/nearActionGrabEntity.js +9 −4
  7. scripts/system/controllers/controllerModules/nearParentGrabEntity.js +10 −8
  8. scripts/system/controllers/controllerModules/nearParentGrabOverlay.js +17 −6
  9. scripts/system/controllers/controllerModules/nearTrigger.js +5 −5
  10. scripts/system/controllers/controllerModules/overlayLaserInput.js +6 −8
  11. scripts/system/controllers/controllerModules/scaleAvatar.js +5 −5
  12. scripts/system/controllers/controllerModules/tabletStylusInput.js +25 −17
  13. scripts/system/controllers/controllerModules/teleport.js +45 −17
  14. scripts/system/controllers/controllerModules/webEntityLaserInput.js +4 −7
scripts/system/controllers/controllerModules/disableOtherModule.js+9−10
@@ -1,15 +1,13 @@
1"use strict";1"use strict";
2 2
3// nearTrigger.js3// disableOtherModule.js
4//4//
5// Distributed under the Apache License, Version 2.0.5// Distributed under the Apache License, Version 2.0.
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8 8
9/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,9/* global Script, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule,
10 enableDispatcherModule, disableDispatcherModule, getGrabbableData, Vec3,10 makeDispatcherModuleParameters, makeRunningValues, getEnabledModuleByName, Messages
11 TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS,
12 getEnabledModuleByName
13*/11*/
14 12
15Script.include("/~/system/libraries/controllerDispatcherUtils.js");13Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -20,7 +18,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 4 unmodified lines
20 this.disableModules = false;18 this.disableModules = false;
21 this.parameters = makeDispatcherModuleParameters(19 this.parameters = makeDispatcherModuleParameters(
22 90,20 90,
23 this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],21 this.hand === RIGHT_HAND ?
22 ["rightHand", "rightHandEquip", "rightHandTrigger"] :
23 ["leftHand", "leftHandEquip", "leftHandTrigger"],
24 [],24 [],
25 100);25 100);
26 26
@@ -37,11 +37,11 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 10 unmodified lines
37 37
38 if (teleportModule) {38 if (teleportModule) {
39 var ready = teleportModule.isReady(controllerData);39 var ready = teleportModule.isReady(controllerData);
40 if (ready) {40 if (ready.active) {
41 return makeRunningValues(false, [], []);41 return makeRunningValues(false, [], []);
42 }42 }
43 }43 }
44 if (!this.disablemodules) {44 if (!this.disableModules) {
45 return makeRunningValues(false, [], []);45 return makeRunningValues(false, [], []);
46 }46 }
47 return makeRunningValues(true, [], []);47 return makeRunningValues(true, [], []);
@@ -61,7 +61,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 13 unmodified lines
61 }61 }
62 if (message === 'right') {62 if (message === 'right') {
63 rightDisableModules.disableModules = true;63 rightDisableModules.disableModules = true;
64
65 }64 }
66 if (message === 'both' || message === 'none') {65 if (message === 'both' || message === 'none') {
67 if (message === 'both') {66 if (message === 'both') {
@@ -75,7 +74,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 7 unmodified lines
75 }74 }
76 }75 }
77 };76 };
78 77
79 Messages.subscribe('Hifi-Hand-Disabler');78 Messages.subscribe('Hifi-Hand-Disabler');
80 this.cleanup = function() {79 this.cleanup = function() {
81 disableDispatcherModule("LeftDisableModules");80 disableDispatcherModule("LeftDisableModules");
scripts/system/controllers/controllerModules/equipEntity.js+2−5
@@ -602,11 +602,8 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa · 601 unmodified lines
602 };602 };
603 603
604 this.isTargetIDValid = function() {604 this.isTargetIDValid = function() {
605 var entityProperties = Entities.getEntityProperties(this.targetEntityID);605 var entityProperties = Entities.getEntityProperties(this.targetEntityID, ["type"]);
606 for (var propertry in entityProperties) {606 return "type" in entityProperties;
607 return true;
608 }
609 return false;
610 };607 };
611 608
612 this.isReady = function (controllerData, deltaTime) {609 this.isReady = function (controllerData, deltaTime) {
scripts/system/controllers/controllerModules/farActionGrabEntity.js+19−11
@@ -13,7 +13,7 @@ · 12 unmodified lines
13 makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,13 makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
14 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,14 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
15 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,15 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
16 getControllerWorldLocation, projectOntoEntityXYPlane16 getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays
17 17
18*/18*/
19 19
@@ -236,10 +236,10 @@ Script.include("/~/system/libraries/controllers.js"); · 216 unmodified lines
236 this.actionID = null;236 this.actionID = null;
237 }237 }
238 238
239 // XXX239 if (this.actionID !== null) {
240 // if (this.actionID !== null) {240 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
241 // this.callEntityMethodOnGrabbed("startDistanceGrab");241 Entities.callEntityMethod(this.grabbedThingID, "startDistanceGrab", args);
242 // }242 }
243 243
244 Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);244 Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand);
245 this.previousRoomControllerPosition = roomControllerPosition;245 this.previousRoomControllerPosition = roomControllerPosition;
@@ -271,8 +271,8 @@ Script.include("/~/system/libraries/controllers.js"); · 25 unmodified lines
271 var handMoved = Vec3.multiply(worldHandDelta, radius);271 var handMoved = Vec3.multiply(worldHandDelta, radius);
272 this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, handMoved);272 this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, handMoved);
273 273
274 // XXX274 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
275 // this.callEntityMethodOnGrabbed("continueDistantGrab");275 Entities.callEntityMethod(this.grabbedThingID, "continueDistanceGrab", args);
276 276
277 // Update radialVelocity277 // Update radialVelocity
278 var lastVelocity = Vec3.multiply(worldHandDelta, 1.0 / deltaObjectTime);278 var lastVelocity = Vec3.multiply(worldHandDelta, 1.0 / deltaObjectTime);
@@ -335,6 +335,10 @@ Script.include("/~/system/libraries/controllers.js"); · 56 unmodified lines
335 this.distanceHolding = false;335 this.distanceHolding = false;
336 this.distanceRotating = false;336 this.distanceRotating = false;
337 Entities.deleteAction(this.grabbedThingID, this.actionID);337 Entities.deleteAction(this.grabbedThingID, this.actionID);
338
339 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
340 Entities.callEntityMethod(this.grabbedThingID, "releaseGrab", args);
341
338 this.actionID = null;342 this.actionID = null;
339 this.grabbedThingID = null;343 this.grabbedThingID = null;
340 };344 };
@@ -343,7 +347,8 @@ Script.include("/~/system/libraries/controllers.js"); · 2 unmodified lines
343 var intersection = controllerData.rayPicks[this.hand];347 var intersection = controllerData.rayPicks[this.hand];
344 var entityProperty = Entities.getEntityProperties(intersection.objectID);348 var entityProperty = Entities.getEntityProperties(intersection.objectID);
345 var entityType = entityProperty.type;349 var entityType = entityProperty.type;
346 if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") || intersection.type === RayPick.INTERSECTED_OVERLAY) {350 if ((intersection.type === RayPick.INTERSECTED_ENTITY && entityType === "Web") ||
351 intersection.type === RayPick.INTERSECTED_OVERLAY) {
347 return true;352 return true;
348 }353 }
349 return false;354 return false;
@@ -354,7 +359,8 @@ Script.include("/~/system/libraries/controllers.js"); · 4 unmodified lines
354 this.distanceHolding = false;359 this.distanceHolding = false;
355 360
356 var worldControllerRotation = getControllerWorldLocation(this.handToController(), true).orientation;361 var worldControllerRotation = getControllerWorldLocation(this.handToController(), true).orientation;
357 var controllerRotationDelta = Quat.multiply(worldControllerRotation, Quat.inverse(this.previousWorldControllerRotation));362 var controllerRotationDelta =
363 Quat.multiply(worldControllerRotation, Quat.inverse(this.previousWorldControllerRotation));
358 // Rotate entity by twice the delta rotation.364 // Rotate entity by twice the delta rotation.
359 controllerRotationDelta = Quat.multiply(controllerRotationDelta, controllerRotationDelta);365 controllerRotationDelta = Quat.multiply(controllerRotationDelta, controllerRotationDelta);
360 366
@@ -426,7 +432,8 @@ Script.include("/~/system/libraries/controllers.js"); · 65 unmodified lines
426 };432 };
427 433
428 this.run = function (controllerData) {434 this.run = function (controllerData) {
429 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.notPointingAtEntity(controllerData) || this.isPointingAtUI(controllerData)) {435 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE ||
436 this.notPointingAtEntity(controllerData) || this.isPointingAtUI(controllerData)) {
430 this.endNearGrabAction();437 this.endNearGrabAction();
431 this.laserPointerOff();438 this.laserPointerOff();
432 return makeRunningValues(false, [], []);439 return makeRunningValues(false, [], []);
@@ -471,6 +478,7 @@ Script.include("/~/system/libraries/controllers.js"); · 38 unmodified lines
471 for (var j = 0; j < nearGrabReadiness.length; j++) {478 for (var j = 0; j < nearGrabReadiness.length; j++) {
472 if (nearGrabReadiness[j].active) {479 if (nearGrabReadiness[j].active) {
473 this.laserPointerOff();480 this.laserPointerOff();
481 this.endNearGrabAction();
474 return makeRunningValues(false, [], []);482 return makeRunningValues(false, [], []);
475 }483 }
476 }484 }
@@ -555,7 +563,7 @@ Script.include("/~/system/libraries/controllers.js"); · 78 unmodified lines
555 joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",563 joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
556 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,564 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,
557 maxDistance: PICK_MAX_DISTANCE,565 maxDistance: PICK_MAX_DISTANCE,
558 posOffset: getGrabPointSphereOffset(this.handToController()),566 posOffset: getGrabPointSphereOffset(this.handToController(), true),
559 renderStates: renderStates,567 renderStates: renderStates,
560 faceAvatar: true,568 faceAvatar: true,
561 defaultRenderStates: defaultRenderStates569 defaultRenderStates: defaultRenderStates
scripts/system/controllers/controllerModules/farTrigger.js+4−8
@@ -6,14 +6,10 @@ · 5 unmodified lines
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8 8
9/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat,9/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, MyAvatar, getGrabPointSphereOffset,
10 getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID,10 makeRunningValues, Entities, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters,
11 enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable,
12 makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
13 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,11 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
14 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,12 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, getGrabbableData
15 getControllerWorldLocation, projectOntoEntityXYPlane, getGrabbableData
16
17*/13*/
18 14
19Script.include("/~/system/libraries/controllerDispatcherUtils.js");15Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -202,7 +198,7 @@ Script.include("/~/system/libraries/controllers.js"); · 182 unmodified lines
202 joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",198 joint: (this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
203 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,199 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,
204 maxDistance: PICK_MAX_DISTANCE,200 maxDistance: PICK_MAX_DISTANCE,
205 posOffset: getGrabPointSphereOffset(this.handToController()),201 posOffset: getGrabPointSphereOffset(this.handToController(), true),
206 renderStates: renderStates,202 renderStates: renderStates,
207 faceAvatar: true,203 faceAvatar: true,
208 defaultRenderStates: defaultRenderStates204 defaultRenderStates: defaultRenderStates
scripts/system/controllers/controllerModules/inEditMode.js+7−8
@@ -5,13 +5,12 @@ · 4 unmodified lines
5// Distributed under the Apache License, Version 2.0.5// Distributed under the Apache License, Version 2.0.
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,8/* jslint bitwise: true */
9 NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues,9
10 Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,10/* global Script, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, makeRunningValues,
11 AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset,11 Messages, makeDispatcherModuleParameters, AVATAR_SELF_ID, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE,
12 COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,12 COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE,
13 DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE,13 getEnabledModuleByName, PICK_MAX_DISTANCE, isInEditMode, LaserPointers, RayPick
14 isInEditMode
15*/14*/
16 15
17Script.include("/~/system/libraries/controllerDispatcherUtils.js");16Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -239,7 +238,7 @@ Script.include("/~/system/libraries/utils.js"); · 221 unmodified lines
239 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",238 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",
240 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,239 filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS,
241 maxDistance: PICK_MAX_DISTANCE,240 maxDistance: PICK_MAX_DISTANCE,
242 posOffset: getGrabPointSphereOffset(this.handToController()),241 posOffset: getGrabPointSphereOffset(this.handToController(), true),
243 renderStates: renderStates,242 renderStates: renderStates,
244 faceAvatar: true,243 faceAvatar: true,
245 defaultRenderStates: defaultRenderStates244 defaultRenderStates: defaultRenderStates
scripts/system/controllers/controllerModules/nearActionGrabEntity.js+9−4
@@ -111,6 +111,9 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 110 unmodified lines
111 grabbedEntity: this.targetEntityID,111 grabbedEntity: this.targetEntityID,
112 joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"112 joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
113 }));113 }));
114
115 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
116 Entities.callEntityMethod(this.targetEntityID, "startNearGrab", args);
114 };117 };
115 118
116 // this is for when the action is going to time-out119 // this is for when the action is going to time-out
@@ -147,10 +150,10 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 30 unmodified lines
147 this.getTargetProps = function (controllerData) {150 this.getTargetProps = function (controllerData) {
148 // nearbyEntityProperties is already sorted by distance from controller151 // nearbyEntityProperties is already sorted by distance from controller
149 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];152 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
153 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
150 for (var i = 0; i < nearbyEntityProperties.length; i++) {154 for (var i = 0; i < nearbyEntityProperties.length; i++) {
151 var props = nearbyEntityProperties[i];155 var props = nearbyEntityProperties[i];
152 var handPosition = controllerData.controllerLocations[this.hand].position;156 if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
153 if (props.distance > NEAR_GRAB_RADIUS) {
154 break;157 break;
155 }158 }
156 if (entityIsGrabbable(props) || entityIsCloneable(props)) {159 if (entityIsGrabbable(props) || entityIsCloneable(props)) {
@@ -173,7 +176,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 16 unmodified lines
173 this.targetEntityID = null;176 this.targetEntityID = null;
174 177
175 var targetProps = this.getTargetProps(controllerData);178 var targetProps = this.getTargetProps(controllerData);
176 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {179 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
180 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
177 return makeRunningValues(false, [], []);181 return makeRunningValues(false, [], []);
178 }182 }
179 183
@@ -192,7 +196,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines
192 196
193 this.run = function (controllerData) {197 this.run = function (controllerData) {
194 if (this.actionID) {198 if (this.actionID) {
195 if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {199 if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
200 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
196 this.endNearGrabAction();201 this.endNearGrabAction();
197 this.hapticTargetID = null;202 this.hapticTargetID = null;
198 return makeRunningValues(false, [], []);203 return makeRunningValues(false, [], []);
scripts/system/controllers/controllerModules/nearParentGrabEntity.js+10−8
@@ -6,11 +6,10 @@ · 5 unmodified lines
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8 8
9/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,9/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID,
10 getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,10 enableDispatcherModule, disableDispatcherModule, propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
11 propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, TRIGGER_OFF_VALUE,11 TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS, findGroupParent,
12 makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS,12 Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE
13 findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE
14*/13*/
15 14
16Script.include("/~/system/libraries/controllerDispatcherUtils.js");15Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -147,11 +146,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 130 unmodified lines
147 this.getTargetProps = function (controllerData) {146 this.getTargetProps = function (controllerData) {
148 // nearbyEntityProperties is already sorted by length from controller147 // nearbyEntityProperties is already sorted by length from controller
149 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];148 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
149 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
150 for (var i = 0; i < nearbyEntityProperties.length; i++) {150 for (var i = 0; i < nearbyEntityProperties.length; i++) {
151 var props = nearbyEntityProperties[i];151 var props = nearbyEntityProperties[i];
152 var handPosition = controllerData.controllerLocations[this.hand].position;152 var handPosition = controllerData.controllerLocations[this.hand].position;
153 var distance = Vec3.distance(props.position, handPosition);153 var distance = Vec3.distance(props.position, handPosition);
154 if (distance > NEAR_GRAB_RADIUS) {154 if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
155 continue;155 continue;
156 }156 }
157 if (entityIsGrabbable(props)) {157 if (entityIsGrabbable(props)) {
@@ -176,7 +176,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 18 unmodified lines
176 this.grabbing = false;176 this.grabbing = false;
177 177
178 var targetProps = this.getTargetProps(controllerData);178 var targetProps = this.getTargetProps(controllerData);
179 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {179 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
180 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
180 return makeRunningValues(false, [], []);181 return makeRunningValues(false, [], []);
181 }182 }
182 183
@@ -195,7 +196,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); · 12 unmodified lines
195 196
196 this.run = function (controllerData, deltaTime) {197 this.run = function (controllerData, deltaTime) {
197 if (this.grabbing) {198 if (this.grabbing) {
198 if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE && controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {199 if (controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
200 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
199 this.endNearParentingGrabEntity();201 this.endNearParentingGrabEntity();
200 this.hapticTargetID = null;202 this.hapticTargetID = null;
201 return makeRunningValues(false, [], []);203 return makeRunningValues(false, [], []);
scripts/system/controllers/controllerModules/nearParentGrabOverlay.js+17−6
@@ -6,14 +6,14 @@ · 5 unmodified lines
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8 8
9/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,9/* global Script, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID,
10 getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,10 enableDispatcherModule, disableDispatcherModule, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
11 Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,11 makeDispatcherModuleParameters, Overlays, makeRunningValues, Vec3, resizeTablet, getTabletWidthFromSettings,
12 makeDispatcherModuleParameters, Overlays, makeRunningValues12 NEAR_GRAB_RADIUS
13*/13*/
14 14
15Script.include("/~/system/libraries/controllerDispatcherUtils.js");15Script.include("/~/system/libraries/controllerDispatcherUtils.js");
16var GRAB_RADIUS = 0.35;16Script.include("/~/system/libraries/utils.js");
17 17
18(function() {18(function() {
19 19
@@ -120,6 +120,11 @@ var GRAB_RADIUS = 0.35; · 100 unmodified lines
120 }120 }
121 Overlays.editOverlay(this.grabbedThingID, reparentProps);121 Overlays.editOverlay(this.grabbedThingID, reparentProps);
122 122
123 // resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
124 if (this.grabbedThingID === HMD.tabletID) {
125 resizeTablet(getTabletWidthFromSettings(), reparentProps.parentJointIndex);
126 }
127
123 Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({128 Messages.sendMessage('Hifi-Object-Manipulation', JSON.stringify({
124 action: 'grab',129 action: 'grab',
125 grabbedEntity: this.grabbedThingID,130 grabbedEntity: this.grabbedThingID,
@@ -140,17 +145,23 @@ var GRAB_RADIUS = 0.35; · 14 unmodified lines
140 parentID: this.previousParentID[this.grabbedThingID],145 parentID: this.previousParentID[this.grabbedThingID],
141 parentJointIndex: this.previousParentJointIndex[this.grabbedThingID]146 parentJointIndex: this.previousParentJointIndex[this.grabbedThingID]
142 });147 });
148
149 // resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
150 if (this.grabbedThingID === HMD.tabletID) {
151 resizeTablet(getTabletWidthFromSettings(), this.previousParentJointIndex[this.grabbedThingID]);
152 }
143 }153 }
144 154
145 this.grabbedThingID = null;155 this.grabbedThingID = null;
146 };156 };
147 157
148 this.getTargetID = function(overlays, controllerData) {158 this.getTargetID = function(overlays, controllerData) {
159 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
149 for (var i = 0; i < overlays.length; i++) {160 for (var i = 0; i < overlays.length; i++) {
150 var overlayPosition = Overlays.getProperty(overlays[i], "position");161 var overlayPosition = Overlays.getProperty(overlays[i], "position");
151 var handPosition = controllerData.controllerLocations[this.hand].position;162 var handPosition = controllerData.controllerLocations[this.hand].position;
152 var distance = Vec3.distance(overlayPosition, handPosition);163 var distance = Vec3.distance(overlayPosition, handPosition);
153 if (distance <= GRAB_RADIUS) {164 if (distance <= NEAR_GRAB_RADIUS * sensorScaleFactor) {
154 return overlays[i];165 return overlays[i];
155 }166 }
156 }167 }
scripts/system/controllers/controllerModules/nearTrigger.js+5−5
@@ -6,9 +6,8 @@ · 5 unmodified lines
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8 8
9/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,9/* global Script, Entities, MyAvatar, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, getGrabbableData,
10 enableDispatcherModule, disableDispatcherModule, getGrabbableData, Vec3,10 Vec3, TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS
11 TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, makeRunningValues, NEAR_GRAB_RADIUS
12*/11*/
13 12
14Script.include("/~/system/libraries/controllerDispatcherUtils.js");13Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -37,11 +36,12 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 22 unmodified lines
37 this.getTargetProps = function (controllerData) {36 this.getTargetProps = function (controllerData) {
38 // nearbyEntityProperties is already sorted by length from controller37 // nearbyEntityProperties is already sorted by length from controller
39 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];38 var nearbyEntityProperties = controllerData.nearbyEntityProperties[this.hand];
39 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
40 for (var i = 0; i < nearbyEntityProperties.length; i++) {40 for (var i = 0; i < nearbyEntityProperties.length; i++) {
41 var props = nearbyEntityProperties[i];41 var props = nearbyEntityProperties[i];
42 var handPosition = controllerData.controllerLocations[this.hand].position;42 var handPosition = controllerData.controllerLocations[this.hand].position;
43 var distance = Vec3.distance(props.position, handPosition);43 var distance = Vec3.distance(props.position, handPosition);
44 if (distance > NEAR_GRAB_RADIUS) {44 if (distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
45 continue;45 continue;
46 }46 }
47 if (entityWantsNearTrigger(props)) {47 if (entityWantsNearTrigger(props)) {
@@ -63,7 +63,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js"); · 15 unmodified lines
63 63
64 this.endNearTrigger = function (controllerData) {64 this.endNearTrigger = function (controllerData) {
65 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];65 var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
66 Entities.callEntityMethod(this.targetEntityID, "endNearTrigger", args);66 Entities.callEntityMethod(this.targetEntityID, "stopNearTrigger", args);
67 };67 };
68 68
69 this.isReady = function (controllerData) {69 this.isReady = function (controllerData) {
scripts/system/controllers/controllerModules/overlayLaserInput.js+6−8
@@ -5,13 +5,11 @@ · 4 unmodified lines
5// Distributed under the Apache License, Version 2.0.5// Distributed under the Apache License, Version 2.0.
6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html6// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 7
8/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,8/* global Script, Entities, Controller, RIGHT_HAND, LEFT_HAND, NULL_UUID, enableDispatcherModule, disableDispatcherModule,
9 NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues,9 makeRunningValues, Messages, Quat, Vec3, makeDispatcherModuleParameters, Overlays, ZERO_VEC, AVATAR_SELF_ID, HMD,
10 Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,10 INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE,
11 AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset,11 COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE,
12 COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,12 TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE, LaserPointers, RayPick, ContextOverlay
13 DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, TRIGGER_OFF_VALUE, getEnabledModuleByName, PICK_MAX_DISTANCE,
14 DISPATCHER_PROPERTIES
15*/13*/
16 14
17Script.include("/~/system/libraries/controllerDispatcherUtils.js");15Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -528,7 +526,7 @@ Script.include("/~/system/libraries/controllers.js"); · 510 unmodified lines
528 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",526 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",
529 filter: RayPick.PICK_OVERLAYS,527 filter: RayPick.PICK_OVERLAYS,
530 maxDistance: PICK_MAX_DISTANCE,528 maxDistance: PICK_MAX_DISTANCE,
531 posOffset: getGrabPointSphereOffset(this.handToController()),529 posOffset: getGrabPointSphereOffset(this.handToController(), true),
532 renderStates: renderStates,530 renderStates: renderStates,
533 faceAvatar: true,531 faceAvatar: true,
534 defaultRenderStates: defaultRenderStates532 defaultRenderStates: defaultRenderStates
scripts/system/controllers/controllerModules/scaleAvatar.js+5−5
@@ -7,9 +7,7 @@ · 6 unmodified lines
7// Distributed under the Apache License, Version 2.0.7// Distributed under the Apache License, Version 2.0.
8// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html8// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 9
10/* global getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings,10/* global Script, Vec3, MyAvatar, RIGHT_HAND */
11 Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset,
12 setGrabCommunications, Menu, HMD, isInEditMode, AvatarList */
13/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */11/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
14 12
15(function () {13(function () {
@@ -37,7 +35,8 @@ · 21 unmodified lines
37 };35 };
38 36
39 this.triggersPressed = function(controllerData) {37 this.triggersPressed = function(controllerData) {
40 if (controllerData.triggerClicks[this.hand] && controllerData.secondaryValues[this.hand] > dispatcherUtils.BUMPER_ON_VALUE) {38 if (controllerData.triggerClicks[this.hand] &&
39 controllerData.secondaryValues[this.hand] > dispatcherUtils.BUMPER_ON_VALUE) {
41 return true;40 return true;
42 }41 }
43 return false;42 return false;
@@ -58,7 +57,8 @@ · 14 unmodified lines
58 var otherModule = this.getOtherModule();57 var otherModule = this.getOtherModule();
59 if (this.triggersPressed(controllerData) && otherModule.triggersPressed(controllerData)) {58 if (this.triggersPressed(controllerData) && otherModule.triggersPressed(controllerData)) {
60 if (this.hand === dispatcherUtils.RIGHT_HAND) {59 if (this.hand === dispatcherUtils.RIGHT_HAND) {
61 var scalingCurrentDistance = Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position,60 var scalingCurrentDistance =
61 Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position,
62 controllerData.controllerLocations[this.otherHand()].position));62 controllerData.controllerLocations[this.otherHand()].position));
63 63
64 var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale;64 var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale;
scripts/system/controllers/controllerModules/tabletStylusInput.js+25−17
@@ -8,7 +8,8 @@ · 7 unmodified lines
8/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,8/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
9 NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues,9 NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeRunningValues,
10 Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,10 Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,
11 AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset11 AVATAR_SELF_ID, HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset,
12 getEnabledModuleByName
12*/13*/
13 14
14Script.include("/~/system/libraries/controllerDispatcherUtils.js");15Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -356,7 +357,7 @@ Script.include("/~/system/libraries/controllers.js"); · 341 unmodified lines
356 this.stylusTip = getControllerWorldLocation(this.handToController(), true);357 this.stylusTip = getControllerWorldLocation(this.handToController(), true);
357 358
358 // translate tip forward according to constant.359 // translate tip forward according to constant.
359 var TIP_OFFSET = {x: 0, y: WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, z: 0};360 var TIP_OFFSET = Vec3.multiply(MyAvatar.sensorToWorldScale, {x: 0, y: WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, z: 0});
360 this.stylusTip.position = Vec3.sum(this.stylusTip.position,361 this.stylusTip.position = Vec3.sum(this.stylusTip.position,
361 Vec3.multiplyQbyV(this.stylusTip.orientation, TIP_OFFSET));362 Vec3.multiplyQbyV(this.stylusTip.orientation, TIP_OFFSET));
362 }363 }
@@ -380,17 +381,17 @@ Script.include("/~/system/libraries/controllers.js"); · 17 unmodified lines
380 return;381 return;
381 }382 }
382 383
384 var X_ROT_NEG_90 = { x: -0.70710678, y: 0, z: 0, w: 0.70710678 };
385 var modelOrientation = Quat.multiply(this.stylusTip.orientation, X_ROT_NEG_90);
386 var modelPositionOffset = Vec3.multiplyQbyV(modelOrientation, { x: 0, y: 0, z: MyAvatar.sensorToWorldScale * -WEB_STYLUS_LENGTH / 2 });
387
383 var stylusProperties = {388 var stylusProperties = {
384 name: "stylus",389 name: "stylus",
385 url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",390 url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
386 loadPriority: 10.0,391 loadPriority: 10.0,
387 localPosition: Vec3.sum({392 position: Vec3.sum(this.stylusTip.position, modelPositionOffset),
388 x: 0.0,393 rotation: modelOrientation,
389 y: WEB_TOUCH_Y_OFFSET,394 dimensions: Vec3.multiply(MyAvatar.sensorToWorldScale, { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH }),
390 z: 0.0
391 }, getGrabPointSphereOffset(this.handToController())),
392 localRotation: Quat.fromVec3Degrees({ x: -90, y: 0, z: 0 }),
393 dimensions: { x: 0.01, y: 0.01, z: WEB_STYLUS_LENGTH },
394 solid: true,395 solid: true,
395 visible: true,396 visible: true,
396 ignoreRayIntersection: true,397 ignoreRayIntersection: true,
@@ -527,9 +528,11 @@ Script.include("/~/system/libraries/controllers.js"); · 130 unmodified lines
527 hysteresisOffset = 0.05;528 hysteresisOffset = 0.05;
528 }529 }
529 530
530 this.isNearStylusTarget = isNearStylusTarget(stylusTargets, EDGE_BORDER + hysteresisOffset,531 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
531 TABLET_MIN_TOUCH_DISTANCE - hysteresisOffset,532 this.isNearStylusTarget = isNearStylusTarget(stylusTargets,
532 WEB_DISPLAY_STYLUS_DISTANCE + hysteresisOffset);533 (EDGE_BORDER + hysteresisOffset) * sensorScaleFactor,
534 (TABLET_MIN_TOUCH_DISTANCE - hysteresisOffset) * sensorScaleFactor,
535 (WEB_DISPLAY_STYLUS_DISTANCE + hysteresisOffset) * sensorScaleFactor);
533 536
534 if (this.isNearStylusTarget) {537 if (this.isNearStylusTarget) {
535 if (!this.useFingerInsteadOfStylus) {538 if (!this.useFingerInsteadOfStylus) {
@@ -544,8 +547,12 @@ Script.include("/~/system/libraries/controllers.js"); · 8 unmodified lines
544 547
545 var nearestStylusTarget = calculateNearestStylusTarget(stylusTargets);548 var nearestStylusTarget = calculateNearestStylusTarget(stylusTargets);
546 549
547 if (nearestStylusTarget && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE &&550 var SCALED_TABLET_MIN_TOUCH_DISTANCE = TABLET_MIN_TOUCH_DISTANCE * sensorScaleFactor;
548 nearestStylusTarget.distance < TABLET_MAX_HOVER_DISTANCE) {551 var SCALED_TABLET_MAX_TOUCH_DISTANCE = TABLET_MAX_TOUCH_DISTANCE * sensorScaleFactor;
552 var SCALED_TABLET_MAX_HOVER_DISTANCE = TABLET_MAX_HOVER_DISTANCE * sensorScaleFactor;
553
554 if (nearestStylusTarget && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE &&
555 nearestStylusTarget.distance < SCALED_TABLET_MAX_HOVER_DISTANCE) {
549 556
550 this.requestTouchFocus(nearestStylusTarget);557 this.requestTouchFocus(nearestStylusTarget);
551 558
@@ -559,8 +566,8 @@ Script.include("/~/system/libraries/controllers.js"); · 7 unmodified lines
559 566
560 // filter out presses when tip is moving away from tablet.567 // filter out presses when tip is moving away from tablet.
561 // ensure that stylus is within bounding box by checking normalizedPosition568 // ensure that stylus is within bounding box by checking normalizedPosition
562 if (nearestStylusTarget.valid && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE &&569 if (nearestStylusTarget.valid && nearestStylusTarget.distance > SCALED_TABLET_MIN_TOUCH_DISTANCE &&
563 nearestStylusTarget.distance < TABLET_MAX_TOUCH_DISTANCE &&570 nearestStylusTarget.distance < SCALED_TABLET_MAX_TOUCH_DISTANCE &&
564 Vec3.dot(this.stylusTip.velocity, nearestStylusTarget.normal) < 0 &&571 Vec3.dot(this.stylusTip.velocity, nearestStylusTarget.normal) < 0 &&
565 nearestStylusTarget.normalizedPosition.x >= 0 && nearestStylusTarget.normalizedPosition.x <= 1 &&572 nearestStylusTarget.normalizedPosition.x >= 0 && nearestStylusTarget.normalizedPosition.x <= 1 &&
566 nearestStylusTarget.normalizedPosition.y >= 0 && nearestStylusTarget.normalizedPosition.y <= 1) {573 nearestStylusTarget.normalizedPosition.y >= 0 && nearestStylusTarget.normalizedPosition.y <= 1) {
@@ -647,7 +654,8 @@ Script.include("/~/system/libraries/controllers.js"); · 80 unmodified lines
647 };654 };
648 655
649 this.overlayLaserActive = function(controllerData) {656 this.overlayLaserActive = function(controllerData) {
650 var overlayLaserModule = getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightOverlayLaserInput" : "LeftOverlayLaserInput");657 var overlayLaserModule =
658 getEnabledModuleByName(this.hand === RIGHT_HAND ? "RightOverlayLaserInput" : "LeftOverlayLaserInput");
651 if (overlayLaserModule) {659 if (overlayLaserModule) {
652 return overlayLaserModule.isReady(controllerData).active;660 return overlayLaserModule.isReady(controllerData).active;
653 }661 }
scripts/system/controllers/controllerModules/teleport.js+45−17
@@ -8,11 +8,11 @@ · 7 unmodified lines
8// Distributed under the Apache License, Version 2.0.8// Distributed under the Apache License, Version 2.0.
9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html9// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 10
11/* jslint bitwise: true */
11 12
12/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID,13/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, AVATAR_SELF_ID, getControllerJointIndex, NULL_UUID,
13 getControllerJointIndex, NULL_UUID, enableDispatcherModule, disableDispatcherModule,14 enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3,
14 Messages, makeDispatcherModuleParameters, makeRunningValues, Settings, entityHasActions,15 LaserPointers, RayPick, HMD, Uuid, AvatarList
15 Vec3, Overlays, flatten, Xform, getControllerWorldLocation, ensureDynamic
16*/16*/
17/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */17/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
18 18
@@ -111,7 +111,7 @@ var seatEnd = { · 92 unmodified lines
111 url: SEAT_MODEL_URL,111 url: SEAT_MODEL_URL,
112 dimensions: TARGET_MODEL_DIMENSIONS,112 dimensions: TARGET_MODEL_DIMENSIONS,
113 ignoreRayIntersection: true113 ignoreRayIntersection: true
114}114};
115 115
116var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd},116var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd},
117 {name: "teleport", path: teleportPath, end: teleportEnd},117 {name: "teleport", path: teleportPath, end: teleportEnd},
@@ -228,8 +228,8 @@ function Teleporter(hand) { · 110 unmodified lines
228 228
229 this.buttonPress = function(value) {229 this.buttonPress = function(value) {
230 _this.buttonValue = value;230 _this.buttonValue = value;
231 }231 };
232 232
233 this.parameters = makeDispatcherModuleParameters(233 this.parameters = makeDispatcherModuleParameters(
234 80,234 80,
235 this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],235 this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
@@ -247,9 +247,36 @@ function Teleporter(hand) { · 11 unmodified lines
247 _this.state = TELEPORTER_STATES.TARGETTING;247 _this.state = TELEPORTER_STATES.TARGETTING;
248 }248 }
249 }, COOL_IN_DURATION);249 }, COOL_IN_DURATION);
250
251 // pad scale with avatar size
252 var AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS = Vec3.multiply(MyAvatar.sensorToWorldScale, TARGET_MODEL_DIMENSIONS);
253
254 if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) {
255 cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS;
256 teleportEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS;
257 seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS;
258
259 teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd},
260 {name: "teleport", path: teleportPath, end: teleportEnd},
261 {name: "seat", path: seatPath, end: seatEnd}];
262
263 LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]);
264 LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]);
265 LaserPointers.editRenderState(this.teleportRayHeadVisible, "cancel", teleportRenderStates[0]);
266 LaserPointers.editRenderState(this.teleportRayHeadInvisible, "cancel", teleportRenderStates[0]);
267
268 LaserPointers.editRenderState(this.teleportRayHandVisible, "teleport", teleportRenderStates[1]);
269 LaserPointers.editRenderState(this.teleportRayHandInvisible, "teleport", teleportRenderStates[1]);
270 LaserPointers.editRenderState(this.teleportRayHeadVisible, "teleport", teleportRenderStates[1]);
271 LaserPointers.editRenderState(this.teleportRayHeadInvisible, "teleport", teleportRenderStates[1]);
272
273 LaserPointers.editRenderState(this.teleportRayHandVisible, "seat", teleportRenderStates[2]);
274 LaserPointers.editRenderState(this.teleportRayHandInvisible, "seat", teleportRenderStates[2]);
275 LaserPointers.editRenderState(this.teleportRayHeadVisible, "seat", teleportRenderStates[2]);
276 LaserPointers.editRenderState(this.teleportRayHeadInvisible, "seat", teleportRenderStates[2]);
277 }
250 };278 };
251 279
252
253 this.isReady = function(controllerData, deltaTime) {280 this.isReady = function(controllerData, deltaTime) {
254 var otherModule = this.getOtherModule();281 var otherModule = this.getOtherModule();
255 if (_this.buttonValue !== 0 && !otherModule.active) {282 if (_this.buttonValue !== 0 && !otherModule.active) {
@@ -259,7 +286,7 @@ function Teleporter(hand) { · 3 unmodified lines
259 }286 }
260 return makeRunningValues(false, [], []);287 return makeRunningValues(false, [], []);
261 };288 };
262 289
263 this.run = function(controllerData, deltaTime) {290 this.run = function(controllerData, deltaTime) {
264 //_this.state = TELEPORTER_STATES.TARGETTING;291 //_this.state = TELEPORTER_STATES.TARGETTING;
265 292
@@ -301,7 +328,6 @@ function Teleporter(hand) { · 35 unmodified lines
301 } else {328 } else {
302 result = LaserPointers.getPrevRayPickResult(_this.teleportRayHandVisible);329 result = LaserPointers.getPrevRayPickResult(_this.teleportRayHandVisible);
303 }330 }
304
305 teleportLocationType = getTeleportTargetType(result);331 teleportLocationType = getTeleportTargetType(result);
306 }332 }
307 333
@@ -327,7 +353,7 @@ function Teleporter(hand) { · 19 unmodified lines
327 if (_this.buttonValue !== 0) {353 if (_this.buttonValue !== 0) {
328 return makeRunningValues(true, [], []);354 return makeRunningValues(true, [], []);
329 }355 }
330 356
331 if (target === TARGET.NONE || target === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) {357 if (target === TARGET.NONE || target === TARGET.INVALID || this.state === TELEPORTER_STATES.COOL_IN) {
332 // Do nothing358 // Do nothing
333 } else if (target === TARGET.SEAT) {359 } else if (target === TARGET.SEAT) {
@@ -362,7 +388,7 @@ function Teleporter(hand) { · 28 unmodified lines
362 }388 }
363 };389 };
364}390}
365 391
366 // related to repositioning the avatar after you teleport392 // related to repositioning the avatar after you teleport
367 var FOOT_JOINT_NAMES = ["RightToe_End", "RightToeBase", "RightFoot"];393 var FOOT_JOINT_NAMES = ["RightToe_End", "RightToeBase", "RightFoot"];
368 var DEFAULT_ROOT_TO_FOOT_OFFSET = 0.5;394 var DEFAULT_ROOT_TO_FOOT_OFFSET = 0.5;
@@ -475,7 +501,7 @@ function Teleporter(hand) { · 106 unmodified lines
475 disableDispatcherModule("RightTeleporter");501 disableDispatcherModule("RightTeleporter");
476 }502 }
477 Script.scriptEnding.connect(cleanup);503 Script.scriptEnding.connect(cleanup);
478 504
479 var setIgnoreEntities = function() {505 var setIgnoreEntities = function() {
480 LaserPointers.setIgnoreEntities(teleporter.teleportRayRightVisible, ignoredEntities);506 LaserPointers.setIgnoreEntities(teleporter.teleportRayRightVisible, ignoredEntities);
481 LaserPointers.setIgnoreEntities(teleporter.teleportRayRightInvisible, ignoredEntities);507 LaserPointers.setIgnoreEntities(teleporter.teleportRayRightInvisible, ignoredEntities);
@@ -483,8 +509,8 @@ function Teleporter(hand) { · 1 unmodified line
483 LaserPointers.setIgnoreEntities(teleporter.teleportRayLeftInvisible, ignoredEntities);509 LaserPointers.setIgnoreEntities(teleporter.teleportRayLeftInvisible, ignoredEntities);
484 LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadVisible, ignoredEntities);510 LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadVisible, ignoredEntities);
485 LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadInvisible, ignoredEntities);511 LaserPointers.setIgnoreEntities(teleporter.teleportRayHeadInvisible, ignoredEntities);
486 }512 };
487 513
488 var isDisabled = false;514 var isDisabled = false;
489 var handleTeleportMessages = function(channel, message, sender) {515 var handleTeleportMessages = function(channel, message, sender) {
490 if (sender === MyAvatar.sessionUUID) {516 if (sender === MyAvatar.sessionUUID) {
@@ -501,7 +527,9 @@ function Teleporter(hand) { · 10 unmodified lines
501 if (message === 'none') {527 if (message === 'none') {
502 isDisabled = false;528 isDisabled = false;
503 }529 }
504 } else if (channel === 'Hifi-Teleport-Ignore-Add' && !Uuid.isNull(message) && ignoredEntities.indexOf(message) === -1) {530 } else if (channel === 'Hifi-Teleport-Ignore-Add' &&
531 !Uuid.isNull(message) &&
532 ignoredEntities.indexOf(message) === -1) {
505 ignoredEntities.push(message);533 ignoredEntities.push(message);
506 setIgnoreEntities();534 setIgnoreEntities();
507 } else if (channel === 'Hifi-Teleport-Ignore-Remove' && !Uuid.isNull(message)) {535 } else if (channel === 'Hifi-Teleport-Ignore-Remove' && !Uuid.isNull(message)) {
@@ -513,7 +541,7 @@ function Teleporter(hand) { · 5 unmodified lines
513 }541 }
514 }542 }
515 };543 };
516 544
517 Messages.subscribe('Hifi-Teleport-Disabler');545 Messages.subscribe('Hifi-Teleport-Disabler');
518 Messages.subscribe('Hifi-Teleport-Ignore-Add');546 Messages.subscribe('Hifi-Teleport-Ignore-Add');
519 Messages.subscribe('Hifi-Teleport-Ignore-Remove');547 Messages.subscribe('Hifi-Teleport-Ignore-Remove');
scripts/system/controllers/controllerModules/webEntityLaserInput.js+4−7
@@ -7,13 +7,10 @@ · 6 unmodified lines
7 7
8/* jslint bitwise: true */8/* jslint bitwise: true */
9 9
10/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat,10/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Vec3, Quat, getGrabPointSphereOffset,
11 getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID,11 makeRunningValues, Entities, NULL_UUID, enableDispatcherModule, disableDispatcherModule, makeDispatcherModuleParameters,
12 enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable,
13 makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
14 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,12 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
15 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC13 AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, ZERO_VEC, Overlays
16
17*/14*/
18 15
19Script.include("/~/system/libraries/controllerDispatcherUtils.js");16Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -459,7 +456,7 @@ Script.include("/~/system/libraries/controllers.js"); · 439 unmodified lines
459 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",456 joint: (this.hand === RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",
460 filter: RayPick.PICK_ENTITIES,457 filter: RayPick.PICK_ENTITIES,
461 maxDistance: PICK_MAX_DISTANCE,458 maxDistance: PICK_MAX_DISTANCE,
462 posOffset: getGrabPointSphereOffset(this.handToController()),459 posOffset: getGrabPointSphereOffset(this.handToController(), true),
463 renderStates: renderStates,460 renderStates: renderStates,
464 faceAvatar: true,461 faceAvatar: true,
465 defaultRenderStates: defaultRenderStates462 defaultRenderStates: defaultRenderStates