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, ...)

Arguments

data3js

The data3js object

x

x coordinate of the sphere center

y

y coordinate of the sphere center

z

z coordinate of the sphere center

radius

sphere radius

col

color

highlight

highlight attributes (see highlight3js())

...

other arguments to pass to material3js()

Value

Returns an updated data3js object

See also

Examples

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