asset.require("spice/base")
local sun = asset.require("scene/solarsystem/sun/sun")
local mars = asset.require("scene/solarsystem/planets/mars/mars")

local models = asset.syncedResource({
  Name = "Insight Models Chutes",
  Type = "HttpSynchronization",
  Identifier = "insight_models",
  Version = 2
})

local ikernels = asset.syncedResource({
  Name = "Insight Kernels",
  Type = "HttpSynchronization",
  Identifier = "insight_kernels",
  Version = 1
})

local iKernels = {
  ikernels .. "nsyt_spk_cruise_od063_v1_approach2surface_SC_Lander.tsc",
  ikernels .. "insight_v02.tfr",
  ikernels .. "mar085s.bsp",
  ikernels .. "nsyt_spk_cruise_POST_approach2surface_SC_Lander.bsp",
  ikernels .. "nsyt_spk_cruise_POST_approach2surface_SC_Lander.bck",
}

local RotationMatrix = {
  -1,  0,  0,
    0,  0, -1,
    0, -1,  0
}

local LightSources = {
  sun.LightSource,
  {
    Type = "SceneGraphLightSource",
    Identifier = "Mars",
    Node = "Mars",
    Intensity = 1.0
  },
  {
    Identifier = "Camera",
    Type = "CameraLightSource",
    Intensity = 0.5
  }
}

--expected timeline
local entryTimeStart = "2018 NOV 26 19:39:03.68"; --(-00:08:07.32 less then pdf)
local parachuteDeployTime1 = "2018 NOV 26 19:42:41.68" -- entry + 218s
local parachuteDeployTime20 = "2018 NOV 26 19:42:42.18" -- entry + 218.5s
local parachuteDeployTime40 = "2018 NOV 26 19:42:42.68" -- entry + 219s
local heatShieldSeperationTime = "2018 NOV 26 19:42:56.68" -- entry + 233s
local legDeployTime = "2018 NOV 26 19:43:06.68" -- entry + 243s
local landerSeperationTime = "2018 NOV 26 19:44:51.68" -- entry + 348s
local touchdownTime = "2018 NOV 26 19:45:32.68" -- entry + 389s
local panelDeployTime = "2018 NOV 26 19:45:33.68" -- entry + 390s

local kernelTouchdownTime = "2018 NOV 26 19:45:32.3"
local spiceRotationEndTime = "2018 NOV 26 19:51:39"

local TranslationKeyframes = {
  ["1850 JAN 01 00:00:00"] = {
      Type = "SpiceTranslation",
      Target = "INSIGHT",
      Observer = "MARS",
      Frame = "IAU_MARS",
      Kernels = iKernels,
      FixedDate = "2018 NOV 26 19:39:03"
  },
  ["2018 NOV 26 19:39:02"] = {
      Type = "SpiceTranslation",
      Target = "INSIGHT",
      Observer = "MARS",
      Frame = "IAU_MARS",
      Kernels = iKernels,
      FixedDate = "2018 NOV 26 19:39:03"
  },
  ["2018 NOV 26 19:39:03"] = {
    Type = "SpiceTranslation",
    Target = "INSIGHT",
    Observer = "MARS",
    Frame = "IAU_MARS",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:39:04"] = {
    Type = "SpiceTranslation",
    Target = "INSIGHT",
    Observer = "MARS",
    Frame = "IAU_MARS",
    Kernels = iKernels
  },
 ["2018 NOV 26 19:45:34"] = {
    Type = "SpiceTranslation",
    Target = "INSIGHT",
    Observer = "MARS",
    Frame = "IAU_MARS",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:45:35"] = {
      Type = "SpiceTranslation",
      Target = "INSIGHT",
      Observer = "MARS",
      Frame = "IAU_MARS",
      Kernels = iKernels,
      FixedDate = "2018 NOV 26 19:45:34"
  }
}

local RotationKeyframes = {
  ["1850 JAN 01 00:00:00"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    FixedDate = "2018 NOV 26 19:39:02",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:39:02"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    FixedDate = "2018 NOV 26 19:39:02",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:39:03"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:39:04"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    Kernels = iKernels
  },
 ["2018 NOV 26 19:45:34"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    Kernels = iKernels
  },
  ["2018 NOV 26 19:45:35"] = {
    Type = "SpiceRotation",
    SourceFrame = "INSIGHT_LANDER_CRUISE",
    DestinationFrame = "IAU_MARS",
    FixedDate = "2018 NOV 26 19:45:34"
  },
}


local InsightParent = {
  Identifier = "InsightParent",
  Parent = mars.Mars.Identifier,
  Transform = {
    Translation ={
      Type = "TimelineTranslation",
      Keyframes = TranslationKeyframes,
    },
    Rotation = {
      Type = "TimelineRotation",
      Keyframes = RotationKeyframes,
    }
  },
  -- TimeFrame = {
  --   Type = "TimeFrameInterval",
  --   Start = entryTimeStart,
  --   End = spiceRotationEndTime
  -- },
  GUI = {
    Hidden = true,
    Name = "InsightParent",
    Path = "/Solar System/Missions/Insight"
  }
}

-- -1397 offset for MOLA
local Insight = {
  Identifier = "Insight",
  Parent = "InsightParent",
  Transform = {
    Rotation = {
      Type = "StaticRotation",
      Rotation = { 0.0, 0.0, -math.pi }
    }
  },
  GUI = {
    Name = "Insight",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Entry_CapsuleA = {
  Identifier = "Insight_Entry_CapsuleA",
  Parent =  Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "cruise_insight_doubleside2_newcapsule_diffuse.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    End = landerSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight Entry CapsuleA",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Entry_Capsule_Ring = {
  Identifier = "Insight_Entry_Capsule_Ring",
  Parent =  Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_cruise_cone_ring_foil_gold.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    End = landerSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight Entry Capsule Ring",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Entry_Capsule_Plugs = {
  Identifier = "Insight_Entry_Capsule_Plugs",
  Parent =  Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_cruise_cone_capsule_diffuse.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    End = landerSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight Entry Capsule Plugs",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Entry_Heatshield = {
  Identifier = "Insight_Entry_Heatshield",
  Parent =  Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_cruise_heatshield_foil_gold.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    End = heatShieldSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight Entry Heatshield",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_0 = {
  Identifier = "Insight_Parachute_0",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_chute_frame01_diff1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime1,
    End = parachuteDeployTime20
  },
  GUI = {
    Hidden = true,
    Name = "Insight Parachute0",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_Cords_0 = {
  Identifier = "Insight_Parachute_Cords_0",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_chute_frame01_cords1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime1,
    End = parachuteDeployTime20
  },
  GUI = {
    Hidden = true,
    Name = "Insight ParachuteC0",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_20 = {
  Identifier = "Insight_Parachute_20",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_chute_frame20_diff1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime20,
    End = parachuteDeployTime40
  },
  GUI = {
    Hidden = true,
    Name = "Insight Parachute20",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_Cords_20 = {
  Identifier = "Insight_Parachute_Cords_20",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_chute_frame20_cords1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime20,
    End = parachuteDeployTime40
  },
  GUI = {
    Hidden = true,
    Name = "Insight ParachuteC20",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_40 = {
  Identifier = "Insight_Parachute_40",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "chute_doubleside_frame40_diff.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime40,
    End = landerSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight Parachute40",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Parachute_Cords_40 = {
  Identifier = "Insight_Parachute_Cords_40",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_chute_frame40_cords1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = parachuteDeployTime40,
    End = landerSeperationTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight ParachuteC40",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A001 = {
  Identifier = "Insight_Lander_A001",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A001",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A002 = {
  Identifier = "Insight_Lander_A002",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO02.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A002",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A003 = {
  Identifier = "Insight_Lander_A003",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO03.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A003",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A004 = {
  Identifier = "Insight_Lander_A004",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO04.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A004",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A005 = {
  Identifier = "Insight_Lander_A005",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO05.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A005",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A006 = {
  Identifier = "Insight_Lander_A006",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO06.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A006",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A007 = {
  Identifier = "Insight_Lander_A007",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO07.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A007",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_A008 = {
  Identifier = "Insight_Lander_A008",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_AO08.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander A008",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_foil1 = {
  Identifier = "Insight_Lander_foil1",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_foil1.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander foil",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_Tex01 = {
  Identifier = "Insight_Lander_Tex01",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_tex01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander Tex01",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Lander_Tex02 = {
  Identifier = "Insight_Lander_Tex02",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_deck_tex02.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  GUI = {
    Hidden = true,
    Name = "Insight Lander Tex02",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Legs_Stowed_tex = {
  Identifier = "Insight_Legs_Stowed_tex",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_legs_stow_tex01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = heatShieldSeperationTime,
    End = legDeployTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight legs_stow_tex",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Legs_Stowed_AO06 = {
  Identifier = "Insight_Legs_Stowed_AO",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_legs_stow_AO06.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = heatShieldSeperationTime,
    End = legDeployTime
  },
  GUI = {
    Hidden = true,
    Name = "Insight legs_stow_AO",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Legs_Deployed_tex = {
  Identifier = "Insight_Legs_Deployed_tex",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_legs_deploy_tex01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources,
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = legDeployTime,
  },
  GUI = {
    Hidden = true,
    Name = "Insight legs_deploy_tex",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Legs_Deployed_AO06 = {
  Identifier = "Insight_Legs_Deployed_AO",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_legs_deploy_AO06.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = legDeployTime,
  },
  GUI = {
    Hidden = true,
    Name = "Insight legs_deploy_AO",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Stowed_tex = {
  Identifier = "Insight_Panels_Stowed_tex",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_panels_stow_tex01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  GUI = {
    Hidden = true,
    Name = "Insight panels_stow_tex",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Stowed_tex2 = {
  Identifier = "Insight_Panels_Stowed_tex2",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_panels_stow_tex02.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  GUI = {
    Hidden = true,
    Name = "Insight panels_stow_tex2",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Stowed_AO01 = {
  Identifier = "Insight_Panels_Stowed_AO",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_panels_stow_AO01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  GUI = {
    Hidden = true,
    Name = "Insight panels_stow_AO",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Deployed_tex = {
  Identifier = "Insight_panels_Deployed_tex",
  Parent = Insight.Identifier,
  Renderable = {
      Type = "RenderableModel",
      GeometryFile = models .. "insight_lander_panels_deploy_tex01.obj",
      ModelTransform = RotationMatrix,
      LightSources = LightSources
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = panelDeployTime,
  },
  GUI = {
    Hidden = true,
    Name = "Insight panels_deploy_tex",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Deployed_tex2 = {
  Identifier = "Insight_panels_Deployed_tex2",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_panels_deploy_tex02.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = panelDeployTime,
  },
  GUI = {
    -- Hidden = true,
    Name = "Insight panels_deploy_tex2",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Panels_Deployed_AO06 = {
  Identifier = "Insight_panels_Deployed_AO",
  Parent = Insight.Identifier,
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "insight_lander_panels_deploy_AO01.obj",
    ModelTransform = RotationMatrix,
    LightSources = LightSources
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = panelDeployTime,
  },
  GUI = {
    Hidden = true,
    Name = "Insight panels_deploy_AO",
    Path = "/Solar System/Missions/Insight"
  }
}

local Insight_Trail = {
  Identifier = "InsightTrail",
  Parent = "Mars",
  Renderable = {
    Enabled = false,
    Type = "RenderableTrailTrajectory",
    Translation = {
      Type = "SpiceTranslation",
      Target = -189,
      Observer = "MARS",
      Frame = "IAU_MARS",
      Kernels = iKernels
    },
    Color = { 0.70, 0.50, 0.20 },
    StartTime = "2018 NOV 26 19:30:13.390",
    EndTime = "2018 NOV 26 19:51:40.890",
    SampleInterval = 2
  },
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = entryTimeStart,
    End = landerSeperationTime
  },
  GUI = {
    Name = "Insight Trail",
    Path = "/Solar System/Missions/Insight"
  }
}

local nodes = {
  InsightParent, Insight, Insight_Entry_CapsuleA, Insight_Entry_Capsule_Ring,
  Insight_Entry_Capsule_Plugs, Insight_Entry_Heatshield, Insight_Parachute_0,
  Insight_Parachute_Cords_0, Insight_Parachute_20, Insight_Parachute_Cords_20,
  Insight_Parachute_40, Insight_Parachute_Cords_40, Insight_Lander_A001,
  Insight_Lander_A002, Insight_Lander_A003, Insight_Lander_A004, Insight_Lander_A005,
  Insight_Lander_A006, Insight_Lander_A007, Insight_Lander_A008, Insight_Lander_foil1,
  Insight_Lander_Tex01, Insight_Lander_Tex02, Insight_Legs_Stowed_tex,
  Insight_Legs_Stowed_AO06, Insight_Legs_Deployed_tex, Insight_Legs_Deployed_AO06,
  Insight_Panels_Stowed_tex, Insight_Panels_Stowed_tex2, Insight_Panels_Stowed_AO01,
  Insight_Panels_Deployed_tex, Insight_Panels_Deployed_tex2,
  Insight_Panels_Deployed_AO06, Insight_Trail
}

asset.onInitialize(function()
  for _, node in ipairs(nodes) do
    openspace.addSceneGraphNode(node)
  end
end)
    
asset.onDeinitialize(function()
  for i = #nodes, 1, -1 do
    openspace.removeSceneGraphNode(nodes[i])
  end
end)

for _, node in ipairs(nodes) do
  asset.export(node)
end
