updateSpin {NGLVieweR} | R Documentation |
Update Spin
Description
Start spin animation and stop rocking. Works on an existing NGLVieweR object in Shinymode.
Usage
updateSpin(NGLVieweR_proxy, spin = TRUE)
Arguments
NGLVieweR_proxy |
A NGLVieweR object. |
spin |
If |
Value
API call containing NGLVieweR
id
and list of message parameters.
See Also
-
NGLVieweR_example()
See example "updateAnimation".
Other animations:
setRock()
,
setSpin()
,
updateRock()
,
updateZoomMove()
,
zoomMove()
Examples
## Not run:
NGLVieweR_proxy("structure") %>% updateRock(TRUE)
## End(Not run)
if (interactive()) {
library(shiny)
ui = fluidPage(
titlePanel("Viewer with API inputs"),
sidebarLayout(
sidebarPanel(
radioButtons("animate", label = "Animation",
choices = c("None", "Spin", "Rock"), selected = "None")
),
mainPanel(
NGLVieweROutput("structure")
)
)
)
server = function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
addRepresentation("cartoon",
param = list(name = "cartoon", color="red"))
})
observeEvent(input$animate,{
if(input$animate == "Rock"){
NGLVieweR_proxy("structure") %>%
updateRock(TRUE)
} else if(input$animate == "Spin") {
NGLVieweR_proxy("structure") %>%
updateSpin(TRUE)
} else{
NGLVieweR_proxy("structure") %>%
updateRock(FALSE) %>%
updateSpin(FALSE)
}
})
}
shinyApp(ui, server)
}
[Package NGLVieweR version 1.3.1 Index]