local bookmarkHelper = asset.require("util/generate_bookmarks")

local dataProvider = "http://data.openspaceproject.com/files/bookmarks/v1/bookmarks.csv"

local bookmarksCSV = asset.syncedResource({
  Identifier = "openspace_bookmarks",
  Name = "OpenSpace Bookmarks",
  Type = "UrlSynchronization",
  UseHash = false,
  Override = true,
  Url = dataProvider
})

local nodes = {}

asset.onInitialize(function ()
  nodes = bookmarkHelper.getBookmarks("OpenSpace Bookmarks", bookmarksCSV .. "bookmarks.csv")
  for _, n in ipairs(nodes) do
    openspace.addSceneGraphNode(n);
  end
end)

asset.onDeinitialize(function ()
  for _, n in ipairs(nodes) do
    openspace.removeSceneGraphNode(n);
  end
end)

for _, n in ipairs(nodes) do
  asset.export(n);
end