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
1414 PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
1515 DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
1616 getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
17− Picks, makeLaserLockInfo Xform, makeLaserParams
17+ Picks, makeLaserLockInfo Xform, makeLaserParams, AddressManager, getEntityParents
1818 */
1919
2020 Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@@ -375,7 +375,7 @@ Script.include("/~/system/libraries/Xform.js"); · 354 unmodified lines
375375 return true;
376376 }
377377 return false;
378− }
378+ };
379379
380380 this.isReady = function (controllerData) {
381381 if (HMD.active) {
@@ -449,11 +449,16 @@ Script.include("/~/system/libraries/Xform.js"); · 67 unmodified lines
449449 if (rayPickInfo.type === Picks.INTERSECTED_ENTITY) {
450450 if (controllerData.triggerClicks[this.hand]) {
451451 var entityID = rayPickInfo.objectID;
452+
452453 var targetProps = Entities.getEntityProperties(entityID, [
453454 "dynamic", "shapeType", "position",
454455 "rotation", "dimensions", "density",
455− "userData", "locked", "type"
456+ "userData", "locked", "type", "href"
456457 ]);
458+ if (targetProps.href !== "") {
459+ AddressManager.handleLookupString(targetProps.href);
460+ return makeRunningValues(false, [], []);
461+ }
457462
458463 this.targetObject = new TargetObject(entityID, targetProps);
459464 this.targetObject.parentProps = getEntityParents(targetProps);
@@ -480,7 +485,8 @@ Script.include("/~/system/libraries/Xform.js"); · 20 unmodified lines
480485 this.grabbedDistance = rayPickInfo.distance;
481486 }
482487
483− if (otherFarGrabModule.grabbedThingID === this.grabbedThingID && otherFarGrabModule.distanceHolding) {
488+ if (otherFarGrabModule.grabbedThingID === this.grabbedThingID &&
489+ otherFarGrabModule.distanceHolding) {
484490 this.prepareDistanceRotatingData(controllerData);
485491 this.distanceRotate(otherFarGrabModule);
486492 } 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