Factored the 3D environment controller into a 'threeD' object. See the file 3Dmain.js