Celestia/Celx 指令碼/CELX Lua 方法/CEL 命令 changedistance
外觀
changedistance { duration <duration> rate <rate> }
在 <duration> 秒內,以指定的 <rate> 改變相機與當前選定物體的距離,以達到特定的 <distance>。
您必須先使用 select 命令選擇一個物體。
注意: <distance> 在 CEL changedistance 命令中未指定。
引數
- duration <duration>
- 改變距離所需的時間(秒)。預設值為 1.0 秒。
- rate <rate>
- 改變距離的速度。預設值為 0.0。
小數值效果最佳,從十進位制值到 5 或 6。
負值使相機更靠近物體,正值使相機遠離物體(“+”號不需要)。
CELX 等效項
基於 observer:gotodistance() 方法。
observer:gotodistance() 方法使用 <distance> 來確定移動到的位置,並且無法定義 <rate>。因此,您必須首先使用 CEL:changedistance 命令在指定的 <rate> 下找出最終的距離,然後將該距離轉換為 observer:gotodistance() 方法的 <distance> 引數。
- 找到名為 <string> 的目標物體,並將其儲存在 "objectname" 中。
objectname = celestia:find( <string> )
- 選擇 "objectname" 以等效於 CEL 指令碼。
實際上,在 CELX 指令碼中不需要此步驟!
celestia:select(objectname)
- 獲取活動檢視的觀察者例項,並在 <duration> 秒內移動到 "objectname" 的指定 <distance> 處。
- <distance> 是從目標中心到停止位置的距離(公里)。
- 如果沒有指定 <distance>,則預設距離 = 20000 公里。
- 如果 <distance> 小於物體的半徑,則移動將在物體內部結束 !!!
- 要獲取物體的半徑(公里),可以使用 object:radius() 方法。
- <duration> 是移動所需的時間(秒)。
- 如果沒有指定 <duration>,則預設時間 = 5.0 秒 !!!
- <distance> 是從目標中心到停止位置的距離(公里)。
obs = celestia:getobserver() obs:gotodistance(objectname, <distance>, <duration> )
- 等待 <duration> 秒。
wait( <duration> )
總結
objectname = celestia:find( <string> ) celestia:select(objectname) obs = celestia:getobserver() obs:gotodistance(objectname, <distance>, <duration> ) wait( <duration> )
示例
以下示例選擇太陽,移動到太陽,然後選擇地球,移動到地球,最後花費 2.5 秒更改顯示距離,使其遠離地球。
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)