Turn arrays into smooth functions. Interpolation functions are ported from Smooth.js.
pod 'Smooth'
github "ryohey/Smooth.swift"
In order to make as little dependence as possible, Smooth.swift does not use SceneKit, but in order to make it easy to use it, a VectorType
is added.
Since SCNVector3
and SCNVector4
are concrete types already implementing VectorType
, you can use VectorInterpolator
by simply specifying it with extension.
extension SCNVector3: Vector3, VectorType {}
extension SCNVector4: Vector4, VectorType {}
VectorInterpolator
is generated by providing Interpolator
which interpolates for each element.
VectorInterpolator(points: [SCNVector3(0.1, 0.2, 0.5), SCNVector3(0.5, 0.6, 0.1)], interpolatorCreator: { LinearInterpolator(points: $0).interpolate })