threejs-worldgen
    Preparing search index...

    Interface MPMMaterial<P>

    A constitutive model for MPMSolver: Kirchhoff stress (and optionally a plasticity return mapping) as TSL functions, the same in plain TypeScript for the CPU reference, and JSON parameters. Register it with registerMPMMaterial; a solver compiles in the materials named in its materials option.

    The solver owns the transfers: per substep it runs P2G (mass, momentum and -dt·V·(4/Δx²)·τ into the grid), the grid update and G2P (velocity, C, F ← (I + dt·C)·F, then MPMMaterial.plasticity).

    interface MPMMaterial<P extends Record<string, number> = Record<string, number>> {
        cpu: {
            plasticity?: (
                c: MPMMaterialCPUContext,
            ) => { F?: Mat3; Jp?: number; temperature?: number };
            stress: (c: MPMMaterialCPUContext) => Mat3;
        };
        defaults: P & { density: number };
        name: string;
        plasticity?: (
            c: MPMMaterialContext,
        ) => { F?: any; Jp?: any; temperature?: any };
        soundSpeed: (p: P) => number;
        stress: (c: MPMMaterialContext) => any;
        viscosity?: (p: P) => number;
    }

    Type Parameters

    • P extends Record<string, number> = Record<string, number>
    Index
    cpu: {
        plasticity?: (
            c: MPMMaterialCPUContext,
        ) => { F?: Mat3; Jp?: number; temperature?: number };
        stress: (c: MPMMaterialCPUContext) => Mat3;
    }

    CPU versions of the hooks above (same maths, plain numbers).

    defaults: P & { density: number }

    Default parameters (plain JSON numbers). density (kg/m³) is required: it sets the particle mass.

    name: string

    Registry key.

    plasticity?: (c: MPMMaterialContext) => { F?: any; Jp?: any; temperature?: any }

    Optional per-particle hook after F is advanced in G2P: plasticity (project F, update Jp), and anything else a material tracks per particle, such as temperature (e.g. lava cooling). Returns TSL nodes; anything left out stays as it was.

    soundSpeed: (p: P) => number

    Fastest elastic wave speed for these parameters, m/s (the time step keeps dt ≤ cfl·Δx / (maxSpeed + c)).

    stress: (c: MPMMaterialContext) => any

    Kirchhoff stress τ = P(F)·Fᵀ, pascals (a TSL mat3 node). Runs in P2G.

    viscosity?: (p: P) => number

    Optional kinematic viscosity ν, m²/s (the time step also keeps dt ≤ Δx² / (6ν)).