-
Notifications
You must be signed in to change notification settings - Fork 0
/
hackathon.scene
91 lines (76 loc) · 2.97 KB
/
hackathon.scene
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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')
-- Load default key bindings applicable to most scenes
asset.require('util/default_keybindings')
asset.require('util/default_dashboard')
asset.require('util/default_joystick')
asset.request('customization/globebrowsing')
-- Keybindings that are specific for this scene
local Keybindings = {
{
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.MarsAtmosphere.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 marsAsset = asset.require('scene/solarsystem/planets/mars/mars')
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({
Focus = marsAsset.Mars.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)