From 00251e5b047ecd103adc2b6ccb4720661e9bc7c2 Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 4 Jun 2015 20:54:50 +0100 Subject: [PATCH] use browserify --- Gruntfile.js | 38 ++++++---------- package.json | 2 +- src/body/Body.js | 10 +++++ src/body/Composite.js | 6 +++ src/body/World.js | 6 +++ src/collision/Contact.js | 2 + src/collision/Detector.js | 6 +++ src/collision/Grid.js | 6 +++ src/collision/Pair.js | 4 ++ src/collision/Pairs.js | 5 +++ src/collision/Query.js | 8 ++++ src/collision/Resolver.js | 7 +++ src/collision/SAT.js | 5 +++ src/constraint/Constraint.js | 9 ++++ src/constraint/MouseConstraint.js | 12 +++++ src/core/Common.js | 2 + src/core/Engine.js | 15 +++++++ src/core/Events.js | 4 ++ src/core/Metrics.js | 4 ++ src/core/Mouse.js | 4 ++ src/core/Runner.js | 6 +++ src/core/Sleeping.js | 4 ++ src/factory/Bodies.js | 8 ++++ src/factory/Composites.js | 8 ++++ src/geometry/Axes.js | 5 +++ src/geometry/Bounds.js | 2 + src/geometry/Svg.js | 4 ++ src/geometry/Vector.js | 2 + src/geometry/Vertices.js | 5 +++ src/module/Intro.js | 33 -------------- src/module/Outro.js | 69 ---------------------------- src/module/main.js | 74 +++++++++++++++++++++++++++++++ src/render/Render.js | 7 +++ src/render/RenderPixi.js | 2 + 34 files changed, 256 insertions(+), 128 deletions(-) delete mode 100644 src/module/Intro.js delete mode 100644 src/module/Outro.js create mode 100644 src/module/main.js diff --git a/Gruntfile.js b/Gruntfile.js index 4384f19..b1d7423 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,23 +4,11 @@ module.exports = function(grunt) { buildName: 'matter', buildVersion: 'edge-master', docVersion: 'v<%= pkg.version %>', - concat: { - build: { - options: { - process: function(src, filepath) { - return '// Begin ' + filepath + '\n\n' + src + '\n\n; // End ' + filepath + '\n\n'; - } - }, - src: ['src/**/*.js', '!src/module/*'], - dest: 'build/<%= buildName %>.js' + browserify: { + options: { + banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n', }, - pack: { - options: { - banner: '/**\n* <%= buildName %>.js <%= buildVersion %> <%= grunt.template.today("yyyy-mm-dd") %>\n* <%= pkg.homepage %>\n* License: <%= pkg.license %>\n*/\n\n' - }, - src: ['src/module/Intro.js', 'build/<%= buildName %>.js', 'src/module/Outro.js'], - dest: 'build/<%= buildName %>.js' - } + 'build/<%= buildName %>.js': ['src/module/main.js'] }, uglify: { min: { @@ -49,9 +37,9 @@ module.exports = function(grunt) { }, copy: { demo: { - src: 'build/<%= buildName %>.js', - dest: 'demo/js/lib/<%= buildName %>.js' - } + src: 'build/<%= buildName %>.js', + dest: 'demo/js/lib/<%= buildName %>.js' + } }, jshint: { options: { @@ -110,7 +98,7 @@ module.exports = function(grunt) { } }); - grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-watch'); @@ -134,20 +122,20 @@ module.exports = function(grunt) { if (isDev) { grunt.config.set('buildName', 'matter-dev'); grunt.config.set('buildVersion', pkg.version + '-dev'); - grunt.task.run('concat', 'uglify:dev', 'uglify:min', 'copy'); + grunt.task.run('browserify', 'uglify:dev', 'uglify:min', 'copy'); } // release build mode if (isRelease) { grunt.config.set('buildName', 'matter-' + pkg.version); grunt.config.set('buildVersion', pkg.version + '-alpha'); - grunt.task.run('concat', 'uglify:min', 'copy'); + grunt.task.run('browserify', 'uglify:min', 'copy'); } // edge build mode (default) if (isEdge || (!isDev && !isRelease)) { grunt.config.set('buildVersion', 'edge-master'); - grunt.task.run('concat', 'preprocess', 'uglify:min'); + grunt.task.run('browserify', 'preprocess', 'uglify:min'); } }); @@ -158,11 +146,11 @@ module.exports = function(grunt) { if (isEdge) grunt.config.set('docVersion', 'edge version (master)'); - + grunt.task.run('yuidoc'); }); grunt.registerTask('set_config', 'Set a config property.', function(name, val) { grunt.config.set(name, val); }); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 98e8906..e05c383 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "devDependencies": { "grunt": "~0.4.2", - "grunt-contrib-concat": "~0.3.0", + "grunt-browserify": "~3.7.0", "grunt-contrib-connect": "~0.6.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-jshint": "~0.6.3", diff --git a/src/body/Body.js b/src/body/Body.js index c6fd9f8..b0ca5c4 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -1,3 +1,11 @@ +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`. @@ -11,6 +19,8 @@ var Body = {}; +module.exports = Body; + (function() { Body._inertiaScale = 4; diff --git a/src/body/Composite.js b/src/body/Composite.js index 962576f..076353b 100644 --- a/src/body/Composite.js +++ b/src/body/Composite.js @@ -1,3 +1,7 @@ +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. @@ -12,6 +16,8 @@ var Composite = {}; +module.exports = Composite; + (function() { /** diff --git a/src/body/World.js b/src/body/World.js index 5082156..3823ed5 100644 --- a/src/body/World.js +++ b/src/body/World.js @@ -1,3 +1,7 @@ +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`. @@ -14,6 +18,8 @@ var World = {}; +module.exports = World; + (function() { /** diff --git a/src/collision/Contact.js b/src/collision/Contact.js index be2c6dd..43e2e17 100644 --- a/src/collision/Contact.js +++ b/src/collision/Contact.js @@ -6,6 +6,8 @@ var Contact = {}; +module.exports = Contact; + (function() { /** diff --git a/src/collision/Detector.js b/src/collision/Detector.js index ef1150d..d6c79fb 100644 --- a/src/collision/Detector.js +++ b/src/collision/Detector.js @@ -1,3 +1,7 @@ +var SAT = require('./SAT'); +var Pair = require('./Pair'); +var Bounds = require('../geometry/Bounds'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -8,6 +12,8 @@ var Detector = {}; +module.exports = Detector; + (function() { /** diff --git a/src/collision/Grid.js b/src/collision/Grid.js index 1b04571..bac5fe7 100644 --- a/src/collision/Grid.js +++ b/src/collision/Grid.js @@ -1,3 +1,7 @@ +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. @@ -7,6 +11,8 @@ var Grid = {}; +module.exports = Grid; + (function() { /** diff --git a/src/collision/Pair.js b/src/collision/Pair.js index dcee2a1..dc58a27 100644 --- a/src/collision/Pair.js +++ b/src/collision/Pair.js @@ -1,3 +1,5 @@ +var Contact = require('./Contact'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +8,8 @@ var Pair = {}; +module.exports = Pair; + (function() { /** diff --git a/src/collision/Pairs.js b/src/collision/Pairs.js index 5e7207a..3591d79 100644 --- a/src/collision/Pairs.js +++ b/src/collision/Pairs.js @@ -1,3 +1,6 @@ +var Pair = require('./Pair'); +var Common = require('../core/Common'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +9,8 @@ var Pairs = {}; +module.exports = Pairs; + (function() { var _pairMaxIdleLife = 1000; diff --git a/src/collision/Query.js b/src/collision/Query.js index 15bd0c7..242f680 100644 --- a/src/collision/Query.js +++ b/src/collision/Query.js @@ -1,3 +1,9 @@ +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. * @@ -6,6 +12,8 @@ var Query = {}; +module.exports = Query; + (function() { /** diff --git a/src/collision/Resolver.js b/src/collision/Resolver.js index 632642e..63a688f 100644 --- a/src/collision/Resolver.js +++ b/src/collision/Resolver.js @@ -1,3 +1,8 @@ +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. * @@ -6,6 +11,8 @@ var Resolver = {}; +module.exports = Resolver; + (function() { Resolver._restingThresh = 4; diff --git a/src/collision/SAT.js b/src/collision/SAT.js index f4d0d21..376c5bb 100644 --- a/src/collision/SAT.js +++ b/src/collision/SAT.js @@ -1,3 +1,6 @@ +var Vertices = require('../geometry/Vertices'); +var Vector = require('../geometry/Vector'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -8,6 +11,8 @@ var SAT = {}; +module.exports = SAT; + (function() { /** diff --git a/src/constraint/Constraint.js b/src/constraint/Constraint.js index 9ab4ff2..4713256 100644 --- a/src/constraint/Constraint.js +++ b/src/constraint/Constraint.js @@ -1,3 +1,10 @@ +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). @@ -19,6 +26,8 @@ var Constraint = {}; +module.exports = Constraint; + (function() { var _minLength = 0.000001, diff --git a/src/constraint/MouseConstraint.js b/src/constraint/MouseConstraint.js index 3c5f1ed..59ba345 100644 --- a/src/constraint/MouseConstraint.js +++ b/src/constraint/MouseConstraint.js @@ -1,3 +1,13 @@ +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. @@ -10,6 +20,8 @@ var MouseConstraint = {}; +module.exports = MouseConstraint; + (function() { /** diff --git a/src/core/Common.js b/src/core/Common.js index 0dd0c43..421f15a 100644 --- a/src/core/Common.js +++ b/src/core/Common.js @@ -6,6 +6,8 @@ var Common = {}; +module.exports = Common; + (function() { Common._nextId = 0; diff --git a/src/core/Engine.js b/src/core/Engine.js index d318574..9797bfd 100644 --- a/src/core/Engine.js +++ b/src/core/Engine.js @@ -1,3 +1,16 @@ +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 and rendering the simulation of the world. @@ -11,6 +24,8 @@ var Engine = {}; +module.exports = Engine; + (function() { var _fps = 60, diff --git a/src/core/Events.js b/src/core/Events.js index 1e87d36..359f3e1 100644 --- a/src/core/Events.js +++ b/src/core/Events.js @@ -1,3 +1,5 @@ +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. @@ -7,6 +9,8 @@ var Events = {}; +module.exports = Events; + (function() { /** diff --git a/src/core/Metrics.js b/src/core/Metrics.js index 03d3eb9..46cded6 100644 --- a/src/core/Metrics.js +++ b/src/core/Metrics.js @@ -1,4 +1,6 @@ // @if DEBUG +var Composite = require('../body/Composite'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +8,8 @@ var Metrics = {}; +module.exports = Metrics; + (function() { /** diff --git a/src/core/Mouse.js b/src/core/Mouse.js index 98e69dc..1aa7dca 100644 --- a/src/core/Mouse.js +++ b/src/core/Mouse.js @@ -1,3 +1,5 @@ +var Common = require('../core/Common'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +8,8 @@ var Mouse = {}; +module.exports = Mouse; + (function() { /** diff --git a/src/core/Runner.js b/src/core/Runner.js index dd35e4a..8461789 100644 --- a/src/core/Runner.js +++ b/src/core/Runner.js @@ -1,3 +1,7 @@ +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. @@ -11,6 +15,8 @@ var Runner = {}; +module.exports = Runner; + (function() { var _fps = 60, diff --git a/src/core/Sleeping.js b/src/core/Sleeping.js index 799ec11..3ecad0c 100644 --- a/src/core/Sleeping.js +++ b/src/core/Sleeping.js @@ -1,3 +1,5 @@ +var Events = require('./Events'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +8,8 @@ var Sleeping = {}; +module.exports = Sleeping; + (function() { Sleeping._motionWakeThreshold = 0.18; diff --git a/src/factory/Bodies.js b/src/factory/Bodies.js index 4d1b74a..a698b11 100644 --- a/src/factory/Bodies.js +++ b/src/factory/Bodies.js @@ -1,3 +1,9 @@ +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). @@ -12,6 +18,8 @@ var Bodies = {}; +module.exports = Bodies; + (function() { /** diff --git a/src/factory/Composites.js b/src/factory/Composites.js index 63d9607..f01c5fb 100644 --- a/src/factory/Composites.js +++ b/src/factory/Composites.js @@ -1,3 +1,9 @@ +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. @@ -7,6 +13,8 @@ var Composites = {}; +module.exports = Composites; + (function() { /** diff --git a/src/geometry/Axes.js b/src/geometry/Axes.js index 709099c..eba3135 100644 --- a/src/geometry/Axes.js +++ b/src/geometry/Axes.js @@ -1,3 +1,6 @@ +var Vector = require('../geometry/Vector'); +var Common = require('../core/Common'); + /** * _Internal Class_, not generally used outside of the engine's internals. * @@ -6,6 +9,8 @@ var Axes = {}; +module.exports = Axes; + (function() { /** diff --git a/src/geometry/Bounds.js b/src/geometry/Bounds.js index 31a1baf..cb942d7 100644 --- a/src/geometry/Bounds.js +++ b/src/geometry/Bounds.js @@ -6,6 +6,8 @@ var Bounds = {}; +module.exports = Bounds; + (function() { /** diff --git a/src/geometry/Svg.js b/src/geometry/Svg.js index 49c2b63..a3449ad 100644 --- a/src/geometry/Svg.js +++ b/src/geometry/Svg.js @@ -1,3 +1,5 @@ +var Bounds = require('../geometry/Bounds'); + /** * The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. * @@ -9,6 +11,8 @@ var Svg = {}; +module.exports = Svg; + (function() { /** diff --git a/src/geometry/Vector.js b/src/geometry/Vector.js index 3cf1939..57c48bf 100644 --- a/src/geometry/Vector.js +++ b/src/geometry/Vector.js @@ -13,6 +13,8 @@ var Vector = {}; +module.exports = Vector; + (function() { /** diff --git a/src/geometry/Vertices.js b/src/geometry/Vertices.js index 95678ad..f6ea829 100644 --- a/src/geometry/Vertices.js +++ b/src/geometry/Vertices.js @@ -1,3 +1,6 @@ +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`. @@ -11,6 +14,8 @@ var Vertices = {}; +module.exports = Vertices; + (function() { /** diff --git a/src/module/Intro.js b/src/module/Intro.js deleted file mode 100644 index 61e5ec7..0000000 --- a/src/module/Intro.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2014 Liam Brummitt - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -(function() { - -var Matter = {}; - -// Begin Matter namespace closure - -// All Matter modules are included below during build -// Outro.js then closes at the end of the file - diff --git a/src/module/Outro.js b/src/module/Outro.js deleted file mode 100644 index 6d9360d..0000000 --- a/src/module/Outro.js +++ /dev/null @@ -1,69 +0,0 @@ -// aliases - -World.add = Composite.add; -World.remove = Composite.remove; -World.addComposite = Composite.addComposite; -World.addBody = Composite.addBody; -World.addConstraint = Composite.addConstraint; -World.clear = Composite.clear; - -Engine.run = Runner.run; - -// exports - -Matter.Body = Body; -Matter.Composite = Composite; -Matter.World = World; -Matter.Contact = Contact; -Matter.Detector = Detector; -Matter.Grid = Grid; -Matter.Pairs = Pairs; -Matter.Pair = Pair; -Matter.Resolver = Resolver; -Matter.SAT = SAT; -Matter.Constraint = Constraint; -Matter.MouseConstraint = MouseConstraint; -Matter.Common = Common; -Matter.Engine = Engine; -Matter.Mouse = Mouse; -Matter.Sleeping = Sleeping; -Matter.Bodies = Bodies; -Matter.Composites = Composites; -Matter.Axes = Axes; -Matter.Bounds = Bounds; -Matter.Vector = Vector; -Matter.Vertices = Vertices; -Matter.Render = Render; -Matter.RenderPixi = RenderPixi; -Matter.Events = Events; -Matter.Query = Query; -Matter.Runner = Runner; -Matter.Svg = Svg; - -// @if DEBUG -Matter.Metrics = Metrics; -// @endif - -// CommonJS module -if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = Matter; - } - exports.Matter = Matter; -} - -// AMD module -if (typeof define === 'function' && define.amd) { - define('Matter', [], function () { - return Matter; - }); -} - -// browser -if (typeof window === 'object' && typeof window.document === 'object') { - window.Matter = Matter; -} - -// End Matter namespace closure - -})(); \ No newline at end of file diff --git a/src/module/main.js b/src/module/main.js new file mode 100644 index 0000000..e06599b --- /dev/null +++ b/src/module/main.js @@ -0,0 +1,74 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2014 Liam Brummitt + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +Matter = module.exports = {}; + +Matter.Body = require('../body/Body'); +Matter.Composite = require('../body/Composite'); +Matter.World = require('../body/World'); + +Matter.Contact = require('../collision/Contact'); +Matter.Detector = require('../collision/Detector'); +Matter.Grid = require('../collision/Grid'); +Matter.Pairs = require('../collision/Pairs'); +Matter.Pair = require('../collision/Pair'); +Matter.Query = require('../collision/Query'); +Matter.Resolver = require('../collision/Resolver'); +Matter.SAT = require('../collision/SAT'); + +Matter.Constraint = require('../constraint/Constraint'); +Matter.MouseConstraint = require('../constraint/MouseConstraint'); + +Matter.Common = require('../core/Common'); +Matter.Engine = require('../core/Engine'); +Matter.Events = require('../core/Events'); +Matter.Mouse = require('../core/Mouse'); +Matter.Runner = require('../core/Runner'); +Matter.Sleeping = require('../core/Sleeping'); + +// @if DEBUG +Matter.Metrics = require('../core/Metrics'); +// @endif + +Matter.Bodies = require('../factory/Bodies'); +Matter.Composites = require('../factory/Composites'); + +Matter.Axes = require('../geometry/Axes'); +Matter.Bounds = require('../geometry/Bounds'); +Matter.Svg = require('../geometry/Svg'); +Matter.Vector = require('../geometry/Vector'); +Matter.Vertices = require('../geometry/Vertices'); + +Matter.Render = require('../render/Render'); +Matter.RenderPixi = require('../render/RenderPixi'); + +// aliases + +Matter.World.add = Matter.Composite.add; +Matter.World.remove = Matter.Composite.remove; +Matter.World.addComposite = Matter.Composite.addComposite; +Matter.World.addBody = Matter.Composite.addBody; +Matter.World.addConstraint = Matter.Composite.addConstraint; +Matter.World.clear = Matter.Composite.clear; +Matter.Engine.run = Matter.Runner.run; \ No newline at end of file diff --git a/src/render/Render.js b/src/render/Render.js index 06f0f7c..d4c9bf8 100644 --- a/src/render/Render.js +++ b/src/render/Render.js @@ -1,3 +1,8 @@ +var Common = require('../core/Common'); +var Composite = require('../body/Composite'); +var Bounds = require('../geometry/Bounds'); +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. @@ -12,6 +17,8 @@ var Render = {}; +module.exports = Render; + (function() { /** diff --git a/src/render/RenderPixi.js b/src/render/RenderPixi.js index fe919b6..04ab813 100644 --- a/src/render/RenderPixi.js +++ b/src/render/RenderPixi.js @@ -7,6 +7,8 @@ var RenderPixi = {}; +module.exports = RenderPixi; + (function() { /**