local sun = asset.require("scene/solarsystem/sun/sun")
local moon_asset = asset.require("scene/solarsystem/planets/earth/moon/moon")



local lem_model = asset.syncedResource({
  Name = "Apollo Lem Models",
  Type = "HttpSynchronization",
  Identifier = "apollo_lem_model",
  Version = 4
})


local Apollo11Lem = {
  Identifier = "Apollo11Lem",
  Parent = moon_asset.Moon.Identifier,
  Transform = {
    Translation = {
      Type = "GlobeTranslation",
      Globe = moon_asset.Moon.Identifier,
      Longitude = -360+23.47306,
      Latitude = 0.67402,
      Altitude = -1927.65,
      UseHeightMap = false
    }
  },
  GUI = {
    Name = "Apollo 11 Lem Position",
    Path = "/Solar System/Missions/Apollo/11"
  }
}

local Apollo11LemModel = {
  Identifier = "Apollo11LemModel",
  Parent = Apollo11Lem.Identifier,
  Transform = {
      Scale = {
      Type = "StaticScale",
      Scale = 0.24
    }
  },
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = lem_model .. "LM-2_ver2clean.obj",
    RotationVector = { 91.044090, 171.229706, 111.666664 },
    LightSources = {
      sun.LightSource,
      {
        Identifier = "Camera",
        Type = "CameraLightSource",
        Intensity = 0.5
      }
    }
  },
  GUI = {
    Name = "Apollo 11 Lem",
    Path = "/Solar System/Missions/Apollo/11"
  }
}


asset.onInitialize(function()
  openspace.addSceneGraphNode(Apollo11Lem)
  openspace.addSceneGraphNode(Apollo11LemModel)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(Apollo11LemModel)
  openspace.removeSceneGraphNode(Apollo11Lem)
end)

asset.export(Apollo11Lem)
asset.export(Apollo11LemModel)
