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

local Sun = {
  Identifier = "Sun",
  Parent = transforms.SunIAU.Identifier,
  Renderable = {
    Type = "RenderableGlobe",
    Enabled = false,
    Radii = { 6.957E8, 6.957E8, 6.957E8 },
    SegmentsPerPatch = 64,
    Layers = {},
    PerformShading = false
  },
  ApproachFactor = 15.0,
  GUI = {
    Name = "Sun",
    Path = "/Solar System/Sun",
    Description = "Globe for the sun in our solar system"
  }
}

local SunLabel = {
  Identifier = "SunLabel",
  Parent = Sun.Identifier,
  Renderable = {
    Enabled = false,
    Type = "RenderableLabels",
    Text = "Sun",
    FontSize = 70.0,
    Size = 14.17,
    MinMaxSize = { 1, 50 },
    OrientationOption = "Camera View Direction",
    BlendMode = "Additive",
    EnableFading = true,
    FadeUnit = "pc",
    FadeDistances = { 1.33, 15.0 },
    FadeWidths = { 1.0, 20.0 }
  },
  Tag = { "solarsystem_labels" },
  GUI = {
    Name = "Sun Label",
    Path = "/Solar System/Sun",
    Description = "Label for the sun in our solar system"
  }
}

local LightSource = {
  Type = "SceneGraphLightSource",
  Identifier = "Sun",
  Node = transforms.SolarSystemBarycenter.Identifier,
  Intensity = 1.0
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(Sun)
  openspace.addSceneGraphNode(SunLabel)
end)
    
asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(SunLabel)
  openspace.removeSceneGraphNode(Sun)
end)
    
asset.export(Sun)
asset.export(SunLabel)
asset.export("LightSource", LightSource)



asset.meta = {
  Name = "Sun",
  Version = "1.1",
  Description = "The Sun and label",
  Author = "OpenSpace Team",
  URL = "http://openspaceproject.com",
  License = "MIT license"
}
