Add example for NavigationState (#3246)

* Add example for NavigationState
* Modify comment messages per code review feedback
* Corrected some details to match examples rules
This commit is contained in:
Gene Payne
2024-05-20 13:55:08 -06:00
committed by GitHub
parent dfbe0f45bb
commit 5aadbf1246
@@ -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)