mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 03:29:16 +02:00
allow highlights in hmd, fix center scale hmd math
This commit is contained in:
parent
cf1c1296a7
commit
3da442a8f9
2 changed files with 104 additions and 59 deletions
|
@ -860,7 +860,7 @@ var toolBar = (function () {
|
||||||
propertiesTool.setVisible(false);
|
propertiesTool.setVisible(false);
|
||||||
selectionManager.clearSelections();
|
selectionManager.clearSelections();
|
||||||
cameraManager.disable();
|
cameraManager.disable();
|
||||||
selectionDisplay.triggerMapping.disable();
|
selectionDisplay.disableTriggerMapping();
|
||||||
tablet.landscape = false;
|
tablet.landscape = false;
|
||||||
Controller.disableMapping(CONTROLLER_MAPPING_NAME);
|
Controller.disableMapping(CONTROLLER_MAPPING_NAME);
|
||||||
} else {
|
} else {
|
||||||
|
@ -876,7 +876,7 @@ var toolBar = (function () {
|
||||||
gridTool.setVisible(true);
|
gridTool.setVisible(true);
|
||||||
grid.setEnabled(true);
|
grid.setEnabled(true);
|
||||||
propertiesTool.setVisible(true);
|
propertiesTool.setVisible(true);
|
||||||
selectionDisplay.triggerMapping.enable();
|
selectionDisplay.enableTriggerMapping();
|
||||||
print("starting tablet in landscape mode");
|
print("starting tablet in landscape mode");
|
||||||
tablet.landscape = true;
|
tablet.landscape = true;
|
||||||
Controller.enableMapping(CONTROLLER_MAPPING_NAME);
|
Controller.enableMapping(CONTROLLER_MAPPING_NAME);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
/* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections,
|
/* global SelectionManager, SelectionDisplay, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections,
|
||||||
getMainTabletIDs, getControllerWorldLocation */
|
getMainTabletIDs, getControllerWorldLocation, TRIGGER_ON_VALUE */
|
||||||
|
|
||||||
var SPACE_LOCAL = "local";
|
var SPACE_LOCAL = "local";
|
||||||
var SPACE_WORLD = "world";
|
var SPACE_WORLD = "world";
|
||||||
|
@ -22,6 +22,7 @@ var HIGHLIGHT_LIST_NAME = "editHandleHighlightList";
|
||||||
|
|
||||||
Script.include([
|
Script.include([
|
||||||
"./controllers.js",
|
"./controllers.js",
|
||||||
|
"./controllerDispatcherUtils.js",
|
||||||
"./utils.js"
|
"./utils.js"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -448,6 +449,8 @@ SelectionDisplay = (function() {
|
||||||
var CTRL_KEY_CODE = 16777249;
|
var CTRL_KEY_CODE = 16777249;
|
||||||
|
|
||||||
var RAIL_AXIS_LENGTH = 10000;
|
var RAIL_AXIS_LENGTH = 10000;
|
||||||
|
|
||||||
|
var NO_HAND = -1;
|
||||||
|
|
||||||
var TRANSLATE_DIRECTION = {
|
var TRANSLATE_DIRECTION = {
|
||||||
X: 0,
|
X: 0,
|
||||||
|
@ -478,8 +481,6 @@ SelectionDisplay = (function() {
|
||||||
YAW: 1,
|
YAW: 1,
|
||||||
ROLL: 2
|
ROLL: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
var NO_TRIGGER_HAND = -1;
|
|
||||||
|
|
||||||
var spaceMode = SPACE_LOCAL;
|
var spaceMode = SPACE_LOCAL;
|
||||||
var overlayNames = [];
|
var overlayNames = [];
|
||||||
|
@ -802,11 +803,21 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
||||||
// But we dont' get mousePressEvents.
|
// But we dont' get mousePressEvents.
|
||||||
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
that.triggerClickMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||||
Script.scriptEnding.connect(that.triggerMapping.disable);
|
that.triggerPressMapping = Controller.newMapping(Script.resolvePath('') + '-press');
|
||||||
that.triggeredHand = NO_TRIGGER_HAND;
|
that.triggeredHand = NO_HAND;
|
||||||
|
that.pressedHand = NO_HAND;
|
||||||
that.triggered = function() {
|
that.triggered = function() {
|
||||||
return that.triggeredHand !== NO_TRIGGER_HAND;
|
return that.triggeredHand !== NO_HAND;
|
||||||
|
}
|
||||||
|
function pointingAtDesktopWindowOrTablet(hand) {
|
||||||
|
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
||||||
|
SelectionManager.pointingAtDesktopWindowRight) ||
|
||||||
|
(hand === Controller.Standard.LeftHand &&
|
||||||
|
SelectionManager.pointingAtDesktopWindowLeft);
|
||||||
|
var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) ||
|
||||||
|
(hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft);
|
||||||
|
return pointingAtDesktopWindow || pointingAtTablet;
|
||||||
}
|
}
|
||||||
function makeClickHandler(hand) {
|
function makeClickHandler(hand) {
|
||||||
return function (clicked) {
|
return function (clicked) {
|
||||||
|
@ -814,26 +825,39 @@ SelectionDisplay = (function() {
|
||||||
if (that.triggered() && hand !== that.triggeredHand) {
|
if (that.triggered() && hand !== that.triggeredHand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!that.triggered() && clicked) {
|
if (!that.triggered() && clicked && !pointingAtDesktopWindowOrTablet(hand)) {
|
||||||
var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand &&
|
|
||||||
SelectionManager.pointingAtDesktopWindowRight) ||
|
|
||||||
(hand === Controller.Standard.LeftHand &&
|
|
||||||
SelectionManager.pointingAtDesktopWindowLeft);
|
|
||||||
var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) ||
|
|
||||||
(hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft);
|
|
||||||
if (pointingAtDesktopWindow || pointingAtTablet) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
that.triggeredHand = hand;
|
that.triggeredHand = hand;
|
||||||
that.mousePressEvent({});
|
that.mousePressEvent({});
|
||||||
} else if (that.triggered() && !clicked) {
|
} else if (that.triggered() && !clicked) {
|
||||||
that.triggeredHand = NO_TRIGGER_HAND;
|
that.triggeredHand = NO_HAND;
|
||||||
that.mouseReleaseEvent({});
|
that.mouseReleaseEvent({});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
that.triggerMapping.from(Controller.Standard.RTClick).peek().to(makeClickHandler(Controller.Standard.RightHand));
|
function makePressHandler(hand) {
|
||||||
that.triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Controller.Standard.LeftHand));
|
return function (value) {
|
||||||
|
if (value >= TRIGGER_ON_VALUE && !that.triggered() && !pointingAtDesktopWindowOrTablet(hand)) {
|
||||||
|
that.pressedHand = hand;
|
||||||
|
that.updateHighlight({});
|
||||||
|
} else {
|
||||||
|
that.pressedHand = NO_HAND;
|
||||||
|
that.resetPreviousHandleColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that.triggerClickMapping.from(Controller.Standard.RTClick).peek().to(makeClickHandler(Controller.Standard.RightHand));
|
||||||
|
that.triggerClickMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Controller.Standard.LeftHand));
|
||||||
|
that.triggerPressMapping.from(Controller.Standard.RT).peek().to(makePressHandler(Controller.Standard.RightHand));
|
||||||
|
that.triggerPressMapping.from(Controller.Standard.LT).peek().to(makePressHandler(Controller.Standard.LeftHand));
|
||||||
|
that.enableTriggerMapping = function() {
|
||||||
|
that.triggerClickMapping.enable();
|
||||||
|
that.triggerPressMapping.enable();
|
||||||
|
};
|
||||||
|
that.disableTriggerMapping = function() {
|
||||||
|
that.triggerClickMapping.disable();
|
||||||
|
that.triggerPressMapping.disable();
|
||||||
|
}
|
||||||
|
Script.scriptEnding.connect(that.disableTriggerMapping);
|
||||||
|
|
||||||
// FUNCTION DEF(s): Intersection Check Helpers
|
// FUNCTION DEF(s): Intersection Check Helpers
|
||||||
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
function testRayIntersect(queryRay, overlayIncludes, overlayExcludes) {
|
||||||
|
@ -960,35 +984,18 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
return Uuid.NULL;
|
return Uuid.NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FUNCTION: MOUSE MOVE EVENT
|
that.updateHighlight = function(event) {
|
||||||
var lastMouseEvent = null;
|
|
||||||
that.mouseMoveEvent = function(event) {
|
|
||||||
var wantDebug = false;
|
|
||||||
if (wantDebug) {
|
|
||||||
print("=============== eST::MouseMoveEvent BEG =======================");
|
|
||||||
}
|
|
||||||
lastMouseEvent = event;
|
|
||||||
if (activeTool) {
|
|
||||||
if (wantDebug) {
|
|
||||||
print(" Trigger ActiveTool(" + activeTool.mode + ")'s onMove");
|
|
||||||
}
|
|
||||||
activeTool.onMove(event);
|
|
||||||
|
|
||||||
if (wantDebug) {
|
|
||||||
print(" Trigger SelectionManager::update");
|
|
||||||
}
|
|
||||||
SelectionManager._update();
|
|
||||||
|
|
||||||
if (wantDebug) {
|
|
||||||
print("=============== eST::MouseMoveEvent END =======================");
|
|
||||||
}
|
|
||||||
// EARLY EXIT--(Move handled via active tool)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if no tool is active, then just look for handles to highlight...
|
// if no tool is active, then just look for handles to highlight...
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
|
var interactiveOverlays = getMainTabletIDs();
|
||||||
|
for (var key in handleTools) {
|
||||||
|
if (handleTools.hasOwnProperty(key)) {
|
||||||
|
interactiveOverlays.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var result = Overlays.findRayIntersection(pickRay);
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
var pickedColor;
|
var pickedColor;
|
||||||
var highlightNeeded = false;
|
var highlightNeeded = false;
|
||||||
|
@ -1039,7 +1046,36 @@ SelectionDisplay = (function() {
|
||||||
} else {
|
} else {
|
||||||
that.resetPreviousHandleColor();
|
that.resetPreviousHandleColor();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// FUNCTION: MOUSE MOVE EVENT
|
||||||
|
var lastMouseEvent = null;
|
||||||
|
that.mouseMoveEvent = function(event) {
|
||||||
|
var wantDebug = false;
|
||||||
|
if (wantDebug) {
|
||||||
|
print("=============== eST::MouseMoveEvent BEG =======================");
|
||||||
|
}
|
||||||
|
lastMouseEvent = event;
|
||||||
|
if (activeTool) {
|
||||||
|
if (wantDebug) {
|
||||||
|
print(" Trigger ActiveTool(" + activeTool.mode + ")'s onMove");
|
||||||
|
}
|
||||||
|
activeTool.onMove(event);
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
print(" Trigger SelectionManager::update");
|
||||||
|
}
|
||||||
|
SelectionManager._update();
|
||||||
|
|
||||||
|
if (wantDebug) {
|
||||||
|
print("=============== eST::MouseMoveEvent END =======================");
|
||||||
|
}
|
||||||
|
// EARLY EXIT--(Move handled via active tool)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
that.updateHighlight(event);
|
||||||
|
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("=============== eST::MouseMoveEvent END =======================");
|
print("=============== eST::MouseMoveEvent END =======================");
|
||||||
}
|
}
|
||||||
|
@ -1135,9 +1171,10 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function controllerComputePickRay() {
|
function controllerComputePickRay(hand) {
|
||||||
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
var hand = that.triggered() ? that.triggeredHand : that.pressedHand;
|
||||||
if (controllerPose.valid && that.triggered()) {
|
var controllerPose = getControllerWorldLocation(hand, true);
|
||||||
|
if (controllerPose.valid) {
|
||||||
var controllerPosition = controllerPose.translation;
|
var controllerPosition = controllerPose.translation;
|
||||||
// This gets point direction right, but if you want general quaternion it would be more complicated:
|
// This gets point direction right, but if you want general quaternion it would be more complicated:
|
||||||
var controllerDirection = Quat.getUp(controllerPose.rotation);
|
var controllerDirection = Quat.getUp(controllerPose.rotation);
|
||||||
|
@ -2083,7 +2120,7 @@ SelectionDisplay = (function() {
|
||||||
var rotation = null;
|
var rotation = null;
|
||||||
var previousPickRay = null;
|
var previousPickRay = null;
|
||||||
var beginMouseEvent = null;
|
var beginMouseEvent = null;
|
||||||
var beginControllerPick = null;
|
var beginControllerPosition = null;
|
||||||
|
|
||||||
var onBegin = function(event, pickRay, pickResult) {
|
var onBegin = function(event, pickRay, pickResult) {
|
||||||
var proportional = directionEnum === STRETCH_DIRECTION.ALL;
|
var proportional = directionEnum === STRETCH_DIRECTION.ALL;
|
||||||
|
@ -2219,7 +2256,11 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
previousPickRay = pickRay;
|
previousPickRay = pickRay;
|
||||||
beginMouseEvent = event;
|
beginMouseEvent = event;
|
||||||
beginControllerPick = pickRay.origin;
|
|
||||||
|
if (that.triggered()) {
|
||||||
|
beginControllerPosition = that.triggeredHand === Controller.Standard.LeftHand ?
|
||||||
|
MyAvatar.getLeftHandPosition() : MyAvatar.getRightHandPosition();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onEnd = function(event, reason) {
|
var onEnd = function(event, reason) {
|
||||||
|
@ -2258,13 +2299,15 @@ SelectionDisplay = (function() {
|
||||||
if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, planeNormal)) {
|
if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, planeNormal)) {
|
||||||
pickRay = previousPickRay;
|
pickRay = previousPickRay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
||||||
|
var controllerTrigger = HMD.isHMDAvailable() && HMD.isHandControllerAvailable() &&
|
||||||
|
controllerPose.valid && that.triggered();
|
||||||
|
|
||||||
// Are we using handControllers or Mouse - only relevant for 3D tools
|
// Are we using handControllers or Mouse - only relevant for 3D tools
|
||||||
var controllerPose = getControllerWorldLocation(that.triggeredHand, true);
|
|
||||||
var vector = null;
|
var vector = null;
|
||||||
var newPick = null;
|
var newPick = null;
|
||||||
if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() &&
|
if (controllerTrigger && directionFor3DStretch) {
|
||||||
controllerPose.valid && that.triggered() && directionFor3DStretch) {
|
|
||||||
localDeltaPivot = deltaPivot3D;
|
localDeltaPivot = deltaPivot3D;
|
||||||
newPick = pickRay.origin;
|
newPick = pickRay.origin;
|
||||||
vector = Vec3.subtract(newPick, lastPick3D);
|
vector = Vec3.subtract(newPick, lastPick3D);
|
||||||
|
@ -2292,8 +2335,10 @@ SelectionDisplay = (function() {
|
||||||
var dimensionsMultiple = toCameraDistance * STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE;
|
var dimensionsMultiple = toCameraDistance * STRETCH_DIRECTION_ALL_CAMERA_DISTANCE_MULTIPLE;
|
||||||
|
|
||||||
var dimensionChange;
|
var dimensionChange;
|
||||||
if (HMD.active) {
|
if (controllerTrigger) {
|
||||||
var vecPickDifference = Vec3.subtract(pickRay.origin, beginControllerPick);
|
var controllerPosition = that.triggeredHand === Controller.Standard.LeftHand ?
|
||||||
|
MyAvatar.getLeftHandPosition() : MyAvatar.getRightHandPosition();
|
||||||
|
var vecPickDifference = Vec3.subtract(controllerPosition, beginControllerPosition);
|
||||||
var pickDifference = vecPickDifference.x + vecPickDifference.y + vecPickDifference.z;
|
var pickDifference = vecPickDifference.x + vecPickDifference.y + vecPickDifference.z;
|
||||||
dimensionChange = pickDifference * dimensionsMultiple;
|
dimensionChange = pickDifference * dimensionsMultiple;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue