History

Merge pull request #12546 from druiz17/fix-hyperlink

Fix hyperlink when far/near grabbing enitities

John Conklin II committed 8 years ago

Commit 3f751bb2 parents 8856d4a d12a4f05 files · +110 −7Browse files

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

Unified · Split

2 files
  1. scripts/system/controllers/controllerModules/farActionGrabEntity.js +10 −4
  2. scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js +95 −0
scripts/system/controllers/controllerModules/farActionGrabEntity.js+10−4
@@ -14,7 +14,7 @@ · 13 unmodified lines
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 DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,15 DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
16 getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI16 getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
17 Picks, makeLaserLockInfo Xform, makeLaserParams17 Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents
18*/18*/
19 19
20Script.include("/~/system/libraries/controllerDispatcherUtils.js");20Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -375,7 +375,7 @@ Script.include("/~/system/libraries/Xform.js"); · 354 unmodified lines
375 return true;375 return true;
376 }376 }
377 return false;377 return false;
378 }378 };
379 379
380 this.isReady = function (controllerData) {380 this.isReady = function (controllerData) {
381 if (HMD.active) {381 if (HMD.active) {
@@ -449,11 +449,16 @@ Script.include("/~/system/libraries/Xform.js"); · 67 unmodified lines
449 if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {449 if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
450 if (controllerData.triggerClicks[this.hand]) {450 if (controllerData.triggerClicks[this.hand]) {
451 var entityID = rayPickInfo.objectID;451 var entityID = rayPickInfo.objectID;
452
452 var targetProps = Entities.getEntityProperties(entityID, [453 var targetProps = Entities.getEntityProperties(entityID, [
453 "dynamic", "shapeType", "position",454 "dynamic", "shapeType", "position",
454 "rotation", "dimensions", "density",455 "rotation", "dimensions", "density",
455 "userData", "locked", "type"456 "userData", "locked", "type", "href"
456 ]);457 ]);
458 if (targetProps.href !== "") {
459 AddressManager.handleLookupString(targetProps.href);
460 return makeRunningValues(false, [], []);
461 }
457 462
458 this.targetObject = new TargetObject(entityID, targetProps);463 this.targetObject = new TargetObject(entityID, targetProps);
459 this.targetObject.parentProps = getEntityParents(targetProps);464 this.targetObject.parentProps = getEntityParents(targetProps);
@@ -480,7 +485,8 @@ Script.include("/~/system/libraries/Xform.js"); · 20 unmodified lines
480 this.grabbedDistance = rayPickInfo.distance;485 this.grabbedDistance = rayPickInfo.distance;
481 }486 }
482 487
483 if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) {488 if (otherFarGrabModule.grabbedThingID === this.grabbedThingID &&
489 otherFarGrabModule.distanceHolding) {
484 this.prepareDistanceRotatingData(controllerData);490 this.prepareDistanceRotatingData(controllerData);
485 this.distanceRotate(otherFarGrabModule);491 this.distanceRotate(otherFarGrabModule);
486 } else {492 } else {
scripts/system/controllers/controllerModules/nearGrabHyperLinkEntity.js+95−0
@@ -0,0 +1,95 @@
1"use strict";
2
3// nearGrabHyperLinkEntity.js
4//
5// Created by Dante Ruiz on 03/02/2018
6//
7// Distributed under the Apache License, Version 2.0.
8// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9
10/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND,
11 getControllerJointIndex, getGrabbableData, enableDispatcherModule, disableDispatcherModule,
12 propsArePhysical, Messages, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, entityIsGrabbable,
13 Quat, Vec3, MSECS_PER_SEC, getControllerWorldLocation, makeDispatcherModuleParameters, makeRunningValues,
14 TRIGGER_OFF_VALUE, NEAR_GRAB_RADIUS, findGroupParent, entityIsCloneable, propsAreCloneDynamic, cloneEntity,
15 HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, AddressManager
16*/
17
18(function() {
19 Script.include("/~/system/libraries/controllerDispatcherUtils.js");
20 Script.include("/~/system/libraries/controllers.js");
21
22 function NearGrabHyperLinkEntity(hand) {
23 this.hand = hand;
24 this.targetEntityID = null;
25 this.hyperlink = "";
26
27 this.parameters = makeDispatcherModuleParameters(
28 485,
29 this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
30 [],
31 100);
32
33
34 this.getTargetProps = function(controllerData) {
35 var nearbyEntitiesProperties = controllerData.nearbyEntityProperties[this.hand];
36 var sensorScaleFactor = MyAvatar.sensorToWorldScale;
37 for (var i = 0; i < nearbyEntitiesProperties.length; i++) {
38 var props = nearbyEntitiesProperties[i];
39 if (props.distance > NEAR_GRAB_RADIUS * sensorScaleFactor) {
40 continue;
41 }
42 if (props.href !== "" && props.href !== undefined) {
43 return props;
44 }
45 }
46 return null;
47 };
48
49 this.isReady = function(controllerData) {
50 this.targetEntityID = null;
51 if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE &&
52 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) {
53 return makeRunningValues(false, [], []);
54 }
55
56 var targetProps = this.getTargetProps(controllerData);
57 if (targetProps) {
58 this.hyperlink = targetProps.href;
59 this.targetEntityID = targetProps.id;
60 return makeRunningValues(true, [], []);
61 }
62
63 return makeRunningValues(false, [], []);
64 };
65
66 this.run = function(controllerData) {
67 if ((controllerData.triggerClicks[this.hand] < TRIGGER_OFF_VALUE &&
68 controllerData.secondaryValues[this.hand] < TRIGGER_OFF_VALUE) || this.hyperlink === "") {
69 return makeRunningValues(false, [], []);
70 }
71
72 if (controllerData.triggerClicks[this.hand] ||
73 controllerData.secondaryValues[this.hand] > BUMPER_ON_VALUE) {
74 AddressManager.handleLookupString(this.hyperlink);
75 return makeRunningValues(false, [], []);
76 }
77
78 return makeRunningValues(true, [], []);
79 };
80 }
81
82 var leftNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(LEFT_HAND);
83 var rightNearGrabHyperLinkEntity = new NearGrabHyperLinkEntity(RIGHT_HAND);
84
85 enableDispatcherModule("LeftNearGrabHyperLink", leftNearGrabHyperLinkEntity);
86 enableDispatcherModule("RightNearGrabHyperLink", rightNearGrabHyperLinkEntity);
87
88 function cleanup() {
89 disableDispatcherModule("LeftNearGrabHyperLink");
90 disableDispatcherModule("RightNearGrabHyperLink");
91
92 }
93
94 Script.scriptEnding.connect(cleanup);
95}());

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