Skip to content

Spline Mesh Demo

App: apps/spline_mesh_demo/

Demonstrates spline mesh extrusion (engine PLM-245 / ADR 0084), part of Block SPL (splines / geometry / scatter): MeshGen.ribbon sweeps a flat ribbon along a Spline and conforms it onto a heightfield terrain — each ribbon station snaps onto the ground so the “river” hugs the hills — while MeshGen.tube sweeps a capped tube along a second spline to arch a pipe over the valley.

Terminal window
% ./plume3d spline_mesh_demo

A raised three-quarter camera looks over the valley. The demo captures a screenshot at frame 60 and exits at frame 80.

  • Builds a heightfield terrain twice — once as a visual MeshGen.heightmap mesh, and once as a matching Physics.addStaticHeightfield collider from the same heights, so the surface the ribbon conforms to lines up with the surface you see. (The collider extends +X/+Z, so its node sits at the -half corner to align with the centered visual mesh.)

    _terrain = MeshGen.heightmap(_heights, _n, _n, _cell, _cell, 1.0)
    var tnode = _scene.addNode("terrain")
    tnode.setPosition(-_half, 0, -_half)
    Physics.addStaticHeightfield(_scene, tnode, _heights, _n, _cell) // same heights → aligned
  • Builds an S-curve river spline from five control points and sweeps a ribbon along it, passing the scene so each station conforms to the terrain:

    var path = Spline.new()
    path.addPoint(-15, 0, -12)
    path.addPoint(-6, 0, -3)
    // … more points …
    _river = MeshGen.ribbon(path, 2.4, 64, _scene) // conformScene = _scene → snap to the ground
    _river.setColor(0.24, 0.44, 0.78, 1.0)

    Passing null instead of _scene would leave the ribbon flat at the spline’s own height.

  • Sweeps a decorative tube along a second spline whose middle control points rise, so the pipe arches over the scene (no conform — it keeps the spline’s own heights):

    var arch = Spline.new()
    arch.addPoint(-10, 0.2, 6)
    arch.addPoint(-4, 4.0, 6)
    arch.addPoint(4, 4.0, 6)
    arch.addPoint(10, 0.2, 6)
    _pipe = MeshGen.tube(arch, 0.35, 12, 48)
  • Draws the terrain, river, and pipe immediate-mode with a lit shader.

  • MeshGen — ribbon (flat swept ribbon, terrain-conformed via the scene) and tube (capped closed tube), plus heightmap for the terrain.
  • Spline — Spline.new / addPoint; the curve both sweeps follow.
  • Physics — addStaticHeightfield (the collider the ribbon conforms onto) and the surface queries ribbon’s conform uses under the hood.
  • Conform is invisible without a collider. ribbon(spline, width, samples, scene) snaps each station via a physics ray-down, which only hits registered colliders. The visual MeshGen.heightmap alone would not conform anything — the matching addStaticHeightfield is what the ray sees. Build both from the same heights and they align.
  • The ribbon’s surface normal is the spline frame’s normal (exact), and the tube’s cross-section is seam-welded, so both shade correctly under a lit shader. Both follow the standard centered / Y-up / CCW-outward MeshGen conventions.

See MeshGen — Spline extrusion for the full ribbon / tube surface and the Spline primitive that drives them.