'Three.js multiple canvas with AJAX method

In my website, I have two templates. In each template I need a canvas to do some Three.js in it.

Every time I move to another page, I'm using AJAX to prevent the reload method. Meaning that every time the page is loading, I'm creating a new canvas.

So my question is : how do I remove properly everything from the previous page's canvas. So far I :

  • kill the related RequestAnimationFrame
  • clear() my renderer
  • I use the dispose() method on my geometries and materials

Can I do something more to fully empty the ressources used from the previous canvas ? Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source