When Orbit control target changed prevent the camera rotation

Hello Everyone

I have scene where I have number of models , So When I click on any of mesh I set the centre of model as target of the Orbit control ( so model rotates from that centre (pivot point))

But when I change the orbit control target camera also rotates - I want camera rotation as it is but changes selected mesh in centre and rotation should be around that model (pivot to centre of that model)


  camera = new THREE.OrthographicCamera();
    
    camera.left = window.innerWidth / -40;
    camera.right = window.innerWidth / 40;
    camera.top = window.innerHeight / 40;
    camera.bottom = window.innerHeight / -40;
    camera.near = 0.1;
    camera.far = 400;

 orbit_ctrl = new THREE.OrbitControls(camera, renderer.domElement);
  orbit_ctrl.enableDamping = true;
  orbit_ctrl.dampingFactor = 0.5;
  orbit_ctrl.minDistance = 200;
  orbit_ctrl.maxDistance = 3400;

This is how I centre the model

function setCenterTarget(result) {
    if (result == main_model) {
            return
    }
    const box = new THREE.Box3().setFromObject(result);
    const center = new THREE.Vector3();
    box.center(center);
    orbit_ctrl.target = center

}

see the video when I tap on model - camera rotates - I want camera should not change rotation - just centre the model

OrbitControls use lookAt() to focus the target which inevitably updates the camera’s orientation.

I’m not sure your expected result is clear. Do you mind describing in more detail? Besides, it seems your video has not been uploaded correctly.

@Mugen87 Thanks for looking into issue , I have uploaded video correctly now

you can see when I select any model , Camera orientation completely changes to other direction

what I need is camera orientation should stay as it is , I have tried to store camera matrix and apply it after I set the target but it wasn’t working

Could you add THREE.AxesHelper, so that it is easier to see how the orientation is changed. My expectation is that the camera is close to the direction of the up vector – this is one of the possible causes of the demonstrated effect. If this is the reason, you will need to change the up vector.

@PavelBoytchev Here is the image

When you click on various locations and the jaw makes strange rotations … does the green axis always point to the top of the window? If the answer is “yes”, then most likely it is a problem with the camera’s up vector.

@Prashant_Tukadiya Did you get the answer ? I’m facing the same issue.

Nope , I think it is something internal