mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-27 13:59:01 -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() {
|
Metrics.create = function() {
|
||||||
return {
|
return {
|
||||||
|
extended: false,
|
||||||
narrowDetections: 0,
|
narrowDetections: 0,
|
||||||
narrowphaseTests: 0,
|
narrowphaseTests: 0,
|
||||||
narrowReuse: 0,
|
narrowReuse: 0,
|
||||||
|
@ -37,6 +38,7 @@ var Metrics = {};
|
||||||
* @param {metrics} metrics
|
* @param {metrics} metrics
|
||||||
*/
|
*/
|
||||||
Metrics.reset = function(metrics) {
|
Metrics.reset = function(metrics) {
|
||||||
|
if (metrics.extended) {
|
||||||
metrics.narrowDetections = 0;
|
metrics.narrowDetections = 0;
|
||||||
metrics.narrowphaseTests = 0;
|
metrics.narrowphaseTests = 0;
|
||||||
metrics.narrowReuse = 0;
|
metrics.narrowReuse = 0;
|
||||||
|
@ -50,6 +52,7 @@ var Metrics = {};
|
||||||
metrics.buckets = 0;
|
metrics.buckets = 0;
|
||||||
metrics.pairs = 0;
|
metrics.pairs = 0;
|
||||||
metrics.bodies = 0;
|
metrics.bodies = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,6 +62,7 @@ var Metrics = {};
|
||||||
* @param {engine} engine
|
* @param {engine} engine
|
||||||
*/
|
*/
|
||||||
Metrics.update = function(metrics, engine) {
|
Metrics.update = function(metrics, engine) {
|
||||||
|
if (metrics.extended) {
|
||||||
var world = engine.world,
|
var world = engine.world,
|
||||||
broadphase = engine.broadphase[engine.broadphase.current];
|
broadphase = engine.broadphase[engine.broadphase.current];
|
||||||
|
|
||||||
|
@ -71,6 +75,7 @@ var Metrics = {};
|
||||||
metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2);
|
metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2);
|
||||||
//if (broadphase.instance)
|
//if (broadphase.instance)
|
||||||
// metrics.buckets = Common.keys(broadphase.instance.buckets).length;
|
// metrics.buckets = Common.keys(broadphase.instance.buckets).length;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
|
@ -86,6 +86,8 @@ var Gui = {};
|
||||||
|
|
||||||
var metrics = datGui.addFolder('Metrics');
|
var metrics = datGui.addFolder('Metrics');
|
||||||
metrics.add(engine.timing, 'fps').listen();
|
metrics.add(engine.timing, 'fps').listen();
|
||||||
|
|
||||||
|
if (engine.metrics.extended) {
|
||||||
metrics.add(engine.timing, 'delta').listen();
|
metrics.add(engine.timing, 'delta').listen();
|
||||||
metrics.add(engine.timing, 'correction').listen();
|
metrics.add(engine.timing, 'correction').listen();
|
||||||
metrics.add(engine.metrics, 'bodies').listen();
|
metrics.add(engine.metrics, 'bodies').listen();
|
||||||
|
@ -96,6 +98,9 @@ var Gui = {};
|
||||||
metrics.add(engine.metrics, 'narrowEff').listen();
|
metrics.add(engine.metrics, 'narrowEff').listen();
|
||||||
metrics.add(engine.metrics, 'narrowReuse').listen();
|
metrics.add(engine.metrics, 'narrowReuse').listen();
|
||||||
metrics.close();
|
metrics.close();
|
||||||
|
} else {
|
||||||
|
metrics.open();
|
||||||
|
}
|
||||||
|
|
||||||
var controls = datGui.addFolder('Add Body');
|
var controls = datGui.addFolder('Add Body');
|
||||||
controls.add(gui, 'amount', 1, 5).step(1);
|
controls.add(gui, 'amount', 1, 5).step(1);
|
||||||
|
|
Loading…
Reference in a new issue