mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Create functions to look in WWT-window at direction in OpenSpace and some cleanup
This commit is contained in:
@@ -27,43 +27,31 @@ namespace {
|
||||
|
||||
namespace openspace::skybrowser::luascriptfunctions {
|
||||
|
||||
int updateFunction(lua_State* L) {
|
||||
// Get FOV from argument
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::updateFunction");
|
||||
float fov = ghoul::lua::value<float>(L, 1);
|
||||
int followCamera(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::followCamera");
|
||||
|
||||
// Get camera position
|
||||
//const glm::dvec3 cameraPosition = global::navigationHandler->camera()->positionVec3();
|
||||
const glm::dvec3 cameraPosition = global::navigationHandler->camera()->viewDirectionWorldSpace();
|
||||
|
||||
// Convert to celestial coordinates
|
||||
const SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();
|
||||
glm::dvec2 celestCoords = module->convertGalacticToCelestial(glm::dvec3(cameraPosition[0], cameraPosition[1], cameraPosition[2]));
|
||||
|
||||
// Execute javascript on browser
|
||||
ScreenSpaceBrowser* browser = dynamic_cast<ScreenSpaceBrowser*>(global::renderEngine->screenSpaceRenderable("ScreenSpaceBowser"));
|
||||
std::string script = "vm.onMessage({event: 'center_on_coordinates', ra : Number(" + std::to_string(celestCoords[0]) + "), dec : Number(" + std::to_string(celestCoords[1]) + "), fov : Number(" + std::to_string(fov) + "), instant : false})";
|
||||
browser->executeJavascript(script);
|
||||
module->WWTfollowCamera();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int testFunction(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::testFunction");
|
||||
int moveBrowser(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::moveBrowser");
|
||||
ScreenSpaceBrowser* browser = dynamic_cast<ScreenSpaceBrowser*>(global::renderEngine->screenSpaceRenderable("ScreenSpaceBowser"));
|
||||
browser->translate(glm::vec3(-0.8, -0.4, 0.0));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int createBrowser(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::createBrowser");
|
||||
ghoul::lua::value<std::string>(L, 1);
|
||||
|
||||
const SkybrowserModule* module = global::moduleEngine->module<SkybrowserModule>();
|
||||
glm::dvec3 testvec = glm::dvec3(0.0, 0.0, 0.0);
|
||||
module->convertGalacticToCelestial(testvec);
|
||||
|
||||
LINFOC(_loggerCat, "hoho");
|
||||
LINFOC(_loggerCat, std::to_string(module->zoomFactor()));
|
||||
|
||||
//std::string _url = "https://wallpaperaccess.com/full/3010132.jpg";
|
||||
// 'https://cdn.wallpapersafari.com/6/92/0nbCPw.jpg'
|
||||
/*
|
||||
// get url from user
|
||||
const std::string _url = ghoul::lua::value<std::string>(L, 1);
|
||||
*/
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
ghoul::Dictionary node;
|
||||
@@ -77,8 +65,6 @@ namespace openspace::skybrowser::luascriptfunctions {
|
||||
"openspace.addScreenSpaceRenderable(" + ghoul::formatLua(node) + ")",
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user