mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Feature/anchor and aim (#799)
Introduce the ability to navigate using an anchor and aim. Example use: Set spacecraft as anchor and planet as aim to always look down at a planet, while followin the spacecraft in its orbit.
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <openspace/properties/property.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* PropertyKey = "property";
|
||||
@@ -40,22 +42,19 @@ namespace openspace {
|
||||
void TriggerPropertyTopic::handleJson(const nlohmann::json& json) {
|
||||
try {
|
||||
const std::string& propertyKey = json.at(PropertyKey).get<std::string>();
|
||||
|
||||
properties::Property* prop = property(propertyKey);
|
||||
if (prop) {
|
||||
LDEBUG("Triggering " + propertyKey);
|
||||
prop->set("poke");
|
||||
}
|
||||
else {
|
||||
LWARNING("Could not find property " + propertyKey);
|
||||
}
|
||||
global::scriptEngine.queueScript(
|
||||
fmt::format(
|
||||
"openspace.setPropertyValueSingle(\"{}\", nil)", propertyKey
|
||||
),
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
catch (const std::out_of_range& e) {
|
||||
LERROR("Could not poke property -- key or value is missing in payload");
|
||||
LERROR("Could not trigger property -- key or value is missing in payload");
|
||||
LERROR(e.what());
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR("Could not poke property -- runtime error:");
|
||||
LERROR("Could not trigger property -- runtime error:");
|
||||
LERROR(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user