Duplicating objects based on type input

Hello! I have made a few questions similar to this before, but would it be possible for someone to type a value into a textbox and then have that many duplicates for what value the user typed in. For example if wanted 4 duplicates of a cube, I could type the number “4” in the textbox and 4 cubes could appear. I already tried using the onChange event function, but that seemed to duplicate an object whenever I clicked it, not what value I typed in.
Here’s my script:

l.html (8.0 KB)
Thanks in advance.

This isn’t really a three.js question but…

  1. Keep track of previous count
  2. const delta = newValue - prev
  3. if delta > 0 // scene.add(Box.clone()) delta times
  4. if delta < 0 remove delta boxes from scene.
1 Like