javascript - Save dat.gui presets for dynamically added controls? -
i'm dynamically adding controls dat.gui interface, "save settings" functionality doesn't recognize them.
var mygui = new dat.gui(); mygui.remember(mygui); // standard way of adding command mygui.control1 = 0.0; var command = mygui.add(mygui, 'control1', -1, 1); // adding controls dynamically var myarray = ['control2', 'control3']; var controls = []; (x in myarray) { controls[myarray[x]] = 0.0; var newcontrol = mygui.add(controls, myarray[x], -1, 1); } the controls work expected, when click gear icon, settings json contains first control, or other controls add together in normal way:
{ "preset": "default", "closed": false, "remembered": { "default": { "0": { "control1": 0.5, } } }, "folders": {} } i assume i'm confusing remember() functionality somehow, ideas?
the lines in loop should be:
mygui[myarray[x]] = 0.0; var newcontrol = mygui2.add(mygui, myarray[x], -1, 1); the first parameter of add function performs 2 functions: both source of sec parameter (the name of command added, in case myarray[x]) destination. can store command names wherever like, if first parameter isn't gui, remember() function won't know controls, , won't added gui's __rememberedobjects attribute or saved in json object.
javascript json dat.gui
No comments:
Post a Comment