Comments (6)
This did not completely fix it for me. If I have a float slider that starts out with an integer value, I still get this problem. Works fine if the initial value is non-integer.
Does the fix here work for everyone else? I.e. float slider that starts out with integer initial value?
I did find a work-around:
- Make sure the initial value is non-integer.
- Add .listen() to the property.
- Then set the property to the integer value.
I.e. I start with:
var UI = {
...
x: .1, // workaround for float slider bug
y: .1,
z: .1,
...
}
gui.add(UI, 'x').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'y').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'z').min(-10).max(10).step(.1).listen().onChange(callback)
UI.x = UI.y = UI.z = 0
from dat.gui.
Having this problem also. Value is a float but the number in the GUI is always displayed as an int.
from dat.gui.
This was fixed by #31, but this change is not reflected in the 0.5.0
built distributable.
See source vs build.
from dat.gui.
updated the build to 0.5.1 with latest from master. https://github.com/dataarts/dat.gui/releases
from dat.gui.
I still see this issue. You can use my code for resolving of problem.
First, add my new method into dat.gui
if ( dat.controllerZeroStep === undefined ) {
//Solving of dat.gui NumberController Step bug.
//
//folder: GUI or folder for new Controller.
//object: The object to be manipulated. See https://github.com/dataarts/dat.gui/blob/master/API.md#GUI+add for details
//property: The name of the property to be manipulated. See https://github.com/dataarts/dat.gui/blob/master/API.md#GUI+add for details
//onchange: Callback function will be called if controller value was changed. Can be undefined.
//
dat.controllerZeroStep = function ( folder, object, property, onchange ) {
var controller = folder.add( object, property ),
input = controller.__input;
controller.__input = document.createElement( 'input' );
input.value = object[property];
input.onchange = function ( value ) {
object[property] = parseFloat( input.value );
if ( onchange !== undefined )
onchange( object[property] );
};
return controller;
};
} else console.error( 'Duplicate dat.controllerZeroStep method.' );
Next, add a controller into gui. For example:
var gui = new dat.GUI();
var object = { min: 123.456 }
dat.controllerZeroStep( gui, object, 'min', function ( value ) {
console.log( 'object.min = ' + object.min + ' value = ' + value );
} );
from dat.gui.
Another way of resolving of issue is debug of dat.GUI. See my
"NumberController Step is working properly" commit for details.
Now you can set step = 0 to gui controller. For example:
var gui = new dat.GUI();
var object = { min: 123.456 }
gui.add( object, 'min', undefined, undefined, 0).onChange( function (value) {
console.log( 'object.min = ' + object.min + ' value = ' + value );
} )
Note: Plaese do not use gui.add( object, 'min').step( 0 ).
Currently I have made pull request. Please write a comments to my pull request if you want to see my code in next dat.GUI release.
from dat.gui.
Related Issues (20)
- Hide / disable "close controls" button HOT 1
- Resize not working when controls first shown
- dat.gui is present after leaving the page HOT 1
- Is there a way to set strings? HOT 3
- gui.removeFolder gives a Uncaught TypeError: folder.domElement is undefined error
- Unable to build using README instructions HOT 1
- How to change a button's value when clicked?
- When dragging over input box, number is changed as if dragging over slider.
- Add link to examples or screenshots on readme
- add types via `index.d.ts` HOT 1
- after use the dat.gui window is not defined in vue, nuxt project HOT 2
- When using NoLoop and redraw callback from onFinishChange(redraw) runs multiple times depending on value
- Duplicated GUI with vite + react + three.js HOT 3
- dat.gui scroll bar cannot scroll to the bottom, can not displaying all contents
- color
- Impossible to revert saved preset to default HOT 1
- [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event.
- Can you please clarify what you mean by "prest" in this context? HOT 4
- The link to the tutorial is broken
- Found a drop in replacement alternative to dat.gui and it's maintained - see links
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.