mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-07 03:49:43 -05:00
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:
@@ -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)
|
||||
Reference in New Issue
Block a user