diff --git a/data/assets/default.scene b/data/assets/default.scene index 364d38fcab..af3d3ae439 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -1,5 +1,6 @@ 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') @@ -18,31 +19,31 @@ asset.request('customization/globebrowsing') local Keybindings = { { Key = "s", - Command = sceneHelper.property.invert('Earth.RenderableGlobe.Layers.NightLayers.Earth at Night 2012.Enabled') .. - sceneHelper.property.invert('Earth.RenderableGlobe.PerformShading') .. - sceneHelper.property.invert('Earth.RenderableGlobe.Atmosphere') .. - sceneHelper.property.invert('Earth.RenderableGlobe.Layers.WaterMasks.MODIS_Water_Mask.Enabled'), + Command = propertyHelper.invert('Scene.Earth.RenderableGlobe.Layers.NightLayers.Earth at Night 2012.Enabled') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.PerformShading') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.Atmosphere') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.Layers.WaterMasks.MODIS_Water_Mask.Enabled'), Documentation = "Toggle night texture, shading, atmosphere, and water for Earth.", Local = false }, { Key = "b", - Command = sceneHelper.property.invert('MilkyWay.renderable.Enabled') .. - sceneHelper.property.invert('Stars.renderable.Enabled'), + Command = propertyHelper.invert('Scene.MilkyWay.renderable.Enabled') .. + propertyHelper.invert('Scene.Stars.renderable.Enabled'), Documentation = "Toggle background (Stars and Milkyway).", Local = false }, { Key = "g", - Command = sceneHelper.property.invert('MilkyWay.renderable.Enabled') .. - sceneHelper.property.invert('Stars.renderable.Enabled') .. - sceneHelper.property.invert('Earth.RenderableGlobe.Layers.NightLayers.Earth at Night 2012.Enabled') .. - sceneHelper.property.invert('Earth.RenderableGlobe.PerformShading') .. - sceneHelper.property.invert('Mars.RenderableGlobe.PerformShading') .. - sceneHelper.property.invert('Earth.RenderableGlobe.Atmosphere') .. - sceneHelper.property.invert('Earth.RenderableGlobe.Layers.WaterMasks.MODIS_Water_Mask.Enabled') .. - sceneHelper.property.invert('Moon.RenderableGlobe.Enabled') .. - sceneHelper.property.invert('Sun.renderable.Enabled'), + Command = propertyHelper.invert('Scene.MilkyWay.renderable.Enabled') .. + propertyHelper.invert('Scene.Stars.renderable.Enabled') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.Layers.NightLayers.Earth at Night 2012.Enabled') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.PerformShading') .. + propertyHelper.invert('Scene.Mars.RenderableGlobe.PerformShading') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.Atmosphere') .. + propertyHelper.invert('Scene.Earth.RenderableGlobe.Layers.WaterMasks.MODIS_Water_Mask.Enabled') .. + propertyHelper.invert('Scene.Moon.RenderableGlobe.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", Local = false }, diff --git a/data/assets/newhorizons.scene b/data/assets/newhorizons.scene index fb2e606c93..3b109a3a34 100644 --- a/data/assets/newhorizons.scene +++ b/data/assets/newhorizons.scene @@ -1,5 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local sceneHelper = asset.require('util/scene_helper') +local propertyHelper = asset.require('util/property_helper') +local renderableHelper = asset.require('util/renderable_helper') -- Specifying which other assets should be loaded in this scene asset.require('spice/base') @@ -34,94 +36,94 @@ local Keybindings = { }, { Key = "F8", - Command = "openspace.setPropertyValue('Pluto.renderable.ProjectionComponent.ClearAllProjections', true);" .. - "openspace.setPropertyValue('Charon.renderable.ProjectionComponent.ClearAllProjections', true);", + Command = "openspace.setPropertyValue('Scene.Pluto.renderable.ProjectionComponent.ClearAllProjections', true);" .. + "openspace.setPropertyValue('Scene.Charon.renderable.ProjectionComponent.ClearAllProjections', true);", Documentation = "Removes all image projections from Pluto and Charon.", Local = false }, { Key = "F9", Command = "openspace.time.setTime('2015-07-14T09:00:00.00');" .. - "openspace.setPropertyValue('Pluto.renderable.ClearAllProjections', true);" .. - "openspace.setPropertyValue('Charon.renderable.ClearAllProjections', true);", + "openspace.setPropertyValue('Scene.Pluto.renderable.ClearAllProjections', true);" .. + "openspace.setPropertyValue('Scene.Charon.renderable.ClearAllProjections', true);", Documentation = "Jumps to the 14th of July 2015 at 0900 UTC and clears all projections.", Local = false }, { Key = "KP_8", - Command = sceneHelper.property.increment('Pluto.renderable.HeightExaggeration', 5000000), + Command = propertyHelper.increment('Scene.Pluto.renderable.HeightExaggeration', 5000000), Documentation = "Increases the height map exaggeration on Pluto.", Local = false }, { Key = "KP_2", - Command = sceneHelper.property.decrement('Pluto.renderable.HeightExaggeration', 5000000), + Command = propertyHelper.decrement('Scene.Pluto.renderable.HeightExaggeration', 5000000), Documentation = "Decreases the height map exaggeration on Pluto.", Local = false }, { Key = "KP_9", - Command = sceneHelper.property.increment('Charon.renderable.HeightExaggeration', 5000000), + Command = propertyHelper.increment('Scene.Charon.renderable.HeightExaggeration', 5000000), Documentation = "Increases the height map exaggeration on Charon.", Local = false }, { Key = "KP_3", - Command = sceneHelper.property.decrement('Charon.renderable.HeightExaggeration', 5000000), + Command = propertyHelper.decrement('Scene.Charon.renderable.HeightExaggeration', 5000000), Documentation = "Decreases the height map exaggeration on Charon.", Local = false }, { Key = "q", - Command = sceneHelper.property.invert('SunMarker.renderable.Enabled'), + Command = propertyHelper.invert('Scene.SunMarker.renderable.Enabled'), Documentation = "Toggles the visibility of the text marking the location of the Sun.", Local = false }, { Key = "e", - Command = sceneHelper.property.invert('EarthMarker.renderable.Enabled'), + Command = propertyHelper.invert('Scene.EarthMarker.renderable.Enabled'), Documentation = "Toggles the visibility of the text marking the location of the Earth.", Local = false }, { Key = "o", - Command = sceneHelper.property.invert('PlutoTrail.renderable.Enabled'), + Command = propertyHelper.invert('Scene.PlutoTrail.renderable.Enabled'), Documentation = "Toggles the visibility of the trail behind Pluto.", Local = false }, { Key = "j", - Command = sceneHelper.renderable.toggle('PlutoText') .. sceneHelper.renderable.toggle('CharonText') .. - sceneHelper.renderable.toggle('HydraText') .. sceneHelper.renderable.toggle('NixText') .. - sceneHelper.renderable.toggle('KerberosText') .. sceneHelper.renderable.toggle('StyxText'), + Command = renderableHelper.toggle('Scene.PlutoText') .. renderableHelper.toggle('Scene.CharonText') .. + renderableHelper.toggle('Scene.HydraText') .. renderableHelper.toggle('Scene.NixText') .. + renderableHelper.toggle('Scene.KerberosText') .. renderableHelper.toggle('Scene.StyxText'), Documentation = "Toggles the visibility of the text labels of Pluto, Charon, Hydra, Nix, Kerberos, and Styx.", Local = false }, { Key = "l", - Command = sceneHelper.property.invert('Labels.renderable.Enabled'), + Command = propertyHelper.invert('Scene.Labels.renderable.Enabled'), Documentation = "Toggles the visibility of the labels for the New Horizons instruments.", Local = false }, { Key = "m", - Command = sceneHelper.property.invert('NH_LORRI.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_LEISA.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_PAN1.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_PAN2.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_RED.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_BLUE.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_FT.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_METHANE.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_RALPH_MVIC_NIR.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_ALICE_AIRGLOW.renderable.SolidDraw') .. - sceneHelper.property.invert('NH_ALICE_SOC.renderable.SolidDraw'), + Command = propertyHelper.invert('Scene.NH_LORRI.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_LEISA.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_PAN1.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_PAN2.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_RED.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_BLUE.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_FT.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_METHANE.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_RALPH_MVIC_NIR.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_ALICE_AIRGLOW.renderable.SolidDraw') .. + propertyHelper.invert('Scene.NH_ALICE_SOC.renderable.SolidDraw'), Documentation = "Draws the instrument field of views in a solid color or as lines.", Local = false }, { Key = "t", - Command = sceneHelper.renderable.toggle('PlutoShadow') .. sceneHelper.renderable.toggle('CharonShadow'), + Command = renderableHelper.toggle('Scene.PlutoShadow') .. renderableHelper.toggle('Scene.CharonShadow'), Documentation = "Toggles the visibility of the shadow visualization of Pluto and Charon.", Local = false } diff --git a/data/assets/osirisrex.scene b/data/assets/osirisrex.scene index 556981a006..98a30d82b0 100644 --- a/data/assets/osirisrex.scene +++ b/data/assets/osirisrex.scene @@ -1,5 +1,6 @@ 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') @@ -64,13 +65,13 @@ local Keybindings = { }, { Key = "q", - Command = sceneHelper.property.invert('SunMarker.renderable.Enabled'), + Command = propertyHelper.invert('Scene.SunMarker.renderable.Enabled'), Documentation = "Toggles the visibility of the text marking the location of the Sun.", Local = false }, { Key = "e", - Command = sceneHelper.property.invert('EarthMarker.renderable.Enabled'), + Command = propertyHelper.invert('Scene.EarthMarker.renderable.Enabled'), Documentation = "Toggles the visibility of the text marking the location of the Earth.", Local = false } diff --git a/data/assets/rosetta.scene b/data/assets/rosetta.scene index 93f37fa291..b4fe3750e1 100644 --- a/data/assets/rosetta.scene +++ b/data/assets/rosetta.scene @@ -1,5 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local sceneHelper = asset.require('util/scene_helper') +local propertyHelper = asset.require('util/property_helper') +local renderableHelper = asset.require('util/renderable_helper') -- Specifying which other assets should be loaded in this scene asset.require('spice/base') @@ -41,38 +43,38 @@ local Keybindings = { }, { Key = "F8", - Command = "openspace.setPropertyValue('67P.renderable.ProjectionComponent.clearAllProjections', true)", + Command = "openspace.setPropertyValue('Scene.67P.renderable.ProjectionComponent.clearAllProjections', true)", Documentation = "Removes all image projections from 67P.", Local = false }, { Key = "q", - Command = sceneHelper.property.invert('SunMarker.renderable.Enabled'), + Command = propertyHelper.invert('Scene.SunMarker.renderable.Enabled'), Documentation = "Toggles the visibility of the text marking the location of the Sun.", Local = false }, { Key = "e", - Command = helper.renderable.toggle('JupiterTrail') .. helper.renderable.toggle('SaturnTrail') .. - helper.renderable.toggle('UranusTrail') .. helper.renderable.toggle('NeptuneTrail'), + Command = renderableHelper.toggle('Scene.JupiterTrail') .. renderableHelper.toggle('Scene.SaturnTrail') .. + renderableHelper.toggle('Scene.UranusTrail') .. renderableHelper.toggle('Scene.NeptuneTrail'), Documentation = "Toggles the visibility of all trails further from the Sun than 67P.", Local = false }, { Key = "i", - Command = sceneHelper.renderable.toggle('ImagePlaneRosetta'), + Command = renderableHelper.toggle('Scene.ImagePlaneRosetta'), Documentation = "Toggles the visibility of the free floating image plane.", Local = false }, { Key = "f", - Command = sceneHelper.renderable.toggle('PhilaeTrail'), + Command = renderableHelper.toggle('Scene.PhilaeTrail'), Documentation = "Toggles the visibility of Philae's trail.", Local = false }, { Key = "p", - Command = sceneHelper.property.invert('67P.renderable.ProjectionComponent.performProjection'), + Command = propertyHelper.invert('Scene.67P.renderable.ProjectionComponent.performProjection'), Documentation = "Enables or disables the image projection on 67P.", Local = false } @@ -129,7 +131,7 @@ asset.onInitialize(function () Rotation = { -0.106166, 0.981574, -0.084545, 0.134513 }, }) - openspace.setPropertyValue('67P.renderable.PerformShading', false); + openspace.setPropertyValue('Scene.67P.renderable.PerformShading', false); end) asset.onDeinitialize(function () diff --git a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset index 6d5bff9427..1444106adc 100644 --- a/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset +++ b/data/assets/scene/solarsystem/missions/osirisrex/osirisrex.asset @@ -2,19 +2,15 @@ asset.request('./bennu') asset.request('./model') asset.request('./trail') - +asset.require('./script_schedule') local mission = asset.localResource('osirisrex.mission') local missionName -local scriptSchedule = asset.localResource("scheduled_scripts.lua") - asset.onInitialize(function() missionName = openspace.loadMission(mission) - openspace.scriptScheduler.loadFile(scriptSchedule) end) asset.onDeinitialize(function() openspace.unloadMission(missionName) - -- openspace.scriptScheduler.unloadFile end) diff --git a/data/assets/scene/solarsystem/missions/osirisrex/scheduled_scripts.lua b/data/assets/scene/solarsystem/missions/osirisrex/scheduled_scripts.lua deleted file mode 100644 index 39698b5532..0000000000 --- a/data/assets/scene/solarsystem/missions/osirisrex/scheduled_scripts.lua +++ /dev/null @@ -1,14 +0,0 @@ -dofile(openspace.absPath("${SCRIPTS}/common.lua")) - -return { - helper.scheduledScript.setEnabled("2016 SEP 08 23:05:00", "OsirisRexTrailSolarSystem", false), - helper.scheduledScript.setEnabled("2016 SEP 08 23:05:00", "OsirisRexTrailBennu", false), - - helper.scheduledScript.reversible.setEnabled("2016 SEP 08 23:05:01", "OsirisRexTrailEarth", true), - helper.scheduledScript.reversible.setEnabled("2016 SEP 09 00:00:00", "OsirisRexTrailSolarSystem", true), - helper.scheduledScript.reversible.setEnabled("2016 SEP 09 02:00:00", "OsirisRexTrailEarth", false), - helper.scheduledScript.reversible.setEnabled("2018 OCT 11 00:00:00", "OsirisRexTrailBennu", true), - helper.scheduledScript.reversible.setEnabled("2018 OCT 15 00:00:00", "OsirisRexTrailSolarSystem", false), - helper.scheduledScript.reversible.setEnabled("2019 AUG 01 00:00:00", "OsirisRexTrailSolarSystem", true), - helper.scheduledScript.reversible.setEnabled("2019 AUG 01 00:00:00", "OsirisRexTrailBennu", false), -} diff --git a/data/assets/scene/solarsystem/missions/osirisrex/script_schedule.asset b/data/assets/scene/solarsystem/missions/osirisrex/script_schedule.asset new file mode 100644 index 0000000000..147d918cfe --- /dev/null +++ b/data/assets/scene/solarsystem/missions/osirisrex/script_schedule.asset @@ -0,0 +1,18 @@ +local scriptSchedulerHelper = asset.require('util/script_scheduler_helper') + +asset.onInitialize(function () + scriptSchedulerHelper.scheduleRenderableEnabled("2016 SEP 08 23:05:00", "OsirisRexTrailSolarSystem", false) + scriptSchedulerHelper.scheduleRenderableEnabled("2016 SEP 08 23:05:00", "OsirisRexTrailBennu", false) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2016 SEP 08 23:05:01", "OsirisRexTrailEarth", true) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2016 SEP 09 00:00:00", "OsirisRexTrailSolarSystem", true) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2016 SEP 09 02:00:00", "OsirisRexTrailEarth", false) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2018 OCT 11 00:00:00", "OsirisRexTrailBennu", true) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2018 OCT 15 00:00:00", "OsirisRexTrailSolarSystem", false) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2019 AUG 01 00:00:00", "OsirisRexTrailSolarSystem", true) + scriptSchedulerHelper.scheduleRenderableEnabledReversable("2019 AUG 01 00:00:00", "OsirisRexTrailBennu", false) +end) + + +asset.onDeinitialize(function () + openspace.scriptScheduler.clear() +end) \ No newline at end of file diff --git a/data/assets/util/default_keybindings.asset b/data/assets/util/default_keybindings.asset index 01fcea5ee6..5a8e0b800b 100644 --- a/data/assets/util/default_keybindings.asset +++ b/data/assets/util/default_keybindings.asset @@ -1,23 +1,24 @@ -local helper = asset.require('./scene_helper') +local sceneHelper = asset.require('./scene_helper') +local propertyHelper = asset.require('./property_helper') local Keybindings = { { Key = "F2", Command = -[[local b = openspace.getPropertyValue('Global Properties.ImGUI.Main.Properties.Enabled'); -local c = openspace.getPropertyValue('Global Properties.ImGUI.Main.IsHidden'); -openspace.setPropertyValue('Global Properties.ImGUI.*.Enabled', false); +[[local b = openspace.getPropertyValue('Modules.ImGUI.Main.Scene Properties.Enabled'); +local c = openspace.getPropertyValue('Modules.ImGUI.Main.IsHidden'); +openspace.setPropertyValue('Modules.ImGUI.*.Enabled', false); if b and c then -- This can happen if the main properties window is enabled, the main gui is enabled -- and then closed again. So the main properties window is enabled, but also all -- windows are hidden - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.IsHidden', false); - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.Properties.Enabled', true); - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.Space/Time.Enabled', true); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.IsHidden', false); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.Scene Properties.Enabled', true); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.Space/Time.Enabled', true); else - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.Properties.Enabled', not b); - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.Space/Time.Enabled', not b); - openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.IsHidden', b); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.Scene Properties.Enabled', not b); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.Space/Time.Enabled', not b); + openspace.setPropertyValueSingle('Modules.ImGUI.Main.IsHidden', b); end]], Documentation = "Shows or hides the properties window", Local = true @@ -25,15 +26,15 @@ end]], { Key = "F3", Command = -[[local b = openspace.getPropertyValue('Global Properties.ImGUI.Main.Enabled'); -openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.Enabled', not b); -openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.IsHidden', b);]], +[[local b = openspace.getPropertyValue('Modules.ImGUI.Main.Enabled'); +openspace.setPropertyValueSingle('Modules.ImGUI.Main.Enabled', not b); +openspace.setPropertyValueSingle('Modules.ImGUI.Main.IsHidden', b);]], Documentation = "Shows or hides the entire user interface", Local = true }, { Key = "F4", - Command = helper.property.invert("RenderEngine.PerformanceMeasurements"), + Command = propertyHelper.invert("RenderEngine.PerformanceMeasurements"), Documentation = "Toogles performance measurements that shows rendering time informations.", Local = true }, @@ -57,19 +58,19 @@ openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.IsHidden', b);]], }, { Key = "f", - Command = helper.property.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'), + Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RotationalFriction'), Documentation = "Toggles the rotational friction of the camera. If it is disabled, the camera rotates around the focus object indefinitely.", Local = false }, { Key = "Shift+f", - Command = helper.property.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'), + Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.ZoomFriction'), Documentation = "Toggles the zoom friction of the camera. If it is disabled, the camera rises up from or closes in towards the focus object indefinitely.", Local = false }, { Key = "Ctrl+f", - Command = helper.property.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'), + Command = propertyHelper.invert('NavigationHandler.OrbitalNavigator.Friction.RollFriction'), Documentation = "Toggles the roll friction of the camera. If it is disabled, the camera rolls around its own axis indefinitely.", Local = false }, @@ -84,9 +85,9 @@ openspace.setPropertyValueSingle('Global Properties.ImGUI.Main.IsHidden', b);]], local DeltaTimeKeys asset.onInitialize(function() - Keys = helper.bindKeys(Keybindings) + Keys = sceneHelper.bindKeys(Keybindings) - DeltaTimeKeys = helper.setDeltaTimeKeys({ + DeltaTimeKeys = sceneHelper.setDeltaTimeKeys({ -- 1 2 3 4 5 6 7 8 9 0 -------------------------------------------------------------------------------------------------------------------------- -- 1s 2s 5s 10s 30s 1m 2m 5m 10m 30m @@ -102,8 +103,8 @@ asset.onInitialize(function() end) asset.onDeinitialize(function () - helper.unbindKeys(Keybindings) - helper.unbindKeys(DeltaTimeKeys) + sceneHelper.unbindKeys(Keybindings) + sceneHelper.unbindKeys(DeltaTimeKeys) end) asset.export("DefaultKeybindings", Keybindings) diff --git a/data/assets/util/property_helper.asset b/data/assets/util/property_helper.asset new file mode 100644 index 0000000000..8d3576d130 --- /dev/null +++ b/data/assets/util/property_helper.asset @@ -0,0 +1,21 @@ +-- Function that returns the string that inverts the fully qualified boolean property 'property' +local invert = function(prop) + local escaped_property = "'" .. prop .. "'" + return "openspace.setPropertyValue(" .. escaped_property .. ", not openspace.getPropertyValue(" .. escaped_property .. "));" +end + +-- Function that returns the string that increments the 'property' by the 'value' +local increment = function(prop, value) + local v = value or 1 + local escaped_property = "'" .. prop .. "'" + return "openspace.setPropertyValue(" .. escaped_property .. ", openspace.getPropertyValue(" .. escaped_property .. ") + " .. v .. ");" +end + +-- Function that returns the string that decrements the 'property' by the 'value' +local decrement = function(prop, value) + return increment(prop, -value) +end + +asset.export('invert', invert) +asset.export('increment', increment) +asset.export('decrement', decrement) diff --git a/data/assets/util/renderable_helper.asset b/data/assets/util/renderable_helper.asset new file mode 100644 index 0000000000..300e66a574 --- /dev/null +++ b/data/assets/util/renderable_helper.asset @@ -0,0 +1,15 @@ +local propertyHelper = asset.require('./property_helper') + +-- Function that returns the string that enables/disables the renderable 'renderable' +local toggle = function(renderable) + return propertyHelper.invert(renderable .. ".renderable.Enabled") +end + +-- Function that returns the string that sets the enabled property of to +local setEnabled = function(renderable, enabled) + return "openspace.setPropertyValue('" .. renderable .. ".renderable.Enabled', " .. (enabled and "true" or "false") .. ");"; +end + + +asset.export('toggle', toggle) +asset.export('setEnabled', setEnabled) \ No newline at end of file diff --git a/data/assets/util/scene_helper.asset b/data/assets/util/scene_helper.asset index fa84befc03..45139ec6c6 100644 --- a/data/assets/util/scene_helper.asset +++ b/data/assets/util/scene_helper.asset @@ -52,11 +52,3 @@ local setDeltaTimeKeys = function(t) return result end asset.export("setDeltaTimeKeys", setDeltaTimeKeys) - ------------------------------------------------------------------ - -dofile(openspace.absPath("${SCRIPTS}/common.lua")) - -asset.export("property", helper.property) -asset.export("renderable", helper.renderable) -asset.export("scheduledScript", helper.scheduledScript) diff --git a/data/assets/util/script_scheduler_helper.asset b/data/assets/util/script_scheduler_helper.asset new file mode 100644 index 0000000000..4a3727b9b3 --- /dev/null +++ b/data/assets/util/script_scheduler_helper.asset @@ -0,0 +1,24 @@ +local renderableHelper = asset.require('./renderable_helper') + +-- Function that schedules scripts setting the enabled property +-- of to at time