Files
OpenSpace/data/assets/events/toggle_sun.asset

62 lines
1.8 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 args.Transition == "Approaching" then
openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Enabled", false)
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Enabled", true)
else -- "Exiting"
openspace.setPropertyValueSingle("Scene.SunGlare.Renderable.Enabled", true)
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Enabled", false)
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 = "/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"
}