Pokemon moon related problem

I went into the ultraworm hole after winning the league to enter the world of sun and when i entered into my home I went into an unlimited 3d space and can’t get out of it. Please help me

Doesn’t this use motion controls? If so, rightclick and drag on the bottom screen to ‘rotate’ your 3ds.

Or you can change the controls in game. I don’t have details, since I don’t have the game.