Update an existing NGLVieweR stage in Shinymode.

updateStage(NGLVieweR_proxy, param = list())

Arguments

NGLVieweR_proxy

A NGLVieweR object.

param

Of type list. Most common options are backgroundColor, rotateSpeed, zoomSpeed, hoverTimeout and lightIntensity. For a full list of options, see the "StageParameters" method in the official NGL.js manual.

Value

API call containing NGLVieweR id and list of message parameters.

See also

Examples

if (FALSE) { # \dontrun{
NGLVieweR("7CID") %>%
 addRepresentation("cartoon",
                   param = list(name = "cartoon", color="red")) %>%
 stageParameters(backgroundColor = "black")
} # }

if (interactive()) {
library(shiny)

ui = fluidPage(
  titlePanel("Viewer with API inputs"),
  sidebarLayout(
    sidebarPanel(
      selectInput("background", "Background", c("black", "white", "blue")),
      actionButton("update", "Update"),
    ),
    mainPanel(
      NGLVieweROutput("structure")
    )
  )
)
server <- function(input, output) {
  output$structure <- renderNGLVieweR({
    NGLVieweR("7CID") %>%
      addRepresentation("cartoon",
        param = list(name = "cartoon", color = "red")
      ) %>%
      stageParameters(backgroundColor = "black")
  })
  observeEvent(input$update, {
    NGLVieweR_proxy("structure") %>%
      updateStage(
      param = list("backgroundColor" = isolate(input$background)))
  })
}
shinyApp(ui, server)
}