"dir.sub(dir, loc);"
I admit the reference of sub() could be more verbose... But this is wrong, as it does nothing to dir: it returns a value that isn't used. The line should be: dir.sub(loc); ie. you subtract loc from dir, changing the latter. Like you did on the next line.
But actually, it is useless, because dir is still (0, 0), since you haven't changed it: you created a new PVector named mouse instead.
So, also change the previous line to dir = new PVector(mouseX, mouseY); and it should do what you want.