mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-13 16:18:50 -05:00
now only fps metrics by default, set metrics.extended true for full metrics
This commit is contained in:
parent
00feed5272
commit
123d391d00
2 changed files with 45 additions and 35 deletions
|
@ -15,6 +15,7 @@ var Metrics = {};
|
|||
*/
|
||||
Metrics.create = function() {
|
||||
return {
|
||||
extended: false,
|
||||
narrowDetections: 0,
|
||||
narrowphaseTests: 0,
|
||||
narrowReuse: 0,
|
||||
|
@ -37,6 +38,7 @@ var Metrics = {};
|
|||
* @param {metrics} metrics
|
||||
*/
|
||||
Metrics.reset = function(metrics) {
|
||||
if (metrics.extended) {
|
||||
metrics.narrowDetections = 0;
|
||||
metrics.narrowphaseTests = 0;
|
||||
metrics.narrowReuse = 0;
|
||||
|
@ -50,6 +52,7 @@ var Metrics = {};
|
|||
metrics.buckets = 0;
|
||||
metrics.pairs = 0;
|
||||
metrics.bodies = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -59,6 +62,7 @@ var Metrics = {};
|
|||
* @param {engine} engine
|
||||
*/
|
||||
Metrics.update = function(metrics, engine) {
|
||||
if (metrics.extended) {
|
||||
var world = engine.world,
|
||||
broadphase = engine.broadphase[engine.broadphase.current];
|
||||
|
||||
|
@ -71,6 +75,7 @@ var Metrics = {};
|
|||
metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2);
|
||||
//if (broadphase.instance)
|
||||
// metrics.buckets = Common.keys(broadphase.instance.buckets).length;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
|
@ -86,6 +86,8 @@ var Gui = {};
|
|||
|
||||
var metrics = datGui.addFolder('Metrics');
|
||||
metrics.add(engine.timing, 'fps').listen();
|
||||
|
||||
if (engine.metrics.extended) {
|
||||
metrics.add(engine.timing, 'delta').listen();
|
||||
metrics.add(engine.timing, 'correction').listen();
|
||||
metrics.add(engine.metrics, 'bodies').listen();
|
||||
|
@ -96,6 +98,9 @@ var Gui = {};
|
|||
metrics.add(engine.metrics, 'narrowEff').listen();
|
||||
metrics.add(engine.metrics, 'narrowReuse').listen();
|
||||
metrics.close();
|
||||
} else {
|
||||
metrics.open();
|
||||
}
|
||||
|
||||
var controls = datGui.addFolder('Add Body');
|
||||
controls.add(gui, 'amount', 1, 5).step(1);
|
||||
|
|
Loading…
Reference in a new issue