Try the following:
controls = new THREE.TrackballControls( camera, renderer.domElement );
The second default argument is document , which I expect is the problem.
(Obviously, you will also have to reorder some of your codes.)
EDIT: for reference, you can also use this construct:
// container container = document.createElement( 'div' ); document.body.appendChild( container ); // renderer renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); //controls controls = new THREE.TrackballControls( camera, container );
source share