-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
45 lines (38 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"use strict";
const Matter = require('matter-js');
/**
* An example plugin for matter.js.
* @module PluginExample
*/
const PluginExample = {
// plugin meta
name: 'matter-dom-plugin', // PLUGIN_NAME
version: '0.1.2', // PLUGIN_VERSION
for: 'matter-js@^0.12.0',
// installs the plugin where `base` is `Matter`
// you should not need to call this directly.
install: function(base) {
// after Matter.Body.create call our plugin init function
base.after('Body.create', function() {
PluginExample.Body.init(this);
});
},
Body: {
/**
* Example function that removes friction every created body.
* Automatically called by the plugin.
* @function PluginExample.Body.init
* @param {Matter.Body} body The body to init.
* @returns {void} No return value.
*/
init: function(body) {
body.friction = 0;
}
}
};
Matter.Plugin.register(PluginExample);
module.exports = PluginExample;
/**
* @namespace Matter.Body
* @see http://brm.io/matter-js/docs/classes/Body.html
*/