]> git.r.bdr.sh - rbdr/lissajous/blob - lib/systems/global_adjuster.js
f7433ca1e3c58e2867452ad990ea019dcaf05f20
[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 id: `global-adjuster-${i}-slider`,
32 min: '5',
33 max: '1000',
34 step: '5',
35 label: '𝜆',
36 className: 'lineLength',
37 get: () => node.configuration.lineLength.toString(),
38 set: (value) => (node.configuration.lineLength = parseFloat(value))
39 }));
40
41 this.adjusterContainer.appendChild(nodeElement);
42 ++i;
43 }
44
45 this.container.appendChild(this.adjusterContainer);
46 }
47
48 removed(){
49
50 this.container.removeChild(this.adjusterContainer);
51 delete this.adjusterContainer;
52 delete this.nodes;
53 }
54
55 update(){}
56 };
57
58