Files
OpenSpace/modules/globebrowsing/scripts/node_support.lua
Micah Acinapura 9be88fdea8 added more scale objects and helper file (#2605)
* added more scale objects and helper file

* Update file identifiers

* reworked scale models with node support script

* using url sync for models that need to be updated

---------

Co-authored-by: Alexander Bock <mail@alexanderbock.eu>
2023-04-15 17:26:38 -04:00

54 lines
3.2 KiB
Lua

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)"
}
}
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.getGeoPositionForCamera();
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