Better random initialisation

pull/3/head
Jelmer van der Linde 2017-08-31 18:07:23 +02:00
rodzic 88c530ff1f
commit 1686265a99
1 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -122,7 +122,6 @@
class Sequence {
constructor(seq) {
this.offset = Math.random();
this.setSequence(seq);
}
@ -139,6 +138,8 @@
});
this.duration = this.steps.reduce((sum, step) => sum + step[1], 0);
this.offset = Math.random() * this.duration;
}
isValid() {
@ -149,7 +150,7 @@
if (isNaN(this.duration))
return undefined;
let dt = this.offset + time % this.duration;
let dt = (this.offset + time) % this.duration;
for (let i = 0; i < this.steps.length; ++i) {
if (dt < this.steps[i][1])