copy method

Material copy(
  1. Material source
)

Implementation

Material copy(Material source) {
  name = source.name;

  blending = source.blending;
  side = source.side;
  vertexColors = source.vertexColors;

  opacity = source.opacity;
  transparent = source.transparent;

  blendSrc = source.blendSrc;
  blendDst = source.blendDst;
  blendEquation = source.blendEquation;
  blendSrcAlpha = source.blendSrcAlpha;
  blendDstAlpha = source.blendDstAlpha;
  blendEquationAlpha = source.blendEquationAlpha;

  depthFunc = source.depthFunc;
  depthTest = source.depthTest;
  depthWrite = source.depthWrite;

  stencilWriteMask = source.stencilWriteMask;
  stencilFunc = source.stencilFunc;
  stencilRef = source.stencilRef;
  stencilFuncMask = source.stencilFuncMask;
  stencilFail = source.stencilFail;
  stencilZFail = source.stencilZFail;
  stencilZPass = source.stencilZPass;
  stencilWrite = source.stencilWrite;

  var srcPlanes = source.clippingPlanes;
  List<Plane>? dstPlanes;

  if (srcPlanes != null) {
    var n = srcPlanes.length;
    dstPlanes = List<Plane>.filled(n, Plane(null, null));

    for (var i = 0; i != n; ++i) {
      dstPlanes[i] = srcPlanes[i].clone();
    }
  }

  clippingPlanes = dstPlanes;
  clipIntersection = source.clipIntersection;
  clipShadows = source.clipShadows;

  shadowSide = source.shadowSide;

  colorWrite = source.colorWrite;

  precision = source.precision;

  polygonOffset = source.polygonOffset;
  polygonOffsetFactor = source.polygonOffsetFactor;
  polygonOffsetUnits = source.polygonOffsetUnits;

  dithering = source.dithering;

  alphaTest = source.alphaTest;
  alphaToCoverage = source.alphaToCoverage;
  premultipliedAlpha = source.premultipliedAlpha;

  visible = source.visible;

  toneMapped = source.toneMapped;

  userData = json.decode(json.encode(source.userData));

  return this;
}