setState method

dynamic setState(
  1. Material material,
  2. Camera camera,
  3. bool useCache
)

Implementation

setState(Material material, Camera camera, bool useCache) {
  var planes = material.clippingPlanes;
  var clipIntersection = material.clipIntersection;
  var clipShadows = material.clipShadows;

  var materialProperties = properties.get(material);

  if (!localClippingEnabled || planes == null || planes.isEmpty || renderingShadows && !clipShadows) {
    // there's no local clipping

    if (renderingShadows) {
      // there's no global clipping

      projectPlanes(null, null, null, null);
    } else {
      resetGlobalState();
    }
  } else {
    var nGlobal = renderingShadows ? 0 : numGlobalPlanes;
    var lGlobal = nGlobal * 4;

    var dstArray = materialProperties["clippingState"];

    uniform["value"] = dstArray; // ensure unique state

    dstArray = projectPlanes(planes, camera, lGlobal, useCache);

    for (var i = 0; i != lGlobal; ++i) {
      dstArray[i] = globalState[i];
    }

    materialProperties["clippingState"] = dstArray;
    numIntersection = clipIntersection ? numPlanes : 0;
    numPlanes += nGlobal;
  }
}