projectPlanes method

List<double>? projectPlanes([
  1. List<Plane>? planes,
  2. Camera? camera,
  3. int dstOffset = 0,
  4. bool skipTransform = false,
])

Implementation

List<double>? projectPlanes([List<Plane>? planes, Camera? camera, int dstOffset = 0, bool skipTransform = false]) {
  final nPlanes = planes != null ? planes.length : 0;
  List<double>? dstArray;

  if (nPlanes != 0) {
    dstArray = uniform["value"];

    if (!skipTransform || dstArray == null) {
      final flatSize = dstOffset + nPlanes * 4;
      final viewMatrix = camera?.matrixWorldInverse ?? Matrix4.identity();

      viewNormalMatrix.getNormalMatrix(viewMatrix);

      if (dstArray == null || dstArray.length < flatSize) {
        dstArray = List<double>.filled(flatSize, 0.0);
      }

      for (int i = 0, i4 = dstOffset; i != nPlanes; ++i, i4 += 4) {
        plane..copyFrom(planes![i])..applyMatrix4(viewMatrix, viewNormalMatrix);

        plane.normal.copyIntoArray(dstArray, i4);
        dstArray[i4 + 3] = plane.constant;
      }
    }

    uniform["value"] = dstArray;
    uniform["needsUpdate"] = true;
  }

  numPlanes = nPlanes;
  numIntersection = 0;

  return dstArray;
}