Materials

PBR materials with base color, metallic, roughness, normal maps, and gemstone / glass light transmission. Surface fields are top-level properties of a material (a nested pbr object is stored but not rendered).

List Materials

const materials = await client.getMaterials();
materials.forEach(m => console.log(m.name, m.baseColor, m.transmission ?? 0));

Create Material

const material = await client.createMaterial({
  name: 'Brushed Metal',
  category: 'metals',
  baseColor: '#808080',
  metallic: 0.9,
  roughness: 0.3
});

Create a Gemstone

// Light passes through: ray traced in the viewer where supported.
// The transparent fallback look is what AR and older viewers show.
const diamond = await client.createMaterial({
  name: 'Diamond',
  gemPreset: 'Diamond',
  transmission: 1,
  transmissionMode: 'gemstone',
  ior: 2.417,
  dispersion: 0.36,
  envMapIntensity: 1.4,
  baseColor: '#ffffff',
  transparencyMode: 'Transparent',
  opacity: 35
});

// Remove a gemstone field with null; transmission: 0 turns it off.
await client.updateMaterial(diamond.id, { dispersion: null });

Update Material

await client.updateMaterial('mat_123', {
  roughness: 0.5,
  metallic: 0.8
});

Delete Material

await client.deleteMaterial('mat_123');

Continue reading