merge with master

This commit is contained in:
ElonOlsson
2021-10-14 11:07:01 -04:00
104 changed files with 2824 additions and 369 deletions

View File

@@ -0,0 +1,105 @@
local toggle_trail = {
Identifier = "os.toggle_trail",
Name = "Toggle Trail",
Command = [[
local node
if is_declared("args") then
node = args.Node
else
node = openspace.navigation.getNavigationState().Anchor
end
local trail
if openspace.hasSceneGraphNode(node .. "Trail") then
trail = node .. "Trail"
elseif openspace.hasSceneGraphNode(node .. "_trail") then
trail = node .. "_trail"
else
-- No trail found, so nothing more to do here
return
end
local visibility
if is_declared("args") then
if args.Transition == "Approaching" then
visibility = false
elseif args.Transition == "Exiting" then
visibility = true
else
return
end
else
visibility = not openspace.getPropertyValue("Scene." .. trail .. ".Renderable.Enabled")
end
openspace.setPropertyValueSingle("Scene." .. trail .. ".Renderable.Enabled", visibility)
]],
Documentation = [[Toggles the visibility of the associated trail of a scene graph node.
This action takes optional arguments to 1) determine which trail to hide (as the
'Node') and 2) the transition direction (as 'After' and 'Before').]],
GuiPath = "/Trails",
IsLocal = true
}
asset.export("toggle_trail", toggle_trail.Identifier)
local hide_trail = {
Identifier = "os.hide_trail",
Name = "Hide Trail",
Command = [[
local node
if is_declared("args") then
node = args.Node
else
node = openspace.navigation.getNavigationState().Anchor
end
if openspace.hasSceneGraphNode(node .. "Trail") then
openspace.setPropertyValue("Scene." .. node .. "Trail.Renderable.Enabled", false)
elseif openspace.hasSceneGraphNode(node .. "_trail") then
openspace.setPropertyValue("Scene." .. node .. "_trail.Renderable.Enabled", false)
end
]],
Documentation = [[Hides the associated trail of a scene graph node. This action takes an
optional argument to determine whose trail to hide. If no argument is provided, the
current focus node is used instead]],
GuiPath = "/Trails",
IsLocal = true
}
asset.export("hide_trail", hide_trail.Identifier)
local show_trail = {
Identifier = "os.show_trail",
Name = "Show Trail",
Command = [[
local node
if is_declared("args") then
node = args.Node
else
node = openspace.navigation.getNavigationState().Anchor
end
if openspace.hasSceneGraphNode(node .. "Trail") then
openspace.setPropertyValue("Scene." .. node .. "Trail.Renderable.Enabled", true)
elseif openspace.hasSceneGraphNode(node .. "_trail") then
openspace.setPropertyValue("Scene." .. node .. "_trail.Renderable.Enabled", true)
end
]],
Documentation = [[Shows the associated trail of a scene graph node. This action takes an
optional argument to determine whose trail to hide. If no argument is provided, the
current focus node is used instead]],
GuiPath = "/Trails",
IsLocal = true
}
asset.export("show_trail", show_trail.Identifier)
asset.onInitialize(function()
openspace.action.registerAction(toggle_trail)
openspace.action.registerAction(show_trail)
openspace.action.registerAction(hide_trail)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(toggle_trail.Identifier)
openspace.action.removeAction(show_trail.Identifier)
openspace.action.removeAction(hide_trail.Identifier)
end)

View File

@@ -0,0 +1,27 @@
local action = asset.require('actions/toggle_trail')
asset.onInitialize(function()
openspace.event.registerEventAction(
"CameraFocusTransition",
action.show_trail,
{ Transition = "Exiting" }
);
openspace.event.registerEventAction(
"CameraFocusTransition",
action.hide_trail,
{ Transition = "Approaching" }
);
end)
asset.onDeinitialize(function()
openspace.event.unregisterEventAction(
"CameraFocusTransition",
action.show_trail,
{ Transition = "Exiting" }
);
openspace.event.unregisterEventAction(
"CameraFocusTransition",
action.hide_trail,
{ Transition = "Approaching" }
);
end)

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)