texture doesnt map correctly in rglWidget when using rgl package in shiny

huangapple go评论70阅读模式
英文:

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(&quot;textures/sunsleep.png&quot;, package = &quot;rgl&quot;),
  alpha = 1,
  texmode = &quot;replace&quot;,
  textype = &quot;rgb&quot;,
  col = &quot;white&quot;
)

texture doesnt map correctly in rglWidget when using rgl package in shiny

Shiny

library(shiny)
library(rgl)

shinyApp(ui = bootstrapPage(
  rglwidgetOutput(&quot;widget&quot;)
  ),
  server = function(input, output, session) {
    output$widget &lt;- renderRglwidget({
      try(close3d(), silent = TRUE)
      open3d(useNULL = TRUE)
      spheres3d(
        x = 0,
        y = 0,
        z = 0,
        radius = 1,
        texture = system.file(&quot;textures/sunsleep.png&quot;, package = &quot;rgl&quot;),
        alpha = 1,
        texmode = &quot;replace&quot;,
        textype = &quot;rgb&quot;,
        col = &quot;white&quot;
      )
      rglwidget()
    })
  }
)

texture doesnt map correctly in rglWidget when using rgl package in shiny

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(&quot;dmurdoch/rgl&quot;)

huangapple
  • 本文由 发表于 2023年4月17日 23:00:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76036543.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定