Browse Source

Fix for OrbitControls not allowing keyboard input in iframe

Gregg Tavares 6 years ago
parent
commit
a3c41f50d8
1 changed files with 7 additions and 0 deletions
  1. 7 0
      examples/js/controls/OrbitControls.js

+ 7 - 0
examples/js/controls/OrbitControls.js

@@ -673,8 +673,15 @@ THREE.OrbitControls = function ( object, domElement ) {
 
 		if ( scope.enabled === false ) return;
 
+		// Prevent the browser from scrolling.
+
 		event.preventDefault();
 
+		// Manually set the focus since calling preventDefault above
+		// prevents the browser from setting it automatically.
+
+		scope.domElement.focus ? scope.domElement.focus() : window.focus();
+
 		switch ( event.button ) {
 
 			case scope.mouseButtons.LEFT: