英文:
texture doesnt map correctly in rglWidget when using rgl package in shiny
问题
I am trying to visualize a sphere with a texture in a shiny app using the rgl
package. However, I've realized that the texture isn't mapped correctly in the shiny output compared to the RGL Device.
Here is an example:
RGL Device
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"
)
Shiny
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.
英文:
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:
RGL Device
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"
)
Shiny
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.
答案1
得分: 0
这在rgl@1.1.13中已解决。
使用以下命令安装rgl的开发版本:
remotes::install_github("dmurdoch/rgl")
英文:
This is solved in rgl@1.1.13.
Install the development version of rgl with:
remotes::install_github("dmurdoch/rgl")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论