createMaterial method

dynamic createMaterial(
  1. dynamic materialParams
)

Implementation

createMaterial(materialParams) {
  var material = new GLTFMeshStandardSGMaterial(materialParams);
  material.fog = true;

  material.color = materialParams.color;

  material.map = materialParams.map == null ? null : materialParams.map;

  material.lightMap = null;
  material.lightMapIntensity = 1.0;

  material.aoMap = materialParams.aoMap == null ? null : materialParams.aoMap;
  material.aoMapIntensity = 1.0;

  material.emissive = materialParams.emissive;
  material.emissiveIntensity = 1.0;
  material.emissiveMap =
      materialParams.emissiveMap == null ? null : materialParams.emissiveMap;

  material.bumpMap =
      materialParams.bumpMap == null ? null : materialParams.bumpMap;
  material.bumpScale = 1;

  material.normalMap =
      materialParams.normalMap == null ? null : materialParams.normalMap;
  material.normalMapType = TangentSpaceNormalMap;

  if (materialParams.normalScale)
    material.normalScale = materialParams.normalScale;

  material.displacementMap = null;
  material.displacementScale = 1;
  material.displacementBias = 0;

  material.specularMap =
      materialParams.specularMap == null ? null : materialParams.specularMap;
  material.specular = materialParams.specular;

  material.glossinessMap = materialParams.glossinessMap == null
      ? null
      : materialParams.glossinessMap;
  material.glossiness = materialParams.glossiness;

  material.alphaMap = null;

  material.envMap =
      materialParams.envMap == null ? null : materialParams.envMap;
  material.envMapIntensity = 1.0;

  return material;
}