refactoring

This commit is contained in:
2025-11-25 17:44:09 +02:00
parent d89522f405
commit c6d4ce9007
6 changed files with 29 additions and 70 deletions
+6 -9
View File
@@ -1,9 +1,6 @@
import { Clock } from 'three';
class MotionEngine {
constructor() {
const aq = [];
const clock = new Clock();
this.animationQueue = aq;
function calcValues(target, values, initial, k = 1, mode = 'offset') {
@@ -30,7 +27,7 @@ class MotionEngine {
}
// a = {o-object, a-attributes, t-time, f-finish event, d-delay, m-mode, r-repeat,
// rd-repeat the delay, rf-reset on finish, u-on update}
// rd-repeat the delay, rf-reset on finish, u-on update, s-scope}
this.add = function (a) {
a = Array.isArray(a) ? a : [a];
a.forEach(e => {
@@ -65,10 +62,9 @@ class MotionEngine {
}
};
this.update = () => {
let t = clock.getDelta();
this.update = (delta) => {
if (aq.length) {
aq.forEach(e => this.animate(e, t));
aq.forEach(e => this.animate(e, delta));
this.clear();
}
};
@@ -105,8 +101,9 @@ class MotionEngine {
return aq.find(e => e.o == object);
};
this.isIdle = function () {
return aq.length == 0;
this.isIdle = function (scope) {
if (!scope) return aq.length == 0;
return aq.filter(e => e.s == scope).length == 0
};
}
}