Here is a 3D mouse snippet that I've put together from many different sources over the past year-and-a-bit. I find it works best for me.
position camera 200,200,200
rem make mouse
make object cube 1,5
position object 1,0,0,0
rem make other object
make object sphere 2,5
position object 2,0,0,0
position camera 0,30,-30
pitch camera down 30
position mouse 400,400
sync on
do
repeat
if object screen x(1) mousex()+3
position object 1,object position x(1)-1,object position y(1),object position z(1)
endif
if object screen y(1) mousey()+3
move object 1,3
endif
until object screen x(1) = mousex()-7 and object screen y(1) = mousey()-7
position object 1,object position x(1),object position y(1),object position z(1)
set cursor 10,10
print "Distance between objects: ";dist_obj(1,2)
if dist_obj(1,2)