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



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

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

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

local S2003J19 = {
  Identifier = "S2003J19",
  Parent = transforms.JupiterBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "561",
      Observer = "JUPITER BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 2000, 2000, 2000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = {
    "moon_solarSystem",
    "moon_giants",
    "moon_jupiter",
    "moon_other",
    "moon_minor",
    "moon_minor_jupiter"
  },
  GUI = {
    Name = "S/2003 J 19",
    Path = "/Solar System/Planets/Jupiter/Minor Moons/Other Group/S2003J19"
  }
}

local S2003J19Trail = {
  Identifier = "S2003J19Trail",
  Parent = transforms.JupiterBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "561",
      Observer = "JUPITER BARYCENTER"
    },
    Color = { 0.4, 0.3, 0.01 },
    Period = 699.12,
    Resolution = 1000
  },
  Tag = {
    "moonTrail_solarSystem",
    "moonTrail_giants",
    "moonTrail_jupiter",
    "moonTrail_minor",
    "moonTrail_minor_jupiter"
  },
  GUI = {
    Name = "S/2003 J 19 Trail",
    Path = "/Solar System/Planets/Jupiter/Minor Moons/Ananke Group/S2003J19"
  }
}

local S2003J19Label = {
  Identifier = "S2003J19Label",
  Parent = S2003J19.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "S/2003 J 19",
    FontSize = 70.0,
    Size = 7.1,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1.0, 150.0 },
    FadeWidths = { 1.0, 50.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "minor_moon_labels" },
  GUI = {
    Name = "S/2003 J 19 Label",
    Path = "/Solar System/Planets/Jupiter/Minor Moons/Ananke Group/S2003J19",
    Description = "Label for Jupiter's moon S/2003 J 19 (other group)"
  }
}

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

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

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


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


  openspace.addSceneGraphNode(Eupheme)
  openspace.addSceneGraphNode(EuphemeTrail)
  openspace.addSceneGraphNode(EuphemeLabel)

  openspace.addSceneGraphNode(S2003J19)
  openspace.addSceneGraphNode(S2003J19Trail)
  openspace.addSceneGraphNode(S2003J19Label)

  openspace.addSceneGraphNode(Valetudo)
  openspace.addSceneGraphNode(ValetudoTrail)
  openspace.addSceneGraphNode(ValetudoLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(ValetudoLabel)
  openspace.removeSceneGraphNode(ValetudoTrail)
  openspace.removeSceneGraphNode(Valetudo)

  openspace.removeSceneGraphNode(S2003J19Label)
  openspace.removeSceneGraphNode(S2003J19Trail)
  openspace.removeSceneGraphNode(S2003J19)

  openspace.removeSceneGraphNode(EuphemeLabel)
  openspace.removeSceneGraphNode(EuphemeTrail)
  openspace.removeSceneGraphNode(Eupheme)


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

asset.export(Eupheme)
asset.export(EuphemeTrail)
asset.export(EuphemeLabel)

asset.export(S2003J19)
asset.export(S2003J19Trail)
asset.export(S2003J19Label)

asset.export(Valetudo)
asset.export(ValetudoTrail)
asset.export(ValetudoLabel)



asset.meta = {
  Name = "Jupiter Pasiphae Other Moons",
  Version = "1.0",
  Description = [[Procedural Globe asset containing Jupiter's Other Group moons: S2003J12,
    S/2003J3, S2011J1, S2003J19, S2003J10, S2003J9, and S2003J2. Blank globes
    and SPICE trails are generated for each moon]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
