HTML5 JavaScript 2D 物理引擎:Matter.js

jopen 11年前

Matter.js是一款采用JavaScript编写的2D刚体物理引擎。

var Bodies = Matter.Bodies;  var Engine = Matter.Engine;  var engine = Engine.create(container, options);  var World = Matter.World;    World.addBody(engine.world, Bodies.rectangle(300, 180, 700, 20, { isStatic: true, angle: Math.PI * 0.06 }));  World.addBody(enigne.world, Bodies.rectangle(300, 70, 40, 40, { friction: 0.001 }));

特性:

  • Physical properties (mass, area, density etc.)
  • Rigid bodies of any convex polygon
  • Stable stacking and resting
  • Restitution (elastic and inelastic collisions)
  • Conservation of momentum
  • Friction and resistance
  • Constraints
  • Gravity
  • Composite bodies
  • Sleeping and static bodies
  • Original JavaScript physics implementation (not a port)
  • HTML5 canvas renderer
  • Mobile-compatible (touch, scaleable)
  • Cross-browser (chrome, firefox, IE8+)
  • World state serialisation (requires resurrect.js)
  • Built in GUI for testing (requires dat.gui.js)
  • Time scaling (slow-mo, speed-up)
  • Broad-phase, mid-phase and narrow-phase collisions


项目主页:http://www.open-open.com/lib/view/home/1393999878115