mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-09 13:12:58 -06:00
Add Lua function to get current distance to focus
This commit is contained in:
@@ -639,7 +639,8 @@ scripting::LuaLibrary NavigationHandler::luaLibrary() {
|
||||
codegen::lua::TriggerIdleBehavior,
|
||||
codegen::lua::ListAllJoysticks,
|
||||
codegen::lua::TargetNextInterestingAnchor,
|
||||
codegen::lua::TargetPreviousInterestingAnchor
|
||||
codegen::lua::TargetPreviousInterestingAnchor,
|
||||
codegen::lua::DistanceToFocus
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -406,6 +406,18 @@ joystickAxis(std::string joystickName, int axis)
|
||||
return global::navigationHandler->listAllJoysticks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance in meters to the current focus node
|
||||
*/
|
||||
[[codegen::luawrap]] double distanceToFocus() {
|
||||
using namespace openspace;
|
||||
|
||||
const SceneGraphNode * focus = global::navigationHandler->anchorNode();
|
||||
Camera * camera = global::navigationHandler->camera();
|
||||
|
||||
return glm::distance(camera->positionVec3(), focus->worldPosition());
|
||||
}
|
||||
|
||||
#include "navigationhandler_lua_codegen.cpp"
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user