Celestia/Celx Scripting/CELX Lua Methods/CEL command changedistance

changedistance

edit

changedistance { duration <duration> rate <rate> }

Changes the camera's distance from the currently selected object in <duration> seconds, with the specified <rate>, to achieve a certain <distance>.

You must first use the select command to select an object.

Note: <distance> is NOT specified in the CEL changedistance command.

Arguments:

duration <duration>
Number of seconds to take when changing the distance. Default is 1.0 second.
rate <rate>
Speed at which to change the distance. default is 0.0.
Small values work best, from decimal values, to 5 or 6.
A negative value moves the camera closer to the object, while a positive value moves the camera further away ("+" sign is not necessary).


CELX equivalent:

Based on the observer:gotodistance() method.

The observer:gotodistance() method uses <distance> to determine to goto and has NO ability to define the <rate>. So you first have to find out the resulting distance using the CEL: changedistance command at the specified <rate> and then convert that distance into the <distance> parameter of the observer:gotodistance() method.

  • Find the target object with name <string> to go to and store in "objectname".
objectname = celestia:find( <string> )
  • Select "objectname" to be equivalent with CEL scripting.
    Actually, this step is not necessary in CELX scripting!
celestia:select(objectname)
  • Get observer instance of the active view and goto given <distance> of "objectname" in <duration> seconds.
    • <distance> is the distance from the center of target where to stop in km.
      • If no <distance> is given, the default distance = 20000 km.
      • If <distance> is smaller than the radius of the object, the goto ends within the object !!!
      • To obtain the radius of an object in km, you can use the object:radius() method.
    • <duration> is the number of seconds the goto should take.
      • If no <duration> is given, the default time = 5.0 seconds !!!
obs = celestia:getobserver()
obs:gotodistance(objectname, <distance>, <duration> )
  • Wait <duration> seconds.
wait( <duration> )

Summarized:

objectname = celestia:find( <string> )
celestia:select(objectname)
obs = celestia:getobserver()
obs:gotodistance(objectname, <distance>, <duration> )
wait( <duration> )

Example:
The following example selects the Sun, travels to it, then selects Earth, travels to it, and then spends 2.5 seconds changing the display distance to be further away from the Earth.

CEL:

select { object "Sol" }
goto   { time 3 }
wait   { duration 5 }
select { object "Sol/Earth" }
goto   { time 3 }
wait   { duration 5 }
changedistance { duration 2.5 rate 0.5 }
wait   { duration 2.5 }

CELX:

sun = celestia:find("Sol")
celestia:select(sun)
obs = celestia:getobserver()
obs:goto(sun, 3.0)
wait(5.0)
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs:goto(earth, 3.0)
wait(5.0)
obs:gotodistance(earth, 89048+6378, 2.5)
wait(2.5)

Back to CEL command index