Comments (11)
I thought I was having this problem, but the problem when the object being
saved controls are part of a folder eg:
obj = { test: 0};
gui.add(obj, "test");
gui.remember(obj); // works ok on save
obj = { test: 0};
var folder = gui.addFolder("folder");
folder.add(obj, "test");
gui.remember(obj); // fails on save
Original comment by [email protected]
on 4 Jul 2012 at 8:12
from dat-gui.
[deleted comment]
from dat-gui.
I have this problem in Chrome Version 25.0.1364.160 Built on Ubuntu 12.04,
running on LinuxMint 13 (25.0.1364.160-0ubuntu0.12.04.1)
This can be seen by clicking the Save button in Dat.gui, on the page
here: http://codepen.io/lingo/full/KuDse
Original comment by [email protected]
on 5 May 2013 at 6:54
from dat-gui.
I have this issue as well, with or without folders.
Uncaught TypeError: Cannot read property 'forEach' of undefined
dat.gui.js:110
Windows 7 64bit
Chrome and firefox.
Strangely, the workshop demo works fine.
Original comment by [email protected]
on 9 Aug 2013 at 11:07
from dat-gui.
Sorry guys,
Just to clarify what works and what doesn't since I just discovered a quirky
behaviour.
On the workshop demo, everything except local storage works properly.
On my own project, local storage doesn't work either, and to make matters
worse, it throws the TypeError when I try to access the preset settings (gear
icon), Save, or New. But if I hit Revert, the preset settings, Save and New now
work! Local storage still doesn't work, but atleast I can grab the JSON from
the preset settings popup and paste it into a document.
I verified this behaviour on http://codepen.io/lingo/full/KuDse
I thought a quickfix would be to run gui.revert() or gui.revert(gui) after you
initialize your gui but it does nothing.
Cheers,
Tom
Original comment by [email protected]
on 9 Aug 2013 at 11:25
from dat-gui.
One more update!
Apparently gui.revert() DOES work as long as you use load some JSON upon
instantiation.
var gui = new dat.GUI({
load: presetJSON
});
gui.remember(sceneProperties);
gui.revert();
So there you have it. As long as you manually hit the Revert button the first
time you use the GUI to generate your initial JSON, and then using the
load:JSON and gui.revert() trick, it works.
Original comment by [email protected]
on 9 Aug 2013 at 11:52
from dat-gui.
SAME ISSUE!
can anyone provide a working example of presets?
Original comment by [email protected]
on 6 Dec 2013 at 5:31
from dat-gui.
I got it to stop bitching like this....
gui = new dat.GUI({
load: {
"preset": "Default",
"closed": false,
"remembered": {
"Default": {}
},
"folders": {}
}
});
gui.revert(); // stop it bitching
gui.save(); // enable revert on Defaults
... no need to create presets first, just use the above. If it saves to
localStorage then it will ignore the load: value, so seems to be safe enough.
Thanks [email protected]
Original comment by [email protected]
on 5 Jan 2014 at 1:14
from dat-gui.
Guys, I just spent an hour hunting through the code and I figured it out. I
have no idea who wrote this stuff, but it's some absurd spaghetti at parts.
***
TypeError / forEach Problem: If your controllers array is not initialized,
you'll get the forEach error. Make sure you call remember() right after you
instantiate the GUI object.
var obj = { foo: 'bar' };
var gui = new dat.GUI();
gui.remember(obj);
I wanted to fix this bug anyway, so around Line 109 I add the following tests
for obj existence:
if (!obj) return;
if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
***
LocalStorage Problem: saveToLocalStorage() is a private function for GUI and
curiously wrapped in a block where only the getters and setters are defined.
The issue is that block is separate from the main method definitions! Thus,
besides the getters and setters, the rest of GUI's common methods cannot call
saveToLocalStorage(). To make matters more weird, it is never called manually.
The function is only bound to a DOM event on window for when the tab closes...
who the hell wrote this?
Fuck, well I tracked this down too. Around Line 1676 add:
var saveToLocalStorage;
Then expose the private save function around Line 1930:
saveToLocalStorage = function () {
if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true') {
localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject()));
}
}
this.saveToLocalStorageIfPossible = saveToLocalStorage;
FINALLY add calls to saveToLocalStorageIfPossible() in GUI's save() and
saveAs() methods (Line 2226):
save: function() {
if (!this.load.remembered) {
this.load.remembered = {};
}
this.load.remembered[this.preset] = getCurrentPreset(this);
markPresetModified(this, false);
this.saveToLocalStorageIfPossible();
},
After it all, you'll get LocalStorage + presets working just fine.
Attached is the patched file. Good god, I can't believe how much time I just
spent on that.
Original comment by [email protected]
on 23 Jan 2014 at 7:04
Attachments:
from dat-gui.
Nice work! Frankly, I still use this library but only for its GUI. The
saving/loading I now do manually with JSON and a mongoDB; not as simple, but
has the advantage of collaborative presets.
Original comment by [email protected]
on 23 Jan 2014 at 2:58
from dat-gui.
Fixed this and merged it to a maintained github-hosted fork of dat.gui
https://github.com/dataarts/dat.gui/commit/f36a8273a1162559a24b9d574aeb7c5112342
9ea
Original comment by [email protected]
on 23 Jan 2014 at 11:24
from dat-gui.
Related Issues (20)
- change radius of THREE.SphereGeometry with slider HOT 2
- Add to Bower index
- extremely hard to get to hue field without it disappearing
- Patch for /.gitignore HOT 1
- changing bounds of variable dynamically HOT 1
- how to disable "h" shortcut?
- Fails when used in Chrome packaged app, since version 34
- Saving parameters with dat.gui seems broken HOT 2
- precision problem HOT 1
- localStorage support check borks in packaged Chrome app HOT 2
- Does not work with bootstrap 3 HOT 2
- Negative floating point range initialises incorrectly
- requestAnimationFrame
- Adding finer control to sliders
- Events not sent when creating a "number" controller with both min() and max() called explicitely
- step() has no effect on a "number" controller with min and max set
- error trying to remove a controller
- How to control checkbox and text in dat.gui?
- Dropdown menu still bugs out, rapidly switching choice selection HOT 1
- Changing presets appears to trigger component change functions incorrectly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dat-gui.