]> git.r.bdr.sh - rbdr/lissajous/blob - lib/systems/global_adjuster.js
7f6df91f8f4dbfb6d96584180b300f37c69c3c65
[rbdr/lissajous] / lib / systems / global_adjuster.js
1 import { System } from '@serpentity/serpentity';
2 import Frequent from '../nodes/configurable';
3 import { settingsContainer, slider } from '../factories/ui';
4
5 export default class GlobalAdjuster extends System {
6
7 constructor(container) {
8
9 super();
10 this.container = container;
11 }
12
13 added(engine){
14
15 this.nodes = engine.getNodes(Frequent);
16 const container = document.getElementById('settings');
17 this.adjusterContainer = settingsContainer({
18 id: 'global-adjuster',
19 label: 'Global'
20 });
21
22 let i = 0;
23 for (const node of this.nodes) {
24 const nodeElement = settingsContainer({
25 id: `global-adjuster-${i}`,
26 label: 'Line',
27 level: 3
28 });
29
30 nodeElement.appendChild(slider({
31 min: '5',
32 max: '2000',
33 step: '1',
34 label: '𝜆',
35 className: 'lineLength',
36 get: () => node.configuration.lineLength.toString(),
37 set: (value) => (node.configuration.lineLength = parseFloat(value))
38 }));
39
40 this.adjusterContainer.appendChild(nodeElement);
41 ++i;
42 }
43
44 this.container.appendChild(this.adjusterContainer);
45 }
46
47 removed(){
48
49 this.container.removeChild(this.adjusterContainer);
50 delete this.adjusterContainer;
51 delete this.nodes;
52 }
53
54 update(){}
55 };
56
57