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



local NeptuneTrail = {
  Identifier = "NeptuneTrail",
  Parent = transforms.SolarSystemBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "NEPTUNE",
      Observer = "SSB"
    },
    Color = { 0.2, 0.5, 1.0 },
    -- Period  = 60200,
    -- Yes, this period is wrong, but the SPICE kernel we load by default only
    -- goes back to 1850.  Neptunes orbit is 164 years, which would mean that we
    -- exceed the SPICE kernel if we go back before 2014, if we try to compute the
    -- entire orbit.  Cutting the orbit length to 100 years allows us to go back
    -- to 1950 instead, which is good enough.
    -- If the positions are needed before that, a different set of kernels are
    -- needed, namely:
    -- https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de431_part-1.bsp
    -- https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de431_part-2.bsp
    -- that cover a larger time span:  -13201-MAY-06 00:00 to  17191-MAR-15 00:00
    Period  = 36500,
    Resolution = 1000
  },
  Tag = { "planetTrail_solarSystem", "planetTrail_giants" },
  GUI = {
    Name = "Neptune Trail",
    Path = "/Solar System/Planets/Neptune",
    Description = "Trail of Neptune as observed by the Sun"
  }
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(NeptuneTrail)
end)
  
asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(NeptuneTrail)
end)
  
asset.export(NeptuneTrail)



asset.meta = {
  Name = "Neptune Trail",
  Version = "1.1",
  Description = "Main trail of Neptune. Data from NASA Spice (see base spice asset)",
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
