melonjs 10.3.0 → 10.4.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.
- package/README.md +6 -6
- package/dist/melonjs.js +2419 -3072
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +3417 -3816
- package/dist/melonjs.module.js +2737 -3002
- package/package.json +16 -16
- package/src/audio/audio.js +29 -30
- package/src/camera/camera2d.js +46 -56
- package/src/entity/draggable.js +12 -13
- package/src/entity/droptarget.js +13 -15
- package/src/entity/entity.js +30 -36
- package/src/game.js +21 -22
- package/src/geometries/ellipse.js +40 -46
- package/src/geometries/line.js +9 -11
- package/src/geometries/poly.js +53 -53
- package/src/geometries/rectangle.js +42 -44
- package/src/index.js +4 -14
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +30 -31
- package/src/input/pointerevent.js +26 -26
- package/src/lang/deprecated.js +25 -6
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -8
- package/src/level/tiled/TMXLayer.js +30 -32
- package/src/level/tiled/TMXObject.js +21 -21
- package/src/level/tiled/TMXTile.js +18 -18
- package/src/level/tiled/TMXTileMap.js +37 -44
- package/src/level/tiled/TMXTileset.js +12 -15
- package/src/level/tiled/TMXTilesetGroup.js +9 -9
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
- package/src/level/tiled/renderer/TMXRenderer.js +24 -25
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
- package/src/loader/loader.js +14 -15
- package/src/loader/loadingscreen.js +2 -4
- package/src/math/color.js +47 -66
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -58
- package/src/math/matrix3.js +56 -62
- package/src/math/observable_vector2.js +75 -76
- package/src/math/observable_vector3.js +79 -80
- package/src/math/vector2.js +91 -92
- package/src/math/vector3.js +94 -96
- package/src/particles/emitter.js +38 -40
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +44 -142
- package/src/physics/bounds.js +47 -47
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +17 -19
- package/src/physics/sat.js +26 -26
- package/src/physics/world.js +24 -28
- package/src/plugin/plugin.js +11 -14
- package/src/renderable/GUI.js +41 -46
- package/src/renderable/collectable.js +4 -8
- package/src/renderable/colorlayer.js +6 -10
- package/src/renderable/container.js +87 -72
- package/src/renderable/imagelayer.js +25 -31
- package/src/renderable/nineslicesprite.js +41 -41
- package/src/renderable/renderable.js +112 -122
- package/src/renderable/sprite.js +62 -68
- package/src/renderable/trigger.js +25 -30
- package/src/state/stage.js +13 -17
- package/src/state/state.js +26 -27
- package/src/system/device.js +74 -75
- package/src/system/event.js +71 -72
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -54
- package/src/text/bitmaptextdata.js +10 -10
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +44 -49
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +43 -44
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +58 -59
- package/src/video/renderer.js +49 -53
- package/src/video/texture.js +98 -111
- package/src/video/texture_cache.js +2 -2
- package/src/video/video.js +15 -16
- package/src/video/webgl/glshader.js +37 -38
- package/src/video/webgl/webgl_compositor.js +31 -32
- package/src/video/webgl/webgl_renderer.js +79 -80
|
@@ -21,12 +21,11 @@ var V_ARRAY = [
|
|
|
21
21
|
* @classdesc
|
|
22
22
|
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
23
23
|
* Pushes texture regions or shape geometry into WebGL buffers, automatically flushes to GPU
|
|
24
|
-
* @class WebGLCompositor
|
|
25
|
-
* @memberof me
|
|
26
|
-
* @param {me.WebGLRenderer} renderer the current WebGL renderer session
|
|
27
24
|
*/
|
|
28
25
|
class WebGLCompositor {
|
|
29
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @param {WebGLRenderer} renderer the current WebGL renderer session
|
|
28
|
+
*/
|
|
30
29
|
constructor (renderer) {
|
|
31
30
|
this.init(renderer);
|
|
32
31
|
}
|
|
@@ -58,16 +57,16 @@ class WebGLCompositor {
|
|
|
58
57
|
/**
|
|
59
58
|
* a reference to the active WebGL shader
|
|
60
59
|
* @name activeShader
|
|
61
|
-
* @memberof
|
|
62
|
-
* @type {
|
|
60
|
+
* @memberof WebGLCompositor
|
|
61
|
+
* @type {GLShader}
|
|
63
62
|
*/
|
|
64
63
|
this.activeShader = null;
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
66
|
* primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
68
67
|
* @name mode
|
|
69
|
-
* @see
|
|
70
|
-
* @memberof
|
|
68
|
+
* @see WebGLCompositor
|
|
69
|
+
* @memberof WebGLCompositor
|
|
71
70
|
* @default gl.TRIANGLES
|
|
72
71
|
*/
|
|
73
72
|
this.mode = gl.TRIANGLES;
|
|
@@ -75,8 +74,8 @@ class WebGLCompositor {
|
|
|
75
74
|
/**
|
|
76
75
|
* an array of vertex attribute properties
|
|
77
76
|
* @name attributes
|
|
78
|
-
* @see
|
|
79
|
-
* @memberof
|
|
77
|
+
* @see WebGLCompositor.addAttribute
|
|
78
|
+
* @memberof WebGLCompositor
|
|
80
79
|
*/
|
|
81
80
|
this.attributes = [];
|
|
82
81
|
|
|
@@ -84,8 +83,8 @@ class WebGLCompositor {
|
|
|
84
83
|
* the size of a single vertex in bytes
|
|
85
84
|
* (will automatically be calculated as attributes definitions are added)
|
|
86
85
|
* @name vertexByteSize
|
|
87
|
-
* @see
|
|
88
|
-
* @memberof
|
|
86
|
+
* @see WebGLCompositor.addAttribute
|
|
87
|
+
* @memberof WebGLCompositor
|
|
89
88
|
*/
|
|
90
89
|
this.vertexByteSize = 0;
|
|
91
90
|
|
|
@@ -93,8 +92,8 @@ class WebGLCompositor {
|
|
|
93
92
|
* the size of a single vertex in floats
|
|
94
93
|
* (will automatically be calculated as attributes definitions are added)
|
|
95
94
|
* @name vertexSize
|
|
96
|
-
* @see
|
|
97
|
-
* @memberof
|
|
95
|
+
* @see WebGLCompositor.addAttribute
|
|
96
|
+
* @memberof WebGLCompositor
|
|
98
97
|
*/
|
|
99
98
|
this.vertexSize = 0;
|
|
100
99
|
|
|
@@ -156,7 +155,7 @@ class WebGLCompositor {
|
|
|
156
155
|
/**
|
|
157
156
|
* add vertex attribute property definition to the compositor
|
|
158
157
|
* @name addAttribute
|
|
159
|
-
* @memberof
|
|
158
|
+
* @memberof WebGLCompositor
|
|
160
159
|
* @function
|
|
161
160
|
* @param {string} name name of the attribute in the vertex shader
|
|
162
161
|
* @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
@@ -204,7 +203,7 @@ class WebGLCompositor {
|
|
|
204
203
|
/**
|
|
205
204
|
* Sets the viewport
|
|
206
205
|
* @name setViewport
|
|
207
|
-
* @memberof
|
|
206
|
+
* @memberof WebGLCompositor
|
|
208
207
|
* @function
|
|
209
208
|
* @param {number} x x position of viewport
|
|
210
209
|
* @param {number} y y position of viewport
|
|
@@ -218,12 +217,12 @@ class WebGLCompositor {
|
|
|
218
217
|
/**
|
|
219
218
|
* Create a WebGL texture from an image
|
|
220
219
|
* @name createTexture2D
|
|
221
|
-
* @memberof
|
|
220
|
+
* @memberof WebGLCompositor
|
|
222
221
|
* @function
|
|
223
222
|
* @param {number} unit Destination texture unit
|
|
224
223
|
* @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
|
|
225
224
|
* @param {number} filter gl.LINEAR or gl.NEAREST
|
|
226
|
-
* @param {string} [repeat="no-repeat"] Image repeat behavior (see {@link
|
|
225
|
+
* @param {string} [repeat="no-repeat"] Image repeat behavior (see {@link ImageLayer#repeat})
|
|
227
226
|
* @param {number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
|
|
228
227
|
* @param {number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
|
|
229
228
|
* @param {number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
|
|
@@ -263,7 +262,7 @@ class WebGLCompositor {
|
|
|
263
262
|
/**
|
|
264
263
|
* delete the given WebGL texture
|
|
265
264
|
* @name bindTexture2D
|
|
266
|
-
* @memberof
|
|
265
|
+
* @memberof WebGLCompositor
|
|
267
266
|
* @function
|
|
268
267
|
* @param {WebGLTexture} [texture] a WebGL texture to delete
|
|
269
268
|
* @param {number} [unit] Texture unit to delete
|
|
@@ -276,7 +275,7 @@ class WebGLCompositor {
|
|
|
276
275
|
/**
|
|
277
276
|
* returns the WebGL texture associated to the given texture unit
|
|
278
277
|
* @name bindTexture2D
|
|
279
|
-
* @memberof
|
|
278
|
+
* @memberof WebGLCompositor
|
|
280
279
|
* @function
|
|
281
280
|
* @param {number} unit Texture unit to which a texture is bound
|
|
282
281
|
* @returns {WebGLTexture} texture a WebGL texture
|
|
@@ -288,7 +287,7 @@ class WebGLCompositor {
|
|
|
288
287
|
/**
|
|
289
288
|
* assign the given WebGL texture to the current batch
|
|
290
289
|
* @name bindTexture2D
|
|
291
|
-
* @memberof
|
|
290
|
+
* @memberof WebGLCompositor
|
|
292
291
|
* @function
|
|
293
292
|
* @param {WebGLTexture} texture a WebGL texture
|
|
294
293
|
* @param {number} unit Texture unit to which the given texture is bound
|
|
@@ -316,7 +315,7 @@ class WebGLCompositor {
|
|
|
316
315
|
/**
|
|
317
316
|
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
318
317
|
* @name unbindTexture2D
|
|
319
|
-
* @memberof
|
|
318
|
+
* @memberof WebGLCompositor
|
|
320
319
|
* @function
|
|
321
320
|
* @param {WebGLTexture} [texture] a WebGL texture
|
|
322
321
|
* @param {number} [unit] a WebGL texture
|
|
@@ -363,10 +362,10 @@ class WebGLCompositor {
|
|
|
363
362
|
/**
|
|
364
363
|
* Select the shader to use for compositing
|
|
365
364
|
* @name useShader
|
|
366
|
-
* @see
|
|
367
|
-
* @memberof
|
|
365
|
+
* @see GLShader
|
|
366
|
+
* @memberof WebGLCompositor
|
|
368
367
|
* @function
|
|
369
|
-
* @param {
|
|
368
|
+
* @param {GLShader} shader a reference to a GLShader instance
|
|
370
369
|
*/
|
|
371
370
|
useShader(shader) {
|
|
372
371
|
if (this.activeShader !== shader) {
|
|
@@ -394,9 +393,9 @@ class WebGLCompositor {
|
|
|
394
393
|
/**
|
|
395
394
|
* Add a textured quad
|
|
396
395
|
* @name addQuad
|
|
397
|
-
* @memberof
|
|
396
|
+
* @memberof WebGLCompositor
|
|
398
397
|
* @function
|
|
399
|
-
* @param {
|
|
398
|
+
* @param {TextureAtlas} texture Source texture atlas
|
|
400
399
|
* @param {number} x Destination x-coordinate
|
|
401
400
|
* @param {number} y Destination y-coordinate
|
|
402
401
|
* @param {number} w Destination width
|
|
@@ -451,7 +450,7 @@ class WebGLCompositor {
|
|
|
451
450
|
/**
|
|
452
451
|
* Flush batched texture operations to the GPU
|
|
453
452
|
* @param {number} [mode=gl.TRIANGLES] the GL drawing mode
|
|
454
|
-
* @memberof
|
|
453
|
+
* @memberof WebGLCompositor
|
|
455
454
|
* @function
|
|
456
455
|
*/
|
|
457
456
|
flush(mode = this.mode) {
|
|
@@ -479,10 +478,10 @@ class WebGLCompositor {
|
|
|
479
478
|
/**
|
|
480
479
|
* Draw an array of vertices
|
|
481
480
|
* @name drawVertices
|
|
482
|
-
* @memberof
|
|
481
|
+
* @memberof WebGLCompositor
|
|
483
482
|
* @function
|
|
484
483
|
* @param {GLenum} mode primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
485
|
-
* @param {
|
|
484
|
+
* @param {Vector2d[]} verts vertices
|
|
486
485
|
* @param {number} [vertexCount=verts.length] amount of points defined in the points array
|
|
487
486
|
*/
|
|
488
487
|
drawVertices(mode, verts, vertexCount = verts.length) {
|
|
@@ -509,7 +508,7 @@ class WebGLCompositor {
|
|
|
509
508
|
/**
|
|
510
509
|
* Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
|
|
511
510
|
* @name clearColor
|
|
512
|
-
* @memberof
|
|
511
|
+
* @memberof WebGLCompositor
|
|
513
512
|
* @function
|
|
514
513
|
* @param {number} [r=0] - the red color value used when the color buffers are cleared
|
|
515
514
|
* @param {number} [g=0] - the green color value used when the color buffers are cleared
|
|
@@ -523,7 +522,7 @@ class WebGLCompositor {
|
|
|
523
522
|
/**
|
|
524
523
|
* Clear the frame buffer
|
|
525
524
|
* @name clear
|
|
526
|
-
* @memberof
|
|
525
|
+
* @memberof WebGLCompositor
|
|
527
526
|
* @function
|
|
528
527
|
*/
|
|
529
528
|
clear() {
|