melonjs 10.2.3 → 10.5.0

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 (96) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +3620 -3582
  3. package/dist/melonjs.min.js +5 -5
  4. package/dist/melonjs.module.d.ts +3646 -4545
  5. package/dist/melonjs.module.js +3912 -3521
  6. package/package.json +21 -20
  7. package/src/audio/audio.js +30 -31
  8. package/src/camera/camera2d.js +47 -58
  9. package/src/entity/entity.js +32 -38
  10. package/src/game.js +21 -22
  11. package/src/{shapes → geometries}/ellipse.js +40 -47
  12. package/src/{shapes → geometries}/line.js +9 -12
  13. package/src/{shapes → geometries}/poly.js +100 -53
  14. package/src/{shapes → geometries}/rectangle.js +42 -45
  15. package/src/index.js +14 -32
  16. package/src/input/gamepad.js +11 -10
  17. package/src/input/input.js +2 -3
  18. package/src/input/keyboard.js +113 -113
  19. package/src/input/pointer.js +61 -29
  20. package/src/input/pointerevent.js +92 -29
  21. package/src/lang/deprecated.js +83 -13
  22. package/src/level/level.js +23 -24
  23. package/src/level/tiled/TMXGroup.js +7 -9
  24. package/src/level/tiled/TMXLayer.js +30 -33
  25. package/src/level/tiled/TMXObject.js +59 -53
  26. package/src/level/tiled/TMXTile.js +18 -19
  27. package/src/level/tiled/TMXTileMap.js +40 -46
  28. package/src/level/tiled/TMXTileset.js +12 -16
  29. package/src/level/tiled/TMXTilesetGroup.js +9 -10
  30. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
  31. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
  32. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
  33. package/src/level/tiled/renderer/TMXRenderer.js +24 -26
  34. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
  35. package/src/loader/loader.js +17 -16
  36. package/src/loader/loadingscreen.js +2 -5
  37. package/src/math/color.js +47 -67
  38. package/src/math/math.js +15 -16
  39. package/src/math/matrix2.js +53 -59
  40. package/src/math/matrix3.js +56 -63
  41. package/src/math/observable_vector2.js +87 -77
  42. package/src/math/observable_vector3.js +97 -80
  43. package/src/math/vector2.js +107 -97
  44. package/src/math/vector3.js +116 -100
  45. package/src/particles/emitter.js +66 -76
  46. package/src/particles/particle.js +4 -6
  47. package/src/particles/particlecontainer.js +2 -4
  48. package/src/physics/body.js +49 -147
  49. package/src/physics/bounds.js +48 -50
  50. package/src/physics/collision.js +13 -14
  51. package/src/physics/detector.js +18 -17
  52. package/src/physics/quadtree.js +17 -20
  53. package/src/physics/sat.js +30 -30
  54. package/src/physics/world.js +24 -29
  55. package/src/plugin/plugin.js +11 -15
  56. package/src/renderable/GUI.js +41 -47
  57. package/src/renderable/collectable.js +5 -10
  58. package/src/renderable/colorlayer.js +10 -15
  59. package/src/renderable/container.js +87 -73
  60. package/src/renderable/dragndrop.js +224 -0
  61. package/src/renderable/imagelayer.js +25 -32
  62. package/src/renderable/nineslicesprite.js +41 -42
  63. package/src/renderable/renderable.js +113 -124
  64. package/src/renderable/sprite.js +62 -69
  65. package/src/renderable/trigger.js +26 -32
  66. package/src/state/stage.js +13 -18
  67. package/src/state/state.js +26 -27
  68. package/src/system/device.js +76 -133
  69. package/src/system/event.js +81 -70
  70. package/src/system/pooling.js +11 -12
  71. package/src/system/save.js +3 -4
  72. package/src/system/timer.js +19 -20
  73. package/src/text/bitmaptext.js +57 -55
  74. package/src/text/bitmaptextdata.js +10 -11
  75. package/src/text/glyph.js +3 -0
  76. package/src/text/text.js +49 -55
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +1 -1
  79. package/src/tweens/tween.js +44 -46
  80. package/src/utils/agent.js +3 -4
  81. package/src/utils/array.js +4 -5
  82. package/src/utils/file.js +3 -4
  83. package/src/utils/function.js +4 -5
  84. package/src/utils/string.js +7 -9
  85. package/src/utils/utils.js +4 -5
  86. package/src/video/canvas/canvas_renderer.js +60 -62
  87. package/src/video/renderer.js +53 -58
  88. package/src/video/texture.js +98 -112
  89. package/src/video/texture_cache.js +26 -10
  90. package/src/video/video.js +15 -16
  91. package/src/video/webgl/buffer/vertex.js +2 -2
  92. package/src/video/webgl/glshader.js +37 -39
  93. package/src/video/webgl/webgl_compositor.js +128 -101
  94. package/src/video/webgl/webgl_renderer.js +126 -106
  95. package/src/entity/draggable.js +0 -139
  96. package/src/entity/droptarget.js +0 -109
@@ -28,43 +28,41 @@ export function createAtlas(width, height, name = "default", repeat = "no-repeat
28
28
 
29
29
  /**
30
30
  * @classdesc
31
- * A Texture atlas object, currently supports : <br>
31
+ * A Texture atlas class, currently supports : <br>
32
32
  * - [TexturePacker]{@link http://www.codeandweb.com/texturepacker/} : through JSON export (standard and multipack texture atlas) <br>
33
33
  * - [ShoeBox]{@link http://renderhjs.net/shoebox/} : through JSON export using the
34
34
  * melonJS setting [file]{@link https://github.com/melonjs/melonJS/raw/master/media/shoebox_JSON_export.sbx} <br>
35
35
  * - [Free Texture Packer]{@link http://free-tex-packer.com/app/} : through JSON export (standard and multipack texture atlas) <br>
36
36
  * - Standard (fixed cell size) spritesheet : through a {framewidth:xx, frameheight:xx, anchorPoint:me.Vector2d} object
37
- * @class Texture
38
- * @memberOf me.Renderer
39
- * @constructor
40
- * @param {object|object[]} atlases atlas information. See {@link me.loader.getJSON}
41
- * @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] Image source
42
- * @param {boolean} [cache=false] Use true to skip caching this Texture
43
- * @example
44
- * // create a texture atlas from a JSON Object
45
- * game.texture = new me.video.renderer.Texture(
46
- * me.loader.getJSON("texture")
47
- * );
48
- *
49
- * // create a texture atlas from a multipack JSON Object
50
- * game.texture = new me.video.renderer.Texture([
51
- * me.loader.getJSON("texture-0"),
52
- * me.loader.getJSON("texture-1"),
53
- * me.loader.getJSON("texture-2")
54
- * ]);
55
- *
56
- * // create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
57
- * game.texture = new me.video.renderer.Texture(
58
- * {
59
- * framewidth : 32,
60
- * frameheight : 32,
61
- * anchorPoint : new me.Vector2d(0.5, 0.5)
62
- * },
63
- * me.loader.getImage("spritesheet")
64
37
  * );
65
38
  */
66
- export class Texture {
67
-
39
+ export class TextureAtlas {
40
+ /**
41
+ * @param {object|object[]} atlases atlas information. See {@link loader.getJSON}
42
+ * @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] Image source
43
+ * @param {boolean} [cache=false] Use true to skip caching this Texture
44
+ * @example
45
+ * // create a texture atlas from a JSON Object
46
+ * game.texture = new me.TextureAtlas(
47
+ * me.loader.getJSON("texture")
48
+ * );
49
+ *
50
+ * // create a texture atlas from a multipack JSON Object
51
+ * game.texture = new me.TextureAtlas([
52
+ * me.loader.getJSON("texture-0"),
53
+ * me.loader.getJSON("texture-1"),
54
+ * me.loader.getJSON("texture-2")
55
+ * ]);
56
+ *
57
+ * // create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
58
+ * game.texture = new me.TextureAtlas(
59
+ * {
60
+ * framewidth : 32,
61
+ * frameheight : 32,
62
+ * anchorPoint : new me.Vector2d(0.5, 0.5)
63
+ * },
64
+ * me.loader.getImage("spritesheet")
65
+ */
68
66
  constructor (atlases, src, cache) {
69
67
  /**
70
68
  * to identify the atlas format (e.g. texture packer)
@@ -201,7 +199,7 @@ export class Texture {
201
199
  height : s.h,
202
200
  angle : (frame.rotated === true) ? -ETA : 0
203
201
  };
204
- this.addUvsMap(atlas, frame.filename, data.meta.size.w, data.meta.size.h);
202
+ this.addUVs(atlas, frame.filename, data.meta.size.w, data.meta.size.h);
205
203
  }
206
204
  });
207
205
  return atlas;
@@ -261,7 +259,7 @@ export class Texture {
261
259
  height : data.frameheight,
262
260
  angle : 0
263
261
  };
264
- this.addUvsMap(atlas, name, width, height);
262
+ this.addUVs(atlas, name, width, height);
265
263
  }
266
264
 
267
265
  pool.push(spritecount);
@@ -269,63 +267,8 @@ export class Texture {
269
267
  return atlas;
270
268
  }
271
269
 
272
- /**
273
- * @ignore
274
- */
275
- addUvsMap(atlas, frame, w, h) {
276
- // ignore if using the Canvas Renderer
277
- if (renderer instanceof WebGLRenderer) {
278
- // Source coordinates
279
- var s = atlas[frame].offset;
280
- var sw = atlas[frame].width;
281
- var sh = atlas[frame].height;
282
-
283
- atlas[frame].uvs = new Float32Array([
284
- s.x / w, // u0 (left)
285
- s.y / h, // v0 (top)
286
- (s.x + sw) / w, // u1 (right)
287
- (s.y + sh) / h // v1 (bottom)
288
- ]);
289
- // Cache source coordinates
290
- // TODO: Remove this when the Batcher only accepts a region name
291
- var key = s.x + "," + s.y + "," + w + "," + h;
292
- atlas[key] = atlas[frame];
293
- }
294
- return atlas[frame];
295
- }
296
-
297
- /**
298
- * @ignore
299
- */
300
- addQuadRegion(name, x, y, w, h) {
301
- // TODO: Require proper atlas regions instead of caching arbitrary region keys
302
- if (renderer.settings.verbose === true) {
303
- console.warn("Adding texture region", name, "for texture", this);
304
- }
305
-
306
- var source = this.getTexture();
307
- var atlas = this.getAtlas();
308
- var dw = source.width;
309
- var dh = source.height;
310
-
311
- atlas[name] = {
312
- name : name,
313
- offset : new Vector2d(x, y),
314
- width : w,
315
- height : h,
316
- angle : 0
317
- };
318
-
319
- this.addUvsMap(atlas, name, dw, dh);
320
-
321
- return atlas[name];
322
- }
323
-
324
270
  /**
325
271
  * return the default or specified atlas dictionnary
326
- * @name getAtlas
327
- * @memberOf me.Renderer.Texture
328
- * @function
329
272
  * @param {string} [name] atlas name in case of multipack textures
330
273
  * @returns {object}
331
274
  */
@@ -339,9 +282,6 @@ export class Texture {
339
282
 
340
283
  /**
341
284
  * return the format of the atlas dictionnary
342
- * @name getFormat
343
- * @memberOf me.Renderer.Texture
344
- * @function
345
285
  * @returns {string} will return "texturepacker", or "ShoeBox", or "melonJS", or "Spritesheet (fixed cell size)"
346
286
  */
347
287
  getFormat() {
@@ -350,9 +290,6 @@ export class Texture {
350
290
 
351
291
  /**
352
292
  * return the source texture for the given region (or default one if none specified)
353
- * @name getTexture
354
- * @memberOf me.Renderer.Texture
355
- * @function
356
293
  * @param {object} [region] region name in case of multipack textures
357
294
  * @returns {HTMLImageElement|HTMLCanvasElement}
358
295
  */
@@ -364,11 +301,41 @@ export class Texture {
364
301
  }
365
302
  }
366
303
 
304
+ /**
305
+ * add a region to the atlas
306
+ * @param {string} name region mame
307
+ * @param {number} x x origin of the region
308
+ * @param {number} y y origin of the region
309
+ * @param {number} w width of the region
310
+ * @param {number} h height of the region
311
+ * @returns {object} the created region
312
+ */
313
+ addRegion(name, x, y, w, h) {
314
+ // TODO: Require proper atlas regions instead of caching arbitrary region keys
315
+ if (renderer.settings.verbose === true) {
316
+ console.warn("Adding texture region", name, "for texture", this);
317
+ }
318
+
319
+ var source = this.getTexture();
320
+ var atlas = this.getAtlas();
321
+ var dw = source.width;
322
+ var dh = source.height;
323
+
324
+ atlas[name] = {
325
+ name : name,
326
+ offset : new Vector2d(x, y),
327
+ width : w,
328
+ height : h,
329
+ angle : 0
330
+ };
331
+
332
+ this.addUVs(atlas, name, dw, dh);
333
+
334
+ return atlas[name];
335
+ }
336
+
367
337
  /**
368
338
  * return a normalized region (or frame) information for the specified sprite name
369
- * @name getRegion
370
- * @memberOf me.Renderer.Texture
371
- * @function
372
339
  * @param {string} name name of the sprite
373
340
  * @param {string} [atlas] name of a specific atlas where to search for the region
374
341
  * @returns {object}
@@ -391,9 +358,6 @@ export class Texture {
391
358
 
392
359
  /**
393
360
  * return the uvs mapping for the given region
394
- * @name getUVs
395
- * @memberOf me.Renderer.Texture
396
- * @function
397
361
  * @param {object} name region (or frame) name
398
362
  * @returns {Float32Array} region Uvs
399
363
  */
@@ -408,23 +372,48 @@ export class Texture {
408
372
  sy = +keys[1],
409
373
  sw = +keys[2],
410
374
  sh = +keys[3];
411
- region = this.addQuadRegion(name, sx, sy, sw, sh);
375
+ region = this.addRegion(name, sx, sy, sw, sh);
412
376
  }
413
377
  return region.uvs;
414
378
  }
415
379
 
380
+ /**
381
+ * add uvs mapping for the given region
382
+ * @param {object} atlas the atlas dictionnary where the region is define
383
+ * @param {object} name region (or frame) name
384
+ * @returns {Float32Array} the created region UVs
385
+ */
386
+ addUVs(atlas, name, w, h) {
387
+ // ignore if using the Canvas Renderer
388
+ if (renderer instanceof WebGLRenderer) {
389
+ // Source coordinates
390
+ var s = atlas[name].offset;
391
+ var sw = atlas[name].width;
392
+ var sh = atlas[name].height;
393
+
394
+ atlas[name].uvs = new Float32Array([
395
+ s.x / w, // u0 (left)
396
+ s.y / h, // v0 (top)
397
+ (s.x + sw) / w, // u1 (right)
398
+ (s.y + sh) / h // v1 (bottom)
399
+ ]);
400
+ // Cache source coordinates
401
+ // TODO: Remove this when the Batcher only accepts a region name
402
+ var key = s.x + "," + s.y + "," + w + "," + h;
403
+ atlas[key] = atlas[name];
404
+ }
405
+ return atlas[name].uvs;
406
+ }
407
+
416
408
  /**
417
409
  * Create a sprite object using the first region found using the specified name
418
- * @name createSpriteFromName
419
- * @memberOf me.Renderer.Texture
420
- * @function
421
410
  * @param {string} name name of the sprite
422
- * @param {object} [settings] Additional settings passed to the {@link me.Sprite} contructor
411
+ * @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
423
412
  * @param {boolean} [nineSlice=false] if true returns a 9-slice sprite
424
- * @returns {me.Sprite|me.NineSliceSprite}
413
+ * @returns {Sprite|NineSliceSprite}
425
414
  * @example
426
415
  * // create a new texture object under the `game` namespace
427
- * game.texture = new me.video.renderer.Texture(
416
+ * game.texture = new me.TextureAtlas(
428
417
  * me.loader.getJSON("texture"),
429
418
  * me.loader.getImage("texture")
430
419
  * );
@@ -458,16 +447,13 @@ export class Texture {
458
447
 
459
448
  /**
460
449
  * Create an animation object using the first region found using all specified names
461
- * @name createAnimationFromName
462
- * @memberOf me.Renderer.Texture
463
- * @function
464
450
  * @param {string[]|number[]} names list of names for each sprite
465
451
  * (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
466
- * @param {object} [settings] Additional settings passed to the {@link me.Sprite} contructor
467
- * @returns {me.Sprite}
452
+ * @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
453
+ * @returns {Sprite}
468
454
  * @example
469
455
  * // create a new texture object under the `game` namespace
470
- * game.texture = new me.video.renderer.Texture(
456
+ * game.texture = new me.TextureAtlas(
471
457
  * me.loader.getJSON("texture"),
472
458
  * me.loader.getImage("texture")
473
459
  * );
@@ -1,7 +1,8 @@
1
1
  import { renderer } from "./video.js";
2
2
  import * as fileUtil from "./../utils/file.js";
3
- import { Texture, createAtlas } from "./texture.js";
3
+ import { TextureAtlas, createAtlas } from "./texture.js";
4
4
  import { isPowerOfTwo} from "./../math/math.js";
5
+ import {ArrayMultimap} from "@teppeis/multimaps";
5
6
 
6
7
 
7
8
  /**
@@ -14,7 +15,8 @@ class TextureCache {
14
15
  * @ignore
15
16
  */
16
17
  constructor(max_size) {
17
- this.cache = new Map();
18
+ // cache uses an array to allow for duplicated key
19
+ this.cache = new ArrayMultimap();
18
20
  this.tinted = new Map();
19
21
  this.units = new Map();
20
22
  this.max_size = max_size || Infinity;
@@ -48,23 +50,37 @@ class TextureCache {
48
50
  * @ignore
49
51
  */
50
52
  get(image, atlas) {
51
- if (!this.cache.has(image)) {
53
+ var entry;
54
+
55
+ if (typeof atlas === "undefined") {
56
+ entry = this.cache.get(image)[0];
57
+ } else {
58
+ // manage cases where a specific atlas is specified
59
+ this.cache.forEach((value, key) => {
60
+ var _atlas = value.getAtlas();
61
+ if (key === image && _atlas[0].width === atlas.framewidth && _atlas[0].height === atlas.frameheight) {
62
+ entry = value;
63
+ }
64
+ });
65
+ }
66
+
67
+ if (typeof entry === "undefined") {
52
68
  if (!atlas) {
53
69
  atlas = createAtlas(image.width, image.height, image.src ? fileUtil.getBasename(image.src) : undefined);
54
70
  }
55
- this.set(image, new Texture(atlas, image, false));
71
+ entry = new TextureAtlas(atlas, image, false);
72
+ this.set(image, entry);
56
73
  }
57
- return this.cache.get(image);
74
+
75
+ return entry;
58
76
  }
59
77
 
60
78
  /**
61
79
  * @ignore
62
80
  */
63
- remove(image) {
81
+ delete(image) {
64
82
  if (!this.cache.has(image)) {
65
- if (this.cache.remove(image) === true) {
66
- this.length--;
67
- }
83
+ this.cache.delete(image);
68
84
  }
69
85
  }
70
86
 
@@ -101,7 +117,7 @@ class TextureCache {
101
117
  "(" + width + "x" + height + ")"
102
118
  );
103
119
  }
104
- this.cache.set(image, texture);
120
+ return this.cache.put(image, texture);
105
121
  }
106
122
 
107
123
  /**
@@ -9,8 +9,7 @@ import { initialized, version } from "./../index.js";
9
9
 
10
10
  /**
11
11
  * video functions
12
- * @namespace me.video
13
- * @memberOf me
12
+ * @namespace video
14
13
  */
15
14
 
16
15
  var designRatio = 1;
@@ -126,7 +125,7 @@ function onresize() {
126
125
  /**
127
126
  * Select the HTML5 Canvas renderer
128
127
  * @name CANVAS
129
- * @memberOf me.video
128
+ * @memberof video
130
129
  * @constant
131
130
  */
132
131
  export const CANVAS = 0;
@@ -134,7 +133,7 @@ export const CANVAS = 0;
134
133
  /**
135
134
  * Select the WebGL renderer
136
135
  * @name WEBGL
137
- * @memberOf me.video
136
+ * @memberof video
138
137
  * @constant
139
138
  */
140
139
  export const WEBGL = 1;
@@ -142,7 +141,7 @@ export const WEBGL = 1;
142
141
  /**
143
142
  * Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
144
143
  * @name AUTO
145
- * @memberOf me.video
144
+ * @memberof video
146
145
  * @constant
147
146
  */
148
147
  export const AUTO = 2;
@@ -153,24 +152,24 @@ export const AUTO = 2;
153
152
  * @type {HTMLElement}
154
153
  * @readonly
155
154
  * @name parent
156
- * @memberOf me.video
155
+ * @memberof video
157
156
  */
158
157
  export let parent = null;
159
158
 
160
159
  /**
161
160
  * the scaling ratio to be applied to the display canvas
162
161
  * @name scaleRatio
163
- * @type {me.Vector2d}
162
+ * @type {Vector2d}
164
163
  * @default <1,1>
165
- * @memberOf me.video
164
+ * @memberof video
166
165
  */
167
166
  export let scaleRatio = new Vector2d(1, 1);
168
167
 
169
168
  /**
170
169
  * A reference to the active Canvas or WebGL active renderer renderer
171
170
  * @name renderer
172
- * @type {me.CanvasRenderer|me.WebGLRenderer}
173
- * @memberOf me.video
171
+ * @type {CanvasRenderer|WebGLRenderer}
172
+ * @memberof video
174
173
  */
175
174
  export let renderer = null;
176
175
 
@@ -191,12 +190,12 @@ export let renderer = null;
191
190
  * <center><img src="images/scale-flex-height.png"/></center><br>
192
191
  * - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
193
192
  * <center><img src="images/scale-stretch.png"/></center><br>
194
- * @function me.video.init
193
+ * @function video.init
195
194
  * @param {number} width The width of the canvas viewport
196
195
  * @param {number} height The height of the canvas viewport
197
196
  * @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
198
197
  * @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
199
- * @param {number} [options.renderer=me.video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
198
+ * @param {number} [options.renderer=video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
200
199
  * @param {boolean} [options.doubleBuffering=false] enable/disable double buffering
201
200
  * @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
202
201
  * @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
@@ -380,7 +379,7 @@ export function init(width, height, options) {
380
379
 
381
380
  /**
382
381
  * Create and return a new Canvas element
383
- * @function me.video.createCanvas
382
+ * @function video.createCanvas
384
383
  * @param {number} width width
385
384
  * @param {number} height height
386
385
  * @param {boolean} [offscreen=false] will returns an OffscreenCanvas if supported
@@ -412,7 +411,7 @@ export function createCanvas(width, height, offscreen = false) {
412
411
 
413
412
  /**
414
413
  * return a reference to the parent DOM element holding the main canvas
415
- * @function me.video.getParent
414
+ * @function video.getParent
416
415
  * @returns {HTMLElement}
417
416
  */
418
417
  export function getParent() {
@@ -423,8 +422,8 @@ export function getParent() {
423
422
  * scale the "displayed" canvas by the given scalar.
424
423
  * this will modify the size of canvas element directly.
425
424
  * Only use this if you are not using the automatic scaling feature.
426
- * @function me.video.scale
427
- * @see me.video.init
425
+ * @function video.scale
426
+ * @see video.init
428
427
  * @param {number} x x scaling multiplier
429
428
  * @param {number} y y scaling multiplier
430
429
  */
@@ -8,7 +8,7 @@
8
8
  class VertexArrayBuffer {
9
9
 
10
10
  constructor(vertex_size, vertex_per_quad) {
11
- // the size of one vertex
11
+ // the size of one vertex in float
12
12
  this.vertexSize = vertex_size;
13
13
  // size of a quad in vertex
14
14
  this.quadSize = vertex_per_quad;
@@ -40,7 +40,7 @@ class VertexArrayBuffer {
40
40
  * return true if full
41
41
  * @ignore
42
42
  */
43
- isFull(vertex = 0) {
43
+ isFull(vertex = this.quadSize) {
44
44
  return (this.vertexCount + vertex >= this.maxVertex);
45
45
  }
46
46
 
@@ -197,37 +197,35 @@ function minify(src) {
197
197
  /**
198
198
  * @classdesc
199
199
  * a base GL Shader object
200
- * @class GLShader
201
- * @memberOf me
202
- * @param {WebGLRenderingContext} gl the current WebGL rendering context
203
- * @param {string} vertex a string containing the GLSL source code to set
204
- * @param {string} fragment a string containing the GLSL source code to set
205
- * @param {string} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
206
- * @constructor
207
- * @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
208
- * @example
209
- * // create a basic shader
210
- * var myShader = new me.GLShader(
211
- * // WebGL rendering context
212
- * gl,
213
- * // vertex shader
214
- * [
215
- * "void main() {",
216
- * " gl_Position = doMathToMakeClipspaceCoordinates;",
217
- * "}"
218
- * ].join("\n"),
219
- * // fragment shader
220
- * [
221
- * "void main() {",
222
- * " gl_FragColor = doMathToMakeAColor;",
223
- * "}"
224
- * ].join("\n")
225
- * )
226
- * // use the shader
227
- * myShader.bind();
228
200
  */
229
201
  class GLShader {
230
-
202
+ /**
203
+ * @param {WebGLRenderingContext} gl the current WebGL rendering context
204
+ * @param {string} vertex a string containing the GLSL source code to set
205
+ * @param {string} fragment a string containing the GLSL source code to set
206
+ * @param {string} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
207
+ * @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
208
+ * @example
209
+ * // create a basic shader
210
+ * var myShader = new me.GLShader(
211
+ * // WebGL rendering context
212
+ * gl,
213
+ * // vertex shader
214
+ * [
215
+ * "void main() {",
216
+ * " gl_Position = doMathToMakeClipspaceCoordinates;",
217
+ * "}"
218
+ * ].join("\n"),
219
+ * // fragment shader
220
+ * [
221
+ * "void main() {",
222
+ * " gl_FragColor = doMathToMakeAColor;",
223
+ * "}"
224
+ * ].join("\n")
225
+ * )
226
+ * // use the shader
227
+ * myShader.bind();
228
+ */
231
229
  constructor(gl, vertex, fragment, precision) {
232
230
 
233
231
  /**
@@ -235,7 +233,7 @@ class GLShader {
235
233
  * @public
236
234
  * @type {WebGLRenderingContext}
237
235
  * @name gl
238
- * @memberOf me.GLShader
236
+ * @memberof GLShader
239
237
  */
240
238
  this.gl = gl;
241
239
 
@@ -244,7 +242,7 @@ class GLShader {
244
242
  * @public
245
243
  * @type {string}
246
244
  * @name vertex
247
- * @memberOf me.GLShader
245
+ * @memberof GLShader
248
246
  */
249
247
  this.vertex = setPrecision(minify(vertex), precision || device.getMaxShaderPrecision(this.gl));
250
248
 
@@ -253,7 +251,7 @@ class GLShader {
253
251
  * @public
254
252
  * @type {string}
255
253
  * @name vertex
256
- * @memberOf me.GLShader
254
+ * @memberof GLShader
257
255
  */
258
256
  this.fragment = setPrecision(minify(fragment), precision || device.getMaxShaderPrecision(this.gl));
259
257
 
@@ -262,7 +260,7 @@ class GLShader {
262
260
  * @public
263
261
  * @type {GLint[]}
264
262
  * @name attributes
265
- * @memberOf me.GLShader
263
+ * @memberof GLShader
266
264
  */
267
265
  this.attributes = extractAttributes(this.gl, this);
268
266
 
@@ -272,7 +270,7 @@ class GLShader {
272
270
  * @public
273
271
  * @type {WebGLProgram}
274
272
  * @name program
275
- * @memberOf me.GLShader
273
+ * @memberof GLShader
276
274
  */
277
275
  this.program = compileProgram(this.gl, this.vertex, this.fragment, this.attributes);
278
276
 
@@ -281,7 +279,7 @@ class GLShader {
281
279
  * @public
282
280
  * @type {object}
283
281
  * @name uniforms
284
- * @memberOf me.GLShader
282
+ * @memberof GLShader
285
283
  */
286
284
  this.uniforms = extractUniforms(this.gl, this);
287
285
 
@@ -294,7 +292,7 @@ class GLShader {
294
292
  /**
295
293
  * Installs this shader program as part of current rendering state
296
294
  * @name bind
297
- * @memberOf me.GLShader
295
+ * @memberof GLShader
298
296
  * @function
299
297
  */
300
298
  bind() {
@@ -304,7 +302,7 @@ class GLShader {
304
302
  /**
305
303
  * returns the location of an attribute variable in this shader program
306
304
  * @name getAttribLocation
307
- * @memberOf me.GLShader
305
+ * @memberof GLShader
308
306
  * @function
309
307
  * @param {string} name the name of the attribute variable whose location to get.
310
308
  * @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
@@ -321,7 +319,7 @@ class GLShader {
321
319
  /**
322
320
  * Set the uniform to the given value
323
321
  * @name setUniform
324
- * @memberOf me.GLShader
322
+ * @memberof GLShader
325
323
  * @function
326
324
  * @param {string} name the uniform name
327
325
  * @param {object|Float32Array} value the value to assign to that uniform
@@ -344,7 +342,7 @@ class GLShader {
344
342
  /**
345
343
  * destroy this shader objects resources (program, attributes, uniforms)
346
344
  * @name destroy
347
- * @memberOf me.GLShader
345
+ * @memberof GLShader
348
346
  * @function
349
347
  */
350
348
  destroy() {