mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-01 09:10:18 -06:00
toggle different textures with hotkey i
This commit is contained in:
@@ -5,40 +5,39 @@ local propertyHelper = asset.require('util/property_helper')
|
||||
local sceneHelper = asset.require('util/scene_helper')
|
||||
|
||||
asset.require('util/default_dashboard')
|
||||
asset.require('spice/base')
|
||||
|
||||
asset.require('scene/solarsystem/sun/magnetogram_textures')
|
||||
assetHelper.requestAll(asset, 'scene/solarsystem/sun/heliosphere')
|
||||
|
||||
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", false)
|
||||
|
||||
-- Namespaced global lua state
|
||||
textureList = {
|
||||
Options = {
|
||||
TexIndex = 1
|
||||
},
|
||||
SunTextures = {
|
||||
asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_20G_offset.png",
|
||||
asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_100G_offset.png",
|
||||
asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_1000G_offset.png",
|
||||
asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/black.png",
|
||||
asset.require('./scene/solarsystem/sun/sun_textures').TexturesPath .. "/sun.jpg",
|
||||
}
|
||||
}
|
||||
-- must be >0
|
||||
textureIndex = 2;
|
||||
|
||||
local Keybindings = {
|
||||
{
|
||||
-- the Shift+s key, might not reset as it is now because it simply
|
||||
-- inverts multiple things that can be inverted indivitually
|
||||
--[[ {
|
||||
Key = "Shift+s",
|
||||
Command =
|
||||
propertyHelper.invert('Scene.MAS_MHD_Fieldlines.Renderable.Enabled') ..
|
||||
propertyHelper.invert('Scene.Sun.Renderable.Layers.ColorLayers.magnetogram.Enabled') ..
|
||||
propertyHelper.invert('Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled') ..
|
||||
propertyHelper.invert('Scene.MAS_MHD_density.Renderable.Enabled') ..
|
||||
propertyHelper.invert('Scene.SunGlare.Renderable.Enabled'),
|
||||
Documentation = "Resets the s ubscene for showing the Sun volume rendering + fieldlines",
|
||||
Documentation = "Resets the subscene for showing the Sun volume rendering + fieldlines",
|
||||
Name = "Reset MHD back",
|
||||
GuiPath = "/CCMC/MHD",
|
||||
Local = false
|
||||
},
|
||||
},--]]
|
||||
{
|
||||
Key = "F6",
|
||||
Command = propertyHelper.invert('Scene.MAS_MHD_density.Renderable.Enabled'),
|
||||
Documentation = "Toggle volume",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "F7",
|
||||
Command = propertyHelper.invert('Scene.MAS_MHD_Fieldlines.Renderable.Enabled'),
|
||||
Documentation = "Toggle fieldlines",
|
||||
Local = false
|
||||
},
|
||||
{
|
||||
Key = "F8",
|
||||
Command = propertyHelper.invert('Scene.SunGlare.Renderable.Enabled'),
|
||||
@@ -54,33 +53,48 @@ local Keybindings = {
|
||||
{
|
||||
Key = "i",
|
||||
Command = [[
|
||||
if (textureList.Options.TexIndex == nil) then
|
||||
textureList.Options.TexIndex = 1
|
||||
textureList = openspace.globebrowsing.getLayers('Sun', 'ColorLayers');
|
||||
|
||||
if (textureIndex == nil) then
|
||||
textureIndex = 1;
|
||||
end;
|
||||
|
||||
textureList.Options.TexIndex = textureList.Options.TexIndex + 1
|
||||
if (textureList.Options.TexIndex > #textureList.SunTextures) then
|
||||
textureList.Options.TexIndex = 1
|
||||
textureIndex = textureIndex + 1
|
||||
if (textureIndex >= #textureList) then
|
||||
textureIndex = 1;
|
||||
end;
|
||||
|
||||
if (textureIndex == 1) then
|
||||
openspace.setPropertyValue("Scene.Sun.Renderable.Layers.ColorLayers.*.Enabled", false);
|
||||
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", true);
|
||||
else
|
||||
openspace.setPropertyValue("Scene.Sun.Renderable.Layers.ColorLayers.*.Enabled", false);
|
||||
|
||||
str = "Scene.Sun.Renderable.Layers.ColorLayers.magnetogram-" .. textureIndex .. ".Enabled";
|
||||
openspace.setPropertyValueSingle(str, true);
|
||||
end;
|
||||
|
||||
openspace.setPropertyValueSingle('Scene.Sun.Renderable.Layers.ColorLayers.magnetogram.tileProvider.FilePath', textureList.SunTextures[textureList.Options.TexIndex]);
|
||||
]],
|
||||
Documentation = "Display next sun texture in list of textures",
|
||||
Local = false
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
local sunAsset = asset.require('scene/solarsystem/sun/sun');
|
||||
local sunAsset = asset.require('scene/solarsystem/sun/sun'); --heliosphere/mas/bastille_day/
|
||||
|
||||
asset.onInitialize(function ()
|
||||
openspace.time.setTime("2000 JUL 14 09:33:37.100")
|
||||
openspace.time.setTime("2000 JUL 14 08:33:37.100")
|
||||
|
||||
sceneHelper.bindKeys(Keybindings)
|
||||
|
||||
openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", false)
|
||||
local str = "Scene.Sun.Renderable.Layers.ColorLayers.magnetogram-" .. textureIndex .. ".Enabled";
|
||||
openspace.setPropertyValueSingle(str, true)
|
||||
|
||||
openspace.setPropertyValueSingle('Scene.SunGlare.Renderable.Enabled', false)
|
||||
|
||||
openspace.markInterestingNodes({
|
||||
"Earth", "Sun", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD"
|
||||
"Earth", "Sun1", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD"
|
||||
});
|
||||
|
||||
openspace.addVirtualProperty(
|
||||
@@ -105,7 +119,7 @@ asset.onDeinitialize(function ()
|
||||
sceneHelper.unbindKeys(Keybindings)
|
||||
|
||||
openspace.removeInterestingNodes({
|
||||
"Earth", "Sun", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD"
|
||||
"Earth", "Sun1", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD"
|
||||
})
|
||||
|
||||
openspace.removeVirtualProperty("*Trail.renderable.Enabled")
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
-- Sun-to-Earth MHD Simulation of the 2000 July 14 Bastille Day Eruption.
|
||||
-- ApJ,
|
||||
-- 856:75.
|
||||
asset.info = {
|
||||
Name = "PREDSCI MAS Bastille Day Textures",
|
||||
Version = "1.0",
|
||||
Description = [[ Magnetograms of the sun ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "https://ui.adsabs.harvard.edu/abs/2018ApJ...856...75T/abstract",
|
||||
License = ""
|
||||
}
|
||||
|
||||
local TexturesPath = asset.syncedResource({
|
||||
Name = "PREDSCI MAS Bastille Day Textures",
|
||||
@@ -1,3 +1,12 @@
|
||||
asset.info = {
|
||||
Name = "Volume Rendering Bastille Day",
|
||||
Version = "1.0",
|
||||
Description = [[ Volumetric rendering for the bastille day CME event ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "",
|
||||
License = ""
|
||||
}
|
||||
|
||||
local assetHelper = asset.require("util/asset_helper")
|
||||
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
|
||||
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
asset.info = {
|
||||
Name = "Fieldlines Bastille Day",
|
||||
Version = "1.0",
|
||||
Description = [[ Magnetic fieldlines for the bastille day CME event ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "",
|
||||
License = ""
|
||||
}
|
||||
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local transforms = asset.require('./transforms')
|
||||
|
||||
|
||||
@@ -1,31 +1,21 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local transforms = asset.require('./transforms')
|
||||
local sun = asset.require('scene/solarsystem/sun/sun')
|
||||
-- Torok, T., Downs, C., Linker, J. A., Lionello, R., Titov, V. S., Mikic, Z., Riley, P., Caplan, R. M., and Wijaya, J. (2018).
|
||||
-- Sun-to-Earth MHD Simulation of the 2000 July 14 Bastille Day Eruption.
|
||||
-- ApJ,
|
||||
-- 856:75.
|
||||
asset.info = {
|
||||
Name = "PREDSCI MAS Bastille Day Textures",
|
||||
Version = "1.0",
|
||||
Description = [[ Magnetograms of the sun ]],
|
||||
Author = "OpenSpace Team",
|
||||
URL = "https://ui.adsabs.harvard.edu/abs/2018ApJ...856...75T/abstract",
|
||||
License = ""
|
||||
}
|
||||
|
||||
local magnetogramDirectory = asset.syncedResource({
|
||||
local TexturesPath = asset.syncedResource({
|
||||
Name = "Bastille Day Magnetogram",
|
||||
Type = "HttpSynchronization",
|
||||
Identifier = "bastille_day_magnetogram",
|
||||
Version = 1
|
||||
})
|
||||
|
||||
asset.export("directory", magnetogramDirectory)
|
||||
|
||||
asset.onInitialize(function ()
|
||||
openspace.globebrowsing.addLayer(
|
||||
'Sun',
|
||||
'ColorLayers',
|
||||
{
|
||||
Identifier = "magnetogram",
|
||||
Name = "Magnetogram",
|
||||
Description = "",
|
||||
FilePath = magnetogramDirectory .. "/br_bas05_100G_inv_redblue.png",
|
||||
Enabled = true
|
||||
}
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
|
||||
end)
|
||||
asset.export("TexturesPath", TexturesPath)
|
||||
|
||||
39
data/assets/scene/solarsystem/sun/magnetogram_textures.asset
Normal file
39
data/assets/scene/solarsystem/sun/magnetogram_textures.asset
Normal file
@@ -0,0 +1,39 @@
|
||||
local assetHelper = asset.require('util/asset_helper')
|
||||
local transforms = asset.require('./transforms')
|
||||
local sun = asset.require('scene/solarsystem/sun/sun')
|
||||
|
||||
-- synced directories
|
||||
local textureDirectory = asset.require('./heliosphere/mas/bastille_day/bastille_day_sun_textures').TexturesPath;
|
||||
local magnetogramDirectory = asset.require('./heliosphere/mas/bastille_day/magnetogram').TexturesPath;
|
||||
|
||||
-- lists of paths
|
||||
local magnetograms = openspace.walkDirectoryFiles(magnetogramDirectory);
|
||||
local textures = openspace.walkDirectoryFiles(textureDirectory);
|
||||
|
||||
-- put elements from textures into magnetograms
|
||||
for _, v in ipairs(textures) do
|
||||
table.insert(magnetograms, v)
|
||||
end
|
||||
|
||||
asset.onInitialize(function ()
|
||||
-- add all all elements in magnetograms as layers
|
||||
for i, imagename in ipairs(magnetograms) do
|
||||
|
||||
openspace.globebrowsing.addLayer(
|
||||
'Sun',
|
||||
'ColorLayers',
|
||||
{
|
||||
Identifier = "magnetogram-" .. i,
|
||||
Name = imagename, --"Magnetogram-" .. i,
|
||||
Description = "",
|
||||
FilePath = imagename,
|
||||
Enabled = false
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
asset.onDeinitialize(function ()
|
||||
|
||||
end)
|
||||
@@ -243,7 +243,7 @@ namespace {
|
||||
return backupValue;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Reference in New Issue
Block a user