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:
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);
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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
|
||||
if (engine.render) {
|
||||
Engine.render(engine);
|
||||
}
|
||||
|
||||
Events.trigger(engine, 'afterTick', event);
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue