GLTFMaterialsIorExtension constructor

GLTFMaterialsIorExtension(
  1. dynamic parser
)

Implementation

GLTFMaterialsIorExtension(parser) {
  this.parser = parser;
  this.name = EXTENSIONS["KHR_MATERIALS_IOR"]!;

  this.getMaterialType = (materialIndex) {
    var parser = this.parser;
    var materialDef = parser.json["materials"][materialIndex];

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

    return MeshPhysicalMaterial;
  };

  this.extendMaterialParams = (materialIndex, materialParams) {
    var parser = this.parser;
    var materialDef = parser.json["materials"][materialIndex];

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

    var extension = materialDef["extensions"][this.name];

    materialParams.ior = extension.ior != null ? extension.ior : 1.5;

    return null;
  };
}