excalibur 0.25.1 → 0.25.2

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 (254) hide show
  1. package/.nvmrc +1 -1
  2. package/CHANGELOG.md +119 -27
  3. package/README.md +0 -1
  4. package/build/dist/Actions/ActionsComponent.d.ts +1 -1
  5. package/build/dist/Actor.d.ts +46 -45
  6. package/build/dist/Camera.d.ts +10 -2
  7. package/build/dist/Class.d.ts +4 -5
  8. package/build/dist/Collision/BodyComponent.d.ts +6 -2
  9. package/build/dist/Collision/BoundingBox.d.ts +6 -0
  10. package/build/dist/Collision/ColliderComponent.d.ts +1 -4
  11. package/build/dist/Collision/Colliders/CircleCollider.d.ts +18 -2
  12. package/build/dist/Collision/Colliders/EdgeCollider.d.ts +1 -1
  13. package/build/dist/Collision/Colliders/SeparatingAxis.d.ts +2 -2
  14. package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
  15. package/build/dist/Collision/Detection/Pair.d.ts +5 -1
  16. package/build/dist/Collision/Group/CollisionGroup.d.ts +0 -1
  17. package/build/dist/Collision/MotionSystem.d.ts +4 -0
  18. package/build/dist/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
  19. package/build/dist/Collision/Solver/Solver.d.ts +1 -1
  20. package/build/dist/Debug/Debug.d.ts +18 -1
  21. package/build/dist/Debug/DebugFlags.d.ts +16 -3
  22. package/build/dist/Engine.d.ts +66 -8
  23. package/build/dist/EntityComponentSystem/Component.d.ts +3 -3
  24. package/build/dist/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
  25. package/build/dist/EntityComponentSystem/Entity.d.ts +4 -4
  26. package/build/dist/EntityComponentSystem/System.d.ts +1 -1
  27. package/build/dist/EntityComponentSystem/SystemManager.d.ts +6 -1
  28. package/build/dist/EventDispatcher.d.ts +0 -5
  29. package/build/dist/Events/ExEvent.d.ts +6 -0
  30. package/build/dist/Events/PointerEvents.d.ts +37 -0
  31. package/build/dist/Graphics/Animation.d.ts +3 -2
  32. package/build/dist/Graphics/Circle.d.ts +2 -0
  33. package/build/dist/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
  34. package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
  35. package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
  36. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
  37. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +53 -0
  38. package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -0
  39. package/build/dist/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
  40. package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +28 -0
  41. package/build/dist/Graphics/Context/{shaders/image-vertex.glsl → image-renderer/image-renderer.vert.glsl} +2 -7
  42. package/build/dist/Graphics/Context/{shaders → line-renderer}/line-fragment.glsl +0 -0
  43. package/build/dist/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
  44. package/build/dist/Graphics/Context/{shaders → line-renderer}/line-vertex.glsl +2 -2
  45. package/build/dist/Graphics/Context/{shaders → point-renderer}/point-fragment.glsl +6 -2
  46. package/build/dist/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
  47. package/build/dist/Graphics/Context/{shaders → point-renderer}/point-vertex.glsl +2 -2
  48. package/build/dist/Graphics/Context/quad-index-buffer.d.ts +36 -0
  49. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
  50. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -0
  51. package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -0
  52. package/build/dist/Graphics/Context/render-source.d.ts +7 -0
  53. package/build/dist/Graphics/Context/render-target.d.ts +26 -0
  54. package/build/dist/Graphics/Context/renderer.d.ts +20 -51
  55. package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +11 -0
  56. package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
  57. package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -0
  58. package/build/dist/Graphics/Context/shader.d.ts +116 -42
  59. package/build/dist/Graphics/Context/shaders/crt-effect.glsl +64 -0
  60. package/build/dist/Graphics/Context/shaders/grayscale-fragment.glsl +13 -0
  61. package/build/dist/Graphics/Context/shaders/invert-fragment.glsl +12 -0
  62. package/build/dist/Graphics/Context/texture-loader.d.ts +8 -2
  63. package/build/dist/Graphics/Context/vertex-buffer.d.ts +49 -0
  64. package/build/dist/Graphics/Context/vertex-layout.d.ts +52 -0
  65. package/build/dist/Graphics/Context/webgl-adapter.d.ts +9 -0
  66. package/build/dist/Graphics/Context/webgl-util.d.ts +22 -0
  67. package/build/dist/Graphics/DebugGraphicsComponent.d.ts +13 -0
  68. package/build/dist/Graphics/Filtering.d.ts +15 -0
  69. package/build/dist/Graphics/Font.d.ts +61 -23
  70. package/build/dist/Graphics/FontCommon.d.ts +43 -2
  71. package/build/dist/Graphics/Graphic.d.ts +23 -9
  72. package/build/dist/Graphics/GraphicsSystem.d.ts +0 -1
  73. package/build/dist/Graphics/ImageSource.d.ts +8 -3
  74. package/build/dist/Graphics/Polygon.d.ts +2 -0
  75. package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
  76. package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
  77. package/build/dist/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
  78. package/build/dist/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
  79. package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +62 -0
  80. package/build/dist/Graphics/Raster.d.ts +32 -5
  81. package/build/dist/Graphics/Sprite.d.ts +5 -0
  82. package/build/dist/Graphics/SpriteFont.d.ts +6 -7
  83. package/build/dist/Graphics/SpriteSheet.d.ts +1 -2
  84. package/build/dist/Graphics/Text.d.ts +18 -2
  85. package/build/dist/Graphics/index.d.ts +14 -0
  86. package/build/dist/Id.d.ts +1 -1
  87. package/build/dist/Input/EngineInput.d.ts +2 -2
  88. package/build/dist/Input/Index.d.ts +10 -3
  89. package/build/dist/Input/NativePointerButton.d.ts +10 -0
  90. package/build/dist/Input/PointerAbstraction.d.ts +33 -0
  91. package/build/dist/Input/PointerButton.d.ts +10 -0
  92. package/build/dist/Input/PointerComponent.d.ts +24 -0
  93. package/build/dist/Input/PointerEvent.d.ts +18 -0
  94. package/build/dist/Input/PointerEventReceiver.d.ts +114 -0
  95. package/build/dist/Input/PointerScope.d.ts +14 -0
  96. package/build/dist/Input/PointerSystem.d.ts +43 -0
  97. package/build/dist/Input/PointerType.d.ts +9 -0
  98. package/build/dist/Input/WheelDeltaMode.d.ts +5 -0
  99. package/build/dist/Input/WheelEvent.d.ts +18 -0
  100. package/build/dist/Interfaces/PointerEventHandlers.d.ts +17 -16
  101. package/build/dist/Label.d.ts +9 -2
  102. package/build/dist/Loader.d.ts +5 -2
  103. package/build/dist/Math/Index.d.ts +1 -0
  104. package/build/dist/Math/matrix.d.ts +19 -1
  105. package/build/dist/Math/util.d.ts +45 -0
  106. package/build/dist/Particles.d.ts +12 -0
  107. package/build/dist/Resources/Gif.d.ts +1 -1
  108. package/build/dist/Scene.d.ts +10 -1
  109. package/build/dist/Screen.d.ts +4 -3
  110. package/build/dist/TileMap.d.ts +3 -2
  111. package/build/dist/Traits/Index.d.ts +0 -1
  112. package/build/dist/Trigger.d.ts +4 -0
  113. package/build/dist/Util/Clock.d.ts +118 -0
  114. package/build/dist/Util/Fps.d.ts +40 -0
  115. package/build/dist/Util/Observable.d.ts +1 -1
  116. package/build/dist/Util/Pool.d.ts +2 -10
  117. package/build/dist/Util/Util.d.ts +23 -66
  118. package/build/dist/excalibur.js +9124 -7580
  119. package/build/dist/excalibur.js.map +1 -1
  120. package/build/dist/excalibur.min.js +1 -1
  121. package/build/dist/excalibur.min.js.LICENSE.txt +2 -2
  122. package/build/dist/excalibur.min.js.map +1 -1
  123. package/build/dist/index.d.ts +5 -2
  124. package/build/esm/Actions/ActionsComponent.d.ts +1 -1
  125. package/build/esm/Actor.d.ts +46 -45
  126. package/build/esm/Camera.d.ts +10 -2
  127. package/build/esm/Class.d.ts +4 -5
  128. package/build/esm/Collision/BodyComponent.d.ts +6 -2
  129. package/build/esm/Collision/BoundingBox.d.ts +6 -0
  130. package/build/esm/Collision/ColliderComponent.d.ts +1 -4
  131. package/build/esm/Collision/Colliders/CircleCollider.d.ts +18 -2
  132. package/build/esm/Collision/Colliders/EdgeCollider.d.ts +1 -1
  133. package/build/esm/Collision/Colliders/SeparatingAxis.d.ts +2 -2
  134. package/build/esm/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
  135. package/build/esm/Collision/Detection/Pair.d.ts +5 -1
  136. package/build/esm/Collision/Group/CollisionGroup.d.ts +0 -1
  137. package/build/esm/Collision/MotionSystem.d.ts +4 -0
  138. package/build/esm/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
  139. package/build/esm/Collision/Solver/Solver.d.ts +1 -1
  140. package/build/esm/Debug/Debug.d.ts +18 -1
  141. package/build/esm/Debug/DebugFlags.d.ts +16 -3
  142. package/build/esm/Engine.d.ts +66 -8
  143. package/build/esm/EntityComponentSystem/Component.d.ts +3 -3
  144. package/build/esm/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
  145. package/build/esm/EntityComponentSystem/Entity.d.ts +4 -4
  146. package/build/esm/EntityComponentSystem/System.d.ts +1 -1
  147. package/build/esm/EntityComponentSystem/SystemManager.d.ts +6 -1
  148. package/build/esm/EventDispatcher.d.ts +0 -5
  149. package/build/esm/Events/ExEvent.d.ts +6 -0
  150. package/build/esm/Events/PointerEvents.d.ts +37 -0
  151. package/build/esm/Graphics/Animation.d.ts +3 -2
  152. package/build/esm/Graphics/Circle.d.ts +2 -0
  153. package/build/esm/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
  154. package/build/esm/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
  155. package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
  156. package/build/esm/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
  157. package/build/esm/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
  158. package/build/esm/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
  159. package/build/esm/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
  160. package/build/esm/Graphics/Context/quad-index-buffer.d.ts +36 -0
  161. package/build/esm/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
  162. package/build/esm/Graphics/Context/render-source.d.ts +7 -0
  163. package/build/esm/Graphics/Context/render-target.d.ts +26 -0
  164. package/build/esm/Graphics/Context/renderer.d.ts +20 -51
  165. package/build/esm/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
  166. package/build/esm/Graphics/Context/shader.d.ts +116 -42
  167. package/build/esm/Graphics/Context/texture-loader.d.ts +8 -2
  168. package/build/esm/Graphics/Context/vertex-buffer.d.ts +49 -0
  169. package/build/esm/Graphics/Context/vertex-layout.d.ts +52 -0
  170. package/build/esm/Graphics/Context/webgl-adapter.d.ts +9 -0
  171. package/build/esm/Graphics/Context/webgl-util.d.ts +22 -0
  172. package/build/esm/Graphics/DebugGraphicsComponent.d.ts +13 -0
  173. package/build/esm/Graphics/Filtering.d.ts +15 -0
  174. package/build/esm/Graphics/Font.d.ts +61 -23
  175. package/build/esm/Graphics/FontCommon.d.ts +43 -2
  176. package/build/esm/Graphics/Graphic.d.ts +23 -9
  177. package/build/esm/Graphics/GraphicsSystem.d.ts +0 -1
  178. package/build/esm/Graphics/ImageSource.d.ts +8 -3
  179. package/build/esm/Graphics/Polygon.d.ts +2 -0
  180. package/build/esm/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
  181. package/build/esm/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
  182. package/build/esm/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
  183. package/build/esm/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
  184. package/build/esm/Graphics/Raster.d.ts +32 -5
  185. package/build/esm/Graphics/Sprite.d.ts +5 -0
  186. package/build/esm/Graphics/SpriteFont.d.ts +6 -7
  187. package/build/esm/Graphics/SpriteSheet.d.ts +1 -2
  188. package/build/esm/Graphics/Text.d.ts +18 -2
  189. package/build/esm/Graphics/index.d.ts +14 -0
  190. package/build/esm/Id.d.ts +1 -1
  191. package/build/esm/Input/EngineInput.d.ts +2 -2
  192. package/build/esm/Input/Index.d.ts +10 -3
  193. package/build/esm/Input/NativePointerButton.d.ts +10 -0
  194. package/build/esm/Input/PointerAbstraction.d.ts +33 -0
  195. package/build/esm/Input/PointerButton.d.ts +10 -0
  196. package/build/esm/Input/PointerComponent.d.ts +24 -0
  197. package/build/esm/Input/PointerEvent.d.ts +18 -0
  198. package/build/esm/Input/PointerEventReceiver.d.ts +114 -0
  199. package/build/esm/Input/PointerScope.d.ts +14 -0
  200. package/build/esm/Input/PointerSystem.d.ts +43 -0
  201. package/build/esm/Input/PointerType.d.ts +9 -0
  202. package/build/esm/Input/WheelDeltaMode.d.ts +5 -0
  203. package/build/esm/Input/WheelEvent.d.ts +18 -0
  204. package/build/esm/Interfaces/PointerEventHandlers.d.ts +17 -16
  205. package/build/esm/Label.d.ts +9 -2
  206. package/build/esm/Loader.d.ts +5 -2
  207. package/build/esm/Math/Index.d.ts +1 -0
  208. package/build/esm/Math/matrix.d.ts +19 -1
  209. package/build/esm/Math/util.d.ts +45 -0
  210. package/build/esm/Particles.d.ts +12 -0
  211. package/build/esm/Resources/Gif.d.ts +1 -1
  212. package/build/esm/Scene.d.ts +10 -1
  213. package/build/esm/Screen.d.ts +4 -3
  214. package/build/esm/TileMap.d.ts +3 -2
  215. package/build/esm/Traits/Index.d.ts +0 -1
  216. package/build/esm/Trigger.d.ts +4 -0
  217. package/build/esm/Util/Clock.d.ts +118 -0
  218. package/build/esm/Util/Fps.d.ts +40 -0
  219. package/build/esm/Util/Observable.d.ts +1 -1
  220. package/build/esm/Util/Pool.d.ts +2 -10
  221. package/build/esm/Util/Util.d.ts +23 -66
  222. package/build/esm/excalibur.js +9001 -7438
  223. package/build/esm/excalibur.js.map +1 -1
  224. package/build/esm/excalibur.min.js +1 -1
  225. package/build/esm/excalibur.min.js.LICENSE.txt +2 -2
  226. package/build/esm/excalibur.min.js.map +1 -1
  227. package/build/esm/index.d.ts +5 -2
  228. package/package.json +31 -27
  229. package/build/dist/Graphics/Context/batch.d.ts +0 -11
  230. package/build/dist/Graphics/Context/draw-image-command.d.ts +0 -47
  231. package/build/dist/Graphics/Context/image-renderer.d.ts +0 -39
  232. package/build/dist/Graphics/Context/line-renderer.d.ts +0 -22
  233. package/build/dist/Graphics/Context/point-renderer.d.ts +0 -22
  234. package/build/dist/Graphics/Context/shaders/image-fragment.glsl +0 -48
  235. package/build/dist/Input/Pointer.d.ts +0 -134
  236. package/build/dist/Input/PointerEvents.d.ts +0 -170
  237. package/build/dist/Input/Pointers.d.ts +0 -78
  238. package/build/dist/PostProcessing/ColorBlindCorrector.d.ts +0 -28
  239. package/build/dist/PostProcessing/Index.d.ts +0 -2
  240. package/build/dist/PostProcessing/PostProcessor.d.ts +0 -6
  241. package/build/dist/Traits/CapturePointer.d.ts +0 -10
  242. package/build/esm/Graphics/Context/batch.d.ts +0 -11
  243. package/build/esm/Graphics/Context/draw-image-command.d.ts +0 -47
  244. package/build/esm/Graphics/Context/image-renderer.d.ts +0 -39
  245. package/build/esm/Graphics/Context/line-renderer.d.ts +0 -22
  246. package/build/esm/Graphics/Context/point-renderer.d.ts +0 -22
  247. package/build/esm/Input/Pointer.d.ts +0 -134
  248. package/build/esm/Input/PointerEvents.d.ts +0 -170
  249. package/build/esm/Input/Pointers.d.ts +0 -78
  250. package/build/esm/PostProcessing/ColorBlindCorrector.d.ts +0 -28
  251. package/build/esm/PostProcessing/Index.d.ts +0 -2
  252. package/build/esm/PostProcessing/PostProcessor.d.ts +0 -6
  253. package/build/esm/Traits/CapturePointer.d.ts +0 -10
  254. package/wallaby.js +0 -77
@@ -0,0 +1,42 @@
1
+ attribute vec2 a_position;
2
+
3
+ // UV coordinate
4
+ attribute vec2 a_uv;
5
+ varying vec2 v_uv;
6
+
7
+ attribute vec2 a_size;
8
+ varying vec2 v_size;
9
+
10
+ // Opacity
11
+ attribute float a_opacity;
12
+ varying float v_opacity;
13
+
14
+ attribute vec4 a_color;
15
+ varying vec4 v_color;
16
+
17
+ attribute vec4 a_strokeColor;
18
+ varying vec4 v_strokeColor;
19
+
20
+ attribute float a_strokeThickness;
21
+ varying float v_strokeThickness;
22
+
23
+ uniform mat4 u_matrix;
24
+
25
+
26
+ void main() {
27
+ // Set the vertex position using the ortho transform matrix
28
+ gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
29
+
30
+ // Pass through UV coords
31
+ v_uv = a_uv;
32
+ // Pass through size
33
+ v_size = a_size;
34
+ // Pass through the Opacity to the fragment shader
35
+ v_opacity = a_opacity;
36
+ // Pass through the color to the fragment shader
37
+ v_color = a_color;
38
+ // Pass through the stroke color to the fragment shader
39
+ v_strokeColor = a_strokeColor;
40
+ // Pass through the stroke thickenss to the fragment shader
41
+ v_strokeThickness = a_strokeThickness;
42
+ }
@@ -0,0 +1,7 @@
1
+ export declare class RenderSource {
2
+ private _gl;
3
+ private _texture;
4
+ constructor(_gl: WebGLRenderingContext, _texture: WebGLTexture);
5
+ use(): void;
6
+ disable(): void;
7
+ }
@@ -0,0 +1,26 @@
1
+ import { RenderSource } from './render-source';
2
+ export declare class RenderTarget {
3
+ width: number;
4
+ height: number;
5
+ private _gl;
6
+ constructor(options: {
7
+ gl: WebGLRenderingContext;
8
+ width: number;
9
+ height: number;
10
+ });
11
+ setResolution(width: number, height: number): void;
12
+ private _frameBuffer;
13
+ get frameBuffer(): WebGLFramebuffer;
14
+ private _frameTexture;
15
+ get frameTexture(): WebGLTexture;
16
+ private _setupFramebuffer;
17
+ toRenderSource(): RenderSource;
18
+ /**
19
+ * When called, all drawing gets redirected to this render target
20
+ */
21
+ use(): void;
22
+ /**
23
+ * When called, all drawing is sent back to the canvas
24
+ */
25
+ disable(): void;
26
+ }
@@ -1,66 +1,35 @@
1
- import { BatchCommand } from './batch';
2
- import { Shader } from './shader';
3
- import { Pool, Poolable } from '../../Util/Pool';
4
- export interface Renderer {
5
- render(): void;
6
- }
7
- export interface Ctor<T> {
8
- new (): T;
9
- }
10
- export interface BatchRendererOptions<T extends Poolable> {
11
- gl: WebGLRenderingContext;
1
+ import { ExcaliburGraphicsContextWebGL } from './ExcaliburGraphicsContextWebGL';
2
+ /**
3
+ * Interface that defines an Excalibur Renderer that can be called with .draw() in the [[ExcaliburGraphicsContext]]
4
+ */
5
+ export interface RendererPlugin {
12
6
  /**
13
- * Draw command constructor
7
+ * Unique type name for this renderer plugin
14
8
  */
15
- command: Ctor<T>;
9
+ readonly type: string;
16
10
  /**
17
- * Number of vertices that are generated per draw command
11
+ * Render priority tie breaker when drawings are at the same z index
12
+ * @warning Not yet used by excalibur
18
13
  */
19
- verticesPerCommand?: number;
20
- /**
21
- * Maximum commands to batch before drawing
22
- */
23
- maxCommandsPerBatch?: number;
24
- /**
25
- * Override the built in command batching mechanism
26
- */
27
- batchFactory?: () => BatchCommand<T>;
28
- }
29
- export declare abstract class BatchRenderer<T extends Poolable> implements Renderer {
30
14
  priority: number;
31
- private _gl;
32
- private _vertices;
33
- private _verticesPerCommand;
34
- private _buffer;
35
- private _maxCommandsPerBatch;
36
- shader: Shader;
37
- commands: Pool<T>;
38
- private _batchPool;
39
- private _batches;
40
- constructor(options: BatchRendererOptions<T>);
41
- /**
42
- * Initialize render, builds shader and initialized webgl buffers
43
- */
44
- init(): void;
45
- get vertexSize(): number;
46
- addCommand(cmd: T): void;
47
15
  /**
48
- * Construct or return the Shader to be used in this batch renderer
16
+ * Initialize your renderer
17
+ *
49
18
  * @param gl
19
+ * @param context
50
20
  */
51
- abstract buildShader(gl: WebGLRenderingContext): Shader;
21
+ initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
52
22
  /**
53
- * Implement populating the vertex buffer, return the number of vertices added to the buffer
54
- * @param vertices
55
- * @param batch
23
+ * Issue a draw command to draw something to the screen
24
+ * @param args
56
25
  */
57
- abstract buildBatchVertices(vertexBuffer: Float32Array, batch: BatchCommand<T>): number;
26
+ draw(...args: any[]): void;
58
27
  /**
59
- * Implement gl draw call to render batch. The vertextBuffer from buildBatchVertices is already bound and the data has been updated.
28
+ * @returns if there are any pending draws in the renderer
60
29
  */
61
- abstract renderBatch(gl: WebGLRenderingContext, batch: BatchCommand<T>, vertexCount: number): void;
30
+ hasPendingDraws(): boolean;
62
31
  /**
63
- * Build batch geometry, submit to the gpu, and issue draw command to underlying webgl
32
+ * Flush any pending graphics draws to the screen
64
33
  */
65
- render(): void;
34
+ flush(): void;
66
35
  }
@@ -0,0 +1,11 @@
1
+ precision mediump float;
2
+
3
+ // Passed in from the vertex shader.
4
+ varying vec2 v_texcoord;
5
+
6
+ // The texture.
7
+ uniform sampler2D u_texture;
8
+
9
+ void main() {
10
+ gl_FragColor = texture2D(u_texture, v_texcoord);
11
+ }
@@ -0,0 +1,13 @@
1
+ import { PostProcessor } from '../../PostProcessor/PostProcessor';
2
+ /**
3
+ * This is responsible for painting the entire screen during the render passes
4
+ */
5
+ export declare class ScreenPassPainter {
6
+ private _gl;
7
+ private _shader;
8
+ private _buffer;
9
+ private _layout;
10
+ constructor(gl: WebGLRenderingContext);
11
+ renderWithPostProcessor(postprocessor: PostProcessor): void;
12
+ renderToScreen(): void;
13
+ }
@@ -0,0 +1,11 @@
1
+ attribute vec2 a_position;
2
+
3
+ attribute vec2 a_texcoord;
4
+ varying vec2 v_texcoord;
5
+
6
+ void main() {
7
+ gl_Position = vec4(a_position, 0.0, 1.0);
8
+
9
+ // Pass the texcoord to the fragment shader.
10
+ v_texcoord = a_texcoord;
11
+ }
@@ -1,81 +1,155 @@
1
+ import { Vector } from '../..';
2
+ import { Matrix } from '../../Math/matrix';
3
+ export declare type UniformTypeNames = 'uniform1f' | 'uniform1i' | 'uniform2f' | 'uniform2i' | 'uniform3f' | 'uniform3i' | 'uniform4f' | 'uniform4i' | 'uniform1fv' | 'uniform1iv' | 'uniform2fv' | 'uniform2iv' | 'uniform3fv' | 'uniform3iv' | 'uniform4fv' | 'uniform4iv' | 'uniformMatrix2fv' | 'uniformMatrix3fv' | 'uniformMatrix4fv';
4
+ declare type RemoveFirstFromTuple<T extends any[]> = T['length'] extends 0 ? undefined : (((...b: T) => void) extends (a: any, ...b: infer I) => void ? I : []);
5
+ declare type UniformParameters<TUniformType extends UniformTypeNames> = RemoveFirstFromTuple<Parameters<WebGLRenderingContext[TUniformType]>>;
6
+ export interface UniformDefinition {
7
+ name: string;
8
+ glType: number;
9
+ location: WebGLUniformLocation;
10
+ }
1
11
  export interface VertexAttributeDefinition {
12
+ /**
13
+ * string name of the attribute in the shader program, commonly `a_nameofmyvariable`
14
+ */
2
15
  name: string;
16
+ /**
17
+ * Number of components for a given attribute
18
+ * Must be 1, 2, 3, or 4
19
+ *
20
+ * For example a vec4 attribute would be `4` floats, so 4
21
+ */
3
22
  size: number;
23
+ /**
24
+ * Supported types in webgl 1
25
+ * * gl.BYTE
26
+ * * gl.SHORT
27
+ * * gl.UNSIGNED_BYTE
28
+ * * gl.UNSIGNED_SHORT
29
+ * * gl.FLOAT
30
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
31
+ */
4
32
  glType: number;
33
+ /**
34
+ * Is the attribute normalized between (0-1)
35
+ */
5
36
  normalized: boolean;
37
+ /**
38
+ * Location index in the shader program
39
+ */
6
40
  location: number;
7
41
  }
8
- export interface UniformDefinition {
9
- name: string;
10
- location: WebGLUniformLocation;
11
- type: string;
12
- data: any;
42
+ export interface ShaderOptions {
43
+ vertexSource: string;
44
+ fragmentSource: string;
13
45
  }
14
- /**
15
- * Create a shader program for the Excalibur WebGL Graphics Context
16
- */
17
46
  export declare class Shader {
47
+ private static _ACTIVE_SHADER_INSTANCE;
18
48
  private _gl;
19
- private _vertexSource;
20
- private _fragmentSource;
21
- program: WebGLProgram | null;
49
+ program: WebGLProgram;
22
50
  uniforms: {
23
51
  [variableName: string]: UniformDefinition;
24
52
  };
25
53
  attributes: {
26
54
  [variableName: string]: VertexAttributeDefinition;
27
55
  };
28
- layout: VertexAttributeDefinition[];
56
+ private _compiled;
57
+ readonly vertexSource: string;
58
+ readonly fragmentSource: string;
59
+ get compiled(): boolean;
29
60
  /**
30
61
  * Create a shader program in excalibur
31
- * @param _gl WebGL graphics context
32
- * @param _vertexSource Vertex shader source as a string
33
- * @param _fragmentSource Fragment shader source as a string
62
+ * @param options specify shader vertex and fragment source
34
63
  */
35
- constructor(_gl: WebGLRenderingContext, _vertexSource: string, _fragmentSource: string);
36
- private _createProgram;
37
- private _compileShader;
64
+ constructor(options?: ShaderOptions);
65
+ /**
66
+ * Binds the shader program
67
+ */
68
+ use(): void;
69
+ isCurrentlyBound(): boolean;
38
70
  /**
39
71
  * Compile the current shader against a webgl context
40
- * @param gl WebGL context
41
72
  */
42
- compile(gl: WebGLRenderingContext): WebGLProgram;
73
+ compile(): WebGLProgram;
74
+ getUniforms(): UniformDefinition[];
75
+ getAttributes(): VertexAttributeDefinition[];
43
76
  /**
44
- * Add a uniform [[Matrix]] to the shader
45
- * @param name Name of the uniform in the shader source
46
- * @param data (4x4) matrix in column major order
77
+ * Set a texture in a gpu texture slot
78
+ * @param slotNumber
79
+ * @param texture
47
80
  */
48
- addUniformMatrix(name: string, data: Float32Array): void;
81
+ setTexture(slotNumber: number, texture: WebGLTexture): void;
49
82
  /**
50
- * Add a uniform array of numbers to the shader
51
- * @param name Name of the uniform in the shader source
52
- * @param data List of numbers
83
+ * Set an integer uniform for the current shader
84
+ *
85
+ * **Important** Must call ex.Shader.use() before setting a uniform!
86
+ *
87
+ * @param name
88
+ * @param value
53
89
  */
54
- addUniformIntegerArray(name: string, data: number[]): void;
90
+ setUniformInt(name: string, value: number): void;
55
91
  /**
56
- * Add attributes in the order they appear in the VBO
57
- * @param name Name of the attribute in the shader source
58
- * @param size The size of the attribute in gl.Type units, for example `vec2 a_pos` would be 2 gl.FLOAT
59
- * @param glType The gl.Type of the attribute
92
+ * Set an integer array uniform for the current shader
93
+ *
94
+ * **Important** Must call ex.Shader.use() before setting a uniform!
95
+ *
96
+ * @param name
97
+ * @param value
60
98
  */
61
- addAttribute(name: string, size: number, glType: number, normalized?: boolean): void;
99
+ setUniformIntArray(name: string, value: number[]): void;
62
100
  /**
63
- * Number of javascript floats a vertex will take up
101
+ * Set a boolean uniform for the current shader
102
+ *
103
+ * **Important** Must call ex.Shader.use() before setting a uniform!
104
+ *
105
+ * @param name
106
+ * @param value
64
107
  */
65
- get vertexAttributeSize(): number;
108
+ setUniformBoolean(name: string, value: boolean): void;
66
109
  /**
67
- * Total number of bytes that the vertex will take up
110
+ * Set a float uniform for the current shader
111
+ *
112
+ * **Important** Must call ex.Shader.use() before setting a uniform!
113
+ *
114
+ * @param name
115
+ * @param value
68
116
  */
69
- get totalVertexSizeBytes(): number;
117
+ setUniformFloat(name: string, value: number): void;
70
118
  /**
71
- * Get a previously defined attribute size in bytes
119
+ * Set a float array uniform for the current shader
120
+ *
121
+ * **Important** Must call ex.Shader.use() before setting a uniform!
122
+ *
72
123
  * @param name
124
+ * @param value
73
125
  */
74
- getAttributeSize(name: string): number;
126
+ setUniformFloatArray(name: string, value: number[]): void;
75
127
  /**
76
- * Sets this shader program as the current in the underlying webgl context
128
+ * Set a [[Vector]] uniform for the current shader
129
+ *
130
+ * **Important** Must call ex.Shader.use() before setting a uniform!
77
131
  *
78
- * **Must** specify all attributes and uniforms before calling this
132
+ * @param name
133
+ * @param value
79
134
  */
80
- use(): void;
135
+ setUniformFloatVector(name: string, value: Vector): void;
136
+ /**
137
+ * Set an [[Matrix]] uniform for the current shader
138
+ *
139
+ * **Important** Must call ex.Shader.use() before setting a uniform!
140
+ *
141
+ * @param name
142
+ * @param value
143
+ */
144
+ setUniformMatrix(name: string, value: Matrix): void;
145
+ /**
146
+ * Set any available uniform type in webgl
147
+ *
148
+ * For example setUniform('uniformMatrix2fv', 'u_my2x2_mat`, ...);
149
+ */
150
+ setUniform<TUniformType extends UniformTypeNames>(uniformType: TUniformType, name: string, ...value: UniformParameters<TUniformType>): void;
151
+ private _createProgram;
152
+ private _compileShader;
153
+ private _processSourceForError;
81
154
  }
155
+ export {};
@@ -0,0 +1,64 @@
1
+ // https://www.shadertoy.com/view/Ms23DR
2
+ precision mediump float;
3
+
4
+ // Passed in from the vertex shader.
5
+ varying vec2 v_texcoord;
6
+
7
+ // The texture.
8
+ uniform sampler2D u_texture;
9
+
10
+ vec2 curve(vec2 uv)
11
+ {
12
+ uv = (uv - 0.5) * 2.0;
13
+ uv *= 1.1;
14
+ uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);
15
+ uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);
16
+ uv = (uv / 2.0) + 0.5;
17
+ uv = uv *0.92 + 0.04;
18
+ return uv;
19
+ }
20
+ void main()
21
+ {
22
+ vec2 uv = vec2(v_texcoord.x, v_texcoord.y);
23
+ uv = curve( uv );
24
+ vec3 oricol = texture2D(u_texture, uv).xyz;
25
+ float iTime = 10.0;
26
+ vec2 iResolution = vec2(1200, 900);
27
+ vec3 col;
28
+ float x = sin(0.3*iTime+uv.y*21.0)*sin(0.7*iTime+uv.y*29.0)*sin(0.3+0.33*iTime+uv.y*31.0)*0.0017;
29
+
30
+ col.r = texture2D(u_texture,vec2(x+uv.x+0.001,uv.y+0.001)).x+0.05;
31
+ col.g = texture2D(u_texture,vec2(x+uv.x+0.000,uv.y-0.002)).y+0.05;
32
+ col.b = texture2D(u_texture,vec2(x+uv.x-0.002,uv.y+0.000)).z+0.05;
33
+ col.r += 0.08*texture2D(u_texture,0.75*vec2(x+0.025, -0.027)+vec2(uv.x+0.001,uv.y+0.001)).x;
34
+ col.g += 0.05*texture2D(u_texture,0.75*vec2(x+-0.022, -0.02)+vec2(uv.x+0.000,uv.y-0.002)).y;
35
+ col.b += 0.08*texture2D(u_texture,0.75*vec2(x+-0.02, -0.018)+vec2(uv.x-0.002,uv.y+0.000)).z;
36
+
37
+ col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0);
38
+
39
+ float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y));
40
+ col *= vec3(pow(vig,0.3));
41
+
42
+ col *= vec3(0.95,1.05,0.95);
43
+ col *= 2.8;
44
+
45
+ float scans = clamp( 0.35+0.35*sin(3.5*iTime+uv.y*iResolution.y*1.5), 0.0, 1.0);
46
+
47
+ float s = pow(scans,1.7);
48
+ col = col*vec3( 0.4+0.7*s) ;
49
+
50
+ col *= 1.0+0.01*sin(110.0*iTime);
51
+ if (uv.x < 0.0 || uv.x > 1.0)
52
+ col *= 0.0;
53
+ if (uv.y < 0.0 || uv.y > 1.0)
54
+ col *= 0.0;
55
+
56
+ col*=1.0-0.65*vec3(clamp((mod(gl_FragCoord.x, 2.0)-1.0)*2.0,0.0,1.0));
57
+
58
+ float comp = smoothstep( 0.1, 0.9, sin(iTime) );
59
+
60
+ // Remove the next line to stop cross-fade between original and postprocess
61
+ // col = mix( col, oricol, comp );
62
+
63
+ gl_FragColor = vec4(col,1.0);
64
+ }
@@ -0,0 +1,13 @@
1
+ precision mediump float;
2
+
3
+ // Passed in from the vertex shader.
4
+ varying vec2 v_texcoord;
5
+
6
+ // The texture.
7
+ uniform sampler2D u_texture;
8
+
9
+ void main() {
10
+ vec4 tex = texture2D(u_texture, vec2(v_texcoord.x, 1.0 - v_texcoord.y));
11
+ float avg = 0.2126 * tex.r + 0.7152 * tex.g + 0.0722 * tex.b;
12
+ gl_FragColor = vec4(avg, avg, avg, 1.0);
13
+ }
@@ -0,0 +1,12 @@
1
+ precision mediump float;
2
+
3
+ // Passed in from the vertex shader.
4
+ varying vec2 v_texcoord;
5
+
6
+ // The texture.
7
+ uniform sampler2D u_texture;
8
+
9
+ void main() {
10
+ vec4 tex = texture2D(u_texture, vec2(v_texcoord.x, 1.0 - v_texcoord.y));
11
+ gl_FragColor = vec4(vec3(1.0, 1.0, 1.0) - tex.rgb, tex.a);
12
+ }
@@ -1,13 +1,18 @@
1
+ import { ImageFiltering } from '../Filtering';
1
2
  import { HTMLImageSource } from './ExcaliburGraphicsContext';
2
3
  /**
3
4
  * Manages loading image sources into webgl textures, a unique id is associated with all sources
4
5
  */
5
6
  export declare class TextureLoader {
7
+ /**
8
+ * Sets the default filtering for the Excalibur texture loader, default [[ImageFiltering.Blended]]
9
+ */
10
+ static filtering: ImageFiltering;
6
11
  private static _POT_CANVAS;
7
12
  private static _POT_CTX;
8
13
  private static _GL;
9
14
  private static _TEXTURE_MAP;
10
- static registerContext(context: WebGLRenderingContext): void;
15
+ static register(context: WebGLRenderingContext): void;
11
16
  /**
12
17
  * Get the WebGL Texture from a source image
13
18
  * @param image
@@ -21,9 +26,10 @@ export declare class TextureLoader {
21
26
  /**
22
27
  * Loads a graphic into webgl and returns it's texture info, a webgl context must be previously registered
23
28
  * @param image Source graphic
29
+ * @param filtering {ImageFiltering} The ImageFiltering mode to apply to the loaded texture
24
30
  * @param forceUpdate Optionally force a texture to be reloaded, useful if the source graphic has changed
25
31
  */
26
- static load(image: HTMLImageSource, forceUpdate?: boolean): WebGLTexture;
32
+ static load(image: HTMLImageSource, filtering?: ImageFiltering, forceUpdate?: boolean): WebGLTexture;
27
33
  /**
28
34
  * Converts source images into power of two images, WebGL only supports POT images
29
35
  * https://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support
@@ -0,0 +1,49 @@
1
+ export interface VertexBufferOptions {
2
+ /**
3
+ * Size in number of floats, so [4.2, 4.0, 2.1] is size = 3
4
+ *
5
+ * Ignored if data is passed directly
6
+ */
7
+ size?: number;
8
+ /**
9
+ * If the vertices never change switching 'static' can be more efficient on the gpu
10
+ *
11
+ * Default is 'dynamic'
12
+ */
13
+ type?: 'static' | 'dynamic';
14
+ /**
15
+ * Optionally pass pre-seeded data, size parameter is ignored
16
+ */
17
+ data?: Float32Array;
18
+ }
19
+ /**
20
+ * Helper around vertex buffer to simplify creating and uploading geometry
21
+ *
22
+ * Under the hood uses Float32Array
23
+ */
24
+ export declare class VertexBuffer {
25
+ private _gl;
26
+ /**
27
+ * Access to the webgl buffer handle
28
+ */
29
+ readonly buffer: WebGLBuffer;
30
+ /**
31
+ * Access to the raw data of the vertex buffer
32
+ */
33
+ readonly bufferData: Float32Array;
34
+ /**
35
+ * If the vertices never change switching 'static' can be more efficient on the gpu
36
+ *
37
+ * Default is 'dynamic'
38
+ */
39
+ type: 'static' | 'dynamic';
40
+ constructor(options: VertexBufferOptions);
41
+ /**
42
+ * Bind this vertex buffer
43
+ */
44
+ bind(): void;
45
+ /**
46
+ * Upload vertex buffer geometry to the GPU
47
+ */
48
+ upload(): void;
49
+ }
@@ -0,0 +1,52 @@
1
+ import { Shader } from './shader';
2
+ import { VertexBuffer } from './vertex-buffer';
3
+ export interface VertexLayoutOptions {
4
+ /**
5
+ * Shader that this layout will be for
6
+ */
7
+ shader: Shader;
8
+ /**
9
+ * Vertex buffer to use for vertex data
10
+ */
11
+ vertexBuffer: VertexBuffer;
12
+ /**
13
+ * Specify the attributes that will exist in the vertex buffer
14
+ *
15
+ * **Important** must specify them in the order that they will be in the vertex buffer!!
16
+ */
17
+ attributes: [name: string, numberOfComponents: number][];
18
+ }
19
+ /**
20
+ * Helper around creating vertex attributes in a given [[VertexBuffer]], this is useful for describing
21
+ * the memory layout for your vertices inside a particular buffer
22
+ *
23
+ * Note: This helper assumes interleaved attributes in one [[VertexBuffer]], not many.
24
+ *
25
+ * Working with `gl.vertexAttribPointer` can be tricky, and this attempts to double check you
26
+ */
27
+ export declare class VertexLayout {
28
+ private _gl;
29
+ private _logger;
30
+ private _shader;
31
+ private _layout;
32
+ private _attributes;
33
+ private _vertexBuffer;
34
+ get vertexBuffer(): VertexBuffer;
35
+ get attributes(): readonly [name: string, numberOfComponents: number][];
36
+ constructor(options: VertexLayoutOptions);
37
+ private _vertexTotalSizeBytes;
38
+ /**
39
+ * Total number of bytes that the vertex will take up
40
+ */
41
+ get totalVertexSizeBytes(): number;
42
+ /**
43
+ * Layouts need shader locations and must be bound to a shader
44
+ */
45
+ initialize(): void;
46
+ /**
47
+ * Bind this layout with it's associated vertex buffer
48
+ *
49
+ * @param uploadBuffer Optionally indicate you wish to upload the buffer to the GPU associated with this layout
50
+ */
51
+ use(uploadBuffer?: boolean): void;
52
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Must be accessed after Engine construction time to ensure the context has been created
3
+ */
4
+ export declare class ExcaliburWebGLContextAccessor {
5
+ private static _GL;
6
+ static clear(): void;
7
+ static register(gl: WebGLRenderingContext): void;
8
+ static get gl(): WebGLRenderingContext;
9
+ }
@@ -10,3 +10,25 @@ export declare function nextHighestPowerOfTwo(x: number): number;
10
10
  * Returns the input number if a power of two, otherwise the next highest power of two
11
11
  */
12
12
  export declare function ensurePowerOfTwo(x: number): number;
13
+ /**
14
+ * Return the size of the GlType in bytes
15
+ * @param gl
16
+ * @param type
17
+ */
18
+ export declare function getGlTypeSizeBytes(gl: WebGLRenderingContext, type: number): number;
19
+ /**
20
+ * Based on the type return the number of attribute components
21
+ *
22
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
23
+ * @param gl
24
+ * @param type
25
+ */
26
+ export declare function getAttributeComponentSize(gl: WebGLRenderingContext, type: number): number;
27
+ /**
28
+ * Based on the attribute return the corresponding supported attrib pointer type
29
+ * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
30
+ *
31
+ * @param gl
32
+ * @param type
33
+ */
34
+ export declare function getAttributePointerType(gl: WebGLRenderingContext, type: number): number;