mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 12:39:24 -05:00
8d7d8b9ba4
* Fix script error in old state machine example * Add a module with a more complex state machine, that can be created and controlled through the Lua API. Useful for interactive installations * Add an example asset for the new state machine and rename the old linear "state machine" to luastatemachine Co-authored-by: Malin Ejdbo <malin.ejdbo@gmail.com>
48 lines
1.3 KiB
Lua
48 lines
1.3 KiB
Lua
local stateMachineHelper = asset.require('util/lua_state_machine_helper')
|
|
|
|
local states = {
|
|
{
|
|
Title = "Highlight EarthTrail",
|
|
Play = function ()
|
|
openspace.setPropertyValue("Scene.EarthTrail.Renderable.Appearance.LineWidth", 10, 1)
|
|
end,
|
|
Rewind = function ()
|
|
openspace.setPropertyValue("Scene.EarthTrail.Renderable.Appearance.LineWidth", 2, 1)
|
|
end
|
|
},
|
|
{
|
|
Title = "Highlight MarsTrail",
|
|
Play = function ()
|
|
openspace.setPropertyValue("Scene.EarthTrail.Renderable.Appearance.LineWidth", 2, 1)
|
|
openspace.setPropertyValue("Scene.MarsTrail.Renderable.Appearance.LineWidth", 10, 1)
|
|
end,
|
|
Rewind = function ()
|
|
openspace.setPropertyValue("Scene.MarsTrail.Renderable.Appearance.LineWidth", 2, 1)
|
|
openspace.setPropertyValue("Scene.EarthTrail.Renderable.Appearance.LineWidth", 10, 1)
|
|
end
|
|
}
|
|
}
|
|
|
|
local stateMachine
|
|
|
|
function next()
|
|
stateMachine.goToNextState()
|
|
end
|
|
|
|
function previous()
|
|
stateMachine.goToPreviousState()
|
|
end
|
|
|
|
asset.onInitialize(function ()
|
|
stateMachine = stateMachineHelper.createStateMachine(states)
|
|
openspace.bindKey('RIGHT', 'next()')
|
|
openspace.bindKey('LEFT', 'previous()')
|
|
end)
|
|
|
|
|
|
asset.onDeinitialize(function ()
|
|
stateMachine = nil
|
|
openspace.clearKey('RIGHT')
|
|
openspace.clearKey('LEFT')
|
|
end)
|