local transforms = asset.require("./transforms")
local kernel = asset.require("./kernels")



local Margaret = {
  Identifier = "Margaret",
  Parent = transforms.UranusBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "MARGARET",
      Observer = "URANUS BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 20000, 20000, 20000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_uranus",
    "moon_irregular_prograde",
    "moon_minor",
    "moon_minor_uranus"
  },
  GUI = {
    Name = "Margaret",
    Path = "/Solar System/Planets/Uranus/Minor Moons/Irregular Prograde Moons/Margaret"
  }
}

local MargaretTrail = {
  Identifier = "MargaretTrail",
  Parent = transforms.UranusBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "MARGARET",
      Observer = "URANUS BARYCENTER"
    },
    Color = { 0.60, 0.65, 0.84 },
    Period = 1694.8,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_uranus",
    "moonTrail_minor",
    "moonTrail_minor_uranus"
  },
  GUI = {
    Name = "Margaret Trail",
    Path = "/Solar System/Planets/Uranus/Minor Moons/Irregular Prograde Moons/Margaret"
  }
}

local MargaretLabel = {
  Identifier = "MargaretLabel",
  Parent = Margaret.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Margaret",
    FontSize = 70.0,
    Size = 7.0,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 2.0, 80.0 },
    FadeWidths = { 1.0, 40.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "Margaret Label",
    Path = "/Solar System/Planets/Uranus/Minor Moons/Irregular Prograde Moons/Margaret",
    Description = "Label for Uranus' moon Margaret (Irregular Prograde Moons)"
  }
}


asset.onInitialize(function()
  openspace.spice.loadKernel(kernel.ura116)


  openspace.addSceneGraphNode(Margaret)
  openspace.addSceneGraphNode(MargaretTrail)
  openspace.addSceneGraphNode(MargaretLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(MargaretLabel)
  openspace.removeSceneGraphNode(MargaretTrail)
  openspace.removeSceneGraphNode(Margaret)


  openspace.spice.unloadKernel(kernel.ura116)
end)

asset.export(Margaret)
asset.export(MargaretTrail)
asset.export(MargaretLabel)



asset.meta = {
  Name = "Uranus Irregular Prograde Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Uranus' irregular prograde moon:
    Margaret. A blank globe and SPICE trail are generated for the moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
