From 509deb7996ad8aef91f51b97cbd74c92c8faa800 Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Tue, 15 Sep 2026 14:37:32 +0300 Subject: #5663 add LEAP API to request camera position and orientation --- indra/newview/llagentlistener.cpp | 20 ++++++++++++++++++++ indra/newview/llagentlistener.h | 1 + 2 files changed, 21 insertions(+) diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index 2c4ec1fc59..f0b508592e 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -208,6 +208,15 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "avatar render position is used as the point", &LLAgentListener::getAgentScreenPos, llsd::map("reply", LLSD())); + + add("getCamera", + "Send information about the viewer camera's current state on [\"reply\"]:\n" + "[\"position\"]: array of [x, y, z] camera position in agent coordinates\n" + "[\"rotation\"]: array of [x, y, z, w] camera rotation quaternion\n" + "[\"fov\"]: vertical field of view, in radians\n" + "[\"focus_position\"]: array of [x, y, z] camera focus position in agent coordinates", + &LLAgentListener::getCamera, + llsd::map("reply", LLSD())); } void LLAgentListener::requestTeleport(LLSD const & event_data) const @@ -849,3 +858,14 @@ void LLAgentListener::getAgentScreenPos(LLSD const& event_data) response["x"] = screen_pos.mX; response["y"] = screen_pos.mY; } + +void LLAgentListener::getCamera(LLSD const& event_data) +{ + Response response(LLSD(), event_data); + LLViewerCamera* camera = LLViewerCamera::getInstance(); + + response["position"] = ll_sd_from_vector3(camera->getOrigin()); + response["rotation"] = ll_sd_from_quaternion(camera->getQuaternion()); + response["fov"] = camera->getView(); + response["focus_position"] = ll_sd_from_vector3(mAgent.getPosAgentFromGlobal(gAgentCamera.getFocusGlobal())); +} diff --git a/indra/newview/llagentlistener.h b/indra/newview/llagentlistener.h index 031fc75e46..fa08822998 100644 --- a/indra/newview/llagentlistener.h +++ b/indra/newview/llagentlistener.h @@ -70,6 +70,7 @@ private: void getNearbyObjectsList(LLSD const& event_data); void getAttachedObjectsList(LLSD const& event_data); void getAgentScreenPos(LLSD const& event_data); + void getCamera(LLSD const& event_data); LLViewerObject * findObjectClosestTo( const LLVector3 & position, bool sit_target = false ) const; -- cgit v1.3