0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-26 13:49:01 -05:00

refactored Mater.Gui

This commit is contained in:
liabru 2014-04-25 16:59:25 +01:00
parent eee9a7b21b
commit d154fc7ac7

View file

@ -162,31 +162,7 @@ var Gui = {};
var render = datGui.addFolder('Render');
render.add(gui, 'renderer', ['canvas', 'webgl'])
.onFinishChange(function(value) {
var controller;
if (value === 'canvas')
controller = Render;
if (value === 'webgl')
controller = RenderPixi;
// remove old canvas
engine.render.element.removeChild(engine.render.canvas);
// create new renderer using the same options object
var options = engine.render.options;
engine.render = controller.create({
element: engine.render.element,
options: options
});
engine.render.options = options;
// bind the mouse to the new canvas
Mouse.setElement(engine.input.mouse, engine.render.canvas);
});
.onFinishChange(function(value) { _setRenderer(gui, value); });
render.add(engine.render.options, 'wireframes');
render.add(engine.render.options, 'showDebug');
@ -204,6 +180,33 @@ var Gui = {};
render.open();
};
var _setRenderer = function(gui, rendererName) {
var engine = gui.engine,
controller;
if (rendererName === 'canvas')
controller = Render;
if (rendererName === 'webgl')
controller = RenderPixi;
// remove old canvas
engine.render.element.removeChild(engine.render.canvas);
// create new renderer using the same options object
var options = engine.render.options;
engine.render = controller.create({
element: engine.render.element,
options: options
});
engine.render.options = options;
// bind the mouse to the new canvas
Mouse.setElement(engine.input.mouse, engine.render.canvas);
};
var _addBody = function(gui) {
var engine = gui.engine;