Three.JS Orbit Controls - enabling and disabling without position jumping

前端 未结 2 845
你的背包
你的背包 2021-02-09 23:39

I am creating a geometry manipulation prototype with Three.JS. I am using OrbitControls.JS to manipulate the camera and am having trouble enabling and disabling the controls.

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-10 00:08

    I haven't been able to test it, but I think that you code should be

    function onDocumentMouseDown( event ) 
    {
    // the following line would stop any other event handler from firing
    // (such as the mouse's TrackballControls)
    // event.preventDefault();
    
    //console.log("Click.");
    MOUSEDOWN = true;
    // update the mouse variable
    mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
    mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
    
    checkSelection();   
        if(editMode==2){
            controls.enabled = false;
            controls.rotate = false;
        }else{
            controls.enabled = true;
            controls.rotate = true;
            controls.onMouseDown (event);    // added this line to set the correct state
        }
    }
    

提交回复
热议问题