local sunTransforms = asset.require("scene/solarsystem/sun/transforms")
local kernels = asset.require("./kernels")



local PlutoBarycenterAccurate = {
  Identifier = "PlutoBarycenterAccurate",
  Parent = sunTransforms.SolarSystemBarycenter.Identifier,
  TimeFrame = {
    Type = "TimeFrameInterval",
    Start = "2015-JAN-01",
    End = "2015-AUG-01"
  },
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "PLUTO BARYCENTER",
      Observer = "SSB"
    }
  },
  GUI = {
    Name = "Pluto Barycenter Accurate",
    Path = "/Solar System/Dwarf Planets/Pluto"
  }
}

local NewHorizonsPosition = {
  Identifier = "NewHorizonsPosition",
  Parent = PlutoBarycenterAccurate.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "NEW HORIZONS",
      Observer = "PLUTO BARYCENTER"
    },
    Rotation = {
      Type = "SpiceRotation",
      SourceFrame = "NH_SPACECRAFT",
      DestinationFrame = "GALACTIC"
    }
  },
  GUI = {
    Name = "New Horizons Position",
    Path = "/Solar System/Missions/New Horizons"
  }
}


asset.onInitialize(function()
  openspace.spice.loadKernel(kernels.PlutoKernels)
  openspace.spice.loadKernel(kernels.NewHorizonsKernels)

  openspace.addSceneGraphNode(PlutoBarycenterAccurate)
  openspace.addSceneGraphNode(NewHorizonsPosition)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(NewHorizonsPosition)
  openspace.removeSceneGraphNode(PlutoBarycenterAccurate)

  openspace.spice.unloadKernel(kernels.NewHorizonsKernels)
  openspace.spice.unloadKernel(kernels.PlutoKernels)
end)

asset.export(PlutoBarycenterAccurate)
asset.export(NewHorizonsPosition)
