Slide 16
Slide 16 text
クロックジェネレータ
export class FrameService {
constructor() {
this.startTime = window.performance.now();
this.subject = new Subject();
}
run(bpm) {
let fps = 1 / (60 / bpm / 4);
let loop = () => {
requestAnimationFrame(loop);
const lastTime = window.performance.now();
const frame = ~~((lastTime - this.startTime) / (1000.0 / fps));
this.subject.next(frame);
};
loop();
}
get observable() {
return this.subject;
}
}