82071

Refreshing dat.gui variable

This is a dropdown list within a dat.gui interface. Once you click any number, the jumpSwitcher will be whatever number you chose. I’m trying to replace each list that pertains to their specific number based on that what the user chose for Starsystem.

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/POqEf.png" alt="enter image description here">

So solPlanets= ['Ilos', 'Tuchanka', 'Illium', 'Palaven'] is what shows in list 2 when you click on 2. On default, solPlanets shows ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'] because default is jumpSwitcher = 1.

Problem is, the list will always show as solPlanets= ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune'], no matter if jumpSwitcher is 2.

I confirmed this by placing an alert message if jumpSwitcher is 2, and the alert pops up, but the list won’t change. This is likely to do with similiar issues where dat.gui doesn't update. I've tried listen() method as it was the main given answer, but it hasn't worked for me.

I've made a fiddle of it.

PS: I've asked this question before but now I realise it's likely to do with dat.gui not refreshing values and not javascript. So I deleted that question because it was kind of reaching a wrong audience, and I didn't make a fiddle for it.

Answer1:

You have to re-create the contorller for the list of planets.

I modified your jsfiddle example here. The main stuff in

function updatePlanets(id) { var controller = gui.__controllers[2]; controller.remove(); gui.add(data, 'Planets', planets[id]).onChange(doSomeStuff); //back to 0 element data.Planets = 0; gui.__controllers[2].updateDisplay(); }

Also, it started to work, when I changed the version of DAT.GUI to 0.6.1

Recommend

  • Definition of structures and arrays
  • Writing my own Provider Class in ASP.NET
  • In perl6, how do you read a file in paragraph mode?
  • JUnit parameterized tests: how do I run only 1 specific test from IntelliJ/Eclipse?
  • Query DBpedia to get abstract for different inputs
  • I can not create an apk on my eclipse
  • Eclipse - black background in javadoc popup
  • How to install the eclipse source code via “Eclipse Marketplace” or “Install New Software” option fr
  • How to randomly take examples from arrays, shuffle them and place them into a new array to be format
  • How to make Eclipse run my program in a terminal
  • Php mail function error, mail sent from wrong address
  • Linq-To-Sql and MARS woes - A severe error occurred on the current command. The results, if any, sho
  • Java code completion in Eclipse IDE
  • MIPS assembly - Reading from a file with hexadecimal values
  • 'The network path was not found' every first attempt to Azure SQL Server
  • GWT Hello World ; java.lang.IllegalArgumentException: No enum constant com.google.gwt.dev.cfg.Module
  • How to specify c++ system include path in Eclipse?
  • Different scatterplot markers with the same label
  • Trouble importing module in Python 2.7
  • How to create a dictionary of the contents of an Excel spreadsheet?
  • Pygame: How do I make my image fall?
  • Could not initialize class org.eclipse.jdt.core.JavaConventions
  • Difference between catch block and throw new Exception in method
  • stray characters coming after splitting the list in tcl
  • 2 count(*)+group by+having+join
  • Porting entire Java projects to to C#
  • SVG background not displaying in Safari
  • Installed a plugin on eclipse (mars), now eclipse won't start. How can I uninstall the plugin?
  • Unable to run tests with JUnit5 Console Launcher
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • htaccess add www if not subdomain, if subdomain remove www
  • JSON response opens as a file, but I can't access it with JavaScript
  • Spray.io: When (not) to use non-blocking route handling?
  • Accessing IRQ description array within a module and displaying action names
  • Modifying destination and filename of gulp-svg-sprite
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • GridView Sorting works once only
  • Converting MP3 duration time