1

I am trying to include labels after 3D vectors in Asymptote, which are drawn with different colors. I want to have all the labels black, but even declaring the color after the label makes no difference. Here's what the output looks like:

enter image description here

How do I fix this? Thank you!

import math;
settings.outformat="pdf";
settings.prc=true;
settings.embed=true;
settings.render=0;
size(5cm,0);
import graph3;

triple F(pair uv) {
real r = uv.x;
real t = uv.y;
return (r*cos(t),r*sin(t), r);}
surface coneup = surface(F, (0,0), (1,2pi), Spline);
draw(coneup, surfacepen=material(paleyellow, emissivepen=0.2 paleyellow), light=Viewport);

triple F2(pair uv) {
real r = uv.x;
real t = uv.y;
return (r*cos(t),r*sin(t), -r);}
surface conedown = surface(F2, (0,0), (1,2pi), Spline);
draw(conedown, surfacepen=material(paleyellow, emissivepen=0.2 paleyellow), light=Viewport);

draw(O--X, Arrow3);
draw(O--Y, Arrow3);
draw(O--Z, Arrow3);

draw(O--Y+Z, L=Label("null", position=EndPoint), yellow, Arrow3);
draw(O--.5*X+1.5*Z, L=Label("timelike", position=EndPoint), green, Arrow3);
draw(O--1.5*X+0.5*Z, L=Label("spacelike", position=EndPoint), red, Arrow3);

Edit: I tried putting the label in a miniscule segment with

draw(0.99*(Y+Z) -- Y+Z, L=Label("null", position=EndPoint));

and it just produced a completely black label box. So the problem is not the colors.

2 Answers 2

3

Thanks for reporting this bug. In the future, please report bugs at https://github.com/vectorgraphics/asymptote/issues

A fix is now included in git and will be included in the upcoming 2.84 release.

Be careful using settings.render=0; only limited support for hidden surface removal, lighting, and transparency is available with this approach. See https://asymptote.sourceforge.io/doc/three.html

In the meantime, if you really wish to continue using the experimental settings.render=0 option, you can delete the following lines marked - from your copy of three.asy:

diff --git a/base/three.asy b/base/three.asy
index c208f59d..9dfad6ce 100644
--- a/base/three.asy
+++ b/base/three.asy
@@ -2907,11 +2907,6 @@ object embed(string prefix=outprefix(), string label=prefix,
   if((preview || (prc && settings.render == 0)) && settings.embed) {
     image=prefix;
     if(settings.inlinetex) image += "_0";
-    if(!preview && !S.pic2.empty2()) {
-      transform T=S.pic2.scaling(S.width,S.height);
-      _shipout(image,S.pic2.fit(T),newframe,nativeformat(),false,false);
-    }
-
     image += "."+nativeformat();
     if(!settings.inlinetex) file3.push(image);
     image=graphic(image,"hiresbb");
1
  • Thank you! I suspected it was a bug and it is comforting to hear confirmation from one of the coauthors. I started playing around with Asymptote very recently and I'll make sure to check the github page in case I come across anything else strange. :-)
    – Ivo Terek
    Oct 12, 2022 at 3:07
1

I would use the built-in unitcone with some geometric transforms. About the color: just use black inside Label to color its string. Hope that the code is simple now.

enter image description here

// http://asymptote.ualberta.ca/
size(6cm,0);
import three;
currentprojection=orthographic(3,2,1,zoom=.9,center=true);

surface conedown=shift(0,0,-1)*unitcone;
surface coneup=scale(1,1,-1)*conedown;
material p=material(paleyellow,emissivepen=0.2 paleyellow);
draw(coneup,surfacepen=p,light=Viewport);
draw(conedown,surfacepen=p,light=Viewport);

draw(O--X, Arrow3);
draw(O--Y, Arrow3);
draw(O--Z, Arrow3);
draw(Label("null",EndPoint,align=E,black),O--Y+Z,yellow,Arrow3);
draw(Label("time-like",EndPoint,black),O--.5*X+1.5*Z,green,Arrow3);
draw(Label("space-like",EndPoint,black),O--1.5*X+0.5*Z,red,Arrow3);
1
  • 1
    +1 Thank you! This code is really simpler than what I had and I wasn't aware of this built-in cone. I'm just giving John's answer the checkmark because it did confirm that what I had was a bug (your code still produced black boxes on my end, so the problem was really here and not there).
    – Ivo Terek
    Oct 12, 2022 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .