Scale all side and keep rotation

preview what i have done so far the problem only in rotation
2021-04-25 02-33-47.mkv (2.5 MB)

the piece of code

function ShiftScaling() {

        let NormalMouseDistance = MouseDis();

        let RotatedMouseDistance = RotateVec(NormalMouseDistance);

        RotatedMouseDistance.x *= Direction[0]; // just direction when press the dots (left top / right top / bottom left / bottom right)

        let YDirection = Direction[0] / Direction[1]; // just direction when press the dots (left top / right top / bottom left / bottom right)

        //#region if you hold shift it should scale all sides

        NewScaleX = PrevouisScale.x + RotatedMouseDistance.x / BoxSize.x; // add scale unite to Prevouis Scale

        NewScaleY = PrevouisScale.y * (NewScaleX / PrevouisScale.x); // get height start from amount added to width (ratio)

        NewSize =

            ((BoxSize.x * NewScaleX) / (BoxSize.y * NewScaleY)) * YDirection; // get new ration to get right Y pos

        // Repose

        ObjectMesh.position.set(

            PrevouisPos.x + NormalMouseDistance.x / 2,

            PrevouisPos.y + NormalMouseDistance.x / (2 * NewSize),

            0

        );

        // Scale

        ObjectMesh.scale.set(NewScaleX, NewScaleY, AnimatorObject.scale.z);

        //#endregion

    }

any idea about what could be wrong or anything may help

It seems, you are working 2D, then why are you using 3JS?
You can accomplish you goal using CSS and Val JS alot easier.

If still wanna go 3D, try creating a GUI to transform the mesh.

i already done the ui as you can see in my video the only problem is the algorithm get broken when we rotate and i really need threejs