stageParameters: Set stage parameters

View source: R/NGLVieweR.R

stageParametersR Documentation

Set stage parameters

Description

Set stage parameters.

Usage

stageParameters(NGLVieweR, ...)

Arguments

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.

Details

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").

Value

Returns list of stage parameters to NGLVieweR htmlwidgets object.

See Also

  • updateStage()

  • NGLVieweR_example() See example "basic".

Examples

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)
}


NGLVieweR documentation built on Oct. 20, 2026, 1:07 a.m.