Adds trails that follow the terrain surface. Trails use lightweight rgl line previews while caching solid meshes for render_highquality(). Each input line is meshed independently, without road grades, lanes, layer rules, intersection solving, or mesh joining.

render_trails(
  trails,
  color = "grey50",
  width = 1,
  width_column = NULL,
  width_units = c("scene", "meters"),
  densify = TRUE,
  offset = NULL,
  height = 0.05,
  clear_previous = TRUE,
  preview = c("line", "mesh"),
  verbose = FALSE,
  parallel = TRUE,
  zscale = 1,
  vertical_exaggeration = 1,
  heightmap = NULL
)

Arguments

trails

Spatial line data used to draw trails. Supports sf, sfc, sfg, SpatialLines, and SpatialLinesDataFrame line inputs.

color

Default "grey50". Trail color.

width

Default 1. Trail width in the units selected by width_units.

width_column

Default NULL. Column name in an sf trail object used to set per-feature trail widths. Values must be positive finite numbers and use the same units as width.

width_units

Default "scene". Units used by width and width_column. "scene" uses scene grid-cell units; "meters" converts physical widths using the scene extent and CRS.

densify

Default TRUE. Whether to densify trails and resample them along the terrain before meshing.

offset

Default NULL. Vertical trail centerline offset in elevation units. When NULL, the mesh is centered on the terrain surface.

height

Default 0.05. Total solid mesh thickness in scene units.

clear_previous

Default TRUE. Whether to remove the existing trail layer before drawing the new one. A clear-only call returns without drawing a replacement.

preview

Default "line". Whether trails are drawn in rgl as lightweight "line" previews or as their cached "mesh" geometry. Both options use the solid mesh in render_highquality().

verbose

Default FALSE. Whether to show native meshing progress.

parallel

Default TRUE. Whether to build independent trail meshes in parallel with the native job queue.

zscale

Default 1. Ratio between horizontal spacing and elevation units. If omitted for a spatial raster scene, rayshader uses its resolution.

vertical_exaggeration

Default 1. Multiplier applied to the effective visual relief. If omitted, rayshader uses the active scene value.

heightmap

Default NULL. Height matrix or spatial raster for the current scene. If omitted, rayshader uses the active scene heightmap.

Value

Invisibly returns the independently meshed trail coordinates.

Examples

volcano_dem = volcano_spatial()
volcano_dem |>
  height_shade() |>
  plot_3d()

render_trails(
  volcano_trails,
  color = "grey50",
  width = 3,
  width_units = "meters"
)
render_camera(theta=-33,phi=40,zoom=0.4)
# RGL render uses lines for speed
render_snapshot()

# High quality render uses mesh trail
render_highquality(samples=16)

# RGL preview can be set to use (potentially slower) mesh preview
render_trails(
  volcano_trails,
  color = "grey50",
  width = 3,
  width_units = "meters",
  preview="mesh",
  clear_previous = TRUE
)
render_snapshot()