Optimise Events Between Modules
Currently SceneJS is designed a bit defensively in terms of
extensibility. When a geometry node is rendered, it
- fires an event to export itself,
- the renderer module collects that, then fires an event to
announce geometry is rendering
- various modules (like modules for material, texture, model
transform) respond by firing export events (unless they have
already exported up to date state for the last geometry)
- rendering module collects those, then builds a hashcode, finds
the right shader from that hash
- adds geometry to display list, linked to currently exported
nodes
Then when traversal done, SceneJS sorts and renders the display
list.
There's a lot of event creation going on in there for rendering
a geometry, which involves looking up listeners, creating param
objects etc. That should be replaced by callbacks, where each
(texture, material etc) module should register a callback directly
on the renderer module through which the latter can just directly
pull state.
Reduce Getters and Setters on Node Classes
Since the JavaScript API is deprecated, the way is clear to make
that inner JS workings more functionally-oriented. Since we now
have them encapsulated behind JSON we can relax the design of the
node classes and do things like expose a lot of their state as
property members instead of through getter and setter methods.
Memoize Scene State Hashes
Compute the hashcodes for nodes like material, geometry etc.
within their modules. Retain those hash codes and only re-compute
them when attributes change.