fromFlatbuffer static method

UnlitMaterial fromFlatbuffer(
  1. Material fbMaterial,
  2. List<Texture> textures
)
override

Implementation

static UnlitMaterial fromFlatbuffer(
    fb.Material fbMaterial, List<gpu.Texture> textures) {
  if (fbMaterial.type != fb.MaterialType.kUnlit) {
    throw Exception('Cannot unpack unlit material from non-unlit material');
  }

  UnlitMaterial material = UnlitMaterial();

  if (fbMaterial.baseColorFactor != null) {
    material.baseColorFactor = Vector4(
        fbMaterial.baseColorFactor!.r,
        fbMaterial.baseColorFactor!.g,
        fbMaterial.baseColorFactor!.b,
        fbMaterial.baseColorFactor!.a);
  }

  if (fbMaterial.baseColorTexture >= 0 &&
      fbMaterial.baseColorTexture < textures.length) {
    material.baseColorTexture = textures[fbMaterial.baseColorTexture];
  }

  return material;
}