TransWikia.com

Include webgl picture from html file into latex

TeX - LaTeX Asked by mvs on March 16, 2021

I have this picture, which is contained in a html page (see below, you can download the code and open the pic in your browser). From what I see the picture is produced through webgl code inside the html file (I know littel about all of this, even if I did produce the picture myself using asymptote program with the html output option).

I want to include this in a pdflatex doc which I want to print. Thus I do not need in the latex doc a link to the html file but I want to have a final pdf where the picture has been inserted and is clearly visible as any other pdf picture would do.

Is there any possibility of doing this, maybe with hyperref package?

Thanks
Maurizio

html with webgl code to be included into latex doc

One Answer

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

enter image description here

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

Answered by AlexG on March 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP