Skip to content

Commit

Permalink
Merge pull request #186 from dmurdoch/reprex
Browse files Browse the repository at this point in the history
Detect `reprex::reprex()` and arrange for a screenshot
  • Loading branch information
dmurdoch authored Mar 7, 2022
2 parents de4bdb0 + b2b33b3 commit fa06260
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rgl
Version: 0.108.21
Version: 0.108.22
Title: 3D Visualization Using OpenGL
Authors@R: c(person("Duncan", "Murdoch", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
* `sprites3d()` now has the option of
`rotating = TRUE`, to allow 3D sprites to rotate with
the scene.

* Added `getShaders()` function to get shaders used in WebGL.

* Now detects if `rgl` is running within `reprex::reprex()`
and if so arranges that a screenshot will be included in the
output.

## Minor changes

* Added `as.mesh3d()` methods for `"rglsubscene"` and `"rglscene"`.
Expand Down
10 changes: 10 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@

if (!rgl.useNULL())
setGraphicsDelay(unixos = unixos)

# Are we running in reprex::reprex? If so, do
# the knitr setup so our output appears there.

if (in_reprex()) {
setupKnitr(autoprint = TRUE)
}
}

# Do we need a delay opening graphics?
Expand Down Expand Up @@ -191,3 +198,6 @@ rgl.init <- function(initValue = 0, onlyNULL = FALSE, debug = getOption("rgl.deb
.C( rgl_quit, success=FALSE )

}

in_reprex <- function()
!is.null(getOption("reprex.current_venue"))

0 comments on commit fa06260

Please sign in to comment.