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



local Triton = {
  Identifier = "Triton",
  Parent = transforms.NeptuneBarycenter.Identifier,
  Transform = {
    Rotation = {
      Type = "SpiceRotation",
      SourceFrame = "IAU_TRITON",
      DestinationFrame = "GALACTIC",
    },
    Translation = {
      Type = "SpiceTranslation",
      Target = "TRITON",
      Observer = "NEPTUNE BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 2709000, 2706000, 2705000 },
    SegmentsPerPatch = 64,
    Layers = {}
  },
  Tag = { "moon_solarSystem", "moon_giants", "moon_neptune", "moon_major_neptune" },
  GUI = {
    Name = "Triton",
    Path = "/Solar System/Planets/Neptune/Major Moons/Triton"
  }
}

local TritonTrail = {
  Identifier = "TritonTrail",
  Parent = transforms.NeptuneBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTrailOrbit",
    Translation = {
      Type = "SpiceTranslation",
      Target = "TRITON",
      Observer = "NEPTUNE BARYCENTER"
    },
    Color = { 0.2, 0.5, 0.75 },
    Period = 5.875,
    Resolution = 1000
  },
  Tag = { "moonTrail_solarSystem", "moonTrail_giants", "moonTrail_neptune", "moonTrail_major_neptune" },
  GUI = {
    Name = "Triton Trail",
    Path = "/Solar System/Planets/Neptune/Major Moons/Triton"
  }
}

local TritonLabel = {
  Identifier = "TritonLabel",
  Parent = Triton.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Triton",
    FontSize = 50.0,
    Size = 7.0,
    MinMaxSize = { 1, 25 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "Gm",
    FadeDistances = { 1, 15.0 },
    FadeWidths = { 1, 15.0 }
  },
  Tag = { "solarsystem_labels", "moon_labels", "major_moon_labels" },
  GUI = {
    Name = "Triton Label",
    Path = "/Solar System/Planets/Neptune/Major Moons/Triton",
    Description = "Label for Neptune's moon Triton"
  }
}


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


  openspace.addSceneGraphNode(Triton)
  openspace.addSceneGraphNode(TritonTrail)
  openspace.addSceneGraphNode(TritonLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(TritonLabel)
  openspace.removeSceneGraphNode(TritonTrail)
  openspace.removeSceneGraphNode(Triton)


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

asset.export(Triton)
asset.export(TritonTrail)
asset.export(TritonLabel)



asset.meta = {
  Name = "Triton",
  Version = "1.1",
  Description = [[Globe asset containing Neptune's moon Triton]],
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
