Set stage parameters.
stageParameters(NGLVieweR, ...)A NGLVieweR object.
Options controlling the stage. 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.
Returns list of stage parameters to NGLVieweR
htmlwidgets object.
Options that are not given use the NGL.js defaults. In Shiny, this
also holds when renderNGLVieweR() re-renders: an option set in an
earlier render but not in the current one returns to its default.
setFocus() and setQuality() are shortcuts that set clipping, fog and
quality. Options named here win over them: for example
setFocus(50) %>% stageParameters(fogFar = 60) keeps the clipping
of focus 50 with fogFar 60.
All NGL.js stage parameters can be set here or changed later with
updateStage(). For example:
Clipping: clipNear, clipFar, clipDist,
clipMode ("scene" or "camera") and clipScale ("relative"
or "absolute").
Fog: fogNear and fogFar.
Lighting: lightColor, lightIntensity,
ambientColor and ambientIntensity.
Camera: cameraType ("perspective", "orthographic" or
"stereo"), cameraFov and cameraEyeSep.
Mouse controls: mousePreset ("default", "pymol", "coot" or
"astexviewer").
NGLVieweR_example() See example "basic".
NGLVieweR("7CID") %>%
stageParameters(backgroundColor = "white", zoomSpeed = 1) %>%
addRepresentation("cartoon", param = list(name = "cartoon", colorScheme="residueindex"))
# Orthographic camera, PyMOL mouse controls and fog
NGLVieweR("7CID") %>%
stageParameters(
cameraType = "orthographic",
mousePreset = "pymol",
fogNear = 40,
fogFar = 80
) %>%
addRepresentation("cartoon")
if (interactive()) {
library(shiny)
ui <- fluidPage(NGLVieweROutput("structure"))
server <- function(input, output) {
output$structure <- renderNGLVieweR({
NGLVieweR("7CID") %>%
stageParameters(backgroundColor = "white", zoomSpeed = 1) %>%
addRepresentation("cartoon",
param = list(name = "cartoon", colorScheme = "residueindex")
)
})
}
shinyApp(ui, server)
}