Update entitySelectionTools to use camera position/orientation instead of avatar

This commit is contained in:
Ryan Huffman 2014-10-16 09:50:06 -07:00
parent 643f28eb3f
commit fdc231424b

View file

@ -22,8 +22,8 @@ SelectionDisplay = (function () {
var mode = "UNKNOWN"; var mode = "UNKNOWN";
var overlayNames = new Array(); var overlayNames = new Array();
var lastAvatarPosition = MyAvatar.position; var lastCameraPosition = Camera.getPosition();
var lastAvatarOrientation = MyAvatar.orientation; var lastCameraOrientation = Camera.getOrientation();
var lastPlaneIntersection; var lastPlaneIntersection;
var currentSelection = { id: -1, isKnownID: false }; var currentSelection = { id: -1, isKnownID: false };
@ -452,15 +452,15 @@ SelectionDisplay = (function () {
currentSelection = entityID; currentSelection = entityID;
entitySelected = true; entitySelected = true;
lastAvatarPosition = MyAvatar.position; lastCameraPosition = Camera.getPosition();
lastAvatarOrientation = MyAvatar.orientation; lastCameraOrientation = Camera.getOrientation();
if (event !== false) { if (event !== false) {
selectedEntityProperties = properties; selectedEntityProperties = properties;
selectedEntityPropertiesOriginalPosition = properties.position; selectedEntityPropertiesOriginalPosition = properties.position;
selectedEntityPropertiesOriginalDimensions = properties.dimensions; selectedEntityPropertiesOriginalDimensions = properties.dimensions;
pickRay = Camera.computePickRay(event.x, event.y); pickRay = Camera.computePickRay(event.x, event.y);
lastPlaneIntersection = rayPlaneIntersection(pickRay, properties.position, Quat.getFront(lastAvatarOrientation)); lastPlaneIntersection = rayPlaneIntersection(pickRay, properties.position, Quat.getFront(lastCameraOrientation));
var wantDebug = false; var wantDebug = false;
if (wantDebug) { if (wantDebug) {
@ -838,7 +838,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -877,7 +877,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -914,7 +914,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -967,7 +967,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1017,7 +1017,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1066,7 +1066,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1115,7 +1115,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1164,7 +1164,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1213,7 +1213,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1280,7 +1280,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1347,7 +1347,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1414,7 +1414,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1481,7 +1481,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1548,7 +1548,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1615,7 +1615,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1682,7 +1682,7 @@ SelectionDisplay = (function () {
// translate mode left/right based on view toward entity // translate mode left/right based on view toward entity
var newIntersection = rayPlaneIntersection(pickRay, var newIntersection = rayPlaneIntersection(pickRay,
selectedEntityPropertiesOriginalPosition, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
var vector = Vec3.subtract(newIntersection, lastPlaneIntersection); var vector = Vec3.subtract(newIntersection, lastPlaneIntersection);
@ -1981,7 +1981,7 @@ SelectionDisplay = (function () {
that.checkMove = function() { that.checkMove = function() {
if (currentSelection.isKnownID && if (currentSelection.isKnownID &&
(!Vec3.equal(MyAvatar.position, lastAvatarPosition) || !Quat.equal(MyAvatar.orientation, lastAvatarOrientation))){ (!Vec3.equal(Camera.getPosition(), lastCameraPosition) || !Quat.equal(Camera.getOrientation(), lastCameraOrientation))){
that.select(currentSelection, false); that.select(currentSelection, false);
} }
}; };
@ -2277,7 +2277,7 @@ SelectionDisplay = (function () {
if (somethingClicked) { if (somethingClicked) {
pickRay = Camera.computePickRay(event.x, event.y); pickRay = Camera.computePickRay(event.x, event.y);
lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition, lastPlaneIntersection = rayPlaneIntersection(pickRay, selectedEntityPropertiesOriginalPosition,
Quat.getFront(lastAvatarOrientation)); Quat.getFront(lastCameraOrientation));
if (wantDebug) { if (wantDebug) {
print("mousePressEvent()...... " + overlayNames[result.overlayID]); print("mousePressEvent()...... " + overlayNames[result.overlayID]);
Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection); Vec3.print(" lastPlaneIntersection:", lastPlaneIntersection);