Probably because you have no mouse function. Mouse_dir3d depends on mouse_pos, but when you do not assign the cursor.x to mouse_pos, it remains 0,0. Making a trace scan from camera to (0,0) instead of your real mouse position could cause some trouble.
*just found out myself the hard way*
Click and join the 3dgs irc community! Room: #3dgs