local transforms = asset.require("./transforms")
asset.require("spice/base")
asset.require("./trail")



local labelsPath = asset.syncedResource({
  Name = "Pluto Labels",
  Type = "HttpSynchronization",
  Identifier = "pluto_labels",
  Version = 1
})


local Pluto = {
  Identifier = "Pluto",
  Parent = transforms.PlutoBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "PLUTO",
      Observer = "PLUTO BARYCENTER"
    },
    Rotation = {
      Type = "SpiceRotation",
      SourceFrame = "IAU_PLUTO",
      DestinationFrame = "GALACTIC"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    Radii = { 1173000, 1173000, 1173000 },
    SegmentsPerPatch = 64,
    Layers = {},
    Labels = {
      Enabled = false,
      FileName = labelsPath .. "pluto.labels",
      AlignmentOption = "Horizontally", -- or Circularly
      FontSize = 20.0,
      Size = 8.5,
      FadeInEnabled = true,
      FadeOutEnabled = true,
      FadeDistances = { 650000.0, 4000000.0 },
      DistanceEPS = 500000.0,
      Color = { 1.0, 1.0, 0.0 }
    }
  },
  Tag = { "planet_solarSystem", "planet_terrestrial", "dwarf_planet" },
  GUI = {
    Path = "/Solar System/Dwarf Planets/Pluto"
  }
}

local PlutoLabel = {
  Identifier = "PlutoLabel",
  Parent = Pluto.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabel",
    Text = "Pluto",
    FontSize = 70.0,
    Size = 9.10,
    MinMaxSize = { 1, 100 },
    BlendMode = "Additive",
    OrientationOption = "Camera View Direction",
    EnableFading = true,
    FadeUnit = "au",
    FadeDistances = { 2.0, 120.0 },
    FadeWidths = { 1.0, 150.0 }
  },
  Tag = { "solarsystem_labels" },
  GUI = {
    Name = "Pluto Label",
    Path = "/Solar System/Dwarf Planets/Pluto",
    Description = "Label for Pluto, visible at the solarsystem overview zoom level"
  }
}


asset.onInitialize(function()
  openspace.addSceneGraphNode(Pluto)
  openspace.addSceneGraphNode(PlutoLabel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(PlutoLabel)
  openspace.removeSceneGraphNode(Pluto)
end)

asset.export(Pluto)
asset.export(PlutoLabel)



asset.meta = {
  Name = "Pluto",
  Version = "1.0",
  Description = "Pluto globe, and main planet label",
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
