0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-11-23 09:26:51 -05:00

fix handling of engine.render

This commit is contained in:
liabru 2015-07-05 15:57:12 +01:00
parent d22b1b4915
commit c46e9155e2
2 changed files with 13 additions and 5 deletions

View file

@ -56,11 +56,13 @@ var Engine = {};
var engine = Common.extend(defaults, options);
if (element && !engine.render) {
engine.render = {
if (element || engine.render) {
var renderDefaults = {
element: element,
controller: Render
};
engine.render = Common.extend(renderDefaults, engine.render);
}
if (engine.render && engine.render.controller) {

View file

@ -105,14 +105,20 @@ var Runner = {};
Events.trigger(engine, 'tick', event);
// if world has been modified, clear the render scene graph
if (engine.world.isModified && engine.render.controller.clear)
if (engine.world.isModified
&& engine.render
&& engine.render.controller
&& engine.render.controller.clear) {
engine.render.controller.clear(engine.render);
}
// update
Engine.update(engine, delta, correction);
// render
Engine.render(engine);
if (engine.render) {
Engine.render(engine);
}
Events.trigger(engine, 'afterTick', event);
})();