Description Usage Arguments Value See Also Examples
Start spin animation and stop rocking. Works on an existing NGLVieweR object in Shinymode.
1 | updateSpin(NGLVieweR_proxy, spin = TRUE)
|
NGLVieweR_proxy |
A NGLVieweR object. |
spin |
If |
API call containing NGLVieweR
id
and list of message parameters.
setSpin()
NGLVieweR_example()
See example "updateAnimation".
Other animations:
setRock()
,
setSpin()
,
updateRock()
,
updateZoomMove()
,
zoomMove()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ## 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.