mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-03 18:19:38 -06:00
Introduce the ability to navigate using an anchor and aim. Example use: Set spacecraft as anchor and planet as aim to always look down at a planet, while followin the spacecraft in its orbit.
112 lines
4.2 KiB
Plaintext
112 lines
4.2 KiB
Plaintext
local assetHelper = asset.require('util/asset_helper')
|
|
local sceneHelper = asset.require('util/scene_helper')
|
|
local propertyHelper = asset.require('util/property_helper')
|
|
|
|
-- Specifying which other assets should be loaded in this scene
|
|
asset.require('spice/base')
|
|
assetHelper.requestAll(asset, 'scene/solarsystem/sun')
|
|
asset.require('scene/solarsystem/planets')
|
|
asset.require('scene/solarsystem/planets/mars/moons/phobos')
|
|
asset.require('scene/solarsystem/planets/mars/moons/deimos')
|
|
asset.require('scene/solarsystem/dwarf_planets/pluto/system')
|
|
assetHelper.requestAll(asset, 'scene/digitaluniverse')
|
|
-- Load default key bindings applicable to most scenes
|
|
asset.require('util/default_keybindings')
|
|
asset.require('util/default_dashboard')
|
|
asset.require('util/default_joystick')
|
|
|
|
asset.require('util/webgui')
|
|
|
|
asset.request('customization/globebrowsing')
|
|
|
|
-- Keybindings that are specific for this scene
|
|
local Keybindings = {
|
|
{
|
|
Key = "s",
|
|
Command = propertyHelper.invert('Scene.Earth.Renderable.Layers.NightLayers.Earth at Night 2012.Enabled') ..
|
|
propertyHelper.invert('Scene.Earth.Renderable.PerformShading') ..
|
|
propertyHelper.invert('Scene.Earth.Renderable.Atmosphere') ..
|
|
propertyHelper.invert('Scene.Earth.Renderable.Layers.WaterMasks.MODIS_Water_Mask.Enabled'),
|
|
Name = "Night for earth",
|
|
Documentation = "Toggle night texture, shading, atmosphere, and water for Earth.",
|
|
GuiPath = "/Rendering",
|
|
Local = false
|
|
},
|
|
{
|
|
Key = "b",
|
|
Name = "Toggle background",
|
|
Command = propertyHelper.invert('Scene.MilkyWay.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.Stars.Renderable.Enabled'),
|
|
Documentation = "Toggle background (Stars and Milkyway).",
|
|
GuiPath = "/Rendering",
|
|
Local = false
|
|
},
|
|
{
|
|
Key = "g",
|
|
Name = "Toggle background/shading",
|
|
Command = propertyHelper.invert('Scene.MilkyWay.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.Stars.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Enabled') ..
|
|
propertyHelper.invert('Scene.EarthAtmosphere.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.MarsAtmosphere.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.Earth.Renderable.Layers.WaterMasks.MODIS_Water_Mask.Enabled') ..
|
|
propertyHelper.invert('Scene.Moon.Renderable.Enabled') ..
|
|
propertyHelper.invert('Scene.Sun.Renderable.Enabled'),
|
|
Documentation = "Toogles background and shading mode on the Earth and Mars alongside visibility of the Moon and the Sun",
|
|
GuiPath = "/Rendering",
|
|
Local = false
|
|
},
|
|
{
|
|
Key = "h",
|
|
Name="Hide Trails",
|
|
Command = "openspace.setPropertyValue('Scene.*Trail.Renderable.Enabled', false)",
|
|
Documentation = "Disables visibility of the trails",
|
|
GuiPath = "/Rendering",
|
|
Local = false
|
|
},
|
|
}
|
|
|
|
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
|
|
|
|
assetHelper.registerInterestingNodes(asset, {
|
|
"Earth", "Mars", "Moon", "Sun"
|
|
})
|
|
|
|
asset.onInitialize(function ()
|
|
local now = openspace.time.currentWallTime()
|
|
-- Jump back one day to show a complete planet
|
|
openspace.time.setTime(openspace.time.advancedTime(now, "-1d"))
|
|
|
|
sceneHelper.bindKeys(Keybindings)
|
|
|
|
openspace.setDefaultGuiSorting()
|
|
|
|
openspace.globebrowsing.loadWMSServersFromFile(
|
|
openspace.absPath("${DATA}/globebrowsing_servers.lua")
|
|
)
|
|
|
|
openspace.addVirtualProperty(
|
|
"BoolProperty",
|
|
"Show Trails",
|
|
"Scene.*Trail.Renderable.Enabled",
|
|
"Disable or enable all trails of the scene at the same time",
|
|
true,
|
|
nil,
|
|
nil
|
|
)
|
|
|
|
openspace.navigation.setCameraState({
|
|
Anchor = earthAsset.Earth.Identifier,
|
|
Position = { 0, 0, 0 },
|
|
Rotation = { 0.758797, 0.221490, -0.605693, -0.091135 },
|
|
})
|
|
|
|
openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000)
|
|
end)
|
|
|
|
asset.onDeinitialize(function ()
|
|
sceneHelper.unbindKeys(Keybindings)
|
|
|
|
openspace.removeVirtualProperty("*Trail.Renderable.Enabled")
|
|
end)
|