refreshUniformsSprites method

void refreshUniformsSprites(
  1. Map<String, dynamic> uniforms,
  2. Material material
)

Implementation

void refreshUniformsSprites(Map<String, dynamic> uniforms, Material material) {
  uniforms["diffuse"]["value"].setFrom(material.color);
  uniforms["opacity"]["value"] = material.opacity;
  uniforms["rotation"]["value"] = material.rotation;

  if (material.map != null) {
    uniforms["map"]["value"] = material.map;
  }

  if (material.alphaMap != null) {
    uniforms["alphaMap"]["value"] = material.alphaMap;
  }

  if (material.alphaTest > 0) {
    uniforms["alphaTest"]["value"] = material.alphaTest;
  }

  // uv repeat and offset setting priorities
  // 1. color map
  // 2. alpha map

  late final Texture? uvScaleMap;

  if (material.map != null) {
    uvScaleMap = material.map;
  } else if (material.alphaMap != null) {
    uvScaleMap = material.alphaMap;
  }

  if (uvScaleMap != null) {
    if (uvScaleMap.matrixAutoUpdate == true) {
      uvScaleMap.updateMatrix();
    }

    uniforms["uvTransform"]["value"].setFrom(uvScaleMap.matrix);
  }
}