From 3fdf3430154152a2960e1231fe672fb030483737 Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 24 Jan 2017 20:34:26 +0000 Subject: [PATCH] changed plugins to use body.plugin --- examples/attractors.js | 10 ++++++---- examples/attractorsPlugin.js | 2 ++ examples/avalanche.js | 2 +- examples/ballPool.js | 2 +- examples/gravityPlugin.js | 6 ++++-- examples/wrapPlugin.js | 6 ++++-- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/attractors.js b/examples/attractors.js index ca6b04f..d5c019b 100644 --- a/examples/attractors.js +++ b/examples/attractors.js @@ -53,11 +53,13 @@ Example.attractors = function() { radius, { mass: Common.random(10, 15), - gravity: G, frictionAir: 0, - wrap: { - min: { x: 0, y: 0 }, - max: { x: render.options.width, y: render.options.height } + plugin: { + gravity: G, + wrap: { + min: { x: 0, y: 0 }, + max: { x: render.options.width, y: render.options.height } + } } } ); diff --git a/examples/attractorsPlugin.js b/examples/attractorsPlugin.js index 7ee2497..aabe558 100644 --- a/examples/attractorsPlugin.js +++ b/examples/attractorsPlugin.js @@ -1,3 +1,5 @@ +// NOTE: this plugin will be moved to its own repo + (function() { var MatterAttractors = { diff --git a/examples/avalanche.js b/examples/avalanche.js index f54f1a8..174748c 100644 --- a/examples/avalanche.js +++ b/examples/avalanche.js @@ -72,7 +72,7 @@ Example.avalanche = function() { // wrapping using matter-wrap plugin for (var i = 0; i < stack.bodies.length; i += 1) { - stack.bodies[i].wrap = { + stack.bodies[i].plugin.wrap = { min: { x: render.bounds.min.x, y: render.bounds.min.y }, max: { x: render.bounds.max.x, y: render.bounds.max.y } }; diff --git a/examples/ballPool.js b/examples/ballPool.js index c74468c..7d60b55 100644 --- a/examples/ballPool.js +++ b/examples/ballPool.js @@ -80,7 +80,7 @@ Example.ballPool = function() { var allBodies = Composite.allBodies(world); for (var i = 0; i < allBodies.length; i += 1) { - allBodies[i].wrap = { + allBodies[i].plugin.wrap = { min: { x: render.bounds.min.x - 100, y: render.bounds.min.y }, max: { x: render.bounds.max.x + 100, y: render.bounds.max.y } }; diff --git a/examples/gravityPlugin.js b/examples/gravityPlugin.js index 971ede8..1076c52 100644 --- a/examples/gravityPlugin.js +++ b/examples/gravityPlugin.js @@ -1,3 +1,5 @@ +// NOTE: this plugin will be moved to its own repo + (function() { var MatterGravity = { @@ -19,7 +21,7 @@ Body: { init: function(body) { - if (body.gravity) { + if (body.plugin.gravity) { body.attractors.push(MatterGravity.Body.applyGravity); } }, @@ -28,7 +30,7 @@ var bToA = Matter.Vector.sub(bodyB.position, bodyA.position), distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001, normal = Matter.Vector.normalise(bToA), - magnitude = -bodyA.gravity * (bodyA.mass * bodyB.mass / distanceSq), + magnitude = -bodyA.plugin.gravity * (bodyA.mass * bodyB.mass / distanceSq), force = Matter.Vector.mult(normal, magnitude); Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force)); diff --git a/examples/wrapPlugin.js b/examples/wrapPlugin.js index 2749a99..220c70d 100644 --- a/examples/wrapPlugin.js +++ b/examples/wrapPlugin.js @@ -1,3 +1,5 @@ +// NOTE: this plugin will be moved to its own repo + (function() { var MatterWrap = { @@ -21,8 +23,8 @@ for (var i = 0; i < bodies.length; i += 1) { var body = bodies[i]; - if (body.wrap) { - MatterWrap.Body.wrap(body, body.wrap); + if (body.plugin.wrap) { + MatterWrap.Body.wrap(body, body.plugin.wrap); } } }