mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-23 13:19:01 -05:00
release 0.9.0
This commit is contained in:
parent
5cf19f5a1b
commit
4622406fd2
6 changed files with 657 additions and 294 deletions
330
CHANGELOG.md
330
CHANGELOG.md
|
@ -1,3 +1,333 @@
|
|||
<a name="0.9.0"></a>
|
||||
# 0.9.0 (2016-01-16)
|
||||
|
||||
### release summary
|
||||
|
||||
* improved documentation
|
||||
* improved performance
|
||||
* improved stability
|
||||
* improved accuracy
|
||||
* improved friction
|
||||
* improved sleeping
|
||||
* improved constraints
|
||||
* improved examples
|
||||
|
||||
* added concave body support
|
||||
* added compound body support
|
||||
* added collision filters
|
||||
* added Matter.Body property setters
|
||||
* added Matter.Sleeping events
|
||||
* added Matter.Composite events
|
||||
* added Matter.Composite transforms
|
||||
* added Matter.MouseConstraint events
|
||||
* added Matter.Render events
|
||||
* added Matter.Runner
|
||||
* added support for nodejs
|
||||
* added support for high dpi rendering
|
||||
* added multiple examples
|
||||
* added automated tests
|
||||
|
||||
* migrated from grunt to gulp
|
||||
* migrated to browserify
|
||||
* migrated to pixi.js v3
|
||||
|
||||
* fixed multiple issues (see commit log)
|
||||
|
||||
|
||||
### commit log
|
||||
|
||||
* Add Pixi DisplayObjectContainer to allow view bounds in webGL ([97f0f8d](https://github.com/liabru/matter-js/commit/97f0f8d))
|
||||
* added beforeRender and afterRender events to Matter.Render ([aa48322](https://github.com/liabru/matter-js/commit/aa48322))
|
||||
* added body sleepStart and sleepEnd events, closes #91 ([bc26469](https://github.com/liabru/matter-js/commit/bc26469)), closes [#91](https://github.com/liabru/matter-js/issues/91)
|
||||
* added Body.nextCategory ([d249165](https://github.com/liabru/matter-js/commit/d249165))
|
||||
* added Body.set ([235b6c8](https://github.com/liabru/matter-js/commit/235b6c8))
|
||||
* added Body.setMass, Body.setDensity, Body.setInertia ([ca978fa](https://github.com/liabru/matter-js/commit/ca978fa))
|
||||
* added Body.setPosition, Body.setAngle, Body.setVelocity, Body.setAngularVelocity ([7ed28f7](https://github.com/liabru/matter-js/commit/7ed28f7))
|
||||
* added Body.setVertices and Vector.clone ([b6dbb25](https://github.com/liabru/matter-js/commit/b6dbb25))
|
||||
* added building and contributing to readme ([9a59e34](https://github.com/liabru/matter-js/commit/9a59e34))
|
||||
* added collisionFilter support to MouseConstraint ([cee8d55](https://github.com/liabru/matter-js/commit/cee8d55))
|
||||
* added composite events ([2841522](https://github.com/liabru/matter-js/commit/2841522))
|
||||
* added composite events example to Demo.events ([296d47e](https://github.com/liabru/matter-js/commit/296d47e))
|
||||
* added Composite.translate, Composite.rotate, Composite.scale ([4c4962f](https://github.com/liabru/matter-js/commit/4c4962f))
|
||||
* added compound support to Query.ray ([10e5d0f](https://github.com/liabru/matter-js/commit/10e5d0f))
|
||||
* added constraint to Demo.compound ([87fbf51](https://github.com/liabru/matter-js/commit/87fbf51))
|
||||
* added CONTRIBUTING.md ([7c936d5](https://github.com/liabru/matter-js/commit/7c936d5))
|
||||
* added CONTRIBUTING.md ([261c794](https://github.com/liabru/matter-js/commit/261c794))
|
||||
* added Demo.compositeManipulation ([4051823](https://github.com/liabru/matter-js/commit/4051823))
|
||||
* added Demo.compound ([b7bf5d6](https://github.com/liabru/matter-js/commit/b7bf5d6))
|
||||
* added Demo.concave, added Bodies.fromVertices, added Vertices.isConvex, fixed compound properties ([0b8efa5](https://github.com/liabru/matter-js/commit/0b8efa5))
|
||||
* added Demo.manipulation ([0a453a2](https://github.com/liabru/matter-js/commit/0a453a2))
|
||||
* added Demo.setManualControl ([203252a](https://github.com/liabru/matter-js/commit/203252a))
|
||||
* added Demo.slingshot ([3043baa](https://github.com/liabru/matter-js/commit/3043baa))
|
||||
* added Demo.staticFriction ([4491dfd](https://github.com/liabru/matter-js/commit/4491dfd))
|
||||
* added Demo.svg, Demo.compoundStack, Demo.concave ([17589bc](https://github.com/liabru/matter-js/commit/17589bc))
|
||||
* added Demo.terrain ([3132d70](https://github.com/liabru/matter-js/commit/3132d70))
|
||||
* added docs ([200fcbe](https://github.com/liabru/matter-js/commit/200fcbe))
|
||||
* added docs for engine.timing.isFixed ([e22ceeb](https://github.com/liabru/matter-js/commit/e22ceeb))
|
||||
* added drag events to MouseConstraint, closes #45 ([c254c8d](https://github.com/liabru/matter-js/commit/c254c8d)), closes [#45](https://github.com/liabru/matter-js/issues/45)
|
||||
* added early out in Constraint.postSolveAll, pass body.velocity when updating bounds ([8210dbe](https://github.com/liabru/matter-js/commit/8210dbe))
|
||||
* added internal edge flagging to Bodies.fromVertices ([ca75fde](https://github.com/liabru/matter-js/commit/ca75fde))
|
||||
* added Matter.Svg.pathToPoints ([7822ead](https://github.com/liabru/matter-js/commit/7822ead))
|
||||
* added Matter.version ([e0a6de0](https://github.com/liabru/matter-js/commit/e0a6de0))
|
||||
* added Matter.World extends Matter.Composite to docs ([b3921fb](https://github.com/liabru/matter-js/commit/b3921fb))
|
||||
* added minimum area check to Bodies.fromVertices ([bf11ee5](https://github.com/liabru/matter-js/commit/bf11ee5))
|
||||
* added missing dependency to Render.js ([df5f16c](https://github.com/liabru/matter-js/commit/df5f16c))
|
||||
* added mouse constraint collision mask example to demo ([440e9d2](https://github.com/liabru/matter-js/commit/440e9d2))
|
||||
* added Mouse.create warning for omitted element ([af83e27](https://github.com/liabru/matter-js/commit/af83e27))
|
||||
* added MouseConstraint.create warning for omitted element ([b6603ca](https://github.com/liabru/matter-js/commit/b6603ca))
|
||||
* added node demo tests ([71c1ae8](https://github.com/liabru/matter-js/commit/71c1ae8))
|
||||
* added options to Metrics.create ([1b7e27d](https://github.com/liabru/matter-js/commit/1b7e27d))
|
||||
* added Query.point ([98ea7c7](https://github.com/liabru/matter-js/commit/98ea7c7))
|
||||
* added release tasks ([5479fbc](https://github.com/liabru/matter-js/commit/5479fbc))
|
||||
* added Render.create warning for omitted element ([0583cdb](https://github.com/liabru/matter-js/commit/0583cdb))
|
||||
* added render.options.showMousePosition ([e191d44](https://github.com/liabru/matter-js/commit/e191d44))
|
||||
* added Render.showInternalEdges, added rendering bounds + axes + positions for compounds, fixed rende ([5ab2bf3](https://github.com/liabru/matter-js/commit/5ab2bf3))
|
||||
* added Render.vertexNumbers, Render.bodyConvexHulls ([9c139ed](https://github.com/liabru/matter-js/commit/9c139ed))
|
||||
* added Runner.create and Runner.tick ([5c69f2e](https://github.com/liabru/matter-js/commit/5c69f2e))
|
||||
* added source link to demo ([1e756d3](https://github.com/liabru/matter-js/commit/1e756d3))
|
||||
* added sprite offsets relative to centre of mass, closes #153 ([3de9d00](https://github.com/liabru/matter-js/commit/3de9d00)), closes [#153](https://github.com/liabru/matter-js/issues/153)
|
||||
* added startdrag and enddrag events to Demo.events ([7c75614](https://github.com/liabru/matter-js/commit/7c75614))
|
||||
* added support for compound bodies in MouseConstraint ([d6829bf](https://github.com/liabru/matter-js/commit/d6829bf))
|
||||
* added support for hidpi rendering ([4746eb9](https://github.com/liabru/matter-js/commit/4746eb9))
|
||||
* added support for multiple vertices input in Bodies.fromVertices ([e8205f8](https://github.com/liabru/matter-js/commit/e8205f8))
|
||||
* added support for sprite scale in RenderPixi, closes #54 ([8dea166](https://github.com/liabru/matter-js/commit/8dea166)), closes [#54](https://github.com/liabru/matter-js/issues/54)
|
||||
* added testDemo to grunt test ([08c5648](https://github.com/liabru/matter-js/commit/08c5648))
|
||||
* added time scaling to Sleeping ([0ae2d02](https://github.com/liabru/matter-js/commit/0ae2d02))
|
||||
* added Vector.create ([b327a40](https://github.com/liabru/matter-js/commit/b327a40))
|
||||
* Allow for negative force to bring a body out of sleeping state. ([d585e80](https://github.com/liabru/matter-js/commit/d585e80))
|
||||
* appease jshint ([89140ae](https://github.com/liabru/matter-js/commit/89140ae))
|
||||
* appease jshint ([18a2627](https://github.com/liabru/matter-js/commit/18a2627))
|
||||
* change browser tests to use JSON.stringify ([75af920](https://github.com/liabru/matter-js/commit/75af920))
|
||||
* change gravity scale to variable rather than a constant ([a38b227](https://github.com/liabru/matter-js/commit/a38b227))
|
||||
* change main to edge build ([9d0e82b](https://github.com/liabru/matter-js/commit/9d0e82b))
|
||||
* change travis to only lint rather than full test (until tests are finished and documented) ([ce478cb](https://github.com/liabru/matter-js/commit/ce478cb))
|
||||
* change world.bounds to Infinity, remove world bounds check from Engine, closes #67 ([8b5192d](https://github.com/liabru/matter-js/commit/8b5192d)), closes [#67](https://github.com/liabru/matter-js/issues/67)
|
||||
* changed Body._initProperties to use Body.setVertices ([2d04389](https://github.com/liabru/matter-js/commit/2d04389))
|
||||
* changed bower main to build/matter.js ([7412335](https://github.com/liabru/matter-js/commit/7412335))
|
||||
* changed certain Matter.Composite methods to private in docs ([8aa148d](https://github.com/liabru/matter-js/commit/8aa148d))
|
||||
* changed Common.log to use console.warn ([c220f41](https://github.com/liabru/matter-js/commit/c220f41))
|
||||
* changed default minimum area in Bodies.fromVertices ([998ab33](https://github.com/liabru/matter-js/commit/998ab33))
|
||||
* changed demo to use Matter.Runner and Matter.Render events ([a1d4748](https://github.com/liabru/matter-js/commit/a1d4748))
|
||||
* changed friction impulse limiting approach ([de4784c](https://github.com/liabru/matter-js/commit/de4784c))
|
||||
* changed Grid.create to accept an options object ([eedd1f2](https://github.com/liabru/matter-js/commit/eedd1f2))
|
||||
* changed jquery reference (matter-tools) to local copy ([0849773](https://github.com/liabru/matter-js/commit/0849773))
|
||||
* changed Math.random to Common.random and use a seeded RNG ([0a46cb2](https://github.com/liabru/matter-js/commit/0a46cb2))
|
||||
* changed Mouse.create to return as a plain object ([eaa9767](https://github.com/liabru/matter-js/commit/eaa9767))
|
||||
* changed Render.bodyIds to show all parts ([3ed8034](https://github.com/liabru/matter-js/commit/3ed8034))
|
||||
* changed Sleeping constants to be public (module level) ([7eadea9](https://github.com/liabru/matter-js/commit/7eadea9))
|
||||
* changed vertex number render fillstyle ([bc88406](https://github.com/liabru/matter-js/commit/bc88406))
|
||||
* changed Vertices.create and Vertices.fromPath to create and return a new array rather than apply in- ([e3e462e](https://github.com/liabru/matter-js/commit/e3e462e))
|
||||
* cleanup ([5888ffc](https://github.com/liabru/matter-js/commit/5888ffc))
|
||||
* cleanup Svg.pathToPoints ([8bf3278](https://github.com/liabru/matter-js/commit/8bf3278))
|
||||
* cleanup Svg.pathToVertices ([7db3d28](https://github.com/liabru/matter-js/commit/7db3d28))
|
||||
* demo tweaks ([d55c700](https://github.com/liabru/matter-js/commit/d55c700))
|
||||
* demo tweaks ([22445c7](https://github.com/liabru/matter-js/commit/22445c7))
|
||||
* disabled angle indicators on some demos ([74bc8ae](https://github.com/liabru/matter-js/commit/74bc8ae))
|
||||
* don't calculate gravity force if there is no actual gravity ([e54802c](https://github.com/liabru/matter-js/commit/e54802c))
|
||||
* dont draw offscreen constraints. Set visible flag on offscreen sprites ([e263ecb](https://github.com/liabru/matter-js/commit/e263ecb))
|
||||
* Ensure passed canvas abides by render options ([0b51dd6](https://github.com/liabru/matter-js/commit/0b51dd6))
|
||||
* expose demo instance externally ([a9122ed](https://github.com/liabru/matter-js/commit/a9122ed))
|
||||
* fix angle indicators for compound bodies ([8031090](https://github.com/liabru/matter-js/commit/8031090))
|
||||
* fix bug in Composites.stack when skipping bodies ([b34669e](https://github.com/liabru/matter-js/commit/b34669e))
|
||||
* fix bug when using timing.isFixed, closes #44 ([0933620](https://github.com/liabru/matter-js/commit/0933620)), closes [#44](https://github.com/liabru/matter-js/issues/44)
|
||||
* fix concat dependency ([84a22ba](https://github.com/liabru/matter-js/commit/84a22ba))
|
||||
* fix demo for tests ([5e6b22b](https://github.com/liabru/matter-js/commit/5e6b22b))
|
||||
* fix Demo.reset to fully reset ids ([500d566](https://github.com/liabru/matter-js/commit/500d566))
|
||||
* fix Demo.stress stability ([d0fdd29](https://github.com/liabru/matter-js/commit/d0fdd29))
|
||||
* Fix for travis ([05f1c46](https://github.com/liabru/matter-js/commit/05f1c46))
|
||||
* fix grunt for travis ([d405910](https://github.com/liabru/matter-js/commit/d405910))
|
||||
* fix grunt for travis ([f55d806](https://github.com/liabru/matter-js/commit/f55d806))
|
||||
* fix gulp issues ([4173e70](https://github.com/liabru/matter-js/commit/4173e70))
|
||||
* fix gulp issues ([3bd556d](https://github.com/liabru/matter-js/commit/3bd556d))
|
||||
* fix handling of engine.render ([c46e915](https://github.com/liabru/matter-js/commit/c46e915))
|
||||
* fix issue in Render.inspector on Chrome ([86fcfcd](https://github.com/liabru/matter-js/commit/86fcfcd))
|
||||
* fix issue of undefined body.parts in constructor ([9d3755a](https://github.com/liabru/matter-js/commit/9d3755a))
|
||||
* fix issue when Bodies.trapezoid slope === 1, closes #138 ([449774c](https://github.com/liabru/matter-js/commit/449774c)), closes [#138](https://github.com/liabru/matter-js/issues/138)
|
||||
* fix issue with mouse when changing renderers, closes #96 ([796faeb](https://github.com/liabru/matter-js/commit/796faeb)), closes [#96](https://github.com/liabru/matter-js/issues/96)
|
||||
* fix issue with Render.debug when no timing passed, closes #171 and #176 ([087fab2](https://github.com/liabru/matter-js/commit/087fab2)), closes [#171](https://github.com/liabru/matter-js/issues/171) [#176](https://github.com/liabru/matter-js/issues/176)
|
||||
* fix jshint ([b0f72ab](https://github.com/liabru/matter-js/commit/b0f72ab))
|
||||
* fix lint issue ([9a599f1](https://github.com/liabru/matter-js/commit/9a599f1))
|
||||
* fix Matter.Demo for node ([2de1161](https://github.com/liabru/matter-js/commit/2de1161))
|
||||
* fix Matter.Demo for node ([06eea3e](https://github.com/liabru/matter-js/commit/06eea3e))
|
||||
* fix Matter.Runner for node ([ad55b85](https://github.com/liabru/matter-js/commit/ad55b85))
|
||||
* fix mobile demo, remove dev.html, fix debug info rendering ([9d5c27a](https://github.com/liabru/matter-js/commit/9d5c27a))
|
||||
* fix orientation event bug in DemoMobile ([f770a7c](https://github.com/liabru/matter-js/commit/f770a7c))
|
||||
* fix pair properties for compounds ([b8f3784](https://github.com/liabru/matter-js/commit/b8f3784))
|
||||
* fix runner for tests, limit precision of refs ([352bfd6](https://github.com/liabru/matter-js/commit/352bfd6))
|
||||
* fix standalone option ([de16529](https://github.com/liabru/matter-js/commit/de16529))
|
||||
* fix support for nodejs ([b669ea0](https://github.com/liabru/matter-js/commit/b669ea0))
|
||||
* fix tests ([eccf0a7](https://github.com/liabru/matter-js/commit/eccf0a7))
|
||||
* fix travis ([3ce6c3a](https://github.com/liabru/matter-js/commit/3ce6c3a))
|
||||
* fix travis issue ([131ed5e](https://github.com/liabru/matter-js/commit/131ed5e))
|
||||
* fix undefined variables, added jshint checks, closes #102 ([536e55f](https://github.com/liabru/matter-js/commit/536e55f)), closes [#102](https://github.com/liabru/matter-js/issues/102)
|
||||
* fixed Body.rotate ([c5212e1](https://github.com/liabru/matter-js/commit/c5212e1))
|
||||
* fixed Body.setVertices ([73ded98](https://github.com/liabru/matter-js/commit/73ded98))
|
||||
* fixed bug in constraints for compounds ([13fcb4b](https://github.com/liabru/matter-js/commit/13fcb4b))
|
||||
* fixed bug in Demo.reset that was creating multiple MouseConstraint ([8204d97](https://github.com/liabru/matter-js/commit/8204d97))
|
||||
* fixed build tasks ([69ff33f](https://github.com/liabru/matter-js/commit/69ff33f))
|
||||
* fixed build tasks, closes #161 ([d1b8705](https://github.com/liabru/matter-js/commit/d1b8705)), closes [#161](https://github.com/liabru/matter-js/issues/161)
|
||||
* fixed chaining for some Matter.Vertices methods ([8746185](https://github.com/liabru/matter-js/commit/8746185))
|
||||
* fixed collision detection issue, closes #12 ([3e48825](https://github.com/liabru/matter-js/commit/3e48825)), closes [#12](https://github.com/liabru/matter-js/issues/12)
|
||||
* fixed collision incident and reference body mapping ([757fffa](https://github.com/liabru/matter-js/commit/757fffa))
|
||||
* fixed collision rendering ([bc9a051](https://github.com/liabru/matter-js/commit/bc9a051))
|
||||
* fixed Common.now, closes #55 ([8555c0c](https://github.com/liabru/matter-js/commit/8555c0c)), closes [#55](https://github.com/liabru/matter-js/issues/55)
|
||||
* fixed compound body stability, improved position resolver ([e01dd22](https://github.com/liabru/matter-js/commit/e01dd22))
|
||||
* fixed critical inertia calculation issue, a potential breaking change, so Body._inertiaScale added t ([9a55b0c](https://github.com/liabru/matter-js/commit/9a55b0c))
|
||||
* fixed Example.timescale ([19656cd](https://github.com/liabru/matter-js/commit/19656cd))
|
||||
* fixed friction in Demo.manipulation ([95ae911](https://github.com/liabru/matter-js/commit/95ae911))
|
||||
* fixed gulp shell task args ([c2b0f30](https://github.com/liabru/matter-js/commit/c2b0f30))
|
||||
* fixed incorrect bounds issue when passing angle in Body.create ([810bd26](https://github.com/liabru/matter-js/commit/810bd26))
|
||||
* fixed issue with Body.applyForce torque, closes #64 ([3f9364c](https://github.com/liabru/matter-js/commit/3f9364c)), closes [#64](https://github.com/liabru/matter-js/issues/64)
|
||||
* fixed issue with docs ([3a16f90](https://github.com/liabru/matter-js/commit/3a16f90))
|
||||
* fixed issue with MouseConstraint.create, closes #185 ([dff0e30](https://github.com/liabru/matter-js/commit/dff0e30)), closes [#185](https://github.com/liabru/matter-js/issues/185)
|
||||
* fixed issues with friction stability ([1db98a3](https://github.com/liabru/matter-js/commit/1db98a3))
|
||||
* Fixed missed variable declaration. ([a940d96](https://github.com/liabru/matter-js/commit/a940d96))
|
||||
* fixed options pass through on Bodies.fromVertices ([eb29367](https://github.com/liabru/matter-js/commit/eb29367))
|
||||
* fixed Query.ray, Number.MIN_VALUE seems to cause SAT.collides to fail ([ccbb98b](https://github.com/liabru/matter-js/commit/ccbb98b))
|
||||
* fixed RenderPixi for compound bodies ([6679b9c](https://github.com/liabru/matter-js/commit/6679b9c))
|
||||
* fixed SAT overlap calculation for containment case ([685f2bd](https://github.com/liabru/matter-js/commit/685f2bd))
|
||||
* fixed scaling on RenderPixi view bounds ([c1964e2](https://github.com/liabru/matter-js/commit/c1964e2))
|
||||
* fixed support finding logic ([bc7dfc7](https://github.com/liabru/matter-js/commit/bc7dfc7))
|
||||
* fixed Vertices.fromPath when parsing scientific notation ([dae684d](https://github.com/liabru/matter-js/commit/dae684d))
|
||||
* fixes for compound bodies ([87f9065](https://github.com/liabru/matter-js/commit/87f9065))
|
||||
* formatting merge ([d4cbdbb](https://github.com/liabru/matter-js/commit/d4cbdbb))
|
||||
* further work on compound implementation ([d2f79b4](https://github.com/liabru/matter-js/commit/d2f79b4))
|
||||
* hide axis indicator on compound bodies ([6a26696](https://github.com/liabru/matter-js/commit/6a26696))
|
||||
* ignoring .idea ([066a416](https://github.com/liabru/matter-js/commit/066a416))
|
||||
* implemented automated browser tests ([a88b3ba](https://github.com/liabru/matter-js/commit/a88b3ba))
|
||||
* implemented compound bodies, added Body.setParts ([f554d6c](https://github.com/liabru/matter-js/commit/f554d6c))
|
||||
* implemented static compound bodies ([90adf14](https://github.com/liabru/matter-js/commit/90adf14))
|
||||
* implemented temporary vector pool ([7a477f2](https://github.com/liabru/matter-js/commit/7a477f2))
|
||||
* improve Composite.car ([5ff2182](https://github.com/liabru/matter-js/commit/5ff2182))
|
||||
* improved collision detection for compounds ([84d9f59](https://github.com/liabru/matter-js/commit/84d9f59))
|
||||
* improved Demo.manipulation ([e186ccd](https://github.com/liabru/matter-js/commit/e186ccd))
|
||||
* improved docs ([2317f02](https://github.com/liabru/matter-js/commit/2317f02))
|
||||
* improved docs ([2e6afd4](https://github.com/liabru/matter-js/commit/2e6afd4))
|
||||
* improved examples ([6e1f8e9](https://github.com/liabru/matter-js/commit/6e1f8e9))
|
||||
* improved friction, added body.frictionStatic ([937c7bf](https://github.com/liabru/matter-js/commit/937c7bf))
|
||||
* improved traction for Composites.car ([95eddb0](https://github.com/liabru/matter-js/commit/95eddb0))
|
||||
* increased tollerance on internal edge finding ([40905e8](https://github.com/liabru/matter-js/commit/40905e8))
|
||||
* initial work on browser tests ([6a88256](https://github.com/liabru/matter-js/commit/6a88256))
|
||||
* initial work on compound bodies ([243fce4](https://github.com/liabru/matter-js/commit/243fce4))
|
||||
* Make background:'transparent' work like canvas renderer ([f9123f9](https://github.com/liabru/matter-js/commit/f9123f9))
|
||||
* Merge branch 'browser-tests' ([a6b82c1](https://github.com/liabru/matter-js/commit/a6b82c1))
|
||||
* Merge branch 'collision-filters' of https://github.com/GustavCarlson/matter-js into GustavCarlson-co ([3a32bda](https://github.com/liabru/matter-js/commit/3a32bda))
|
||||
* Merge branch 'GustavCarlson-collision-filters' ([a58fe2a](https://github.com/liabru/matter-js/commit/a58fe2a))
|
||||
* Merge branch 'master' into runner-improve ([a48d219](https://github.com/liabru/matter-js/commit/a48d219))
|
||||
* Merge branch 'master' into topic/addBounds ([a461fc7](https://github.com/liabru/matter-js/commit/a461fc7))
|
||||
* Merge branch 'master' of github.com:liabru/matter-js ([4067108](https://github.com/liabru/matter-js/commit/4067108))
|
||||
* Merge branch 'master' of https://github.com/rfoligno/matter-js into rfoligno-master ([41b4b7f](https://github.com/liabru/matter-js/commit/41b4b7f))
|
||||
* Merge branch 'master' of https://github.com/schahriar/matter-js into schahriar-master ([2510cdf](https://github.com/liabru/matter-js/commit/2510cdf))
|
||||
* Merge branch 'no-gravity-optim' of https://github.com/BlackDice/matter-js into BlackDice-no-gravity- ([1b8574a](https://github.com/liabru/matter-js/commit/1b8574a))
|
||||
* Merge branch 'node-tests' into browserify ([6e0e7e4](https://github.com/liabru/matter-js/commit/6e0e7e4))
|
||||
* Merge branch 'pr/60' ([42dc72d](https://github.com/liabru/matter-js/commit/42dc72d))
|
||||
* Merge branch 'pr/95' ([eed9167](https://github.com/liabru/matter-js/commit/eed9167))
|
||||
* Merge branch 'runner-improve' into browserify ([9e3438f](https://github.com/liabru/matter-js/commit/9e3438f))
|
||||
* Merge pull request #30 from mrspeaker/master ([e95e328](https://github.com/liabru/matter-js/commit/e95e328))
|
||||
* Merge pull request #31 from mrspeaker/topic/addBounds ([6652bb4](https://github.com/liabru/matter-js/commit/6652bb4))
|
||||
* Merge pull request #51 from tumult/pair_refreshes_from_body_values ([7c1efb6](https://github.com/liabru/matter-js/commit/7c1efb6))
|
||||
* Merge remote-tracking branch 'origin/pr/33' ([c6a9414](https://github.com/liabru/matter-js/commit/c6a9414))
|
||||
* merge tumult:old_ie_fixes + tweaks ([6e1ab9a](https://github.com/liabru/matter-js/commit/6e1ab9a))
|
||||
* migrated from grunt to gulp, jshint to eslint ([19bb655](https://github.com/liabru/matter-js/commit/19bb655))
|
||||
* Missing argument whose default is 1. ([61855ab](https://github.com/liabru/matter-js/commit/61855ab))
|
||||
* More fine-grained collision filtering in the style of Box2D ([dd4fc65](https://github.com/liabru/matter-js/commit/dd4fc65))
|
||||
* move /tests to /test ([ad403ae](https://github.com/liabru/matter-js/commit/ad403ae))
|
||||
* move Demo.* to Example.* ([b722012](https://github.com/liabru/matter-js/commit/b722012))
|
||||
* move license in build ([9ba8a2a](https://github.com/liabru/matter-js/commit/9ba8a2a))
|
||||
* move require statements below module export ([99c3bb3](https://github.com/liabru/matter-js/commit/99c3bb3))
|
||||
* moved collision events into Engine.update, changed collisionStart to trigger before collisions resol ([69b1d05](https://github.com/liabru/matter-js/commit/69b1d05))
|
||||
* moved Engine.run to Matter.Runner ([6911395](https://github.com/liabru/matter-js/commit/6911395))
|
||||
* moved engine.timing properties, tick events and Engine.render into Matter.Runner module ([dcdc43d](https://github.com/liabru/matter-js/commit/dcdc43d))
|
||||
* pass width and height options to Pixi webGL renderer ([a9278fc](https://github.com/liabru/matter-js/commit/a9278fc))
|
||||
* publish to npm ([a12fbcb](https://github.com/liabru/matter-js/commit/a12fbcb))
|
||||
* refactor Bodies.fromVertices ([4a2c6e7](https://github.com/liabru/matter-js/commit/4a2c6e7))
|
||||
* refactor Demo.create ([c0b24da](https://github.com/liabru/matter-js/commit/c0b24da))
|
||||
* refactor Demo.init ([fb76605](https://github.com/liabru/matter-js/commit/fb76605))
|
||||
* remove constraint torque clamp ([6f89250](https://github.com/liabru/matter-js/commit/6f89250))
|
||||
* removed Body.resetForcesAll, removed Body.applyGravityAll, removed Body.updateAll ([9aa0945](https://github.com/liabru/matter-js/commit/9aa0945))
|
||||
* removed collision.supportCorrected instead using bodyB.position, added render.options.showSeparation ([2b6a8d3](https://github.com/liabru/matter-js/commit/2b6a8d3))
|
||||
* removed complexity check in Bodies.fromVertices, enforce clockwise sort ([2d1ef0d](https://github.com/liabru/matter-js/commit/2d1ef0d))
|
||||
* removed Detector.bruteForce ([e04de5f](https://github.com/liabru/matter-js/commit/e04de5f))
|
||||
* removed engine.broadphase.current, removed engine.broadphase.instance, changed engine.broadphase to ([6dd0c05](https://github.com/liabru/matter-js/commit/6dd0c05))
|
||||
* removed engine.input, removed Engine mouse events, added MouseConstraint mouse events ([fb5d899](https://github.com/liabru/matter-js/commit/fb5d899))
|
||||
* removed line width change from Body.setStatic ([04955bb](https://github.com/liabru/matter-js/commit/04955bb))
|
||||
* removed Matter.Metrics from release builds (now dev only) ([968bba2](https://github.com/liabru/matter-js/commit/968bba2))
|
||||
* removed old build ([a068bec](https://github.com/liabru/matter-js/commit/a068bec))
|
||||
* removed redundant property ([14392b4](https://github.com/liabru/matter-js/commit/14392b4))
|
||||
* removed Render.clear (redundant) ([0a15d7d](https://github.com/liabru/matter-js/commit/0a15d7d))
|
||||
* removed Render.setBackground (now use render.options) ([01bc813](https://github.com/liabru/matter-js/commit/01bc813))
|
||||
* removed unused vars from examples ([0bff037](https://github.com/liabru/matter-js/commit/0bff037))
|
||||
* removed version number from edge build name ([e6b998e](https://github.com/liabru/matter-js/commit/e6b998e))
|
||||
* render normals pointing out of static bodies ([d082b3a](https://github.com/liabru/matter-js/commit/d082b3a))
|
||||
* skip presolve when impulse 0 ([296059c](https://github.com/liabru/matter-js/commit/296059c))
|
||||
* skip unnecessary loops in Composites.mesh, closes #85 ([0a73a64](https://github.com/liabru/matter-js/commit/0a73a64)), closes [#85](https://github.com/liabru/matter-js/issues/85)
|
||||
* Some fixes in pixi.js v3 update ([96735dd](https://github.com/liabru/matter-js/commit/96735dd))
|
||||
* Spellchecking ([940976a](https://github.com/liabru/matter-js/commit/940976a))
|
||||
* Spellchecking ([c2e0c23](https://github.com/liabru/matter-js/commit/c2e0c23))
|
||||
* Spellchecking ([cd5d401](https://github.com/liabru/matter-js/commit/cd5d401))
|
||||
* Spellchecking ([611a429](https://github.com/liabru/matter-js/commit/611a429))
|
||||
* Spellchecking ([723ddcf](https://github.com/liabru/matter-js/commit/723ddcf))
|
||||
* Spellchecking ([65d5d93](https://github.com/liabru/matter-js/commit/65d5d93))
|
||||
* Spellchecking ([3127654](https://github.com/liabru/matter-js/commit/3127654))
|
||||
* tweak jshint ([71df1b9](https://github.com/liabru/matter-js/commit/71df1b9))
|
||||
* tweaks to collision filtering ([5060c76](https://github.com/liabru/matter-js/commit/5060c76))
|
||||
* tweaks to Matter.Runner ([ce474da](https://github.com/liabru/matter-js/commit/ce474da))
|
||||
* Update JSDoc ([25ab2a3](https://github.com/liabru/matter-js/commit/25ab2a3))
|
||||
* Update JSDoc ([18e0642](https://github.com/liabru/matter-js/commit/18e0642))
|
||||
* Update JSDoc ([71ef6c2](https://github.com/liabru/matter-js/commit/71ef6c2))
|
||||
* Update JSDoc ([10a46b7](https://github.com/liabru/matter-js/commit/10a46b7))
|
||||
* Update JSDoc ([5b87f47](https://github.com/liabru/matter-js/commit/5b87f47))
|
||||
* Update JSDoc ([d17eb6c](https://github.com/liabru/matter-js/commit/d17eb6c))
|
||||
* Update JSDoc ([aa3eabc](https://github.com/liabru/matter-js/commit/aa3eabc))
|
||||
* update node version for travis ([e698b6b](https://github.com/liabru/matter-js/commit/e698b6b))
|
||||
* updated browser test refs ([1810f93](https://github.com/liabru/matter-js/commit/1810f93))
|
||||
* updated browser test refs ([ae32d63](https://github.com/liabru/matter-js/commit/ae32d63))
|
||||
* updated browser test refs ([31fb748](https://github.com/liabru/matter-js/commit/31fb748))
|
||||
* updated contributing notes ([8b89e87](https://github.com/liabru/matter-js/commit/8b89e87))
|
||||
* updated docs for collisionFilter ([9f10f88](https://github.com/liabru/matter-js/commit/9f10f88))
|
||||
* updated edge build ([2fa1570](https://github.com/liabru/matter-js/commit/2fa1570))
|
||||
* updated edge build ([02ab198](https://github.com/liabru/matter-js/commit/02ab198))
|
||||
* updated edge build ([37a86cd](https://github.com/liabru/matter-js/commit/37a86cd))
|
||||
* updated edge build ([cd00353](https://github.com/liabru/matter-js/commit/cd00353))
|
||||
* updated edge build ([37ccc84](https://github.com/liabru/matter-js/commit/37ccc84))
|
||||
* updated edge build ([bf3f986](https://github.com/liabru/matter-js/commit/bf3f986))
|
||||
* updated edge build ([16733ad](https://github.com/liabru/matter-js/commit/16733ad))
|
||||
* updated edge build ([2f2d416](https://github.com/liabru/matter-js/commit/2f2d416))
|
||||
* updated edge build ([5770013](https://github.com/liabru/matter-js/commit/5770013))
|
||||
* updated edge build ([43fd2e3](https://github.com/liabru/matter-js/commit/43fd2e3))
|
||||
* updated edge build ([fbb7c1a](https://github.com/liabru/matter-js/commit/fbb7c1a))
|
||||
* updated edge build ([d6cbd07](https://github.com/liabru/matter-js/commit/d6cbd07))
|
||||
* updated edge build ([9561d5d](https://github.com/liabru/matter-js/commit/9561d5d))
|
||||
* updated edge build ([a80fbc1](https://github.com/liabru/matter-js/commit/a80fbc1))
|
||||
* updated edge build ([5b2b060](https://github.com/liabru/matter-js/commit/5b2b060))
|
||||
* updated edge build ([d22b1b4](https://github.com/liabru/matter-js/commit/d22b1b4))
|
||||
* updated edge build ([2ab20b0](https://github.com/liabru/matter-js/commit/2ab20b0))
|
||||
* updated edge build ([f2635ab](https://github.com/liabru/matter-js/commit/f2635ab))
|
||||
* updated matter-tools ([c969767](https://github.com/liabru/matter-js/commit/c969767))
|
||||
* updated matter-tools ([4ecad0f](https://github.com/liabru/matter-js/commit/4ecad0f))
|
||||
* updated node test refs ([b1e6a45](https://github.com/liabru/matter-js/commit/b1e6a45))
|
||||
* Updated pixi.js to v3 ([419d2ad](https://github.com/liabru/matter-js/commit/419d2ad))
|
||||
* updated readme ([137580c](https://github.com/liabru/matter-js/commit/137580c))
|
||||
* updated readme ([f4f3bf7](https://github.com/liabru/matter-js/commit/f4f3bf7))
|
||||
* updated readme ([d2dcc77](https://github.com/liabru/matter-js/commit/d2dcc77))
|
||||
* updated readme ([2806fd3](https://github.com/liabru/matter-js/commit/2806fd3))
|
||||
* updated readme ([3e5abab](https://github.com/liabru/matter-js/commit/3e5abab))
|
||||
* updated readme ([8f2f8ee](https://github.com/liabru/matter-js/commit/8f2f8ee))
|
||||
* updated readme ([6cd00b1](https://github.com/liabru/matter-js/commit/6cd00b1))
|
||||
* updated test refs ([b79ece2](https://github.com/liabru/matter-js/commit/b79ece2))
|
||||
* updated test refs ([1a55259](https://github.com/liabru/matter-js/commit/1a55259))
|
||||
* updated test refs ([110aea8](https://github.com/liabru/matter-js/commit/110aea8))
|
||||
* updated test refs ([729e2bf](https://github.com/liabru/matter-js/commit/729e2bf))
|
||||
* upgraded pixi.js to v3.0.6 ([d03145e](https://github.com/liabru/matter-js/commit/d03145e))
|
||||
* use actual canvas size for default render bounds ([c3129b8](https://github.com/liabru/matter-js/commit/c3129b8))
|
||||
* use browserify ([00251e5](https://github.com/liabru/matter-js/commit/00251e5))
|
||||
* use build folder for demo ([fa47d5c](https://github.com/liabru/matter-js/commit/fa47d5c))
|
||||
* use different port for test server, fix test precision limiter ([c1f71b9](https://github.com/liabru/matter-js/commit/c1f71b9))
|
||||
* Use own Common.indexOf method for IE 6-8 compatibility ([b91af36](https://github.com/liabru/matter-js/commit/b91af36))
|
||||
* When updating pairs use current values from bodies as they may have changed ([f0e7491](https://github.com/liabru/matter-js/commit/f0e7491))
|
||||
|
||||
|
||||
|
||||
# Matter.js Changelog
|
||||
|
||||
[brm.io/matter-js](http://brm.io/matter-js)
|
||||
|
|
83
README.md
83
README.md
|
@ -14,50 +14,50 @@
|
|||
<tr>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#mixed">Mixed Shapes</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#mixedSolid">Solid Shapes</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#svg">Concave SVG Paths</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#terrain">Concave Terrain</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#concave">Concave Bodies</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#compound">Compound Bodies</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#newtonsCradle">Newton's Cradle</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#wreckingBall">Wrecking Ball</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#slingshot">Slingshot Game</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#rounded">Rounded Corners</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#views">Views</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#timescale">Time Scaling</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#manipulation">Body Manipulation</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#compositeManipulation">Composite Manipulation</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#raycasting">Raycasting</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#sprites">Sprites</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#pyramid">Pyramid</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#car">Car</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#catapult">Catapult</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#gravity">Reverse Gravity</a></li>
|
||||
<li><a href="http://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="http://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="http://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="http://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="http://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="http://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="http://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="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>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#bridge">Bridge</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#avalanche">Avalanche</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#softBody">Basic Soft Bodies</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#cloth">Cloth</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#events">Events</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#collisionFiltering">Collision Filtering</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#chains">Chains</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#ballPool">Ball Pool</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#stack">Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#circleStack">Circle Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#compoundStack">Compound Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#restitution">Restitution</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#friction">Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#airFriction">Air Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#staticFriction">Static Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#sleeping">Sleeping</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#broadphase">Grid Broadphase</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#beachBalls">Beach Balls</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#stress">Stress 1</a></li>
|
||||
<li><a href="http://brm.io/matter-js-demo-master#stress2">Stress 2</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#bridge">Bridge</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#avalanche">Avalanche</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#softBody">Basic Soft Bodies</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#cloth">Cloth</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#events">Events</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#collisionFiltering">Collision Filtering</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#chains">Chains</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#ballPool">Ball Pool</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#stack">Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#circleStack">Circle Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#compoundStack">Compound Stack</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#restitution">Restitution</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#friction">Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#airFriction">Air Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#staticFriction">Static Friction</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#sleeping">Sleeping</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#broadphase">Grid Broadphase</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#beachBalls">Beach Balls</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#stress">Stress 1</a></li>
|
||||
<li><a href="http://brm.io/matter-js/demo#stress2">Stress 2</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
</td>
|
||||
|
@ -130,8 +130,7 @@ There are even more examples on [codepen](http://codepen.io/collection/Fuagy/).
|
|||
|
||||
### Documentation
|
||||
|
||||
Edge build documentation is at [Matter.js API Docs (master)](http://brm.io/matter-js-docs-master/)
|
||||
Stable release documentation is at [Matter.js API Docs (v0.8.0)](http://brm.io/matter-js-docs/)
|
||||
See the [API Documentation](http://brm.io/matter-js/docs) and the [wiki](https://github.com/liabru/matter-js/wiki)
|
||||
|
||||
### Building and Contributing
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Matter",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"homepage": "https://github.com/liabru/matter-js",
|
||||
"authors": [
|
||||
"Liam Brummitt <liam@brm.io> (http://brm.io/)"
|
||||
|
|
394
build/matter.js
394
build/matter.js
File diff suppressed because it is too large
Load diff
140
build/matter.min.js
vendored
140
build/matter.min.js
vendored
|
@ -1,77 +1,77 @@
|
|||
/**
|
||||
* matter-js master by @liabru 2015-12-23
|
||||
* matter-js 0.9.0 by @liabru 2016-01-16
|
||||
* http://brm.io/matter-js/
|
||||
* License MIT
|
||||
*/
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function e(t,o,n){function i(s,a){if(!o[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=o[s]={exports:{}};t[s][0].call(d.exports,function(e){var o=t[s][1][e];return i(o?o:e)},d,d.exports,e,t,o,n)}return o[s].exports}for(var r="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){n._inertiaScale=4;var e=1,t=-1,o=1;n.create=function(e){
|
||||
var t={id:a.nextId(),type:"body",label:"Body",parts:[],angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:1.5}},o=a.extend(t,e);return d(o,e),o},n.nextGroup=function(o){return o?t--:e++},n.nextCategory=function(){return o<<=1};var d=function(e,t){n.set(e,{bounds:e.bounds||l.create(e.vertices),positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),
|
||||
l.update(e.bounds,e.vertices,e.velocity),n.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var o=e.isStatic?"#eeeeee":a.choose(["#556270","#4ECDC4","#C7F464","#FF6B6B","#C44D58"]),s=a.shadeColor(o,-20);e.render.fillStyle=e.render.fillStyle||o,e.render.strokeStyle=e.render.strokeStyle||s,e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};n.set=function(e,t,o){var i;"string"==typeof t&&(i=t,t={},t[i]=o);for(i in t)if(o=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":n.setStatic(e,o);break;case"isSleeping":s.set(e,o);break;case"mass":n.setMass(e,o);break;case"density":n.setDensity(e,o);break;case"inertia":n.setInertia(e,o);break;case"vertices":n.setVertices(e,o);break;case"position":n.setPosition(e,o);break;case"angle":n.setAngle(e,o);break;case"velocity":n.setVelocity(e,o);break;case"angularVelocity":n.setAngularVelocity(e,o);
|
||||
break;case"parts":n.setParts(e,o);break;default:e[i]=o}},n.setStatic=function(e,t){for(var o=0;o<e.parts.length;o++){var n=e.parts[o];n.isStatic=t,t&&(n.restitution=0,n.friction=1,n.mass=n.inertia=n.density=1/0,n.inverseMass=n.inverseInertia=0,n.positionPrev.x=n.position.x,n.positionPrev.y=n.position.y,n.anglePrev=n.angle,n.angularVelocity=0,n.speed=0,n.angularSpeed=0,n.motion=0)}},n.setMass=function(e,t){e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},n.setDensity=function(e,t){n.setMass(e,t*e.area),e.density=t},n.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},n.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),n.setMass(e,e.density*e.area);var o=i.centre(e.vertices);i.translate(e.vertices,o,-1),n.setInertia(e,n._inertiaScale*i.inertia(e.vertices,e.mass)),i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},n.setParts=function(e,t,o){var r;for(t=t.slice(0),
|
||||
e.parts.length=0,e.parts.push(e),e.parent=e,r=0;r<t.length;r++){var s=t[r];s!==e&&(s.parent=e,e.parts.push(s))}if(1!==e.parts.length){if(o="undefined"!=typeof o?o:!0){var a=[];for(r=0;r<t.length;r++)a=a.concat(t[r].vertices);i.clockwiseSort(a);var l=i.hull(a),c=i.centre(l);n.setVertices(e,l),i.translate(e.vertices,c)}var d=u(e);e.area=d.area,e.parent=e,e.position.x=d.centre.x,e.position.y=d.centre.y,e.positionPrev.x=d.centre.x,e.positionPrev.y=d.centre.y,n.setMass(e,d.mass),n.setInertia(e,d.inertia),n.setPosition(e,d.centre)}},n.setPosition=function(e,t){var o=r.sub(t,e.position);e.positionPrev.x+=o.x,e.positionPrev.y+=o.y;for(var n=0;n<e.parts.length;n++){var s=e.parts[n];s.position.x+=o.x,s.position.y+=o.y,i.translate(s.vertices,o),l.update(s.bounds,s.vertices,e.velocity)}},n.setAngle=function(e,t){var o=t-e.angle;e.anglePrev+=o;for(var n=0;n<e.parts.length;n++){var s=e.parts[n];s.angle+=o,i.rotate(s.vertices,o,e.position),c.rotate(s.axes,o),l.update(s.bounds,s.vertices,e.velocity),n>0&&r.rotateAbout(s.position,o,e.position,s.position);
|
||||
}},n.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},n.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},n.translate=function(e,t){n.setPosition(e,r.add(e.position,t))},n.rotate=function(e,t){n.setAngle(e,e.angle+t)},n.scale=function(e,t,o,r){for(var s=0;s<e.parts.length;s++){var a=e.parts[s];i.scale(a.vertices,t,o,e.position),a.axes=c.fromVertices(a.vertices),e.isStatic||(a.area=i.area(a.vertices),n.setMass(a,e.density*a.area),i.translate(a.vertices,{x:-a.position.x,y:-a.position.y}),n.setInertia(a,i.inertia(a.vertices,a.mass)),i.translate(a.vertices,{x:a.position.x,y:a.position.y})),l.update(a.bounds,a.vertices,e.velocity)}if(!e.isStatic){var d=u(e);e.area=d.area,n.setMass(e,d.mass),n.setInertia(e,d.inertia)}},n.update=function(e,t,o,n){var s=Math.pow(t*o*e.timeScale,2),a=1-e.frictionAir*o*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;
|
||||
e.velocity.x=d*a*n+e.force.x/e.mass*s,e.velocity.y=u*a*n+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*n+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},n.applyForce=function(e,t,o){e.force.x+=o.x,e.force.y+=o.y;var n={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=n.x*o.y-n.y*o.x};var u=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},o=1===e.parts.length?0:1;o<e.parts.length;o++){var n=e.parts[o];
|
||||
t.mass+=n.mass,t.area+=n.area,t.inertia+=n.inertia,t.centre=r.add(t.centre,r.mult(n.position,n.mass!==1/0?n.mass:1))}return t.centre=r.div(t.centre,t.mass!==1/0?t.mass:e.parts.length),t}}()},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29}],2:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Events"),r=e("../core/Common"),s=e("./Body");!function(){n.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite"},e)},n.setModified=function(e,t,o,i){if(e.isModified=t,o&&e.parent&&n.setModified(e.parent,t,o,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];n.setModified(s,t,o,i)}},n.add=function(e,t){var o=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<o.length;s++){var a=o[s];switch(a.type){case"body":if(a.parent!==a){r.log("Composite.add: skipped adding a compound body part (you must add its parent instead)","warn");
|
||||
break}n.addBody(e,a);break;case"constraint":n.addConstraint(e,a);break;case"composite":n.addComposite(e,a);break;case"mouseConstraint":n.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},n.remove=function(e,t,o){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":n.removeBody(e,a,o);break;case"constraint":n.removeConstraint(e,a,o);break;case"composite":n.removeComposite(e,a,o);break;case"mouseConstraint":n.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},n.addComposite=function(e,t){return e.composites.push(t),t.parent=e,n.setModified(e,!0,!0,!1),e},n.removeComposite=function(e,t,o){var i=r.indexOf(e.composites,t);if(-1!==i&&(n.removeCompositeAt(e,i),n.setModified(e,!0,!0,!1)),o)for(var s=0;s<e.composites.length;s++)n.removeComposite(e.composites[s],t,!0);return e},n.removeCompositeAt=function(e,t){return e.composites.splice(t,1),n.setModified(e,!0,!0,!1),e},
|
||||
n.addBody=function(e,t){return e.bodies.push(t),n.setModified(e,!0,!0,!1),e},n.removeBody=function(e,t,o){var i=r.indexOf(e.bodies,t);if(-1!==i&&(n.removeBodyAt(e,i),n.setModified(e,!0,!0,!1)),o)for(var s=0;s<e.composites.length;s++)n.removeBody(e.composites[s],t,!0);return e},n.removeBodyAt=function(e,t){return e.bodies.splice(t,1),n.setModified(e,!0,!0,!1),e},n.addConstraint=function(e,t){return e.constraints.push(t),n.setModified(e,!0,!0,!1),e},n.removeConstraint=function(e,t,o){var i=r.indexOf(e.constraints,t);if(-1!==i&&n.removeConstraintAt(e,i),o)for(var s=0;s<e.composites.length;s++)n.removeConstraint(e.composites[s],t,!0);return e},n.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),n.setModified(e,!0,!0,!1),e},n.clear=function(e,t,o){if(o)for(var i=0;i<e.composites.length;i++)n.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,n.setModified(e,!0,!0,!1),e},n.allBodies=function(e){
|
||||
for(var t=[].concat(e.bodies),o=0;o<e.composites.length;o++)t=t.concat(n.allBodies(e.composites[o]));return t},n.allConstraints=function(e){for(var t=[].concat(e.constraints),o=0;o<e.composites.length;o++)t=t.concat(n.allConstraints(e.composites[o]));return t},n.allComposites=function(e){for(var t=[].concat(e.composites),o=0;o<e.composites.length;o++)t=t.concat(n.allComposites(e.composites[o]));return t},n.get=function(e,t,o){var i,r;switch(o){case"body":i=n.allBodies(e);break;case"constraint":i=n.allConstraints(e);break;case"composite":i=n.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},n.move=function(e,t,o){return n.remove(e,t),n.add(o,t),e},n.rebase=function(e){for(var t=n.allBodies(e).concat(n.allConstraints(e)).concat(n.allComposites(e)),o=0;o<t.length;o++)t[o].id=r.nextId();return n.setModified(e,!0,!0,!1),e},n.translate=function(e,t,o){for(var i=o?n.allBodies(e):e.bodies,r=0;r<i.length;r++)s.translate(i[r],t);
|
||||
return n.setModified(e,!0,!0,!1),e},n.rotate=function(e,t,o,i){for(var r=Math.cos(t),a=Math.sin(t),l=i?n.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-o.x,p=d.position.y-o.y;s.setPosition(d,{x:o.x+(u*r-p*a),y:o.y+(u*a+p*r)}),s.rotate(d,t)}return n.setModified(e,!0,!0,!1),e},n.scale=function(e,t,o,i,r){for(var a=r?n.allBodies(e):e.bodies,l=0;l<a.length;l++){var c=a[l],d=c.position.x-i.x,u=c.position.y-i.y;s.setPosition(c,{x:i.x+d*t,y:i.y+u*o}),s.scale(c,t,o)}return n.setModified(e,!0,!0,!1),e}}()},{"../core/Common":14,"../core/Events":16,"./Body":1}],3:[function(e,t,o){var n={};t.exports=n;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){n.create=function(e){var t=i.create(),o={label:"World",gravity:{x:0,y:1},bounds:{min:{x:-(1/0),y:-(1/0)},max:{x:1/0,y:1/0}}};return r.extend(t,o,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,o){var n={};t.exports=n,function(){n.create=function(e){
|
||||
return{id:n.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},n.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,o){var n={};t.exports=n;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){n.collisions=function(e,t){for(var o=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&n.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var v=d.parts[f];if(p===c&&v===d||s.overlaps(p.bounds,v.bounds)){var y,m=r.id(p,v),g=a[m];y=g&&g.isActive?g.collision:null;var x=i.collides(p,v,y);x.collided&&o.push(x)}}}return o},n.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!==(e.mask&t.category)&&0!==(t.mask&e.category)}}()},{"../geometry/Bounds":24,"./Pair":7,"./SAT":11}],6:[function(e,t,o){var n={};t.exports=n;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");
|
||||
!function(){n.create=function(e){var t={controller:n,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},n.update=function(o,n,i,r){var s,p,f,v,y,m=i.world,g=o.buckets,x=!1;for(s=0;s<n.length;s++){var h=n[s];if((!h.isSleeping||r)&&!(h.bounds.max.x<0||h.bounds.min.x>m.bounds.width||h.bounds.max.y<0||h.bounds.min.y>m.bounds.height)){var b=t(o,h);if(!h.region||b.id!==h.region.id||r){(!h.region||r)&&(h.region=b);var S=e(b,h.region);for(p=S.startCol;p<=S.endCol;p++)for(f=S.startRow;f<=S.endRow;f++){y=a(p,f),v=g[y];var w=p>=b.startCol&&p<=b.endCol&&f>=b.startRow&&f<=b.endRow,C=p>=h.region.startCol&&p<=h.region.endCol&&f>=h.region.startRow&&f<=h.region.endRow;!w&&C&&C&&v&&d(o,v,h),(h.region===b||w&&!C||r)&&(v||(v=l(g,y)),c(o,v,h))}h.region=b,x=!0}}}x&&(o.pairsList=u(o))},n.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]};var e=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow);
|
||||
return o(n,i,r,s)},t=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o(i,r,s,a)},o=function(e,t,o,n){return{id:e+","+t+","+o+","+n,startCol:e,endCol:t,startRow:o,endRow:n}},a=function(e,t){return e+","+t},l=function(e,t){var o=e[t]=[];return o},c=function(e,t,o){for(var n=0;n<t.length;n++){var r=t[n];if(!(o.id===r.id||o.isStatic&&r.isStatic)){var s=i.id(o,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[o,r,1]}}t.push(o)},d=function(e,t,o){t.splice(s.indexOf(t,o),1);for(var n=0;n<t.length;n++){var r=t[n],a=i.id(o,r),l=e.pairs[a];l&&(l[2]-=1)}},u=function(e){var t,o,n=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)o=e.pairs[t[i]],o[2]>0?n.push(o):delete e.pairs[t[i]];return n}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],7:[function(e,t,o){var n={};t.exports=n;var i=e("./Contact");!function(){n.create=function(e,t){var o=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={
|
||||
id:n.id(o,i),bodyA:o,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return n.update(a,e,t),a},n.update=function(e,t,o){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}e.separation=t.depth,n.setActive(e,!0,o)}else e.isActive===!0&&n.setActive(e,!1,o)},n.setActive=function(e,t,o){t?(e.isActive=!0,e.timeUpdated=o):(e.isActive=!1,e.activeContacts.length=0);
|
||||
},n.id=function(e,t){return e.id<t.id?e.id+"_"+t.id:t.id+"_"+e.id}}()},{"./Contact":4}],8:[function(e,t,o){var n={};t.exports=n;var i=e("./Pair"),r=e("../core/Common");!function(){var e=1e3;n.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},n.update=function(e,t,o){var n,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,v=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)n=t[l],n.collided&&(s=i.id(n.bodyA,n.bodyB),v.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,n,o)):(a=i.create(n,o),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(v,a.id)&&(i.setActive(a,!1,o),p.push(a))},n.removeOld=function(t,o){var n,i,r,s,a=t.list,l=t.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=o:o-n.timeUpdated>e&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},n.clear=function(e){
|
||||
return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){n.ray=function(e,t,o,n){n=n||1e-100;for(var l=i.angle(t,o),c=i.magnitude(i.sub(t,o)),d=.5*(o.x+t.x),u=.5*(o.y+t.y),p=a.rectangle(d,u,c,n,{angle:l}),f=[],v=0;v<e.length;v++){var y=e[v];if(s.overlaps(y.bounds,p.bounds))for(var m=1===y.parts.length?0:1;m<y.parts.length;m++){var g=y.parts[m];if(s.overlaps(g.bounds,p.bounds)){var x=r.collides(g,p);if(x.collided){x.body=x.bodyA=x.bodyB=y,f.push(x);break}}}}return f},n.region=function(e,t,o){for(var n=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!o||!a&&o)&&n.push(r)}return n},n.point=function(e,t){for(var o=[],n=0;n<e.length;n++){var i=e[n];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){
|
||||
var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){o.push(i);break}}}return o}}()},{"../factory/Bodies":21,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"./SAT":11}],10:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){n._restingThresh=4,n._restingThreshTangent=6,n._positionDampen=.9,n._positionWarming=.8,n._frictionNormalMultiplier=5,n.preSolvePosition=function(e){var t,o,n;for(t=0;t<e.length;t++)o=e[t],o.isActive&&(n=o.activeContacts.length,o.collision.parentA.totalContacts+=n,o.collision.parentB.totalContacts+=n)},n.solvePosition=function(e,t){var o,i,s,a,l,c,d,u,p,f=r._temp[0],v=r._temp[1],y=r._temp[2],m=r._temp[3];for(o=0;o<e.length;o++)i=e[o],i.isActive&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,v),y),m),i.separation=r.dot(c,d));
|
||||
for(o=0;o<e.length;o++)i=e[o],!i.isActive||i.separation<0||(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=n._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=n._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},n.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var o=e[t];if(o.totalContacts=0,0!==o.positionImpulse.x||0!==o.positionImpulse.y){for(var s=0;s<o.parts.length;s++){var l=o.parts[s];i.translate(l.vertices,o.positionImpulse),a.update(l.bounds,l.vertices,o.velocity),l.position.x+=o.positionImpulse.x,l.position.y+=o.positionImpulse.y}o.positionPrev.x+=o.positionImpulse.x,o.positionPrev.y+=o.positionImpulse.y,r.dot(o.positionImpulse,o.velocity)<0?(o.positionImpulse.x=0,o.positionImpulse.y=0):(o.positionImpulse.x*=n._positionWarming,o.positionImpulse.y*=n._positionWarming)}}
|
||||
},n.preSolveVelocity=function(e){var t,o,n,i,s,a,l,c,d,u,p,f,v,y,m=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(n=e[t],n.isActive)for(i=n.activeContacts,s=n.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,o=0;o<i.length;o++)u=i[o],p=u.vertex,f=u.normalImpulse,v=u.tangentImpulse,(0!==f||0!==v)&&(m.x=c.x*f+d.x*v,m.y=c.y*f+d.y*v,a.isStatic||a.isSleeping||(y=r.sub(p,a.position,g),a.positionPrev.x+=m.x*a.inverseMass,a.positionPrev.y+=m.y*a.inverseMass,a.anglePrev+=r.cross(y,m)*a.inverseInertia),l.isStatic||l.isSleeping||(y=r.sub(p,l.position,g),l.positionPrev.x-=m.x*l.inverseMass,l.positionPrev.y-=m.y*l.inverseMass,l.anglePrev-=r.cross(y,m)*l.inverseInertia))},n.solveVelocity=function(e,t){for(var o=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){var f=e[p];if(f.isActive){var v=f.collision,y=v.parentA,m=v.parentB,g=v.normal,x=v.tangent,h=f.activeContacts,b=1/h.length;y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,
|
||||
m.velocity.x=m.position.x-m.positionPrev.x,m.velocity.y=m.position.y-m.positionPrev.y,y.angularVelocity=y.angle-y.anglePrev,m.angularVelocity=m.angle-m.anglePrev;for(var S=0;S<h.length;S++){var w=h[S],C=w.vertex,A=r.sub(C,y.position,a),B=r.sub(C,m.position,l),P=r.add(y.velocity,r.mult(r.perp(A),y.angularVelocity),c),M=r.add(m.velocity,r.mult(r.perp(B),m.angularVelocity),d),k=r.sub(P,M,u),I=r.dot(g,k),T=r.dot(x,k),V=Math.abs(T),R=s.sign(T),E=(1+f.restitution)*I,L=s.clamp(f.separation+I,0,1)*n._frictionNormalMultiplier,_=T,O=1/0;V>f.friction*f.frictionStatic*L*o&&(O=V,_=s.clamp(f.friction*R*o,-O,O));var W=r.cross(A,g),F=r.cross(B,g),N=b/(y.inverseMass+m.inverseMass+y.inverseInertia*W*W+m.inverseInertia*F*F);if(E*=N,_*=N,0>I&&I*I>n._restingThresh*o)w.normalImpulse=0;else{var D=w.normalImpulse;w.normalImpulse=Math.min(w.normalImpulse+E,0),E=w.normalImpulse-D}if(T*T>n._restingThreshTangent*o)w.tangentImpulse=0;else{var q=w.tangentImpulse;w.tangentImpulse=s.clamp(w.tangentImpulse+_,-O,O),_=w.tangentImpulse-q;
|
||||
}i.x=g.x*E+x.x*_,i.y=g.y*E+x.y*_,y.isStatic||y.isSleeping||(y.positionPrev.x+=i.x*y.inverseMass,y.positionPrev.y+=i.y*y.inverseMass,y.anglePrev+=r.cross(A,i)*y.inverseInertia),m.isStatic||m.isSleeping||(m.positionPrev.x-=i.x*m.inverseMass,m.positionPrev.y-=i.y*m.inverseMass,m.anglePrev-=r.cross(B,i)*m.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],11:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){n.collides=function(t,n,s){var a,l,c,d,u=s,p=!1;if(u){var f=t.parent,v=n.parent,y=f.speed*f.speed+f.angularSpeed*f.angularSpeed+v.speed*v.speed+v.angularSpeed*v.angularSpeed;p=u&&u.collided&&.2>y,d=u}else d={collided:!1,bodyA:t,bodyB:n};if(u&&p){var m=d.axisBody,g=m===t?n:t,x=[m.axes[u.axisNumber]];if(c=e(m.vertices,g.vertices,x),d.reused=!0,c.overlap<=0)return d.collided=!1,d}else{if(a=e(t.vertices,n.vertices,t.axes),a.overlap<=0)return d.collided=!1,d;if(l=e(n.vertices,t.vertices,n.axes),
|
||||
l.overlap<=0)return d.collided=!1,d;a.overlap<l.overlap?(c=a,d.axisBody=t):(c=l,d.axisBody=n),d.axisNumber=c.axisNumber}d.bodyA=t.id<n.id?t:n,d.bodyB=t.id<n.id?n:t,d.collided=!0,d.normal=c.axis,d.depth=c.overlap,d.parentA=d.bodyA.parent,d.parentB=d.bodyB.parent,t=d.bodyA,n=d.bodyB,r.dot(d.normal,r.sub(n.position,t.position))>0&&(d.normal=r.neg(d.normal)),d.tangent=r.perp(d.normal),d.penetration={x:d.normal.x*d.depth,y:d.normal.y*d.depth};var h=o(t,n,d.normal),b=d.supports||[];if(b.length=0,i.contains(t.vertices,h[0])&&b.push(h[0]),i.contains(t.vertices,h[1])&&b.push(h[1]),b.length<2){var S=o(n,t,r.neg(d.normal));i.contains(n.vertices,S[0])&&b.push(S[0]),b.length<2&&i.contains(n.vertices,S[1])&&b.push(S[1])}return b.length<1&&(b=[h[0]]),d.supports=b,d};var e=function(e,o,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],t(a,e,s),t(l,o,s),i=Math.min(a.max-l.min,l.max-a.min),0>=i)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d);
|
||||
}return c},t=function(e,t,o){for(var n=r.dot(t[0],o),i=n,s=1;s<t.length;s+=1){var a=r.dot(t[s],o);a>i?i=a:n>a&&(n=a)}e.min=n,e.max=i},o=function(e,t,o){for(var n,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,n=-r.dot(o,c),l>n&&(l=n,s=i);var f=s.index-1>=0?s.index-1:d.length-1;i=d[f],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(o,c),a=i;var v=(s.index+1)%d.length;return i=d[v],c.x=i.x-u.x,c.y=i.y-u.y,n=-r.dot(o,c),l>n&&(a=i),[s,a]}}()},{"../geometry/Vector":26,"../geometry/Vertices":27}],12:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){var e=1e-6,t=.001;n.create=function(t){var o=t;o.bodyA&&!o.pointA&&(o.pointA={x:0,y:0}),o.bodyB&&!o.pointB&&(o.pointB={x:0,y:0});var n=o.bodyA?r.add(o.bodyA.position,o.pointA):o.pointA,i=o.bodyB?r.add(o.bodyB.position,o.pointB):o.pointB,s=r.magnitude(r.sub(n,i));
|
||||
o.length=o.length||s||e;var a={visible:!0,lineWidth:2,strokeStyle:"#666"};return o.render=c.extend(a,o.render),o.id=o.id||c.nextId(),o.label=o.label||"Constraint",o.type="constraint",o.stiffness=o.stiffness||1,o.angularStiffness=o.angularStiffness||0,o.angleA=o.bodyA?o.bodyA.angle:o.angleA,o.angleB=o.bodyB?o.bodyB.angle:o.angleB,o},n.solveAll=function(e,t){for(var o=0;o<e.length;o++)n.solve(e[o],t)},n.solve=function(o,n){var i=o.bodyA,a=o.bodyB,l=o.pointA,d=o.pointB;i&&!i.isStatic&&(o.pointA=r.rotate(l,i.angle-o.angleA),o.angleA=i.angle),a&&!a.isStatic&&(o.pointB=r.rotate(d,a.angle-o.angleB),o.angleB=a.angle);var u=l,p=d;if(i&&(u=r.add(i.position,l)),a&&(p=r.add(a.position,d)),u&&p){var f=r.sub(u,p),v=r.magnitude(f);0===v&&(v=e);var y=(v-o.length)/v,m=r.div(f,v),g=r.mult(f,.5*y*o.stiffness*n*n);if(!(Math.abs(1-v/o.length)<t*n)){var x,h,b,S,w,C,A,B;i&&!i.isStatic?(b={x:u.x-i.position.x+g.x,y:u.y-i.position.y+g.y},i.velocity.x=i.position.x-i.positionPrev.x,i.velocity.y=i.position.y-i.positionPrev.y,
|
||||
i.angularVelocity=i.angle-i.anglePrev,x=r.add(i.velocity,r.mult(r.perp(b),i.angularVelocity)),w=r.dot(b,m),A=i.inverseMass+i.inverseInertia*w*w):(x={x:0,y:0},A=i?i.inverseMass:0),a&&!a.isStatic?(S={x:p.x-a.position.x-g.x,y:p.y-a.position.y-g.y},a.velocity.x=a.position.x-a.positionPrev.x,a.velocity.y=a.position.y-a.positionPrev.y,a.angularVelocity=a.angle-a.anglePrev,h=r.add(a.velocity,r.mult(r.perp(S),a.angularVelocity)),C=r.dot(S,m),B=a.inverseMass+a.inverseInertia*C*C):(h={x:0,y:0},B=a?a.inverseMass:0);var P=r.sub(h,x),M=r.dot(m,P)/(A+B);M>0&&(M=0);var k,I={x:m.x*M,y:m.y*M};i&&!i.isStatic&&(k=r.cross(b,I)*i.inverseInertia*(1-o.angularStiffness),s.set(i,!1),k=c.clamp(k,-.01,.01),i.constraintImpulse.x-=g.x,i.constraintImpulse.y-=g.y,i.constraintImpulse.angle+=k,i.position.x-=g.x,i.position.y-=g.y,i.angle+=k),a&&!a.isStatic&&(k=r.cross(S,I)*a.inverseInertia*(1-o.angularStiffness),s.set(a,!1),k=c.clamp(k,-.01,.01),a.constraintImpulse.x+=g.x,a.constraintImpulse.y+=g.y,a.constraintImpulse.angle-=k,
|
||||
a.position.x+=g.x,a.position.y+=g.y,a.angle-=k)}}},n.postSolveAll=function(e){for(var t=0;t<e.length;t++){var o=e[t],n=o.constraintImpulse;if(0!==n.x||0!==n.y||0!==n.angle){for(var s=0;s<o.parts.length;s++){var c=o.parts[s];i.translate(c.vertices,n),s>0&&(c.position.x+=n.x,c.position.y+=n.y),0!==n.angle&&(i.rotate(c.vertices,n.angle,o.position),l.rotate(c.axes,n.angle),s>0&&r.rotateAbout(c.position,n.angle,o.position,c.position)),a.update(c.bounds,c.vertices,o.velocity)}n.angle=0,n.x=0,n.y=0}}}}()},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],13:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");!function(){n.create=function(t,o){var i=(t?t.mouse:null)||(o?o.mouse:null);i||(t&&t.render&&t.render.canvas?i=s.create(t.render.canvas):(i=s.create(),
|
||||
u.log("MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected","warn")));var r=c.create({label:"Mouse Constraint",pointA:i.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),l={type:"mouseConstraint",mouse:i,body:null,constraint:r,collisionFilter:{category:1,mask:4294967295,group:0}},p=u.extend(l,o);return a.on(t,"tick",function(){var o=d.allBodies(t.world);n.update(p,o),e(p)}),p},n.update=function(e,t){var o=e.mouse,n=e.constraint,s=e.body;if(0===o.button){if(n.bodyB)r.set(n.bodyB,!1),n.pointA=o.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,o.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,o.position)){n.pointA=o.position,n.bodyB=e.body=s,n.pointB={x:o.position.x-s.position.x,y:o.position.y-s.position.y},n.angleB=s.angle,r.set(s,!1),
|
||||
a.trigger(e,"startdrag",{mouse:o,body:s});break}}}else n.bodyB=e.body=null,n.pointB=null,s&&a.trigger(e,"enddrag",{mouse:o,body:s})};var e=function(e){var t=e.mouse,o=t.sourceEvents;o.mousemove&&a.trigger(e,"mousemove",{mouse:t}),o.mousedown&&a.trigger(e,"mousedown",{mouse:t}),o.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":18,"../core/Sleeping":20,"../geometry/Bounds":24,"../geometry/Vertices":27,"./Constraint":12}],14:[function(e,t,o){var n={};t.exports=n,function(){n._nextId=0,n._seed=0,n.extend=function(e,t){var o,i,r;"boolean"==typeof t?(o=2,r=t):(o=1,r=!0),i=Array.prototype.slice.call(arguments,o);for(var s=0;s<i.length;s++){var a=i[s];if(a)for(var l in a)r&&a[l]&&a[l].constructor===Object?e[l]&&e[l].constructor!==Object?e[l]=a[l]:(e[l]=e[l]||{},n.extend(e[l],r,a[l])):e[l]=a[l]}return e},n.clone=function(e,t){return n.extend({},t,e)},n.keys=function(e){if(Object.keys)return Object.keys(e);
|
||||
var t=[];for(var o in e)t.push(o);return t},n.values=function(e){var t=[];if(Object.keys){for(var o=Object.keys(e),n=0;n<o.length;n++)t.push(e[o[n]]);return t}for(var i in e)t.push(e[i]);return t},n.shadeColor=function(e,t){var o=parseInt(e.slice(1),16),n=Math.round(2.55*t),i=(o>>16)+n,r=(o>>8&255)+n,s=(255&o)+n;return"#"+(16777216+65536*(255>i?1>i?0:i:255)+256*(255>r?1>r?0:r:255)+(255>s?1>s?0:s:255)).toString(16).slice(1)},n.shuffle=function(e){for(var t=e.length-1;t>0;t--){var o=Math.floor(n.random()*(t+1)),i=e[t];e[t]=e[o],e[o]=i}return e},n.choose=function(e){return e[Math.floor(n.random()*e.length)]},n.isElement=function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},n.clamp=function(e,t,o){return t>e?t:e>o?o:e},n.sign=function(e){return 0>e?-1:1},n.now=function(){var e=window.performance||{};return e.now=function(){
|
||||
return e.now||e.webkitNow||e.msNow||e.oNow||e.mozNow||function(){return+new Date}}(),e.now()},n.random=function(t,o){return t="undefined"!=typeof t?t:0,o="undefined"!=typeof o?o:1,t+e()*(o-t)},n.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},n.log=function(e,t){if(console&&console.log&&console.warn)switch(t){case"warn":console.warn("Matter.js:",e);break;case"error":console.log("Matter.js:",e)}},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var o=0;o<e.length;o++)if(e[o]===t)return o;return-1};var e=function(){return n._seed=(9301*n._seed+49297)%233280,n._seed/233280}}()},{}],15:[function(e,t,o){var n={};t.exports=n;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),v=e("../body/Body");
|
||||
!function(){n.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null;var o={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},n=f.extend(o,t);if(e||n.render){var r={element:e,controller:a};n.render=f.extend(r,n.render)}return n.render&&n.render.controller&&(n.render=n.render.controller.create(n.render)),n.world=i.create(n.world),n.pairs=l.create(),n.broadphase=n.broadphase.controller.create(n.broadphase),n.metrics=n.metrics||{extended:!1},n},n.update=function(n,i,a){a="undefined"!=typeof a?a:1;var c,f=n.world,v=n.timing,y=n.broadphase,m=[];v.timestamp+=i*v.timeScale;var g={timestamp:v.timestamp};d.trigger(n,"beforeUpdate",g);var x=u.allBodies(f),h=u.allConstraints(f);for(n.enableSleeping&&r.update(x,v.timeScale),t(x,f.gravity),o(x,i,v.timeScale,a,f.bounds),c=0;c<n.constraintIterations;c++)p.solveAll(h,v.timeScale);p.postSolveAll(x),y.controller?(f.isModified&&y.controller.clear(y),
|
||||
y.controller.update(y,x,n,f.isModified),m=y.pairsList):m=x;var b=y.detector(m,n),S=n.pairs,w=v.timestamp;for(l.update(S,b,w),l.removeOld(S,w),n.enableSleeping&&r.afterCollisions(S.list,v.timeScale),S.collisionStart.length>0&&d.trigger(n,"collisionStart",{pairs:S.collisionStart}),s.preSolvePosition(S.list),c=0;c<n.positionIterations;c++)s.solvePosition(S.list,v.timeScale);for(s.postSolvePosition(x),s.preSolveVelocity(S.list),c=0;c<n.velocityIterations;c++)s.solveVelocity(S.list,v.timeScale);return S.collisionActive.length>0&&d.trigger(n,"collisionActive",{pairs:S.collisionActive}),S.collisionEnd.length>0&&d.trigger(n,"collisionEnd",{pairs:S.collisionEnd}),e(x),f.isModified&&u.setModified(f,!1,!1,!0),d.trigger(n,"afterUpdate",g),n},n.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,n.clear(e);for(var o=u.allBodies(e.world),i=0;i<o.length;i++){var s=o[i];r.set(s,!1),s.id=f.nextId()}}},n.clear=function(e){var t=e.world;l.clear(e.pairs);var o=e.broadphase;if(o.controller){var n=u.allBodies(t);
|
||||
o.controller.clear(o),o.controller.update(o,n,e,!0)}};var e=function(e){for(var t=0;t<e.length;t++){var o=e[t];o.force.x=0,o.force.y=0,o.torque=0}},t=function(e,t){for(var o=0;o<e.length;o++){var n=e[o];n.isStatic||n.isSleeping||(n.force.y+=n.mass*t.y*.001,n.force.x+=n.mass*t.x*.001)}},o=function(e,t,o,n,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||v.update(s,t,o,n)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":29,"./Common":14,"./Events":16,"./Metrics":17,"./Sleeping":20}],16:[function(e,t,o){var n={};t.exports=n;var i=e("./Common");!function(){n.on=function(e,t,o){for(var n,i=t.split(" "),r=0;r<i.length;r++)n=i[r],e.events=e.events||{},e.events[n]=e.events[n]||[],e.events[n].push(o);return o},n.off=function(e,t,o){if(!t)return void(e.events={});"function"==typeof t&&(o=t,t=i.keys(e.events).join(" "));for(var n=t.split(" "),r=0;r<n.length;r++){
|
||||
var s=e.events[n[r]],a=[];if(o&&s)for(var l=0;l<s.length;l++)s[l]!==o&&a.push(s[l]);e.events[n[r]]=a}},n.trigger=function(e,t,o){var n,r,s,a;if(e.events){o||(o={}),n=t.split(" ");for(var l=0;l<n.length;l++)if(r=n[l],s=e.events[r]){a=i.clone(o,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,o){},{"../body/Composite":2,"./Common":14}],18:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Common");!function(){n.create=function(t){var o={};return t||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),o.element=t||document.body,o.absolute={x:0,y:0},o.position={x:0,y:0},o.mousedownPosition={x:0,y:0},o.mouseupPosition={x:0,y:0},o.offset={x:0,y:0},o.scale={x:1,y:1},o.wheelDelta=0,o.button=-1,o.pixelRatio=o.element.getAttribute("data-pixel-ratio")||1,o.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},o.mousemove=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i&&(o.button=0,
|
||||
t.preventDefault()),o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.sourceEvents.mousemove=t},o.mousedown=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i?(o.button=0,t.preventDefault()):o.button=t.button,o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.mousedownPosition.x=o.position.x,o.mousedownPosition.y=o.position.y,o.sourceEvents.mousedown=t},o.mouseup=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i&&t.preventDefault(),o.button=-1,o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.mouseupPosition.x=o.position.x,o.mouseupPosition.y=o.position.y,o.sourceEvents.mouseup=t},o.mousewheel=function(e){o.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},n.setElement(o,o.element),o},n.setElement=function(e,t){
|
||||
e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},n.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},n.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},n.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y};var e=function(e,t,o){var n,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;
|
||||
return c?(n=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(n=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:n/(t.clientWidth/t.width*o),y:i/(t.clientHeight/t.height*o)}}}()},{"../core/Common":14}],19:[function(e,t,o){var n={};t.exports=n;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),n.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,counterTimestamp:0,frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},o=s.extend(t,e);return o.delta=o.delta||1e3/o.fps,o.deltaMin=o.deltaMin||1e3/o.fps,o.deltaMax=o.deltaMax||1e3/(.5*o.fps),o.fps=1e3/o.delta,o},n.run=function(t,o){
|
||||
return"undefined"!=typeof t.positionIterations&&(o=t,t=n.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&n.tick(t,o,r)}(),t},n.tick=function(e,t,o){var n,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?n=e.delta:(n=o-e.timePrev||e.delta,e.timePrev=o,e.deltaHistory.push(n),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),n=Math.min.apply(null,e.deltaHistory),n=n<e.deltaMin?e.deltaMin:n,n=n>e.deltaMax?e.deltaMax:n,a=n/e.delta,e.delta=n),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,o-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((o-e.counterTimestamp)/1e3),e.counterTimestamp=o,e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,n,a),i.trigger(e,"afterUpdate",l),
|
||||
t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},n.stop=function(e){t(e.frameRequestId)},n.start=function(e,t){n.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],20:[function(e,t,o){var n={};t.exports=n;var i=e("./Events");!function(){n._motionWakeThreshold=.18,n._motionSleepThreshold=.08,n._minBias=.9,n.update=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=n._minBias*a+(1-n._minBias)*l,r.sleepThreshold>0&&r.motion<n._motionSleepThreshold*o?(r.sleepCounter+=1,r.sleepCounter>=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){
|
||||
var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>n._motionWakeThreshold*o&&n.set(c,!1)}}}},n.set=function(e,t){var o=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,o||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,o&&i.trigger(e,"sleepEnd"))}}()},{"./Events":16}],21:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../core/Common"),s=e("../body/Body"),a=e("../geometry/Bounds"),l=e("../geometry/Vector");!function(){n.rectangle=function(e,t,o,n,a){a=a||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:i.fromPath("L 0 0 L "+o+" 0 L "+o+" "+n+" L 0 "+n)};if(a.chamfer){var c=a.chamfer;l.vertices=i.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),
|
||||
delete a.chamfer}return s.create(r.extend({},l,a))},n.trapezoid=function(e,t,o,n,a,l){l=l||{},a*=.5;var c,d=(1-2*a)*o,u=o*a,p=u+d,f=p+u;c=.5>a?"L 0 0 L "+u+" "+-n+" L "+p+" "+-n+" L "+f+" 0":"L 0 0 L "+p+" "+-n+" L "+f+" 0";var v={label:"Trapezoid Body",position:{x:e,y:t},vertices:i.fromPath(c)};if(l.chamfer){var y=l.chamfer;v.vertices=i.chamfer(v.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete l.chamfer}return s.create(r.extend({},v,l))},n.circle=function(e,t,o,i,r){i=i||{},i.label="Circle Body",r=r||25;var s=Math.ceil(Math.max(10,Math.min(r,o)));return s%2===1&&(s+=1),i.circleRadius=o,n.polygon(e,t,s,o,i)},n.polygon=function(e,t,o,a,l){if(l=l||{},3>o)return n.circle(e,t,a,l);for(var c=2*Math.PI/o,d="",u=.5*c,p=0;o>p;p+=1){var f=u+p*c,v=Math.cos(f)*a,y=Math.sin(f)*a;d+="L "+v.toFixed(3)+" "+y.toFixed(3)+" "}var m={label:"Polygon Body",position:{x:e,y:t},vertices:i.fromPath(d)};if(l.chamfer){var g=l.chamfer;m.vertices=i.chamfer(m.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),
|
||||
delete l.chamfer}return s.create(r.extend({},m,l))},n.fromVertices=function(e,t,o,n,c,d,u){var p,f,v,y,m,g,x,h,b;for(n=n||{},f=[],c="undefined"!=typeof c?c:!1,d="undefined"!=typeof d?d:.01,u="undefined"!=typeof u?u:10,window.decomp||r.log("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.","warn"),r.isArray(o[0])||(o=[o]),h=0;h<o.length;h+=1)if(y=o[h],v=i.isConvex(y),v||!window.decomp)y=v?i.clockwiseSort(y):i.hull(y),f.push({position:{x:e,y:t},vertices:y});else{var S=new decomp.Polygon;for(m=0;m<y.length;m++)S.vertices.push([y[m].x,y[m].y]);S.makeCCW(),d!==!1&&S.removeCollinearPoints(d);var w=S.quickDecomp();for(m=0;m<w.length;m++){var C=w[m],A=[];for(g=0;g<C.vertices.length;g++)A.push({x:C.vertices[g][0],y:C.vertices[g][1]});u>0&&i.area(A)<u||f.push({position:i.centre(A),vertices:A})}}for(m=0;m<f.length;m++)f[m]=s.create(r.extend(f[m],n));if(c){var B=5;for(m=0;m<f.length;m++){var P=f[m];for(g=m+1;g<f.length;g++){var M=f[g];if(a.overlaps(P.bounds,M.bounds)){
|
||||
var k=P.vertices,I=M.vertices;for(x=0;x<P.vertices.length;x++)for(b=0;b<M.vertices.length;b++){var T=l.magnitudeSquared(l.sub(k[(x+1)%k.length],I[b])),V=l.magnitudeSquared(l.sub(k[x],I[(b+1)%I.length]));B>T&&B>V&&(k[x].isInternal=!0,I[b].isInternal=!0)}}}}}return f.length>1?(p=s.create(r.extend({parts:f.slice(0)},n)),s.setPosition(p,{x:e,y:t}),p):f[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],22:[function(e,t,o){var n={};t.exports=n;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){n.stack=function(e,t,o,n,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,v=0;n>v;v++){for(var y=0,m=0;o>m;m++){var g=l(u,p,m,v,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>y&&(y=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=y+s,u=e}return d},n.chain=function(e,t,o,n,a,l){
|
||||
for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,v=u.bounds.max.x-u.bounds.min.x,y=p.bounds.max.y-p.bounds.min.y,m=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:v*t,y:f*o},bodyB:p,pointB:{x:m*n,y:y*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},n.mesh=function(e,t,o,n,a){var l,c,d,u,p,f=e.bodies;for(l=0;o>l;l++){for(c=1;t>c;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)));if(l>0)for(c=0;t>c;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),n&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),n&&t-1>c&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a))))}return e.label+=" Mesh",e},n.pyramid=function(e,t,o,i,r,s,l){return n.stack(e,t,o,i,r,s,function(t,n,s,c,d,u){var p=Math.min(i,Math.ceil(o/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var v=c,y=o-1-c;if(!(v>s||s>y)){
|
||||
1===u&&a.translate(d,{x:(s+(o%2===1?1:-1))*f,y:0});var m=d?s*f:0;return l(e+m+s*r,n,s,c,d,u)}}})},n.newtonsCradle=function(e,t,o,n,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;o>c;c++){var d=1.9,u=l.circle(e+c*(n*d),t+s,n,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),p=r.create({pointA:{x:e+c*(n*d),y:t},bodyB:u});i.addBody(a,u),i.addConstraint(a,p)}return a},n.car=function(e,t,o,n,s){var c=a.nextGroup(!0),d=-20,u=.5*-o+d,p=.5*o-d,f=0,v=i.create({label:"Car"}),y=l.trapezoid(e,t,o,n,.3,{collisionFilter:{group:c},friction:.01,chamfer:{radius:10}}),m=l.circle(e+u,t+f,s,{collisionFilter:{group:c},restitution:.5,friction:.9,frictionStatic:10,slop:.5,density:.01}),g=l.circle(e+p,t+f,s,{collisionFilter:{group:c},restitution:.5,friction:.9,frictionStatic:10,slop:.5,density:.01}),x=r.create({bodyA:y,pointA:{x:u,y:f},bodyB:m,stiffness:.5}),h=r.create({bodyA:y,pointA:{x:p,y:f},bodyB:g,stiffness:.5});return i.addBody(v,y),i.addBody(v,m),i.addBody(v,g),i.addConstraint(v,x),i.addConstraint(v,h),
|
||||
v},n.softBody=function(e,t,o,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.4},p);var f=n.stack(e,t,o,i,r,a,function(e,t){return l.circle(e,t,d,u)});return n.mesh(f,o,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":21}],23:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){n.fromVertices=function(e){for(var t={},o=0;o<e.length;o++){var n=(o+1)%e.length,s=i.normalise({x:e[n].y-e[o].y,y:e[o].x-e[n].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},n.rotate=function(e,t){if(0!==t)for(var o=Math.cos(t),n=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*o-s.y*n,s.y=s.x*n+s.y*o,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":26}],24:[function(e,t,o){var n={};t.exports=n,function(){n.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&n.update(t,e),t},n.update=function(e,t,o){e.min.x=Number.MAX_VALUE,
|
||||
e.max.x=Number.MIN_VALUE,e.min.y=Number.MAX_VALUE,e.max.y=Number.MIN_VALUE;for(var n=0;n<t.length;n++){var i=t[n];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}o&&(o.x>0?e.max.x+=o.x:e.min.x+=o.x,o.y>0?e.max.y+=o.y:e.min.y+=o.y)},n.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},n.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},n.translate=function(e,t){e.min.x+=t.x,e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},n.shift=function(e,t){var o=e.max.x-e.min.x,n=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+o,e.min.y=t.y,e.max.y=t.y+n}}()},{}],25:[function(e,t,o){var n={};t.exports=n;e("../geometry/Bounds");!function(){n.pathToVertices=function(t,o){var n,i,r,s,a,l,c,d,u,p,f,v,y=[],m=0,g=0,x=0;o=o||15;var h=function(e,t,o){var n=o%2===1&&o>1;if(!u||e!=u.x||t!=u.y){u&&n?(f=u.x,v=u.y):(f=0,v=0);var i={x:f+e,y:v+t};(n||!u)&&(u=i),y.push(i),g=f+e,x=v+t}},b=function(e){
|
||||
var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":g=e.x,x=e.y;break;case"H":g=e.x;break;case"V":x=e.y}h(g,x,e.pathSegType)}};for(e(t),r=t.getTotalLength(),l=[],n=0;n<t.pathSegList.numberOfItems;n+=1)l.push(t.pathSegList.getItem(n));for(c=l.concat();r>m;){if(p=t.getPathSegAtLength(m),a=l[p],a!=d){for(;c.length&&c[0]!=a;)b(c.shift());d=a}switch(a.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":s=t.getPointAtLength(m),h(s.x,s.y,0)}m+=o}for(n=0,i=c.length;i>n;++n)b(c[n]);return y};var e=function(e){for(var t,o,n,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;d>u;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(n=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);
|
||||
break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,n,i,r,s),u);break;case"s":a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,n,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=o}("M"==f||"m"==f)&&(t=l,o=c)}}}()},{"../geometry/Bounds":24}],26:[function(e,t,o){var n={};t.exports=n,function(){n.create=function(e,t){return{x:e||0,y:t||0}},n.clone=function(e){return{x:e.x,y:e.y}},n.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},n.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},n.rotate=function(e,t){var o=Math.cos(t),n=Math.sin(t);return{x:e.x*o-e.y*n,y:e.x*n+e.y*o}},n.rotateAbout=function(e,t,o,n){
|
||||
var i=Math.cos(t),r=Math.sin(t);n||(n={});var s=o.x+((e.x-o.x)*i-(e.y-o.y)*r);return n.y=o.y+((e.x-o.x)*r+(e.y-o.y)*i),n.x=s,n},n.normalise=function(e){var t=n.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},n.dot=function(e,t){return e.x*t.x+e.y*t.y},n.cross=function(e,t){return e.x*t.y-e.y*t.x},n.cross3=function(e,t,o){return(t.x-e.x)*(o.y-e.y)-(t.y-e.y)*(o.x-e.x)},n.add=function(e,t,o){return o||(o={}),o.x=e.x+t.x,o.y=e.y+t.y,o},n.sub=function(e,t,o){return o||(o={}),o.x=e.x-t.x,o.y=e.y-t.y,o},n.mult=function(e,t){return{x:e.x*t,y:e.y*t}},n.div=function(e,t){return{x:e.x/t,y:e.y/t}},n.perp=function(e,t){return t=t===!0?-1:1,{x:t*-e.y,y:t*e.x}},n.neg=function(e){return{x:-e.x,y:-e.y}},n.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},n._temp=[n.create(),n.create(),n.create(),n.create(),n.create(),n.create()]}()},{}],27:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){n.create=function(e,t){for(var o=[],n=0;n<e.length;n++){
|
||||
var i=e[n],r={x:i.x,y:i.y,index:n,body:t,isInternal:!1};o.push(r)}return o},n.fromPath=function(e,t){var o=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(o,function(e,t,o){i.push({x:parseFloat(t),y:parseFloat(o)})}),n.create(i,t)},n.centre=function(e){for(var t,o,r,s=n.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),o=i.mult(i.add(e[l],e[r]),t),a=i.add(a,o);return i.div(a,6*s)},n.mean=function(e){for(var t={x:0,y:0},o=0;o<e.length;o++)t.x+=e[o].x,t.y+=e[o].y;return i.div(t,e.length)},n.area=function(e,t){for(var o=0,n=e.length-1,i=0;i<e.length;i++)o+=(e[n].x-e[i].x)*(e[n].y+e[i].y),n=i;return t?o/2:Math.abs(o)/2},n.inertia=function(e,t){for(var o,n,r=0,s=0,a=e,l=0;l<a.length;l++)n=(l+1)%a.length,o=Math.abs(i.cross(a[n],a[l])),r+=o*(i.dot(a[n],a[n])+i.dot(a[n],a[l])+i.dot(a[l],a[l])),s+=o;return t/6*(r/s)},n.translate=function(e,t,o){var n;if(o)for(n=0;n<e.length;n++)e[n].x+=t.x*o,e[n].y+=t.y*o;else for(n=0;n<e.length;n++)e[n].x+=t.x,e[n].y+=t.y;
|
||||
return e},n.rotate=function(e,t,o){if(0!==t){for(var n=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-o.x,l=s.y-o.y;s.x=o.x+(a*n-l*i),s.y=o.y+(a*i+l*n)}return e}},n.contains=function(e,t){for(var o=0;o<e.length;o++){var n=e[o],i=e[(o+1)%e.length];if((t.x-n.x)*(i.y-n.y)+(t.y-n.y)*(n.x-i.x)>0)return!1}return!0},n.scale=function(e,t,o,r){if(1===t&&1===o)return e;r=r||n.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*o;return e},n.chamfer=function(e,t,o,n,s){t=t||[8],t.length||(t=[t]),o="undefined"!=typeof o?o:-1,n=n||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),v=i.normalise({x:u.y-d.y,y:d.x-u.x}),y=Math.sqrt(2*Math.pow(p,2)),m=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,v),.5)),x=i.sub(d,i.mult(g,y)),h=o;-1===o&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,n,s),h%2===1&&(h+=1);for(var b=Math.acos(i.dot(f,v)),S=b/h,w=0;h>w;w++)a.push(i.add(i.rotate(m,S*w),x));
|
||||
}else a.push(d)}return a},n.clockwiseSort=function(e){var t=n.mean(e);return e.sort(function(e,o){return i.angle(t,e)-i.angle(t,o)}),e},n.isConvex=function(e){var t,o,n,i,r=0,s=e.length;if(3>s)return null;for(t=0;s>t;t++)if(o=(t+1)%s,n=(t+2)%s,i=(e[o].x-e[t].x)*(e[n].y-e[o].y),i-=(e[o].y-e[t].y)*(e[n].x-e[o].x),0>i?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r?!0:null},n.hull=function(e){var t,o,n=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var o=e.x-t.x;return 0!==o?o:e.y-t.y}),o=0;o<e.length;o++){for(t=e[o];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(o=e.length-1;o>=0;o--){for(t=e[o];n.length>=2&&i.cross3(n[n.length-2],n[n.length-1],t)<=0;)n.pop();n.push(t)}return n.pop(),r.pop(),n.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":26}],28:[function(e,t,o){var n=t.exports={};n.version="master",n.Body=e("../body/Body"),n.Composite=e("../body/Composite"),n.World=e("../body/World"),n.Contact=e("../collision/Contact"),n.Detector=e("../collision/Detector"),
|
||||
n.Grid=e("../collision/Grid"),n.Pairs=e("../collision/Pairs"),n.Pair=e("../collision/Pair"),n.Query=e("../collision/Query"),n.Resolver=e("../collision/Resolver"),n.SAT=e("../collision/SAT"),n.Constraint=e("../constraint/Constraint"),n.MouseConstraint=e("../constraint/MouseConstraint"),n.Common=e("../core/Common"),n.Engine=e("../core/Engine"),n.Events=e("../core/Events"),n.Mouse=e("../core/Mouse"),n.Runner=e("../core/Runner"),n.Sleeping=e("../core/Sleeping"),n.Bodies=e("../factory/Bodies"),n.Composites=e("../factory/Composites"),n.Axes=e("../geometry/Axes"),n.Bounds=e("../geometry/Bounds"),n.Svg=e("../geometry/Svg"),n.Vector=e("../geometry/Vector"),n.Vertices=e("../geometry/Vertices"),n.Render=e("../render/Render"),n.RenderPixi=e("../render/RenderPixi"),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,n.Engine.run=n.Runner.run;
|
||||
},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Metrics":17,"../core/Mouse":18,"../core/Runner":19,"../core/Sleeping":20,"../factory/Bodies":21,"../factory/Composites":22,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Svg":25,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29,"../render/RenderPixi":30}],29:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector");!function(){n.create=function(t){var o={controller:n,element:null,canvas:null,mouse:null,options:{width:800,height:600,pixelRatio:1,background:"#fafafa",
|
||||
wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(o,t);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.canvas=r.canvas||e(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&n.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),r},n.setPixelRatio=function(e,o){var n=e.options,i=e.canvas;"auto"===o&&(o=t(i)),n.pixelRatio=o,i.setAttribute("data-pixel-ratio",o),
|
||||
i.width=n.width*o,i.height=n.height*o,i.style.width=n.width+"px",i.style.height=n.height+"px",e.context.scale(o,o)},n.world=function(e){var t,o=e.render,i=e.world,u=o.canvas,p=o.context,f=o.options,v=r.allBodies(i),y=r.allConstraints(i),m=f.wireframes?f.wireframeBackground:f.background,g=[],x=[],h={timestamp:e.timing.timestamp};if(a.trigger(o,"beforeRender",h),o.currentBackground!==m&&d(o,m),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",f.hasBounds){var b=o.bounds.max.x-o.bounds.min.x,S=o.bounds.max.y-o.bounds.min.y,w=b/f.width,C=S/f.height;for(t=0;t<v.length;t++){var A=v[t];s.overlaps(A.bounds,o.bounds)&&g.push(A)}for(t=0;t<y.length;t++){var B=y[t],P=B.bodyA,M=B.bodyB,k=B.pointA,I=B.pointB;P&&(k=c.add(P.position,B.pointA)),M&&(I=c.add(M.position,B.pointB)),k&&I&&(s.contains(o.bounds,k)||s.contains(o.bounds,I))&&x.push(B)}p.scale(1/w,1/C),p.translate(-o.bounds.min.x,-o.bounds.min.y)}else x=y,g=v;
|
||||
!f.wireframes||e.enableSleeping&&f.showSleeping?n.bodies(e,g,p):(f.showConvexHulls&&n.bodyConvexHulls(e,g,p),n.bodyWireframes(e,g,p)),f.showBounds&&n.bodyBounds(e,g,p),(f.showAxes||f.showAngleIndicator)&&n.bodyAxes(e,g,p),f.showPositions&&n.bodyPositions(e,g,p),f.showVelocity&&n.bodyVelocity(e,g,p),f.showIds&&n.bodyIds(e,g,p),f.showSeparations&&n.separations(e,e.pairs.list,p),f.showCollisions&&n.collisions(e,e.pairs.list,p),f.showVertexNumbers&&n.vertexNumbers(e,g,p),f.showMousePosition&&n.mousePosition(e,o.mouse,p),n.constraints(x,p),f.showBroadphase&&e.broadphase.controller===l&&n.grid(e,e.broadphase,p),f.showDebug&&n.debug(e,p),f.hasBounds&&p.setTransform(f.pixelRatio,0,0,f.pixelRatio,0,0),a.trigger(o,"afterRender",h)},n.debug=function(e,t){var o=t,n=e.world,i=e.render,s=e.metrics,a=i.options,l=(r.allBodies(n)," ");if(e.timing.timestamp-(i.debugTimestamp||0)>=500){var c="";s.timing&&(c+="fps: "+Math.round(s.timing.fps)+l),i.debugString=c,i.debugTimestamp=e.timing.timestamp}if(i.debugString){
|
||||
o.font="12px Arial",a.wireframes?o.fillStyle="rgba(255,255,255,0.5)":o.fillStyle="rgba(0,0,0,0.5)";for(var d=i.debugString.split("\n"),u=0;u<d.length;u++)o.fillText(d[u],50,50+18*u)}},n.constraints=function(e,t){for(var o=t,n=0;n<e.length;n++){var i=e[n];if(i.render.visible&&i.pointA&&i.pointB){var r=i.bodyA,s=i.bodyB;r?(o.beginPath(),o.moveTo(r.position.x+i.pointA.x,r.position.y+i.pointA.y)):(o.beginPath(),o.moveTo(i.pointA.x,i.pointA.y)),s?o.lineTo(s.position.x+i.pointB.x,s.position.y+i.pointB.y):o.lineTo(i.pointB.x,i.pointB.y),o.lineWidth=i.render.lineWidth,o.strokeStyle=i.render.strokeStyle,o.stroke()}}},n.bodyShadows=function(e,t,o){for(var n=o,i=e.render,r=0;r<t.length;r++){var s=t[r];if(s.render.visible){if(s.circleRadius)n.beginPath(),n.arc(s.position.x,s.position.y,s.circleRadius,0,2*Math.PI),n.closePath();else{n.beginPath(),n.moveTo(s.vertices[0].x,s.vertices[0].y);for(var a=1;a<s.vertices.length;a++)n.lineTo(s.vertices[a].x,s.vertices[a].y);n.closePath()}var l=s.position.x-.5*i.options.width,c=s.position.y-.2*i.options.height,d=Math.abs(l)+Math.abs(c);
|
||||
n.shadowColor="rgba(0,0,0,0.15)",n.shadowOffsetX=.05*l,n.shadowOffsetY=.05*c,n.shadowBlur=1+12*Math.min(1,d/1e3),n.fill(),n.shadowColor=null,n.shadowOffsetX=null,n.shadowOffsetY=null,n.shadowBlur=null}}},n.bodies=function(e,t,n){var r,s,a,l,c=n,d=e.render,u=d.options;for(a=0;a<t.length;a++)if(r=t[a],r.render.visible)for(l=r.parts.length>1?1:0;l<r.parts.length;l++)if(s=r.parts[l],s.render.visible)if(s.render.sprite&&s.render.sprite.texture&&!u.wireframes){var p=s.render.sprite,f=o(d,p.texture);u.showSleeping&&r.isSleeping&&(c.globalAlpha=.5),c.translate(s.position.x,s.position.y),c.rotate(s.angle),c.drawImage(f,f.width*-p.xOffset*p.xScale,f.height*-p.yOffset*p.yScale,f.width*p.xScale,f.height*p.yScale),c.rotate(-s.angle),c.translate(-s.position.x,-s.position.y),u.showSleeping&&r.isSleeping&&(c.globalAlpha=1)}else{if(s.circleRadius)c.beginPath(),c.arc(s.position.x,s.position.y,s.circleRadius,0,2*Math.PI);else{c.beginPath(),c.moveTo(s.vertices[0].x,s.vertices[0].y);for(var v=1;v<s.vertices.length;v++)c.lineTo(s.vertices[v].x,s.vertices[v].y);
|
||||
c.closePath()}u.wireframes?(c.lineWidth=1,c.strokeStyle="#bbb",u.showSleeping&&r.isSleeping&&(c.strokeStyle="rgba(255,255,255,0.2)"),c.stroke()):(u.showSleeping&&r.isSleeping?c.fillStyle=i.shadeColor(s.render.fillStyle,50):c.fillStyle=s.render.fillStyle,c.lineWidth=s.render.lineWidth,c.strokeStyle=s.render.strokeStyle,c.fill(),c.stroke())}},n.bodyWireframes=function(e,t,o){var n,i,r,s,a,l=o,c=e.render.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.render.visible)for(a=n.parts.length>1?1:0;a<n.parts.length;a++){for(i=n.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y)}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},n.bodyConvexHulls=function(e,t,o){var n,i,r,s=o;for(s.beginPath(),
|
||||
i=0;i<t.length;i++)if(n=t[i],n.render.visible&&1!==n.parts.length){for(s.moveTo(n.vertices[0].x,n.vertices[0].y),r=1;r<n.vertices.length;r++)s.lineTo(n.vertices[r].x,n.vertices[r].y);s.lineTo(n.vertices[0].x,n.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},n.vertexNumbers=function(e,t,o){var n,i,r,s=o;for(n=0;n<t.length;n++){var a=t[n].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(n+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},n.mousePosition=function(e,t,o){var n=o;n.fillStyle="rgba(255,255,255,0.8)",n.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},n.bodyBounds=function(e,t,o){var n=o,i=e.render,r=i.options;n.beginPath();for(var s=0;s<t.length;s++){var a=t[s];if(a.render.visible)for(var l=t[s].parts,c=l.length>1?1:0;c<l.length;c++){var d=l[c];n.rect(d.bounds.min.x,d.bounds.min.y,d.bounds.max.x-d.bounds.min.x,d.bounds.max.y-d.bounds.min.y);
|
||||
}}r.wireframes?n.strokeStyle="rgba(255,255,255,0.08)":n.strokeStyle="rgba(0,0,0,0.1)",n.lineWidth=1,n.stroke()},n.bodyAxes=function(e,t,o){var n,i,r,s,a=o,l=e.render,c=l.options;for(a.beginPath(),i=0;i<t.length;i++){var d=t[i],u=d.parts;if(d.render.visible)if(c.showAxes)for(r=u.length>1?1:0;r<u.length;r++)for(n=u[r],s=0;s<n.axes.length;s++){var p=n.axes[s];a.moveTo(n.position.x,n.position.y),a.lineTo(n.position.x+20*p.x,n.position.y+20*p.y)}else for(r=u.length>1?1:0;r<u.length;r++)for(n=u[r],s=0;s<n.axes.length;s++)a.moveTo(n.position.x,n.position.y),a.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2)}c.wireframes?a.strokeStyle="indianred":a.strokeStyle="rgba(0,0,0,0.3)",a.lineWidth=1,a.stroke()},n.bodyPositions=function(e,t,o){var n,i,r,s,a=o,l=e.render,c=l.options;for(a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.render.visible)for(s=0;s<n.parts.length;s++)i=n.parts[s],a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();
|
||||
for(c.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)n=t[r],n.render.visible&&(a.arc(n.positionPrev.x,n.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},n.bodyVelocity=function(e,t,o){var n=o;n.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(n.moveTo(r.position.x,r.position.y),n.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}n.lineWidth=3,n.strokeStyle="cornflowerblue",n.stroke()},n.bodyIds=function(e,t,o){var n,i,r=o;for(n=0;n<t.length;n++)if(t[n].render.visible){var s=t[n].parts;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},n.collisions=function(e,t,o){var n,i,r,s,a=o,l=e.render.options;for(a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.isActive)for(i=n.collision,s=0;s<n.activeContacts.length;s++){var c=n.activeContacts[s],d=c.vertex;
|
||||
a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.isActive&&(i=n.collision,n.activeContacts.length>0)){var u=n.activeContacts[0].vertex.x,p=n.activeContacts[0].vertex.y;2===n.activeContacts.length&&(u=(n.activeContacts[0].vertex.x+n.activeContacts[1].vertex.x)/2,p=(n.activeContacts[0].vertex.y+n.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||i.bodyA.isStatic===!0?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},n.separations=function(e,t,o){var n,i,r,s,a,l=o,c=e.render.options;for(l.beginPath(),a=0;a<t.length;a++)if(n=t[a],n.isActive){i=n.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),
|
||||
d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},n.grid=function(e,t,o){var n=o,r=e.render.options;r.wireframes?n.strokeStyle="rgba(255,180,0,0.1)":n.strokeStyle="rgba(255,180,0,0.5)",n.beginPath();for(var s=i.keys(t.buckets),a=0;a<s.length;a++){var l=s[a];if(!(t.buckets[l].length<2)){var c=l.split(",");n.rect(.5+parseInt(c[0],10)*t.bucketWidth,.5+parseInt(c[1],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}n.lineWidth=1,n.stroke()},n.inspector=function(e,t){var o,n=e.engine,i=e.selected,r=n.render,s=r.options;if(s.hasBounds){var a=r.bounds.max.x-r.bounds.min.x,l=r.bounds.max.y-r.bounds.min.y,c=a/r.options.width,d=l/r.options.height;t.scale(1/c,1/d),t.translate(-r.bounds.min.x,-r.bounds.min.y)}for(var u=0;u<i.length;u++){var p=i[u].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",
|
||||
t.setLineDash([1,2]),p.type){case"body":o=p.bounds,t.beginPath(),t.rect(Math.floor(o.min.x-3),Math.floor(o.min.y-3),Math.floor(o.max.x-o.min.x+6),Math.floor(o.max.y-o.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var f=p.pointA;p.bodyA&&(f=p.pointB),t.beginPath(),t.arc(f.x,f.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",t.fillStyle="rgba(255,165,0,0.1)",o=e.selectBounds,t.beginPath(),t.rect(Math.floor(o.min.x),Math.floor(o.min.y),Math.floor(o.max.x-o.min.x),Math.floor(o.max.y-o.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),s.hasBounds&&t.setTransform(1,0,0,1,0,0)};var e=function(e,t){var o=document.createElement("canvas");return o.width=e,o.height=t,o.oncontextmenu=function(){return!1},o.onselectstart=function(){return!1},o},t=function(e){var t=e.getContext("2d"),o=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;
|
||||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Matter=e()}}(function(){return function e(t,o,n){function i(s,a){if(!o[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(r)return r(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=o[s]={exports:{}};t[s][0].call(d.exports,function(e){var o=t[s][1][e];return i(o?o:e)},d,d.exports,e,t,o,n)}return o[s].exports}for(var r="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=(e("../render/Render"),e("../core/Common")),l=e("../geometry/Bounds"),c=e("../geometry/Axes");!function(){n._inertiaScale=4,n._nextCollidingGroupId=1,
|
||||
n._nextNonCollidingGroupId=-1,n._nextCategory=1,n.create=function(t){var o={id:a.nextId(),type:"body",label:"Body",parts:[],angle:0,vertices:i.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isStatic:!1,isSleeping:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:1.5}},n=a.extend(o,t);return e(n,t),n},n.nextGroup=function(e){return e?n._nextNonCollidingGroupId--:n._nextCollidingGroupId++},n.nextCategory=function(){return n._nextCategory=n._nextCategory<<1,n._nextCategory};var e=function(e,t){n.set(e,{bounds:e.bounds||l.create(e.vertices),positionPrev:e.positionPrev||r.clone(e.position),anglePrev:e.anglePrev||e.angle,
|
||||
vertices:e.vertices,parts:e.parts||[e],isStatic:e.isStatic,isSleeping:e.isSleeping,parent:e.parent||e}),i.rotate(e.vertices,e.angle,e.position),c.rotate(e.axes,e.angle),l.update(e.bounds,e.vertices,e.velocity),n.set(e,{axes:t.axes||e.axes,area:t.area||e.area,mass:t.mass||e.mass,inertia:t.inertia||e.inertia});var o=e.isStatic?"#eeeeee":a.choose(["#556270","#4ECDC4","#C7F464","#FF6B6B","#C44D58"]),s=a.shadeColor(o,-20);e.render.fillStyle=e.render.fillStyle||o,e.render.strokeStyle=e.render.strokeStyle||s,e.render.sprite.xOffset+=-(e.bounds.min.x-e.position.x)/(e.bounds.max.x-e.bounds.min.x),e.render.sprite.yOffset+=-(e.bounds.min.y-e.position.y)/(e.bounds.max.y-e.bounds.min.y)};n.set=function(e,t,o){var i;"string"==typeof t&&(i=t,t={},t[i]=o);for(i in t)if(o=t[i],t.hasOwnProperty(i))switch(i){case"isStatic":n.setStatic(e,o);break;case"isSleeping":s.set(e,o);break;case"mass":n.setMass(e,o);break;case"density":n.setDensity(e,o);break;case"inertia":n.setInertia(e,o);break;case"vertices":n.setVertices(e,o);
|
||||
break;case"position":n.setPosition(e,o);break;case"angle":n.setAngle(e,o);break;case"velocity":n.setVelocity(e,o);break;case"angularVelocity":n.setAngularVelocity(e,o);break;case"parts":n.setParts(e,o);break;default:e[i]=o}},n.setStatic=function(e,t){for(var o=0;o<e.parts.length;o++){var n=e.parts[o];n.isStatic=t,t&&(n.restitution=0,n.friction=1,n.mass=n.inertia=n.density=1/0,n.inverseMass=n.inverseInertia=0,n.positionPrev.x=n.position.x,n.positionPrev.y=n.position.y,n.anglePrev=n.angle,n.angularVelocity=0,n.speed=0,n.angularSpeed=0,n.motion=0)}},n.setMass=function(e,t){e.mass=t,e.inverseMass=1/e.mass,e.density=e.mass/e.area},n.setDensity=function(e,t){n.setMass(e,t*e.area),e.density=t},n.setInertia=function(e,t){e.inertia=t,e.inverseInertia=1/e.inertia},n.setVertices=function(e,t){t[0].body===e?e.vertices=t:e.vertices=i.create(t,e),e.axes=c.fromVertices(e.vertices),e.area=i.area(e.vertices),n.setMass(e,e.density*e.area);var o=i.centre(e.vertices);i.translate(e.vertices,o,-1),n.setInertia(e,n._inertiaScale*i.inertia(e.vertices,e.mass)),
|
||||
i.translate(e.vertices,e.position),l.update(e.bounds,e.vertices,e.velocity)},n.setParts=function(e,o,r){var s;for(o=o.slice(0),e.parts.length=0,e.parts.push(e),e.parent=e,s=0;s<o.length;s++){var a=o[s];a!==e&&(a.parent=e,e.parts.push(a))}if(1!==e.parts.length){if(r="undefined"!=typeof r?r:!0){var l=[];for(s=0;s<o.length;s++)l=l.concat(o[s].vertices);i.clockwiseSort(l);var c=i.hull(l),d=i.centre(c);n.setVertices(e,c),i.translate(e.vertices,d)}var u=t(e);e.area=u.area,e.parent=e,e.position.x=u.centre.x,e.position.y=u.centre.y,e.positionPrev.x=u.centre.x,e.positionPrev.y=u.centre.y,n.setMass(e,u.mass),n.setInertia(e,u.inertia),n.setPosition(e,u.centre)}},n.setPosition=function(e,t){var o=r.sub(t,e.position);e.positionPrev.x+=o.x,e.positionPrev.y+=o.y;for(var n=0;n<e.parts.length;n++){var s=e.parts[n];s.position.x+=o.x,s.position.y+=o.y,i.translate(s.vertices,o),l.update(s.bounds,s.vertices,e.velocity)}},n.setAngle=function(e,t){var o=t-e.angle;e.anglePrev+=o;for(var n=0;n<e.parts.length;n++){
|
||||
var s=e.parts[n];s.angle+=o,i.rotate(s.vertices,o,e.position),c.rotate(s.axes,o),l.update(s.bounds,s.vertices,e.velocity),n>0&&r.rotateAbout(s.position,o,e.position,s.position)}},n.setVelocity=function(e,t){e.positionPrev.x=e.position.x-t.x,e.positionPrev.y=e.position.y-t.y,e.velocity.x=t.x,e.velocity.y=t.y,e.speed=r.magnitude(e.velocity)},n.setAngularVelocity=function(e,t){e.anglePrev=e.angle-t,e.angularVelocity=t,e.angularSpeed=Math.abs(e.angularVelocity)},n.translate=function(e,t){n.setPosition(e,r.add(e.position,t))},n.rotate=function(e,t){n.setAngle(e,e.angle+t)},n.scale=function(e,o,r,s){for(var a=0;a<e.parts.length;a++){var d=e.parts[a];i.scale(d.vertices,o,r,e.position),d.axes=c.fromVertices(d.vertices),e.isStatic||(d.area=i.area(d.vertices),n.setMass(d,e.density*d.area),i.translate(d.vertices,{x:-d.position.x,y:-d.position.y}),n.setInertia(d,i.inertia(d.vertices,d.mass)),i.translate(d.vertices,{x:d.position.x,y:d.position.y})),l.update(d.bounds,d.vertices,e.velocity)}if(!e.isStatic){
|
||||
var u=t(e);e.area=u.area,n.setMass(e,u.mass),n.setInertia(e,u.inertia)}},n.update=function(e,t,o,n){var s=Math.pow(t*o*e.timeScale,2),a=1-e.frictionAir*o*e.timeScale,d=e.position.x-e.positionPrev.x,u=e.position.y-e.positionPrev.y;e.velocity.x=d*a*n+e.force.x/e.mass*s,e.velocity.y=u*a*n+e.force.y/e.mass*s,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.position.x+=e.velocity.x,e.position.y+=e.velocity.y,e.angularVelocity=(e.angle-e.anglePrev)*a*n+e.torque/e.inertia*s,e.anglePrev=e.angle,e.angle+=e.angularVelocity,e.speed=r.magnitude(e.velocity),e.angularSpeed=Math.abs(e.angularVelocity);for(var p=0;p<e.parts.length;p++){var f=e.parts[p];i.translate(f.vertices,e.velocity),p>0&&(f.position.x+=e.velocity.x,f.position.y+=e.velocity.y),0!==e.angularVelocity&&(i.rotate(f.vertices,e.angularVelocity,e.position),c.rotate(f.axes,e.angularVelocity),p>0&&r.rotateAbout(f.position,e.angularVelocity,e.position,f.position)),l.update(f.bounds,f.vertices,e.velocity)}},n.applyForce=function(e,t,o){
|
||||
e.force.x+=o.x,e.force.y+=o.y;var n={x:t.x-e.position.x,y:t.y-e.position.y};e.torque+=n.x*o.y-n.y*o.x};var t=function(e){for(var t={mass:0,area:0,inertia:0,centre:{x:0,y:0}},o=1===e.parts.length?0:1;o<e.parts.length;o++){var n=e.parts[o];t.mass+=n.mass,t.area+=n.area,t.inertia+=n.inertia,t.centre=r.add(t.centre,r.mult(n.position,n.mass!==1/0?n.mass:1))}return t.centre=r.div(t.centre,t.mass!==1/0?t.mass:e.parts.length),t}}()},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29}],2:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Events"),r=e("../core/Common"),s=e("./Body");!function(){n.create=function(e){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite"},e)},n.setModified=function(e,t,o,i){if(e.isModified=t,o&&e.parent&&n.setModified(e.parent,t,o,i),i)for(var r=0;r<e.composites.length;r++){var s=e.composites[r];
|
||||
n.setModified(s,t,o,i)}},n.add=function(e,t){var o=[].concat(t);i.trigger(e,"beforeAdd",{object:t});for(var s=0;s<o.length;s++){var a=o[s];switch(a.type){case"body":if(a.parent!==a){r.log("Composite.add: skipped adding a compound body part (you must add its parent instead)","warn");break}n.addBody(e,a);break;case"constraint":n.addConstraint(e,a);break;case"composite":n.addComposite(e,a);break;case"mouseConstraint":n.addConstraint(e,a.constraint)}}return i.trigger(e,"afterAdd",{object:t}),e},n.remove=function(e,t,o){var r=[].concat(t);i.trigger(e,"beforeRemove",{object:t});for(var s=0;s<r.length;s++){var a=r[s];switch(a.type){case"body":n.removeBody(e,a,o);break;case"constraint":n.removeConstraint(e,a,o);break;case"composite":n.removeComposite(e,a,o);break;case"mouseConstraint":n.removeConstraint(e,a.constraint)}}return i.trigger(e,"afterRemove",{object:t}),e},n.addComposite=function(e,t){return e.composites.push(t),t.parent=e,n.setModified(e,!0,!0,!1),e},n.removeComposite=function(e,t,o){
|
||||
var i=r.indexOf(e.composites,t);if(-1!==i&&(n.removeCompositeAt(e,i),n.setModified(e,!0,!0,!1)),o)for(var s=0;s<e.composites.length;s++)n.removeComposite(e.composites[s],t,!0);return e},n.removeCompositeAt=function(e,t){return e.composites.splice(t,1),n.setModified(e,!0,!0,!1),e},n.addBody=function(e,t){return e.bodies.push(t),n.setModified(e,!0,!0,!1),e},n.removeBody=function(e,t,o){var i=r.indexOf(e.bodies,t);if(-1!==i&&(n.removeBodyAt(e,i),n.setModified(e,!0,!0,!1)),o)for(var s=0;s<e.composites.length;s++)n.removeBody(e.composites[s],t,!0);return e},n.removeBodyAt=function(e,t){return e.bodies.splice(t,1),n.setModified(e,!0,!0,!1),e},n.addConstraint=function(e,t){return e.constraints.push(t),n.setModified(e,!0,!0,!1),e},n.removeConstraint=function(e,t,o){var i=r.indexOf(e.constraints,t);if(-1!==i&&n.removeConstraintAt(e,i),o)for(var s=0;s<e.composites.length;s++)n.removeConstraint(e.composites[s],t,!0);return e},n.removeConstraintAt=function(e,t){return e.constraints.splice(t,1),n.setModified(e,!0,!0,!1),
|
||||
e},n.clear=function(e,t,o){if(o)for(var i=0;i<e.composites.length;i++)n.clear(e.composites[i],t,!0);return t?e.bodies=e.bodies.filter(function(e){return e.isStatic}):e.bodies.length=0,e.constraints.length=0,e.composites.length=0,n.setModified(e,!0,!0,!1),e},n.allBodies=function(e){for(var t=[].concat(e.bodies),o=0;o<e.composites.length;o++)t=t.concat(n.allBodies(e.composites[o]));return t},n.allConstraints=function(e){for(var t=[].concat(e.constraints),o=0;o<e.composites.length;o++)t=t.concat(n.allConstraints(e.composites[o]));return t},n.allComposites=function(e){for(var t=[].concat(e.composites),o=0;o<e.composites.length;o++)t=t.concat(n.allComposites(e.composites[o]));return t},n.get=function(e,t,o){var i,r;switch(o){case"body":i=n.allBodies(e);break;case"constraint":i=n.allConstraints(e);break;case"composite":i=n.allComposites(e).concat(e)}return i?(r=i.filter(function(e){return e.id.toString()===t.toString()}),0===r.length?null:r[0]):null},n.move=function(e,t,o){return n.remove(e,t),
|
||||
n.add(o,t),e},n.rebase=function(e){for(var t=n.allBodies(e).concat(n.allConstraints(e)).concat(n.allComposites(e)),o=0;o<t.length;o++)t[o].id=r.nextId();return n.setModified(e,!0,!0,!1),e},n.translate=function(e,t,o){for(var i=o?n.allBodies(e):e.bodies,r=0;r<i.length;r++)s.translate(i[r],t);return n.setModified(e,!0,!0,!1),e},n.rotate=function(e,t,o,i){for(var r=Math.cos(t),a=Math.sin(t),l=i?n.allBodies(e):e.bodies,c=0;c<l.length;c++){var d=l[c],u=d.position.x-o.x,p=d.position.y-o.y;s.setPosition(d,{x:o.x+(u*r-p*a),y:o.y+(u*a+p*r)}),s.rotate(d,t)}return n.setModified(e,!0,!0,!1),e},n.scale=function(e,t,o,i,r){for(var a=r?n.allBodies(e):e.bodies,l=0;l<a.length;l++){var c=a[l],d=c.position.x-i.x,u=c.position.y-i.y;s.setPosition(c,{x:i.x+d*t,y:i.y+u*o}),s.scale(c,t,o)}return n.setModified(e,!0,!0,!1),e}}()},{"../core/Common":14,"../core/Events":16,"./Body":1}],3:[function(e,t,o){var n={};t.exports=n;var i=e("./Composite"),r=(e("../constraint/Constraint"),e("../core/Common"));!function(){n.create=function(e){
|
||||
var t=i.create(),o={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-(1/0),y:-(1/0)},max:{x:1/0,y:1/0}}};return r.extend(t,o,e)}}()},{"../constraint/Constraint":12,"../core/Common":14,"./Composite":2}],4:[function(e,t,o){var n={};t.exports=n,function(){n.create=function(e){return{id:n.id(e),vertex:e,normalImpulse:0,tangentImpulse:0}},n.id=function(e){return e.body.id+"_"+e.index}}()},{}],5:[function(e,t,o){var n={};t.exports=n;var i=e("./SAT"),r=e("./Pair"),s=e("../geometry/Bounds");!function(){n.collisions=function(e,t){for(var o=[],a=t.pairs.table,l=0;l<e.length;l++){var c=e[l][0],d=e[l][1];if((!c.isStatic&&!c.isSleeping||!d.isStatic&&!d.isSleeping)&&n.canCollide(c.collisionFilter,d.collisionFilter)&&s.overlaps(c.bounds,d.bounds))for(var u=c.parts.length>1?1:0;u<c.parts.length;u++)for(var p=c.parts[u],f=d.parts.length>1?1:0;f<d.parts.length;f++){var v=d.parts[f];if(p===c&&v===d||s.overlaps(p.bounds,v.bounds)){var y,m=r.id(p,v),g=a[m];y=g&&g.isActive?g.collision:null;var x=i.collides(p,v,y);
|
||||
x.collided&&o.push(x)}}}return o},n.canCollide=function(e,t){return e.group===t.group&&0!==e.group?e.group>0:0!==(e.mask&t.category)&&0!==(t.mask&e.category)}}()},{"../geometry/Bounds":24,"./Pair":7,"./SAT":11}],6:[function(e,t,o){var n={};t.exports=n;var i=e("./Pair"),r=e("./Detector"),s=e("../core/Common");!function(){n.create=function(e){var t={controller:n,detector:r.collisions,buckets:{},pairs:{},pairsList:[],bucketWidth:48,bucketHeight:48};return s.extend(t,e)},n.update=function(o,n,i,r){var s,p,f,v,y,m=i.world,g=o.buckets,x=!1;for(s=0;s<n.length;s++){var h=n[s];if((!h.isSleeping||r)&&!(h.bounds.max.x<0||h.bounds.min.x>m.bounds.width||h.bounds.max.y<0||h.bounds.min.y>m.bounds.height)){var b=t(o,h);if(!h.region||b.id!==h.region.id||r){(!h.region||r)&&(h.region=b);var S=e(b,h.region);for(p=S.startCol;p<=S.endCol;p++)for(f=S.startRow;f<=S.endRow;f++){y=a(p,f),v=g[y];var C=p>=b.startCol&&p<=b.endCol&&f>=b.startRow&&f<=b.endRow,w=p>=h.region.startCol&&p<=h.region.endCol&&f>=h.region.startRow&&f<=h.region.endRow;
|
||||
!C&&w&&w&&v&&d(o,v,h),(h.region===b||C&&!w||r)&&(v||(v=l(g,y)),c(o,v,h))}h.region=b,x=!0}}}x&&(o.pairsList=u(o))},n.clear=function(e){e.buckets={},e.pairs={},e.pairsList=[]};var e=function(e,t){var n=Math.min(e.startCol,t.startCol),i=Math.max(e.endCol,t.endCol),r=Math.min(e.startRow,t.startRow),s=Math.max(e.endRow,t.endRow);return o(n,i,r,s)},t=function(e,t){var n=t.bounds,i=Math.floor(n.min.x/e.bucketWidth),r=Math.floor(n.max.x/e.bucketWidth),s=Math.floor(n.min.y/e.bucketHeight),a=Math.floor(n.max.y/e.bucketHeight);return o(i,r,s,a)},o=function(e,t,o,n){return{id:e+","+t+","+o+","+n,startCol:e,endCol:t,startRow:o,endRow:n}},a=function(e,t){return e+","+t},l=function(e,t){var o=e[t]=[];return o},c=function(e,t,o){for(var n=0;n<t.length;n++){var r=t[n];if(!(o.id===r.id||o.isStatic&&r.isStatic)){var s=i.id(o,r),a=e.pairs[s];a?a[2]+=1:e.pairs[s]=[o,r,1]}}t.push(o)},d=function(e,t,o){t.splice(s.indexOf(t,o),1);for(var n=0;n<t.length;n++){var r=t[n],a=i.id(o,r),l=e.pairs[a];l&&(l[2]-=1)}},u=function(e){
|
||||
var t,o,n=[];t=s.keys(e.pairs);for(var i=0;i<t.length;i++)o=e.pairs[t[i]],o[2]>0?n.push(o):delete e.pairs[t[i]];return n}}()},{"../core/Common":14,"./Detector":5,"./Pair":7}],7:[function(e,t,o){var n={};t.exports=n;var i=e("./Contact");!function(){n.create=function(e,t){var o=e.bodyA,i=e.bodyB,r=e.parentA,s=e.parentB,a={id:n.id(o,i),bodyA:o,bodyB:i,contacts:{},activeContacts:[],separation:0,isActive:!0,timeCreated:t,timeUpdated:t,inverseMass:r.inverseMass+s.inverseMass,friction:Math.min(r.friction,s.friction),frictionStatic:Math.max(r.frictionStatic,s.frictionStatic),restitution:Math.max(r.restitution,s.restitution),slop:Math.max(r.slop,s.slop)};return n.update(a,e,t),a},n.update=function(e,t,o){var r=e.contacts,s=t.supports,a=e.activeContacts,l=t.parentA,c=t.parentB;if(e.collision=t,e.inverseMass=l.inverseMass+c.inverseMass,e.friction=Math.min(l.friction,c.friction),e.frictionStatic=Math.max(l.frictionStatic,c.frictionStatic),e.restitution=Math.max(l.restitution,c.restitution),e.slop=Math.max(l.slop,c.slop),
|
||||
a.length=0,t.collided){for(var d=0;d<s.length;d++){var u=s[d],p=i.id(u),f=r[p];f?a.push(f):a.push(r[p]=i.create(u))}e.separation=t.depth,n.setActive(e,!0,o)}else e.isActive===!0&&n.setActive(e,!1,o)},n.setActive=function(e,t,o){t?(e.isActive=!0,e.timeUpdated=o):(e.isActive=!1,e.activeContacts.length=0)},n.id=function(e,t){return e.id<t.id?e.id+"_"+t.id:t.id+"_"+e.id}}()},{"./Contact":4}],8:[function(e,t,o){var n={};t.exports=n;var i=e("./Pair"),r=e("../core/Common");!function(){var e=1e3;n.create=function(e){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},e)},n.update=function(e,t,o){var n,s,a,l,c=e.list,d=e.table,u=e.collisionStart,p=e.collisionEnd,f=e.collisionActive,v=[];for(u.length=0,p.length=0,f.length=0,l=0;l<t.length;l++)n=t[l],n.collided&&(s=i.id(n.bodyA,n.bodyB),v.push(s),a=d[s],a?(a.isActive?f.push(a):u.push(a),i.update(a,n,o)):(a=i.create(n,o),d[s]=a,u.push(a),c.push(a)));for(l=0;l<c.length;l++)a=c[l],a.isActive&&-1===r.indexOf(v,a.id)&&(i.setActive(a,!1,o),
|
||||
p.push(a))},n.removeOld=function(t,o){var n,i,r,s,a=t.list,l=t.table,c=[];for(s=0;s<a.length;s++)n=a[s],i=n.collision,i.bodyA.isSleeping||i.bodyB.isSleeping?n.timeUpdated=o:o-n.timeUpdated>e&&c.push(s);for(s=0;s<c.length;s++)r=c[s]-s,n=a[r],delete l[n.id],a.splice(r,1)},n.clear=function(e){return e.table={},e.list.length=0,e.collisionStart.length=0,e.collisionActive.length=0,e.collisionEnd.length=0,e}}()},{"../core/Common":14,"./Pair":7}],9:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("./SAT"),s=e("../geometry/Bounds"),a=e("../factory/Bodies"),l=e("../geometry/Vertices");!function(){n.ray=function(e,t,o,n){n=n||1e-100;for(var l=i.angle(t,o),c=i.magnitude(i.sub(t,o)),d=.5*(o.x+t.x),u=.5*(o.y+t.y),p=a.rectangle(d,u,c,n,{angle:l}),f=[],v=0;v<e.length;v++){var y=e[v];if(s.overlaps(y.bounds,p.bounds))for(var m=1===y.parts.length?0:1;m<y.parts.length;m++){var g=y.parts[m];if(s.overlaps(g.bounds,p.bounds)){var x=r.collides(g,p);if(x.collided){x.body=x.bodyA=x.bodyB=y,
|
||||
f.push(x);break}}}}return f},n.region=function(e,t,o){for(var n=[],i=0;i<e.length;i++){var r=e[i],a=s.overlaps(r.bounds,t);(a&&!o||!a&&o)&&n.push(r)}return n},n.point=function(e,t){for(var o=[],n=0;n<e.length;n++){var i=e[n];if(s.contains(i.bounds,t))for(var r=1===i.parts.length?0:1;r<i.parts.length;r++){var a=i.parts[r];if(s.contains(a.bounds,t)&&l.contains(a.vertices,t)){o.push(i);break}}}return o}}()},{"../factory/Bodies":21,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27,"./SAT":11}],10:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Common"),a=e("../geometry/Bounds");!function(){n._restingThresh=4,n._restingThreshTangent=6,n._positionDampen=.9,n._positionWarming=.8,n._frictionNormalMultiplier=5,n.preSolvePosition=function(e){var t,o,n;for(t=0;t<e.length;t++)o=e[t],o.isActive&&(n=o.activeContacts.length,o.collision.parentA.totalContacts+=n,o.collision.parentB.totalContacts+=n)},n.solvePosition=function(e,t){
|
||||
var o,i,s,a,l,c,d,u,p,f=r._temp[0],v=r._temp[1],y=r._temp[2],m=r._temp[3];for(o=0;o<e.length;o++)i=e[o],i.isActive&&(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,d=r.sub(r.add(l.positionImpulse,l.position,f),r.add(a.positionImpulse,r.sub(l.position,s.penetration,v),y),m),i.separation=r.dot(c,d));for(o=0;o<e.length;o++)i=e[o],!i.isActive||i.separation<0||(s=i.collision,a=s.parentA,l=s.parentB,c=s.normal,p=(i.separation-i.slop)*t,(a.isStatic||l.isStatic)&&(p*=2),a.isStatic||a.isSleeping||(u=n._positionDampen/a.totalContacts,a.positionImpulse.x+=c.x*p*u,a.positionImpulse.y+=c.y*p*u),l.isStatic||l.isSleeping||(u=n._positionDampen/l.totalContacts,l.positionImpulse.x-=c.x*p*u,l.positionImpulse.y-=c.y*p*u))},n.postSolvePosition=function(e){for(var t=0;t<e.length;t++){var o=e[t];if(o.totalContacts=0,0!==o.positionImpulse.x||0!==o.positionImpulse.y){for(var s=0;s<o.parts.length;s++){var l=o.parts[s];i.translate(l.vertices,o.positionImpulse),a.update(l.bounds,l.vertices,o.velocity),l.position.x+=o.positionImpulse.x,
|
||||
l.position.y+=o.positionImpulse.y}o.positionPrev.x+=o.positionImpulse.x,o.positionPrev.y+=o.positionImpulse.y,r.dot(o.positionImpulse,o.velocity)<0?(o.positionImpulse.x=0,o.positionImpulse.y=0):(o.positionImpulse.x*=n._positionWarming,o.positionImpulse.y*=n._positionWarming)}}},n.preSolveVelocity=function(e){var t,o,n,i,s,a,l,c,d,u,p,f,v,y,m=r._temp[0],g=r._temp[1];for(t=0;t<e.length;t++)if(n=e[t],n.isActive)for(i=n.activeContacts,s=n.collision,a=s.parentA,l=s.parentB,c=s.normal,d=s.tangent,o=0;o<i.length;o++)u=i[o],p=u.vertex,f=u.normalImpulse,v=u.tangentImpulse,(0!==f||0!==v)&&(m.x=c.x*f+d.x*v,m.y=c.y*f+d.y*v,a.isStatic||a.isSleeping||(y=r.sub(p,a.position,g),a.positionPrev.x+=m.x*a.inverseMass,a.positionPrev.y+=m.y*a.inverseMass,a.anglePrev+=r.cross(y,m)*a.inverseInertia),l.isStatic||l.isSleeping||(y=r.sub(p,l.position,g),l.positionPrev.x-=m.x*l.inverseMass,l.positionPrev.y-=m.y*l.inverseMass,l.anglePrev-=r.cross(y,m)*l.inverseInertia))},n.solveVelocity=function(e,t){for(var o=t*t,i=r._temp[0],a=r._temp[1],l=r._temp[2],c=r._temp[3],d=r._temp[4],u=r._temp[5],p=0;p<e.length;p++){
|
||||
var f=e[p];if(f.isActive){var v=f.collision,y=v.parentA,m=v.parentB,g=v.normal,x=v.tangent,h=f.activeContacts,b=1/h.length;y.velocity.x=y.position.x-y.positionPrev.x,y.velocity.y=y.position.y-y.positionPrev.y,m.velocity.x=m.position.x-m.positionPrev.x,m.velocity.y=m.position.y-m.positionPrev.y,y.angularVelocity=y.angle-y.anglePrev,m.angularVelocity=m.angle-m.anglePrev;for(var S=0;S<h.length;S++){var C=h[S],w=C.vertex,A=r.sub(w,y.position,a),B=r.sub(w,m.position,l),P=r.add(y.velocity,r.mult(r.perp(A),y.angularVelocity),c),M=r.add(m.velocity,r.mult(r.perp(B),m.angularVelocity),d),k=r.sub(P,M,u),I=r.dot(g,k),T=r.dot(x,k),V=Math.abs(T),R=s.sign(T),E=(1+f.restitution)*I,_=s.clamp(f.separation+I,0,1)*n._frictionNormalMultiplier,L=T,O=1/0;V>f.friction*f.frictionStatic*_*o&&(O=V,L=s.clamp(f.friction*R*o,-O,O));var W=r.cross(A,g),F=r.cross(B,g),N=b/(y.inverseMass+m.inverseMass+y.inverseInertia*W*W+m.inverseInertia*F*F);if(E*=N,L*=N,0>I&&I*I>n._restingThresh*o)C.normalImpulse=0;else{var D=C.normalImpulse;
|
||||
C.normalImpulse=Math.min(C.normalImpulse+E,0),E=C.normalImpulse-D}if(T*T>n._restingThreshTangent*o)C.tangentImpulse=0;else{var q=C.tangentImpulse;C.tangentImpulse=s.clamp(C.tangentImpulse+L,-O,O),L=C.tangentImpulse-q}i.x=g.x*E+x.x*L,i.y=g.y*E+x.y*L,y.isStatic||y.isSleeping||(y.positionPrev.x+=i.x*y.inverseMass,y.positionPrev.y+=i.y*y.inverseMass,y.anglePrev+=r.cross(A,i)*y.inverseInertia),m.isStatic||m.isSleeping||(m.positionPrev.x-=i.x*m.inverseMass,m.positionPrev.y-=i.y*m.inverseMass,m.anglePrev-=r.cross(B,i)*m.inverseInertia)}}}}}()},{"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],11:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector");!function(){n.collides=function(t,n,s){var a,l,c,d,u=s,p=!1;if(u){var f=t.parent,v=n.parent,y=f.speed*f.speed+f.angularSpeed*f.angularSpeed+v.speed*v.speed+v.angularSpeed*v.angularSpeed;p=u&&u.collided&&.2>y,d=u}else d={collided:!1,bodyA:t,bodyB:n};if(u&&p){var m=d.axisBody,g=m===t?n:t,x=[m.axes[u.axisNumber]];
|
||||
if(c=e(m.vertices,g.vertices,x),d.reused=!0,c.overlap<=0)return d.collided=!1,d}else{if(a=e(t.vertices,n.vertices,t.axes),a.overlap<=0)return d.collided=!1,d;if(l=e(n.vertices,t.vertices,n.axes),l.overlap<=0)return d.collided=!1,d;a.overlap<l.overlap?(c=a,d.axisBody=t):(c=l,d.axisBody=n),d.axisNumber=c.axisNumber}d.bodyA=t.id<n.id?t:n,d.bodyB=t.id<n.id?n:t,d.collided=!0,d.normal=c.axis,d.depth=c.overlap,d.parentA=d.bodyA.parent,d.parentB=d.bodyB.parent,t=d.bodyA,n=d.bodyB,r.dot(d.normal,r.sub(n.position,t.position))>0&&(d.normal=r.neg(d.normal)),d.tangent=r.perp(d.normal),d.penetration={x:d.normal.x*d.depth,y:d.normal.y*d.depth};var h=o(t,n,d.normal),b=d.supports||[];if(b.length=0,i.contains(t.vertices,h[0])&&b.push(h[0]),i.contains(t.vertices,h[1])&&b.push(h[1]),b.length<2){var S=o(n,t,r.neg(d.normal));i.contains(n.vertices,S[0])&&b.push(S[0]),b.length<2&&i.contains(n.vertices,S[1])&&b.push(S[1])}return b.length<1&&(b=[h[0]]),d.supports=b,d};var e=function(e,o,n){for(var i,s,a=r._temp[0],l=r._temp[1],c={
|
||||
overlap:Number.MAX_VALUE},d=0;d<n.length;d++){if(s=n[d],t(a,e,s),t(l,o,s),i=Math.min(a.max-l.min,l.max-a.min),0>=i)return c.overlap=i,c;i<c.overlap&&(c.overlap=i,c.axis=s,c.axisNumber=d)}return c},t=function(e,t,o){for(var n=r.dot(t[0],o),i=n,s=1;s<t.length;s+=1){var a=r.dot(t[s],o);a>i?i=a:n>a&&(n=a)}e.min=n,e.max=i},o=function(e,t,o){for(var n,i,s,a,l=Number.MAX_VALUE,c=r._temp[0],d=t.vertices,u=e.position,p=0;p<d.length;p++)i=d[p],c.x=i.x-u.x,c.y=i.y-u.y,n=-r.dot(o,c),l>n&&(l=n,s=i);var f=s.index-1>=0?s.index-1:d.length-1;i=d[f],c.x=i.x-u.x,c.y=i.y-u.y,l=-r.dot(o,c),a=i;var v=(s.index+1)%d.length;return i=d[v],c.x=i.x-u.x,c.y=i.y-u.y,n=-r.dot(o,c),l>n&&(a=i),[s,a]}}()},{"../geometry/Vector":26,"../geometry/Vertices":27}],12:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../geometry/Vector"),s=e("../core/Sleeping"),a=e("../geometry/Bounds"),l=e("../geometry/Axes"),c=e("../core/Common");!function(){var e=1e-6,t=.001;n.create=function(t){var o=t;o.bodyA&&!o.pointA&&(o.pointA={
|
||||
x:0,y:0}),o.bodyB&&!o.pointB&&(o.pointB={x:0,y:0});var n=o.bodyA?r.add(o.bodyA.position,o.pointA):o.pointA,i=o.bodyB?r.add(o.bodyB.position,o.pointB):o.pointB,s=r.magnitude(r.sub(n,i));o.length=o.length||s||e;var a={visible:!0,lineWidth:2,strokeStyle:"#666"};return o.render=c.extend(a,o.render),o.id=o.id||c.nextId(),o.label=o.label||"Constraint",o.type="constraint",o.stiffness=o.stiffness||1,o.angularStiffness=o.angularStiffness||0,o.angleA=o.bodyA?o.bodyA.angle:o.angleA,o.angleB=o.bodyB?o.bodyB.angle:o.angleB,o},n.solveAll=function(e,t){for(var o=0;o<e.length;o++)n.solve(e[o],t)},n.solve=function(o,n){var i=o.bodyA,s=o.bodyB,a=o.pointA,l=o.pointB;i&&!i.isStatic&&(o.pointA=r.rotate(a,i.angle-o.angleA),o.angleA=i.angle),s&&!s.isStatic&&(o.pointB=r.rotate(l,s.angle-o.angleB),o.angleB=s.angle);var c=a,d=l;if(i&&(c=r.add(i.position,a)),s&&(d=r.add(s.position,l)),c&&d){var u=r.sub(c,d),p=r.magnitude(u);0===p&&(p=e);var f=(p-o.length)/p,v=r.div(u,p),y=r.mult(u,.5*f*o.stiffness*n*n);if(!(Math.abs(1-p/o.length)<t*n)){
|
||||
var m,g,x,h,b,S,C,w;i&&!i.isStatic?(x={x:c.x-i.position.x+y.x,y:c.y-i.position.y+y.y},i.velocity.x=i.position.x-i.positionPrev.x,i.velocity.y=i.position.y-i.positionPrev.y,i.angularVelocity=i.angle-i.anglePrev,m=r.add(i.velocity,r.mult(r.perp(x),i.angularVelocity)),b=r.dot(x,v),C=i.inverseMass+i.inverseInertia*b*b):(m={x:0,y:0},C=i?i.inverseMass:0),s&&!s.isStatic?(h={x:d.x-s.position.x-y.x,y:d.y-s.position.y-y.y},s.velocity.x=s.position.x-s.positionPrev.x,s.velocity.y=s.position.y-s.positionPrev.y,s.angularVelocity=s.angle-s.anglePrev,g=r.add(s.velocity,r.mult(r.perp(h),s.angularVelocity)),S=r.dot(h,v),w=s.inverseMass+s.inverseInertia*S*S):(g={x:0,y:0},w=s?s.inverseMass:0);var A=r.sub(g,m),B=r.dot(v,A)/(C+w);B>0&&(B=0);var P,M={x:v.x*B,y:v.y*B};i&&!i.isStatic&&(P=r.cross(x,M)*i.inverseInertia*(1-o.angularStiffness),i.constraintImpulse.x-=y.x,i.constraintImpulse.y-=y.y,i.constraintImpulse.angle+=P,i.position.x-=y.x,i.position.y-=y.y,i.angle+=P),s&&!s.isStatic&&(P=r.cross(h,M)*s.inverseInertia*(1-o.angularStiffness),
|
||||
s.constraintImpulse.x+=y.x,s.constraintImpulse.y+=y.y,s.constraintImpulse.angle-=P,s.position.x+=y.x,s.position.y+=y.y,s.angle-=P)}}},n.postSolveAll=function(e){for(var t=0;t<e.length;t++){var o=e[t],n=o.constraintImpulse;if(0!==n.x||0!==n.y||0!==n.angle){s.set(o,!1);for(var c=0;c<o.parts.length;c++){var d=o.parts[c];i.translate(d.vertices,n),c>0&&(d.position.x+=n.x,d.position.y+=n.y),0!==n.angle&&(i.rotate(d.vertices,n.angle,o.position),l.rotate(d.axes,n.angle),c>0&&r.rotateAbout(d.position,n.angle,o.position,d.position)),a.update(d.bounds,d.vertices,o.velocity)}n.angle=0,n.x=0,n.y=0}}}}()},{"../core/Common":14,"../core/Sleeping":20,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],13:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../core/Sleeping"),s=e("../core/Mouse"),a=e("../core/Events"),l=e("../collision/Detector"),c=e("./Constraint"),d=e("../body/Composite"),u=e("../core/Common"),p=e("../geometry/Bounds");
|
||||
!function(){n.create=function(t,o){var i=(t?t.mouse:null)||(o?o.mouse:null);i||(t&&t.render&&t.render.canvas?i=s.create(t.render.canvas):(i=s.create(),u.log("MouseConstraint.create: options.mouse was undefined, engine.render.canvas was undefined, may not function as expected","warn")));var r=c.create({label:"Mouse Constraint",pointA:i.position,pointB:{x:0,y:0},length:.01,stiffness:.1,angularStiffness:1,render:{strokeStyle:"#90EE90",lineWidth:3}}),l={type:"mouseConstraint",mouse:i,body:null,constraint:r,collisionFilter:{category:1,mask:4294967295,group:0}},p=u.extend(l,o);return a.on(t,"tick",function(){var o=d.allBodies(t.world);n.update(p,o),e(p)}),p},n.update=function(e,t){var o=e.mouse,n=e.constraint,s=e.body;if(0===o.button){if(n.bodyB)r.set(n.bodyB,!1),n.pointA=o.position;else for(var c=0;c<t.length;c++)if(s=t[c],p.contains(s.bounds,o.position)&&l.canCollide(s.collisionFilter,e.collisionFilter))for(var d=s.parts.length>1?1:0;d<s.parts.length;d++){var u=s.parts[d];if(i.contains(u.vertices,o.position)){
|
||||
n.pointA=o.position,n.bodyB=e.body=s,n.pointB={x:o.position.x-s.position.x,y:o.position.y-s.position.y},n.angleB=s.angle,r.set(s,!1),a.trigger(e,"startdrag",{mouse:o,body:s});break}}}else n.bodyB=e.body=null,n.pointB=null,s&&a.trigger(e,"enddrag",{mouse:o,body:s})};var e=function(e){var t=e.mouse,o=t.sourceEvents;o.mousemove&&a.trigger(e,"mousemove",{mouse:t}),o.mousedown&&a.trigger(e,"mousedown",{mouse:t}),o.mouseup&&a.trigger(e,"mouseup",{mouse:t}),s.clearSourceEvents(t)}}()},{"../body/Composite":2,"../collision/Detector":5,"../core/Common":14,"../core/Events":16,"../core/Mouse":18,"../core/Sleeping":20,"../geometry/Bounds":24,"../geometry/Vertices":27,"./Constraint":12}],14:[function(e,t,o){var n={};t.exports=n,function(){n._nextId=0,n._seed=0,n.extend=function(e,t){var o,i,r;"boolean"==typeof t?(o=2,r=t):(o=1,r=!0),i=Array.prototype.slice.call(arguments,o);for(var s=0;s<i.length;s++){var a=i[s];if(a)for(var l in a)r&&a[l]&&a[l].constructor===Object?e[l]&&e[l].constructor!==Object?e[l]=a[l]:(e[l]=e[l]||{},
|
||||
n.extend(e[l],r,a[l])):e[l]=a[l]}return e},n.clone=function(e,t){return n.extend({},t,e)},n.keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var o in e)t.push(o);return t},n.values=function(e){var t=[];if(Object.keys){for(var o=Object.keys(e),n=0;n<o.length;n++)t.push(e[o[n]]);return t}for(var i in e)t.push(e[i]);return t},n.shadeColor=function(e,t){var o=parseInt(e.slice(1),16),n=Math.round(2.55*t),i=(o>>16)+n,r=(o>>8&255)+n,s=(255&o)+n;return"#"+(16777216+65536*(255>i?1>i?0:i:255)+256*(255>r?1>r?0:r:255)+(255>s?1>s?0:s:255)).toString(16).slice(1)},n.shuffle=function(e){for(var t=e.length-1;t>0;t--){var o=Math.floor(n.random()*(t+1)),i=e[t];e[t]=e[o],e[o]=i}return e},n.choose=function(e){return e[Math.floor(n.random()*e.length)]},n.isElement=function(e){try{return e instanceof HTMLElement}catch(t){return"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument}},n.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e);
|
||||
},n.clamp=function(e,t,o){return t>e?t:e>o?o:e},n.sign=function(e){return 0>e?-1:1},n.now=function(){var e=window.performance||{};return e.now=function(){return e.now||e.webkitNow||e.msNow||e.oNow||e.mozNow||function(){return+new Date}}(),e.now()},n.random=function(t,o){return t="undefined"!=typeof t?t:0,o="undefined"!=typeof o?o:1,t+e()*(o-t)},n.colorToNumber=function(e){return e=e.replace("#",""),3==e.length&&(e=e.charAt(0)+e.charAt(0)+e.charAt(1)+e.charAt(1)+e.charAt(2)+e.charAt(2)),parseInt(e,16)},n.log=function(e,t){if(console&&console.log&&console.warn)switch(t){case"warn":console.warn("Matter.js:",e);break;case"error":console.log("Matter.js:",e)}},n.nextId=function(){return n._nextId++},n.indexOf=function(e,t){if(e.indexOf)return e.indexOf(t);for(var o=0;o<e.length;o++)if(e[o]===t)return o;return-1};var e=function(){return n._seed=(9301*n._seed+49297)%233280,n._seed/233280}}()},{}],15:[function(e,t,o){var n={};t.exports=n;var i=e("../body/World"),r=e("./Sleeping"),s=e("../collision/Resolver"),a=e("../render/Render"),l=e("../collision/Pairs"),c=(e("./Metrics"),
|
||||
e("../collision/Grid")),d=e("./Events"),u=e("../body/Composite"),p=e("../constraint/Constraint"),f=e("./Common"),v=e("../body/Body");!function(){n.create=function(e,t){t=f.isElement(e)?t:e,e=f.isElement(e)?e:null;var o={positionIterations:6,velocityIterations:4,constraintIterations:2,enableSleeping:!1,events:[],timing:{timestamp:0,timeScale:1},broadphase:{controller:c}},n=f.extend(o,t);if(e||n.render){var r={element:e,controller:a};n.render=f.extend(r,n.render)}return n.render&&n.render.controller&&(n.render=n.render.controller.create(n.render)),n.world=i.create(n.world),n.pairs=l.create(),n.broadphase=n.broadphase.controller.create(n.broadphase),n.metrics=n.metrics||{extended:!1},n},n.update=function(n,i,a){a="undefined"!=typeof a?a:1;var c,f=n.world,v=n.timing,y=n.broadphase,m=[];v.timestamp+=i*v.timeScale;var g={timestamp:v.timestamp};d.trigger(n,"beforeUpdate",g);var x=u.allBodies(f),h=u.allConstraints(f);for(n.enableSleeping&&r.update(x,v.timeScale),t(x,f.gravity),o(x,i,v.timeScale,a,f.bounds),
|
||||
c=0;c<n.constraintIterations;c++)p.solveAll(h,v.timeScale);p.postSolveAll(x),y.controller?(f.isModified&&y.controller.clear(y),y.controller.update(y,x,n,f.isModified),m=y.pairsList):m=x;var b=y.detector(m,n),S=n.pairs,C=v.timestamp;for(l.update(S,b,C),l.removeOld(S,C),n.enableSleeping&&r.afterCollisions(S.list,v.timeScale),S.collisionStart.length>0&&d.trigger(n,"collisionStart",{pairs:S.collisionStart}),s.preSolvePosition(S.list),c=0;c<n.positionIterations;c++)s.solvePosition(S.list,v.timeScale);for(s.postSolvePosition(x),s.preSolveVelocity(S.list),c=0;c<n.velocityIterations;c++)s.solveVelocity(S.list,v.timeScale);return S.collisionActive.length>0&&d.trigger(n,"collisionActive",{pairs:S.collisionActive}),S.collisionEnd.length>0&&d.trigger(n,"collisionEnd",{pairs:S.collisionEnd}),e(x),f.isModified&&u.setModified(f,!1,!1,!0),d.trigger(n,"afterUpdate",g),n},n.merge=function(e,t){if(f.extend(e,t),t.world){e.world=t.world,n.clear(e);for(var o=u.allBodies(e.world),i=0;i<o.length;i++){var s=o[i];
|
||||
r.set(s,!1),s.id=f.nextId()}}},n.clear=function(e){var t=e.world;l.clear(e.pairs);var o=e.broadphase;if(o.controller){var n=u.allBodies(t);o.controller.clear(o),o.controller.update(o,n,e,!0)}};var e=function(e){for(var t=0;t<e.length;t++){var o=e[t];o.force.x=0,o.force.y=0,o.torque=0}},t=function(e,t){var o="undefined"!=typeof t.scale?t.scale:.001;if((0!==t.x||0!==t.y)&&0!==o)for(var n=0;n<e.length;n++){var i=e[n];i.isStatic||i.isSleeping||(i.force.y+=i.mass*t.y*o,i.force.x+=i.mass*t.x*o)}},o=function(e,t,o,n,i){for(var r=0;r<e.length;r++){var s=e[r];s.isStatic||s.isSleeping||v.update(s,t,o,n)}}}()},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Grid":6,"../collision/Pairs":8,"../collision/Resolver":10,"../constraint/Constraint":12,"../render/Render":29,"./Common":14,"./Events":16,"./Metrics":17,"./Sleeping":20}],16:[function(e,t,o){var n={};t.exports=n;var i=e("./Common");!function(){n.on=function(e,t,o){for(var n,i=t.split(" "),r=0;r<i.length;r++)n=i[r],e.events=e.events||{},
|
||||
e.events[n]=e.events[n]||[],e.events[n].push(o);return o},n.off=function(e,t,o){if(!t)return void(e.events={});"function"==typeof t&&(o=t,t=i.keys(e.events).join(" "));for(var n=t.split(" "),r=0;r<n.length;r++){var s=e.events[n[r]],a=[];if(o&&s)for(var l=0;l<s.length;l++)s[l]!==o&&a.push(s[l]);e.events[n[r]]=a}},n.trigger=function(e,t,o){var n,r,s,a;if(e.events){o||(o={}),n=t.split(" ");for(var l=0;l<n.length;l++)if(r=n[l],s=e.events[r]){a=i.clone(o,!1),a.name=r,a.source=e;for(var c=0;c<s.length;c++)s[c].apply(e,[a])}}}}()},{"./Common":14}],17:[function(e,t,o){},{"../body/Composite":2,"./Common":14}],18:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Common");!function(){n.create=function(t){var o={};return t||i.log("Mouse.create: element was undefined, defaulting to document.body","warn"),o.element=t||document.body,o.absolute={x:0,y:0},o.position={x:0,y:0},o.mousedownPosition={x:0,y:0},o.mouseupPosition={x:0,y:0},o.offset={x:0,y:0},o.scale={x:1,y:1},o.wheelDelta=0,o.button=-1,o.pixelRatio=o.element.getAttribute("data-pixel-ratio")||1,
|
||||
o.sourceEvents={mousemove:null,mousedown:null,mouseup:null,mousewheel:null},o.mousemove=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i&&(o.button=0,t.preventDefault()),o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.sourceEvents.mousemove=t},o.mousedown=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i?(o.button=0,t.preventDefault()):o.button=t.button,o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.mousedownPosition.x=o.position.x,o.mousedownPosition.y=o.position.y,o.sourceEvents.mousedown=t},o.mouseup=function(t){var n=e(t,o.element,o.pixelRatio),i=t.changedTouches;i&&t.preventDefault(),o.button=-1,o.absolute.x=n.x,o.absolute.y=n.y,o.position.x=o.absolute.x*o.scale.x+o.offset.x,o.position.y=o.absolute.y*o.scale.y+o.offset.y,o.mouseupPosition.x=o.position.x,o.mouseupPosition.y=o.position.y,
|
||||
o.sourceEvents.mouseup=t},o.mousewheel=function(e){o.wheelDelta=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail)),e.preventDefault()},n.setElement(o,o.element),o},n.setElement=function(e,t){e.element=t,t.addEventListener("mousemove",e.mousemove),t.addEventListener("mousedown",e.mousedown),t.addEventListener("mouseup",e.mouseup),t.addEventListener("mousewheel",e.mousewheel),t.addEventListener("DOMMouseScroll",e.mousewheel),t.addEventListener("touchmove",e.mousemove),t.addEventListener("touchstart",e.mousedown),t.addEventListener("touchend",e.mouseup)},n.clearSourceEvents=function(e){e.sourceEvents.mousemove=null,e.sourceEvents.mousedown=null,e.sourceEvents.mouseup=null,e.sourceEvents.mousewheel=null,e.wheelDelta=0},n.setOffset=function(e,t){e.offset.x=t.x,e.offset.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y},n.setScale=function(e,t){e.scale.x=t.x,e.scale.y=t.y,e.position.x=e.absolute.x*e.scale.x+e.offset.x,e.position.y=e.absolute.y*e.scale.y+e.offset.y;
|
||||
};var e=function(e,t,o){var n,i,r=t.getBoundingClientRect(),s=document.documentElement||document.body.parentNode||document.body,a=void 0!==window.pageXOffset?window.pageXOffset:s.scrollLeft,l=void 0!==window.pageYOffset?window.pageYOffset:s.scrollTop,c=e.changedTouches;return c?(n=c[0].pageX-r.left-a,i=c[0].pageY-r.top-l):(n=e.pageX-r.left-a,i=e.pageY-r.top-l),{x:n/(t.clientWidth/t.width*o),y:i/(t.clientHeight/t.height*o)}}}()},{"../core/Common":14}],19:[function(e,t,o){var n={};t.exports=n;var i=e("./Events"),r=e("./Engine"),s=e("./Common");!function(){var e,t;"undefined"!=typeof window&&(e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){window.setTimeout(function(){e(s.now())},1e3/60)},t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame),n.create=function(e){var t={fps:60,correction:1,deltaSampleSize:60,counterTimestamp:0,
|
||||
frameCounter:0,deltaHistory:[],timePrev:null,timeScalePrev:1,frameRequestId:null,isFixed:!1,enabled:!0},o=s.extend(t,e);return o.delta=o.delta||1e3/o.fps,o.deltaMin=o.deltaMin||1e3/o.fps,o.deltaMax=o.deltaMax||1e3/(.5*o.fps),o.fps=1e3/o.delta,o},n.run=function(t,o){return"undefined"!=typeof t.positionIterations&&(o=t,t=n.create()),function i(r){t.frameRequestId=e(i),r&&t.enabled&&n.tick(t,o,r)}(),t},n.tick=function(e,t,o){var n,s=t.timing,a=1,l={timestamp:s.timestamp};i.trigger(e,"beforeTick",l),i.trigger(t,"beforeTick",l),e.isFixed?n=e.delta:(n=o-e.timePrev||e.delta,e.timePrev=o,e.deltaHistory.push(n),e.deltaHistory=e.deltaHistory.slice(-e.deltaSampleSize),n=Math.min.apply(null,e.deltaHistory),n=n<e.deltaMin?e.deltaMin:n,n=n>e.deltaMax?e.deltaMax:n,a=n/e.delta,e.delta=n),0!==e.timeScalePrev&&(a*=s.timeScale/e.timeScalePrev),0===s.timeScale&&(a=0),e.timeScalePrev=s.timeScale,e.correction=a,e.frameCounter+=1,o-e.counterTimestamp>=1e3&&(e.fps=e.frameCounter*((o-e.counterTimestamp)/1e3),e.counterTimestamp=o,
|
||||
e.frameCounter=0),i.trigger(e,"tick",l),i.trigger(t,"tick",l),t.world.isModified&&t.render&&t.render.controller&&t.render.controller.clear&&t.render.controller.clear(t.render),i.trigger(e,"beforeUpdate",l),r.update(t,n,a),i.trigger(e,"afterUpdate",l),t.render&&t.render.controller&&(i.trigger(e,"beforeRender",l),i.trigger(t,"beforeRender",l),t.render.controller.world(t),i.trigger(e,"afterRender",l),i.trigger(t,"afterRender",l)),i.trigger(e,"afterTick",l),i.trigger(t,"afterTick",l)},n.stop=function(e){t(e.frameRequestId)},n.start=function(e,t){n.run(e,t)}}()},{"./Common":14,"./Engine":15,"./Events":16}],20:[function(e,t,o){var n={};t.exports=n;var i=e("./Events");!function(){n._motionWakeThreshold=.18,n._motionSleepThreshold=.08,n._minBias=.9,n.update=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i],s=r.speed*r.speed+r.angularSpeed*r.angularSpeed;if(0===r.force.x&&0===r.force.y){var a=Math.min(r.motion,s),l=Math.max(r.motion,s);r.motion=n._minBias*a+(1-n._minBias)*l,r.sleepThreshold>0&&r.motion<n._motionSleepThreshold*o?(r.sleepCounter+=1,
|
||||
r.sleepCounter>=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(e,t){for(var o=t*t*t,i=0;i<e.length;i++){var r=e[i];if(r.isActive){var s=r.collision,a=s.bodyA.parent,l=s.bodyB.parent;if(!(a.isSleeping&&l.isSleeping||a.isStatic||l.isStatic)&&(a.isSleeping||l.isSleeping)){var c=a.isSleeping&&!a.isStatic?a:l,d=c===a?l:a;!c.isStatic&&d.motion>n._motionWakeThreshold*o&&n.set(c,!1)}}}},n.set=function(e,t){var o=e.isSleeping;t?(e.isSleeping=!0,e.sleepCounter=e.sleepThreshold,e.positionImpulse.x=0,e.positionImpulse.y=0,e.positionPrev.x=e.position.x,e.positionPrev.y=e.position.y,e.anglePrev=e.angle,e.speed=0,e.angularSpeed=0,e.motion=0,o||i.trigger(e,"sleepStart")):(e.isSleeping=!1,e.sleepCounter=0,o&&i.trigger(e,"sleepEnd"))}}()},{"./Events":16}],21:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vertices"),r=e("../core/Common"),s=e("../body/Body"),a=e("../geometry/Bounds"),l=e("../geometry/Vector");!function(){n.rectangle=function(e,t,o,n,a){
|
||||
a=a||{};var l={label:"Rectangle Body",position:{x:e,y:t},vertices:i.fromPath("L 0 0 L "+o+" 0 L "+o+" "+n+" L 0 "+n)};if(a.chamfer){var c=a.chamfer;l.vertices=i.chamfer(l.vertices,c.radius,c.quality,c.qualityMin,c.qualityMax),delete a.chamfer}return s.create(r.extend({},l,a))},n.trapezoid=function(e,t,o,n,a,l){l=l||{},a*=.5;var c,d=(1-2*a)*o,u=o*a,p=u+d,f=p+u;c=.5>a?"L 0 0 L "+u+" "+-n+" L "+p+" "+-n+" L "+f+" 0":"L 0 0 L "+p+" "+-n+" L "+f+" 0";var v={label:"Trapezoid Body",position:{x:e,y:t},vertices:i.fromPath(c)};if(l.chamfer){var y=l.chamfer;v.vertices=i.chamfer(v.vertices,y.radius,y.quality,y.qualityMin,y.qualityMax),delete l.chamfer}return s.create(r.extend({},v,l))},n.circle=function(e,t,o,i,r){i=i||{},i.label="Circle Body",r=r||25;var s=Math.ceil(Math.max(10,Math.min(r,o)));return s%2===1&&(s+=1),i.circleRadius=o,n.polygon(e,t,s,o,i)},n.polygon=function(e,t,o,a,l){if(l=l||{},3>o)return n.circle(e,t,a,l);for(var c=2*Math.PI/o,d="",u=.5*c,p=0;o>p;p+=1){var f=u+p*c,v=Math.cos(f)*a,y=Math.sin(f)*a;
|
||||
d+="L "+v.toFixed(3)+" "+y.toFixed(3)+" "}var m={label:"Polygon Body",position:{x:e,y:t},vertices:i.fromPath(d)};if(l.chamfer){var g=l.chamfer;m.vertices=i.chamfer(m.vertices,g.radius,g.quality,g.qualityMin,g.qualityMax),delete l.chamfer}return s.create(r.extend({},m,l))},n.fromVertices=function(e,t,o,n,c,d,u){var p,f,v,y,m,g,x,h,b;for(n=n||{},f=[],c="undefined"!=typeof c?c:!1,d="undefined"!=typeof d?d:.01,u="undefined"!=typeof u?u:10,window.decomp||r.log("Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.","warn"),r.isArray(o[0])||(o=[o]),h=0;h<o.length;h+=1)if(y=o[h],v=i.isConvex(y),v||!window.decomp)y=v?i.clockwiseSort(y):i.hull(y),f.push({position:{x:e,y:t},vertices:y});else{var S=new decomp.Polygon;for(m=0;m<y.length;m++)S.vertices.push([y[m].x,y[m].y]);S.makeCCW(),d!==!1&&S.removeCollinearPoints(d);var C=S.quickDecomp();for(m=0;m<C.length;m++){var w=C[m],A=[];for(g=0;g<w.vertices.length;g++)A.push({x:w.vertices[g][0],y:w.vertices[g][1]
|
||||
});u>0&&i.area(A)<u||f.push({position:i.centre(A),vertices:A})}}for(m=0;m<f.length;m++)f[m]=s.create(r.extend(f[m],n));if(c){var B=5;for(m=0;m<f.length;m++){var P=f[m];for(g=m+1;g<f.length;g++){var M=f[g];if(a.overlaps(P.bounds,M.bounds)){var k=P.vertices,I=M.vertices;for(x=0;x<P.vertices.length;x++)for(b=0;b<M.vertices.length;b++){var T=l.magnitudeSquared(l.sub(k[(x+1)%k.length],I[b])),V=l.magnitudeSquared(l.sub(k[x],I[(b+1)%I.length]));B>T&&B>V&&(k[x].isInternal=!0,I[b].isInternal=!0)}}}}}return f.length>1?(p=s.create(r.extend({parts:f.slice(0)},n)),s.setPosition(p,{x:e,y:t}),p):f[0]}}()},{"../body/Body":1,"../core/Common":14,"../geometry/Bounds":24,"../geometry/Vector":26,"../geometry/Vertices":27}],22:[function(e,t,o){var n={};t.exports=n;var i=e("../body/Composite"),r=e("../constraint/Constraint"),s=e("../core/Common"),a=e("../body/Body"),l=e("./Bodies");!function(){n.stack=function(e,t,o,n,r,s,l){for(var c,d=i.create({label:"Stack"}),u=e,p=t,f=0,v=0;n>v;v++){for(var y=0,m=0;o>m;m++){
|
||||
var g=l(u,p,m,v,c,f);if(g){var x=g.bounds.max.y-g.bounds.min.y,h=g.bounds.max.x-g.bounds.min.x;x>y&&(y=x),a.translate(g,{x:.5*h,y:.5*x}),u=g.bounds.max.x+r,i.addBody(d,g),c=g,f+=1}else u+=r}p+=y+s,u=e}return d},n.chain=function(e,t,o,n,a,l){for(var c=e.bodies,d=1;d<c.length;d++){var u=c[d-1],p=c[d],f=u.bounds.max.y-u.bounds.min.y,v=u.bounds.max.x-u.bounds.min.x,y=p.bounds.max.y-p.bounds.min.y,m=p.bounds.max.x-p.bounds.min.x,g={bodyA:u,pointA:{x:v*t,y:f*o},bodyB:p,pointB:{x:m*n,y:y*a}},x=s.extend(g,l);i.addConstraint(e,r.create(x))}return e.label+=" Chain",e},n.mesh=function(e,t,o,n,a){var l,c,d,u,p,f=e.bodies;for(l=0;o>l;l++){for(c=1;t>c;c++)d=f[c-1+l*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a)));if(l>0)for(c=0;t>c;c++)d=f[c+(l-1)*t],u=f[c+l*t],i.addConstraint(e,r.create(s.extend({bodyA:d,bodyB:u},a))),n&&c>0&&(p=f[c-1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u},a)))),n&&t-1>c&&(p=f[c+1+(l-1)*t],i.addConstraint(e,r.create(s.extend({bodyA:p,bodyB:u
|
||||
},a))))}return e.label+=" Mesh",e},n.pyramid=function(e,t,o,i,r,s,l){return n.stack(e,t,o,i,r,s,function(t,n,s,c,d,u){var p=Math.min(i,Math.ceil(o/2)),f=d?d.bounds.max.x-d.bounds.min.x:0;if(!(c>p)){c=p-c;var v=c,y=o-1-c;if(!(v>s||s>y)){1===u&&a.translate(d,{x:(s+(o%2===1?1:-1))*f,y:0});var m=d?s*f:0;return l(e+m+s*r,n,s,c,d,u)}}})},n.newtonsCradle=function(e,t,o,n,s){for(var a=i.create({label:"Newtons Cradle"}),c=0;o>c;c++){var d=1.9,u=l.circle(e+c*(n*d),t+s,n,{inertia:1/0,restitution:1,friction:0,frictionAir:1e-4,slop:1}),p=r.create({pointA:{x:e+c*(n*d),y:t},bodyB:u});i.addBody(a,u),i.addConstraint(a,p)}return a},n.car=function(e,t,o,n,s){var c=a.nextGroup(!0),d=-20,u=.5*-o+d,p=.5*o-d,f=0,v=i.create({label:"Car"}),y=l.trapezoid(e,t,o,n,.3,{collisionFilter:{group:c},friction:.01,chamfer:{radius:10}}),m=l.circle(e+u,t+f,s,{collisionFilter:{group:c},friction:.8,density:.01}),g=l.circle(e+p,t+f,s,{collisionFilter:{group:c},friction:.8,density:.01}),x=r.create({bodyA:y,pointA:{x:u,y:f},bodyB:m,
|
||||
stiffness:.2}),h=r.create({bodyA:y,pointA:{x:p,y:f},bodyB:g,stiffness:.2});return i.addBody(v,y),i.addBody(v,m),i.addBody(v,g),i.addConstraint(v,x),i.addConstraint(v,h),v},n.softBody=function(e,t,o,i,r,a,c,d,u,p){u=s.extend({inertia:1/0},u),p=s.extend({stiffness:.4},p);var f=n.stack(e,t,o,i,r,a,function(e,t){return l.circle(e,t,d,u)});return n.mesh(f,o,i,c,p),f.label="Soft Body",f}}()},{"../body/Body":1,"../body/Composite":2,"../constraint/Constraint":12,"../core/Common":14,"./Bodies":21}],23:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){n.fromVertices=function(e){for(var t={},o=0;o<e.length;o++){var n=(o+1)%e.length,s=i.normalise({x:e[n].y-e[o].y,y:e[o].x-e[n].x}),a=0===s.y?1/0:s.x/s.y;a=a.toFixed(3).toString(),t[a]=s}return r.values(t)},n.rotate=function(e,t){if(0!==t)for(var o=Math.cos(t),n=Math.sin(t),i=0;i<e.length;i++){var r,s=e[i];r=s.x*o-s.y*n,s.y=s.x*n+s.y*o,s.x=r}}}()},{"../core/Common":14,"../geometry/Vector":26}],24:[function(e,t,o){
|
||||
var n={};t.exports=n,function(){n.create=function(e){var t={min:{x:0,y:0},max:{x:0,y:0}};return e&&n.update(t,e),t},n.update=function(e,t,o){e.min.x=Number.MAX_VALUE,e.max.x=Number.MIN_VALUE,e.min.y=Number.MAX_VALUE,e.max.y=Number.MIN_VALUE;for(var n=0;n<t.length;n++){var i=t[n];i.x>e.max.x&&(e.max.x=i.x),i.x<e.min.x&&(e.min.x=i.x),i.y>e.max.y&&(e.max.y=i.y),i.y<e.min.y&&(e.min.y=i.y)}o&&(o.x>0?e.max.x+=o.x:e.min.x+=o.x,o.y>0?e.max.y+=o.y:e.min.y+=o.y)},n.contains=function(e,t){return t.x>=e.min.x&&t.x<=e.max.x&&t.y>=e.min.y&&t.y<=e.max.y},n.overlaps=function(e,t){return e.min.x<=t.max.x&&e.max.x>=t.min.x&&e.max.y>=t.min.y&&e.min.y<=t.max.y},n.translate=function(e,t){e.min.x+=t.x,e.max.x+=t.x,e.min.y+=t.y,e.max.y+=t.y},n.shift=function(e,t){var o=e.max.x-e.min.x,n=e.max.y-e.min.y;e.min.x=t.x,e.max.x=t.x+o,e.min.y=t.y,e.max.y=t.y+n}}()},{}],25:[function(e,t,o){var n={};t.exports=n;e("../geometry/Bounds");!function(){n.pathToVertices=function(t,o){var n,i,r,s,a,l,c,d,u,p,f,v,y=[],m=0,g=0,x=0;
|
||||
o=o||15;var h=function(e,t,o){var n=o%2===1&&o>1;if(!u||e!=u.x||t!=u.y){u&&n?(f=u.x,v=u.y):(f=0,v=0);var i={x:f+e,y:v+t};(n||!u)&&(u=i),y.push(i),g=f+e,x=v+t}},b=function(e){var t=e.pathSegTypeAsLetter.toUpperCase();if("Z"!==t){switch(t){case"M":case"L":case"T":case"C":case"S":case"Q":g=e.x,x=e.y;break;case"H":g=e.x;break;case"V":x=e.y}h(g,x,e.pathSegType)}};for(e(t),r=t.getTotalLength(),l=[],n=0;n<t.pathSegList.numberOfItems;n+=1)l.push(t.pathSegList.getItem(n));for(c=l.concat();r>m;){if(p=t.getPathSegAtLength(m),a=l[p],a!=d){for(;c.length&&c[0]!=a;)b(c.shift());d=a}switch(a.pathSegTypeAsLetter.toUpperCase()){case"C":case"T":case"S":case"Q":case"A":s=t.getPointAtLength(m),h(s.x,s.y,0)}m+=o}for(n=0,i=c.length;i>n;++n)b(c[n]);return y};var e=function(e){for(var t,o,n,i,r,s,a=e.pathSegList,l=0,c=0,d=a.numberOfItems,u=0;d>u;++u){var p=a.getItem(u),f=p.pathSegTypeAsLetter;if(/[MLHVCSQTA]/.test(f))"x"in p&&(l=p.x),"y"in p&&(c=p.y);else switch("x1"in p&&(n=l+p.x1),"x2"in p&&(r=l+p.x2),"y1"in p&&(i=c+p.y1),
|
||||
"y2"in p&&(s=c+p.y2),"x"in p&&(l+=p.x),"y"in p&&(c+=p.y),f){case"m":a.replaceItem(e.createSVGPathSegMovetoAbs(l,c),u);break;case"l":a.replaceItem(e.createSVGPathSegLinetoAbs(l,c),u);break;case"h":a.replaceItem(e.createSVGPathSegLinetoHorizontalAbs(l),u);break;case"v":a.replaceItem(e.createSVGPathSegLinetoVerticalAbs(c),u);break;case"c":a.replaceItem(e.createSVGPathSegCurvetoCubicAbs(l,c,n,i,r,s),u);break;case"s":a.replaceItem(e.createSVGPathSegCurvetoCubicSmoothAbs(l,c,r,s),u);break;case"q":a.replaceItem(e.createSVGPathSegCurvetoQuadraticAbs(l,c,n,i),u);break;case"t":a.replaceItem(e.createSVGPathSegCurvetoQuadraticSmoothAbs(l,c),u);break;case"a":a.replaceItem(e.createSVGPathSegArcAbs(l,c,p.r1,p.r2,p.angle,p.largeArcFlag,p.sweepFlag),u);break;case"z":case"Z":l=t,c=o}("M"==f||"m"==f)&&(t=l,o=c)}}}()},{"../geometry/Bounds":24}],26:[function(e,t,o){var n={};t.exports=n,function(){n.create=function(e,t){return{x:e||0,y:t||0}},n.clone=function(e){return{x:e.x,y:e.y}},n.magnitude=function(e){return Math.sqrt(e.x*e.x+e.y*e.y);
|
||||
},n.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y},n.rotate=function(e,t){var o=Math.cos(t),n=Math.sin(t);return{x:e.x*o-e.y*n,y:e.x*n+e.y*o}},n.rotateAbout=function(e,t,o,n){var i=Math.cos(t),r=Math.sin(t);n||(n={});var s=o.x+((e.x-o.x)*i-(e.y-o.y)*r);return n.y=o.y+((e.x-o.x)*r+(e.y-o.y)*i),n.x=s,n},n.normalise=function(e){var t=n.magnitude(e);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},n.dot=function(e,t){return e.x*t.x+e.y*t.y},n.cross=function(e,t){return e.x*t.y-e.y*t.x},n.cross3=function(e,t,o){return(t.x-e.x)*(o.y-e.y)-(t.y-e.y)*(o.x-e.x)},n.add=function(e,t,o){return o||(o={}),o.x=e.x+t.x,o.y=e.y+t.y,o},n.sub=function(e,t,o){return o||(o={}),o.x=e.x-t.x,o.y=e.y-t.y,o},n.mult=function(e,t){return{x:e.x*t,y:e.y*t}},n.div=function(e,t){return{x:e.x/t,y:e.y/t}},n.perp=function(e,t){return t=t===!0?-1:1,{x:t*-e.y,y:t*e.x}},n.neg=function(e){return{x:-e.x,y:-e.y}},n.angle=function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)},n._temp=[n.create(),n.create(),n.create(),n.create(),n.create(),n.create()];
|
||||
}()},{}],27:[function(e,t,o){var n={};t.exports=n;var i=e("../geometry/Vector"),r=e("../core/Common");!function(){n.create=function(e,t){for(var o=[],n=0;n<e.length;n++){var i=e[n],r={x:i.x,y:i.y,index:n,body:t,isInternal:!1};o.push(r)}return o},n.fromPath=function(e,t){var o=/L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/gi,i=[];return e.replace(o,function(e,t,o){i.push({x:parseFloat(t),y:parseFloat(o)})}),n.create(i,t)},n.centre=function(e){for(var t,o,r,s=n.area(e,!0),a={x:0,y:0},l=0;l<e.length;l++)r=(l+1)%e.length,t=i.cross(e[l],e[r]),o=i.mult(i.add(e[l],e[r]),t),a=i.add(a,o);return i.div(a,6*s)},n.mean=function(e){for(var t={x:0,y:0},o=0;o<e.length;o++)t.x+=e[o].x,t.y+=e[o].y;return i.div(t,e.length)},n.area=function(e,t){for(var o=0,n=e.length-1,i=0;i<e.length;i++)o+=(e[n].x-e[i].x)*(e[n].y+e[i].y),n=i;return t?o/2:Math.abs(o)/2},n.inertia=function(e,t){for(var o,n,r=0,s=0,a=e,l=0;l<a.length;l++)n=(l+1)%a.length,o=Math.abs(i.cross(a[n],a[l])),r+=o*(i.dot(a[n],a[n])+i.dot(a[n],a[l])+i.dot(a[l],a[l])),
|
||||
s+=o;return t/6*(r/s)},n.translate=function(e,t,o){var n;if(o)for(n=0;n<e.length;n++)e[n].x+=t.x*o,e[n].y+=t.y*o;else for(n=0;n<e.length;n++)e[n].x+=t.x,e[n].y+=t.y;return e},n.rotate=function(e,t,o){if(0!==t){for(var n=Math.cos(t),i=Math.sin(t),r=0;r<e.length;r++){var s=e[r],a=s.x-o.x,l=s.y-o.y;s.x=o.x+(a*n-l*i),s.y=o.y+(a*i+l*n)}return e}},n.contains=function(e,t){for(var o=0;o<e.length;o++){var n=e[o],i=e[(o+1)%e.length];if((t.x-n.x)*(i.y-n.y)+(t.y-n.y)*(n.x-i.x)>0)return!1}return!0},n.scale=function(e,t,o,r){if(1===t&&1===o)return e;r=r||n.centre(e);for(var s,a,l=0;l<e.length;l++)s=e[l],a=i.sub(s,r),e[l].x=r.x+a.x*t,e[l].y=r.y+a.y*o;return e},n.chamfer=function(e,t,o,n,s){t=t||[8],t.length||(t=[t]),o="undefined"!=typeof o?o:-1,n=n||2,s=s||14;for(var a=[],l=0;l<e.length;l++){var c=e[l-1>=0?l-1:e.length-1],d=e[l],u=e[(l+1)%e.length],p=t[l<t.length?l:t.length-1];if(0!==p){var f=i.normalise({x:d.y-c.y,y:c.x-d.x}),v=i.normalise({x:u.y-d.y,y:d.x-u.x}),y=Math.sqrt(2*Math.pow(p,2)),m=i.mult(r.clone(f),p),g=i.normalise(i.mult(i.add(f,v),.5)),x=i.sub(d,i.mult(g,y)),h=o;
|
||||
-1===o&&(h=1.75*Math.pow(p,.32)),h=r.clamp(h,n,s),h%2===1&&(h+=1);for(var b=Math.acos(i.dot(f,v)),S=b/h,C=0;h>C;C++)a.push(i.add(i.rotate(m,S*C),x))}else a.push(d)}return a},n.clockwiseSort=function(e){var t=n.mean(e);return e.sort(function(e,o){return i.angle(t,e)-i.angle(t,o)}),e},n.isConvex=function(e){var t,o,n,i,r=0,s=e.length;if(3>s)return null;for(t=0;s>t;t++)if(o=(t+1)%s,n=(t+2)%s,i=(e[o].x-e[t].x)*(e[n].y-e[o].y),i-=(e[o].y-e[t].y)*(e[n].x-e[o].x),0>i?r|=1:i>0&&(r|=2),3===r)return!1;return 0!==r?!0:null},n.hull=function(e){var t,o,n=[],r=[];for(e=e.slice(0),e.sort(function(e,t){var o=e.x-t.x;return 0!==o?o:e.y-t.y}),o=0;o<e.length;o++){for(t=e[o];r.length>=2&&i.cross3(r[r.length-2],r[r.length-1],t)<=0;)r.pop();r.push(t)}for(o=e.length-1;o>=0;o--){for(t=e[o];n.length>=2&&i.cross3(n[n.length-2],n[n.length-1],t)<=0;)n.pop();n.push(t)}return n.pop(),r.pop(),n.concat(r)}}()},{"../core/Common":14,"../geometry/Vector":26}],28:[function(e,t,o){var n=t.exports={};n.version="master",n.Body=e("../body/Body"),
|
||||
n.Composite=e("../body/Composite"),n.World=e("../body/World"),n.Contact=e("../collision/Contact"),n.Detector=e("../collision/Detector"),n.Grid=e("../collision/Grid"),n.Pairs=e("../collision/Pairs"),n.Pair=e("../collision/Pair"),n.Query=e("../collision/Query"),n.Resolver=e("../collision/Resolver"),n.SAT=e("../collision/SAT"),n.Constraint=e("../constraint/Constraint"),n.MouseConstraint=e("../constraint/MouseConstraint"),n.Common=e("../core/Common"),n.Engine=e("../core/Engine"),n.Events=e("../core/Events"),n.Mouse=e("../core/Mouse"),n.Runner=e("../core/Runner"),n.Sleeping=e("../core/Sleeping"),n.Bodies=e("../factory/Bodies"),n.Composites=e("../factory/Composites"),n.Axes=e("../geometry/Axes"),n.Bounds=e("../geometry/Bounds"),n.Svg=e("../geometry/Svg"),n.Vector=e("../geometry/Vector"),n.Vertices=e("../geometry/Vertices"),n.Render=e("../render/Render"),n.RenderPixi=e("../render/RenderPixi"),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,
|
||||
n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,n.Engine.run=n.Runner.run},{"../body/Body":1,"../body/Composite":2,"../body/World":3,"../collision/Contact":4,"../collision/Detector":5,"../collision/Grid":6,"../collision/Pair":7,"../collision/Pairs":8,"../collision/Query":9,"../collision/Resolver":10,"../collision/SAT":11,"../constraint/Constraint":12,"../constraint/MouseConstraint":13,"../core/Common":14,"../core/Engine":15,"../core/Events":16,"../core/Metrics":17,"../core/Mouse":18,"../core/Runner":19,"../core/Sleeping":20,"../factory/Bodies":21,"../factory/Composites":22,"../geometry/Axes":23,"../geometry/Bounds":24,"../geometry/Svg":25,"../geometry/Vector":26,"../geometry/Vertices":27,"../render/Render":29,"../render/RenderPixi":30}],29:[function(e,t,o){var n={};t.exports=n;var i=e("../core/Common"),r=e("../body/Composite"),s=e("../geometry/Bounds"),a=e("../core/Events"),l=e("../collision/Grid"),c=e("../geometry/Vector");
|
||||
!function(){n.create=function(t){var o={controller:n,element:null,canvas:null,mouse:null,options:{width:800,height:600,pixelRatio:1,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showSeparations:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1,showVertexNumbers:!1,showConvexHulls:!1,showInternalEdges:!1,showMousePosition:!1}},r=i.extend(o,t);return r.canvas&&(r.canvas.width=r.options.width||r.canvas.width,r.canvas.height=r.options.height||r.canvas.height),r.canvas=r.canvas||e(r.options.width,r.options.height),r.context=r.canvas.getContext("2d"),r.textures={},r.bounds=r.bounds||{min:{x:0,y:0},max:{x:r.canvas.width,y:r.canvas.height}},1!==r.options.pixelRatio&&n.setPixelRatio(r,r.options.pixelRatio),i.isElement(r.element)?r.element.appendChild(r.canvas):i.log("Render.create: options.element was undefined, render.canvas was created but not appended","warn"),
|
||||
r},n.setPixelRatio=function(e,o){var n=e.options,i=e.canvas;"auto"===o&&(o=t(i)),n.pixelRatio=o,i.setAttribute("data-pixel-ratio",o),i.width=n.width*o,i.height=n.height*o,i.style.width=n.width+"px",i.style.height=n.height+"px",e.context.scale(o,o)},n.world=function(e){var t,o=e.render,i=e.world,u=o.canvas,p=o.context,f=o.options,v=r.allBodies(i),y=r.allConstraints(i),m=f.wireframes?f.wireframeBackground:f.background,g=[],x=[],h={timestamp:e.timing.timestamp};if(a.trigger(o,"beforeRender",h),o.currentBackground!==m&&d(o,m),p.globalCompositeOperation="source-in",p.fillStyle="transparent",p.fillRect(0,0,u.width,u.height),p.globalCompositeOperation="source-over",f.hasBounds){var b=o.bounds.max.x-o.bounds.min.x,S=o.bounds.max.y-o.bounds.min.y,C=b/f.width,w=S/f.height;for(t=0;t<v.length;t++){var A=v[t];s.overlaps(A.bounds,o.bounds)&&g.push(A)}for(t=0;t<y.length;t++){var B=y[t],P=B.bodyA,M=B.bodyB,k=B.pointA,I=B.pointB;P&&(k=c.add(P.position,B.pointA)),M&&(I=c.add(M.position,B.pointB)),k&&I&&(s.contains(o.bounds,k)||s.contains(o.bounds,I))&&x.push(B);
|
||||
}p.scale(1/C,1/w),p.translate(-o.bounds.min.x,-o.bounds.min.y)}else x=y,g=v;!f.wireframes||e.enableSleeping&&f.showSleeping?n.bodies(e,g,p):(f.showConvexHulls&&n.bodyConvexHulls(e,g,p),n.bodyWireframes(e,g,p)),f.showBounds&&n.bodyBounds(e,g,p),(f.showAxes||f.showAngleIndicator)&&n.bodyAxes(e,g,p),f.showPositions&&n.bodyPositions(e,g,p),f.showVelocity&&n.bodyVelocity(e,g,p),f.showIds&&n.bodyIds(e,g,p),f.showSeparations&&n.separations(e,e.pairs.list,p),f.showCollisions&&n.collisions(e,e.pairs.list,p),f.showVertexNumbers&&n.vertexNumbers(e,g,p),f.showMousePosition&&n.mousePosition(e,o.mouse,p),n.constraints(x,p),f.showBroadphase&&e.broadphase.controller===l&&n.grid(e,e.broadphase,p),f.showDebug&&n.debug(e,p),f.hasBounds&&p.setTransform(f.pixelRatio,0,0,f.pixelRatio,0,0),a.trigger(o,"afterRender",h)},n.debug=function(e,t){var o=t,n=e.world,i=e.render,s=e.metrics,a=i.options,l=(r.allBodies(n)," ");if(e.timing.timestamp-(i.debugTimestamp||0)>=500){var c="";s.timing&&(c+="fps: "+Math.round(s.timing.fps)+l),
|
||||
i.debugString=c,i.debugTimestamp=e.timing.timestamp}if(i.debugString){o.font="12px Arial",a.wireframes?o.fillStyle="rgba(255,255,255,0.5)":o.fillStyle="rgba(0,0,0,0.5)";for(var d=i.debugString.split("\n"),u=0;u<d.length;u++)o.fillText(d[u],50,50+18*u)}},n.constraints=function(e,t){for(var o=t,n=0;n<e.length;n++){var i=e[n];if(i.render.visible&&i.pointA&&i.pointB){var r=i.bodyA,s=i.bodyB;r?(o.beginPath(),o.moveTo(r.position.x+i.pointA.x,r.position.y+i.pointA.y)):(o.beginPath(),o.moveTo(i.pointA.x,i.pointA.y)),s?o.lineTo(s.position.x+i.pointB.x,s.position.y+i.pointB.y):o.lineTo(i.pointB.x,i.pointB.y),o.lineWidth=i.render.lineWidth,o.strokeStyle=i.render.strokeStyle,o.stroke()}}},n.bodyShadows=function(e,t,o){for(var n=o,i=e.render,r=0;r<t.length;r++){var s=t[r];if(s.render.visible){if(s.circleRadius)n.beginPath(),n.arc(s.position.x,s.position.y,s.circleRadius,0,2*Math.PI),n.closePath();else{n.beginPath(),n.moveTo(s.vertices[0].x,s.vertices[0].y);for(var a=1;a<s.vertices.length;a++)n.lineTo(s.vertices[a].x,s.vertices[a].y);
|
||||
n.closePath()}var l=s.position.x-.5*i.options.width,c=s.position.y-.2*i.options.height,d=Math.abs(l)+Math.abs(c);n.shadowColor="rgba(0,0,0,0.15)",n.shadowOffsetX=.05*l,n.shadowOffsetY=.05*c,n.shadowBlur=1+12*Math.min(1,d/1e3),n.fill(),n.shadowColor=null,n.shadowOffsetX=null,n.shadowOffsetY=null,n.shadowBlur=null}}},n.bodies=function(e,t,n){var r,s,a,l,c=n,d=e.render,u=d.options;for(a=0;a<t.length;a++)if(r=t[a],r.render.visible)for(l=r.parts.length>1?1:0;l<r.parts.length;l++)if(s=r.parts[l],s.render.visible)if(s.render.sprite&&s.render.sprite.texture&&!u.wireframes){var p=s.render.sprite,f=o(d,p.texture);u.showSleeping&&r.isSleeping&&(c.globalAlpha=.5),c.translate(s.position.x,s.position.y),c.rotate(s.angle),c.drawImage(f,f.width*-p.xOffset*p.xScale,f.height*-p.yOffset*p.yScale,f.width*p.xScale,f.height*p.yScale),c.rotate(-s.angle),c.translate(-s.position.x,-s.position.y),u.showSleeping&&r.isSleeping&&(c.globalAlpha=1)}else{if(s.circleRadius)c.beginPath(),c.arc(s.position.x,s.position.y,s.circleRadius,0,2*Math.PI);else{
|
||||
c.beginPath(),c.moveTo(s.vertices[0].x,s.vertices[0].y);for(var v=1;v<s.vertices.length;v++)c.lineTo(s.vertices[v].x,s.vertices[v].y);c.closePath()}u.wireframes?(c.lineWidth=1,c.strokeStyle="#bbb",u.showSleeping&&r.isSleeping&&(c.strokeStyle="rgba(255,255,255,0.2)"),c.stroke()):(u.showSleeping&&r.isSleeping?c.fillStyle=i.shadeColor(s.render.fillStyle,50):c.fillStyle=s.render.fillStyle,c.lineWidth=s.render.lineWidth,c.strokeStyle=s.render.strokeStyle,c.fill(),c.stroke())}},n.bodyWireframes=function(e,t,o){var n,i,r,s,a,l=o,c=e.render.options.showInternalEdges;for(l.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.render.visible)for(a=n.parts.length>1?1:0;a<n.parts.length;a++){for(i=n.parts[a],l.moveTo(i.vertices[0].x,i.vertices[0].y),s=1;s<i.vertices.length;s++)!i.vertices[s-1].isInternal||c?l.lineTo(i.vertices[s].x,i.vertices[s].y):l.moveTo(i.vertices[s].x,i.vertices[s].y),i.vertices[s].isInternal&&!c&&l.moveTo(i.vertices[(s+1)%i.vertices.length].x,i.vertices[(s+1)%i.vertices.length].y);l.lineTo(i.vertices[0].x,i.vertices[0].y);
|
||||
}l.lineWidth=1,l.strokeStyle="#bbb",l.stroke()},n.bodyConvexHulls=function(e,t,o){var n,i,r,s=o;for(s.beginPath(),i=0;i<t.length;i++)if(n=t[i],n.render.visible&&1!==n.parts.length){for(s.moveTo(n.vertices[0].x,n.vertices[0].y),r=1;r<n.vertices.length;r++)s.lineTo(n.vertices[r].x,n.vertices[r].y);s.lineTo(n.vertices[0].x,n.vertices[0].y)}s.lineWidth=1,s.strokeStyle="rgba(255,255,255,0.2)",s.stroke()},n.vertexNumbers=function(e,t,o){var n,i,r,s=o;for(n=0;n<t.length;n++){var a=t[n].parts;for(r=a.length>1?1:0;r<a.length;r++){var l=a[r];for(i=0;i<l.vertices.length;i++)s.fillStyle="rgba(255,255,255,0.2)",s.fillText(n+"_"+i,l.position.x+.8*(l.vertices[i].x-l.position.x),l.position.y+.8*(l.vertices[i].y-l.position.y))}}},n.mousePosition=function(e,t,o){var n=o;n.fillStyle="rgba(255,255,255,0.8)",n.fillText(t.position.x+" "+t.position.y,t.position.x+5,t.position.y-5)},n.bodyBounds=function(e,t,o){var n=o,i=e.render,r=i.options;n.beginPath();for(var s=0;s<t.length;s++){var a=t[s];if(a.render.visible)for(var l=t[s].parts,c=l.length>1?1:0;c<l.length;c++){
|
||||
var d=l[c];n.rect(d.bounds.min.x,d.bounds.min.y,d.bounds.max.x-d.bounds.min.x,d.bounds.max.y-d.bounds.min.y)}}r.wireframes?n.strokeStyle="rgba(255,255,255,0.08)":n.strokeStyle="rgba(0,0,0,0.1)",n.lineWidth=1,n.stroke()},n.bodyAxes=function(e,t,o){var n,i,r,s,a=o,l=e.render,c=l.options;for(a.beginPath(),i=0;i<t.length;i++){var d=t[i],u=d.parts;if(d.render.visible)if(c.showAxes)for(r=u.length>1?1:0;r<u.length;r++)for(n=u[r],s=0;s<n.axes.length;s++){var p=n.axes[s];a.moveTo(n.position.x,n.position.y),a.lineTo(n.position.x+20*p.x,n.position.y+20*p.y)}else for(r=u.length>1?1:0;r<u.length;r++)for(n=u[r],s=0;s<n.axes.length;s++)a.moveTo(n.position.x,n.position.y),a.lineTo((n.vertices[0].x+n.vertices[n.vertices.length-1].x)/2,(n.vertices[0].y+n.vertices[n.vertices.length-1].y)/2)}c.wireframes?a.strokeStyle="indianred":a.strokeStyle="rgba(0,0,0,0.3)",a.lineWidth=1,a.stroke()},n.bodyPositions=function(e,t,o){var n,i,r,s,a=o,l=e.render,c=l.options;for(a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.render.visible)for(s=0;s<n.parts.length;s++)i=n.parts[s],
|
||||
a.arc(i.position.x,i.position.y,3,0,2*Math.PI,!1),a.closePath();for(c.wireframes?a.fillStyle="indianred":a.fillStyle="rgba(0,0,0,0.5)",a.fill(),a.beginPath(),r=0;r<t.length;r++)n=t[r],n.render.visible&&(a.arc(n.positionPrev.x,n.positionPrev.y,2,0,2*Math.PI,!1),a.closePath());a.fillStyle="rgba(255,165,0,0.8)",a.fill()},n.bodyVelocity=function(e,t,o){var n=o;n.beginPath();for(var i=0;i<t.length;i++){var r=t[i];r.render.visible&&(n.moveTo(r.position.x,r.position.y),n.lineTo(r.position.x+2*(r.position.x-r.positionPrev.x),r.position.y+2*(r.position.y-r.positionPrev.y)))}n.lineWidth=3,n.strokeStyle="cornflowerblue",n.stroke()},n.bodyIds=function(e,t,o){var n,i,r=o;for(n=0;n<t.length;n++)if(t[n].render.visible){var s=t[n].parts;for(i=s.length>1?1:0;i<s.length;i++){var a=s[i];r.font="12px Arial",r.fillStyle="rgba(255,255,255,0.5)",r.fillText(a.id,a.position.x+10,a.position.y-10)}}},n.collisions=function(e,t,o){var n,i,r,s,a=o,l=e.render.options;for(a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.isActive)for(i=n.collision,
|
||||
s=0;s<n.activeContacts.length;s++){var c=n.activeContacts[s],d=c.vertex;a.rect(d.x-1.5,d.y-1.5,3.5,3.5)}for(l.wireframes?a.fillStyle="rgba(255,255,255,0.7)":a.fillStyle="orange",a.fill(),a.beginPath(),r=0;r<t.length;r++)if(n=t[r],n.isActive&&(i=n.collision,n.activeContacts.length>0)){var u=n.activeContacts[0].vertex.x,p=n.activeContacts[0].vertex.y;2===n.activeContacts.length&&(u=(n.activeContacts[0].vertex.x+n.activeContacts[1].vertex.x)/2,p=(n.activeContacts[0].vertex.y+n.activeContacts[1].vertex.y)/2),i.bodyB===i.supports[0].body||i.bodyA.isStatic===!0?a.moveTo(u-8*i.normal.x,p-8*i.normal.y):a.moveTo(u+8*i.normal.x,p+8*i.normal.y),a.lineTo(u,p)}l.wireframes?a.strokeStyle="rgba(255,165,0,0.7)":a.strokeStyle="orange",a.lineWidth=1,a.stroke()},n.separations=function(e,t,o){var n,i,r,s,a,l=o,c=e.render.options;for(l.beginPath(),a=0;a<t.length;a++)if(n=t[a],n.isActive){i=n.collision,r=i.bodyA,s=i.bodyB;var d=1;s.isStatic||r.isStatic||(d=.5),s.isStatic&&(d=0),l.moveTo(s.position.x,s.position.y),
|
||||
l.lineTo(s.position.x-i.penetration.x*d,s.position.y-i.penetration.y*d),d=1,s.isStatic||r.isStatic||(d=.5),r.isStatic&&(d=0),l.moveTo(r.position.x,r.position.y),l.lineTo(r.position.x+i.penetration.x*d,r.position.y+i.penetration.y*d)}c.wireframes?l.strokeStyle="rgba(255,165,0,0.5)":l.strokeStyle="orange",l.stroke()},n.grid=function(e,t,o){var n=o,r=e.render.options;r.wireframes?n.strokeStyle="rgba(255,180,0,0.1)":n.strokeStyle="rgba(255,180,0,0.5)",n.beginPath();for(var s=i.keys(t.buckets),a=0;a<s.length;a++){var l=s[a];if(!(t.buckets[l].length<2)){var c=l.split(",");n.rect(.5+parseInt(c[0],10)*t.bucketWidth,.5+parseInt(c[1],10)*t.bucketHeight,t.bucketWidth,t.bucketHeight)}}n.lineWidth=1,n.stroke()},n.inspector=function(e,t){var o,n=e.engine,i=e.selected,r=n.render,s=r.options;if(s.hasBounds){var a=r.bounds.max.x-r.bounds.min.x,l=r.bounds.max.y-r.bounds.min.y,c=a/r.options.width,d=l/r.options.height;t.scale(1/c,1/d),t.translate(-r.bounds.min.x,-r.bounds.min.y)}for(var u=0;u<i.length;u++){
|
||||
var p=i[u].data;switch(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.9)",t.setLineDash([1,2]),p.type){case"body":o=p.bounds,t.beginPath(),t.rect(Math.floor(o.min.x-3),Math.floor(o.min.y-3),Math.floor(o.max.x-o.min.x+6),Math.floor(o.max.y-o.min.y+6)),t.closePath(),t.stroke();break;case"constraint":var f=p.pointA;p.bodyA&&(f=p.pointB),t.beginPath(),t.arc(f.x,f.y,10,0,2*Math.PI),t.closePath(),t.stroke()}t.setLineDash([]),t.translate(-.5,-.5)}null!==e.selectStart&&(t.translate(.5,.5),t.lineWidth=1,t.strokeStyle="rgba(255,165,0,0.6)",t.fillStyle="rgba(255,165,0,0.1)",o=e.selectBounds,t.beginPath(),t.rect(Math.floor(o.min.x),Math.floor(o.min.y),Math.floor(o.max.x-o.min.x),Math.floor(o.max.y-o.min.y)),t.closePath(),t.stroke(),t.fill(),t.translate(-.5,-.5)),s.hasBounds&&t.setTransform(1,0,0,1,0,0)};var e=function(e,t){var o=document.createElement("canvas");return o.width=e,o.height=t,o.oncontextmenu=function(){return!1},o.onselectstart=function(){return!1},o},t=function(e){var t=e.getContext("2d"),o=window.devicePixelRatio||1,n=t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;
|
||||
return o/n},o=function(e,t){var o=e.textures[t];return o?o:(o=e.textures[t]=new Image,o.src=t,o)},d=function(e,t){var o=t;/(jpg|gif|png)$/.test(t)&&(o="url("+t+")"),e.canvas.style.background=o,e.canvas.style.backgroundSize="contain",e.currentBackground=t}}()},{"../body/Composite":2,"../collision/Grid":6,"../core/Common":14,"../core/Events":16,"../geometry/Bounds":24,"../geometry/Vector":26}],30:[function(e,t,o){var n={};t.exports=n;var i=e("../body/Composite"),r=e("../core/Common");!function(){n.create=function(e){var t={controller:n,element:null,canvas:null,options:{width:800,height:600,background:"#fafafa",wireframeBackground:"#222",hasBounds:!1,enabled:!0,wireframes:!0,showSleeping:!0,showDebug:!1,showBroadphase:!1,showBounds:!1,showVelocity:!1,showCollisions:!1,showAxes:!1,showPositions:!1,showAngleIndicator:!1,showIds:!1,showShadows:!1}},o=r.extend(t,e),i=!o.options.wireframes&&"transparent"===o.options.background;return o.context=new PIXI.WebGLRenderer(o.options.width,o.options.height,{
|
||||
view:o.canvas,transparent:i,antialias:!0,backgroundColor:e.background}),o.canvas=o.context.view,o.container=new PIXI.Container,o.bounds=o.bounds||{min:{x:0,y:0},max:{x:o.options.width,y:o.options.height}},o.textures={},o.sprites={},o.primitives={},o.spriteContainer=new PIXI.Container,o.container.addChild(o.spriteContainer),r.isElement(o.element)?o.element.appendChild(o.canvas):r.log('No "render.element" passed, "render.canvas" was not inserted into document.',"warn"),o.canvas.oncontextmenu=function(){return!1},o.canvas.onselectstart=function(){return!1},o},n.clear=function(e){for(var t=e.container,o=e.spriteContainer;t.children[0];)t.removeChild(t.children[0]);for(;o.children[0];)o.removeChild(o.children[0]);var n=e.sprites["bg-0"];e.textures={},e.sprites={},e.primitives={},e.sprites["bg-0"]=n,n&&t.addChildAt(n,0),e.container.addChild(e.spriteContainer),e.currentBackground=null,t.scale.set(1,1),t.position.set(0,0)},n.setBackground=function(e,t){if(e.currentBackground!==t){var n=t.indexOf&&-1!==t.indexOf("#"),i=e.sprites["bg-0"];
|
||||
if(n){var s=r.colorToNumber(t);e.context.backgroundColor=s,i&&e.container.removeChild(i)}else if(!i){var a=o(e,t);i=e.sprites["bg-0"]=new PIXI.Sprite(a),i.position.x=0,i.position.y=0,e.container.addChildAt(i,0)}e.currentBackground=t}},n.world=function(e){var t,o=e.render,r=e.world,s=o.context,a=o.container,l=o.options,c=i.allBodies(r),d=i.allConstraints(r),u=[];l.wireframes?n.setBackground(o,l.wireframeBackground):n.setBackground(o,l.background);var p=o.bounds.max.x-o.bounds.min.x,f=o.bounds.max.y-o.bounds.min.y,v=p/o.options.width,y=f/o.options.height;if(l.hasBounds){for(t=0;t<c.length;t++){var m=c[t];m.render.sprite.visible=Bounds.overlaps(m.bounds,o.bounds)}for(t=0;t<d.length;t++){var g=d[t],x=g.bodyA,h=g.bodyB,b=g.pointA,S=g.pointB;x&&(b=Vector.add(x.position,g.pointA)),h&&(S=Vector.add(h.position,g.pointB)),b&&S&&(Bounds.contains(o.bounds,b)||Bounds.contains(o.bounds,S))&&u.push(g)}a.scale.set(1/v,1/y),a.position.set(-o.bounds.min.x*(1/v),-o.bounds.min.y*(1/y))}else u=d;for(t=0;t<c.length;t++)n.body(e,c[t]);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "matter-js",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.0",
|
||||
"license": "MIT",
|
||||
"homepage": "http://brm.io/matter-js/",
|
||||
"author": "Liam Brummitt <liam@brm.io> (http://brm.io/)",
|
||||
|
|
Loading…
Reference in a new issue