RenderableTravelSpeed docs update and more examples (#3885)

* Update docs to clairify that the travel is synced to the simulation time

* Add a couple more examples for RenderableTravelSpeed

* Fix broken example and add description of the things showed

It's not as apparent for the speed indicators, as they will not naturally be shown when focusing

* Fix typo

Clarify that simulation delta time is controlling the speed

* Apply suggestions from code review

Co-authored-by: Alexander Bock <alexander.bock@liu.se>

* Apply suggestions from code review

* Make comments in examples more consistent

---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Emma Broman
2026-02-02 11:53:43 +01:00
committed by GitHub
parent 15a44acff1
commit 6a26bb1b62
3 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
-- Indicator Length and Width
-- This example creates a light speed indicator where the length and width of the line
-- have been adjusted for the indicator to be more visible across the large distance from
-- Earth to Mars. The line will move according to the speed of light.
local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
local marsAsset = asset.require("scene/solarsystem/planets/mars/mars")
local Node = {
Identifier = "RenderableTravelSpeed_Example_LengthAndWidth",
Parent = earthAsset.Earth.Identifier,
Renderable = {
Type = "RenderableTravelSpeed",
Target = marsAsset.Mars.Identifier,
-- Length in seconds, where 1 second = distance light travels in 1 second
IndicatorLength = 60.0,
-- Increase line width for visibility
LineWidth = 5.0
},
GUI = {
Name = "RenderableTravelSpeed - Indicator Length and Width",
Path = "/Examples",
Description = [[
A light speed indicator from Earth to Mars. The indicator's length corresponds to
60 seconds of travel at the speed of light.
]]
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Node)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(Node)
end)

View File

@@ -0,0 +1,40 @@
-- Custom Travel Speed
-- This example creates a speed indicator; a line that moves with a given speed from the
-- parent node (Earth) to the target node (Jupiter). The travel speed is here set to 1
-- light-hour per second.
local earthAsset = asset.require("scene/solarsystem/planets/earth/earth")
local jupiterAsset = asset.require("scene/solarsystem/planets/jupiter/jupiter")
local Node = {
Identifier = "RenderableTravelSpeed_Example_TravelSpeed",
Parent = earthAsset.Earth.Identifier,
Renderable = {
Type = "RenderableTravelSpeed",
Target = jupiterAsset.Jupiter.Identifier,
TravelSpeed = 1.07925285e9, -- 1 light-hour in meters
-- Length in seconds, where 1 second = distance traveled in 1 second at the set
-- travel speed
IndicatorLength = 60,
-- Increase line width for visibility
LineWidth = 5.0
},
GUI = {
Name = "RenderableTravelSpeed - Light-hour Speed Indicator",
Path = "/Examples",
Description = [[
A speed indicator from Earth to Jupiter, moving at 1 light-hour per second. The
indicator's length corresponds to 60 seconds of travel at the set travel speed.
]]
}
}
asset.onInitialize(function()
openspace.addSceneGraphNode(Node)
end)
asset.onDeinitialize(function()
openspace.removeSceneGraphNode(Node)
end)

View File

@@ -105,6 +105,10 @@ namespace {
// to show more information related to the distance traveled. For example, a length
// of 1 shows how far an object would move over a duration of one second based on the
// selected speed.
//
// The indicator will move from the parent to the target node based on the currently
// set simulation time and the set `TravelSpeed`. That is, increasing the simulation
// speed makes the indicator move faster.
struct [[codegen::Dictionary(RenderableTravelSpeed)]] Parameters {
// [[codegen::verbatim(TargetInfo.description)]]
std::string target [[codegen::identifier()]];