mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:38:27 +02:00
implement FAR side stretching
This commit is contained in:
parent
88c983cd3b
commit
6207e951b6
1 changed files with 55 additions and 0 deletions
|
@ -771,6 +771,51 @@ SelectionDisplay = (function () {
|
||||||
that.select(currentSelection, false); // TODO: this should be more than highlighted
|
that.select(currentSelection, false); // TODO: this should be more than highlighted
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.stretchFAR = function(event) {
|
||||||
|
if (!entitySelected || mode !== "STRETCH_FAR") {
|
||||||
|
return; // not allowed
|
||||||
|
}
|
||||||
|
pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
|
||||||
|
// translate mode left/right based on view toward entity
|
||||||
|
var newIntersection = rayPlaneIntersection(pickRay,
|
||||||
|
selectedEntityPropertiesOriginalPosition,
|
||||||
|
Quat.getFront(lastAvatarOrientation));
|
||||||
|
|
||||||
|
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
|
||||||
|
|
||||||
|
var halfDimensions = Vec3.multiply(selectedEntityPropertiesOriginalDimensions, 0.5);
|
||||||
|
var originalFAR = selectedEntityPropertiesOriginalPosition.z + halfDimensions.z;
|
||||||
|
var newFAR = originalFAR + vector.z;
|
||||||
|
var changeInDimensions = { x: 0, y: 0, z: (newFAR - originalFAR) };
|
||||||
|
var newDimensions = Vec3.sum(selectedEntityPropertiesOriginalDimensions, changeInDimensions);
|
||||||
|
var changeInPosition = { x: 0, y: 0, z: (newFAR - originalFAR) * 0.5 };
|
||||||
|
var newPosition = Vec3.sum(selectedEntityPropertiesOriginalPosition, changeInPosition);
|
||||||
|
var wantDebug = false;
|
||||||
|
if (wantDebug) {
|
||||||
|
print("stretchFAR... ");
|
||||||
|
Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection);
|
||||||
|
Vec3.print(" newIntersection:", newIntersection);
|
||||||
|
Vec3.print(" vector:", vector);
|
||||||
|
print(" originalFAR:" + originalFAR);
|
||||||
|
print(" newFAR:" + newFAR);
|
||||||
|
Vec3.print(" originalDimensions:", selectedEntityPropertiesOriginalDimensions);
|
||||||
|
Vec3.print(" changeInDimensions:", changeInDimensions);
|
||||||
|
Vec3.print(" newDimensions:", newDimensions);
|
||||||
|
|
||||||
|
Vec3.print(" originalPosition:", selectedEntityPropertiesOriginalPosition);
|
||||||
|
Vec3.print(" changeInPosition:", changeInPosition);
|
||||||
|
Vec3.print(" newPosition:", newPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
selectedEntityProperties.position = newPosition;
|
||||||
|
selectedEntityProperties.dimensions = newDimensions;
|
||||||
|
Entities.editEntity(currentSelection, selectedEntityProperties);
|
||||||
|
tooltip.updateText(selectedEntityProperties);
|
||||||
|
that.select(currentSelection, false); // TODO: this should be more than highlighted
|
||||||
|
};
|
||||||
|
|
||||||
that.stretchRBN = function(event) {
|
that.stretchRBN = function(event) {
|
||||||
if (!entitySelected || mode !== "STRETCH_RBN") {
|
if (!entitySelected || mode !== "STRETCH_RBN") {
|
||||||
return; // not allowed
|
return; // not allowed
|
||||||
|
@ -896,6 +941,13 @@ SelectionDisplay = (function () {
|
||||||
somethingClicked = true;
|
somethingClicked = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case grabberFAR:
|
||||||
|
case grabberEdgeTF:
|
||||||
|
case grabberEdgeBF:
|
||||||
|
mode = "STRETCH_FAR";
|
||||||
|
somethingClicked = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mode = "UNKNOWN";
|
mode = "UNKNOWN";
|
||||||
break;
|
break;
|
||||||
|
@ -969,6 +1021,9 @@ SelectionDisplay = (function () {
|
||||||
case "STRETCH_NEAR":
|
case "STRETCH_NEAR":
|
||||||
that.stretchNEAR(event);
|
that.stretchNEAR(event);
|
||||||
break;
|
break;
|
||||||
|
case "STRETCH_FAR":
|
||||||
|
that.stretchFAR(event);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// nothing to do by default
|
// nothing to do by default
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue