Overview
Bending a mesh along a path is a common need: trains on tracks, text running along a ribbon, tentacles, cables and conveyor props. Three.js's CurveModifier addon does it on the GPU. This playground deforms a mesh along an editable Catmull-Rom spline and slides it along the curve in real time, with controls for the path's shape and the object's roll.
How it works
Flow from examples/jsm/modifiers/CurveModifier.js wraps a mesh and replaces its material's vertex shader logic. The curve is sampled and its points and moving frames (tangent, normal and binormal) are stored in a data texture. In the vertex shader, each vertex's position along the mesh's long axis is treated as a distance along the curve: the shader looks up the curve point and frame at that distance, then places the vertex using its remaining two coordinates as offsets in the frame's normal and binormal directions. The result is a mesh that bends smoothly to follow the path.
Moving the object along the path is just a matter of adding an offset to that distance each frame with flow.moveAlongCurve(amount), so animation costs almost nothing on the CPU. When you change the spline (bend, arc height, centre height or tension), the demo rebuilds the curve, resamples it, and updates the flow texture. The roll parameter rotates the object around the tangent.
Exploring the demo
Adjust bend and arc height to reshape the path and watch the mesh conform to it as it travels. Increase the tension to tighten the corners, and change the roll to twist the object around its direction of travel. Turn on the spline line and control points to see exactly what the mesh is following.
Practical advice
The mesh needs enough subdivisions along its long axis to bend smoothly, since only vertices move. Moving frames can twist unexpectedly on curves with inflection points; parallel-transport frames or a fixed up vector avoid that. For curve construction see the spline editor, for interpolation theory see Bézier interpolants, and for sweeping profiles along curves see lathe and sweep.