eslint controller modules

This commit is contained in:
Dante Ruiz 2017-11-01 11:36:36 -07:00
parent abb6f786fa
commit 66f07cb21b
15 changed files with 36 additions and 41 deletions

View file

@ -10,7 +10,8 @@
/* global Script, Entities, Overlays, Controller, Vec3, Quat, getControllerWorldLocation, RayPick, /* global Script, Entities, Overlays, Controller, Vec3, Quat, getControllerWorldLocation, RayPick,
controllerDispatcherPlugins:true, controllerDispatcherPluginsNeedSort:true, controllerDispatcherPlugins:true, controllerDispatcherPluginsNeedSort:true,
LEFT_HAND, RIGHT_HAND, NEAR_GRAB_PICK_RADIUS, DEFAULT_SEARCH_SPHERE_DISTANCE, DISPATCHER_PROPERTIES, LEFT_HAND, RIGHT_HAND, NEAR_GRAB_PICK_RADIUS, DEFAULT_SEARCH_SPHERE_DISTANCE, DISPATCHER_PROPERTIES,
getGrabPointSphereOffset, HMD, MyAvatar, Messages, findHandChildEntities getGrabPointSphereOffset, HMD, MyAvatar, Messages, findHandChildEntities, Pointers, PickType, COLORS_GRAB_SEARCHING_HALF_SQUEEZE
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, Picks
*/ */
controllerDispatcherPlugins = {}; controllerDispatcherPlugins = {};
@ -157,7 +158,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
var handLaser = plugin.parameters.handLaser; var handLaser = plugin.parameters.handLaser;
if (handLaser !== undefined) { if (handLaser !== undefined) {
_this.laserVisibleStatus[handLaser] = false; _this.laserVisibleStatus[handLaser] = false;
_this.laserLockStatus[handLaser] = false; _this.laserLockStatus[handLaser] = false;
} }
}; };
@ -258,16 +259,16 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
// update left hand laser // update left hand laser
var HUD_LASER_OFFSET = 2; var HUD_LASER_OFFSET = 2;
var laserLocked;
if (_this.laserVisibleStatus[LEFT_HAND]) { if (_this.laserVisibleStatus[LEFT_HAND]) {
var laserLocked = _this.laserLockStatus[LEFT_HAND]; laserLocked = _this.laserLockStatus[LEFT_HAND];
_this.updateLaserRenderState(_this.leftControllerPointer,_this.leftTriggerClicked, laserLocked); _this.updateLaserRenderState(_this.leftControllerPointer,_this.leftTriggerClicked, laserLocked);
} else { } else {
Pointers.setRenderState(_this.leftControllerPointer, ""); Pointers.setRenderState(_this.leftControllerPointer, "");
} }
//update right hand laser
if (_this.laserVisibleStatus[RIGHT_HAND]) { if (_this.laserVisibleStatus[RIGHT_HAND]) {
var laserLocked = _this.laserLockStatus[RIGHT_HAND]; laserLocked = _this.laserLockStatus[RIGHT_HAND];
_this.updateLaserRenderState(_this.rightControllerPointer, _this.rightTriggerClicked, laserLocked); _this.updateLaserRenderState(_this.rightControllerPointer, _this.rightTriggerClicked, laserLocked);
} else { } else {
Pointers.setRenderState(_this.rightControllerPointer, ""); Pointers.setRenderState(_this.rightControllerPointer, "");
@ -636,8 +637,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
} }
function mouseReleaseOnOverlay(overlayID, event) { function mouseReleaseOnOverlay(overlayID, event) {
if (overlayID === HMD.homeButtonID) { if (overlayID === HMD.homeButtonID) {
print(JSON.stringify(event));
print("---------> go home <--------");
Messages.sendLocalMessage("home", overlayID); Messages.sendLocalMessage("home", overlayID);
} }
} }

View file

@ -73,13 +73,13 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
} }
} }
} }
}; }
Messages.subscribe('Hifi-Hand-Disabler'); Messages.subscribe('Hifi-Hand-Disabler');
function cleanup() { function cleanup() {
disableDispatcherModule("LeftDisableModules"); disableDispatcherModule("LeftDisableModules");
disableDispatcherModule("RightDisableModules"); disableDispatcherModule("RightDisableModules");
}; }
Messages.messageReceived.connect(handleMessage); Messages.messageReceived.connect(handleMessage);
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -773,6 +773,6 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
disableDispatcherModule("LeftEquipEntity"); disableDispatcherModule("LeftEquipEntity");
disableDispatcherModule("RightEquipEntity"); disableDispatcherModule("RightEquipEntity");
clearAttachPoints(); clearAttachPoints();
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -14,14 +14,13 @@
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
Picks, makeLaserLockInfo
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Script.include("/~/system/libraries/controllers.js"); Script.include("/~/system/libraries/controllers.js");
(function() { (function() {
var PICK_WITH_HAND_RAY = true;
var GRABBABLE_PROPERTIES = [ var GRABBABLE_PROPERTIES = [
"position", "position",
"registrationPoint", "registrationPoint",
@ -249,7 +248,7 @@ Script.include("/~/system/libraries/controllers.js");
this.grabbedThingID = null; this.grabbedThingID = null;
}; };
this.updateRecommendedArea = function() { this.updateRecommendedArea = function() {
var dims = Controller.getViewportDimensions(); var dims = Controller.getViewportDimensions();
this.reticleMaxX = dims.x - MARGIN; this.reticleMaxX = dims.x - MARGIN;
this.reticleMaxY = dims.y - MARGIN; this.reticleMaxY = dims.y - MARGIN;
@ -480,6 +479,6 @@ Script.include("/~/system/libraries/controllers.js");
rightFarActionGrabEntity.cleanup(); rightFarActionGrabEntity.cleanup();
disableDispatcherModule("LeftFarActionGrabEntity"); disableDispatcherModule("LeftFarActionGrabEntity");
disableDispatcherModule("RightFarActionGrabEntity"); disableDispatcherModule("RightFarActionGrabEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -99,6 +99,6 @@ Script.include("/~/system/libraries/controllers.js");
function cleanup() { function cleanup() {
disableDispatcherModule("LeftFarTriggerEntity"); disableDispatcherModule("LeftFarTriggerEntity");
disableDispatcherModule("RightFarTriggerEntity"); disableDispatcherModule("RightFarTriggerEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -10,7 +10,7 @@
/* global Script, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, makeRunningValues, /* global Script, Controller, RIGHT_HAND, LEFT_HAND, enableDispatcherModule, disableDispatcherModule, makeRunningValues,
Messages, makeDispatcherModuleParameters, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, Messages, makeDispatcherModuleParameters, HMD, getGrabPointSphereOffset, COLORS_GRAB_SEARCHING_HALF_SQUEEZE,
COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_ON_VALUE,
getEnabledModuleByName, PICK_MAX_DISTANCE, isInEditMode, LaserPointers, RayPick getEnabledModuleByName, PICK_MAX_DISTANCE, isInEditMode, LaserPointers, RayPick, Picks
*/ */
Script.include("/~/system/libraries/controllerDispatcherUtils.js"); Script.include("/~/system/libraries/controllerDispatcherUtils.js");
@ -128,7 +128,7 @@ Script.include("/~/system/libraries/utils.js");
rightHandInEditMode.cleanup(); rightHandInEditMode.cleanup();
disableDispatcherModule("LeftHandInEditMode"); disableDispatcherModule("LeftHandInEditMode");
disableDispatcherModule("RightHandInEditMode"); disableDispatcherModule("RightHandInEditMode");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -261,6 +261,6 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
rightNearActionGrabEntity.cleanup(); rightNearActionGrabEntity.cleanup();
disableDispatcherModule("LeftNearActionGrabEntity"); disableDispatcherModule("LeftNearActionGrabEntity");
disableDispatcherModule("RightNearActionGrabEntity"); disableDispatcherModule("RightNearActionGrabEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -343,6 +343,6 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
rightNearParentingGrabEntity.cleanup(); rightNearParentingGrabEntity.cleanup();
disableDispatcherModule("LeftNearParentingGrabEntity"); disableDispatcherModule("LeftNearParentingGrabEntity");
disableDispatcherModule("RightNearParentingGrabEntity"); disableDispatcherModule("RightNearParentingGrabEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -229,6 +229,6 @@ Script.include("/~/system/libraries/utils.js");
rightNearParentingGrabOverlay.cleanup(); rightNearParentingGrabOverlay.cleanup();
disableDispatcherModule("LeftNearParentingGrabOverlay"); disableDispatcherModule("LeftNearParentingGrabOverlay");
disableDispatcherModule("RightNearParentingGrabOverlay"); disableDispatcherModule("RightNearParentingGrabOverlay");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -115,6 +115,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
rightNearTriggerEntity.cleanup(); rightNearTriggerEntity.cleanup();
disableDispatcherModule("LeftNearTriggerEntity"); disableDispatcherModule("LeftNearTriggerEntity");
disableDispatcherModule("RightNearTriggerEntity"); disableDispatcherModule("RightNearTriggerEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -95,6 +95,6 @@ Script.include("/~/system/libraries/controllers.js");
function cleanup() { function cleanup() {
disableDispatcherModule("LeftOverlayLaserInput"); disableDispatcherModule("LeftOverlayLaserInput");
disableDispatcherModule("RightOverlayLaserInput"); disableDispatcherModule("RightOverlayLaserInput");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());

View file

@ -8,7 +8,6 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* global Script, Vec3, MyAvatar, RIGHT_HAND */ /* global Script, Vec3, MyAvatar, RIGHT_HAND */
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
(function () { (function () {
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js"); var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
@ -59,7 +58,7 @@
if (this.hand === dispatcherUtils.RIGHT_HAND) { if (this.hand === dispatcherUtils.RIGHT_HAND) {
var scalingCurrentDistance = var scalingCurrentDistance =
Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position, Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position,
controllerData.controllerLocations[this.otherHand()].position)); controllerData.controllerLocations[this.otherHand()].position));
var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale; var newAvatarScale = (scalingCurrentDistance / this.scalingStartDistance) * this.scalingStartAvatarScale;
MyAvatar.scale = newAvatarScale; MyAvatar.scale = newAvatarScale;
@ -79,6 +78,6 @@
function cleanup() { function cleanup() {
dispatcherUtils.disableDispatcherModule("LeftScaleAvatar"); dispatcherUtils.disableDispatcherModule("LeftScaleAvatar");
dispatcherUtils.disableDispatcherModule("RightScaleAvatar"); dispatcherUtils.disableDispatcherModule("RightScaleAvatar");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
})(); })();

View file

@ -8,11 +8,9 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* global Script, Vec3, MyAvatar, RIGHT_HAND */ /* global Script, Vec3, MyAvatar, RIGHT_HAND */
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
(function() { (function() {
var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js"); var dispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
function ScaleEntity(hand) { function ScaleEntity(hand) {
this.hand = hand; this.hand = hand;
this.grabbedThingID = false; this.grabbedThingID = false;
@ -81,7 +79,7 @@
if (this.hand === dispatcherUtils.RIGHT_HAND) { if (this.hand === dispatcherUtils.RIGHT_HAND) {
var scalingCurrentDistance = var scalingCurrentDistance =
Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position, Vec3.length(Vec3.subtract(controllerData.controllerLocations[this.hand].position,
controllerData.controllerLocations[this.otherHand()].position)); controllerData.controllerLocations[this.otherHand()].position));
var currentRescale = scalingCurrentDistance / this.scalingStartDistance; var currentRescale = scalingCurrentDistance / this.scalingStartDistance;
var newDimensions = Vec3.multiply(currentRescale, this.scalingStartDimensions); var newDimensions = Vec3.multiply(currentRescale, this.scalingStartDimensions);
Entities.editEntity(this.grabbedThingID, { dimensions: newDimensions }); Entities.editEntity(this.grabbedThingID, { dimensions: newDimensions });
@ -101,6 +99,6 @@
function cleanup() { function cleanup() {
dispatcherUtils.disableDispatcherModule("LeftScaleEntity"); dispatcherUtils.disableDispatcherModule("LeftScaleEntity");
dispatcherUtils.disableDispatcherModule("RightScaleEntity"); dispatcherUtils.disableDispatcherModule("RightScaleEntity");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
})(); })();

View file

@ -12,7 +12,7 @@
/* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex, /* global Script, Entities, MyAvatar, Controller, RIGHT_HAND, LEFT_HAND, getControllerJointIndex,
enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3, enableDispatcherModule, disableDispatcherModule, Messages, makeDispatcherModuleParameters, makeRunningValues, Vec3,
LaserPointers, RayPick, HMD, Uuid, AvatarList LaserPointers, RayPick, HMD, Uuid, AvatarList, Picks
*/ */
Script.include("/~/system/libraries/Xform.js"); Script.include("/~/system/libraries/Xform.js");
@ -109,8 +109,8 @@ Script.include("/~/system/libraries/controllers.js");
var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, var teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd},
{name: "teleport", path: teleportPath, end: teleportEnd}, {name: "teleport", path: teleportPath, end: teleportEnd},
{name: "seat", path: seatPath, end: seatEnd}]; {name: "seat", path: seatPath, end: seatEnd}];
var DEFAULT_DISTANCE = 50; var DEFAULT_DISTANCE = 50;
var teleportDefaultRenderStates = [{name: "cancel", distance: DEFAULT_DISTANCE, path: cancelPath}]; var teleportDefaultRenderStates = [{name: "cancel", distance: DEFAULT_DISTANCE, path: cancelPath}];
@ -127,18 +127,18 @@ Script.include("/~/system/libraries/controllers.js");
}; };
var TARGET = { var TARGET = {
NONE: 'none', // Not currently targetting anything NONE: 'none', // Not currently targetting anything
INVISIBLE: 'invisible', // The current target is an invvsible surface INVISIBLE: 'invisible', // The current target is an invvsible surface
INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.) INVALID: 'invalid', // The current target is invalid (wall, ceiling, etc.)
SURFACE: 'surface', // The current target is a valid surface SURFACE: 'surface', // The current target is a valid surface
SEAT: 'seat' // The current target is a seat SEAT: 'seat' // The current target is a seat
}; };
function Teleporter(hand) { function Teleporter(hand) {
var _this = this; var _this = this;
this.hand = hand; this.hand = hand;
this.buttonValue = 0; this.buttonValue = 0;
this.disabled = false; // used by the 'Hifi-Teleport-Disabler' message handler this.disabled = false; // used by the 'Hifi-Teleport-Disabler' message handler
this.active = false; this.active = false;
this.state = TELEPORTER_STATES.IDLE; this.state = TELEPORTER_STATES.IDLE;
this.currentTarget = TARGET.INVALID; this.currentTarget = TARGET.INVALID;
@ -218,8 +218,8 @@ Script.include("/~/system/libraries/controllers.js");
seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS;
teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd},
{name: "teleport", path: teleportPath, end: teleportEnd}, {name: "teleport", path: teleportPath, end: teleportEnd},
{name: "seat", path: seatPath, end: seatEnd}]; {name: "seat", path: seatPath, end: seatEnd}];
LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]); LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]);
LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]); LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]);

View file

@ -60,7 +60,7 @@ Script.include("/~/system/libraries/controllers.js");
function cleanup() { function cleanup() {
disableDispatcherModule("LeftWebEntityLaserInput"); disableDispatcherModule("LeftWebEntityLaserInput");
disableDispatcherModule("RightWebEntityLaserInput"); disableDispatcherModule("RightWebEntityLaserInput");
}; }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);
}()); }());