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,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = LorriOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "LORRI",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphLeisa = {
  Identifier = "NH_RALPH_LEISA",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH LEISA",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicPan1 = {
  Identifier = "NH_RALPH_MVIC_PAN1",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC PAN 1",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicPan2 = {
  Identifier = "NH_RALPH_MVIC_PAN2",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC PAN 2",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicRed = {
  Identifier = "NH_RALPH_MVIC_RED",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC RED",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicBlue = {
  Identifier = "NH_RALPH_MVIC_BLUE",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC BLUE",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicFt = {
  Identifier = "NH_RALPH_MVIC_FT",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC FT",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicMethane = {
  Identifier = "NH_RALPH_MVIC_METHANE",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC METHANE",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local RalphMvicNir = {
  Identifier = "NH_RALPH_MVIC_NIR",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RalphOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "RALPH MVIC NIR",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local AliceAirglow = {
  Identifier = "NH_ALICE_AIRGLOW",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = AliceOffset
    }
  },
  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
  },
  GUI = {
    Name = "ALICE AIRGLOW",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local AliceSoc = {
  Identifier = "NH_ALICE_SOC",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = AliceOffset
    }
  },
  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"
    }
  },
  GUI = {
    Name = "ALICE SOC",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}

local Rex = {
  Identifier = "NH_REX",
  Parent = transforms.NewHorizonsPosition.Identifier,
  Transform = {
    Translation = {
      Type = "StaticTranslation",
      Position = RexOffset
    },
    Rotation = {
      Type = "StaticRotation",
      Rotation = { -math.pi / 2, 0.0, -math.pi / 2 }
    }
  },
  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 }
    }
  },
  GUI = {
    Name = "REX",
    Path = "/Solar System/Missions/New Horizons/Instruments"
  }
}


asset.onInitialize(function()
  openspace.addSceneGraphNode(Lorri)
  openspace.addSceneGraphNode(RalphLeisa)
  openspace.addSceneGraphNode(RalphMvicPan1)
  openspace.addSceneGraphNode(RalphMvicPan2)
  openspace.addSceneGraphNode(RalphMvicRed)
  openspace.addSceneGraphNode(RalphMvicBlue)
  openspace.addSceneGraphNode(RalphMvicFt)
  openspace.addSceneGraphNode(RalphMvicMethane)
  openspace.addSceneGraphNode(RalphMvicNir)
  openspace.addSceneGraphNode(AliceAirglow)
  openspace.addSceneGraphNode(AliceSoc)
  openspace.addSceneGraphNode(Rex)
end)

asset.onDeinitialize(function()
  openspace.removeSceneGraphNode(Rex)
  openspace.removeSceneGraphNode(AliceSoc)
  openspace.removeSceneGraphNode(AliceAirglow)
  openspace.removeSceneGraphNode(RalphMvicNir)
  openspace.removeSceneGraphNode(RalphMvicMethane)
  openspace.removeSceneGraphNode(RalphMvicFt)
  openspace.removeSceneGraphNode(RalphMvicBlue)
  openspace.removeSceneGraphNode(RalphMvicRed)
  openspace.removeSceneGraphNode(RalphMvicPan2)
  openspace.removeSceneGraphNode(RalphMvicPan1)
  openspace.removeSceneGraphNode(RalphLeisa)
  openspace.removeSceneGraphNode(Lorri)
end)

asset.export(Lorri)
asset.export(RalphLeisa)
asset.export(RalphMvicPan1)
asset.export(RalphMvicPan2)
asset.export(RalphMvicRed)
asset.export(RalphMvicBlue)
asset.export(RalphMvicFt)
asset.export(RalphMvicMethane)
asset.export(RalphMvicNir)
asset.export(AliceAirglow)
asset.export(AliceSoc)
asset.export(Rex)
