add lerp function to util and lerp method to vector3
This commit is contained in:
@ -216,6 +216,25 @@ end
|
||||
function Vector3:copy()
|
||||
return Vector3(self)
|
||||
end
|
||||
|
||||
---Returns a new vector as a linear interpolation between self and b.
|
||||
---@param b vectorlike
|
||||
---@param t number
|
||||
---@return Vector3
|
||||
function Vector3:lerp(b, t)
|
||||
-- return self:copy()
|
||||
if not is_weak_vector3(b) then
|
||||
error("Vector3: b must be a Vector3-like table. Returning copy of self.")
|
||||
return self:copy()
|
||||
end
|
||||
local w = Vector3(b)
|
||||
return Vector3{
|
||||
util.lerp(self.x, w.x, t),
|
||||
util.lerp(self.y, w.y, t),
|
||||
util.lerp(self.z, w.z, t),
|
||||
}
|
||||
end
|
||||
|
||||
---- CONSTANTS
|
||||
|
||||
Vector3.UP = Vector3(0, 1, 0)
|
||||
|
Reference in New Issue
Block a user