m_translate() pans the camera rather than translating the model. m_translate_scene() translates the models relative to the current view. It does not change the center of rotation.

m_translate(id, x, y, animationDuration, fixedPath)

m_translate_scene(id, x, y, animationDuration, fixedPath)

Arguments

id

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

x

Relative change numeric in view coordinates of camera

y

Relative change numeric in view coordinates of camera

animationDuration

an optional parameter of milliseconds numeric that denotes the duration of a zoom animation

fixedPath

if true animation is constrained to requested motion, overriding updates that happen during the animation

Value

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

Examples

library(r3dmol)

# Translate current view by x,y screen coordinates
r3dmol() %>%
  m_add_model(data = pdb_1j72, format = "pdb") %>%
  m_set_style(style = c(m_style_cartoon(), m_style_stick())) %>%
  m_translate(
    x = 200,
    y = 50,
    animationDuration = 1000
  ) %>%
  m_rotate(
    angle = 90,
    axis = "z",
    animationDuration = 1000
  ) %>%
  m_zoom_to()
# Translate current models by x,y screen coordinates r3dmol() %>% m_add_model(data = pdb_1j72, format = "pdb") %>% m_set_style(style = c(m_style_cartoon(), m_style_stick())) %>% m_translate_scene( x = 200, y = 50, animationDuration = 1000 ) %>% m_rotate( angle = 90, axis = "z", animationDuration = 1000 ) %>% m_zoom_to()