]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/main.js
6a2ea8f9cc427f38372ec488f8298be956c4c6a7
1 import Serpentity
from '@serpentity/serpentity';
2 import WebGLRenderer
from './systems/webgl_renderer';
3 import LissajousPositionUpdater
from './systems/lissajous_position_updater';
4 import { lissajousCurve
} from './factories/curves';
5 import { canvasId
, fps
} from './config';
17 const engine
= new Serpentity();
20 engine
.addSystem(new LissajousPositionUpdater(canvasId
));
21 engine
.addSystem(new WebGLRenderer(canvasId
));
24 engine
.addEntity(lissajousCurve());
26 internals
.engine
= engine
;
30 internals
.engine
= null;
35 const delta
= time
- internals
.currentTime
;
36 const interval
= 1000 / fps
;
38 if (delta
>= interval
) {
39 internals
.engine
.update(delta
);
40 internals
.currentTime
= time
;
43 internals
.started
&& window
.requestAnimationFrame(internals
.run
);
47 if (!internals
.started
) {
48 internals
.started
= true;
50 window
.requestAnimationFrame(internals
.run
);
55 if (internals
.started
) {
56 internals
.started
= false;