Not sure if this is more of a lil-gui question, but in detail I’m having an issue updating a threejs parameter.
I’d like to control some lil-gui values from the “outside”.
For this I created a css range-slider in html next to threejs within the same file.
Using jquery to copy the value from the new range-slider to the lil-gui input field.
Lil-gui does work and changes do reflect visually in threejs.
But when I use my own range-slider all values do reflect only in the input field of lil-gui.
No matter what I try I can’t get threejs to update the value from the overwritten lil-gui input field.
Do I miss some “controls.update()” within the animate() function?
Help is very much welcome - thanks for getting into this.
By the way, …
Is there a good way accessing these settings within the lil-gui structure?
Or is it possible to give them some id’s? It doesn’t feel right and I’m sure I will end up having troubles with these “random” names like “input[aria-labelledby=‘lil-gui-name-4’”
I would advise against reaching into the HTML DOM of lil-gui itself. That structure might change with any lil-gui release, it is not a stable public API.
What you probably want to do is to listen for changes published by lil-gui itself:
gui.add( myObject, 'myProperty' )
.name( 'Custom Name' )
.onChange( value => {
// update your HTML here
} );
@donmccurdy I’ve tried to implement your solution.
But for some reason I can’t get the .listen() to work.
lil-gui does speak to the slider, but the slider won’t talk back.
If the slider’s value has changed, there’s no need to set anything further on the slider itself. You may want to listen for change events from the slider using jQuery’s .on() API, then modify the “params” object that is the data storage for your parameters.
This onchange snippet is needed for another number input field. It reflects the slider as number-value.
I removed it for this example. Somehow I forgot to remove this part.
.on() - > thanks!
Update: Using .on(“input”, … will update in realtime, not only on click-release.
Update: This method does work for a simple slider.
But I ran into issues using a pure css range slider with multiple handles. Everything works the same. Only the visual view is lacking… It’s strange.
In detail I want to control the emissive parameter of three.js. The parameter within the control does update. But it won’t update the 3d view. Any idea why this isn’t working out?
Is “emissiveintensity” and/or “ligthmapintensity” in someway different to other controls?
…speaking in terms of updating the renderer? SOLVED - had a typo