How to get rid of the viewer's (incorrect) axes in an Asymptote 3D graphics
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.
OK, so this is accessible by Javascript as scene.showOrientationAxes = false
. The shortest way I found is to patch Asymptote to do it every time I create a 3D scene:
--- three.asy.orig 2012-04-08 19:28:50.000000000 +0200
+++ three.asy 2012-04-08 19:31:01.000000000 +0200
@@ -2558,6 +2558,8 @@ private string billboard(int[] index, tr
{
if(index.length == 0) return "";
string s="
+scene.showOrientationAxes = false;
+
var zero=new Vector3(0,0,0);
var nodes=scene.nodes;
var count=nodes.count;
Of course, it'd be nicer to make it a setting accessible via Asymptote!