Vector3Curve

显示已弃用

*此内容使用人工智能(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)

返回 控制 X 通道 (类型 命名的第一个子实例)。如果未找到任何内容,将创建一个空的 FloatCurve


返回

返回 FloatCurve 控制 Y 通道 (类型 FloatCurve 命名的第一个子实例),用于控制 Y 通道。如果未找到任何内容,将创建一个空的 FloatCurve


返回

返回 FloatCurve 控制 Z 通道 (类型 FloatCurve 命名的第一个子实例),用于控制 Z 通道 (类型 Z 命名的第一个子实例).如果未找到任何内容,将创建一个空的 FloatCurve


返回

活动