hex-world
    Preparing search index...

    Function smoothPath

    • Converts a hex cell path into a dense array of world-space points following a smooth Catmull-Rom spline through the cell centres.

      Use this to draw a curved path preview line instead of straight segments between cell centres. The returned points include the Y elevation of each cell so the curve follows the terrain surface.

      Pass the result directly to a THREE.BufferGeometry position attribute to render a THREE.Line, or feed it into your own tube/ribbon builder.

      Parameters

      • path: HexCoord[]

        HexCoord[] path, e.g. from findPath().

      • layout: HexLayout

        The same HexLayout used for rendering.

      • map: { getElevation(col: number, row: number): number }

        Any object with a getElevation(col, row) method.

      • samplesPerSegment: number = 8

        Control-point samples between each pair of cells. Default 8.

      Returns { x: number; y: number; z: number }[]

      const pts = smoothPath(path, layout, map);
      const positions = new Float32Array(pts.length * 3);
      pts.forEach((p, i) => {
      positions[i * 3] = p.x;
      positions[i * 3 + 1] = p.y + 0.15; // float above terrain
      positions[i * 3 + 2] = p.z;
      });
      const geo = new THREE.BufferGeometry();
      geo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
      const line = new THREE.Line(geo, new THREE.LineBasicMaterial({ color: 0xffaa22 }));