Skip to content

Commit

Permalink
release 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 6, 2017
1 parent 774d8bc commit 63b02cf
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 109 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,50 @@
<a name="0.13.0"></a>
# 0.13.0 (2017-07-06)

* added Composite.bounds ([79ffcf8](https://github.com/liabru/matter-js/commit/79ffcf8))
* added constraint damping ([44c4d1f](https://github.com/liabru/matter-js/commit/44c4d1f))
* added constraint.render.type and constraint.render.anchor ([0952516](https://github.com/liabru/matter-js/commit/0952516))
* added Example.constraints ([b93c08f](https://github.com/liabru/matter-js/commit/b93c08f))
* added Example.doublePendulum ([a7aa47d](https://github.com/liabru/matter-js/commit/a7aa47d))
* added Examples.ragdoll ([48611c5](https://github.com/liabru/matter-js/commit/48611c5))
* added optional output argument to Vector.rotate ([59d62be](https://github.com/liabru/matter-js/commit/59d62be))
* added rotation point parameter to Body.rotate, closes #410 ([749ed50](https://github.com/liabru/matter-js/commit/749ed50)), closes [#410](https://github.com/liabru/matter-js/issues/410)
* added second pass for constraint solving ([f49d053](https://github.com/liabru/matter-js/commit/f49d053))
* change constraint solve order ([a5bd6b2](https://github.com/liabru/matter-js/commit/a5bd6b2))
* changed lint rules ([d1fbe95](https://github.com/liabru/matter-js/commit/d1fbe95))
* fix constraint.angularStiffness ([ab0283b](https://github.com/liabru/matter-js/commit/ab0283b))
* fix Example.collisionFiltering rendering ([74a7cfc](https://github.com/liabru/matter-js/commit/74a7cfc))
* fix lint errors ([774d8bc](https://github.com/liabru/matter-js/commit/774d8bc))
* fix soft body stiffness ([1bae2de](https://github.com/liabru/matter-js/commit/1bae2de))
* fixed Common.now ([2b76c4c](https://github.com/liabru/matter-js/commit/2b76c4c))
* fixed constraint torque calculation ([a8d1950](https://github.com/liabru/matter-js/commit/a8d1950))
* fixed constraint torque calculation ([068fdc0](https://github.com/liabru/matter-js/commit/068fdc0))
* fixed Examples.compound constraint offset ([e6babf0](https://github.com/liabru/matter-js/commit/e6babf0))
* fixed various constraints in examples ([ac67ef8](https://github.com/liabru/matter-js/commit/ac67ef8))
* fixed various problems with constraints ([26a60e4](https://github.com/liabru/matter-js/commit/26a60e4))
* implemented constraint warming ([daf26af](https://github.com/liabru/matter-js/commit/daf26af))
* improved Example.car using pin constraint ([130e6b3](https://github.com/liabru/matter-js/commit/130e6b3))
* improved Example.catapult using pin constraint ([0e15099](https://github.com/liabru/matter-js/commit/0e15099))
* improved Example.chains using pin constraint ([9d2f0ff](https://github.com/liabru/matter-js/commit/9d2f0ff))
* improved Examples.bridge ([b277b39](https://github.com/liabru/matter-js/commit/b277b39))
* improved Examples.bridge ([b6e5973](https://github.com/liabru/matter-js/commit/b6e5973))
* improved position resolver ([71998a0](https://github.com/liabru/matter-js/commit/71998a0))
* improved spring and pin rendering ([837c43b](https://github.com/liabru/matter-js/commit/837c43b))
* refactored Common.isElement ([295cffe](https://github.com/liabru/matter-js/commit/295cffe))
* removed Common.shadeColor ([d63b0c2](https://github.com/liabru/matter-js/commit/d63b0c2))
* tweaked Example.doublePendulum ([4894008](https://github.com/liabru/matter-js/commit/4894008))
* update alpha build ([fe9b05d](https://github.com/liabru/matter-js/commit/fe9b05d))
* update alpha build ([b874f4d](https://github.com/liabru/matter-js/commit/b874f4d))
* update alpha build ([08aa3f2](https://github.com/liabru/matter-js/commit/08aa3f2))
* update readme and remove redundant plugins ([2560a68](https://github.com/liabru/matter-js/commit/2560a68))
* Update README.md ([4168d3c](https://github.com/liabru/matter-js/commit/4168d3c))
* updated license and contributing ([d2af721](https://github.com/liabru/matter-js/commit/d2af721))
* updated readme ([26c1200](https://github.com/liabru/matter-js/commit/26c1200))
* upgraded matter-tools ([477f2d7](https://github.com/liabru/matter-js/commit/477f2d7))
* upgraded matter-wrap ([c9294eb](https://github.com/liabru/matter-js/commit/c9294eb))



<a name="0.12.0"></a>
# 0.12.0 (2017-02-02)

Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "Matter",
"version": "0.12.0",
"version": "0.13.0",
"homepage": "https://github.com/liabru/matter-js",
"authors": [
"Liam Brummitt <liam@brm.io> (http://brm.io/)"
Expand Down
126 changes: 57 additions & 69 deletions build/matter.js
@@ -1,13 +1,13 @@
/**
* matter-js 0.12.0-alpha by @liabru 2017-06-26
* matter-js 0.13.0 by @liabru 2017-07-06
* http://brm.io/matter-js/
* License MIT
*/

/**
* The MIT License (MIT)
*
* Copyright (c) 2014 Liam Brummitt
* Copyright (c) Liam Brummitt and contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -185,7 +185,7 @@ var Axes = _dereq_('../geometry/Axes');

// render properties
var defaultFillStyle = (body.isStatic ? '#2e2b44' : Common.choose(['#006BA6', '#0496FF', '#FFBC42', '#D81159', '#8F2D56'])),
defaultStrokeStyle = Common.shadeColor(defaultFillStyle, -20);
defaultStrokeStyle = '#000';
body.render.fillStyle = body.render.fillStyle || defaultFillStyle;
body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle;
body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
Expand Down Expand Up @@ -672,6 +672,7 @@ var Axes = _dereq_('../geometry/Axes');
* @return {}
*/
var _totalProperties = function(body) {
// from equations at:
// https://ecourses.ou.edu/cgi-bin/ebook.cgi?doc=&topic=st&chap_sec=07.2&page=theory
// http://output.to/sideway/default.asp?qno=121100087

Expand Down Expand Up @@ -1155,7 +1156,7 @@ var Axes = _dereq_('../geometry/Axes');
*
* @property render.lineWidth
* @type number
* @default 1.5
* @default 0
*/

/**
Expand Down Expand Up @@ -1738,6 +1739,24 @@ var Body = _dereq_('./Body');
return composite;
};

/**
* Returns the union of the bounds of all of the composite's bodies.
* @method bounds
* @param {composite} composite The composite.
* @returns {bounds} The composite bounds.
*/
Composite.bounds = function(composite) {
var bodies = Matter.Composite.allBodies(composite),
vertices = [];

for (var i = 0; i < bodies.length; i += 1) {
var body = bodies[i];
vertices.push(body.bounds.min, body.bounds.max);
}

return Matter.Bounds.create(vertices);
};

/*
*
* Events Documentation
Expand Down Expand Up @@ -2946,7 +2965,7 @@ var Bounds = _dereq_('../geometry/Bounds');
for (i = 0; i < pairs.length; i++) {
pair = pairs[i];

if (!pair.isActive || pair.isSensor || pair.separation < 0)
if (!pair.isActive || pair.isSensor)
continue;

collision = pair.collision;
Expand Down Expand Up @@ -3546,7 +3565,7 @@ var Common = _dereq_('../core/Common');
anchors: true
};

if (constraint.length === 0) {
if (constraint.length === 0 && constraint.stiffness > 0.1) {
render.type = 'pin';
render.anchors = false;
} else if (constraint.stiffness < 0.9) {
Expand Down Expand Up @@ -4204,6 +4223,7 @@ module.exports = Common;

Common._nextId = 0;
Common._seed = 0;
Common._nowStartTime = +(new Date());

/**
* Extends the object in the first argument using the object in the second argument.
Expand Down Expand Up @@ -4333,25 +4353,6 @@ module.exports = Common;
return val;
};

/**
* Returns a hex colour string made by lightening or darkening color by percent.
* @method shadeColor
* @param {string} color
* @param {number} percent
* @return {string} A hex colour
*/
Common.shadeColor = function(color, percent) {
// http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color
var colorInteger = parseInt(color.slice(1),16),
amount = Math.round(2.55 * percent),
R = (colorInteger >> 16) + amount,
B = (colorInteger >> 8 & 0x00FF) + amount,
G = (colorInteger & 0x0000FF) + amount;
return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R :255) * 0x10000
+ (B < 255 ? B < 1 ? 0 : B : 255) * 0x100
+ (G < 255 ? G < 1 ? 0 : G : 255)).toString(16).slice(1);
};

/**
* Shuffles the given array in-place.
* The function uses a seeded random generator.
Expand Down Expand Up @@ -4387,15 +4388,7 @@ module.exports = Common;
* @return {boolean} True if the object is a HTMLElement, otherwise false
*/
Common.isElement = function(obj) {
// http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
try {
return obj instanceof HTMLElement;
}
catch(e){
return (typeof obj==="object") &&
(obj.nodeType===1) && (typeof obj.style === "object") &&
(typeof obj.ownerDocument ==="object");
}
return obj instanceof HTMLElement;
};

/**
Expand Down Expand Up @@ -4465,26 +4458,21 @@ module.exports = Common;
};

/**
* Returns the current timestamp (high-res if available).
* Returns the current timestamp since the time origin (e.g. from page load).
* The result will be high-resolution including decimal places if available.
* @method now
* @return {number} the current timestamp (high-res if available)
* @return {number} the current timestamp
*/
Common.now = function() {
// http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript
// https://gist.github.com/davidwaterston/2982531

var performance = window.performance || {};

performance.now = (function() {
return performance.now ||
performance.webkitNow ||
performance.msNow ||
performance.oNow ||
performance.mozNow ||
function() { return +(new Date()); };
})();

return performance.now();
if (window.performance) {
if (window.performance.now) {
return window.performance.now();
} else if (window.performance.webkitNow) {
return window.performance.webkitNow();
}
}

return (new Date()) - Common._nowStartTime;
};

/**
Expand All @@ -4502,7 +4490,7 @@ module.exports = Common;
};

var _seededRandom = function() {
// https://gist.github.com/ngryman/3830489
// https://en.wikipedia.org/wiki/Linear_congruential_generator
Common._seed = (Common._seed * 9301 + 49297) % 233280;
return Common._seed / 233280;
};
Expand Down Expand Up @@ -4634,7 +4622,9 @@ module.exports = Common;
* @return {array} Partially ordered set of vertices in topological order.
*/
Common.topologicalSort = function(graph) {
// https://mgechev.github.io/javascript-algorithms/graphs_others_topological-sort.js.html
// https://github.com/mgechev/javascript-algorithms
// Copyright (c) Minko Gechev (MIT license)
// Modifications: tidy formatting and naming
var result = [],
visited = [],
temp = [];
Expand Down Expand Up @@ -5396,7 +5386,7 @@ var Common = _dereq_('./Common');
* @readOnly
* @type {String}
*/
Matter.version = '0.12.0-alpha';
Matter.version = '0.13.0';

/**
* A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`.
Expand Down Expand Up @@ -7080,21 +7070,15 @@ var Bodies = _dereq_('./Bodies');
pointB: { x: wheelAOffset, y: wheelYOffset },
bodyA: wheelA,
stiffness: 1,
length: 0,
render: {
lineWidth: 0
}
length: 0
});

var axelB = Constraint.create({
bodyB: body,
pointB: { x: wheelBOffset, y: wheelYOffset },
bodyA: wheelB,
stiffness: 1,
length: 0,
render: {
lineWidth: 0
}
length: 0
});

Composite.addBody(car, body);
Expand Down Expand Up @@ -7123,7 +7107,7 @@ var Bodies = _dereq_('./Bodies');
*/
Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) {
particleOptions = Common.extend({ inertia: Infinity }, particleOptions);
constraintOptions = Common.extend({ stiffness: 0.2 }, constraintOptions);
constraintOptions = Common.extend({ stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions);

var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) {
return Bodies.circle(x, y, particleRadius, particleOptions);
Expand Down Expand Up @@ -7480,6 +7464,9 @@ var Bounds = _dereq_('../geometry/Bounds');

var _svgPathToAbsolute = function(path) {
// http://phrogz.net/convert-svg-path-to-all-absolute-commands
// Copyright (c) Gavin Kistner
// http://phrogz.net/js/_ReuseLicense.txt
// Modifications: tidy formatting and naming
var x0, y0, x1, y1, x2, y2, segs = path.pathSegList,
x = 0, y = 0, len = segs.numberOfItems;

Expand Down Expand Up @@ -7937,7 +7924,7 @@ var Common = _dereq_('../core/Common');
j;

// find the polygon's moment of inertia, using second moment of area
// http://www.physicsforums.com/showthread.php?t=25293
// from equations at http://www.physicsforums.com/showthread.php?t=25293
for (var n = 0; n < v.length; n++) {
j = (n + 1) % v.length;
cross = Math.abs(Vector.cross(v[j], v[n]));
Expand Down Expand Up @@ -8141,6 +8128,7 @@ var Common = _dereq_('../core/Common');
*/
Vertices.isConvex = function(vertices) {
// http://paulbourke.net/geometry/polygonmesh/
// Copyright (c) Paul Bourke (use permitted)

var flag = 0,
n = vertices.length,
Expand Down Expand Up @@ -8183,7 +8171,7 @@ var Common = _dereq_('../core/Common');
* @return [vertex] vertices
*/
Vertices.hull = function(vertices) {
// http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain
// http://geomalgorithms.com/a10-_hull-1.html

var upper = [],
lower = [],
Expand All @@ -8198,7 +8186,7 @@ var Common = _dereq_('../core/Common');
});

// build lower hull
for (i = 0; i < vertices.length; i++) {
for (i = 0; i < vertices.length; i += 1) {
vertex = vertices[i];

while (lower.length >= 2
Expand All @@ -8210,7 +8198,7 @@ var Common = _dereq_('../core/Common');
}

// build upper hull
for (i = vertices.length - 1; i >= 0; i--) {
for (i = vertices.length - 1; i >= 0; i -= 1) {
vertex = vertices[i];

while (upper.length >= 2
Expand Down Expand Up @@ -8771,7 +8759,7 @@ var Mouse = _dereq_('../core/Mouse');

if (constraint.render.type === 'pin') {
c.beginPath();
c.arc(start.x, start.y, 4, 0, 2 * Math.PI);
c.arc(start.x, start.y, 3, 0, 2 * Math.PI);
c.closePath();
} else {
if (bodyB) {
Expand All @@ -8789,7 +8777,7 @@ var Mouse = _dereq_('../core/Mouse');
coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)),
offset;

for (var j = 0; j < coils; j += 1) {
for (var j = 1; j < coils; j += 1) {
offset = j % 2 === 0 ? 1 : -1;

c.lineTo(
Expand Down

0 comments on commit 63b02cf

Please sign in to comment.