Files
OpenSpace/data/assets/events/toggle_sun.asset
T
Alexander Bock 163ac4dcef Cleanup of mostly asset files
- Fixes for all files
 - constexpr cleanup
 - Cosmetic changes
 - Remove punctuation from the end of messages
2022-07-28 17:21:59 +02:00

66 lines
2.0 KiB
Lua

local toggle_sun = {
Identifier = "os.toggle_sun",
Name = "Toggle Sun",
Command = [[
if not is_declared("args") then
openspace.printError("Cannot execute 'os.toggle_sun' manually")
return
end
if not openspace.getPropertyValue("Scene.Sun.Renderable.Enabled") then
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Enabled", true)
end
if args.Transition == "Approaching" then
openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Fade", 0.0, 1.0)
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Fade", 1.0, 1.0)
else -- "Exiting"
openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Fade", 1.0, 1.0)
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Fade", 0.0, 1.0)
end
]],
Documentation = [[Toggles the visibility of the Sun glare and the Sun globe when the
camera is approaching either so that from far away the Sun Glare is rendered and when
close up, the globe is rendered instead]],
GuiPath = "/Solar System/Sun",
IsLocal = false
}
asset.onInitialize(function()
openspace.action.registerAction(toggle_sun)
openspace.event.registerEventAction(
"CameraFocusTransition",
toggle_sun.Identifier,
{ Node = "Sun", Transition = "Approaching" }
)
openspace.event.registerEventAction(
"CameraFocusTransition",
toggle_sun.Identifier,
{ Node = "Sun", Transition = "Exiting" }
)
end)
asset.onDeinitialize(function()
openspace.event.unregisterEventAction(
"CameraFocusTransition",
toggle_sun.Identifier,
{ Node = "Sun", Transition = "Exiting" }
)
openspace.event.unregisterEventAction(
"CameraFocusTransition",
toggle_sun.Identifier,
{ Node = "Sun", Transition = "Approaching" }
)
openspace.action.removeAction(toggle_sun)
end)
asset.meta = {
Name = "Actions - Toggle current Trails",
Version = "1.0",
Description = "Asset providing actions to toggle trails",
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license"
}