admin管理员组文章数量:1178545
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.
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.
Share Improve this question edited Nov 18, 2013 at 23:19 Charles 51.4k13 gold badges106 silver badges144 bronze badges asked Nov 18, 2013 at 21:44 rastafermorastafermo 4381 gold badge5 silver badges13 bronze badges 5 |2 Answers
Reset to default 30Stumbled 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 example code, you can just disable orbitControls when transformControls are used:
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { TransformControls } from 'three/addons/controls/TransformControls.js';
let orbitControls= new OrbitControls(camera, renderer.domElement);
orbitControls.addEventListener('change', render);
let transformControls = new TransformControls(camera, renderer.domElement);
transformControls.addEventListener('change', render);
transformControls.attach(targetObject);
transformControls.addEventListener('dragging-changed', function (event) {
orbitControls.enabled = !event.value;
});
On every dragging of the controls, the orbitControls will be set orbitControls.enabled = false
.
Note that if you have targetObject.matrixAutoUpdate = false
then you need to call targetObject.updateMatrix()
before render
in the change
event handler.
本文标签: javascriptthreejs disable orbit camera while using transform controlStack Overflow
版权声明:本文标题:javascript - threejs disable orbit camera while using transform control - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738106556a2064383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
controls.enableRotate = false;
– aswzen Commented Aug 8, 2019 at 16:01