mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-03 09:20:26 -05:00
Merge pull request #1759 from OpenSpace/feature/animation-fixes
JWST update
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
local horizons = asset.syncedResource({
|
||||
Name = "JWST Horizons",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_horizons",
|
||||
Version = 2
|
||||
})
|
||||
|
||||
asset.export('horizons', horizons)
|
||||
+37
-15
@@ -1,14 +1,8 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local transforms = asset.require('scene/solarsystem/planets/earth/transforms')
|
||||
local jwstTransforms = asset.require('scene/solarsystem/missions/jwst/jwst')
|
||||
local jwstTransforms = asset.require('./transforms')
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
|
||||
local image = asset.syncedResource({
|
||||
Name = "HUDF image",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "hudf_image",
|
||||
Version = 1
|
||||
})
|
||||
local image = asset.require('./image').image
|
||||
|
||||
local DISTANCE = 9.2E15;
|
||||
|
||||
@@ -29,9 +23,12 @@ local HUDFPosition = {
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
Name = "Hubble Ultra Deep field",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true
|
||||
Name = "Hubble Ultra Deep Field Position",
|
||||
Path = "/Solar System/Missions/JWST/HUDF",
|
||||
Hidden = true,
|
||||
Description = [[
|
||||
Galactic cartesian position for the Hubble Ultra Deep Field
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,18 +36,27 @@ local HUDFImage = {
|
||||
Identifier = "HUDFImage",
|
||||
Enabled = false,
|
||||
Type = "ScreenSpaceImageLocal",
|
||||
Name = "Hubble Ultra Deep field",
|
||||
Name = "Hubble Ultra Deep Field",
|
||||
UseRadiusAzimuthElevation = true,
|
||||
FaceCamera = false,
|
||||
RadiusAzimuthElevation = { 200.0, 0.5, 0.15 },
|
||||
RadiusAzimuthElevation = { 200.0, 0.5, 0.1 },
|
||||
UsePerspectiveProjection = false,
|
||||
Opacity = 1.0,
|
||||
TexturePath = image .. "/Hubble_ultra_deep_field.jpg",
|
||||
TexturePath = image .. "/Hubble_ultra_deep_field.png",
|
||||
Tag = { "mission_jwst_hudf" },
|
||||
Description = [[
|
||||
Image of the Hubble Ultra Deep Field by NASA, ESA, and S. Beckwith (STScI) and
|
||||
the HUDF Team.
|
||||
]],
|
||||
}
|
||||
|
||||
local HUDFJWSTLine = {
|
||||
Identifier = "HUDFJWSTLine",
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2021 OCT 01"
|
||||
},
|
||||
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
@@ -63,7 +69,10 @@ local HUDFJWSTLine = {
|
||||
Tag = { "mission_jwst_hudf" },
|
||||
GUI = {
|
||||
Name = "JWST to HUDF Line",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Path = "/Solar System/Missions/JWST/HUDF",
|
||||
Description = [[
|
||||
Line from the James Webb Space Telescope to the Hubble Ultra Deep Field
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,3 +84,16 @@ end)
|
||||
asset.onDeinitialize(function()
|
||||
openspace.removeScreenSpaceRenderable(HUDFImage.Identifier)
|
||||
end)
|
||||
|
||||
asset.meta = {
|
||||
Name = "Hubble Ultra Deep Field Image and Line",
|
||||
Version = "1.0",
|
||||
Description = [[
|
||||
Screenspace image of the Hubble Ultra Deep Field and a line from the
|
||||
James Webb Space Telescope to the Hubble Ultra Deep Field position.
|
||||
]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license",
|
||||
Identifiers = {"HUDFPosition", "HUDFImage", "HUDFJWSTLine"}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
local image = asset.syncedResource({
|
||||
Name = "HUDF Image",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "hudf_image",
|
||||
Version = 3
|
||||
})
|
||||
|
||||
asset.export('image', image)
|
||||
|
||||
asset.meta = {
|
||||
Name = "Hubble Ultra Deep Field",
|
||||
Version = "1.0",
|
||||
Description = "Hubble Ultra Deep Field Image",
|
||||
Author = "NASA, ESA, and S. Beckwith (STScI) and the HUDF Team",
|
||||
URL = "https://esahubble.org/images/heic0611b/",
|
||||
License = [[
|
||||
Original image by NASA, ESA, and S. Beckwith (STScI) and the HUDF Team,
|
||||
white frame and red arrow added by OpenSpace Team.<br>
|
||||
https://creativecommons.org/licenses/by/4.0/
|
||||
]]
|
||||
}
|
||||
@@ -1,30 +1,8 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
|
||||
local transforms = asset.require('./transforms')
|
||||
local models = asset.require('./model').models
|
||||
asset.require('spice/base')
|
||||
asset.require('scene/solarsystem/planets/earth/lagrange_points/lagrange_points')
|
||||
local transforms = asset.require('scene/solarsystem/planets/earth/lagrange_points/L2')
|
||||
|
||||
local JWSTKernel = asset.syncedResource({
|
||||
Name = "JWST Kernel",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_kernels",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
--[[local JWSTHorizons = asset.syncedResource({
|
||||
Name = "JWST Horizons",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_horizons",
|
||||
Version = 1
|
||||
})]]--
|
||||
|
||||
local model = asset.syncedResource({
|
||||
Name = "JWST Model",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_model",
|
||||
Version = 2
|
||||
})
|
||||
|
||||
local band = asset.syncedResource({
|
||||
Name = "JWST band texture",
|
||||
@@ -33,47 +11,14 @@ local band = asset.syncedResource({
|
||||
Version = 1
|
||||
})
|
||||
|
||||
local JWSTPosition = {
|
||||
Identifier = "JWSTPosition",
|
||||
Parent = transforms.L2.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = "JWST",
|
||||
Observer = "392", -- L2
|
||||
Kernels = JWSTKernel .. "/jwst_horizons_20200101_20240101_v01.bsp"
|
||||
},
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Position",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true,
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTRotation = {
|
||||
Identifier = "JWSTRotation",
|
||||
Parent = JWSTPosition.Identifier,
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "FixedRotation",
|
||||
Attached = "JWSTRotation",
|
||||
XAxis = { 1, 0, 0 },
|
||||
XAxisOrthogonal = true,
|
||||
YAxisInvert = true,
|
||||
YAxis = sunTransforms.SolarSystemBarycenter.Identifier
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Rotation",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true,
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTBand = {
|
||||
Identifier = "JWSTBand",
|
||||
Parent = JWSTPosition.Identifier,
|
||||
Parent = transforms.JWSTPosition.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2021 OCT 01"
|
||||
},
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "FixedRotation",
|
||||
@@ -97,25 +42,28 @@ local JWSTBand = {
|
||||
Tag = { "mission_jwst_fov" },
|
||||
GUI = {
|
||||
Name = "JWST Safe Viewing Band",
|
||||
Path = "/Solar System/Missions/JWST"
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Description = [[
|
||||
The safe viewing band for the James Webb Space Telescope at its current position
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTModel = {
|
||||
Identifier = "JWSTModel",
|
||||
Parent = JWSTRotation.Identifier,
|
||||
Parent = transforms.JWSTRotation.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2020 JAN 01",
|
||||
End = "2024 JAN 01"
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2021 OCT 01"
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
GeometryFile = model .. "/JWST.osmodel",
|
||||
ModelScale = "Foot",
|
||||
InvertModelScale = true,
|
||||
GeometryFile = models .. "/jwst_anim74_2fps_2018_nb.osmodel",
|
||||
ModelScale = 0.0328, -- First scale down with centimeters then scale up with feet
|
||||
EnableAnimation = true,
|
||||
AnimationStartTime = "2018 10 01 14:05:52",
|
||||
AnimationStartTime = "2018 10 01 14:06:03",
|
||||
AnimationTimeScale = "Millisecond",
|
||||
AnimationMode = "Once",
|
||||
LightSources = {
|
||||
{
|
||||
@@ -131,55 +79,21 @@ local JWSTModel = {
|
||||
GUI = {
|
||||
Name = "James Webb Space Telescope Model",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTTrail = {
|
||||
Identifier = "JWSTTrail",
|
||||
Parent = transforms.L2.Identifier,
|
||||
Renderable = {
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = "JWST",
|
||||
Observer = "392", -- L2
|
||||
Kernels = JWSTKernel .. "/jwst_horizons_20200101_20240101_v01.bsp"
|
||||
},
|
||||
Color = { 0.9, 0.9, 0.0 },
|
||||
Period = 91.3105,
|
||||
Resolution = 100
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Trail",
|
||||
Path = "/Solar System/Missions/JWST"
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTSunTrail = {
|
||||
Identifier = "JWSTSunTrail",
|
||||
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = "JWST",
|
||||
Observer = "SSB",
|
||||
Kernels = JWSTKernel .. "/jwst_horizons_20200101_20240101_v01.bsp"
|
||||
},
|
||||
Color = { 0.0, 0.9, 0.9 },
|
||||
Period = 365.242,
|
||||
Resolution = 1000
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Sun Trail",
|
||||
Path = "/Solar System/Missions/JWST"
|
||||
Description = [[
|
||||
Animated model of the James Webb Space Telescope that shows its deployment in
|
||||
real time
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTFov = {
|
||||
Identifier = "JWSTFov",
|
||||
Parent = JWSTModel.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2021 OCT 01"
|
||||
},
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderablePrism",
|
||||
@@ -200,103 +114,53 @@ local JWSTFov = {
|
||||
GUI = {
|
||||
Name = "JWST Field of View",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Description = [[
|
||||
The field of view for the James Webb Space Telescope at its current position
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
-- Launch, coming soon
|
||||
--[[local JWSTLaunchPosition = {
|
||||
Identifier = "JWSTLaunchPosition",
|
||||
Parent = transforms.L2.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = JWSTHorizons .. "/horizons_jwst_launch.dat",
|
||||
},
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Launch Position",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true,
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTLaunchModel = {
|
||||
Identifier = "JWSTLaunchModel",
|
||||
Parent = JWSTLaunchPosition.Identifier,
|
||||
local JWSTLabel = {
|
||||
Identifier = "JWSTLabel",
|
||||
Parent = transforms.JWSTPosition.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 14:05:52",
|
||||
End = "2019 OCT 01"
|
||||
},
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "FixedRotation",
|
||||
Attached = "JWSTRotation",
|
||||
XAxis = { 1, 0, 0 },
|
||||
XAxisOrthogonal = true,
|
||||
YAxisInvert = true,
|
||||
YAxis = sunTransforms.SolarSystemBarycenter.Identifier
|
||||
}
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2021 OCT 01"
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableModel",
|
||||
GeometryFile = model .. "/JWST.osmodel",
|
||||
ModelScale = "Foot",
|
||||
InvertModelScale = true,
|
||||
EnableAnimation = true,
|
||||
AnimationStartTime = "2018 10 01 14:05:52",
|
||||
AnimationMode = "Once",
|
||||
LightSources = {
|
||||
{
|
||||
Type = "SceneGraphLightSource",
|
||||
Identifier = "Sun",
|
||||
Node = sunTransforms.SolarSystemBarycenter.Identifier,
|
||||
Intensity = 1.0
|
||||
}
|
||||
},
|
||||
PerformShading = true,
|
||||
DisableFaceCulling = true
|
||||
Enabled = true,
|
||||
Type = "RenderableLabels",
|
||||
Text = "JWST",
|
||||
FontSize = 20,
|
||||
Size = 6.25,
|
||||
MinMaxSize = { 1.0, 100.0 },
|
||||
OrientationOption = "Camera View Direction",
|
||||
BlendMode = "Normal",
|
||||
EnableFading = false
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Launch Model",
|
||||
Name = "JWST Label",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Description = "Main label for the James Webb Space Telescope"
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTLaunchTrail = {
|
||||
Identifier = "JWSTLaunchTrail",
|
||||
Parent = transforms.L2.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 13:18:00",
|
||||
End = "2019 OCT 01"
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableTrailTrajectory",
|
||||
Translation = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = JWSTHorizons .. "/horizons_jwst_launch.dat",
|
||||
},
|
||||
Color = { 0.9, 0.9, 0.0 },
|
||||
StartTime = "2018 OCT 01 13:18:00",
|
||||
EndTime = "2019 OCT 01",
|
||||
SampleInterval = 600
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Launch Trail",
|
||||
Path = "/Solar System/Missions/JWST"
|
||||
}
|
||||
}]]--
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, {
|
||||
JWSTTrail,
|
||||
JWSTSunTrail,
|
||||
--JWSTLaunchTrail,
|
||||
JWSTPosition,
|
||||
--JWSTLaunchPosition,
|
||||
JWSTRotation,
|
||||
JWSTBand,
|
||||
JWSTModel,
|
||||
--JWSTLaunchModel,
|
||||
JWSTFov
|
||||
JWSTFov,
|
||||
JWSTLabel
|
||||
})
|
||||
|
||||
asset.meta = {
|
||||
Name = "James Webb Space Telescope",
|
||||
Version = "1.0",
|
||||
Description = [[
|
||||
James Webb Space Telescope animated model, safe viewing band, field of view and label.
|
||||
]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license",
|
||||
Identifiers = {"JWSTBand", "JWSTModel", "JWSTFov", "JWSTLabel"}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
local kernels = asset.syncedResource({
|
||||
Name = "JWST Kernel",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_kernels",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
asset.export('kernels', kernels)
|
||||
@@ -0,0 +1,8 @@
|
||||
local models = asset.syncedResource({
|
||||
Name = "JWST Model",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "jwst_model",
|
||||
Version = 3
|
||||
})
|
||||
|
||||
asset.export('models', models)
|
||||
@@ -0,0 +1,436 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
|
||||
-- JWST timelapse timeline
|
||||
local timelapse = [[
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:06:02",
|
||||
"",
|
||||
"openspace.scriptScheduler.clear(0)"
|
||||
)
|
||||
-- Mission start
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:06:04",
|
||||
"openspace.setPropertyValueSingle('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma', 0.7)" ..
|
||||
"openspace.setPropertyValueSingle('Scene.EarthAtmosphere.Renderable.Enabled', false)",
|
||||
"openspace.time.interpolateDeltaTime(-1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '')" ..
|
||||
"openspace.setPropertyValueSingle('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma', 1.0)" ..
|
||||
"openspace.setPropertyValueSingle('Scene.EarthAtmosphere.Renderable.Enabled', true)"
|
||||
)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:06:05", -- 2 sec delay
|
||||
"openspace.time.interpolateDeltaTime(120)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '')"
|
||||
)
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:10:03", -- 4 min pre delay
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '')"
|
||||
)
|
||||
|
||||
-- array deploy, forwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:35:23", -- 1 min pre delay so time to interpolate
|
||||
"openspace.time.interpolateDeltaTime(1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 1 second/second')"
|
||||
)
|
||||
-- array deploy, backwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:36:23",
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-120)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 minutes/second')"
|
||||
)
|
||||
|
||||
-- array complete, forwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:36:45",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')"
|
||||
)
|
||||
-- array complete, backwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 14:37:55", -- 1 min 10 sec pre delay so time to interpolate
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -1 second/second')"
|
||||
)
|
||||
-- array complete, backwards prepare
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 01 15:46:45", -- 1h 10 min delay for interpolation
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-120)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 minutes/second')"
|
||||
)
|
||||
|
||||
-- antenna deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 02 08:06:03",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- antenna complete, forwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 02 13:45:03",
|
||||
"openspace.time.interpolateDeltaTime(18000)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 5 hours/second')"
|
||||
)
|
||||
-- antenna complete, backwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 02 14:45:03", -- 1h pre delay so time to interpolate
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- fw palette deploy, forwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 04 06:26:38", -- 2h pre delay so time to interpolate
|
||||
"openspace.time.interpolateDeltaTime(3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 1 hour/second')"
|
||||
)
|
||||
-- fw palette deploy, backwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 04 08:26:38",
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-18000)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -5 hours/second')"
|
||||
)
|
||||
|
||||
-- fw palette complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 04 20:06:03",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -1 hour/second')"
|
||||
)
|
||||
|
||||
-- r palette deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 04 22:57:03",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- r palette complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 05 02:06:03",
|
||||
"openspace.time.interpolateDeltaTime(120)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- base rise deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 05 02:28:03",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-120)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 minutes/second')"
|
||||
)
|
||||
|
||||
-- base rise complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 06 07:41:03",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- aft flap deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 06 11:06:03",
|
||||
"openspace.time.interpolateDeltaTime(600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 10 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- aft flap complete, forwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 06 15:43:03",
|
||||
"openspace.time.interpolateDeltaTime(3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 1 hour/second')"
|
||||
)
|
||||
-- aft flap complete, backwards
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 06 16:13:03", -- 30 min pre delay so time to interpolate
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -10 minutes/second')"
|
||||
)
|
||||
|
||||
-- mid booms extend
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 01:35:46",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -1 hour/second')"
|
||||
)
|
||||
|
||||
-- first boom stop
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 02:22:19",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- right boom complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 07:48:08",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- left booms complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 12:12:03",
|
||||
"openspace.time.interpolateDeltaTime(30)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 seconds/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- tension sun shield membranes
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 12:15:17",
|
||||
"openspace.time.interpolateDeltaTime(60)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 1 minute/second')",
|
||||
"openspace.time.interpolateDeltaTime(-30)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 seconds/second')"
|
||||
)
|
||||
|
||||
-- membrane tension complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 07 12:26:03",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-60)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -1 minute/second')"
|
||||
)
|
||||
|
||||
-- membranes separate
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 08 02:42:52",
|
||||
"openspace.time.interpolateDeltaTime(3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 1 hour/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- secondary mirror deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 08 14:06:03",
|
||||
"openspace.time.interpolateDeltaTime(18000)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 5 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-3600)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -1 hour/second')"
|
||||
)
|
||||
|
||||
-- secondary mirror complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 13 00:39:03",
|
||||
"openspace.time.interpolateDeltaTime(1200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 20 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-18000)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -5 hours/second')"
|
||||
)
|
||||
|
||||
-- aft radiator deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 13 02:26:51",
|
||||
"openspace.time.interpolateDeltaTime(1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 30 minutes/second')",
|
||||
"openspace.time.interpolateDeltaTime(-1200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -20 minutes/second')"
|
||||
)
|
||||
|
||||
-- aft radiator complete, forward
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 13 06:11:03",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')"
|
||||
)
|
||||
-- aft radiator complete, backward
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 13 07:11:03", -- 1h pre delay so time to interpolate
|
||||
"",
|
||||
"openspace.time.interpolateDeltaTime(-1800)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -30 minutes/second')"
|
||||
)
|
||||
|
||||
-- rt cord fold wings deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 13 23:36:03",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- rt cord fold wings complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 15 02:46:51",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- lft cord fold wings deploy
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 15 13:06:03",
|
||||
"openspace.time.interpolateDeltaTime(7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: 2 hours/second')",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')"
|
||||
)
|
||||
|
||||
-- lft cord fold wings complete
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 16 09:06:03",
|
||||
"openspace.time.interpolateDeltaTime(1)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '')" ..
|
||||
"openspace.setPropertyValueSingle('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma', 1.0)" ..
|
||||
"openspace.setPropertyValueSingle('Scene.EarthAtmosphere.Renderable.Enabled', true)",
|
||||
"openspace.time.interpolateDeltaTime(-7200)" ..
|
||||
"openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', 'Time speed: -2 hours/second')" ..
|
||||
"openspace.setPropertyValueSingle('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma', 0.7)" ..
|
||||
"openspace.setPropertyValueSingle('Scene.EarthAtmosphere.Renderable.Enabled', false)"
|
||||
)
|
||||
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 OCT 16 09:06:05",
|
||||
"openspace.scriptScheduler.clear(0)"
|
||||
)
|
||||
]]
|
||||
|
||||
local playForwards = {
|
||||
Identifier = "jwst.play.forwards",
|
||||
Name = "Play JWST from start",
|
||||
Command = [[
|
||||
openspace.scriptScheduler.clear(0);
|
||||
openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '');
|
||||
openspace.time.setDeltaTime(1);
|
||||
openspace.time.setTime('2018 OCT 01 14:06:03');
|
||||
]] .. timelapse .. [[
|
||||
]],
|
||||
Documentation = "Jump to the JWST launch time and play the timelapse of deployment forward",
|
||||
GuiPath = "/JWST",
|
||||
IsLocal = false
|
||||
}
|
||||
|
||||
local playBackwards = {
|
||||
Identifier = "jwst.play.backwards",
|
||||
Name = "Play JWST from end",
|
||||
Command = [[
|
||||
openspace.scriptScheduler.clear(0);
|
||||
openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '');
|
||||
openspace.time.setDeltaTime(-1);
|
||||
openspace.time.setTime('2018 OCT 16 09:06:04');
|
||||
]] .. timelapse .. [[
|
||||
]],
|
||||
Documentation = "Jump to the end of JWST deployment time and play the timelapse of deployment in reverse",
|
||||
GuiPath = "/JWST",
|
||||
IsLocal = false
|
||||
}
|
||||
|
||||
local clearPlay = {
|
||||
Identifier = "jwst.play.clear",
|
||||
Name = "Clear JWST timelapse",
|
||||
Command = [[
|
||||
openspace.scriptScheduler.clear(0);
|
||||
openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '');
|
||||
openspace.setPropertyValueSingle('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Settings.Gamma', 1.0)
|
||||
openspace.setPropertyValueSingle('Scene.EarthAtmosphere.Renderable.Enabled', true)
|
||||
local deltaTime = openspace.time.deltaTime();
|
||||
if deltaTime > 0 then
|
||||
openspace.time.setDeltaTime(1);
|
||||
else
|
||||
openspace.time.setDeltaTime(-1);
|
||||
end
|
||||
]],
|
||||
Documentation = "Set delta time back to realtime and clear the JWST deployment timelapse",
|
||||
GuiPath = "/JWST",
|
||||
IsLocal = false
|
||||
}
|
||||
|
||||
local togglePlayDirection = {
|
||||
Identifier = "jwst.toggle.direction",
|
||||
Name = "Toggle forwards/ backwards",
|
||||
Command = [[
|
||||
-- Flip deltatime
|
||||
local deltaTime = openspace.time.deltaTime();
|
||||
openspace.time.setDeltaTime(-deltaTime);
|
||||
|
||||
-- Update the dashboard text
|
||||
local text = openspace.getPropertyValue('Dashboard.JWSTStateText.Text');
|
||||
if(string.len(text) > 14) then
|
||||
local newText = ''
|
||||
if(text:sub(13, 13) == '-') then
|
||||
newText = text:sub(1,12) .. text:sub(14)
|
||||
else
|
||||
newText = text:sub(1,12) .. '-' .. text:sub(13)
|
||||
end
|
||||
openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', tostring(newText));
|
||||
else
|
||||
openspace.setPropertyValueSingle('Dashboard.JWSTStateText.Text', '');
|
||||
end
|
||||
]],
|
||||
Documentation = "Toggle deployment timelapse direction between forwards and backwards",
|
||||
GuiPath = "/JWST",
|
||||
IsLocal = false
|
||||
}
|
||||
|
||||
asset.onInitialize(function()
|
||||
openspace.action.registerAction(playForwards)
|
||||
openspace.action.registerAction(playBackwards)
|
||||
openspace.action.registerAction(clearPlay)
|
||||
openspace.action.registerAction(togglePlayDirection)
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
openspace.scriptScheduler.clear()
|
||||
|
||||
openspace.action.removeAction(playForwards.Identifier)
|
||||
openspace.action.removeAction(playBackwards.Identifier)
|
||||
openspace.action.removeAction(clearPlay.Identifier)
|
||||
openspace.action.removeAction(togglePlayDirection.Identifier)
|
||||
end)
|
||||
|
||||
assetHelper.registerDashboardItems(asset, {
|
||||
{
|
||||
Type = "DashboardItemText",
|
||||
Identifier = "JWSTStateText",
|
||||
GuiName = "JWST State Dashboard Text",
|
||||
Text = ""
|
||||
}
|
||||
})
|
||||
|
||||
asset.meta = {
|
||||
Name = "James Webb Space Telescope Timelapse",
|
||||
Version = "1.0",
|
||||
Description = [[
|
||||
Scripts that are scheduled to alter the speed of the simulation time so the deployment
|
||||
of the James Webb Space Telescope looks smoother.
|
||||
]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license"
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local transforms = asset.require('scene/solarsystem/planets/earth/lagrange_points/L2')
|
||||
local earthTransforms = asset.require('scene/solarsystem/planets/earth/transforms')
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
local horizons = asset.require('./horizons').horizons
|
||||
local kernels = asset.require('./kernels').kernels
|
||||
asset.require("spice/base")
|
||||
|
||||
-- (malej 2021-10-04) In general, there is no trajectery data of JWST for the scheduled
|
||||
-- launch in December 2021, no horizons and no SPICE. Instead data from the 2018 launch
|
||||
-- is used, old data from an old launch time that never happened because of delays.
|
||||
-- If we can get our hands on the 2021 launch data, the jwst assets will be updated.
|
||||
|
||||
-- Trail of JWST relative the Earth for the first month after launch
|
||||
-- Makes histroy of trail to stay at Earth, that a trail relative to L2 won't
|
||||
local JWSTTrailLaunch = {
|
||||
Identifier = "JWSTTrailLaunch",
|
||||
Parent = earthTransforms.EarthCenter.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 OCT 01 14:06:03",
|
||||
End = "2018 NOV 01"
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableTrailTrajectory",
|
||||
Translation = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = horizons .. "/horizons_jwst_launch.dat",
|
||||
},
|
||||
Color = { 0.9, 0.9, 0.0 },
|
||||
StartTime = "2018 OCT 01 14:06:00",
|
||||
EndTime = "2018 NOV 01",
|
||||
SampleInterval = 60
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Launch Trail",
|
||||
Path = "/Solar System/Missions/JWST/Trails",
|
||||
Description = [[
|
||||
James Webb Space Telescope Launch Trail relative to Earth based on Horizons data from the
|
||||
2018 launch.
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
-- Trail of JWST relative to L2 after first month to reach L2
|
||||
-- Gives a better trail history of the orbit around L2 than if it was relative to Earth
|
||||
local JWSTTrailOrbit = {
|
||||
Identifier = "JWSTTrailOrbit",
|
||||
Parent = transforms.L2.Identifier,
|
||||
TimeFrame = {
|
||||
Type = "TimeFrameInterval",
|
||||
Start = "2018 NOV 01 00:00:00",
|
||||
End = "2024 OCT 01"
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = horizons .. "/horizons_jwst_orbit.dat",
|
||||
},
|
||||
Color = { 0.9, 0.9, 0.0 },
|
||||
Period = 182.621099, -- About 6 months
|
||||
Resolution = 4383 -- About a sample rate of once per hour
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Orbit Trail",
|
||||
Path = "/Solar System/Missions/JWST/Trails",
|
||||
Description = [[
|
||||
James Webb Space Telescope Orbit Trail relative to L2 based on Horizons data from the
|
||||
2018 launch.
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
-- JPL Horizons doesn't have data of JWST relative to the Sun,
|
||||
-- instead a SPICE kernel with data from 2020 to 2024 is used.
|
||||
-- However, this SPICE kernel is (somehow) based on the horizons
|
||||
-- data of the 2018 launch anyway. Which mean that this kernel doesn't
|
||||
-- have any data of the launch, just the orbit.
|
||||
local JWSTSunTrail = {
|
||||
Identifier = "JWSTSunTrail",
|
||||
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableTrailOrbit",
|
||||
Translation = {
|
||||
Type = "SpiceTranslation",
|
||||
Target = "JWST",
|
||||
Observer = "SSB",
|
||||
Kernels = kernels .. "/jwst_horizons_20200101_20240101_v01.bsp"
|
||||
},
|
||||
Color = { 0.0, 0.9, 0.9 },
|
||||
Period = 365.242,
|
||||
Resolution = 1000
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Sun Trail",
|
||||
Path = "/Solar System/Missions/JWST/Trails",
|
||||
Description = [[
|
||||
James Webb Space Telescope Trail relative to the Sun based on Horizons data from the
|
||||
2018 launch.
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, {
|
||||
JWSTTrailLaunch,
|
||||
JWSTTrailOrbit,
|
||||
JWSTSunTrail
|
||||
})
|
||||
|
||||
asset.meta = {
|
||||
Name = "James Webb Space Telescope Trails",
|
||||
Version = "1.0",
|
||||
Description = [[
|
||||
Trail of James Webb Space Telescope in respect to Earth, L2 and the Sun
|
||||
]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license",
|
||||
Identifiers = {"JWSTTrailLaunch", "JWSTTrailOrbit", "JWSTSunTrail"}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local earthTransforms = asset.require('scene/solarsystem/planets/earth/transforms')
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
local horizons = asset.require('./horizons').horizons
|
||||
asset.require('spice/base')
|
||||
|
||||
local JWSTPosition = {
|
||||
Identifier = "JWSTPosition",
|
||||
Parent = earthTransforms.EarthCenter.Identifier,
|
||||
Transform = {
|
||||
Translation = {
|
||||
Type = "TimelineTranslation",
|
||||
ShouldInterpolate = false,
|
||||
Keyframes = {
|
||||
['2018 OCT 01 14:06:03'] = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = horizons .. "/horizons_jwst_launch.dat",
|
||||
},
|
||||
['2018 NOV 01 00:00:00'] = {
|
||||
Type = "HorizonsTranslation",
|
||||
HorizonsTextFile = horizons .. "/horizons_jwst_orbit.dat",
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Position",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true,
|
||||
Description = [[
|
||||
James Webb Space Telescope Position relative to Earth based on Horizons data from the
|
||||
2018 launch.
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
local JWSTRotation = {
|
||||
Identifier = "JWSTRotation",
|
||||
Parent = JWSTPosition.Identifier,
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "FixedRotation",
|
||||
Attached = "JWSTRotation",
|
||||
XAxis = { 1, 0, 0 },
|
||||
XAxisOrthogonal = true,
|
||||
YAxisInvert = true,
|
||||
YAxis = sunTransforms.SolarSystemBarycenter.Identifier
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
Name = "JWST Rotation",
|
||||
Path = "/Solar System/Missions/JWST",
|
||||
Hidden = true,
|
||||
Description = [[
|
||||
James Webb Space Telescope Rotation so the sunshield always faces the Sun.
|
||||
]],
|
||||
}
|
||||
}
|
||||
|
||||
-- Reparent the JWSTPosition node when the data changes at 01 Nov 2018
|
||||
asset.onInitialize(function()
|
||||
openspace.scriptScheduler.loadScheduledScript(
|
||||
"2018 NOV 01 00:00:00",
|
||||
"openspace.setParent('JWSTPosition', 'L2')",
|
||||
"openspace.setParent('JWSTPosition', 'EarthCenter')",
|
||||
"",
|
||||
1 -- Not default group, never clear this script
|
||||
)
|
||||
end)
|
||||
|
||||
assetHelper.registerSceneGraphNodesAndExport(asset, {
|
||||
JWSTPosition,
|
||||
JWSTRotation
|
||||
})
|
||||
|
||||
asset.meta = {
|
||||
Name = "James Webb Space Telescope Transforms",
|
||||
Version = "1.0",
|
||||
Description = [[
|
||||
JWST transforms: JWST position relative to Earth using horizons data from the planned
|
||||
launch of 2018. JWST rotation, a fixed rotation so sunshield always points toward
|
||||
the Sun.
|
||||
]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "http://openspaceproject.com",
|
||||
License = "MIT license",
|
||||
Identifiers = {"JWSTPosition", "JWSTRotation"}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ local L1 = {
|
||||
Identifier = "L1",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderablePlaneImageLocal",
|
||||
RenderableType = "Opaque",
|
||||
Billboard = true,
|
||||
@@ -35,7 +34,6 @@ local L1Label = {
|
||||
Identifier = "L1Label",
|
||||
Parent = L1.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableLabels",
|
||||
Text = "L1",
|
||||
FontSize = 20,
|
||||
|
||||
@@ -34,7 +34,6 @@ local L2 = {
|
||||
Identifier = "L2",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderablePlaneImageLocal",
|
||||
RenderableType = "Opaque",
|
||||
Billboard = true,
|
||||
@@ -61,7 +60,6 @@ local L2SmallLabel = {
|
||||
Identifier = "L2SmallLabel",
|
||||
Parent = L2.Identifier,
|
||||
Renderable = {
|
||||
Enabled = true,
|
||||
Type = "RenderableLabels",
|
||||
Text = "L2",
|
||||
FontSize = 20.0,
|
||||
@@ -83,7 +81,6 @@ local L2Label = {
|
||||
Identifier = "L2Label",
|
||||
Parent = L2.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableLabels",
|
||||
Text = "L2",
|
||||
FontSize = 20,
|
||||
|
||||
@@ -8,7 +8,6 @@ local L4 = {
|
||||
Identifier = "L4",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderablePlaneImageLocal",
|
||||
RenderableType = "Opaque",
|
||||
Billboard = true,
|
||||
@@ -35,7 +34,6 @@ local L4Label = {
|
||||
Identifier = "L4Label",
|
||||
Parent = L4.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableLabels",
|
||||
Text = "L4",
|
||||
FontSize = 20,
|
||||
|
||||
@@ -8,7 +8,6 @@ local L5 = {
|
||||
Identifier = "L5",
|
||||
Parent = transforms.SolarSystemBarycenter.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderablePlaneImageLocal",
|
||||
RenderableType = "Opaque",
|
||||
Billboard = true,
|
||||
@@ -35,7 +34,6 @@ local L5Label = {
|
||||
Identifier = "L5Label",
|
||||
Parent = L5.Identifier,
|
||||
Renderable = {
|
||||
Enabled = false,
|
||||
Type = "RenderableLabels",
|
||||
Text = "L5",
|
||||
FontSize = 20,
|
||||
|
||||
+154
-8
@@ -29,7 +29,7 @@
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.toggle.l2",
|
||||
"is_local": false,
|
||||
"name": "Toggle L2",
|
||||
"name": "Toggle L2 line and small L2 label",
|
||||
"script": "local list = openspace.getProperty('{lagrange_points_earth_l2_small}.*.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end"
|
||||
},
|
||||
{
|
||||
@@ -39,22 +39,71 @@
|
||||
"is_local": false,
|
||||
"name": "Toggle JWST field of view and view band",
|
||||
"script": "local list = openspace.getProperty('{mission_jwst_fov}.*.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end"
|
||||
},
|
||||
{
|
||||
"documentation": "Set the time to the 2018 launch time of JWST",
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.set.2018_launch",
|
||||
"is_local": false,
|
||||
"name": "Set to 2018 launch time",
|
||||
"script": "openspace.time.setTime('2018-10-01T14:06:03'); openspace.time.setDeltaTime(1)"
|
||||
},
|
||||
{
|
||||
"documentation": "Set the time to 2021 where the JWST Sun trail has valid data (2020-2024)",
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.set.2021_sun",
|
||||
"is_local": false,
|
||||
"name": "Set to 2021 Sun trail",
|
||||
"script": "openspace.time.setTime('2021-12-18T14:06:03'); openspace.time.setDeltaTime(1)"
|
||||
},
|
||||
{
|
||||
"documentation": "Toggle all planet and moon trails, except the Moon",
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.toggle.trails_not_moon",
|
||||
"is_local": false,
|
||||
"name": "Toggle trails (except Moon)",
|
||||
"script": "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled') for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end openspace.setPropertyValueSingle('Scene.MoonTrail.Renderable.Enabled', true)"
|
||||
},
|
||||
{
|
||||
"documentation": "Toggle JWST launch and orbit trails",
|
||||
"gui_path": "/JWST",
|
||||
"identifier": "profile.toggle.jwst_trails",
|
||||
"is_local": false,
|
||||
"name": "Toggle JWST trails",
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"additional_scripts": [
|
||||
"openspace.setPropertyValue(\"Scene.MoonTrail.Renderable.Appearance.Color\", {0.7, 0.5, 0.5});"
|
||||
],
|
||||
"assets": [
|
||||
"base",
|
||||
"scene/solarsystem/planets/earth/earth",
|
||||
"scene/solarsystem/planets/earth/satellites/satellites",
|
||||
"scene/solarsystem/planets/earth/lagrange_points/lagrange_points",
|
||||
"scene/solarsystem/missions/jwst/jwst",
|
||||
"scene/solarsystem/missions/jwst/HUDFImage",
|
||||
"scene/solarsystem/missions/jwst/trail",
|
||||
"scene/solarsystem/missions/jwst/hudf",
|
||||
"scene/solarsystem/missions/jwst/timelapse",
|
||||
"scene/digitaluniverse/hdf"
|
||||
],
|
||||
"camera": {
|
||||
"altitude": 17000000.0,
|
||||
"anchor": "Earth",
|
||||
"latitude": 3.5559,
|
||||
"longitude": -53.0515,
|
||||
"type": "goToGeo"
|
||||
"aim": "",
|
||||
"anchor": "JWSTModel",
|
||||
"frame": "Root",
|
||||
"yaw": -0.005731,
|
||||
"pitch": -0.001656,
|
||||
"type": "setNavigationState",
|
||||
"position": {
|
||||
"x": 30.188156,
|
||||
"y": -9.477188,
|
||||
"z": -9.203491
|
||||
},
|
||||
"up": {
|
||||
"x": 0.361587,
|
||||
"y": 0.893643,
|
||||
"z": 0.265813
|
||||
}
|
||||
},
|
||||
"delta_times": [
|
||||
1.0,
|
||||
@@ -98,6 +147,38 @@
|
||||
{
|
||||
"action": "profile.toggle.jwst_fov",
|
||||
"key": "V"
|
||||
},
|
||||
{
|
||||
"action": "profile.set.2018_launch",
|
||||
"key": "J"
|
||||
},
|
||||
{
|
||||
"action": "profile.set.2021_sun",
|
||||
"key": "K"
|
||||
},
|
||||
{
|
||||
"action": "jwst.play.forwards",
|
||||
"key": "M"
|
||||
},
|
||||
{
|
||||
"action": "jwst.play.backwards",
|
||||
"key": "N"
|
||||
},
|
||||
{
|
||||
"action": "jwst.play.clear",
|
||||
"key": "B"
|
||||
},
|
||||
{
|
||||
"action": "profile.toggle.trails_not_moon",
|
||||
"key": "G"
|
||||
},
|
||||
{
|
||||
"action": "jwst.toggle.direction",
|
||||
"key": "Y"
|
||||
},
|
||||
{
|
||||
"action": "profile.toggle.jwst_trails",
|
||||
"key": "T"
|
||||
}
|
||||
],
|
||||
"mark_nodes": [
|
||||
@@ -121,11 +202,76 @@
|
||||
"name": "{earth_satellites}.Renderable.Enabled",
|
||||
"type": "setPropertyValue",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.MoonTrail.Renderable.Appearance.Fade",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "3.0"
|
||||
},
|
||||
{
|
||||
"name": "Scene.JWSTTrailLaunch.Renderable.Appearance.EnableFade",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L1.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L1Label.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L2.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L2Label.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L4.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L4Label.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L5.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L5Label.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L2Small.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L2SmallLabel.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "Scene.L2SunLine.Renderable.Enabled",
|
||||
"type": "setPropertyValueSingle",
|
||||
"value": "false"
|
||||
}
|
||||
],
|
||||
"time": {
|
||||
"type": "absolute",
|
||||
"value": "2021-10-31T00:00:00"
|
||||
"value": "2018-10-01T14:06:03"
|
||||
},
|
||||
"version": {
|
||||
"major": 1,
|
||||
|
||||
@@ -25,10 +25,14 @@
|
||||
#ifndef __OPENSPACE_CORE___SCRIPTSCHEDULER___H__
|
||||
#define __OPENSPACE_CORE___SCRIPTSCHEDULER___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
|
||||
#include <openspace/navigation/keyframenavigator.h>
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -44,8 +48,10 @@ struct LuaLibrary;
|
||||
* Maintains an ordered list of <code>ScheduledScript</code>s and provides a simple
|
||||
* interface for retrieveing scheduled scripts
|
||||
*/
|
||||
class ScriptScheduler {
|
||||
class ScriptScheduler : public properties::PropertyOwner {
|
||||
public:
|
||||
ScriptScheduler();
|
||||
|
||||
struct ScheduledScript {
|
||||
ScheduledScript() = default;
|
||||
ScheduledScript(const ghoul::Dictionary& dict);
|
||||
@@ -54,6 +60,8 @@ public:
|
||||
std::string forwardScript;
|
||||
std::string backwardScript;
|
||||
std::string universalScript;
|
||||
|
||||
int group = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -73,8 +81,11 @@ public:
|
||||
|
||||
/**
|
||||
* Removes all scripts for the schedule.
|
||||
*
|
||||
* \param An int that specifies which group to clear.
|
||||
* If none given then all scripts is cleared from the schedule.
|
||||
*/
|
||||
void clearSchedule();
|
||||
void clearSchedule(std::optional<int> group = std::nullopt);
|
||||
|
||||
/**
|
||||
* Progresses the script schedulers time and returns all scripts that has been
|
||||
@@ -97,8 +108,17 @@ public:
|
||||
*/
|
||||
// std::queue<std::string> progressTo(const std::string& timeStr);
|
||||
|
||||
using ScriptIt = std::vector<std::string>::const_iterator;
|
||||
std::pair<ScriptIt, ScriptIt> progressTo(double newTime);
|
||||
/**
|
||||
* Progresses the script schedulers time and returns all scripts that has been
|
||||
* scheduled to run between \param newTime and the time provided in the last invocation
|
||||
* of this method.
|
||||
*
|
||||
* \param newTime A j2000 time value specifying the new time stamp that
|
||||
* the script scheduler should progress to.
|
||||
*
|
||||
* \returns vector with the scheduled scripts that should be run from begining to end.
|
||||
*/
|
||||
std::vector<std::string> progressTo(double newTime);
|
||||
|
||||
/**
|
||||
* Returns the the j2000 time value that the script scheduler is currently at
|
||||
@@ -106,9 +126,19 @@ public:
|
||||
double currentTime() const;
|
||||
|
||||
/**
|
||||
* \returns a vector of all scripts that has been loaded
|
||||
* Updates the current time to the given j2000 time value
|
||||
*/
|
||||
std::vector<ScheduledScript> allScripts() const;
|
||||
void setCurrentTime(double time);
|
||||
|
||||
/**
|
||||
* Function that returns all scripts currently loaded in the script scheduler
|
||||
*
|
||||
* \param group An int specifying which group to return, if empty all scripts
|
||||
* will be returned
|
||||
*
|
||||
* \returns a vector of all scripts that has been loaded
|
||||
*/
|
||||
std::vector<ScheduledScript> allScripts(std::optional<int> group = std::nullopt) const;
|
||||
|
||||
/**
|
||||
* Sets the mode for how each scheduled script's timestamp will be interpreted.
|
||||
@@ -137,9 +167,9 @@ public:
|
||||
static documentation::Documentation Documentation();
|
||||
|
||||
private:
|
||||
std::vector<double> _timings;
|
||||
std::vector<std::string> _forwardScripts;
|
||||
std::vector<std::string> _backwardScripts;
|
||||
properties::BoolProperty _enabled;
|
||||
properties::BoolProperty _shouldRunAllTimeJump;
|
||||
std::vector<ScheduledScript> _scripts;
|
||||
|
||||
int _currentIndex = 0;
|
||||
double _currentTime = 0;
|
||||
|
||||
@@ -28,13 +28,24 @@
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo ShouldInterpolateInfo = {
|
||||
"ShouldInterpolate",
|
||||
"Should Interpolate",
|
||||
"If this value is set to 'true', an interpolation is applied between the given keyframes. "
|
||||
"If this value is set to 'false', the interpolation is not applied."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(TimelineTranslation)]] Parameters {
|
||||
// A table of keyframes, with keys formatted as YYYY-MM-DDTHH:MM:SS and values
|
||||
// that are valid Translation objects
|
||||
std::map<std::string, ghoul::Dictionary> keyframes
|
||||
[[codegen::reference("core_transform_translation")]];
|
||||
|
||||
// [[codegen::verbatim(ShouldInterpolateInfo.description)]]
|
||||
std::optional<bool> shouldInterpolate;
|
||||
};
|
||||
#include "timelinetranslation_codegen.cpp"
|
||||
} // namespace
|
||||
@@ -45,7 +56,9 @@ documentation::Documentation TimelineTranslation::Documentation() {
|
||||
return codegen::doc<Parameters>("base_transform_translation_keyframe");
|
||||
}
|
||||
|
||||
TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) {
|
||||
TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary)
|
||||
: _shouldInterpolate(ShouldInterpolateInfo, true)
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
for (const std::pair<const std::string, ghoul::Dictionary>& kf : p.keyframes) {
|
||||
@@ -57,6 +70,9 @@ TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) {
|
||||
_timeline.addKeyframe(t, std::move(translation));
|
||||
}
|
||||
}
|
||||
|
||||
_shouldInterpolate = p.shouldInterpolate.value_or(_shouldInterpolate);
|
||||
addProperty(_shouldInterpolate);
|
||||
}
|
||||
|
||||
glm::dvec3 TimelineTranslation::position(const UpdateData& data) const {
|
||||
@@ -78,11 +94,22 @@ glm::dvec3 TimelineTranslation::position(const UpdateData& data) const {
|
||||
const double prevTime = prev->timestamp;
|
||||
const double nextTime = next->timestamp;
|
||||
|
||||
double t = 0.0;
|
||||
if (nextTime - prevTime > 0.0) {
|
||||
t = (now - prevTime) / (nextTime - prevTime);
|
||||
if (_shouldInterpolate) {
|
||||
double t = 0.0;
|
||||
if (nextTime - prevTime > 0.0) {
|
||||
t = (now - prevTime) / (nextTime - prevTime);
|
||||
}
|
||||
return t * next->data->position(data) + (1.0 - t) * prev->data->position(data);
|
||||
}
|
||||
return t * next->data->position(data) + (1.0 - t) * prev->data->position(data);
|
||||
else {
|
||||
if (prevTime <= now && now < nextTime) {
|
||||
return prev->data->position(data);
|
||||
}
|
||||
else if (nextTime <= now) {
|
||||
return next->data->position(data);
|
||||
}
|
||||
}
|
||||
return glm::dvec3(0.0);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
|
||||
#define __OPENSPACE_MODULE_BASE___TIMELINETRANSLATION___H__
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/scene/translation.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
#include <ghoul/misc/managedmemoryuniqueptr.h>
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
|
||||
private:
|
||||
Timeline<ghoul::mm_unique_ptr<Translation>> _timeline;
|
||||
properties::BoolProperty _shouldInterpolate;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -391,6 +391,7 @@ void initialize() {
|
||||
rootPropertyOwner->addPropertySubOwner(global::interactionMonitor);
|
||||
rootPropertyOwner->addPropertySubOwner(global::sessionRecording);
|
||||
rootPropertyOwner->addPropertySubOwner(global::timeManager);
|
||||
rootPropertyOwner->addPropertySubOwner(global::scriptScheduler);
|
||||
|
||||
rootPropertyOwner->addPropertySubOwner(global::renderEngine);
|
||||
rootPropertyOwner->addPropertySubOwner(global::screenSpaceRootPropertyOwner);
|
||||
|
||||
@@ -1147,13 +1147,12 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
|
||||
global::timeManager->preSynchronization(dt);
|
||||
|
||||
using Iter = std::vector<std::string>::const_iterator;
|
||||
std::pair<Iter, Iter> scheduledScripts = global::scriptScheduler->progressTo(
|
||||
std::vector<std::string> scheduledScripts = global::scriptScheduler->progressTo(
|
||||
global::timeManager->time().j2000Seconds()
|
||||
);
|
||||
for (Iter it = scheduledScripts.first; it != scheduledScripts.second; ++it) {
|
||||
for (const std::string& script : scheduledScripts) {
|
||||
global::scriptEngine->queueScript(
|
||||
*it,
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
|
||||
@@ -921,6 +921,14 @@ scripting::LuaLibrary Scene::luaLibrary() {
|
||||
"string",
|
||||
"Returns the world rotation matrix of the scene graph node with the "
|
||||
"given string as identifier"
|
||||
},
|
||||
{
|
||||
"setParent",
|
||||
&luascriptfunctions::setParent,
|
||||
{},
|
||||
"string, string",
|
||||
"The scene graph node identified by the first string is reparented to be "
|
||||
"a child of the scene graph node identified by the second string."
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -901,6 +901,31 @@ int worldRotation(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setParent(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::setParent");
|
||||
auto [identifier, newParent] = ghoul::lua::values<std::string, std::string>(L);
|
||||
|
||||
SceneGraphNode* node = sceneGraphNode(identifier);
|
||||
if (!node) {
|
||||
return ghoul::lua::luaError(
|
||||
L,
|
||||
fmt::format("Did not find a match for identifier: {} ", identifier)
|
||||
);
|
||||
}
|
||||
SceneGraphNode* newParentNode = sceneGraphNode(newParent);
|
||||
if (!newParentNode) {
|
||||
return ghoul::lua::luaError(
|
||||
L,
|
||||
fmt::format("Did not find a match for new parent identifier: {} ", newParent)
|
||||
);
|
||||
}
|
||||
|
||||
node->setParent(*newParentNode);
|
||||
global::renderEngine->scene()->markNodeRegistryDirty();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup LuaScripts
|
||||
* isBoolValue(const std::string& s):
|
||||
|
||||
@@ -33,6 +33,22 @@
|
||||
#include "scriptscheduler_lua.inl"
|
||||
|
||||
namespace {
|
||||
constexpr openspace::properties::Property::PropertyInfo EnabledInfo = {
|
||||
"EnabledInfo",
|
||||
"Enabled",
|
||||
"This enables or disables the ScriptScheduler. If disabled, no scheduled scripts "
|
||||
"will be executed. If enabled, scheduled scripts will be executed at their given "
|
||||
"time as normal."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ShouldRunAllTimeJumpInfo = {
|
||||
"ShouldRunAllTimeJumpInfo",
|
||||
"Should Run All Time Jump",
|
||||
"If 'true': In a time jump, all scheduled scripts between the old time and the "
|
||||
"new time is executed. If 'false': In a time jump, no scripts scheduled between "
|
||||
"the new time and the old time is executed."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(ScheduledScript)]] Parameters {
|
||||
// The time at which, when the in game time passes it, the two scripts will
|
||||
// be executed. If the traversal is forwards (towards + infinity), the
|
||||
@@ -52,6 +68,9 @@ namespace {
|
||||
// The Lua script that is executed when OpenSpace passes the time in a
|
||||
// backward direction
|
||||
std::optional<std::string> backwardScript;
|
||||
|
||||
// The group that this script belongs to, default group is 0
|
||||
std::optional<int> group;
|
||||
};
|
||||
#include "scriptscheduler_codegen.cpp"
|
||||
} // namespace
|
||||
@@ -65,6 +84,15 @@ documentation::Documentation ScriptScheduler::Documentation() {
|
||||
return codegen::doc<Parameters>("core_scheduledscript");
|
||||
}
|
||||
|
||||
ScriptScheduler::ScriptScheduler()
|
||||
: properties::PropertyOwner({ "ScriptScheduler" })
|
||||
, _enabled(EnabledInfo, true)
|
||||
, _shouldRunAllTimeJump(ShouldRunAllTimeJumpInfo, true)
|
||||
{
|
||||
addProperty(_enabled);
|
||||
addProperty(_shouldRunAllTimeJump);
|
||||
}
|
||||
|
||||
ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict) {
|
||||
const Parameters p = codegen::bake<Parameters>(dict);
|
||||
|
||||
@@ -72,6 +100,7 @@ ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict)
|
||||
forwardScript = p.forwardScript.value_or(forwardScript);
|
||||
backwardScript = p.backwardScript.value_or(backwardScript);
|
||||
universalScript = p.script.value_or(universalScript);
|
||||
group = p.group.value_or(group);
|
||||
}
|
||||
|
||||
void ScriptScheduler::loadScripts(std::vector<ScheduledScript> scheduledScripts) {
|
||||
@@ -85,36 +114,23 @@ void ScriptScheduler::loadScripts(std::vector<ScheduledScript> scheduledScripts)
|
||||
}
|
||||
);
|
||||
|
||||
// Move the scheduled scripts into their SOA alignment
|
||||
// For the forward scripts, this is the forwards direction
|
||||
// For the backward scripts, we insert them in the opposite order so that we can still
|
||||
// return forward iterators to them in the progressTo method
|
||||
for (ScheduledScript& script : scheduledScripts) {
|
||||
_timings.push_back(script.time);
|
||||
|
||||
std::string forward =
|
||||
script.universalScript.empty() ?
|
||||
std::move(script.forwardScript) :
|
||||
std::move(script.universalScript) + ';' + std::move(script.forwardScript);
|
||||
_forwardScripts.push_back(forward);
|
||||
|
||||
std::string backward =
|
||||
script.universalScript.empty() ?
|
||||
std::move(script.backwardScript) :
|
||||
std::move(script.universalScript) + ';' + std::move(script.backwardScript);
|
||||
_backwardScripts.insert(_backwardScripts.begin(), backward);
|
||||
_scripts.push_back(script);
|
||||
}
|
||||
|
||||
// Re-sort so it is always in sorted order in regards to time
|
||||
std::stable_sort(
|
||||
_scripts.begin(),
|
||||
_scripts.end(),
|
||||
[](const ScheduledScript& lhs, const ScheduledScript& rhs) {
|
||||
return lhs.time < rhs.time;
|
||||
}
|
||||
);
|
||||
|
||||
// Ensure _currentIndex and _currentTime is accurate after new scripts was added
|
||||
const double lastTime = _currentTime;
|
||||
rewind();
|
||||
progressTo(lastTime);
|
||||
|
||||
ghoul_assert(
|
||||
(_timings.size() == _forwardScripts.size()) &&
|
||||
(_timings.size() == _backwardScripts.size()),
|
||||
"The SOA data structure has been mistreated and has different number of values"
|
||||
);
|
||||
}
|
||||
|
||||
void ScriptScheduler::rewind() {
|
||||
@@ -122,18 +138,34 @@ void ScriptScheduler::rewind() {
|
||||
_currentTime = -std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
void ScriptScheduler::clearSchedule() {
|
||||
rewind();
|
||||
_timings.clear();
|
||||
_forwardScripts.clear();
|
||||
_backwardScripts.clear();
|
||||
void ScriptScheduler::clearSchedule(std::optional<int> group) {
|
||||
if (group.has_value()) {
|
||||
for (auto it = _scripts.begin(); it < _scripts.end(); ) {
|
||||
if (it->group == *group) {
|
||||
it = _scripts.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure _currentIndex and _currentTime is accurate after scripts was removed
|
||||
const double lastTime = _currentTime;
|
||||
rewind();
|
||||
progressTo(lastTime);
|
||||
}
|
||||
else {
|
||||
rewind();
|
||||
_scripts.clear();
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<ScriptScheduler::ScriptIt, ScriptScheduler::ScriptIt>
|
||||
ScriptScheduler::progressTo(double newTime)
|
||||
{
|
||||
if (newTime == _currentTime) {
|
||||
return { _forwardScripts.end(), _forwardScripts.end() };
|
||||
std::vector<std::string> ScriptScheduler::progressTo(double newTime) {
|
||||
std::vector<std::string> result;
|
||||
if (!_enabled || newTime == _currentTime || _scripts.empty()) {
|
||||
// Update the new time
|
||||
_currentTime = newTime;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (newTime > _currentTime) {
|
||||
@@ -141,44 +173,65 @@ ScriptScheduler::progressTo(double newTime)
|
||||
// vector that is still smaller than the newTime
|
||||
size_t prevIndex = _currentIndex;
|
||||
const auto it = std::upper_bound(
|
||||
_timings.begin() + prevIndex, // We only need to start at the previous time
|
||||
_timings.end(),
|
||||
newTime
|
||||
_scripts.begin() + prevIndex, // We only need to start at the previous time
|
||||
_scripts.end(),
|
||||
newTime,
|
||||
[](const double value, const ScheduledScript& item) {
|
||||
return value < item.time;
|
||||
}
|
||||
);
|
||||
|
||||
// How many values did we pass over?
|
||||
const ptrdiff_t n = std::distance(_timings.begin() + prevIndex, it);
|
||||
const ptrdiff_t n = std::distance(_scripts.begin() + prevIndex, it);
|
||||
_currentIndex = static_cast<int>(prevIndex + n);
|
||||
|
||||
// Update the new time
|
||||
_currentTime = newTime;
|
||||
|
||||
return {
|
||||
_forwardScripts.begin() + prevIndex,
|
||||
_forwardScripts.begin() + _currentIndex
|
||||
};
|
||||
// Construct result
|
||||
for (auto iter = _scripts.begin() + prevIndex;
|
||||
iter < (_scripts.begin() + _currentIndex);
|
||||
++iter)
|
||||
{
|
||||
std::string script = iter->universalScript.empty() ?
|
||||
iter->forwardScript :
|
||||
iter->universalScript + "; " + iter->forwardScript;
|
||||
result.push_back(script);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
// Moving backward in time; the need to find the lowest entry that is still bigger
|
||||
// than the newTime
|
||||
const size_t prevIndex = _currentIndex;
|
||||
const auto it = std::lower_bound(
|
||||
_timings.begin(),
|
||||
_timings.begin() + prevIndex, // We can stop at the previous time
|
||||
newTime
|
||||
_scripts.begin(),
|
||||
_scripts.begin() + prevIndex, // We can stop at the previous time
|
||||
newTime,
|
||||
[](const ScheduledScript& item, const double value) {
|
||||
return item.time < value;
|
||||
}
|
||||
);
|
||||
|
||||
// How many values did we pass over?
|
||||
const ptrdiff_t n = std::distance(it, _timings.begin() + prevIndex);
|
||||
const ptrdiff_t n = std::distance(it, _scripts.begin() + prevIndex);
|
||||
_currentIndex = static_cast<int>(prevIndex - n);
|
||||
|
||||
// Update the new time
|
||||
_currentTime = newTime;
|
||||
|
||||
return {
|
||||
_backwardScripts.begin() + (_timings.size() - prevIndex),
|
||||
_backwardScripts.begin() + (_timings.size() - _currentIndex)
|
||||
};
|
||||
// Construct result
|
||||
auto start = _scripts.begin() + prevIndex - 1;
|
||||
auto end = it;
|
||||
for (auto iter = start; iter != _scripts.end() && iter >= end; --iter) {
|
||||
std::string script = iter->universalScript.empty() ?
|
||||
iter->backwardScript :
|
||||
iter->universalScript + "; " + iter->backwardScript;
|
||||
result.push_back(script);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,15 +251,29 @@ double ScriptScheduler::currentTime() const {
|
||||
return _currentTime;
|
||||
}
|
||||
|
||||
std::vector<ScriptScheduler::ScheduledScript> ScriptScheduler::allScripts() const {
|
||||
std::vector<ScheduledScript> result;
|
||||
for (size_t i = 0; i < _timings.size(); ++i) {
|
||||
ScheduledScript script;
|
||||
script.time = _timings[i];
|
||||
script.forwardScript = _forwardScripts[i];
|
||||
script.backwardScript = _backwardScripts[i];
|
||||
void ScriptScheduler::setCurrentTime(double time) {
|
||||
// Ensure _currentIndex and _currentTime is accurate after time jump
|
||||
std::vector<std::string> scheduledScripts = progressTo(time);
|
||||
|
||||
result.push_back(std::move(script));
|
||||
if (_shouldRunAllTimeJump) {
|
||||
// Queue all scripts for the time jump
|
||||
for (const std::string& script : scheduledScripts) {
|
||||
global::scriptEngine->queueScript(
|
||||
script,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ScriptScheduler::ScheduledScript> ScriptScheduler::allScripts(
|
||||
std::optional<int> group) const
|
||||
{
|
||||
std::vector<ScheduledScript> result;
|
||||
for (const ScheduledScript& script : _scripts) {
|
||||
if (!group.has_value() || script.group == *group) {
|
||||
result.push_back(script);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -56,16 +56,22 @@ int loadFile(lua_State* L) {
|
||||
}
|
||||
|
||||
int loadScheduledScript(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, { 2, 4 }, "lua::loadScheduledScript");
|
||||
auto [time, forwardScript, backwardScript, universalScript] = ghoul::lua::values<
|
||||
std::string, std::string, std::optional<std::string>, std::optional<std::string>
|
||||
>(L);
|
||||
ghoul::lua::checkArgumentsAndThrow(L, { 2, 5 }, "lua::loadScheduledScript");
|
||||
auto [time, forwardScript, backwardScript, universalScript, group] =
|
||||
ghoul::lua::values<
|
||||
std::string,
|
||||
std::string,
|
||||
std::optional<std::string>,
|
||||
std::optional<std::string>,
|
||||
std::optional<int>
|
||||
>(L);
|
||||
|
||||
scripting::ScriptScheduler::ScheduledScript script;
|
||||
script.time = Time::convertTime(time);
|
||||
script.forwardScript = std::move(forwardScript);
|
||||
script.backwardScript = backwardScript.value_or(script.backwardScript);
|
||||
script.universalScript = universalScript.value_or(script.universalScript);
|
||||
script.group = group.value_or(script.group);
|
||||
|
||||
std::vector<scripting::ScriptScheduler::ScheduledScript> scripts;
|
||||
scripts.push_back(std::move(script));
|
||||
@@ -92,8 +98,10 @@ int setModeSimulationTime(lua_State* L) {
|
||||
}
|
||||
|
||||
int clear(lua_State* L) {
|
||||
ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clear");
|
||||
global::scriptScheduler->clearSchedule();
|
||||
ghoul::lua::checkArgumentsAndThrow(L, { 0, 1 }, "lua::clear");
|
||||
std::optional<int> group = ghoul::lua::value<std::optional<int>>(L);
|
||||
|
||||
global::scriptScheduler->clearSchedule(group);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openspace/interaction/keybindingmanager.h>
|
||||
#include <openspace/interaction/sessionrecording.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/scripting/scriptscheduler.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -405,6 +406,7 @@ void TimeManager::setTimeNextFrame(Time t) {
|
||||
_shouldSetTime = true;
|
||||
_timeNextFrame = std::move(t);
|
||||
clearKeyframes();
|
||||
global::scriptScheduler->setCurrentTime(t.j2000Seconds());
|
||||
}
|
||||
|
||||
void TimeManager::setDeltaTime(double deltaTime) {
|
||||
|
||||
+112
-112
@@ -38,7 +38,7 @@ TEST_CASE("ScriptScheduler: Simple Forward", "[scriptscheduler]") {
|
||||
);
|
||||
|
||||
using namespace openspace::scripting;
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
|
||||
std::vector<ScriptScheduler::ScheduledScript> scripts;
|
||||
@@ -49,16 +49,16 @@ TEST_CASE("ScriptScheduler: Simple Forward", "[scriptscheduler]") {
|
||||
script.backwardScript = "BackwardScript1";
|
||||
scripts.push_back(script);
|
||||
}
|
||||
|
||||
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(res.first == res.second);
|
||||
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -91,15 +91,15 @@ TEST_CASE("ScriptScheduler: Multiple Forward Single Jump", "[scriptscheduler]")
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(res.first == res.second);
|
||||
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript2");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -127,18 +127,18 @@ TEST_CASE("ScriptScheduler: Multiple Forward Ordering", "[scriptscheduler]") {
|
||||
script2.backwardScript = "BackwardScript2";
|
||||
scripts.push_back(script2);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(*(std::next(res.first)) == "ForwardScript2");
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
REQUIRE(res[1] == "ForwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -160,17 +160,17 @@ TEST_CASE("ScriptScheduler: Simple Backward", "[scriptscheduler]") {
|
||||
script1.backwardScript = "BackwardScript1";
|
||||
scripts.push_back(script1);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 05"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -198,21 +198,21 @@ TEST_CASE("ScriptScheduler: Multiple Backward Single Jump", "[scriptscheduler]")
|
||||
script2.backwardScript = "BackwardScript2";
|
||||
scripts.push_back(script2);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(res.first == res.second);
|
||||
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -240,18 +240,18 @@ TEST_CASE("ScriptScheduler: Multiple Backward Ordering", "[scriptscheduler]") {
|
||||
script2.backwardScript = "BackwardScript2";
|
||||
scripts.push_back(script2);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
REQUIRE(*(std::next(res.first)) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
REQUIRE(res[1] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -263,24 +263,24 @@ TEST_CASE("ScriptScheduler: Empty", "[scriptscheduler]") {
|
||||
);
|
||||
|
||||
using namespace openspace::scripting;
|
||||
|
||||
|
||||
static const std::vector<double> TestTimes = {
|
||||
0.0, 1.0, -1.0, std::numeric_limits<double>::min(),
|
||||
-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()
|
||||
};
|
||||
|
||||
|
||||
// First test if a new ScriptScheduler will return an empty list
|
||||
for (double t : TestTimes) {
|
||||
ScriptScheduler scheduler;
|
||||
auto res = scheduler.progressTo(t);
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
}
|
||||
|
||||
|
||||
// Then test the same thing but keeping the same ScriptScheduler
|
||||
ScriptScheduler scheduler;
|
||||
for (double t : TestTimes) {
|
||||
auto res = scheduler.progressTo(t);
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
}
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
@@ -294,7 +294,7 @@ TEST_CASE("ScriptScheduler: Forward Backwards", "[scriptscheduler]") {
|
||||
|
||||
using namespace openspace::scripting;
|
||||
using namespace std::string_literals;
|
||||
|
||||
|
||||
std::vector<ScriptScheduler::ScheduledScript> scripts;
|
||||
{
|
||||
ScriptScheduler::ScheduledScript script1;
|
||||
@@ -309,25 +309,25 @@ TEST_CASE("ScriptScheduler: Forward Backwards", "[scriptscheduler]") {
|
||||
script2.backwardScript = "BackwardScript2";
|
||||
scripts.push_back(script2);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
|
||||
REQUIRE(res.size() == 2);
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -355,19 +355,19 @@ TEST_CASE("ScriptScheduler: Rewind", "[scriptscheduler]") {
|
||||
script2.backwardScript = "BackwardScript2";
|
||||
scripts.push_back(script2);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
|
||||
REQUIRE(res.size() == 2);
|
||||
|
||||
scheduler.rewind();
|
||||
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -379,12 +379,12 @@ TEST_CASE("ScriptScheduler: CurrentTime", "[scriptscheduler]") {
|
||||
);
|
||||
|
||||
using namespace openspace::scripting;
|
||||
|
||||
|
||||
static const std::vector<double> TestValues = {
|
||||
0.0, 1.0, 42.0, std::numeric_limits<double>::min(),
|
||||
-std::numeric_limits<double>::max(), std::numeric_limits<double>::max()
|
||||
};
|
||||
|
||||
|
||||
for (double t : TestValues) {
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.progressTo(t);
|
||||
@@ -402,7 +402,7 @@ TEST_CASE("ScriptScheduler: All Scripts", "[scriptscheduler]") {
|
||||
|
||||
using namespace openspace::scripting;
|
||||
using namespace std::string_literals;
|
||||
|
||||
|
||||
std::vector<ScriptScheduler::ScheduledScript> scripts;
|
||||
{
|
||||
ScriptScheduler::ScheduledScript script1;
|
||||
@@ -423,7 +423,7 @@ TEST_CASE("ScriptScheduler: All Scripts", "[scriptscheduler]") {
|
||||
script3.backwardScript = "BackwardScript3";
|
||||
scripts.push_back(script3);
|
||||
}
|
||||
|
||||
|
||||
ScriptScheduler scheduler;
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
@@ -458,18 +458,18 @@ TEST_CASE("ScriptScheduler: Jump Equal", "[scriptscheduler]") {
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 11:00:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:00:00"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:01:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:00:00"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -496,11 +496,11 @@ TEST_CASE("ScriptScheduler: Same Time", "[scriptscheduler]") {
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:00:00"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:00:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -527,17 +527,17 @@ TEST_CASE("ScriptScheduler: Multi Inner Jump", "[scriptscheduler]") {
|
||||
scheduler.loadScripts(scripts);
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 10:00:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 11:00:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 13:00:00"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 03 12:30:00"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -571,15 +571,15 @@ TEST_CASE(
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript2");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -610,12 +610,12 @@ TEST_CASE("ScriptScheduler: Multiple Forward Ordering Multiple Load" "[scriptsch
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 02"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(*(std::next(res.first)) == "ForwardScript2");
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
REQUIRE(res[1] == "ForwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -648,15 +648,15 @@ TEST_CASE(
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -689,14 +689,14 @@ TEST_CASE(
|
||||
scheduler.loadScripts({ script1 });
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
std::pair<ScriptScheduler::ScriptIt, ScriptScheduler::ScriptIt> res =
|
||||
std::vector<std::string> res =
|
||||
scheduler.progressTo(openspace::Time::convertTime("2000 JAN 06"));
|
||||
REQUIRE(res.first == res.second);
|
||||
REQUIRE(res.empty());
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
REQUIRE(*(std::next(res.first)) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 2);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
REQUIRE(res[1] == "BackwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -726,19 +726,19 @@ TEST_CASE("ScriptScheduler: Forward Backwards Multiple Load", "[scriptscheduler]
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 01"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript1");
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(res.size() == 2);
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "BackwardScript2");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "BackwardScript2");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
@@ -768,13 +768,13 @@ TEST_CASE("ScriptScheduler: Rewind Multiple Load", "[scriptscheduler]") {
|
||||
scheduler.loadScripts({ script2 });
|
||||
|
||||
auto res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 07"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 2);
|
||||
REQUIRE(res.size() == 2);
|
||||
|
||||
scheduler.rewind();
|
||||
|
||||
res = scheduler.progressTo(openspace::Time::convertTime("2000 JAN 04"));
|
||||
REQUIRE(std::distance(res.first, res.second) == 1);
|
||||
REQUIRE(*(res.first) == "ForwardScript1");
|
||||
REQUIRE(res.size() == 1);
|
||||
REQUIRE(res[0] == "ForwardScript1");
|
||||
|
||||
openspace::SpiceManager::deinitialize();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user