You can have both, interactive 3D content that opens on click and a nicely rendered vector image for printing and PDF viewers that don't support PRC. For this, add
import three;
settings.render = 0;
at top of the asy
code.
Compile example.tex
with
pdflatex example
asy example-1.asy
pdflatex example
Input example.tex
:
\documentclass[varwidth,border=3pt]{standalone}
\usepackage{hyperref,calc}
\usepackage[inline]{asymptote}
\setlength{\textwidth}{\widthof{\begin{NoHyper}\url{https://asymptote.sourceforge.io/gallery/3Dwebgl}\end{NoHyper}}}
\begin{document}
Example \verb+cylinder.asy+, taken from\\
\url{https://asymptote.sourceforge.io/gallery/3Dwebgl}
\begin{center}
\begin{asy}
import three;
settings.render = 0;
size(0,100);
import solids;
currentlight=Viewport;
triple v=O;
real r=1;
real h=1.5;
triple axis=Y+Z;
// Optimized cylinder
surface cylinder=shift(v)*align(unit(axis))*scale(r,r,h)*unitcylinder;
draw(cylinder,green,render(merge=true));
// Skeleton
revolution r=cylinder(v,r,h,axis);
//draw(surface(r),green,render(merge=true));
draw(r,blue+0.15mm);
\end{asy}
\end{center}
\end{document}
If you want only the vector image that is used as the poster image for the inactive 3D content as a stand-alone file, run asy
with option -k
(keep files) and look for example-1+0_0.pdf
. This file can be included in other documents in the usual way using \includegraphics
:
asy -k example-1.asy
asy -f png
orasy -f pdf
give you a usable output, instead of trying to convert a webgl or html file into an image.