wasabia / three_dart

three.js rewrite by Dart, Dart 3D library. an easy to use, lightweight, cross-platform, general purpose 3D library.
MIT License
444 stars 77 forks source link

iOS autoClear not work #138

Open notbucai opened 10 months ago

notbucai commented 10 months ago

renderer!.autoClear = true;

image image


  initRenderer() {
    Map<String, dynamic> options = {
      "width": width,
      "height": height,
      "gl": three3dRender.gl,
      "antialias": true,
      "canvas": three3dRender.element,
      "alpha": true,
      "clearColor": 0xffffff,
      "clearAlpha": 0,
    };
    renderer = three.WebGLRenderer(options);
    renderer!.setPixelRatio(dpr);
    renderer!.setSize(width, height, false);
    renderer!.shadowMap.enabled = false;
    renderer!.alpha = true;
    renderer!.setClearColor(three.Color(0xffffff), 0);
    renderer!.autoClearDepth = true;
    renderer!.autoClearStencil = true;
    renderer!.autoClear = true;

    if (!kIsWeb) {
      var pars = three.WebGLRenderTargetOptions({"format": three.RGBAFormat});
      renderTarget = three.WebGLMultisampleRenderTarget(
          (width * dpr).toInt(), (height * dpr).toInt(), pars);
      renderTarget.samples = 4;
      renderer!.setRenderTarget(renderTarget);
      sourceTexture = renderer!.getRenderTargetGLTexture(renderTarget);
      // update
      three3dRender.updateTexture(sourceTexture);
    }
  }

  render() {
    // int t = DateTime.now().millisecondsSinceEpoch;
    renderer!.clear(true, true, true);

    final gl = three3dRender.gl;

    renderer!.render(scene, camera);

    gl.flush();

    if (!kIsWeb) {
      three3dRender.updateTexture(sourceTexture);
    }
  }
animate() {
    if (!mounted || disposed) {
      return;
    }

    if (!loaded) {
      return;
    }

    controls?.update();

    render();

    Future.delayed(const Duration(milliseconds: 40), () {
      animate();
    });
  }
Knightro63 commented 10 months ago

Hi @notbucai,

When using the above code I am able to get it to work. Can you tell me what version of three_dart you are using? Please try three_dart: 0.0.14.

Thanks