[Tex/LaTex] How to get rid of the viewer’s (incorrect) axes in an Asymptote 3D graphics

3dasymptote

I have an Asymptote graph of a 3D surface (code below) that I export into 3D PDF file (containing PRC). I include nice axes with LaTeX labels on them, but in addition to these the viewer displays very small axes in the lower left corner (I tried with both Adobe Acrobat Pro X, and Adobe Reader 9):

enter image description here

What's really bugging me is that these viewer axes don't correpond to my model axes really, which makes them not only ugly, but confusing. How can I disable these in my PDF, from the Asymptote source code?

Edit: According to this Adobe Forums thread, I'm supposed to use scene.showOrientationAxes = false; in some Javascript. How can I attach that to my Asymptote source code?


The Asymptote source code for the figure is below:

import graph3; import solids;
settings.outformat="pdf";
size(200,0); currentprojection=orthographic(-0.1,1,0.2);
real pow2(real x) { return (x)*(x); }
real pow4(real x) { return pow2(x)*pow2(x); }
triple sph2cart (triple t)
{ return (t.x*sin(t.y)*cos(t.z),t.x*sin(t.y)*sin(t.z),t.x*cos(t.y)); }
triple f(pair t) {
  return sph2cart((1/(0. - 1.3005572680251514*pow2(cos(t.x))*pow2(cos(t.y))*pow2(sin(t.x)) + 0.13201243635761023*pow2(cos(t.x))*pow2(sin(t.x))*pow2(sin(t.y)) + 1.110738498635555*pow4(cos(t.x)) + 0.11721516517669359*pow2(cos(t.y))*pow2(sin(t.y))*pow4(sin(t.x)) + 0.40749453039149086*pow4(cos(t.y))*pow4(sin(t.x)) + 0.01640741258244529*pow4(sin(t.x))*pow4(sin(t.y))), t.x, t.y));
}

pen p=rgb(0.2,0.5,0.7);
surface s=surface(f,(0,0),(pi,2pi), 30, 30, Spline);
draw(s,lightred);

real max=94.7252;
xaxis3("$x$",-max,max,red,Arrow3);
yaxis3("$y$",-max,max,green,Arrow3);
zaxis3("$z$",-max,max,blue,Arrow3);

It should be run with asy -tex pdflatex input.asy.

Best Answer

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.

Related Question