excalibur 0.25.2 → 0.25.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/CHANGELOG.md +7 -2
  2. package/build/dist/Actions/Action/Blink.js +51 -0
  3. package/build/dist/Actions/Action/Blink.js.map +1 -0
  4. package/build/dist/Actions/Action/CallMethod.js +21 -0
  5. package/build/dist/Actions/Action/CallMethod.js.map +1 -0
  6. package/build/dist/Actions/Action/Delay.js +25 -0
  7. package/build/dist/Actions/Action/Delay.js.map +1 -0
  8. package/build/dist/Actions/Action/Die.js +22 -0
  9. package/build/dist/Actions/Action/Die.js.map +1 -0
  10. package/build/dist/Actions/Action/EaseTo.js +69 -0
  11. package/build/dist/Actions/Action/EaseTo.js.map +1 -0
  12. package/build/dist/Actions/Action/Fade.js +46 -0
  13. package/build/dist/Actions/Action/Fade.js.map +1 -0
  14. package/build/dist/Actions/Action/Follow.js +55 -0
  15. package/build/dist/Actions/Action/Follow.js.map +1 -0
  16. package/build/dist/Actions/Action/Meet.js +52 -0
  17. package/build/dist/Actions/Action/Meet.js.map +1 -0
  18. package/build/dist/Actions/Action/MoveBy.js +47 -0
  19. package/build/dist/Actions/Action/MoveBy.js.map +1 -0
  20. package/build/dist/Actions/Action/MoveTo.js +40 -0
  21. package/build/dist/Actions/Action/MoveTo.js.map +1 -0
  22. package/build/dist/Actions/Action/Repeat.js +31 -0
  23. package/build/dist/Actions/Action/Repeat.js.map +1 -0
  24. package/build/dist/Actions/Action/RepeatForever.js +37 -0
  25. package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
  26. package/build/dist/Actions/Action/RotateBy.js +91 -0
  27. package/build/dist/Actions/Action/RotateBy.js.map +1 -0
  28. package/build/dist/Actions/Action/RotateTo.js +90 -0
  29. package/build/dist/Actions/Action/RotateTo.js.map +1 -0
  30. package/build/dist/Actions/Action/ScaleBy.js +45 -0
  31. package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
  32. package/build/dist/Actions/Action/ScaleTo.js +56 -0
  33. package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
  34. package/build/dist/Actions/Action.js +2 -0
  35. package/build/dist/Actions/Action.js.map +1 -0
  36. package/build/dist/Actions/ActionContext.js +305 -0
  37. package/build/dist/Actions/ActionContext.js.map +1 -0
  38. package/build/dist/Actions/ActionQueue.js +87 -0
  39. package/build/dist/Actions/ActionQueue.js.map +1 -0
  40. package/build/dist/Actions/Actionable.js +2 -0
  41. package/build/dist/Actions/Actionable.js.map +1 -0
  42. package/build/dist/Actions/ActionsComponent.js +198 -0
  43. package/build/dist/Actions/ActionsComponent.js.map +1 -0
  44. package/build/dist/Actions/ActionsSystem.js +18 -0
  45. package/build/dist/Actions/ActionsSystem.js.map +1 -0
  46. package/build/dist/Actions/Index.js +22 -0
  47. package/build/dist/Actions/Index.js.map +1 -0
  48. package/build/dist/Actions/RotationType.js +27 -0
  49. package/build/dist/Actions/RotationType.js.map +1 -0
  50. package/build/dist/Actor.js +831 -0
  51. package/build/dist/Actor.js.map +1 -0
  52. package/build/dist/Camera.js +663 -0
  53. package/build/dist/Camera.js.map +1 -0
  54. package/build/dist/Class.js +48 -0
  55. package/build/dist/Class.js.map +1 -0
  56. package/build/dist/Collision/BodyComponent.js +351 -0
  57. package/build/dist/Collision/BodyComponent.js.map +1 -0
  58. package/build/dist/Collision/BoundingBox.js +361 -0
  59. package/build/dist/Collision/BoundingBox.js.map +1 -0
  60. package/build/dist/Collision/ColliderComponent.js +198 -0
  61. package/build/dist/Collision/ColliderComponent.js.map +1 -0
  62. package/build/dist/Collision/Colliders/CircleCollider.js +264 -0
  63. package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
  64. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
  65. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
  66. package/build/dist/Collision/Colliders/Collider.js +26 -0
  67. package/build/dist/Collision/Colliders/Collider.js.map +1 -0
  68. package/build/dist/Collision/Colliders/CollisionJumpTable.js +301 -0
  69. package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
  70. package/build/dist/Collision/Colliders/CompositeCollider.js +232 -0
  71. package/build/dist/Collision/Colliders/CompositeCollider.js.map +1 -0
  72. package/build/dist/Collision/Colliders/EdgeCollider.js +253 -0
  73. package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
  74. package/build/dist/Collision/Colliders/PolygonCollider.js +389 -0
  75. package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
  76. package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
  77. package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
  78. package/build/dist/Collision/Colliders/Shape.js +102 -0
  79. package/build/dist/Collision/Colliders/Shape.js.map +1 -0
  80. package/build/dist/Collision/CollisionSystem.js +116 -0
  81. package/build/dist/Collision/CollisionSystem.js.map +1 -0
  82. package/build/dist/Collision/CollisionType.js +33 -0
  83. package/build/dist/Collision/CollisionType.js.map +1 -0
  84. package/build/dist/Collision/Detection/CollisionContact.js +46 -0
  85. package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
  86. package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
  87. package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
  88. package/build/dist/Collision/Detection/DynamicTree.js +442 -0
  89. package/build/dist/Collision/Detection/DynamicTree.js.map +1 -0
  90. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js +211 -0
  91. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.js.map +1 -0
  92. package/build/dist/Collision/Detection/Pair.js +92 -0
  93. package/build/dist/Collision/Detection/Pair.js.map +1 -0
  94. package/build/dist/Collision/Group/CollisionGroup.js +114 -0
  95. package/build/dist/Collision/Group/CollisionGroup.js.map +1 -0
  96. package/build/dist/Collision/Group/CollisionGroupManager.js +52 -0
  97. package/build/dist/Collision/Group/CollisionGroupManager.js.map +1 -0
  98. package/build/dist/Collision/Index.js +29 -0
  99. package/build/dist/Collision/Index.js.map +1 -0
  100. package/build/dist/Collision/Integrator.js +11 -0
  101. package/build/dist/Collision/Integrator.js.map +1 -0
  102. package/build/dist/Collision/MotionSystem.js +42 -0
  103. package/build/dist/Collision/MotionSystem.js.map +1 -0
  104. package/build/dist/Collision/Physics.js +163 -0
  105. package/build/dist/Collision/Physics.js.map +1 -0
  106. package/build/dist/Collision/Side.js +51 -0
  107. package/build/dist/Collision/Side.js.map +1 -0
  108. package/build/dist/Collision/Solver/ArcadeSolver.js +101 -0
  109. package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
  110. package/build/dist/Collision/Solver/ContactConstraintPoint.js +83 -0
  111. package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
  112. package/build/dist/Collision/Solver/RealisticSolver.js +248 -0
  113. package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
  114. package/build/dist/Collision/Solver/Solver.js +37 -0
  115. package/build/dist/Collision/Solver/Solver.js.map +1 -0
  116. package/build/dist/Color.js +461 -0
  117. package/build/dist/Color.js.map +1 -0
  118. package/build/dist/Configurable.js +32 -0
  119. package/build/dist/Configurable.js.map +1 -0
  120. package/build/dist/Debug/Debug.js +375 -0
  121. package/build/dist/Debug/Debug.js.map +1 -0
  122. package/build/dist/Debug/DebugFlags.js +40 -0
  123. package/build/dist/Debug/DebugFlags.js.map +1 -0
  124. package/build/dist/Debug/DebugSystem.js +251 -0
  125. package/build/dist/Debug/DebugSystem.js.map +1 -0
  126. package/build/dist/Debug/index.js +4 -0
  127. package/build/dist/Debug/index.js.map +1 -0
  128. package/build/dist/Deprecated.js +2 -0
  129. package/build/dist/Deprecated.js.map +1 -0
  130. package/build/dist/Drawing/Animation.js +294 -0
  131. package/build/dist/Drawing/Animation.js.map +1 -0
  132. package/build/dist/Drawing/CanvasDrawComponent.js +16 -0
  133. package/build/dist/Drawing/CanvasDrawComponent.js.map +1 -0
  134. package/build/dist/Drawing/CanvasDrawingSystem.js +95 -0
  135. package/build/dist/Drawing/CanvasDrawingSystem.js.map +1 -0
  136. package/build/dist/Drawing/Index.js +10 -0
  137. package/build/dist/Drawing/Index.js.map +1 -0
  138. package/build/dist/Drawing/Polygon.js +139 -0
  139. package/build/dist/Drawing/Polygon.js.map +1 -0
  140. package/build/dist/Drawing/Sprite.js +355 -0
  141. package/build/dist/Drawing/Sprite.js.map +1 -0
  142. package/build/dist/Drawing/SpriteEffects.js +246 -0
  143. package/build/dist/Drawing/SpriteEffects.js.map +1 -0
  144. package/build/dist/Drawing/SpriteSheet.js +413 -0
  145. package/build/dist/Drawing/SpriteSheet.js.map +1 -0
  146. package/build/dist/Drawing/Texture.js +69 -0
  147. package/build/dist/Drawing/Texture.js.map +1 -0
  148. package/build/dist/Engine.d.ts +4 -1
  149. package/build/dist/Engine.js +985 -0
  150. package/build/dist/Engine.js.map +1 -0
  151. package/build/dist/EntityComponentSystem/Component.js +65 -0
  152. package/build/dist/EntityComponentSystem/Component.js.map +1 -0
  153. package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
  154. package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
  155. package/build/dist/EntityComponentSystem/Components/TransformComponent.js +249 -0
  156. package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
  157. package/build/dist/EntityComponentSystem/Entity.js +452 -0
  158. package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
  159. package/build/dist/EntityComponentSystem/EntityManager.js +128 -0
  160. package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
  161. package/build/dist/EntityComponentSystem/Query.js +91 -0
  162. package/build/dist/EntityComponentSystem/Query.js.map +1 -0
  163. package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
  164. package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
  165. package/build/dist/EntityComponentSystem/System.js +76 -0
  166. package/build/dist/EntityComponentSystem/System.js.map +1 -0
  167. package/build/dist/EntityComponentSystem/SystemManager.js +102 -0
  168. package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
  169. package/build/dist/EntityComponentSystem/Util.js +5 -0
  170. package/build/dist/EntityComponentSystem/Util.js.map +1 -0
  171. package/build/dist/EntityComponentSystem/World.js +55 -0
  172. package/build/dist/EntityComponentSystem/World.js.map +1 -0
  173. package/build/dist/EntityComponentSystem/index.js +11 -0
  174. package/build/dist/EntityComponentSystem/index.js.map +1 -0
  175. package/build/dist/EventDispatcher.js +114 -0
  176. package/build/dist/EventDispatcher.js.map +1 -0
  177. package/build/dist/Events/ExEvent.js +12 -0
  178. package/build/dist/Events/ExEvent.js.map +1 -0
  179. package/build/dist/Events/MediaEvents.js +75 -0
  180. package/build/dist/Events/MediaEvents.js.map +1 -0
  181. package/build/dist/Events/PointerEvents.js +52 -0
  182. package/build/dist/Events/PointerEvents.js.map +1 -0
  183. package/build/dist/Events.js +497 -0
  184. package/build/dist/Events.js.map +1 -0
  185. package/build/dist/Flags.js +90 -0
  186. package/build/dist/Flags.js.map +1 -0
  187. package/build/dist/Graphics/Animation.js +310 -0
  188. package/build/dist/Graphics/Animation.js.map +1 -0
  189. package/build/dist/Graphics/Canvas.js +38 -0
  190. package/build/dist/Graphics/Canvas.js.map +1 -0
  191. package/build/dist/Graphics/Circle.js +47 -0
  192. package/build/dist/Graphics/Circle.js.map +1 -0
  193. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
  194. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
  195. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +207 -0
  196. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
  197. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +331 -0
  198. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
  199. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +160 -0
  200. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
  201. package/build/dist/Graphics/Context/debug-text.js +47 -0
  202. package/build/dist/Graphics/Context/debug-text.js.map +1 -0
  203. package/build/dist/Graphics/Context/image-renderer/image-renderer.js +209 -0
  204. package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
  205. package/build/dist/Graphics/Context/line-renderer/line-renderer.js +87 -0
  206. package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
  207. package/build/dist/Graphics/Context/point-renderer/point-renderer.js +82 -0
  208. package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
  209. package/build/dist/Graphics/Context/quad-index-buffer.js +69 -0
  210. package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
  211. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +272 -0
  212. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
  213. package/build/dist/Graphics/Context/render-source.js +16 -0
  214. package/build/dist/Graphics/Context/render-source.js.map +1 -0
  215. package/build/dist/Graphics/Context/render-target.js +65 -0
  216. package/build/dist/Graphics/Context/render-target.js.map +1 -0
  217. package/build/dist/Graphics/Context/renderer.js +2 -0
  218. package/build/dist/Graphics/Context/renderer.js.map +1 -0
  219. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +53 -0
  220. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
  221. package/build/dist/Graphics/Context/shader.js +236 -0
  222. package/build/dist/Graphics/Context/shader.js.map +1 -0
  223. package/build/dist/Graphics/Context/state-stack.js +27 -0
  224. package/build/dist/Graphics/Context/state-stack.js.map +1 -0
  225. package/build/dist/Graphics/Context/texture-loader.d.ts +8 -0
  226. package/build/dist/Graphics/Context/texture-loader.js +121 -0
  227. package/build/dist/Graphics/Context/texture-loader.js.map +1 -0
  228. package/build/dist/Graphics/Context/transform-stack.js +30 -0
  229. package/build/dist/Graphics/Context/transform-stack.js.map +1 -0
  230. package/build/dist/Graphics/Context/vertex-buffer.js +45 -0
  231. package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
  232. package/build/dist/Graphics/Context/vertex-layout.js +93 -0
  233. package/build/dist/Graphics/Context/vertex-layout.js.map +1 -0
  234. package/build/dist/Graphics/Context/webgl-adapter.js +19 -0
  235. package/build/dist/Graphics/Context/webgl-adapter.js.map +1 -0
  236. package/build/dist/Graphics/Context/webgl-util.js +105 -0
  237. package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
  238. package/build/dist/Graphics/DebugGraphicsComponent.js +15 -0
  239. package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
  240. package/build/dist/Graphics/Filtering.js +17 -0
  241. package/build/dist/Graphics/Filtering.js.map +1 -0
  242. package/build/dist/Graphics/Font.js +293 -0
  243. package/build/dist/Graphics/Font.js.map +1 -0
  244. package/build/dist/Graphics/FontCommon.js +109 -0
  245. package/build/dist/Graphics/FontCommon.js.map +1 -0
  246. package/build/dist/Graphics/Graphic.js +200 -0
  247. package/build/dist/Graphics/Graphic.js.map +1 -0
  248. package/build/dist/Graphics/GraphicsComponent.js +290 -0
  249. package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
  250. package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
  251. package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
  252. package/build/dist/Graphics/GraphicsGroup.js +69 -0
  253. package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
  254. package/build/dist/Graphics/GraphicsSystem.js +153 -0
  255. package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
  256. package/build/dist/Graphics/ImageSource.js +116 -0
  257. package/build/dist/Graphics/ImageSource.js.map +1 -0
  258. package/build/dist/Graphics/Polygon.js +59 -0
  259. package/build/dist/Graphics/Polygon.js.map +1 -0
  260. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
  261. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
  262. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
  263. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
  264. package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
  265. package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
  266. package/build/dist/Graphics/PostProcessor/ScreenShader.js +56 -0
  267. package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
  268. package/build/dist/Graphics/Raster.js +207 -0
  269. package/build/dist/Graphics/Raster.js.map +1 -0
  270. package/build/dist/Graphics/Rectangle.js +29 -0
  271. package/build/dist/Graphics/Rectangle.js.map +1 -0
  272. package/build/dist/Graphics/Sprite.js +103 -0
  273. package/build/dist/Graphics/Sprite.js.map +1 -0
  274. package/build/dist/Graphics/SpriteFont.js +120 -0
  275. package/build/dist/Graphics/SpriteFont.js.map +1 -0
  276. package/build/dist/Graphics/SpriteSheet.js +115 -0
  277. package/build/dist/Graphics/SpriteSheet.js.map +1 -0
  278. package/build/dist/Graphics/Text.js +94 -0
  279. package/build/dist/Graphics/Text.js.map +1 -0
  280. package/build/dist/Graphics/index.js +42 -0
  281. package/build/dist/Graphics/index.js.map +1 -0
  282. package/build/dist/Id.js +8 -0
  283. package/build/dist/Id.js.map +1 -0
  284. package/build/dist/Input/CapturePointerConfig.js +5 -0
  285. package/build/dist/Input/CapturePointerConfig.js.map +1 -0
  286. package/build/dist/Input/EngineInput.js +2 -0
  287. package/build/dist/Input/EngineInput.js.map +1 -0
  288. package/build/dist/Input/Gamepad.js +358 -0
  289. package/build/dist/Input/Gamepad.js.map +1 -0
  290. package/build/dist/Input/Index.js +22 -0
  291. package/build/dist/Input/Index.js.map +1 -0
  292. package/build/dist/Input/Keyboard.js +267 -0
  293. package/build/dist/Input/Keyboard.js.map +1 -0
  294. package/build/dist/Input/NativePointerButton.js +12 -0
  295. package/build/dist/Input/NativePointerButton.js.map +1 -0
  296. package/build/dist/Input/PointerAbstraction.js +41 -0
  297. package/build/dist/Input/PointerAbstraction.js.map +1 -0
  298. package/build/dist/Input/PointerButton.js +12 -0
  299. package/build/dist/Input/PointerButton.js.map +1 -0
  300. package/build/dist/Input/PointerComponent.js +28 -0
  301. package/build/dist/Input/PointerComponent.js.map +1 -0
  302. package/build/dist/Input/PointerEvent.js +25 -0
  303. package/build/dist/Input/PointerEvent.js.map +1 -0
  304. package/build/dist/Input/PointerEventReceiver.js +414 -0
  305. package/build/dist/Input/PointerEventReceiver.js.map +1 -0
  306. package/build/dist/Input/PointerScope.js +16 -0
  307. package/build/dist/Input/PointerScope.js.map +1 -0
  308. package/build/dist/Input/PointerSystem.js +217 -0
  309. package/build/dist/Input/PointerSystem.js.map +1 -0
  310. package/build/dist/Input/PointerType.js +11 -0
  311. package/build/dist/Input/PointerType.js.map +1 -0
  312. package/build/dist/Input/WheelDeltaMode.js +7 -0
  313. package/build/dist/Input/WheelDeltaMode.js.map +1 -0
  314. package/build/dist/Input/WheelEvent.js +21 -0
  315. package/build/dist/Input/WheelEvent.js.map +1 -0
  316. package/build/dist/Interfaces/Audio.js +2 -0
  317. package/build/dist/Interfaces/Audio.js.map +1 -0
  318. package/build/dist/Interfaces/AudioImplementation.js +11 -0
  319. package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
  320. package/build/dist/Interfaces/Clonable.js +2 -0
  321. package/build/dist/Interfaces/Clonable.js.map +1 -0
  322. package/build/dist/Interfaces/Drawable.js +2 -0
  323. package/build/dist/Interfaces/Drawable.js.map +1 -0
  324. package/build/dist/Interfaces/Evented.js +2 -0
  325. package/build/dist/Interfaces/Evented.js.map +1 -0
  326. package/build/dist/Interfaces/Index.js +10 -0
  327. package/build/dist/Interfaces/Index.js.map +1 -0
  328. package/build/dist/Interfaces/LifecycleEvents.js +51 -0
  329. package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
  330. package/build/dist/Interfaces/Loadable.js +2 -0
  331. package/build/dist/Interfaces/Loadable.js.map +1 -0
  332. package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
  333. package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
  334. package/build/dist/Interfaces/Trait.js +2 -0
  335. package/build/dist/Interfaces/Trait.js.map +1 -0
  336. package/build/dist/Label.js +273 -0
  337. package/build/dist/Label.js.map +1 -0
  338. package/build/dist/Loader.js +367 -0
  339. package/build/dist/Loader.js.map +1 -0
  340. package/build/dist/Math/Index.js +10 -0
  341. package/build/dist/Math/Index.js.map +1 -0
  342. package/build/dist/Math/Random.js +239 -0
  343. package/build/dist/Math/Random.js.map +1 -0
  344. package/build/dist/Math/global-coordinates.js +30 -0
  345. package/build/dist/Math/global-coordinates.js.map +1 -0
  346. package/build/dist/Math/line.js +194 -0
  347. package/build/dist/Math/line.js.map +1 -0
  348. package/build/dist/Math/matrix.js +446 -0
  349. package/build/dist/Math/matrix.js.map +1 -0
  350. package/build/dist/Math/projection.js +24 -0
  351. package/build/dist/Math/projection.js.map +1 -0
  352. package/build/dist/Math/ray.js +52 -0
  353. package/build/dist/Math/ray.js.map +1 -0
  354. package/build/dist/Math/util.js +82 -0
  355. package/build/dist/Math/util.js.map +1 -0
  356. package/build/dist/Math/vector-view.js +25 -0
  357. package/build/dist/Math/vector-view.js.map +1 -0
  358. package/build/dist/Math/vector.js +326 -0
  359. package/build/dist/Math/vector.js.map +1 -0
  360. package/build/dist/Particles.js +449 -0
  361. package/build/dist/Particles.js.map +1 -0
  362. package/build/dist/Polyfill.js +56 -0
  363. package/build/dist/Polyfill.js.map +1 -0
  364. package/build/dist/Promises.js +205 -0
  365. package/build/dist/Promises.js.map +1 -0
  366. package/build/dist/Resources/Gif.js +479 -0
  367. package/build/dist/Resources/Gif.js.map +1 -0
  368. package/build/dist/Resources/Index.js +4 -0
  369. package/build/dist/Resources/Index.js.map +1 -0
  370. package/build/dist/Resources/Resource.js +74 -0
  371. package/build/dist/Resources/Resource.js.map +1 -0
  372. package/build/dist/Resources/Sound/AudioContext.js +16 -0
  373. package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
  374. package/build/dist/Resources/Sound/Index.js +4 -0
  375. package/build/dist/Resources/Sound/Index.js.map +1 -0
  376. package/build/dist/Resources/Sound/Sound.js +240 -0
  377. package/build/dist/Resources/Sound/Sound.js.map +1 -0
  378. package/build/dist/Resources/Sound/WebAudioInstance.js +160 -0
  379. package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
  380. package/build/dist/Scene.js +458 -0
  381. package/build/dist/Scene.js.map +1 -0
  382. package/build/dist/Screen.js +634 -0
  383. package/build/dist/Screen.js.map +1 -0
  384. package/build/dist/ScreenElement.js +29 -0
  385. package/build/dist/ScreenElement.js.map +1 -0
  386. package/build/dist/TileMap.js +488 -0
  387. package/build/dist/TileMap.js.map +1 -0
  388. package/build/dist/Timer.js +198 -0
  389. package/build/dist/Timer.js.map +1 -0
  390. package/build/dist/Traits/Index.js +5 -0
  391. package/build/dist/Traits/Index.js.map +1 -0
  392. package/build/dist/Traits/OffscreenCulling.js +35 -0
  393. package/build/dist/Traits/OffscreenCulling.js.map +1 -0
  394. package/build/dist/Trigger.js +113 -0
  395. package/build/dist/Trigger.js.map +1 -0
  396. package/build/dist/Util/Actors.js +19 -0
  397. package/build/dist/Util/Actors.js.map +1 -0
  398. package/build/dist/Util/Browser.js +66 -0
  399. package/build/dist/Util/Browser.js.map +1 -0
  400. package/build/dist/Util/Clock.js +219 -0
  401. package/build/dist/Util/Clock.js.map +1 -0
  402. package/build/dist/Util/CullingBox.js +104 -0
  403. package/build/dist/Util/CullingBox.js.map +1 -0
  404. package/build/dist/Util/Decorators.js +78 -0
  405. package/build/dist/Util/Decorators.js.map +1 -0
  406. package/build/dist/Util/Detector.js +167 -0
  407. package/build/dist/Util/Detector.js.map +1 -0
  408. package/build/dist/Util/DrawUtil.js +117 -0
  409. package/build/dist/Util/DrawUtil.js.map +1 -0
  410. package/build/dist/Util/EasingFunctions.js +118 -0
  411. package/build/dist/Util/EasingFunctions.js.map +1 -0
  412. package/build/dist/Util/Fps.js +47 -0
  413. package/build/dist/Util/Fps.js.map +1 -0
  414. package/build/dist/Util/Index.js +7 -0
  415. package/build/dist/Util/Index.js.map +1 -0
  416. package/build/dist/Util/Log.js +195 -0
  417. package/build/dist/Util/Log.js.map +1 -0
  418. package/build/dist/Util/Observable.js +60 -0
  419. package/build/dist/Util/Observable.js.map +1 -0
  420. package/build/dist/Util/Pool.js +66 -0
  421. package/build/dist/Util/Pool.js.map +1 -0
  422. package/build/dist/Util/SortedList.js +261 -0
  423. package/build/dist/Util/SortedList.js.map +1 -0
  424. package/build/dist/Util/Sound.js +22 -0
  425. package/build/dist/Util/Sound.js.map +1 -0
  426. package/build/dist/Util/Util.js +294 -0
  427. package/build/dist/Util/Util.js.map +1 -0
  428. package/build/dist/Util/Watch.js +67 -0
  429. package/build/dist/Util/Watch.js.map +1 -0
  430. package/build/dist/Util/WebAudio.js +62 -0
  431. package/build/dist/Util/WebAudio.js.map +1 -0
  432. package/build/dist/excalibur.js +101 -22
  433. package/build/dist/excalibur.js.map +1 -1
  434. package/build/dist/excalibur.min.js +1 -1
  435. package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
  436. package/build/dist/excalibur.min.js.map +1 -1
  437. package/build/dist/index.js +74 -0
  438. package/build/dist/index.js.map +1 -0
  439. package/build/esm/Engine.d.ts +4 -1
  440. package/build/esm/Graphics/Context/texture-loader.d.ts +8 -0
  441. package/build/esm/excalibur.js +101 -22
  442. package/build/esm/excalibur.js.map +1 -1
  443. package/build/esm/excalibur.min.js +1 -1
  444. package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
  445. package/build/esm/excalibur.min.js.map +1 -1
  446. package/package.json +23 -22
@@ -0,0 +1,101 @@
1
+ import { PostCollisionEvent, PreCollisionEvent } from '../../Events';
2
+ import { CollisionType } from '../CollisionType';
3
+ import { Side } from '../Side';
4
+ import { CollisionSolver } from './Solver';
5
+ import { BodyComponent } from '../BodyComponent';
6
+ /**
7
+ * ArcadeSolver is the default in Excalibur. It solves collisions so that there is no overlap between contacts,
8
+ * and negates velocity along the collision normal.
9
+ *
10
+ * This is usually the type of collisions used for 2D games that don't need a more realistic collision simulation.
11
+ *
12
+ */
13
+ export class ArcadeSolver extends CollisionSolver {
14
+ preSolve(contacts) {
15
+ for (const contact of contacts) {
16
+ const side = Side.fromDirection(contact.mtv);
17
+ const mtv = contact.mtv.negate();
18
+ // Publish collision events on both participants
19
+ contact.colliderA.events.emit('precollision', new PreCollisionEvent(contact.colliderA, contact.colliderB, side, mtv));
20
+ contact.colliderB.events.emit('precollision', new PreCollisionEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), mtv.negate()));
21
+ }
22
+ }
23
+ postSolve(contacts) {
24
+ var _a, _b;
25
+ for (const contact of contacts) {
26
+ const colliderA = contact.colliderA;
27
+ const colliderB = contact.colliderB;
28
+ const bodyA = (_a = colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
29
+ const bodyB = (_b = colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
30
+ if (bodyA && bodyB) {
31
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
32
+ continue;
33
+ }
34
+ }
35
+ const side = Side.fromDirection(contact.mtv);
36
+ const mtv = contact.mtv.negate();
37
+ // Publish collision events on both participants
38
+ contact.colliderA.events.emit('postcollision', new PostCollisionEvent(contact.colliderA, contact.colliderB, side, mtv));
39
+ contact.colliderB.events.emit('postcollision', new PostCollisionEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), mtv.negate()));
40
+ }
41
+ }
42
+ solvePosition(contacts) {
43
+ var _a, _b;
44
+ for (const contact of contacts) {
45
+ // if bounds no longer interesect skip to the next
46
+ // this removes jitter from overlapping/stacked solid tiles or a wall of solid tiles
47
+ if (!contact.colliderA.bounds.intersect(contact.colliderB.bounds)) {
48
+ continue;
49
+ }
50
+ let mtv = contact.mtv;
51
+ const colliderA = contact.colliderA;
52
+ const colliderB = contact.colliderB;
53
+ const bodyA = (_a = colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
54
+ const bodyB = (_b = colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
55
+ if (bodyA && bodyB) {
56
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
57
+ continue;
58
+ }
59
+ if (bodyA.collisionType === CollisionType.Active && bodyB.collisionType === CollisionType.Active) {
60
+ // split overlaps if both are Active
61
+ mtv = mtv.scale(0.5);
62
+ }
63
+ // Resolve overlaps
64
+ if (bodyA.collisionType === CollisionType.Active) {
65
+ bodyA.pos.x -= mtv.x;
66
+ bodyA.pos.y -= mtv.y;
67
+ }
68
+ if (bodyB.collisionType === CollisionType.Active) {
69
+ bodyB.pos.x += mtv.x;
70
+ bodyB.pos.y += mtv.y;
71
+ }
72
+ }
73
+ }
74
+ }
75
+ solveVelocity(contacts) {
76
+ var _a, _b;
77
+ for (const contact of contacts) {
78
+ const colliderA = contact.colliderA;
79
+ const colliderB = contact.colliderB;
80
+ const bodyA = (_a = colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
81
+ const bodyB = (_b = colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
82
+ if (bodyA && bodyB) {
83
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
84
+ continue;
85
+ }
86
+ const normal = contact.normal;
87
+ const opposite = normal.negate();
88
+ // Cancel out velocity opposite direction of collision normal
89
+ if (bodyA.collisionType === CollisionType.Active) {
90
+ const velAdj = normal.scale(normal.dot(bodyA.vel.negate()));
91
+ bodyA.vel = bodyA.vel.add(velAdj);
92
+ }
93
+ if (bodyB.collisionType === CollisionType.Active) {
94
+ const velAdj = opposite.scale(opposite.dot(bodyB.vel.negate()));
95
+ bodyB.vel = bodyB.vel.add(velAdj);
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ //# sourceMappingURL=ArcadeSolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcadeSol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ClD,MAAM,KAAK,GAAG,MAAA,SAAS,CAAC,KAAK,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAC;YAElD,IAAI,KAAK,IAAI,KAAK,EAAE;gBAElB,IAAI,KAAK,CAAC,aAAa,KAAK,aAAa,CAAC,OAAO,IAAI,KAAK,CAAC,aAAa,KAAK,aAAa,CAAC,OAAO,EAAE;oBAClG,SAAS;iBACV;gBAED,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;gBAEjC,6DAA6D;gBAC7D,IAAI,KAAK,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,EAAE;oBAChD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAC5D,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACnC;gBAED,IAAI,KAAK,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,EAAE;oBAChD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;oBAChE,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACnC;aACF;SACF;IACH,CAAC;CACF"}
@@ -0,0 +1,83 @@
1
+ import { Vector } from '../../Math/vector';
2
+ import { BodyComponent } from '../BodyComponent';
3
+ /**
4
+ * Holds information about contact points, meant to be reused over multiple frames of contact
5
+ */
6
+ export class ContactConstraintPoint {
7
+ constructor(point, local, contact) {
8
+ this.point = point;
9
+ this.local = local;
10
+ this.contact = contact;
11
+ /**
12
+ * Impulse accumulated over time in normal direction
13
+ */
14
+ this.normalImpulse = 0;
15
+ /**
16
+ * Impulse accumulated over time in the tangent direction
17
+ */
18
+ this.tangentImpulse = 0;
19
+ /**
20
+ * Effective mass seen in the normal direction
21
+ */
22
+ this.normalMass = 0;
23
+ /**
24
+ * Effective mass seen in the tangent direction
25
+ */
26
+ this.tangentMass = 0;
27
+ /**
28
+ * Direction from center of mass of bodyA to contact point
29
+ */
30
+ this.aToContact = new Vector(0, 0);
31
+ /**
32
+ * Direction from center of mass of bodyB to contact point
33
+ */
34
+ this.bToContact = new Vector(0, 0);
35
+ this.update();
36
+ }
37
+ /**
38
+ * Updates the contact information
39
+ */
40
+ update() {
41
+ var _a, _b;
42
+ const bodyA = (_a = this.contact.colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
43
+ const bodyB = (_b = this.contact.colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
44
+ if (bodyA && bodyB) {
45
+ const normal = this.contact.normal;
46
+ const tangent = this.contact.tangent;
47
+ this.aToContact = this.point.sub(bodyA.pos);
48
+ this.bToContact = this.point.sub(bodyB.pos);
49
+ const aToContactNormal = this.aToContact.cross(normal);
50
+ const bToContactNormal = this.bToContact.cross(normal);
51
+ this.normalMass =
52
+ bodyA.inverseMass +
53
+ bodyB.inverseMass +
54
+ bodyA.inverseInertia * aToContactNormal * aToContactNormal +
55
+ bodyB.inverseInertia * bToContactNormal * bToContactNormal;
56
+ const aToContactTangent = this.aToContact.cross(tangent);
57
+ const bToContactTangent = this.bToContact.cross(tangent);
58
+ this.tangentMass =
59
+ bodyA.inverseMass +
60
+ bodyB.inverseMass +
61
+ bodyA.inverseInertia * aToContactTangent * aToContactTangent +
62
+ bodyB.inverseInertia * bToContactTangent * bToContactTangent;
63
+ }
64
+ return this;
65
+ }
66
+ /**
67
+ * Returns the relative velocity between bodyA and bodyB
68
+ */
69
+ getRelativeVelocity() {
70
+ var _a, _b;
71
+ const bodyA = (_a = this.contact.colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
72
+ const bodyB = (_b = this.contact.colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
73
+ if (bodyA && bodyB) {
74
+ // Relative velocity in linear terms
75
+ // Angular to linear velocity formula -> omega = velocity/radius so omega x radius = velocity
76
+ const velA = bodyA.vel.add(Vector.cross(bodyA.angularVelocity, this.aToContact));
77
+ const velB = bodyB.vel.add(Vector.cross(bodyB.angularVelocity, this.bToContact));
78
+ return velB.sub(velA);
79
+ }
80
+ return Vector.Zero;
81
+ }
82
+ }
83
+ //# sourceMappingURL=ContactConstraintPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContactConstraintPoint.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Solver/ContactConstraintPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACjC,YAAmB,KAAa,EAAS,KAAa,EAAS,OAAyB;QAArE,UAAK,GAAL,KAAK,CAAQ;QAAS,UAAK,GAAL,KAAK,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAkB;QAwDxF;;WAEG;QACI,kBAAa,GAAW,CAAC,CAAC;QAEjC;;WAEG;QACI,mBAAc,GAAW,CAAC,CAAC;QAElC;;WAEG;QACI,eAAU,GAAW,CAAC,CAAC;QAE9B;;WAEG;QACI,gBAAW,GAAW,CAAC,CAAC;QAE/B;;WAEG;QACI,eAAU,GAAW,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAE7C;;WAEG;QACI,eAAU,GAAW,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAnF3C,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,MAAM;;QACJ,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC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I,CAAC;IACd,CAAC;IAED;;OAEG;IACI,mBAAmB;;QACxB,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,0CAAE,GAAG,CAAC,aAAa,CAAC,CAAC;QAC/D,IAAI,KAAK,IAAI,KAAK,EAAE;YAClB,oCAAoC;YACpC,6FAA6F;YAC7F,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YACjF,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YACjF,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACvB;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;CA+BF"}
@@ -0,0 +1,248 @@
1
+ import { CollisionPostSolveEvent, CollisionPreSolveEvent, PostCollisionEvent, PreCollisionEvent } from '../../Events';
2
+ import { clamp } from '../../Math/util';
3
+ import { CollisionType } from '../CollisionType';
4
+ import { ContactConstraintPoint } from './ContactConstraintPoint';
5
+ import { Side } from '../Side';
6
+ import { Physics } from '../Physics';
7
+ import { CollisionSolver } from './Solver';
8
+ import { BodyComponent } from '../BodyComponent';
9
+ import { CollisionJumpTable } from '../Colliders/CollisionJumpTable';
10
+ export class RealisticSolver extends CollisionSolver {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.lastFrameContacts = new Map();
14
+ // map contact id to contact points
15
+ this.idToContactConstraint = new Map();
16
+ }
17
+ getContactConstraints(id) {
18
+ var _a;
19
+ return (_a = this.idToContactConstraint.get(id)) !== null && _a !== void 0 ? _a : [];
20
+ }
21
+ preSolve(contacts) {
22
+ var _a, _b, _c;
23
+ for (const contact of contacts) {
24
+ // Publish collision events on both participants
25
+ const side = Side.fromDirection(contact.mtv);
26
+ contact.colliderA.events.emit('precollision', new PreCollisionEvent(contact.colliderA, contact.colliderB, side, contact.mtv));
27
+ contact.colliderA.events.emit('beforecollisionresolve', new CollisionPreSolveEvent(contact.colliderA, contact.colliderB, side, contact.mtv, contact));
28
+ contact.colliderB.events.emit('precollision', new PreCollisionEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), contact.mtv.negate()));
29
+ contact.colliderB.events.emit('beforecollisionresolve', new CollisionPreSolveEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), contact.mtv.negate(), contact));
30
+ // Match awake state for sleeping
31
+ contact.matchAwake();
32
+ }
33
+ // Keep track of contacts that done
34
+ const finishedContactIds = Array.from(this.idToContactConstraint.keys());
35
+ for (const contact of contacts) {
36
+ // Remove all current contacts that are not done
37
+ const index = finishedContactIds.indexOf(contact.id);
38
+ if (index > -1) {
39
+ finishedContactIds.splice(index, 1);
40
+ }
41
+ const contactPoints = (_a = this.idToContactConstraint.get(contact.id)) !== null && _a !== void 0 ? _a : [];
42
+ let pointIndex = 0;
43
+ const bodyA = contact.colliderA.owner.get(BodyComponent);
44
+ const bodyB = contact.colliderB.owner.get(BodyComponent);
45
+ if (bodyA && bodyB) {
46
+ for (const point of contact.points) {
47
+ const normal = contact.normal;
48
+ const tangent = contact.tangent;
49
+ const aToContact = point.sub(bodyA.pos);
50
+ const bToContact = point.sub(bodyB.pos);
51
+ const aToContactNormal = aToContact.cross(normal);
52
+ const bToContactNormal = bToContact.cross(normal);
53
+ const normalMass = bodyA.inverseMass +
54
+ bodyB.inverseMass +
55
+ bodyA.inverseInertia * aToContactNormal * aToContactNormal +
56
+ bodyB.inverseInertia * bToContactNormal * bToContactNormal;
57
+ const aToContactTangent = aToContact.cross(tangent);
58
+ const bToContactTangent = bToContact.cross(tangent);
59
+ const tangentMass = bodyA.inverseMass +
60
+ bodyB.inverseMass +
61
+ bodyA.inverseInertia * aToContactTangent * aToContactTangent +
62
+ bodyB.inverseInertia * bToContactTangent * bToContactTangent;
63
+ // Preserve normal/tangent impulse by re-using the contact point if it's close
64
+ if (contactPoints[pointIndex] && ((_c = (_b = contactPoints[pointIndex]) === null || _b === void 0 ? void 0 : _b.point) === null || _c === void 0 ? void 0 : _c.squareDistance(point)) < 4) {
65
+ contactPoints[pointIndex].point = point;
66
+ contactPoints[pointIndex].local = contact.localPoints[pointIndex];
67
+ }
68
+ else {
69
+ // new contact if it's not close or doesn't exist
70
+ contactPoints[pointIndex] = new ContactConstraintPoint(point, contact.localPoints[pointIndex], contact);
71
+ }
72
+ // Update contact point calculations
73
+ contactPoints[pointIndex].aToContact = aToContact;
74
+ contactPoints[pointIndex].bToContact = bToContact;
75
+ contactPoints[pointIndex].normalMass = normalMass;
76
+ contactPoints[pointIndex].tangentMass = tangentMass;
77
+ pointIndex++;
78
+ }
79
+ }
80
+ this.idToContactConstraint.set(contact.id, contactPoints);
81
+ }
82
+ // Clean up any contacts that did not occur last frame
83
+ for (const id of finishedContactIds) {
84
+ this.idToContactConstraint.delete(id);
85
+ }
86
+ // Warm contacts with accumulated impulse
87
+ // Useful for tall stacks
88
+ if (Physics.warmStart) {
89
+ this.warmStart(contacts);
90
+ }
91
+ else {
92
+ for (const contact of contacts) {
93
+ const contactPoints = this.getContactConstraints(contact.id);
94
+ for (const point of contactPoints) {
95
+ point.normalImpulse = 0;
96
+ point.tangentImpulse = 0;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ postSolve(contacts) {
102
+ for (const contact of contacts) {
103
+ const bodyA = contact.colliderA.owner.get(BodyComponent);
104
+ const bodyB = contact.colliderB.owner.get(BodyComponent);
105
+ if (bodyA && bodyB) {
106
+ // Skip post solve for active+passive collisions
107
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
108
+ continue;
109
+ }
110
+ // Update motion values for sleeping
111
+ bodyA.updateMotion();
112
+ bodyB.updateMotion();
113
+ }
114
+ // Publish collision events on both participants
115
+ const side = Side.fromDirection(contact.mtv);
116
+ contact.colliderA.events.emit('postcollision', new PostCollisionEvent(contact.colliderA, contact.colliderB, side, contact.mtv));
117
+ contact.colliderA.events.emit('aftercollisionresolve', new CollisionPostSolveEvent(contact.colliderA, contact.colliderB, side, contact.mtv, contact));
118
+ contact.colliderB.events.emit('postcollision', new PostCollisionEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), contact.mtv.negate()));
119
+ contact.colliderB.events.emit('aftercollisionresolve', new CollisionPostSolveEvent(contact.colliderB, contact.colliderA, Side.getOpposite(side), contact.mtv.negate(), contact));
120
+ }
121
+ // Store contacts
122
+ this.lastFrameContacts.clear();
123
+ for (const c of contacts) {
124
+ this.lastFrameContacts.set(c.id, c);
125
+ }
126
+ }
127
+ /**
128
+ * Warm up body's based on previous frame contact points
129
+ * @param contacts
130
+ */
131
+ warmStart(contacts) {
132
+ var _a, _b, _c;
133
+ for (const contact of contacts) {
134
+ const bodyA = (_a = contact.colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
135
+ const bodyB = (_b = contact.colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
136
+ if (bodyA && bodyB) {
137
+ const contactPoints = (_c = this.idToContactConstraint.get(contact.id)) !== null && _c !== void 0 ? _c : [];
138
+ for (const point of contactPoints) {
139
+ if (Physics.warmStart) {
140
+ const normalImpulse = contact.normal.scale(point.normalImpulse);
141
+ const tangentImpulse = contact.tangent.scale(point.tangentImpulse);
142
+ const impulse = normalImpulse.add(tangentImpulse);
143
+ bodyA.applyImpulse(point.point, impulse.negate());
144
+ bodyB.applyImpulse(point.point, impulse);
145
+ }
146
+ else {
147
+ point.normalImpulse = 0;
148
+ point.tangentImpulse = 0;
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+ /**
155
+ * Iteratively solve the position overlap constraint
156
+ * @param contacts
157
+ */
158
+ solvePosition(contacts) {
159
+ var _a, _b, _c;
160
+ for (let i = 0; i < Physics.positionIterations; i++) {
161
+ for (const contact of contacts) {
162
+ const bodyA = (_a = contact.colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
163
+ const bodyB = (_b = contact.colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
164
+ if (bodyA && bodyB) {
165
+ // Skip solving active+passive
166
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
167
+ continue;
168
+ }
169
+ const constraints = (_c = this.idToContactConstraint.get(contact.id)) !== null && _c !== void 0 ? _c : [];
170
+ for (const point of constraints) {
171
+ const normal = contact.normal;
172
+ const separation = CollisionJumpTable.FindContactSeparation(contact, point.local);
173
+ const steeringConstant = Physics.steeringFactor; //0.2;
174
+ const maxCorrection = -5;
175
+ const slop = Physics.slop; //1;
176
+ // Clamp to avoid over-correction
177
+ // Remember that we are shooting for 0 overlap in the end
178
+ const steeringForce = clamp(steeringConstant * (separation + slop), maxCorrection, 0);
179
+ const impulse = normal.scale(-steeringForce / point.normalMass);
180
+ // This is a pseudo impulse, meaning we aren't doing a real impulse calculation
181
+ // We adjust position and rotation instead of doing the velocity
182
+ if (bodyA.collisionType === CollisionType.Active) {
183
+ bodyA.pos = bodyA.pos.add(impulse.negate().scale(bodyA.inverseMass));
184
+ bodyA.rotation -= point.aToContact.cross(impulse) * bodyA.inverseInertia;
185
+ }
186
+ if (bodyB.collisionType === CollisionType.Active) {
187
+ bodyB.pos = bodyB.pos.add(impulse.scale(bodyB.inverseMass));
188
+ bodyB.rotation += point.bToContact.cross(impulse) * bodyB.inverseInertia;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ solveVelocity(contacts) {
196
+ var _a, _b, _c;
197
+ for (let i = 0; i < Physics.velocityIterations; i++) {
198
+ for (const contact of contacts) {
199
+ const bodyA = (_a = contact.colliderA.owner) === null || _a === void 0 ? void 0 : _a.get(BodyComponent);
200
+ const bodyB = (_b = contact.colliderB.owner) === null || _b === void 0 ? void 0 : _b.get(BodyComponent);
201
+ if (bodyA && bodyB) {
202
+ // Skip solving active+passive
203
+ if (bodyA.collisionType === CollisionType.Passive || bodyB.collisionType === CollisionType.Passive) {
204
+ continue;
205
+ }
206
+ const restitution = bodyA.bounciness * bodyB.bounciness;
207
+ const friction = Math.min(bodyA.friction, bodyB.friction);
208
+ const constraints = (_c = this.idToContactConstraint.get(contact.id)) !== null && _c !== void 0 ? _c : [];
209
+ for (const point of constraints) {
210
+ const relativeVelocity = point.getRelativeVelocity();
211
+ // Negate velocity in tangent direction to simulate friction
212
+ const tangentVelocity = -relativeVelocity.dot(contact.tangent);
213
+ let impulseDelta = tangentVelocity / point.tangentMass;
214
+ // Clamping based in Erin Catto's GDC 2006 talk
215
+ // Correct clamping https://github.com/erincatto/box2d-lite/blob/master/docs/GDC2006_Catto_Erin_PhysicsTutorial.pdf
216
+ // Accumulated fiction impulse is always between -uMaxFriction < dT < uMaxFriction
217
+ // But deltas can vary
218
+ const maxFriction = friction * point.normalImpulse;
219
+ const newImpulse = clamp(point.tangentImpulse + impulseDelta, -maxFriction, maxFriction);
220
+ impulseDelta = newImpulse - point.tangentImpulse;
221
+ point.tangentImpulse = newImpulse;
222
+ const impulse = contact.tangent.scale(impulseDelta);
223
+ bodyA.applyImpulse(point.point, impulse.negate());
224
+ bodyB.applyImpulse(point.point, impulse);
225
+ }
226
+ for (const point of constraints) {
227
+ // Need to recalc relative velocity because the previous step could have changed vel
228
+ const relativeVelocity = point.getRelativeVelocity();
229
+ // Compute impulse in normal direction
230
+ const normalVelocity = relativeVelocity.dot(contact.normal);
231
+ // See https://en.wikipedia.org/wiki/Collision_response
232
+ let impulseDelta = (-(1 + restitution) * normalVelocity) / point.normalMass;
233
+ // Clamping based in Erin Catto's GDC 2014 talk
234
+ // Accumulated impulse stored in the contact is always positive (dV > 0)
235
+ // But deltas can be negative
236
+ const newImpulse = Math.max(point.normalImpulse + impulseDelta, 0);
237
+ impulseDelta = newImpulse - point.normalImpulse;
238
+ point.normalImpulse = newImpulse;
239
+ const impulse = contact.normal.scale(impulseDelta);
240
+ bodyA.applyImpulse(point.point, impulse.negate());
241
+ bodyB.applyImpulse(point.point, impulse);
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ //# sourceMappingURL=RealisticSolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RealisticSolver.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Solver/RealisticSolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,MAAM,OAAO,eAAgB,SAAQ,eAAe;IAApD;;QACE,sBAAiB,GAAkC,IAAI,GAAG,EAAE,CAAC;QAE7D,mCAAmC;QACnC,0BAAqB,GAA0C,IAAI,GAAG,EAAE,CAAC;IA4R3E,CAAC;IA1RC,qBAAqB,CAAC,EAAU;;QAC9B,OAAO,MAAA,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,mCAAI,EAAE,CAAC;IAClD,CAAC;IAED,QAAQ,CAAC,QAA4B;;QACnC,KAAK,MAAM,OAAO,I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ACnE,YAAY,GAAG,UAAU,GAAG,KAAK,CAAC,aAAa,CAAC;wBAChD,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;wBAEjC,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;wBACnD,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;wBAClD,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;qBAC1C;iBACF;aACF;SACF;IACH,CAAC;CACF"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * A collision solver figures out how to position colliders such that they are no longer overlapping
3
+ *
4
+ * Solvers are executed in the order
5
+ *
6
+ * 1. preSolve
7
+ * 2. solveVelocity
8
+ * 3. solvePosition
9
+ * 4. postSolve
10
+ * @inheritdoc
11
+ */
12
+ export class CollisionSolver {
13
+ /**
14
+ * Solves overlapping contact in
15
+ *
16
+ * Solvers are executed in the order
17
+ * 1. preSolve
18
+ * 2. solveVelocity
19
+ * 3. solvePosition
20
+ * 4. postSolve
21
+ * @param contacts
22
+ */
23
+ solve(contacts) {
24
+ // Events and init
25
+ this.preSolve(contacts);
26
+ // Remove any canceled contacts
27
+ contacts = contacts.filter(c => !c.isCanceled());
28
+ // Solve velocity first
29
+ this.solveVelocity(contacts);
30
+ // Solve position last because non-overlap is the most important
31
+ this.solvePosition(contacts);
32
+ // Events and any contact house-keeping the solver needs
33
+ this.postSolve(contacts);
34
+ return contacts;
35
+ }
36
+ }
37
+ //# sourceMappingURL=Solver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Solver.js","sourceRoot":"","sources":["../../../../src/engine/Collision/Solver/Solver.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,OAAgB,eAAe;IA8BnC;;;;;;;;;OASG;IACI,KAAK,CAAC,QAA4B;QACvC,kBAAkB;QAClB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAExB,+BAA+B;QAC/B,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;QAEjD,uBAAuB;QACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAE7B,gEAAgE;QAChE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAE7B,wDAAwD;QACxD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}