Catalog of model!procgen.paintMaterials | paintMaterials painters plus a method to swap a SceneMesh's material to one of them at runtime.

Per-(SceneModel, painter) materials are created on first use and cached, so applying the same painter to many meshes — or to many objects — produces a single shared SceneMaterial backing all of them rather than a fresh material per mesh.

The mesh-replacement path mirrors the supported mutation pattern the SDK documents: snapshot the mesh's params (id, geometryId, matrix, opacity, parentTransform), detach it from its SceneObject, destroy it, then create a new SceneMesh with the same id but bound to the palette's SceneMaterial and re-attach to the same SceneObject. The object keeps its identity; only the mesh-material binding changes.

Constructors

  • Creates a MaterialsPalette.

    Parameters

    • params: { catalog?: PainterCatalogEntry[]; textureSize?: number; uvScale?: number } = {}
      • Optionalcatalog?: PainterCatalogEntry[]

        Override the default catalog. When omitted, the palette ships with every applicable model!procgen.paintMaterials | paintMaterials painter pre-registered.

      • OptionaltextureSize?: number

        Painter texture size in pixels. Default 256.

      • OptionaluvScale?: number

        Metres of geometry per texture repeat, forwarded to each created SceneMaterial as triplanarScale. Default 1.0.

    Returns MaterialsPalette

Properties

Painter catalog. Each entry carries an id, a human-readable label, a category, the painter callable, and any non-texture material parameters (opacity / colour tint / alpha mode).

textureSize: number

Painter texture size in pixels (square). Default 256. Larger values produce sharper close-up texturing at the cost of a one-off paint cost on first use.

uvScale: number

Approximate metres of geometry per texture repeat. Forwarded to each created SceneMaterial as triplanarScale, which the renderer's triplanar texture-sampling fallback consults when painting UV-less geometry (typical of BIM, sweeps and lofted curves). Smaller values tile the painted texture more times across each surface. Default 1.0.

Methods

  • Replaces sceneMesh on its parent SceneObject with a fresh SceneMesh whose materialId references the palette's SceneMaterial for painterId. The new mesh keeps the same id, geometry, local matrix, opacity, and parent transform — only the material binding changes.

    Mesh replacement uses the supported detach + destroy + recreate

    • reattach pattern: see the comment on applyIFCMaterials for the rationale (renderer batches are sized per-material, so swapping a mesh's material requires a mesh-create / mesh-destroy round-trip rather than a live field-set).

    Parameters

    • sceneMesh: SceneMesh

      The SceneMesh to repaint. Must be attached to a SceneObject in a SceneModel.

    • painterId: string

      Catalog entry id (e.g. "brick", "polSteel").

    Returns SDKResult<SceneMesh>

    SDKResult — ok: true with the new SceneMesh on success; ok: false when the mesh is detached / destroyed / the painter is unknown / texture or material creation fails.