clean up code and finialize changes

This commit is contained in:
Dante Ruiz 2017-11-13 13:37:53 -08:00
parent 43c6d71236
commit 5852224a31
8 changed files with 44 additions and 38 deletions

View file

@ -11,7 +11,7 @@
controllerDispatcherPlugins:true, controllerDispatcherPluginsNeedSort:true,
LEFT_HAND, RIGHT_HAND, NEAR_GRAB_PICK_RADIUS, DEFAULT_SEARCH_SPHERE_DISTANCE, DISPATCHER_PROPERTIES,
getGrabPointSphereOffset, HMD, MyAvatar, Messages, findHandChildEntities, Pointers, PickType, COLORS_GRAB_SEARCHING_HALF_SQUEEZE
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, Picks, TRIGGER_ON_VALUE
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, Picks, TRIGGER_ON_VALUE, PointerManager
*/
controllerDispatcherPlugins = {};
@ -325,11 +325,10 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
_this.runningPluginNames[orderedPluginName] = true;
_this.markSlots(candidatePlugin, orderedPluginName);
_this.pointerManager.makePointerVisible(candidatePlugin.parameters.handLaser);
//_this.enableLaserForPlugin(candidatePlugin);
if (DEBUG) {
print("controllerDispatcher running " + orderedPluginName);
}
}
}
if (PROFILE) {
Script.endProfileRange("dispatch.isReady." + orderedPluginName);
}
@ -473,14 +472,11 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.cleanup = function () {
Script.update.disconnect(_this.update);
Controller.disableMapping(MAPPING_NAME);
Pointers.removePointer(_this.leftControllerPointer);
Pointers.removePointer(_this.rightControllerPointer);
Pointers.removePointer(_this.rightControllerHudRayPick);
Pointers.removePointer(_this.leftControllerHudRayPick);
this.pointerManager.removePointers();
};
}
function mouseReleaseOnOverlay(overlayID, event) {
if (overlayID === HMD.homeButtonID) {
if (overlayID === HMD.homeButtonID && event.button === "Primary") {
Messages.sendLocalMessage("home", overlayID);
}
}

View file

@ -25,7 +25,6 @@
var MARGIN = 25;
var HUD_LASER_OFFSET = 2;
function HudOverlayPointer(hand) {
var _this = this;
this.hand = hand;
this.reticleMinX = MARGIN;
this.reticleMaxX;

View file

@ -77,7 +77,7 @@ Script.include("/~/system/libraries/utils.js");
this.isReady = function(controllerData) {
if (isInEditMode()) {
if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) {
if (controllerData.triggerValues[this.hand] < TRIGGER_ON_VALUE) {
this.triggerClicked = false;
}
return makeRunningValues(true, [], []);

View file

@ -9,14 +9,13 @@
enableDispatcherModule, disableDispatcherModule, makeRunningValues,
Messages, Quat, Vec3, getControllerWorldLocation, makeDispatcherModuleParameters, Overlays, ZERO_VEC,
HMD, INCHES_TO_METERS, DEFAULT_REGISTRATION_POINT, Settings, getGrabPointSphereOffset,
getEnabledModuleByName
getEnabledModuleByName, Pointers, Picks, PickType
*/
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.include("/~/system/libraries/controllers.js");
(function() {
var TouchEventUtils = Script.require("/~/system/libraries/touchEventUtils.js");
function isNearStylusTarget(stylusTargets, maxNormalDistance) {
var stylusTargetIDs = [];
for (var index = 0; index < stylusTargets.length; index++) {
@ -36,7 +35,14 @@ Script.include("/~/system/libraries/controllers.js");
};
}
function TabletStylusInput(hand) {
function getEntityDistance(controllerPosition, entityProps) {
return {
id: entityProps.id,
distance: Vec3.distance(entityProps.position, controllerPosition)
};
}
function TabletStylusInput(hand) {
this.hand = hand;
this.parameters = makeDispatcherModuleParameters(
@ -82,21 +88,9 @@ Script.include("/~/system/libraries/controllers.js");
// build list of stylus targets, near the stylusTip
var stylusTargets = [];
var candidateEntities = controllerData.nearbyEntityProperties;
var candidateOverlays = controllerData.nearbyOverlayIDs;
var controllerPosition = controllerData.controllerLocations[this.hand].position;
var i, props, stylusTarget;
/*for (i = 0; i < candidateEntities.length; i++) {
props = candidateEntities[i];
if (props && props.type === "Web") {
stylusTarget = TouchEventUtils.calculateTouchTargetFromEntity({position: controllerPosition}, candidateEntities[i]);
if (stylusTarget) {
stylusTargets.push(stylusTarget);
}
}
}*/
var i, stylusTarget;
for (i = 0; i < candidateOverlays.length; i++) {
if (candidateOverlays[i] !== HMD.tabletID &&
@ -108,8 +102,6 @@ Script.include("/~/system/libraries/controllers.js");
}
}
// add the tabletScreen, if it is valid
if (HMD.tabletScreenID && HMD.tabletScreenID !== Uuid.NULL &&
Overlays.getProperty(HMD.tabletScreenID, "visible")) {
@ -132,7 +124,6 @@ Script.include("/~/system/libraries/controllers.js");
var nearStylusTarget = isNearStylusTarget(stylusTargets, WEB_DISPLAY_STYLUS_DISTANCE * sensorScaleFactor);
if (nearStylusTarget.length !== 0) {
print(this.hand + "---" + this.disable);
if (!this.disable) {
Pointers.setRenderState(this.pointer,"events on");
Pointers.setIncludeItems(this.pointer, nearStylusTarget);
@ -145,8 +136,6 @@ Script.include("/~/system/libraries/controllers.js");
Pointers.setIncludeItems(this.pointer, []);
return false;
}
// var nearestStylusTarget = calculateNearestStylusTarget(stylusTargets);
};
this.isReady = function (controllerData) {
@ -160,9 +149,9 @@ Script.include("/~/system/libraries/controllers.js");
this.run = function (controllerData, deltaTime) {
return this.isReady(controllerData);
};
this.cleanup = function () {
//Pointers.createPointer(this.pointer);
Pointers.removePointer(this.pointer);
};
}

View file

@ -1,6 +1,6 @@
"use strict";
// overlayLaserInput.js
// webSurfaceLaserInput.js
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -18,6 +18,7 @@ Script.include("/~/system/libraries/controllers.js");
(function() {
function OverlayLaserInput(hand) {
this.hand = hand;
this.running = false;
this.parameters = makeDispatcherModuleParameters(
120,
@ -44,6 +45,10 @@ Script.include("/~/system/libraries/controllers.js");
return false;
};
this.getOtherModule = function() {
return this.hand === RIGHT_HAND ? leftOverlayLaserInput : rightOverlayLaserInput;
};
this.isPointingAtWebEntity = function(controllerData) {
var intersection = controllerData.rayPicks[this.hand];
var entityProperty = Entities.getEntityProperties(intersection.objectID);
@ -72,7 +77,9 @@ Script.include("/~/system/libraries/controllers.js");
};
this.isReady = function (controllerData) {
if (this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) {
var otherModuleRunning = this.getOtherModule().running;
if ((this.isPointingAtOverlay(controllerData) || this.isPointingAtWebEntity(controllerData)) &&
!otherModuleRunning) {
if (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE) {
return makeRunningValues(true, [], []);
}
@ -83,9 +90,11 @@ Script.include("/~/system/libraries/controllers.js");
this.run = function (controllerData, deltaTime) {
var grabModuleNeedsToRun = this.grabModuleWantsNearbyOverlay(controllerData);
if (controllerData.triggerValues[this.hand] > TRIGGER_OFF_VALUE && !grabModuleNeedsToRun) {
this.running = true;
return makeRunningValues(true, [], []);
}
this.deleteContextOverlay();
this.running = false;
return makeRunningValues(false, [], []);
};
}

View file

@ -22,7 +22,7 @@ var CONTOLLER_SCRIPTS = [
"controllerModules/tabletStylusInput.js",
"controllerModules/equipEntity.js",
"controllerModules/nearTrigger.js",
"controllerModules/overlayLaserInput.js",
"controllerModules/webSurfaceLaserInput.js",
"controllerModules/inEditMode.js",
"controllerModules/inVREditMode.js",
"controllerModules/disableOtherModule.js",

View file

@ -101,7 +101,8 @@ DISPATCHER_PROPERTIES = [
"parentJointIndex",
"density",
"dimensions",
"userData"
"userData",
"type"
];
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step

View file

@ -109,9 +109,15 @@ Pointer = function(hudLayer, pickType, pointerData) {
}
this.enable = function() {
Pointers.enablePointer(this.pointerID);
};
this.disable = function() {
Pointers.disablePointer(this.pointerID);
};
this.removePointer = function() {
Pointers.removePointer(this.pointerID);
};
this.makeVisible = function() {
@ -153,7 +159,6 @@ Pointer = function(hudLayer, pickType, pointerData) {
pointerData.renderStates = this.renderStates;
pointerData.defaultRenderStates = this.defaultRenderStates;
this.pointerID = createPointer(pickType, pointerData);
print(this.pointerID);
};
@ -189,4 +194,11 @@ PointerManager = function() {
this.pointers[index].updateRenderState(triggerClicks, triggerValues);
}
};
this.removePointers = function() {
for (var index = 0; index < this.pointers.length; index++) {
this.pointers[index].removePointer();
}
this.pointers = [];
};
};