threejs-worldgen
    Preparing search index...

    Class MeshBuilder

    Builds flat-shaded low-poly meshes into typed arrays.

    Index
    • An axis-aligned box centred at c with full size. taper scales the top face's x and z half sizes; shift moves the top face along z (raked windscreens, sloped bows).

      Parameters

      • c: Vec3
      • size: Vec3
      • s: Paint
      • taper: [x: number, z: number] = ...
      • shift: number = 0

      Returns this

    • A cylinder (or cone/frustum with radius2) along an axis, centred at c.

      Parameters

      • axis: Axis
      • c: Vec3
      • radius: number
      • length: number
      • s: Paint
      • segments: number = 10
      • radius2: number = radius
      • caps: Paint | null = s

      Returns this

    • A low-poly ellipsoid (top = upper half only: canopies, domes).

      Parameters

      • c: Vec3
      • radii: Vec3
      • s: Paint
      • segU: number = 10
      • segV: number = 6
      • top: boolean = false

      Returns this

    • Adds a planar convex polygon (fan-triangulated, flat normal). With inside, the face is turned to point away from that point.

      Parameters

      Returns this

    • A flat convex outline ([u, v] points) in the plane through origin spanned by u and v, extruded by thickness (wings, tail fins, rudders, blades).

      Parameters

      Returns this

    • Runs fn with everything it adds rotated (Euler YXZ, radians) and then offset.

      Parameters

      • offset: Vec3
      • rotation: Vec3
      • fn: () => void

      Returns this

    • A smooth solid of revolution about an axis through c: profile is a list of (radius, offset along the axis) points (tyres, hubs, headlight buckets, tanks). paintOf(k) colours the band between profile points k and k+1.

      Parameters

      • axis: Axis
      • c: Vec3
      • profile: [radius: number, offset: number][]
      • paintOf: Paint | ((k: number) => Paint)
      • segments: number = 24

      Returns this

    • A hull lofted through cross-sections along z (fuselages, boat hulls, train cars). Faces whose centre lies below split.y use split.paint (antifouling under the waterline, a belly colour).

      Parameters

      • sections: Section[]
      • s: Paint
      • segments: number = 12
      • Optionalsplit: { paint: Paint; y: number }

      Returns this

    • A smooth rounded box (superellipsoid) centred at c with full size: exponent e 2 = ellipsoid, higher = boxier with rounded edges (seats, mirrors, lamps, bumpers, cabs).

      Parameters

      • c: Vec3
      • size: Vec3
      • s: Paint
      • e: number = 4
      • segU: number = 16
      • segV: number = 8

      Returns this

    • A smooth-shaded surface through a grid of points: rows[i][j], rows along the length, points around (closed: each row is a ring). Normals are averaged over the grid, so curved bodywork shows no facets; paintOf(i, j) colours the cell between rows i, i+1 and points j, j+1 (colour edges stay crisp). Faces are turned outwards (away from each row's centre); caps closes the first and last ring with flat faces.

      Parameters

      • rows: Vec3[][]
      • paintOf: (i: number, j: number) => Paint
      • closed: boolean = true
      • caps: [Paint | null, Paint | null] = ...

      Returns this

    • A hollow tube (duct, ring) along an axis.

      Parameters

      • axis: Axis
      • c: Vec3
      • outer: number
      • inner: number
      • length: number
      • s: Paint
      • segments: number = 12

      Returns this