0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-20 17:10:11 -05:00

release 0.8.0

This commit is contained in:
liabru 2014-05-05 19:32:51 +01:00
parent 8b6b623369
commit b6ed9f04bc
13 changed files with 2261 additions and 2577 deletions

View file

@ -4,6 +4,88 @@
----------
## 0.8.0-alpha - 2014-05-05
#### Release Highlights
- added [Views](http://brm.io/matter-js-demo/#views) demo
- added [Time Scaling](http://brm.io/matter-js-demo/#timescale) demo
- added [Rounded Corners (Chamfering)](http://brm.io/matter-js-demo#rounded) demo
- added [Raycasting](http://brm.io/matter-js-demo/#raycasting) demo
- added Query module, including raycasting
- added 3 useful new Composite methods
- added support for mouse wheel, mouse scaling and offsets
- added Body.scale for scaling bodies on the fly
- added Body.timeScale for slowing down bodies per-body
- added Body.setStatic for correctly setting static
- added Vertices.chamfer for rounding corners of any set of vertices
- added integration of chamfer to body factories
- added engine.timing.isFixed option to disable dynamic timing
- added render.bounds for translating and scaling views
- easier use of Engine.update and Engine.render for those using custom game loops
- fixed issues with time scaling
- fixed error in calculation of centre of mass
- removed Matter.Gui in preparation for the [MatterTools](https://github.com/liabru/matter-tools) project launch
#### Added
- added Demo.views
- added Demo.timescale
- added Demo.rounded
- added Demo.raycasting
- added demo support for hash + '-inspect' to start the [MatterTools](https://github.com/liabru/matter-tools) inspector
- added Composite.rebase
- added Composite.move
- added Composite.get
- added Matter.Query
- added Query.ray
- added Query.region
- added Bounds.translate
- added Bounds.shift
- added Mouse.setScale
- added Mouse.setPosition
- added mouse.absolute
- added mouse.wheelDelta
- added mouse.offset
- added Body.setStatic
- added Body.scale
- added body.timeScale
- added Vector.angle
- added Vertices.chamfer for rounding corners
- added Engine.render
- added engine.timing.isFixed option
- added render.bounds for translating and scaling views
- added Common.nextId
- added body.label
- added constraint.label
- added composite.label
#### Changed
- changed engine.timing.timestamp to be simulation based rather than wall-clock based
- changed correction to now be optional in Engine.update (defaults to 1)
- changed Events.on to return callback
- changed Events.off to accept callbacks for removal
- changed vertices in Bounds.create to optional
- changed engine.timeScale to engine.timing.timeScale
- moved Matter.Inspector and Matter.Gui to the [MatterTools](https://github.com/liabru/matter-tools) project
- moved event documentation to end of file for clarity
- moved respective engine event triggers into Engine.update and Engine.render
#### Removed
- removed body.render.path (redundant)
- removed Body.nextId
- removed Constraint.nextId
- removed Composite.nextId
- removed Body.updateProperties (now a private method)
#### Fixed
- fixed issues with timing.timeScale
- fixed constraints now account for timeScale
- fixed Vertices.centre calculation to get correct centre of mass
## 0.7.0-alpha - 2014-04-01
#### Release Highlights

View file

@ -14,6 +14,10 @@
- [Solid Shapes](http://brm.io/matter-js-demo#mixedSolid)
- [Newton's Cradle](http://brm.io/matter-js-demo#newtonsCradle)
- [Wrecking Ball](http://brm.io/matter-js-demo#wreckingBall)
- [Rounded Corners (Chamfering)](http://brm.io/matter-js-demo#rounded)
- [Views](http://brm.io/matter-js-demo/#views)
- [Time Scaling](http://brm.io/matter-js-demo/#timescale)
- [Raycasting](http://brm.io/matter-js-demo/#raycasting)
- [Sprites](http://brm.io/matter-js-demo/#sprites)
- [Pyramid](http://brm.io/matter-js-demo#pyramid)
- [Car](http://brm.io/matter-js-demo#car)
@ -51,14 +55,17 @@
- Composite bodies
- Sleeping and static bodies
- Events
- Rounded corners (chamfering)
- Views (translate, zoom)
- Collision queries (raycasting, region tests)
- Time scaling (slow-mo, speed-up)
- Canvas renderer (supports vectors and textures)
- WebGL renderer (requires [pixi.js](https://github.com/GoodBoyDigital/pixi.js/))
- [MatterTools](https://github.com/liabru/matter-tools) for creating, testing and debugging worlds
- World state serialisation (requires [resurrect.js](https://github.com/skeeto/resurrect-js))
- Built in GUI for testing (requires [dat.gui.js](http://workshop.chromeexperiments.com/examples/gui/))
- Cross-browser (Chrome, Firefox, Safari, IE8+)
- Mobile-compatible (touch, responsive)
- An original JavaScript physics implementation, not a port!
- An original JavaScript physics implementation (not a port)
### Status
@ -73,9 +80,9 @@ Though if I get time and people are interested, I may continue working on it.
### Install
Download [matter-0.7.0.js](https://github.com/liabru/matter-js/releases/download/0.7.0-alpha/matter-0.7.0.js) or [matter-0.7.0.min.js](https://github.com/liabru/matter-js/releases/download/0.7.0-alpha/matter-0.7.0.min.js) and include the script in your HTML file:
Download [matter-0.8.0.js](https://github.com/liabru/matter-js/releases/download/0.8.0-alpha/matter-0.8.0.js) or [matter-0.8.0.min.js](https://github.com/liabru/matter-js/releases/download/0.8.0-alpha/matter-0.8.0.min.js) and include the script in your HTML file:
<script src="matter-0.7.0.js" type="text/javascript"></script>
<script src="matter-0.8.0.js" type="text/javascript"></script>
For the latest features try the [edge version (master)](https://raw.github.com/liabru/matter-js/master/build/matter.js), but it may not be fully stable.
@ -92,7 +99,7 @@ Some of the demos are avaliable at [codepen.io/liabru](http://codepen.io/liabru/
### Documentation
See the [Matter.js API Docs (v0.7.0)](http://brm.io/matter-js-docs/).
See the [Matter.js API Docs (v0.8.0)](http://brm.io/matter-js-docs/).
<br>If you're using the [edge version (master)](https://raw2.github.com/liabru/matter-js/master/build/matter.js) then see the [API Docs (master)](http://brm.io/matter-js-docs-master/).
### Changelog

View file

@ -1,12 +1,12 @@
{
"name": "Matter",
"version": "0.7.0",
"version": "0.8.0",
"homepage": "https://github.com/liabru/matter-js",
"authors": [
"Liam Brummitt <liam@brm.io> (http://brm.io/)"
],
"description": "a 2D rigid body physics engine for the web",
"main": "build/matter-0.7.0.min.js",
"main": "build/matter-0.8.0.min.js",
"keywords": [
"javascript",
"canvas",

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

8
build/matter-0.8.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

7
build/matter.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -9,8 +9,8 @@
<!-- only required if using Matter.RenderPixi -->
<script type="text/javascript" src="./js/lib/pixi.dev.js"></script>
<!-- matter lib v0.7.0 -->
<script type="text/javascript" src="./js/lib/matter-0.7.0.js"></script>
<!-- matter lib v0.8.0 -->
<script type="text/javascript" src="./js/lib/matter-0.8.0.js"></script>
<!-- only required if using MatterTools -->
<link rel="stylesheet" href="./js/lib/matter-tools/matter-tools.css" type="text/css">
@ -33,8 +33,12 @@
<option value="mixedSolid">Solid Rendering</option>
<option value="newtonsCradle">Newton's Cradle</option>
<option value="wreckingBall">Wrecking Ball</option>
<option value="rounded">Rounded Corners (Chamfering)</option>
<option value="views">Views</option>
<option value="timescale">Time Scaling</option>
<option value="sprites">Sprites</option>
<option value="pyramid">Pyramid</option>
<option value="raycasting">Raycasting</option>
<option value="car">Car</option>
<option value="catapult">Catapult</option>
<option value="gravity">Reverse Gravity</option>

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
/**
* matter-tools-dev.min.js 0.5.0-dev 2014-05-01
* matter-tools-dev.min.js 0.5.0-dev 2014-05-04
* https://github.com/liabru/matter-tools
* License: MIT
*/
(function() {
var MatterTools = {};
var Engine = Matter.Engine, World = Matter.World, Bodies = Matter.Bodies, Body = Matter.Body, Composite = Matter.Composite, Composites = Matter.Composites, Common = Matter.Common, Constraint = Matter.Constraint, Events = Matter.Events, Bounds = Matter.Bounds, Vector = Matter.Vector, Vertices = Matter.Vertices, MouseConstraint = Matter.MouseConstraint, Query = Matter.Query;
var Engine = Matter.Engine, World = Matter.World, Bodies = Matter.Bodies, Body = Matter.Body, Composite = Matter.Composite, Composites = Matter.Composites, Common = Matter.Common, Constraint = Matter.Constraint, Events = Matter.Events, Bounds = Matter.Bounds, Vector = Matter.Vector, Vertices = Matter.Vertices, MouseConstraint = Matter.MouseConstraint, Render = Matter.Render, RenderPixi = Matter.RenderPixi, Mouse = Matter.Mouse, Query = Matter.Query;
var Gui = {};
(function() {
Gui.create = function(engine, options) {
@ -30,7 +30,8 @@
x:0,
y:0
},
renderer:"canvas"
renderer:"canvas",
chamfer:0
};
if (Resurrect) {
gui.serializer = new Resurrect({
@ -72,7 +73,6 @@
Gui.serialise = function(serializer, object, indent) {
indent = indent || 0;
return serializer.stringify(object, function(key, value) {
if (key === "path") return undefined;
if (!/^#/.exec(key) && typeof value === "number") {
var fixed = parseFloat(value.toFixed(3));
if (fixed === 0 && value !== 0) return value;
@ -81,6 +81,11 @@
return value;
}, indent);
};
Gui.clone = function(serializer, object) {
var clone = serializer.parse(Gui.serialise(serializer, object));
clone.id = Common.nextId();
return clone;
};
var _initDatGui = function(gui) {
var engine = gui.engine, datGui = gui.datGui;
var funcs = {
@ -126,6 +131,7 @@
controls.add(gui, "friction", 0, 1).step(.05);
controls.add(gui, "frictionAir", 0, gui.frictionAir * 10).step(gui.frictionAir / 10);
controls.add(gui, "restitution", 0, 1).step(.1);
controls.add(gui, "chamfer", 0, 30).step(2);
controls.add(funcs, "addBody");
controls.open();
var worldGui = datGui.addFolder("World");
@ -188,6 +194,11 @@
frictionAir:gui.frictionAir,
restitution:gui.restitution
};
if (gui.chamfer && gui.sides > 2) {
options.chamfer = {
radius:gui.chamfer
};
}
for (var i = 0; i < gui.amount; i++) {
World.add(engine.world, Bodies.polygon(gui.offset.x + 120 + i * gui.size + i * 50, gui.offset.y + 200, gui.sides, gui.size, options));
}
@ -229,6 +240,7 @@
hasTransitions:_isWebkit ? true :false,
bodyClass:"",
exportIndent:0,
clipboard:[],
controls:{
container:null,
worldTree:null
@ -303,7 +315,9 @@
help += "[shift + space] pause or play simulation.\n";
help += "[right click] and drag on empty space to select a region.\n";
help += "[right click] and drag on an object to move it.\n";
help += "[right click + shift] and drag to move whole selection.\n";
help += "[right click + shift] and drag to move whole selection.\n\n";
help += "[ctrl-c] to copy selected world objects.\n";
help += "[ctrl-v] to paste copied world objects to mouse position.\n";
help += "[del] or [backspace] delete selected objects.\n\n";
help += "[shift + s] scale-xy selected objects with mouse or arrows.\n";
help += "[shift + s + d] scale-x selected objects with mouse or arrows.\n";
@ -353,6 +367,12 @@
_key("backspace", function() {
_deleteSelectedObjects(inspector);
});
_key("ctrl+c", function() {
_copySelectedObjects(inspector);
});
_key("ctrl+v", function() {
_pasteSelectedObjects(inspector);
});
$(document).unbind("keydown").bind("keydown", function(event) {
var doPrevent = false;
if (event.keyCode === 8) {
@ -609,6 +629,30 @@
Composite.remove(inspector.root, objects, true);
_setSelectedObjects(inspector, []);
};
var _copySelectedObjects = function(inspector) {
inspector.clipboard.length = 0;
for (var i = 0; i < inspector.selected.length; i++) {
var object = inspector.selected[i].data;
if (object.type !== "body") continue;
inspector.clipboard.push(object);
}
};
var _pasteSelectedObjects = function(inspector) {
var objects = [], worldTree = inspector.controls.worldTree.data("jstree");
for (var i = 0; i < inspector.clipboard.length; i++) {
var object = inspector.clipboard[i], clone = Gui.clone(inspector.serializer, object);
Body.translate(clone, {
x:50,
y:50
});
var node = worldTree.get_node(object.type + "_" + object.id, false), compositeId = node.data.compositeId, composite = Composite.get(inspector.engine.world, compositeId, "composite");
Composite.add(composite, clone);
objects.push(clone);
}
setTimeout(function() {
_setSelectedObjects(inspector, objects);
}, 200);
};
var _updateSelectedMouseDownOffset = function(inspector) {
var selected = inspector.selected, mouse = inspector.engine.input.mouse, mousePosition = _getMousePosition(inspector), item, data;
for (var i = 0; i < selected.length; i++) {

View file

@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="robots" content="noindex">
<script type="text/javascript" src="./js/lib/matter-0.7.0.js"></script>
<script type="text/javascript" src="./js/lib/matter-0.8.0.js"></script>
<script type="text/javascript" src="./js/DemoMobile.js"></script>
<link rel="stylesheet" href="./css/style.css" type="text/css">
<title>Matter.js Physics Engine Mobile Demo</title>

View file

@ -1,11 +1,11 @@
{
"name": "Matter",
"version": "0.7.0",
"version": "0.8.0",
"license": "MIT",
"homepage": "http://brm.io/matter-js/",
"author": "Liam Brummitt <liam@brm.io> (http://brm.io/)",
"description": "a 2D rigid body physics engine for the web",
"main": "build/matter-0.7.0.min.js",
"main": "build/matter-0.8.0.min.js",
"repository":{
"type" : "git",
"url" : "https://github.com/liabru/matter-js.git"