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

< Celestia < Celx Scripting < CELX Lua Methods

changedistance

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.

objectname = celestia:find( <string> )
celestia:select(objectname)
obs = celestia:getobserver()
obs:gotodistance(objectname, <distance>, <duration> )
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

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.