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



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


local majorMoons = {
  {
    Identifier = "Miranda",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "MIRANDA",
    Radii = { 471600, 468000, 466000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Major Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.413479,
    Kernels = kernel
  },
  {
    Identifier = "Ariel",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "ARIEL",
    Radii = { 1162000, 1156000, 1155000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Major Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 2.520379,
    Kernels = kernel
  },
  {
    Identifier = "Umbriel",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "UMBRIEL",
    Radii = { 1169400, 1169400, 1169400 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Major Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 4.144177,
    Kernels = kernel
  },
  {
    Identifier = "Titania",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "TITANIA",
    Radii = { 1576800, 1576800, 1576800 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Major Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 8.705872,
    Kernels = kernel
  },
  {
    Identifier = "Oberon",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "OBERON",
    Radii = { 1522800, 1522800, 1522800 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Uranus/Moons/Major Moons"
    },
    TrailColor = trailColor,
    OrbitPeriod = 13.463239,
    Kernels = kernel
  }
}

local nodes = proceduralGlobes.createGlobes(majorMoons)

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 Marjor Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Uranus' major moons: Miranda, Ariel,
    Umbriel, Titania, and Oberon. Blank globes and SPICE trails are generated for each
    moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
