Jorge Hernández
Jorge Hernández

Reputation: 662

How I can configure "metalness" parameter for the globe render on echarts4r?

Hi and thanks for reading me I'm currently working on a globe made with echarts (inside echarts4r) and would like to set a parameter that I saw in their official documentation, which is: "realisticMaterial.metalness", but so far I couldn't get it to work. In the official documentation displays the parameter as follows: enter image description here

I wanted to adapt the code inside echats4r in the following way:

library(echarts4r.assets)
library(echarts4r)

airports <- read.csv(
  paste0("https://raw.githubusercontent.com/plotly/datasets/",
         "master/2011_february_us_airport_traffic.csv")
)

airports |> 
  e_charts(long) |> 
  e_globe(
    viewControl = list(rotateSensitivity = 5),
    realisticMaterial = list(metalness = 1),
    globeOuterRadius = 100
  ) |> 
  e_scatter_3d(lat, cnt, coord_system = "globe", blendMode = 'lighter') |> 
  e_visual_map(inRange = list(symbolSize = c(1, 10))) |> 
  e_color(background = "transparent")

But I haven't been able to get it to work, does anyone know what I could be doing wrong?

Thanks for the help

Upvotes: 2

Views: 67

Answers (1)

Kat
Kat

Reputation: 18754

I'm not sure what you're expecting. (And you asked this quite a while back!)

In order to specify metalness, you have to define what to do with it by specifying the base_texture. (Whether you want to "blend" or "overlay"...apparently, no default is set.)

Check out the code and corresponding perspectives shown here.

In this first plot, I stopped rotation (just to make images easier), changed the amount of metalness to lighten the image, added roughness so that the metal-like appearance would be more evident, added height_texture, and set the base_texture.

airports |> 
  e_charts(long) |> 
  e_globe(
    viewControl = list(rotateSensitivity = 5,
                       autoRotateSpeed = 0),
    shading = 'realistic',
    height_texture = ea_asset('world topo'),
    realisticMaterial = list(metalness = .4, roughness = .1),
    base_texture = 'blend',
    globeOuterRadius = 100
  ) |> 
  e_scatter_3d(lat, cnt, coord_system = "globe", blendMode = 'lighter') |> 
  e_visual_map(inRange = list(symbolSize = c(1, 10))) |> 
  e_color(background = "transparent")

enter image description here

enter image description here

The only difference here is more metalness. The second image (in which I rotated the globe) reflects a bit more of the 'metalness' of it.

airports |> 
  e_charts(long) |> 
  e_globe(
    viewControl = list(rotateSensitivity = 5,
                       autoRotateSpeed = 0),
    shading = 'realistic',
    height_texture = ea_asset('world topo'),
    realisticMaterial = list(metalness = .6, roughness = .1),
    base_texture = 'blend',
    globeOuterRadius = 100
  ) |> 
  e_scatter_3d(lat, cnt, coord_system = "globe", blendMode = 'lighter') |> 
  e_visual_map(inRange = list(symbolSize = c(1, 10))) |> 
  e_color(background = "transparent")

enter image description here

enter image description here

Here I've maximized the metalness and the roughness.

airports |> 
  e_charts(long) |> 
  e_globe(
    viewControl = list(rotateSensitivity = 5,
                       autoRotateSpeed = 0),
    shading = 'realistic',
    height_texture = ea_asset('world topo'),
    realisticMaterial = list(metalness = 1, roughness = 1),
    base_texture = 'blend',
    globeOuterRadius = 100
  ) |> 
  e_scatter_3d(lat, cnt, coord_system = "globe", blendMode = 'lighter') |> 
  e_visual_map(inRange = list(symbolSize = c(1, 10))) |> 
  e_color(background = "transparent")

enter image description here

enter image description here

Upvotes: 1

Related Questions