unviersial web3d vs laser

This commit is contained in:
Dante Ruiz 2017-08-25 17:40:30 -07:00
parent a5508c9f75
commit 0eceb7b382
4 changed files with 33 additions and 32 deletions

View file

@ -33,6 +33,7 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
var totalVariance = 0;
var highVarianceCount = 0;
var veryhighVarianceCount = 0;
this.tabletID = null;
// a module can occupy one or more "activity" slots while it's running. If all the required slots for a module are
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
@ -126,8 +127,17 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
return deltaTime;
};
this.setIgnoreTablet = function() {
if (HMD.tabletID !== _this.tabletID) {
RayPick.setIgnoreOverlays(_this.leftControllerRayPick, [HMD.tabletID]);
RayPick.setIgnoreOverlays(_this.rightControllerRayPick, [HMD.tabletID]);
tabletIgnored = true
}
}
this.update = function () {
var deltaTime = this.updateTimings();
this.setIgnoreTablet()
if (controllerDispatcherPluginsNeedSort) {
this.orderedPluginNames = [];
@ -336,6 +346,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
});
this.cleanup = function () {
Script.update.disconnect(_this.update);
Controller.disableMapping(MAPPING_NAME);

View file

@ -317,17 +317,18 @@ Script.include("/~/system/libraries/controllers.js");
this.grabbedThingID = null;
};
this.pointingOnTablet = function(controllerData) {
var target = controllerData.rayPicks[this.hand].objectID;
if (target === HMD.homeButtonID || target === HMD.tabletScreenID) {
this.pointingAtWebOverlay = function(controllerData) {
var intersection = controllerData.rayPicks[this.hand];
var overlayType = Overlays.getOverlayType(intersection.objectID);
print(JSON.stringify(Entities.getEntityProperties(intersection.objectID)));
if ((intersection.type === RayPick.INTERSECTED_OVERLAY && overlayType === "web3d") || intersection.objectID === HMD.tabletButtonID) {
return true;
}
return false
};
this.isReady = function (controllerData) {
if (this.pointingOnTablet(controllerData)) {
if (this.pointingAtWebOverlay(controllerData)) {
return makeRunningValues(false, [], []);
}
@ -343,7 +344,7 @@ Script.include("/~/system/libraries/controllers.js");
};
this.run = function (controllerData) {
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.pointingOnTablet(controllerData)) {
if (controllerData.triggerValues[this.hand] < TRIGGER_OFF_VALUE || this.pointingAtWebOverlay(controllerData)) {
this.endNearGrabAction();
this.laserPointerOff();
return makeRunningValues(false, [], []);

View file

@ -275,7 +275,7 @@ Script.include("/~/system/libraries/controllers.js");
this.active = false;
this.previousLaserClikcedTarget = false;
this.laserPressingTarget = false;
this.tabletScreenID = HMD.tabletScreenID;
this.tabletScreenID = null;
this.mode = "none";
this.laserTargetID = null;
this.laserTarget = null;
@ -361,9 +361,10 @@ Script.include("/~/system/libraries/controllers.js");
};
this.hovering = function() {
if (this.hasTouchFocus(this.laserTargetID)) {
sendHoverOverEventToLaserTarget(this.hand, this.laserTarget);
if (!laserTargetHasKeyboardFocus(this.laserTagetID)) {
setKeyboardFocusOnLaserTarget(this.laserTargetID);
}
sendHoverOverEventToLaserTarget(this.hand, this.laserTarget);
};
this.laserPressEnter = function () {
@ -412,33 +413,21 @@ Script.include("/~/system/libraries/controllers.js");
}
};
this.pointingAtTablet = function(target) {
return (target === HMD.tabletID);
};
this.pointingAtTabletScreen = function(target) {
return (target === HMD.tabletScreenID);
}
this.pointingAtHomeButton = function(target) {
return (target === HMD.homeButtonID);
}
this.releaseTouchEvent = function() {
sendTouchEndEventToLaserTarget(this.hand, this.pressEnterLaserTarget);
}
this.updateLaserTargets = function() {
var intersection = LaserPointers.getPrevRayPickResult(this.laserPointer);
this.updateLaserTargets = function(controllerData) {
var intersection = controllerData.rayPicks[this.hand];
this.laserTargetID = intersection.objectID;
this.laserTarget = calculateLaserTargetFromOverlay(intersection.intersection, intersection.objectID);
};
this.shouldExit = function(controllerData) {
var target = controllerData.rayPicks[this.hand].objectID;
var isLaserOffTablet = (!this.pointingAtTabletScreen(target) && !this.pointingAtHomeButton(target) && !this.pointingAtTablet(target));
return isLaserOffTablet;
var intersection = controllerData.rayPicks[this.hand];
var offOverlay = (intersection.type !== RayPick.INTERSECTED_OVERLAY)
return offOverlay;
}
this.exitModule = function() {
@ -461,10 +450,9 @@ Script.include("/~/system/libraries/controllers.js");
};
this.isReady = function (controllerData) {
var target = controllerData.rayPicks[this.hand].objectID;
if (this.pointingAtTabletScreen(target) || this.pointingAtHomeButton(target) || this.pointingAtTablet(target)) {
var intersection = controllerData.rayPicks[this.hand];
if (intersection.type === RayPick.INTERSECTED_OVERLAY) {
if (controllerData.triggerValues[this.hand] > TRIGGER_ON_VALUE && !this.getOtherModule().active) {
this.tabletScrenID = HMD.tabletScreenID;
this.active = true;
return makeRunningValues(true, [], []);
}
@ -480,7 +468,7 @@ Script.include("/~/system/libraries/controllers.js");
return makeRunningValues(false, [], []);
}
this.updateLaserTargets();
this.updateLaserTargets(controllerData);
this.processControllerTriggers(controllerData);
this.updateLaserPointer(controllerData);
@ -511,7 +499,7 @@ Script.include("/~/system/libraries/controllers.js");
this.halfEnd = halfEnd;
this.fullEnd = fullEnd;
this.laserPointer = LaserPointers.createLaserPointer({
joint: (this.hand == RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
joint: (this.hand == RIGHT_HAND) ? "_CONTROLLER_RIGHTHAND" : "_CONTROLLER_LEFTHAND",
filter: RayPick.PICK_OVERLAYS,
maxDistance: PICK_MAX_DISTANCE,
posOffset: getGrabPointSphereOffset(this.handToController()),

View file

@ -26,7 +26,7 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/equipEntity.js",
"controllerModules/nearTrigger.js",
"controllerModules/cloneEntity.js",
"controllerModules/tabletLaserInput.js",
"controllerModules/web3DOverlayLaserInput.js",
"teleport.js"
];