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.
- package/.nvmrc +1 -1
- package/CHANGELOG.md +119 -27
- package/README.md +0 -1
- package/build/dist/Actions/ActionsComponent.d.ts +1 -1
- package/build/dist/Actor.d.ts +46 -45
- package/build/dist/Camera.d.ts +10 -2
- package/build/dist/Class.d.ts +4 -5
- package/build/dist/Collision/BodyComponent.d.ts +6 -2
- package/build/dist/Collision/BoundingBox.d.ts +6 -0
- package/build/dist/Collision/ColliderComponent.d.ts +1 -4
- package/build/dist/Collision/Colliders/CircleCollider.d.ts +18 -2
- package/build/dist/Collision/Colliders/EdgeCollider.d.ts +1 -1
- package/build/dist/Collision/Colliders/SeparatingAxis.d.ts +2 -2
- package/build/dist/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
- package/build/dist/Collision/Detection/Pair.d.ts +5 -1
- package/build/dist/Collision/Group/CollisionGroup.d.ts +0 -1
- package/build/dist/Collision/MotionSystem.d.ts +4 -0
- package/build/dist/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
- package/build/dist/Collision/Solver/Solver.d.ts +1 -1
- package/build/dist/Debug/Debug.d.ts +18 -1
- package/build/dist/Debug/DebugFlags.d.ts +16 -3
- package/build/dist/Engine.d.ts +66 -8
- package/build/dist/EntityComponentSystem/Component.d.ts +3 -3
- package/build/dist/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
- package/build/dist/EntityComponentSystem/Entity.d.ts +4 -4
- package/build/dist/EntityComponentSystem/System.d.ts +1 -1
- package/build/dist/EntityComponentSystem/SystemManager.d.ts +6 -1
- package/build/dist/EventDispatcher.d.ts +0 -5
- package/build/dist/Events/ExEvent.d.ts +6 -0
- package/build/dist/Events/PointerEvents.d.ts +37 -0
- package/build/dist/Graphics/Animation.d.ts +3 -2
- package/build/dist/Graphics/Circle.d.ts +2 -0
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
- package/build/dist/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
- package/build/dist/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.frag.glsl +53 -0
- package/build/dist/Graphics/Context/circle-renderer/circle-renderer.vert.glsl +37 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
- package/build/dist/Graphics/Context/image-renderer/image-renderer.frag.glsl +28 -0
- package/build/dist/Graphics/Context/{shaders/image-vertex.glsl → image-renderer/image-renderer.vert.glsl} +2 -7
- package/build/dist/Graphics/Context/{shaders → line-renderer}/line-fragment.glsl +0 -0
- package/build/dist/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
- package/build/dist/Graphics/Context/{shaders → line-renderer}/line-vertex.glsl +2 -2
- package/build/dist/Graphics/Context/{shaders → point-renderer}/point-fragment.glsl +6 -2
- package/build/dist/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
- package/build/dist/Graphics/Context/{shaders → point-renderer}/point-vertex.glsl +2 -2
- package/build/dist/Graphics/Context/quad-index-buffer.d.ts +36 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.frag.glsl +85 -0
- package/build/dist/Graphics/Context/rectangle-renderer/rectangle-renderer.vert.glsl +42 -0
- package/build/dist/Graphics/Context/render-source.d.ts +7 -0
- package/build/dist/Graphics/Context/render-target.d.ts +26 -0
- package/build/dist/Graphics/Context/renderer.d.ts +20 -51
- package/build/dist/Graphics/Context/screen-pass-painter/screen-fragment.glsl +11 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
- package/build/dist/Graphics/Context/screen-pass-painter/screen-vertex.glsl +11 -0
- package/build/dist/Graphics/Context/shader.d.ts +116 -42
- package/build/dist/Graphics/Context/shaders/crt-effect.glsl +64 -0
- package/build/dist/Graphics/Context/shaders/grayscale-fragment.glsl +13 -0
- package/build/dist/Graphics/Context/shaders/invert-fragment.glsl +12 -0
- package/build/dist/Graphics/Context/texture-loader.d.ts +8 -2
- package/build/dist/Graphics/Context/vertex-buffer.d.ts +49 -0
- package/build/dist/Graphics/Context/vertex-layout.d.ts +52 -0
- package/build/dist/Graphics/Context/webgl-adapter.d.ts +9 -0
- package/build/dist/Graphics/Context/webgl-util.d.ts +22 -0
- package/build/dist/Graphics/DebugGraphicsComponent.d.ts +13 -0
- package/build/dist/Graphics/Filtering.d.ts +15 -0
- package/build/dist/Graphics/Font.d.ts +61 -23
- package/build/dist/Graphics/FontCommon.d.ts +43 -2
- package/build/dist/Graphics/Graphic.d.ts +23 -9
- package/build/dist/Graphics/GraphicsSystem.d.ts +0 -1
- package/build/dist/Graphics/ImageSource.d.ts +8 -3
- package/build/dist/Graphics/Polygon.d.ts +2 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
- package/build/dist/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
- package/build/dist/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
- package/build/dist/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
- package/build/dist/Graphics/PostProcessor/color-blind-fragment.glsl +62 -0
- package/build/dist/Graphics/Raster.d.ts +32 -5
- package/build/dist/Graphics/Sprite.d.ts +5 -0
- package/build/dist/Graphics/SpriteFont.d.ts +6 -7
- package/build/dist/Graphics/SpriteSheet.d.ts +1 -2
- package/build/dist/Graphics/Text.d.ts +18 -2
- package/build/dist/Graphics/index.d.ts +14 -0
- package/build/dist/Id.d.ts +1 -1
- package/build/dist/Input/EngineInput.d.ts +2 -2
- package/build/dist/Input/Index.d.ts +10 -3
- package/build/dist/Input/NativePointerButton.d.ts +10 -0
- package/build/dist/Input/PointerAbstraction.d.ts +33 -0
- package/build/dist/Input/PointerButton.d.ts +10 -0
- package/build/dist/Input/PointerComponent.d.ts +24 -0
- package/build/dist/Input/PointerEvent.d.ts +18 -0
- package/build/dist/Input/PointerEventReceiver.d.ts +114 -0
- package/build/dist/Input/PointerScope.d.ts +14 -0
- package/build/dist/Input/PointerSystem.d.ts +43 -0
- package/build/dist/Input/PointerType.d.ts +9 -0
- package/build/dist/Input/WheelDeltaMode.d.ts +5 -0
- package/build/dist/Input/WheelEvent.d.ts +18 -0
- package/build/dist/Interfaces/PointerEventHandlers.d.ts +17 -16
- package/build/dist/Label.d.ts +9 -2
- package/build/dist/Loader.d.ts +5 -2
- package/build/dist/Math/Index.d.ts +1 -0
- package/build/dist/Math/matrix.d.ts +19 -1
- package/build/dist/Math/util.d.ts +45 -0
- package/build/dist/Particles.d.ts +12 -0
- package/build/dist/Resources/Gif.d.ts +1 -1
- package/build/dist/Scene.d.ts +10 -1
- package/build/dist/Screen.d.ts +4 -3
- package/build/dist/TileMap.d.ts +3 -2
- package/build/dist/Traits/Index.d.ts +0 -1
- package/build/dist/Trigger.d.ts +4 -0
- package/build/dist/Util/Clock.d.ts +118 -0
- package/build/dist/Util/Fps.d.ts +40 -0
- package/build/dist/Util/Observable.d.ts +1 -1
- package/build/dist/Util/Pool.d.ts +2 -10
- package/build/dist/Util/Util.d.ts +23 -66
- package/build/dist/excalibur.js +9124 -7580
- package/build/dist/excalibur.js.map +1 -1
- package/build/dist/excalibur.min.js +1 -1
- package/build/dist/excalibur.min.js.LICENSE.txt +2 -2
- package/build/dist/excalibur.min.js.map +1 -1
- package/build/dist/index.d.ts +5 -2
- package/build/esm/Actions/ActionsComponent.d.ts +1 -1
- package/build/esm/Actor.d.ts +46 -45
- package/build/esm/Camera.d.ts +10 -2
- package/build/esm/Class.d.ts +4 -5
- package/build/esm/Collision/BodyComponent.d.ts +6 -2
- package/build/esm/Collision/BoundingBox.d.ts +6 -0
- package/build/esm/Collision/ColliderComponent.d.ts +1 -4
- package/build/esm/Collision/Colliders/CircleCollider.d.ts +18 -2
- package/build/esm/Collision/Colliders/EdgeCollider.d.ts +1 -1
- package/build/esm/Collision/Colliders/SeparatingAxis.d.ts +2 -2
- package/build/esm/Collision/Detection/DynamicTreeCollisionProcessor.d.ts +4 -4
- package/build/esm/Collision/Detection/Pair.d.ts +5 -1
- package/build/esm/Collision/Group/CollisionGroup.d.ts +0 -1
- package/build/esm/Collision/MotionSystem.d.ts +4 -0
- package/build/esm/Collision/Solver/ContactConstraintPoint.d.ts +1 -1
- package/build/esm/Collision/Solver/Solver.d.ts +1 -1
- package/build/esm/Debug/Debug.d.ts +18 -1
- package/build/esm/Debug/DebugFlags.d.ts +16 -3
- package/build/esm/Engine.d.ts +66 -8
- package/build/esm/EntityComponentSystem/Component.d.ts +3 -3
- package/build/esm/EntityComponentSystem/Components/MotionComponent.d.ts +2 -2
- package/build/esm/EntityComponentSystem/Entity.d.ts +4 -4
- package/build/esm/EntityComponentSystem/System.d.ts +1 -1
- package/build/esm/EntityComponentSystem/SystemManager.d.ts +6 -1
- package/build/esm/EventDispatcher.d.ts +0 -5
- package/build/esm/Events/ExEvent.d.ts +6 -0
- package/build/esm/Events/PointerEvents.d.ts +37 -0
- package/build/esm/Graphics/Animation.d.ts +3 -2
- package/build/esm/Graphics/Circle.d.ts +2 -0
- package/build/esm/Graphics/Context/ExcaliburGraphicsContext.d.ts +37 -5
- package/build/esm/Graphics/Context/ExcaliburGraphicsContext2DCanvas.d.ts +12 -2
- package/build/esm/Graphics/Context/ExcaliburGraphicsContextWebGL.d.ts +29 -13
- package/build/esm/Graphics/Context/circle-renderer/circle-renderer.d.ts +22 -0
- package/build/esm/Graphics/Context/image-renderer/image-renderer.d.ts +27 -0
- package/build/esm/Graphics/Context/line-renderer/line-renderer.d.ts +21 -0
- package/build/esm/Graphics/Context/point-renderer/point-renderer.d.ts +21 -0
- package/build/esm/Graphics/Context/quad-index-buffer.d.ts +36 -0
- package/build/esm/Graphics/Context/rectangle-renderer/rectangle-renderer.d.ts +23 -0
- package/build/esm/Graphics/Context/render-source.d.ts +7 -0
- package/build/esm/Graphics/Context/render-target.d.ts +26 -0
- package/build/esm/Graphics/Context/renderer.d.ts +20 -51
- package/build/esm/Graphics/Context/screen-pass-painter/screen-pass-painter.d.ts +13 -0
- package/build/esm/Graphics/Context/shader.d.ts +116 -42
- package/build/esm/Graphics/Context/texture-loader.d.ts +8 -2
- package/build/esm/Graphics/Context/vertex-buffer.d.ts +49 -0
- package/build/esm/Graphics/Context/vertex-layout.d.ts +52 -0
- package/build/esm/Graphics/Context/webgl-adapter.d.ts +9 -0
- package/build/esm/Graphics/Context/webgl-util.d.ts +22 -0
- package/build/esm/Graphics/DebugGraphicsComponent.d.ts +13 -0
- package/build/esm/Graphics/Filtering.d.ts +15 -0
- package/build/esm/Graphics/Font.d.ts +61 -23
- package/build/esm/Graphics/FontCommon.d.ts +43 -2
- package/build/esm/Graphics/Graphic.d.ts +23 -9
- package/build/esm/Graphics/GraphicsSystem.d.ts +0 -1
- package/build/esm/Graphics/ImageSource.d.ts +8 -3
- package/build/esm/Graphics/Polygon.d.ts +2 -0
- package/build/esm/Graphics/PostProcessor/ColorBlindnessMode.d.ts +5 -0
- package/build/esm/Graphics/PostProcessor/ColorBlindnessPostProcessor.d.ts +17 -0
- package/build/esm/Graphics/PostProcessor/PostProcessor.d.ts +7 -0
- package/build/esm/Graphics/PostProcessor/ScreenShader.d.ts +16 -0
- package/build/esm/Graphics/Raster.d.ts +32 -5
- package/build/esm/Graphics/Sprite.d.ts +5 -0
- package/build/esm/Graphics/SpriteFont.d.ts +6 -7
- package/build/esm/Graphics/SpriteSheet.d.ts +1 -2
- package/build/esm/Graphics/Text.d.ts +18 -2
- package/build/esm/Graphics/index.d.ts +14 -0
- package/build/esm/Id.d.ts +1 -1
- package/build/esm/Input/EngineInput.d.ts +2 -2
- package/build/esm/Input/Index.d.ts +10 -3
- package/build/esm/Input/NativePointerButton.d.ts +10 -0
- package/build/esm/Input/PointerAbstraction.d.ts +33 -0
- package/build/esm/Input/PointerButton.d.ts +10 -0
- package/build/esm/Input/PointerComponent.d.ts +24 -0
- package/build/esm/Input/PointerEvent.d.ts +18 -0
- package/build/esm/Input/PointerEventReceiver.d.ts +114 -0
- package/build/esm/Input/PointerScope.d.ts +14 -0
- package/build/esm/Input/PointerSystem.d.ts +43 -0
- package/build/esm/Input/PointerType.d.ts +9 -0
- package/build/esm/Input/WheelDeltaMode.d.ts +5 -0
- package/build/esm/Input/WheelEvent.d.ts +18 -0
- package/build/esm/Interfaces/PointerEventHandlers.d.ts +17 -16
- package/build/esm/Label.d.ts +9 -2
- package/build/esm/Loader.d.ts +5 -2
- package/build/esm/Math/Index.d.ts +1 -0
- package/build/esm/Math/matrix.d.ts +19 -1
- package/build/esm/Math/util.d.ts +45 -0
- package/build/esm/Particles.d.ts +12 -0
- package/build/esm/Resources/Gif.d.ts +1 -1
- package/build/esm/Scene.d.ts +10 -1
- package/build/esm/Screen.d.ts +4 -3
- package/build/esm/TileMap.d.ts +3 -2
- package/build/esm/Traits/Index.d.ts +0 -1
- package/build/esm/Trigger.d.ts +4 -0
- package/build/esm/Util/Clock.d.ts +118 -0
- package/build/esm/Util/Fps.d.ts +40 -0
- package/build/esm/Util/Observable.d.ts +1 -1
- package/build/esm/Util/Pool.d.ts +2 -10
- package/build/esm/Util/Util.d.ts +23 -66
- package/build/esm/excalibur.js +9001 -7438
- package/build/esm/excalibur.js.map +1 -1
- package/build/esm/excalibur.min.js +1 -1
- package/build/esm/excalibur.min.js.LICENSE.txt +2 -2
- package/build/esm/excalibur.min.js.map +1 -1
- package/build/esm/index.d.ts +5 -2
- package/package.json +31 -27
- package/build/dist/Graphics/Context/batch.d.ts +0 -11
- package/build/dist/Graphics/Context/draw-image-command.d.ts +0 -47
- package/build/dist/Graphics/Context/image-renderer.d.ts +0 -39
- package/build/dist/Graphics/Context/line-renderer.d.ts +0 -22
- package/build/dist/Graphics/Context/point-renderer.d.ts +0 -22
- package/build/dist/Graphics/Context/shaders/image-fragment.glsl +0 -48
- package/build/dist/Input/Pointer.d.ts +0 -134
- package/build/dist/Input/PointerEvents.d.ts +0 -170
- package/build/dist/Input/Pointers.d.ts +0 -78
- package/build/dist/PostProcessing/ColorBlindCorrector.d.ts +0 -28
- package/build/dist/PostProcessing/Index.d.ts +0 -2
- package/build/dist/PostProcessing/PostProcessor.d.ts +0 -6
- package/build/dist/Traits/CapturePointer.d.ts +0 -10
- package/build/esm/Graphics/Context/batch.d.ts +0 -11
- package/build/esm/Graphics/Context/draw-image-command.d.ts +0 -47
- package/build/esm/Graphics/Context/image-renderer.d.ts +0 -39
- package/build/esm/Graphics/Context/line-renderer.d.ts +0 -22
- package/build/esm/Graphics/Context/point-renderer.d.ts +0 -22
- package/build/esm/Input/Pointer.d.ts +0 -134
- package/build/esm/Input/PointerEvents.d.ts +0 -170
- package/build/esm/Input/Pointers.d.ts +0 -78
- package/build/esm/PostProcessing/ColorBlindCorrector.d.ts +0 -28
- package/build/esm/PostProcessing/Index.d.ts +0 -2
- package/build/esm/PostProcessing/PostProcessor.d.ts +0 -6
- package/build/esm/Traits/CapturePointer.d.ts +0 -10
- package/wallaby.js +0 -77
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Vector } from '../../Math/vector';
|
|
2
|
+
import { Matrix } from '../../Math/matrix';
|
|
2
3
|
import { Color } from '../../Color';
|
|
4
|
+
import { ScreenDimension } from '../../Screen';
|
|
5
|
+
import { PostProcessor } from '../PostProcessor/PostProcessor';
|
|
3
6
|
export declare type HTMLImageSource = HTMLImageElement | HTMLCanvasElement;
|
|
4
7
|
export interface ExcaliburGraphicsContextOptions {
|
|
5
8
|
canvasElement: HTMLCanvasElement;
|
|
@@ -55,7 +58,7 @@ export interface ExcaliburGraphicsContext {
|
|
|
55
58
|
width: number;
|
|
56
59
|
height: number;
|
|
57
60
|
/**
|
|
58
|
-
* Snaps all drawings to the nearest pixel
|
|
61
|
+
* Snaps all drawings to the nearest pixel truncated down, by default false
|
|
59
62
|
*/
|
|
60
63
|
snapToPixel: boolean;
|
|
61
64
|
/**
|
|
@@ -74,10 +77,19 @@ export interface ExcaliburGraphicsContext {
|
|
|
74
77
|
* Resets the current transform to the identity matrix
|
|
75
78
|
*/
|
|
76
79
|
resetTransform(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Gets the current transform
|
|
82
|
+
*/
|
|
83
|
+
getTransform(): Matrix;
|
|
84
|
+
/**
|
|
85
|
+
* Multiplies the current transform by a matrix
|
|
86
|
+
* @param m
|
|
87
|
+
*/
|
|
88
|
+
multiply(m: Matrix): void;
|
|
77
89
|
/**
|
|
78
90
|
* Update the context with the current viewport dimensions (used in resizing)
|
|
79
91
|
*/
|
|
80
|
-
updateViewport(): void;
|
|
92
|
+
updateViewport(resolution: ScreenDimension): void;
|
|
81
93
|
/**
|
|
82
94
|
* Access the debug drawing api
|
|
83
95
|
*/
|
|
@@ -112,14 +124,16 @@ export interface ExcaliburGraphicsContext {
|
|
|
112
124
|
* @param height
|
|
113
125
|
* @param color
|
|
114
126
|
*/
|
|
115
|
-
drawRectangle(pos: Vector, width: number, height: number, color: Color): void;
|
|
127
|
+
drawRectangle(pos: Vector, width: number, height: number, color: Color, stroke?: Color, strokeThickness?: number): void;
|
|
116
128
|
/**
|
|
117
|
-
* Draw a
|
|
129
|
+
* Draw a circle to the Excalibur Graphics context
|
|
118
130
|
* @param pos
|
|
119
131
|
* @param radius
|
|
120
132
|
* @param color
|
|
133
|
+
* @param stroke Optionally specify the stroke color
|
|
134
|
+
* @param thickness
|
|
121
135
|
*/
|
|
122
|
-
drawCircle(pos: Vector, radius: number, color: Color): void;
|
|
136
|
+
drawCircle(pos: Vector, radius: number, color: Color, stroke?: Color, thickness?: number): void;
|
|
123
137
|
/**
|
|
124
138
|
* Save the current state of the canvas to the stack (transforms and opacity)
|
|
125
139
|
*/
|
|
@@ -144,6 +158,22 @@ export interface ExcaliburGraphicsContext {
|
|
|
144
158
|
* @param y
|
|
145
159
|
*/
|
|
146
160
|
scale(x: number, y: number): void;
|
|
161
|
+
/**
|
|
162
|
+
* Add a post processor to the graphics context
|
|
163
|
+
*
|
|
164
|
+
* Post processors are run in the order they were added.
|
|
165
|
+
* @param postprocessor
|
|
166
|
+
*/
|
|
167
|
+
addPostProcessor(postprocessor: PostProcessor): void;
|
|
168
|
+
/**
|
|
169
|
+
* Remove a specific post processor from the graphics context
|
|
170
|
+
* @param postprocessor
|
|
171
|
+
*/
|
|
172
|
+
removePostProcessor(postprocessor: PostProcessor): void;
|
|
173
|
+
/**
|
|
174
|
+
* Remove all post processors from the graphics context
|
|
175
|
+
*/
|
|
176
|
+
clearPostProcessors(): void;
|
|
147
177
|
/**
|
|
148
178
|
* Clears the screen with the current background color
|
|
149
179
|
*/
|
|
@@ -152,4 +182,6 @@ export interface ExcaliburGraphicsContext {
|
|
|
152
182
|
* Flushes the batched draw calls to the screen
|
|
153
183
|
*/
|
|
154
184
|
flush(): void;
|
|
185
|
+
beginDrawLifecycle(): void;
|
|
186
|
+
endDrawLifecycle(): void;
|
|
155
187
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ExcaliburGraphicsContext, LineGraphicsOptions, PointGraphicsOptions, ExcaliburGraphicsContextOptions, DebugDraw, HTMLImageSource } from './ExcaliburGraphicsContext';
|
|
2
2
|
import { Vector } from '../../Math/vector';
|
|
3
3
|
import { Color } from '../../Color';
|
|
4
|
+
import { Matrix } from '../../Math/matrix';
|
|
5
|
+
import { ScreenDimension } from '../../Screen';
|
|
6
|
+
import { PostProcessor } from '../PostProcessor/PostProcessor';
|
|
4
7
|
declare class ExcaliburGraphicsContext2DCanvasDebug implements DebugDraw {
|
|
5
8
|
private _ex;
|
|
6
9
|
private _debugText;
|
|
@@ -34,7 +37,7 @@ export declare class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphi
|
|
|
34
37
|
set smoothing(value: boolean);
|
|
35
38
|
constructor(options: ExcaliburGraphicsContextOptions);
|
|
36
39
|
resetTransform(): void;
|
|
37
|
-
updateViewport(): void;
|
|
40
|
+
updateViewport(_resolution: ScreenDimension): void;
|
|
38
41
|
/**
|
|
39
42
|
* Draw an image to the Excalibur Graphics context at an x and y coordinate using the images width and height
|
|
40
43
|
*/
|
|
@@ -52,7 +55,7 @@ export declare class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphi
|
|
|
52
55
|
drawImage(image: HTMLImageSource, sx: number, sy: number, swidth?: number, sheight?: number, dx?: number, dy?: number, dwidth?: number, dheight?: number): void;
|
|
53
56
|
drawLine(start: Vector, end: Vector, color: Color, thickness?: number): void;
|
|
54
57
|
drawRectangle(pos: Vector, width: number, height: number, color: Color): void;
|
|
55
|
-
drawCircle(pos: Vector, radius: number, color: Color): void;
|
|
58
|
+
drawCircle(pos: Vector, radius: number, color: Color, stroke?: Color, thickness?: number): void;
|
|
56
59
|
debug: ExcaliburGraphicsContext2DCanvasDebug;
|
|
57
60
|
/**
|
|
58
61
|
* Save the current state of the canvas to the stack (transforms and opacity)
|
|
@@ -78,6 +81,13 @@ export declare class ExcaliburGraphicsContext2DCanvas implements ExcaliburGraphi
|
|
|
78
81
|
* @param y
|
|
79
82
|
*/
|
|
80
83
|
scale(x: number, y: number): void;
|
|
84
|
+
getTransform(): Matrix;
|
|
85
|
+
multiply(_m: Matrix): void;
|
|
86
|
+
addPostProcessor(_postprocessor: PostProcessor): void;
|
|
87
|
+
removePostProcessor(_postprocessor: PostProcessor): void;
|
|
88
|
+
clearPostProcessors(): void;
|
|
89
|
+
beginDrawLifecycle(): void;
|
|
90
|
+
endDrawLifecycle(): void;
|
|
81
91
|
clear(): void;
|
|
82
92
|
/**
|
|
83
93
|
* Flushes the batched draw calls to the screen
|
|
@@ -4,10 +4,10 @@ import { TransformStack } from './transform-stack';
|
|
|
4
4
|
import { Vector } from '../../Math/vector';
|
|
5
5
|
import { Color } from '../../Color';
|
|
6
6
|
import { StateStack } from './state-stack';
|
|
7
|
-
import { LineRenderer } from './line-renderer';
|
|
8
|
-
import { ImageRenderer } from './image-renderer';
|
|
9
|
-
import { PointRenderer } from './point-renderer';
|
|
10
7
|
import { ScreenDimension } from '../../Screen';
|
|
8
|
+
import { PostProcessor } from '../PostProcessor/PostProcessor';
|
|
9
|
+
import { RendererPlugin } from './renderer';
|
|
10
|
+
import { LineRenderer } from './line-renderer/line-renderer';
|
|
11
11
|
declare class ExcaliburGraphicsContextWebGLDebug implements DebugDraw {
|
|
12
12
|
private _webglCtx;
|
|
13
13
|
private _debugText;
|
|
@@ -38,9 +38,17 @@ declare class ExcaliburGraphicsContextWebGLDebug implements DebugDraw {
|
|
|
38
38
|
export interface WebGLGraphicsContextInfo {
|
|
39
39
|
transform: TransformStack;
|
|
40
40
|
state: StateStack;
|
|
41
|
-
|
|
41
|
+
ortho: Matrix;
|
|
42
|
+
context: ExcaliburGraphicsContextWebGL;
|
|
42
43
|
}
|
|
43
44
|
export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsContext {
|
|
45
|
+
private _logger;
|
|
46
|
+
private _renderers;
|
|
47
|
+
private _isDrawLifecycle;
|
|
48
|
+
private _renderTarget;
|
|
49
|
+
private _postProcessTargets;
|
|
50
|
+
private _screenRenderer;
|
|
51
|
+
private _postprocessors;
|
|
44
52
|
/**
|
|
45
53
|
* Meant for internal use only. Access the internal context at your own risk and no guarantees this will exist in the future.
|
|
46
54
|
* @internal
|
|
@@ -58,11 +66,6 @@ export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsC
|
|
|
58
66
|
private _transform;
|
|
59
67
|
private _state;
|
|
60
68
|
private _ortho;
|
|
61
|
-
/**
|
|
62
|
-
* Meant for internal use only. Access the internal context at your own risk and no guarantees this will exist in the future.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
__pointRenderer: PointRenderer;
|
|
66
69
|
/**
|
|
67
70
|
* Meant for internal use only. Access the internal context at your own risk and no guarantees this will exist in the future.
|
|
68
71
|
* @internal
|
|
@@ -72,7 +75,6 @@ export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsC
|
|
|
72
75
|
* Meant for internal use only. Access the internal context at your own risk and no guarantees this will exist in the future.
|
|
73
76
|
* @internal
|
|
74
77
|
*/
|
|
75
|
-
__imageRenderer: ImageRenderer;
|
|
76
78
|
snapToPixel: boolean;
|
|
77
79
|
smoothing: boolean;
|
|
78
80
|
backgroundColor: Color;
|
|
@@ -80,6 +82,7 @@ export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsC
|
|
|
80
82
|
set opacity(value: number);
|
|
81
83
|
get width(): number;
|
|
82
84
|
get height(): number;
|
|
85
|
+
get ortho(): Matrix;
|
|
83
86
|
/**
|
|
84
87
|
* Checks the underlying webgl implementation if the requested internal resolution is supported
|
|
85
88
|
* @param dim
|
|
@@ -87,14 +90,22 @@ export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsC
|
|
|
87
90
|
checkIfResolutionSupported(dim: ScreenDimension): boolean;
|
|
88
91
|
constructor(options: ExcaliburGraphicsContextOptions);
|
|
89
92
|
private _init;
|
|
93
|
+
register<T extends RendererPlugin>(renderer: T): void;
|
|
94
|
+
get(rendererName: string): RendererPlugin;
|
|
95
|
+
private _currentRenderer;
|
|
96
|
+
private _isCurrentRenderer;
|
|
97
|
+
beginDrawLifecycle(): void;
|
|
98
|
+
endDrawLifecycle(): void;
|
|
99
|
+
private _alreadyWarnedDrawLifecycle;
|
|
100
|
+
draw<TRenderer extends RendererPlugin>(rendererName: TRenderer['type'], ...args: Parameters<TRenderer['draw']>): void;
|
|
90
101
|
resetTransform(): void;
|
|
91
|
-
updateViewport(): void;
|
|
102
|
+
updateViewport(resolution: ScreenDimension): void;
|
|
92
103
|
drawImage(image: HTMLImageSource, x: number, y: number): void;
|
|
93
104
|
drawImage(image: HTMLImageSource, x: number, y: number, width: number, height: number): void;
|
|
94
105
|
drawImage(image: HTMLImageSource, sx: number, sy: number, swidth?: number, sheight?: number, dx?: number, dy?: number, dwidth?: number, dheight?: number): void;
|
|
95
106
|
drawLine(start: Vector, end: Vector, color: Color, thickness?: number): void;
|
|
96
|
-
drawRectangle(pos: Vector, width: number, height: number, color: Color): void;
|
|
97
|
-
drawCircle(pos: Vector, radius: number, color: Color): void;
|
|
107
|
+
drawRectangle(pos: Vector, width: number, height: number, color: Color, stroke?: Color, strokeThickness?: number): void;
|
|
108
|
+
drawCircle(pos: Vector, radius: number, color: Color, stroke?: Color, thickness?: number): void;
|
|
98
109
|
debug: ExcaliburGraphicsContextWebGLDebug;
|
|
99
110
|
save(): void;
|
|
100
111
|
restore(): void;
|
|
@@ -102,6 +113,11 @@ export declare class ExcaliburGraphicsContextWebGL implements ExcaliburGraphicsC
|
|
|
102
113
|
rotate(angle: number): void;
|
|
103
114
|
scale(x: number, y: number): void;
|
|
104
115
|
transform(matrix: Matrix): void;
|
|
116
|
+
getTransform(): Matrix;
|
|
117
|
+
multiply(m: Matrix): void;
|
|
118
|
+
addPostProcessor(postprocessor: PostProcessor): void;
|
|
119
|
+
removePostProcessor(postprocessor: PostProcessor): void;
|
|
120
|
+
clearPostProcessors(): void;
|
|
105
121
|
clear(): void;
|
|
106
122
|
/**
|
|
107
123
|
* Flushes all batched rendering to the screen
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Color } from '../../../Color';
|
|
2
|
+
import { Vector } from '../../../Math/vector';
|
|
3
|
+
import { ExcaliburGraphicsContextWebGL } from '../ExcaliburGraphicsContextWebGL';
|
|
4
|
+
import { RendererPlugin } from '../renderer';
|
|
5
|
+
export declare class CircleRenderer implements RendererPlugin {
|
|
6
|
+
readonly type = "ex.circle";
|
|
7
|
+
priority: number;
|
|
8
|
+
private _maxCircles;
|
|
9
|
+
private _shader;
|
|
10
|
+
private _context;
|
|
11
|
+
private _gl;
|
|
12
|
+
private _buffer;
|
|
13
|
+
private _layout;
|
|
14
|
+
private _quads;
|
|
15
|
+
private _circleCount;
|
|
16
|
+
private _vertexIndex;
|
|
17
|
+
initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
|
|
18
|
+
private _isFull;
|
|
19
|
+
draw(pos: Vector, radius: number, color: Color, stroke?: Color, strokeThickness?: number): void;
|
|
20
|
+
hasPendingDraws(): boolean;
|
|
21
|
+
flush(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#ifdef GL_OES_standard_derivatives
|
|
2
|
+
#extension GL_OES_standard_derivatives : enable
|
|
3
|
+
#endif
|
|
4
|
+
precision highp float;
|
|
5
|
+
|
|
6
|
+
// UV coord
|
|
7
|
+
varying vec2 v_uv;
|
|
8
|
+
|
|
9
|
+
// Color coord to blend with image
|
|
10
|
+
varying lowp vec4 v_color;
|
|
11
|
+
|
|
12
|
+
// Stroke color if used
|
|
13
|
+
varying lowp vec4 v_strokeColor;
|
|
14
|
+
|
|
15
|
+
// Stroke thickness if used
|
|
16
|
+
varying lowp float v_strokeThickness;
|
|
17
|
+
|
|
18
|
+
// Opacity
|
|
19
|
+
varying float v_opacity;
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
// make (0, 0) the center the uv
|
|
23
|
+
vec2 uv = v_uv * 2.0 - 1.0;
|
|
24
|
+
|
|
25
|
+
vec4 color = v_color;
|
|
26
|
+
vec4 strokeColor = v_strokeColor;
|
|
27
|
+
|
|
28
|
+
// circle border is at radius 1.0
|
|
29
|
+
// dist is > 0 when inside the circle
|
|
30
|
+
float d = length(uv);
|
|
31
|
+
float dist = 1.0 - length(uv);
|
|
32
|
+
|
|
33
|
+
// Fade based on fwidth
|
|
34
|
+
float fade = fwidth(dot(uv, uv));
|
|
35
|
+
|
|
36
|
+
// if dist is greater than 0 step to 1;
|
|
37
|
+
// when we cross this 0 threshold add a smooth fade
|
|
38
|
+
float fill = smoothstep(-fade/2.0, fade/2.0, dist);
|
|
39
|
+
|
|
40
|
+
// if dist is greater than the stroke thickness step to 1
|
|
41
|
+
float stroke = 1.0 - smoothstep(v_strokeThickness, v_strokeThickness + fade, dist);
|
|
42
|
+
|
|
43
|
+
strokeColor.a *= fill * stroke;
|
|
44
|
+
strokeColor.rgb *= strokeColor.a;
|
|
45
|
+
|
|
46
|
+
color.a *= fill * (1.0 - stroke);
|
|
47
|
+
color.rgb *= color.a;
|
|
48
|
+
|
|
49
|
+
vec4 finalColor = mix(vec4(0.0), (color + strokeColor), fill);
|
|
50
|
+
finalColor.rgb = finalColor.rgb * v_opacity;
|
|
51
|
+
finalColor.a = finalColor.a * v_opacity;
|
|
52
|
+
gl_FragColor = finalColor;
|
|
53
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
attribute vec2 a_position;
|
|
2
|
+
|
|
3
|
+
// UV coordinate
|
|
4
|
+
attribute vec2 a_uv;
|
|
5
|
+
varying vec2 v_uv;
|
|
6
|
+
|
|
7
|
+
// Opacity
|
|
8
|
+
attribute float a_opacity;
|
|
9
|
+
varying float v_opacity;
|
|
10
|
+
|
|
11
|
+
attribute vec4 a_color;
|
|
12
|
+
varying vec4 v_color;
|
|
13
|
+
|
|
14
|
+
attribute vec4 a_strokeColor;
|
|
15
|
+
varying vec4 v_strokeColor;
|
|
16
|
+
|
|
17
|
+
attribute float a_strokeThickness;
|
|
18
|
+
varying float v_strokeThickness;
|
|
19
|
+
|
|
20
|
+
uniform mat4 u_matrix;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
void main() {
|
|
24
|
+
// Set the vertex position using the ortho transform matrix
|
|
25
|
+
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
26
|
+
|
|
27
|
+
// Pass through UV coords
|
|
28
|
+
v_uv = a_uv;
|
|
29
|
+
// Pass through the Opacity to the fragment shader
|
|
30
|
+
v_opacity = a_opacity;
|
|
31
|
+
// Pass through the color to the fragment shader
|
|
32
|
+
v_color = a_color;
|
|
33
|
+
// Pass through the stroke color to the fragment shader
|
|
34
|
+
v_strokeColor = a_strokeColor;
|
|
35
|
+
// Pass through the stroke thickenss to the fragment shader
|
|
36
|
+
v_strokeThickness = a_strokeThickness;
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HTMLImageSource } from '../ExcaliburGraphicsContext';
|
|
2
|
+
import { ExcaliburGraphicsContextWebGL } from '../ExcaliburGraphicsContextWebGL';
|
|
3
|
+
import { RendererPlugin } from '../renderer';
|
|
4
|
+
export declare class ImageRenderer implements RendererPlugin {
|
|
5
|
+
readonly type = "ex.image";
|
|
6
|
+
priority: number;
|
|
7
|
+
private _maxImages;
|
|
8
|
+
private _maxTextures;
|
|
9
|
+
private _context;
|
|
10
|
+
private _gl;
|
|
11
|
+
private _shader;
|
|
12
|
+
private _buffer;
|
|
13
|
+
private _layout;
|
|
14
|
+
private _quads;
|
|
15
|
+
private _imageCount;
|
|
16
|
+
private _textures;
|
|
17
|
+
private _vertexIndex;
|
|
18
|
+
initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
|
|
19
|
+
private _transformFragmentSource;
|
|
20
|
+
private _addImageAsTexture;
|
|
21
|
+
private _bindTextures;
|
|
22
|
+
private _getTextureIdForImage;
|
|
23
|
+
private _isFull;
|
|
24
|
+
draw(image: HTMLImageSource, sx: number, sy: number, swidth?: number, sheight?: number, dx?: number, dy?: number, dwidth?: number, dheight?: number): void;
|
|
25
|
+
hasPendingDraws(): boolean;
|
|
26
|
+
flush(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
precision mediump float;
|
|
2
|
+
|
|
3
|
+
// UV coord
|
|
4
|
+
varying vec2 v_texcoord;
|
|
5
|
+
|
|
6
|
+
// Texture index
|
|
7
|
+
varying lowp float v_textureIndex;
|
|
8
|
+
|
|
9
|
+
// Textures in the current draw
|
|
10
|
+
uniform sampler2D u_textures[%%count%%];
|
|
11
|
+
|
|
12
|
+
// Opacity
|
|
13
|
+
varying float v_opacity;
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
// In order to support the most efficient sprite batching, we have multiple
|
|
17
|
+
// textures loaded into the gpu (usually 8) this picker logic skips over textures
|
|
18
|
+
// that do not apply to a particular sprite.
|
|
19
|
+
|
|
20
|
+
vec4 color = vec4(1.0, 0, 0, 1.0);
|
|
21
|
+
|
|
22
|
+
// GLSL is templated out to pick the right texture and set the vec4 color
|
|
23
|
+
%%texture_picker%%
|
|
24
|
+
|
|
25
|
+
color.rgb = color.rgb * v_opacity;
|
|
26
|
+
color.a = color.a * v_opacity;
|
|
27
|
+
gl_FragColor = color;
|
|
28
|
+
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
attribute
|
|
1
|
+
attribute vec2 a_position;
|
|
2
2
|
|
|
3
3
|
// Opacity
|
|
4
4
|
attribute float a_opacity;
|
|
5
5
|
varying float v_opacity;
|
|
6
6
|
|
|
7
|
-
attribute vec4 a_color;
|
|
8
|
-
varying vec4 v_color;
|
|
9
|
-
|
|
10
7
|
// UV coordinate
|
|
11
8
|
attribute vec2 a_texcoord;
|
|
12
9
|
varying vec2 v_texcoord;
|
|
@@ -20,7 +17,7 @@ uniform mat4 u_matrix;
|
|
|
20
17
|
|
|
21
18
|
void main() {
|
|
22
19
|
// Set the vertex position using the ortho transform matrix
|
|
23
|
-
gl_Position = u_matrix * a_position;
|
|
20
|
+
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
24
21
|
|
|
25
22
|
// Pass through the Opacity to the fragment shader
|
|
26
23
|
v_opacity = a_opacity;
|
|
@@ -28,6 +25,4 @@ void main() {
|
|
|
28
25
|
v_texcoord = a_texcoord;
|
|
29
26
|
// Pass through the texture number to the fragment shader
|
|
30
27
|
v_textureIndex = a_textureIndex;
|
|
31
|
-
// Pass through the color to the fragment shader
|
|
32
|
-
v_color = a_color;
|
|
33
28
|
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Vector } from '../../../Math/vector';
|
|
2
|
+
import { Color } from '../../../Color';
|
|
3
|
+
import { ExcaliburGraphicsContextWebGL } from '../ExcaliburGraphicsContextWebGL';
|
|
4
|
+
import { RendererPlugin } from '../renderer';
|
|
5
|
+
export declare class LineRenderer implements RendererPlugin {
|
|
6
|
+
readonly type = "ex.line";
|
|
7
|
+
priority: number;
|
|
8
|
+
private _context;
|
|
9
|
+
private _gl;
|
|
10
|
+
private _shader;
|
|
11
|
+
private _maxLines;
|
|
12
|
+
private _vertexBuffer;
|
|
13
|
+
private _layout;
|
|
14
|
+
private _vertexIndex;
|
|
15
|
+
private _lineCount;
|
|
16
|
+
initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
|
|
17
|
+
draw(start: Vector, end: Vector, color: Color): void;
|
|
18
|
+
private _isFull;
|
|
19
|
+
hasPendingDraws(): boolean;
|
|
20
|
+
flush(): void;
|
|
21
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
attribute
|
|
1
|
+
attribute vec2 a_position;
|
|
2
2
|
attribute vec4 a_color;
|
|
3
3
|
|
|
4
4
|
varying lowp vec4 v_color;
|
|
@@ -8,7 +8,7 @@ uniform mat4 u_matrix;
|
|
|
8
8
|
|
|
9
9
|
void main() {
|
|
10
10
|
// Set the vertex position using the ortho transform matrix
|
|
11
|
-
gl_Position = u_matrix * a_position;
|
|
11
|
+
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
12
12
|
|
|
13
13
|
// Passthrough the color
|
|
14
14
|
v_color = a_color;
|
|
@@ -9,7 +9,7 @@ void main() {
|
|
|
9
9
|
float r = 0.0, delta = 0.0, alpha = 1.0;
|
|
10
10
|
vec2 cxy = 2.0 * gl_PointCoord - 1.0;
|
|
11
11
|
r = dot(cxy, cxy);
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
#ifdef GL_OES_standard_derivatives
|
|
14
14
|
delta = fwidth(r);
|
|
15
15
|
alpha = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);
|
|
@@ -18,5 +18,9 @@ void main() {
|
|
|
18
18
|
discard;
|
|
19
19
|
}
|
|
20
20
|
#endif
|
|
21
|
-
|
|
21
|
+
// "premultiply" the color by alpha
|
|
22
|
+
vec4 color = v_color;
|
|
23
|
+
color.a = color.a * alpha;
|
|
24
|
+
color.rgb = color.rgb * color.a;
|
|
25
|
+
gl_FragColor = color;
|
|
22
26
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Vector } from '../../../Math/vector';
|
|
2
|
+
import { Color } from '../../../Color';
|
|
3
|
+
import { ExcaliburGraphicsContextWebGL } from '../ExcaliburGraphicsContextWebGL';
|
|
4
|
+
import { RendererPlugin } from '../renderer';
|
|
5
|
+
export declare class PointRenderer implements RendererPlugin {
|
|
6
|
+
readonly type = "ex.point";
|
|
7
|
+
priority: number;
|
|
8
|
+
private _shader;
|
|
9
|
+
private _maxPoints;
|
|
10
|
+
private _buffer;
|
|
11
|
+
private _layout;
|
|
12
|
+
private _gl;
|
|
13
|
+
private _context;
|
|
14
|
+
private _pointCount;
|
|
15
|
+
private _vertexIndex;
|
|
16
|
+
initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
|
|
17
|
+
draw(point: Vector, color: Color, size: number): void;
|
|
18
|
+
private _isFull;
|
|
19
|
+
hasPendingDraws(): boolean;
|
|
20
|
+
flush(): void;
|
|
21
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
attribute
|
|
1
|
+
attribute vec2 a_position;
|
|
2
2
|
attribute vec4 a_color;
|
|
3
3
|
attribute float a_size;
|
|
4
4
|
varying lowp vec4 v_color;
|
|
5
5
|
uniform mat4 u_matrix;
|
|
6
6
|
|
|
7
7
|
void main() {
|
|
8
|
-
gl_Position = u_matrix * a_position;
|
|
8
|
+
gl_Position = u_matrix * vec4(a_position, 0.0, 1.0);
|
|
9
9
|
gl_PointSize = a_size * 2.0;
|
|
10
10
|
v_color = a_color;
|
|
11
11
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper that defines and index buffer for quad geometry
|
|
3
|
+
*
|
|
4
|
+
* Index buffers allow you to save space in vertex buffers when you share vertices in geometry
|
|
5
|
+
* it is almost always worth it in terms of performance to use an index buffer.
|
|
6
|
+
*/
|
|
7
|
+
export declare class QuadIndexBuffer {
|
|
8
|
+
private _gl;
|
|
9
|
+
private _logger;
|
|
10
|
+
/**
|
|
11
|
+
* Access to the webgl buffer handle
|
|
12
|
+
*/
|
|
13
|
+
buffer: WebGLBuffer;
|
|
14
|
+
/**
|
|
15
|
+
* Access to the raw data of the index buffer
|
|
16
|
+
*/
|
|
17
|
+
bufferData: Uint16Array | Uint32Array;
|
|
18
|
+
/**
|
|
19
|
+
* Depending on the browser this is either gl.UNSIGNED_SHORT or gl.UNSIGNED_INT
|
|
20
|
+
*/
|
|
21
|
+
bufferGlType: number;
|
|
22
|
+
/**
|
|
23
|
+
* @param numberOfQuads Specify the max number of quads you want to draw
|
|
24
|
+
* @param useUint16 Optionally force a uint16 buffer
|
|
25
|
+
*/
|
|
26
|
+
constructor(numberOfQuads: number, useUint16?: boolean);
|
|
27
|
+
get size(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Upload data to the GPU
|
|
30
|
+
*/
|
|
31
|
+
upload(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Bind this index buffer
|
|
34
|
+
*/
|
|
35
|
+
bind(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Color } from '../../../Color';
|
|
2
|
+
import { Vector } from '../../../Math/vector';
|
|
3
|
+
import { ExcaliburGraphicsContextWebGL } from '../ExcaliburGraphicsContextWebGL';
|
|
4
|
+
import { RendererPlugin } from '../renderer';
|
|
5
|
+
export declare class RectangleRenderer implements RendererPlugin {
|
|
6
|
+
readonly type = "ex.rectangle";
|
|
7
|
+
priority: number;
|
|
8
|
+
private _maxRectangles;
|
|
9
|
+
private _shader;
|
|
10
|
+
private _gl;
|
|
11
|
+
private _context;
|
|
12
|
+
private _buffer;
|
|
13
|
+
private _layout;
|
|
14
|
+
private _quads;
|
|
15
|
+
private _rectangleCount;
|
|
16
|
+
private _vertexIndex;
|
|
17
|
+
initialize(gl: WebGLRenderingContext, context: ExcaliburGraphicsContextWebGL): void;
|
|
18
|
+
private _isFull;
|
|
19
|
+
drawLine(start: Vector, end: Vector, color: Color, thickness?: number): void;
|
|
20
|
+
draw(pos: Vector, width: number, height: number, color: Color, stroke?: Color, strokeThickness?: number): void;
|
|
21
|
+
hasPendingDraws(): boolean;
|
|
22
|
+
flush(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#ifdef GL_OES_standard_derivatives
|
|
2
|
+
#extension GL_OES_standard_derivatives : enable
|
|
3
|
+
#endif
|
|
4
|
+
precision mediump float;
|
|
5
|
+
|
|
6
|
+
// UV coord
|
|
7
|
+
varying vec2 v_uv;
|
|
8
|
+
|
|
9
|
+
varying vec2 v_size; // in pixels
|
|
10
|
+
|
|
11
|
+
// Color coord to blend with image
|
|
12
|
+
varying lowp vec4 v_color;
|
|
13
|
+
|
|
14
|
+
// Stroke color if used
|
|
15
|
+
varying lowp vec4 v_strokeColor;
|
|
16
|
+
|
|
17
|
+
// Stroke thickness if used
|
|
18
|
+
varying lowp float v_strokeThickness; // in pixels
|
|
19
|
+
|
|
20
|
+
// Opacity
|
|
21
|
+
varying float v_opacity;
|
|
22
|
+
|
|
23
|
+
void main() {
|
|
24
|
+
// modified from https://stackoverflow.com/questions/59197671/glsl-rounded-rectangle-with-variable-border
|
|
25
|
+
vec2 uv = v_uv;
|
|
26
|
+
vec2 fragCoord = uv * v_size;
|
|
27
|
+
float maxX = v_size.x - v_strokeThickness;
|
|
28
|
+
float minX = v_strokeThickness;
|
|
29
|
+
float maxY = v_size.y - v_strokeThickness;
|
|
30
|
+
float minY = v_strokeThickness;
|
|
31
|
+
|
|
32
|
+
if (fragCoord.x < maxX && fragCoord.x > minX &&
|
|
33
|
+
fragCoord.y < maxY && fragCoord.y > minY) {
|
|
34
|
+
gl_FragColor = v_color;
|
|
35
|
+
} else {
|
|
36
|
+
gl_FragColor = v_strokeColor;
|
|
37
|
+
}
|
|
38
|
+
gl_FragColor.a *= v_opacity;
|
|
39
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
40
|
+
|
|
41
|
+
// vec2 v2CenteredPos = abs(fragCoord - v_size.xy / 2.0);
|
|
42
|
+
// vec2 v2HalfShapeSizePx = v_size.xy/2.0 - v_strokeThickness/2.0;
|
|
43
|
+
|
|
44
|
+
// float fHalfBorderDist = 0.0;
|
|
45
|
+
// float fHalfBorderThickness = 0.0;
|
|
46
|
+
|
|
47
|
+
// if (fragCoord.x > max(v_radius, v_strokeThickness) &&
|
|
48
|
+
// fragCoord.x < v_size.x - max(v_radius, v_strokeThickness))
|
|
49
|
+
// {
|
|
50
|
+
// fHalfBorderDist = v2CenteredPos.y - v2HalfShapeSizePx.y;
|
|
51
|
+
// fHalfBorderThickness = v_strokeThickness / 2.0;
|
|
52
|
+
// }
|
|
53
|
+
// else if (fragCoord.y > max(v_radius, v_strokeThickness) &&
|
|
54
|
+
// fragCoord.y < v_size.y - max(v_radius, v_strokeThickness))
|
|
55
|
+
// {
|
|
56
|
+
// fHalfBorderDist = v2CenteredPos.x - v2HalfShapeSizePx.x;
|
|
57
|
+
// fHalfBorderThickness = v_strokeThickness / 2.0;
|
|
58
|
+
// }
|
|
59
|
+
// else
|
|
60
|
+
// {
|
|
61
|
+
// vec2 edgeVec = max(vec2(0.0), v_radius - vec2(
|
|
62
|
+
// uv.x > 0.5 ? v_size.x - fragCoord.x : fragCoord.x,
|
|
63
|
+
// uv.y > 0.5 ? v_size.y - fragCoord.y : fragCoord.y));
|
|
64
|
+
|
|
65
|
+
// float ellipse_ab = v_radius-v_strokeThickness;
|
|
66
|
+
// vec2 ellipse_isect = (v_strokeThickness > v_radius || v_strokeThickness > v_radius) ? vec2(0.0) :
|
|
67
|
+
// edgeVec.xy * ellipse_ab*ellipse_ab / length(ellipse_ab*edgeVec.yx);
|
|
68
|
+
|
|
69
|
+
// fHalfBorderThickness = (v_radius - length(ellipse_isect)) / 2.0;
|
|
70
|
+
// fHalfBorderDist = length(edgeVec) - (v_radius - fHalfBorderThickness);
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// vec4 v4FromColor = v_strokeColor;
|
|
74
|
+
// v4FromColor.rgb *= v4FromColor.a;
|
|
75
|
+
// vec4 v4ToColor = vec4(0.0); // background color is transparent
|
|
76
|
+
// if (fHalfBorderDist < 0.0) {
|
|
77
|
+
// v4ToColor = v_color;
|
|
78
|
+
// v4ToColor.rgb *= v4ToColor.a;
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
// float mixPct = abs(fHalfBorderDist) - fHalfBorderThickness;
|
|
82
|
+
|
|
83
|
+
// vec4 finalColor = mix(v4FromColor, v4ToColor, mixPct);
|
|
84
|
+
// gl_FragColor = finalColor;
|
|
85
|
+
}
|