local textures = asset.syncedResource({
  Name = "Open Clusters Textures",
  Type = "HttpSynchronization",
  Identifier = "digitaluniverse_openclusters_textures",
  Version = 1
})

local speck = asset.syncedResource({
  Name = "Open Clusters Speck Files",
  Type = "HttpSynchronization",
  Identifier = "digitaluniverse_openclusters_speck",
  Version = 3
})


local Object = {
  Identifier = "OpenStarClusters",
  Renderable = {
    Type = "RenderableBillboardsCloud",
    Enabled = false,
    Labels = {
      File = speck .. "oc.label",
      Color = { 0.05, 0.4, 0.2 },
      Size = 15.5,
      MinMaxSize = { 4, 30 },
      Unit = "pc"
    },
    Color = { 0.1, 0.8, 0.4 },
    Opacity = 0.5,
    File = speck .. "oc.speck",
    Unit = "pc",
    Texture = textures .. "point4.png",
    PolygonSides = 12,
    ScaleFactor = 405.75,
    BillboardMinMaxSize = { 0.0, 604.0 },
    EnablePixelSizeControl = true
  },
  GUI = {
    Name = "Open Star Clusters",
    Path = "/Milky Way",
    Description = [[Census: 1,867 clusters. DU Version 7.8. <br> An open star cluster is a
      loose assemblage of stars numbering from hundreds to thousands that are bound by
      their mutual gravitation. Astronomers know from their stellar spectra that stars in
      open clusters are typically young. (With a star's spectrum, we can determine the
      spectral type and the luminosity class, revealing the star's age.) Because these are
      young stars, we expect to see them in the star-forming regions of our Galaxy, namely
      in the spiral arms. For this reason, open clusters exist, for the most part, in the
      plane of the Galaxy, where we view the arms edge-on as that band of light in the
      night sky. Because of this, open clusters were originally known as Galactic
      clusters, but this term fell out of favor once astronomers began to understand that
      the Galaxy includes objects beyond the Milky Way's disk. <br><br> Data Reference:
      Galactic spiral structure revealed by Gaia EDR3 (Poggio+, 2021)]]
  }
}


asset.onInitialize(function()
  openspace.addSceneGraphNode(Object)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(Object)
end)

asset.export(Object)



asset.meta = {
  Name = "Open Star Clusters",
  Version = "2.1",
  Description = "Digital Universe asset for Open Star Clusters",
  Author = "Brian Abbott (AMNH)",
  URL = "https://www.amnh.org/research/hayden-planetarium/digital-universe",
  License = "AMNH Digital Universe"
}
