[ad_1]
Hi all, Interpolation in tweens helps to create very clean motion between a number of values, however at present I don’t see this function within the Cocos. I believe it won’t be laborious so as to add this to the tween object.
Here is my at present code of implementation in my recreation:
const highWorldPosition = dishesHolder.worldPosition
.clone()
.add(dish.worldPosition)
.multiplyScalar(0.5)
.add3f(0, 2, 0);
const interpolationPositions = {
x: [
dish.worldPosition.x,
highWorldPosition.x,
dishesHolder.worldPosition.x,
],
y: [
dish.worldPosition.y,
highWorldPosition.y,
dishesHolder.worldPosition.y,
],
z: [
dish.worldPosition.z,
highWorldPosition.z,
dishesHolder.worldPosition.z,
],
};
const worldPosAnimationVec = new Vec3();
tween({ v: 0 })
.to(
0.5,
{ v: 1 },
{
onUpdate(goal?, ratio?) {
for (const key in interpolationPositions) {
worldPosAnimationVec[key] = Interpolation.Bezier(
interpolationPositions[key],
ratio
);
}
dish.worldPosition = worldPosAnimationVec;
},
}
)
.begin();
Here I want clean motion between 3 vectors, I received Interpolation perform from Tween.js:
I hope in future variations we may use them in such implementation:
tween(obj.place).to(2, {x: [1, 4, 5], y: [0, 2, 5], z: [5, 3, 2]}, {interpolation: "bezier"}).begin();
[ad_2]