0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-28 14:09:01 -05:00

added module export to examples

This commit is contained in:
liabru 2019-09-14 18:54:50 +01:00
parent 6b698ea2f6
commit f9ea7995bf
44 changed files with 347 additions and 122 deletions

View file

@ -79,3 +79,7 @@ Example.airFriction = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -90,3 +90,7 @@ Example.avalanche = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -98,3 +98,7 @@ Example.ballPool = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -123,3 +123,7 @@ Example.bridge = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -94,3 +94,7 @@ Example.broadphase = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -88,3 +88,7 @@ Example.car = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -95,3 +95,7 @@ Example.catapult = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -121,3 +121,7 @@ Example.chains = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -80,3 +80,7 @@ Example.circleStack = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -83,3 +83,7 @@ Example.cloth = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -154,3 +154,7 @@ Example.collisionFiltering = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -106,3 +106,7 @@ Example.compositeManipulation = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -105,3 +105,7 @@ Example.compound = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -88,3 +88,7 @@ Example.compoundStack = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -94,3 +94,7 @@ Example.concave = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -178,3 +178,7 @@ Example.constraints = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -151,3 +151,7 @@ Example.doublePendulum = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -177,3 +177,7 @@ Example.events = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -89,3 +89,7 @@ Example.friction = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -95,3 +95,7 @@ Example.gravity = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -68,6 +68,7 @@ Example.gyro = function() {
]);
// add gyro control
if (typeof window !== 'undefined') {
var updateGravity = function(event) {
var orientation = typeof window.orientation !== 'undefined' ? window.orientation : 0,
gravity = engine.world.gravity;
@ -88,6 +89,7 @@ Example.gyro = function() {
};
window.addEventListener('deviceorientation', updateGravity);
}
// add mouse control
var mouse = Mouse.create(render.canvas),
@ -121,7 +123,13 @@ Example.gyro = function() {
stop: function() {
Matter.Render.stop(render);
Matter.Runner.stop(runner);
if (typeof window !== 'undefined') {
window.removeEventListener('deviceorientation', updateGravity);
}
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

45
examples/index.js Normal file
View file

@ -0,0 +1,45 @@
module.exports = {
airFriction: require('./airFriction.js'),
avalanche: require('./avalanche.js'),
ballPool: require('./ballPool.js'),
bridge: require('./bridge.js'),
broadphase: require('./broadphase.js'),
car: require('./car.js'),
catapult: require('./catapult.js'),
chains: require('./chains.js'),
circleStack: require('./circleStack.js'),
cloth: require('./cloth.js'),
collisionFiltering: require('./collisionFiltering.js'),
compositeManipulation: require('./compositeManipulation.js'),
compound: require('./compound.js'),
compoundStack: require('./compoundStack.js'),
concave: require('./concave.js'),
constraints: require('./constraints.js'),
doublePendulum: require('./doublePendulum.js'),
events: require('./events.js'),
friction: require('./friction.js'),
gravity: require('./gravity.js'),
gyro: require('./gyro.js'),
manipulation: require('./manipulation.js'),
mixed: require('./mixed.js'),
newtonsCradle: require('./newtonsCradle.js'),
ragdoll: require('./ragdoll.js'),
pyramid: require('./pyramid.js'),
raycasting: require('./raycasting.js'),
restitution: require('./restitution.js'),
rounded: require('./rounded.js'),
sensors: require('./sensors.js'),
sleeping: require('./sleeping.js'),
slingshot: require('./slingshot.js'),
softBody: require('./softBody.js'),
sprites: require('./sprites.js'),
stack: require('./stack.js'),
staticFriction: require('./staticFriction.js'),
stress: require('./stress.js'),
stress2: require('./stress2.js'),
svg: require('./svg.js'),
terrain: require('./terrain.js'),
timescale: require('./timescale.js'),
views: require('./views.js'),
wreckingBall: require('./wreckingBall.js')
};

View file

@ -139,3 +139,7 @@ Example.manipulation = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -104,3 +104,7 @@ Example.mixed = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -75,3 +75,7 @@ Example.newtonsCradle = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -80,3 +80,7 @@ Example.pyramid = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -496,3 +496,7 @@ Example.ragdoll.ragdoll = function(x, y, scale, options) {
return person;
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -134,3 +134,7 @@ Example.raycasting = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -84,3 +84,7 @@ Example.restitution = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -108,3 +108,7 @@ Example.rounded = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -130,3 +130,7 @@ Example.sensors = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -103,3 +103,7 @@ Example.sleeping = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -99,3 +99,7 @@ Example.slingshot = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -84,3 +84,7 @@ Example.softBody = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -112,3 +112,7 @@ Example.sprites = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -80,3 +80,7 @@ Example.stack = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -105,3 +105,7 @@ Example.staticFriction = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -78,3 +78,7 @@ Example.stress = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -78,3 +78,7 @@ Example.stress2 = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -40,6 +40,7 @@ Example.svg = function() {
'iconmonstr-user-icon'
];
if (typeof $ !== 'undefined') {
for (var i = 0; i < svgs.length; i += 1) {
(function(i) {
$.get('./svg/' + svgs[i] + '.svg').done(function(data) {
@ -78,6 +79,7 @@ Example.svg = function() {
}
}, true));
});
}
World.add(world, [
Bodies.rectangle(400, 0, 800, 50, { isStatic: true }),
@ -121,3 +123,7 @@ Example.svg = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -36,6 +36,7 @@ Example.terrain = function() {
// add bodies
var terrain;
if (typeof $ !== 'undefined') {
$.get('./svg/terrain.svg').done(function(data) {
var vertexSets = [];
@ -66,6 +67,7 @@ Example.terrain = function() {
}
}));
});
}
// add mouse control
var mouse = Mouse.create(render.canvas),
@ -102,3 +104,7 @@ Example.terrain = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example;
}

View file

@ -150,3 +150,7 @@ Example.timescale = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -181,3 +181,7 @@ Example.views = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}

View file

@ -92,3 +92,7 @@ Example.wreckingBall = function() {
}
};
};
if (typeof module !== 'undefined' && module.exports) {
module.exports = Example[Object.keys(Example)[0]];
}