littlejsengine 1.9.0 → 1.9.1

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.
@@ -534,11 +534,11 @@ function smoothStep(percent) { return percent * percent * (3 - 2 * percent); }
534
534
  function nearestPowerOfTwo(value) { return 2**Math.ceil(Math.log2(value)); }
535
535
 
536
536
  /** Returns true if two axis aligned bounding boxes are overlapping
537
- * @param {Vector2} pointA - Center of box A
538
- * @param {Vector2} sizeA - Size of box A
539
- * @param {Vector2} pointB - Center of box B
540
- * @param {Vector2} sizeB - Size of box B
541
- * @return {Boolean} - True if overlapping
537
+ * @param {Vector2} pointA - Center of box A
538
+ * @param {Vector2} sizeA - Size of box A
539
+ * @param {Vector2} pointB - Center of box B
540
+ * @param {Vector2} sizeB - Size of box B
541
+ * @return {Boolean} - True if overlapping
542
542
  * @memberof Utilities */
543
543
  function isOverlapping(pointA, sizeA, pointB, sizeB)
544
544
  {
@@ -1557,12 +1557,12 @@ function setDebugKey(key) { debugKey = key; }
1557
1557
  class EngineObject
1558
1558
  {
1559
1559
  /** Create an engine object and adds it to the list of objects
1560
- * @param {Vector2} [pos=Vector2()] - World space position of the object
1561
- * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
1562
- * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
1563
- * @param {Number} [angle] - Angle the object is rotated by
1564
- * @param {Color} [color=Color()] - Color to apply to tile when rendered
1565
- * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
1560
+ * @param {Vector2} [pos=(0,0)] - World space position of the object
1561
+ * @param {Vector2} [size=(1,1)] - World space size of the object
1562
+ * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
1563
+ * @param {Number} [angle] - Angle the object is rotated by
1564
+ * @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
1565
+ * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
1566
1566
  */
1567
1567
  constructor(pos=vec2(), size=vec2(1), tileInfo, angle=0, color, renderOrder=0)
1568
1568
  {
@@ -1862,7 +1862,7 @@ class EngineObject
1862
1862
 
1863
1863
  /** Attaches a child to this with a given local transform
1864
1864
  * @param {EngineObject} child
1865
- * @param {Vector2} [localPos=Vector2()]
1865
+ * @param {Vector2} [localPos=(0,0)]
1866
1866
  * @param {Number} [localAngle] */
1867
1867
  addChild(child, localPos=vec2(), localAngle=0)
1868
1868
  {
@@ -1979,7 +1979,7 @@ let drawCount;
1979
1979
  * Create a tile info object
1980
1980
  * - This can take vecs or floats for easier use and conversion
1981
1981
  * - If an index is passed in, the tile size and index will determine the position
1982
- * @param {(Number|Vector2)} [pos=Vector2()] - Top left corner of tile in pixels or index
1982
+ * @param {(Number|Vector2)} [pos=(0,0)] - Top left corner of tile in pixels or index
1983
1983
  * @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
1984
1984
  * @param {Number} [textureIndex] - Texture index to use
1985
1985
  * @return {TileInfo}
@@ -2022,7 +2022,7 @@ function tile(pos=vec2(), size=tileSizeDefault, textureIndex=0)
2022
2022
  class TileInfo
2023
2023
  {
2024
2024
  /** Create a tile info object
2025
- * @param {Vector2} [pos=Vector2()] - Top left corner of tile in pixels
2025
+ * @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
2026
2026
  * @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
2027
2027
  * @param {Number} [textureIndex] - Texture index to use
2028
2028
  */
@@ -2099,16 +2099,16 @@ function worldToScreen(worldPos)
2099
2099
  }
2100
2100
 
2101
2101
  /** Draw textured tile centered in world space, with color applied if using WebGL
2102
- * @param {Vector2} pos - Center of the tile in world space
2103
- * @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
2104
- * @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
2105
- * @param {Color} [color=Color()] - Color to modulate with
2106
- * @param {Number} [angle] - Angle to rotate by
2107
- * @param {Boolean} [mirror] - If true image is flipped along the Y axis
2108
- * @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
2109
- * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
2110
- * @param {Boolean} [screenSpace] - If true the pos and size are in screen space
2111
- * @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2102
+ * @param {Vector2} pos - Center of the tile in world space
2103
+ * @param {Vector2} [size=(1,1)] - Size of the tile in world space
2104
+ * @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
2105
+ * @param {Color} [color=(1,1,1,1)] - Color to modulate with
2106
+ * @param {Number} [angle] - Angle to rotate by
2107
+ * @param {Boolean} [mirror] - If true image is flipped along the Y axis
2108
+ * @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
2109
+ * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
2110
+ * @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
2111
+ * @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2112
2112
  * @memberof Draw */
2113
2113
  function drawTile(pos, size=vec2(1), tileInfo, color=new Color,
2114
2114
  angle=0, mirror, additiveColor=new Color(0,0,0,0), useWebGL=glEnable, screenSpace, context)
@@ -2176,11 +2176,11 @@ function drawTile(pos, size=vec2(1), tileInfo, color=new Color,
2176
2176
 
2177
2177
  /** Draw colored rect centered on pos
2178
2178
  * @param {Vector2} pos
2179
- * @param {Vector2} [size=Vector2(1,1)]
2180
- * @param {Color} [color=Color()]
2179
+ * @param {Vector2} [size=(1,1)]
2180
+ * @param {Color} [color=(1,1,1,1)]
2181
2181
  * @param {Number} [angle]
2182
2182
  * @param {Boolean} [useWebGL=glEnable]
2183
- * @param {Boolean} [screenSpace]
2183
+ * @param {Boolean} [screenSpace=false]
2184
2184
  * @param {CanvasRenderingContext2D} [context]
2185
2185
  * @memberof Draw */
2186
2186
  function drawRect(pos, size, color, angle, useWebGL, screenSpace, context)
@@ -2190,8 +2190,8 @@ function drawRect(pos, size, color, angle, useWebGL, screenSpace, context)
2190
2190
 
2191
2191
  /** Draw colored polygon using passed in points
2192
2192
  * @param {Array} points - Array of Vector2 points
2193
- * @param {Color} [color=Color()]
2194
- * @param {Boolean} [screenSpace]
2193
+ * @param {Color} [color=(1,1,1,1)]
2194
+ * @param {Boolean} [screenSpace=false]
2195
2195
  * @param {CanvasRenderingContext2D} [context=mainContext]
2196
2196
  * @memberof Draw */
2197
2197
  function drawPoly(points, color=new Color, screenSpace, context=mainContext)
@@ -2207,9 +2207,9 @@ function drawPoly(points, color=new Color, screenSpace, context=mainContext)
2207
2207
  * @param {Vector2} posA
2208
2208
  * @param {Vector2} posB
2209
2209
  * @param {Number} [thickness]
2210
- * @param {Color} [color=Color()]
2210
+ * @param {Color} [color=(1,1,1,1)]
2211
2211
  * @param {Boolean} [useWebGL=glEnable]
2212
- * @param {Boolean} [screenSpace]
2212
+ * @param {Boolean} [screenSpace=false]
2213
2213
  * @param {CanvasRenderingContext2D} [context]
2214
2214
  * @memberof Draw */
2215
2215
  function drawLine(posA, posB, thickness=.1, color, useWebGL, screenSpace, context)
@@ -2225,7 +2225,7 @@ function drawLine(posA, posB, thickness=.1, color, useWebGL, screenSpace, contex
2225
2225
  * @param {Number} angle
2226
2226
  * @param {Boolean} mirror
2227
2227
  * @param {Function} drawFunction
2228
- * @param {Boolean} [screenSpace]
2228
+ * @param {Boolean} [screenSpace=false]
2229
2229
  * @param {CanvasRenderingContext2D} [context=mainContext]
2230
2230
  * @memberof Draw */
2231
2231
  function drawCanvas2D(pos, size, angle, mirror, drawFunction, screenSpace, context=mainContext)
@@ -2267,9 +2267,9 @@ function setBlendMode(additive, useWebGL=glEnable, context)
2267
2267
  * @param {String} text
2268
2268
  * @param {Vector2} pos
2269
2269
  * @param {Number} [size]
2270
- * @param {Color} [color=Color()]
2270
+ * @param {Color} [color=(1,1,1,1)]
2271
2271
  * @param {Number} [lineWidth]
2272
- * @param {Color} [lineColor=Color(0,0,0)]
2272
+ * @param {Color} [lineColor=(0,0,0,1)]
2273
2273
  * @param {CanvasTextAlign} [textAlign='center']
2274
2274
  * @param {String} [font=fontDefault]
2275
2275
  * @param {CanvasRenderingContext2D} [context=overlayContext]
@@ -2284,9 +2284,9 @@ function drawText(text, pos, size=1, color, lineWidth=0, lineColor, textAlign, f
2284
2284
  * @param {String} text
2285
2285
  * @param {Vector2} pos
2286
2286
  * @param {Number} [size]
2287
- * @param {Color} [color=Color()]
2287
+ * @param {Color} [color=(1,1,1,1)]
2288
2288
  * @param {Number} [lineWidth]
2289
- * @param {Color} [lineColor=Color(0,0,0)]
2289
+ * @param {Color} [lineColor=(0,0,0,1)]
2290
2290
  * @param {CanvasTextAlign} [textAlign]
2291
2291
  * @param {String} [font=fontDefault]
2292
2292
  * @param {CanvasRenderingContext2D} [context=overlayContext]
@@ -2329,9 +2329,9 @@ let engineFontImage;
2329
2329
  class FontImage
2330
2330
  {
2331
2331
  /** Create an image font
2332
- * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
2333
- * @param {Vector2} [tileSize=Vector2(8)] - Size of the font source tiles
2334
- * @param {Vector2} [paddingSize=Vector2(0,1)] - How much extra space to add between characters
2332
+ * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
2333
+ * @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
2334
+ * @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
2335
2335
  * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
2336
2336
  */
2337
2337
  constructor(image, tileSize=vec2(8), paddingSize=vec2(0,1), context=overlayContext)
@@ -2609,10 +2609,10 @@ function inputUpdatePost()
2609
2609
  ///////////////////////////////////////////////////////////////////////////////
2610
2610
  // Mouse event handlers
2611
2611
 
2612
- onmousedown = (e)=> {isUsingGamepad = false; inputData[0][e.button] = 3; window.onmousemove(e); e.button && e.preventDefault();}
2612
+ onmousedown = (e)=> {isUsingGamepad = false; inputData[0][e.button] = 3; mousePosScreen = mouseToScreen(e); e.button && e.preventDefault();}
2613
2613
  onmouseup = (e)=> inputData[0][e.button] = inputData[0][e.button] & 2 | 4;
2614
2614
  onmousemove = (e)=> mousePosScreen = mouseToScreen(e);
2615
- onwheel = (e)=> e.ctrlKey || (mouseWheel = sign(e.deltaY));
2615
+ onwheel = (e)=> mouseWheel = e.ctrlKey ? 0 : sign(e.deltaY);
2616
2616
  oncontextmenu = (e)=> false; // prevent right click menu
2617
2617
 
2618
2618
  // convert a mouse or touch event position to screen space
@@ -2706,7 +2706,7 @@ function gamepadsUpdate()
2706
2706
  ///////////////////////////////////////////////////////////////////////////////
2707
2707
 
2708
2708
  /** Pulse the vibration hardware if it exists
2709
- * @param {Number} [pattern] - a single value in miliseconds or vibration interval array
2709
+ * @param {Number|Array} [pattern] - single value in ms or vibration interval array
2710
2710
  * @memberof Input */
2711
2711
  function vibrate(pattern=100)
2712
2712
  { vibrateEnable && navigator && navigator.vibrate && navigator.vibrate(pattern); }
@@ -3513,7 +3513,7 @@ function getTileCollisionData(pos)
3513
3513
 
3514
3514
  /** Check if collision with another object should occur
3515
3515
  * @param {Vector2} pos
3516
- * @param {Vector2} [size=Vector2(1,1)]
3516
+ * @param {Vector2} [size=(1,1)]
3517
3517
  * @param {EngineObject} [object]
3518
3518
  * @return {Boolean}
3519
3519
  * @memberof TileCollision */
@@ -3629,11 +3629,11 @@ class TileLayerData
3629
3629
  class TileLayer extends EngineObject
3630
3630
  {
3631
3631
  /** Create a tile layer object
3632
- * @param {Vector2} [position=Vector2()] - World space position
3632
+ * @param {Vector2} [position=(0,0)] - World space position
3633
3633
  * @param {Vector2} [size=tileCollisionSize] - World space size
3634
- * @param {TileInfo} [tileInfo] - Tile info for layer
3635
- * @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
3636
- * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
3634
+ * @param {TileInfo} [tileInfo] - Tile info for layer
3635
+ * @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
3636
+ * @param {Number} [renderOrder] - Objects are sorted by renderOrder
3637
3637
  */
3638
3638
  constructor(position, size=tileCollisionSize, tileInfo=tile(), scale=vec2(1), renderOrder=0)
3639
3639
  {
@@ -3694,16 +3694,18 @@ class TileLayer extends EngineObject
3694
3694
  }
3695
3695
 
3696
3696
  /** Draw all the tile data to an offscreen canvas
3697
- * - This may be slow in some browsers
3698
- */
3697
+ * - This may be slow in some browsers but only needs to be done once */
3699
3698
  redraw()
3700
3699
  {
3701
3700
  this.redrawStart(true);
3702
- this.drawAllTileData();
3701
+ for (let x = this.size.x; x--;)
3702
+ for (let y = this.size.y; y--;)
3703
+ this.drawTileData(vec2(x,y), false);
3703
3704
  this.redrawEnd();
3704
3705
  }
3705
3706
 
3706
3707
  /** Call to start the redraw process
3708
+ * - This can be used to manually update small parts of the level
3707
3709
  * @param {Boolean} [clear] - Should it clear the canvas before drawing */
3708
3710
  redrawStart(clear=false)
3709
3711
  {
@@ -3711,17 +3713,19 @@ class TileLayer extends EngineObject
3711
3713
  /** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
3712
3714
  this.savedRenderSettings = [mainCanvas, mainContext, mainCanvasSize, cameraPos, cameraScale];
3713
3715
 
3714
- // hack: use normal rendering system to render the tiles
3716
+ // use webgl rendering system to render the tiles if enabled
3717
+ // this works by temporally taking control of the rendering system
3715
3718
  mainCanvas = this.canvas;
3716
3719
  mainContext = this.context;
3720
+ mainCanvasSize = this.size.multiply(this.tileInfo.size);
3717
3721
  cameraPos = this.size.scale(.5);
3718
3722
  cameraScale = this.tileInfo.size.x;
3719
3723
 
3720
3724
  if (clear)
3721
3725
  {
3722
3726
  // clear and set size
3723
- mainCanvas.width = this.size.x * this.tileInfo.size.x;
3724
- mainCanvas.height = this.size.y * this.tileInfo.size.y;
3727
+ mainCanvas.width = mainCanvasSize.x;
3728
+ mainCanvas.height = mainCanvasSize.y;
3725
3729
  }
3726
3730
 
3727
3731
  // begin a new render for the tile canvas
@@ -3739,32 +3743,33 @@ class TileLayer extends EngineObject
3739
3743
  [mainCanvas, mainContext, mainCanvasSize, cameraPos, cameraScale] = this.savedRenderSettings;
3740
3744
  }
3741
3745
 
3742
- /** Draw the tile at a given position
3743
- * @param {Vector2} layerPos */
3744
- drawTileData(layerPos)
3746
+ /** Draw the tile at a given position in the tile grid
3747
+ * This can be used to clear out tiles when they are destroyed
3748
+ * Tiles can also be redrawn if isinde a redrawStart/End block
3749
+ * @param {Vector2} layerPos
3750
+ * @param {Boolean} [clear] - should the old tile be cleared out
3751
+ */
3752
+ drawTileData(layerPos, clear=true)
3745
3753
  {
3746
- // first clear out where the tile was
3747
- const pos = layerPos.floor().add(this.pos).add(vec2(.5));
3748
- this.drawCanvas2D(pos, vec2(1), 0, false, (context)=>context.clearRect(-.5, -.5, 1, 1));
3754
+ // clear out where the tile was, for full opaque tiles this can be skipped
3755
+ const s = this.tileInfo.size;
3756
+ if (clear)
3757
+ {
3758
+ const pos = layerPos.multiply(s);
3759
+ this.context.clearRect(pos.x, this.canvas.height-pos.y, s.x, -s.y);
3760
+ }
3749
3761
 
3750
3762
  // draw the tile if not undefined
3751
3763
  const d = this.getData(layerPos);
3752
3764
  if (d.tile != undefined)
3753
3765
  {
3766
+ const pos = this.pos.add(layerPos).add(vec2(.5));
3754
3767
  ASSERT(mainContext == this.context, 'must call redrawStart() before drawing tiles');
3755
- const tileInfo = tile(d.tile, this.tileInfo.size, this.tileInfo.textureIndex);
3768
+ const tileInfo = tile(d.tile, s, this.tileInfo.textureIndex);
3756
3769
  drawTile(pos, vec2(1), tileInfo, d.color, d.direction*PI/2, d.mirror);
3757
3770
  }
3758
3771
  }
3759
3772
 
3760
- /** Draw all the tiles in this layer */
3761
- drawAllTileData()
3762
- {
3763
- for (let x = this.size.x; x--;)
3764
- for (let y = this.size.y; y--;)
3765
- this.drawTileData(vec2(x,y));
3766
- }
3767
-
3768
3773
  /** Draw directly to the 2D canvas in world space (bipass webgl)
3769
3774
  * @param {Vector2} pos
3770
3775
  * @param {Vector2} size
@@ -3784,11 +3789,11 @@ class TileLayer extends EngineObject
3784
3789
  context.restore();
3785
3790
  }
3786
3791
 
3787
- /** Draw a tile directly onto the layer canvas
3792
+ /** Draw a tile directly onto the layer canvas in world space
3788
3793
  * @param {Vector2} pos
3789
- * @param {Vector2} [size=Vector2(1,1)]
3794
+ * @param {Vector2} [size=(1,1)]
3790
3795
  * @param {TileInfo} [tileInfo]
3791
- * @param {Color} [color=Color()]
3796
+ * @param {Color} [color=(1,1,1,1)]
3792
3797
  * @param {Number} [angle=0]
3793
3798
  * @param {Boolean} [mirror=0] */
3794
3799
  drawTile(pos, size=vec2(1), tileInfo, color=new Color, angle, mirror)
@@ -3813,10 +3818,10 @@ class TileLayer extends EngineObject
3813
3818
  });
3814
3819
  }
3815
3820
 
3816
- /** Draw a rectangle directly onto the layer canvas
3821
+ /** Draw a rectangle directly onto the layer canvas in world space
3817
3822
  * @param {Vector2} pos
3818
- * @param {Vector2} [size=Vector2(1,1)]
3819
- * @param {Color} [color=Color()]
3823
+ * @param {Vector2} [size=(1,1)]
3824
+ * @param {Color} [color=(1,1,1,1)]
3820
3825
  * @param {Number} [angle=0] */
3821
3826
  drawRect(pos, size, color, angle)
3822
3827
  { this.drawTile(pos, size, undefined, color, angle); }
@@ -3854,10 +3859,10 @@ class ParticleEmitter extends EngineObject
3854
3859
  * @param {Number} [emitRate] - How many particles per second to spawn, does not emit if 0
3855
3860
  * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
3856
3861
  * @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
3857
- * @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
3858
- * @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
3859
- * @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
3860
- * @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
3862
+ * @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
3863
+ * @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
3864
+ * @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
3865
+ * @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
3861
3866
  * @param {Number} [particleTime] - How long particles live
3862
3867
  * @param {Number} [sizeStart] - How big are particles at start
3863
3868
  * @param {Number} [sizeEnd] - How big are particles at end
@@ -4695,6 +4700,8 @@ function glCopyToContext(context, forceDraw=false)
4695
4700
  * @memberof WebGL */
4696
4701
  function glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdditive=0)
4697
4702
  {
4703
+ ASSERT(typeof rgba == 'number' && typeof rgbaAdditive == 'number', 'invalid color');
4704
+
4698
4705
  // flush if there is not enough room or if different blend mode
4699
4706
  if (glInstanceCount >= gl_MAX_INSTANCES-1 || glBatchAdditive != glAdditive)
4700
4707
  glFlush();
@@ -4723,7 +4730,7 @@ let glPostShader, glPostArrayBuffer, glPostTexture, glPostIncludeOverlay;
4723
4730
  * @param {String} shaderCode
4724
4731
  * @param {Boolean} includeOverlay
4725
4732
  * @memberof WebGL */
4726
- function glInitPostProcess(shaderCode, includeOverlay)
4733
+ function glInitPostProcess(shaderCode, includeOverlay=false)
4727
4734
  {
4728
4735
  ASSERT(!glPostShader, 'can only have 1 post effects shader');
4729
4736
 
@@ -4759,6 +4766,8 @@ function glInitPostProcess(shaderCode, includeOverlay)
4759
4766
 
4760
4767
  // hide the original 2d canvas
4761
4768
  mainCanvas.style.visibility = 'hidden';
4769
+ if (glPostIncludeOverlay)
4770
+ overlayCanvas.style.visibility = 'hidden';
4762
4771
  }
4763
4772
 
4764
4773
  // Render the post processing shader, called automatically by the engine
@@ -4779,14 +4788,8 @@ function glRenderPostProcess()
4779
4788
  glContext.viewport(0, 0, glCanvas.width = mainCanvas.width, glCanvas.height = mainCanvas.height);
4780
4789
  }
4781
4790
 
4782
- if (glPostIncludeOverlay)
4783
- {
4784
- // copy overlay canvas so it will be included in post processing
4785
- mainContext.drawImage(overlayCanvas, 0, 0);
4786
-
4787
- // clear overlay canvas
4788
- overlayCanvas.width = mainCanvas.width;
4789
- }
4791
+ // copy overlay canvas so it will be included in post processing
4792
+ glPostIncludeOverlay && mainContext.drawImage(overlayCanvas, 0, 0);
4790
4793
 
4791
4794
  // setup shader program to draw one triangle
4792
4795
  glContext.useProgram(glPostShader);
@@ -4880,7 +4883,7 @@ const engineName = 'LittleJS';
4880
4883
  * @type {String}
4881
4884
  * @default
4882
4885
  * @memberof Engine */
4883
- const engineVersion = '1.9.0';
4886
+ const engineVersion = '1.9.1';
4884
4887
 
4885
4888
  /** Frames per second to update objects
4886
4889
  * @type {Number}