Event System (#1741)

* Add implementation of the EventEngine to handle global event chains
* Add properties to SceneGraphNodes to determine two distance radii for camera-based events
This commit is contained in:
Alexander Bock
2021-10-11 21:53:00 +02:00
committed by GitHub
parent d230675181
commit 76dd45e5ce
36 changed files with 2176 additions and 59 deletions
+68
View File
@@ -0,0 +1,68 @@
local assetHelper = asset.require('util/asset_helper')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local transforms = asset.require('scene/solarsystem/planets/earth/transforms')
local generic_action = {
Identifier = "os.example.generic",
Name = "Generic Example",
Command = [[
openspace.printInfo("Node: " .. args.Node)
openspace.printInfo("Transition: " .. args.Transition)
]],
Documentation = "Prints the argument information for camera transitions to the log",
GuiPath = "/Examples/Events",
IsLocal = true
}
local model = asset.syncedResource({
Name = "Animated Box",
Type = "HttpSynchronization",
Identifier = "animated_box",
Version = 1
})
local obj = {
Identifier = "ExampleEventModel",
Parent = transforms.EarthCenter.Identifier,
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 0.0, 11E7, 0.0 }
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = model .. "/BoxAnimated.glb",
ModelScale = 1.0,
LightSources = {
{
Type = "SceneGraphLightSource",
Identifier = "Sun",
Node = sunTransforms.SolarSystemBarycenter.Identifier,
Intensity = 1.0
}
},
PerformShading = true,
DisableFaceCulling = true
},
InteractionSphere = 1000.0,
OnApproach = { "os.example.generic" },
OnReach = { "os.example.generic" },
OnRecede = { "os.example.generic" },
OnExit = { "os.example.generic" },
GUI = {
Name = "Example Event Model",
Path = "/Example",
Description = "",
}
}
asset.onInitialize(function()
openspace.action.registerAction(generic_action)
openspace.addSceneGraphNode(obj)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(obj.Identifier)
openspace.action.removeAction(generic_action.Identifier)
end)