Files
OpenSpace/modules/globebrowsing/scripts/node_support.lua
Emma Broman 1fbd5e827d Utilize new docs functionality in API scripts that are defined in Lua files (#3505)
* Fix a reference to a deprecated and renamed function in navigationstate docs

* Review documentation for scripts defined in .lua files

And utilize new markdown functionality

* Update renderable box grid size specs

So that it can have a size less than 1, and throws a specification error when the size is given as negative

* Fix some issues with the gaia filtering scripts

* Try adding param documentation to the lua script documentation

It works!

* Utiliize mroe markdown features in the updated documentations

* Add function parameter info and make small updated to gaia filtering functions

* Replace a long parameter info in description with `param` description

* Update usage examples

* Add example of how to create debug axes for the current SGN
2025-02-11 08:59:33 +01:00

88 lines
4.2 KiB
Lua

openspace.globebrowsing.documentation = {
{
Name = "setNodePosition",
Arguments = {
{ "nodeIdentifier", "String" },
{ "globeIdentifier", "String" },
{ "latitude", "Number" },
{ "longitude", "Number" },
{ "altitude", "Number?" }
},
Documentation = [[
Sets the position of a scene graph node that has a
[GlobeTranslation](#globebrowsing_translation_globetranslation) and/or
[GlobeRotation](#globebrowsing_rotation_globerotation).
Usage:
```lua
openspace.globebrowsing.setNodePosition(
"Scale_StatueOfLiberty", "Earth", 40.000, -117.5, optionalAltitude
)
```
\\param nodeIdentifier The identifier of the scene graph node to move
\\param globeIdentifier The identifier of the [RenderableGlobe](#globebrowsing_renderableglobe)
that the object should be put on
\\param latitude The latitude value for the new position, in degrees
\\param longitude The longitude value for the new position, in degrees
\\param altitude An optional altitude value for the new position, in meters. If
excluded, an altitude of 0 will be used
]]
},
{
Name = "setNodePositionFromCamera",
Arguments = {
{ "nodeIdentifer", "String" },
{ "useAltitude", "Boolean?" }
},
Documentation = [[
Sets the position of a scene graph node that has a
[GlobeTranslation](#globebrowsing_translation_globetranslation) and/or
[GlobeRotation](#globebrowsing_rotation_globerotation) 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:
```lua
openspace.globebrowsing.setNodePositionFromCamera(
"Scale_StatueOfLiberty", optionalUseAltitude
)
```
\\param nodeIdentifier The identifier of the scene graph node to move
\\param useAltitude If true, the camera's altitude will also be used for the new
positions. Otherwise, it will not.
]]
}
}
openspace.globebrowsing.setNodePosition = function (node_identifer, globe_identifier, lat, lon, altitude)
openspace.setParent(node_identifer, globe_identifier)
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Globe", globe_identifier);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Latitude", lat);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Longitude", lon);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Globe", globe_identifier);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Latitude", lat);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Longitude", lon);
if (altitude) then
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Altitude", altitude);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Altitude", altitude);
end
end
openspace.globebrowsing.setNodePositionFromCamera = function (node_identifer, use_altitude)
local lat, lon, alt = openspace.globebrowsing.geoPositionForCamera();
local camera = openspace.navigation.getNavigationState();
openspace.setParent(node_identifer, camera.Anchor)
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Globe", camera.Anchor);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Latitude", lat);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Longitude", lon);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Globe", camera.Anchor);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Latitude", lat);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Rotation.Longitude", lon);
if (use_altitude) then
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Altitude", alt);
openspace.setPropertyValueSingle("Scene." .. node_identifer .. ".Translation.Altitude", alt);
end
end