Use m_add_unit_cell to create and add unit cell visualization, and m_remove_unit_cell to remove it from model. Use m_replicate_unit_cell to replicate atoms in model to form a super cell of the specified dimensions. Original cell will be centered as much as possible.

m_add_unit_cell(id, model, spec)

m_replicate_unit_cell(id, a, b, c, model)

m_remove_unit_cell(id, model)

Arguments

id

R3dmol id or a r3dmol object (the output from r3dmol())

model

Model with unit cell information (e.g., pdb derived). If omitted uses most recently added model.

spec

Visualization style.

a

number of times to replicate cell in X dimension.

b

number of times to replicate cell in Y dimension. If absent, X value is used.

c

number of times to replicate cell in Z dimension. If absent, Y value is used.

Value

R3dmol id or a r3dmol object (the output from r3dmol())

Examples

library(r3dmol)

# Create model
mol <- r3dmol() %>%
  m_add_model(
    data = cif_254385,
    "cif",
    options = list(doAssembly = TRUE, normalizeAssembly = TRUE)
  ) %>%
  m_set_style(style = c(
    m_style_sphere(colorScheme = "Jmol", scale = 0.25),
    m_style_stick(colorScheme = "Jmol")
  )) %>%
  m_add_unit_cell(spec = list(
    alabel = "x",
    blabel = "y",
    clabel = "z",
    box = list(hidden = TRUE)
  )) %>%
  m_zoom_to()

# Render model
mol
# Remove unit cell mol %>% m_remove_unit_cell()
# Replicate atoms in model to form a super cell r3dmol() %>% m_add_model(data = cif_254385, format = "cif") %>% m_set_style(style = m_style_sphere(scale = 0.25)) %>% m_add_unit_cell() %>% m_zoom_to() %>% m_replicate_unit_cell(a = 3, b = 2, c = 1)