mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
Add "Rotate as the Next Clicked Surface"
Add "Rotate as the Next Clicked Surface"
This commit is contained in:
parent
1ce338d972
commit
79b34ae541
2 changed files with 140 additions and 21 deletions
|
@ -109,6 +109,8 @@ var entityIconOverlayManager = new EntityIconOverlayManager(["Light", "ParticleE
|
||||||
});
|
});
|
||||||
|
|
||||||
var hmdMultiSelectMode = false;
|
var hmdMultiSelectMode = false;
|
||||||
|
var expectingRotateAsClickedSurface = false;
|
||||||
|
var keepSelectedOnNextClick = false;
|
||||||
|
|
||||||
var cameraManager = new CameraManager();
|
var cameraManager = new CameraManager();
|
||||||
|
|
||||||
|
@ -1106,25 +1108,41 @@ function findClickedEntity(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var result;
|
var result;
|
||||||
|
if (expectingRotateAsClickedSurface) {
|
||||||
if (iconResult.intersects) {
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
result = iconResult;
|
audioFeedback.rejection();
|
||||||
} else if (entityResult.intersects) {
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
result = entityResult;
|
expectingRotateAsClickedSurface = false;
|
||||||
|
} else {
|
||||||
|
//Rotate Selection according the Surface Normal
|
||||||
|
selectionDisplay.rotateSelection(Quat.lookAt(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1), Vec3.UP));
|
||||||
|
selectionManager._update(false, this);
|
||||||
|
pushCommandForSelections();
|
||||||
|
expectingRotateAsClickedSurface = false;
|
||||||
|
audioFeedback.action();
|
||||||
|
}
|
||||||
|
keepSelectedOnNextClick = true;
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
if (iconResult.intersects) {
|
||||||
}
|
result = iconResult;
|
||||||
|
} else if (entityResult.intersects) {
|
||||||
|
result = entityResult;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!result.accurate) {
|
if (!result.accurate) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var foundEntity = result.entityID;
|
var foundEntity = result.entityID;
|
||||||
return {
|
return {
|
||||||
pickRay: pickRay,
|
pickRay: pickRay,
|
||||||
entityID: foundEntity,
|
entityID: foundEntity,
|
||||||
intersection: result.intersection
|
intersection: result.intersection
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles selections on overlays while in edit mode by querying entities from
|
// Handles selections on overlays while in edit mode by querying entities from
|
||||||
|
@ -1295,7 +1313,10 @@ function mouseClickEvent(event) {
|
||||||
|
|
||||||
if (result === null || result === undefined) {
|
if (result === null || result === undefined) {
|
||||||
if (!event.isShifted) {
|
if (!event.isShifted) {
|
||||||
selectionManager.clearSelections(this);
|
if (!keepSelectedOnNextClick) {
|
||||||
|
selectionManager.clearSelections(this);
|
||||||
|
}
|
||||||
|
keepSelectedOnNextClick = false;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2052,6 +2073,26 @@ function gridToAvatarKey(value) {
|
||||||
alignGridToAvatar();
|
alignGridToAvatar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function rotateAsNextClickedSurfaceKey(value) {
|
||||||
|
if (value === 0) { // on release
|
||||||
|
rotateAsNextClickedSurface();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function quickRotate90xKey(value) {
|
||||||
|
if (value === 0) { // on release
|
||||||
|
selectionDisplay.rotate90degreeSelection("X");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function quickRotate90yKey(value) {
|
||||||
|
if (value === 0) { // on release
|
||||||
|
selectionDisplay.rotate90degreeSelection("Y");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function quickRotate90zKey(value) {
|
||||||
|
if (value === 0) { // on release
|
||||||
|
selectionDisplay.rotate90degreeSelection("Z");
|
||||||
|
}
|
||||||
|
}
|
||||||
function recursiveAdd(newParentID, parentData) {
|
function recursiveAdd(newParentID, parentData) {
|
||||||
if (parentData.children !== undefined) {
|
if (parentData.children !== undefined) {
|
||||||
var children = parentData.children;
|
var children = parentData.children;
|
||||||
|
@ -2819,6 +2860,10 @@ mapping.from([Controller.Hardware.Keyboard.J]).to(gridKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.G]).to(viewGridKey);
|
mapping.from([Controller.Hardware.Keyboard.G]).to(viewGridKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.H]).to(snapKey);
|
mapping.from([Controller.Hardware.Keyboard.H]).to(snapKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.K]).to(gridToAvatarKey);
|
mapping.from([Controller.Hardware.Keyboard.K]).to(gridToAvatarKey);
|
||||||
|
mapping.from([Controller.Hardware.Keyboard["0"]]).to(rotateAsNextClickedSurfaceKey);
|
||||||
|
mapping.from([Controller.Hardware.Keyboard["7"]]).to(quickRotate90xKey);
|
||||||
|
mapping.from([Controller.Hardware.Keyboard["8"]]).to(quickRotate90yKey);
|
||||||
|
mapping.from([Controller.Hardware.Keyboard["9"]]).to(quickRotate90zKey);
|
||||||
mapping.from([Controller.Hardware.Keyboard.X])
|
mapping.from([Controller.Hardware.Keyboard.X])
|
||||||
.when([Controller.Hardware.Keyboard.Control])
|
.when([Controller.Hardware.Keyboard.Control])
|
||||||
.to(whenReleased(function() { selectionManager.cutSelectedEntities() }));
|
.to(whenReleased(function() { selectionManager.cutSelectedEntities() }));
|
||||||
|
@ -2867,6 +2912,14 @@ keyUpEventFromUIWindow = function(keyUpEvent) {
|
||||||
snapKey(pressedValue);
|
snapKey(pressedValue);
|
||||||
} else if (keyUpEvent.keyCodeString === "K") {
|
} else if (keyUpEvent.keyCodeString === "K") {
|
||||||
gridToAvatarKey(pressedValue);
|
gridToAvatarKey(pressedValue);
|
||||||
|
} else if (keyUpEvent.keyCodeString === "0") {
|
||||||
|
rotateAsNextClickedSurfaceKey(pressedValue);
|
||||||
|
} else if (keyUpEvent.keyCodeString === "7") {
|
||||||
|
quickRotate90xKey(pressedValue);
|
||||||
|
} else if (keyUpEvent.keyCodeString === "8") {
|
||||||
|
quickRotate90yKey(pressedValue);
|
||||||
|
} else if (keyUpEvent.keyCodeString === "9") {
|
||||||
|
quickRotate90zKey(pressedValue);
|
||||||
} else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "X") {
|
} else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "X") {
|
||||||
selectionManager.cutSelectedEntities();
|
selectionManager.cutSelectedEntities();
|
||||||
} else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "C") {
|
} else if (keyUpEvent.controlKey && keyUpEvent.keyCodeString === "C") {
|
||||||
|
@ -3015,4 +3068,14 @@ function toggleGridVisibility() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rotateAsNextClickedSurface() {
|
||||||
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
|
audioFeedback.rejection();
|
||||||
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
|
expectingRotateAsClickedSurface = false;
|
||||||
|
} else {
|
||||||
|
expectingRotateAsClickedSurface = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
|
@ -103,10 +103,25 @@ SelectionManager = (function() {
|
||||||
if (wantDebug) {
|
if (wantDebug) {
|
||||||
print("setting selection to " + messageParsed.entityID);
|
print("setting selection to " + messageParsed.entityID);
|
||||||
}
|
}
|
||||||
if (hmdMultiSelectMode) {
|
if (expectingRotateAsClickedSurface) {
|
||||||
that.addEntity(messageParsed.entityID, true, that);
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
|
audioFeedback.rejection();
|
||||||
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
|
expectingRotateAsClickedSurface = false;
|
||||||
|
} else {
|
||||||
|
//Rotate Selection according the Surface Normal
|
||||||
|
selectionDisplay.rotateSelection(Quat.lookAt(Vec3.ZERO, Vec3.multiply(messageParsed.surfaceNormal, -1), Vec3.UP));
|
||||||
|
that._update(false, this);
|
||||||
|
pushCommandForSelections();
|
||||||
|
expectingRotateAsClickedSurface = false;
|
||||||
|
audioFeedback.action();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
that.setSelections([messageParsed.entityID], that);
|
if (hmdMultiSelectMode) {
|
||||||
|
that.addEntity(messageParsed.entityID, true, that);
|
||||||
|
} else {
|
||||||
|
that.setSelections([messageParsed.entityID], that);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (messageParsed.method === "clearSelection") {
|
} else if (messageParsed.method === "clearSelection") {
|
||||||
|
@ -2377,7 +2392,48 @@ SelectionDisplay = (function() {
|
||||||
}
|
}
|
||||||
debugPickPlaneHits = [];
|
debugPickPlaneHits = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.rotateSelection = function(rotation) {
|
||||||
|
SelectionManager.saveProperties();
|
||||||
|
if (SelectionManager.selections.length === 1) {
|
||||||
|
SelectionManager.savedProperties[SelectionManager.selections[0]].rotation = Quat.IDENTITY;
|
||||||
|
}
|
||||||
|
updateSelectionsRotation(rotation, SelectionManager.worldPosition);
|
||||||
|
};
|
||||||
|
|
||||||
|
that.rotate90degreeSelection = function(axis) {
|
||||||
|
//axis is a string and expect "X", "Y" or "Z"
|
||||||
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
|
audioFeedback.rejection();
|
||||||
|
Window.notifyEditError("You have nothing selected, or the selection is locked.");
|
||||||
|
} else {
|
||||||
|
var currentRotation, axisRotation;
|
||||||
|
SelectionManager.saveProperties();
|
||||||
|
if (selectionManager.selections.length === 1 && spaceMode === SPACE_LOCAL) {
|
||||||
|
currentRotation = SelectionManager.localRotation;
|
||||||
|
}else{
|
||||||
|
currentRotation = SelectionManager.worldRotation;
|
||||||
|
}
|
||||||
|
switch(axis) {
|
||||||
|
case "X":
|
||||||
|
axisRotation = Quat.angleAxis(90.0, Quat.getRight(currentRotation));
|
||||||
|
break;
|
||||||
|
case "Y":
|
||||||
|
axisRotation = Quat.angleAxis(90.0, Quat.getUp(currentRotation));
|
||||||
|
break;
|
||||||
|
case "Z":
|
||||||
|
axisRotation = Quat.angleAxis(90.0, Quat.getForward(currentRotation));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateSelectionsRotation(axisRotation, SelectionManager.worldPosition);
|
||||||
|
SelectionManager._update(false, this);
|
||||||
|
pushCommandForSelections();
|
||||||
|
audioFeedback.action();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function addUnlitMaterialOnToolEntity(toolEntityParentID) {
|
function addUnlitMaterialOnToolEntity(toolEntityParentID) {
|
||||||
var toolEntitiesMaterialData = "{\n \"materialVersion\": 1,\n \"materials\": [\n {\n \"name\": \"0\",\n \"defaultFallthrough\": true,\n \"unlit\": true,\n \"model\": \"hifi_pbr\"\n }\n ]\n}";
|
var toolEntitiesMaterialData = "{\n \"materialVersion\": 1,\n \"materials\": [\n {\n \"name\": \"0\",\n \"defaultFallthrough\": true,\n \"unlit\": true,\n \"model\": \"hifi_pbr\"\n }\n ]\n}";
|
||||||
var materialEntityID = Entities.addEntity({
|
var materialEntityID = Entities.addEntity({
|
||||||
|
|
Loading…
Reference in a new issue