mars2020 first commit

This commit is contained in:
Micah Acinapura
2020-06-05 04:13:01 -04:00
parent d2fbfdbf22
commit 0049a2db38
8 changed files with 2147 additions and 0 deletions
+65
View File
@@ -0,0 +1,65 @@
asset.require('./base')
local sceneHelper = asset.require('util/scene_helper')
local perseveranceAsset = asset.require('scene/solarsystem/missions/perseverance/perseverance')
local perseveranceShortcuts = asset.require('scene/solarsystem/missions/perseverance/shortcuts')
local insightAsset = asset.require('scene/solarsystem/missions/insight/edl')
local insightShortcuts = asset.require('scene/solarsystem/missions/insight/shortcuts')
local insightEDLShortcuts = sceneHelper.extractShortcuts({"Insight Height Offset",
"Enable HiRISE",
"Insight EDL Time",
"Insight EDL NavigationState"},
insightShortcuts.Shortcuts)
local insightDisableShortcuts = sceneHelper.extractShortcuts({
"Default Height Offset",
"Disable HiRISE"},
insightShortcuts.Shortcuts)
local PerseverenceLandedShortcuts = sceneHelper.extractShortcuts({
"Perseverance Height Offset",
"Perseverance landed time",
-- "Show Perseverance Trail",
"Enable HiRISE"},
perseveranceShortcuts.Shortcuts)
local Keybindings = {
sceneHelper.createKeyBindFromShortcuts("i",
insightEDLShortcuts,
"/Missions/Insight",
"Set and goto Insight Landing",
"Setup scene for insight EDL"
),
sceneHelper.createKeyBindFromShortcuts("SHIFT+i",
insightDisableShortcuts,
"/Missions/Insight",
"Unset Insight Landing",
"Disable Mars layer settings used for insight EDL"
),
sceneHelper.createKeyBindFromShortcuts("p",
PerseverenceLandedShortcuts,
"/Missions/Perseverance"
)
}
asset.onInitialize(function ()
local now = openspace.time.currentWallTime()
openspace.time.setTime(now)
sceneHelper.bindKeys(Keybindings)
openspace.globebrowsing.goToGeo("Mars", 58.5877, 16.1924, 8000000)
openspace.markInterestingNodes({ "Mars", insightAsset.Insight.Identifier })
end)
asset.onDeinitialize(function ()
sceneHelper.unbindKeys(Keybindings)
openspace.removeInterestingNodes({ "Mars", insightAsset.Insight.Identifier})
end)
@@ -0,0 +1,62 @@
--insight/shortcuts.asset
local InsightEntryTime = "2018 NOV 26 19:39:03.68"
local insightNavigationSate = "{" ..
"Anchor = 'Insight'," ..
"Pitch = 0.567457E-4," ..
"Position = { 1.240506E1,-1.369270E1,-2.423553E0 }," ..
"ReferenceFrame = 'Root',"..
"Up = { 0.441211E0,0.247019E0,0.862737E0 }," ..
"Yaw = -0.446853E-4}"
local Shortcuts = {
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -469.300000);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', -470.800006);",
Documentation = "Enable Insight landing height layer offset",
Name = "Insight Height Offset",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', 0);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', 0);",
Documentation = "Disable Insight landing height layer offset",
Name = "Default Height Offset",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', true);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', true);",
Documentation = "Enables HiRISE layer for insight landing",
Name = "Enable HiRISE",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', false);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', false);",
Documentation = "Disables HiRISE layer used for insight landing",
Name = "Disable HiRISE",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.navigation.setNavigationState(" .. insightNavigationSate .. ");",
Documentation = "Change the camera state for the start of Insight EDL",
Name = "Insight EDL NavigationState",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.time.setPause(true);openspace.time.setTime('" .. InsightEntryTime .. "');",
Documentation = "Change the time for the start of Insight EDL",
Name = "Insight EDL Time",
GuiPath = "/Missions/Insight",
Local = false
},
}
asset.export("Shortcuts", Shortcuts)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,5 @@
--perseverance.asset
asset.require('./model')
asset.require('./trail')
@@ -0,0 +1,70 @@
--perseverance/shortcuts.asset
local PerseveranceLaunchTime = "2020 JUL 17 13:56:42"
local PerseveranceLandingTime = "2021 FEB 18 20:32:16"
local PerseveranceNavigationSate = "{" ..
"Anchor = 'Insight'," ..
"Pitch = 0.567457E-4," ..
"Position = { 1.240506E1,-1.369270E1,-2.423553E0 }," ..
"ReferenceFrame = 'Root',"..
"Up = { 0.441211E0,0.247019E0,0.862737E0 }," ..
"Yaw = -0.446853E-4}"
local Shortcuts = {
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -469.300000);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', -470.800006);",
Documentation = "Enable height layer offset for Perseverance landing trail",
Name = "Perseverance Height Offset",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', 0);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Settings.Offset', 0);",
Documentation = "Disable Perseverance landing height layer offset",
Name = "Default Height Offset",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', true);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', true);",
Documentation = "Enables HiRISE layer for Perseverance",
Name = "Enable HiRISE",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISELS.Enabled', false);" ..
"openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISELS.Enabled', false);",
Documentation = "Disables HiRISE layer used for Perseverance",
Name = "Disable HiRISE",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.navigation.setNavigationState(" .. PerseveranceNavigationSate .. ");",
Documentation = "Change the camera state for the start of Insight EDL",
Name = "Insight EDL NavigationState",
GuiPath = "/Missions/Insight",
Local = false
},
{
Command = "openspace.time.setPause(true);openspace.time.setTime('" .. PerseveranceLaunchTime .. "');",
Documentation = "Change the time for Perseverance launch",
Name = "Perseverance launch time",
GuiPath = "/Missions/Perseverance",
Local = false
},
{
Command = "openspace.time.setPause(true);openspace.time.setTime('" .. PerseveranceLandingTime .. "');",
Documentation = "Change the time for when Perseverance has landed",
Name = "Perseverance landed time",
GuiPath = "/Missions/Perseverance",
Local = false
},
}
asset.export("Shortcuts", Shortcuts)
@@ -0,0 +1,94 @@
--trail.asset
local assetHelper = asset.require('util/asset_helper')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local marsTransforms = asset.require('scene/solarsystem/planets/mars/transforms')
local kernels = asset.syncedResource({
Name = "Mars 2020 Kernels",
Type = "HttpSynchronization",
Identifier = "perseverance_kernels",
Version = 1
})
local m2020_kernels = {
kernels .. "/m2020.tf",
kernels .. "/m2020.tls",
kernels .. "/naif0012.tls",
kernels .. "/m2020.tsc",
kernels .. "/m2020_FMAresponse_JEZ_20200717_P000.cruise.bsp",
kernels .. "/m2020_FMAresponse_JEZ_20200717_P000.edl.bsp",
}
local startTime = "2020 JUL 17 13:56:42"
local approachMars = "2021 FEB 11 20:32:16"
local endTime = "2021 FEB 18 20:32:16"
local PerseveranceNode = {
Identifier = "PerseveranceNode",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Transform = {
Translation = {
Type = "SpiceTranslation",
Target = "-168",
Observer = "SUN",
Kernels = m2020_kernels
},
},
GUI = {
Name = "Perseverance Node",
Path = "/Solar System/Missions/Perseverance",
}
}
local PerseveranceTrailSun = {
Identifier = "PerseveranceTrailSun",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Renderable = {
Type = "RenderableTrailTrajectory",
Translation = {
Type = "SpiceTranslation",
Target = "-168",
Observer = "SUN",
Kernels = m2020_kernels
},
Color = { 0.2, 0.7, 0.1 },
StartTime = startTime,
EndTime = endTime,
SampleInterval = 100
},
GUI = {
Name = "Perseverance Trail",
Path = "/Solar System/Missions/Perseverance",
}
}
local PerseveranceTrailMars = {
Identifier = "PerseveranceTrailMars",
Parent = marsTransforms.MarsBarycenter.Identifier,
Renderable = {
Type = "RenderableTrailTrajectory",
Translation = {
Type = "SpiceTranslation",
Target = "-168",
Observer = "MARS",
Kernels = m2020_kernels
},
Color = { 0.7, 0.9, 0.6 },
StartTime = approachMars,
EndTime = endTime,
SampleInterval = 100
},
GUI = {
Name = "Perseverance Trail (Mars)",
Path = "/Solar System/Missions/Perseverance",
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
PerseveranceNode,
PerseveranceTrailSun,
PerseveranceTrailMars
})
@@ -0,0 +1,528 @@
local assetHelper = asset.require('util/asset_helper')
local marsTransforms = asset.require('scene/solarsystem/planets/mars/transforms')
local marsAsset = asset.require('scene/solarsystem/planets/mars/mars')
local m2020_pos = {
Identifier = "m2020_pos",
Parent = marsAsset.Mars.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = "Mars",
Latitude = 18.3628,
Longitude = 77.5945,
UseHeightmap = true
},
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true,
}
}
local MSL_Body = {
Identifier = "MSL_Body",
Parent = m2020_pos.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0, 0.0, 2.8 }
},
Rotation = {
Type = "StaticRotation",
Rotation = { -1.884960,0.000000,2.905970 }
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
---- ROBOTIC ARM RA ----
local RA_Base_Location = {
Identifier = "RA_Base_Location",
Parent = MSL_Body.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 1.111, -0.4525, -0.106 }
},
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
--AZ
local RA_Shoulder_AZ_Location = {
Identifier = "RA_Shoulder_AZ_Location",
Parent = RA_Base_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.0, -0.08}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
----EL
local RA_Shoulder_EL_Location = {
Identifier = "RA_Shoulder_EL_Location",
Parent = RA_Shoulder_AZ_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.17, 0.2, -0.005}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
--ELBOW
local RA_Elbow_Location = {
Identifier = "RA_Elbow_Location",
Parent = RA_Shoulder_EL_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.83, -0.2, 0.0 }
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
--WRIST
local RA_Wrist_Location = {
Identifier = "RA_Wrist_Location",
Parent = RA_Elbow_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.77, 0.13, 0.035}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
--TURRET
local RA_Turret_Location = {
Identifier = "RA_Turret_Location",
Parent = RA_Wrist_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.04, -0.15}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
--MAHLI
local RA_Mahli_Location = {
Identifier = "RA_Mahli_Location",
Parent = RA_Turret_Location.Identifier
}
---- MASTCAM RSM ----
local RSM_ROOT_Location = {
Identifier = "RSM_ROOT_Location",
Parent = MSL_Body.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.7039, 0.5769, -0.563}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local RSM_AZ_Location = {
Identifier = "RSM_AZ_Location",
Parent = RSM_ROOT_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.008, 0.0}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local RSM_ZERO_EL_Location = {
Identifier = "RSM_ZERO_EL_Location",
Parent = RSM_AZ_Location.Identifier,
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local RSM_EL_Location = {
Identifier = "RSM_EL_Location",
Parent = RSM_AZ_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
--Position = {0.0, 0.0, -0.664}
Position = {0.002, 0.007, -0.688}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
---- HIGH GAIN ANTENNA HGA ----
local HGA_AZ_Location = {
Identifier = "HGA_AZ_Location",
Parent = MSL_Body.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {-0.46, -0.47, -0.55}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local HGA_EL_Location = {
Identifier = "HGA_EL_Location",
Parent = HGA_AZ_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.0, -0.17}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
---- SAM & HEMIN ----
local SAM_Cover_1_Location = {
Identifier = "SAM_Cover_1_Location",
Parent = MSL_Body.Identifier,
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local SAM_Cover_2_Location = {
Identifier = "SAM_Cover_2_Location",
Parent = MSL_Body.Identifier,
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local CHEMIN_Location = {
Identifier = "CHEMIN_Location",
Parent = MSL_Body.Identifier,
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
---- Wheels ----
local Wheel_base_Location = {
Identifier = "Wheel_base_Location",
Parent = MSL_Body.Identifier,
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
-- Left side --
local Leg_1_L_Location = {
Identifier = "Leg_1_L_Location",
Parent = Wheel_base_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.217, -0.812, -0.215} --for the right side
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Leg_2_L_Location = {
Identifier = "Leg_2_L_Location",
Parent = Leg_1_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {-0.74, -0.00380, 0.223} --CORRECT, DONT CHANGE
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wrist_F_L_Location = {
Identifier = "Wrist_F_L_Location",
Parent = Leg_1_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.8839, -0.2659, 0.2} --CORRECT, DONT TOUCH
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_F_L_Location = {
Identifier = "Wheel_F_L_Location",
Parent = Wrist_F_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.0, 0.426}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_C_L_Location = {
Identifier = "Wheel_C_L_Location",
Parent = Leg_2_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.45, -0.4, 0.403}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wrist_B_L_Location = {
Identifier = "Wrist_B_L_Location",
Parent = Leg_2_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {-0.627, -0.2635, -0.022} --CORRECT, DONT CHANGE
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_B_L_Location = {
Identifier = "Wheel_B_L_Location",
Parent = Wrist_B_L_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, -0.0, 0.426}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
-- wheels, Right Side --
local Leg_1_R_Location = {
Identifier = "Leg_1_R_Location",
Parent = Wheel_base_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.217, 0.812, -0.215} --Check with caroline!!!
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Leg_2_R_Location = {
Identifier = "Leg_2_R_Location",
Parent = Leg_1_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
--Position = {-0.74, 0.0, 0.24}
Position = {-0.74, 0.00380, 0.223} --want to use this one, once the center point is changed in maya
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wrist_F_R_Location = {
Identifier = "Wrist_F_R_Location",
Parent = Leg_1_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.882, 0.259, 0.215}
--Position = {0.8839, 0.2659, 0.2} --position for the Wrist_F_L
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_F_R_Location = {
Identifier = "Wheel_F_R_Location",
Parent = Wrist_F_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, 0.0, 0.426}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_C_R_Location = {
Identifier = "Wheel_C_R_Location",
Parent = Leg_2_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.45, 0.4, 0.403}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wrist_B_R_Location = {
Identifier = "Wrist_B_R_Location",
Parent = Leg_2_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {-0.6208, 0.2759, -0.025}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
local Wheel_B_R_Location = {
Identifier = "Wheel_B_R_Location",
Parent = Wrist_B_R_Location.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = {0.0, -0.0005, 0.426}
}
},
GUI = {
Path = "/Solar System/Missions/Perseverance/Transforms",
Hidden = true
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
m2020_pos,
MSL_Body,
RA_Base_Location,
RA_Shoulder_AZ_Location,
RA_Shoulder_EL_Location,
RA_Elbow_Location,
RA_Wrist_Location,
RA_Turret_Location,
RA_Mahli_Location,
RSM_ROOT_Location,
RSM_AZ_Location,
RSM_ZERO_EL_Location,
RSM_EL_Location,
HGA_AZ_Location,
HGA_EL_Location,
SAM_Cover_1_Location,
SAM_Cover_2_Location,
CHEMIN_Location,
Wheel_base_Location,
Leg_1_L_Location,
Leg_2_L_Location,
Wrist_F_L_Location,
Wheel_F_L_Location,
Wheel_C_L_Location,
Wrist_B_L_Location,
Wheel_B_L_Location,
Leg_1_R_Location,
Leg_2_R_Location,
Wrist_F_R_Location,
Wheel_F_R_Location,
Wheel_C_R_Location,
Wrist_B_R_Location,
Wheel_B_R_Location
})
+77
View File
@@ -66,3 +66,80 @@ local setDeltaTimeKeys = function(t)
return result
end
asset.export("setDeltaTimeKeys", setDeltaTimeKeys)
--shortcut function
local function has_value (tab, val)
for index, value in ipairs(tab) do
-- We grab the first index of our sub-table instead
if value[1] == val then
return true
end
end
return false
end
local extractShortcuts = function(names, shortcuts)
local foundShortcuts = {};
if type(names) ~= "table" then
openspace.printWarning("scene_helper.extractShortcuts invalid paramater names (not Table)")
end
if type(shortcuts) ~= "table" then
openspace.printWarning("scene_helper.extractShortcuts invalid paramater shortcuts (not Table)")
end
for _, shortcut in ipairs(shortcuts) do
for _, name in ipairs(names ) do
if (shortcut.Name == name) then
foundShortcuts[#foundShortcuts+1] = shortcut
end
end
end
return foundShortcuts
end
asset.export("extractShortcuts", extractShortcuts)
local createKeyBindFromShortcuts = function(key, shortcuts, guipath, title, documentation)
if type(key) ~= "string" then
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater key (not String)")
end
if type(shortcuts) ~= "table" or #shortcuts == 0 then
openspace.printWarning("scene_helper.createKeyBindFromShortcuts invalid paramater shortcuts (not Table or empty)")
end
-- if type(guipath) ~= "string" then
-- guipath = shortcuts[0].GuiPath
-- end
local concatTitle = type(title) ~= "string"
local concatDocumentation = type(documentation) ~= "string"
local keybind = {
Key = key,
Command = "",
Name = name or "",
Documentation = documentation or "",
GuiPath = guipath or "",
Local = false
}
for _, shortcut in ipairs(shortcuts) do
keybind.Command = keybind.Command .. shortcut.Command
if concatTitle then
keybind.Name = keybind.Name .. "/" .. shortcut.Name
end
if concatDocumentation then
keybind.Documentation = keybind.Documentation .. "," .. shortcut.Documentation
end
keybind.Local = keybind.Local and shortcut.Local
end
return keybind
end
asset.export("createKeyBindFromShortcuts", createKeyBindFromShortcuts)