material_set

Defines or replaces the material named ref (glTF metallic-roughness, linear values): baseColor [r, g, b, a] in [0, 1], metallic and roughness in [0, 1], optional emissive [r, g, b] in [0, 10000] and opacity in [0, 1]. Optional textures { texture, texCoord?: 0 } by texture ref: baseColorTexture and emissiveTexture (sRGB, multiply their factor), metallicRoughnessTexture (G roughness, B metallic), normalTexture (+ scale in [-10, 10]) and occlusionTexture (+ strength in [0, 1]); a texture not defined yet samples as absent. Objects with this materialRef use it from the next frame. Returns { ref, changed }.

Command

Usage

TypeScript
surface.execute('material_set', { ref, baseColor, metallic, roughness, emissive?, opacity?, baseColorTexture?, metallicRoughnessTexture?, normalTexture?, occlusionTexture?, emissiveTexture? })

Parameters

  • refstring

    Required

  • baseColornumber[]

    Required

  • metallicnumber

    Required

  • roughnessnumber

    Required

  • emissivenumber[]

    Optional

  • opacitynumber

    Optional

  • baseColorTextureobject

    Optional

  • metallicRoughnessTextureobject

    Optional

  • normalTextureobject

    Optional

  • occlusionTextureobject

    Optional

  • emissiveTextureobject

    Optional

Returns

object with ref, changed, in the ok: true envelope.

JSON
{
  "type": "object",
  "properties": {
    "ref": {
      "type": "string"
    },
    "changed": {
      "type": "boolean"
    }
  },
  "required": [
    "ref",
    "changed"
  ]
}

See also