threejs-worldgen
    Preparing search index...

    Class Lakes

    Draws the lakes (and optionally rivers) of a bounded-map hydrology result: each lake is a flat water surface at its spill level using the ocean's wave shading, extended under its shore; rivers are ribbons along their polylines with flow-mapped water moving downstream. Carve the rivers into the world first (riverModifiers), or their surfaces sit on the unchanged ground.

    const hydrology = computeHydrology(world.height, { x: -2000, z: -2000, width: 4000, depth: 4000, cellSize: 8 }, { seaLevel: 0 })
    for (const m of riverModifiers(hydrology, world.frame)) world.addModifier(m)
    const lakes = await Lakes.create({ hydrology, frame: world.frame, scene, camera })
    Index
    camera: Camera | null

    Camera for the detail fade, if any.

    frame: LocalFrame | null

    Frame the hydrology lives in, or null for world coordinates on a flat world.

    hydrology: HydrologyResult

    The hydrology being drawn. Swap it with Lakes.setHydrology.

    object: Group<Object3DEventMap> = ...

    Root object: lake and river meshes in the hydrology's frame.

    riverUniforms: {
        crest: UniformNode<"float", number>;
        deepColor: UniformNode<"color", Color>;
        detail: UniformNode<"float", number>;
        detailDirection: UniformNode<"vec2", Vector2>;
        detailScale: UniformNode<"float", number>;
        detailSpeed: UniformNode<"float", number>;
        environmentIntensity: UniformNode<"float", number>;
        flowPeriod: UniformNode<"float", number>;
        foam: UniformNode<"float", number>;
        foamColor: UniformNode<"color", Color>;
        foamWidth: UniformNode<"float", number>;
        gridAngle: UniformNode<"float", number>;
        gridMinSpacing: UniformNode<"float", number>;
        gridScale: UniformNode<"float", number>;
        horizonColor: UniformNode<"color", Color>;
        maxArc: UniformNode<"float", number>;
        radius: UniformNode<"float", number>;
        rapids: UniformNode<"float", number>;
        reflectivity: UniformNode<"float", number>;
        refraction: UniformNode<"float", number>;
        roughness: UniformNode<"float", number>;
        shallowColor: UniformNode<"color", Color>;
        skyColor: UniformNode<"color", Color>;
        specular: UniformNode<"float", number>;
        sunColor: UniformNode<"color", Color>;
        sunDirection: UniformNode<"vec3", Vector3>;
        tanHalfFov: UniformNode<"float", number>;
        time: UniformNode<"float", number>;
        visibility: UniformNode<"float", number>;
        waveA: UniformArrayNode<string>;
        waveB: UniformArrayNode<string>;
        waveCount: UniformNode<"int", number>;
        whitecaps: UniformNode<"float", number>;
    } = ...

    Uniforms of the river (flow) material.

    Type Declaration

    • crest: UniformNode<"float", number>

      Σ k·chop of the waves (normalises whitecaps).

    • deepColor: UniformNode<"color", Color>

      deepColor.

    • detail: UniformNode<"float", number>

      detail.

    • detailDirection: UniformNode<"vec2", Vector2>

      Unit drift direction of the ripples (x, z).

    • detailScale: UniformNode<"float", number>

      detailScale, metres.

    • detailSpeed: UniformNode<"float", number>

      detailSpeed, m/s.

    • environmentIntensity: UniformNode<"float", number>

      environmentIntensity.

    • flowPeriod: UniformNode<"float", number>

      Seconds per flow-map cycle (rivers).

    • foam: UniformNode<"float", number>

      foam, 0 … 1.

    • foamColor: UniformNode<"color", Color>

      foamColor.

    • foamWidth: UniformNode<"float", number>

      foamWidth, metres.

    • gridAngle: UniformNode<"float", number>

      Vertex spacing per metre of distance (2π / segments for the ocean rings; 0 = uniform grid).

    • gridMinSpacing: UniformNode<"float", number>

      Smallest vertex spacing, metres. Waves shorter than ~3 spacings fade out in the vertex stage.

    • gridScale: UniformNode<"float", number>

      Multiplier from geometry x/z to tangent-plane metres (the ocean's ring scale).

    • horizonColor: UniformNode<"color", Color>

      horizonColor.

    • maxArc: UniformNode<"float", number>

      Surface distance beyond which vertices are clamped (the horizon on planets).

    • radius: UniformNode<"float", number>

      Sphere radius the surface bends to (sea radius on planets; huge = flat).

    • rapids: UniformNode<"float", number>

      Flow speed (m/s) where river rapids start foaming.

    • reflectivity: UniformNode<"float", number>

      reflectivity (F0).

    • refraction: UniformNode<"float", number>

      refraction.

    • roughness: UniformNode<"float", number>

      roughness.

    • shallowColor: UniformNode<"color", Color>

      shallowColor.

    • skyColor: UniformNode<"color", Color>

      skyColor.

    • specular: UniformNode<"float", number>

      specular.

    • sunColor: UniformNode<"color", Color>

      Sun colour × intensity.

    • sunDirection: UniformNode<"vec3", Vector3>

      Direction towards the sun, world space.

    • tanHalfFov: UniformNode<"float", number>

      tan(fov / 2) of the camera, for the per-pixel detail fade.

    • time: UniformNode<"float", number>

      Seconds, advanced by the owner's update().

    • visibility: UniformNode<"float", number>

      visibility, metres.

    • waveA: UniformArrayNode<string>

      Per wave: direction x, direction z, wavenumber k, amplitude.

    • waveB: UniformArrayNode<string>

      Per wave: horizontal amplitude (chop), phase (radians, includes −ωt), unused, unused.

    • waveCount: UniformNode<"int", number>

      Active entries in waveA/waveB.

    • whitecaps: UniformNode<"float", number>

      Whitecap amount 0 … 1 (oceans and lakes).

    settings: LakesSettings

    Resolved settings.

    time: number = 0

    Seconds of wave and flow time.

    uniforms: {
        crest: UniformNode<"float", number>;
        deepColor: UniformNode<"color", Color>;
        detail: UniformNode<"float", number>;
        detailDirection: UniformNode<"vec2", Vector2>;
        detailScale: UniformNode<"float", number>;
        detailSpeed: UniformNode<"float", number>;
        environmentIntensity: UniformNode<"float", number>;
        flowPeriod: UniformNode<"float", number>;
        foam: UniformNode<"float", number>;
        foamColor: UniformNode<"color", Color>;
        foamWidth: UniformNode<"float", number>;
        gridAngle: UniformNode<"float", number>;
        gridMinSpacing: UniformNode<"float", number>;
        gridScale: UniformNode<"float", number>;
        horizonColor: UniformNode<"color", Color>;
        maxArc: UniformNode<"float", number>;
        radius: UniformNode<"float", number>;
        rapids: UniformNode<"float", number>;
        reflectivity: UniformNode<"float", number>;
        refraction: UniformNode<"float", number>;
        roughness: UniformNode<"float", number>;
        shallowColor: UniformNode<"color", Color>;
        skyColor: UniformNode<"color", Color>;
        specular: UniformNode<"float", number>;
        sunColor: UniformNode<"color", Color>;
        sunDirection: UniformNode<"vec3", Vector3>;
        tanHalfFov: UniformNode<"float", number>;
        time: UniformNode<"float", number>;
        visibility: UniformNode<"float", number>;
        waveA: UniformArrayNode<string>;
        waveB: UniformArrayNode<string>;
        waveCount: UniformNode<"int", number>;
        whitecaps: UniformNode<"float", number>;
    } = ...

    Uniforms of the lake (wave) material.

    Type Declaration

    • crest: UniformNode<"float", number>

      Σ k·chop of the waves (normalises whitecaps).

    • deepColor: UniformNode<"color", Color>

      deepColor.

    • detail: UniformNode<"float", number>

      detail.

    • detailDirection: UniformNode<"vec2", Vector2>

      Unit drift direction of the ripples (x, z).

    • detailScale: UniformNode<"float", number>

      detailScale, metres.

    • detailSpeed: UniformNode<"float", number>

      detailSpeed, m/s.

    • environmentIntensity: UniformNode<"float", number>

      environmentIntensity.

    • flowPeriod: UniformNode<"float", number>

      Seconds per flow-map cycle (rivers).

    • foam: UniformNode<"float", number>

      foam, 0 … 1.

    • foamColor: UniformNode<"color", Color>

      foamColor.

    • foamWidth: UniformNode<"float", number>

      foamWidth, metres.

    • gridAngle: UniformNode<"float", number>

      Vertex spacing per metre of distance (2π / segments for the ocean rings; 0 = uniform grid).

    • gridMinSpacing: UniformNode<"float", number>

      Smallest vertex spacing, metres. Waves shorter than ~3 spacings fade out in the vertex stage.

    • gridScale: UniformNode<"float", number>

      Multiplier from geometry x/z to tangent-plane metres (the ocean's ring scale).

    • horizonColor: UniformNode<"color", Color>

      horizonColor.

    • maxArc: UniformNode<"float", number>

      Surface distance beyond which vertices are clamped (the horizon on planets).

    • radius: UniformNode<"float", number>

      Sphere radius the surface bends to (sea radius on planets; huge = flat).

    • rapids: UniformNode<"float", number>

      Flow speed (m/s) where river rapids start foaming.

    • reflectivity: UniformNode<"float", number>

      reflectivity (F0).

    • refraction: UniformNode<"float", number>

      refraction.

    • roughness: UniformNode<"float", number>

      roughness.

    • shallowColor: UniformNode<"color", Color>

      shallowColor.

    • skyColor: UniformNode<"color", Color>

      skyColor.

    • specular: UniformNode<"float", number>

      specular.

    • sunColor: UniformNode<"color", Color>

      Sun colour × intensity.

    • sunDirection: UniformNode<"vec3", Vector3>

      Direction towards the sun, world space.

    • tanHalfFov: UniformNode<"float", number>

      tan(fov / 2) of the camera, for the per-pixel detail fade.

    • time: UniformNode<"float", number>

      Seconds, advanced by the owner's update().

    • visibility: UniformNode<"float", number>

      visibility, metres.

    • waveA: UniformArrayNode<string>

      Per wave: direction x, direction z, wavenumber k, amplitude.

    • waveB: UniformArrayNode<string>

      Per wave: horizontal amplitude (chop), phase (radians, includes −ωt), unused, unused.

    • waveCount: UniformNode<"int", number>

      Active entries in waveA/waveB.

    • whitecaps: UniformNode<"float", number>

      Whitecap amount 0 … 1 (oceans and lakes).

    • Removes the meshes from the scene and frees their GPU resources.

      Returns void

    • Moves the floating origin. Same as set({ origin }).

      Parameters

      • origin: readonly number[]

      Returns this

    • Advances waves and flow, places the meshes and reads the sun. Called automatically with a scene (and by <Lakes>).

      Parameters

      • delta: number = ...

      Returns void