Object mimicking device movement in 3d space

While tracking device movement of a phone in 6 Degrees of Freedom I want to visualise this correctly with an object showing the same position and rotation movement.

When rotating my device the position movement should also rotate. (so when rotating the device 90 degrees on the x axis, moving the device sideways should make the object go from or towards you like in real life)

At the starting point rotating the cube does not change the positioning on the x/y/z axis.
Then I was thinking of having one object as a parent for rotation and then having a child for the positioning (as seen in video down in tweet)
After that I thought of giving every Axis its own parent child relation ( so pos.x > pos.y > pos.z > rot.x > rot.y > rot.z > cube) but that would also not give the correct position.

Here you can see a video of the setup now, but in this way the origin point of the rotation is off

So I figured out that I have to use “Object3D.translateZ( distance );” for this. Now I just have to get this implemented in a good way because this just moves it the distance given instead of positioning to it.