diff --git a/DESCRIPTION b/DESCRIPTION index bc0831b84..50627abfe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "murdoch.duncan@gmail.com"), diff --git a/NEWS.md b/NEWS.md index 472c54644..a4ccb67ee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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"`. diff --git a/R/zzz.R b/R/zzz.R index b4eec2f3b..489cfa0d5 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -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? @@ -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")) diff --git a/src/BBoxDeco.cpp b/src/BBoxDeco.cpp index fa6b6dc4f..9036d942d 100644 --- a/src/BBoxDeco.cpp +++ b/src/BBoxDeco.cpp @@ -463,25 +463,21 @@ struct BBoxDeco::BBoxDecoImpl { } } - AxisInfo* axis; Edge* axisedge; int nedges; switch(coord) { case 0: - axis = &(bboxdeco.xaxis); axisedge = xaxisedge; nedges = 4; break; case 1: - axis = &(bboxdeco.yaxis); axisedge = yaxisedge; nedges = 8; break; case 2: default: - axis = &(bboxdeco.zaxis); axisedge = zaxisedge; nedges = 4; break; @@ -520,13 +516,14 @@ struct BBoxDeco::BBoxDecoImpl { static Edge* fixedEdge(Material* material) { - Edge* axisedge; - int i,j, lim, coord = material->marginCoord; + Edge* axisedge = xaxisedge; + int i,j, lim = 4, coord = material->marginCoord; bool match; switch(coord) { case 0: - axisedge = xaxisedge; - lim = 4; + // Initialized to this case to suppress "may be unused" message + // axisedge = xaxisedge; + // lim = 4; break; case 1: axisedge = yaxisedge; diff --git a/src/api.cpp b/src/api.cpp index b8e16061e..b1b0582e6 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -321,8 +321,9 @@ void rgl::rgl_attrib_count(int* id, int* attrib, int* count) RGLView* rglview = device->getRGLView(); Scene* scene = rglview->getScene(); Subscene* subscene = scene->whichSubscene(*id); - AABox bbox = subscene->getBoundingBox(); SceneNode* scenenode = scene->get_scenenode(*id); + // getBoundingBox is called for the side effect of possibly calculating data_bbox. + subscene->getBoundingBox(); if ( scenenode ) *count = scenenode->getAttributeCount(subscene, *attrib); else