threejs-worldgen
    Preparing search index...

    Class RoadNavigator

    Drives many vehicles over a road network: each one keeps to its lane, picks a seeded turn at every junction (never a U-turn unless it's a dead end) and rounds corners on a curve instead of snapping. State is in typed arrays, one slot per vehicle.

    Index
    cornerIn: Float32Array

    Corner radius at the start of the current edge (shared with the previous edge).

    cornerOut: Float32Array

    Corner radius at the end of the current edge.

    edge: Int32Array

    Current edge per vehicle (−1 = not placed).

    from: Int32Array

    Node the vehicle came from (start of its current edge in travel direction).

    height: ((x: number, z: number) => number) | null = null

    Ground height for nodes without y.

    leftHand: boolean = false

    Drive on the left instead of the right.

    maxCorner: number = 7

    Largest corner radius, metres.

    next: Int32Array

    Edge chosen for after the next junction.

    prevDir: Float32Array

    Direction (x, z) of the previous edge, for the corner just rounded.

    The network.

    seed: number

    Seed for turn choices.

    u: Float64Array

    Metres travelled along the current edge.

    visits: Uint32Array

    Junctions passed (seeds the next choice).

    • Moves vehicle i forward by ds metres, turning onto chosen edges at junctions.

      Parameters

      • i: number
      • ds: number

      Returns void

    • Length of edge e, metres.

      Parameters

      • e: number

      Returns number

    • Puts vehicle i at a seeded spot on the network. Returns false if the network has no usable edge.

      Parameters

      • i: number
      • salt: number = 0

      Returns boolean