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



local Themisto = {
  Identifier = "Themisto",
  Parent = transforms.JupiterBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "THEMISTO",
      Observer = "JUPITER BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 8000, 8000, 8000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_jupiter",
    "moon_themisto",
    "moon_minor",
    "moon_minor_jupiter"
  },
  GUI = {
    Name = "Themisto",
    Path = "/Solar System/Planets/Jupiter/Minor Moons/Themisto Group/Themisto"
  }
}

local ThemistoTrail = {
  Identifier = "ThemistoTrail",
  Parent = transforms.JupiterBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "THEMISTO",
      Observer = "JUPITER BARYCENTER"
    },
    Color = { 0.4, 0.3, 0.01 },
    Period = 129.87,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_jupiter",
    "moonTrail_minor",
    "moonTrail_minor_jupiter"
  },
  GUI = {
    Name = "Themisto Trail",
    Path = "/Solar System/Planets/Jupiter/Minor Moons/Themisto Group/Themisto"
  }
}

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


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


  openspace.addSceneGraphNode(Themisto)
  openspace.addSceneGraphNode(ThemistoTrail)
  openspace.addSceneGraphNode(ThemistoLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(ThemistoLabel)
  openspace.removeSceneGraphNode(ThemistoTrail)
  openspace.removeSceneGraphNode(Themisto)


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

asset.export(Themisto)
asset.export(ThemistoTrail)
asset.export(ThemistoLabel)



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