Pipe

Procedural extruded mesh along a path: sweep a 2D base shape along a 3D polyline with per‑segment thickness, optional end caps and color gradient.

Pipe

Pipe(base_shape=Quad, origin=(0,0), path=((0,0,0),(0,1,0)), thicknesses=((1,1),), color_gradient=None, look_at=True, cap_ends=True, mode='triangle', **kwargs)

Located in ursina/models/procedural/pipe.py

Overview

Extrudes a 2D cross‑section (base_shape) along a 3D path, generating side faces and optional end‑caps. Supports variable thickness per segment and color gradients along the sweep.

Constructor Arguments

ArgumentTypeDefaultDescription
base_shapeMesh or listQuadCross‑section shape to extrude (Mesh instance or list of 2D points).
origintuple(float,float)(0,0)Local origin pivot within the base shape.
pathsequence of Vec3((0,0,0),(0,1,0))3D positions defining the sweep centerline.
thicknessessequence of tuple((1,1),)Per‑point scale of the base shape (width, height).
color_gradientsequence of ColorNoneGradient colors sampled along the path.
look_atboolTrueIf True, orient cross‑section to face next path point.
cap_endsboolTrueAdd triangular end‑caps at start and end.
modestr'triangle'Primitive mode for mesh generation.
**kwargsanyOther Mesh kwargs (static, thickness, etc.).

Fields

NameDescription
.base_shapeVertex list of the 2D cross‑section.
.pathThe input polyline of Vec3 positions.
.thicknessesScale factors applied to the base_shape at each path point.
.look_atWhether each segment faces forward along the path.
.cap_endsWhether to generate end‑cap triangles.

Methods

MethodDescription
generate()Build the mesh: extrude base_shape along path, create side faces, apply caps and colors.

Example Usage

from ursina import *
app = Ursina()

# build a circular path
from ursina.models.procedural.circle import Circle
path = [v * 5 for v in Circle().vertices]
path.append(path[0])

# sweep a quad along that path without end caps
e = Entity(model=Pipe(path=path, cap_ends=False))
print(len(e.model.vertices), len(e.model.colors))

EditorCamera()
app.run()