Three js memory management

后端 未结 2 673
渐次进展
渐次进展 2021-02-04 08:56

I have a large scene with a lot of Mesh and MorphAnimMesh. I want to free memory when the meshes are removed. If i know right this is the best way to do:

for ( v         


        
相关标签:
2条回答
  • 2021-02-04 09:39

    Most likely, you need to add some, or all, of the following:

    geometry.dispose();
    material.dispose();
    texture.dispose();
    

    Check out these examples:

    http://mrdoob.github.com/three.js/examples/webgl_test_memory.html

    http://mrdoob.github.com/three.js/examples/webgl_test_memory2.html

    three.js r.60

    0 讨论(0)
  • 2021-02-04 09:39

    I did try all the dispose and deallocate methods but nothing worked.

    Then I did the following for my ionic application which is using webgl renderer to render a 360 image.

    this.renderer = new THREE.WebGLRenderer({ antialias: true });
    RicohView.prototype.stopRendering = function () {
        this.canRender = false;
        this.renderer.forceContextLoss();
        this.renderer.dispose();
        console.log('renderer disposed');
        cancelAnimationFrame(this.requestId);
    }
    

    requestId is something which can be captured from

    this.requestId = requestAnimationFrame(render);
    
    0 讨论(0)
提交回复
热议问题