mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
basic hand-controller editing
This commit is contained in:
parent
af67d814eb
commit
b8e6572ebf
3 changed files with 112 additions and 42 deletions
|
@ -221,6 +221,14 @@ function entityHasActions(entityID) {
|
||||||
return Entities.getActionIDs(entityID).length > 0;
|
return Entities.getActionIDs(entityID).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findRayIntersection(pickRay, precise, include, exclude) {
|
||||||
|
var entities = Entities.findRayIntersection(pickRay, precise, include, exclude);
|
||||||
|
var overlays = Overlays.findRayIntersection(pickRay);
|
||||||
|
if (!overlays.intersects || (entities.distance <= overlays.distance)) {
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
|
return overlays;
|
||||||
|
}
|
||||||
function entityIsGrabbedByOther(entityID) {
|
function entityIsGrabbedByOther(entityID) {
|
||||||
// by convention, a distance grab sets the tag of its action to be grab-*owner-session-id*.
|
// by convention, a distance grab sets the tag of its action to be grab-*owner-session-id*.
|
||||||
var actionIDs = Entities.getActionIDs(entityID);
|
var actionIDs = Entities.getActionIDs(entityID);
|
||||||
|
@ -251,6 +259,10 @@ function propsArePhysical(props) {
|
||||||
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
||||||
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
||||||
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
||||||
|
var EDIT_SETTING = "io.highfidelity.isEditting";
|
||||||
|
function isEditing() {
|
||||||
|
return EXTERNALLY_MANAGED_2D_MINOR_MODE && Settings.getValue(EDIT_SETTING);
|
||||||
|
}
|
||||||
function isIn2DMode() {
|
function isIn2DMode() {
|
||||||
// In this version, we make our own determination of whether we're aimed a HUD element,
|
// In this version, we make our own determination of whether we're aimed a HUD element,
|
||||||
// because other scripts (such as handControllerPointer) might be using some other visualization
|
// because other scripts (such as handControllerPointer) might be using some other visualization
|
||||||
|
@ -1069,20 +1081,15 @@ function MyController(hand) {
|
||||||
|
|
||||||
var intersection;
|
var intersection;
|
||||||
if (USE_BLACKLIST === true && blacklist.length !== 0) {
|
if (USE_BLACKLIST === true && blacklist.length !== 0) {
|
||||||
intersection = Entities.findRayIntersection(pickRayBacked, true, [], blacklist);
|
intersection = findRayIntersection(pickRayBacked, true, [], blacklist);
|
||||||
} else {
|
} else {
|
||||||
intersection = Entities.findRayIntersection(pickRayBacked, true);
|
intersection = findRayIntersection(pickRayBacked, true);
|
||||||
}
|
|
||||||
|
|
||||||
var overlayIntersection = Overlays.findRayIntersection(pickRayBacked);
|
|
||||||
if (!intersection.intersects ||
|
|
||||||
(overlayIntersection.intersects && (intersection.distance > overlayIntersection.distance))) {
|
|
||||||
intersection = overlayIntersection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
return {
|
return {
|
||||||
entityID: intersection.entityID,
|
entityID: intersection.entityID,
|
||||||
|
overlayID: intersection.overlayID,
|
||||||
searchRay: pickRay,
|
searchRay: pickRay,
|
||||||
distance: Vec3.distance(pickRay.origin, intersection.intersection)
|
distance: Vec3.distance(pickRay.origin, intersection.intersection)
|
||||||
};
|
};
|
||||||
|
@ -1326,6 +1333,8 @@ function MyController(hand) {
|
||||||
if (this.entityIsGrabbable(rayPickInfo.entityID) && rayPickInfo.distance < NEAR_GRAB_PICK_RADIUS) {
|
if (this.entityIsGrabbable(rayPickInfo.entityID) && rayPickInfo.distance < NEAR_GRAB_PICK_RADIUS) {
|
||||||
grabbableEntities.push(rayPickInfo.entityID);
|
grabbableEntities.push(rayPickInfo.entityID);
|
||||||
}
|
}
|
||||||
|
} else if (rayPickInfo.overlayID) {
|
||||||
|
this.intersectionDistance = rayPickInfo.distance;
|
||||||
} else {
|
} else {
|
||||||
this.intersectionDistance = 0;
|
this.intersectionDistance = 0;
|
||||||
}
|
}
|
||||||
|
@ -1382,7 +1391,7 @@ function MyController(hand) {
|
||||||
// TODO: highlight the far-triggerable object?
|
// TODO: highlight the far-triggerable object?
|
||||||
}
|
}
|
||||||
} else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) {
|
} else if (this.entityIsDistanceGrabbable(rayPickInfo.entityID, handPosition)) {
|
||||||
if (this.triggerSmoothedGrab()) {
|
if (this.triggerSmoothedGrab() && !isEditing()) {
|
||||||
this.grabbedEntity = entity;
|
this.grabbedEntity = entity;
|
||||||
this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'");
|
this.setState(STATE_DISTANCE_HOLDING, "distance hold '" + name + "'");
|
||||||
return;
|
return;
|
||||||
|
@ -1942,8 +1951,8 @@ function MyController(hand) {
|
||||||
|
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
|
if (now - this.lastPickTime > MSECS_PER_SEC / PICKS_PER_SECOND_PER_HAND) {
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = findRayIntersection(pickRay, true);
|
||||||
if (intersection.accurate) {
|
if (intersection.accurate || intersection.overlayID) {
|
||||||
this.lastPickTime = now;
|
this.lastPickTime = now;
|
||||||
if (intersection.entityID != this.grabbedEntity) {
|
if (intersection.entityID != this.grabbedEntity) {
|
||||||
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
this.callEntityMethodOnGrabbed("stopFarTrigger");
|
||||||
|
|
|
@ -332,6 +332,8 @@ var toolBar = (function() {
|
||||||
entityListTool.clearEntityList();
|
entityListTool.clearEntityList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var EDIT_SETTING = "io.highfidelity.isEditting"; // for communication with other scripts
|
||||||
|
Settings.setValue(EDIT_SETTING, false);
|
||||||
that.setActive = function(active) {
|
that.setActive = function(active) {
|
||||||
if (active != isActive) {
|
if (active != isActive) {
|
||||||
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
if (active && !Entities.canRez() && !Entities.canRezTmp()) {
|
||||||
|
@ -341,6 +343,7 @@ var toolBar = (function() {
|
||||||
enabled: active
|
enabled: active
|
||||||
}));
|
}));
|
||||||
isActive = active;
|
isActive = active;
|
||||||
|
Settings.setValue(EDIT_SETTING, active);
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
entityListTool.setVisible(false);
|
entityListTool.setVisible(false);
|
||||||
gridTool.setVisible(false);
|
gridTool.setVisible(false);
|
||||||
|
@ -348,6 +351,7 @@ var toolBar = (function() {
|
||||||
propertiesTool.setVisible(false);
|
propertiesTool.setVisible(false);
|
||||||
selectionManager.clearSelections();
|
selectionManager.clearSelections();
|
||||||
cameraManager.disable();
|
cameraManager.disable();
|
||||||
|
selectionDisplay.triggerMapping.disable();
|
||||||
} else {
|
} else {
|
||||||
UserActivityLogger.enabledEdit();
|
UserActivityLogger.enabledEdit();
|
||||||
hasShownPropertiesTool = false;
|
hasShownPropertiesTool = false;
|
||||||
|
@ -356,6 +360,7 @@ var toolBar = (function() {
|
||||||
grid.setEnabled(true);
|
grid.setEnabled(true);
|
||||||
propertiesTool.setVisible(true);
|
propertiesTool.setVisible(true);
|
||||||
// Not sure what the following was meant to accomplish, but it currently causes
|
// Not sure what the following was meant to accomplish, but it currently causes
|
||||||
|
selectionDisplay.triggerMapping.enable();
|
||||||
// everybody else to think that Interface has lost focus overall. fogbugzid:558
|
// everybody else to think that Interface has lost focus overall. fogbugzid:558
|
||||||
// Window.setFocus();
|
// Window.setFocus();
|
||||||
}
|
}
|
||||||
|
@ -1438,6 +1443,9 @@ function pushCommandForSelections(createdEntityData, deletedEntityData) {
|
||||||
var entityID = SelectionManager.selections[i];
|
var entityID = SelectionManager.selections[i];
|
||||||
var initialProperties = SelectionManager.savedProperties[entityID];
|
var initialProperties = SelectionManager.savedProperties[entityID];
|
||||||
var currentProperties = Entities.getEntityProperties(entityID);
|
var currentProperties = Entities.getEntityProperties(entityID);
|
||||||
|
if (!initialProperties) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
undoData.setProperties.push({
|
undoData.setProperties.push({
|
||||||
entityID: entityID,
|
entityID: entityID,
|
||||||
properties: {
|
properties: {
|
||||||
|
|
|
@ -1005,6 +1005,56 @@ SelectionDisplay = (function() {
|
||||||
var activeTool = null;
|
var activeTool = null;
|
||||||
var grabberTools = {};
|
var grabberTools = {};
|
||||||
|
|
||||||
|
// We get mouseMoveEvents from the handControllers, via handControllerPointer.
|
||||||
|
// But we dont' get mousePressEvents.
|
||||||
|
that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click');
|
||||||
|
Script.scriptEnding.connect(that.triggerMapping.disable);
|
||||||
|
that.TRIGGER_GRAB_VALUE = 0.85; // From handControllerGrab/Pointer.js. Should refactor.
|
||||||
|
that.TRIGGER_ON_VALUE = 0.4;
|
||||||
|
that.TRIGGER_OFF_VALUE = 0.15;
|
||||||
|
that.triggered = false;
|
||||||
|
var activeHand = Controller.Standard.RightHand;
|
||||||
|
function makeTriggerHandler(hand) {
|
||||||
|
return function (value) {
|
||||||
|
if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth?
|
||||||
|
that.triggered = true;
|
||||||
|
if (activeHand !== hand) {
|
||||||
|
// No switching while the other is already triggered, so no need to release.
|
||||||
|
activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand;
|
||||||
|
}
|
||||||
|
var eventResult = that.mousePressEvent({});
|
||||||
|
if (!eventResult || (eventResult === 'selectionBox')) {
|
||||||
|
var pickRay = controllerComputePickRay();
|
||||||
|
if (pickRay) {
|
||||||
|
var entityIntersection = Entities.findRayIntersection(pickRay, true);
|
||||||
|
var overlayIntersection = Overlays.findRayIntersection(pickRay);
|
||||||
|
if (entityIntersection.intersects &&
|
||||||
|
(!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) {
|
||||||
|
selectionManager.setSelections([entityIntersection.entityID]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) {
|
||||||
|
that.triggered = false;
|
||||||
|
that.mouseReleaseEvent({});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand));
|
||||||
|
that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand));
|
||||||
|
function controllerComputePickRay() {
|
||||||
|
var controllerPose = Controller.getPoseValue(activeHand);
|
||||||
|
if (controllerPose.valid && that.triggered) {
|
||||||
|
var controllerPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, controllerPose.translation),
|
||||||
|
MyAvatar.position);
|
||||||
|
// This gets point direction right, but if you want general quaternion it would be more complicated:
|
||||||
|
var controllerDirection = Quat.getUp(Quat.multiply(MyAvatar.orientation, controllerPose.rotation));
|
||||||
|
return {origin: controllerPosition, direction: controllerDirection};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function generalComputePickRay(x, y) {
|
||||||
|
return controllerComputePickRay() || Camera.computePickRay(x, y);
|
||||||
|
}
|
||||||
function addGrabberTool(overlay, tool) {
|
function addGrabberTool(overlay, tool) {
|
||||||
grabberTools[overlay] = {
|
grabberTools[overlay] = {
|
||||||
mode: tool.mode,
|
mode: tool.mode,
|
||||||
|
@ -1047,7 +1097,7 @@ SelectionDisplay = (function() {
|
||||||
lastCameraOrientation = Camera.getOrientation();
|
lastCameraOrientation = Camera.getOrientation();
|
||||||
|
|
||||||
if (event !== false) {
|
if (event !== false) {
|
||||||
pickRay = Camera.computePickRay(event.x, event.y);
|
pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
|
@ -2269,7 +2319,7 @@ SelectionDisplay = (function() {
|
||||||
startPosition = SelectionManager.worldPosition;
|
startPosition = SelectionManager.worldPosition;
|
||||||
var dimensions = SelectionManager.worldDimensions;
|
var dimensions = SelectionManager.worldDimensions;
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
initialXZPick = rayPlaneIntersection(pickRay, translateXZTool.pickPlanePosition, {
|
initialXZPick = rayPlaneIntersection(pickRay, translateXZTool.pickPlanePosition, {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 1,
|
y: 1,
|
||||||
|
@ -2312,7 +2362,7 @@ SelectionDisplay = (function() {
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
pickRay = Camera.computePickRay(event.x, event.y);
|
pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
var pick = rayPlaneIntersection2(pickRay, translateXZTool.pickPlanePosition, {
|
var pick = rayPlaneIntersection2(pickRay, translateXZTool.pickPlanePosition, {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -2422,6 +2472,9 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
for (var i = 0; i < SelectionManager.selections.length; i++) {
|
||||||
var properties = SelectionManager.savedProperties[SelectionManager.selections[i]];
|
var properties = SelectionManager.savedProperties[SelectionManager.selections[i]];
|
||||||
|
if (!properties) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var newPosition = Vec3.sum(properties.position, {
|
var newPosition = Vec3.sum(properties.position, {
|
||||||
x: vector.x,
|
x: vector.x,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
@ -2448,7 +2501,7 @@ SelectionDisplay = (function() {
|
||||||
addGrabberTool(grabberMoveUp, {
|
addGrabberTool(grabberMoveUp, {
|
||||||
mode: "TRANSLATE_UP_DOWN",
|
mode: "TRANSLATE_UP_DOWN",
|
||||||
onBegin: function(event) {
|
onBegin: function(event) {
|
||||||
pickRay = Camera.computePickRay(event.x, event.y);
|
pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
upDownPickNormal = Quat.getFront(lastCameraOrientation);
|
upDownPickNormal = Quat.getFront(lastCameraOrientation);
|
||||||
// Remove y component so the y-axis lies along the plane we picking on - this will
|
// Remove y component so the y-axis lies along the plane we picking on - this will
|
||||||
|
@ -2481,7 +2534,7 @@ SelectionDisplay = (function() {
|
||||||
pushCommandForSelections(duplicatedEntityIDs);
|
pushCommandForSelections(duplicatedEntityIDs);
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
pickRay = Camera.computePickRay(event.x, event.y);
|
pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
// translate mode left/right based on view toward entity
|
// translate mode left/right based on view toward entity
|
||||||
var newIntersection = rayPlaneIntersection(pickRay, SelectionManager.worldPosition, upDownPickNormal);
|
var newIntersection = rayPlaneIntersection(pickRay, SelectionManager.worldPosition, upDownPickNormal);
|
||||||
|
@ -2690,7 +2743,7 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
planeNormal = Vec3.multiplyQbyV(rotation, planeNormal);
|
planeNormal = Vec3.multiplyQbyV(rotation, planeNormal);
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
lastPick = rayPlaneIntersection(pickRay,
|
lastPick = rayPlaneIntersection(pickRay,
|
||||||
pickRayPosition,
|
pickRayPosition,
|
||||||
planeNormal);
|
planeNormal);
|
||||||
|
@ -2726,7 +2779,7 @@ SelectionDisplay = (function() {
|
||||||
rotation = SelectionManager.worldRotation;
|
rotation = SelectionManager.worldRotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
newPick = rayPlaneIntersection(pickRay,
|
newPick = rayPlaneIntersection(pickRay,
|
||||||
pickRayPosition,
|
pickRayPosition,
|
||||||
planeNormal);
|
planeNormal);
|
||||||
|
@ -2782,10 +2835,10 @@ SelectionDisplay = (function() {
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print(stretchMode);
|
print(stretchMode);
|
||||||
Vec3.print(" newIntersection:", newIntersection);
|
//Vec3.print(" newIntersection:", newIntersection);
|
||||||
Vec3.print(" vector:", vector);
|
Vec3.print(" vector:", vector);
|
||||||
Vec3.print(" oldPOS:", oldPOS);
|
//Vec3.print(" oldPOS:", oldPOS);
|
||||||
Vec3.print(" newPOS:", newPOS);
|
//Vec3.print(" newPOS:", newPOS);
|
||||||
Vec3.print(" changeInDimensions:", changeInDimensions);
|
Vec3.print(" changeInDimensions:", changeInDimensions);
|
||||||
Vec3.print(" newDimensions:", newDimensions);
|
Vec3.print(" newDimensions:", newDimensions);
|
||||||
|
|
||||||
|
@ -3350,7 +3403,7 @@ SelectionDisplay = (function() {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -3520,7 +3573,7 @@ SelectionDisplay = (function() {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -3682,7 +3735,7 @@ SelectionDisplay = (function() {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
},
|
},
|
||||||
onMove: function(event) {
|
onMove: function(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -3797,13 +3850,13 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
that.mousePressEvent = function(event) {
|
that.mousePressEvent = function(event) {
|
||||||
var wantDebug = false;
|
var wantDebug = false;
|
||||||
if (!event.isLeftButton) {
|
if (!event.isLeftButton && !that.triggered) {
|
||||||
// if another mouse button than left is pressed ignore it
|
// if another mouse button than left is pressed ignore it
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var somethingClicked = false;
|
var somethingClicked = false;
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
|
|
||||||
// before we do a ray test for grabbers, disable the ray intersection for our selection box
|
// before we do a ray test for grabbers, disable the ray intersection for our selection box
|
||||||
Overlays.editOverlay(selectionBox, {
|
Overlays.editOverlay(selectionBox, {
|
||||||
|
@ -3837,7 +3890,7 @@ SelectionDisplay = (function() {
|
||||||
if (tool) {
|
if (tool) {
|
||||||
activeTool = tool;
|
activeTool = tool;
|
||||||
mode = tool.mode;
|
mode = tool.mode;
|
||||||
somethingClicked = true;
|
somethingClicked = 'tool';
|
||||||
if (activeTool && activeTool.onBegin) {
|
if (activeTool && activeTool.onBegin) {
|
||||||
activeTool.onBegin(event);
|
activeTool.onBegin(event);
|
||||||
}
|
}
|
||||||
|
@ -3845,7 +3898,7 @@ SelectionDisplay = (function() {
|
||||||
switch (result.overlayID) {
|
switch (result.overlayID) {
|
||||||
case grabberMoveUp:
|
case grabberMoveUp:
|
||||||
mode = "TRANSLATE_UP_DOWN";
|
mode = "TRANSLATE_UP_DOWN";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
|
|
||||||
// in translate mode, we hide our stretch handles...
|
// in translate mode, we hide our stretch handles...
|
||||||
for (var i = 0; i < stretchHandles.length; i++) {
|
for (var i = 0; i < stretchHandles.length; i++) {
|
||||||
|
@ -3860,34 +3913,34 @@ SelectionDisplay = (function() {
|
||||||
case grabberEdgeTN: // TODO: maybe this should be TOP+NEAR stretching?
|
case grabberEdgeTN: // TODO: maybe this should be TOP+NEAR stretching?
|
||||||
case grabberEdgeBN: // TODO: maybe this should be BOTTOM+FAR stretching?
|
case grabberEdgeBN: // TODO: maybe this should be BOTTOM+FAR stretching?
|
||||||
mode = "STRETCH_NEAR";
|
mode = "STRETCH_NEAR";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case grabberFAR:
|
case grabberFAR:
|
||||||
case grabberEdgeTF: // TODO: maybe this should be TOP+FAR stretching?
|
case grabberEdgeTF: // TODO: maybe this should be TOP+FAR stretching?
|
||||||
case grabberEdgeBF: // TODO: maybe this should be BOTTOM+FAR stretching?
|
case grabberEdgeBF: // TODO: maybe this should be BOTTOM+FAR stretching?
|
||||||
mode = "STRETCH_FAR";
|
mode = "STRETCH_FAR";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
case grabberTOP:
|
case grabberTOP:
|
||||||
mode = "STRETCH_TOP";
|
mode = "STRETCH_TOP";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
case grabberBOTTOM:
|
case grabberBOTTOM:
|
||||||
mode = "STRETCH_BOTTOM";
|
mode = "STRETCH_BOTTOM";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
case grabberRIGHT:
|
case grabberRIGHT:
|
||||||
case grabberEdgeTR: // TODO: maybe this should be TOP+RIGHT stretching?
|
case grabberEdgeTR: // TODO: maybe this should be TOP+RIGHT stretching?
|
||||||
case grabberEdgeBR: // TODO: maybe this should be BOTTOM+RIGHT stretching?
|
case grabberEdgeBR: // TODO: maybe this should be BOTTOM+RIGHT stretching?
|
||||||
mode = "STRETCH_RIGHT";
|
mode = "STRETCH_RIGHT";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
case grabberLEFT:
|
case grabberLEFT:
|
||||||
case grabberEdgeTL: // TODO: maybe this should be TOP+LEFT stretching?
|
case grabberEdgeTL: // TODO: maybe this should be TOP+LEFT stretching?
|
||||||
case grabberEdgeBL: // TODO: maybe this should be BOTTOM+LEFT stretching?
|
case grabberEdgeBL: // TODO: maybe this should be BOTTOM+LEFT stretching?
|
||||||
mode = "STRETCH_LEFT";
|
mode = "STRETCH_LEFT";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -3955,7 +4008,7 @@ SelectionDisplay = (function() {
|
||||||
if (tool) {
|
if (tool) {
|
||||||
activeTool = tool;
|
activeTool = tool;
|
||||||
mode = tool.mode;
|
mode = tool.mode;
|
||||||
somethingClicked = true;
|
somethingClicked = 'tool';
|
||||||
if (activeTool && activeTool.onBegin) {
|
if (activeTool && activeTool.onBegin) {
|
||||||
activeTool.onBegin(event);
|
activeTool.onBegin(event);
|
||||||
}
|
}
|
||||||
|
@ -3963,7 +4016,7 @@ SelectionDisplay = (function() {
|
||||||
switch (result.overlayID) {
|
switch (result.overlayID) {
|
||||||
case yawHandle:
|
case yawHandle:
|
||||||
mode = "ROTATE_YAW";
|
mode = "ROTATE_YAW";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
overlayOrientation = yawHandleRotation;
|
overlayOrientation = yawHandleRotation;
|
||||||
overlayCenter = yawCenter;
|
overlayCenter = yawCenter;
|
||||||
yawZero = result.intersection;
|
yawZero = result.intersection;
|
||||||
|
@ -3973,7 +4026,7 @@ SelectionDisplay = (function() {
|
||||||
case pitchHandle:
|
case pitchHandle:
|
||||||
mode = "ROTATE_PITCH";
|
mode = "ROTATE_PITCH";
|
||||||
initialPosition = SelectionManager.worldPosition;
|
initialPosition = SelectionManager.worldPosition;
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
overlayOrientation = pitchHandleRotation;
|
overlayOrientation = pitchHandleRotation;
|
||||||
overlayCenter = pitchCenter;
|
overlayCenter = pitchCenter;
|
||||||
pitchZero = result.intersection;
|
pitchZero = result.intersection;
|
||||||
|
@ -3982,7 +4035,7 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
case rollHandle:
|
case rollHandle:
|
||||||
mode = "ROTATE_ROLL";
|
mode = "ROTATE_ROLL";
|
||||||
somethingClicked = true;
|
somethingClicked = mode;
|
||||||
overlayOrientation = rollHandleRotation;
|
overlayOrientation = rollHandleRotation;
|
||||||
overlayCenter = rollCenter;
|
overlayCenter = rollCenter;
|
||||||
rollZero = result.intersection;
|
rollZero = result.intersection;
|
||||||
|
@ -4156,7 +4209,7 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
mode = translateXZTool.mode;
|
mode = translateXZTool.mode;
|
||||||
activeTool.onBegin(event);
|
activeTool.onBegin(event);
|
||||||
somethingClicked = true;
|
somethingClicked = 'selectionBox';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
|
@ -4169,7 +4222,7 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (somethingClicked) {
|
if (somethingClicked) {
|
||||||
pickRay = Camera.computePickRay(event.x, event.y);
|
pickRay = generalComputePickRay(event.x, event.y);
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("mousePressEvent()...... " + overlayNames[result.overlayID]);
|
print("mousePressEvent()...... " + overlayNames[result.overlayID]);
|
||||||
}
|
}
|
||||||
|
@ -4201,7 +4254,7 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 = Camera.computePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
var result = Overlays.findRayIntersection(pickRay);
|
var result = Overlays.findRayIntersection(pickRay);
|
||||||
var pickedColor;
|
var pickedColor;
|
||||||
var pickedAlpha;
|
var pickedAlpha;
|
||||||
|
@ -4320,7 +4373,7 @@ SelectionDisplay = (function() {
|
||||||
that.updateHandleSizes = function() {
|
that.updateHandleSizes = function() {
|
||||||
if (selectionManager.hasSelection()) {
|
if (selectionManager.hasSelection()) {
|
||||||
var diff = Vec3.subtract(selectionManager.worldPosition, Camera.getPosition());
|
var diff = Vec3.subtract(selectionManager.worldPosition, Camera.getPosition());
|
||||||
var grabberSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 2;
|
var grabberSize = Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 5;
|
||||||
var dimensions = SelectionManager.worldDimensions;
|
var dimensions = SelectionManager.worldDimensions;
|
||||||
var avgDimension = (dimensions.x + dimensions.y + dimensions.z) / 3;
|
var avgDimension = (dimensions.x + dimensions.y + dimensions.z) / 3;
|
||||||
grabberSize = Math.min(grabberSize, avgDimension / 10);
|
grabberSize = Math.min(grabberSize, avgDimension / 10);
|
||||||
|
|
Loading…
Reference in a new issue