3

When I output an rgl scene using OpenGL that includes text and a dark background, the text does not display properly.

Sample code:

library(rgl); library(htmlwidgets)
open3d()
bg3d(color = "black")
text3d(0, 0, 0, text = "Text", color = "blue")
saveWidget(rglwidget(), "Example.html")

Output in R's default device:

Default

Output from HTML widget (displayed here in Google Chrome):

HTML

What can I do to correct for this behavior?

hfisch
  • 1,312
  • 4
  • 19
  • 36
  • I wonder if it might be intentional since typical annotations are black and need a whitish halo in order to remain visible on a dark background. – IRTFM May 11 '17 at 21:51

1 Answers1

4

You must set to black the background option of saveWidget.

library(rgl); library(htmlwidgets)
open3d()
bg3d(color = "black")
text3d(0, 0, 0, text = "Text", color = "blue", specular="black",)
saveWidget(rglwidget(), "Example.html", background = "black")

enter image description here

Marco Sandri
  • 23,289
  • 7
  • 54
  • 58
  • The same problem occurs in ShinyRGL, but this solution will not work. Any idea how to fix it? Lets say in ui.R I'm calling plot: rglwidgetOutput("myPlot") – Art Jul 19 '17 at 07:11
  • @Art Your problem is interesting. I suggest you to open a post on SO and ask for a solution. – Marco Sandri Jul 20 '17 at 09:27