目前已知缓动系统方法只能从A点运动到B点,然后再B到C,缓动系统可以A到C时曲线运动吗?或者中间不是直线,随机曲线也行、正弦余弦都可以那种,请问有解题思路吗?
找找api,贝塞尔曲线。
可以直接用的
public static bezierTo(target: any, duration: number, p1: Vec3, cp: Vec3, p2: Vec3,opts?: any): Tween<any> {
opts = opts || Object.create(null);
let twoBezier = (t: number, p1: Vec3, cp: Vec3, p2: Vec3) => {
let x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
let y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
let z = (1 - t) * (1 - t) * p1.z + 2 * t * (1 - t) * cp.z + t * t * p2.z;
return new Vec3(x, y, z);
};
opts.onUpdate = (_arg: Vec3, ratio: number) => {
let newPos = twoBezier(ratio, p1, cp, p2);
target.worldPosition = newPos;
};
return tween(target).to(duration, {}, opts);
}
3赞
找到问题了,是我停止缓动方式错了,不是停止node,




