threejs-worldgen
    Preparing search index...

    Class City

    A procedural settlement on a threejs-biomes World: roads grown along a tensor field, blocks, lots and buildings in a few BatchedMesh draw calls with procedural facades, terrain flattened under roads and buildings. Everything derives from the options and the world.

    const world = new World({ seed: 7 })
    const city = await City.create({ world, camera, scene, size: 'town', center: [400, -200] })
    city.set({ facade: { night: 1 } }) // lights on
    Index
    camera: Camera | null

    Camera used for LOD; can be swapped any time.

    frame: LocalFrame

    The frame the city is laid out in.

    local: Group<Object3DEventMap> = ...

    Child of object in frame-local coordinates: add props here at positions from City.data.

    object: Group<Object3DEventMap> = ...

    Root object: positioned at the centre on the world surface, y along the local up.

    options: CityOptions

    Resolved settings. Change them with City.set / City.reset.

    plan: CityPlan | null = null

    The generated plan (roads, lots, buildings), or null while generating.

    stats: CityStats = ...

    Live counters.

    uniforms: {
        centerLine: UniformNode<"color", Color>;
        concrete: UniformNode<"color", Color>;
        frame: UniformNode<"color", Color>;
        glass: UniformNode<"color", Color>;
        kerb: UniformNode<"color", Color>;
        lightIntensity: UniformNode<"float", number>;
        marking: UniformNode<"color", Color>;
        markings: UniformNode<"float", number>;
        night: UniformNode<"float", number>;
        patternScale: UniformNode<"float", number>;
        roadColors: UniformArrayNode<string>;
        roadWeather: UniformNode<"vec4", Vector4>;
        roofWeather: UniformNode<"vec4", Vector4>;
        sidewalk: UniformNode<"color", Color>;
        wallWeather: UniformNode<"vec4", Vector4>;
        wear: UniformNode<"float", number>;
        windowA: UniformArrayNode<string>;
        windowB: UniformArrayNode<string>;
        windowLight: UniformNode<"color", Color>;
    } = ...

    Shader uniforms (night, window grids, weather, road look).

    Type Declaration

    • centerLine: UniformNode<"color", Color>

      Arterial centre line colour.

    • concrete: UniformNode<"color", Color>

      Bridge concrete colour.

    • frame: UniformNode<"color", Color>

      Window frame colour.

    • glass: UniformNode<"color", Color>

      Window glass colour.

    • kerb: UniformNode<"color", Color>

      Kerb colour.

    • lightIntensity: UniformNode<"float", number>

      Lit window brightness.

    • marking: UniformNode<"color", Color>

      Lane marking colour.

    • markings: UniformNode<"float", number>

      1 = paint markings, 0 = none.

    • night: UniformNode<"float", number>

      0 = day, 1 = night: lit windows glow.

    • patternScale: UniformNode<"float", number>

      Pattern size multiplier (bricks, planks, tiles).

    • roadColors: UniformArrayNode<string>

      Road base colour per surface (asphalt, cobblestone, gravel, dirt).

    • roadWeather: UniformNode<"vec4", Vector4>

      Road weather: wetness, snow, burn, damage.

    • roofWeather: UniformNode<"vec4", Vector4>

      Roof weather: wetness, snow, burn, damage.

    • sidewalk: UniformNode<"color", Color>

      Sidewalk colour.

    • wallWeather: UniformNode<"vec4", Vector4>

      Wall weather: wetness, snow, burn, damage.

    • wear: UniformNode<"float", number>

      Road wear 0..1.

    • windowA: UniformArrayNode<string>

      Per building style: bay width, window width, window height, sill.

    • windowB: UniformArrayNode<string>

      Per building style: frame width, lit share, floor height, unused.

    • windowLight: UniformNode<"color", Color>

      Lit window colour.

    world: World

    The world.

    • The building at frame-local (x, z), or null.

      Parameters

      • x: number
      • z: number

      Returns Building | null

    • Plain-data snapshot for props, vehicles and crowds (frame-local coordinates), or null while generating.

      Returns CityData | null

    • Removes the city, its terrain modifiers and its GPU resources.

      Returns void

    • Throws away the current settlement and generates it again (e.g. after editing the world by hand).

      Returns void

    • Changes settings, merging into the current input. Looks are instant; layout changes regenerate.

      Parameters

      Returns this

    • Overrides weather for one building (0..1 each; the larger of this and options.weather.walls/roofs applies).

      Parameters

      • id: number
      • weather: Partial<Weather>

      Returns void

    • Advances progressive generation (within budget ms) and updates level of detail. Called automatically when a scene was given (and by <City>); otherwise call it once per frame.

      Parameters

      • budget: number = ...

      Returns void