local proceduralGlobes = asset.require("util/procedural_globe")
local transforms = asset.require("./transforms")
local kernel = asset.require("./kernels").ura112



local parentIdentifier = transforms.UranusBarycenter.Identifier
local parentSpice = "URANUS BARYCENTER"
local tags = { "moon_solarSystem", "moon_giants", "moon_uranus", "moon_irregular_retrograde", "moon_minor" }
local trailColor = { 0.60, 0.65, 0.84 }
local trailTags = { 
  "moonTrail_solarSystem",
  "moonTrail_giants",
  "moonTrail_uranus",
  "moonTrail_minor"
}

local irregularMoons = {
  {
    Identifier = "Francisco",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "FRANCISCO",
    Radii = { 22000, 22000, 22000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 266.56,
    Kernels = kernel
  },
  {
    Identifier = "Caliban",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "CALIBAN",
    Radii = { 72000, 72000, 72000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 579.50,
    Kernels = kernel
  },
  {
    Identifier = "Stephano",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "STEPHANO",
    Radii = { 32000, 32000, 32000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 676.50,
    Kernels = kernel
  },
  {
    Identifier = "Trinculo",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "TRINCULO",
    Radii = { 18000, 18000, 18000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 758.10,
    Kernels = kernel
  },
  {
    Identifier = "Sycorax",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "SYCORAX",
    Radii = { 165000, 165000, 165000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1283.4,
    Kernels = kernel
  },
  {
    Identifier = "Prospero",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "PROSPERO",
    Radii = { 50000, 50000, 50000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1992.8,
    Kernels = kernel
  },
  {
    Identifier = "Setebos",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "SETEBOS",
    Radii = { 48000, 48000, 48000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 2202.3,
    Kernels = kernel
  },
  {
    Identifier = "Ferdinand",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "FERDINAND",
    Radii = { 20000, 20000, 20000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Irregular Retrograde Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 2823.4,
    Kernels = kernel
  }
}

local nodes = proceduralGlobes.createGlobes(irregularMoons)

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


asset.meta = {
  Name = "Uranus Irregular Retrograde Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Uranus' irregular retrograde moons:
    Francisco, Caliban, Stephano, Trinculo, Sycorax, Prospero, Setebos and Ferdinand.
    Blank globes and SPICE trails are generated for each moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
