Although SceneJS does its best to keep a pool of free WebGL
resources available using LRU eviction, it should also be possible
to explicitly free them.
A SceneJS.Node could then have a destroy flag so that subsequent
traversal within its subgraph will be in RENDER_DESTROY mode. Each
node type would have its own destruction function to execute when
rendered in this mode.
Removal of a node from its parent would actually be a "soft
removal" that would set its destroy flag. If the node was then
added to some other parent, the destroy flag would be unset.
SceneJS would then only actually detach a destroyed child after
rendering it. After that, it could be reattached to another
parent.
Destruction operations are only required on nodes that store
state on WebGL or the SceneJS framework instance, which
include:
- SceneJS.Geometry
- SceneJS.Texture
- SceneJS.Socket
TODO: explore cases, design alorithm.
TODO: explore case in which a node is transferred across two
separate scene graphs, where it would then be referencing the wrong
VRAM resources.