The example is already quite complex.
It may make sense to look at other examples.
From the Collection of examples from discourse.threejs.org
eXtended eXamples noisejs POWERWOLF - @author prisoner849
eXtended eXamples Deforming - @author sciecode
BeginnerExample // … step 07: dynamic geometry
and sandbox => examples THREEf