kopia lustrzana https://github.com/geodienst/lighthousemap
Better random initialisation
rodzic
88c530ff1f
commit
1686265a99
|
@ -122,7 +122,6 @@
|
||||||
|
|
||||||
class Sequence {
|
class Sequence {
|
||||||
constructor(seq) {
|
constructor(seq) {
|
||||||
this.offset = Math.random();
|
|
||||||
this.setSequence(seq);
|
this.setSequence(seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +138,8 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this.duration = this.steps.reduce((sum, step) => sum + step[1], 0);
|
this.duration = this.steps.reduce((sum, step) => sum + step[1], 0);
|
||||||
|
|
||||||
|
this.offset = Math.random() * this.duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
isValid() {
|
isValid() {
|
||||||
|
@ -149,7 +150,7 @@
|
||||||
if (isNaN(this.duration))
|
if (isNaN(this.duration))
|
||||||
return undefined;
|
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) {
|
for (let i = 0; i < this.steps.length; ++i) {
|
||||||
if (dt < this.steps[i][1])
|
if (dt < this.steps[i][1])
|
||||||
|
|
Ładowanie…
Reference in New Issue