threejs-worldgen
    Preparing search index...

    Class MPMReference

    The MLS-MPM substep in plain TypeScript, for tiny particle sets: the same weights, fixed-point P2G, grid update, terrain boundary and G2P as the GPU solver, in float64. Used by the tests to check the GPU (within float tolerance) and the physics (momentum, resting on terrain).

    Index
    • A reference solver with capacity particle slots; height is the terrain (none by default).

      Parameters

      • input: {
            capacity?: number;
            cellSize?: number;
            cfl?: number;
            friction?: number;
            gravity?: [number, number, number];
            materials?: {
                [key: string]: { [key: string]: number | undefined } | undefined;
            };
            maxSpeed?: number;
            maxSubsteps?: number;
            origin?: [number, number, number];
            render?: {
                colors?: string[];
                opacity?: number;
                size?: number;
                strainScale?: number;
            };
            resolution?: [number, number, number];
            seed?: string | number;
            substeps?: number;
            walls?: boolean;
        } = {}
        • Optionalcapacity?: number

          Most particles. Fixed at construction.

        • OptionalcellSize?: number

          Grid spacing Δx, metres. Particles are emitted 2 per cell per axis (8 per cell). Fixed at construction.

        • Optionalcfl?: number

          Courant number C of the stable step dt ≤ C·Δx / (maxSpeed + sound speed) (see mpmStableStep).

        • Optionalfriction?: number

          Terrain friction coefficient (Coulomb): 0 slips, large values stick.

        • Optionalgravity?: [number, number, number]

          Gravity, m/s².

        • Optionalmaterials?: { [key: string]: { [key: string]: number | undefined } | undefined }

          Materials compiled in (keys, fixed at construction) and their parameters (live).

        • OptionalmaxSpeed?: number

          Particle speed limit, m/s: the "max particle speed" of the stable step, enforced in G2P.

        • OptionalmaxSubsteps?: number

          Most substeps per frame; past it the simulation runs slower than real time instead of going unstable.

        • Optionalorigin?: [number, number, number]

          World position of the domain's minimum corner, metres. Moving it shifts the domain by whole cells (the particles keep their world positions; those left outside freeze). Floating-origin safe: the GPU only sees positions relative to it.

        • Optionalrender?: { colors?: string[]; opacity?: number; size?: number; strainScale?: number }

          Drawing through the particle pool's unlit shading.

          • Optionalcolors?: string[]

            Colour ramp by volume change J: first key squashed, middle at rest, last stretched (1 to 8 #rrggbb).

          • Optionalopacity?: number

            Opacity.

          • Optionalsize?: number

            Sprite width, in particle spacings (Δx / 2).

          • OptionalstrainScale?: number

            How much volume change spans the colour ramp: key = 0.5 + (J − 1) × strainScale.

        • Optionalresolution?: [number, number, number]

          Grid nodes along x, y, z (8…160 each). Fixed at construction.

        • Optionalseed?: string | number

          Seed for the emission jitter.

        • Optionalsubsteps?: number

          Substeps per frame at least. More are added when the frame is longer than the stable step allows.

        • Optionalwalls?: boolean

          Domain sides act as slip walls (else particles that leave the domain freeze).

      • height: MPMHeightFn | null = null

      Returns MPMReference

    colliders: MPMCollider[] = []

    Kinematic colliders, world metres (as MPMSolver.setColliders).

    Particles.

    frictionMap: Float32Array

    Friction multiplier per node column (see MPMReference.setFriction).

    grid: Float64Array

    Last grid: x, y, z velocity and mass per node.

    heights: Float32Array

    Baked node-column heights (local).

    materials: string[]

    Material names by index.

    options: MPMOptions

    Resolved settings.

    time: number = 0

    Simulated seconds.