Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawing a 3d path confuses axis ticks in a later (2d) figure #514

Open
sanjoymahajan opened this issue Jan 13, 2025 · 8 comments
Open

drawing a 3d path confuses axis ticks in a later (2d) figure #514

sanjoymahajan opened this issue Jan 13, 2025 · 8 comments

Comments

@sanjoymahajan
Copy link

With the following code, the graph in the second pdf figure has a extra set of axis ticks next to the left end. These ticks are closely spaced (and not what was intended). But changing the unitcircle3 to unitcircle solves the problem. The code is compiled with asy -noprc -render=0 -tex pdflatex -f pdf -V -wait "three-graph-bug" using Asymptote 2.95 (on Debian linux). I think that this behavior is a bug (maybe a name clash between something in the three module and the graph module?), but I am happy to be corrected.

import graph;
import three;

size(150);
draw(unitcircle3, dashed);  // next figure works fine if drawing unitcircle here, instead of unitcircle3
shipout(outprefix());

erase();

size(300,150);
xaxis(xmin=0, xmax=3, Ticks(format=" ", Step=1));
shipout(outprefix()+"-tmp");

erase();
@johncbowman
Copy link
Member

Yes, this appears to be a bug. In the meantime remove -render=0 from the command line; this is an experimental feature that isn't intended for normal use. Proper 3D graphics visualization requires rendering.

@sanjoymahajan
Copy link
Author

Thanks, I've just now tried it. Without -render=0, the graph (the "-tmp.pdf" figure) is correct. However, removing the switch causes a couple problems. One is small: During the compilation, a ghost window pops up and disappears on its own (twice).

The second is larger: The 3d figure (the dashed unitcircle3) is rendered as a raster image in the PDF file, rather than as a vector graphic. I couldn't find a switch to force vector graphics, other than -render=0 (which is why it's been in my .asy->.pdf Makefile rule for eons).

@charlesstaats
Copy link
Contributor

Possible workaround (not tested): Rather than calling erase();, try currentpicture = new picture;. That requires you to reset the size information, but you're doing that anyway.

@johncbowman
Copy link
Member

  1. The ghost window that pops up is the OpenGL rendering window. You may be able to avoid this with the setting -conify=true. The need for a rendering window will disappear when we switch over the master branch to use Vulkan. In the meantime you can try out the version in the vulkan branch.

  2. Currently, the only official 3D vector graphics format for PDF is the deprecated (and limited) PRC format. This requires the option -prc and the resulting PDF must be viewed with Adobe Acrobat (acroread). The only other solution is to use the V3D format and the online V3D-aware PDF viewer at https://github.com/vectorgraphics/pdfv3dReader. We are working on a plugin that adds V3D support to Okular but it isn't ready yet.

@johncbowman
Copy link
Member

P.S. If you insist on using the experimental -render=0 setting, Charle's suggestion of changing the first erase(); to
currentpicture=new picture; is a good workaround for now.

@sanjoymahajan
Copy link
Author

Possible workaround (not tested): Rather than calling erase();, try currentpicture = new picture;. That requires you to reset the size information, but you're doing that anyway.

Thank you -- I've just tested it, and it works.

@sanjoymahajan
Copy link
Author

  1. The ghost window that pops up is the OpenGL rendering window. You may be able to avoid this with the setting -conify=true. The need for a rendering window will disappear when we switch over the master branch to use Vulkan. In the meantime you can try out the version in the vulkan branch.

I tried asy -iconify -tex pdflatex -f pdf "three-graph-bug" but it hangs. With -v:

$ asy -v -iconify -tex pdflatex -f pdf "three-graph-bug"
Processing three-graph-bug
adjusting camera to (5.00992732115699,4.00805144468558,1.95907880773636)
adjusting target to (0.00992732115699363,0.00805144468557806,-0.0409211922636425)

But it may be an issue with talking to my window manager (X11+fvwm3). It's probably not the most modern of setups (since forever, I had used twm).

@sanjoymahajan
Copy link
Author

P.S. If you insist on using the experimental -render=0 setting, Charle's suggestion of changing the first erase(); to currentpicture=new picture; is a good workaround for now.

Indeed, that workaround did work.

I like -render=0! I don't need, or at least don't think that I need, full 3d visualization in a viewer. I mostly make figures (for textbooks on paper or viewed on screen), and most figures are just 2d. But a few are semi-3d: They should look 3d enough for students to do 3d manipulations on them mentally and reliably.

Of course, if PDF had a universal and decent 3d format (universal in the sense of being supported on almost all viewers including on Linux), I would happily use it too where needed pedagogically. But it seems like such a format change to PDF will never happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants