dispose method

void dispose()

Implementation

void dispose(){
  if(disposed) return;
  disposed = true;

  for(final child in children){
    child.dispose();
  }

  material?.dispose();
  material = null;
  overrideMaterial?.dispose();
  overrideMaterial = null;
  customDepthMaterial?.dispose();
  customDepthMaterial = null;
  customDistanceMaterial?.dispose();
  customDistanceMaterial = null;

  geometry?.dispose();
  geometry = null;
  environment?.dispose();
  environment = null;

  instanceMatrix?.dispose();
  instanceMatrix = null;
  instanceColor?.dispose();
  instanceColor = null;

  parent?.dispose();

  if(background is NativeArray || background is ImageElement || background is Texture){
    background?.dispose();
    background = null;
  }
}