mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
revert pointer changes
This commit is contained in:
parent
fed39d9056
commit
5ad5899140
1 changed files with 35 additions and 109 deletions
|
@ -23,12 +23,12 @@
|
||||||
|
|
||||||
// UTILITIES -------------
|
// UTILITIES -------------
|
||||||
//
|
//
|
||||||
function ignore() {}
|
function ignore() { }
|
||||||
|
|
||||||
// Utility to make it easier to setup and disconnect cleanly.
|
// Utility to make it easier to setup and disconnect cleanly.
|
||||||
function setupHandler(event, handler) {
|
function setupHandler(event, handler) {
|
||||||
event.connect(handler);
|
event.connect(handler);
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function () {
|
||||||
event.disconnect(handler);
|
event.disconnect(handler);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,10 @@ function setupHandler(event, handler) {
|
||||||
// If some capability is not available until expiration milliseconds after the last update.
|
// If some capability is not available until expiration milliseconds after the last update.
|
||||||
function TimeLock(expiration) {
|
function TimeLock(expiration) {
|
||||||
var last = 0;
|
var last = 0;
|
||||||
this.update = function(optionalNow) {
|
this.update = function (optionalNow) {
|
||||||
last = optionalNow || Date.now();
|
last = optionalNow || Date.now();
|
||||||
};
|
};
|
||||||
this.expired = function(optionalNow) {
|
this.expired = function (optionalNow) {
|
||||||
return ((optionalNow || Date.now()) - last) > expiration;
|
return ((optionalNow || Date.now()) - last) > expiration;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,9 @@ function Trigger(label) {
|
||||||
that.rawTriggerValue = 0;
|
that.rawTriggerValue = 0;
|
||||||
that.triggerValue = 0; // rolling average of trigger value
|
that.triggerValue = 0; // rolling average of trigger value
|
||||||
that.triggerClicked = false;
|
that.triggerClicked = false;
|
||||||
that.triggerClick = function(value) {
|
that.triggerClick = function (value) { that.triggerClicked = value; };
|
||||||
that.triggerClicked = value;
|
that.triggerPress = function (value) { that.rawTriggerValue = value; };
|
||||||
};
|
that.updateSmoothedTrigger = function () { // e.g., call once/update for effect
|
||||||
that.triggerPress = function(value) {
|
|
||||||
that.rawTriggerValue = value;
|
|
||||||
};
|
|
||||||
that.updateSmoothedTrigger = function() { // e.g., call once/update for effect
|
|
||||||
var triggerValue = that.rawTriggerValue;
|
var triggerValue = that.rawTriggerValue;
|
||||||
// smooth out trigger value
|
// smooth out trigger value
|
||||||
that.triggerValue = (that.triggerValue * that.TRIGGER_SMOOTH_RATIO) +
|
that.triggerValue = (that.triggerValue * that.TRIGGER_SMOOTH_RATIO) +
|
||||||
|
@ -70,19 +66,19 @@ function Trigger(label) {
|
||||||
OffscreenFlags.navigationFocusDisabled = that.triggerValue != 0.0;
|
OffscreenFlags.navigationFocusDisabled = that.triggerValue != 0.0;
|
||||||
};
|
};
|
||||||
// Current smoothed state, without hysteresis. Answering booleans.
|
// Current smoothed state, without hysteresis. Answering booleans.
|
||||||
that.triggerSmoothedClick = function() {
|
that.triggerSmoothedClick = function () {
|
||||||
return that.triggerClicked;
|
return that.triggerClicked;
|
||||||
};
|
};
|
||||||
that.triggerSmoothedSqueezed = function() {
|
that.triggerSmoothedSqueezed = function () {
|
||||||
return that.triggerValue > that.TRIGGER_ON_VALUE;
|
return that.triggerValue > that.TRIGGER_ON_VALUE;
|
||||||
};
|
};
|
||||||
that.triggerSmoothedReleased = function() {
|
that.triggerSmoothedReleased = function () {
|
||||||
return that.triggerValue < that.TRIGGER_OFF_VALUE;
|
return that.triggerValue < that.TRIGGER_OFF_VALUE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This part is not from handControllerGrab.js
|
// This part is not from handControllerGrab.js
|
||||||
that.state = null; // tri-state: falsey, 'partial', 'full'
|
that.state = null; // tri-state: falsey, 'partial', 'full'
|
||||||
that.update = function() { // update state, called from an update function
|
that.update = function () { // update state, called from an update function
|
||||||
var state = that.state;
|
var state = that.state;
|
||||||
that.updateSmoothedTrigger();
|
that.updateSmoothedTrigger();
|
||||||
|
|
||||||
|
@ -100,10 +96,10 @@ function Trigger(label) {
|
||||||
that.state = state;
|
that.state = state;
|
||||||
};
|
};
|
||||||
// Answer a controller source function (answering either 0.0 or 1.0).
|
// Answer a controller source function (answering either 0.0 or 1.0).
|
||||||
that.partial = function() {
|
that.partial = function () {
|
||||||
return that.state ? 1.0 : 0.0; // either 'partial' or 'full'
|
return that.state ? 1.0 : 0.0; // either 'partial' or 'full'
|
||||||
};
|
};
|
||||||
that.full = function() {
|
that.full = function () {
|
||||||
return (that.state === 'full') ? 1.0 : 0.0;
|
return (that.state === 'full') ? 1.0 : 0.0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -119,7 +115,6 @@ function updateFieldOfView() {
|
||||||
// SHIMS ----------
|
// SHIMS ----------
|
||||||
//
|
//
|
||||||
var weMovedReticle = false;
|
var weMovedReticle = false;
|
||||||
|
|
||||||
function ignoreMouseActivity() {
|
function ignoreMouseActivity() {
|
||||||
// If we're paused, or if change in cursor position is from this script, not the hardware mouse.
|
// If we're paused, or if change in cursor position is from this script, not the hardware mouse.
|
||||||
if (!Reticle.allowMouseCapture) {
|
if (!Reticle.allowMouseCapture) {
|
||||||
|
@ -137,16 +132,13 @@ function ignoreMouseActivity() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var MARGIN = 25;
|
var MARGIN = 25;
|
||||||
var reticleMinX = MARGIN,
|
var reticleMinX = MARGIN, reticleMaxX, reticleMinY = MARGIN, reticleMaxY;
|
||||||
reticleMaxX, reticleMinY = MARGIN,
|
|
||||||
reticleMaxY;
|
|
||||||
|
|
||||||
function updateRecommendedArea() {
|
function updateRecommendedArea() {
|
||||||
var dims = Controller.getViewportDimensions();
|
var dims = Controller.getViewportDimensions();
|
||||||
reticleMaxX = dims.x - MARGIN;
|
reticleMaxX = dims.x - MARGIN;
|
||||||
reticleMaxY = dims.y - MARGIN;
|
reticleMaxY = dims.y - MARGIN;
|
||||||
}
|
}
|
||||||
var setReticlePosition = function(point2d) {
|
var setReticlePosition = function (point2d) {
|
||||||
weMovedReticle = true;
|
weMovedReticle = true;
|
||||||
point2d.x = Math.max(reticleMinX, Math.min(point2d.x, reticleMaxX));
|
point2d.x = Math.max(reticleMinX, Math.min(point2d.x, reticleMaxX));
|
||||||
point2d.y = Math.max(reticleMinY, Math.min(point2d.y, reticleMaxY));
|
point2d.y = Math.max(reticleMinY, Math.min(point2d.y, reticleMaxY));
|
||||||
|
@ -162,7 +154,6 @@ function findRayIntersection(pickRay) {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPointingAtOverlay(optionalHudPosition2d) {
|
function isPointingAtOverlay(optionalHudPosition2d) {
|
||||||
return Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(optionalHudPosition2d || Reticle.position);
|
return Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(optionalHudPosition2d || Reticle.position);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +161,6 @@ function isPointingAtOverlay(optionalHudPosition2d) {
|
||||||
// Generalized HUD utilities, with or without HMD:
|
// Generalized HUD utilities, with or without HMD:
|
||||||
// This "var" is for documentation. Do not change the value!
|
// This "var" is for documentation. Do not change the value!
|
||||||
var PLANAR_PERPENDICULAR_HUD_DISTANCE = 1;
|
var PLANAR_PERPENDICULAR_HUD_DISTANCE = 1;
|
||||||
|
|
||||||
function calculateRayUICollisionPoint(position, direction) {
|
function calculateRayUICollisionPoint(position, direction) {
|
||||||
// Answer the 3D intersection of the HUD by the given ray, or falsey if no intersection.
|
// Answer the 3D intersection of the HUD by the given ray, or falsey if no intersection.
|
||||||
if (HMD.active) {
|
if (HMD.active) {
|
||||||
|
@ -190,7 +180,6 @@ function calculateRayUICollisionPoint(position, direction) {
|
||||||
return Vec3.sum(position, Vec3.multiply(scale, direction));
|
return Vec3.sum(position, Vec3.multiply(scale, direction));
|
||||||
}
|
}
|
||||||
var DEGREES_TO_HALF_RADIANS = Math.PI / 360;
|
var DEGREES_TO_HALF_RADIANS = Math.PI / 360;
|
||||||
|
|
||||||
function overlayFromWorldPoint(point) {
|
function overlayFromWorldPoint(point) {
|
||||||
// Answer the 2d pixel-space location in the HUD that covers the given 3D point.
|
// Answer the 2d pixel-space location in the HUD that covers the given 3D point.
|
||||||
// REQUIRES: that the 3d point be on the hud surface!
|
// REQUIRES: that the 3d point be on the hud surface!
|
||||||
|
@ -210,10 +199,7 @@ function overlayFromWorldPoint(point) {
|
||||||
var verticalFraction = 1 - (cameraY / hudHeight + 0.5);
|
var verticalFraction = 1 - (cameraY / hudHeight + 0.5);
|
||||||
var horizontalPixels = size.x * horizontalFraction;
|
var horizontalPixels = size.x * horizontalFraction;
|
||||||
var verticalPixels = size.y * verticalFraction;
|
var verticalPixels = size.y * verticalFraction;
|
||||||
return {
|
return { x: horizontalPixels, y: verticalPixels };
|
||||||
x: horizontalPixels,
|
|
||||||
y: verticalPixels
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey.
|
function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey.
|
||||||
|
@ -245,17 +231,12 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl
|
||||||
// MOUSE ACTIVITY --------
|
// MOUSE ACTIVITY --------
|
||||||
//
|
//
|
||||||
var isSeeking = false;
|
var isSeeking = false;
|
||||||
var averageMouseVelocity = 0,
|
var averageMouseVelocity = 0, lastIntegration = 0, lastMouse;
|
||||||
lastIntegration = 0,
|
|
||||||
lastMouse;
|
|
||||||
var WEIGHTING = 1 / 20; // simple moving average over last 20 samples
|
var WEIGHTING = 1 / 20; // simple moving average over last 20 samples
|
||||||
var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
||||||
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
||||||
|
|
||||||
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
||||||
var now = Date.now(),
|
var now = Date.now(), mouse = Reticle.position, isShaking = false;
|
||||||
mouse = Reticle.position,
|
|
||||||
isShaking = false;
|
|
||||||
if (lastIntegration && (lastIntegration !== now)) {
|
if (lastIntegration && (lastIntegration !== now)) {
|
||||||
var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration);
|
var velocity = Vec3.length(Vec3.subtract(mouse, lastMouse)) / (now - lastIntegration);
|
||||||
averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity);
|
averageMouseVelocity = (ONE_MINUS_WEIGHTING * averageMouseVelocity) + (WEIGHTING * velocity);
|
||||||
|
@ -269,7 +250,6 @@ function isShakingMouse() { // True if the person is waving the mouse around try
|
||||||
}
|
}
|
||||||
var NON_LINEAR_DIVISOR = 2;
|
var NON_LINEAR_DIVISOR = 2;
|
||||||
var MINIMUM_SEEK_DISTANCE = 0.1;
|
var MINIMUM_SEEK_DISTANCE = 0.1;
|
||||||
|
|
||||||
function updateSeeking(doNotStartSeeking) {
|
function updateSeeking(doNotStartSeeking) {
|
||||||
if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) {
|
if (!doNotStartSeeking && (!Reticle.visible || isShakingMouse())) {
|
||||||
if (!isSeeking) {
|
if (!isSeeking) {
|
||||||
|
@ -288,7 +268,6 @@ function updateSeeking(doNotStartSeeking) {
|
||||||
return; // E.g., if parallel to location in HUD
|
return; // E.g., if parallel to location in HUD
|
||||||
}
|
}
|
||||||
var copy = Reticle.position;
|
var copy = Reticle.position;
|
||||||
|
|
||||||
function updateDimension(axis) {
|
function updateDimension(axis) {
|
||||||
var distanceBetween = lookAt2D[axis] - Reticle.position[axis];
|
var distanceBetween = lookAt2D[axis] - Reticle.position[axis];
|
||||||
var move = distanceBetween / NON_LINEAR_DIVISOR;
|
var move = distanceBetween / NON_LINEAR_DIVISOR;
|
||||||
|
@ -298,8 +277,7 @@ function updateSeeking(doNotStartSeeking) {
|
||||||
copy[axis] += move;
|
copy[axis] += move;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var okX = !updateDimension('x'),
|
var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit.
|
||||||
okY = !updateDimension('y'); // Evaluate both. Don't short-circuit.
|
|
||||||
if (okX && okY) {
|
if (okX && okY) {
|
||||||
print('Finished seeking mouse');
|
print('Finished seeking mouse');
|
||||||
isSeeking = false;
|
isSeeking = false;
|
||||||
|
@ -322,19 +300,16 @@ function updateMouseActivity(isClick) {
|
||||||
handControllerLockOut.update(now);
|
handControllerLockOut.update(now);
|
||||||
Reticle.visible = true;
|
Reticle.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function expireMouseCursor(now) {
|
function expireMouseCursor(now) {
|
||||||
if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) {
|
if (!isPointingAtOverlay() && mouseCursorActivity.expired(now)) {
|
||||||
Reticle.visible = false;
|
Reticle.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function hudReticleDistance() { // 3d distance from camera to the reticle position on hud
|
function hudReticleDistance() { // 3d distance from camera to the reticle position on hud
|
||||||
// (The camera is only in the center of the sphere on reset.)
|
// (The camera is only in the center of the sphere on reset.)
|
||||||
var reticlePositionOnHUD = HMD.worldPointFromOverlay(Reticle.position);
|
var reticlePositionOnHUD = HMD.worldPointFromOverlay(Reticle.position);
|
||||||
return Vec3.distance(reticlePositionOnHUD, HMD.position);
|
return Vec3.distance(reticlePositionOnHUD, HMD.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseMove() {
|
function onMouseMove() {
|
||||||
// Display cursor at correct depth (as in depthReticle.js), and updateMouseActivity.
|
// Display cursor at correct depth (as in depthReticle.js), and updateMouseActivity.
|
||||||
if (ignoreMouseActivity()) {
|
if (ignoreMouseActivity()) {
|
||||||
|
@ -352,7 +327,6 @@ function onMouseMove() {
|
||||||
}
|
}
|
||||||
updateMouseActivity(); // After the above, just in case the depth movement is awkward when becoming visible.
|
updateMouseActivity(); // After the above, just in case the depth movement is awkward when becoming visible.
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseClick() {
|
function onMouseClick() {
|
||||||
updateMouseActivity(true);
|
updateMouseActivity(true);
|
||||||
}
|
}
|
||||||
|
@ -371,7 +345,6 @@ var LEFT_HUD_LASER = 1;
|
||||||
var RIGHT_HUD_LASER = 2;
|
var RIGHT_HUD_LASER = 2;
|
||||||
var BOTH_HUD_LASERS = LEFT_HUD_LASER + RIGHT_HUD_LASER;
|
var BOTH_HUD_LASERS = LEFT_HUD_LASER + RIGHT_HUD_LASER;
|
||||||
var activeHudLaser = RIGHT_HUD_LASER;
|
var activeHudLaser = RIGHT_HUD_LASER;
|
||||||
|
|
||||||
function toggleHand() { // unequivocally switch which hand controls mouse position
|
function toggleHand() { // unequivocally switch which hand controls mouse position
|
||||||
if (activeHand === Controller.Standard.RightHand) {
|
if (activeHand === Controller.Standard.RightHand) {
|
||||||
activeHand = Controller.Standard.LeftHand;
|
activeHand = Controller.Standard.LeftHand;
|
||||||
|
@ -384,9 +357,8 @@ function toggleHand() { // unequivocally switch which hand controls mouse positi
|
||||||
}
|
}
|
||||||
clearSystemLaser();
|
clearSystemLaser();
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeToggleAction(hand) { // return a function(0|1) that makes the specified hand control mouse when 1
|
function makeToggleAction(hand) { // return a function(0|1) that makes the specified hand control mouse when 1
|
||||||
return function(on) {
|
return function (on) {
|
||||||
if (on && (activeHand !== hand)) {
|
if (on && (activeHand !== hand)) {
|
||||||
toggleHand();
|
toggleHand();
|
||||||
}
|
}
|
||||||
|
@ -406,7 +378,7 @@ function isPointingAtOverlayStartedNonFullTrigger(trigger) {
|
||||||
// true if isPointingAtOverlay AND we were NOT full triggered when we became so.
|
// true if isPointingAtOverlay AND we were NOT full triggered when we became so.
|
||||||
// The idea is to not count clicks when we're full-triggering and reach the edge of a window.
|
// The idea is to not count clicks when we're full-triggering and reach the edge of a window.
|
||||||
var lockedIn = false;
|
var lockedIn = false;
|
||||||
return function() {
|
return function () {
|
||||||
if (trigger !== activeTrigger) {
|
if (trigger !== activeTrigger) {
|
||||||
return lockedIn = false;
|
return lockedIn = false;
|
||||||
}
|
}
|
||||||
|
@ -426,28 +398,26 @@ clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigge
|
||||||
// clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
// clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||||
// except that we first update the reticle position from the appropriate hand position, before invoking the ContextMenu.
|
// except that we first update the reticle position from the appropriate hand position, before invoking the ContextMenu.
|
||||||
var wantsMenu = 0;
|
var wantsMenu = 0;
|
||||||
clickMapping.from(function() {
|
clickMapping.from(function () { return wantsMenu; }).to(Controller.Actions.ContextMenu);
|
||||||
return wantsMenu;
|
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function (clicked) {
|
||||||
}).to(Controller.Actions.ContextMenu);
|
|
||||||
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function(clicked) {
|
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
activeHudPoint2d(Controller.Standard.RightHand);
|
activeHudPoint2d(Controller.Standard.RightHand);
|
||||||
}
|
}
|
||||||
wantsMenu = clicked;
|
wantsMenu = clicked;
|
||||||
});
|
});
|
||||||
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function(clicked) {
|
clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (clicked) {
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
activeHudPoint2d(Controller.Standard.LeftHand);
|
activeHudPoint2d(Controller.Standard.LeftHand);
|
||||||
}
|
}
|
||||||
wantsMenu = clicked;
|
wantsMenu = clicked;
|
||||||
});
|
});
|
||||||
clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function() {
|
clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function () {
|
||||||
// Allow the reticle depth to be set correctly:
|
// Allow the reticle depth to be set correctly:
|
||||||
// Wait a tick for the context menu to be displayed, and then simulate a (non-hand-controller) mouse move
|
// Wait a tick for the context menu to be displayed, and then simulate a (non-hand-controller) mouse move
|
||||||
// so that the system updates qml state (Reticle.pointingAtSystemOverlay) before it gives us a mouseMove.
|
// so that the system updates qml state (Reticle.pointingAtSystemOverlay) before it gives us a mouseMove.
|
||||||
// We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove
|
// We don't want the system code to always do this for us, because, e.g., we do not want to get a mouseMove
|
||||||
// after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse.
|
// after the Left/RightSecondaryThumb gives us a context menu. Only from the mouse.
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function () {
|
||||||
Reticle.setPosition(Reticle.position);
|
Reticle.setPosition(Reticle.position);
|
||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
@ -459,25 +429,10 @@ clickMapping.enable();
|
||||||
// VISUAL AID -----------
|
// VISUAL AID -----------
|
||||||
// Same properties as handControllerGrab search sphere
|
// Same properties as handControllerGrab search sphere
|
||||||
var LASER_ALPHA = 0.5;
|
var LASER_ALPHA = 0.5;
|
||||||
var LASER_SEARCH_COLOR_XYZW = {
|
var LASER_SEARCH_COLOR_XYZW = {x: 10 / 255, y: 10 / 255, z: 255 / 255, w: LASER_ALPHA};
|
||||||
x: 10 / 255,
|
var LASER_TRIGGER_COLOR_XYZW = {x: 250 / 255, y: 10 / 255, z: 10 / 255, w: LASER_ALPHA};
|
||||||
y: 10 / 255,
|
var SYSTEM_LASER_DIRECTION = {x: 0, y: 0, z: -1};
|
||||||
z: 255 / 255,
|
|
||||||
w: LASER_ALPHA
|
|
||||||
};
|
|
||||||
var LASER_TRIGGER_COLOR_XYZW = {
|
|
||||||
x: 250 / 255,
|
|
||||||
y: 10 / 255,
|
|
||||||
z: 10 / 255,
|
|
||||||
w: LASER_ALPHA
|
|
||||||
};
|
|
||||||
var SYSTEM_LASER_DIRECTION = {
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
z: -1
|
|
||||||
};
|
|
||||||
var systemLaserOn = false;
|
var systemLaserOn = false;
|
||||||
|
|
||||||
function clearSystemLaser() {
|
function clearSystemLaser() {
|
||||||
if (!systemLaserOn) {
|
if (!systemLaserOn) {
|
||||||
return;
|
return;
|
||||||
|
@ -485,12 +440,8 @@ function clearSystemLaser() {
|
||||||
HMD.disableHandLasers(BOTH_HUD_LASERS);
|
HMD.disableHandLasers(BOTH_HUD_LASERS);
|
||||||
systemLaserOn = false;
|
systemLaserOn = false;
|
||||||
weMovedReticle = true;
|
weMovedReticle = true;
|
||||||
Reticle.position = {
|
Reticle.position = { x: -1, y: -1 };
|
||||||
x: -1,
|
|
||||||
y: -1
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setColoredLaser() { // answer trigger state if lasers supported, else falsey.
|
function setColoredLaser() { // answer trigger state if lasers supported, else falsey.
|
||||||
var color = (activeTrigger.state === 'full') ? LASER_TRIGGER_COLOR_XYZW : LASER_SEARCH_COLOR_XYZW;
|
var color = (activeTrigger.state === 'full') ? LASER_TRIGGER_COLOR_XYZW : LASER_SEARCH_COLOR_XYZW;
|
||||||
return HMD.setHandLasers(activeHudLaser, true, color, SYSTEM_LASER_DIRECTION) && activeTrigger.state;
|
return HMD.setHandLasers(activeHudLaser, true, color, SYSTEM_LASER_DIRECTION) && activeTrigger.state;
|
||||||
|
@ -500,7 +451,6 @@ function setColoredLaser() { // answer trigger state if lasers supported, else f
|
||||||
//
|
//
|
||||||
function update() {
|
function update() {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
function off() {
|
function off() {
|
||||||
expireMouseCursor();
|
expireMouseCursor();
|
||||||
clearSystemLaser();
|
clearSystemLaser();
|
||||||
|
@ -554,31 +504,7 @@ function checkSettings() {
|
||||||
checkSettings();
|
checkSettings();
|
||||||
|
|
||||||
var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL);
|
var settingsChecker = Script.setInterval(checkSettings, SETTINGS_CHANGE_RECHECK_INTERVAL);
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function () {
|
||||||
Script.clearInterval(settingsChecker);
|
Script.clearInterval(settingsChecker);
|
||||||
OffscreenFlags.navigationFocusDisabled = false;
|
OffscreenFlags.navigationFocusDisabled = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
var isDisabled = false;
|
|
||||||
var handleHandMessages = function(channel, message, sender) {
|
|
||||||
var data;
|
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
|
||||||
if (channel === 'Hifi-Hand-Pointer-Disabler') {
|
|
||||||
if (message === 'both') {
|
|
||||||
isDisabled = 'both';
|
|
||||||
}
|
|
||||||
if (message === 'left') {
|
|
||||||
isDisabled = 'left';
|
|
||||||
}
|
|
||||||
if (message === 'right') {
|
|
||||||
isDisabled = 'right';
|
|
||||||
}
|
|
||||||
if (message === 'none') {
|
|
||||||
isDisabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Messages.subscribe('Hifi-Hand-Pointer-Disabler');
|
|
||||||
Messages.messageReceived.connect(handleHandMessages);
|
|
Loading…
Reference in a new issue