Files
OpenSpace/data/assets/examples/rotation/fixedrotation/fixed_moving-two-objects.asset
Alexander Bock 5008aa7cd7 Adding documentation and examples (#3541)
- Make the SourceType and DestinationType parameters required in the DashboardItemAngle
  - Shift the "UTC" string in the DashboardDate from the FormatString to the TimeFormat
  - Make the SourceType and DestinationType parameters for the DashboardItemDistance required
  - Add new "Deltatime" option to the DashboardItemFramerate.  Add examples for the DashboardItemFramerate
  - Fix issue where the inputstate would not update if no option was selected
  - Automatically disable simplification if a unit is requested in the asset for a DashboardItemSimulationIncrement or DashboardItemVelocity
2025-03-14 11:25:26 +01:00

88 lines
2.5 KiB
Lua

-- Rotation Following Two Moving Objects
-- This asset creates a rotation that places coordinate axes orbiting close to two spheres
-- with the y axis always pointing towards the first sphere and the z axis always pointing
-- towards the second sphere as the coordinate system moves around. The set of coordinate
-- axes are orbiting using a [KeplerTranslation](#space_transform_kepler) that provides a
-- configurable orbital motion. The use of the
-- [KeplerTranslation](#space_transform_kepler) in this example is arbitrary and the
-- FixedRotation does not depend on the use of that class. We use it in this example as we
-- want a moving object to show that the `FixedRotation` will always point at the object,
-- even as it is moving.
--
-- Note that in this example the coordinate system will be skewed as, in general, it is
-- not guaranteed that the direction from the node to the two spheres will be an
-- orthogonal vector.
local Sphere1 = {
Identifier = "FixedRotation_Example_Moving_TwoObjects_Sphere1",
Transform = {
Translation = {
Type = "StaticTranslation",
Position = { 3.0, -2.0, 0.0 }
}
},
Renderable = {
Type = "RenderableSphericalGrid"
},
GUI = {
Name = "FixedRotation - Moving Two Objects (Sphere 1)",
Path = "/Examples"
}
}
local Sphere2 = {
Identifier = "FixedRotation_Example_Moving_TwoObjects_Sphere2",
Transform = {
Translation = {
Type = "KeplerTranslation",
Eccentricity = 0.5,
SemiMajorAxis = 0.0025,
Inclination = 0.0,
AscendingNode = 0.0,
ArgumentOfPeriapsis = 0.0,
MeanAnomaly = 0.0,
Epoch = "2000 JAN 01 12:00:00",
Period = 10.0
}
},
Renderable = {
Type = "RenderableSphericalGrid"
},
GUI = {
Name = "FixedRotation - Moving Two Objects (Sphere 2)",
Path = "/Examples"
}
}
local Node = {
Identifier = "FixedRotation_Example_Moving_TwoObjects",
Transform = {
Rotation = {
Type = "FixedRotation",
Attached = "FixedRotation_Example_Moving_TwoObjects",
YAxis = Sphere1.Identifier,
YAxisOrthogonal = true,
ZAxis = Sphere2.Identifier
}
},
Renderable = {
Type = "RenderableCartesianAxes"
},
GUI = {
Name = "FixedRotation - Moving Two Objects",
Path = "/Examples"
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Sphere1)
openspace.addSceneGraphNode(Sphere2)
openspace.addSceneGraphNode(Node)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(Node)
openspace.removeSceneGraphNode(Sphere2)
openspace.removeSceneGraphNode(Sphere1)
end)