initRenderer method

void initRenderer()

Implementation

void initRenderer() {
  renderer = lateRenderer;
  if(renderer == null){
    Map<String, dynamic> options = {
      "width": width,
      "height": height,
      "gl": gl,
      "stencil": settings.stencil,
      "antialias": true,
      "alpha": settings.alpha,
      "clearColor": settings.clearColor,
      "clearAlpha": settings.clearAlpha,
      "logarithmicDepthBuffer": settings.logarithmicDepthBuffer
    };

    renderer = lateRenderer ?? core.WebGLRenderer(options);
    renderer!.setPixelRatio(dpr);
    renderer!.setSize(width, height, false);
    renderer!.alpha = settings.alpha;
    renderer!.shadowMap.enabled = settings.enableShadowMap;
    renderer!.shadowMap.type = settings.shadowMapType;
    renderer!.autoClear = settings.autoClear;
    renderer!.setClearColor(
      Color.fromHex32(settings.clearColor),
      settings.clearAlpha
    );
    renderer!.autoClearDepth = settings.autoClearDepth;
    renderer!.autoClearStencil = settings.autoClearStencil;
    renderer!.outputEncoding = sRGBEncoding;
    renderer!.localClippingEnabled = settings.localClippingEnabled;
    renderer!.clippingPlanes = settings.clippingPlanes;
    renderer!.toneMapping = settings.toneMapping;
    renderer!.toneMappingExposure = settings.toneMappingExposure;
  }

  if(settings.useSourceTexture && !kIsWeb){
    final core.WebGLRenderTargetOptions pars = core.WebGLRenderTargetOptions(settings.renderOptions);
    renderTarget = core.WebGLRenderTarget((width * dpr).toInt(), (height * dpr).toInt(), pars);
    renderer!.setRenderTarget(renderTarget);
    sourceTexture = renderer!.getRenderTargetGLTexture(renderTarget!);

    falseMesh = core.Mesh(core.PlaneGeometry(0,0), null);
    falseRenderTarget = core.WebGLRenderTarget(0,0, core.WebGLRenderTargetOptions({}));
    falseCamera = core.Camera();
    renderer!.setRenderTarget(falseRenderTarget);
  }
}