threejs-worldgen
    Preparing search index...

    Class World

    A procedural world: climate, height, rivers, volcanoes, 20 blended biomes and their ground, as deterministic functions of seed and position. Works as an infinite flat world or as a planet, and is cheap enough to query per vertex, per blade of grass or per tree.

    Positions on the base surface are 3D metres: (x, ·, z) on a flat world (y is ignored), or any point on a planet (it is projected onto the sphere). Use World.height for a classic (x, z) => y height function — on a planet it works in a local flat frame around origin.

    const world = new World({ seed: 'archipelago', continents: { landBias: -0.1 } })
    world.height(120, -40) // metres
    world.biomeAt(120, -40).name // 'Temperate grassland'
    world.set({ mountains: { height: 1600 } }) // live update; listeners rebuild
    Index
    frame: LocalFrame

    Local flat frame used by World.height on planets (identity on flat worlds).

    options: WorldOptions

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

    version: number = 0

    Bumped on every change; caches compare it.

    • A local flat frame centred at a planet position given in degrees (or the world itself on a flat world). Packages that think in (x, z) => y — grass, scatter, water, cities — work in frames.

      Parameters

      • latitude: number
      • longitude: number

      Returns LocalFrame

    • Ground material weights (in GROUND_MATERIALS order, summing to 1) and the blended ground colour (sRGB) for a sample. slope is rise/run (0 = flat); pass it from your mesh normals.

      Parameters

      • sample: WorldSample
      • slope: number
      • weightsOut: Float32Array = ...
      • colorOut: Float32Array = ...
      • overrides: boolean = true

        Apply the slope/cold/waterline/river overrides (rock, snow, sand, mud). The terrain shader applies those per pixel itself, so chunks pass false and get the biome soil colour only.

      Returns { color: Float32Array; weights: Float32Array }

    • Height function (x, z) => y: the flat world itself, or a local flat frame around origin on a planet.

      Parameters

      • x: number
      • z: number

      Returns number

    • Calls listener after every change. region is set when only that box (base-surface coordinates) changed — e.g. a modifier was added — so caches can rebuild just what it touches. Returns an unsubscribe function.

      Parameters

      Returns () => void

    • Samples everything at a base-surface position (see the class docs for what that means).

      Parameters

      • px: number
      • py: number
      • pz: number
      • out: WorldSample = ...
      • minWavelength: number = 0

        Skip noise detail smaller than this many metres (pass a LOD's vertex spacing ×2).

      Returns WorldSample