I have tried without success to create a toggle-able plot display using the following code:
library(shiny)
library(rgl)
ui <- (fluidPage(
checkboxInput("chk", label = "Display", value = TRUE),
playwidgetOutput("control"),
rglwidgetOutput("wdg")
))
server <- function(input, output, session) {
options(rgl.useNULL = TRUE)
save <- options(rgl.inShiny = TRUE)
on.exit(options(save))
open3d()
plot3d(rnorm(100), rnorm(100), rnorm(100))
scene <- scene3d()
rgl.close()
plot3d(scene)
output$wdg <- renderRglwidget({
rglwidget(controllers = c("control"))
})
output$control <- renderPlaywidget({
toggleWidget("wdg", respondTo = "chk",
ids = as.integer(names(scene$objects[1])))
})
}
shinyApp(ui = ui, server = server)
With the current code setup, I get the following error:
Error: length(buttonLabels) == length(components) is not TRUE
From what I can tell about the way toggleWidget wraps playwidget, though, it seems like both buttonLabels and components are character vectors with a length of 1.
I have also tried a number of different variations for the ids variable of toggleWidget with similar levels of success. Examples for rgl in Shiny seem to be few and far between.
What is the proper way to use a toggleWidget in rgl with Shiny?
toggleWidgetinsiderenderPlaywidget. The latter is intended to hold aplayWidgetand nothing else. However, I don't know Shiny well enough to know what you should be doing instead. How would you include html code? - user2554330