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