local transforms = asset.require("./transforms")



local LorriOffset = { -6.626, -4.1, -3.23 }
local RalphOffset = {   -6.9, -4.6,  8.7  }
local AliceOffset = {   -7.9, -1.7,  8.3  }
local RexOffset   = {      0,    0,    0  }

local Lorri = {
  Identifier = "NH_LORRI",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    Color = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_LORRI",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = LorriOffset
    }
  },
  GUI = {
    Name = "LORRI",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphLeisa = {
  Identifier = "NH_RALPH_LEISA",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_LEISA",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH LEISA",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicPan1 = {
  Identifier = "NH_RALPH_MVIC_PAN1",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_PAN1",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC PAN 1",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicPan2 = {
  Identifier = "NH_RALPH_MVIC_PAN2",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_PAN2",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC PAN 2",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicRed = {
  Identifier = "NH_RALPH_MVIC_RED",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_RED",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC RED",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicBlue = {
  Identifier = "NH_RALPH_MVIC_BLUE",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_BLUE",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC BLUE",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicFt = {
  Identifier = "NH_RALPH_MVIC_FT",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_FT",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC FT",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicMethane = {
  Identifier = "NH_RALPH_MVIC_METHANE",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_METHANE",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC METHANE",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicNir = {
  Identifier = "NH_RALPH_MVIC_NIR",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_RALPH_MVIC_NIR",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  GUI = {
    Name = "RALPH MVIC NIR",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local AliceAirglow = {
  Identifier = "NH_ALICE_AIRGLOW",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_ALICE_AIRGLOW",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    },
    SimplifyBounds = true
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = AliceOffset
    }
  },
  GUI = {
    Name = "ALICE AIRGLOW",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local AliceSoc = {
  Identifier = "NH_ALICE_SOC",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableFov",
    Body  = "NEW HORIZONS",
    Frame = "NH_SPACECRAFT",
    RGB   = { 0.8, 0.7, 0.7 },
    Instrument = {
      Name       = "NH_ALICE_SOC",
      Aberration = "NONE"
    },
    PotentialTargets = {
      "Pluto",
      "Charon",
      -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto"
    }
  },
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = AliceOffset
    }
  },
  GUI = {
    Name = "ALICE SOC",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local Rex = {
  Identifier = "NH_REX",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Renderable = {
    Type  = "RenderableCrawlingLine",
    Source = "NH_REX",
    Target = "EARTH",
    Instrument = "NH_REX",
    Color = {
      Start = { 1.0, 0.7, 0.0, 1.0 },
      End = { 0.0, 0.0, 0.0, 0.0 }
    }
  },
  Transform = {
    Rotation = {
      Type = "StaticRotation",
      Rotation = { -math.pi/2, 0.0, -math.pi/2 }
    },
    Translation = {
      Type = "StaticTranslation",
      Position = RexOffset
    }
  },
  GUI = {
    Name = "REX",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local nodes = {
  Lorri,
  RalphLeisa,
  RalphMvicPan1,
  RalphMvicPan2,
  RalphMvicRed,
  RalphMvicBlue,
  RalphMvicFt,
  RalphMvicMethane,
  RalphMvicNir,
  AliceAirglow,
  AliceSoc,
  Rex
}

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
