diff --git a/Gruntfile.js b/Gruntfile.js index b73015f..91e17c4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -60,7 +60,7 @@ module.exports = function(grunt) { watch: { options: { port: 9000, - open: 'http://localhost:9000/demo/dev.html', + open: 'http://localhost:9000/demo', livereload: 9001 } }, diff --git a/demo/dev.html b/demo/dev.html deleted file mode 100644 index 3adc99d..0000000 --- a/demo/dev.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Matter.js Demo (Dev. Build) - - -
-

Matter.js Demo (Dev. Build)

- -
- - - -
-
-
- - diff --git a/demo/index.html b/demo/index.html index f3bb382..104ac37 100644 --- a/demo/index.html +++ b/demo/index.html @@ -3,40 +3,51 @@ - + + + + - - + + + + - Matter.js Physics Engine Demo + Matter.js Demo (Edge Build)
-

Matter.js Physics Engine Demo

- +

Matter.js Demo (Edge Build)

+
+
- \ No newline at end of file + diff --git a/demo/js/Demo.js b/demo/js/Demo.js index bc3206c..8b260e7 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -1,3 +1,11 @@ +/** +* The Matter.js demo page controller and example runner. +* +* NOTE: For the actual example code, refer to the source files in `/examples/`. +* +* @class Demo +*/ + (function() { var _isBrowser = typeof window !== 'undefined' && window.location, @@ -67,6 +75,9 @@ // set up demo interface (see end of this file) Demo.initControls(demo); + // pass through runner as timing for debug rendering + demo.engine.metrics.timing = demo.runner; + return demo; }; diff --git a/demo/js/DemoMobile.js b/demo/js/DemoMobile.js index 47abc83..3f367b8 100644 --- a/demo/js/DemoMobile.js +++ b/demo/js/DemoMobile.js @@ -36,7 +36,11 @@ Demo.fullscreen(); setTimeout(function() { - Engine.run(_engine); + var runner = Engine.run(_engine); + + // pass through runner as timing for debug rendering + _engine.metrics.timing = runner; + Demo.updateScene(); }, 800); }); diff --git a/demo/mobile.html b/demo/mobile.html index 3615820..4b0b7e0 100644 --- a/demo/mobile.html +++ b/demo/mobile.html @@ -7,24 +7,29 @@ - - + + + + + + + Matter.js Physics Engine Mobile Demo - +

Matter.js Mobile Demo

Open this page on your mobile device in Chrome or Safari +

+ Touch and drag to interact with the blocks +

+ Tilt and turn to master gravity like you're the boss of it

-

- Touch and drag to interact with the blocks -
Tilt and turn to master gravity like you're the boss of it -

- -

Or back to the full demo page for more info.

-
+ +

Or back to the full demo page for more info.

+
\ No newline at end of file diff --git a/src/render/Render.js b/src/render/Render.js index 331c2a3..f2ee31a 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -253,30 +253,31 @@ var Grid = require('../collision/Grid'); var c = context, world = engine.world, render = engine.render, + metrics = engine.metrics, options = render.options, bodies = Composite.allBodies(world), space = " "; if (engine.timing.timestamp - (render.debugTimestamp || 0) >= 500) { var text = ""; - text += "fps: " + Math.round(engine.timing.fps) + space; + text += "fps: " + Math.round(metrics.timing.fps) + space; // @if DEBUG - if (engine.metrics.extended) { - text += "delta: " + engine.timing.delta.toFixed(3) + space; - text += "correction: " + engine.timing.correction.toFixed(3) + space; + if (metrics.extended) { + text += "delta: " + metrics.timing.delta.toFixed(3) + space; + text += "correction: " + metrics.timing.correction.toFixed(3) + space; text += "bodies: " + bodies.length + space; if (engine.broadphase.controller === Grid) - text += "buckets: " + engine.metrics.buckets + space; + text += "buckets: " + metrics.buckets + space; text += "\n"; - text += "collisions: " + engine.metrics.collisions + space; + text += "collisions: " + metrics.collisions + space; text += "pairs: " + engine.pairs.list.length + space; - text += "broad: " + engine.metrics.broadEff + space; - text += "mid: " + engine.metrics.midEff + space; - text += "narrow: " + engine.metrics.narrowEff + space; + text += "broad: " + metrics.broadEff + space; + text += "mid: " + metrics.midEff + space; + text += "narrow: " + metrics.narrowEff + space; } // @endif diff --git a/src/render/RenderPixi.js b/src/render/RenderPixi.js index 04ab813..7ab62f9 100644 --- a/src/render/RenderPixi.js +++ b/src/render/RenderPixi.js @@ -9,6 +9,9 @@ var RenderPixi = {}; module.exports = RenderPixi; +var Composite = require('../body/Composite'); +var Common = require('../core/Common'); + (function() { /** diff --git a/test/browser/TestDemo.js b/test/browser/TestDemo.js index 336e1cd..31a968a 100644 --- a/test/browser/TestDemo.js +++ b/test/browser/TestDemo.js @@ -6,7 +6,7 @@ var system = require('system'); var demo, frames = 10, - testUrl = 'http://localhost:8000/demo/dev.html', + testUrl = 'http://localhost:8000/demo/index.html', refsPath = 'test/browser/refs', diffsPath = 'test/browser/diffs'; diff --git a/test/node/TestDemo.js b/test/node/TestDemo.js index 31089e9..965988e 100644 --- a/test/node/TestDemo.js +++ b/test/node/TestDemo.js @@ -164,7 +164,7 @@ var getDemoNames = function() { 'events', 'collisionFiltering', 'sleeping' ]; - $('#demo-select option', fs.readFileSync('demo/dev.html').toString()) + $('#demo-select option', fs.readFileSync('demo/index.html').toString()) .each(function() { var name = $(this).val(); if (skip.indexOf(name) === -1) {