diff --git a/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset new file mode 100644 index 0000000000..688d90181d --- /dev/null +++ b/data/assets/scene/solarsystem/missions/jwst/toggle_trail.asset @@ -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) diff --git a/data/profiles/jwst.profile b/data/profiles/jwst.profile index d604b90cdd..49067feea8 100644 --- a/data/profiles/jwst.profile +++ b/data/profiles/jwst.profile @@ -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": { diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 95ad7958e1..92a5d2de8d 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -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();