threejs-worldgen
    Preparing search index...

    Class WorldTerrain

    Streaming level-of-detail terrain for a World: a grid of quadtrees on flat worlds, a cube-sphere of quadtrees on planets. Chunks split as the camera approaches (down to minChunkSize), build in Web Workers or within a main-thread budget, never leave holes while they swap, and rebuild only the region a world change touched. Geometry is stored relative to each chunk's centre and placed relative to a floating origin, so it stays precise from orbit to ant scale.

    const world = new World({ surface: 'sphere', radius: 60_000 })
    const terrain = await WorldTerrain.create({ world, camera, scene })
    terrain.set({ material: { debug: 'biomes' } })
    Index
    camera: Camera

    Camera that drives the level of detail.

    material: MeshStandardNodeMaterial

    The shared terrain material.

    object: Group<Object3DEventMap> = ...

    Root of all chunk meshes.

    Resolved settings.

    stats: TerrainStats = ...

    Live counters.

    uniforms: {
        brightness: UniformNode<"float", number>;
        bump: UniformNode<"float", number>;
        detail: UniformNode<"float", number>;
        detailDistance: UniformNode<"float", number>;
        detailScale: UniformNode<"float", number>;
        mudColor: UniformNode<"color", Color>;
        rockColor: UniformNode<"color", Color>;
        rockSlope: UniformNode<"float", number>;
        sandBand: UniformNode<"float", number>;
        sandColor: UniformNode<"color", Color>;
        saturation: UniformNode<"float", number>;
        snowColor: UniformNode<"color", Color>;
        snowTemperature: UniformNode<"float", number>;
    }

    Shader uniforms of the shared terrain material.

    Type Declaration

    • brightness: UniformNode<"float", number>

      Brightness multiplier.

    • bump: UniformNode<"float", number>

      Bump strength.

    • detail: UniformNode<"float", number>

      Detail strength.

    • detailDistance: UniformNode<"float", number>

      Detail fade distance, metres.

    • detailScale: UniformNode<"float", number>

      Detail noise scale.

    • mudColor: UniformNode<"color", Color>

      Mud colour (linear).

    • rockColor: UniformNode<"color", Color>

      Rock colour (linear).

    • rockSlope: UniformNode<"float", number>

      Slope (rise/run) where bare rock takes over (synced from the world's ground.rockSlope).

    • sandBand: UniformNode<"float", number>

      Height band around sea level that is sand, metres (synced from ground.sandBand).

    • sandColor: UniformNode<"color", Color>

      Sand colour (linear).

    • saturation: UniformNode<"float", number>

      Saturation multiplier.

    • snowColor: UniformNode<"color", Color>

      Snow colour (linear).

    • snowTemperature: UniformNode<"float", number>

      Temperature (°C) below which snow settles (synced from ground.snowTemperature).

    world: World

    The world being rendered.

    • Frees all GPU resources, stops workers and detaches from the scene and world.

      Returns void

    • Moves the floating origin (planet-centred position that maps to render-space zero).

      Parameters

      Returns this

    • Picks chunks for the camera, schedules builds and swaps meshes. Call once per frame (done for you when a scene was passed). budgetMs overrides buildBudget for main-thread builds.

      Parameters

      • budgetMs: number = ...

      Returns void