uxebu / bonsai

BonsaiJS is a graphics library and renderer
http://bonsaijs.org
Other
1.96k stars 189 forks source link

Change `stage.loop()` so that movies are advanced in tree order #131

Open davidaurelio opened 12 years ago

davidaurelio commented 12 years ago

Advance Timeline Tree Depth-First

Current State

stage.loop() is the central method that “moves the playhead” of all objects having a timeline and currently added to the stage.

It loops over all these objects using the movie registry. Objects are added to / removed from it by addChild() / removeChild().

The movie registry contains objects in insertion order. This allows movies inserted during the advancement / looping process to be advanced as well.

Change to Tree Traversal

The request is to change the logic to depth-first hierarchical tree traversal. This makes the actual order easier to predict for developers building things that depend on the tree structure.

padolsey commented 12 years ago

These all sound like good changes.

I think optimisation numbers (1) and (2) are absolute necessities since we're ditching registry.movies. (3) sounds good too -- makes things more intuitive.

I guess what'll take the most time is ensuring we have good test coverage for this stuff.