My goal is to display points on a transparent sphere using RGL. This works fine by using
open3d(windowRect=c(0,0,512,512))
plot3d(c(x,-x),c(y,-y),c(z,z),aspect=F)
shade3d(ellipse3d(diag(3), c(0,0,0),t=1),
color='lightgray',alpha=0.8,lit=FALSE, add=TRUE)
rglwidget()
However, when in the same plot the function bgplot3d()
is called, the sphere is somehow pushed into the foreground and drowns out all the points and the box around it:
It would be great to have the sphere in the same way as before, even in the case bgplot3d()
has been called. I already experimented with depth_mask, but nothing worked so far.
CodePudding user response:
Call plot3d
after shade3d
:
library(rgl)
set.seed(666)
pts <- uniformly::runif_on_sphere(25, d = 3)
x <- rnorm(100)
y <- rnorm(100)
open3d(windowRect = c(50, 50, 562, 562))
shade3d(ellipse3d(diag(3), t = 1),
color = 'lightgray', alpha = 0.8, lit = FALSE)
plot3d(pts, aspect = FALSE, add = TRUE, col = "red", size = 4)
bgplot3d(plot(x, y))
CodePudding user response:
The problem has vanished after installing the most recent rgl
update (version 0.109.2).