mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-14 16:28:42 -05:00
merge branch 'master' into timing-improve
This commit is contained in:
commit
207c2f3ccb
69 changed files with 18015 additions and 12977 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,12 +1,11 @@
|
||||||
.idea
|
.idea
|
||||||
node_modules
|
node_modules
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
doc
|
docs
|
||||||
matter-doc-theme
|
matter-doc-theme
|
||||||
build/matter-dev.js
|
build/matter-dev.js
|
||||||
build/matter-dev.min.js
|
build/matter-dev.min.js
|
||||||
demo/js/lib/matter-dev.js
|
demo/js/lib/matter-dev.js
|
||||||
demo/js/Examples.js
|
|
||||||
demo/js/Examples.min.js
|
demo/js/Examples.min.js
|
||||||
examples/build
|
examples/build
|
||||||
test/browser/diffs
|
test/browser/diffs
|
||||||
|
|
54
CHANGELOG.md
54
CHANGELOG.md
|
@ -1,3 +1,57 @@
|
||||||
|
## 0.15.0 (2020-12-24)
|
||||||
|
|
||||||
|
* add window global, stub require and handle bad values in test tools ([497ac80](https://github.com/liabru/matter-js/commit/497ac80))
|
||||||
|
* added Body.setCentre, closes #684, closes #461, closes #679 ([2ec247b](https://github.com/liabru/matter-js/commit/2ec247b)), closes [#684](https://github.com/liabru/matter-js/issues/684) [#461](https://github.com/liabru/matter-js/issues/461) [#679](https://github.com/liabru/matter-js/issues/679)
|
||||||
|
* added browser tests ([ceb7cd5](https://github.com/liabru/matter-js/commit/ceb7cd5))
|
||||||
|
* Added build comparison tools and tests ([b7c938a](https://github.com/liabru/matter-js/commit/b7c938a))
|
||||||
|
* added check for window in Common.now ([9ef9d02](https://github.com/liabru/matter-js/commit/9ef9d02))
|
||||||
|
* added comparison output file option to test tools ([45aae25](https://github.com/liabru/matter-js/commit/45aae25))
|
||||||
|
* Added config and test files to lint ([21e4ea6](https://github.com/liabru/matter-js/commit/21e4ea6))
|
||||||
|
* added Constraint.pointAWorld and Constraint.pointBWorld ([3c32969](https://github.com/liabru/matter-js/commit/3c32969))
|
||||||
|
* added examples to dev server bundle and commit built examples ([fe80478](https://github.com/liabru/matter-js/commit/fe80478))
|
||||||
|
* added module export to examples ([f9ea799](https://github.com/liabru/matter-js/commit/f9ea799))
|
||||||
|
* added overlap metric to test tools ([3fd674d](https://github.com/liabru/matter-js/commit/3fd674d))
|
||||||
|
* added release scripts ([341c247](https://github.com/liabru/matter-js/commit/341c247))
|
||||||
|
* added tag push to release task ([060283b](https://github.com/liabru/matter-js/commit/060283b))
|
||||||
|
* added timing to engine snapshot ([e0cdbb8](https://github.com/liabru/matter-js/commit/e0cdbb8))
|
||||||
|
* Added watch content base to dev server ([f471d4e](https://github.com/liabru/matter-js/commit/f471d4e))
|
||||||
|
* added webpack build script ([046013e](https://github.com/liabru/matter-js/commit/046013e))
|
||||||
|
* changed alpha build configuration ([182c84a](https://github.com/liabru/matter-js/commit/182c84a))
|
||||||
|
* changed demo to auto populate examples with sourceLink and init ([5b0d34b](https://github.com/liabru/matter-js/commit/5b0d34b))
|
||||||
|
* changed demo to serve without sub-directory ([823bbc0](https://github.com/liabru/matter-js/commit/823bbc0))
|
||||||
|
* changed docs build config ([864452d](https://github.com/liabru/matter-js/commit/864452d))
|
||||||
|
* changed example tests to use jest ([104d319](https://github.com/liabru/matter-js/commit/104d319))
|
||||||
|
* fix decomp import in Bodies.fromVertices ([94e9614](https://github.com/liabru/matter-js/commit/94e9614))
|
||||||
|
* fix decomp require ([0af1645](https://github.com/liabru/matter-js/commit/0af1645))
|
||||||
|
* fix issues with render pixel ratio, closes #686, closes #687 ([d577477](https://github.com/liabru/matter-js/commit/d577477)), closes [#686](https://github.com/liabru/matter-js/issues/686) [#687](https://github.com/liabru/matter-js/issues/687)
|
||||||
|
* fix lint ([5a0079d](https://github.com/liabru/matter-js/commit/5a0079d))
|
||||||
|
* fix lint issues ([9ca21c1](https://github.com/liabru/matter-js/commit/9ca21c1))
|
||||||
|
* fix path to build in test worker ([fcdb4fa](https://github.com/liabru/matter-js/commit/fcdb4fa))
|
||||||
|
* fix preversion script ([c368c14](https://github.com/liabru/matter-js/commit/c368c14))
|
||||||
|
* fix terrain example module export ([4a967ec](https://github.com/liabru/matter-js/commit/4a967ec))
|
||||||
|
* Fix typo in docs ([c486635](https://github.com/liabru/matter-js/commit/c486635))
|
||||||
|
* fixed plugins in compare ([82bb415](https://github.com/liabru/matter-js/commit/82bb415))
|
||||||
|
* implemented threaded comparison testing ([285d70d](https://github.com/liabru/matter-js/commit/285d70d))
|
||||||
|
* Optimized Body's hidden class ([b3220cf](https://github.com/liabru/matter-js/commit/b3220cf))
|
||||||
|
* Optimized Events.trigger method when no event is emitted ([b17cb48](https://github.com/liabru/matter-js/commit/b17cb48))
|
||||||
|
* remove gulp ([6a28090](https://github.com/liabru/matter-js/commit/6a28090))
|
||||||
|
* remove old demo libs ([13c7eb5](https://github.com/liabru/matter-js/commit/13c7eb5))
|
||||||
|
* removed unused gulp release tasks ([e5a7311](https://github.com/liabru/matter-js/commit/e5a7311))
|
||||||
|
* removed yuidocjs dev dependency ([ee848d2](https://github.com/liabru/matter-js/commit/ee848d2))
|
||||||
|
* Set loose build version on dev server ([1fcf292](https://github.com/liabru/matter-js/commit/1fcf292))
|
||||||
|
* update build script ([90abab6](https://github.com/liabru/matter-js/commit/90abab6))
|
||||||
|
* update default render theme ([d258411](https://github.com/liabru/matter-js/commit/d258411))
|
||||||
|
* update demo and example render styles ([6dd5ec5](https://github.com/liabru/matter-js/commit/6dd5ec5))
|
||||||
|
* update dependencies ([e1e058c](https://github.com/liabru/matter-js/commit/e1e058c)) ([5f5b8a1](https://github.com/liabru/matter-js/commit/5f5b8a1))
|
||||||
|
* update examples build config and scripts ([69afb11](https://github.com/liabru/matter-js/commit/69afb11))
|
||||||
|
* update package lock ([ac3da07](https://github.com/liabru/matter-js/commit/ac3da07))
|
||||||
|
* updated build scripts ([6b698ea](https://github.com/liabru/matter-js/commit/6b698ea))
|
||||||
|
* updated ci ([288b9cd](https://github.com/liabru/matter-js/commit/288b9cd))
|
||||||
|
* updated docs ([50cf171](https://github.com/liabru/matter-js/commit/50cf171))
|
||||||
|
* updated readme ([ea5c012](https://github.com/liabru/matter-js/commit/ea5c012)) ([61b1963](https://github.com/liabru/matter-js/commit/61b1963))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.14.2"></a>
|
<a name="0.14.2"></a>
|
||||||
## <small>0.14.2 (2018-06-11)</small>
|
## <small>0.14.2 (2018-06-11)</small>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ By providing any kind of contribution to this project, **you must agree and be l
|
||||||
|
|
||||||
## Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions by pull request or issues are welcome. Please ensure they follow the same style and architecture as the rest of the code. Use `npm run lint` before submitting. Please **do not include** any changes to the files in the `build` directory.
|
Contributions by pull request or issues are welcome. Please ensure they follow the same style and architecture as the rest of the code. Use `npm run lint` and see [Testing](#Testing) below before submitting. Please **do not include** any changes to the files in the `build` directory.
|
||||||
|
|
||||||
Before contributing please read the license agreement described at the beginning of this document.
|
Before contributing please read the license agreement described at the beginning of this document.
|
||||||
|
|
||||||
|
@ -22,6 +22,16 @@ which will install the required build dependencies, then run
|
||||||
|
|
||||||
which will run the development server and opens `http://localhost:8000/` in your browser. Any changes you make to the source will automatically rebuild and reload the page.
|
which will run the development server and opens `http://localhost:8000/` in your browser. Any changes you make to the source will automatically rebuild and reload the page.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
All contributions should pass when running the commands
|
||||||
|
|
||||||
|
- `npm run lint`
|
||||||
|
- `npm run test`
|
||||||
|
- `npm run test-browser`
|
||||||
|
|
||||||
|
The output of `npm run test` also includes a [comparison report](https://github.com/liabru/matter-js/pull/794), which highlights changes in results, performance and accuracy against the last release build.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
The following development commands can be run at the terminal
|
The following development commands can be run at the terminal
|
||||||
|
@ -33,8 +43,8 @@ creates a release build
|
||||||
- **npm run lint**
|
- **npm run lint**
|
||||||
runs the linter
|
runs the linter
|
||||||
- **npm run test**
|
- **npm run test**
|
||||||
runs the tests
|
runs the tests and compares results
|
||||||
- **npm run compare**
|
- **npm run test-browser**
|
||||||
compares the output of examples for current source against release build
|
runs the browser tests
|
||||||
- **npm run doc**
|
- **npm run doc**
|
||||||
builds the documentation
|
builds the documentation
|
||||||
|
|
90
Gulpfile.js
90
Gulpfile.js
|
@ -1,90 +0,0 @@
|
||||||
/* eslint-env es6 */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const gulp = require('gulp');
|
|
||||||
const bump = require('gulp-bump');
|
|
||||||
const changelog = require('gulp-conventional-changelog');
|
|
||||||
const tag = require('gulp-tag-version');
|
|
||||||
const sequence = require('run-sequence');
|
|
||||||
const gutil = require('gulp-util');
|
|
||||||
const pkg = require('./package.json');
|
|
||||||
const exec = require('child_process').exec;
|
|
||||||
|
|
||||||
const shellExec = (command, callback) => {
|
|
||||||
const args = process.argv.slice(3).join(' '),
|
|
||||||
proc = exec(command + ' ' + args, (err, stdout, stderr) => {
|
|
||||||
callback(err, stdout, stderr, proc);
|
|
||||||
});
|
|
||||||
|
|
||||||
proc.stdout.on('data', data => process.stdout.write(data));
|
|
||||||
proc.stderr.on('data', data => process.stderr.write(data));
|
|
||||||
};
|
|
||||||
|
|
||||||
const shell = command => (callback => { shellExec(command, callback); });
|
|
||||||
|
|
||||||
const hint = command => (callback => {
|
|
||||||
gutil.log(gutil.colors.red('Error'), 'use', gutil.colors.yellow(command), 'instead.');
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('default', hint('npm run build'));
|
|
||||||
gulp.task('dev', hint('npm run dev'));
|
|
||||||
gulp.task('build', hint('npm run build'));
|
|
||||||
gulp.task('test', hint('npm run test'));
|
|
||||||
gulp.task('lint', hint('npm run lint'));
|
|
||||||
|
|
||||||
gulp.task('doc', callback => {
|
|
||||||
shellExec(`yuidoc --config yuidoc.json --project-version ${pkg.version}`, callback);
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bump', () => {
|
|
||||||
return gulp.src(['package.json', 'bower.json'])
|
|
||||||
.pipe(bump({ type: process.argv[4] || 'minor' }))
|
|
||||||
.pipe(gulp.dest('.'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('tag', () => {
|
|
||||||
return gulp.src('package.json')
|
|
||||||
.pipe(tag({ prefix: '' }));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('changelog', () => {
|
|
||||||
return gulp.src('CHANGELOG.md')
|
|
||||||
.pipe(changelog())
|
|
||||||
.pipe(gulp.dest('.'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('release', callback => {
|
|
||||||
shellExec('git status --porcelain', (err, stdout) => {
|
|
||||||
if (stdout && stdout.trim()) {
|
|
||||||
throw new gutil.PluginError({
|
|
||||||
plugin: 'release',
|
|
||||||
message: 'cannot build release as there are uncomitted changes'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
sequence(
|
|
||||||
'release:lint', 'bump', 'release:build', 'release:test',
|
|
||||||
'doc', 'changelog', callback
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('release:lint', shell('npm run lint'));
|
|
||||||
gulp.task('release:build', shell('npm run build'));
|
|
||||||
gulp.task('release:test', shell('TEST_BUILD=true npm run test'));
|
|
||||||
gulp.task('release:push:git', shell('git push origin && git push origin --tags'));
|
|
||||||
gulp.task('release:push:npm', shell('npm publish'));
|
|
||||||
|
|
||||||
gulp.task('release:push', callback => {
|
|
||||||
shellExec('git status --porcelain', (err, stdout) => {
|
|
||||||
if (stdout && stdout.trim()) {
|
|
||||||
throw new gutil.PluginError({
|
|
||||||
plugin: 'release',
|
|
||||||
message: 'cannot push release as it has not yet been committed'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
sequence('tag', 'release:push:git', 'release:push:npm', callback);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
122
README.md
122
README.md
|
@ -1,10 +1,10 @@
|
||||||
<img alt="Matter.js" src="http://brm.io/matter-js/img/matter-js.svg" width="300">
|
<img alt="Matter.js" src="https://brm.io/matter-js/img/matter-js.svg" width="300">
|
||||||
|
|
||||||
> *Matter.js* is a JavaScript 2D rigid body physics engine for the web
|
> *Matter.js* is a JavaScript 2D rigid body physics engine for the web
|
||||||
|
|
||||||
[brm.io/matter-js](http://brm.io/matter-js/)
|
[brm.io/matter-js](https://brm.io/matter-js/)
|
||||||
|
|
||||||
[Demos](#demos) - [Gallery](#gallery) - [Features](#features) - [Plugins](#plugins) - [Install](#install) - [Usage](#usage) - [Examples](#examples) - [Docs](#documentation) - [Wiki](https://github.com/liabru/matter-js/wiki) - [References](#references) - [License](#license)
|
[Demos](#demos) ・ [Gallery](#gallery) ・ [Features](#features) ・ [Plugins](#plugins) ・ [Install](#install) ・ [Usage](#usage) ・ [Examples](#examples) ・ [Docs](#documentation) ・ [Wiki](https://github.com/liabru/matter-js/wiki) ・ [References](#references) ・ [License](#license)
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/liabru/matter-js.png?branch=master)](https://travis-ci.org/liabru/matter-js)
|
[![Build Status](https://travis-ci.org/liabru/matter-js.png?branch=master)](https://travis-ci.org/liabru/matter-js)
|
||||||
|
|
||||||
|
@ -14,51 +14,55 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#mixed">Mixed Shapes</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#mixed">Mixed Shapes</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#mixedSolid">Solid Shapes</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#mixedSolid">Solid Shapes</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#svg">Concave SVG Paths</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#svg">Concave SVG Paths</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#terrain">Concave Terrain</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#terrain">Concave Terrain</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#concave">Concave Bodies</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#concave">Concave Bodies</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#compound">Compound Bodies</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#compound">Compound Bodies</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#newtonsCradle">Newton's Cradle</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#newtonsCradle">Newton's Cradle</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#wreckingBall">Wrecking Ball</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#wreckingBall">Wrecking Ball</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#slingshot">Slingshot Game</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#slingshot">Slingshot Game</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#rounded">Rounded Corners</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#rounded">Rounded Corners</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#views">Views</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#views">Views</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#timescale">Time Scaling</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#timescale">Time Scaling</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#manipulation">Body Manipulation</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#manipulation">Body Manipulation</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#compositeManipulation">Composite Manipulation</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#compositeManipulation">Composite Manipulation</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#raycasting">Raycasting</a></li>
|
|
||||||
<li><a href="http://brm.io/matter-js/demo/#sprites">Sprites</a></li>
|
|
||||||
<li><a href="http://brm.io/matter-js/demo/#pyramid">Pyramid</a></li>
|
|
||||||
<li><a href="http://brm.io/matter-js/demo/#car">Car</a></li>
|
|
||||||
<li><a href="http://brm.io/matter-js/demo/#catapult">Catapult</a></li>
|
|
||||||
<li><a href="http://brm.io/matter-js/demo/#gravity">Reverse Gravity</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#bridge">Bridge</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#raycasting">Raycasting</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#avalanche">Avalanche</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#sprites">Sprites</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#softBody">Basic Soft Bodies</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#pyramid">Pyramid</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#cloth">Cloth</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#car">Car</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#events">Events</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#catapult">Catapult</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#collisionFiltering">Collision Filtering</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#gravity">Reverse Gravity</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#chains">Chains</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#bridge">Bridge</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#ballPool">Ball Pool</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#avalanche">Avalanche</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#stack">Stack</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#softBody">Basic Soft Bodies</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#circleStack">Circle Stack</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#cloth">Cloth</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#compoundStack">Compound Stack</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#events">Events</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#restitution">Restitution</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#collisionFiltering">Collision Filtering</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#friction">Friction</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#chains">Chains</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#airFriction">Air Friction</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#ballPool">Ball Pool</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#staticFriction">Static Friction</a></li>
|
</ul>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#sleeping">Sleeping</a></li>
|
</td>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#broadphase">Grid Broadphase</a></li>
|
<td>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#beachBalls">Beach Balls</a></li>
|
<ul>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#stress">Stress 1</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#stack">Stack</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#stress2">Stress 2</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#circleStack">Circle Stack</a></li>
|
||||||
<li><a href="http://brm.io/matter-js/demo/#sensors">Sensors</a></li>
|
<li><a href="https://brm.io/matter-js/demo/#compoundStack">Compound Stack</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#restitution">Restitution</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#friction">Friction</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#airFriction">Air Friction</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#staticFriction">Static Friction</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#sleeping">Sleeping</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#broadphase">Grid Broadphase</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#beachBalls">Beach Balls</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#stress">Stress 1</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#stress2">Stress 2</a></li>
|
||||||
|
<li><a href="https://brm.io/matter-js/demo/#sensors">Sensors</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</td>
|
</td>
|
||||||
|
@ -69,16 +73,18 @@
|
||||||
|
|
||||||
See how others are using matter.js physics
|
See how others are using matter.js physics
|
||||||
|
|
||||||
- [Les métamorphoses de Mr. Kalia](http://lab212.org/Les-metamorphoses-de-Mr-Kalia) by Lab212 for Google
|
- [Patrick Heng](https://patrickheng.com/) by Patrick Heng
|
||||||
- [4ify](http://pauliescanlon.io/4ify-channel-4-rebrand-2/) by Supernatural for Channel 4
|
- [USELESS](https://useless.london/) by Nice and Serious
|
||||||
- [Adobe Analytics Live Stream](http://adobefirehose.mediarain.com/) by Rain for Adobe
|
- [Secret 7](https://secret-7.com/) by Goodness
|
||||||
- [Blood Sweat & Tools Interactive](http://bloodsweatandtools.discovery.ca/gamebench/) by Jam3 for Discovery
|
- [New Company](https://www.new.company/) by New Company
|
||||||
- [Oracle OpenWorld Experiment](http://theappslab.com/2016/10/10/how-i-attended-oracle-openworld-2016/) by Ed Jones for Oracle
|
- [Game of The Year](https://gameoftheyear.withgoogle.com/) by Google
|
||||||
- [Pablo The Flamingo](http://pablotheflamingo.com/) by Nathan Gordon
|
- [Pablo The Flamingo](https://pablotheflamingo.com/) by Nathan Gordon
|
||||||
- [Goblins and Grottos](http://store.steampowered.com/app/389190) by Psychic Software
|
- [Les métamorphoses de Mr. Kalia](https://lab212.org/oeuvres/2:art/18/Les-metamorphoses-de-Mr-Kalia) by Lab212
|
||||||
- [masQueLaCara](https://www.instagram.com/p/BCFqCs6JNsq/) by Zach Lieberman for Art Blocks Houston
|
- [Phaser](https://phaser.io/) by Photon Storm
|
||||||
- [#GIFMYLIVE](http://bonhommeparis.com/en/projects/arte-gifmylive) by Bonhomme for Arte
|
- [Sorry I Have No Filter](https://sorryihavenofilter.com/pages/about/) by Jessica Walsh
|
||||||
- [Hype](http://tumult.com/hype/pro/) by Tumult
|
- [Fuse](https://fuse.blog/) by Fuse
|
||||||
|
- [Glyphfinder](https://www.glyphfinder.com/) by überdosis
|
||||||
|
- [Isolation](https://isolation.is/postcards/my-week) by sabato studio
|
||||||
- [more...](https://github.com/liabru/matter-js/wiki/Gallery)
|
- [more...](https://github.com/liabru/matter-js/wiki/Gallery)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
@ -131,7 +137,7 @@ See the list of [tutorials](https://github.com/liabru/matter-js/wiki/Tutorials).
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
See the [examples](https://github.com/liabru/matter-js/tree/master/examples) directory which contains the source for all [demos](#demos).
|
See the [examples](https://github.com/liabru/matter-js/tree/master/examples) directory which contains the source for all [demos](#demos).
|
||||||
There are even more examples on [codepen](http://codepen.io/collection/Fuagy/).
|
There are even more examples on [codepen](https://codepen.io/collection/Fuagy/).
|
||||||
|
|
||||||
### Plugins
|
### Plugins
|
||||||
|
|
||||||
|
@ -144,11 +150,11 @@ The engine can be extended through plugins, see these resources:
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
See the [API Documentation](http://brm.io/matter-js/docs/) and the [wiki](https://github.com/liabru/matter-js/wiki)
|
See the [API Documentation](https://brm.io/matter-js/docs/) and the [wiki](https://github.com/liabru/matter-js/wiki)
|
||||||
|
|
||||||
### Building and Contributing
|
### Building and Contributing
|
||||||
|
|
||||||
To build you must first install [node.js](http://nodejs.org/), then run
|
To build you must first install [node.js](https://nodejs.org/), then run
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
|
@ -168,7 +174,7 @@ See the wiki page on [References](https://github.com/liabru/matter-js/wiki/Refer
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
||||||
Matter.js is licensed under [The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
Matter.js is licensed under [The MIT License (MIT)](https://opensource.org/licenses/MIT)
|
||||||
Copyright (c) 2014 Liam Brummitt
|
Copyright (c) 2014 Liam Brummitt
|
||||||
|
|
||||||
This license is also supplied with the release and source code.
|
This license is also supplied with the release and source code.
|
||||||
|
|
42
RELEASE.md
Normal file
42
RELEASE.md
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
## ▲.● matter.js `0.15.0`
|
||||||
|
|
||||||
|
Release notes for `0.15.0`. See the release [readme](https://github.com/liabru/matter-js/blob/0.15.0/README.md) for further information.
|
||||||
|
|
||||||
|
### Highlights ✺
|
||||||
|
|
||||||
|
- __Optimised performance up to ~30% boost vs. `0.14.2`__ ([#528](https://github.com/liabru/matter-js/pull/528)) ([#522](https://github.com/liabru/matter-js/pull/522)) ([#553](https://github.com/liabru/matter-js/pull/553))
|
||||||
|
- Added `Body.setCentre` ([2ec247b](https://github.com/liabru/matter-js/commit/2ec247b))
|
||||||
|
- Added `Constraint.pointAWorld` and `Constraint.pointBWorld` ([3c32969](https://github.com/liabru/matter-js/commit/3c32969))
|
||||||
|
- Changed default colour scheme ([d258411](https://github.com/liabru/matter-js/commit/d258411)) ([6dd5ec5](https://github.com/liabru/matter-js/commit/6dd5ec5))
|
||||||
|
- Fixed issues with decomp require ([0af1645](https://github.com/liabru/matter-js/commit/0af1645))
|
||||||
|
- Fixed issues with render pixel ratio ([d577477](https://github.com/liabru/matter-js/commit/d577477))
|
||||||
|
|
||||||
|
### Changes ✲
|
||||||
|
|
||||||
|
See the release [compare page](https://github.com/liabru/matter-js/compare/0.14.2...0.15.0) and the [changelog](https://github.com/liabru/matter-js/blob/0.15.0/CHANGELOG.md) for a detailed list of all changes.
|
||||||
|
|
||||||
|
### Comparison ⎄
|
||||||
|
|
||||||
|
Differences in behaviour, quality and performance against the previous release `0.14.2`. For more information see [comparison method](https://github.com/liabru/matter-js/pull/794).
|
||||||
|
|
||||||
|
```ocaml
|
||||||
|
Output comparison of 41 examples against matter-js@0.14.2 build on last run
|
||||||
|
|
||||||
|
Similarity 100% Performance +33.6% Overlap +0.00%
|
||||||
|
|
||||||
|
airFriction · · avalanche · · ballPool · · bridge · · broadphase · · car · ·
|
||||||
|
catapult · · chains · · circleStack · · cloth · · collisionFiltering · ·
|
||||||
|
compositeManipulation · · compound · · compoundStack · · concave · · constraints · ·
|
||||||
|
doublePendulum · · events · · friction · · gravity · · gyro · ·
|
||||||
|
manipulation · · mixed · · newtonsCradle · · pyramid · · ragdoll · ·
|
||||||
|
raycasting · · restitution · · rounded · · sensors · · sleeping · ·
|
||||||
|
slingshot · · softBody · · sprites · · stack · · staticFriction · ·
|
||||||
|
stress · · stress2 · · timescale · · views · · wreckingBall · ·
|
||||||
|
|
||||||
|
where · no change ● extrinsics changed ◆ intrinsics changed
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Contributors ♥︎
|
||||||
|
|
||||||
|
Many thanks to the [contributors](https://github.com/liabru/matter-js/compare/0.14.2...0.15.0) of this release, [past contributors](https://github.com/liabru/matter-js/graphs/contributors) as well those involved in the [community](https://github.com/liabru/matter-js/issues) for your input and support.
|
27
bower.json
27
bower.json
|
@ -1,27 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Matter",
|
|
||||||
"version": "0.14.2",
|
|
||||||
"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.js",
|
|
||||||
"keywords": [
|
|
||||||
"javascript",
|
|
||||||
"canvas",
|
|
||||||
"html5",
|
|
||||||
"physics",
|
|
||||||
"physics engine",
|
|
||||||
"game engine",
|
|
||||||
"rigid body physics"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"ignore": [
|
|
||||||
"**/.*",
|
|
||||||
"node_modules",
|
|
||||||
"bower_components",
|
|
||||||
"test",
|
|
||||||
"tests"
|
|
||||||
]
|
|
||||||
}
|
|
13728
build/matter.js
13728
build/matter.js
File diff suppressed because it is too large
Load diff
102
build/matter.min.js
vendored
102
build/matter.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -16,6 +16,9 @@
|
||||||
<script type="text/javascript" src="./lib/decomp.js"></script>
|
<script type="text/javascript" src="./lib/decomp.js"></script>
|
||||||
<script type="text/javascript" src="./lib/pathseg.js"></script>
|
<script type="text/javascript" src="./lib/pathseg.js"></script>
|
||||||
|
|
||||||
|
<!-- Examples -->
|
||||||
|
<script src="./js/Examples.js"></script>
|
||||||
|
|
||||||
<!-- Matter -->
|
<!-- Matter -->
|
||||||
<script src="../build/matter.js"></script>
|
<script src="../build/matter.js"></script>
|
||||||
|
|
||||||
|
@ -28,51 +31,6 @@
|
||||||
<!-- Plugins -->
|
<!-- Plugins -->
|
||||||
<script src="./lib/matter-wrap.js"></script>
|
<script src="./lib/matter-wrap.js"></script>
|
||||||
|
|
||||||
<!-- Examples -->
|
|
||||||
<script src="../examples/airFriction.js"></script>
|
|
||||||
<script src="../examples/avalanche.js"></script>
|
|
||||||
<script src="../examples/ballPool.js"></script>
|
|
||||||
<script src="../examples/bridge.js"></script>
|
|
||||||
<script src="../examples/broadphase.js"></script>
|
|
||||||
<script src="../examples/car.js"></script>
|
|
||||||
<script src="../examples/catapult.js"></script>
|
|
||||||
<script src="../examples/chains.js"></script>
|
|
||||||
<script src="../examples/circleStack.js"></script>
|
|
||||||
<script src="../examples/cloth.js"></script>
|
|
||||||
<script src="../examples/collisionFiltering.js"></script>
|
|
||||||
<script src="../examples/compositeManipulation.js"></script>
|
|
||||||
<script src="../examples/compound.js"></script>
|
|
||||||
<script src="../examples/compoundStack.js"></script>
|
|
||||||
<script src="../examples/concave.js"></script>
|
|
||||||
<script src="../examples/constraints.js"></script>
|
|
||||||
<script src="../examples/doublePendulum.js"></script>
|
|
||||||
<script src="../examples/events.js"></script>
|
|
||||||
<script src="../examples/friction.js"></script>
|
|
||||||
<script src="../examples/gravity.js"></script>
|
|
||||||
<script src="../examples/gyro.js"></script>
|
|
||||||
<script src="../examples/manipulation.js"></script>
|
|
||||||
<script src="../examples/mixed.js"></script>
|
|
||||||
<script src="../examples/newtonsCradle.js"></script>
|
|
||||||
<script src="../examples/ragdoll.js"></script>
|
|
||||||
<script src="../examples/pyramid.js"></script>
|
|
||||||
<script src="../examples/raycasting.js"></script>
|
|
||||||
<script src="../examples/restitution.js"></script>
|
|
||||||
<script src="../examples/rounded.js"></script>
|
|
||||||
<script src="../examples/sensors.js"></script>
|
|
||||||
<script src="../examples/sleeping.js"></script>
|
|
||||||
<script src="../examples/slingshot.js"></script>
|
|
||||||
<script src="../examples/softBody.js"></script>
|
|
||||||
<script src="../examples/sprites.js"></script>
|
|
||||||
<script src="../examples/stack.js"></script>
|
|
||||||
<script src="../examples/staticFriction.js"></script>
|
|
||||||
<script src="../examples/stress.js"></script>
|
|
||||||
<script src="../examples/stress2.js"></script>
|
|
||||||
<script src="../examples/svg.js"></script>
|
|
||||||
<script src="../examples/terrain.js"></script>
|
|
||||||
<script src="../examples/timescale.js"></script>
|
|
||||||
<script src="../examples/views.js"></script>
|
|
||||||
<script src="../examples/wreckingBall.js"></script>
|
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
* {
|
* {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -103,6 +61,10 @@
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.matter-demo canvas {
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -99,6 +99,8 @@
|
||||||
examples: examples
|
examples: examples
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.MatterDemo = demo;
|
||||||
|
|
||||||
document.body.appendChild(demo.dom.root);
|
document.body.appendChild(demo.dom.root);
|
||||||
|
|
||||||
MatterTools.Demo.start(demo);
|
MatterTools.Demo.start(demo);
|
||||||
|
|
5699
demo/js/Examples.js
Normal file
5699
demo/js/Examples.js
Normal file
File diff suppressed because it is too large
Load diff
3
demo/js/Server.js
Normal file
3
demo/js/Server.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// bundle entry point for the development server
|
||||||
|
Example = require('../../examples/index.js');
|
||||||
|
module.exports = require('../../src/module/main.js');
|
4
demo/lib/jquery-1.11.0.min.js
vendored
4
demo/lib/jquery-1.11.0.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -80,6 +80,8 @@ Example.airFriction = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.airFriction.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.airFriction;
|
||||||
}
|
}
|
|
@ -45,9 +45,9 @@ Example.avalanche = function() {
|
||||||
World.add(world, stack);
|
World.add(world, stack);
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(200, 150, 700, 20, { isStatic: true, angle: Math.PI * 0.06 }),
|
Bodies.rectangle(200, 150, 700, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(500, 350, 700, 20, { isStatic: true, angle: -Math.PI * 0.06 }),
|
Bodies.rectangle(500, 350, 700, 20, { isStatic: true, angle: -Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(340, 580, 700, 20, { isStatic: true, angle: Math.PI * 0.04 })
|
Bodies.rectangle(340, 580, 700, 20, { isStatic: true, angle: Math.PI * 0.04, render: { fillStyle: '#060a19' } })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// add mouse control
|
// add mouse control
|
||||||
|
@ -91,6 +91,8 @@ Example.avalanche = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.avalanche.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.avalanche;
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@ Example.ballPool = function() {
|
||||||
|
|
||||||
// add bodies
|
// add bodies
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(400, 600, 1200, 50.5, { isStatic: true })
|
Bodies.rectangle(400, 600, 1200, 50.5, { isStatic: true, render: { fillStyle: '#060a19' } })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var stack = Composites.stack(100, 0, 10, 8, 10, 10, function(x, y) {
|
var stack = Composites.stack(100, 0, 10, 8, 10, 10, function(x, y) {
|
||||||
|
@ -99,6 +99,8 @@ Example.ballPool = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.ballPool.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.ballPool;
|
||||||
}
|
}
|
|
@ -44,7 +44,7 @@ Example.bridge = function() {
|
||||||
density: 0.005,
|
density: 0.005,
|
||||||
frictionAir: 0.05,
|
frictionAir: 0.05,
|
||||||
render: {
|
render: {
|
||||||
fillStyle: '#575375'
|
fillStyle: '#060a19'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -124,6 +124,8 @@ Example.bridge = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.bridge.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.bridge;
|
||||||
}
|
}
|
|
@ -95,6 +95,8 @@ Example.broadphase = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.broadphase.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.broadphase;
|
||||||
}
|
}
|
|
@ -48,9 +48,9 @@ Example.car = function() {
|
||||||
World.add(world, Composites.car(350, 300, 150 * scale, 30 * scale, 30 * scale));
|
World.add(world, Composites.car(350, 300, 150 * scale, 30 * scale, 30 * scale));
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(200, 150, 400, 20, { isStatic: true, angle: Math.PI * 0.06 }),
|
Bodies.rectangle(200, 150, 400, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' }}),
|
||||||
Bodies.rectangle(500, 350, 650, 20, { isStatic: true, angle: -Math.PI * 0.06 }),
|
Bodies.rectangle(500, 350, 650, 20, { isStatic: true, angle: -Math.PI * 0.06, render: { fillStyle: '#060a19' }}),
|
||||||
Bodies.rectangle(300, 560, 600, 20, { isStatic: true, angle: Math.PI * 0.04 })
|
Bodies.rectangle(300, 560, 600, 20, { isStatic: true, angle: Math.PI * 0.04, render: { fillStyle: '#060a19' }})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// add mouse control
|
// add mouse control
|
||||||
|
@ -89,6 +89,8 @@ Example.car = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.car.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.car;
|
||||||
}
|
}
|
|
@ -48,9 +48,9 @@ Example.catapult = function() {
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
stack,
|
stack,
|
||||||
catapult,
|
catapult,
|
||||||
Bodies.rectangle(400, 600, 800, 50.5, { isStatic: true }),
|
Bodies.rectangle(400, 600, 800, 50.5, { isStatic: true, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(250, 555, 20, 50, { isStatic: true }),
|
Bodies.rectangle(250, 555, 20, 50, { isStatic: true, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(400, 535, 20, 80, { isStatic: true, collisionFilter: { group: group } }),
|
Bodies.rectangle(400, 535, 20, 80, { isStatic: true, collisionFilter: { group: group }, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.circle(560, 100, 50, { density: 0.005 }),
|
Bodies.circle(560, 100, 50, { density: 0.005 }),
|
||||||
Constraint.create({
|
Constraint.create({
|
||||||
bodyA: catapult,
|
bodyA: catapult,
|
||||||
|
@ -96,6 +96,8 @@ Example.catapult = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.catapult.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.catapult;
|
||||||
}
|
}
|
|
@ -122,6 +122,8 @@ Example.chains = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.chains.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.chains;
|
||||||
}
|
}
|
|
@ -81,6 +81,8 @@ Example.circleStack = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.circleStack.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.circleStack;
|
||||||
}
|
}
|
|
@ -43,8 +43,8 @@ Example.cloth = function() {
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
cloth,
|
cloth,
|
||||||
Bodies.circle(300, 500, 80, { isStatic: true }),
|
Bodies.circle(300, 500, 80, { isStatic: true, render: { fillStyle: '#060a19' }}),
|
||||||
Bodies.rectangle(500, 480, 80, 80, { isStatic: true }),
|
Bodies.rectangle(500, 480, 80, 80, { isStatic: true, render: { fillStyle: '#060a19' }}),
|
||||||
Bodies.rectangle(400, 609, 800, 50, { isStatic: true })
|
Bodies.rectangle(400, 609, 800, 50, { isStatic: true })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -84,6 +84,8 @@ Example.cloth = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.cloth.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.cloth;
|
||||||
}
|
}
|
|
@ -23,8 +23,7 @@ Example.collisionFiltering = function() {
|
||||||
options: {
|
options: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
wireframes: false,
|
wireframes: false
|
||||||
background: '#111'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -40,9 +39,9 @@ Example.collisionFiltering = function() {
|
||||||
greenCategory = 0x0004,
|
greenCategory = 0x0004,
|
||||||
blueCategory = 0x0008;
|
blueCategory = 0x0008;
|
||||||
|
|
||||||
var redColor = '#C44D58',
|
var colorA = '#f55a3c',
|
||||||
blueColor = '#4ECDC4',
|
colorB = '#063e7b',
|
||||||
greenColor = '#C7F464';
|
colorC = '#f5d259';
|
||||||
|
|
||||||
// add floor
|
// add floor
|
||||||
World.add(world, Bodies.rectangle(400, 600, 900, 50, {
|
World.add(world, Bodies.rectangle(400, 600, 900, 50, {
|
||||||
|
@ -57,14 +56,14 @@ Example.collisionFiltering = function() {
|
||||||
World.add(world,
|
World.add(world,
|
||||||
Composites.stack(275, 100, 5, 9, 10, 10, function(x, y, column, row) {
|
Composites.stack(275, 100, 5, 9, 10, 10, function(x, y, column, row) {
|
||||||
var category = redCategory,
|
var category = redCategory,
|
||||||
color = redColor;
|
color = colorA;
|
||||||
|
|
||||||
if (row > 5) {
|
if (row > 5) {
|
||||||
category = blueCategory;
|
category = blueCategory;
|
||||||
color = blueColor;
|
color = colorB;
|
||||||
} else if (row > 2) {
|
} else if (row > 2) {
|
||||||
category = greenCategory;
|
category = greenCategory;
|
||||||
color = greenColor;
|
color = colorC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Bodies.circle(x, y, 20, {
|
return Bodies.circle(x, y, 20, {
|
||||||
|
@ -87,7 +86,7 @@ Example.collisionFiltering = function() {
|
||||||
mask: defaultCategory | greenCategory
|
mask: defaultCategory | greenCategory
|
||||||
},
|
},
|
||||||
render: {
|
render: {
|
||||||
fillStyle: greenColor
|
fillStyle: colorC
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -99,7 +98,7 @@ Example.collisionFiltering = function() {
|
||||||
mask: defaultCategory | redCategory
|
mask: defaultCategory | redCategory
|
||||||
},
|
},
|
||||||
render: {
|
render: {
|
||||||
fillStyle: redColor
|
fillStyle: colorA
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -111,7 +110,7 @@ Example.collisionFiltering = function() {
|
||||||
mask: defaultCategory | blueCategory
|
mask: defaultCategory | blueCategory
|
||||||
},
|
},
|
||||||
render: {
|
render: {
|
||||||
fillStyle: blueColor
|
fillStyle: colorB
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -155,6 +154,8 @@ Example.collisionFiltering = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.collisionFiltering.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.collisionFiltering;
|
||||||
}
|
}
|
|
@ -108,6 +108,8 @@ Example.compositeManipulation = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.compositeManipulation.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.compositeManipulation;
|
||||||
}
|
}
|
|
@ -106,6 +106,8 @@ Example.compound = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.compound.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.compound;
|
||||||
}
|
}
|
|
@ -89,6 +89,8 @@ Example.compoundStack = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.compoundStack.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.compoundStack;
|
||||||
}
|
}
|
|
@ -47,7 +47,7 @@ Example.concave = function() {
|
||||||
horseShoe = Vertices.fromPath('35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7');
|
horseShoe = Vertices.fromPath('35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7');
|
||||||
|
|
||||||
var stack = Composites.stack(50, 50, 6, 4, 10, 10, function(x, y) {
|
var stack = Composites.stack(50, 50, 6, 4, 10, 10, function(x, y) {
|
||||||
var color = Common.choose(['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58']);
|
var color = Common.choose(['#f19648', '#f5d259', '#f55a3c', '#063e7b', '#ececd1']);
|
||||||
return Bodies.fromVertices(x, y, Common.choose([arrow, chevron, star, horseShoe]), {
|
return Bodies.fromVertices(x, y, Common.choose([arrow, chevron, star, horseShoe]), {
|
||||||
render: {
|
render: {
|
||||||
fillStyle: color,
|
fillStyle: color,
|
||||||
|
@ -95,6 +95,8 @@ Example.concave = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.concave.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.concave;
|
||||||
}
|
}
|
|
@ -179,6 +179,8 @@ Example.constraints = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.constraints.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.constraints;
|
||||||
}
|
}
|
|
@ -26,8 +26,7 @@ Example.doublePendulum = function() {
|
||||||
options: {
|
options: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
wireframes: false,
|
wireframes: false
|
||||||
background: '#0f0f13'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,9 +53,6 @@ Example.doublePendulum = function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
pendulum.bodies[0].render.strokeStyle = '#4a485b';
|
|
||||||
pendulum.bodies[1].render.strokeStyle = '#4a485b';
|
|
||||||
|
|
||||||
world.gravity.scale = 0.002;
|
world.gravity.scale = 0.002;
|
||||||
|
|
||||||
Composites.chain(pendulum, 0.45, 0, -0.45, 0, {
|
Composites.chain(pendulum, 0.45, 0, -0.45, 0, {
|
||||||
|
@ -152,6 +148,8 @@ Example.doublePendulum = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.doublePendulum.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.doublePendulum;
|
||||||
}
|
}
|
|
@ -186,6 +186,8 @@ Example.events = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.events.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.events;
|
||||||
}
|
}
|
|
@ -40,17 +40,17 @@ Example.friction = function() {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(300, 180, 700, 20, { isStatic: true, angle: Math.PI * 0.06 }),
|
Bodies.rectangle(300, 180, 700, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(300, 70, 40, 40, { friction: 0.001 })
|
Bodies.rectangle(300, 70, 40, 40, { friction: 0.001 })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(300, 350, 700, 20, { isStatic: true, angle: Math.PI * 0.06 }),
|
Bodies.rectangle(300, 350, 700, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(300, 250, 40, 40, { friction: 0.0005 })
|
Bodies.rectangle(300, 250, 40, 40, { friction: 0.0005 })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
Bodies.rectangle(300, 520, 700, 20, { isStatic: true, angle: Math.PI * 0.06 }),
|
Bodies.rectangle(300, 520, 700, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
|
||||||
Bodies.rectangle(300, 430, 40, 40, { friction: 0 })
|
Bodies.rectangle(300, 430, 40, 40, { friction: 0 })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -90,6 +90,8 @@ Example.friction = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.friction.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.friction;
|
||||||
}
|
}
|
|
@ -96,6 +96,8 @@ Example.gravity = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.gravity.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.gravity;
|
||||||
}
|
}
|
|
@ -130,6 +130,8 @@ Example.gyro = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.gyro.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.gyro;
|
||||||
}
|
}
|
|
@ -36,15 +36,15 @@ Example.manipulation = function() {
|
||||||
Runner.run(runner, engine);
|
Runner.run(runner, engine);
|
||||||
|
|
||||||
// add bodies
|
// add bodies
|
||||||
var bodyA = Bodies.rectangle(100, 200, 50, 50, { isStatic: true }),
|
var bodyA = Bodies.rectangle(100, 200, 50, 50, { isStatic: true, render: { fillStyle: '#060a19' } }),
|
||||||
bodyB = Bodies.rectangle(200, 200, 50, 50),
|
bodyB = Bodies.rectangle(200, 200, 50, 50),
|
||||||
bodyC = Bodies.rectangle(300, 200, 50, 50),
|
bodyC = Bodies.rectangle(300, 200, 50, 50),
|
||||||
bodyD = Bodies.rectangle(400, 200, 50, 50),
|
bodyD = Bodies.rectangle(400, 200, 50, 50),
|
||||||
bodyE = Bodies.rectangle(550, 200, 50, 50),
|
bodyE = Bodies.rectangle(550, 200, 50, 50),
|
||||||
bodyF = Bodies.rectangle(700, 200, 50, 50),
|
bodyF = Bodies.rectangle(700, 200, 50, 50),
|
||||||
bodyG = Bodies.circle(400, 100, 25),
|
bodyG = Bodies.circle(400, 100, 25, { render: { fillStyle: '#060a19' } }),
|
||||||
partA = Bodies.rectangle(600, 200, 120 * 0.8, 50 * 0.8),
|
partA = Bodies.rectangle(600, 200, 120 * 0.8, 50 * 0.8, { render: { fillStyle: '#060a19' } }),
|
||||||
partB = Bodies.rectangle(660, 200, 50 * 0.8, 190 * 0.8),
|
partB = Bodies.rectangle(660, 200, 50 * 0.8, 190 * 0.8, { render: { fillStyle: '#060a19' } }),
|
||||||
compound = Body.create({
|
compound = Body.create({
|
||||||
parts: [partA, partB],
|
parts: [partA, partB],
|
||||||
isStatic: true
|
isStatic: true
|
||||||
|
@ -139,6 +139,8 @@ Example.manipulation = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.manipulation.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.manipulation;
|
||||||
}
|
}
|
|
@ -105,6 +105,8 @@ Example.mixed = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.mixed.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.mixed;
|
||||||
}
|
}
|
|
@ -76,6 +76,8 @@ Example.newtonsCradle = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.newtonsCradle.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.newtonsCradle;
|
||||||
}
|
}
|
|
@ -81,6 +81,8 @@ Example.pyramid = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.pyramid.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.pyramid;
|
||||||
}
|
}
|
|
@ -25,8 +25,7 @@ Example.ragdoll = function() {
|
||||||
options: {
|
options: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
showAngleIndicator: true,
|
showAngleIndicator: true
|
||||||
background: '#0f0f13'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -43,7 +42,9 @@ Example.ragdoll = function() {
|
||||||
return Bodies.rectangle(x - 50, y + column * 50, 100, 1000, {
|
return Bodies.rectangle(x - 50, y + column * 50, 100, 1000, {
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
render: {
|
render: {
|
||||||
fillStyle: '#222'
|
fillStyle: '#060a19',
|
||||||
|
strokeStyle: '#ffffff',
|
||||||
|
lineWidth: 1
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -53,7 +54,7 @@ Example.ragdoll = function() {
|
||||||
var sides = Math.round(Common.random(1, 8)),
|
var sides = Math.round(Common.random(1, 8)),
|
||||||
options = {
|
options = {
|
||||||
render: {
|
render: {
|
||||||
fillStyle: Common.choose(['#006BA6', '#0496FF', '#D81159', '#8F2D56'])
|
fillStyle: Common.choose(['#f19648', '#f5d259', '#f55a3c', '#063e7b', '#ececd1'])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -495,6 +496,8 @@ Example.ragdoll.ragdoll = function(x, y, scale, options) {
|
||||||
return person;
|
return person;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.ragdoll.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.ragdoll;
|
||||||
}
|
}
|
|
@ -135,6 +135,8 @@ Example.raycasting = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.raycasting.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.raycasting;
|
||||||
}
|
}
|
|
@ -85,6 +85,8 @@ Example.restitution = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.restitution.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.restitution;
|
||||||
}
|
}
|
|
@ -109,6 +109,8 @@ Example.rounded = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.rounded.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.rounded;
|
||||||
}
|
}
|
|
@ -21,8 +21,7 @@ Example.sensors = function() {
|
||||||
options: {
|
options: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
wireframes: false,
|
wireframes: false
|
||||||
background: '#111'
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,14 +32,14 @@ Example.sensors = function() {
|
||||||
Runner.run(runner, engine);
|
Runner.run(runner, engine);
|
||||||
|
|
||||||
// add bodies
|
// add bodies
|
||||||
var redColor = '#C44D58',
|
var colorA = '#f55a3c',
|
||||||
greenColor = '#C7F464';
|
colorB = '#f5d259';
|
||||||
|
|
||||||
var collider = Bodies.rectangle(400, 300, 500, 50, {
|
var collider = Bodies.rectangle(400, 300, 500, 50, {
|
||||||
isSensor: true,
|
isSensor: true,
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
render: {
|
render: {
|
||||||
strokeStyle: redColor,
|
strokeStyle: colorA,
|
||||||
fillStyle: 'transparent',
|
fillStyle: 'transparent',
|
||||||
lineWidth: 1
|
lineWidth: 1
|
||||||
}
|
}
|
||||||
|
@ -48,11 +47,11 @@ Example.sensors = function() {
|
||||||
|
|
||||||
World.add(world, [
|
World.add(world, [
|
||||||
collider,
|
collider,
|
||||||
Bodies.rectangle(400, 620, 800, 50, {
|
Bodies.rectangle(400, 600, 800, 50, {
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
render: {
|
render: {
|
||||||
fillStyle: 'transparent',
|
fillStyle: '#060a19',
|
||||||
lineWidth: 1
|
lineWidth: 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
@ -60,7 +59,7 @@ Example.sensors = function() {
|
||||||
World.add(world,
|
World.add(world,
|
||||||
Bodies.circle(400, 40, 30, {
|
Bodies.circle(400, 40, 30, {
|
||||||
render: {
|
render: {
|
||||||
strokeStyle: greenColor,
|
strokeStyle: colorB,
|
||||||
fillStyle: 'transparent',
|
fillStyle: 'transparent',
|
||||||
lineWidth: 1
|
lineWidth: 1
|
||||||
}
|
}
|
||||||
|
@ -74,9 +73,9 @@ Example.sensors = function() {
|
||||||
var pair = pairs[i];
|
var pair = pairs[i];
|
||||||
|
|
||||||
if (pair.bodyA === collider) {
|
if (pair.bodyA === collider) {
|
||||||
pair.bodyB.render.strokeStyle = redColor;
|
pair.bodyB.render.strokeStyle = colorA;
|
||||||
} else if (pair.bodyB === collider) {
|
} else if (pair.bodyB === collider) {
|
||||||
pair.bodyA.render.strokeStyle = redColor;
|
pair.bodyA.render.strokeStyle = colorA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,9 +87,9 @@ Example.sensors = function() {
|
||||||
var pair = pairs[i];
|
var pair = pairs[i];
|
||||||
|
|
||||||
if (pair.bodyA === collider) {
|
if (pair.bodyA === collider) {
|
||||||
pair.bodyB.render.strokeStyle = greenColor;
|
pair.bodyB.render.strokeStyle = colorB;
|
||||||
} else if (pair.bodyB === collider) {
|
} else if (pair.bodyB === collider) {
|
||||||
pair.bodyA.render.strokeStyle = greenColor;
|
pair.bodyA.render.strokeStyle = colorB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -131,6 +130,8 @@ Example.sensors = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.sensors.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.sensors;
|
||||||
}
|
}
|
|
@ -104,6 +104,8 @@ Example.sleeping = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.sleeping.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.sleeping;
|
||||||
}
|
}
|
|
@ -35,7 +35,7 @@ Example.slingshot = function() {
|
||||||
Runner.run(runner, engine);
|
Runner.run(runner, engine);
|
||||||
|
|
||||||
// add bodies
|
// add bodies
|
||||||
var ground = Bodies.rectangle(395, 600, 815, 50, { isStatic: true }),
|
var ground = Bodies.rectangle(395, 600, 815, 50, { isStatic: true, render: { fillStyle: '#060a19' } }),
|
||||||
rockOptions = { density: 0.004 },
|
rockOptions = { density: 0.004 },
|
||||||
rock = Bodies.polygon(170, 450, 8, 20, rockOptions),
|
rock = Bodies.polygon(170, 450, 8, 20, rockOptions),
|
||||||
anchor = { x: 170, y: 450 },
|
anchor = { x: 170, y: 450 },
|
||||||
|
@ -49,7 +49,7 @@ Example.slingshot = function() {
|
||||||
return Bodies.rectangle(x, y, 25, 40);
|
return Bodies.rectangle(x, y, 25, 40);
|
||||||
});
|
});
|
||||||
|
|
||||||
var ground2 = Bodies.rectangle(610, 250, 200, 20, { isStatic: true });
|
var ground2 = Bodies.rectangle(610, 250, 200, 20, { isStatic: true, render: { fillStyle: '#060a19' } });
|
||||||
|
|
||||||
var pyramid2 = Composites.pyramid(550, 0, 5, 10, 0, 0, function(x, y) {
|
var pyramid2 = Composites.pyramid(550, 0, 5, 10, 0, 0, function(x, y) {
|
||||||
return Bodies.rectangle(x, y, 25, 40);
|
return Bodies.rectangle(x, y, 25, 40);
|
||||||
|
@ -107,6 +107,8 @@ Example.slingshot = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.slingshot.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.slingshot;
|
||||||
}
|
}
|
|
@ -85,6 +85,8 @@ Example.softBody = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.softBody.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.softBody;
|
||||||
}
|
}
|
|
@ -22,7 +22,6 @@ Example.sprites = function() {
|
||||||
options: {
|
options: {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
background: '#0f0f13',
|
|
||||||
showAngleIndicator: false,
|
showAngleIndicator: false,
|
||||||
wireframes: false
|
wireframes: false
|
||||||
}
|
}
|
||||||
|
@ -113,6 +112,8 @@ Example.sprites = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.sprites.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.sprites;
|
||||||
}
|
}
|
|
@ -81,6 +81,8 @@ Example.stack = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.stack.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.stack;
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@ Example.staticFriction = function() {
|
||||||
Runner.run(runner, engine);
|
Runner.run(runner, engine);
|
||||||
|
|
||||||
// add bodies
|
// add bodies
|
||||||
var body = Bodies.rectangle(400, 500, 200, 60, { isStatic: true, chamfer: 10 }),
|
var body = Bodies.rectangle(400, 500, 200, 60, { isStatic: true, chamfer: 10, isStatic: true, chamfer: 10, render: { fillStyle: '#060a19' } }),
|
||||||
size = 50;
|
size = 50;
|
||||||
|
|
||||||
var stack = Composites.stack(350, 470 - 6 * size, 1, 6, 0, 0, function(x, y) {
|
var stack = Composites.stack(350, 470 - 6 * size, 1, 6, 0, 0, function(x, y) {
|
||||||
|
@ -101,6 +101,8 @@ Example.staticFriction = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.staticFriction.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.staticFriction;
|
||||||
}
|
}
|
|
@ -79,6 +79,8 @@ Example.stress = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.stress.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.stress;
|
||||||
}
|
}
|
|
@ -79,6 +79,8 @@ Example.stress2 = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.stress2.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.stress2;
|
||||||
}
|
}
|
|
@ -45,7 +45,7 @@ Example.svg = function() {
|
||||||
(function(i) {
|
(function(i) {
|
||||||
$.get('./svg/' + svgs[i] + '.svg').done(function(data) {
|
$.get('./svg/' + svgs[i] + '.svg').done(function(data) {
|
||||||
var vertexSets = [],
|
var vertexSets = [],
|
||||||
color = Common.choose(['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58']);
|
color = Common.choose(['#f19648', '#f5d259', '#f55a3c', '#063e7b', '#ececd1']);
|
||||||
|
|
||||||
$(data).find('path').each(function(i, path) {
|
$(data).find('path').each(function(i, path) {
|
||||||
var points = Svg.pathToVertices(path, 30);
|
var points = Svg.pathToVertices(path, 30);
|
||||||
|
@ -65,7 +65,7 @@ Example.svg = function() {
|
||||||
|
|
||||||
$.get('./svg/svg.svg').done(function(data) {
|
$.get('./svg/svg.svg').done(function(data) {
|
||||||
var vertexSets = [],
|
var vertexSets = [],
|
||||||
color = Common.choose(['#556270', '#4ECDC4', '#C7F464', '#FF6B6B', '#C44D58']);
|
color = Common.choose(['#f19648', '#f5d259', '#f55a3c', '#063e7b', '#ececd1']);
|
||||||
|
|
||||||
$(data).find('path').each(function(i, path) {
|
$(data).find('path').each(function(i, path) {
|
||||||
vertexSets.push(Svg.pathToVertices(path, 30));
|
vertexSets.push(Svg.pathToVertices(path, 30));
|
||||||
|
@ -124,6 +124,8 @@ Example.svg = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.svg.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.svg;
|
||||||
}
|
}
|
|
@ -47,8 +47,8 @@ Example.terrain = function() {
|
||||||
terrain = Bodies.fromVertices(400, 350, vertexSets, {
|
terrain = Bodies.fromVertices(400, 350, vertexSets, {
|
||||||
isStatic: true,
|
isStatic: true,
|
||||||
render: {
|
render: {
|
||||||
fillStyle: '#2e2b44',
|
fillStyle: '#060a19',
|
||||||
strokeStyle: '#2e2b44',
|
strokeStyle: '#060a19',
|
||||||
lineWidth: 1
|
lineWidth: 1
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -105,6 +105,8 @@ Example.terrain = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.terrain.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example;
|
module.exports = Example.terrain;
|
||||||
}
|
}
|
|
@ -150,6 +150,8 @@ Example.timescale = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.timescale.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.timescale;
|
||||||
}
|
}
|
|
@ -182,6 +182,8 @@ Example.views = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.views.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.views;
|
||||||
}
|
}
|
|
@ -93,6 +93,8 @@ Example.wreckingBall = function() {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Example.wreckingBall.for = '>=0.14.2';
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = Example[Object.keys(Example)[0]];
|
module.exports = Example.wreckingBall;
|
||||||
}
|
}
|
10350
package-lock.json
generated
10350
package-lock.json
generated
File diff suppressed because it is too large
Load diff
35
package.json
35
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "matter-js",
|
"name": "matter-js",
|
||||||
"version": "0.14.2",
|
"version": "0.15.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "http://brm.io/matter-js/",
|
"homepage": "http://brm.io/matter-js/",
|
||||||
"author": "Liam Brummitt <liam@brm.io> (http://brm.io/)",
|
"author": "Liam Brummitt <liam@brm.io> (http://brm.io/)",
|
||||||
|
@ -20,30 +20,35 @@
|
||||||
"rigid body physics"
|
"rigid body physics"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"conventional-changelog-cli": "^2.1.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"gulp": "^4.0.2",
|
|
||||||
"gulp-bump": "^2.6.1",
|
|
||||||
"gulp-conventional-changelog": "^1.1.0",
|
|
||||||
"gulp-tag-version": "^1.3.0",
|
|
||||||
"gulp-util": "^3.0.8",
|
|
||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-worker": "^24.9.0",
|
"jest-worker": "^24.9.0",
|
||||||
"json-stringify-pretty-compact": "^2.0.0",
|
"json-stringify-pretty-compact": "^2.0.0",
|
||||||
"run-sequence": "^1.1.4",
|
"puppeteer-core": "^5.5.0",
|
||||||
"webpack": "^4.42.0",
|
"run-sequence": "^2.2.1",
|
||||||
|
"webpack": "^4.44.2",
|
||||||
"webpack-cli": "^3.3.11",
|
"webpack-cli": "^3.3.11",
|
||||||
"webpack-dev-server": "^3.10.3"
|
"webpack-dev-server": "^3.11.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack-dev-server --watch-content-base",
|
"dev": "webpack-dev-server --watch-content-base",
|
||||||
"build": "webpack --mode=production & webpack --mode=production --env.MINIMIZE",
|
"build": "webpack --mode=production & webpack --mode=production --env.MINIMIZE",
|
||||||
"build-alpha": "webpack --mode=production --env.ALPHA & webpack --mode=production --env.MINIMIZE --env.ALPHA",
|
"build-alpha": "webpack --mode=production --env.ALPHA & webpack --mode=production --env.MINIMIZE --env.ALPHA",
|
||||||
"build-examples": "webpack --config webpack.examples.config.js --mode=production --env.ALPHA & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.ALPHA",
|
"build-examples": "webpack --config webpack.examples.config.js --mode=production & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE",
|
||||||
"lint": "eslint 'src/**/*.js' 'demo/js/Demo.js' 'demo/js/Compare.js' 'examples/*.js' 'webpack.*.js' 'Gulpfile.js'",
|
"build-examples-alpha": "webpack --config webpack.examples.config.js --mode=production --env.ALPHA & webpack --config webpack.examples.config.js --mode=production --env.MINIMIZE --env.ALPHA",
|
||||||
"doc": "gulp doc",
|
"lint": "eslint 'src/**/*.js' 'demo/js/Demo.js' 'demo/js/Compare.js' 'examples/*.js' 'webpack.*.js'",
|
||||||
"test": "jest",
|
"doc": "yuidoc --config yuidoc.json --project-version $npm_package_version",
|
||||||
"test-save": "SAVE=true jest",
|
"test": "npm run test-node",
|
||||||
"test-watch": "jest --watch"
|
"test-all": "jest",
|
||||||
|
"test-save": "SAVE=true npm run test-node",
|
||||||
|
"test-watch": "npm run test-node -- --watch",
|
||||||
|
"test-node": "jest ./test/Examples.spec.js",
|
||||||
|
"test-browser": "jest ./test/Browser.spec.js",
|
||||||
|
"changelog": "conventional-changelog -i CHANGELOG.md -s -r",
|
||||||
|
"release": "npm version --no-git-tag-version",
|
||||||
|
"preversion": "git checkout master && npm run lint && SAVE=true npm run test-all",
|
||||||
|
"version": "git checkout -b release/$npm_package_version && npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"files": [
|
"files": [
|
||||||
|
|
|
@ -75,13 +75,15 @@ var Axes = require('../geometry/Axes');
|
||||||
render: {
|
render: {
|
||||||
visible: true,
|
visible: true,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
|
strokeStyle: null,
|
||||||
|
fillStyle: null,
|
||||||
|
lineWidth: null,
|
||||||
sprite: {
|
sprite: {
|
||||||
xScale: 1,
|
xScale: 1,
|
||||||
yScale: 1,
|
yScale: 1,
|
||||||
xOffset: 0,
|
xOffset: 0,
|
||||||
yOffset: 0
|
yOffset: 0
|
||||||
},
|
}
|
||||||
lineWidth: 0
|
|
||||||
},
|
},
|
||||||
events: null,
|
events: null,
|
||||||
bounds: null,
|
bounds: null,
|
||||||
|
@ -166,10 +168,12 @@ var Axes = require('../geometry/Axes');
|
||||||
});
|
});
|
||||||
|
|
||||||
// render properties
|
// render properties
|
||||||
var defaultFillStyle = (body.isStatic ? '#2e2b44' : Common.choose(['#006BA6', '#0496FF', '#FFBC42', '#D81159', '#8F2D56'])),
|
var defaultFillStyle = (body.isStatic ? '#14151f' : Common.choose(['#f19648', '#f5d259', '#f55a3c', '#063e7b', '#ececd1'])),
|
||||||
defaultStrokeStyle = '#000';
|
defaultStrokeStyle = body.isStatic ? '#555' : '#ccc',
|
||||||
|
defaultLineWidth = body.isStatic && body.render.fillStyle === null ? 1 : 0;
|
||||||
body.render.fillStyle = body.render.fillStyle || defaultFillStyle;
|
body.render.fillStyle = body.render.fillStyle || defaultFillStyle;
|
||||||
body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle;
|
body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle;
|
||||||
|
body.render.lineWidth = body.render.lineWidth || defaultLineWidth;
|
||||||
body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
|
body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x);
|
||||||
body.render.sprite.yOffset += -(body.bounds.min.y - body.position.y) / (body.bounds.max.y - body.bounds.min.y);
|
body.render.sprite.yOffset += -(body.bounds.min.y - body.position.y) / (body.bounds.max.y - body.bounds.min.y);
|
||||||
};
|
};
|
||||||
|
|
|
@ -266,6 +266,8 @@ var Common = require('./Common');
|
||||||
* Only the following range types are supported:
|
* Only the following range types are supported:
|
||||||
* - Tilde ranges e.g. `~1.2.3`
|
* - Tilde ranges e.g. `~1.2.3`
|
||||||
* - Caret ranges e.g. `^1.2.3`
|
* - Caret ranges e.g. `^1.2.3`
|
||||||
|
* - Greater than ranges e.g. `>1.2.3`
|
||||||
|
* - Greater than or equal ranges e.g. `>=1.2.3`
|
||||||
* - Exact version e.g. `1.2.3`
|
* - Exact version e.g. `1.2.3`
|
||||||
* - Any version `*`
|
* - Any version `*`
|
||||||
* @method versionParse
|
* @method versionParse
|
||||||
|
@ -273,29 +275,28 @@ var Common = require('./Common');
|
||||||
* @return {object} The version range parsed into its components.
|
* @return {object} The version range parsed into its components.
|
||||||
*/
|
*/
|
||||||
Plugin.versionParse = function(range) {
|
Plugin.versionParse = function(range) {
|
||||||
var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/;
|
var pattern = /^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-]+)?$/;
|
||||||
|
|
||||||
if (!pattern.test(range)) {
|
if (!pattern.test(range)) {
|
||||||
Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.');
|
Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var identifiers = range.split('-');
|
var parts = pattern.exec(range);
|
||||||
range = identifiers[0];
|
var major = Number(parts[4]);
|
||||||
|
var minor = Number(parts[5]);
|
||||||
var isRange = isNaN(Number(range[0])),
|
var patch = Number(parts[6]);
|
||||||
version = isRange ? range.substr(1) : range,
|
|
||||||
parts = Common.map(version.split('.'), function(part) {
|
|
||||||
return Number(part);
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isRange: isRange,
|
isRange: Boolean(parts[1] || parts[2]),
|
||||||
version: version,
|
version: parts[3],
|
||||||
range: range,
|
range: range,
|
||||||
operator: isRange ? range[0] : '',
|
operator: parts[1] || parts[2] || '',
|
||||||
parts: parts,
|
major: major,
|
||||||
prerelease: identifiers[1],
|
minor: minor,
|
||||||
number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2]
|
patch: patch,
|
||||||
|
parts: [major, minor, patch],
|
||||||
|
prerelease: parts[7],
|
||||||
|
number: major * 1e8 + minor * 1e4 + patch
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -311,30 +312,36 @@ var Common = require('./Common');
|
||||||
Plugin.versionSatisfies = function(version, range) {
|
Plugin.versionSatisfies = function(version, range) {
|
||||||
range = range || '*';
|
range = range || '*';
|
||||||
|
|
||||||
var rangeParsed = Plugin.versionParse(range),
|
var r = Plugin.versionParse(range),
|
||||||
rangeParts = rangeParsed.parts,
|
v = Plugin.versionParse(version);
|
||||||
versionParsed = Plugin.versionParse(version),
|
|
||||||
versionParts = versionParsed.parts;
|
|
||||||
|
|
||||||
if (rangeParsed.isRange) {
|
if (r.isRange) {
|
||||||
if (rangeParsed.operator === '*' || version === '*') {
|
if (r.operator === '*' || version === '*') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rangeParsed.operator === '~') {
|
if (r.operator === '>') {
|
||||||
return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2];
|
return v.number > r.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rangeParsed.operator === '^') {
|
if (r.operator === '>=') {
|
||||||
if (rangeParts[0] > 0) {
|
return v.number >= r.number;
|
||||||
return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number;
|
}
|
||||||
|
|
||||||
|
if (r.operator === '~') {
|
||||||
|
return v.major === r.major && v.minor === r.minor && v.patch >= r.patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r.operator === '^') {
|
||||||
|
if (r.major > 0) {
|
||||||
|
return v.major === r.major && v.number >= r.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rangeParts[1] > 0) {
|
if (r.minor > 0) {
|
||||||
return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2];
|
return v.minor === r.minor && v.patch >= r.patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return versionParts[2] === rangeParts[2];
|
return v.patch === r.patch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,7 +196,8 @@ var Vector = require('../geometry/Vector');
|
||||||
* @return {body}
|
* @return {body}
|
||||||
*/
|
*/
|
||||||
Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) {
|
Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) {
|
||||||
var decomp = global.decomp || require('poly-decomp'),
|
var globals = typeof global !== 'undefined' ? global : window,
|
||||||
|
decomp,
|
||||||
body,
|
body,
|
||||||
parts,
|
parts,
|
||||||
isConvex,
|
isConvex,
|
||||||
|
@ -207,6 +208,12 @@ var Vector = require('../geometry/Vector');
|
||||||
v,
|
v,
|
||||||
z;
|
z;
|
||||||
|
|
||||||
|
try {
|
||||||
|
decomp = globals.decomp || require('poly-decomp');
|
||||||
|
} catch (e) {
|
||||||
|
// decomp is undefined
|
||||||
|
}
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
parts = [];
|
parts = [];
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ var Mouse = require('../core/Mouse');
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
pixelRatio: 1,
|
pixelRatio: 1,
|
||||||
background: '#18181d',
|
background: '#14151f',
|
||||||
wireframeBackground: '#0f0f13',
|
wireframeBackground: '#14151f',
|
||||||
hasBounds: !!options.bounds,
|
hasBounds: !!options.bounds,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
wireframes: true,
|
wireframes: true,
|
||||||
|
|
97
test/Browser.spec.js
Normal file
97
test/Browser.spec.js
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/* eslint-env es6 */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
jest.setTimeout(120 * 1000);
|
||||||
|
|
||||||
|
const puppeteer = require('puppeteer-core');
|
||||||
|
const Example = require('../examples/index');
|
||||||
|
const MatterBuild = require('../build/matter');
|
||||||
|
const { versionSatisfies } = require('../src/core/Plugin');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const examples = Object.keys(Example).filter(key => {
|
||||||
|
const buildVersion = MatterBuild.version;
|
||||||
|
const exampleFor = Example[key].for;
|
||||||
|
return versionSatisfies(buildVersion, exampleFor);
|
||||||
|
});
|
||||||
|
|
||||||
|
const browserPath = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome';
|
||||||
|
const demoPagePath = 'http://localhost:8000/';
|
||||||
|
const totalUpdates = 5;
|
||||||
|
|
||||||
|
if (!fs.existsSync(browserPath)) {
|
||||||
|
// Skip if browser is missing
|
||||||
|
console.warn('Could not find browser. Browser tests skipped.');
|
||||||
|
describe.skip('Browser integration tests');
|
||||||
|
} else {
|
||||||
|
describe('Browser integration tests', () => {
|
||||||
|
let results;
|
||||||
|
|
||||||
|
// Set up the environment and run examples
|
||||||
|
beforeAll(async () => results = await runExamplesBrowser(totalUpdates));
|
||||||
|
|
||||||
|
it('all examples run without throwing error', () => {
|
||||||
|
if (results.error) {
|
||||||
|
console.error(results.error);
|
||||||
|
expect(!results.error).toBe(true);
|
||||||
|
} else {
|
||||||
|
for (const example of examples) {
|
||||||
|
expect(results[example].id).toBe(example);
|
||||||
|
expect(results[example].timestamp).toBeGreaterThan(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const runExamplesBrowser = async updates => {
|
||||||
|
// Set up browser environment
|
||||||
|
const browser = await puppeteer.launch({ executablePath: browserPath });
|
||||||
|
const page = await browser.newPage();
|
||||||
|
const results = {};
|
||||||
|
|
||||||
|
// Load local demo page and catch errors
|
||||||
|
let pageError;
|
||||||
|
const onPageError = error => pageError = error;
|
||||||
|
page.addListener('pageerror', onPageError);
|
||||||
|
await page.goto(demoPagePath).catch(onPageError);
|
||||||
|
|
||||||
|
// For every example
|
||||||
|
for (const example of examples) {
|
||||||
|
// Bail on error
|
||||||
|
if (pageError) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the demo page context
|
||||||
|
results[example] = await page.evaluate(async (example, updates) => {
|
||||||
|
// Set the current example
|
||||||
|
MatterTools.Demo.setExampleById(MatterDemo, example);
|
||||||
|
const instance = MatterDemo.example.instance;
|
||||||
|
let ticks = 0;
|
||||||
|
|
||||||
|
// Wait while running
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
Matter.Events.on(instance.runner, 'tick', () => {
|
||||||
|
// Stop after enough updates
|
||||||
|
if (ticks >= updates) {
|
||||||
|
Matter.Runner.stop(instance.runner);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
ticks += 1;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return results
|
||||||
|
return {
|
||||||
|
id: MatterDemo.example.id,
|
||||||
|
timestamp: instance.engine.timing.timestamp
|
||||||
|
};
|
||||||
|
}, example, updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tear down
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
return pageError ? { error: pageError } : results;
|
||||||
|
};
|
|
@ -7,13 +7,21 @@ const { comparisonReport, toMatchExtrinsics, toMatchIntrinsics } = require('./Te
|
||||||
|
|
||||||
const Example = require('../examples/index');
|
const Example = require('../examples/index');
|
||||||
const MatterBuild = require('../build/matter');
|
const MatterBuild = require('../build/matter');
|
||||||
|
const { versionSatisfies } = require('../src/core/Plugin');
|
||||||
const Worker = require('jest-worker').default;
|
const Worker = require('jest-worker').default;
|
||||||
|
|
||||||
const testComparison = process.env.COMPARE === 'true';
|
const testComparison = process.env.COMPARE === 'true';
|
||||||
const saveComparison = process.env.SAVE === 'true';
|
const saveComparison = process.env.SAVE === 'true';
|
||||||
const excludeExamples = ['svg', 'terrain'];
|
const excludeExamples = ['svg', 'terrain'];
|
||||||
const excludeJitter = ['stack', 'circleStack', 'restitution', 'staticFriction', 'friction', 'newtonsCradle', 'catapult'];
|
const excludeJitter = ['stack', 'circleStack', 'restitution', 'staticFriction', 'friction', 'newtonsCradle', 'catapult'];
|
||||||
const examples = Object.keys(Example).filter(key => !excludeExamples.includes(key));
|
|
||||||
|
const examples = Object.keys(Example).filter(key => {
|
||||||
|
const excluded = excludeExamples.includes(key);
|
||||||
|
const buildVersion = MatterBuild.version;
|
||||||
|
const exampleFor = Example[key].for;
|
||||||
|
const supported = versionSatisfies(buildVersion, exampleFor);
|
||||||
|
return !excluded && supported;
|
||||||
|
});
|
||||||
|
|
||||||
const runExamples = async useDev => {
|
const runExamples = async useDev => {
|
||||||
const worker = new Worker(require.resolve('./ExampleWorker'), {
|
const worker = new Worker(require.resolve('./ExampleWorker'), {
|
||||||
|
|
|
@ -145,13 +145,18 @@ const captureSimilarityExtrinsic = (currentCaptures, referenceCaptures) => {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const writeCaptures = (name, obj) => {
|
const writeResult = (name, obj) => {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(comparePath, { recursive: true });
|
fs.mkdirSync(comparePath, { recursive: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.code !== 'EEXIST') throw err;
|
if (err.code !== 'EEXIST') throw err;
|
||||||
}
|
}
|
||||||
fs.writeFileSync(`${comparePath}/${name}.json`, compactStringify(obj, { maxLength: 100 }), 'utf8');
|
|
||||||
|
if (typeof obj === 'string') {
|
||||||
|
fs.writeFileSync(`${comparePath}/${name}.md`, obj, 'utf8');
|
||||||
|
} else {
|
||||||
|
fs.writeFileSync(`${comparePath}/${name}.json`, compactStringify(obj, { maxLength: 100 }), 'utf8');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const toMatchExtrinsics = {
|
const toMatchExtrinsics = {
|
||||||
|
@ -242,34 +247,37 @@ const comparisonReport = (capturesDev, capturesBuild, buildVersion, save) => {
|
||||||
|
|
||||||
const overlapChange = (totalOverlapDev / (totalOverlapBuild || 1)) - 1;
|
const overlapChange = (totalOverlapDev / (totalOverlapBuild || 1)) - 1;
|
||||||
|
|
||||||
if (save) {
|
const report = (breakEvery, format) => [
|
||||||
writeCaptures('examples-dev', devIntrinsicsChanged);
|
|
||||||
writeCaptures('examples-build', buildIntrinsicsChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
[`Output comparison of ${similarityEntries.length}`,
|
[`Output comparison of ${similarityEntries.length}`,
|
||||||
`examples against ${color('matter-js@' + buildVersion, colors.Yellow)} build on last run`
|
`examples against ${format('matter-js@' + buildVersion, colors.Yellow)} build on last run`
|
||||||
].join(' '),
|
].join(' '),
|
||||||
`\n\n${color('Similarity', colors.White)}`,
|
`\n\n${format('Similarity', colors.White)}`,
|
||||||
`${color(toPercent(similarityAvg), similarityAvg === 1 ? colors.Green : colors.Yellow)}%`,
|
`${format(toPercent(similarityAvg), similarityAvg === 1 ? colors.Green : colors.Yellow)}%`,
|
||||||
`${color('Performance', colors.White)}`,
|
`${format('Performance', colors.White)}`,
|
||||||
`${color((perfChange >= 0 ? '+' : '') + toPercent(perfChange), perfChange >= 0 ? colors.Green : colors.Red)}%`,
|
`${format((perfChange >= 0 ? '+' : '') + toPercent(perfChange), perfChange >= 0 ? colors.Green : colors.Red)}%`,
|
||||||
`${color('Overlap', colors.White)}`,
|
`${format('Overlap', colors.White)}`,
|
||||||
`${color((overlapChange >= 0 ? '+' : '') + toPercent(overlapChange), overlapChange > 0 ? colors.Red : colors.Green)}%`,
|
`${format((overlapChange >= 0 ? '+' : '') + toPercent(overlapChange), overlapChange > 0 ? colors.Red : colors.Green)}%`,
|
||||||
capturePerformance.reduce((output, p, i) => {
|
capturePerformance.reduce((output, p, i) => {
|
||||||
output += `${p.name} `;
|
output += `${p.name} `;
|
||||||
output += `${similarityRatings(similaritys[p.name])} `;
|
output += `${similarityRatings(similaritys[p.name])} `;
|
||||||
output += `${changeRatings(capturesDev[p.name].changedIntrinsics)} `;
|
output += `${changeRatings(capturesDev[p.name].changedIntrinsics)} `;
|
||||||
if (i > 0 && i < capturePerformance.length && i % 5 === 0) {
|
if (i > 0 && i < capturePerformance.length && breakEvery > 0 && i % breakEvery === 0) {
|
||||||
output += '\n';
|
output += '\n';
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}, '\n\n'),
|
}, '\n\n'),
|
||||||
`\nwhere · no change ● extrinsics changed ◆ intrinsics changed\n`,
|
`\nwhere · no change ● extrinsics changed ◆ intrinsics changed\n`,
|
||||||
similarityAvg < 1 ? `\n${color('▶', colors.White)} ${color(compareCommand + '=' + 120 + '#' + similarityEntries[0][0], colors.BrightCyan)}` : '',
|
similarityAvg < 1 ? `\n${format('▶', colors.White)} ${format(compareCommand + '=' + 120 + '#' + similarityEntries[0][0], colors.BrightCyan)}` : '',
|
||||||
intrinsicChangeCount > 0 ? `\n${color('▶', colors.White)} ${color((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : ''
|
intrinsicChangeCount > 0 ? `\n${format('▶', colors.White)} ${format((save ? diffCommand : diffSaveCommand), colors.BrightCyan)}` : ''
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
||||||
|
if (save) {
|
||||||
|
writeResult('examples-dev', devIntrinsicsChanged);
|
||||||
|
writeResult('examples-build', buildIntrinsicsChanged);
|
||||||
|
writeResult('examples-report', report(5, s => s));
|
||||||
|
}
|
||||||
|
|
||||||
|
return report(5, color);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
|
const fs = require('fs');
|
||||||
const execSync = require('child_process').execSync;
|
const execSync = require('child_process').execSync;
|
||||||
|
|
||||||
module.exports = (env = {}) => {
|
module.exports = (env = {}) => {
|
||||||
|
@ -14,16 +15,19 @@ module.exports = (env = {}) => {
|
||||||
|
|
||||||
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
||||||
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
|
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
|
||||||
|
const license = fs.readFileSync('LICENSE', 'utf8');
|
||||||
const date = new Date().toISOString().slice(0, 10);
|
const date = new Date().toISOString().slice(0, 10);
|
||||||
const name = 'matter';
|
const name = 'matter';
|
||||||
const alphaInfo = 'Experimental pre-release build.\n ';
|
const alphaInfo = 'Experimental pre-release build.\n ';
|
||||||
const banner =
|
const banner =
|
||||||
` ${pkg.name} ${version} by @liabru (c) ${date}
|
`${pkg.name} ${version} by @liabru ${date}
|
||||||
${alpha ? alphaInfo : ''}${pkg.homepage}
|
${alpha ? alphaInfo : ''}${pkg.homepage}
|
||||||
License ${pkg.license}`;
|
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;
|
||||||
|
|
||||||
|
const entry = isDevServer ? './demo/js/Server.js' : './src/module/main.js';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: { [name]: './src/module/main.js' },
|
entry: { [name]: entry },
|
||||||
output: {
|
output: {
|
||||||
library: 'Matter',
|
library: 'Matter',
|
||||||
libraryTarget: 'umd',
|
libraryTarget: 'umd',
|
||||||
|
|
|
@ -4,20 +4,24 @@
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const pkg = require('./package.json');
|
const pkg = require('./package.json');
|
||||||
|
const fs = require('fs');
|
||||||
const execSync = require('child_process').execSync;
|
const execSync = require('child_process').execSync;
|
||||||
|
|
||||||
module.exports = (env = {}) => {
|
module.exports = (env = {}) => {
|
||||||
const minimize = env.MINIMIZE || false;
|
const minimize = env.MINIMIZE || false;
|
||||||
const edge = env.EDGE || false;
|
const alpha = env.ALPHA || false;
|
||||||
const maxSize = minimize ? 100 * 1024 : 512 * 1024;
|
const maxSize = minimize ? 100 * 1024 : 512 * 1024;
|
||||||
|
|
||||||
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
|
||||||
const version = !edge ? pkg.version : `${pkg.version}-alpha-${commitHash}`;
|
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
|
||||||
|
const license = fs.readFileSync('LICENSE', 'utf8');
|
||||||
const date = new Date().toISOString().slice(0, 10);
|
const date = new Date().toISOString().slice(0, 10);
|
||||||
const name = 'matter-examples';
|
const name = 'matter-js-examples';
|
||||||
const banner = `${name} ${version} by @liabru ${date}
|
const alphaInfo = 'Experimental pre-release build.\n ';
|
||||||
${pkg.homepage}
|
const banner =
|
||||||
License ${pkg.license}`;
|
`${name} ${version} by @liabru ${date}
|
||||||
|
${alpha ? alphaInfo : ''}${pkg.homepage}
|
||||||
|
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: './examples/index.js',
|
entry: './examples/index.js',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"url": "http://brm.io/matter-js/",
|
"url": "http://brm.io/matter-js/",
|
||||||
"options": {
|
"options": {
|
||||||
"linkNatives": true,
|
"linkNatives": true,
|
||||||
"outdir": "doc/build",
|
"outdir": "docs",
|
||||||
"themedir": "matter-doc-theme",
|
"themedir": "matter-doc-theme",
|
||||||
"paths": "src"
|
"paths": "src"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue