lookAt - flip / spin looking at poles

Hello everyone.
Let’s say I have two moving Object3Ds, source and target, and I want source to rotate towards target, in a fashion similar to lookAt. my function is:

        const up = new THREE.Vector3(0, 1, 0);

        const p1 = source.getWorldPosition(new THREE.Vector3());
        const p2 = target.getWorldPosition(new THREE.Vector3());
      
        const vector_direction =
            new THREE.Vector3().subVectors(p2, p1).normalize();
        const align_q =
            new THREE.Quaternion().setFromUnitVectors( up, vector_direction );
        
        source.quaternion.copy(align_q);


it works more or less like lookAt, and similarly to lookAt, when the direction crosses north and south poles, the source object “spins” so it always faces up.

Now, is there any way to avoid this? I mean, given an initial object orientation, I’d simply like to rotate it towards the target, and if it crosses the poles, it lust keeps rotating and “facing upside down”.

How can I achieve this behaviour?
thanks in advance.

Maybe stupid question, but if you want it to work like lookAt, rotate like lookAt, face direction properly like lookAt … why not lookAt :eyes:?

ahah, that’s right, but it doesn’t matter, the core of my function is more or less the same as lookAt, and the result is the same.
Problem is with transformations, and I don’t know so much about them.