2011-02-09 21:50:24 +00:00
|
|
|
<!doctype html>
|
2011-04-19 00:27:33 +00:00
|
|
|
<html>
|
2011-01-31 04:53:33 +00:00
|
|
|
<head>
|
2011-04-19 17:43:44 +00:00
|
|
|
|
2011-04-18 19:01:45 +00:00
|
|
|
<title>dat.gui</title>
|
2011-02-11 19:12:07 +00:00
|
|
|
|
2011-04-19 18:09:09 +00:00
|
|
|
<link rel='icon' type='image/png' href='docs/assets/favicon.png'/>
|
2011-04-19 17:43:44 +00:00
|
|
|
|
|
|
|
<!--Minified build-->
|
2011-04-19 17:45:15 +00:00
|
|
|
<!--<script type='text/javascript' src='build/DAT.GUI.min.js'></script>-->
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--Build--->
|
|
|
|
<!--<script type='text/javascript' src='build/DAT.GUI.js'></script>-->
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--All source-->
|
2011-04-19 17:45:15 +00:00
|
|
|
<link href='src/DAT/GUI/GUI.css' media='screen' rel='stylesheet' type='text/css'/>
|
|
|
|
<script type='text/javascript' src='src/DAT/GUI/GUI.js'></script>
|
2011-04-19 21:51:37 +00:00
|
|
|
<script type='text/javascript' src='src/DAT/GUI/ControllerNumberSlider.js'></script>
|
2011-04-19 17:45:15 +00:00
|
|
|
<script type='text/javascript' src='src/DAT/GUI/Controller.js'></script>
|
|
|
|
<script type='text/javascript' src='src/DAT/GUI/ControllerBoolean.js'></script>
|
|
|
|
<script type='text/javascript' src='src/DAT/GUI/ControllerString.js'></script>
|
|
|
|
<script type='text/javascript' src='src/DAT/GUI/ControllerFunction.js'></script>
|
|
|
|
<script type='text/javascript' src='src/DAT/GUI/ControllerNumber.js'></script>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--Demo-->
|
2011-04-19 18:15:17 +00:00
|
|
|
<link href='docs/docs.css' media='screen' rel='stylesheet' type='text/css'/>
|
2011-04-19 18:09:09 +00:00
|
|
|
<script type='text/javascript' src='docs/RequestAnimationFrame.js'></script>
|
|
|
|
<script type='text/javascript' src='docs/improvedNoise.js'></script>
|
|
|
|
<script type='text/javascript' src='docs/prettify.js'></script>
|
|
|
|
<script type='text/javascript' src='docs/demo.js'></script>
|
2011-04-19 17:43:44 +00:00
|
|
|
|
|
|
|
<script type='text/javascript'>
|
2011-02-11 19:12:07 +00:00
|
|
|
//<![CDATA[
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
window.onload = function() {
|
|
|
|
|
|
|
|
prettyPrint();
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
var fizzyText = new FizzyText('dat.gui');
|
2011-04-18 22:40:26 +00:00
|
|
|
var gui = new DAT.GUI();
|
|
|
|
|
|
|
|
// Text field
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'message');
|
2011-04-18 22:40:26 +00:00
|
|
|
|
|
|
|
// Sliders with min + max
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'maxSize').min(0.5).max(7);
|
|
|
|
gui.add(fizzyText, 'growthSpeed').min(0.01).max(1).step(0.05);
|
|
|
|
gui.add(fizzyText, 'speed', 0.1, 2, 0.05); // shorthand for min/max/step
|
2011-04-18 22:40:26 +00:00
|
|
|
|
|
|
|
// Sliders with min, max and increment.
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'noiseStrength', 10, 100, 5);
|
2011-04-18 22:40:26 +00:00
|
|
|
|
|
|
|
// Boolean checkbox
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'displayOutline');
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
// Fires a function called 'explode'
|
|
|
|
gui.add(fizzyText, 'explode').name('Explode!'); // Specify a custom name.
|
2011-04-18 22:40:26 +00:00
|
|
|
|
|
|
|
// Javascript for documentation
|
|
|
|
getCollapsables();
|
|
|
|
handleListening();
|
|
|
|
};
|
|
|
|
|
|
|
|
function toggle(e) {
|
|
|
|
|
|
|
|
var collapsable = this.childNodes[3],
|
|
|
|
wrapper = collapsable.childNodes[1];
|
|
|
|
|
|
|
|
if (this.className === 'collapsed') {
|
|
|
|
this.className = 'expanded';
|
|
|
|
collapsable.style.height = wrapper.clientHeight + 'px';
|
|
|
|
} else {
|
|
|
|
this.className = 'collapsed';
|
|
|
|
collapsable.style.height = '0px';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCollapsables() {
|
|
|
|
|
|
|
|
if (document.getElementsByClassName == undefined) {
|
|
|
|
document.getElementsByClassName = function(className) {
|
2011-04-19 17:43:44 +00:00
|
|
|
var hasClassName = new RegExp('(?:^|\\s)' + className + '(?:$|\\s)');
|
|
|
|
var allElements = document.getElementsByTagName('*');
|
2011-04-18 22:40:26 +00:00
|
|
|
var results = [];
|
|
|
|
|
|
|
|
var element;
|
|
|
|
for (var i = 0; (element = allElements[i]) != null; i++) {
|
|
|
|
var elementClass = element.className;
|
2011-04-19 00:10:05 +00:00
|
|
|
if (elementClass && elementClass.indexOf(className) != -1 &&
|
|
|
|
hasClassName.test(elementClass))
|
2011-04-18 22:40:26 +00:00
|
|
|
results.push(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
collapsed = document.getElementsByClassName('collapsed');
|
|
|
|
expanded = document.getElementsByClassName('expanded');
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleListening() {
|
|
|
|
|
|
|
|
for (var i = 0; i < collapsed.length; i++) {
|
|
|
|
collapsed[i].addEventListener('click', toggle, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var j = 0; j < expanded.length; j++) {
|
|
|
|
expanded[i].addEventListener('click', toggle, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//]]>
|
2011-01-31 04:53:33 +00:00
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
2011-04-19 17:43:44 +00:00
|
|
|
<div id='container'>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
<!-- GUIDAT logo -->
|
2011-04-19 17:43:44 +00:00
|
|
|
<div id='helvetica-demo'></div>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
<!-- It gives you this! -->
|
2011-04-19 17:43:44 +00:00
|
|
|
<div id='notifier'></div>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-19 18:09:09 +00:00
|
|
|
<h1><a href='http://twitter.com/guidat'><img src='docs/assets/profile.png'
|
2011-04-19 17:43:44 +00:00
|
|
|
border='0' alt='dat.gui flag'/></a>
|
2011-04-18 22:40:26 +00:00
|
|
|
</h1>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-19 18:15:17 +00:00
|
|
|
<p><strong>dat.gui</strong> is a lightweight controller library for JavaScript.
|
2011-04-18 22:40:26 +00:00
|
|
|
It allows you to easily manipulate variables and fire functions on the fly.
|
|
|
|
</p>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
<ul>
|
2011-04-19 17:43:44 +00:00
|
|
|
<li>
|
2011-04-21 01:57:48 +00:00
|
|
|
<a href='https://github.com/dataarts/dat.gui/raw/build/DAT.GUI.min.js'><strong>Download the minified source</strong></a>
|
2011-04-20 04:17:16 +00:00
|
|
|
<small id='buildsizemin'>[19.5kb]
|
2011-04-19 17:43:44 +00:00
|
|
|
</small>
|
|
|
|
</li>
|
|
|
|
<li>
|
2011-04-21 01:57:48 +00:00
|
|
|
<a href='https://github.com/dataarts/dat.gui/raw/build/DAT.GUI.js'><strong>Download the uncompressed source</strong></a>
|
2011-04-20 04:17:16 +00:00
|
|
|
<small id='buildsize'>[33.6kb]
|
2011-04-18 22:40:26 +00:00
|
|
|
</small>
|
|
|
|
</li>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<li><a href='http://github.com/dataarts/dat.gui'>Contribute on GitHub!</a></li>
|
2011-04-18 22:40:26 +00:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<h2>Basic Usage</h2>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre id='demo-pre' class='prettyprint'>
|
2011-04-19 18:09:09 +00:00
|
|
|
<script type='text/javascript' src='DAT.GUI.min.js'></script>
|
2011-04-19 17:43:44 +00:00
|
|
|
<script type='text/javascript'>
|
2011-01-28 20:26:38 +00:00
|
|
|
|
|
|
|
window.onload = function() {
|
|
|
|
|
2011-04-19 18:09:09 +00:00
|
|
|
var fizzyText = new <a href='docs/demo.js'>FizzyText</a>('dat.gui');
|
2011-01-28 20:26:38 +00:00
|
|
|
|
2011-04-18 19:01:45 +00:00
|
|
|
var gui = new DAT.GUI();
|
2011-01-29 00:38:58 +00:00
|
|
|
|
2011-01-28 20:26:38 +00:00
|
|
|
// Text field
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'message');
|
2011-01-28 20:26:38 +00:00
|
|
|
|
2011-02-09 19:39:18 +00:00
|
|
|
// Sliders with min + max
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'maxSize').min(0.5).max(7);
|
|
|
|
gui.add(fizzyText, 'growthSpeed').min(0.01).max(1).step(0.05);
|
|
|
|
gui.add(fizzyText, 'speed', 0.1, 2, 0.05); // shorthand for min/max/step
|
2011-01-29 00:38:58 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'noiseStrength', 10, 100, 5);
|
2011-01-29 00:38:58 +00:00
|
|
|
|
2011-01-28 20:26:38 +00:00
|
|
|
// Boolean checkbox
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(fizzyText, 'displayOutline');
|
2011-01-28 20:26:38 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
// Fires a function called 'explode'
|
|
|
|
gui.add(fizzyText, 'explode').name('Explode!'); // Specify a custom name.
|
2011-01-29 00:38:58 +00:00
|
|
|
|
2011-01-28 20:26:38 +00:00
|
|
|
};
|
|
|
|
|
2011-01-31 04:53:33 +00:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<ul id='desc'>
|
2011-04-19 18:09:09 +00:00
|
|
|
<li><code>DAT.GUI</code> will infer the type of the property you're trying
|
2011-04-18 22:40:26 +00:00
|
|
|
to add<br/>
|
|
|
|
(based on its initial value) and create the corresponding control.
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>The properties must be public, i.e. defined by <code><strong>this</strong>.prop
|
|
|
|
= value</code>.
|
|
|
|
</li>
|
|
|
|
</ul>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
<!--
|
2011-04-19 17:43:44 +00:00
|
|
|
<h2 class='collapsed'>Fire a function when someone uses a control</h2>
|
|
|
|
<pre class='prettyprint'>gui.add(obj, 'propName').onChange(function(n) {
|
|
|
|
alert('You changed me to ' + n);
|
2011-01-31 04:53:33 +00:00
|
|
|
});</pre>-->
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<div class='collapsed'>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!---->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<h2 class='section'>Saving your parameters</h2>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<div class='collapsable'>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--<div>-->
|
|
|
|
<!--<p>The simplest way to save your parameters is via-->
|
|
|
|
<!--<code>DAT.GUI.saveURL()</code>. This method directs your browser to a-->
|
|
|
|
<!--URL containing the current GUI settings.</p>-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<pre class='prettyprint last'>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--// Make a button for the url function-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--gui.add(DAT.GUI, 'saveURL');</pre>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--</div>-->
|
|
|
|
<!--</div>-->
|
|
|
|
<!--</div>-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<div class='collapsed'>-->
|
|
|
|
<!--<h2 class='section'>Advanced saving</h2>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<div class='collapsable'>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--<div>-->
|
|
|
|
<!--<p>Let's say you'd like to share your settings with someone. Instead of-->
|
|
|
|
<!--sending a long link with lots of parameters stored in it, you can make-->
|
|
|
|
<!--your saved settings the defaults.</p>-->
|
|
|
|
|
|
|
|
<!--<p>First, add the method <code>DAT.GUI.showSaveString()</code> to a gui-->
|
|
|
|
<!--object:</p>-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<pre class='prettyprint'>var gui = new DAT.GUI();-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
|
|
|
<!--// Add some stuff (and pretend I change their values);-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--gui.add(someObject, 'someProperty');-->
|
|
|
|
<!--gui.add(someObject, 'someOtherProperty');-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
|
|
|
<!--// Make a save button.-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--gui.add(DAT.GUI, 'showSaveString');</pre>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<p>Clicking the 'showSaveString' button bring up an alert with a string.-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--Copy and paste that string into the method <code>DAT.GUI.load()</code>-->
|
|
|
|
<!--before you instantiate any gui objects.</p>-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<pre class='prettyprint'>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--// Replace COPIED STRING with the value you got from showSaveString()-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--DAT.GUI.load('COPIED STRING');-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
|
|
|
<!--var gui = new DAT.GUI();-->
|
|
|
|
|
|
|
|
<!--// Now these properties will be set to the values you just saved.-->
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--gui.add(someObject, 'someProperty');-->
|
|
|
|
<!--gui.add(someObject, 'someOtherProperty');</pre>-->
|
2011-04-19 02:47:05 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<!--<p class='last'><strong>Save strings won't work if you change the order in-->
|
2011-04-19 02:47:05 +00:00
|
|
|
<!--which you've added properties to your gui objects, or the order of the-->
|
|
|
|
<!--gui objects themselves.</strong>. If you want to add more parameters to-->
|
|
|
|
<!--your gui and use an old save string, make sure they're added after the-->
|
|
|
|
<!--properties whose values you've saved.</p>-->
|
|
|
|
<!--</div>-->
|
|
|
|
<!--</div>-->
|
|
|
|
<!--</div>-->
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-02-09 21:28:35 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Choosing from a list of values</h2>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint first last'>gui.add(obj, 'propertyName').options(1, 2, 3, 5, 8);
|
2011-02-09 21:28:35 +00:00
|
|
|
|
|
|
|
// Alternatively, you can specify custom labels using object syntax
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(obj, 'propertyName').options({'Small': 1, 'Medium': 2, 'Large': 3});
|
2011-02-09 21:28:35 +00:00
|
|
|
</pre>
|
2011-02-11 19:12:07 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Listen for variable changes inside the GUI</h2>
|
2011-02-11 19:12:07 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
|
|
|
<p>To fire a function whenever a user changes a variable via the GUI, use
|
|
|
|
the following syntax:</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint'>gui.add(obj, 'propertyName').onChange(function(newValue) {
|
|
|
|
alert('You changed me to ' + newValue);
|
2011-04-18 22:40:26 +00:00
|
|
|
});</pre>
|
|
|
|
<p>This can be slightly annoying for types like number or string. You may
|
|
|
|
not want to fire a function while the user is sliding, or while they're
|
|
|
|
typing. To fire a function when the user has <em>finished</em> making
|
|
|
|
changes, use the following:</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint'>gui.add(obj, 'propertyName').onFinishChange(function(newValue) {
|
|
|
|
alert('You just finished changing me to ' + newValue);
|
2011-02-09 19:39:18 +00:00
|
|
|
});</pre>
|
2011-04-18 22:40:26 +00:00
|
|
|
<p>Finally, if you'd like to do a little something extra when a function
|
|
|
|
is called, use the following:</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint last'>gui.add(obj, 'functionName').onFire(function() {
|
|
|
|
alert('You called a function with dat.gui');
|
2011-02-09 19:39:18 +00:00
|
|
|
});</pre>
|
2011-02-11 19:12:07 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Listen for variable changes outside of the GUI</h2>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
|
|
|
<p>Let's say you have a variable that changes by itself from time to time.
|
2011-04-19 18:09:09 +00:00
|
|
|
If you'd like the GUI to reflect those changes, use the <code>listen()</code>
|
2011-04-18 22:40:26 +00:00
|
|
|
method.</p>
|
|
|
|
<pre
|
2011-04-19 17:43:44 +00:00
|
|
|
class='prettyprint last'>gui.add(obj, 'changingProperty').listen();</pre>
|
2011-02-11 19:12:07 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Advanced listening</h2>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
2011-04-19 18:09:09 +00:00
|
|
|
<p>By default, <code>DAT.GUI</code> will create an internal interval
|
2011-04-18 22:40:26 +00:00
|
|
|
that checks for changes in the values you've marked with
|
|
|
|
<code>listen()</code>. If you'd like to check for these changes in an
|
|
|
|
interval of your own definition, use the following:</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint'>
|
2011-01-29 04:04:33 +00:00
|
|
|
gui.autoListen = false; // disables internal interval
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(obj, 'changingProperty').listen();
|
2011-01-29 04:04:33 +00:00
|
|
|
|
|
|
|
// Make your own loop
|
|
|
|
setInterval(function() {
|
2011-02-11 19:12:07 +00:00
|
|
|
gui.listen(); // updates values you've marked with listen()
|
2011-02-01 00:49:14 +00:00
|
|
|
}, 1000 / 60);</pre>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-18 22:40:26 +00:00
|
|
|
<p>Alternatively, you can forego calling <code>listen()</code> on
|
|
|
|
individual controllers, and instead choose to monitor changes in
|
|
|
|
<em>all</em> values controlled by your gui.</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint last'>
|
2011-01-29 04:04:33 +00:00
|
|
|
gui.autoListen = false; // disables internal interval
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.add(obj, 'add');
|
|
|
|
gui.add(obj, 'lotsa');
|
|
|
|
gui.add(obj, 'properties');
|
2011-01-29 04:04:33 +00:00
|
|
|
|
|
|
|
// Make your own loop
|
|
|
|
setInterval(function() {
|
2011-02-11 19:12:07 +00:00
|
|
|
gui.listenAll(); // updates ALL values managed by this gui
|
2011-02-01 00:49:14 +00:00
|
|
|
}, 1000 / 60);</pre>
|
2011-02-11 19:12:07 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Multiple panels and custom placement</h2>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
|
|
|
<p>You can instantiate multiple <code>DAT.GUI</code> objects and name them
|
|
|
|
however you'd like.</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint'>var gui1 = new DAT.GUI();
|
2011-04-18 19:01:45 +00:00
|
|
|
var gui2 = new DAT.GUI();
|
2011-01-30 23:03:09 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
// The name function overwrites the 'Show Controls' text.
|
|
|
|
gui1.name('Utilities');
|
|
|
|
gui2.name('Camera Placement');</pre>
|
2011-01-31 04:53:33 +00:00
|
|
|
|
2011-04-19 18:09:09 +00:00
|
|
|
<p>By default, <code>DAT.GUI</code> panels will be automatically added
|
|
|
|
to the HTML document and fixed to the top of the screen from right to
|
|
|
|
left. You can disable this behavior and append the gui DOM element to
|
|
|
|
a container of your choosing.</p>
|
2011-04-19 17:43:44 +00:00
|
|
|
<pre class='prettyprint last'>
|
2011-04-18 19:01:45 +00:00
|
|
|
// Notice this belongs to the DAT.GUI class (uppercase)
|
2011-01-30 23:03:09 +00:00
|
|
|
// and not an instance thereof.
|
2011-04-18 19:01:45 +00:00
|
|
|
DAT.GUI.autoPlace = false;
|
2011-01-30 23:03:09 +00:00
|
|
|
|
2011-04-18 19:01:45 +00:00
|
|
|
var gui = new DAT.GUI();
|
2011-01-30 23:03:09 +00:00
|
|
|
|
|
|
|
// Do some custom styles ...
|
2011-04-19 17:43:44 +00:00
|
|
|
gui.domElement.style.position = 'absolute';
|
|
|
|
gui.domElement.style.top = '20px';
|
|
|
|
gui.domElement.style.left = '20px';
|
2011-01-30 23:03:09 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
document.getElementById('my-gui-container').appendChild( gui.domElement );</pre>
|
2011-01-31 04:53:33 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2011-01-31 20:21:14 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsed'>
|
|
|
|
<h2 class='section'>Pro tips.</h2>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='collapsable'>
|
2011-04-18 22:40:26 +00:00
|
|
|
<div>
|
2011-04-19 17:43:44 +00:00
|
|
|
<ol id='secrets'>
|
2011-04-19 18:15:17 +00:00
|
|
|
<li><code>DAT.GUI</code> panels are resizeable. Drag the open/close
|
2011-04-18 22:40:26 +00:00
|
|
|
button.
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>Press 'H' to show/hide GUI's.</li>
|
|
|
|
</ol>
|
2011-02-11 19:12:07 +00:00
|
|
|
</div>
|
2011-04-18 22:40:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<div class='trans'> </div>
|
2011-04-18 22:40:26 +00:00
|
|
|
|
2011-04-19 17:43:44 +00:00
|
|
|
<footer class='trans'>Initiated by <a href='http://georgemichaelbrower.com/'>George
|
|
|
|
Michael Brower</a> and <a href='http://jonobr1.com/'>Jono Brandel</a> of the
|
2011-04-18 22:40:26 +00:00
|
|
|
Data Arts Team, Google Creative Lab.
|
|
|
|
</footer>
|
2011-01-31 04:53:33 +00:00
|
|
|
</body>
|
2011-01-29 00:38:58 +00:00
|
|
|
</html>
|