1

This is a follow up after my own question. Back when the following MWE worked and compiled correctly.

\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));

path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;

triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];

triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];

triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];

path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
draw(sq11,white+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle);

path3 q21=rotate(-28,X)*q11;
surface sq21=surface(q21);
draw(sq21,white+opacity(.6),light=nolight);
draw(rotate(-28,X)*(D -- -Y -- C-Y -- C -- cycle));

path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
draw(sq31,white+opacity(.6),light=nolight);
draw(D--C--A--B--cycle);

path3 q34=(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);
surface sq34=surface(q34);
draw(sq34,white+opacity(.6),light=nolight);
draw(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);

path3 q22=(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);
surface sq22=surface(q22);
draw(sq22,white+opacity(.6),light=nolight);
draw(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);

path3 q12=(D -- C -- E -- F -- cycle);
surface sq12=surface(q12);
draw(sq12,white+opacity(.6),light=nolight);
draw(q12);

surface s4=surface(pl3);
draw(s4,white+opacity(.6),light=nolight);
draw(pl3);

path3 q32=(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);
surface sq32=surface(q32);
draw(sq32,white+opacity(.6),light=nolight);
draw(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);

path3 q13=(Y -- C+Y -- E -- F -- cycle);
surface sq13=surface(q13);
draw(sq13,white+opacity(.6),light=nolight);
draw(Y -- C+Y -- E -- F -- cycle);

dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);

//From Charles Staats's tutorial
//Direction of a point toward the camera.
triple cameradirection(triple pt, projection P=currentprojection) {
  if (P.infinity) {
    return unit(P.camera);
  } else {
    return unit(P.camera - pt);
  }
}

//Move a point closer to the camera.
triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
  return pt + distance * cameradirection(pt, P);
}

label("$A$",align=NE,position=towardcamera((A)));
label("$B$",align=S,position=towardcamera((B)));
label("$C$",align=SE,position=towardcamera((C)));
label("$D$",align=SW,position=towardcamera((D)));
label("$E$",align=NE,position=towardcamera((E)));
label("$F$",align=S,position=towardcamera((F)));
\end{asy}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));

path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;

triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];

triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];

triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];

path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
draw(sq11,red+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle,red);

path3 q21=rotate(-28,X)*q11;
surface sq21=surface(q21);
draw(sq21,blue+opacity(.6),light=nolight);
draw(rotate(-28,X)*(D -- -Y -- C-Y -- C -- cycle),blue);

path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
draw(sq31,green+opacity(.6),light=nolight);
draw(D--C--A--B--cycle,green);

path3 q34=(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);
surface sq34=surface(q34);
draw(sq34,green+opacity(.6),light=nolight);
draw(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle,green);

path3 q22=(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);
surface sq22=surface(q22);
draw(sq22,blue+opacity(.6),light=nolight);
draw(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle,blue);

path3 q12=(D -- C -- E -- F -- cycle);
surface sq12=surface(q12);
draw(sq12,red+opacity(.6),light=nolight);
draw(q12,red);

surface s4=surface(pl3);
draw(s4,yellow+opacity(.6),light=nolight);
draw(pl3,yellow);

path3 q32=(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);
surface sq32=surface(q32);
draw(sq32,green+opacity(.6),light=nolight);
draw(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle,green);

path3 q13=(Y -- C+Y -- E -- F -- cycle);
surface sq13=surface(q13);
draw(sq13,red+opacity(.6),light=nolight);
draw(Y -- C+Y -- E -- F -- cycle,red);

dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);

//From Charles Staats's tutorial
//Direction of a point toward the camera.
triple cameradirection(triple pt, projection P=currentprojection) {
  if (P.infinity) {
    return unit(P.camera);
  } else {
    return unit(P.camera - pt);
  }
}

//Move a point closer to the camera.
triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
  return pt + distance * cameradirection(pt, P);
}

label("$A$",align=NE,position=towardcamera((A)));
label("$B$",align=S,position=towardcamera((B)));
label("$C$",align=SE,position=towardcamera((C)));
label("$D$",align=SW,position=towardcamera((D)));
label("$E$",align=NE,position=towardcamera((E)));
label("$F$",align=S,position=towardcamera((F)));
\end{asy}
\end{document}

enter image description here

Now I have an issue for no reason. When I compile exactly that MWE, a black empty window appears and then quickly disappears in the first run.

enter image description here

It doesn't appear anymore in the following compiling runs (I use TexStudio). In the output document there appears just a space reserved for the picture. Nothing else.

enter image description here

If I change settings.render = 0; into settings.render = 16; everything works:

enter image description here

But I must use vector graphics. This is a publishing house requirement. Apparently, this is a problem with compilation, not with Asymptote. How to fix this? I need vector picture as it used to be. @cfr, @CharlesStaats.

%==== UPDATE =======

By @CharlesStaats suggestion I used this superminimal working example

\documentclass[10pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
Hello!

    \begin{figure}[h]
        \begin{asy}
        settings.outformat = "pdf";
        settings.prc = false;
        settings.render = 16;
        import three;
        import bsp;
        texpreamble("\usepackage{euler,beton}");
        size(5cm, 0);
        currentprojection=orthographic((5,4,3));

        path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
        path3 pl1=rotate(-28,X)*pl;
        path3 pl2=rotate(-56,X)*pl;
        path3 pl3=shift(-0.3*normal(pl1))*pl1;

        draw (pl);
        draw (pl1);
        draw (pl2);
        draw (pl3);

        triple[] asd=intersectionpoints(pl2,pl3);
        triple A=asd[1];
        triple B=asd[0];

        triple[] asf=intersectionpoints(pl,pl2);
        triple C=asf[1];
        triple D=asf[0];

        triple[] asg=intersectionpoints(pl,pl3);
        triple E=asg[1];
        triple F=asg[0];

        surface s1=surface(pl);
        draw(s1,white+opacity(.6),light=nolight);
        surface s2=surface(pl1);
        draw(s2,white+opacity(.6),light=nolight);
        surface s3=surface(pl2);
        draw(s3,white+opacity(.6),light=nolight);
        surface s4=surface(pl3);
        draw(s4,white+opacity(.6),light=nolight);


        draw(B--A);
        draw(C--D);
        draw(E--F);

        dot(A,red);
        dot(B,red);
        dot(C,red);
        dot(D,red);
        dot(E,red);
        dot(F,red);

        //From Charles Staats's tutorial
        //Direction of a point toward the camera.
        triple cameradirection(triple pt, projection P=currentprojection) {
        if (P.infinity) {
        return unit(P.camera);
        } else {
        return unit(P.camera - pt);
        }
        }

        //Move a point closer to the camera.
        triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
        return pt + distance * cameradirection(pt, P);
        }

        label("$A$",align=NE,position=towardcamera((A)));
        label("$B$",align=S,position=towardcamera((B)));
        label("$C$",align=SE,position=towardcamera((C)));
        label("$D$",align=SE,position=towardcamera((D)));
        label("$E$",align=NE,position=towardcamera((E)));
        label("$F$",align=S,position=towardcamera((F)));
        \end{asy}

    \end{figure}

Hello world!
\end{document}

The black window is back. Output: enter image description here

BUT! This is NOT vector graphics! (settings.render = 16;)

With settings.render = 0 works weirdly: enter image description here

After placing the document.tex (standard for TexStudio) into home-folder and starting

asy -vv document.tex

this is what the terminal gives (apparently a haven't change a symbol in the code): enter image description here

Maybe I should install the newest asymptote like it was suggested here in comments (somebody erased that comment for some reason.) I even asked the question how to do it. Nobody has answers yet.

  • If you need to draw the plane segments by hand, you could consider doing it with TikZ, e.g. tex.stackexchange.com/a/509163. – Schrödinger's cat Feb 21 at 16:52
  • Thanks for the suggestion. Although he previous example works, but not on my machine (even though it used to) and I want to understand why. – Sergey Belyaev Feb 21 at 18:06
  • 1
    Yes, I understand this. I recently encountered similar problems with asymptote, which is why I upvoted the question. My point was simply that, if you cannot solve the problem in time, you may temporarily switch to other methods to generate the vector graphics. – Schrödinger's cat Feb 21 at 19:45
  • What happens if you try copying the asymptote code (everything inside \begin{asy}...\end{asy}) into its own file and run asy on that directly? Better yet, run asy -vv [filename], where the -vv will raise the verbosity level, and show us what is printed on the terminal. – Charles Staats Feb 24 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.