diff --git a/interface/src/ui/overlays/Billboardable.cpp b/interface/src/ui/overlays/Billboardable.cpp index 34a4ef6df5..e71e8bb951 100644 --- a/interface/src/ui/overlays/Billboardable.cpp +++ b/interface/src/ui/overlays/Billboardable.cpp @@ -13,6 +13,7 @@ #include #include +#include "avatar/AvatarManager.h" void Billboardable::setProperties(const QVariantMap& properties) { auto isFacingAvatar = properties["isFacingAvatar"]; @@ -32,10 +33,11 @@ bool Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offse if (isFacingAvatar()) { glm::vec3 billboardPos = transform.getTranslation(); glm::vec3 cameraPos = qApp->getCamera().getPosition(); - glm::vec3 look = cameraPos - billboardPos; - float elevation = -asinf(look.y / glm::length(look)); - float azimuth = atan2f(look.x, look.z); - glm::quat rotation(glm::vec3(elevation, azimuth, 0)); + + glm::vec3 avatarUP = DependencyManager::get()->getMyAvatar()->getOrientation()*Vectors::UP; + + glm::quat rotation(conjugate(toQuat(glm::lookAt(billboardPos, cameraPos, avatarUP)))); + transform.setRotation(rotation); transform.postRotate(offsetRotation); return true; diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 6db9564c77..3a422bcb8a 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -203,14 +203,7 @@ SelectionManager = (function() { print("ERROR: entitySelectionTool.update got exception: " + JSON.stringify(e)); } } - - //update overlay to face Avatar - if ((!activeTool) || isActiveTool(grabberMoveUp)) { - Overlays.editOverlay(grabberMoveUp, { - rotation: Quat.lookAt(grabberMoveUpPosition, Camera.position, Quat.getUp(MyAvatar.orientation)) - }); - } - + }; return that; @@ -467,6 +460,7 @@ SelectionDisplay = (function() { visible: false, size: 0.1, scale: 0.1, + isFacingAvatar: true, drawInFront: true }); @@ -2113,8 +2107,7 @@ SelectionDisplay = (function() { z: position.z + (grabberMoveUpOffset + worldTop) * upVec.z }; Overlays.editOverlay(grabberMoveUp, { - visible: (!activeTool) || isActiveTool(grabberMoveUp), - rotation: Quat.lookAt(grabberMoveUpPosition, Camera.position, upVec) + visible: (!activeTool) || isActiveTool(grabberMoveUp) }); Overlays.editOverlay(baseOfEntityProjectionOverlay, { @@ -2463,7 +2456,7 @@ SelectionDisplay = (function() { var vector = Vec3.subtract(newIntersection, lastXYPick); // project vector onto avatar up vector - // we want the avatar referential not the camera. + // we want the avatar referential not the camera. var avatarUpVector = Quat.getUp(MyAvatar.orientation); var dotVectorUp = Vec3.dot(vector, avatarUpVector); vector = Vec3.multiply(dotVectorUp, avatarUpVector);