gdsestimating / three-dxf

A dxf viewer for the browser using three.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disposing WebGL objects

bercht-a opened this issue · comments

If I use this three-dxf user in angular SPA and have several calls to "new ThreeDxf.Viewer" I get an warning "Too many active WebGL contexts. Oldest context will be lost."
What is the best approach to clean up those webgl objects? should I somehow call dispose() on all three.js objects?

I found a way to avoid webgl leaks...

When I call dispose() and forceContextLoss() on the renderer, I don't get those leaks:

this.dxfViewer?.renderer.dispose();
this.dxfViewer?.renderer.forceContextLoss();

Thanks for sharing your solution. I wasn't finding much on it. Glad you figured it out