1 Star 0 Fork 0

坐看彼岸花开花败/贝塞尔曲线路径

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
motion.js 886 Bytes
一键复制 编辑 原始数据 按行查看 历史
坐看彼岸花开花败 提交于 2020-12-09 14:19 . 零碎调整
import { get } from "lodash";
import { parse } from "./index";
export default class Motion {
constructor(points, duration) {
this.bezierList = parse(points);
if (this.bezierList.length <= 0) {
return;
}
this.t = 0;
this.moving = false;
this.speed = (1 * this.bezierList.length) / duration;
this.onCompleted = null;
}
start() {
this.moving = true;
this.t = 0;
}
stop() {
this.moving = false;
this.onCompleted && this.onCompleted();
}
update(dt) {
if (!this.moving) {
return;
}
this.t += this.speed * dt;
const bezier = this.bezierList[Math.floor(this.t)];
if (bezier) {
return bezier.getPos(this.t % 1);
} else {
this.stop();
return null;
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/sitseebloomfade/bessel-curve-path.git
git@gitee.com:sitseebloomfade/bessel-curve-path.git
sitseebloomfade
bessel-curve-path
贝塞尔曲线路径
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385