Skip to content

Commit

Permalink
Merge pull request #422 from dmurdoch/bgplotbug
Browse files Browse the repository at this point in the history
Fix background issues
  • Loading branch information
dmurdoch authored May 1, 2024
2 parents 3ce3610 + b01710a commit 0b13a69
Show file tree
Hide file tree
Showing 13 changed files with 14 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: 1.3.5
Version: 1.3.6
Title: 3D Visualization Using OpenGL
Authors@R: c(person("Duncan", "Murdoch", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# rgl 1.3.5
# rgl 1.3.6

## Minor changes

* `readSTL()` can now read (some) ASCII format STL files.

## Bug fixes

* Background plots did not always appear (issue #421).
* Changing the background resulted in an additional background
object instead of replacing the current one.

# rgl 1.3.4

## Bug fixes
Expand Down
3 changes: 2 additions & 1 deletion R/bgplot3d.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ bgplot3d <- function(expression, bg.color = getr3dDefaults("bg", "color"),
grDevices::devAskNewPage(FALSE)
value <- try(expression)
safe.dev.off()
result <- bg3d(texture = filename, col = "white", lit = FALSE, ...)
result <- bg3d(texture = filename, col = "white", lit = FALSE,
front = "filled", back = "filled", ...)
} else {
value <- NULL
result <- bg3d(col = bg.color, ...)
Expand Down
1 change: 1 addition & 0 deletions R/r3d.rgl.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ bg3d <- function(color,
else if (flags["exp_fog", 1]) "exp"
else if (flags["exp2_fog", 1]) "exp2"
else "none"
pop3d(type = "background", id = bgid)
}
dots <- list(...)

Expand Down
3 changes: 3 additions & 0 deletions inst/htmlwidgets/lib/rglClass/draw.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,17 @@
savepr = this.prMatrix;
saveinvpr = this.invPrMatrix;
savemv = this.mvMatrix;
savenorm = this.normMatrix;
this.prMatrix = new CanvasMatrix4();
this.invPrMatrix = new CanvasMatrix4();
this.mvMatrix = new CanvasMatrix4();
this.normMatrix = new CanvasMatrix4();
for (i=0; i < obj.quad.length; i++)
result = result.concat(this.drawObjId(obj.quad[i], subsceneid));
this.prMatrix = savepr;
this.invPrMatrix = saveinvpr;
this.mvMatrix = savemv;
this.normMatrix = savenorm;

} else if (obj.sphere) {
subscene = this.getObj(subsceneid);
Expand Down
Binary file modified tests/testthat/testdata/mergeVertices.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/obj.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/qmesh3d.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/r3d.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/shade3detc.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/subscenes.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/tmesh3d.rds
Binary file not shown.
Binary file modified tests/testthat/testdata/transformations.rds
Binary file not shown.

0 comments on commit 0b13a69

Please sign in to comment.