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,361 @@
1
+ import { Vector } from '../Math/vector';
2
+ import { Color } from '../Color';
3
+ import { Side } from './Side';
4
+ /**
5
+ * Axis Aligned collision primitive for Excalibur.
6
+ */
7
+ export class BoundingBox {
8
+ /**
9
+ * Constructor allows passing of either an object with all coordinate components,
10
+ * or the coordinate components passed separately.
11
+ * @param leftOrOptions Either x coordinate of the left edge or an options object
12
+ * containing the four coordinate components.
13
+ * @param top y coordinate of the top edge
14
+ * @param right x coordinate of the right edge
15
+ * @param bottom y coordinate of the bottom edge
16
+ */
17
+ constructor(leftOrOptions = 0, top = 0, right = 0, bottom = 0) {
18
+ if (typeof leftOrOptions === 'object') {
19
+ this.left = leftOrOptions.left;
20
+ this.top = leftOrOptions.top;
21
+ this.right = leftOrOptions.right;
22
+ this.bottom = leftOrOptions.bottom;
23
+ }
24
+ else if (typeof leftOrOptions === 'number') {
25
+ this.left = leftOrOptions;
26
+ this.top = top;
27
+ this.right = right;
28
+ this.bottom = bottom;
29
+ }
30
+ }
31
+ /**
32
+ * Given bounding box A & B, returns the side relative to A when intersection is performed.
33
+ * @param intersection Intersection vector between 2 bounding boxes
34
+ */
35
+ static getSideFromIntersection(intersection) {
36
+ if (!intersection) {
37
+ return Side.None;
38
+ }
39
+ if (intersection) {
40
+ if (Math.abs(intersection.x) > Math.abs(intersection.y)) {
41
+ if (intersection.x < 0) {
42
+ return Side.Right;
43
+ }
44
+ return Side.Left;
45
+ }
46
+ else {
47
+ if (intersection.y < 0) {
48
+ return Side.Bottom;
49
+ }
50
+ return Side.Top;
51
+ }
52
+ }
53
+ return Side.None;
54
+ }
55
+ static fromPoints(points) {
56
+ let minX = Infinity;
57
+ let minY = Infinity;
58
+ let maxX = -Infinity;
59
+ let maxY = -Infinity;
60
+ for (let i = 0; i < points.length; i++) {
61
+ if (points[i].x < minX) {
62
+ minX = points[i].x;
63
+ }
64
+ if (points[i].x > maxX) {
65
+ maxX = points[i].x;
66
+ }
67
+ if (points[i].y < minY) {
68
+ minY = points[i].y;
69
+ }
70
+ if (points[i].y > maxY) {
71
+ maxY = points[i].y;
72
+ }
73
+ }
74
+ return new BoundingBox(minX, minY, maxX, maxY);
75
+ }
76
+ static fromDimension(width, height, anchor = Vector.Half, pos = Vector.Zero) {
77
+ return new BoundingBox(-width * anchor.x + pos.x, -height * anchor.y + pos.y, width - width * anchor.x + pos.x, height - height * anchor.y + pos.y);
78
+ }
79
+ /**
80
+ * Returns the calculated width of the bounding box
81
+ */
82
+ get width() {
83
+ return this.right - this.left;
84
+ }
85
+ /**
86
+ * Returns the calculated height of the bounding box
87
+ */
88
+ get height() {
89
+ return this.bottom - this.top;
90
+ }
91
+ /**
92
+ * Return whether the bounding box has zero dimensions in height,width or both
93
+ */
94
+ hasZeroDimensions() {
95
+ return this.width === 0 || this.height === 0;
96
+ }
97
+ /**
98
+ * Returns the center of the bounding box
99
+ */
100
+ get center() {
101
+ return new Vector((this.left + this.right) / 2, (this.top + this.bottom) / 2);
102
+ }
103
+ translate(pos) {
104
+ return new BoundingBox(this.left + pos.x, this.top + pos.y, this.right + pos.x, this.bottom + pos.y);
105
+ }
106
+ /**
107
+ * Rotates a bounding box by and angle and around a point, if no point is specified (0, 0) is used by default. The resulting bounding
108
+ * box is also axis-align. This is useful when a new axis-aligned bounding box is needed for rotated geometry.
109
+ */
110
+ rotate(angle, point = Vector.Zero) {
111
+ const points = this.getPoints().map((p) => p.rotate(angle, point));
112
+ return BoundingBox.fromPoints(points);
113
+ }
114
+ scale(scale, point = Vector.Zero) {
115
+ const shifted = this.translate(point);
116
+ return new BoundingBox(shifted.left * scale.x, shifted.top * scale.y, shifted.right * scale.x, shifted.bottom * scale.y);
117
+ }
118
+ transform(matrix) {
119
+ const points = this.getPoints().map((p) => matrix.multv(p));
120
+ return BoundingBox.fromPoints(points);
121
+ }
122
+ /**
123
+ * Returns the perimeter of the bounding box
124
+ */
125
+ getPerimeter() {
126
+ const wx = this.width;
127
+ const wy = this.height;
128
+ return 2 * (wx + wy);
129
+ }
130
+ getPoints() {
131
+ const results = [];
132
+ results.push(new Vector(this.left, this.top));
133
+ results.push(new Vector(this.right, this.top));
134
+ results.push(new Vector(this.right, this.bottom));
135
+ results.push(new Vector(this.left, this.bottom));
136
+ return results;
137
+ }
138
+ /**
139
+ * Determines whether a ray intersects with a bounding box
140
+ */
141
+ rayCast(ray, farClipDistance = Infinity) {
142
+ // algorithm from https://tavianator.com/fast-branchless-raybounding-box-intersections/
143
+ let tmin = -Infinity;
144
+ let tmax = +Infinity;
145
+ const xinv = ray.dir.x === 0 ? Number.MAX_VALUE : 1 / ray.dir.x;
146
+ const yinv = ray.dir.y === 0 ? Number.MAX_VALUE : 1 / ray.dir.y;
147
+ const tx1 = (this.left - ray.pos.x) * xinv;
148
+ const tx2 = (this.right - ray.pos.x) * xinv;
149
+ tmin = Math.min(tx1, tx2);
150
+ tmax = Math.max(tx1, tx2);
151
+ const ty1 = (this.top - ray.pos.y) * yinv;
152
+ const ty2 = (this.bottom - ray.pos.y) * yinv;
153
+ tmin = Math.max(tmin, Math.min(ty1, ty2));
154
+ tmax = Math.min(tmax, Math.max(ty1, ty2));
155
+ return tmax >= Math.max(0, tmin) && tmin < farClipDistance;
156
+ }
157
+ rayCastTime(ray, farClipDistance = Infinity) {
158
+ // algorithm from https://tavianator.com/fast-branchless-raybounding-box-intersections/
159
+ let tmin = -Infinity;
160
+ let tmax = +Infinity;
161
+ const xinv = ray.dir.x === 0 ? Number.MAX_VALUE : 1 / ray.dir.x;
162
+ const yinv = ray.dir.y === 0 ? Number.MAX_VALUE : 1 / ray.dir.y;
163
+ const tx1 = (this.left - ray.pos.x) * xinv;
164
+ const tx2 = (this.right - ray.pos.x) * xinv;
165
+ tmin = Math.min(tx1, tx2);
166
+ tmax = Math.max(tx1, tx2);
167
+ const ty1 = (this.top - ray.pos.y) * yinv;
168
+ const ty2 = (this.bottom - ray.pos.y) * yinv;
169
+ tmin = Math.max(tmin, Math.min(ty1, ty2));
170
+ tmax = Math.min(tmax, Math.max(ty1, ty2));
171
+ if (tmax >= Math.max(0, tmin) && tmin < farClipDistance) {
172
+ return tmin;
173
+ }
174
+ return -1;
175
+ }
176
+ contains(val) {
177
+ if (val instanceof Vector) {
178
+ return this.left <= val.x && this.top <= val.y && this.bottom >= val.y && this.right >= val.x;
179
+ }
180
+ else if (val instanceof BoundingBox) {
181
+ if (this.left < val.left && this.top < val.top && val.bottom < this.bottom && val.right < this.right) {
182
+ return true;
183
+ }
184
+ return false;
185
+ }
186
+ return false;
187
+ }
188
+ /**
189
+ * Combines this bounding box and another together returning a new bounding box
190
+ * @param other The bounding box to combine
191
+ */
192
+ combine(other) {
193
+ const compositeBB = new BoundingBox(Math.min(this.left, other.left), Math.min(this.top, other.top), Math.max(this.right, other.right), Math.max(this.bottom, other.bottom));
194
+ return compositeBB;
195
+ }
196
+ get dimensions() {
197
+ return new Vector(this.width, this.height);
198
+ }
199
+ /**
200
+ * Test wether this bounding box intersects with another returning
201
+ * the intersection vector that can be used to resolve the collision. If there
202
+ * is no intersection null is returned.
203
+ *
204
+ * @param other Other [[BoundingBox]] to test intersection with
205
+ * @returns A Vector in the direction of the current BoundingBox, this <- other
206
+ */
207
+ intersect(other) {
208
+ const totalBoundingBox = this.combine(other);
209
+ // If the total bounding box is less than or equal the sum of the 2 bounds then there is collision
210
+ if (totalBoundingBox.width < other.width + this.width &&
211
+ totalBoundingBox.height < other.height + this.height &&
212
+ !totalBoundingBox.dimensions.equals(other.dimensions) &&
213
+ !totalBoundingBox.dimensions.equals(this.dimensions)) {
214
+ // collision
215
+ let overlapX = 0;
216
+ // right edge is between the other's left and right edge
217
+ /**
218
+ * +-this-+
219
+ * | |
220
+ * | +-other-+
221
+ * +----|-+ |
222
+ * | |
223
+ * +-------+
224
+ * <---
225
+ * ^ overlap
226
+ */
227
+ if (this.right >= other.left && this.right <= other.right) {
228
+ overlapX = other.left - this.right;
229
+ // right edge is past the other's right edge
230
+ /**
231
+ * +-other-+
232
+ * | |
233
+ * | +-this-+
234
+ * +----|--+ |
235
+ * | |
236
+ * +------+
237
+ * --->
238
+ * ^ overlap
239
+ */
240
+ }
241
+ else {
242
+ overlapX = other.right - this.left;
243
+ }
244
+ let overlapY = 0;
245
+ // top edge is between the other's top and bottom edge
246
+ /**
247
+ * +-other-+
248
+ * | |
249
+ * | +-this-+ | <- overlap
250
+ * +----|--+ | |
251
+ * | | \ /
252
+ * +------+ '
253
+ */
254
+ if (this.top <= other.bottom && this.top >= other.top) {
255
+ overlapY = other.bottom - this.top;
256
+ // top edge is above the other top edge
257
+ /**
258
+ * +-this-+ .
259
+ * | | / \
260
+ * | +-other-+ | <- overlap
261
+ * +----|-+ | |
262
+ * | |
263
+ * +-------+
264
+ */
265
+ }
266
+ else {
267
+ overlapY = other.top - this.bottom;
268
+ }
269
+ if (Math.abs(overlapX) < Math.abs(overlapY)) {
270
+ return new Vector(overlapX, 0);
271
+ }
272
+ else {
273
+ return new Vector(0, overlapY);
274
+ }
275
+ // Case of total containment of one bounding box by another
276
+ }
277
+ else if (totalBoundingBox.dimensions.equals(other.dimensions) || totalBoundingBox.dimensions.equals(this.dimensions)) {
278
+ let overlapX = 0;
279
+ // this is wider than the other
280
+ if (this.width - other.width >= 0) {
281
+ // This right edge is closest to the others right edge
282
+ if (this.right - other.right <= other.left - this.left) {
283
+ overlapX = other.left - this.right;
284
+ // This left edge is closest to the others left edge
285
+ }
286
+ else {
287
+ overlapX = other.right - this.left;
288
+ }
289
+ // other is wider than this
290
+ }
291
+ else {
292
+ // This right edge is closest to the others right edge
293
+ if (other.right - this.right <= this.left - other.left) {
294
+ overlapX = this.left - other.right;
295
+ // This left edge is closest to the others left edge
296
+ }
297
+ else {
298
+ overlapX = this.right - other.left;
299
+ }
300
+ }
301
+ let overlapY = 0;
302
+ // this is taller than other
303
+ if (this.height - other.height >= 0) {
304
+ // The bottom edge is closest to the others bottom edge
305
+ if (this.bottom - other.bottom <= other.top - this.top) {
306
+ overlapY = other.top - this.bottom;
307
+ }
308
+ else {
309
+ overlapY = other.bottom - this.top;
310
+ }
311
+ // other is taller than this
312
+ }
313
+ else {
314
+ // The bottom edge is closest to the others bottom edge
315
+ if (other.bottom - this.bottom <= this.top - other.top) {
316
+ overlapY = this.top - other.bottom;
317
+ }
318
+ else {
319
+ overlapY = this.bottom - other.top;
320
+ }
321
+ }
322
+ if (Math.abs(overlapX) < Math.abs(overlapY)) {
323
+ return new Vector(overlapX, 0);
324
+ }
325
+ else {
326
+ return new Vector(0, overlapY);
327
+ }
328
+ }
329
+ else {
330
+ return null;
331
+ }
332
+ }
333
+ /**
334
+ * Test whether the bounding box has intersected with another bounding box, returns the side of the current bb that intersected.
335
+ * @param bb The other actor to test
336
+ */
337
+ intersectWithSide(bb) {
338
+ const intersect = this.intersect(bb);
339
+ return BoundingBox.getSideFromIntersection(intersect);
340
+ }
341
+ /**
342
+ *
343
+ * @deprecated signature will change in v0.26.0
344
+ * @param ctx
345
+ * @param color
346
+ */
347
+ /* istanbul ignore next */
348
+ debugDraw(ctx, color = Color.Yellow) {
349
+ ctx.strokeStyle = color.toString();
350
+ ctx.strokeRect(this.left, this.top, this.width, this.height);
351
+ }
352
+ /**
353
+ * Draw a debug bounding box
354
+ * @param ex
355
+ * @param color
356
+ */
357
+ draw(ex, color = Color.Yellow) {
358
+ ex.debug.drawRect(this.left, this.top, this.width, this.height, { color });
359
+ }
360
+ }
361
+ //# sourceMappingURL=BoundingBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BoundingBox.js","sourceRoot":"","sources":["../../../src/engine/Collision/BoundingBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAW9B;;GAEG;AACH,MAAM,OAAO,WAAW;IAMtB;;;;;;;;OAQG;IACH,YAAY,gBAA6C,CAAC,EAAE,MAAc,CAAC,EAAE,QAAgB,CAAC,EAAE,SAAiB,CAAC;QAChH,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACrC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YAC/B,IAAI,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK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AA6B,EAAE,QAAe,KAAK,CAAC,MAAM;QACzE,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACI,IAAI,CAAC,EAA4B,EAAE,QAAe,KAAK,CAAC,MAAM;QACnE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;CACF"}
@@ -0,0 +1,198 @@
1
+ import { Vector } from '../Math/vector';
2
+ import { TransformComponent } from '../EntityComponentSystem';
3
+ import { Component } from '../EntityComponentSystem/Component';
4
+ import { EventDispatcher } from '../EventDispatcher';
5
+ import { CollisionEndEvent, CollisionStartEvent, PostCollisionEvent, PreCollisionEvent } from '../Events';
6
+ import { Observable } from '../Util/Observable';
7
+ import { BoundingBox } from './BoundingBox';
8
+ import { CompositeCollider } from './Colliders/CompositeCollider';
9
+ import { Shape } from './Colliders/Shape';
10
+ export class ColliderComponent extends Component {
11
+ constructor(collider) {
12
+ super();
13
+ this.type = 'ex.collider';
14
+ this.events = new EventDispatcher();
15
+ /**
16
+ * Observable that notifies when a collider is added to the body
17
+ */
18
+ this.$colliderAdded = new Observable();
19
+ /**
20
+ * Observable that notifies when a collider is removed from the body
21
+ */
22
+ this.$colliderRemoved = new Observable();
23
+ this.set(collider);
24
+ }
25
+ /**
26
+ * Get the current collider geometry
27
+ */
28
+ get() {
29
+ return this._collider;
30
+ }
31
+ /**
32
+ * Set the collider geometry
33
+ * @param collider
34
+ * @returns the collider you set
35
+ */
36
+ set(collider) {
37
+ this.clear();
38
+ if (collider) {
39
+ this._collider = collider;
40
+ this._collider.owner = this.owner;
41
+ this.events.wire(collider.events);
42
+ this.$colliderAdded.notifyAll(collider);
43
+ this.update();
44
+ }
45
+ return collider;
46
+ }
47
+ /**
48
+ * Remove collider geometry from collider component
49
+ */
50
+ clear() {
51
+ if (this._collider) {
52
+ this.events.unwire(this._collider.events);
53
+ this.$colliderRemoved.notifyAll(this._collider);
54
+ this._collider.owner = null;
55
+ this._collider = null;
56
+ }
57
+ }
58
+ /**
59
+ * Return world space bounds
60
+ */
61
+ get bounds() {
62
+ var _a, _b;
63
+ return (_b = (_a = this._collider) === null || _a === void 0 ? void 0 : _a.bounds) !== null && _b !== void 0 ? _b : new BoundingBox();
64
+ }
65
+ /**
66
+ * Return local space bounds
67
+ */
68
+ get localBounds() {
69
+ var _a, _b;
70
+ return (_b = (_a = this._collider) === null || _a === void 0 ? void 0 : _a.localBounds) !== null && _b !== void 0 ? _b : new BoundingBox();
71
+ }
72
+ /**
73
+ * Update the collider's transformed geometry
74
+ */
75
+ update() {
76
+ var _a;
77
+ const tx = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.get(TransformComponent);
78
+ if (this._collider) {
79
+ this._collider.owner = this.owner;
80
+ if (tx) {
81
+ this._collider.update(tx);
82
+ }
83
+ }
84
+ }
85
+ /**
86
+ * Collide component with another
87
+ * @param other
88
+ */
89
+ collide(other) {
90
+ let colliderA = this._collider;
91
+ let colliderB = other._collider;
92
+ if (!colliderA || !colliderB) {
93
+ return [];
94
+ }
95
+ // If we have a composite lefthand side :(
96
+ // Might bite us, but to avoid updating all the handlers make composite always left side
97
+ let flipped = false;
98
+ if (colliderB instanceof CompositeCollider) {
99
+ colliderA = colliderB;
100
+ colliderB = this._collider;
101
+ flipped = true;
102
+ }
103
+ if (this._collider) {
104
+ const contacts = colliderA.collide(colliderB);
105
+ if (contacts) {
106
+ if (flipped) {
107
+ contacts.forEach((contact) => {
108
+ contact.mtv = contact.mtv.negate();
109
+ contact.normal = contact.normal.negate();
110
+ contact.tangent = contact.normal.perpendicular();
111
+ contact.colliderA = this._collider;
112
+ contact.colliderB = other._collider;
113
+ });
114
+ }
115
+ return contacts;
116
+ }
117
+ return [];
118
+ }
119
+ return [];
120
+ }
121
+ onAdd(entity) {
122
+ if (this._collider) {
123
+ this.update();
124
+ }
125
+ // Wire up the collider events to the owning entity
126
+ this.events.on('precollision', (evt) => {
127
+ const precollision = evt;
128
+ entity.events.emit('precollision', new PreCollisionEvent(precollision.target.owner, precollision.other.owner, precollision.side, precollision.intersection));
129
+ });
130
+ this.events.on('postcollision', (evt) => {
131
+ const postcollision = evt;
132
+ entity.events.emit('postcollision', new PostCollisionEvent(postcollision.target.owner, postcollision.other.owner, postcollision.side, postcollision.intersection));
133
+ });
134
+ this.events.on('collisionstart', (evt) => {
135
+ const start = evt;
136
+ entity.events.emit('collisionstart', new CollisionStartEvent(start.target.owner, start.other.owner, start.contact));
137
+ });
138
+ this.events.on('collisionend', (evt) => {
139
+ const end = evt;
140
+ entity.events.emit('collisionend', new CollisionEndEvent(end.target.owner, end.other.owner));
141
+ });
142
+ }
143
+ onRemove() {
144
+ this.events.clear();
145
+ this.$colliderRemoved.notifyAll(this._collider);
146
+ }
147
+ /**
148
+ * Sets up a box geometry based on the current bounds of the associated actor of this physics body.
149
+ *
150
+ * If no width/height are specified the body will attempt to use the associated actor's width/height.
151
+ *
152
+ * By default, the box is center is at (0, 0) which means it is centered around the actors anchor.
153
+ */
154
+ useBoxCollider(width, height, anchor = Vector.Half, center = Vector.Zero) {
155
+ const collider = Shape.Box(width, height, anchor, center);
156
+ return (this.set(collider));
157
+ }
158
+ /**
159
+ * Sets up a [[PolygonCollider|polygon]] collision geometry based on a list of of points relative
160
+ * to the anchor of the associated actor
161
+ * of this physics body.
162
+ *
163
+ * Only [convex polygon](https://en.wikipedia.org/wiki/Convex_polygon) definitions are supported.
164
+ *
165
+ * By default, the box is center is at (0, 0) which means it is centered around the actors anchor.
166
+ */
167
+ usePolygonCollider(points, center = Vector.Zero) {
168
+ const poly = Shape.Polygon(points, false, center);
169
+ return (this.set(poly));
170
+ }
171
+ /**
172
+ * Sets up a [[Circle|circle collision geometry]] as the only collider with a specified radius in pixels.
173
+ *
174
+ * By default, the box is center is at (0, 0) which means it is centered around the actors anchor.
175
+ */
176
+ useCircleCollider(radius, center = Vector.Zero) {
177
+ const collider = Shape.Circle(radius, center);
178
+ return (this.set(collider));
179
+ }
180
+ /**
181
+ * Sets up an [[Edge|edge collision geometry]] with a start point and an end point relative to the anchor of the associated actor
182
+ * of this physics body.
183
+ *
184
+ * By default, the box is center is at (0, 0) which means it is centered around the actors anchor.
185
+ */
186
+ useEdgeCollider(begin, end) {
187
+ const collider = Shape.Edge(begin, end);
188
+ return (this.set(collider));
189
+ }
190
+ /**
191
+ * Setups up a [[CompositeCollider]] which can define any arbitrary set of excalibur colliders
192
+ * @param colliders
193
+ */
194
+ useCompositeCollider(colliders) {
195
+ return (this.set(new CompositeCollider(colliders)));
196
+ }
197
+ }
198
+ //# sourceMappingURL=ColliderComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColliderComponent.js","sourceRoot":"","sources":["../../../src/engine/Collision/ColliderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,KAAK,EAAE,M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