Feature/night sky items (#2613)

* added night sky items and camera event
---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Micah Acinapura
2023-04-16 17:29:48 -04:00
committed by GitHub
parent 8a62752434
commit 5a9bb529f3
30 changed files with 1751 additions and 48 deletions

View File

@@ -0,0 +1,110 @@
local level_horizon_yaw = {
Identifier = "os.nightsky.level_horizon_yaw",
Name = "Level Horizon Yaw",
Command = [[
local currentNavState = openspace.navigation.getNavigationState();
local newNavState = {};
newNavState["Pitch"] = currentNavState["Pitch"];
newNavState["Anchor"] = currentNavState["Anchor"];
newNavState["Yaw"] = 0.0;
newNavState["Position"] = currentNavState["Position"];
newNavState["Up"] = currentNavState["Up"];
openspace.navigation.setNavigationState(newNavState)
]],
Documentation = "Levels the horizon horizontally.",
GuiPath = "/Night Sky/View",
IsLocal = false
}
local look_up = {
Identifier = "os.nightsky.look_up",
Name = "Look up",
Command = [[
local currentNavState = openspace.navigation.getNavigationState();
local newNavState = {};
newNavState["Pitch"] = math.pi;
newNavState["Anchor"] = currentNavState["Anchor"];
newNavState["Yaw"] = currentNavState["Yaw"];
newNavState["Position"] = currentNavState["Position"];
newNavState["Up"] = currentNavState["Up"];
openspace.navigation.setNavigationState(newNavState)
]],
Documentation = "Sets the view to be looking at the zenith",
GuiPath = "/Night Sky/View",
IsLocal = false
}
local level_horizon_pitch = {
Identifier = "os.nightsky.level_horizon_pitch",
Name = "Level Horizon Pitch",
Command = [[
local currentNavState = openspace.navigation.getNavigationState();
local newNavState = {};
newNavState["Pitch"] = math.pi / 2.0;
newNavState["Anchor"] = currentNavState["Anchor"];
newNavState["Yaw"] = currentNavState["Yaw"];
newNavState["Position"] = currentNavState["Position"];
newNavState["Up"] = currentNavState["Up"];
openspace.navigation.setNavigationState(newNavState)
]],
Documentation = "Levels the view to the horizon.",
GuiPath = "/Night Sky/View",
IsLocal = false
}
local looking_north = {
Identifier = "os.nightsky.looking_north",
Name = "Looking North",
Command = [[
local currentNavState = openspace.navigation.getNavigationState();
local newNavState = {};
newNavState["Pitch"] = math.pi / 2.0;
newNavState["Anchor"] = currentNavState["Anchor"];
newNavState["Yaw"] = currentNavState["Yaw"];
newNavState["Position"] = currentNavState["Position"];
newNavState["Up"] = { 0.0, 0.0, 1.0 };
openspace.navigation.setNavigationState(newNavState)
]],
Documentation = "Sets the view for a horizon looking North.",
GuiPath = "/Night Sky/View",
IsLocal = false
}
local looking_south = {
Identifier = "os.nightsky.looking_south",
Name = "Looking South",
Command = [[
local currentNavState = openspace.navigation.getNavigationState();
local newNavState = {};
newNavState["Pitch"] = math.pi / 2.0;
newNavState["Anchor"] = currentNavState["Anchor"];
newNavState["Yaw"] = currentNavState["Yaw"];
newNavState["Position"] = currentNavState["Position"];
newNavState["Up"] = { 0.0, 0.0, -1.0 };
openspace.navigation.setNavigationState(newNavState)
]],
Documentation = "Sets the view for a horizon looking South.",
GuiPath = "/Night Sky/View",
IsLocal = false
}
asset.onInitialize(function()
openspace.action.registerAction(look_up)
openspace.action.registerAction(level_horizon_yaw)
openspace.action.registerAction(level_horizon_pitch)
openspace.action.registerAction(looking_north)
openspace.action.registerAction(looking_south)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(looking_south)
openspace.action.removeAction(looking_north)
openspace.action.removeAction(level_horizon_pitch)
openspace.action.removeAction(level_horizon_yaw)
openspace.action.removeAction(look_up)
end)
asset.export(look_up)
asset.export(level_horizon_yaw)
asset.export(level_horizon_pitch)
asset.export(looking_north)
asset.export(looking_south)

View File

@@ -0,0 +1,30 @@
local enableDimming = {
Identifier = "os.nightsky.enable_dimming",
Name = "Enable atmosphere dimming",
Command = "openspace.setPropertyValue('{daytime_hidden}.Renderable.DimInAtmosphere', true)",
Documentation = "Sets items like the stars and constellations to be hidden during the day",
GuiPath = "/Night Sky/Daytime",
IsLocal = false
}
local disableDimming = {
Identifier = "os.nightsky.disable_dimming",
Name = "Disable atmosphere dimming",
Command = "openspace.setPropertyValue('{daytime_hidden}.Renderable.DimInAtmosphere', false)",
Documentation = "Sets items like the stars and constellations to be shown during the day",
GuiPath = "/Night Sky/Daytime",
IsLocal = false
}
asset.onInitialize(function()
openspace.action.registerAction(enableDimming)
openspace.action.registerAction(disableDimming)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(disableDimming)
openspace.action.removeAction(enableDimming)
end)
asset.export(enableDimming)
asset.export(disableDimming)

View File

@@ -53,6 +53,7 @@ asset.require("scene/digitaluniverse/superclusters")
asset.require("scene/digitaluniverse/supernovaremnants")
asset.require("scene/digitaluniverse/tully")
asset.require("scene/digitaluniverse/voids")
asset.require("nightsky/nightsky")
asset.require("customization/globebrowsing")
asset.require("util/default_actions")

View File

@@ -0,0 +1,109 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local gridPosition = {
Identifier = "AltAzGridPosition",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
Altitude = 0.0,
UseHeightmap = false,
UseCamera = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
UseHeightmap = false,
UseCamera = true
}
},
GUI = {
Name = "Altitude/Azimuth Grid Position",
Path = "/Other/Grids",
Hidden = true
}
}
local grid = {
Identifier = "AltAzGrid",
Parent = gridPosition.Identifier,
Transform = {
Scale = {
Type = "StaticScale",
Scale = 50000
},
Rotation = {
Type = "StaticRotation",
Rotation = { -math.pi / 2.0, 0.0, 0.0 }
},
},
Renderable = {
Type = "RenderableSphericalGrid",
Enabled = asset.enabled,
Opacity = 0.8,
Color = { 0.4, 0.8, 0.4 },
LineWidth = 2.0,
RenderBinMode = "PostDeferredTransparent"
},
GUI = {
Name = "Altitude/Azimuth Grid",
Path = "/Other/Grids"
}
}
local showAction = {
Identifier = "os.nightsky.show_altaz",
Name = "Show Alt/Az grid",
Command = [[
local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent('AltAzGridPosition', camera.Anchor)
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Translation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Translation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Translation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Rotation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Rotation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.AltAzGridPosition.Rotation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.AltAzGrid.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.AltAzGrid.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.AltAzGrid.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows a local Altitude/Azimuth grid centered around your position",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_altaz",
Name = "Hide Alt/Az grid",
Command = [[
openspace.setPropertyValueSingle('Scene.AltAzGrid.Renderable.Fade', 0, 1);
]],
Documentation = "Hides the Alt/Az grid",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(gridPosition)
openspace.addSceneGraphNode(grid)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(showAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(showAction)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(grid)
openspace.removeSceneGraphNode(gridPosition)
end)
asset.export(showAction)
asset.export(hideAction)
asset.export(grid)

View File

@@ -0,0 +1,139 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local textures = asset.syncedResource({
Name = "Cardinal Direction Textures",
Type = "UrlSynchronization",
Identifier = "cardinal_direction_textures",
Url = {
"https://wms.openspace.amnh.org/static/sync/url/directions/sphere.png",
"https://wms.openspace.amnh.org/static/sync/url/directions/sphere2.png",
"https://wms.openspace.amnh.org/static/sync/url/directions/sphere3.png",
"https://wms.openspace.amnh.org/static/sync/url/directions/sphere4.png",
"https://wms.openspace.amnh.org/static/sync/url/directions/sphere5.png"
},
Override = false
})
local Position = {
Identifier = "CardinalDirectionsPosition",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
Altitude = 0.0,
UseCamera = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
UseCamera = true,
Angle = 270.0
}
},
GUI = {
Name = "Cardinal Directions Position",
Path = "/Other/Night Sky",
Hidden = true
}
}
local sphere = {
Identifier = "CardinalDirectionSphere",
Parent = Position.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { -math.pi/2, 0.0, 0.0 }
},
},
Renderable = {
Type = "RenderableSphere",
Enabled = asset.enabled,
Size = 50000,
Segments = 80,
Opacity = 0.9,
Texture = textures .. 'sphere.png',
Orientation = "Inside",
MirrorTexture = true,
RenderBinMode = "PostDeferredTransparent"
},
GUI = {
Name = "Cardinal Directions",
Path = "/Other/Night Sky"
}
}
local showCommand = [[
local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent('CardinalDirectionsPosition', camera.Anchor)
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Translation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Translation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Translation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Rotation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Rotation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.CardinalDirectionsPosition.Rotation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Fade', 1.0, 1.0);
]]
local showBandAction = {
Identifier = "os.nightsky.show_nesw_band",
Name = "Show cardinal directions (with ticks)",
Command = "openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Texture','"
.. textures:gsub("\\","/") .. "sphere5.png')"
.. showCommand,
Documentation = "Shows the cardinal direction sphere with letters and circle with tick marks",
GuiPath = "/Night Sky/Directions",
IsLocal = false
}
local showLettersAction = {
Identifier = "os.nightsky.show_nesw_letters",
Name = "Show cardinal directions (letters only)",
Command = "openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Texture','"
.. textures:gsub("\\","/") .. "sphere.png')"
.. showCommand,
Documentation = "Shows the cardinal direction sphere with letters only",
GuiPath = "/Night Sky/Directions",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_nesw",
Name = "Hide cardinal directions",
Command = [[
openspace.setPropertyValueSingle('Scene.CardinalDirectionSphere.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the cardinal directions",
GuiPath = "/Night Sky/Directions",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Position)
openspace.addSceneGraphNode(sphere)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(showBandAction)
openspace.action.registerAction(showLettersAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(showLettersAction)
openspace.action.removeAction(showBandAction)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(sphere)
openspace.removeSceneGraphNode(Position)
end)
asset.export(showBandAction)
asset.export(showLettersAction)
asset.export(hideAction)
asset.export(sphere)
asset.export(Position)

View File

@@ -0,0 +1,140 @@
local transforms = asset.require("scene/solarsystem/sun/transforms")
local textures = asset.syncedResource({
Name = "Ecliptic Band Textures",
Type = "HttpSynchronization",
Identifier = "ecliptic_band_textures",
Version = 1
})
local eclipticRotationMatrix = {
-0.05487554, 0.4941095, -0.8676661,
-0.9938214, -0.1109906, -0.0003515167,
-0.09647644, 0.8622859, 0.4971472
}
local line = {
Identifier = "EclipticLine",
Parent = transforms.SolarSystemBarycenter.Name,
Transform = {
Scale = {
Type = "StaticScale",
Scale = 4.28601E17;
},
Rotation = {
Type = "StaticRotation",
Rotation = eclipticRotationMatrix
}
},
Renderable = {
Type = "RenderableRadialGrid",
Opacity = 0.8,
Color = { 1.0, 1.0, 1.0 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
Radii = { 0.5, 0.5 },
Enabled = asset.enabled
},
GUI = {
Name = "Ecliptic Line",
Path = "/Other/Lines"
}
}
local band = {
Identifier = "EclipticBand",
Parent = transforms.SolarSystemBarycenter.Name,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = eclipticRotationMatrix
}
},
Renderable = {
Type = "RenderableSphere",
Texture = textures .. "band.png",
Size = 4.28601E17,
Segments = 50,
DisableFadeInOut = true,
Orientation = "Inside",
Opacity = 0.05,
Enabled = asset.enabled
},
GUI = {
Name = "Ecliptic Band",
Path = "/Other/Lines"
}
}
local showLineAction = {
Identifier = "os.nightsky.show_ecliptic_line",
Name = "Show ecliptic line",
Command = [[
openspace.setPropertyValueSingle('Scene.EclipticLine.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.EclipticLine.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.EclipticLine.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows the ecliptic line",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideLineAction = {
Identifier = "os.nightsky.hide_ecliptic_line",
Name = "Hide ecliptic line",
Command = [[
openspace.setPropertyValueSingle('Scene.EclipticLine.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the ecliptic line",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local showBandAction = {
Identifier = "os.nightsky.show_ecliptic_band",
Name = "Show ecliptic band",
Command = [[
openspace.setPropertyValueSingle('Scene.EclipticBand.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.EclipticBand.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.EclipticBand.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows the ecliptic band",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideBandAction = {
Identifier = "os.nightsky.hide_ecliptic_band",
Name = "Hide ecliptic band",
Command = [[
openspace.setPropertyValueSingle('Scene.EclipticBand.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the ecliptic band",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(line)
openspace.addSceneGraphNode(band)
openspace.action.registerAction(showLineAction)
openspace.action.registerAction(hideLineAction)
openspace.action.registerAction(showBandAction)
openspace.action.registerAction(hideBandAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(hideLineAction)
openspace.action.removeAction(showLineAction)
openspace.action.removeAction(hideBandAction)
openspace.action.removeAction(showBandAction)
openspace.removeSceneGraphNode(band)
openspace.removeSceneGraphNode(line)
end)
asset.export(band)
asset.export(line)
asset.export(showLineAction)
asset.export(hideLineAction)
asset.export(showBandAction)
asset.export(hideBandAction)

View File

@@ -0,0 +1,75 @@
local transforms = asset.require("scene/solarsystem/sun/transforms")
local equatorialRotationMatrix = {
-0.05487554, 0.4941095, -0.8676661,
-0.8734371, -0.4448296, -0.1980764,
-0.483835, 0.7469823, 0.4559838
}
local line = {
Identifier = "EquatorialLine",
Parent = transforms.SolarSystemBarycenter.Name,
Transform = {
Scale = {
Type = "StaticScale",
Scale = 4.28601E17;
},
Rotation = {
Type = "StaticRotation",
Rotation = equatorialRotationMatrix
}
},
Renderable = {
Type = "RenderableRadialGrid",
Opacity = 0.8,
Color = { 1.0, 1.0, 1.0 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
Radii = { 0.5, 0.5 },
Enabled = asset.enabled
},
GUI = {
Name = "Equatorial Line",
Path = "/Other/Lines"
}
}
local showLineAction = {
Identifier = "os.nightsky.show_equatorial_line",
Name = "Show equatorial line",
Command = [[
openspace.setPropertyValueSingle('Scene.EquatorialLine.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.EquatorialLine.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.EquatorialLine.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows the equatorial line",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideLineAction = {
Identifier = "os.nightsky.hide_equatorial_line",
Name = "Hide equatorial line",
Command = [[
openspace.setPropertyValueSingle('Scene.EquatorialLine.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the equatorial line",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(line)
openspace.action.registerAction(showLineAction)
openspace.action.registerAction(hideLineAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(hideLineAction)
openspace.action.removeAction(showLineAction)
openspace.removeSceneGraphNode(line)
end)
asset.export(line)
asset.export(showLineAction)
asset.export(hideLineAction)

View File

@@ -0,0 +1,65 @@
local transforms = asset.require("scene/solarsystem/sun/transforms")
local band = {
Identifier = "GalacticBand",
Parent = transforms.SolarSystemBarycenter.Name,
Transform = {
Scale = {
Type = "StaticScale",
Scale = 9.46377307652E18;
}
},
Renderable = {
Type = "RenderableRadialGrid",
Opacity = 0.8,
Color = { 1.0, 1.0, 1.0 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
Radii = { 0.5, 0.5 },
Enabled = asset.enabled
},
GUI = {
Name = "Galactic Band",
Path = "/Other/Lines"
}
}
local showAction = {
Identifier = "os.nightsky.show_galactic_band",
Name = "Show galactic band",
Command = [[
openspace.setPropertyValueSingle('Scene.GalacticBand.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.GalacticBand.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.GalacticBand.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows the galactic band",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_galactic_band",
Name = "Hide galactic band",
Command = [[
openspace.setPropertyValueSingle('Scene.GalacticBand.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the galactic band",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(band)
openspace.action.registerAction(showAction)
openspace.action.registerAction(hideAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(hideAction)
openspace.action.removeAction(showAction)
openspace.removeSceneGraphNode(band)
end)
asset.export(band)
asset.export(showAction)
asset.export(hideAction)

View File

@@ -0,0 +1,186 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local textures = asset.syncedResource({
Name = "Ground Panorama Textures",
Type = "UrlSynchronization",
Identifier = "ground_panorama_textures",
Url = {
"https://wms.openspace.amnh.org/static/sync/url/panos/0.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/1.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/2.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/3.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/4.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/5.png",
"https://wms.openspace.amnh.org/static/sync/url/panos/6.png",
},
Override = false
})
local position = {
Identifier = "GroundPanoPosition",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 34.201639,
Longitude = -118.171319,
Altitude = 10.0,
UseCamera = true,
UseCameraAltitude = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 34.201639,
Longitude = -118.171319,
UseHeightmap = false,
Angle = 270.0
}
},
GUI = {
Name = "Ground Pano Position",
Path = "/Other/Night Sky",
Hidden = true
}
}
local sphere = {
Identifier = "GroundPanoSphere",
Parent = position.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { -math.pi/2, 0.0, 0.0 }
},
},
Renderable = {
Type = "RenderableSphere",
Size = 8.5,
Segments = 40,
Opacity = 1.0,
Enabled = asset.enabled,
Texture = textures .. "3.png",
Orientation = "Inside",
MirrorTexture = true,
FadeOutThreshold = 1.00,
Background = true,
RenderBinMode = "Overlay"
},
GUI = {
Name = "Ground Panorama",
Path = "/Other/Night Sky"
}
}
local showCommand = [[
local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent('GroundPanoPosition', camera.Anchor)
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Translation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Translation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Translation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Translation.Altitude', alt);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Rotation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Rotation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.GroundPanoPosition.Rotation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.GroundPanoSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.GroundPanoSphere.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.GroundPanoSphere.Renderable.Fade', 1.0, 1.0);
]]
local setTextureCommand = function(scene)
local command = 'openspace.setPropertyValueSingle("Scene.GroundPanoSphere.Renderable.Texture", "'
command = command .. textures
if (scene == "forest") then
command = command .. "1"
elseif (scene == 'city') then
command = command .. "2"
elseif (scene == 'backyard') then
command = command .. "3"
elseif (scene == 'desert') then
command = command .. "4"
else
openspace.printDebug("unknown scene")
end
command = command .. '.png")'
command = command:gsub( "\\", "\\\\")
return command
end
local showForestAction = {
Identifier = "os.nightsky.show_forest_pano",
Name = "Show forest panorama",
Command = setTextureCommand("forest") .. showCommand,
Documentation = "Shows the panorama sphere with a forest scene",
GuiPath = "/Night Sky/Panoramas",
IsLocal = false
}
local showCityAction = {
Identifier = "os.nightsky.show_city_pano",
Name = "Show city panorama",
Command = setTextureCommand("city") .. showCommand,
Documentation = "Shows the panorama sphere with a city scene",
GuiPath = "/Night Sky/Panoramas",
IsLocal = false
}
local showBackyardAction = {
Identifier = "os.nightsky.show_backyard_pano",
Name = "Show backyard panorama",
Command = setTextureCommand("backyard") .. showCommand,
Documentation = "Shows the panorama sphere with a backyard scene",
GuiPath = "/Night Sky/Panoramas",
IsLocal = false
}
local showDesertAction = {
Identifier = "os.nightsky.show_desert_pano",
Name = "Show desert panorama",
Command = setTextureCommand("desert") .. showCommand,
Documentation = "Shows the panorama sphere with a desert scene",
GuiPath = "/Night Sky/Panoramas",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_ground_pano",
Name = "Hide ground panorama",
Command = [[
-- same position as above
openspace.setPropertyValueSingle('Scene.GroundPanoSphere.Renderable.Fade', 0.0, 0.5);
]],
Documentation = "Hides the ground panorama",
GuiPath = "/Night Sky/Panoramas",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(position)
openspace.addSceneGraphNode(sphere)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(showForestAction)
openspace.action.registerAction(showCityAction)
openspace.action.registerAction(showBackyardAction)
openspace.action.registerAction(showDesertAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(showForestAction)
openspace.action.removeAction(showCityAction)
openspace.action.removeAction(showBackyardAction)
openspace.action.removeAction(showDesertAction)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(sphere)
openspace.removeSceneGraphNode(position)
end)
asset.export(position)
asset.export(sphere)
asset.export(hideAction)
asset.export(showForestAction)
asset.export(showCityAction)
asset.export(showBackyardAction)
asset.export(showDesertAction)

View File

@@ -0,0 +1,248 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local textures = asset.syncedResource({
Name = "Light Pollution Textures",
Type = "HttpSynchronization",
Identifier = "light_pollution_textures",
Version = 1
})
local sphere = {
Identifier = "LightPollutionSphere",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 34.201639,
Longitude = -118.171319,
Altitude = 10.0,
UseCamera = true,
UseCameraAltitude = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 34.201639,
Longitude = -118.171319,
UseHeightmap = false,
Angle = 270.0
}
},
Renderable = {
Type = "RenderableSphere",
Size = 8.5,
Segments = 40,
Opacity = 0.0,
Enabled = asset.enabled,
Texture = textures .. "fullsphere.png",
Orientation = "Inside",
MirrorTexture = true,
FadeOutThreshold = 1.00,
Background = true,
RenderBinMode = "PostDeferredTransparent",
Enabled = asset.enabled
},
GUI = {
Name = "Light Pollution Sphere",
Path = "/Other/Night Sky",
Hidden = false
}
}
local pollution_1 = {
Identifier = "os.nightsky.set_light_pollution_level_1",
Name = "Set light pollution level 1",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.9, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.01, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 6.1, 0.3);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.1",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_2 = {
Identifier = "os.nightsky.set_light_pollution_level_2",
Name = "Set light pollution level 2",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.8, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.02, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 6.0, 0.3);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.2",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_3 = {
Identifier = "os.nightsky.set_light_pollution_level_3",
Name = "Set light pollution level 3",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.7, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.03, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.9, 0.3);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.3",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_4 = {
Identifier = "os.nightsky.set_light_pollution_level_4",
Name = "Set light pollution level 4",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.6, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.04, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.8, 0.3);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.4",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_5 = {
Identifier = "os.nightsky.set_light_pollution_level_5",
Name = "Set light pollution level 5",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.5, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.05, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.8, 0.4);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.5",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_6 = {
Identifier = "os.nightsky.set_light_pollution_level_6",
Name = "Set light pollution level 6",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.4, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.06, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.7, 0.4);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.6",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_7 = {
Identifier = "os.nightsky.set_light_pollution_level_7",
Name = "Set light pollution level 7",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.3, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.07, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.6, 0.4);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.7",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_8 = {
Identifier = "os.nightsky.set_light_pollution_level_8",
Name = "Set light pollution level 8",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0);
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.2, 0.3)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.08, 0.5);
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.5, 0.4);
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.8",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local pollution_9 = {
Identifier = "os.nightsky.set_light_pollution_level_9",
Name = "Set light pollution level 9",
Command = [[
openspace.globebrowsing.setNodePositionFromCamera("LightPollutionSphere", true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Enabled', true)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 1.0)
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Opacity', 0.09, 0.5)
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 0.1, 0.3)
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 5.4, 0.4)
]],
Documentation = "Adds a light pollution sphere and lowers the level of the stars by 0.9",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.undo_light_pollution",
Name = "Undo light pollution",
Command = [[
openspace.setPropertyValueSingle('Scene.LightPollutionSphere.Renderable.Fade', 0.0, 0.3)
openspace.setPropertyValueSingle('Scene.Stars.Renderable.ParametersOwner.MagnitudeExponent', 6.2, 0.3)
openspace.setPropertyValueSingle("Scene.MilkyWay.Renderable.Fade", 1.0, 0.3)
]],
Documentation = "Hides the light pollution sphere and resets the stars",
GuiPath = "/Night Sky/Light Pollution",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(sphere)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(pollution_1)
openspace.action.registerAction(pollution_2)
openspace.action.registerAction(pollution_3)
openspace.action.registerAction(pollution_4)
openspace.action.registerAction(pollution_5)
openspace.action.registerAction(pollution_6)
openspace.action.registerAction(pollution_7)
openspace.action.registerAction(pollution_8)
openspace.action.registerAction(pollution_9)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(pollution_9)
openspace.action.removeAction(pollution_8)
openspace.action.removeAction(pollution_7)
openspace.action.removeAction(pollution_6)
openspace.action.removeAction(pollution_5)
openspace.action.removeAction(pollution_4)
openspace.action.removeAction(pollution_3)
openspace.action.removeAction(pollution_2)
openspace.action.removeAction(pollution_1)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(sphere)
end)
asset.export(sphere)
asset.export(hideAction)
asset.export(pollution_1)
asset.export(pollution_2)
asset.export(pollution_3)
asset.export(pollution_4)
asset.export(pollution_5)
asset.export(pollution_6)
asset.export(pollution_7)
asset.export(pollution_8)
asset.export(pollution_9)

View File

@@ -0,0 +1,105 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local position = {
Identifier = "MeridianPosition",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
Altitude = 0.0,
UseCamera = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
UseCamera = true
}
},
GUI = {
Name = "Local Meridian Position",
Path = "/Other/Lines",
Hidden = true
}
}
local plane = {
Identifier = "Meridian",
Parent = position.Identifier,
Transform = {
Scale = {
Type = "StaticScale",
Scale = 1000000
},
},
Renderable = {
Type = "RenderableRadialGrid",
Opacity = 0.8,
Color = { 1.0, 1.0, 1.0 },
LineWidth = 3.0,
GridSegments = { 1, 1 },
Radii = { 0.5, 0.5 },
Enabled = asset.enabled,
RenderBinMode = "PostDeferredTransparent"
},
GUI = {
Name = "Local Meridian",
Path = "/Other/Lines"
}
}
local showAction = {
Identifier = "os.nightsky.show_meridian",
Name = "Show local meridian",
Command = [[
local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent('MeridianPosition', camera.Anchor)
openspace.setPropertyValueSingle('Scene.MeridianPosition.Translation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.MeridianPosition.Translation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.MeridianPosition.Translation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.MeridianPosition.Rotation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.MeridianPosition.Rotation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.MeridianPosition.Rotation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.Meridian.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.Meridian.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.Meridian.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows a line for the local meridian",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_meridian",
Name = "Hide local meridian",
Command = [[
openspace.setPropertyValueSingle('Scene.Meridian.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the line for the local meridian",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(position)
openspace.addSceneGraphNode(plane)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(showAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(showAction)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(plane)
openspace.removeSceneGraphNode(position)
end)
asset.export(position)
asset.export(plane)
asset.export(hideAction)
asset.export(showAction)

View File

@@ -0,0 +1,12 @@
asset.require("./altaz", false)
asset.require("./cardinal_directions", false)
asset.require("./ecliptic_band", false)
asset.require("./equatorial_band", false)
asset.require("./galactic_band", false)
asset.require("./ground_panoramas", false)
asset.require("./meredian", false)
asset.require("./light_pollution", false)
asset.require("./zenith", false)
asset.require("./planets", false)
asset.require("actions/nightsky/camera", false)
asset.require("actions/nightsky/daytime", false)

View File

@@ -0,0 +1,173 @@
local mercury = asset.require('scene/solarsystem/planets/mercury/transforms')
local venus = asset.require('scene/solarsystem/planets/venus/transforms')
local mars = asset.require('scene/solarsystem/planets/mars/transforms')
local jupiter = asset.require('scene/solarsystem/planets/jupiter/transforms')
local saturn = asset.require('scene/solarsystem/planets/saturn/transforms')
local textures = asset.syncedResource({
Name = "Night Sky Planet Textures",
Type = "HttpSynchronization",
Identifier = "night_sky_planet_textures",
Version = 1
})
local Mercury = {
Identifier = "NightSkyMercury",
Parent = mercury.MercuryBarycenter.Identifier,
Renderable = {
Type = "RenderablePlaneImageLocal",
Billboard = true,
Enabled = asset.enabled,
Size = 2439700 * 500,
Texture = textures .. "glare.png",
MultiplyColor = { 0.608, 0.604, 0.455 },
DimInAtmosphere = true,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "nightsky_billboard"},
GUI = {
Name = "Night Sky Mercury",
Path = "/Other/Night Sky/Planets"
}
}
local Venus = {
Identifier = "NightSkyVenus",
Parent = venus.VenusBarycenter.Identifier,
Renderable = {
Type = "RenderablePlaneImageLocal",
Enabled = asset.enabled,
Billboard = true,
Size = 6051900 * 500,
Texture = textures .. "glare.png",
MultiplyColor = { 0.608, 0.604, 0.455 },
DimInAtmosphere = true,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "nightsky_billboard"},
GUI = {
Name = "Night Sky Venus",
Path = "/Other/Night Sky/Planets"
}
}
local Mars = {
Identifier = "NightSkyMars",
Parent = mars.MarsBarycenter.Identifier,
Renderable = {
Type = "RenderablePlaneImageLocal",
Enabled = asset.enabled,
Billboard = true,
Size = 3396190 * 1000,
Texture = textures .. "glare.png",
MultiplyColor = { 0.756, 0.267, 0.054 },
DimInAtmosphere = true,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "nightsky_billboard"},
GUI = {
Name = "Night Sky Mars",
Path = "/Other/Night Sky/Planets"
}
}
local Jupiter = {
Identifier = "NightSkyJupiter",
Parent = jupiter.JupiterBarycenter.Identifier,
Renderable = {
Type = "RenderablePlaneImageLocal",
Enabled = asset.enabled,
Billboard = true,
Size = 71492000 * 400,
Texture = textures .. "glare.png",
MultiplyColor = { 0.608, 0.604, 0.455 },
DimInAtmosphere = true,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "nightsky_billboard"},
GUI = {
Name = "Night Sky Jupiter",
Path = "/Other/Night Sky/Planets"
}
}
local Saturn = {
Identifier = "NightSkySaturn",
Parent = saturn.SaturnBarycenter.Identifier,
Renderable = {
Type = "RenderablePlaneImageLocal",
Enabled = asset.enabled,
Billboard = true,
Size = 60268000 * 500,
Texture = textures .. "glare.png",
MultiplyColor = { 0.608, 0.604, 0.455 },
DimInAtmosphere = true,
RenderBinMode = "PostDeferredTransparent"
},
Tag = { "nightsky_billboard"},
GUI = {
Name = "Night Sky Saturn",
Path = "/Other/Night Sky/Planets"
}
}
local showAction = {
Identifier = "os.nightsky.show_night_sky_planets",
Name = "Show night sky planets",
Command = [[
openspace.setPropertyValueSingle('Scene.NightSkyMercury.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.NightSkyVenus.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.NightSkyMars.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.NightSkyJupiter.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.NightSkySaturn.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.NightSkyMercury.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.NightSkyVenus.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.NightSkyMars.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.NightSkyJupiter.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.NightSkySaturn.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.NightSkyMercury.Renderable.Fade', 1.0, 0.25);
openspace.setPropertyValueSingle('Scene.NightSkyVenus.Renderable.Fade', 1.0, 0.25);
openspace.setPropertyValueSingle('Scene.NightSkyMars.Renderable.Fade', 1.0, 0.25);
openspace.setPropertyValueSingle('Scene.NightSkyJupiter.Renderable.Fade', 1.0, 0.25);
openspace.setPropertyValueSingle('Scene.NightSkySaturn.Renderable.Fade', 1.0, 0.25);
]],
Documentation = "Show night sky versions of the planets",
GuiPath = "/Night Sky/Planets",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_night_sky_planets",
Name = "Hide night sky planets",
Command = [[
openspace.setPropertyValueSingle('Scene.NightSkyMercury.Renderable.Fade', 0.0, 1.0);
openspace.setPropertyValueSingle('Scene.NightSkyVenus.Renderable.Fade', 0.0, 1.0);
openspace.setPropertyValueSingle('Scene.NightSkyMars.Renderable.Fade', 0.0, 1.0);
openspace.setPropertyValueSingle('Scene.NightSkyJupiter.Renderable.Fade', 0.0, 1.0);
openspace.setPropertyValueSingle('Scene.NightSkySaturn.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides night sky versions of the planets",
GuiPath = "/Night Sky/Planets",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Mercury)
openspace.addSceneGraphNode(Venus)
openspace.addSceneGraphNode(Mars)
openspace.addSceneGraphNode(Jupiter)
openspace.addSceneGraphNode(Saturn)
openspace.action.registerAction(showAction)
openspace.action.registerAction(hideAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(hideAction)
openspace.action.removeAction(showAction)
openspace.removeSceneGraphNode(Saturn)
openspace.removeSceneGraphNode(Jupiter)
openspace.removeSceneGraphNode(Mars)
openspace.removeSceneGraphNode(Venus)
openspace.removeSceneGraphNode(Mercury)
end)

View File

@@ -0,0 +1,112 @@
local earthAsset = asset.require('scene/solarsystem/planets/earth/earth')
local textures = asset.syncedResource({
Name = "Zenith Textures",
Type = "HttpSynchronization",
Identifier = "zenith_textures",
Version = 1
})
local position = {
Identifier = "ZenithPosition",
Parent = earthAsset.Earth.Identifier,
Transform = {
Translation = {
Type = "GlobeTranslation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
Altitude = 100000000.0,
UseCamera = true
},
Rotation = {
Type = "GlobeRotation",
Globe = earthAsset.Earth.Identifier,
Latitude = 0.0,
Longitude = 0.0,
UseHeightmap = false,
UseCamera = true
}
},
GUI = {
Name = "Zenith Position",
Path = "/Other/Points",
Hidden = true
}
}
local plane = {
Identifier = "ZenithDot",
Parent = position.Identifier,
Transform = {
Rotation = {
Type = "StaticRotation",
Rotation = { -math.pi, 0.0, 0.0 }
},
},
Renderable = {
Type = "RenderablePlaneImageLocal",
Enabled = asset.enabled,
Size = 1000000,
Origin = "Center",
Billboard = true,
Texture = textures .. "point3A.png",
BlendMode = "Additive"
},
GUI = {
Name = "Zenith",
Path = "/Other/Points"
}
}
local showAction = {
Identifier = "os.nightsky.show_zenith",
Name = "Show local zenith",
Command = [[
local lat, lon, alt = openspace.globebrowsing.getGeoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent('ZenithPosition', camera.Anchor)
openspace.setPropertyValueSingle('Scene.ZenithPosition.Translation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.ZenithPosition.Translation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.ZenithPosition.Translation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.ZenithPosition.Rotation.Globe', camera.Anchor);
openspace.setPropertyValueSingle('Scene.ZenithPosition.Rotation.Latitude', lat);
openspace.setPropertyValueSingle('Scene.ZenithPosition.Rotation.Longitude', lon);
openspace.setPropertyValueSingle('Scene.ZenithDot.Renderable.Enabled', true);
openspace.setPropertyValueSingle('Scene.ZenithDot.Renderable.Fade', 0.0);
openspace.setPropertyValueSingle('Scene.ZenithDot.Renderable.Fade', 1.0, 1.0);
]],
Documentation = "Shows a dot for the local zenith",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
local hideAction = {
Identifier = "os.nightsky.hide_zenith",
Name = "Hide local zenith",
Command = [[
openspace.setPropertyValueSingle('Scene.ZenithDot.Renderable.Fade', 0.0, 1.0);
]],
Documentation = "Hides the dot for the local zenith",
GuiPath = "/Night Sky/Lines and Grids",
IsLocal = false
}
asset.onInitialize(function()
openspace.addSceneGraphNode(position)
openspace.addSceneGraphNode(plane)
openspace.action.registerAction(hideAction)
openspace.action.registerAction(showAction)
end)
asset.onDeinitialize(function()
openspace.action.removeAction(showAction)
openspace.action.removeAction(hideAction)
openspace.removeSceneGraphNode(plane)
openspace.removeSceneGraphNode(position)
end)
asset.export(position)
asset.export(plane)
asset.export(hideAction)
asset.export(showAction)

View File

@@ -55,8 +55,9 @@ local constellations = {
NamesFile = speck .. "constellations.dat",
Colors = { { 0.6, 0.4, 0.4 }, { 0.8, 0.0, 0.0 }, { 0.0, 0.3, 0.8 } },
Unit = "pc",
-- Selection = zodiacs
DimInAtmosphere = true
},
Tag = {"daytime_hidden"},
GUI = {
Name = "Constellations",
Path = "/Milky Way/Constellations",

View File

@@ -18,7 +18,7 @@ local sphere = {
Type = "RenderableSphere",
Size = 9.2E21,
Segments = 40,
Opacity = 0.35,
Opacity = 0.25,
Texture = sphereTextures .. "DarkUniverse_mellinger_4k.jpg",
Orientation = "Inside",
MirrorTexture = true,
@@ -26,6 +26,7 @@ local sphere = {
Background = true,
DimInAtmosphere = true,
},
Tag = {"daytime_hidden"},
GUI = {
Name = "Milky Way Sphere",
Path = "/Milky Way",

View File

@@ -50,6 +50,7 @@ local stars = {
},
DimInAtmosphere = true,
},
Tag = {"daytime_hidden"},
GUI = {
Name = "Stars",
Path = "/Milky Way/Stars",

View File

@@ -75,9 +75,10 @@ local createConstellations = function (baseIdentifier, guiPath, constellationfil
LazyLoading = true,
Texture = images .. imageName,
BlendMode = "Additive",
Opacity = 0.1
Opacity = 0.1,
DimInAtmosphere = true
},
Tag = { "ImageConstellation", group },
Tag = { "ImageConstellation", group, "daytime_hidden" },
GUI = {
Name = name .. " Image",
Path = "/Milky Way/" .. guiPath,
@@ -148,7 +149,7 @@ local hide_zodiac_art = {
Command = [[
openspace.fadeOut("{zodiac}")
]],
Documentation = "fades down zodiac art work",
Documentation = "Fades down zodiac art work",
GuiPath = "/Constellations/Art",
IsLocal = false
}

View File

@@ -0,0 +1,71 @@
{
"additional_scripts": [
"openspace.action.triggerAction(\"os.nightsky.level_horizon_pitch\")"
],
"assets": [
"base",
"base_keybindings",
"events/toggle_sun",
"scene/solarsystem/planets/earth/earth",
"scene/solarsystem/planets/earth/satellites/satellites"
],
"camera": {
"altitude": 50.0,
"anchor": "Earth",
"latitude": 58.5877,
"longitude": 16.1652,
"type": "goToGeo"
},
"delta_times": [
1.0,
5.0,
10.0,
30.0,
60.0,
120.0,
300.0,
600.0,
900.0,
1800.0,
3600.0,
7200.0,
14400.0
],
"mark_nodes": [
"Earth",
"Mars",
"Moon",
"Sun",
"Venus",
"ISS"
],
"meta": {
"author": "OpenSpace Team",
"description": "A profile starting at night on the surface of earth looking out at the horizon. The city lights map has been disabled.",
"license": "MIT License",
"name": "Default",
"url": "https://www.openspaceproject.com",
"version": "1.0"
},
"properties": [
{
"name": "{earth_satellites}.Renderable.Enabled",
"type": "setPropertyValue",
"value": "false"
},
{
"name": "Scene.Earth.Renderable.Layers.NightLayers.Earth_at_Night_2012.Enabled",
"type": "setPropertyValueSingle",
"value": "false"
}
],
"time": {
"is_paused": false,
"type": "absolute",
"value": "2023-04-13T19:40:00"
},
"version": {
"major": 1,
"minor": 2
}
}

View File

@@ -79,6 +79,7 @@ struct Event {
RenderableDisabled,
CameraPathStarted,
CameraPathFinished,
CameraMovedPosition,
Custom
};
constexpr explicit Event(Type type_) : type(type_) {}
@@ -560,6 +561,18 @@ struct EventCameraPathFinished : public Event {
const tstring destination;
};
/**
* This event is created when the a camera moves location
*/
struct EventCameraMovedPosition : public Event {
static constexpr Type Type = Event::Type::CameraMovedPosition;
/**
* Creates an instance of an EventCameraMovedPosition event.
*/
EventCameraMovedPosition();
};
/**
* A custom event type that can be used in a pinch when no explicit event type is
* available. This should only be used in special circumstances and it should be

View File

@@ -58,7 +58,7 @@ public:
* Returns true if any of the velocities are larger than zero,
* i.e. wether an interaction happened
*/
bool hasNonZeroVelocities();
bool hasNonZeroVelocities(bool checkOnlyMovement = false);
protected:
struct InteractionState {

View File

@@ -98,6 +98,8 @@ public:
void tickIdleBehaviorTimer(double deltaTime);
void triggerIdleBehavior(std::string_view choice = "");
void tickMovementTimer(float deltaTime);
Camera* camera() const;
void setCamera(Camera* camera);
void clearPreviousState();
@@ -253,6 +255,8 @@ private:
IdleBehavior _idleBehavior;
float _idleBehaviorTriggerTimer = 0.f;
float _movementTimer = 0.f;
/**
* Decomposes the camera's rotation in to a global and a local rotation defined by
* CameraRotationDecomposition. The global rotation defines the rotation so that the

View File

@@ -1,22 +1,22 @@
openspace.globebrowsing.documentation = {
{
Name = "setNodePosition",
Arguments = { nodeIdentifer = "String", globeIdentifier = "String", latitude = "Number", longitude = "Number", altitude = "Number" },
Documentation =
"Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations. " ..
"Usage: openspace.globebrowsing.setNodePosition(" ..
"\"Scale_StatueOfLiberty\", \"Earth\", 40.000, -117.5, optionalAltitude)"
},
{
Name = "setNodePositionFromCamera",
Arguments = { nodeIdentifer = "String", useAltitude = "Number" },
Documentation =
"Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations" ..
" to match the camera. Only uses camera position not rotation. If useAltitude" ..
" is true, then the position will also be updated to the camera's altitude." ..
"Usage: openspace.globebrowsing.setNodePositionFromCamera(" ..
"\"Scale_StatueOfLiberty\", optionalUseAltitude)"
}
{
Name = "setNodePosition",
Arguments = { nodeIdentifer = "String", globeIdentifier = "String", latitude = "Number", longitude = "Number", altitude = "Number" },
Documentation =
"Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations. " ..
"Usage: openspace.globebrowsing.setNodePosition(" ..
"\"Scale_StatueOfLiberty\", \"Earth\", 40.000, -117.5, optionalAltitude)"
},
{
Name = "setNodePositionFromCamera",
Arguments = { nodeIdentifer = "String", useAltitude = "Boolean" },
Documentation =
"Sets the position of a SceneGraphNode that has GlobeTranslation/GlobeRotations" ..
" to match the camera. Only uses camera position not rotation. If useAltitude" ..
" is true, then the position will also be updated to the camera's altitude." ..
"Usage: openspace.globebrowsing.setNodePositionFromCamera(" ..
"\"Scale_StatueOfLiberty\", optionalUseAltitude)"
}
}
openspace.globebrowsing.setNodePosition = function (node_identifer, globe_identifier, lat, lon, altitude)
@@ -48,6 +48,3 @@ openspace.globebrowsing.setNodePositionFromCamera = function (node_identifer, us
openspace.setPropertyValueSingle('Scene.' .. node_identifer .. '.Translation.Altitude', alt);
end
end

View File

@@ -83,6 +83,14 @@ namespace {
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo UseCameraInfo = {
"UseCamera",
"Use Camera",
"If this value is 'true', the lat and lon are updated to match the camera",
// @VISIBILITY(?)
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(GlobeRotation)]] Parameters {
// [[codegen::verbatim(GlobeInfo.description)]]
std::string globe
@@ -99,6 +107,9 @@ namespace {
// [[codegen::verbatim(UseHeightmapInfo.description)]]
std::optional<bool> useHeightmap;
// [[codegen::verbatim(UseCameraInfo.description)]]
std::optional<bool> useCamera;
};
#include "globerotation_codegen.cpp"
} // namespace
@@ -115,6 +126,7 @@ GlobeRotation::GlobeRotation(const ghoul::Dictionary& dictionary)
, _longitude(LongitudeInfo, 0.0, -180.0, 180.0)
, _angle(AngleInfo, 0.0, 0.0, 360.0)
, _useHeightmap(UseHeightmapInfo, false)
, _useCamera(UseCameraInfo, false)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -140,6 +152,11 @@ GlobeRotation::GlobeRotation(const ghoul::Dictionary& dictionary)
_angle = p.angle.value_or(_angle);
_angle.onChange([this]() { setUpdateVariables(); });
addProperty(_angle);
_useCamera = p.useCamera.value_or(_useCamera);
_useCamera.onChange([this]() { setUpdateVariables(); });
addProperty(_useCamera);
}
void GlobeRotation::findGlobe() {
@@ -189,7 +206,7 @@ glm::vec3 GlobeRotation::computeSurfacePosition(double latitude, double longitud
}
void GlobeRotation::update(const UpdateData& data) {
if (_useHeightmap) {
if (_useHeightmap || _useCamera) {
// If we use the heightmap, we have to compute the height every frame
setUpdateVariables();
}
@@ -211,21 +228,31 @@ glm::dmat3 GlobeRotation::matrix(const UpdateData&) const {
return _matrix;
}
double lat = _latitude;
double lon = _longitude;
if (_useCamera) {
GlobeBrowsingModule* mod = global::moduleEngine->module<GlobeBrowsingModule>();
glm::dvec3 position = mod->geoPosition();
lat = position.x;
lon = position.y;
}
// Compute vector that points out of globe surface
glm::dvec3 yAxis = glm::dvec3(0.0);
if (_useHeightmap) {
const double angleDiff = 0.00001; // corresponds to a meter-ish
const glm::vec3 posCenter = computeSurfacePosition(_latitude, _longitude);
const glm::vec3 pos1 = computeSurfacePosition(_latitude, _longitude + angleDiff);
const glm::vec3 pos2 = computeSurfacePosition(_latitude + angleDiff, _longitude);
const glm::vec3 posCenter = computeSurfacePosition(lat, lon);
const glm::vec3 pos1 = computeSurfacePosition(lat, lon + angleDiff);
const glm::vec3 pos2 = computeSurfacePosition(lat + angleDiff, lon);
const glm::vec3 v1 = pos1 - posCenter;
const glm::vec3 v2 = pos2 - posCenter;
yAxis = glm::dvec3(glm::cross(v1, v2));
}
else {
float latitudeRad = glm::radians(static_cast<float>(_latitude));
float longitudeRad = glm::radians(static_cast<float>(_longitude));
float latitudeRad = glm::radians(static_cast<float>(lat));
float longitudeRad = glm::radians(static_cast<float>(lon));
yAxis = _globeNode->ellipsoid().geodeticSurfaceNormal(
{ latitudeRad, longitudeRad }
);

View File

@@ -54,6 +54,7 @@ private:
properties::DoubleProperty _longitude;
properties::DoubleProperty _angle;
properties::BoolProperty _useHeightmap;
properties::BoolProperty _useCamera;
RenderableGlobe* _globeNode = nullptr;

View File

@@ -84,6 +84,22 @@ namespace {
openspace::properties::Property::Visibility::User
};
constexpr openspace::properties::Property::PropertyInfo UseCameraInfo = {
"UseCamera",
"Use Camera",
"If this value is 'true', the lat and lon are updated to match the camera",
// @VISIBILITY(?)
openspace::properties::Property::Visibility::AdvancedUser
};
constexpr openspace::properties::Property::PropertyInfo UseCameraAltitudeInfo = {
"UseCameraAltitude",
"Use Camera Altitude",
"If this value is 'true', the altitude is updated to match the camera",
// @VISIBILITY(?)
openspace::properties::Property::Visibility::AdvancedUser
};
struct [[codegen::Dictionary(GlobeTranslation)]] Parameters {
// [[codegen::verbatim(GlobeInfo.description)]]
std::string globe
@@ -100,6 +116,12 @@ namespace {
// [[codegen::verbatim(UseHeightmapInfo.description)]]
std::optional<bool> useHeightmap;
// [[codegen::verbatim(UseCameraInfo.description)]]
std::optional<bool> useCamera;
// [[codegen::verbatim(UseCameraAltitudeInfo.description)]]
std::optional<bool> useCameraAltitude;
};
#include "globetranslation_codegen.cpp"
} // namespace
@@ -116,6 +138,8 @@ GlobeTranslation::GlobeTranslation(const ghoul::Dictionary& dictionary)
, _longitude(LongitudeInfo, 0.0, -180.0, 180.0)
, _altitude(AltitudeInfo, 0.0, -1e12, 1e12)
, _useHeightmap(UseHeightmapInfo, false)
, _useCamera(UseCameraInfo, false)
, _useCameraAltitude(UseCameraAltitudeInfo, false)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
@@ -143,6 +167,14 @@ GlobeTranslation::GlobeTranslation(const ghoul::Dictionary& dictionary)
_useHeightmap = p.useHeightmap.value_or(_useHeightmap);
_useHeightmap.onChange([this]() { setUpdateVariables(); });
addProperty(_useHeightmap);
_useCamera = p.useCamera.value_or(_useCamera);
_useCamera.onChange([this]() { setUpdateVariables(); });
addProperty(_useCamera);
_useCameraAltitude = p.useCameraAltitude.value_or(_useCameraAltitude);
_useCameraAltitude.onChange([this]() { setUpdateVariables(); });
addProperty(_useCameraAltitude);
}
void GlobeTranslation::fillAttachedNode() {
@@ -168,7 +200,7 @@ void GlobeTranslation::setUpdateVariables() {
}
void GlobeTranslation::update(const UpdateData& data) {
if (_useHeightmap) {
if (_useHeightmap || _useCamera) {
// If we use the heightmap, we have to compute the height every frame
setUpdateVariables();
}
@@ -192,11 +224,25 @@ glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
GlobeBrowsingModule* mod = global::moduleEngine->module<GlobeBrowsingModule>();
double lat = _latitude;
double lon = _longitude;
double alt = _altitude;
if (_useCamera) {
glm::dvec3 position = mod->geoPosition();
lat = position.x;
lon = position.y;
if (_useCameraAltitude) {
alt = position.z;
}
}
if (_useHeightmap) {
glm::vec3 groundPos = mod->cartesianCoordinatesFromGeo(
*_attachedNode,
_latitude,
_longitude,
lat,
lon,
0.0
);
@@ -205,18 +251,18 @@ glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
_position = mod->cartesianCoordinatesFromGeo(
*_attachedNode,
_latitude,
_longitude,
h.heightToSurface + _altitude
lat,
lon,
h.heightToSurface + alt
);
return _position;
}
else {
_position = mod->cartesianCoordinatesFromGeo(
*_attachedNode,
_latitude,
_longitude,
_altitude
lat,
lon,
alt
);
_positionIsDirty = false;
return _position;

View File

@@ -53,6 +53,8 @@ private:
properties::DoubleProperty _longitude;
properties::DoubleProperty _altitude;
properties::BoolProperty _useHeightmap;
properties::BoolProperty _useCamera;
properties::BoolProperty _useCameraAltitude;
RenderableGlobe* _attachedNode = nullptr;

View File

@@ -205,6 +205,11 @@ void log(int i, const EventCameraPathFinished& e) {
));
}
void log(int i, const EventCameraMovedPosition& e) {
ghoul_assert(e.type == EventCameraMovedPosition::Type, "Wrong type");
LINFO(fmt::format("[{}] EventCameraMovedPosition", i));
}
void log(int i, const CustomEvent& e) {
ghoul_assert(e.type == CustomEvent::Type, "Wrong type");
LINFO(fmt::format("[{}] CustomEvent: {} ({})", i, e.subtype, e.payload));
@@ -234,6 +239,7 @@ std::string_view toString(Event::Type type) {
case Event::Type::RenderableDisabled: return "RenderableDisabled";
case Event::Type::CameraPathStarted: return "CameraPathStarted";
case Event::Type::CameraPathFinished: return "CameraPathFinished";
case Event::Type::CameraMovedPosition: return "CameraMovedPosition";
case Event::Type::Custom: return "Custom";
default:
throw ghoul::MissingCaseException();
@@ -304,6 +310,9 @@ Event::Type fromString(std::string_view str) {
else if (str == "CameraPathFinished") {
return Event::Type::CameraPathFinished;
}
else if (str == "CameraMovedPosition") {
return Event::Type::CameraMovedPosition;
}
else if (str == "Custom") {
return Event::Type::Custom;
}
@@ -725,6 +734,10 @@ EventCameraPathFinished::EventCameraPathFinished(const SceneGraphNode* origin_,
, destination(temporaryString(destination_->identifier()))
{}
EventCameraMovedPosition::EventCameraMovedPosition()
: Event(Type)
{}
CustomEvent::CustomEvent(std::string_view subtype_, std::string_view payload_)
: Event(Type)
, subtype(subtype_)

View File

@@ -84,13 +84,16 @@ void CameraInteractionStates::resetVelocities() {
_globalRollState.velocity.setHard({ 0.0, 0.0 });
}
bool CameraInteractionStates::hasNonZeroVelocities() {
glm::dvec2 sum = globalRotationVelocity();
sum += localRotationVelocity();
bool CameraInteractionStates::hasNonZeroVelocities(bool checkOnlyMovement) {
glm::dvec2 sum = glm::dvec2(0.0);
sum += globalRotationVelocity();
sum += truckMovementVelocity();
sum += localRotationVelocity();
sum += localRollVelocity();
sum += globalRollVelocity();
if (!checkOnlyMovement) {
sum += localRotationVelocity();
sum += localRotationVelocity();
sum += localRollVelocity();
sum += globalRollVelocity();
}
// Epsilon size based on that even if no interaction is happening,
// there might still be some residual velocity in the variables
return glm::length(sum) > 0.001;

View File

@@ -713,6 +713,19 @@ void OrbitalNavigator::updateStatesFromInput(const MouseInputState& mouseInputSt
else {
tickIdleBehaviorTimer(deltaTime);
}
bool cameraLocationChanged = _mouseStates.hasNonZeroVelocities(true) ||
_joystickStates.hasNonZeroVelocities(true) ||
_websocketStates.hasNonZeroVelocities(true) ||
_scriptStates.hasNonZeroVelocities(true);
if (cameraLocationChanged && (_movementTimer < 0.f)) {
global::eventEngine->publishEvent<events::EventCameraMovedPosition>();
_movementTimer = _idleBehavior.idleWaitTime;
}
else if (!cameraLocationChanged) {
tickMovementTimer(deltaTime);
}
}
void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) {
@@ -902,6 +915,10 @@ void OrbitalNavigator::updateOnCameraInteraction() {
}
}
void OrbitalNavigator::tickMovementTimer(float deltaTime) {
_movementTimer -= deltaTime;
}
void OrbitalNavigator::tickIdleBehaviorTimer(double deltaTime) {
if (!_idleBehavior.shouldTriggerWhenIdle) {
return;