Serious problem with my selection box.

Hy guys. This forum helped me get my answers to a lot of my questions, but theres this problem a cant solve with my limited codeing experience.

Below you can see a mockup of a game i`m working on. The cubes represent my spaceship parts with a white plane connecting them. I would like to expand this ship using a selection box to determine my build area.

Now, on the first picture my ship does not move, my selection box lines up with it`s start and end markers.Everything works as exepected.

But when i start to move/rotate around my end marker starts to orbit my ship and my selection box will start to rotate around and will not line up with its markers, as seen on picture 2.

Heres some code snippet.

This creates the selection box.

public void BuildPositions()
	{

		if(Input.GetKeyDown(KeyCode.Mouse0))
		{
			//clickPos = mouseSnap.cursor.position;
			clickPos = mouseSnap.cursor.position;
			clickPosObj.position = clickPos;


		}
		if(Input.GetKey(KeyCode.Mouse0))
		{
			currentPos = mouseSnap.cursor.position;
			//floorHol.transform.rotation = Quaternion.Euler(90,0,0);
			Vector3 centre = (clickPos + currentPos) / 2;
			floorHol.position = centre + new Vector3(0,-0.01f,0);
			floorHol.localScale = new Vector3(clickPos.x - currentPos.x+0.02f,clickPos.z - currentPos.z+0.02f,1);

		}

		 
	}

mouseSnap.cursor.position gets its position from a raycast. Maybe this is my problem because it`s in world position?

It’s probably the Raycast.I tried to convert it to local space using InversTransformPoint but it just made it worse. Is it possible to convert Raycast hits to some kind of local coordinate system.Like lets say on the first picture where the start located that point would always be(-2,0,0) and so on.