melonjs 10.10.0 → 10.11.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 +4 -3
- package/dist/melonjs.js +817 -1922
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +339 -1183
- package/dist/melonjs.module.js +745 -1846
- package/package.json +12 -15
- package/src/audio/audio.js +0 -1
- package/src/camera/camera2d.js +1 -16
- package/src/entity/entity.js +1 -4
- package/src/geometries/ellipse.js +2 -11
- package/src/geometries/line.js +1 -4
- package/src/geometries/path2d.js +0 -10
- package/src/geometries/poly.js +5 -22
- package/src/geometries/rectangle.js +2 -14
- package/src/geometries/roundrect.js +2 -6
- package/src/index.js +0 -1
- package/src/input/gamepad.js +3 -14
- package/src/input/keyboard.js +1 -9
- package/src/input/pointer.js +0 -1
- package/src/input/pointerevent.js +14 -23
- package/src/lang/deprecated.js +4 -3
- package/src/level/level.js +0 -9
- package/src/level/tiled/TMXGroup.js +0 -4
- package/src/level/tiled/TMXLayer.js +0 -8
- package/src/level/tiled/TMXObject.js +0 -3
- package/src/level/tiled/TMXTile.js +4 -5
- package/src/level/tiled/TMXTileMap.js +1 -7
- package/src/level/tiled/TMXTileset.js +0 -5
- package/src/level/tiled/TMXTilesetGroup.js +1 -4
- package/src/level/tiled/TMXUtils.js +0 -3
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -7
- package/src/loader/loader.js +0 -11
- package/src/loader/loadingscreen.js +1 -1
- package/src/math/color.js +5 -26
- package/src/math/math.js +0 -10
- package/src/math/matrix2.js +12 -27
- package/src/math/matrix3.js +1 -22
- package/src/math/observable_vector2.js +0 -29
- package/src/math/observable_vector3.js +0 -29
- package/src/math/vector2.js +3 -40
- package/src/math/vector3.js +4 -41
- package/src/particles/emitter.js +1 -1
- package/src/physics/body.js +1 -1
- package/src/physics/bounds.js +5 -19
- package/src/physics/collision.js +0 -1
- package/src/physics/detector.js +0 -4
- package/src/physics/quadtree.js +0 -7
- package/src/physics/sat.js +3 -3
- package/src/physics/world.js +0 -4
- package/src/plugin/plugin.js +0 -2
- package/src/polyfill/roundrect.js +4 -2
- package/src/renderable/GUI.js +0 -5
- package/src/renderable/collectable.js +1 -0
- package/src/renderable/container.js +0 -28
- package/src/renderable/dragndrop.js +0 -9
- package/src/renderable/imagelayer.js +1 -5
- package/src/renderable/light2d.js +1 -2
- package/src/renderable/renderable.js +0 -22
- package/src/renderable/sprite.js +0 -12
- package/src/renderable/trigger.js +1 -1
- package/src/state/stage.js +0 -4
- package/src/state/state.js +3 -20
- package/src/system/device.js +14 -53
- package/src/system/event.js +11 -0
- package/src/system/pooling.js +19 -8
- package/src/system/save.js +9 -11
- package/src/system/timer.js +239 -218
- package/src/text/bitmaptextdata.js +1 -4
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +7 -5
- package/src/text/textmetrics.js +0 -2
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +2 -2
- package/src/tweens/tween.js +1 -13
- package/src/utils/agent.js +1 -3
- package/src/utils/array.js +0 -3
- package/src/utils/file.js +0 -2
- package/src/utils/function.js +0 -2
- package/src/utils/string.js +0 -6
- package/src/utils/utils.js +0 -3
- package/src/video/canvas/canvas_renderer.js +4 -39
- package/src/video/renderer.js +1 -23
- package/src/video/texture/cache.js +0 -1
- package/src/video/texture/canvas_texture.js +16 -4
- package/src/video/video.js +3 -3
- package/src/video/webgl/glshader.js +0 -5
- package/src/video/webgl/utils/uniforms.js +3 -6
- package/src/video/webgl/webgl_compositor.js +0 -14
- package/src/video/webgl/webgl_renderer.js +0 -42
|
@@ -16,7 +16,7 @@ import Renderable from "./../../renderable/renderable.js";
|
|
|
16
16
|
import Container from "./../../renderable/container.js";
|
|
17
17
|
|
|
18
18
|
// constant to identify the collision object layer
|
|
19
|
-
|
|
19
|
+
const COLLISION_GROUP = "collision";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* set a compatible renderer object
|
|
@@ -256,7 +256,6 @@ class TMXTileMap {
|
|
|
256
256
|
* @name getRenderer
|
|
257
257
|
* @memberof TMXTileMap
|
|
258
258
|
* @public
|
|
259
|
-
* @function
|
|
260
259
|
* @returns {TMXRenderer} a TMX renderer
|
|
261
260
|
*/
|
|
262
261
|
getRenderer() {
|
|
@@ -270,7 +269,6 @@ class TMXTileMap {
|
|
|
270
269
|
* return the map bounding rect
|
|
271
270
|
* @name TMXRenderer#getBounds
|
|
272
271
|
* @public
|
|
273
|
-
* @function
|
|
274
272
|
* @returns {Bounds}
|
|
275
273
|
*/
|
|
276
274
|
getBounds() {
|
|
@@ -353,7 +351,6 @@ class TMXTileMap {
|
|
|
353
351
|
* note : this will not automatically update the camera viewport
|
|
354
352
|
* @name TMXTileMap#addTo
|
|
355
353
|
* @public
|
|
356
|
-
* @function
|
|
357
354
|
* @param {Container} container target container
|
|
358
355
|
* @param {boolean} [flatten=true] if true, flatten all objects into the given container, else a `me.Container` object will be created for each corresponding groups
|
|
359
356
|
* @param {boolean} [setViewportBounds=false] if true, set the viewport bounds to the map size, this should be set to true especially if adding a level to the game world container.
|
|
@@ -430,7 +427,6 @@ class TMXTileMap {
|
|
|
430
427
|
* return an Array of instantiated objects, based on the map object definition
|
|
431
428
|
* @name TMXTileMap#getObjects
|
|
432
429
|
* @public
|
|
433
|
-
* @function
|
|
434
430
|
* @param {boolean} [flatten=true] if true, flatten all objects into the returned array.
|
|
435
431
|
* when false, a `me.Container` object will be created for each corresponding groups
|
|
436
432
|
* @returns {Renderable[]} Array of Objects
|
|
@@ -601,7 +597,6 @@ class TMXTileMap {
|
|
|
601
597
|
* return all the existing layers
|
|
602
598
|
* @name TMXTileMap#getLayers
|
|
603
599
|
* @public
|
|
604
|
-
* @function
|
|
605
600
|
* @returns {TMXLayer[]} Array of Layers
|
|
606
601
|
*/
|
|
607
602
|
getLayers() {
|
|
@@ -614,7 +609,6 @@ class TMXTileMap {
|
|
|
614
609
|
* destroy function, clean all allocated objects
|
|
615
610
|
* @name TMXTileMap#destroy
|
|
616
611
|
* @public
|
|
617
|
-
* @function
|
|
618
612
|
*/
|
|
619
613
|
destroy() {
|
|
620
614
|
this.tilesets = undefined;
|
|
@@ -166,7 +166,6 @@ class TMXTileset {
|
|
|
166
166
|
* return the tile image from a "Collection of Image" tileset
|
|
167
167
|
* @name TMXTileset#getTileImage
|
|
168
168
|
* @public
|
|
169
|
-
* @function
|
|
170
169
|
* @param {number} gid
|
|
171
170
|
* @returns {Image} corresponding image or undefined
|
|
172
171
|
*/
|
|
@@ -178,7 +177,6 @@ class TMXTileset {
|
|
|
178
177
|
/**
|
|
179
178
|
* set the tile properties
|
|
180
179
|
* @ignore
|
|
181
|
-
* @function
|
|
182
180
|
*/
|
|
183
181
|
setTileProperty(gid, prop) {
|
|
184
182
|
// set the given tile id
|
|
@@ -189,7 +187,6 @@ class TMXTileset {
|
|
|
189
187
|
* return true if the gid belongs to the tileset
|
|
190
188
|
* @name TMXTileset#contains
|
|
191
189
|
* @public
|
|
192
|
-
* @function
|
|
193
190
|
* @param {number} gid
|
|
194
191
|
* @returns {boolean}
|
|
195
192
|
*/
|
|
@@ -201,7 +198,6 @@ class TMXTileset {
|
|
|
201
198
|
* Get the view (local) tile ID from a GID, with animations applied
|
|
202
199
|
* @name TMXTileset#getViewTileId
|
|
203
200
|
* @public
|
|
204
|
-
* @function
|
|
205
201
|
* @param {number} gid Global tile ID
|
|
206
202
|
* @returns {number} View tile ID
|
|
207
203
|
*/
|
|
@@ -220,7 +216,6 @@ class TMXTileset {
|
|
|
220
216
|
* return the properties of the specified tile
|
|
221
217
|
* @name TMXTileset#getTileProperties
|
|
222
218
|
* @public
|
|
223
|
-
* @function
|
|
224
219
|
* @param {number} tileId
|
|
225
220
|
* @returns {object}
|
|
226
221
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
// bitmask constants to check for flipped & rotated tiles
|
|
3
|
-
|
|
3
|
+
const TMX_CLEAR_BIT_MASK = ~(0x80000000 | 0x40000000 | 0x20000000);
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc
|
|
@@ -17,7 +17,6 @@ class TMXTilesetGroup {
|
|
|
17
17
|
* add a tileset to the tileset group
|
|
18
18
|
* @name TMXTilesetGroup#add
|
|
19
19
|
* @public
|
|
20
|
-
* @function
|
|
21
20
|
* @param {TMXTileset} tileset
|
|
22
21
|
*/
|
|
23
22
|
add(tileset) {
|
|
@@ -29,7 +28,6 @@ class TMXTilesetGroup {
|
|
|
29
28
|
* return the tileset at the specified index
|
|
30
29
|
* @name TMXTilesetGroup#getTilesetByIndex
|
|
31
30
|
* @public
|
|
32
|
-
* @function
|
|
33
31
|
* @param {number} i
|
|
34
32
|
* @returns {TMXTileset} corresponding tileset
|
|
35
33
|
*/
|
|
@@ -42,7 +40,6 @@ class TMXTilesetGroup {
|
|
|
42
40
|
* will throw an exception if no matching tileset is found
|
|
43
41
|
* @name TMXTilesetGroup#getTilesetByGid
|
|
44
42
|
* @public
|
|
45
|
-
* @function
|
|
46
43
|
* @param {number} gid
|
|
47
44
|
* @returns {TMXTileset} corresponding tileset
|
|
48
45
|
*/
|
|
@@ -98,7 +98,6 @@ function parseAttributes(obj, elt) {
|
|
|
98
98
|
/**
|
|
99
99
|
* decompress zlib/gzip data (NOT IMPLEMENTED)
|
|
100
100
|
* @ignore
|
|
101
|
-
* @function
|
|
102
101
|
* @name decompress
|
|
103
102
|
* @param {number[]} data Array of bytes
|
|
104
103
|
* @param {string} format compressed data format ("gzip","zlib")
|
|
@@ -110,7 +109,6 @@ export function decompress() {
|
|
|
110
109
|
/**
|
|
111
110
|
* Decode a CSV encoded array into a binary array
|
|
112
111
|
* @ignore
|
|
113
|
-
* @function
|
|
114
112
|
* @name decodeCSV
|
|
115
113
|
* @param {string} input CSV formatted data (only numbers, everything else will be converted to NaN)
|
|
116
114
|
* @returns {number[]} Decoded data
|
|
@@ -128,7 +126,6 @@ export function decodeCSV(input) {
|
|
|
128
126
|
/**
|
|
129
127
|
* Decode a base64 encoded string into a byte array
|
|
130
128
|
* @ignore
|
|
131
|
-
* @function
|
|
132
129
|
* @name decodeBase64AsArray
|
|
133
130
|
* @param {string} input Base64 encoded data
|
|
134
131
|
* @param {number} [bytes] number of bytes per array entry
|
|
@@ -6,13 +6,13 @@ import TMXLayer from "./../TMXLayer.js";
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// scope global var & constants
|
|
9
|
-
|
|
9
|
+
const offsetsStaggerX = [
|
|
10
10
|
{x: 0, y: 0},
|
|
11
11
|
{x: + 1, y: - 1},
|
|
12
12
|
{x: + 1, y: 0},
|
|
13
13
|
{x: + 2, y: 0}
|
|
14
14
|
];
|
|
15
|
-
|
|
15
|
+
const offsetsStaggerY = [
|
|
16
16
|
{x: 0, y: 0},
|
|
17
17
|
{x: - 1, y: + 1},
|
|
18
18
|
{x: 0, y: + 1},
|
|
@@ -81,7 +81,6 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
81
81
|
* return the bounding rect for this map renderer
|
|
82
82
|
* @name TMXHexagonalRenderer#getBounds
|
|
83
83
|
* @public
|
|
84
|
-
* @function
|
|
85
84
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
86
85
|
* @returns {Bounds}
|
|
87
86
|
*/
|
|
@@ -41,7 +41,6 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
41
41
|
* return the bounding rect for this map renderer
|
|
42
42
|
* @name TMXIsometricRenderer#getBounds
|
|
43
43
|
* @public
|
|
44
|
-
* @function
|
|
45
44
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
46
45
|
* @returns {Bounds}
|
|
47
46
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import pool from "./../../../system/pooling.js";
|
|
4
4
|
import TMXLayer from "./../TMXLayer.js";
|
|
5
|
-
import Bounds from "./../../../physics/
|
|
5
|
+
import Bounds from "./../../../physics/bounds.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @classdesc
|
|
@@ -27,7 +27,6 @@ class TMXRenderer {
|
|
|
27
27
|
* return true if the renderer can render the specified map or layer
|
|
28
28
|
* @name TMXRenderer#canRender
|
|
29
29
|
* @public
|
|
30
|
-
* @function
|
|
31
30
|
* @param {TMXTileMap|TMXLayer} component TMX Map or Layer
|
|
32
31
|
* @returns {boolean}
|
|
33
32
|
*/
|
|
@@ -48,7 +47,6 @@ class TMXRenderer {
|
|
|
48
47
|
* return the bounding rect for this map renderer
|
|
49
48
|
* @name TMXRenderer#getBounds
|
|
50
49
|
* @public
|
|
51
|
-
* @function
|
|
52
50
|
* @param {TMXLayer} [layer] calculate the bounding rect for a specific layer (will return a new bounds object)
|
|
53
51
|
* @returns {Bounds}
|
|
54
52
|
*/
|
|
@@ -66,7 +64,6 @@ class TMXRenderer {
|
|
|
66
64
|
* return the tile position corresponding to the specified pixel
|
|
67
65
|
* @name TMXRenderer#pixelToTileCoords
|
|
68
66
|
* @public
|
|
69
|
-
* @function
|
|
70
67
|
* @param {number} x X coordinate
|
|
71
68
|
* @param {number} y Y coordinate
|
|
72
69
|
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
@@ -80,7 +77,6 @@ class TMXRenderer {
|
|
|
80
77
|
* return the pixel position corresponding of the specified tile
|
|
81
78
|
* @name TMXRenderer#tileToPixelCoords
|
|
82
79
|
* @public
|
|
83
|
-
* @function
|
|
84
80
|
* @param {number} col tile horizontal position
|
|
85
81
|
* @param {number} row tile vertical position
|
|
86
82
|
* @param {Vector2d} [v] an optional vector object where to put the return values
|
|
@@ -94,7 +90,6 @@ class TMXRenderer {
|
|
|
94
90
|
* draw the given tile at the specified layer
|
|
95
91
|
* @name TMXRenderer#drawTile
|
|
96
92
|
* @public
|
|
97
|
-
* @function
|
|
98
93
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
99
94
|
* @param {number} x X coordinate where to draw the tile
|
|
100
95
|
* @param {number} y Y coordinate where to draw the tile
|
|
@@ -107,7 +102,6 @@ class TMXRenderer {
|
|
|
107
102
|
* draw the given TMX Layer for the given area
|
|
108
103
|
* @name TMXRenderer#drawTileLayer
|
|
109
104
|
* @public
|
|
110
|
-
* @function
|
|
111
105
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
112
106
|
* @param {TMXLayer} layer a TMX Layer object
|
|
113
107
|
* @param {Rect} rect the area of the layer to draw
|
package/src/loader/loader.js
CHANGED
|
@@ -310,7 +310,6 @@ var loader = {
|
|
|
310
310
|
/**
|
|
311
311
|
* onload callback
|
|
312
312
|
* @public
|
|
313
|
-
* @function
|
|
314
313
|
* @name onload
|
|
315
314
|
* @memberof loader
|
|
316
315
|
* @example
|
|
@@ -324,7 +323,6 @@ var loader = {
|
|
|
324
323
|
* each time a resource is loaded, the loader will fire the specified function,
|
|
325
324
|
* giving the actual progress [0 ... 1], as argument, and an object describing the resource loaded
|
|
326
325
|
* @public
|
|
327
|
-
* @function
|
|
328
326
|
* @name onProgress
|
|
329
327
|
* @memberof loader
|
|
330
328
|
* @example
|
|
@@ -412,7 +410,6 @@ var loader = {
|
|
|
412
410
|
* @name setBaseURL
|
|
413
411
|
* @memberof loader
|
|
414
412
|
* @public
|
|
415
|
-
* @function
|
|
416
413
|
* @param {string} type "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
|
|
417
414
|
* @param {string} [url="./"] default base URL
|
|
418
415
|
* @example
|
|
@@ -443,7 +440,6 @@ var loader = {
|
|
|
443
440
|
* @name preload
|
|
444
441
|
* @memberof loader
|
|
445
442
|
* @public
|
|
446
|
-
* @function
|
|
447
443
|
* @param {object[]} res
|
|
448
444
|
* @param {string} res.name internal name of the resource
|
|
449
445
|
* @param {string} res.type "audio", binary", "image", "json","js", "tmx", "tsx", "fontface"
|
|
@@ -508,7 +504,6 @@ var loader = {
|
|
|
508
504
|
* @name load
|
|
509
505
|
* @memberof loader
|
|
510
506
|
* @public
|
|
511
|
-
* @function
|
|
512
507
|
* @param {object} res
|
|
513
508
|
* @param {string} res.name internal name of the resource
|
|
514
509
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
@@ -578,7 +573,6 @@ var loader = {
|
|
|
578
573
|
* @name unload
|
|
579
574
|
* @memberof loader
|
|
580
575
|
* @public
|
|
581
|
-
* @function
|
|
582
576
|
* @param {object} res
|
|
583
577
|
* @param {string} res.name internal name of the resource
|
|
584
578
|
* @param {string} res.type "audio", binary", "image", "json", "tmx", "tsx"
|
|
@@ -640,7 +634,6 @@ var loader = {
|
|
|
640
634
|
* @name unloadAll
|
|
641
635
|
* @memberof loader
|
|
642
636
|
* @public
|
|
643
|
-
* @function
|
|
644
637
|
* @example me.loader.unloadAll();
|
|
645
638
|
*/
|
|
646
639
|
unloadAll() {
|
|
@@ -695,7 +688,6 @@ var loader = {
|
|
|
695
688
|
* @name getTMX
|
|
696
689
|
* @memberof loader
|
|
697
690
|
* @public
|
|
698
|
-
* @function
|
|
699
691
|
* @param {string} elt name of the tmx/tsx element ("map1");
|
|
700
692
|
* @returns {object} requested element or null if not found
|
|
701
693
|
*/
|
|
@@ -713,7 +705,6 @@ var loader = {
|
|
|
713
705
|
* @name getBinary
|
|
714
706
|
* @memberof loader
|
|
715
707
|
* @public
|
|
716
|
-
* @function
|
|
717
708
|
* @param {string} elt name of the binary object ("ymTrack");
|
|
718
709
|
* @returns {object} requested element or null if not found
|
|
719
710
|
*/
|
|
@@ -731,7 +722,6 @@ var loader = {
|
|
|
731
722
|
* @name getImage
|
|
732
723
|
* @memberof loader
|
|
733
724
|
* @public
|
|
734
|
-
* @function
|
|
735
725
|
* @param {string} image name of the Image element ("tileset-platformer");
|
|
736
726
|
* @returns {HTMLImageElement} requested element or null if not found
|
|
737
727
|
*/
|
|
@@ -750,7 +740,6 @@ var loader = {
|
|
|
750
740
|
* @name getJSON
|
|
751
741
|
* @memberof loader
|
|
752
742
|
* @public
|
|
753
|
-
* @function
|
|
754
743
|
* @param {string} elt name of the json file to load
|
|
755
744
|
* @returns {object}
|
|
756
745
|
*/
|
|
@@ -72,7 +72,7 @@ class IconLogo extends Renderable {
|
|
|
72
72
|
this.iconTexture = pool.pull("CanvasTexture",
|
|
73
73
|
renderer.WebGLVersion > 1 ? this.width : nextPowerOfTwo(this.width),
|
|
74
74
|
renderer.WebGLVersion > 1 ? this.height : nextPowerOfTwo(this.height),
|
|
75
|
-
true
|
|
75
|
+
{ offscreenCanvas: true }
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
var context = this.iconTexture.context;
|
package/src/math/color.js
CHANGED
|
@@ -6,11 +6,11 @@ var toHex = function (component) {
|
|
|
6
6
|
return "0123456789ABCDEF".charAt((component - (component % 16)) >> 4) + "0123456789ABCDEF".charAt(component % 16);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const rgbaRx = /^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/;
|
|
10
|
+
const hex3Rx = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/;
|
|
11
|
+
const hex4Rx = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])([\da-fA-F])$/;
|
|
12
|
+
const hex6Rx = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
|
|
13
|
+
const hex8Rx = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
|
|
14
14
|
|
|
15
15
|
var cssToRGB = new Map();
|
|
16
16
|
|
|
@@ -188,9 +188,6 @@ class Color {
|
|
|
188
188
|
* @ignore
|
|
189
189
|
*/
|
|
190
190
|
onResetEvent(r = 0, g = 0, b = 0, alpha = 1.0) {
|
|
191
|
-
/**
|
|
192
|
-
* @ignore
|
|
193
|
-
*/
|
|
194
191
|
if (typeof (this.glArray) === "undefined") {
|
|
195
192
|
// Color components in a Float32Array suitable for WebGL
|
|
196
193
|
this.glArray = new Float32Array([ 0.0, 0.0, 0.0, 1.0 ]);
|
|
@@ -257,7 +254,6 @@ class Color {
|
|
|
257
254
|
* Set this color to the specified value.
|
|
258
255
|
* @name setColor
|
|
259
256
|
* @memberof Color
|
|
260
|
-
* @function
|
|
261
257
|
* @param {number} r red component [0 .. 255]
|
|
262
258
|
* @param {number} g green component [0 .. 255]
|
|
263
259
|
* @param {number} b blue component [0 .. 255]
|
|
@@ -276,7 +272,6 @@ class Color {
|
|
|
276
272
|
* Create a new copy of this color object.
|
|
277
273
|
* @name clone
|
|
278
274
|
* @memberof Color
|
|
279
|
-
* @function
|
|
280
275
|
* @returns {Color} Reference to the newly cloned object
|
|
281
276
|
*/
|
|
282
277
|
clone() {
|
|
@@ -287,7 +282,6 @@ class Color {
|
|
|
287
282
|
* Copy a color object or CSS color into this one.
|
|
288
283
|
* @name copy
|
|
289
284
|
* @memberof Color
|
|
290
|
-
* @function
|
|
291
285
|
* @param {Color|string} color
|
|
292
286
|
* @returns {Color} Reference to this object for method chaining
|
|
293
287
|
*/
|
|
@@ -304,7 +298,6 @@ class Color {
|
|
|
304
298
|
* Blend this color with the given one using addition.
|
|
305
299
|
* @name add
|
|
306
300
|
* @memberof Color
|
|
307
|
-
* @function
|
|
308
301
|
* @param {Color} color
|
|
309
302
|
* @returns {Color} Reference to this object for method chaining
|
|
310
303
|
*/
|
|
@@ -321,7 +314,6 @@ class Color {
|
|
|
321
314
|
* Darken this color value by 0..1
|
|
322
315
|
* @name darken
|
|
323
316
|
* @memberof Color
|
|
324
|
-
* @function
|
|
325
317
|
* @param {number} scale
|
|
326
318
|
* @returns {Color} Reference to this object for method chaining
|
|
327
319
|
*/
|
|
@@ -338,7 +330,6 @@ class Color {
|
|
|
338
330
|
* Linearly interpolate between this color and the given one.
|
|
339
331
|
* @name lerp
|
|
340
332
|
* @memberof Color
|
|
341
|
-
* @function
|
|
342
333
|
* @param {Color} color
|
|
343
334
|
* @param {number} alpha with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
344
335
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -356,7 +347,6 @@ class Color {
|
|
|
356
347
|
* Lighten this color value by 0..1
|
|
357
348
|
* @name lighten
|
|
358
349
|
* @memberof Color
|
|
359
|
-
* @function
|
|
360
350
|
* @param {number} scale
|
|
361
351
|
* @returns {Color} Reference to this object for method chaining
|
|
362
352
|
*/
|
|
@@ -373,7 +363,6 @@ class Color {
|
|
|
373
363
|
* Generate random r,g,b values for this color object
|
|
374
364
|
* @name random
|
|
375
365
|
* @memberof Color
|
|
376
|
-
* @function
|
|
377
366
|
* @param {number} [min=0] minimum value for the random range
|
|
378
367
|
* @param {number} [max=255] maxmium value for the random range
|
|
379
368
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -399,7 +388,6 @@ class Color {
|
|
|
399
388
|
* given one.
|
|
400
389
|
* @name equals
|
|
401
390
|
* @memberof Color
|
|
402
|
-
* @function
|
|
403
391
|
* @param {Color} color
|
|
404
392
|
* @returns {boolean}
|
|
405
393
|
*/
|
|
@@ -417,7 +405,6 @@ class Color {
|
|
|
417
405
|
* r,g,b values
|
|
418
406
|
* @name parseCSS
|
|
419
407
|
* @memberof Color
|
|
420
|
-
* @function
|
|
421
408
|
* @param {string} cssColor
|
|
422
409
|
* @returns {Color} Reference to this object for method chaining
|
|
423
410
|
*/
|
|
@@ -435,7 +422,6 @@ class Color {
|
|
|
435
422
|
* Parse an RGB or RGBA CSS color string
|
|
436
423
|
* @name parseRGB
|
|
437
424
|
* @memberof Color
|
|
438
|
-
* @function
|
|
439
425
|
* @param {string} rgbColor
|
|
440
426
|
* @returns {Color} Reference to this object for method chaining
|
|
441
427
|
*/
|
|
@@ -455,7 +441,6 @@ class Color {
|
|
|
455
441
|
* the corresponding r,g,b,a values
|
|
456
442
|
* @name parseHex
|
|
457
443
|
* @memberof Color
|
|
458
|
-
* @function
|
|
459
444
|
* @param {string} hexColor
|
|
460
445
|
* @param {boolean} [argb = false] true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
461
446
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -515,7 +500,6 @@ class Color {
|
|
|
515
500
|
* Pack this color into a Uint32 ARGB representation
|
|
516
501
|
* @name toUint32
|
|
517
502
|
* @memberof Color
|
|
518
|
-
* @function
|
|
519
503
|
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
520
504
|
* @returns {number}
|
|
521
505
|
*/
|
|
@@ -532,7 +516,6 @@ class Color {
|
|
|
532
516
|
* return an array representation of this object
|
|
533
517
|
* @name toArray
|
|
534
518
|
* @memberof Color
|
|
535
|
-
* @function
|
|
536
519
|
* @returns {Float32Array}
|
|
537
520
|
*/
|
|
538
521
|
toArray() {
|
|
@@ -544,7 +527,6 @@ class Color {
|
|
|
544
527
|
* Get the color in "#RRGGBB" format
|
|
545
528
|
* @name toHex
|
|
546
529
|
* @memberof Color
|
|
547
|
-
* @function
|
|
548
530
|
* @returns {string}
|
|
549
531
|
*/
|
|
550
532
|
toHex() {
|
|
@@ -558,7 +540,6 @@ class Color {
|
|
|
558
540
|
* Get the color in "#RRGGBBAA" format
|
|
559
541
|
* @name toHex8
|
|
560
542
|
* @memberof Color
|
|
561
|
-
* @function
|
|
562
543
|
* @returns {string}
|
|
563
544
|
*/
|
|
564
545
|
toHex8(alpha = this.alpha) {
|
|
@@ -572,7 +553,6 @@ class Color {
|
|
|
572
553
|
* Get the color in "rgb(R,G,B)" format
|
|
573
554
|
* @name toRGB
|
|
574
555
|
* @memberof Color
|
|
575
|
-
* @function
|
|
576
556
|
* @returns {string}
|
|
577
557
|
*/
|
|
578
558
|
toRGB() {
|
|
@@ -590,7 +570,6 @@ class Color {
|
|
|
590
570
|
* Get the color in "rgba(R,G,B,A)" format
|
|
591
571
|
* @name toRGBA
|
|
592
572
|
* @memberof Color
|
|
593
|
-
* @function
|
|
594
573
|
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
595
574
|
* @returns {string}
|
|
596
575
|
*/
|
package/src/math/math.js
CHANGED
|
@@ -51,7 +51,6 @@ export const EPSILON = 0.000001;
|
|
|
51
51
|
/**
|
|
52
52
|
* returns true if the given value is a power of two
|
|
53
53
|
* @public
|
|
54
|
-
* @function
|
|
55
54
|
* @memberof Math
|
|
56
55
|
* @name isPowerOfTwo
|
|
57
56
|
* @param {number} val
|
|
@@ -64,7 +63,6 @@ export function isPowerOfTwo(val) {
|
|
|
64
63
|
/**
|
|
65
64
|
* returns the next power of two for the given value
|
|
66
65
|
* @public
|
|
67
|
-
* @function
|
|
68
66
|
* @memberof Math
|
|
69
67
|
* @name nextPowerOfTwo
|
|
70
68
|
* @param {number} val
|
|
@@ -84,7 +82,6 @@ export function nextPowerOfTwo(val) {
|
|
|
84
82
|
/**
|
|
85
83
|
* Converts an angle in degrees to an angle in radians
|
|
86
84
|
* @public
|
|
87
|
-
* @function
|
|
88
85
|
* @memberof Math
|
|
89
86
|
* @name degToRad
|
|
90
87
|
* @param {number} angle angle in degrees
|
|
@@ -100,7 +97,6 @@ export function degToRad(angle) {
|
|
|
100
97
|
/**
|
|
101
98
|
* Converts an angle in radians to an angle in degrees.
|
|
102
99
|
* @public
|
|
103
|
-
* @function
|
|
104
100
|
* @memberof Math
|
|
105
101
|
* @name radToDeg
|
|
106
102
|
* @param {number} radians angle in radians
|
|
@@ -116,7 +112,6 @@ export function radToDeg(radians) {
|
|
|
116
112
|
/**
|
|
117
113
|
* clamp the given value
|
|
118
114
|
* @public
|
|
119
|
-
* @function
|
|
120
115
|
* @memberof Math
|
|
121
116
|
* @name clamp
|
|
122
117
|
* @param {number} val the value to clamp
|
|
@@ -131,7 +126,6 @@ export function clamp(val, low, high) {
|
|
|
131
126
|
/**
|
|
132
127
|
* return a random integer between min (included) and max (excluded)
|
|
133
128
|
* @public
|
|
134
|
-
* @function
|
|
135
129
|
* @memberof Math
|
|
136
130
|
* @name random
|
|
137
131
|
* @param {number} min minimum value.
|
|
@@ -148,7 +142,6 @@ export function random(min, max) {
|
|
|
148
142
|
/**
|
|
149
143
|
* return a random float between min, max (exclusive)
|
|
150
144
|
* @public
|
|
151
|
-
* @function
|
|
152
145
|
* @memberof Math
|
|
153
146
|
* @name randomFloat
|
|
154
147
|
* @param {number} min minimum value.
|
|
@@ -165,7 +158,6 @@ export function randomFloat(min, max) {
|
|
|
165
158
|
/**
|
|
166
159
|
* return a weighted random between min, max (exclusive)
|
|
167
160
|
* @public
|
|
168
|
-
* @function
|
|
169
161
|
* @memberof Math
|
|
170
162
|
* @name weightedRandom
|
|
171
163
|
* @param {number} min minimum value.
|
|
@@ -182,7 +174,6 @@ export function weightedRandom(min, max) {
|
|
|
182
174
|
/**
|
|
183
175
|
* round a value to the specified number of digit
|
|
184
176
|
* @public
|
|
185
|
-
* @function
|
|
186
177
|
* @memberof Math
|
|
187
178
|
* @name round
|
|
188
179
|
* @param {number} num value to be rounded.
|
|
@@ -201,7 +192,6 @@ export function round(num, dec = 0) {
|
|
|
201
192
|
/**
|
|
202
193
|
* check if the given value is close to the expected one
|
|
203
194
|
* @public
|
|
204
|
-
* @function
|
|
205
195
|
* @memberof Math
|
|
206
196
|
* @name toBeCloseTo
|
|
207
197
|
* @param {number} expected value to be compared with.
|