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



local Albiorix = {
  Identifier = "Albiorix",
  Parent = transforms.SaturnBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "ALBIORIX",
      Observer = "SATURN BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 32000, 32000, 32000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_saturn",
    "moon_gallic",
    "moon_minor",
    "moon_minor_saturn"
  },
  GUI = {
    Name = "Albiorix",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Albiorix"
  }
}

local AlbiorixTrail = {
  Identifier = "AlbiorixTrail",
  Parent = transforms.SaturnBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "ALBIORIX",
      Observer = "SATURN BARYCENTER"
    },
    Color = { 0.5, 0.3, 0.3 },
    Period = 774.58,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_saturn",
    "moonTrail_minor",
    "moonTrail_minor_saturn"
  },
  GUI = {
    Name = "Albiorix Trail",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Albiorix"
  }
}

local AlbiorixLabel = {
  Identifier = "AlbiorixLabel",
  Parent = Albiorix.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Albiorix",
    FontSize = 70.0,
    Size = 7.1,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1.25, 90.0 },
    FadeWidths = { 0.25, 90.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "Albiorix Label",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Albiorix",
    Description = "Label for Saturn's moon Albiorix (Gallic group)"
  }
}

local Bebhionn = {
  Identifier = "Bebhionn",
  Parent = transforms.SaturnBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "BEBHIONN",
      Observer = "SATURN BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 6000, 6000, 6000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_saturn",
    "moon_gallic",
    "moon_minor",
    "moon_minor_saturn"
  },
  GUI = {
    Name = "Bebhionn",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Bebhionn"
  }
}

local BebhionnTrail = {
  Identifier = "BebhionnTrail",
  Parent = transforms.SaturnBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "BEBHIONN",
      Observer = "SATURN BARYCENTER"
    },
    Color = { 0.5, 0.3, 0.3 },
    Period = 838.77,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_saturn",
    "moonTrail_minor",
    "moonTrail_minor_saturn"
  },
  GUI = {
    Name = "Bebhionn Trail",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Bebhionn"
  }
}

local BebhionnLabel = {
  Identifier = "BebhionnLabel",
  Parent = Bebhionn.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Bebhionn",
    FontSize = 70.0,
    Size = 7.1,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1.25, 90.0 },
    FadeWidths = { 0.25, 90.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "Bebhionn Label",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Bebhionn",
    Description = "Label for Saturn's moon Bebhionn (Gallic group)"
  }
}

local Erriapus = {
  Identifier = "Erriapus",
  Parent = transforms.SaturnBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "ERRIAPUS",
      Observer = "SATURN BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 10000, 10000, 10000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_saturn",
    "moon_gallic",
    "moon_minor",
    "moon_minor_saturn"
  },
  GUI = {
    Name = "Erriapus",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Erriapus"
  }
}

local ErriapusTrail = {
  Identifier = "ErriapusTrail",
  Parent = transforms.SaturnBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "ERRIAPUS",
      Observer = "SATURN BARYCENTER"
    },
    Color = { 0.5, 0.3, 0.3 },
    Period = 844.89,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_saturn",
    "moonTrail_minor",
    "moonTrail_minor_saturn"
  },
  GUI = {
    Name = "Erriapus Trail",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Erriapus"
  }
}

local ErriapusLabel = {
  Identifier = "ErriapusLabel",
  Parent = Erriapus.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Erriapus",
    FontSize = 70.0,
    Size = 7.1,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1.25, 90.0 },
    FadeWidths = { 0.25, 90.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "Erriapus Label",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Erriapus",
    Description = "Label for Saturn's moon Erriapus (Gallic group)"
  }
}

local Tarvos = {
  Identifier = "Tarvos",
  Parent = transforms.SaturnBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "TARVOS",
      Observer = "SATURN BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 15000, 15000, 15000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_saturn",
    "moon_gallic",
    "moon_minor",
    "moon_minor_saturn"
  },
  GUI = {
    Name = "Tarvos",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Tarvos"
  }
}

local TarvosTrail = {
  Identifier = "TarvosTrail",
  Parent = transforms.SaturnBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "TARVOS",
      Observer = "SATURN BARYCENTER"
    },
    Color = { 0.5, 0.3, 0.3 },
    Period = 944.23,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_saturn",
    "moonTrail_minor",
    "moonTrail_minor_saturn"
  },
  GUI = {
    Name = "Tarvos Trail",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Tarvos"
  }
}

local TarvosLabel = {
  Identifier = "TarvosLabel",
  Parent = Tarvos.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Tarvos",
    FontSize = 70.0,
    Size = 7.1,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1.25, 90.0 },
    FadeWidths = { 0.25, 90.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "Tarvos Label",
    Path = "/Solar System/Planets/Saturn/Minor Moons/Gallic Group/Tarvos",
    Description = "Label for Saturn's moon Tarvos (Gallic group)"
  }
}


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


  openspace.addSceneGraphNode(Albiorix)
  openspace.addSceneGraphNode(AlbiorixTrail)
  openspace.addSceneGraphNode(AlbiorixLabel)

  openspace.addSceneGraphNode(Bebhionn)
  openspace.addSceneGraphNode(BebhionnTrail)
  openspace.addSceneGraphNode(BebhionnLabel)

  openspace.addSceneGraphNode(Erriapus)
  openspace.addSceneGraphNode(ErriapusTrail)
  openspace.addSceneGraphNode(ErriapusLabel)

  openspace.addSceneGraphNode(Tarvos)
  openspace.addSceneGraphNode(TarvosTrail)
  openspace.addSceneGraphNode(TarvosLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(TarvosLabel)
  openspace.removeSceneGraphNode(TarvosTrail)
  openspace.removeSceneGraphNode(Tarvos)

  openspace.removeSceneGraphNode(ErriapusLabel)
  openspace.removeSceneGraphNode(ErriapusTrail)
  openspace.removeSceneGraphNode(Erriapus)

  openspace.removeSceneGraphNode(BebhionnLabel)
  openspace.removeSceneGraphNode(BebhionnTrail)
  openspace.removeSceneGraphNode(Bebhionn)

  openspace.removeSceneGraphNode(AlbiorixLabel)
  openspace.removeSceneGraphNode(AlbiorixTrail)
  openspace.removeSceneGraphNode(Albiorix)


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

asset.export(Albiorix)
asset.export(AlbiorixTrail)
asset.export(AlbiorixLabel)

asset.export(Bebhionn)
asset.export(BebhionnTrail)
asset.export(BebhionnLabel)

asset.export(Erriapus)
asset.export(ErriapusTrail)
asset.export(ErriapusLabel)

asset.export(Tarvos)
asset.export(TarvosTrail)
asset.export(TarvosLabel)



asset.meta = {
  Name = "Saturn Gallic Group Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Saturn's Gallic Group moons: Albiorix,
    Bebhionn, Erriapus, and Tarvos. Blank globes and SPICE trails are generated for each
    moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
