excalibur 0.28.3 → 0.28.4

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 (482) hide show
  1. package/.gitattributes +63 -63
  2. package/CHANGELOG.md +2003 -1955
  3. package/LICENSE.md +25 -25
  4. package/README.md +134 -134
  5. package/STYLEGUIDE.md +136 -136
  6. package/build/dist/Actions/Action/ActionSequence.js +31 -0
  7. package/build/dist/Actions/Action/ActionSequence.js.map +1 -0
  8. package/build/dist/Actions/Action/Blink.js +54 -0
  9. package/build/dist/Actions/Action/Blink.js.map +1 -0
  10. package/build/dist/Actions/Action/CallMethod.js +21 -0
  11. package/build/dist/Actions/Action/CallMethod.js.map +1 -0
  12. package/build/dist/Actions/Action/Delay.js +26 -0
  13. package/build/dist/Actions/Action/Delay.js.map +1 -0
  14. package/build/dist/Actions/Action/Die.js +22 -0
  15. package/build/dist/Actions/Action/Die.js.map +1 -0
  16. package/build/dist/Actions/Action/EaseBy.js +70 -0
  17. package/build/dist/Actions/Action/EaseBy.js.map +1 -0
  18. package/build/dist/Actions/Action/EaseTo.js +69 -0
  19. package/build/dist/Actions/Action/EaseTo.js.map +1 -0
  20. package/build/dist/Actions/Action/Fade.js +48 -0
  21. package/build/dist/Actions/Action/Fade.js.map +1 -0
  22. package/build/dist/Actions/Action/Follow.js +56 -0
  23. package/build/dist/Actions/Action/Follow.js.map +1 -0
  24. package/build/dist/Actions/Action/Meet.js +54 -0
  25. package/build/dist/Actions/Action/Meet.js.map +1 -0
  26. package/build/dist/Actions/Action/MoveBy.js +48 -0
  27. package/build/dist/Actions/Action/MoveBy.js.map +1 -0
  28. package/build/dist/Actions/Action/MoveTo.js +41 -0
  29. package/build/dist/Actions/Action/MoveTo.js.map +1 -0
  30. package/build/dist/Actions/Action/ParallelActions.js +23 -0
  31. package/build/dist/Actions/Action/ParallelActions.js.map +1 -0
  32. package/build/dist/Actions/Action/Repeat.js +31 -0
  33. package/build/dist/Actions/Action/Repeat.js.map +1 -0
  34. package/build/dist/Actions/Action/RepeatForever.js +37 -0
  35. package/build/dist/Actions/Action/RepeatForever.js.map +1 -0
  36. package/build/dist/Actions/Action/RotateBy.js +95 -0
  37. package/build/dist/Actions/Action/RotateBy.js.map +1 -0
  38. package/build/dist/Actions/Action/RotateTo.js +91 -0
  39. package/build/dist/Actions/Action/RotateTo.js.map +1 -0
  40. package/build/dist/Actions/Action/ScaleBy.js +46 -0
  41. package/build/dist/Actions/Action/ScaleBy.js.map +1 -0
  42. package/build/dist/Actions/Action/ScaleTo.js +58 -0
  43. package/build/dist/Actions/Action/ScaleTo.js.map +1 -0
  44. package/build/dist/Actions/Action.js +2 -0
  45. package/build/dist/Actions/Action.js.map +1 -0
  46. package/build/dist/Actions/ActionContext.js +322 -0
  47. package/build/dist/Actions/ActionContext.js.map +1 -0
  48. package/build/dist/Actions/ActionQueue.js +87 -0
  49. package/build/dist/Actions/ActionQueue.js.map +1 -0
  50. package/build/dist/Actions/Actionable.js +2 -0
  51. package/build/dist/Actions/Actionable.js.map +1 -0
  52. package/build/dist/Actions/ActionsComponent.js +195 -0
  53. package/build/dist/Actions/ActionsComponent.js.map +1 -0
  54. package/build/dist/Actions/ActionsSystem.js +30 -0
  55. package/build/dist/Actions/ActionsSystem.js.map +1 -0
  56. package/build/dist/Actions/Index.js +26 -0
  57. package/build/dist/Actions/Index.js.map +1 -0
  58. package/build/dist/Actions/RotationType.js +27 -0
  59. package/build/dist/Actions/RotationType.js.map +1 -0
  60. package/build/dist/Actor.js +629 -0
  61. package/build/dist/Actor.js.map +1 -0
  62. package/build/dist/Camera.js +660 -0
  63. package/build/dist/Camera.js.map +1 -0
  64. package/build/dist/Collision/BoundingBox.js +415 -0
  65. package/build/dist/Collision/BoundingBox.js.map +1 -0
  66. package/build/dist/Collision/ColliderComponent.js +202 -0
  67. package/build/dist/Collision/ColliderComponent.js.map +1 -0
  68. package/build/dist/Collision/Colliders/CircleCollider.js +226 -0
  69. package/build/dist/Collision/Colliders/CircleCollider.js.map +1 -0
  70. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js +211 -0
  71. package/build/dist/Collision/Colliders/ClosestLineJumpTable.js.map +1 -0
  72. package/build/dist/Collision/Colliders/Collider.js +32 -0
  73. package/build/dist/Collision/Colliders/Collider.js.map +1 -0
  74. package/build/dist/Collision/Colliders/CollisionJumpTable.js +300 -0
  75. package/build/dist/Collision/Colliders/CollisionJumpTable.js.map +1 -0
  76. package/build/dist/Collision/Colliders/EdgeCollider.js +229 -0
  77. package/build/dist/Collision/Colliders/EdgeCollider.js.map +1 -0
  78. package/build/dist/Collision/Colliders/PolygonCollider.js +556 -0
  79. package/build/dist/Collision/Colliders/PolygonCollider.js.map +1 -0
  80. package/build/dist/Collision/Colliders/SeparatingAxis.js +67 -0
  81. package/build/dist/Collision/Colliders/SeparatingAxis.js.map +1 -0
  82. package/build/dist/Collision/Colliders/Shape.js +99 -0
  83. package/build/dist/Collision/Colliders/Shape.js.map +1 -0
  84. package/build/dist/Collision/CollisionType.js +33 -0
  85. package/build/dist/Collision/CollisionType.js.map +1 -0
  86. package/build/dist/Collision/Detection/CollisionContact.js +51 -0
  87. package/build/dist/Collision/Detection/CollisionContact.js.map +1 -0
  88. package/build/dist/Collision/Detection/CollisionProcessor.js +2 -0
  89. package/build/dist/Collision/Detection/CollisionProcessor.js.map +1 -0
  90. package/build/dist/Collision/Detection/DynamicTree.js +442 -0
  91. package/build/dist/Collision/Detection/DynamicTree.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/Detection/QuadTree.js +193 -0
  95. package/build/dist/Collision/Detection/QuadTree.js.map +1 -0
  96. package/build/dist/Collision/Group/CollisionGroup.js +3 -3
  97. package/build/dist/Collision/Integrator.js +25 -0
  98. package/build/dist/Collision/Integrator.js.map +1 -0
  99. package/build/dist/Collision/MotionSystem.js +35 -0
  100. package/build/dist/Collision/MotionSystem.js.map +1 -0
  101. package/build/dist/Collision/Physics.js +163 -0
  102. package/build/dist/Collision/Physics.js.map +1 -0
  103. package/build/dist/Collision/PhysicsWorld.js +10 -0
  104. package/build/dist/Collision/PhysicsWorld.js.map +1 -0
  105. package/build/dist/Collision/Side.js +51 -0
  106. package/build/dist/Collision/Side.js.map +1 -0
  107. package/build/dist/Collision/Solver/ArcadeSolver.js +154 -0
  108. package/build/dist/Collision/Solver/ArcadeSolver.js.map +1 -0
  109. package/build/dist/Collision/Solver/ContactConstraintPoint.js +87 -0
  110. package/build/dist/Collision/Solver/ContactConstraintPoint.js.map +1 -0
  111. package/build/dist/Collision/Solver/RealisticSolver.js +293 -0
  112. package/build/dist/Collision/Solver/RealisticSolver.js.map +1 -0
  113. package/build/dist/Collision/Solver/Solver.js +2 -0
  114. package/build/dist/Collision/Solver/Solver.js.map +1 -0
  115. package/build/dist/Color.js +417 -0
  116. package/build/dist/Color.js.map +1 -0
  117. package/build/dist/Configurable.js +32 -0
  118. package/build/dist/Configurable.js.map +1 -0
  119. package/build/dist/Debug/Debug.d.ts +11 -0
  120. package/build/dist/Debug/Debug.js +385 -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 +263 -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/Engine.js +986 -0
  131. package/build/dist/Engine.js.map +1 -0
  132. package/build/dist/EntityComponentSystem/Component.js +65 -0
  133. package/build/dist/EntityComponentSystem/Component.js.map +1 -0
  134. package/build/dist/EntityComponentSystem/Components/MotionComponent.js +33 -0
  135. package/build/dist/EntityComponentSystem/Components/MotionComponent.js.map +1 -0
  136. package/build/dist/EntityComponentSystem/Components/TransformComponent.js +107 -0
  137. package/build/dist/EntityComponentSystem/Components/TransformComponent.js.map +1 -0
  138. package/build/dist/EntityComponentSystem/Entity.js +487 -0
  139. package/build/dist/EntityComponentSystem/Entity.js.map +1 -0
  140. package/build/dist/EntityComponentSystem/EntityManager.js +137 -0
  141. package/build/dist/EntityComponentSystem/EntityManager.js.map +1 -0
  142. package/build/dist/EntityComponentSystem/Query.js +90 -0
  143. package/build/dist/EntityComponentSystem/Query.js.map +1 -0
  144. package/build/dist/EntityComponentSystem/QueryManager.js +90 -0
  145. package/build/dist/EntityComponentSystem/QueryManager.js.map +1 -0
  146. package/build/dist/EntityComponentSystem/System.js +76 -0
  147. package/build/dist/EntityComponentSystem/System.js.map +1 -0
  148. package/build/dist/EntityComponentSystem/SystemManager.js +104 -0
  149. package/build/dist/EntityComponentSystem/SystemManager.js.map +1 -0
  150. package/build/dist/EntityComponentSystem/Util.js +5 -0
  151. package/build/dist/EntityComponentSystem/Util.js.map +1 -0
  152. package/build/dist/EntityComponentSystem/World.js +55 -0
  153. package/build/dist/EntityComponentSystem/World.js.map +1 -0
  154. package/build/dist/EntityComponentSystem/index.js +11 -0
  155. package/build/dist/EntityComponentSystem/index.js.map +1 -0
  156. package/build/dist/EventDispatcher.js +122 -0
  157. package/build/dist/EventDispatcher.js.map +1 -0
  158. package/build/dist/EventEmitter.js +86 -0
  159. package/build/dist/EventEmitter.js.map +1 -0
  160. package/build/dist/Events/ExEvent.js +12 -0
  161. package/build/dist/Events/ExEvent.js.map +1 -0
  162. package/build/dist/Events/MediaEvents.js +75 -0
  163. package/build/dist/Events/MediaEvents.js.map +1 -0
  164. package/build/dist/Events/PointerEvents.js +52 -0
  165. package/build/dist/Events/PointerEvents.js.map +1 -0
  166. package/build/dist/Events.js +473 -0
  167. package/build/dist/Events.js.map +1 -0
  168. package/build/dist/Flags.js +67 -0
  169. package/build/dist/Flags.js.map +1 -0
  170. package/build/dist/Graphics/Animation.js +344 -0
  171. package/build/dist/Graphics/Animation.js.map +1 -0
  172. package/build/dist/Graphics/Canvas.js +38 -0
  173. package/build/dist/Graphics/Canvas.js.map +1 -0
  174. package/build/dist/Graphics/Circle.js +48 -0
  175. package/build/dist/Graphics/Circle.js.map +1 -0
  176. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js +2 -0
  177. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.js.map +1 -0
  178. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js +237 -0
  179. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.js.map +1 -0
  180. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
  181. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js +481 -0
  182. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.js.map +1 -0
  183. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +52 -52
  184. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js +174 -0
  185. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.js.map +1 -0
  186. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -37
  187. package/build/dist/Graphics/Context/debug-text.js +47 -0
  188. package/build/dist/Graphics/Context/debug-text.js.map +1 -0
  189. package/build/dist/Graphics/Context/draw-call.js +16 -0
  190. package/build/dist/Graphics/Context/draw-call.js.map +1 -0
  191. package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +32 -32
  192. package/build/dist/Graphics/Context/image-renderer/image-renderer.js +246 -0
  193. package/build/dist/Graphics/Context/image-renderer/image-renderer.js.map +1 -0
  194. package/build/dist/Graphics/Context/image-renderer/image-renderer.vert.glsl +32 -32
  195. package/build/dist/Graphics/Context/line-renderer/line-fragment.glsl +10 -10
  196. package/build/dist/Graphics/Context/line-renderer/line-renderer.js +90 -0
  197. package/build/dist/Graphics/Context/line-renderer/line-renderer.js.map +1 -0
  198. package/build/dist/Graphics/Context/line-renderer/line-vertex.glsl +14 -14
  199. package/build/dist/Graphics/Context/material-renderer/material-renderer.js +23 -2
  200. package/build/dist/Graphics/Context/material-renderer/material-renderer.js.map +1 -1
  201. package/build/dist/Graphics/Context/material.d.ts +2 -0
  202. package/build/dist/Graphics/Context/material.js +72 -0
  203. package/build/dist/Graphics/Context/material.js.map +1 -0
  204. package/build/dist/Graphics/Context/point-renderer/point-fragment.glsl +19 -19
  205. package/build/dist/Graphics/Context/point-renderer/point-renderer.js +91 -0
  206. package/build/dist/Graphics/Context/point-renderer/point-renderer.js.map +1 -0
  207. package/build/dist/Graphics/Context/point-renderer/point-vertex.glsl +11 -11
  208. package/build/dist/Graphics/Context/quad-index-buffer.js +67 -0
  209. package/build/dist/Graphics/Context/quad-index-buffer.js.map +1 -0
  210. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -85
  211. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js +305 -0
  212. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.js.map +1 -0
  213. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -42
  214. package/build/dist/Graphics/Context/render-source.js +16 -0
  215. package/build/dist/Graphics/Context/render-source.js.map +1 -0
  216. package/build/dist/Graphics/Context/render-target.js +65 -0
  217. package/build/dist/Graphics/Context/render-target.js.map +1 -0
  218. package/build/dist/Graphics/Context/renderer.js +2 -0
  219. package/build/dist/Graphics/Context/renderer.js.map +1 -0
  220. package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +13 -13
  221. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js +56 -0
  222. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.js.map +1 -0
  223. package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -11
  224. package/build/dist/Graphics/Context/state-stack.js +37 -0
  225. package/build/dist/Graphics/Context/state-stack.js.map +1 -0
  226. package/build/dist/Graphics/Context/texture-loader.js +109 -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 +53 -0
  231. package/build/dist/Graphics/Context/vertex-buffer.js.map +1 -0
  232. package/build/dist/Graphics/Context/webgl-util.js +79 -0
  233. package/build/dist/Graphics/Context/webgl-util.js.map +1 -0
  234. package/build/dist/Graphics/DebugGraphicsComponent.d.ts +3 -2
  235. package/build/dist/Graphics/DebugGraphicsComponent.js +16 -0
  236. package/build/dist/Graphics/DebugGraphicsComponent.js.map +1 -0
  237. package/build/dist/Graphics/Filtering.js +17 -0
  238. package/build/dist/Graphics/Filtering.js.map +1 -0
  239. package/build/dist/Graphics/Font.js +148 -0
  240. package/build/dist/Graphics/Font.js.map +1 -0
  241. package/build/dist/Graphics/FontCache.d.ts +1 -0
  242. package/build/dist/Graphics/FontCache.js +80 -0
  243. package/build/dist/Graphics/FontCache.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/FontTextInstance.js +230 -0
  247. package/build/dist/Graphics/FontTextInstance.js.map +1 -0
  248. package/build/dist/Graphics/Graphic.js +208 -0
  249. package/build/dist/Graphics/Graphic.js.map +1 -0
  250. package/build/dist/Graphics/GraphicsComponent.js +336 -0
  251. package/build/dist/Graphics/GraphicsComponent.js.map +1 -0
  252. package/build/dist/Graphics/GraphicsDiagnostics.js +9 -0
  253. package/build/dist/Graphics/GraphicsDiagnostics.js.map +1 -0
  254. package/build/dist/Graphics/GraphicsGroup.js +69 -0
  255. package/build/dist/Graphics/GraphicsGroup.js.map +1 -0
  256. package/build/dist/Graphics/GraphicsSystem.js +210 -0
  257. package/build/dist/Graphics/GraphicsSystem.js.map +1 -0
  258. package/build/dist/Graphics/ImageSource.js +124 -0
  259. package/build/dist/Graphics/ImageSource.js.map +1 -0
  260. package/build/dist/Graphics/Line.js +45 -0
  261. package/build/dist/Graphics/Line.js.map +1 -0
  262. package/build/dist/Graphics/OffscreenSystem.js +64 -0
  263. package/build/dist/Graphics/OffscreenSystem.js.map +1 -0
  264. package/build/dist/Graphics/ParallaxComponent.js +11 -0
  265. package/build/dist/Graphics/ParallaxComponent.js.map +1 -0
  266. package/build/dist/Graphics/Polygon.js +59 -0
  267. package/build/dist/Graphics/Polygon.js.map +1 -0
  268. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js +7 -0
  269. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.js.map +1 -0
  270. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js +52 -0
  271. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.js.map +1 -0
  272. package/build/dist/Graphics/PostProcessor/PostProcessor.js +2 -0
  273. package/build/dist/Graphics/PostProcessor/PostProcessor.js.map +1 -0
  274. package/build/dist/Graphics/PostProcessor/ScreenShader.js +59 -0
  275. package/build/dist/Graphics/PostProcessor/ScreenShader.js.map +1 -0
  276. package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +64 -64
  277. package/build/dist/Graphics/Raster.js +215 -0
  278. package/build/dist/Graphics/Raster.js.map +1 -0
  279. package/build/dist/Graphics/Rectangle.js +29 -0
  280. package/build/dist/Graphics/Rectangle.js.map +1 -0
  281. package/build/dist/Graphics/Sprite.js +82 -0
  282. package/build/dist/Graphics/Sprite.js.map +1 -0
  283. package/build/dist/Graphics/SpriteFont.js +139 -0
  284. package/build/dist/Graphics/SpriteFont.js.map +1 -0
  285. package/build/dist/Graphics/SpriteSheet.js +116 -0
  286. package/build/dist/Graphics/SpriteSheet.js.map +1 -0
  287. package/build/dist/Graphics/Text.js +103 -0
  288. package/build/dist/Graphics/Text.js.map +1 -0
  289. package/build/dist/Graphics/index.js +46 -0
  290. package/build/dist/Graphics/index.js.map +1 -0
  291. package/build/dist/Id.js +8 -0
  292. package/build/dist/Id.js.map +1 -0
  293. package/build/dist/Input/CapturePointerConfig.js +5 -0
  294. package/build/dist/Input/CapturePointerConfig.js.map +1 -0
  295. package/build/dist/Input/EngineInput.js +2 -0
  296. package/build/dist/Input/EngineInput.js.map +1 -0
  297. package/build/dist/Input/Gamepad.js +422 -0
  298. package/build/dist/Input/Gamepad.js.map +1 -0
  299. package/build/dist/Input/Index.js +88 -0
  300. package/build/dist/Input/Index.js.map +1 -0
  301. package/build/dist/Input/InputMapper.js +45 -0
  302. package/build/dist/Input/InputMapper.js.map +1 -0
  303. package/build/dist/Input/Keyboard.js +348 -0
  304. package/build/dist/Input/Keyboard.js.map +1 -0
  305. package/build/dist/Input/NativePointerButton.js +12 -0
  306. package/build/dist/Input/NativePointerButton.js.map +1 -0
  307. package/build/dist/Input/PointerAbstraction.js +44 -0
  308. package/build/dist/Input/PointerAbstraction.js.map +1 -0
  309. package/build/dist/Input/PointerButton.js +12 -0
  310. package/build/dist/Input/PointerButton.js.map +1 -0
  311. package/build/dist/Input/PointerComponent.js +28 -0
  312. package/build/dist/Input/PointerComponent.js.map +1 -0
  313. package/build/dist/Input/PointerEvent.js +25 -0
  314. package/build/dist/Input/PointerEvent.js.map +1 -0
  315. package/build/dist/Input/PointerEventReceiver.js +456 -0
  316. package/build/dist/Input/PointerEventReceiver.js.map +1 -0
  317. package/build/dist/Input/PointerScope.js +16 -0
  318. package/build/dist/Input/PointerScope.js.map +1 -0
  319. package/build/dist/Input/PointerSystem.js +249 -0
  320. package/build/dist/Input/PointerSystem.js.map +1 -0
  321. package/build/dist/Input/PointerType.js +11 -0
  322. package/build/dist/Input/PointerType.js.map +1 -0
  323. package/build/dist/Input/WheelDeltaMode.js +7 -0
  324. package/build/dist/Input/WheelDeltaMode.js.map +1 -0
  325. package/build/dist/Input/WheelEvent.js +21 -0
  326. package/build/dist/Input/WheelEvent.js.map +1 -0
  327. package/build/dist/Interfaces/Audio.js +2 -0
  328. package/build/dist/Interfaces/Audio.js.map +1 -0
  329. package/build/dist/Interfaces/AudioImplementation.js +11 -0
  330. package/build/dist/Interfaces/AudioImplementation.js.map +1 -0
  331. package/build/dist/Interfaces/Clonable.js +2 -0
  332. package/build/dist/Interfaces/Clonable.js.map +1 -0
  333. package/build/dist/Interfaces/Evented.js +2 -0
  334. package/build/dist/Interfaces/Evented.js.map +1 -0
  335. package/build/dist/Interfaces/Index.js +8 -0
  336. package/build/dist/Interfaces/Index.js.map +1 -0
  337. package/build/dist/Interfaces/LifecycleEvents.js +51 -0
  338. package/build/dist/Interfaces/LifecycleEvents.js.map +1 -0
  339. package/build/dist/Interfaces/Loadable.js +2 -0
  340. package/build/dist/Interfaces/Loadable.js.map +1 -0
  341. package/build/dist/Interfaces/PointerEventHandlers.js +2 -0
  342. package/build/dist/Interfaces/PointerEventHandlers.js.map +1 -0
  343. package/build/dist/Label.js +81 -0
  344. package/build/dist/Label.js.map +1 -0
  345. package/build/dist/Loader.js +416 -0
  346. package/build/dist/Loader.js.map +1 -0
  347. package/build/dist/Math/Index.js +13 -0
  348. package/build/dist/Math/Index.js.map +1 -0
  349. package/build/dist/Math/Random.js +239 -0
  350. package/build/dist/Math/Random.js.map +1 -0
  351. package/build/dist/Math/affine-matrix.js +331 -0
  352. package/build/dist/Math/affine-matrix.js.map +1 -0
  353. package/build/dist/Math/coord-plane.js +17 -0
  354. package/build/dist/Math/coord-plane.js.map +1 -0
  355. package/build/dist/Math/global-coordinates.js +30 -0
  356. package/build/dist/Math/global-coordinates.js.map +1 -0
  357. package/build/dist/Math/line-segment.js +205 -0
  358. package/build/dist/Math/line-segment.js.map +1 -0
  359. package/build/dist/Math/matrix.js +457 -0
  360. package/build/dist/Math/matrix.js.map +1 -0
  361. package/build/dist/Math/projection.js +24 -0
  362. package/build/dist/Math/projection.js.map +1 -0
  363. package/build/dist/Math/ray.js +52 -0
  364. package/build/dist/Math/ray.js.map +1 -0
  365. package/build/dist/Math/transform.js +219 -0
  366. package/build/dist/Math/transform.js.map +1 -0
  367. package/build/dist/Math/util.js +82 -0
  368. package/build/dist/Math/util.js.map +1 -0
  369. package/build/dist/Math/vector-view.js +25 -0
  370. package/build/dist/Math/vector-view.js.map +1 -0
  371. package/build/dist/Math/vector.js +340 -0
  372. package/build/dist/Math/vector.js.map +1 -0
  373. package/build/dist/Math/watch-vector.js +26 -0
  374. package/build/dist/Math/watch-vector.js.map +1 -0
  375. package/build/dist/Particles.js +430 -0
  376. package/build/dist/Particles.js.map +1 -0
  377. package/build/dist/Polyfill.js +56 -0
  378. package/build/dist/Polyfill.js.map +1 -0
  379. package/build/dist/Resources/Gif.js +464 -0
  380. package/build/dist/Resources/Gif.js.map +1 -0
  381. package/build/dist/Resources/Index.js +4 -0
  382. package/build/dist/Resources/Index.js.map +1 -0
  383. package/build/dist/Resources/Resource.js +81 -0
  384. package/build/dist/Resources/Resource.js.map +1 -0
  385. package/build/dist/Resources/Sound/AudioContext.js +16 -0
  386. package/build/dist/Resources/Sound/AudioContext.js.map +1 -0
  387. package/build/dist/Resources/Sound/Index.js +4 -0
  388. package/build/dist/Resources/Sound/Index.js.map +1 -0
  389. package/build/dist/Resources/Sound/Sound.js +326 -0
  390. package/build/dist/Resources/Sound/Sound.js.map +1 -0
  391. package/build/dist/Resources/Sound/WebAudioInstance.js +190 -0
  392. package/build/dist/Resources/Sound/WebAudioInstance.js.map +1 -0
  393. package/build/dist/Scene.js +444 -0
  394. package/build/dist/Scene.js.map +1 -0
  395. package/build/dist/Screen.js +782 -0
  396. package/build/dist/Screen.js.map +1 -0
  397. package/build/dist/ScreenElement.js +43 -0
  398. package/build/dist/ScreenElement.js.map +1 -0
  399. package/build/dist/TileMap/IsometricEntityComponent.js +17 -0
  400. package/build/dist/TileMap/IsometricEntityComponent.js.map +1 -0
  401. package/build/dist/TileMap/IsometricEntitySystem.js +23 -0
  402. package/build/dist/TileMap/IsometricEntitySystem.js.map +1 -0
  403. package/build/dist/TileMap/IsometricMap.js +311 -0
  404. package/build/dist/TileMap/IsometricMap.js.map +1 -0
  405. package/build/dist/TileMap/TileMap.d.ts +2 -1
  406. package/build/dist/TileMap/TileMap.js +630 -0
  407. package/build/dist/TileMap/TileMap.js.map +1 -0
  408. package/build/dist/TileMap/index.js +5 -0
  409. package/build/dist/TileMap/index.js.map +1 -0
  410. package/build/dist/Timer.js +202 -0
  411. package/build/dist/Timer.js.map +1 -0
  412. package/build/dist/Trigger.js +94 -0
  413. package/build/dist/Trigger.js.map +1 -0
  414. package/build/dist/Util/Browser.js +66 -0
  415. package/build/dist/Util/Browser.js.map +1 -0
  416. package/build/dist/Util/Clock.js +219 -0
  417. package/build/dist/Util/Clock.js.map +1 -0
  418. package/build/dist/Util/Decorators.js +78 -0
  419. package/build/dist/Util/Decorators.js.map +1 -0
  420. package/build/dist/Util/Detector.js +167 -0
  421. package/build/dist/Util/Detector.js.map +1 -0
  422. package/build/dist/Util/DrawUtil.js +115 -0
  423. package/build/dist/Util/DrawUtil.js.map +1 -0
  424. package/build/dist/Util/EasingFunctions.js +102 -0
  425. package/build/dist/Util/EasingFunctions.js.map +1 -0
  426. package/build/dist/Util/Fps.js +47 -0
  427. package/build/dist/Util/Fps.js.map +1 -0
  428. package/build/dist/Util/Future.js +30 -0
  429. package/build/dist/Util/Future.js.map +1 -0
  430. package/build/dist/Util/IFrame.js +23 -0
  431. package/build/dist/Util/IFrame.js.map +1 -0
  432. package/build/dist/Util/Index.js +7 -0
  433. package/build/dist/Util/Index.js.map +1 -0
  434. package/build/dist/Util/Log.js +195 -0
  435. package/build/dist/Util/Log.js.map +1 -0
  436. package/build/dist/Util/Observable.js +66 -0
  437. package/build/dist/Util/Observable.js.map +1 -0
  438. package/build/dist/Util/Pool.js +74 -0
  439. package/build/dist/Util/Pool.js.map +1 -0
  440. package/build/dist/Util/Semaphore.js +55 -0
  441. package/build/dist/Util/Semaphore.js.map +1 -0
  442. package/build/dist/Util/Sound.js +22 -0
  443. package/build/dist/Util/Sound.js.map +1 -0
  444. package/build/dist/Util/StateMachine.js +79 -0
  445. package/build/dist/Util/StateMachine.js.map +1 -0
  446. package/build/dist/Util/Toaster.css +28 -28
  447. package/build/dist/Util/Toaster.js +84 -0
  448. package/build/dist/Util/Toaster.js.map +1 -0
  449. package/build/dist/Util/Util.d.ts +6 -0
  450. package/build/dist/Util/Util.js +95 -0
  451. package/build/dist/Util/Util.js.map +1 -0
  452. package/build/dist/Util/Watch.js +67 -0
  453. package/build/dist/Util/Watch.js.map +1 -0
  454. package/build/dist/Util/WebAudio.js +62 -0
  455. package/build/dist/Util/WebAudio.js.map +1 -0
  456. package/build/dist/excalibur.d.ts +2 -2
  457. package/build/dist/excalibur.js +389 -258
  458. package/build/dist/excalibur.js.map +1 -1
  459. package/build/dist/excalibur.min.js +1 -1
  460. package/build/dist/excalibur.min.js.LICENSE.txt +1 -1
  461. package/build/dist/excalibur.min.js.map +1 -1
  462. package/build/dist/index.js +81 -0
  463. package/build/dist/index.js.map +1 -0
  464. package/build/esm/Debug/Debug.d.ts +11 -0
  465. package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +1 -0
  466. package/build/esm/Graphics/Context/material.d.ts +2 -0
  467. package/build/esm/Graphics/DebugGraphicsComponent.d.ts +3 -2
  468. package/build/esm/Graphics/FontCache.d.ts +1 -0
  469. package/build/esm/TileMap/TileMap.d.ts +2 -1
  470. package/build/esm/Util/Util.d.ts +6 -0
  471. package/build/esm/excalibur.d.ts +2 -2
  472. package/build/esm/excalibur.js +389 -258
  473. package/build/esm/excalibur.js.map +1 -1
  474. package/build/esm/excalibur.min.js +1 -1
  475. package/build/esm/excalibur.min.js.LICENSE.txt +1 -1
  476. package/build/esm/excalibur.min.js.map +1 -1
  477. package/docker-compose.yml +11 -11
  478. package/package.json +131 -131
  479. package/build/dist/Loader.css +0 -122
  480. package/build/nuget/Excalibur.0.28.3.nupkg +0 -0
  481. package/build/v0.28.3.zip +0 -0
  482. package/excalibur-0.28.3.tgz +0 -0
@@ -0,0 +1,174 @@
1
+ import { Color } from '../../../Color';
2
+ import { vec } from '../../../Math/vector';
3
+ import { GraphicsDiagnostics } from '../../GraphicsDiagnostics';
4
+ import { pixelSnapEpsilon } from '../ExcaliburGraphicsContextWebGL';
5
+ import { QuadIndexBuffer } from '../quad-index-buffer';
6
+ import { Shader } from '../shader';
7
+ import { VertexBuffer } from '../vertex-buffer';
8
+ import { VertexLayout } from '../vertex-layout';
9
+ import frag from './circle-renderer.frag.glsl';
10
+ import vert from './circle-renderer.vert.glsl';
11
+ export class CircleRenderer {
12
+ constructor() {
13
+ this.type = 'ex.circle';
14
+ this.priority = 0;
15
+ this._maxCircles = 10922; // max(uint16) / 6 verts
16
+ this._circleCount = 0;
17
+ this._vertexIndex = 0;
18
+ }
19
+ initialize(gl, context) {
20
+ this._gl = gl;
21
+ this._context = context;
22
+ this._shader = new Shader({
23
+ gl,
24
+ fragmentSource: frag,
25
+ vertexSource: vert
26
+ });
27
+ this._shader.compile();
28
+ // setup uniforms
29
+ this._shader.use();
30
+ this._shader.setUniformMatrix('u_matrix', context.ortho);
31
+ this._buffer = new VertexBuffer({
32
+ gl,
33
+ size: 14 * 4 * this._maxCircles,
34
+ type: 'dynamic'
35
+ });
36
+ this._layout = new VertexLayout({
37
+ gl,
38
+ shader: this._shader,
39
+ vertexBuffer: this._buffer,
40
+ attributes: [
41
+ ['a_position', 2],
42
+ ['a_uv', 2],
43
+ ['a_opacity', 1],
44
+ ['a_color', 4],
45
+ ['a_strokeColor', 4],
46
+ ['a_strokeThickness', 1]
47
+ ]
48
+ });
49
+ this._quads = new QuadIndexBuffer(gl, this._maxCircles, true);
50
+ }
51
+ _isFull() {
52
+ if (this._circleCount >= this._maxCircles) {
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+ draw(pos, radius, color, stroke = Color.Transparent, strokeThickness = 0) {
58
+ if (this._isFull()) {
59
+ this.flush();
60
+ }
61
+ this._circleCount++;
62
+ // transform based on current context
63
+ const transform = this._context.getTransform();
64
+ const opacity = this._context.opacity;
65
+ const snapToPixel = this._context.snapToPixel;
66
+ const topLeft = transform.multiply(pos.add(vec(-radius, -radius)));
67
+ const topRight = transform.multiply(pos.add(vec(radius, -radius)));
68
+ const bottomRight = transform.multiply(pos.add(vec(radius, radius)));
69
+ const bottomLeft = transform.multiply(pos.add(vec(-radius, radius)));
70
+ if (snapToPixel) {
71
+ topLeft.x = ~~(topLeft.x + pixelSnapEpsilon);
72
+ topLeft.y = ~~(topLeft.y + pixelSnapEpsilon);
73
+ topRight.x = ~~(topRight.x + pixelSnapEpsilon);
74
+ topRight.y = ~~(topRight.y + pixelSnapEpsilon);
75
+ bottomLeft.x = ~~(bottomLeft.x + pixelSnapEpsilon);
76
+ bottomLeft.y = ~~(bottomLeft.y + pixelSnapEpsilon);
77
+ bottomRight.x = ~~(bottomRight.x + pixelSnapEpsilon);
78
+ bottomRight.y = ~~(bottomRight.y + pixelSnapEpsilon);
79
+ }
80
+ // TODO UV could be static vertex buffer
81
+ const uvx0 = 0;
82
+ const uvy0 = 0;
83
+ const uvx1 = 1;
84
+ const uvy1 = 1;
85
+ // update data
86
+ const vertexBuffer = this._layout.vertexBuffer.bufferData;
87
+ // (0, 0) - 0
88
+ vertexBuffer[this._vertexIndex++] = topLeft.x;
89
+ vertexBuffer[this._vertexIndex++] = topLeft.y;
90
+ vertexBuffer[this._vertexIndex++] = uvx0;
91
+ vertexBuffer[this._vertexIndex++] = uvy0;
92
+ vertexBuffer[this._vertexIndex++] = opacity;
93
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
94
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
95
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
96
+ vertexBuffer[this._vertexIndex++] = color.a;
97
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
98
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
99
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
100
+ vertexBuffer[this._vertexIndex++] = stroke.a;
101
+ vertexBuffer[this._vertexIndex++] = strokeThickness / radius;
102
+ // (0, 1) - 1
103
+ vertexBuffer[this._vertexIndex++] = bottomLeft.x;
104
+ vertexBuffer[this._vertexIndex++] = bottomLeft.y;
105
+ vertexBuffer[this._vertexIndex++] = uvx0;
106
+ vertexBuffer[this._vertexIndex++] = uvy1;
107
+ vertexBuffer[this._vertexIndex++] = opacity;
108
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
109
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
110
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
111
+ vertexBuffer[this._vertexIndex++] = color.a;
112
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
113
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
114
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
115
+ vertexBuffer[this._vertexIndex++] = stroke.a;
116
+ vertexBuffer[this._vertexIndex++] = strokeThickness / radius;
117
+ // (1, 0) - 2
118
+ vertexBuffer[this._vertexIndex++] = topRight.x;
119
+ vertexBuffer[this._vertexIndex++] = topRight.y;
120
+ vertexBuffer[this._vertexIndex++] = uvx1;
121
+ vertexBuffer[this._vertexIndex++] = uvy0;
122
+ vertexBuffer[this._vertexIndex++] = opacity;
123
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
124
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
125
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
126
+ vertexBuffer[this._vertexIndex++] = color.a;
127
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
128
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
129
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
130
+ vertexBuffer[this._vertexIndex++] = stroke.a;
131
+ vertexBuffer[this._vertexIndex++] = strokeThickness / radius;
132
+ // (1, 1) - 3
133
+ vertexBuffer[this._vertexIndex++] = bottomRight.x;
134
+ vertexBuffer[this._vertexIndex++] = bottomRight.y;
135
+ vertexBuffer[this._vertexIndex++] = uvx1;
136
+ vertexBuffer[this._vertexIndex++] = uvy1;
137
+ vertexBuffer[this._vertexIndex++] = opacity;
138
+ vertexBuffer[this._vertexIndex++] = color.r / 255;
139
+ vertexBuffer[this._vertexIndex++] = color.g / 255;
140
+ vertexBuffer[this._vertexIndex++] = color.b / 255;
141
+ vertexBuffer[this._vertexIndex++] = color.a;
142
+ vertexBuffer[this._vertexIndex++] = stroke.r / 255;
143
+ vertexBuffer[this._vertexIndex++] = stroke.g / 255;
144
+ vertexBuffer[this._vertexIndex++] = stroke.b / 255;
145
+ vertexBuffer[this._vertexIndex++] = stroke.a;
146
+ vertexBuffer[this._vertexIndex++] = strokeThickness / radius;
147
+ }
148
+ hasPendingDraws() {
149
+ return this._circleCount !== 0;
150
+ }
151
+ flush() {
152
+ // nothing to draw early exit
153
+ if (this._circleCount === 0) {
154
+ return;
155
+ }
156
+ const gl = this._gl;
157
+ // Bind the shader
158
+ this._shader.use();
159
+ // Bind the memory layout and upload data
160
+ this._layout.use(true);
161
+ // Update ortho matrix uniform
162
+ this._shader.setUniformMatrix('u_matrix', this._context.ortho);
163
+ // Bind index buffer
164
+ this._quads.bind();
165
+ // Draw all the quads
166
+ gl.drawElements(gl.TRIANGLES, this._circleCount * 6, this._quads.bufferGlType, 0);
167
+ GraphicsDiagnostics.DrawnImagesCount += this._circleCount;
168
+ GraphicsDiagnostics.DrawCallCount++;
169
+ // Reset
170
+ this._circleCount = 0;
171
+ this._vertexIndex = 0;
172
+ }
173
+ }
174
+ //# sourceMappingURL=circle-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circle-renderer.js","sourceRoot":"","sources":["../../../../../src/engine/Graphics/Context/circle-renderer/circle-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,GAAG,EAAU,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAiC,gBAAgB,EAAE,MAAM,k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AkB;QAClB,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAEnB,yCAAyC;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEvB,8BAA8B;QAC9B,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE/D,oBAAoB;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAEnB,qBAAqB;QACrB,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAElF,mBAAmB,CAAC,gBAAgB,IAAI,IAAI,CAAC,YAAY,CAAC;QAC1D,mBAAmB,CAAC,aAAa,EAAE,CAAC;QAEpC,QAAQ;QACR,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;IACxB,CAAC;CAEF"}
@@ -1,38 +1,38 @@
1
- #version 300 es
2
- in vec2 a_position;
3
-
4
- // UV coordinate
5
- in vec2 a_uv;
6
- out vec2 v_uv;
7
-
8
- // Opacity
9
- in float a_opacity;
10
- out float v_opacity;
11
-
12
- in vec4 a_color;
13
- out vec4 v_color;
14
-
15
- in vec4 a_strokeColor;
16
- out vec4 v_strokeColor;
17
-
18
- in float a_strokeThickness;
19
- out float v_strokeThickness;
20
-
21
- uniform mat4 u_matrix;
22
-
23
-
24
- void main() {
25
- // Set the vertex position using the ortho transform matrix
26
- gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
27
-
28
- // Pass through UV coords
29
- v_uv = a_uv;
30
- // Pass through the Opacity to the fragment shader
31
- v_opacity = a_opacity;
32
- // Pass through the color to the fragment shader
33
- v_color = a_color;
34
- // Pass through the stroke color to the fragment shader
35
- v_strokeColor = a_strokeColor;
36
- // Pass through the stroke thickenss to the fragment shader
37
- v_strokeThickness = a_strokeThickness;
1
+ #version 300 es
2
+ in vec2 a_position;
3
+
4
+ // UV coordinate
5
+ in vec2 a_uv;
6
+ out vec2 v_uv;
7
+
8
+ // Opacity
9
+ in float a_opacity;
10
+ out float v_opacity;
11
+
12
+ in vec4 a_color;
13
+ out vec4 v_color;
14
+
15
+ in vec4 a_strokeColor;
16
+ out vec4 v_strokeColor;
17
+
18
+ in float a_strokeThickness;
19
+ out float v_strokeThickness;
20
+
21
+ uniform mat4 u_matrix;
22
+
23
+
24
+ void main() {
25
+ // Set the vertex position using the ortho transform matrix
26
+ gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
27
+
28
+ // Pass through UV coords
29
+ v_uv = a_uv;
30
+ // Pass through the Opacity to the fragment shader
31
+ v_opacity = a_opacity;
32
+ // Pass through the color to the fragment shader
33
+ v_color = a_color;
34
+ // Pass through the stroke color to the fragment shader
35
+ v_strokeColor = a_strokeColor;
36
+ // Pass through the stroke thickenss to the fragment shader
37
+ v_strokeThickness = a_strokeThickness;
38
38
  }
@@ -0,0 +1,47 @@
1
+ import { ImageSource, SpriteFont, SpriteSheet } from '..';
2
+ import debugFont from './debug-font.png';
3
+ /**
4
+ * Internal debugtext helper
5
+ */
6
+ export class DebugText {
7
+ constructor() {
8
+ /**
9
+ * base64 font
10
+ */
11
+ this.fontSheet = debugFont;
12
+ this.size = 16;
13
+ this.load();
14
+ }
15
+ load() {
16
+ this._imageSource = new ImageSource(this.fontSheet);
17
+ return this._imageSource.load().then(() => {
18
+ this._spriteSheet = SpriteSheet.fromImageSource({
19
+ image: this._imageSource,
20
+ grid: {
21
+ rows: 4,
22
+ columns: 16,
23
+ spriteWidth: 16,
24
+ spriteHeight: 16
25
+ }
26
+ });
27
+ this._spriteFont = new SpriteFont({
28
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ,!\'&."?-()+# ',
29
+ caseInsensitive: true,
30
+ spriteSheet: this._spriteSheet,
31
+ spacing: -6
32
+ });
33
+ });
34
+ }
35
+ /**
36
+ * Writes debug text using the built in sprint font
37
+ * @param ctx
38
+ * @param text
39
+ * @param pos
40
+ */
41
+ write(ctx, text, pos) {
42
+ if (this._imageSource.isLoaded()) {
43
+ this._spriteFont.render(ctx, text, null, pos.x, pos.y);
44
+ }
45
+ }
46
+ }
47
+ //# sourceMappingURL=debug-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-text.js","sourceRoot":"","sources":["../../../../src/engine/Graphics/Context/debug-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEpF,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB;QAIA;;WAEG;QACa,cAAS,GAAG,SAAS,CAAC;QAC/B,SAAI,GAAW,EAAE,CAAC;QAPvB,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAUM,IAAI;QACT,IAAI,CAAC,YAAY,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACxC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,eAAe,CAAC;gBAC9C,KAAK,EAAE,IAAI,CAAC,YAAY;gBACxB,IAAI,EAAE;oBACJ,IAAI,EAAE,CAAC;oBACP,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,EAAE;oBACf,YAAY,EAAE,EAAE;iBACjB;aACF,CAAC,CAAC;YACH,IAAI,CAAC,WAAW,GAAG,IAAI,UAAU,CAAC;gBAChC,QAAQ,EAAE,oDAAoD;gBAC9D,eAAe,EAAE,IAAI;gBACrB,WAAW,EAAE,IAAI,CAAC,YAAY;gBAC9B,OAAO,EAAE,CAAC,CAAC;aACZ,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,GAA6B,EAAE,IAAY,EAAE,GAAW;QACnE,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import { AffineMatrix } from '../../Math/affine-matrix';
2
+ import { Color } from '../../Color';
3
+ export class DrawCall {
4
+ constructor() {
5
+ this.z = 0;
6
+ this.priority = 0;
7
+ this.transform = AffineMatrix.identity();
8
+ this.state = {
9
+ z: 0,
10
+ opacity: 1,
11
+ tint: Color.White,
12
+ material: null
13
+ };
14
+ }
15
+ }
16
+ //# sourceMappingURL=draw-call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draw-call.js","sourceRoot":"","sources":["../../../../src/engine/Graphics/Context/draw-call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,OAAO,QAAQ;IAArB;QACS,MAAC,GAAW,CAAC,CAAC;QACd,aAAQ,GAAW,CAAC,CAAC;QAErB,cAAS,GAAiB,YAAY,CAAC,QAAQ,EAAE,CAAC;QAClD,UAAK,GAAkC;YAC5C,CAAC,EAAE,CAAC;YACJ,OAAO,EAAE,CAAC;YACV,IAAI,EAAE,KAAK,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI;SACf,CAAC;IAEJ,CAAC;CAAA"}
@@ -1,33 +1,33 @@
1
- #version 300 es
2
- precision mediump float;
3
-
4
- // UV coord
5
- in vec2 v_texcoord;
6
-
7
- // Texture index
8
- in lowp float v_textureIndex;
9
-
10
- // Textures in the current draw
11
- uniform sampler2D u_textures[%%count%%];
12
-
13
- // Opacity
14
- in float v_opacity;
15
-
16
- in vec4 v_tint;
17
-
18
- out vec4 fragColor;
19
-
20
- void main() {
21
- // In order to support the most efficient sprite batching, we have multiple
22
- // textures loaded into the gpu (usually 8) this picker logic skips over textures
23
- // that do not apply to a particular sprite.
24
-
25
- vec4 color = vec4(1.0, 0, 0, 1.0);
26
-
27
- // GLSL is templated out to pick the right texture and set the vec4 color
28
- %%texture_picker%%
29
-
30
- color.rgb = color.rgb * v_opacity;
31
- color.a = color.a * v_opacity;
32
- fragColor = color * v_tint;
1
+ #version 300 es
2
+ precision mediump float;
3
+
4
+ // UV coord
5
+ in vec2 v_texcoord;
6
+
7
+ // Texture index
8
+ in lowp float v_textureIndex;
9
+
10
+ // Textures in the current draw
11
+ uniform sampler2D u_textures[%%count%%];
12
+
13
+ // Opacity
14
+ in float v_opacity;
15
+
16
+ in vec4 v_tint;
17
+
18
+ out vec4 fragColor;
19
+
20
+ void main() {
21
+ // In order to support the most efficient sprite batching, we have multiple
22
+ // textures loaded into the gpu (usually 8) this picker logic skips over textures
23
+ // that do not apply to a particular sprite.
24
+
25
+ vec4 color = vec4(1.0, 0, 0, 1.0);
26
+
27
+ // GLSL is templated out to pick the right texture and set the vec4 color
28
+ %%texture_picker%%
29
+
30
+ color.rgb = color.rgb * v_opacity;
31
+ color.a = color.a * v_opacity;
32
+ fragColor = color * v_tint;
33
33
  }
@@ -0,0 +1,246 @@
1
+ import { vec } from '../../../Math/vector';
2
+ import { ImageFiltering } from '../../Filtering';
3
+ import { GraphicsDiagnostics } from '../../GraphicsDiagnostics';
4
+ import { pixelSnapEpsilon } from '../ExcaliburGraphicsContextWebGL';
5
+ import { QuadIndexBuffer } from '../quad-index-buffer';
6
+ import { Shader } from '../shader';
7
+ import { VertexBuffer } from '../vertex-buffer';
8
+ import { VertexLayout } from '../vertex-layout';
9
+ import frag from './image-renderer.frag.glsl';
10
+ import vert from './image-renderer.vert.glsl';
11
+ export class ImageRenderer {
12
+ constructor() {
13
+ this.type = 'ex.image';
14
+ this.priority = 0;
15
+ this._maxImages = 10922; // max(uint16) / 6 verts
16
+ this._maxTextures = 0;
17
+ // Per flush vars
18
+ this._imageCount = 0;
19
+ this._textures = [];
20
+ this._vertexIndex = 0;
21
+ }
22
+ initialize(gl, context) {
23
+ this._gl = gl;
24
+ this._context = context;
25
+ // Transform shader source
26
+ // FIXME: PIXEL 6 complains `ERROR: Expression too complex.` if we use it's reported max texture units, 125 seems to work for now...
27
+ this._maxTextures = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), 125);
28
+ const transformedFrag = this._transformFragmentSource(frag, this._maxTextures);
29
+ // Compile shader
30
+ this._shader = new Shader({
31
+ gl,
32
+ fragmentSource: transformedFrag,
33
+ vertexSource: vert
34
+ });
35
+ this._shader.compile();
36
+ // setup uniforms
37
+ this._shader.use();
38
+ this._shader.setUniformMatrix('u_matrix', context.ortho);
39
+ // Initialize texture slots to [0, 1, 2, 3, 4, .... maxGPUTextures]
40
+ this._shader.setUniformIntArray('u_textures', [...Array(this._maxTextures)].map((_, i) => i));
41
+ // Setup memory layout
42
+ this._buffer = new VertexBuffer({
43
+ gl,
44
+ size: 10 * 4 * this._maxImages, // 10 components * 4 verts
45
+ type: 'dynamic'
46
+ });
47
+ this._layout = new VertexLayout({
48
+ gl,
49
+ shader: this._shader,
50
+ vertexBuffer: this._buffer,
51
+ attributes: [
52
+ ['a_position', 2],
53
+ ['a_opacity', 1],
54
+ ['a_texcoord', 2],
55
+ ['a_textureIndex', 1],
56
+ ['a_tint', 4]
57
+ ]
58
+ });
59
+ // Setup index buffer
60
+ this._quads = new QuadIndexBuffer(gl, this._maxImages, true);
61
+ }
62
+ _transformFragmentSource(source, maxTextures) {
63
+ let newSource = source.replace('%%count%%', maxTextures.toString());
64
+ let texturePickerBuilder = '';
65
+ for (let i = 0; i < maxTextures; i++) {
66
+ if (i === 0) {
67
+ texturePickerBuilder += `if (v_textureIndex <= ${i}.5) {\n`;
68
+ }
69
+ else {
70
+ texturePickerBuilder += ` else if (v_textureIndex <= ${i}.5) {\n`;
71
+ }
72
+ texturePickerBuilder += ` color = texture(u_textures[${i}], v_texcoord);\n`;
73
+ texturePickerBuilder += ` }\n`;
74
+ }
75
+ newSource = newSource.replace('%%texture_picker%%', texturePickerBuilder);
76
+ return newSource;
77
+ }
78
+ _addImageAsTexture(image) {
79
+ const maybeFiltering = image.getAttribute('filtering');
80
+ let filtering = null;
81
+ if (maybeFiltering === ImageFiltering.Blended ||
82
+ maybeFiltering === ImageFiltering.Pixel) {
83
+ filtering = maybeFiltering;
84
+ }
85
+ const force = image.getAttribute('forceUpload') === 'true' ? true : false;
86
+ const texture = this._context.textureLoader.load(image, filtering, force);
87
+ // remove force attribute after upload
88
+ image.removeAttribute('forceUpload');
89
+ if (this._textures.indexOf(texture) === -1) {
90
+ this._textures.push(texture);
91
+ }
92
+ }
93
+ _bindTextures(gl) {
94
+ // Bind textures in the correct order
95
+ for (let i = 0; i < this._maxTextures; i++) {
96
+ gl.activeTexture(gl.TEXTURE0 + i);
97
+ gl.bindTexture(gl.TEXTURE_2D, this._textures[i] || this._textures[0]);
98
+ }
99
+ }
100
+ _getTextureIdForImage(image) {
101
+ if (image) {
102
+ const maybeTexture = this._context.textureLoader.get(image);
103
+ return this._textures.indexOf(maybeTexture);
104
+ }
105
+ return -1;
106
+ }
107
+ _isFull() {
108
+ if (this._imageCount >= this._maxImages) {
109
+ return true;
110
+ }
111
+ if (this._textures.length >= this._maxTextures) {
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+ draw(image, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) {
117
+ var _a, _b, _c, _d;
118
+ // Force a render if the batch is full
119
+ if (this._isFull()) {
120
+ this.flush();
121
+ }
122
+ this._imageCount++;
123
+ // This creates and uploads the texture if not already done
124
+ this._addImageAsTexture(image);
125
+ let width = (image === null || image === void 0 ? void 0 : image.width) || swidth || 0;
126
+ let height = (image === null || image === void 0 ? void 0 : image.height) || sheight || 0;
127
+ let view = [0, 0, (_a = swidth !== null && swidth !== void 0 ? swidth : image === null || image === void 0 ? void 0 : image.width) !== null && _a !== void 0 ? _a : 0, (_b = sheight !== null && sheight !== void 0 ? sheight : image === null || image === void 0 ? void 0 : image.height) !== null && _b !== void 0 ? _b : 0];
128
+ let dest = [sx !== null && sx !== void 0 ? sx : 1, sy !== null && sy !== void 0 ? sy : 1];
129
+ // If destination is specified, update view and dest
130
+ if (dx !== undefined && dy !== undefined && dwidth !== undefined && dheight !== undefined) {
131
+ view = [sx !== null && sx !== void 0 ? sx : 1, sy !== null && sy !== void 0 ? sy : 1, (_c = swidth !== null && swidth !== void 0 ? swidth : image === null || image === void 0 ? void 0 : image.width) !== null && _c !== void 0 ? _c : 0, (_d = sheight !== null && sheight !== void 0 ? sheight : image === null || image === void 0 ? void 0 : image.height) !== null && _d !== void 0 ? _d : 0];
132
+ dest = [dx, dy];
133
+ width = dwidth;
134
+ height = dheight;
135
+ }
136
+ sx = view[0];
137
+ sy = view[1];
138
+ const sw = view[2];
139
+ const sh = view[3];
140
+ // transform based on current context
141
+ const transform = this._context.getTransform();
142
+ const opacity = this._context.opacity;
143
+ const snapToPixel = this._context.snapToPixel;
144
+ let topLeft = vec(dest[0], dest[1]);
145
+ let topRight = vec(dest[0] + width, dest[1]);
146
+ let bottomLeft = vec(dest[0], dest[1] + height);
147
+ let bottomRight = vec(dest[0] + width, dest[1] + height);
148
+ topLeft = transform.multiply(topLeft);
149
+ topRight = transform.multiply(topRight);
150
+ bottomLeft = transform.multiply(bottomLeft);
151
+ bottomRight = transform.multiply(bottomRight);
152
+ if (snapToPixel) {
153
+ topLeft.x = ~~(topLeft.x + pixelSnapEpsilon);
154
+ topLeft.y = ~~(topLeft.y + pixelSnapEpsilon);
155
+ topRight.x = ~~(topRight.x + pixelSnapEpsilon);
156
+ topRight.y = ~~(topRight.y + pixelSnapEpsilon);
157
+ bottomLeft.x = ~~(bottomLeft.x + pixelSnapEpsilon);
158
+ bottomLeft.y = ~~(bottomLeft.y + pixelSnapEpsilon);
159
+ bottomRight.x = ~~(bottomRight.x + pixelSnapEpsilon);
160
+ bottomRight.y = ~~(bottomRight.y + pixelSnapEpsilon);
161
+ }
162
+ const tint = this._context.tint;
163
+ const textureId = this._getTextureIdForImage(image);
164
+ const imageWidth = image.width || width;
165
+ const imageHeight = image.height || height;
166
+ const uvx0 = (sx) / imageWidth;
167
+ const uvy0 = (sy) / imageHeight;
168
+ const uvx1 = (sx + sw - 0.01) / imageWidth;
169
+ const uvy1 = (sy + sh - 0.01) / imageHeight;
170
+ // update data
171
+ const vertexBuffer = this._layout.vertexBuffer.bufferData;
172
+ // (0, 0) - 0
173
+ vertexBuffer[this._vertexIndex++] = topLeft.x;
174
+ vertexBuffer[this._vertexIndex++] = topLeft.y;
175
+ vertexBuffer[this._vertexIndex++] = opacity;
176
+ vertexBuffer[this._vertexIndex++] = uvx0;
177
+ vertexBuffer[this._vertexIndex++] = uvy0;
178
+ vertexBuffer[this._vertexIndex++] = textureId;
179
+ vertexBuffer[this._vertexIndex++] = tint.r / 255;
180
+ vertexBuffer[this._vertexIndex++] = tint.g / 255;
181
+ vertexBuffer[this._vertexIndex++] = tint.b / 255;
182
+ vertexBuffer[this._vertexIndex++] = tint.a;
183
+ // (0, 1) - 1
184
+ vertexBuffer[this._vertexIndex++] = bottomLeft.x;
185
+ vertexBuffer[this._vertexIndex++] = bottomLeft.y;
186
+ vertexBuffer[this._vertexIndex++] = opacity;
187
+ vertexBuffer[this._vertexIndex++] = uvx0;
188
+ vertexBuffer[this._vertexIndex++] = uvy1;
189
+ vertexBuffer[this._vertexIndex++] = textureId;
190
+ vertexBuffer[this._vertexIndex++] = tint.r / 255;
191
+ vertexBuffer[this._vertexIndex++] = tint.g / 255;
192
+ vertexBuffer[this._vertexIndex++] = tint.b / 255;
193
+ vertexBuffer[this._vertexIndex++] = tint.a;
194
+ // (1, 0) - 2
195
+ vertexBuffer[this._vertexIndex++] = topRight.x;
196
+ vertexBuffer[this._vertexIndex++] = topRight.y;
197
+ vertexBuffer[this._vertexIndex++] = opacity;
198
+ vertexBuffer[this._vertexIndex++] = uvx1;
199
+ vertexBuffer[this._vertexIndex++] = uvy0;
200
+ vertexBuffer[this._vertexIndex++] = textureId;
201
+ vertexBuffer[this._vertexIndex++] = tint.r / 255;
202
+ vertexBuffer[this._vertexIndex++] = tint.g / 255;
203
+ vertexBuffer[this._vertexIndex++] = tint.b / 255;
204
+ vertexBuffer[this._vertexIndex++] = tint.a;
205
+ // (1, 1) - 3
206
+ vertexBuffer[this._vertexIndex++] = bottomRight.x;
207
+ vertexBuffer[this._vertexIndex++] = bottomRight.y;
208
+ vertexBuffer[this._vertexIndex++] = opacity;
209
+ vertexBuffer[this._vertexIndex++] = uvx1;
210
+ vertexBuffer[this._vertexIndex++] = uvy1;
211
+ vertexBuffer[this._vertexIndex++] = textureId;
212
+ vertexBuffer[this._vertexIndex++] = tint.r / 255;
213
+ vertexBuffer[this._vertexIndex++] = tint.g / 255;
214
+ vertexBuffer[this._vertexIndex++] = tint.b / 255;
215
+ vertexBuffer[this._vertexIndex++] = tint.a;
216
+ }
217
+ hasPendingDraws() {
218
+ return this._imageCount !== 0;
219
+ }
220
+ flush() {
221
+ // nothing to draw early exit
222
+ if (this._imageCount === 0) {
223
+ return;
224
+ }
225
+ const gl = this._gl;
226
+ // Bind the shader
227
+ this._shader.use();
228
+ // Bind the memory layout and upload data
229
+ this._layout.use(true, 4 * 10 * this._imageCount);
230
+ // Update ortho matrix uniform
231
+ this._shader.setUniformMatrix('u_matrix', this._context.ortho);
232
+ // Bind textures to
233
+ this._bindTextures(gl);
234
+ // Bind index buffer
235
+ this._quads.bind();
236
+ // Draw all the quads
237
+ gl.drawElements(gl.TRIANGLES, this._imageCount * 6, this._quads.bufferGlType, 0);
238
+ GraphicsDiagnostics.DrawnImagesCount += this._imageCount;
239
+ GraphicsDiagnostics.DrawCallCount++;
240
+ // Reset
241
+ this._imageCount = 0;
242
+ this._vertexIndex = 0;
243
+ this._textures.length = 0;
244
+ }
245
+ }
246
+ //# sourceMappingURL=image-renderer.js.map