HTML5 JavaScript 2D 物理引擎:Matter.js
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 }));</pre>
特性:
- 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 </ul>

本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!