mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:56:52 +02:00
fix tablet grabbing and eslint changes
This commit is contained in:
parent
b1b31444f0
commit
ec40df711d
3 changed files with 31 additions and 43 deletions
|
@ -10,10 +10,17 @@
|
||||||
// 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, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays,
|
/* global Script, Controller, LaserPointers, RayPick, RIGHT_HAND, LEFT_HAND, Mat4, MyAvatar, Vec3, Camera, Quat,
|
||||||
MyAvatar, Menu, AvatarInputs, Vec3 */
|
getGrabPointSphereOffset, getEnabledModuleByName, makeRunningValues, Entities, NULL_UUID,
|
||||||
|
enableDispatcherModule, disableDispatcherModule, entityIsDistanceGrabbable,
|
||||||
|
makeDispatcherModuleParameters, MSECS_PER_SEC, HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION,
|
||||||
|
PICK_MAX_DISTANCE, COLORS_GRAB_SEARCHING_HALF_SQUEEZE, COLORS_GRAB_SEARCHING_FULL_SQUEEZE, COLORS_GRAB_DISTANCE_HOLD,
|
||||||
|
AVATAR_SELF_ID, DEFAULT_SEARCH_SPHERE_DISTANCE, TRIGGER_OFF_VALUE, TRIGGER_ON_VALUE, ZERO_VEC, ensureDynamic,
|
||||||
|
getControllerWorldLocation, projectOntoEntityXYPlane, ContextOverlay, HMD, Reticle, Overlays, isPointingAtUI
|
||||||
|
|
||||||
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
Script.include("/~/system/libraries/controllers.js")
|
Script.include("/~/system/libraries/controllers.js");
|
||||||
var ControllerDispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
var ControllerDispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
var halfPath = {
|
var halfPath = {
|
||||||
type: "line3d",
|
type: "line3d",
|
||||||
|
@ -82,18 +89,8 @@
|
||||||
{name: "hold", distance: DEFAULT_SEARCH_SPHERE_DISTANCE, path: holdPath}
|
{name: "hold", distance: DEFAULT_SEARCH_SPHERE_DISTANCE, path: holdPath}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// triggered when stylus presses a web overlay/entity
|
|
||||||
var HAPTIC_STYLUS_STRENGTH = 1.0;
|
|
||||||
var HAPTIC_STYLUS_DURATION = 20.0;
|
|
||||||
var MARGIN = 25;
|
var MARGIN = 25;
|
||||||
|
|
||||||
function distance2D(a, b) {
|
|
||||||
var dx = (a.x - b.x);
|
|
||||||
var dy = (a.y - b.y);
|
|
||||||
return Math.sqrt(dx * dx + dy * dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
function HudOverlayPointer(hand) {
|
function HudOverlayPointer(hand) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
|
@ -118,15 +115,11 @@
|
||||||
return _this.triggerClicked;
|
return _this.triggerClicked;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getOtherModule = function() {
|
|
||||||
return (this.hand === RIGHT_HAND) ? leftOverlayLaserInput : rightOverlayLaserInput;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.handToController = function() {
|
this.handToController = function() {
|
||||||
return (this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
return (this.hand === RIGHT_HAND) ? Controller.Standard.RightHand : Controller.Standard.LeftHand;
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
@ -159,7 +152,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.calculateNewReticlePosition = function(intersection) {
|
this.calculateNewReticlePosition = function(intersection) {
|
||||||
this.updateRecommendedArea();
|
this.updateRecommendedArea();
|
||||||
var point2d = HMD.overlayFromWorldPoint(intersection);
|
var point2d = HMD.overlayFromWorldPoint(intersection);
|
||||||
point2d.x = Math.max(this.reticleMinX, Math.min(point2d.x, this.reticleMaxX));
|
point2d.x = Math.max(this.reticleMinX, Math.min(point2d.x, this.reticleMaxX));
|
||||||
|
@ -176,14 +169,6 @@
|
||||||
return (rayPick.objectID === HMD.tabletScreenID || rayPick.objectID === HMD.homeButtonID);
|
return (rayPick.objectID === HMD.tabletScreenID || rayPick.objectID === HMD.homeButtonID);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.moveMouseAwayFromTablet = function() {
|
|
||||||
if (!this.movedAway) {
|
|
||||||
var point = {x: 25, y: 25};
|
|
||||||
// this.setReticlePosition(point);
|
|
||||||
this.movedAway = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.processLaser = function(controllerData) {
|
this.processLaser = function(controllerData) {
|
||||||
var controllerLocation = controllerData.controllerLocations[this.hand];
|
var controllerLocation = controllerData.controllerLocations[this.hand];
|
||||||
if ((controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
if ((controllerData.triggerValues[this.hand] < ControllerDispatcherUtils.TRIGGER_ON_VALUE || !controllerLocation.valid) ||
|
||||||
|
@ -192,7 +177,6 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var hudRayPick = controllerData.hudRayPicks[this.hand];
|
var hudRayPick = controllerData.hudRayPicks[this.hand];
|
||||||
var controllerLocation = controllerData.controllerLocations[this.hand];
|
|
||||||
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
|
var point2d = this.calculateNewReticlePosition(hudRayPick.intersection);
|
||||||
this.setReticlePosition(point2d);
|
this.setReticlePosition(point2d);
|
||||||
if (!Reticle.isPointingAtSystemOverlay(point2d)) {
|
if (!Reticle.isPointingAtSystemOverlay(point2d)) {
|
||||||
|
@ -208,7 +192,6 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
this.exitModule = function() {
|
this.exitModule = function() {
|
||||||
this.moveMouseAwayFromTablet();
|
|
||||||
LaserPointers.disableLaserPointer(this.laserPointer);
|
LaserPointers.disableLaserPointer(this.laserPointer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -240,7 +223,7 @@
|
||||||
enabled: true,
|
enabled: true,
|
||||||
defaultRenderStates: defaultRenderStates
|
defaultRenderStates: defaultRenderStates
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var leftHudOverlayPointer = new HudOverlayPointer(LEFT_HAND);
|
var leftHudOverlayPointer = new HudOverlayPointer(LEFT_HAND);
|
||||||
|
|
|
@ -13,9 +13,6 @@
|
||||||
(function() {
|
(function() {
|
||||||
var ControllerDispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
var ControllerDispatcherUtils = Script.require("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
|
||||||
var WEIGHTING = 1 / 20; // simple moving average over last 20 samples
|
|
||||||
var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
|
||||||
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
|
||||||
function TimeLock(experation) {
|
function TimeLock(experation) {
|
||||||
this.experation = experation;
|
this.experation = experation;
|
||||||
this.last = 0;
|
this.last = 0;
|
||||||
|
@ -67,14 +64,15 @@
|
||||||
var result = controllerData.mouseRayPick;
|
var result = controllerData.mouseRayPick;
|
||||||
Reticle.depth = result.intersects ? result.distance : APPARENT_MAXIMUM_DEPTH;
|
Reticle.depth = result.intersects ? result.distance : APPARENT_MAXIMUM_DEPTH;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
this.ignoreMouseActivity = function() {
|
this.ignoreMouseActivity = function() {
|
||||||
if (!Reticle.allowMouseCapture) {
|
if (!Reticle.allowMouseCapture) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = Reticle.position;
|
var pos = Reticle.position;
|
||||||
if (!pos || (pos.x == -1 && pos.y == -1)) {
|
if (!pos || (pos.x === -1 && pos.y === -1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,10 +248,17 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.nearGrabWantsToRun = function(controllerData) {
|
||||||
|
var moduleName = this.hand === RIGHT_HAND ? "RightNearParentingGrabOverlay" : "LeftNearParentingGrabOverlay";
|
||||||
|
var module = getEnabledModuleByName(moduleName);
|
||||||
|
var ready = module ? module.isReady(controllerData) : makeRunningValues(false, [], []);
|
||||||
|
return ready.active;
|
||||||
|
};
|
||||||
|
|
||||||
this.processStylus = function(controllerData) {
|
this.processStylus = function(controllerData) {
|
||||||
this.updateStylusTip();
|
this.updateStylusTip();
|
||||||
|
|
||||||
if (!this.stylusTip.valid || this.overlayLaserActive(controllerData)) {
|
if (!this.stylusTip.valid || this.overlayLaserActive(controllerData) || this.nearGrabWantsToRun(controllerData)) {
|
||||||
this.pointFinger(false);
|
this.pointFinger(false);
|
||||||
this.hideStylus();
|
this.hideStylus();
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue