I have a scene with multiple meshes, each one of them associated to a different transformControl; in order to select different objects, I'm using raycasting techniques. I'm also using an orbit camera in order to navigate the scene.
Whenever I modify the position/rotation/scale of the selected object using transform control, I want to disable orbit camera, because sometimes while I'm clicking on a picker, I'm also picking on the background of the scene, so the orbit camera moves.
I'd like to stop this behavior and I've already tried to handle it with raycasting techniques, but it doesn't work.
Stumbled over this and thought it would be helpful to see the answer (credits to BuildingJarl):
// if youre definition is like
var controls = new THREE.OrbitControls( camera );
// you can easily disable it by using
controls.enabled = false;
In my case I was using a UI overlay and I got issues with getting the focus to it. Disabling the controls solved my problems.
Greetings Mat
Taken from three.js editor's code:
var orbitControls= new THREE.EditorControls(camera, renderer.domElement);
orbitControls.addEventListener('change', render);
var transformControls = new THREE.TransformControls(camera, renderer.domElement);
transformControls.addEventListener('change', render);
transformControls.attach(mesh);
transformControls.addEventListener('mouseDown', function () {
orbitControls.enabled = false;
});
transformControls.addEventListener('mouseUp', function () {
orbitControls.enabled = true;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With