Description Usage Arguments Author(s) Examples
Render a WebGL Shiny output.
1 2 | renderWebGL(expr, width = "auto", height = "auto",
env = parent.frame(), quoted = FALSE)
|
expr |
The expression to be evaluated which should produce a rgl scene. |
width |
Either "auto", in which case the width will be calculated (reactively) based on the size of the glOutput element associated with this function, or a numeric value representing the width of the desired WebGL scene in pixels. |
height |
The height of the WebGL scene. See
|
env |
The environment in which |
quoted |
Is |
Jeff Allen jeff@trestletech.com
1 2 3 4 5 6 | ## Not run:
renderWebGL({
points3d(1:10,1:10,1:10)
})
## End(Not run)
|
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
3: .onUnload failed in unloadNamespace() for 'rgl', details:
call: fun(...)
error: object 'rgl_quit' not found
function (shinysession, name, ...)
{
open3d(useNULL = TRUE)
func()
prefix <- "gl_output_"
if (width == "auto")
width <- shinysession$clientData[[paste(prefix, name,
"_width", sep = "")]]
if (height == "auto")
height <- shinysession$clientData[[paste(prefix, name,
"_height", sep = "")]]
if (is.null(width) || is.null(height) || width <= 0 || height <=
0)
return(NULL)
if (is.null(width) || !is.numeric(width)) {
stop("Can't support non-numeric width parameter. 'width' must be in px.")
}
if (is.null(height) || !is.numeric(height)) {
stop("Can't support non-numeric height parameter. 'height' must be in px.")
}
zoom <- isolate(shinysession$clientData[[paste(prefix, name,
"_zoom", sep = "")]])
fov <- isolate(shinysession$clientData[[paste(prefix, name,
"_fov", sep = "")]])
pan <- isolate(shinysession$clientData[[paste(prefix, name,
"_pan", sep = "")]])
if (!is.null(zoom)) {
par3d(zoom = zoom)
}
if (!is.null(fov)) {
par3d(FOV = fov)
}
if (!is.null(pan)) {
mat <- matrix(pan, ncol = 4)
par3d(userMatrix = mat)
}
id <- paste(sample(c(letters, LETTERS), 10), collapse = "")
tempDir <- paste(tempdir(), "/", id, "/", sep = "")
tempFile <- file(file.path(tempdir(), paste(id, ".html",
sep = "")), "w")
writeLines(paste("%", id, "WebGL%", sep = ""), tempFile)
close(tempFile)
writeWebGL(dir = tempDir, snapshot = FALSE, template = file.path(tempdir(),
paste(id, ".html", sep = "")), height = height, width = width,
prefix = id)
lines <- readLines(paste(tempDir, "/index.html", sep = ""))
lines <- lines[-1]
unlink(tempDir, recursive = TRUE)
unlink(paste(tempdir(), id, ".html", sep = ""))
rgl.close()
toRet <- paste(lines, collapse = "\\n")
return(list(prefix = id, html = HTML(toRet)))
}
<environment: 0x2a39c78>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.