Construct an indexed sweep with independent geometry, normal, and texture indices. Geometry construction is independent of any renderer.

extruded_path_mesh(
  points,
  polygon = NA,
  polygon_end = NA,
  breaks = NA,
  closed = FALSE,
  closed_smooth = TRUE,
  polygon_add_points = 0,
  twists = 0,
  texture_repeats = 1,
  straight = FALSE,
  precomputed_control_points = FALSE,
  width = 1,
  width_end = NA,
  width_ease = "spline",
  smooth_normals = FALSE,
  u_min = 0,
  u_max = 1,
  linear_step = FALSE,
  end_caps = c(TRUE, TRUE),
  initial_normal = NULL,
  smooth_angle = 180,
  arc_tolerance = 1e-05,
  position = c(0, 0, 0),
  scale = c(1, 1, 1),
  angle = c(0, 0, 0),
  pivot_point = c(0, 0, 0),
  order_rotation = c(1, 2, 3),
  material = material_list(),
  material_caps = NULL,
  separate_caps = FALSE
)

Arguments

points

Matrix or data frame with three columns, or a list of numeric three-vectors, describing the path. With precomputed controls, a list of four-by-three cubic Bezier control-point matrices.

polygon

Default NA. Cross-section accepted by xy.coords(); defaults to a 30-sided circle with diameter one. Must be a simple polygon without holes. A repeated closing vertex is removed.

polygon_end

Default NA. Optional final profile with the same number of vertices. Corresponding rows are interpolated along the full path.

breaks

Default NA. Samples along the full path, including endpoints; defaults to 20 times the number of Bezier segments. Exact trim endpoints and polyline corners are inserted as needed.

closed

Default FALSE. Close the path and align its end frames.

closed_smooth

Default TRUE. Use C2-continuous periodic interpolation for a closed smooth path. Otherwise its closing segment has C1 continuity. Ignored for straight paths and precomputed controls.

polygon_add_points

Default 0. Number of points to insert per profile edge before sweeping.

twists

Default 0. Number of full profile rotations over the path.

texture_repeats

Default 1. Texture repetitions along the full path.

straight

Default FALSE. Connect points with straight segments.

precomputed_control_points

Default FALSE. Interpret points as cubic Bezier controls instead of interpolation points.

width

Default 1. Nonnegative profile scale, or numeric width values spaced evenly along the path. An xy.coords() representation supplies explicit positions from zero to one and widths. Zero-width rings form triangle fans.

width_end

Default NA. Final width when width is a scalar; otherwise ignored. Defaults to the initial width.

width_ease

Default "spline". Shape-preserving cubic interpolation between widths. Other choices are linear, quad, cubic, and exp.

smooth_normals

Default FALSE. Include surface normals accounting for taper, twist, and changing profiles. Cap normals remain hard.

u_min

Default 0. Start of the retained path interval. Closed paths can wrap across their seam.

u_max

Default 1. End of the retained path interval. A full closed interval has no caps. Equal endpoints produce an empty mesh.

linear_step

Default FALSE. Interpret path coordinates as normalized arc length using adaptive sampling instead of Bezier parameter distance.

end_caps

Default c(TRUE, TRUE). Include the starting and ending caps.

initial_normal

Default NULL. Initial direction of the profile's positive X axis, projected perpendicular to the path tangent. Must not be parallel to that tangent. By default curvature or a stable axis is used.

smooth_angle

Default 180. Maximum profile turning angle in degrees to smooth. Smaller values preserve corners when smooth_normals = TRUE.

arc_tolerance

Default 1e-5. Relative adaptive sampling tolerance, measured against the total control-polygon length.

position

Default c(0, 0, 0). Translation of the completed mesh.

scale

Default c(1, 1, 1). Scale of the mesh, uniformly or per axis.

angle

Default c(0, 0, 0). Rotation angles in degrees.

pivot_point

Default c(0, 0, 0). Point around which to rotate.

order_rotation

Default c(1, 2, 3). Order to rotate the axes.

material

Default material_list(). Surface material.

material_caps

Default NULL. Cap material; defaults to material.

separate_caps

Default FALSE. Return surfaces and caps separately for independent editing or material assignment by another renderer.

Value

A ray_mesh, or NULL for an empty interval or entirely zero-width sweep. With separate_caps = TRUE, a list with surface and caps entries, each containing a ray_mesh or NULL.

Details

Closed sweeps correct accumulated frame rotation. Full loops and intervals crossing the seam require compatible endpoint profiles, widths, and twists. For example, a square profile permits quarter-turn seam rotations. Invalid seams raise an error. Profile winding is normalized while retaining the first vertex. Texture seams and shading creases use separate attribute indices.

Examples

path = rbind(c(0, 0, 0), c(0, 1, 1), c(1, 2, 1))
tube = extruded_path_mesh(path, width = 0.2, smooth_normals = TRUE)
parts = extruded_path_mesh(path, width = 0.2, separate_caps = TRUE)