local proceduralGlobes = asset.require("util/procedural_globe")
local transforms = asset.require("../transforms")
local kernels = asset.require("../kernels")
local kernel375 = kernels.sat375
local kernel393 = kernels.sat393



local parentIdentifier = transforms.SaturnBarycenter.Identifier
local parentSpice = "SATURN BARYCENTER"
local tags = { "moon_solarSystem", "moon_giants", "moon_saturn", "moon_other", "moon_minor" }
local trailColor = { 0.5, 0.3, 0.3 }
local trailTags = { 
  "moonTrail_solarSystem",
  "moonTrail_giants",
  "moonTrail_saturn",
  "moonTrail_minor"
}

local otherGroup = {
  {
    Identifier = "Aegaeon",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "AEGAEON",
    Radii = { 500, 500, 500 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 0.80812,
    Kernels = kernel393
  },
  {
    Identifier = "Methone",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "METHONE",
    Radii = { 3200, 3200, 3200 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.00957,
    Kernels = kernel393
  },
  {
    Identifier = "Anthe",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "ANTHE",
    Radii = { 1800, 1800, 1800 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.05089,
    Kernels = kernel393
  },
  {
    Identifier = "Pallene",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "PALLENE",
    Radii = { 6000, 6000, 4000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.370218,
    Kernels = kernel393
  },
  {
    Identifier = "Telesto",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "TELESTO",
    Radii = { 33000, 24000, 20000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.887802,
    Kernels = kernel375
  },
  {
    Identifier = "Calypso",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "CALYPSO",
    Radii = { 30000, 23000, 14000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 1.887802,
    Kernels = kernel375
  },
  {
    Identifier = "Helene",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "HELENE",
    Radii = { 43000, 38000, 26000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 2.736915,
    Kernels = kernel375
  },
  {
    Identifier = "Polydeuces",
    Parent = {
      Identifier = parentIdentifier,
      Spice = parentSpice
    },
    Spice = "POLYDEUCES",
    Radii = { 3000, 2000, 1000 },
    Tags = tags,
    TrailTags = trailTags,
    GUI = {
      Path = "/Solar System/Planets/Saturn/Moons/Other Group"
    },
    TrailColor = trailColor,
    OrbitPeriod = 2.736915,
    Kernels = kernel393
  }
}

local nodes = proceduralGlobes.createGlobes(otherGroup)

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 = "Saturn Other Group Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Saturn's Other Group moons: Aegaeon,
    Methone, Anthe, Pallene, Telesto, Calypso, Helene, Polydeuces. Blank globes and SPICE
    trails are generated for each moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
