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 totalVariance = 0;
var highVarianceCount = 0; var highVarianceCount = 0;
var veryhighVarianceCount = 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 // 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 // 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; 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 () { this.update = function () {
var deltaTime = this.updateTimings(); var deltaTime = this.updateTimings();
this.setIgnoreTablet()
if (controllerDispatcherPluginsNeedSort) { if (controllerDispatcherPluginsNeedSort) {
this.orderedPluginNames = []; this.orderedPluginNames = [];
@ -336,6 +346,8 @@ Script.include("/~/system/controllers/controllerDispatcherUtils.js");
}); });
this.cleanup = function () { this.cleanup = function () {
Script.update.disconnect(_this.update); Script.update.disconnect(_this.update);
Controller.disableMapping(MAPPING_NAME); Controller.disableMapping(MAPPING_NAME);

View file

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

View file

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

View file

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