mirror of
https://github.com/liabru/matter-js.git
synced 2024-11-27 09:50:52 -05:00
fix handling of engine.render
This commit is contained in:
parent
d22b1b4915
commit
c46e9155e2
2 changed files with 13 additions and 5 deletions
|
@ -56,11 +56,13 @@ var Engine = {};
|
||||||
|
|
||||||
var engine = Common.extend(defaults, options);
|
var engine = Common.extend(defaults, options);
|
||||||
|
|
||||||
if (element && !engine.render) {
|
if (element || engine.render) {
|
||||||
engine.render = {
|
var renderDefaults = {
|
||||||
element: element,
|
element: element,
|
||||||
controller: Render
|
controller: Render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
engine.render = Common.extend(renderDefaults, engine.render);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine.render && engine.render.controller) {
|
if (engine.render && engine.render.controller) {
|
||||||
|
|
|
@ -105,14 +105,20 @@ var Runner = {};
|
||||||
Events.trigger(engine, 'tick', event);
|
Events.trigger(engine, 'tick', event);
|
||||||
|
|
||||||
// if world has been modified, clear the render scene graph
|
// 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);
|
engine.render.controller.clear(engine.render);
|
||||||
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
Engine.update(engine, delta, correction);
|
Engine.update(engine, delta, correction);
|
||||||
|
|
||||||
// render
|
// render
|
||||||
|
if (engine.render) {
|
||||||
Engine.render(engine);
|
Engine.render(engine);
|
||||||
|
}
|
||||||
|
|
||||||
Events.trigger(engine, 'afterTick', event);
|
Events.trigger(engine, 'afterTick', event);
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue