Open duping123456 opened 2 months ago
Ah yes, on unmount you'll want to do this:
const index = Two.Instances.indexOf(two);
const parent = two.renderer.domElement.parentElement;
if (index >= 0) Two.Instances.splice(index, 1);
if (parent) parent.removeChild(two.renderer.domElement);
two.release(two.scene);
Assuming your instance of Two.js is called two
.
I have a Vue project that references this JS. In one of the pages, four graphics drawn by TwoJS were rendered. When I re rendered the page, the four TwoJs were not destroyed and were regenerated. This caused the memory to constantly increase every time I switched data and re rendered the component, until the webpage crashed