11

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.

2
  • 3
    Unset the "Show 3D orientation axis" preference in the Preference panel "3D & Multimedia". This is a viewer feature, which has nothing to do with TeX.
    – egreg
    Apr 8, 2012 at 16:06
  • @egreg first, thanks for the information, which is useful. However, I'd prefer a way to hide this by default, probably as a preference from the PDF-generating tool (which is, in this case, the Asymptote/LaTeX combo). I hope this might be possible using a setting or javascript…
    – F'x
    Apr 8, 2012 at 17:09

3 Answers 3

11

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.

2
  • Two JavaScripts attached where?
    – alfC
    Jul 26, 2013 at 1:41
  • @alfC: Attached to the 3D annotation via the add3djscript option. Both are run once upon activation and produce the described behaviour.
    – AlexG
    Jul 26, 2013 at 15:31
7

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!

0
currentprojection=orthographic(camera=(1,0.5,0.2));
1
  • 2
    Welcome to TeX.SE! Please explain in your words what that line of code does and why it solves the given issue. Please see that only a one liner is not a good answer ...
    – Mensch
    Jun 16, 2020 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .