Update:
The workaround listed below is obsolete as of Asymptote 2.17. Now, the model axes are always in alignment with the viewer axes, independent from the projection angle set in the asy
input.
The reason for the misalignment is the fact that asymptote transforms the 3D object within the x-y-z world-coordinate system of the PRC file according to the
currentprojection=orthographic(-0.1,1,0.2);
setting in the asy source. It would be better to only apply the vector given to the initial camera position in the viewer. (Someone should tell this to the asymptote developpers.)
To have the axes of the 3D object aligned with the world axes do as follows:
Use
currentprojection=orthographic(0,0,1);
in the asy source file. And compile it with
asy -keep -tex pdflatex source.asy
Then, embed the prc produced using the media9
package:
\documentclass{article}
\usepackage{media9}
\includemedia[
width=0.8\linewidth,height=0.8\linewidth,
activate=pageopen,
add3Djscript=asylabels.js,
add3Djscript=3Dspintool.js,
3Dmenu,
3Dc2c=1 1 0.2, %object-to-camera vector
%settings below found by right-click-->Generate Default View
3Dcoo=-1.2360605001449585 -2.1437549591064453 -345.6598815917969,
3Droo=377.89275461201964,
3Dlights=Headlamp,
]{\includegraphics{source+0.pdf}}{source+0.prc}
\end{document}
Two JavaScripts have been attached in this example. asylabels.js
enables "billboard" behaviour of text labels. 3Dspintool.js
enables the 3D spin tool which facilitates moving the 3D object. The initial camera position was set using the 3Dc2c
option which is the object-to-camera direction vector.
WOW! This is really quite elegant.
You could have made your life a lot easier though, if you had used the TikZ 3D coordinate system, defined as \draw (0,1,2)--(2,3,4);
and, if needed, adjusting the x,y and z coorinates by \begin{tikzpicture}[x={(1cm,0cm)},y={(0cm,1cm)},z={(0.73cm,0.73cm)}]
or something alike.
This changes the lengths with which the x,y and z are projected onto x and y.
As an alternative, you could have used thetikz-3dplot
package to rotate your camera perspective about azimuth and elevation. Really just a two liner:
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords]
for 70 degree azimuth and 110 degree of elevation.
When rotating, you have to remember though, that TikZ has no real 3D support, as in:
z-buffering is not (yet?) supported. You might therefore have to adjust some colors after rotation. This is because, with rotation, the drawing order can change. Then things are in front of others, because of the time they are calculated, not where they are in 3D. This is explained in the tikz3dplot example manual, chapter 3.3.
Also, the use of relative coordinates helps to focus on the contents, rather than the creation of the figure. \draw (2,3,4)--++(0,0,1);
takes you towards z by one, from where you used to be.
On a rather unrelated note, you should load the TikZ-packages in the preamble, otherwise you would have to reload them in every scope. This would slow down compilation speed, for larger documents.
Best Answer
What you want is called "oblique" projection. As explained here http://en.wikipedia.org/wiki/Oblique_projection.
You need to use
currentprojection=oblique;
to achieve this kind of projection.First two examples from the gallery:
http://asymptote.sourceforge.net/gallery/planes.asy
http://asymptote.sourceforge.net/gallery/.cache/planes.png
Now the code:
(BTW, I couldn't make the sign of the angle argument of
obliqueZ
orobliqueX
to make the "x" axis to stick to left-top direction.)and just to illustrate that is not possible to get this with other projections,