Let's say I have a plane. This plane is either $z=a$, $y=a$ or $x=a$ ($a$ being any constant). I have a camera somewhere in the world in which this plane lies.
I look at a line on a plane parallel to the given plane. I know the length of this line, and the projection angle $\beta$ (the angle under which I look at it with my camera).
Is it possible to determine the distance to the endpoints of my line?
Below is a little drawing for clarification. The endpoints of the line have the same $x$, $y$ or $z$ coordinates as the line is parallel to the given plane.

Since I don't really work a lot with camera models, my terminology will probably be imprecise.
Let's call $O$ the "center of projection" of the camera. Since I don't know how you track your camera, the position of $O$ may not exactly be that of the camera, but working with $O$ makes everything simpler. Normally if you know your camera matrix, you can deduce the position of $O$ from that of the camera.
With that said, let $PQ$ be the line segment, and $H$ the affine plane through $O,P,Q$. Choose an arbitrary coordinate system in $H$ with origin $O$. If you can obtain the polar coordinates of $P(\rho_P,\theta_P),Q(\rho_Q,\theta_Q)$ in $H$, then you're done. From your description you already know how to obtain the $\theta$ angle coordinate for both points, and you also know the vector $\vec{PQ}$.
Let $\mathbf u(\theta)$ denote the unit vector parallel to $H$ with angle $\theta$ in $H$. By definition $\vec{OP}=\rho_P\mathbf u(\theta_P)$ and $\vec{OQ}=\rho_Q\mathbf u(\theta_Q)$. Because $\vec{PQ}$ is parallel to $H$, there exists some angle $\varphi$ such that $\vec{PQ}=a\mathbf u(\varphi)$, where $a$ denotes the side length of the cube. With the information you have, you should be able to compute (one of) the value(s) of $\varphi$.
From there you can establish a system of equation to obtain $\rho_P,\rho_Q$ from the other parameters $a,\theta_P,\theta_Q,\varphi$. Using $\vec{PQ}=\vec{OQ}-\vec{OP}$ you can express the square of the length $PQ$ in two ways, which yield $$ a^2=\rho_P^2+\rho_Q^2-2\rho_P\rho_Q\cos(\theta_P-\theta_Q)$$ Similarly you can compute the scalar product $\vec{OQ}.\vec{OP}$ in two ways which yield $$\rho_P\rho_Q\cos(\theta_P-\theta_Q)=\rho_P^2+a\rho_P\cos(\theta_P-\varphi)$$ Under the (reasonable) assumption that $\rho_P\neq 0$, you can inject the second equation into the first, and you will obtain $\rho_Q$ or $\rho_P$ by solving a quadratic equation.