Skip to content

Instantly share code, notes, and snippets.

@aogilvie
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aogilvie/1818972c834590c2b53d to your computer and use it in GitHub Desktop.
Save aogilvie/1818972c834590c2b53d to your computer and use it in GitHub Desktop.
OrbitControls modification for Ejecta

To use OrbitControls for Ejecta you will need to modify the OrbitControls.js where touchmove is looking for variable element.clientHeight and element.clientWidth. These are read-only properties of Element which are not available in Ejecta.

If you are passing the default document Element using controls = new THREE.OrbitControls( camera );, then you can replace the following lines with the innerWidth and innerHeight properties of window. (window == document are basically same element in Ejecta).


function touchmove( event ) {

		if ( scope.enabled === false ) { return; }

		event.preventDefault();
		event.stopPropagation();

		var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
		// -------- modification
		if (window.ejecta) {
    		element.clientHeight = window.innerHeight;
    		element.clientWidth = window.innerHeight;
		}
		// -------- end modification
		
		switch ( event.touches.length ) {
		...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment