diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index fdec09c04..8a8ba4c99 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -33,8 +33,6 @@ jobs: steps: - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-pandoc@v2 - name: Install dependencies on MacOS if: runner.os == 'macOS' diff --git a/.github/workflows/R-CMD-fullcheck.yaml b/.github/workflows/R-CMD-fullcheck.yaml index da407d6bc..bd298e891 100644 --- a/.github/workflows/R-CMD-fullcheck.yaml +++ b/.github/workflows/R-CMD-fullcheck.yaml @@ -43,8 +43,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} diff --git a/.github/workflows/R-CMD-nosoft-check.yml b/.github/workflows/R-CMD-nosoft-check.yml index cd7c02f57..7399bbb02 100644 --- a/.github/workflows/R-CMD-nosoft-check.yml +++ b/.github/workflows/R-CMD-nosoft-check.yml @@ -40,8 +40,6 @@ jobs: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} rtools-version: ${{ matrix.config.rtools-version }} - - - uses: r-lib/actions/setup-pandoc@v2 - name: Install automake if: runner.os == 'macOS' diff --git a/.github/workflows/R-CMD-oldwincheck.yml b/.github/workflows/R-CMD-oldwincheck.yml index 301aef4cc..aacb3caac 100644 --- a/.github/workflows/R-CMD-oldwincheck.yml +++ b/.github/workflows/R-CMD-oldwincheck.yml @@ -36,8 +36,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index f1bd86353..83c046a73 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -23,8 +23,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true diff --git a/DESCRIPTION b/DESCRIPTION index 5012863e1..35c197a26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: rgl -Version: 1.2.8 +Version: 1.2.9 Title: 3D Visualization Using OpenGL Authors@R: c(person("Duncan", "Murdoch", role = c("aut", "cre"), email = "murdoch.duncan@gmail.com"), @@ -26,7 +26,8 @@ Authors@R: c(person("Duncan", "Murdoch", role = c("aut", "cre"), person("Michael", "Sumner", role = "ctb"), person("Mike", "Stein", role = "ctb")) Depends: R (>= 3.3.0) -Suggests: MASS, rmarkdown (>= 2.16), deldir (>= 1.0-4), orientlib, lattice, misc3d, +Suggests: MASS, markdown (>= 1.12), + rmarkdown (>= 2.16), deldir (>= 1.0-4), orientlib, lattice, misc3d, magick, plotrix (>= 3.7-3), tripack, interp, alphashape3d, tcltk, js (>= 1.2), webshot2 (>= 0.1.0), downlit (>= 0.4.0), pkgdown (>= 2.0.0), extrafont, shiny, manipulateWidget (>= 0.9.0), testthat, markdown, @@ -46,10 +47,9 @@ URL: https://github.com/dmurdoch/rgl, SystemRequirements: OpenGL and GLU Library (Required for display in R. See "Installing OpenGL support" in README.md. Not needed if only browser displays using rglwidget() are wanted.), - zlib (optional), libpng (>=1.2.9, optional), FreeType (optional), - pandoc (>=1.14, needed for vignettes) + zlib (optional), libpng (>=1.2.9, optional), FreeType (optional) BugReports: https://github.com/dmurdoch/rgl/issues VignetteBuilder: knitr, rmarkdown Biarch: true -RoxygenNote: 7.2.2.9000 +RoxygenNote: 7.2.3 Roxygen: list(markdown = TRUE) diff --git a/NEWS.md b/NEWS.md index 366c18771..e4729d12d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,11 @@ -# rgl 1.2.8 +# rgl 1.2.9 ## Minor changes * ARIA support now declares `rgl` scenes with `role = "img"`. +* The vignettes in this package now use +`markdown::html_format`, so they no longer require Pandoc +(though Pandoc-using output formats like `html_document` will still be supported). ## Bug fixes diff --git a/R/knitr.R b/R/knitr.R index 81c61ca5e..339c45db6 100644 --- a/R/knitr.R +++ b/R/knitr.R @@ -69,9 +69,9 @@ hook_rgl <- function(before, options, envir) { margin <- options$rgl.margin if (is.null(margin)) margin <- 100 par3d(windowRect = margin + options$dpi * - c(0, 0, options$fig.width, options$fig.height)) + c(0, 0, options$fig.width, options$fig.height)) Sys.sleep(.05) # need time to respond to window size change - + dir <- knitr::opts_knit$get("base_dir") if (is.character(dir)) { if (!file_test("-d", dir)) dir.create(dir, recursive = TRUE) @@ -114,9 +114,9 @@ save_rgl <- function(name, devices) { # Evaluate an expression using our own private stream of # randomness (not affected by set.seed). withPrivateSeed <- local({ - + ownSeed <- NULL - + function(expr) { # Save the old seed if present. if (exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) { @@ -125,7 +125,7 @@ withPrivateSeed <- local({ } else { hasOrigSeed <- FALSE } - + # Swap in the private seed. if (is.null(ownSeed)) { if (hasOrigSeed) { @@ -135,11 +135,11 @@ withPrivateSeed <- local({ } else { .GlobalEnv$.Random.seed <- ownSeed } - + # On exit, save the modified private seed, and put the old seed back. on.exit({ ownSeed <<- .GlobalEnv$.Random.seed - + if (hasOrigSeed) { .GlobalEnv$.Random.seed <- origSeed } else { @@ -149,7 +149,7 @@ withPrivateSeed <- local({ # commented it out. # Need to call this to make sure that the value of .Random.seed gets put # into R's internal RNG state. (Issue #1763) - + # httpuv::getRNGState() # nolint }) @@ -177,32 +177,20 @@ fns <- local({ setupKnitr <- function(autoprint = FALSE, rgl.newwindow = autoprint, rgl.closewindows = autoprint) { + + # R produces multiple vignettes in the same session. + # Watch out for leftovers + if (!is.null(setupDone)) { - if (setupDone$autoprint) { - message("undoing setup") - options(saveopts) - saveopts <<- NULL - setupDone <<- NULL - } - } - - if (!is.null(setupDone)) { - if (setupDone$autoprint != autoprint || - setupDone$rgl.newwindow != rgl.newwindow || - setupDone$rgl.closewindows != rgl.closewindows) { - warning("Already set autoprint = ", setupDone$autoprint, - ", rgl.newwindow = ", setupDone$rgl.newwindow, - ", rgl.closewindows = ", setupDone$rgl.closewindows) - } - return() - } + options(saveopts) + saveopts <<- NULL counter <<- 0L + } setupDone <<- list(autoprint = autoprint, rgl.newwindow = rgl.newwindow, rgl.closewindows = rgl.closewindows) - # R produces multiple vignettes in the same session. knitr::opts_chunk$set(rgl.newwindow = rgl.newwindow, rgl.closewindows = rgl.closewindows, rgl.chunk = TRUE) @@ -239,49 +227,49 @@ fns <- local({ } else invisible(x) } - - sew.rglRecordedplot <- function(x, options = list(), ...) { - latex <- identical(opts_knit$get("out.format"), "latex") || identical(opts_knit$get("rmarkdown.pandoc.to"), "latex") - scene <- x$scene - doSnapshot <- knitrNeedsSnapshot(options) - content <- rglwidget(scene, - width = x$width, - height = x$height, - webgl = !doSnapshot) - if (inherits(content, "knit_image_paths")) { - # # We've done a snapshot, put it in the right place. - name <- fig_path("-rgl.png", options, rgl_counter()) - if (!file_test("-d", dirname(name))) - dir.create(dirname(name), recursive = TRUE) - file.copy(content, name, overwrite = TRUE) - unlink(content) - content <- structure(list(file = name, - extension = "png"), - class = "html_screenshot") - } - fig.align <- options$fig.align - if (length(fig.align) == 1 && fig.align != "default") - content <- prependContent(content, - tags$style(sprintf( - "#%s {%s}", - content$elementId, - switch(fig.align, - center = "margin:auto;", - left = "margin-left:0;margin-right:auto;", - right = "margin-left:auto;margin-right:0;", - "")))) - result <- do.call("knit_print", c(list(content, options), x$args)) - if (!latex) - class(result) <- c(class(result), "knit_asis_htmlwidget") - - sew(result, options) + + sew.rglRecordedplot <- function(x, options = list(), ...) { + latex <- identical(opts_knit$get("out.format"), "latex") || identical(opts_knit$get("rmarkdown.pandoc.to"), "latex") + scene <- x$scene + doSnapshot <- knitrNeedsSnapshot(options) + content <- rglwidget(scene, + width = x$width, + height = x$height, + webgl = !doSnapshot) + if (inherits(content, "knit_image_paths")) { + # # We've done a snapshot, put it in the right place. + name <- fig_path("-rgl.png", options, rgl_counter()) + if (!file_test("-d", dirname(name))) + dir.create(dirname(name), recursive = TRUE) + file.copy(content, name, overwrite = TRUE) + unlink(content) + content <- structure(list(file = name, + extension = "png"), + class = "html_screenshot") } + fig.align <- options$fig.align + if (length(fig.align) == 1 && fig.align != "default") + content <- prependContent(content, + tags$style(sprintf( + "#%s {%s}", + content$elementId, + switch(fig.align, + center = "margin:auto;", + left = "margin-left:0;margin-right:auto;", + right = "margin-left:auto;margin-right:0;", + "")))) + result <- do.call("knit_print", c(list(content, options), x$args)) + if (!latex) + class(result) <- c(class(result), "knit_asis_htmlwidget") - list( - setupKnitr = setupKnitr, - knit_print.rglOpen3d = knit_print.rglOpen3d, - knit_print.rglId = knit_print.rglId, - sew.rglRecordedplot = sew.rglRecordedplot) + sew(result, options) + } + + list( + setupKnitr = setupKnitr, + knit_print.rglOpen3d = knit_print.rglOpen3d, + knit_print.rglId = knit_print.rglId, + sew.rglRecordedplot = sew.rglRecordedplot) }) setupKnitr <- fns[["setupKnitr"]] diff --git a/README.Rmd b/README.Rmd index 6610c6e7c..be47797a4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,5 +1,6 @@ --- -output: github_document +output: + markdown::html_format --- @@ -16,9 +17,8 @@ knitr::opts_chunk$set( options(rgl.useNULL=TRUE) suppressPackageStartupMessages(library(rgl)) -if (!requireNamespace("rmarkdown", quietly = TRUE) || - !rmarkdown::pandoc_available("1.14")) { - warning(call. = FALSE, "These vignettes assume rmarkdown and pandoc version 1.14. These were not found. Older versions will not work.") +if (!requireNamespace("rmarkdown", quietly = TRUE)) { + warning(call. = FALSE, "These vignettes assume rmarkdown. This was not found.") knitr::knit_exit() } setupKnitr(autoprint = TRUE) diff --git a/man/setupKnitr.Rd b/man/setupKnitr.Rd index 22ec12e40..9188ccb73 100644 --- a/man/setupKnitr.Rd +++ b/man/setupKnitr.Rd @@ -42,11 +42,6 @@ or \code{\link{highlevel}} functions. All RGL functions that produce graphics do this, but functions in other packages that call them may not return values appropriately. -If you have multiple calls to \code{setupKnitr()}, all -should have the same arguments. If any differ, a -warning will be issued, and the first set of arguments -will be used. - Mixing explicit calls to \code{\link{rglwidget}} with auto-printing is likely to lead to failure of some scenes to display. To avoid this, set \code{options(rgl.printRglwidget = FALSE)} before using such explicit calls. Similarly, diff --git a/vignettes/WebGL.Rmd b/vignettes/WebGL.Rmd index d5a72765b..fd15102ad 100644 --- a/vignettes/WebGL.Rmd +++ b/vignettes/WebGL.Rmd @@ -3,6 +3,9 @@ title: "User Interaction in WebGL (updated)" author: "Duncan Murdoch" date: "`r format(Sys.time(), '%B %d, %Y')`" output: + markdown::html_format: + options: + toc: true rmarkdown::html_vignette: toc: yes fig_width: 5 diff --git a/vignettes/demos.Rmd b/vignettes/demos.Rmd index 81d988d1c..3e9471084 100644 --- a/vignettes/demos.Rmd +++ b/vignettes/demos.Rmd @@ -2,8 +2,9 @@ title: "rgl Demos" date: "`r Sys.Date()`" output: - rmarkdown::html_vignette: - toc: true + markdown::html_format: + options: + toc: true vignette: > %\VignetteIndexEntry{rgl Demos} %\VignetteEngine{knitr::rmarkdown} diff --git a/vignettes/deprecation.Rmd b/vignettes/deprecation.Rmd index 2952cefec..abb183a0b 100644 --- a/vignettes/deprecation.Rmd +++ b/vignettes/deprecation.Rmd @@ -3,6 +3,9 @@ title: "Deprecating the `rgl.*` interface" author: "Duncan Murdoch" date: "`r Sys.Date()`" output: + markdown::html_format: + options: + toc: true rmarkdown::html_vignette: toc: true vignette: > diff --git a/vignettes/pkgdown.Rmd b/vignettes/pkgdown.Rmd index 739bee24b..c979376c4 100644 --- a/vignettes/pkgdown.Rmd +++ b/vignettes/pkgdown.Rmd @@ -2,6 +2,9 @@ title: "Using RGL in pkgdown web sites" author: "Duncan Murdoch" output: + markdown::html_format: + options: + toc: true rmarkdown::html_vignette: fig_height: 5 fig_width: 5 @@ -18,9 +21,8 @@ vignette: > --- ```{r setup, include=FALSE} -if (!requireNamespace("rmarkdown", quietly = TRUE) || - !rmarkdown::pandoc_available("1.14")) { - warning(call. = FALSE, "These vignettes assume rmarkdown and pandoc version 1.14. These were not found. Older versions will not work.") +if (!requireNamespace("rmarkdown", quietly = TRUE)) { + warning(call. = FALSE, "These vignettes assume rmarkdown. This was not found.") knitr::knit_exit() } knitr::opts_chunk$set(echo = TRUE) diff --git a/vignettes/rgl.Rmd b/vignettes/rgl.Rmd index e31958929..83342f19a 100644 --- a/vignettes/rgl.Rmd +++ b/vignettes/rgl.Rmd @@ -3,6 +3,9 @@ title: "rgl Overview" author: "Duncan Murdoch" date: "`r format(Sys.time(), '%B %d, %Y')`" output: + markdown::html_format: + options: + toc: true rmarkdown::html_vignette: fig_height: 5 fig_width: 5 diff --git a/vignettes/setup.R b/vignettes/setup.R index b9a5e0913..963a3e4d6 100644 --- a/vignettes/setup.R +++ b/vignettes/setup.R @@ -3,9 +3,8 @@ suppressPackageStartupMessages(library(rgl)) options(rgl.useNULL=TRUE) options(rgl.printRglwidget=FALSE) -if (!requireNamespace("rmarkdown", quietly = TRUE) || - !rmarkdown::pandoc_available("1.14")) { - warning(call. = FALSE, "These vignettes assume rmarkdown and pandoc version 1.14. These were not found. Older versions will not work.") +if (!requireNamespace("rmarkdown", quietly = TRUE)) { + warning(call. = FALSE, "These vignettes assume rmarkdown is installed. It was not found.") knitr::knit_exit() } diff --git a/vignettes/transparency.Rmd b/vignettes/transparency.Rmd index 3be5f8837..3da5b384e 100644 --- a/vignettes/transparency.Rmd +++ b/vignettes/transparency.Rmd @@ -22,15 +22,15 @@ vignette: > --- ```{r setup, include=FALSE} -if (!requireNamespace("rmarkdown", quietly = TRUE) || - !rmarkdown::pandoc_available("1.14")) { - warning(call. = FALSE, "These vignettes assume rmarkdown and pandoc version 1.14. These were not found. Older versions will not work.") +if (!requireNamespace("rmarkdown", quietly = TRUE)) { + warning(call. = FALSE, "These vignettes assume rmarkdown is installed. This was not found.") knitr::knit_exit() } knitr::opts_chunk$set(echo = TRUE) library(rgl) options(rgl.useNULL = TRUE) setupKnitr(autoprint = TRUE) + M <- structure(c(0.997410774230957, 0.0707177817821503, -0.0130676832050085, 0, -0.0703366547822952, 0.99714070558548, 0.02762770652771, 0, 0.0149840852245688, -0.0266370177268982, 0.999532878398895, 0,