If you want to change the default behavior of OrbitControls
in listening to mouse events on the entire document
, causing conflicts with other functionalities like selecting text or opening context menus, you can specify a specific DOM node as the second argument when constructing THREE.OrbitControls
. This way, OrbitControls
will only listen to mouse events on this designated DOM node.
For instance, if your code looks like this:
var renderer = …;
container.appendChild(renderer.domElement);
…
var controls = new THREE.OrbitControls(camera);
You can modify the last line to be:
var controls = new THREE.OrbitControls(camera, renderer.domElement);
In the example mentioned, you should move the initialization of controls
:
controls = new THREE.OrbitControls( camera );
controls.addEventListener( 'change', render );
To after initializing renderer
, and include renderer.domElement
as the second argument in the constructor THREE.OrbitControls
. This adjustment allows you to freely select text on the page without interference.