mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Changed tabs to two spaces. Happy?
This commit is contained in:
parent
561b4a1411
commit
92a13fd869
10
demo/demo.js
10
demo/demo.js
@ -10,7 +10,7 @@ function FizzyText(message) {
|
|||||||
this.maxSize = 3.2; // how big can they get?
|
this.maxSize = 3.2; // how big can they get?
|
||||||
this.noiseStrength = 10; // how turbulent is the flow?
|
this.noiseStrength = 10; // how turbulent is the flow?
|
||||||
this.speed = 0.4; // how fast do particles move?
|
this.speed = 0.4; // how fast do particles move?
|
||||||
this.displayOutline = false; // should we draw the message as a stroke?
|
this.displayOutline = true; // should we draw the message as a stroke?
|
||||||
this.framesRendered = 0;
|
this.framesRendered = 0;
|
||||||
|
|
||||||
// __defineGetter__ and __defineSetter__ makes JavaScript believe that
|
// __defineGetter__ and __defineSetter__ makes JavaScript believe that
|
||||||
@ -30,11 +30,11 @@ function FizzyText(message) {
|
|||||||
// 0 arguments, we can call them from the dat-gui panel.
|
// 0 arguments, we can call them from the dat-gui panel.
|
||||||
|
|
||||||
this.explode = function() {
|
this.explode = function() {
|
||||||
var mag = Math.random()*30+30;
|
var mag = Math.random() * 30 + 30;
|
||||||
for (var i in particles) {
|
for (var i in particles) {
|
||||||
var angle= Math.random()*Math.PI*2;
|
var angle = Math.random() * Math.PI * 2;
|
||||||
particles[i].vx = Math.cos(angle)*mag;
|
particles[i].vx = Math.cos(angle) * mag;
|
||||||
particles[i].vy = Math.sin(angle)*mag;
|
particles[i].vy = Math.sin(angle) * mag;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ DAT.GUI.BooleanController = function() {
|
|||||||
var input = document.createElement('input');
|
var input = document.createElement('input');
|
||||||
input.setAttribute('type', 'checkbox');
|
input.setAttribute('type', 'checkbox');
|
||||||
|
|
||||||
if(arguments[3]) {
|
if (arguments[3]) {
|
||||||
input.checked = true;
|
input.checked = true;
|
||||||
this.setValue(true);
|
this.setValue(true);
|
||||||
} else {
|
} else {
|
||||||
@ -38,7 +38,8 @@ DAT.GUI.BooleanController = function() {
|
|||||||
if (typeof val != "boolean") {
|
if (typeof val != "boolean") {
|
||||||
try {
|
try {
|
||||||
val = eval(val);
|
val = eval(val);
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DAT.GUI.Controller.prototype.setValue.call(this, val);
|
return DAT.GUI.Controller.prototype.setValue.call(this, val);
|
||||||
};
|
};
|
||||||
|
@ -54,7 +54,8 @@ DAT.GUI.Controller.prototype.getValue = function() {
|
|||||||
return this.object[this.propertyName];
|
return this.object[this.propertyName];
|
||||||
};
|
};
|
||||||
|
|
||||||
DAT.GUI.Controller.prototype.updateDisplay = function() {};
|
DAT.GUI.Controller.prototype.updateDisplay = function() {
|
||||||
|
};
|
||||||
|
|
||||||
DAT.GUI.Controller.prototype.onChange = function(fnc) {
|
DAT.GUI.Controller.prototype.onChange = function(fnc) {
|
||||||
this.changeFunction = fnc;
|
this.changeFunction = fnc;
|
||||||
|
@ -25,5 +25,6 @@ DAT.GUI.FunctionController = function() {
|
|||||||
}
|
}
|
||||||
_this.object[_this.propertyName].call(_this.object);
|
_this.object[_this.propertyName].call(_this.object);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
DAT.GUI.extendController(DAT.GUI.FunctionController);
|
DAT.GUI.extendController(DAT.GUI.FunctionController);
|
||||||
|
@ -20,7 +20,7 @@ DAT.GUI.NumberController = function() {
|
|||||||
|
|
||||||
if (!step) {
|
if (!step) {
|
||||||
if (min != undefined && max != undefined) {
|
if (min != undefined && max != undefined) {
|
||||||
step = (max-min)*0.01;
|
step = (max - min) * 0.01;
|
||||||
} else {
|
} else {
|
||||||
step = 1;
|
step = 1;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ DAT.GUI.NumberController = function() {
|
|||||||
|
|
||||||
numberField.addEventListener('mousewheel', function(e) {
|
numberField.addEventListener('mousewheel', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
_this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY)/e.wheelDeltaY*step);
|
_this.setValue(_this.getValue() + Math.abs(e.wheelDeltaY) / e.wheelDeltaY * step);
|
||||||
return false;
|
return false;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ DAT.GUI.NumberController = function() {
|
|||||||
// Handle up arrow and down arrow
|
// Handle up arrow and down arrow
|
||||||
numberField.addEventListener('keydown', function(e) {
|
numberField.addEventListener('keydown', function(e) {
|
||||||
var newVal;
|
var newVal;
|
||||||
switch(e.keyCode) {
|
switch (e.keyCode) {
|
||||||
case 13: // enter
|
case 13: // enter
|
||||||
newVal = parseFloat(this.value);
|
newVal = parseFloat(this.value);
|
||||||
_this.setValue(newVal);
|
_this.setValue(newVal);
|
||||||
@ -89,7 +89,7 @@ DAT.GUI.NumberController = function() {
|
|||||||
numberField.focus();
|
numberField.focus();
|
||||||
numberField.select();
|
numberField.select();
|
||||||
}
|
}
|
||||||
if(slider) slider.domElement.className = slider.domElement.className.replace(' active', '');
|
if (slider) slider.domElement.className = slider.domElement.className.replace(' active', '');
|
||||||
draggedNumberField = false;
|
draggedNumberField = false;
|
||||||
clickedNumberField = false;
|
clickedNumberField = false;
|
||||||
if (_this.finishChangeFunction != null) {
|
if (_this.finishChangeFunction != null) {
|
||||||
@ -110,12 +110,12 @@ DAT.GUI.NumberController = function() {
|
|||||||
DAT.GUI.makeUnselectable(_this.parent.domElement);
|
DAT.GUI.makeUnselectable(_this.parent.domElement);
|
||||||
DAT.GUI.makeUnselectable(numberField);
|
DAT.GUI.makeUnselectable(numberField);
|
||||||
|
|
||||||
if(slider) slider.domElement.className += ' active';
|
if (slider) slider.domElement.className += ' active';
|
||||||
|
|
||||||
py = y;
|
py = y;
|
||||||
y = e.pageY;
|
y = e.pageY;
|
||||||
var dy = py - y;
|
var dy = py - y;
|
||||||
var newVal = _this.getValue() + dy*step;
|
var newVal = _this.getValue() + dy * step;
|
||||||
_this.setValue(newVal);
|
_this.setValue(newVal);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ DAT.GUI.Slider = function(numberController, min, max, step, initValue) {
|
|||||||
var pos = findPos(_this.domElement);
|
var pos = findPos(_this.domElement);
|
||||||
var val = DAT.GUI.map(e.pageX, pos[0], pos[0] + _this.domElement
|
var val = DAT.GUI.map(e.pageX, pos[0], pos[0] + _this.domElement
|
||||||
.offsetWidth, min, max);
|
.offsetWidth, min, max);
|
||||||
val = Math.round(val/step)*step;
|
val = Math.round(val / step) * step;
|
||||||
numberController.setValue(val);
|
numberController.setValue(val);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ DAT.GUI.Slider = function(numberController, min, max, step, initValue) {
|
|||||||
|
|
||||||
this.__defineSetter__('value', function(e) {
|
this.__defineSetter__('value', function(e) {
|
||||||
var pct = DAT.GUI.map(e, min, max, 0, 100);
|
var pct = DAT.GUI.map(e, min, max, 0, 100);
|
||||||
this.fg.style.width = pct+"%";
|
this.fg.style.width = pct + "%";
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('mousemove', onDrag, false);
|
document.addEventListener('mousemove', onDrag, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user