如何阻止 Asymptote 上的 3D 標籤自動填滿顏色?

如何阻止 Asymptote 上的 3D 標籤自動填滿顏色?

我試圖在 Asymptote 中的 3D 向量後麵包含標籤,這些標籤是用不同的顏色繪製的。我想讓所有標籤都是黑色的,但甚至聲明顏色標籤沒有差別。輸出如下圖所示:

在此輸入影像描述

我該如何解決?謝謝你!

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);

編輯:我嘗試將標籤放在一個很小的部分中

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

它剛剛生產了一個完全黑色的標籤盒。所以問題不在於顏色。

答案1

感謝您回報此錯誤。將來,請在以下位置報告錯誤:https://github.com/vectorgraphics/asymptote/issues

修復現已包含在 git 中,並將包含在即將發布的 2.84 版本中。

使用settings.render=0時要小心;此方法僅對隱藏表面移除、照明和透明度提供有限的支援。看 https://asymptote.sourceforge.io/doc/ Three.html

同時,如果你真的希望繼續使用實驗性的 settings.render=0 選項,您可以從您的 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");

答案2

我會使用內建的unitcone一些幾何變換。關於顏色:只需使用blackinsideLabel為其字串著色即可。希望現在的程式碼很簡單。

在此輸入影像描述

// 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);

相關內容