The planes3d expands and draws the area based on the sphere's radius. Is there a way to suppress this? More desirable for me would be to clip the drawing area, though.
library(rgl)
z <- c(0,0,1)
y <- c(0,1,0)
x <- c(1,0,0)
bg3d(color = "white")
rgl.spheres(x, y, z, r = 0.02, color = "grey")
planes3d(1, 0, 0, 0, col = 'blue', alpha = 0.6, size = 0)
planes3d(0, 1, 0, 0, col = 'red', alpha = 0.6, size = 0)
planes3d(0, 0, 1, 0, col = 'green', alpha = 0.6, size = 0)
view3d(theta=230, phi=-30, zoom=1, fov=0)
snapshot3d("r0_02.png", fmt="png", width=640, height=480, webshot=F)
clear3d()
rgl.spheres(x, y, z, r = 0.2, color = "grey")
planes3d(1, 0, 0, 0, col = 'blue', alpha = 0.6, size = 0)
planes3d(0, 1, 0, 0, col = 'red', alpha = 0.6, size = 0)
planes3d(0, 0, 1, 0, col = 'green', alpha = 0.6, size = 0)
view3d(theta=230, phi=-30, zoom=1, fov=0)
snapshot3d("r0_2.png", fmt="png", width=640, height=480, webshot=F)
I'm expecting a workaround.
You shouldn't be using
planes3d(), which draws infinite planes, clipped to the bounding box.There might be a workaround where you put the planes in one subscene and apply clipping there, and put the spheres in a different subscene with no clipping, but that would be tricky to implement.
A better approach is to use
quads3d()instead ofplanes3d(). With your example, this would beCreated on 2024-01-11 with reprex v2.0.2
In an earlier version of this answer, the spheres showed weird black blobs on the edges. That was due to a bug in
rglthat has been fixed. This image was drawn with the development version 1.2.10.