threejs-worldgen
    Preparing search index...

    Function applyMaterialStates

    • Applies the four material states to a surface. This is the contract every package plugs into: give it what your material would output without weather plus the state nodes, and use what it returns. Order: damage → burn → wetness → snow (snow covers everything, wet char looks wet).

      Parameters

      Returns StateResult

      const out = applyMaterialStates(
      { color: barkColor, roughness: 0.9, normal: normalView },
      { wetness: field.wetness, snow: field.snow, burn: instance.burn, heat: fire.heat },
      { foliage: true },
      )
      material.colorNode = out.color; material.roughnessNode = out.roughness
      material.normalNode = out.normal; material.emissiveNode = out.emissive; material.opacityNode = out.opacity