threejs-worldgen
    Preparing search index...

    Class SplashEmitter

    Rain on the ground near the camera as MPM splashes: each update a seeded number of drops (rain × splashes × area × dt, fractions carried over) hit the terrain within radius of center, and each spawns a few water particles in the solver: on a puddle a crown and a jet, on dry ground a low scatter. Those particles are tagged (SPLASH_TAG); the retire pass from SplashEmitter.prepare removes them when they land again (their water is already counted in the puddles). With a PuddleField, the rain also feeds it. Far from the camera, keep drawing rain as streaks; this is the near field.

    const puddles = new PuddleField({ resolution: [96, 96], cellSize: 0.05, origin: [-2.4, -2.4] }, height)
    const rain = new SplashEmitter(mpm, { rain: 12, radius: 2 }, { height, puddles })
    // each frame:
    rain.set({ center: [camera.position.x, camera.position.z] }).update(dt)
    renderer.compute([...mpm.prepare(dt), ...rain.prepare()])
    Index
    • An emitter into target (an MPMSolver, or an MPMReference for tests) over height.

      Parameters

      • target: SplashTarget
      • input: {
            center?: [number, number];
            material?: string;
            maxPerFrame?: number;
            particles?: [number, number];
            puddleDepth?: number;
            radius?: number;
            rain?: number;
            retireOutside?: boolean;
            seed?: string | number;
            soak?: number;
            speed?: number;
            splashes?: number;
        } = {}
        • Optionalcenter?: [number, number]

          Centre of the splash area, world x and z.

        • Optionalmaterial?: string

          Material of the splash particles (one of the solver's).

        • OptionalmaxPerFrame?: number

          Most splashes per update (the rest of that frame's are dropped).

        • Optionalparticles?: [number, number]

          Particles per splash: on dry ground (a low scatter of droplets) and on a puddle (a crown plus a central jet).

        • OptionalpuddleDepth?: number

          Puddle depth from which a drop splashes as onto water, metres.

        • Optionalradius?: number

          Splashes land within this radius of center, metres (e.g. the near field around the camera).

        • Optionalrain?: number

          Rain rate, mm/h (0: no rain; puddles drain and dry).

        • OptionalretireOutside?: boolean

          Also remove any particle that leaves the solver's domain (a stream running off its side), instead of freezing it.

        • Optionalseed?: string | number

          Seed of the impact positions and splash shapes.

        • Optionalsoak?: number

          Also remove stray water: a particle on its own (grid mass at its node below this many full cells of 1000 kg/m³) resting on the ground soaks in, instead of lying there as a 15 mL bead. 0: off.

        • Optionalspeed?: number

          Launch speed of the splash droplets, m/s (a crown on water; dry-ground droplets fly lower and wider).

        • Optionalsplashes?: number

          MPM splashes per m² per second per mm/h of rain: the few visible splashes among the real drop impacts (~70 per m²·s per mm/h).

      • __namedParameters: { height?: MPMHeightFn | null; puddles?: PuddleField | null } = {}

      Returns SplashEmitter

    impacts: SplashImpact[] = []

    The last update's impacts.

    options: SplashOptions

    Resolved settings.

    puddles: PuddleField | null

    The puddles the rain feeds (if any).

    spawned: number = 0

    Splashes spawned so far (the serial of the next one: seeds its random numbers).

    • The retire pass (GPU solvers only): removes splash particles that have landed (moving down within half a cell of the ground), stray water soaking in (soak) and, with retireOutside, any particle outside the domain. Batch it after the solver's passes: renderer.compute([...mpm.prepare(dt), ...rain.prepare()]).

      Returns ComputeNode[]

    • Merges input into the settings.

      Parameters

      • input: {
            center?: [number, number];
            material?: string;
            maxPerFrame?: number;
            particles?: [number, number];
            puddleDepth?: number;
            radius?: number;
            rain?: number;
            retireOutside?: boolean;
            seed?: string | number;
            soak?: number;
            speed?: number;
            splashes?: number;
        }
        • Optionalcenter?: [number, number]

          Centre of the splash area, world x and z.

        • Optionalmaterial?: string

          Material of the splash particles (one of the solver's).

        • OptionalmaxPerFrame?: number

          Most splashes per update (the rest of that frame's are dropped).

        • Optionalparticles?: [number, number]

          Particles per splash: on dry ground (a low scatter of droplets) and on a puddle (a crown plus a central jet).

        • OptionalpuddleDepth?: number

          Puddle depth from which a drop splashes as onto water, metres.

        • Optionalradius?: number

          Splashes land within this radius of center, metres (e.g. the near field around the camera).

        • Optionalrain?: number

          Rain rate, mm/h (0: no rain; puddles drain and dry).

        • OptionalretireOutside?: boolean

          Also remove any particle that leaves the solver's domain (a stream running off its side), instead of freezing it.

        • Optionalseed?: string | number

          Seed of the impact positions and splash shapes.

        • Optionalsoak?: number

          Also remove stray water: a particle on its own (grid mass at its node below this many full cells of 1000 kg/m³) resting on the ground soaks in, instead of lying there as a 15 mL bead. 0: off.

        • Optionalspeed?: number

          Launch speed of the splash droplets, m/s (a crown on water; dry-ground droplets fly lower and wider).

        • Optionalsplashes?: number

          MPM splashes per m² per second per mm/h of rain: the few visible splashes among the real drop impacts (~70 per m²·s per mm/h).

      Returns this

    • Spawns this frame's splashes into the target and advances the puddles. Returns how many splashes.

      Parameters

      • dt: number

      Returns number