mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Add an action to automatically switch the Sun and SunGlare when approaching the Sun (closes #1914)
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
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"
|
||||
}
|
||||
@@ -5,12 +5,12 @@ asset.onInitialize(function()
|
||||
"CameraFocusTransition",
|
||||
action.show_trail,
|
||||
{ Transition = "Exiting" }
|
||||
);
|
||||
)
|
||||
openspace.event.registerEventAction(
|
||||
"CameraFocusTransition",
|
||||
action.hide_trail,
|
||||
{ Transition = "Approaching" }
|
||||
);
|
||||
)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
@@ -18,10 +18,10 @@ asset.onDeinitialize(function()
|
||||
"CameraFocusTransition",
|
||||
action.show_trail,
|
||||
{ Transition = "Exiting" }
|
||||
);
|
||||
)
|
||||
openspace.event.unregisterEventAction(
|
||||
"CameraFocusTransition",
|
||||
action.hide_trail,
|
||||
{ Transition = "Approaching" }
|
||||
);
|
||||
)
|
||||
end)
|
||||
|
||||
@@ -12,6 +12,7 @@ local Sun = {
|
||||
Layers = {},
|
||||
PerformShading = false
|
||||
},
|
||||
ApproachFactor = 15.0,
|
||||
GUI = {
|
||||
Name = "Sun",
|
||||
Path = "/Solar System/Sun",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
],
|
||||
"assets": [
|
||||
"base",
|
||||
"events/toggle_sun",
|
||||
"scene/solarsystem/planets/earth/earth",
|
||||
"scene/solarsystem/planets/earth/satellites/satellites"
|
||||
],
|
||||
@@ -104,4 +105,4 @@
|
||||
"major": 1,
|
||||
"minor": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
],
|
||||
"assets": [
|
||||
"base",
|
||||
"events/toggle_sun",
|
||||
"scene/solarsystem/planets/earth/earth",
|
||||
"scene/solarsystem/planets/earth/satellites/satellites",
|
||||
"scene/solarsystem/planets/jupiter/major_moons",
|
||||
@@ -130,4 +131,4 @@
|
||||
"major": 1,
|
||||
"minor": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user