处理-透视透明3D形状

处理-透视透明3D形状,3d,processing,3d,Processing,我希望能够看到通过透明的三维形状。 例如,这: void setup() { size(400, 400, P3D); } void draw() { clear(); translate(width/2, height/2, -width/2); stroke(255); fill(0, 255, 255, 100); box(width); noStroke(); lights(); fill(255);

我希望能够看到通过透明的三维形状。 例如,这:

void setup() {
    size(400, 400, P3D);
}

void draw() {
    clear();
    translate(width/2, height/2, -width/2);

    stroke(255);
    fill(0, 255, 255, 100);
    box(width);

    noStroke();
    lights();
    fill(255);
    sphere(100);

}
…显示以下内容:

但我想要这个:


注意,我刚刚为第二个添加了
提示(禁用深度测试)
。我想要一个没有这个的解决方案,因为,你知道,它禁用了深度测试。

我建议用禁用的深度测试绘制框。但在绘制球体之前启用深度测试:

void draw() {
    clear();
    translate(width/2, height/2, -width/2);

    hint(DISABLE_DEPTH_TEST);
    stroke(255);
    fill(0, 255, 255, 100);
    box(width);

    hint(ENABLE_DEPTH_TEST);
    noStroke();
    lights();
    fill(255);
    sphere(100); 
}

您知道这是预期的处理行为,还是一个bug的解决方法?这同样适用于2个形状,但是如果场景有数百个形状呢?