-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_VOLUME enabled

-- Before using this example,
-- the volume data itself needs to be generated,
-- using the task 'data/tasks/volume/generate_cartesian_sequence.task'

local transforms = asset.require("scene/solarsystem/sun/transforms")

local sunRadius = 695508000

local volume = {
  Identifier = "GeneratedVolume",
  Parent = transforms.SolarSystemBarycenter.Identifier,
  Renderable = {
    Type = "RenderableTimeVaryingVolume",
    SourceDirectory = asset.localResource("cartesiansequence"),
    TransferFunction = asset.localResource("../transferfunction.txt"),
    StepSize = 0.01,
    MinValue = 0,
    MaxValue = 1,
    GridType = "Cartesian",
    SecondsBefore = 50*365*24*60*60, -- 50 years before
    SecondsAfter = 50*365*24*60*60 -- 50 years after
  },
  GUI = {
    Path = "/Examples"
  },
  Transform = {
    Scale = {
      Type = "StaticScale",
      Scale = 1000 * sunRadius
    }
  }
}

asset.onInitialize(function()
  openspace.addSceneGraphNode(volume)
end)
  
asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(volume)
end)

asset.export(volume)
