mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-01 16:29:43 -05:00
Add event to toggle JWST trail when approaching or going away
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
local toggle_trail = {
|
||||
Identifier = "event.jwst.toggle_trail",
|
||||
Name = "Toggle JWST Trail (Auto)",
|
||||
Command = [[
|
||||
local node
|
||||
if is_declared("args") then
|
||||
node = args.Node
|
||||
else
|
||||
node = openspace.navigation.getNavigationState().Anchor
|
||||
end
|
||||
|
||||
if node ~= "JWSTModel" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local launchTrail = "JWSTTrailLaunch"
|
||||
local orbitTrail = "JWSTTrailOrbit"
|
||||
|
||||
local visibility
|
||||
if is_declared("args") then
|
||||
if args.Transition == "Approaching" then
|
||||
visibility = false
|
||||
elseif args.Transition == "Exiting" then
|
||||
visibility = true
|
||||
else
|
||||
return
|
||||
end
|
||||
else
|
||||
visibility = not (
|
||||
openspace.getPropertyValue("Scene." .. launchTrail .. ".Renderable.Enabled") or
|
||||
openspace.getPropertyValue("Scene." .. orbitTrail .. ".Renderable.Enabled")
|
||||
)
|
||||
end
|
||||
|
||||
openspace.setPropertyValueSingle(
|
||||
"Scene." .. launchTrail .. ".Renderable.Enabled",
|
||||
visibility
|
||||
)
|
||||
openspace.setPropertyValueSingle(
|
||||
"Scene." .. orbitTrail .. ".Renderable.Enabled",
|
||||
visibility
|
||||
)
|
||||
]],
|
||||
Documentation = [[Toggles the visibility of the JWST trail with an
|
||||
approaching/exiting event. This action takes optional arguments to 1) determine which
|
||||
node is currently in focus and only hide JWST trail if it is in focus (as the
|
||||
'Node') and 2) the transition direction (as 'Approaching' or 'Exiting').]],
|
||||
GuiPath = "/events/JWST",
|
||||
IsLocal = true
|
||||
}
|
||||
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.action.registerAction(toggle_trail)
|
||||
|
||||
openspace.event.registerEventAction(
|
||||
"CameraFocusTransition",
|
||||
toggle_trail.Identifier,
|
||||
{ Transition = "Exiting" }
|
||||
)
|
||||
openspace.event.registerEventAction(
|
||||
"CameraFocusTransition",
|
||||
toggle_trail.Identifier,
|
||||
{ Transition = "Approaching" }
|
||||
)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function()
|
||||
openspace.event.unregisterEventAction(
|
||||
"CameraFocusTransition",
|
||||
toggle_trail.Identifier,
|
||||
{ Transition = "Exiting" }
|
||||
)
|
||||
openspace.event.unregisterEventAction(
|
||||
"CameraFocusTransition",
|
||||
toggle_trail.Identifier,
|
||||
{ Transition = "Approaching" }
|
||||
)
|
||||
|
||||
openspace.action.removeAction(toggle_trail)
|
||||
end)
|
||||
|
||||
asset.export("jwst.toggle_trail", toggle_trail.Identifier)
|
||||
@@ -69,7 +69,7 @@
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.toggle.jwst_trails",
|
||||
"is_local": false,
|
||||
"name": "Toggle JWST trails",
|
||||
"name": "Toggle JWST trail",
|
||||
"script": "local list = {'Scene.JWSTTrailLaunch.Renderable.Enabled', 'Scene.JWSTTrailOrbit.Renderable.Enabled'}; for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)); end"
|
||||
}
|
||||
],
|
||||
@@ -85,6 +85,7 @@
|
||||
"scene/solarsystem/missions/jwst/trail",
|
||||
"scene/solarsystem/missions/jwst/hudf",
|
||||
"scene/solarsystem/missions/jwst/timelapse",
|
||||
"scene/solarsystem/missions/jwst/toggle_trail",
|
||||
"scene/digitaluniverse/hdf"
|
||||
],
|
||||
"camera": {
|
||||
@@ -292,6 +293,11 @@
|
||||
"name": "Scene.JWSTFov.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.JWSTModel.ApproachFactor",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "900"
|
||||
}
|
||||
],
|
||||
"time": {
|
||||
|
||||
@@ -693,6 +693,8 @@ void RenderableModel::update(const UpdateData& data) {
|
||||
glm::compMax(data.modelTransform.scale)
|
||||
);
|
||||
|
||||
setInteractionSphere(_boundingSphere);
|
||||
|
||||
if (_geometry->hasAnimation() && !_animationStart.empty()) {
|
||||
double relativeTime;
|
||||
double now = data.time.j2000Seconds();
|
||||
|
||||
Reference in New Issue
Block a user