Vector3Curve

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

代表 3D 向量曲線,組合三個 FloatCurve 實例。每個子 FloatCurve 可以通過 Vector3Curve:X()Vector3Curve:Y()Vector3Curve:Z() 方法進行訪問。三軸可以同時透過方法 Vector3Curve:GetValueAtTime() 進行樣本化。

範例程式碼

Creating a Vector3Curve

--- Vector3Curve
local function createVector3Curve()
local vectorCurve = Instance.new("Vector3Curve")
local curveX = vectorCurve:X() -- creates and returns a FloatCurve animating the X channel
local curveY = vectorCurve:Y() -- creates and returns a FloatCurve animating the Y channel
-- Not setting the Z channel will leave the Z channel not animated.
-- A missing curve or a curve with no keys don't participate in the animation
local key = FloatCurveKey.new(0, 1) -- creates a key at time 0 and with value 1
curveX:InsertKey(key)
curveY:InsertKey(key)
local key2 = FloatCurveKey.new(1, 2) -- creates a key at time 1 and with value 2
curveX:InsertKey(key2)
curveY:InsertKey(key2)
return vectorCurve
end
local function testVector3Curve()
local curve = createVector3Curve()
-- sampling the curve at a given time (returns a vector3)
print(curve:GetValueAtTime(0)) -- returns 1, 1, void
print(curve:GetValueAtTime(0.5)) -- returns 1.5, 1.5, void (result of cubic interpolation with auto tangents)
curve:X():RemoveKeyAtIndex(1)
curve:X():RemoveKeyAtIndex(1)
print(curve:X().Length) -- number of keys = 0
print(curve:GetValueAtTime(0.5)) -- returns void, 1.5, void
end
testVector3Curve()

概要

方法

屬性

方法

GetValueAtTime

返回傳送時間參數中的三個 FloatCurves (X、Y、Z) 以一個三數字陣列的形式。如果通道曲線缺少或在曲線中找不到鑰匙,通道將評為 nil

參數

time: number

取得值的時間。

預設值:""

返回

傳送時間參引數中的三個 FloatCurves (X、Y、Z)。

返回 FloatCurve 控制 X 通道 (類型 FloatCurve 命名的第一個子實例),用於控制 X 通道。如果找不到任何一個,將創建一個空的 FloatCurve


返回

返回 FloatCurve 控制 Y 通道 (命名為 FloatCurve 的第一個子實例類型),用於控制 Y 通道。如果找不到任何一個,將創建一個空的 FloatCurve


返回

返回 FloatCurve 控制 Z 通道 (命名為 FloatCurve 的第一個子實例類型),用於控制 Z 通道。如果找不到任何一個,將創建一個空的 FloatCurve


返回

活動