local transforms = asset.require("scene/solarsystem/planets/earth/transforms")

local omm = asset.syncedResource({
  Name = "Satellite OMM Data (SpaceStations)",
  Type = "UrlSynchronization",
  Identifier = "satellite_omm_data_stations",
  Url = "https://www.celestrak.com/NORAD/elements/gp.php?GROUP=stations&FORMAT=kvn",
  Filename = "stations.txt",
  Override = true
})

local satellites = {
  Identifier = "stations",
  Parent = transforms.EarthInertial.Identifier,
  Renderable = {
    Type = "RenderableOrbitalKepler",
    Path = omm .. "stations.txt",
    Format = "OMM",
    SegmentQuality = 3,
    Color = { 0.9, 0.1, 0.0 },
    Fade = 1.5,
    RenderBinMode = "PostDeferredTransparent"
  },
  Tag = { "earth_satellites" },
  GUI = {
    Name = "SpaceStations",
    Path = "/Solar System/Planets/Earth/Satellites",
    Description = [[A collection of space stations (including the ISS and China's 
      Tiangong), along with certain cubesats and satellite constellations from space 
      agencies.]]
  }
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(satellites)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(satellites)
end)

asset.export(satellites)



asset.meta = {
  Name = "Satellites SpaceStations",
  Version = "1.0",
  Description = "Satellites asset for SpaceStations. Data from Celestrak",
  Author = "OpenSpace Team",
  URL = "https://celestrak.com/NORAD/elements/",
  License = "Celestrak"
}
