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

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

local Venus = {
  Identifier = "Venus",
  Parent = transforms.VenusBarycenter.Identifier,
  Transform = {
    Translation = {
      Type = "SpiceTranslation",
      Target = "VENUS",
      Observer = "VENUS BARYCENTER"
    },
    Rotation = {
      Type = "SpiceRotation",
      SourceFrame = "IAU_VENUS",
      DestinationFrame = "GALACTIC"
    },
    Translation = {
      Type = "SpiceTranslation",
      Target = "VENUS",
      Observer = "VENUS BARYCENTER"
    }
  },
  Renderable = {
    Type = "RenderableGlobe",
    --Radii = { 6051900.0, 6051900.0, 6051800.0 },
    Radii = { 6051900.0, 6051900.0, 6051900.0 },
    SegmentsPerPatch = 64,
    Layers = {},
    Labels = {
      Enabled = false,
      FileName = labelsPath .. "venus.labels",
      AlignmentOption = "Horizontally", -- or Circularly
      FontSize = 20.0,
      Size = 11.0,
      FadeInEnabled = true,
      FadeOutEnabled = true,
      FadeDistances = { 2000000.0, 7000000.0 },
      DistanceEPS = 4000000.0,
      Color = { 1.0, 1.0, 0.0 }
    }
  },
  Tag = { "planet_solarSystem", "planet_terrestrial" },
  GUI = {
    Name = "Venus",
    Path = "/Solar System/Planets/Venus",
    Description = "Venus globe with labels and map layers"
  }
}

local VenusLabel = {
  Identifier = "VenusLabel",
  Parent = Venus.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabels",
    Text = "Venus",
    FontSize = 70.0,
    Size = 8.54,
    MinMaxSize = { 1, 100 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive"
  },
  Tag = { "solarsystem_labels" },
  GUI = {
      Name = "Venus Label",
      Path = "/Solar System/Planets/Venus",
      Description = "Label for Venus, viewable within the solar system"
  }
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(Venus)
  openspace.addSceneGraphNode(VenusLabel)
end)
    
asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(VenusLabel)
  openspace.removeSceneGraphNode(Venus)
end)
    
asset.export(Venus)
asset.export(VenusLabel)



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