vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Does WebGL output support a two and a three dimensional next to each other? #374

Closed kiryph closed 1 year ago

kiryph commented 1 year ago

Consider this example from https://tex.stackexchange.com/a/615968/8917

import graph;
import solids;
currentprojection=orthographic(3,3,1.5);
//currentlight=Viewport;
currentlight.background = gray(.7);

picture pic1,pic2;
size(pic1,200);
size(pic2,200);
path g= (0, 0.65){right}
..{up}(0.45, 1)
--(0.5, 1){down}
..{left}(0.1,0.6)
{right}..{down}(0.15,0.55)
..{down}(0.075,0.35){down}
..{down}(0.075, 0.2)
..(0.15,0.15){down}
..{left}(0.1,0.1){right}
..{right}(0.4,0.05)
--(0.4,0){left}
..{left}(0,0.05);
pen[] colors={red,green,blue};
colors.cyclic=true;

for(int i=0;i<length(g);++i){

draw(pic1,subpath(g,i,i+1),colors[i]+1bp);
path3 p=path3(subpath(g,i,i+1),YZplane);
revolution R=revolution(p,Z,0,300);
draw(pic2,surface(R),colors[i],meshpen=black+0.55bp);

}
xaxis(pic1,"$x$",Arrow());
yaxis(pic1,"$y$",Arrow());

picture pic;
picture pic3;
add(pic,pic1.fit(),(0,0),15W);
add(pic,pic2.fit(),(0,0),15E);
draw(pic3,(-15,0)--(15,0),Arrow);
add(pic,pic3.fit());
add(pic.fit(),Fill(gray(.7)));

Run it with asy -f pdf -o TwoAndThreeNext demo-splits.asy and you get X4j0W

When I run it with

asy -f html -o TwoAndThreeNext demo-splits.asy

I get following errors:

This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-03-30>
(./TwoAndThreeNext_.tex
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/usr/local/texlive/2023/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2023/texmf-dist/tex/latex/graphics-def/dvips.def)))
(/usr/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-dvips.def)
(./TwoAndThreeNext_.aux)

! LaTeX Error: File `TwoAndThreeNext+0' not found.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.165 ...ludegraphics[hiresbb]{TwoAndThreeNext+0}}
                                                  %
[1] (./TwoAndThreeNext_.aux) )
(see the transcript file for additional information)
Output written on TwoAndThreeNext_.dvi (1 page, 6084 bytes).
Transcript written on TwoAndThreeNext_.log.
  _shipout(prefix,f,currentpatterns,format,wait,view,t);
          ^
/usr/local/texlive/2023/texmf-dist/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed

Related question on tex.stackoverflow.com

If this is not possible, what would be a good workaround?

johncbowman commented 1 year ago

First of all, the original example doesn't contain any 3D vector graphics: the 3D content has already been projected to a static 2D bitmap and added to a 2D image.

We haven't added any support for 2D to the AsyGL library since one can use SVG instead. So you need to use -fsvg not -fhtml for 2D scenes like this.