UNPKG

matter-js

Version:

a 2D rigid body physics engine for the web

39 lines (32 loc) 764 B
/** * The `Matter.Contact` module contains methods for creating and manipulating collision contacts. * * @class Contact */ var Contact = {}; module.exports = Contact; (function() { /** * Creates a new contact. * @method create * @param {vertex} vertex * @return {contact} A new contact */ Contact.create = function(vertex) { return { id: Contact.id(vertex), vertex: vertex, normalImpulse: 0, tangentImpulse: 0 }; }; /** * Generates a contact id. * @method id * @param {vertex} vertex * @return {string} Unique contactID */ Contact.id = function(vertex) { return vertex.body.id + '_' + vertex.index; }; })();