littlejsengine 1.8.9 → 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.
Files changed (48) hide show
  1. package/README.md +17 -17
  2. package/build/littlejs.d.ts +352 -288
  3. package/build/littlejs.esm.js +695 -658
  4. package/build/littlejs.esm.min.js +1 -1
  5. package/build/littlejs.js +694 -658
  6. package/build/littlejs.min.js +1 -1
  7. package/build/littlejs.release.js +629 -594
  8. package/examples/breakout/game.js +4 -4
  9. package/examples/breakout/index.html +3 -3
  10. package/examples/breakoutTutorial/index.html +2 -2
  11. package/examples/electron/game.js +1 -1
  12. package/examples/electron/index.html +2 -2
  13. package/examples/favicon.png +0 -0
  14. package/examples/js13k/build.js +1 -1
  15. package/examples/js13k/index.html +13 -13
  16. package/examples/module/game.js +1 -1
  17. package/examples/module/index.html +1 -1
  18. package/examples/particles/index.html +1 -1
  19. package/examples/platformer/game.js +6 -6
  20. package/examples/platformer/gameCharacter.js +293 -0
  21. package/examples/platformer/gameEffects.js +8 -5
  22. package/examples/platformer/gameObjects.js +13 -13
  23. package/examples/platformer/gamePlayer.js +9 -293
  24. package/examples/platformer/index.html +7 -6
  25. package/examples/puzzle/game.js +3 -2
  26. package/examples/puzzle/index.html +2 -2
  27. package/examples/starter/build.js +1 -1
  28. package/examples/starter/game.js +2 -2
  29. package/examples/starter/index.html +13 -13
  30. package/examples/stress/index.html +35 -27
  31. package/examples/typescript/index.html +1 -1
  32. package/index.d.ts +2094 -0
  33. package/package.json +1 -1
  34. package/src/engine.js +28 -28
  35. package/src/engineAudio.js +57 -57
  36. package/src/engineDebug.js +66 -65
  37. package/src/engineDraw.js +64 -73
  38. package/src/engineExport.js +1 -0
  39. package/src/engineInput.js +57 -40
  40. package/src/engineMedals.js +32 -29
  41. package/src/engineObject.js +42 -27
  42. package/src/engineParticles.js +98 -72
  43. package/src/engineRelease.js +1 -1
  44. package/src/engineSettings.js +22 -22
  45. package/src/engineTileLayer.js +66 -60
  46. package/src/engineUtilities.js +49 -49
  47. package/src/engineWebGL.js +112 -135
  48. package/src/jsconfig.json +10 -0
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * LittleJS WebGL Interface
3
3
  * - All webgl used by the engine is wrapped up here
4
4
  * - For normal stuff you won't need to see or call anything in this file
@@ -17,13 +17,13 @@
17
17
  * @memberof WebGL */
18
18
  let glCanvas;
19
19
 
20
- /** 2d context for glCanvas
21
- * @type {WebGLRenderingContext}
20
+ /** 2d context for glCanvas
21
+ * @type {WebGL2RenderingContext}
22
22
  * @memberof WebGL */
23
23
  let glContext;
24
24
 
25
25
  // WebGL internal variables not exposed to documentation
26
- let glActiveTexture, glShader, glArrayBuffer, glVertexData, glPositionData, glColorData, glBatchCount, glBatchAdditive, glAdditive;
26
+ let glShader, glActiveTexture, glArrayBuffer, glGeometryBuffer, glPositionData, glColorData, glInstanceCount, glAdditive, glBatchAdditive;
27
27
 
28
28
  ///////////////////////////////////////////////////////////////////////////////
29
29
 
@@ -39,73 +39,89 @@ function glInit()
39
39
 
40
40
  // setup vertex and fragment shaders
41
41
  glShader = glCreateProgram(
42
- '#version 300 es\n' + // specify GLSL ES version
43
- 'precision highp float;'+ // use highp for better accuracy
44
- 'uniform mat4 m;'+ // transform matrix
45
- 'in vec4 p,c,a;'+ // position, uv, color, additiveColor
46
- 'out vec4 v,d,e;'+ // return uv, color, additiveColor
47
- 'void main(){'+ // shader entry point
48
- 'gl_Position=m*vec4(p.xy,1,1);'+ // transform position
49
- 'v=p;d=c;e=a;'+ // pass stuff to fragment shader
50
- '}' // end of shader
42
+ '#version 300 es\n' + // specify GLSL ES version
43
+ 'precision highp float;'+ // use highp for better accuracy
44
+ 'uniform mat4 m;'+ // transform matrix
45
+ 'in vec2 g;'+ // geometry
46
+ 'in vec4 p,u,c,a;'+ // position/size, uvs, color, additiveColor
47
+ 'in float r;'+ // rotation
48
+ 'out vec2 v;'+ // return uv, color, additiveColor
49
+ 'out vec4 d,e;'+ // return uv, color, additiveColor
50
+ 'void main(){'+ // shader entry point
51
+ 'vec2 s=(g-.5)*p.zw;'+ // get size offset
52
+ 'gl_Position=m*vec4(p.xy+s*cos(r)-vec2(-s.y,s)*sin(r),1,1);'+ // transform position
53
+ 'v=mix(u.xw,u.zy,g);'+ // pass uv to fragment shader
54
+ 'd=c;e=a;'+ // pass colors to fragment shader
55
+ '}' // end of shader
51
56
  ,
52
- '#version 300 es\n' + // specify GLSL ES version
53
- 'precision highp float;'+ // use highp for better accuracy
54
- 'in vec4 v,d,e;'+ // position, uv, color, additiveColor
55
- 'uniform sampler2D s;'+ // texture
56
- 'out vec4 c;'+ // out color
57
- 'void main(){'+ // shader entry point
58
- 'c=texture(s,v.zw)*d+e;'+ // modulate texture by color plus additive
59
- '}' // end of shader
57
+ '#version 300 es\n' + // specify GLSL ES version
58
+ 'precision highp float;'+ // use highp for better accuracy
59
+ 'in vec2 v;'+ // uv
60
+ 'in vec4 d,e;'+ // color, additiveColor
61
+ 'uniform sampler2D s;'+ // texture
62
+ 'out vec4 c;'+ // out color
63
+ 'void main(){'+ // shader entry point
64
+ 'c=texture(s,v)*d+e;'+ // modulate texture by color plus additive
65
+ '}' // end of shader
60
66
  );
61
67
 
62
68
  // init buffers
63
- glVertexData = new ArrayBuffer(gl_VERTEX_BUFFER_SIZE);
64
- glPositionData = new Float32Array(glVertexData);
65
- glColorData = new Uint32Array(glVertexData);
69
+ const glInstanceData = new ArrayBuffer(gl_INSTANCE_BUFFER_SIZE);
70
+ glPositionData = new Float32Array(glInstanceData);
71
+ glColorData = new Uint32Array(glInstanceData);
66
72
  glArrayBuffer = glContext.createBuffer();
67
- glBatchCount = 0;
73
+ glGeometryBuffer = glContext.createBuffer();
74
+
75
+ // create the geometry buffer, triangle strip square
76
+ const geometry = new Float32Array([glInstanceCount=0,0,1,0,0,1,1,1]);
77
+ glContext.bindBuffer(gl_ARRAY_BUFFER, glGeometryBuffer);
78
+ glContext.bufferData(gl_ARRAY_BUFFER, geometry, gl_STATIC_DRAW);
68
79
  }
69
80
 
70
81
  // Setup render each frame, called automatically by engine
71
82
  function glPreRender()
72
83
  {
73
84
  // clear and set to same size as main canvas
74
- glContext.viewport(0, 0, glCanvas.width = mainCanvas.width, glCanvas.height = mainCanvas.height);
85
+ glContext.viewport(0, 0, glCanvas.width=mainCanvas.width, glCanvas.height=mainCanvas.height);
75
86
  glContext.clear(gl_COLOR_BUFFER_BIT);
76
87
 
77
88
  // set up the shader
78
89
  glContext.useProgram(glShader);
79
90
  glContext.activeTexture(gl_TEXTURE0);
80
91
  glContext.bindTexture(gl_TEXTURE_2D, glActiveTexture = textureInfos[0].glTexture);
81
- glContext.bindBuffer(gl_ARRAY_BUFFER, glArrayBuffer);
82
- glContext.bufferData(gl_ARRAY_BUFFER, gl_VERTEX_BUFFER_SIZE, gl_DYNAMIC_DRAW);
83
- glAdditive = 0;
84
-
92
+
85
93
  // set vertex attributes
86
- let offset = 0;
87
- const initVertexAttribArray = (name, type, typeSize, size, normalize=0)=>
94
+ let offset = glAdditive = glBatchAdditive = 0;
95
+ let initVertexAttribArray = (name, type, typeSize, size)=>
88
96
  {
89
97
  const location = glContext.getAttribLocation(glShader, name);
98
+ const stride = typeSize && gl_INSTANCE_BYTE_STRIDE; // only if not geometry
99
+ const divisor = typeSize && 1; // only if not geometry
100
+ const normalize = typeSize==1; // only if color
90
101
  glContext.enableVertexAttribArray(location);
91
- glContext.vertexAttribPointer(location, size, type, normalize, gl_VERTEX_BYTE_STRIDE, offset);
102
+ glContext.vertexAttribPointer(location, size, type, normalize, stride, offset);
103
+ glContext.vertexAttribDivisor(location, divisor);
92
104
  offset += size*typeSize;
93
105
  }
94
- initVertexAttribArray('p', gl_FLOAT, 4, 4); // position & texture
95
- initVertexAttribArray('c', gl_UNSIGNED_BYTE, 1, 4, 1); // color
96
- initVertexAttribArray('a', gl_UNSIGNED_BYTE, 1, 4, 1); // additiveColor
106
+ glContext.bindBuffer(gl_ARRAY_BUFFER, glGeometryBuffer);
107
+ initVertexAttribArray('g', gl_FLOAT, 0, 2); // geometry
108
+ glContext.bindBuffer(gl_ARRAY_BUFFER, glArrayBuffer);
109
+ glContext.bufferData(gl_ARRAY_BUFFER, gl_INSTANCE_BUFFER_SIZE, gl_DYNAMIC_DRAW);
110
+ initVertexAttribArray('p', gl_FLOAT, 4, 4); // position & size
111
+ initVertexAttribArray('u', gl_FLOAT, 4, 4); // texture coords
112
+ initVertexAttribArray('c', gl_UNSIGNED_BYTE, 1, 4); // color
113
+ initVertexAttribArray('a', gl_UNSIGNED_BYTE, 1, 4); // additiveColor
114
+ initVertexAttribArray('r', gl_FLOAT, 4, 1); // rotation
97
115
 
98
116
  // build the transform matrix
99
- const sx = 2 * cameraScale / mainCanvas.width;
100
- const sy = 2 * cameraScale / mainCanvas.height;
101
- const cx = -1 - sx*cameraPos.x;
102
- const cy = -1 - sy*cameraPos.y;
103
- glContext.uniformMatrix4fv(glContext.getUniformLocation(glShader, 'm'), 0,
117
+ const s = vec2(2*cameraScale).divide(mainCanvasSize);
118
+ const p = vec2(-1).subtract(cameraPos.multiply(s));
119
+ glContext.uniformMatrix4fv(glContext.getUniformLocation(glShader, 'm'), false,
104
120
  new Float32Array([
105
- sx, 0, 0, 0,
106
- 0, sy, 0, 0,
107
- 1, 1, -1, 1,
108
- cx, cy, 0, 0
121
+ s.x, 0, 0, 0,
122
+ 0, s.y, 0, 0,
123
+ 1, 1, 1, 1,
124
+ p.x, p.y, 0, 0
109
125
  ])
110
126
  );
111
127
  }
@@ -126,7 +142,7 @@ function glSetTexture(texture)
126
142
 
127
143
  /** Compile WebGL shader of the given type, will throw errors if in debug mode
128
144
  * @param {String} source
129
- * @param type
145
+ * @param {Number} type
130
146
  * @return {WebGLShader}
131
147
  * @memberof WebGL */
132
148
  function glCompileShader(source, type)
@@ -143,8 +159,8 @@ function glCompileShader(source, type)
143
159
  }
144
160
 
145
161
  /** Create WebGL program with given shaders
146
- * @param {WebGLShader} vsSource
147
- * @param {WebGLShader} fsSource
162
+ * @param {String} vsSource
163
+ * @param {String} fsSource
148
164
  * @return {WebGLProgram}
149
165
  * @memberof WebGL */
150
166
  function glCreateProgram(vsSource, fsSource)
@@ -162,7 +178,7 @@ function glCreateProgram(vsSource, fsSource)
162
178
  }
163
179
 
164
180
  /** Create WebGL texture from an image and init the texture settings
165
- * @param {Image} image
181
+ * @param {HTMLImageElement} image
166
182
  * @return {WebGLTexture}
167
183
  * @memberof WebGL */
168
184
  function glCreateTexture(image)
@@ -172,7 +188,7 @@ function glCreateTexture(image)
172
188
  glContext.bindTexture(gl_TEXTURE_2D, texture);
173
189
  if (image)
174
190
  glContext.texImage2D(gl_TEXTURE_2D, 0, gl_RGBA, gl_RGBA, gl_UNSIGNED_BYTE, image);
175
-
191
+
176
192
  // use point filtering for pixelated rendering
177
193
  const filter = canvasPixelated ? gl_NEAREST : gl_LINEAR;
178
194
  glContext.texParameteri(gl_TEXTURE_2D, gl_TEXTURE_MIN_FILTER, filter);
@@ -187,29 +203,31 @@ function glCreateTexture(image)
187
203
  * @memberof WebGL */
188
204
  function glFlush()
189
205
  {
190
- if (!glBatchCount) return;
206
+ if (!glInstanceCount) return;
191
207
 
192
208
  const destBlend = glBatchAdditive ? gl_ONE : gl_ONE_MINUS_SRC_ALPHA;
193
209
  glContext.blendFuncSeparate(gl_SRC_ALPHA, destBlend, gl_ONE, destBlend);
194
210
  glContext.enable(gl_BLEND);
195
211
 
196
212
  // draw all the sprites in the batch and reset the buffer
197
- glContext.bufferSubData(gl_ARRAY_BUFFER, 0, glVertexData);
198
- glContext.drawArrays(gl_TRIANGLE_STRIP, 0, glBatchCount);
199
- glBatchCount = 0;
213
+ glContext.bufferSubData(gl_ARRAY_BUFFER, 0, glPositionData);
214
+ glContext.drawArraysInstanced(gl_TRIANGLE_STRIP, 0, 4, glInstanceCount);
215
+ if (showWatermark)
216
+ drawCount += glInstanceCount;
217
+ glInstanceCount = 0;
200
218
  glBatchAdditive = glAdditive;
201
219
  }
202
220
 
203
221
  /** Draw any sprites still in the buffer, copy to main canvas and clear
204
222
  * @param {CanvasRenderingContext2D} context
205
- * @param {Boolean} [forceDraw=0]
223
+ * @param {Boolean} [forceDraw]
206
224
  * @memberof WebGL */
207
- function glCopyToContext(context, forceDraw)
225
+ function glCopyToContext(context, forceDraw=false)
208
226
  {
209
- if (!glBatchCount && !forceDraw) return;
210
-
227
+ if (!glInstanceCount && !forceDraw) return;
228
+
211
229
  glFlush();
212
-
230
+
213
231
  // do not draw in overlay mode because the canvas is visible
214
232
  if (!glOverlay || forceDraw)
215
233
  context.drawImage(glCanvas, 0, 0);
@@ -230,61 +248,25 @@ function glCopyToContext(context, forceDraw)
230
248
  * @memberof WebGL */
231
249
  function glDraw(x, y, sizeX, sizeY, angle, uv0X, uv0Y, uv1X, uv1Y, rgba, rgbaAdditive=0)
232
250
  {
233
- // flush if there is not enough room or if different blend mode
234
- const vertCount = 6;
235
- if (glBatchCount >= gl_MAX_BATCH-vertCount || glBatchAdditive != glAdditive)
236
- glFlush();
237
-
238
- // prepare to create the verts from size and angle
239
- const c = Math.cos(angle)/2, s = Math.sin(angle)/2;
240
- const cx = c*sizeX, cy = c*sizeY, sx = s*sizeX, sy = s*sizeY;
241
- const positionData =
242
- [
243
- x-cx+sy, y+cy+sx, uv0X, uv0Y,
244
- x-cx-sy, y-cy+sx, uv0X, uv1Y,
245
- x+cx+sy, y+cy-sx, uv1X, uv0Y,
246
- x+cx-sy, y-cy-sx, uv1X, uv1Y,
247
- ];
248
-
249
- // setup 2 triangle strip quad
250
- for(let i = vertCount, offset = glBatchCount * gl_INDICIES_PER_VERT; i--;)
251
- {
252
- const j = clamp(i-1, 0, 3)*4; // degenerate tri at ends
253
- glPositionData[offset++] = positionData[j+0];
254
- glPositionData[offset++] = positionData[j+1];
255
- glPositionData[offset++] = positionData[j+2];
256
- glPositionData[offset++] = positionData[j+3];
257
- glColorData[offset++] = rgba;
258
- glColorData[offset++] = rgbaAdditive;
259
- }
260
- glBatchCount += vertCount;
261
- }
251
+ ASSERT(typeof rgba == 'number' && typeof rgbaAdditive == 'number', 'invalid color');
262
252
 
263
- /** Add a convex polygon to the gl draw list
264
- * @param {Array} points - Array of Vector2 points
265
- * @param {Number} rgba - Color of the polygon
266
- * @memberof WebGL */
267
- function glDrawPoints(points, rgba)
268
- {
269
253
  // flush if there is not enough room or if different blend mode
270
- const vertCount = points.length + 2;
271
- if (glBatchCount >= gl_MAX_BATCH-vertCount || glBatchAdditive != glAdditive)
254
+ if (glInstanceCount >= gl_MAX_INSTANCES-1 || glBatchAdditive != glAdditive)
272
255
  glFlush();
273
-
274
- // setup triangle strip from list of points
275
- for(let i = vertCount, offset = glBatchCount * gl_INDICIES_PER_VERT; i--;)
276
- {
277
- const j = clamp(i-1, 0, vertCount-3); // degenerate tri at ends
278
- const h = j>>1;
279
- const point = points[j%2? h : vertCount-3-h];
280
- glPositionData[offset++] = point.x;
281
- glPositionData[offset++] = point.y;
282
- glPositionData[offset++] = 0; // uvx
283
- glPositionData[offset++] = 0; // uvy
284
- glColorData[offset++] = 0; // nothing to tint
285
- glColorData[offset++] = rgba; // apply rgba via additive
286
- }
287
- glBatchCount += vertCount;
256
+
257
+ let offset = glInstanceCount * gl_INDICIES_PER_INSTANCE;
258
+ glPositionData[offset++] = x;
259
+ glPositionData[offset++] = y;
260
+ glPositionData[offset++] = sizeX;
261
+ glPositionData[offset++] = sizeY;
262
+ glPositionData[offset++] = uv0X;
263
+ glPositionData[offset++] = uv0Y;
264
+ glPositionData[offset++] = uv1X;
265
+ glPositionData[offset++] = uv1Y;
266
+ glColorData[offset++] = rgba;
267
+ glColorData[offset++] = rgbaAdditive;
268
+ glPositionData[offset++] = angle;
269
+ glInstanceCount++;
288
270
  }
289
271
 
290
272
  ///////////////////////////////////////////////////////////////////////////////
@@ -296,9 +278,9 @@ let glPostShader, glPostArrayBuffer, glPostTexture, glPostIncludeOverlay;
296
278
  * @param {String} shaderCode
297
279
  * @param {Boolean} includeOverlay
298
280
  * @memberof WebGL */
299
- function glInitPostProcess(shaderCode, includeOverlay)
281
+ function glInitPostProcess(shaderCode, includeOverlay=false)
300
282
  {
301
- ASSERT(!glPostShader); // can only have 1 post effects shader
283
+ ASSERT(!glPostShader, 'can only have 1 post effects shader');
302
284
 
303
285
  if (!shaderCode) // default shader pass through
304
286
  shaderCode = 'void mainImage(out vec4 c,vec2 p){c=texture(iChannel0,p/iResolution.xy);}';
@@ -309,14 +291,14 @@ function glInitPostProcess(shaderCode, includeOverlay)
309
291
  'precision highp float;'+ // use highp for better accuracy
310
292
  'in vec2 p;'+ // position
311
293
  'void main(){'+ // shader entry point
312
- 'gl_Position=vec4(p,1,1);'+ // set position
294
+ 'gl_Position=vec4(p+p-1.,1,1);'+ // set position
313
295
  '}' // end of shader
314
296
  ,
315
297
  '#version 300 es\n' + // specify GLSL ES version
316
298
  'precision highp float;'+ // use highp for better accuracy
317
299
  'uniform sampler2D iChannel0;'+ // input texture
318
300
  'uniform vec3 iResolution;'+ // size of output texture
319
- 'uniform float iTime;'+ // time passed
301
+ 'uniform float iTime;'+ // time
320
302
  'out vec4 c;'+ // out color
321
303
  '\n' + shaderCode + '\n'+ // insert custom shader code
322
304
  'void main(){'+ // shader entry point
@@ -327,11 +309,13 @@ function glInitPostProcess(shaderCode, includeOverlay)
327
309
 
328
310
  // create buffer and texture
329
311
  glPostArrayBuffer = glContext.createBuffer();
330
- glPostTexture = glCreateTexture();
312
+ glPostTexture = glCreateTexture(undefined);
331
313
  glPostIncludeOverlay = includeOverlay;
332
314
 
333
315
  // hide the original 2d canvas
334
316
  mainCanvas.style.visibility = 'hidden';
317
+ if (glPostIncludeOverlay)
318
+ overlayCanvas.style.visibility = 'hidden';
335
319
  }
336
320
 
337
321
  // Render the post processing shader, called automatically by the engine
@@ -352,21 +336,14 @@ function glRenderPostProcess()
352
336
  glContext.viewport(0, 0, glCanvas.width = mainCanvas.width, glCanvas.height = mainCanvas.height);
353
337
  }
354
338
 
355
- if (glPostIncludeOverlay)
356
- {
357
- // copy overlay canvas so it will be included in post processing
358
- mainContext.drawImage(overlayCanvas, 0, 0);
359
-
360
- // clear overlay canvas
361
- overlayCanvas.width = mainCanvas.width;
362
- }
339
+ // copy overlay canvas so it will be included in post processing
340
+ glPostIncludeOverlay && mainContext.drawImage(overlayCanvas, 0, 0);
363
341
 
364
342
  // setup shader program to draw one triangle
365
343
  glContext.useProgram(glPostShader);
344
+ glContext.bindBuffer(gl_ARRAY_BUFFER, glGeometryBuffer);
345
+ glContext.pixelStorei(gl_UNPACK_FLIP_Y_WEBGL, 1);
366
346
  glContext.disable(gl_BLEND);
367
- glContext.bindBuffer(gl_ARRAY_BUFFER, glPostArrayBuffer);
368
- glContext.bufferData(gl_ARRAY_BUFFER, new Float32Array([-3,1,1,-3,1,1]), gl_STATIC_DRAW);
369
- glContext.pixelStorei(gl_UNPACK_FLIP_Y_WEBGL, true);
370
347
 
371
348
  // set textures, pass in the 2d canvas and gl canvas in separate texture channels
372
349
  glContext.activeTexture(gl_TEXTURE0);
@@ -377,19 +354,19 @@ function glRenderPostProcess()
377
354
  const vertexByteStride = 8;
378
355
  const pLocation = glContext.getAttribLocation(glPostShader, 'p');
379
356
  glContext.enableVertexAttribArray(pLocation);
380
- glContext.vertexAttribPointer(pLocation, 2, gl_FLOAT, 0, vertexByteStride, 0);
357
+ glContext.vertexAttribPointer(pLocation, 2, gl_FLOAT, false, vertexByteStride, 0);
381
358
 
382
359
  // set uniforms and draw
383
360
  const uniformLocation = (name)=>glContext.getUniformLocation(glPostShader, name);
384
361
  glContext.uniform1i(uniformLocation('iChannel0'), 0);
385
362
  glContext.uniform1f(uniformLocation('iTime'), time);
386
363
  glContext.uniform3f(uniformLocation('iResolution'), mainCanvas.width, mainCanvas.height, 1);
387
- glContext.drawArrays(gl_TRIANGLE_STRIP, 0, 3);
364
+ glContext.drawArrays(gl_TRIANGLE_STRIP, 0, 4);
388
365
  }
389
366
 
390
367
  ///////////////////////////////////////////////////////////////////////////////
391
368
  // store gl constants as integers so their name doesn't use space in minifed
392
- const
369
+ const
393
370
  gl_ONE = 1,
394
371
  gl_TRIANGLE_STRIP = 5,
395
372
  gl_SRC_ALPHA = 770,
@@ -411,14 +388,14 @@ gl_TEXTURE0 = 33984,
411
388
  gl_ARRAY_BUFFER = 34962,
412
389
  gl_STATIC_DRAW = 35044,
413
390
  gl_DYNAMIC_DRAW = 35048,
414
- gl_FRAGMENT_SHADER = 35632,
391
+ gl_FRAGMENT_SHADER = 35632,
415
392
  gl_VERTEX_SHADER = 35633,
416
393
  gl_COMPILE_STATUS = 35713,
417
394
  gl_LINK_STATUS = 35714,
418
395
  gl_UNPACK_FLIP_Y_WEBGL = 37440,
419
396
 
420
397
  // constants for batch rendering
421
- gl_INDICIES_PER_VERT = 6,
422
- gl_MAX_BATCH = 1e5,
423
- gl_VERTEX_BYTE_STRIDE = (4 * 2) * 2 + (4) * 2, // vec2 * 2 + (char * 4) * 2
424
- gl_VERTEX_BUFFER_SIZE = gl_MAX_BATCH * gl_VERTEX_BYTE_STRIDE;
398
+ gl_INDICIES_PER_INSTANCE = 11,
399
+ gl_MAX_INSTANCES = 1e4,
400
+ gl_INSTANCE_BYTE_STRIDE = gl_INDICIES_PER_INSTANCE * 4, // 11 * 4
401
+ gl_INSTANCE_BUFFER_SIZE = gl_MAX_INSTANCES * gl_INSTANCE_BYTE_STRIDE;
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "checkJs": true,
4
+ "target": "ES6"
5
+ },
6
+ "exclude": [
7
+ "engineRelease.js",
8
+ "engineExport.js"
9
+ ]
10
+ }