setValueV3f method

void setValueV3f(
  1. RenderingContext gl,
  2. dynamic v, [
  3. WebGLTextures? textures
])

Implementation

void setValueV3f(RenderingContext gl, v, [WebGLTextures? textures]) {
  final cache = this.cache;

  if (v is Vector3) {
    if (cache[0] != v.x || cache[1] != v.y || cache[2] != v.z) {
      gl.uniform3f(addr, v.x, v.y, v.z);

      cache[0] = v.x;
      cache[1] = v.y;
      cache[2] = v.z;
    }
  } else if (v is Color) {
    double cacheR = 0;
    double cacheG = 0;
    double cacheB = 0;

    if (cache.length >= 3) {
      cacheR = cache[0];
      cacheG = cache[1];
      cacheB = cache[2];
    }

    if (cacheR != v.red || cacheG != v.green || cacheB != v.blue) {
      gl.uniform3f(addr, v.red, v.green, v.blue);

      cache[0] = v.red;
      cache[1] = v.green;
      cache[2] = v.blue;
    }
  } else {
    if (arraysEqual(cache, v)) return;
    gl.uniform3fv(addr, Float32List.fromList(v));

    copyArray(cache, v);
  }
}