sphere3js.Rd
Unlike points3js, where geometric points can also be represented as spheres, this adds sphere that is sized with respect to the actual dimensions of the plotting space (and so if aspect ratios differ for each axis may not actually appear sphere-like).
sphere3js(data3js, x, y, z, radius, col = "black", highlight, ...)
The data3js object
x coordinate of the sphere center
y coordinate of the sphere center
z coordinate of the sphere center
sphere radius
color
highlight attributes (see highlight3js()
)
other arguments to pass to material3js()
Returns an updated data3js object
Other plot components:
arrows3js()
,
axis3js()
,
box3js()
,
grid3js()
,
legend3js()
,
light3js()
,
lines3js()
,
mtext3js()
,
points3js()
,
segments3js()
,
shape3js()
,
surface3js()
,
text3js()
,
triangle3js()
# Setup base plot
p <- plot3js(
xlim = c(-10, 10),
ylim = c(-5, 5),
zlim = c(-8, 8)
)
# Add sphere (this will look distorted because of axis scaling)
p <- sphere3js(
data3js = p,
0, 0, 0,
radius = 5,
col = "green"
)
r3js(p, zoom = 2.5)
# Setup base plot with equal aspect ratio
p <- plot3js(
xlim = c(-10, 10),
ylim = c(-5, 5),
zlim = c(-8, 8),
aspect = c(1, 1, 1)
)
# Add sphere (fixed aspect ratio now makes the sphere look spherical)
p <- sphere3js(
data3js = p,
0, 0, 0,
radius = 5,
col = "green"
)
r3js(p, zoom = 2)