Class for creating an opengl scene with rgl.

Class for creating an opengl scene with rgl.

Public fields

default_material

default material

width, height

dimensions of rgl window

polygon_offset, polygon_offset_delta

current polygon offset, and the delta to adjust the offset by every time an element is drawn

Active bindings

width, height

dimensions of rgl window

polygon_offset, polygon_offset_delta

current polygon offset, and the delta to adjust the offset by every time an element is drawn

Methods

Public methods


Method new()

initialise

Usage

RGLDoc$new(
  fov = 30,
  width = 800,
  height = 600,
  zscale = 1,
  view = c("front", "flat"),
  view_angle = 0,
  view_flat_angle = -45,
  zoom = 0.8,
  view3d_args = NULL,
  light = list(theta = 0, phi = 0),
  background = list(color = "white"),
  default_material = standard_material,
  polygon_offset_delta = 0.03,
  ...
)

Arguments

fov

field of view. default: 0 isometric view. Other good values are 30 and 45.

width, height

dimensions of viewing window. default 800x600

zscale

scale factor applied to z axis. default 1.

view

One of 'front', 'flat'. This will be ignored if view3d_args is set.

view_angle

rotation angle of view in degrees. Only used if view is 'front' or 'flat'. Default: 0

view_flat_angle

angle to tip view when view is 'flat'.

zoom

zoom level. default 0.800. Larger values make the plot appear further from the screen.

view3d_args

full viewpoint specification as a list of arguments to rgl::view3d(). Default: NULL

light

list of arguments to rgl.light() to define the light for this scene.

background

list of arguments to rgl.bg() to define the background for these scene

default_material

default material for objects

polygon_offset_delta

incremental change in polygon_offset after every element is rendered. Adjust this value to try and minimise issues with z-fighting of overlapping elements.

...

other arguments passed to rgl::open3d() Add a circle


Method circle()

Usage

RGLDoc$circle(
  x,
  y,
  z,
  r,
  colour,
  color = colour,
  alpha = 1,
  circle_segments = 30
)

Arguments

x, y, z

coords

r

radius

colour, color

colour

alpha

alpha

circle_segments

number of segments to render for a circle Add an arbitrary call to this document


Method add_call()

Usage

RGLDoc$add_call(cc, default_args = standard_material)

Arguments

cc

standard R call object

default_args

default args Add a sphere


Method sphere()

Usage

RGLDoc$sphere(x, y, z, r, colour, color = colour, alpha = 1)

Arguments

x, y, z

coords

r

radius

colour, color

colour

alpha

alpha Add a point


Method point()

Usage

RGLDoc$point(x, y, z, r, colour, color = colour, alpha = 1)

Arguments

x, y, z

coords

r

radius

colour, color

colour

alpha

alpha Add a rect


Method rect()

Usage

RGLDoc$rect(
  x1,
  y1,
  x2,
  y2,
  z,
  colour,
  fill,
  lwd = 3,
  color = colour,
  alpha = 1
)

Arguments

x1, y1, x2, y2, z

coords

colour, color, fill

colour

lwd

line width i.e. size

alpha

alpha Add a line


Method line()

Usage

RGLDoc$line(x1, y1, x2, y2, z, colour, lwd = 3, color = colour)

Arguments

x1, y1, x2, y2, z

coords

colour, color

colour

lwd

line width i.e. size Add a polyline


Method polyline()

Usage

RGLDoc$polyline(xs, ys, z, colour, lwd = 3, color = colour)

Arguments

xs, ys, z

coords

colour, color

colour

lwd

line width i.e. size Add a polygon


Method polygon_old()

Usage

RGLDoc$polygon_old(xs, ys, z = 0, colour, fill, alpha = 1, lwd = 3)

Arguments

xs, ys, z

coords

colour, fill

colour

alpha

alpha

lwd

line width i.e. size Add a polygon


Method polygon()

Usage

RGLDoc$polygon(xs, ys, z = 0, colour, fill, alpha = 1, lwd = 3)

Arguments

xs, ys, z

coords

colour, fill

colour

alpha

alpha

lwd

line width i.e. size Add a path


Method path()

Usage

RGLDoc$path(df, colour, fill, alpha = 1, lwd = 3)

Arguments

df

polygon specification

colour, fill

colour

alpha

alpha

lwd

line width i.e. size Add text


Method text()

Usage

RGLDoc$text(text, x, y, z = 0, colour, cex = 1)

Arguments

text

text to write

x, y, z

coords

colour, color

colour

cex

character expansion values Render an image onto a quad


Method image_as_quad()

Usage

RGLDoc$image_as_quad(
  png_filename,
  x,
  y,
  z,
  width,
  height,
  alpha = 1,
  angle = 0,
  option = 0
)

Arguments

png_filename

filename of PNG to add to image

x, y

display position

z

height

width, height

display width and height

alpha

overall alpha

angle

rotation angle of quad around the z axis

option

generic option to control rendering Save as PNG or WebGL based upon suffix


Method save()

Usage

RGLDoc$save(filename)

Arguments

filename

filename


Method clone()

The objects of this class are cloneable with this method.

Usage

RGLDoc$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.