littlejsengine 1.5.0 → 1.5.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.
@@ -35,18 +35,21 @@ const keyWasReleased = (key, device=0)=> inputData[device] && inputData[device][
35
35
  const clearInput = ()=> inputData = [[]];
36
36
 
37
37
  /** Returns true if mouse button is down
38
+ * @function
38
39
  * @param {Number} button
39
40
  * @return {Boolean}
40
41
  * @memberof Input */
41
42
  const mouseIsDown = keyIsDown;
42
43
 
43
44
  /** Returns true if mouse button was pressed
45
+ * @function
44
46
  * @param {Number} button
45
47
  * @return {Boolean}
46
48
  * @memberof Input */
47
49
  const mouseWasPressed = keyWasPressed;
48
50
 
49
51
  /** Returns true if mouse button was released
52
+ * @function
50
53
  * @param {Number} button
51
54
  * @return {Boolean}
52
55
  * @memberof Input */
@@ -63,14 +66,17 @@ let mousePos = vec2();
63
66
  let mousePosScreen = vec2();
64
67
 
65
68
  /** Mouse wheel delta this frame
69
+ * @type {Number}
66
70
  * @memberof Input */
67
71
  let mouseWheel = 0;
68
72
 
69
73
  /** Returns true if user is using gamepad (has more recently pressed a gamepad button)
74
+ * @type {Boolean}
70
75
  * @memberof Input */
71
76
  let isUsingGamepad = 0;
72
77
 
73
78
  /** Prevents input continuing to the default browser handling (false by default)
79
+ * @type {Boolean}
74
80
  * @memberof Input */
75
81
  let preventDefaultInput = 0;
76
82
 
@@ -246,7 +252,6 @@ const vibrateStop = ()=> vibrate(0);
246
252
  // Touch input
247
253
 
248
254
  /** True if a touch device has been detected
249
- * @const {Boolean}
250
255
  * @memberof Input */
251
256
  const isTouchDevice = window.ontouchstart !== undefined;
252
257
 
@@ -9,6 +9,7 @@
9
9
  'use strict';
10
10
 
11
11
  /** List of all medals
12
+ * @type {Array}
12
13
  * @memberof Medals */
13
14
  const medals = [];
14
15
 
@@ -32,15 +32,15 @@
32
32
  class EngineObject
33
33
  {
34
34
  /** Create an engine object and adds it to the list of objects
35
- * @param {Vector2} [position=new Vector2()] - World space position of the object
36
- * @param {Vector2} [size=objectDefaultSize] - World space size of the object
35
+ * @param {Vector2} [position=Vector2()] - World space position of the object
36
+ * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
37
37
  * @param {Number} [tileIndex=-1] - Tile to use to render object (-1 is untextured)
38
38
  * @param {Vector2} [tileSize=tileSizeDefault] - Size of tile in source pixels
39
39
  * @param {Number} [angle=0] - Angle the object is rotated by
40
- * @param {Color} [color] - Color to apply to tile when rendered
40
+ * @param {Color} [color=Color()] - Color to apply to tile when rendered
41
41
  * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
42
42
  */
43
- constructor(pos=vec2(), size=objectDefaultSize, tileIndex=-1, tileSize=tileSizeDefault, angle=0, color, renderOrder=0)
43
+ constructor(pos=vec2(), size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, angle=0, color, renderOrder=0)
44
44
  {
45
45
  // set passed in params
46
46
  ASSERT(isVector2(pos) && isVector2(size)); // ensure pos and size are vec2s
@@ -77,7 +77,7 @@ class EngineObject
77
77
  this.gravityScale = 1;
78
78
  /** @property {Number} [renderOrder=0] - Objects are sorted by render order */
79
79
  this.renderOrder = renderOrder;
80
- /** @property {Vector2} [velocity=new Vector2()] - Velocity of the object */
80
+ /** @property {Vector2} [velocity=Vector2()] - Velocity of the object */
81
81
  this.velocity = new Vector2();
82
82
  /** @property {Number} [angleVelocity=0] - Angular velocity of the object */
83
83
  this.angleVelocity = 0;
@@ -320,7 +320,7 @@ class EngineObject
320
320
 
321
321
  /** Attaches a child to this with a given local transform
322
322
  * @param {EngineObject} child
323
- * @param {Vector2} [localPos=new Vector2]
323
+ * @param {Vector2} [localPos=Vector2()]
324
324
  * @param {Number} [localAngle=0] */
325
325
  addChild(child, localPos=vec2(), localAngle=0)
326
326
  {
@@ -34,11 +34,11 @@ class ParticleEmitter extends EngineObject
34
34
  * @param {Number} [emitRate=100] - How many particles per second to spawn, does not emit if 0
35
35
  * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
36
36
  * @param {Number} [tileIndex=-1] - Index into tile sheet, if <0 no texture is applied
37
- * @param {Vector2} [tileSize=tileSizeDefault] - Tile size for particles
38
- * @param {Color} [colorStartA=new Color(1,1,1)] - Color at start of life 1, randomized between start colors
39
- * @param {Color} [colorStartB=new Color(1,1,1)] - Color at start of life 2, randomized between start colors
40
- * @param {Color} [colorEndA=new Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
41
- * @param {Color} [colorEndB=new Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
37
+ * @param {Vector2} [tileSize=tileSizeDefault] - Tile size for particles
38
+ * @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
39
+ * @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
40
+ * @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
41
+ * @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
42
42
  * @param {Number} [particleTime=.5] - How long particles live
43
43
  * @param {Number} [sizeStart=.1] - How big are particles at start
44
44
  * @param {Number} [sizeEnd=1] - How big are particles at end
@@ -10,11 +10,12 @@
10
10
 
11
11
  /** Position of camera in world space
12
12
  * @type {Vector2}
13
- * @default
13
+ * @default Vector2()
14
14
  * @memberof Settings */
15
15
  let cameraPos = vec2();
16
16
 
17
17
  /** Scale of camera in world space
18
+ * @type {Number}
18
19
  * @default
19
20
  * @memberof Settings */
20
21
  let cameraScale = 32;
@@ -23,24 +24,26 @@ let cameraScale = 32;
23
24
  // Display settings
24
25
 
25
26
  /** The max size of the canvas, centered if window is larger
26
- * @type {Vector2}
27
- * @default
27
+ * @type {Vector2}
28
+ * @default Vector2(1920,1200)
28
29
  * @memberof Settings */
29
30
  let canvasMaxSize = vec2(1920, 1200);
30
31
 
31
32
  /** Fixed size of the canvas, if enabled canvas size never changes
32
33
  * - you may also need to set mainCanvasSize if using screen space coords in startup
33
- * @type {Vector2}
34
- * @default
34
+ * @type {Vector2}
35
+ * @default Vector2()
35
36
  * @memberof Settings */
36
37
  let canvasFixedSize = vec2();
37
38
 
38
39
  /** Disables anti aliasing for pixel art if true
40
+ * @type {Boolean}
39
41
  * @default
40
42
  * @memberof Settings */
41
43
  let cavasPixelated = 1;
42
44
 
43
45
  /** Default font used for text rendering
46
+ * @type {String}
44
47
  * @default
45
48
  * @memberof Settings */
46
49
  let fontDefault = 'arial';
@@ -49,11 +52,13 @@ let fontDefault = 'arial';
49
52
  // WebGL settings
50
53
 
51
54
  /** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
55
+ * @type {Boolean}
52
56
  * @default
53
57
  * @memberof Settings */
54
58
  let glEnable = 1;
55
59
 
56
60
  /** Fixes slow rendering in some browsers by not compositing the WebGL canvas
61
+ * @type {Boolean}
57
62
  * @default
58
63
  * @memberof Settings */
59
64
  let glOverlay = 1;
@@ -62,12 +67,13 @@ let glOverlay = 1;
62
67
  // Tile sheet settings
63
68
 
64
69
  /** Default size of tiles in pixels
65
- * @type {Vector2}
66
- * @default
70
+ * @type {Vector2}
71
+ * @default Vector2(16,16)
67
72
  * @memberof Settings */
68
73
  let tileSizeDefault = vec2(16);
69
74
 
70
75
  /** Prevent tile bleeding from neighbors in pixels
76
+ * @type {Number}
71
77
  * @default
72
78
  * @memberof Settings */
73
79
  let tileFixBleedScale = .3;
@@ -75,53 +81,56 @@ let tileFixBleedScale = .3;
75
81
  ///////////////////////////////////////////////////////////////////////////////
76
82
  // Object settings
77
83
 
78
- /** Default size of objects
79
- * @type {Vector2}
80
- * @default
81
- * @memberof Settings */
82
- let objectDefaultSize = vec2(1);
83
-
84
84
  /** Enable physics solver for collisions between objects
85
+ * @type {Boolean}
85
86
  * @default
86
87
  * @memberof Settings */
87
88
  let enablePhysicsSolver = 1;
88
89
 
89
90
  /** Default object mass for collison calcuations (how heavy objects are)
91
+ * @type {Number}
90
92
  * @default
91
93
  * @memberof Settings */
92
94
  let objectDefaultMass = 1;
93
95
 
94
96
  /** How much to slow velocity by each frame (0-1)
97
+ * @type {Number}
95
98
  * @default
96
99
  * @memberof Settings */
97
- let objectDefaultDamping = .99;
100
+ let objectDefaultDamping = 1;
98
101
 
99
102
  /** How much to slow angular velocity each frame (0-1)
103
+ * @type {Number}
100
104
  * @default
101
105
  * @memberof Settings */
102
- let objectDefaultAngleDamping = .99;
106
+ let objectDefaultAngleDamping = 1;
103
107
 
104
108
  /** How much to bounce when a collision occurs (0-1)
105
- * @default
109
+ * @type {Number}
110
+ * @default 0
106
111
  * @memberof Settings */
107
112
  let objectDefaultElasticity = 0;
108
113
 
109
114
  /** How much to slow when touching (0-1)
115
+ * @type {Number}
110
116
  * @default
111
117
  * @memberof Settings */
112
118
  let objectDefaultFriction = .8;
113
119
 
114
120
  /** Clamp max speed to avoid fast objects missing collisions
121
+ * @type {Number}
115
122
  * @default
116
123
  * @memberof Settings */
117
124
  let objectMaxSpeed = 1;
118
125
 
119
126
  /** How much gravity to apply to objects along the Y axis, negative is down
120
- * @default
127
+ * @type {Number}
128
+ * @default 0
121
129
  * @memberof Settings */
122
130
  let gravity = 0;
123
131
 
124
132
  /** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
133
+ * @type {Number}
125
134
  * @default
126
135
  * @memberof Settings */
127
136
  let particleEmitRateScale = 1;
@@ -130,16 +139,19 @@ let particleEmitRateScale = 1;
130
139
  // Input settings
131
140
 
132
141
  /** Should gamepads be allowed
142
+ * @type {Boolean}
133
143
  * @default
134
144
  * @memberof Settings */
135
145
  let gamepadsEnable = 1;
136
146
 
137
147
  /** If true, the dpad input is also routed to the left analog stick (for better accessability)
148
+ * @type {Boolean}
138
149
  * @default
139
150
  * @memberof Settings */
140
151
  let gamepadDirectionEmulateStick = 1;
141
152
 
142
153
  /** If true the WASD keys are also routed to the direction keys (for better accessability)
154
+ * @type {Boolean}
143
155
  * @default
144
156
  * @memberof Settings */
145
157
  let inputWASDEmulateDirection = 1;
@@ -147,26 +159,31 @@ let inputWASDEmulateDirection = 1;
147
159
  /** True if touch gamepad should appear on mobile devices
148
160
  * <br> - Supports left analog stick, 4 face buttons and start button (button 9)
149
161
  * <br> - Must be set by end of gameInit to be activated
150
- * @default
162
+ * @type {Boolean}
163
+ * @default 0
151
164
  * @memberof Settings */
152
165
  let touchGamepadEnable = 0;
153
166
 
154
167
  /** True if touch gamepad should be analog stick or false to use if 8 way dpad
168
+ * @type {Boolean}
155
169
  * @default
156
170
  * @memberof Settings */
157
171
  let touchGamepadAnalog = 1;
158
172
 
159
173
  /** Size of virutal gamepad for touch devices in pixels
174
+ * @type {Number}
160
175
  * @default
161
176
  * @memberof Settings */
162
177
  let touchGamepadSize = 99;
163
178
 
164
179
  /** Transparency of touch gamepad overlay
180
+ * @type {Number}
165
181
  * @default
166
182
  * @memberof Settings */
167
183
  let touchGamepadAlpha = .3;
168
184
 
169
185
  /** Allow vibration hardware if it exists
186
+ * @type {Boolean}
170
187
  * @default
171
188
  * @memberof Settings */
172
189
  let vibrateEnable = 1;
@@ -175,21 +192,25 @@ let vibrateEnable = 1;
175
192
  // Audio settings
176
193
 
177
194
  /** All audio code can be disabled and removed from build
195
+ * @type {Boolean}
178
196
  * @default
179
197
  * @memberof Settings */
180
198
  let soundEnable = 1;
181
199
 
182
200
  /** Volume scale to apply to all sound, music and speech
201
+ * @type {Number}
183
202
  * @default
184
203
  * @memberof Settings */
185
204
  let soundVolume = .5;
186
205
 
187
206
  /** Default range where sound no longer plays
207
+ * @type {Number}
188
208
  * @default
189
209
  * @memberof Settings */
190
210
  let soundDefaultRange = 40;
191
211
 
192
212
  /** Default range percent to start tapering off sound (0-1)
213
+ * @type {Number}
193
214
  * @default
194
215
  * @memberof Settings */
195
216
  let soundDefaultTaper = .7;
@@ -198,26 +219,31 @@ let soundDefaultTaper = .7;
198
219
  // Medals settings
199
220
 
200
221
  /** How long to show medals for in seconds
222
+ * @type {Number}
201
223
  * @default
202
224
  * @memberof Settings */
203
225
  let medalDisplayTime = 5;
204
226
 
205
227
  /** How quickly to slide on/off medals in seconds
228
+ * @type {Number}
206
229
  * @default
207
230
  * @memberof Settings */
208
231
  let medalDisplaySlideTime = .5;
209
232
 
210
233
  /** Size of medal display
211
- * @default
234
+ * @type {Vector2}
235
+ * @default Vector2(640,80)
212
236
  * @memberof Settings */
213
237
  let medalDisplaySize = vec2(640, 80);
214
238
 
215
239
  /** Size of icon in medal display
240
+ * @type {Number}
216
241
  * @default
217
242
  * @memberof Settings */
218
243
  let medalDisplayIconSize = 50;
219
244
 
220
245
  /** Set to stop medals from being unlockable (like if cheats are enabled)
221
- * @default
246
+ * @type {Boolean}
247
+ * @default 0
222
248
  * @memberof Settings */
223
249
  let medalsPreventUnlock;
@@ -13,6 +13,7 @@
13
13
  'use strict';
14
14
 
15
15
  /** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
16
+ * @type {Array}
16
17
  * @memberof TileCollision */
17
18
  let tileCollision = [];
18
19
 
@@ -48,7 +49,7 @@ const getTileCollisionData = (pos)=>
48
49
 
49
50
  /** Check if collision with another object should occur
50
51
  * @param {Vector2} pos
51
- * @param {Vector2} [size=new Vector2(1,1)]
52
+ * @param {Vector2} [size=Vector2(1,1)]
52
53
  * @param {EngineObject} [object]
53
54
  * @return {Boolean}
54
55
  * @memberof TileCollision */
@@ -116,11 +117,11 @@ function tileCollisionRaycast(posStart, posEnd, object)
116
117
  class TileLayerData
117
118
  {
118
119
  /** Create a tile layer data object, one for each tile in a TileLayer
119
- * @param {Number} [tile] - The tile to use, untextured if undefined
120
- * @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
121
- * @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
122
- * @param {Color} [color=new Color(1,1,1)] - Color of the tile */
123
- constructor(tile, direction=0, mirror=0, color=new Color)
120
+ * @param {Number} [tile] - The tile to use, untextured if undefined
121
+ * @param {Number} [direction=0] - Integer direction of tile, in 90 degree increments
122
+ * @param {Boolean} [mirror=0] - If the tile should be mirrored along the x axis
123
+ * @param {Color} [color=Color()] - Color of the tile */
124
+ constructor(tile, direction=0, mirror=0, color=new Color())
124
125
  {
125
126
  /** @property {Number} - The tile to use, untextured if undefined */
126
127
  this.tile = tile;
@@ -151,10 +152,10 @@ class TileLayerData
151
152
  class TileLayer extends EngineObject
152
153
  {
153
154
  /** Create a tile layer object
154
- * @param {Vector2} [position=new Vector2()] - World space position
155
+ * @param {Vector2} [position=Vector2()] - World space position
155
156
  * @param {Vector2} [size=tileCollisionSize] - World space size
156
157
  * @param {Vector2} [tileSize=tileSizeDefault] - Size of tiles in source pixels
157
- * @param {Vector2} [scale=new Vector2(1,1)] - How much to scale this layer when rendered
158
+ * @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
158
159
  * @param {Number} [renderOrder=0] - Objects sorted by renderOrder before being rendered
159
160
  */
160
161
  constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1), renderOrder=0)
@@ -306,10 +307,10 @@ constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1)
306
307
 
307
308
  /** Draw a tile directly onto the layer canvas
308
309
  * @param {Vector2} pos
309
- * @param {Vector2} [size=new Vector2(1,1)]
310
+ * @param {Vector2} [size=Vector2(1,1)]
310
311
  * @param {Number} [tileIndex=-1]
311
312
  * @param {Vector2} [tileSize=tileSizeDefault]
312
- * @param {Color} [color=new Color(1,1,1)]
313
+ * @param {Color} [color=Color()]
313
314
  * @param {Number} [angle=0]
314
315
  * @param {Boolean} [mirror=0] */
315
316
  drawTile(pos, size=vec2(1), tileIndex=-1, tileSize=tileSizeDefault, color=new Color, angle, mirror)
@@ -335,8 +336,8 @@ constructor(pos, size=tileCollisionSize, tileSize=tileSizeDefault, scale=vec2(1)
335
336
 
336
337
  /** Draw a rectangle directly onto the layer canvas
337
338
  * @param {Vector2} pos
338
- * @param {Vector2} [size=new Vector2(1,1)]
339
- * @param {Color} [color=new Color(1,1,1)]
339
+ * @param {Vector2} [size=Vector2(1,1)]
340
+ * @param {Color} [color=Color()]
340
341
  * @param {Number} [angle=0] */
341
342
  drawRect(pos, size, color, angle)
342
343
  { this.drawTile(pos, size, -1, 0, color, angle); }
@@ -10,7 +10,8 @@
10
10
  'use strict';
11
11
 
12
12
  /** A shortcut to get Math.PI
13
- * @const
13
+ * @type {Number}
14
+ * @default Math.PI
14
15
  * @memberof Utilities */
15
16
  const PI = Math.PI;
16
17
 
@@ -90,7 +91,7 @@ const nearestPowerOfTwo = (v)=> 2**Math.ceil(Math.log2(v));
90
91
  * @param {Vector2} [sizeB] - Size of box B
91
92
  * @return {Boolean} - True if overlapping
92
93
  * @memberof Utilities */
93
- const isOverlapping = (pA, sA, pB, sB)=> abs(pA.x - pB.x)*2 < sA.x + sB.x & abs(pA.y - pB.y)*2 < sA.y + sB.y;
94
+ const isOverlapping = (pA, sA, pB, sB)=> abs(pA.x - pB.x)*2 < sA.x + sB.x && abs(pA.y - pB.y)*2 < sA.y + sB.y;
94
95
 
95
96
  /** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
96
97
  * @param {Number} [frequency=1] - Frequency of the wave in Hz
@@ -144,8 +145,8 @@ const randInCircle = (radius=1, minRadius=0)=> radius > 0 ? randVector(radius *
144
145
  const randVector = (length=1)=> new Vector2().setAngle(rand(2*PI), length);
145
146
 
146
147
  /** Returns a random color between the two passed in colors, combine components if linear
147
- * @param {Color} [colorA=new Color(1,1,1,1)]
148
- * @param {Color} [colorB=new Color(0,0,0,1)]
148
+ * @param {Color} [colorA=Color()]
149
+ * @param {Color} [colorB=Color(0,0,0,1)]
149
150
  * @param {Boolean} [linear]
150
151
  * @return {Color}
151
152
  * @memberof Random */
@@ -153,6 +154,8 @@ const randColor = (cA = new Color, cB = new Color(0,0,0,1), linear)=>
153
154
  linear ? cA.lerp(cB, rand()) : new Color(rand(cA.r,cB.r),rand(cA.g,cB.g),rand(cA.b,cB.b),rand(cA.a,cB.a));
154
155
 
155
156
  /** Seed used by the randSeeded function
157
+ * @type {Number}
158
+ * @default
156
159
  * @memberof Random */
157
160
  let randSeed = 1;
158
161
 
@@ -291,7 +294,8 @@ class Vector2
291
294
 
292
295
  /** Sets this vector with angle and length passed in
293
296
  * @param {Number} [angle=0]
294
- * @param {Number} [length=1] */
297
+ * @param {Number} [length=1]
298
+ * @return {Vector2} */
295
299
  setAngle(a=0, length=1) { this.x = length*Math.sin(a); this.y = length*Math.cos(a); return this; }
296
300
 
297
301
  /** Returns copy of this vector rotated by the angle passed in
@@ -360,9 +364,11 @@ const colorHSLA = (h, s, l, a)=> new Color().setHSLA(h, s, l, a);
360
364
  /**
361
365
  * Color object (red, green, blue, alpha) with some helpful functions
362
366
  * @example
363
- * let a = new Color; // white
364
- * let b = new Color(1, 0, 0); // red
365
- * let c = new Color(0, 0, 0, 0); // transparent black
367
+ * let a = new Color; // white
368
+ * let b = new Color(1, 0, 0); // red
369
+ * let c = new Color(0, 0, 0, 0); // transparent black
370
+ * let d = colorRGBA(0, 0, 1); // blue using rgb color
371
+ * let e = colorHSLA(.3, 1, .5); // green using hsl color
366
372
  */
367
373
  class Color
368
374
  {
@@ -263,12 +263,13 @@ function glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdd
263
263
  ///////////////////////////////////////////////////////////////////////////////
264
264
  // post processing - can be enabled to pass other canvases through a final shader
265
265
 
266
- let glPostShader, glPostArrayBuffer, glPostTexture;
266
+ let glPostShader, glPostArrayBuffer, glPostTexture, glPostIncludeOverlay;
267
267
 
268
268
  /** Set up a post processing shader
269
269
  * @param {String} shaderCode
270
+ * @param {Boolean} includeOverlay
270
271
  * @memberof WebGL */
271
- function glInitPostProcess(shaderCode)
272
+ function glInitPostProcess(shaderCode, includeOverlay)
272
273
  {
273
274
  ASSERT(!glPostShader); // can only have 1 post effects shader
274
275
 
@@ -297,6 +298,7 @@ function glInitPostProcess(shaderCode)
297
298
  // create buffer and texture
298
299
  glPostArrayBuffer = glContext.createBuffer();
299
300
  glPostTexture = glCreateTexture();
301
+ glPostIncludeOverlay = includeOverlay;
300
302
 
301
303
  // hide the original 2d canvas
302
304
  mainCanvas.style.visibility = 'hidden';
@@ -317,6 +319,15 @@ function glRenderPostProcess()
317
319
  else // set viewport
318
320
  glContext.viewport(0, 0, glCanvas.width = mainCanvas.width, glCanvas.height = mainCanvas.height);
319
321
 
322
+ if (glPostIncludeOverlay)
323
+ {
324
+ // copy overlay canvas so it will be included in post processing
325
+ mainContext.drawImage(overlayCanvas, 0, 0);
326
+
327
+ // clear overlay canvas
328
+ overlayCanvas.width = mainCanvas.width;
329
+ }
330
+
320
331
  // setup shader program to draw one triangle
321
332
  glContext.useProgram(glPostShader);
322
333
  glContext.disable(gl_BLEND);