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

local models = asset.syncedResource({
  Name = "Apollo Boulders Models",
  Type = "HttpSynchronization",
  Identifier = "apollo_boulders",
  Version = 2
})

local Station2Boulder1Holder = {
  Identifier = "Station_2_Boulder1",
  Parent = moon_asset.Moon.Identifier,
  Transform = {
    Translation = {
      Type = "GlobeTranslation",
      Globe = moon_asset.Moon.Identifier,
      Longitude = -360+30.5294692,
      Latitude = 20.098824,
      Altitude = -2442.8,
      UseHeightMap = false
    }
  },
  GUI = {
    Name = "Station 2 Boulder 1",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local Station2Boulder1Model = {
  Identifier = "Station2Boulder1Model",
  Parent = Station2Boulder1Holder.Identifier,
  Transform = {
    Scale = {
      Type = "StaticScale",
      Scale = 0.06
    }
  },
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "b1-v2.obj",
    RotationVector = { 243.243256 ,206.270264, 309.677429 },
    LightSources = {
      sun.LightSource,
      {
        Identifier = "Camera",
        Type = "CameraLightSource",
        Intensity = 0.5
      }
    },
    PerformShading = false,
    DisableFaceCulling = true
  },
  GUI = {
    Name = "Station 2 Boulder 1 Model",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local Station2Boulder2Holder = {
  Identifier = "Station_2_Boulder2",
  Parent = moon_asset.Moon.Identifier,
  Transform = {
    Translation = {
      Type = "GlobeTranslation",
      Globe = moon_asset.Moon.Identifier,
      Longitude = -360+30.5287892,
      Latitude = 20.098240,
      Altitude = -2434.6,
      UseHeightMap = false
    }
  },
  GUI = {
    Name = "Station 2 Boulder 2",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local Station2Boulder2Model = {
  Identifier = "Station2Boulder2Model",
  Parent = Station2Boulder2Holder.Identifier,
  Transform = {
    Scale = {
      Type = "StaticScale",
      Scale = 0.06
    }
  },
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "b2model.obj",
    RotationVector = { 66.162155, 7.783780, 114.193550 },
    LightSources = {
      sun.LightSource,
      {
        Identifier = "Camera",
        Type = "CameraLightSource",
        Intensity = 0.5
      }
    },
    PerformShading = false,
    DisableFaceCulling = true
  },
  GUI = {
    Name = "Station 2 Boulder 2 Model",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local Station2Boulder3Holder = {
  Identifier = "Station_2_Boulder3",
  Parent = moon_asset.Moon.Identifier,
  Transform = {
    Translation = {
      Type = "GlobeTranslation",
      Globe = moon_asset.Moon.Identifier,
      Longitude = -360+30.5294692,
      Latitude = 20.098610,
      Altitude = -2441.55,
      UseHeightMap = false
    }
  },
  GUI = {
    Name = "Station 2 Boulder 3",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local Station2Boulder3Model = {
  Identifier = "Station2Boulder3Model",
  Parent = Station2Boulder3Holder.Identifier,
  Transform = {
    Scale = {
      Type = "StaticScale",
      Scale = 0.06
    }
  },
  Renderable = {
    Type = "RenderableModel",
    GeometryFile = models .. "b3model.obj",
    RotationVector = { 161.513519 ,243.243256, 65.806450 },
    LightSources = {
      sun.LightSource,
      {
        Identifier = "Camera",
        Type = "CameraLightSource",
        Intensity = 0.5
      }
    },
    PerformShading = false,
    DisableFaceCulling = true
  },
  GUI = {
    Name = "Station 2 Boulder 3 Model",
    Path = "/Solar System/Missions/Apollo/17/Station 2"
  }
}

local nodes = {
  Station2Boulder1Holder, Station2Boulder1Model,
  Station2Boulder2Holder, Station2Boulder2Model,
  Station2Boulder3Holder, Station2Boulder3Model
}

asset.onInitialize(function()
  for i, node in ipairs(nodes) do
    openspace.addSceneGraphNode(node)
  end
end)
  
asset.onDeinitialize(function()
  for i = #nodes, 1, -1 do
    local node = nodes[i]
    openspace.removeSceneGraphNode(node)
  end
end)

for i, node in ipairs(nodes) do
  asset.export(node)
end
