Skip to content

Commit 3fdf343

Browse files
committed
changed plugins to use body.plugin
1 parent b353393 commit 3fdf343

6 files changed

Lines changed: 18 additions & 10 deletions

File tree

examples/attractors.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ Example.attractors = function() {
5353
radius,
5454
{
5555
mass: Common.random(10, 15),
56-
gravity: G,
5756
frictionAir: 0,
58-
wrap: {
59-
min: { x: 0, y: 0 },
60-
max: { x: render.options.width, y: render.options.height }
57+
plugin: {
58+
gravity: G,
59+
wrap: {
60+
min: { x: 0, y: 0 },
61+
max: { x: render.options.width, y: render.options.height }
62+
}
6163
}
6264
}
6365
);

examples/attractorsPlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// NOTE: this plugin will be moved to its own repo
2+
13
(function() {
24

35
var MatterAttractors = {

examples/avalanche.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Example.avalanche = function() {
7272

7373
// wrapping using matter-wrap plugin
7474
for (var i = 0; i < stack.bodies.length; i += 1) {
75-
stack.bodies[i].wrap = {
75+
stack.bodies[i].plugin.wrap = {
7676
min: { x: render.bounds.min.x, y: render.bounds.min.y },
7777
max: { x: render.bounds.max.x, y: render.bounds.max.y }
7878
};

examples/ballPool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Example.ballPool = function() {
8080
var allBodies = Composite.allBodies(world);
8181

8282
for (var i = 0; i < allBodies.length; i += 1) {
83-
allBodies[i].wrap = {
83+
allBodies[i].plugin.wrap = {
8484
min: { x: render.bounds.min.x - 100, y: render.bounds.min.y },
8585
max: { x: render.bounds.max.x + 100, y: render.bounds.max.y }
8686
};

examples/gravityPlugin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// NOTE: this plugin will be moved to its own repo
2+
13
(function() {
24

35
var MatterGravity = {
@@ -19,7 +21,7 @@
1921

2022
Body: {
2123
init: function(body) {
22-
if (body.gravity) {
24+
if (body.plugin.gravity) {
2325
body.attractors.push(MatterGravity.Body.applyGravity);
2426
}
2527
},
@@ -28,7 +30,7 @@
2830
var bToA = Matter.Vector.sub(bodyB.position, bodyA.position),
2931
distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001,
3032
normal = Matter.Vector.normalise(bToA),
31-
magnitude = -bodyA.gravity * (bodyA.mass * bodyB.mass / distanceSq),
33+
magnitude = -bodyA.plugin.gravity * (bodyA.mass * bodyB.mass / distanceSq),
3234
force = Matter.Vector.mult(normal, magnitude);
3335

3436
Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force));

examples/wrapPlugin.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// NOTE: this plugin will be moved to its own repo
2+
13
(function() {
24

35
var MatterWrap = {
@@ -21,8 +23,8 @@
2123
for (var i = 0; i < bodies.length; i += 1) {
2224
var body = bodies[i];
2325

24-
if (body.wrap) {
25-
MatterWrap.Body.wrap(body, body.wrap);
26+
if (body.plugin.wrap) {
27+
MatterWrap.Body.wrap(body, body.plugin.wrap);
2628
}
2729
}
2830
}

0 commit comments

Comments
 (0)