From 99c3bb327313c8f897cf1c9bc0badf4bef30fba6 Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 13 Aug 2015 23:03:08 +0100 Subject: [PATCH] move require statements below module export --- src/body/Body.js | 16 ++++++++-------- src/body/Composite.js | 8 ++++---- src/body/World.js | 8 ++++---- src/collision/Detector.js | 8 ++++---- src/collision/Grid.js | 8 ++++---- src/collision/Pair.js | 4 ++-- src/collision/Pairs.js | 6 +++--- src/collision/Query.js | 12 ++++++------ src/collision/Resolver.js | 10 +++++----- src/collision/SAT.js | 6 +++--- src/constraint/Constraint.js | 14 +++++++------- src/constraint/MouseConstraint.js | 20 ++++++++++---------- src/core/Engine.js | 26 +++++++++++++------------- src/core/Events.js | 4 ++-- src/core/Metrics.js | 6 +++--- src/core/Mouse.js | 4 ++-- src/core/Runner.js | 8 ++++---- src/core/Sleeping.js | 4 ++-- src/factory/Bodies.js | 12 ++++++------ src/factory/Composites.js | 12 ++++++------ src/geometry/Axes.js | 6 +++--- src/geometry/Svg.js | 4 ++-- src/geometry/Vertices.js | 6 +++--- src/render/Render.js | 12 ++++++------ 24 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/body/Body.js b/src/body/Body.js index b0ca5c49..d4bef9f1 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -1,11 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Vector = require('../geometry/Vector'); -var Sleeping = require('../core/Sleeping'); -var Render = require('../render/Render'); -var Common = require('../core/Common'); -var Bounds = require('../geometry/Bounds'); -var Axes = require('../geometry/Axes'); - /** * The `Matter.Body` module contains methods for creating and manipulating body models. * A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. @@ -21,6 +13,14 @@ var Body = {}; module.exports = Body; +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); +var Sleeping = require('../core/Sleeping'); +var Render = require('../render/Render'); +var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); +var Axes = require('../geometry/Axes'); + (function() { Body._inertiaScale = 4; diff --git a/src/body/Composite.js b/src/body/Composite.js index 076353b1..58194840 100644 --- a/src/body/Composite.js +++ b/src/body/Composite.js @@ -1,7 +1,3 @@ -var Events = require('../core/Events'); -var Common = require('../core/Common'); -var Body = require('./Body'); - /** * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. @@ -18,6 +14,10 @@ var Composite = {}; module.exports = Composite; +var Events = require('../core/Events'); +var Common = require('../core/Common'); +var Body = require('./Body'); + (function() { /** diff --git a/src/body/World.js b/src/body/World.js index 3823ed5b..bcaa4120 100644 --- a/src/body/World.js +++ b/src/body/World.js @@ -1,7 +1,3 @@ -var Composite = require('./Composite'); -var Constraint = require('../constraint/Constraint'); -var Common = require('../core/Common'); - /** * The `Matter.World` module contains methods for creating and manipulating the world composite. * A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. @@ -20,6 +16,10 @@ var World = {}; module.exports = World; +var Composite = require('./Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('../core/Common'); + (function() { /** diff --git a/src/collision/Detector.js b/src/collision/Detector.js index d6c79fbd..719eb92a 100644 --- a/src/collision/Detector.js +++ b/src/collision/Detector.js @@ -1,7 +1,3 @@ -var SAT = require('./SAT'); -var Pair = require('./Pair'); -var Bounds = require('../geometry/Bounds'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -14,6 +10,10 @@ var Detector = {}; module.exports = Detector; +var SAT = require('./SAT'); +var Pair = require('./Pair'); +var Bounds = require('../geometry/Bounds'); + (function() { /** diff --git a/src/collision/Grid.js b/src/collision/Grid.js index bac5fe7a..783a4aa6 100644 --- a/src/collision/Grid.js +++ b/src/collision/Grid.js @@ -1,7 +1,3 @@ -var Pair = require('./Pair'); -var Detector = require('./Detector'); -var Common = require('../core/Common'); - /** * See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js) * and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples. @@ -13,6 +9,10 @@ var Grid = {}; module.exports = Grid; +var Pair = require('./Pair'); +var Detector = require('./Detector'); +var Common = require('../core/Common'); + (function() { /** diff --git a/src/collision/Pair.js b/src/collision/Pair.js index dc58a278..bfa2da84 100644 --- a/src/collision/Pair.js +++ b/src/collision/Pair.js @@ -1,5 +1,3 @@ -var Contact = require('./Contact'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -10,6 +8,8 @@ var Pair = {}; module.exports = Pair; +var Contact = require('./Contact'); + (function() { /** diff --git a/src/collision/Pairs.js b/src/collision/Pairs.js index 3591d795..57961045 100644 --- a/src/collision/Pairs.js +++ b/src/collision/Pairs.js @@ -1,6 +1,3 @@ -var Pair = require('./Pair'); -var Common = require('../core/Common'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -11,6 +8,9 @@ var Pairs = {}; module.exports = Pairs; +var Pair = require('./Pair'); +var Common = require('../core/Common'); + (function() { var _pairMaxIdleLife = 1000; diff --git a/src/collision/Query.js b/src/collision/Query.js index 242f6803..b5adf5dc 100644 --- a/src/collision/Query.js +++ b/src/collision/Query.js @@ -1,9 +1,3 @@ -var Vector = require('../geometry/Vector'); -var SAT = require('./SAT'); -var Bounds = require('../geometry/Bounds'); -var Bodies = require('../factory/Bodies'); -var Vertices = require('../geometry/Vertices'); - /** * The `Matter.Query` module contains methods for performing collision queries. * @@ -14,6 +8,12 @@ var Query = {}; module.exports = Query; +var Vector = require('../geometry/Vector'); +var SAT = require('./SAT'); +var Bounds = require('../geometry/Bounds'); +var Bodies = require('../factory/Bodies'); +var Vertices = require('../geometry/Vertices'); + (function() { /** diff --git a/src/collision/Resolver.js b/src/collision/Resolver.js index 4399c957..8dc09c09 100644 --- a/src/collision/Resolver.js +++ b/src/collision/Resolver.js @@ -1,8 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Vector = require('../geometry/Vector'); -var Common = require('../core/Common'); -var Bounds = require('../geometry/Bounds'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -13,6 +8,11 @@ var Resolver = {}; module.exports = Resolver; +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); + (function() { Resolver._restingThresh = 4; diff --git a/src/collision/SAT.js b/src/collision/SAT.js index 376c5bb6..8fe87e38 100644 --- a/src/collision/SAT.js +++ b/src/collision/SAT.js @@ -1,6 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Vector = require('../geometry/Vector'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -13,6 +10,9 @@ var SAT = {}; module.exports = SAT; +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); + (function() { /** diff --git a/src/constraint/Constraint.js b/src/constraint/Constraint.js index 47132565..ea72dcb9 100644 --- a/src/constraint/Constraint.js +++ b/src/constraint/Constraint.js @@ -1,10 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Vector = require('../geometry/Vector'); -var Sleeping = require('../core/Sleeping'); -var Bounds = require('../geometry/Bounds'); -var Axes = require('../geometry/Axes'); -var Common = require('../core/Common'); - /** * The `Matter.Constraint` module contains methods for creating and manipulating constraints. * Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). @@ -28,6 +21,13 @@ var Constraint = {}; module.exports = Constraint; +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); +var Sleeping = require('../core/Sleeping'); +var Bounds = require('../geometry/Bounds'); +var Axes = require('../geometry/Axes'); +var Common = require('../core/Common'); + (function() { var _minLength = 0.000001, diff --git a/src/constraint/MouseConstraint.js b/src/constraint/MouseConstraint.js index 59ba345f..4d243c6c 100644 --- a/src/constraint/MouseConstraint.js +++ b/src/constraint/MouseConstraint.js @@ -1,13 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Sleeping = require('../core/Sleeping'); -var Mouse = require('../core/Mouse'); -var Events = require('../core/Events'); -var Detector = require('../collision/Detector'); -var Constraint = require('./Constraint'); -var Composite = require('../body/Composite'); -var Common = require('../core/Common'); -var Bounds = require('../geometry/Bounds'); - /** * The `Matter.MouseConstraint` module contains methods for creating mouse constraints. * Mouse constraints are used for allowing user interaction, providing the ability to move bodies via the mouse or touch. @@ -22,6 +12,16 @@ var MouseConstraint = {}; module.exports = MouseConstraint; +var Vertices = require('../geometry/Vertices'); +var Sleeping = require('../core/Sleeping'); +var Mouse = require('../core/Mouse'); +var Events = require('../core/Events'); +var Detector = require('../collision/Detector'); +var Constraint = require('./Constraint'); +var Composite = require('../body/Composite'); +var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); + (function() { /** diff --git a/src/core/Engine.js b/src/core/Engine.js index 78680b0a..f20b9d37 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -1,16 +1,3 @@ -var World = require('../body/World'); -var Sleeping = require('./Sleeping'); -var Resolver = require('../collision/Resolver'); -var Render = require('../render/Render'); -var Pairs = require('../collision/Pairs'); -var Metrics = require('./Metrics'); -var Grid = require('../collision/Grid'); -var Events = require('./Events'); -var Composite = require('../body/Composite'); -var Constraint = require('../constraint/Constraint'); -var Common = require('./Common'); -var Body = require('../body/Body'); - /** * The `Matter.Engine` module contains methods for creating and manipulating engines. * An engine is a controller that manages updating the simulation of the world. @@ -26,6 +13,19 @@ var Engine = {}; module.exports = Engine; +var World = require('../body/World'); +var Sleeping = require('./Sleeping'); +var Resolver = require('../collision/Resolver'); +var Render = require('../render/Render'); +var Pairs = require('../collision/Pairs'); +var Metrics = require('./Metrics'); +var Grid = require('../collision/Grid'); +var Events = require('./Events'); +var Composite = require('../body/Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('./Common'); +var Body = require('../body/Body'); + (function() { /** diff --git a/src/core/Events.js b/src/core/Events.js index 359f3e12..5a7fd912 100644 --- a/src/core/Events.js +++ b/src/core/Events.js @@ -1,5 +1,3 @@ -var Common = require('./Common'); - /** * See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js) * and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples. @@ -11,6 +9,8 @@ var Events = {}; module.exports = Events; +var Common = require('./Common'); + (function() { /** diff --git a/src/core/Metrics.js b/src/core/Metrics.js index 204a183b..4500a9f9 100644 --- a/src/core/Metrics.js +++ b/src/core/Metrics.js @@ -1,7 +1,4 @@ // @if DEBUG -var Composite = require('../body/Composite'); -var Common = require('./Common'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -11,6 +8,9 @@ var Metrics = {}; module.exports = Metrics; +var Composite = require('../body/Composite'); +var Common = require('./Common'); + (function() { /** diff --git a/src/core/Mouse.js b/src/core/Mouse.js index 1aa7dcaf..74545606 100644 --- a/src/core/Mouse.js +++ b/src/core/Mouse.js @@ -1,5 +1,3 @@ -var Common = require('../core/Common'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -10,6 +8,8 @@ var Mouse = {}; module.exports = Mouse; +var Common = require('../core/Common'); + (function() { /** diff --git a/src/core/Runner.js b/src/core/Runner.js index 8c8121f2..8068ebbc 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -1,7 +1,3 @@ -var Events = require('./Events'); -var Engine = require('./Engine'); -var Common = require('./Common'); - /** * The `Matter.Runner` module is an optional utility which provides a game loop, * that handles updating and rendering a `Matter.Engine` for you within a browser. @@ -20,6 +16,10 @@ var Runner = {}; module.exports = Runner; +var Events = require('./Events'); +var Engine = require('./Engine'); +var Common = require('./Common'); + (function() { if (typeof window === 'undefined') { diff --git a/src/core/Sleeping.js b/src/core/Sleeping.js index 3ecad0c0..7de6a97c 100644 --- a/src/core/Sleeping.js +++ b/src/core/Sleeping.js @@ -1,5 +1,3 @@ -var Events = require('./Events'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -10,6 +8,8 @@ var Sleeping = {}; module.exports = Sleeping; +var Events = require('./Events'); + (function() { Sleeping._motionWakeThreshold = 0.18; diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index a698b11a..bc77d75d 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -1,9 +1,3 @@ -var Vertices = require('../geometry/Vertices'); -var Common = require('../core/Common'); -var Body = require('../body/Body'); -var Bounds = require('../geometry/Bounds'); -var Vector = require('../geometry/Vector'); - /** * The `Matter.Bodies` module contains factory methods for creating rigid body models * with commonly used body configurations (such as rectangles, circles and other polygons). @@ -20,6 +14,12 @@ var Bodies = {}; module.exports = Bodies; +var Vertices = require('../geometry/Vertices'); +var Common = require('../core/Common'); +var Body = require('../body/Body'); +var Bounds = require('../geometry/Bounds'); +var Vector = require('../geometry/Vector'); + (function() { /** diff --git a/src/factory/Composites.js b/src/factory/Composites.js index f01c5fb5..e86c5817 100644 --- a/src/factory/Composites.js +++ b/src/factory/Composites.js @@ -1,9 +1,3 @@ -var Composite = require('../body/Composite'); -var Constraint = require('../constraint/Constraint'); -var Common = require('../core/Common'); -var Body = require('../body/Body'); -var Bodies = require('./Bodies'); - /** * See [Demo.js](https://github.com/liabru/matter-js/blob/master/demo/js/Demo.js) * and [DemoMobile.js](https://github.com/liabru/matter-js/blob/master/demo/js/DemoMobile.js) for usage examples. @@ -15,6 +9,12 @@ var Composites = {}; module.exports = Composites; +var Composite = require('../body/Composite'); +var Constraint = require('../constraint/Constraint'); +var Common = require('../core/Common'); +var Body = require('../body/Body'); +var Bodies = require('./Bodies'); + (function() { /** diff --git a/src/geometry/Axes.js b/src/geometry/Axes.js index eba3135f..e5a3d51e 100644 --- a/src/geometry/Axes.js +++ b/src/geometry/Axes.js @@ -1,6 +1,3 @@ -var Vector = require('../geometry/Vector'); -var Common = require('../core/Common'); - /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -11,6 +8,9 @@ var Axes = {}; module.exports = Axes; +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); + (function() { /** diff --git a/src/geometry/Svg.js b/src/geometry/Svg.js index f78a9f46..9c8d5497 100644 --- a/src/geometry/Svg.js +++ b/src/geometry/Svg.js @@ -1,5 +1,3 @@ -var Bounds = require('../geometry/Bounds'); - /** * The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. * @@ -13,6 +11,8 @@ var Svg = {}; module.exports = Svg; +var Bounds = require('../geometry/Bounds'); + (function() { /** diff --git a/src/geometry/Vertices.js b/src/geometry/Vertices.js index f6ea8293..ef57bef8 100644 --- a/src/geometry/Vertices.js +++ b/src/geometry/Vertices.js @@ -1,6 +1,3 @@ -var Vector = require('../geometry/Vector'); -var Common = require('../core/Common'); - /** * The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. @@ -16,6 +13,9 @@ var Vertices = {}; module.exports = Vertices; +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); + (function() { /** diff --git a/src/render/Render.js b/src/render/Render.js index 2194e063..331c2a35 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -1,9 +1,3 @@ -var Common = require('../core/Common'); -var Composite = require('../body/Composite'); -var Bounds = require('../geometry/Bounds'); -var Events = require('../core/Events'); -var Grid = require('../collision/Grid'); - /** * The `Matter.Render` module is the default `render.controller` used by a `Matter.Engine`. * This renderer is HTML5 canvas based and supports a number of drawing options including sprites and viewports. @@ -20,6 +14,12 @@ var Render = {}; module.exports = Render; +var Common = require('../core/Common'); +var Composite = require('../body/Composite'); +var Bounds = require('../geometry/Bounds'); +var Events = require('../core/Events'); +var Grid = require('../collision/Grid'); + (function() { /**