dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
84 stars 20 forks source link

writeOBJ doesn't save textures/colors #386

Closed maxkarlsson closed 10 months ago

maxkarlsson commented 10 months ago

Hi! when I am saving an .obj from a scene, writeOBJ doesn't keep the colors in the resulting .obj file.

Here is an example:

library(tidyverse)
library(rgl)

points <- 
  tibble(x = rnorm(10),
         y = rnorm(10),
         z = rnorm(10)) %>% 
  mutate(color = colorRampPalette(colors = c("gray", "orangered"))(10))

open3d()
points3d(x = points$x, 
         y = points$y, 
         z = points$z, 
         color = points$color)
writeOBJ("test.obj", withTextures = T, pointRadius = 0.1)
close3d()

This is how the file looks like in the Windows 3D Viewer: image

Any ideas what the issue might be?

I'm grateful for your help!

dmurdoch commented 10 months ago

This is documented in ?writeOBJ.