matter-js README

The project's README from github.com/liabru/matter-js. As one markdown file: README.md.

Matter.js

Matter.js is a JavaScript 2D rigid body physics engine for the web

brm.io/matter-js

Demos ・ Gallery ・ Features ・ Plugins ・ Install ・ Usage ・ Examples ・ Docs ・ Wiki ・ References ・ License

Demos


See how others are using matter.js physics

Features

Install

You can install using package managers npm and Yarn using:

npm install matter-js

Alternatively you can download a stable release or try the latest experimental alpha build (master) and include the script in your web page:

<script src="matter.js" type="text/javascript"></script>

Performance with other tools (e.g. Webpack, Vue etc.)

Bundlers and frameworks may reduce real-time performance when using their default configs, especially in development modes.

When using Webpack, the default sourcemap config can have a large impact, for a solution see issue.

When using Vue.js, watchers can have a large impact, for a solution see issue.

Usage

Visit the Getting started wiki page for a minimal usage example which should work in both browsers and Node.js.
Also see the Running and Rendering wiki pages, which show how to use your own game and rendering loops.

Tutorials

See the list of tutorials.

Examples

See the examples directory which contains the source for all demos.
There are even more examples on codepen.

Plugins

The engine can be extended through plugins, see these resources:

Documentation

See the API Documentation and the wiki

Building and Contributing

To build you must first install node.js, then run

npm install

This will install the required build dependencies, then run

npm run dev

to spawn a development server. For information on contributing see CONTRIBUTING.md.

Changelog

To see what's new or changed in the latest version, see the changelog.

References

See the wiki page on References.

License

Matter.js is licensed under The MIT License (MIT)
Copyright (c) 2014 Liam Brummitt

This license is also supplied with the release and source code.
As stated in the license, absolutely no warranty is provided.

matter-js (liabru/matter-js)

Searching Database…

18.5K ·GitHub
这是什么东西?Matter.js 是一个面向网页的 JavaScript 2D 刚体物理引擎——你可以把它放进网页或 Node.js 应用里,用来做物理模拟。
它是一个我在自己代码里调用的物理库,还是一个现成的游戏引擎?它是一个由你自己的 JavaScript 代码来驱动的库,并不是完整的游戏引擎。它自带一个 canvas 渲染器,但文档会教你如何把它接入自己的游戏循环和渲染循环。
怎么把它加到网页项目里?用 npm 或 Yarn 安装(npm install matter-js),也可以下载稳定版本,然后在页面里引入对应的脚本。它没有任何运行时依赖需要提前安装。
在现代打包工具和框架里使用它有什么坑?有:打包工具和框架的默认配置可能拖累实时性能,开发环境下尤其明显。README 里特别点名了 Webpack 的 sourcemap 和 Vue.js 的 watcher,影响很大。
它只能在浏览器里运行,还是服务器和手机上也能用?浏览器和 Node.js 都支持——包括 Chrome、Firefox、Safari 甚至 IE8+——而且兼容移动端,支持触摸和响应式。
这个物理模拟具体都包含哪些功能?支持刚体、复合体和组合体,凹多边形和凸包,弹性(restitution)、摩擦力、约束、重力、休眠和静态物体,还有射线检测、区域检测这类碰撞查询,以及用于慢动作效果的时间缩放。
它是从别的物理引擎移植过来的吗?不是——README 明确说明它是原创的 JavaScript 实现,不是移植版本。
可以用插件来扩展这个引擎吗?可以,它有插件系统。README 里链接了使用和创建插件的指南、现有插件列表,还有一个 matter-plugin-boilerplate 起步模板。
MatterTools 是什么?它是随引擎附带的一套工具,用来创建、测试和调试物理世界。
Creator
liabru
Size
22.3 MB
Stars
18.5K
Updated
CommitSep 30
Age
12y
Commits · 90 Days