Render tasks for Nodes (updated demo!)

In this new approach a Map is populated during each tick of the Motor whenever a setter on a Node is used, while firing all the render tasks, in order to keep track of which nodes need rendering. After all tasks are fired, then the Map is iterated over, all nodes rendered, and finally the Map cleared. This means that each animation frame a Map is populated then cleared. The Map keys are the nodes, and currently the values are undefined because I just need a list a nodes and don’t actually care what the Map values are. I want to avoid Garabage Collection (GC), so when the Map is cleared, the nodes are released, which should be fine because the render tasks contain references to the nodes in their scopes, so the nodes won’t be GCed until at least the render tasks manipulating the nodes removed (i.e. animations finished). I’m curious to know if having undefined for the Map values will cause those undefined values to be GCed? I’m curious to know how undefined is treated: is each undefined Map value an object that the JS engine keeps track of and eventually GCs when I release them? If so (I’ll wait for an answer on es-discuss) then we can just set the Map values to some const value stored inside Motor.

The API also guards against people who might use their own (possibly naive) animation loop. When a Node setter is used outside of the Motor’s animation loop, the Node automatically places itself into the Motor’s animation loop, so it’s possible to do:

let rotation = 0
window.setInterval(function() {
    rotation += 1
    node1.rotation = [0,rotation,0]

    if (rotation > 200)
        node2.rotation = [0,rotation,rotation]
}, 16.66)

These nodes that are being modified will not render outside of the Motor’s animation loop, but note that there is now a little extra overhead from running two loops (each tick of this setInterval loop causes a render task for the modified Nodes to be added and removed in the next Motor tick).