GLTFMaterialsTransmissionExtension constructor

GLTFMaterialsTransmissionExtension(
  1. dynamic parser
)

Implementation

GLTFMaterialsTransmissionExtension(this.parser) {
  name = gltfExtensions["KHR_MATERIALS_TRANSMISSION"]!;

  getMaterialType = (materialIndex) {
    var parser = this.parser;
    Map<String, dynamic> materialDef = parser.json["materials"][materialIndex];

    if (materialDef["extensions"] == null || materialDef["extensions"][name] == null) return null;

    return MeshPhysicalMaterial;
  };

  extendMaterialParams = (materialIndex, materialParams) async {
    var parser = this.parser;
    Map<String, dynamic> materialDef = parser.json["materials"][materialIndex];

    if (materialDef["extensions"] == null || materialDef["extensions"][name] == null) {
      return null;
    }

    List<Future> pending = [];

    Map<String, dynamic> exten = materialDef["extensions"][name];

    if (exten["transmissionFactor"] != null) {
      materialParams.transmission = exten["transmissionFactor"];
    }

    if (exten["transmissionTexture"] != null) {
      pending.add(parser.assignTexture(materialParams, 'transmissionMap', exten["transmissionTexture"]));
    }

    return Future.wait(pending);
  };
}