I am trying to visualize a sphere with a texture in shiny app using rgl
package. However, I've realized that texture isn't mapped correctly in the shiny output compared to RGL Device.
Here is an example:
library(rgl)
spheres3d(
x = 0,
y = 0,
z = 0,
radius = 1,
texture = system.file("textures/sunsleep.png", package = "rgl"),
alpha = 1,
texmode = "replace",
textype = "rgb",
col = "white"
)
library(shiny)
library(rgl)
shinyApp(ui = bootstrapPage(
rglwidgetOutput("widget")
),
server = function(input, output, session) {
output$widget <- renderRglwidget({
try(close3d(), silent = TRUE)
open3d(useNULL = TRUE)
spheres3d(
x = 0,
y = 0,
z = 0,
radius = 1,
texture = system.file("textures/sunsleep.png", package = "rgl"),
alpha = 1,
texmode = "replace",
textype = "rgb",
col = "white"
)
rglwidget()
})
}
)
You can see that they look different, the texture in the shiny output didn't get mapped correctly. How can I fix the texture mapping so it looks exactly like the rgl device version? So far I have tried tweaking the par3d but to no avail.
This is solved in [email protected].
Install the development version of rgl with:
remotes::install_github("dmurdoch/rgl")