Smooth.swift
将数组转换为平滑函数。插值函数移植自Smooth.js。
安装
CocoaPods
pod 'Smooth'
Carthage
github "ryohey/Smooth.swift"
输入
插值
平滑处理
与SceneKit结合使用
为了尽量减少依赖,Smooth.swift没有使用SceneKit,但为了便于使用,添加了VectorType
。由于SCNVector3
和SCNVector4
已经实现了VectorType
的具体类型,您可以通过扩展简单地使用VectorInterpolator
。
extension SCNVector3: Vector3, VectorType {}
extension SCNVector4: Vector4, VectorType {}
VectorInterpolator
是通过提供用于每个元素的Interpolator
来生成的。
VectorInterpolator(points: [SCNVector3(0.1, 0.2, 0.5), SCNVector3(0.5, 0.6, 0.1)], interpolatorCreator: { LinearInterpolator(points: $0).interpolate })