From 5aadbf12464d0c6086b0db48cd2c82f333b32403 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Mon, 20 May 2024 13:55:08 -0600 Subject: [PATCH] Add example for NavigationState (#3246) * Add example for NavigationState * Modify comment messages per code review feedback * Corrected some details to match examples rules --- data/assets/examples/navigationstate.asset | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 data/assets/examples/navigationstate.asset diff --git a/data/assets/examples/navigationstate.asset b/data/assets/examples/navigationstate.asset new file mode 100644 index 0000000000..da04d88241 --- /dev/null +++ b/data/assets/examples/navigationstate.asset @@ -0,0 +1,35 @@ +-- Basic +-- Example of an action that uses getNavigationState and setNavigationState +-- to manipulate the camera view + +local FlipUpsideDown = { + Identifier = "NavigationState_Example", + Name = "Flip View Upside-Down", + Command = [[ + -- Get the current navigation state + local currentNavState = openspace.navigation.getNavigationState() + -- Create a new navigation state and populate with all original orientation + -- values, except for a new Up vector to flip the camera upside-down + local newNavState = { + Pitch = currentNavState["Pitch"], + Anchor = currentNavState["Anchor"], + Yaw = currentNavState["Yaw"], + Position = currentNavState["Position"], + Up = {0.0, 0.0, -1.0} + } + -- Set the navigation state with the new navigation state variable + openspace.navigation.setNavigationState(newNavState) + ]], + GUI = { + Name = "Basic", + Path = "/Examples/NavigationState" + } +} + +asset.onInitialize(function() + openspace.action.registerAction(FlipUpsideDown) +end) + +asset.onDeinitialize(function() + openspace.action.removeAction(FlipUpsideDown) +end)