setValueV3f method

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

Implementation

void setValueV3f(gl, v, [WebGLTextures? textures]) {
  var 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) {
    var cacheR;
    var cacheG;
    var cacheB;

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

    if (cacheR != v.r || cacheG != v.g || cacheB != v.b) {
      gl.uniform3f(addr, v.r, v.g, v.b);

      cache[0] = v.r;
      cache[1] = v.g;
      cache[2] = v.b;
    }
  } else {
    if (arraysEqual(cache, v)) return;
    gl.uniform3fv(addr, Float32Array.from(v));

    copyArray(cache, v);
  }
}