Pass only a single parameter to gui.add to automatically add all of its properties

This commit is contained in:
George Michael Brower 2011-04-18 17:35:27 -07:00
parent 60d2a580e3
commit 320bdb2926
3 changed files with 13 additions and 5 deletions

View File

@ -30,9 +30,9 @@
prettyPrint();
var fizzyText = new FizzyText("dat.gui");
var gui = new DAT.GUI();
// Text field
gui.add(fizzyText, "message");

View File

@ -116,7 +116,7 @@ DAT.GUI.ControllerNumber = function() {
numberField.addEventListener('mousewheel', function(e) {
e.preventDefault();
_this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY) / e.wheelDeltaY * step);
_this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY) / e.wheelDeltaY * _this.getStep());
return false;
}, false);
@ -140,11 +140,11 @@ DAT.GUI.ControllerNumber = function() {
_this.setValue(newVal);
break;
case 38: // up
newVal = _this.getValue() + step;
newVal = _this.getValue() + _this.getStep();
_this.setValue(newVal);
break;
case 40: // down
newVal = _this.getValue() - step;
newVal = _this.getValue() - _this.getStep();
_this.setValue(newVal);
break;
}
@ -192,7 +192,7 @@ DAT.GUI.ControllerNumber = function() {
draggedNumberField = true;
e.preventDefault();
var newVal = _this.getValue() + dy * step;
var newVal = _this.getValue() + dy * _this.getStep();
_this.setValue(newVal);
return false;

View File

@ -275,6 +275,14 @@ DAT.GUI = function(parameters) {
this.add = function() {
if (arguments.length == 1) {
var toReturn = [];
for (var i in arguments[0]) {
toReturn.push(_this.add(arguments[0], i));
}
return toReturn;
}
var object = arguments[0];
var propertyName = arguments[1];