melonjs 10.2.3 → 10.3.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/dist/melonjs.js +1741 -1558
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +1256 -1758
- package/dist/melonjs.module.js +1734 -1582
- package/package.json +12 -12
- package/src/audio/audio.js +3 -3
- package/src/camera/camera2d.js +26 -27
- package/src/entity/draggable.js +10 -19
- package/src/entity/droptarget.js +12 -20
- package/src/entity/entity.js +13 -13
- package/src/game.js +6 -6
- package/src/{shapes → geometries}/ellipse.js +19 -20
- package/src/{shapes → geometries}/line.js +6 -7
- package/src/{shapes → geometries}/poly.js +70 -23
- package/src/{shapes → geometries}/rectangle.js +23 -24
- package/src/index.js +8 -9
- package/src/input/gamepad.js +7 -7
- package/src/input/input.js +2 -2
- package/src/input/keyboard.js +108 -108
- package/src/input/pointer.js +61 -28
- package/src/input/pointerevent.js +79 -16
- package/src/lang/deprecated.js +26 -15
- package/src/level/level.js +10 -10
- package/src/level/tiled/TMXGroup.js +6 -7
- package/src/level/tiled/TMXLayer.js +10 -11
- package/src/level/tiled/TMXObject.js +57 -51
- package/src/level/tiled/TMXTile.js +2 -3
- package/src/level/tiled/TMXTileMap.js +3 -4
- package/src/level/tiled/TMXTileset.js +1 -2
- package/src/level/tiled/TMXTilesetGroup.js +1 -2
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +1 -2
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +17 -15
- package/src/loader/loadingscreen.js +1 -2
- package/src/math/color.js +23 -24
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +24 -25
- package/src/math/matrix3.js +26 -27
- package/src/math/observable_vector2.js +46 -35
- package/src/math/observable_vector3.js +54 -36
- package/src/math/vector2.js +58 -47
- package/src/math/vector3.js +66 -48
- package/src/particles/emitter.js +64 -72
- package/src/particles/particle.js +3 -4
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +38 -39
- package/src/physics/bounds.js +30 -32
- package/src/physics/collision.js +6 -6
- package/src/physics/detector.js +3 -3
- package/src/physics/quadtree.js +8 -9
- package/src/physics/sat.js +4 -4
- package/src/physics/world.js +11 -12
- package/src/plugin/plugin.js +6 -7
- package/src/renderable/GUI.js +7 -8
- package/src/renderable/collectable.js +3 -4
- package/src/renderable/colorlayer.js +7 -8
- package/src/renderable/container.js +36 -37
- package/src/renderable/imagelayer.js +4 -5
- package/src/renderable/nineslicesprite.js +2 -3
- package/src/renderable/renderable.js +45 -46
- package/src/renderable/sprite.js +16 -17
- package/src/renderable/trigger.js +4 -5
- package/src/state/stage.js +8 -9
- package/src/state/state.js +24 -24
- package/src/system/device.js +41 -97
- package/src/system/event.js +45 -33
- package/src/system/pooling.js +1 -1
- package/src/system/save.js +3 -3
- package/src/system/timer.js +13 -13
- package/src/text/bitmaptext.js +12 -13
- package/src/text/bitmaptextdata.js +5 -6
- package/src/text/text.js +16 -17
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +14 -15
- package/src/utils/agent.js +3 -3
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +3 -3
- package/src/utils/function.js +3 -3
- package/src/utils/string.js +7 -7
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +39 -40
- package/src/video/renderer.js +29 -30
- package/src/video/texture.js +8 -9
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +7 -7
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +11 -12
- package/src/video/webgl/webgl_compositor.js +118 -90
- package/src/video/webgl/webgl_renderer.js +95 -74
package/src/physics/body.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vector2d from "./../math/vector2.js";
|
|
2
|
-
import Rect from "./../
|
|
3
|
-
import Ellipse from "./../
|
|
4
|
-
import Polygon from "./../
|
|
2
|
+
import Rect from "./../geometries/rectangle.js";
|
|
3
|
+
import Ellipse from "./../geometries/ellipse.js";
|
|
4
|
+
import Polygon from "./../geometries/poly.js";
|
|
5
5
|
import Bounds from "./bounds.js";
|
|
6
6
|
import collision from "./collision.js";
|
|
7
7
|
import * as arrayUtil from "./../utils/array.js";
|
|
@@ -13,8 +13,7 @@ import { world } from "./../game.js";
|
|
|
13
13
|
/**
|
|
14
14
|
* a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
|
|
15
15
|
* @class Body
|
|
16
|
-
* @
|
|
17
|
-
* @constructor
|
|
16
|
+
* @memberof me
|
|
18
17
|
* @param {me.Renderable} ancestor the parent object this body is attached to
|
|
19
18
|
* @param {me.Rect|me.Rect[]|me.Polygon|me.Polygon[]|me.Line|me.Line[]|me.Ellipse|me.Ellipse[]|me.Bounds|me.Bounds[]|object} [shapes] a initial shape, list of shapes, or JSON object defining the body
|
|
20
19
|
* @param {Function} [onBodyUpdate] callback for when the body is updated (e.g. add/remove shapes)
|
|
@@ -38,7 +37,7 @@ class Body {
|
|
|
38
37
|
* @public
|
|
39
38
|
* @type {me.Bounds}
|
|
40
39
|
* @name bounds
|
|
41
|
-
* @
|
|
40
|
+
* @memberof me.Body
|
|
42
41
|
*/
|
|
43
42
|
if (typeof this.bounds === "undefined") {
|
|
44
43
|
this.bounds = new Bounds();
|
|
@@ -49,7 +48,7 @@ class Body {
|
|
|
49
48
|
* @ignore
|
|
50
49
|
* @type {me.Polygon[]|me.Line[]|me.Ellipse[]}
|
|
51
50
|
* @name shapes
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.Body
|
|
53
52
|
*/
|
|
54
53
|
if (typeof this.shapes === "undefined") {
|
|
55
54
|
this.shapes = [];
|
|
@@ -63,7 +62,7 @@ class Body {
|
|
|
63
62
|
* @default me.collision.types.ALL_OBJECT
|
|
64
63
|
* @name collisionMask
|
|
65
64
|
* @see me.collision.types
|
|
66
|
-
* @
|
|
65
|
+
* @memberof me.Body
|
|
67
66
|
*/
|
|
68
67
|
this.collisionMask = collision.types.ALL_OBJECT;
|
|
69
68
|
|
|
@@ -74,7 +73,7 @@ class Body {
|
|
|
74
73
|
* @default me.collision.types.ENEMY_OBJECT
|
|
75
74
|
* @name collisionType
|
|
76
75
|
* @see me.collision.types
|
|
77
|
-
* @
|
|
76
|
+
* @memberof me.Body
|
|
78
77
|
* @example
|
|
79
78
|
* // set the body collision type
|
|
80
79
|
* myEntity.body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
@@ -87,7 +86,7 @@ class Body {
|
|
|
87
86
|
* @type {me.Vector2d}
|
|
88
87
|
* @default <0,0>
|
|
89
88
|
* @name vel
|
|
90
|
-
* @
|
|
89
|
+
* @memberof me.Body
|
|
91
90
|
*/
|
|
92
91
|
if (typeof this.vel === "undefined") {
|
|
93
92
|
this.vel = new Vector2d();
|
|
@@ -102,7 +101,7 @@ class Body {
|
|
|
102
101
|
* @default <0,0>
|
|
103
102
|
* @name force
|
|
104
103
|
* @see me.Body.setMaxVelocity
|
|
105
|
-
* @
|
|
104
|
+
* @memberof me.Body
|
|
106
105
|
* @example
|
|
107
106
|
* // define a default maximum acceleration, initial force and friction
|
|
108
107
|
* this.body.force.set(0, 0);
|
|
@@ -132,7 +131,7 @@ class Body {
|
|
|
132
131
|
* @type {me.Vector2d}
|
|
133
132
|
* @default <0,0>
|
|
134
133
|
* @name friction
|
|
135
|
-
* @
|
|
134
|
+
* @memberof me.Body
|
|
136
135
|
*/
|
|
137
136
|
if (typeof this.friction === "undefined") {
|
|
138
137
|
this.friction = new Vector2d();
|
|
@@ -146,7 +145,7 @@ class Body {
|
|
|
146
145
|
* @type {number}
|
|
147
146
|
* @default 0
|
|
148
147
|
* @name bounce
|
|
149
|
-
* @
|
|
148
|
+
* @memberof me.Body
|
|
150
149
|
*/
|
|
151
150
|
this.bounce = 0;
|
|
152
151
|
|
|
@@ -156,7 +155,7 @@ class Body {
|
|
|
156
155
|
* @type {number}
|
|
157
156
|
* @default 1
|
|
158
157
|
* @name mass
|
|
159
|
-
* @
|
|
158
|
+
* @memberof me.Body
|
|
160
159
|
*/
|
|
161
160
|
this.mass = 1;
|
|
162
161
|
|
|
@@ -166,7 +165,7 @@ class Body {
|
|
|
166
165
|
* @type {me.Vector2d}
|
|
167
166
|
* @default <490,490>
|
|
168
167
|
* @name maxVel
|
|
169
|
-
* @
|
|
168
|
+
* @memberof me.Body
|
|
170
169
|
*/
|
|
171
170
|
if (typeof this.maxVel === "undefined") {
|
|
172
171
|
this.maxVel = new Vector2d();
|
|
@@ -182,7 +181,7 @@ class Body {
|
|
|
182
181
|
* @type {boolean}
|
|
183
182
|
* @default false
|
|
184
183
|
* @name isStatic
|
|
185
|
-
* @
|
|
184
|
+
* @memberof me.Body
|
|
186
185
|
*/
|
|
187
186
|
this.isStatic = false;
|
|
188
187
|
|
|
@@ -194,7 +193,7 @@ class Body {
|
|
|
194
193
|
* @type {number}
|
|
195
194
|
* @default 1.0
|
|
196
195
|
* @name gravityScale
|
|
197
|
-
* @
|
|
196
|
+
* @memberof me.Body
|
|
198
197
|
*/
|
|
199
198
|
this.gravityScale = 1.0;
|
|
200
199
|
|
|
@@ -205,7 +204,7 @@ class Body {
|
|
|
205
204
|
* @type {boolean}
|
|
206
205
|
* @default false
|
|
207
206
|
* @name ignoreGravity
|
|
208
|
-
* @
|
|
207
|
+
* @memberof me.Body
|
|
209
208
|
*/
|
|
210
209
|
this.ignoreGravity = false;
|
|
211
210
|
|
|
@@ -218,7 +217,7 @@ class Body {
|
|
|
218
217
|
* @type {boolean}
|
|
219
218
|
* @default false
|
|
220
219
|
* @name falling
|
|
221
|
-
* @
|
|
220
|
+
* @memberof me.Body
|
|
222
221
|
*/
|
|
223
222
|
this.falling = false;
|
|
224
223
|
|
|
@@ -230,7 +229,7 @@ class Body {
|
|
|
230
229
|
* @type {boolean}
|
|
231
230
|
* @default false
|
|
232
231
|
* @name jumping
|
|
233
|
-
* @
|
|
232
|
+
* @memberof me.Body
|
|
234
233
|
*/
|
|
235
234
|
this.jumping = false;
|
|
236
235
|
|
|
@@ -260,7 +259,7 @@ class Body {
|
|
|
260
259
|
* set the body as a static body
|
|
261
260
|
* static body do not move automatically and do not check againt collision with others
|
|
262
261
|
* @name setStatic
|
|
263
|
-
* @
|
|
262
|
+
* @memberof me.Body
|
|
264
263
|
* @public
|
|
265
264
|
* @function
|
|
266
265
|
* @param {boolean} [isStatic=true]
|
|
@@ -273,7 +272,7 @@ class Body {
|
|
|
273
272
|
* add a collision shape to this body <br>
|
|
274
273
|
* (note: me.Rect objects will be converted to me.Polygon before being added)
|
|
275
274
|
* @name addShape
|
|
276
|
-
* @
|
|
275
|
+
* @memberof me.Body
|
|
277
276
|
* @public
|
|
278
277
|
* @function
|
|
279
278
|
* @param {me.Rect|me.Polygon|me.Line|me.Ellipse|me.Bounds|object} shape a shape or JSON object
|
|
@@ -327,7 +326,7 @@ class Body {
|
|
|
327
326
|
/**
|
|
328
327
|
* set the body vertices to the given one
|
|
329
328
|
* @name setVertices
|
|
330
|
-
* @
|
|
329
|
+
* @memberof me.Body
|
|
331
330
|
* @public
|
|
332
331
|
* @function
|
|
333
332
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
|
|
@@ -354,7 +353,7 @@ class Body {
|
|
|
354
353
|
/**
|
|
355
354
|
* add the given vertices to the body shape
|
|
356
355
|
* @name addVertices
|
|
357
|
-
* @
|
|
356
|
+
* @memberof me.Body
|
|
358
357
|
* @public
|
|
359
358
|
* @function
|
|
360
359
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
|
|
@@ -368,7 +367,7 @@ class Body {
|
|
|
368
367
|
* add collision mesh based on a JSON object
|
|
369
368
|
* (this will also apply any physic properties defined in the given JSON file)
|
|
370
369
|
* @name fromJSON
|
|
371
|
-
* @
|
|
370
|
+
* @memberof me.Body
|
|
372
371
|
* @public
|
|
373
372
|
* @function
|
|
374
373
|
* @param {object} json a JSON object as exported from a Physics Editor tool
|
|
@@ -412,7 +411,7 @@ class Body {
|
|
|
412
411
|
/**
|
|
413
412
|
* return the collision shape at the given index
|
|
414
413
|
* @name getShape
|
|
415
|
-
* @
|
|
414
|
+
* @memberof me.Body
|
|
416
415
|
* @public
|
|
417
416
|
* @function
|
|
418
417
|
* @param {number} [index=0] the shape object at the specified index
|
|
@@ -425,7 +424,7 @@ class Body {
|
|
|
425
424
|
/**
|
|
426
425
|
* returns the AABB bounding box for this body
|
|
427
426
|
* @name getBounds
|
|
428
|
-
* @
|
|
427
|
+
* @memberof me.Body
|
|
429
428
|
* @function
|
|
430
429
|
* @returns {me.Bounds} bounding box Rectangle object
|
|
431
430
|
*/
|
|
@@ -436,7 +435,7 @@ class Body {
|
|
|
436
435
|
/**
|
|
437
436
|
* remove the specified shape from the body shape list
|
|
438
437
|
* @name removeShape
|
|
439
|
-
* @
|
|
438
|
+
* @memberof me.Body
|
|
440
439
|
* @public
|
|
441
440
|
* @function
|
|
442
441
|
* @param {me.Polygon|me.Line|me.Ellipse} shape a shape object
|
|
@@ -458,7 +457,7 @@ class Body {
|
|
|
458
457
|
/**
|
|
459
458
|
* remove the shape at the given index from the body shape list
|
|
460
459
|
* @name removeShapeAt
|
|
461
|
-
* @
|
|
460
|
+
* @memberof me.Body
|
|
462
461
|
* @public
|
|
463
462
|
* @function
|
|
464
463
|
* @param {number} index the shape object at the specified index
|
|
@@ -473,7 +472,7 @@ class Body {
|
|
|
473
472
|
* but it's also possible to specify 'collision filters' to provide a finer <br>
|
|
474
473
|
* control over which entities can collide with each other.
|
|
475
474
|
* @name setCollisionMask
|
|
476
|
-
* @
|
|
475
|
+
* @memberof me.Body
|
|
477
476
|
* @public
|
|
478
477
|
* @function
|
|
479
478
|
* @see me.collision.types
|
|
@@ -492,7 +491,7 @@ class Body {
|
|
|
492
491
|
/**
|
|
493
492
|
* define the collision type of the body for collision filtering
|
|
494
493
|
* @name setCollisionType
|
|
495
|
-
* @
|
|
494
|
+
* @memberof me.Body
|
|
496
495
|
* @public
|
|
497
496
|
* @function
|
|
498
497
|
* @see me.collision.types
|
|
@@ -515,7 +514,7 @@ class Body {
|
|
|
515
514
|
* the built-in function to solve the collision response
|
|
516
515
|
* @protected
|
|
517
516
|
* @name respondToCollision
|
|
518
|
-
* @
|
|
517
|
+
* @memberof me.Body
|
|
519
518
|
* @function
|
|
520
519
|
* @param {me.collision.ResponseObject} response the collision response object
|
|
521
520
|
*/
|
|
@@ -555,7 +554,7 @@ class Body {
|
|
|
555
554
|
* - The index of element in the array. <br>
|
|
556
555
|
* - The array forEach() was called upon. <br>
|
|
557
556
|
* @name forEach
|
|
558
|
-
* @
|
|
557
|
+
* @memberof me.Body.prototype
|
|
559
558
|
* @function
|
|
560
559
|
* @param {Function} callback fnction to execute on each element
|
|
561
560
|
* @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
|
|
@@ -592,7 +591,7 @@ class Body {
|
|
|
592
591
|
/**
|
|
593
592
|
* Returns true if the any of the shape composing the body contains the given point.
|
|
594
593
|
* @name contains
|
|
595
|
-
* @
|
|
594
|
+
* @memberof me.Body
|
|
596
595
|
* @function
|
|
597
596
|
* @param {me.Vector2d} point
|
|
598
597
|
* @returns {boolean} true if contains
|
|
@@ -601,7 +600,7 @@ class Body {
|
|
|
601
600
|
/**
|
|
602
601
|
* Returns true if the any of the shape composing the body contains the given point.
|
|
603
602
|
* @name contains
|
|
604
|
-
* @
|
|
603
|
+
* @memberof me.Body
|
|
605
604
|
* @function
|
|
606
605
|
* @param {number} x x coordinate
|
|
607
606
|
* @param {number} y y coordinate
|
|
@@ -635,7 +634,7 @@ class Body {
|
|
|
635
634
|
* Rotate this body (counter-clockwise) by the specified angle (in radians).
|
|
636
635
|
* Unless specified the body will be rotated around its center point
|
|
637
636
|
* @name rotate
|
|
638
|
-
* @
|
|
637
|
+
* @memberof me.Body
|
|
639
638
|
* @function
|
|
640
639
|
* @param {number} angle The angle to rotate (in radians)
|
|
641
640
|
* @param {me.Vector2d|me.ObservableVector2d} [v=me.Body.getBounds().center] an optional point to rotate around
|
|
@@ -662,7 +661,7 @@ class Body {
|
|
|
662
661
|
/**
|
|
663
662
|
* cap the body velocity (body.maxVel property) to the specified value<br>
|
|
664
663
|
* @name setMaxVelocity
|
|
665
|
-
* @
|
|
664
|
+
* @memberof me.Body
|
|
666
665
|
* @function
|
|
667
666
|
* @param {number} x max velocity on x axis
|
|
668
667
|
* @param {number} y max velocity on y axis
|
|
@@ -676,7 +675,7 @@ class Body {
|
|
|
676
675
|
/**
|
|
677
676
|
* set the body default friction
|
|
678
677
|
* @name setFriction
|
|
679
|
-
* @
|
|
678
|
+
* @memberof me.Body
|
|
680
679
|
* @function
|
|
681
680
|
* @param {number} x horizontal friction
|
|
682
681
|
* @param {number} y vertical friction
|
|
@@ -763,7 +762,7 @@ class Body {
|
|
|
763
762
|
* At this time a call to Body.Update does not call the onBodyUpdate callback that is listed in the constructor arguments.
|
|
764
763
|
* @name update
|
|
765
764
|
* @ignore
|
|
766
|
-
* @
|
|
765
|
+
* @memberof me.Body
|
|
767
766
|
* @function
|
|
768
767
|
* @param {number} dt time since the last update in milliseconds.
|
|
769
768
|
* @returns {boolean} true if resulting velocity is different than 0
|
package/src/physics/bounds.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import Vector2d from "./../math/vector2.js";
|
|
2
|
-
import Polygon from "./../
|
|
2
|
+
import Polygon from "./../geometries/poly.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
|
|
7
7
|
* @class Bounds
|
|
8
|
-
* @
|
|
9
|
-
* @constructor
|
|
10
|
-
* @memberOf me
|
|
8
|
+
* @memberof me
|
|
11
9
|
* @param {me.Vector2d[]} [vertices] an array of me.Vector2d points
|
|
12
10
|
* @returns {me.Bounds} A new bounds object
|
|
13
11
|
*/
|
|
@@ -36,7 +34,7 @@ class Bounds {
|
|
|
36
34
|
/**
|
|
37
35
|
* reset the bound
|
|
38
36
|
* @name clear
|
|
39
|
-
* @
|
|
37
|
+
* @memberof me.Bounds
|
|
40
38
|
* @function
|
|
41
39
|
*/
|
|
42
40
|
clear() {
|
|
@@ -47,7 +45,7 @@ class Bounds {
|
|
|
47
45
|
/**
|
|
48
46
|
* sets the bounds to the given min and max value
|
|
49
47
|
* @name setMinMax
|
|
50
|
-
* @
|
|
48
|
+
* @memberof me.Bounds
|
|
51
49
|
* @function
|
|
52
50
|
* @param {number} minX
|
|
53
51
|
* @param {number} minY
|
|
@@ -67,7 +65,7 @@ class Bounds {
|
|
|
67
65
|
* @public
|
|
68
66
|
* @type {number}
|
|
69
67
|
* @name x
|
|
70
|
-
* @
|
|
68
|
+
* @memberof me.Bounds
|
|
71
69
|
*/
|
|
72
70
|
get x() {
|
|
73
71
|
return this.min.x;
|
|
@@ -84,7 +82,7 @@ class Bounds {
|
|
|
84
82
|
* @public
|
|
85
83
|
* @type {number}
|
|
86
84
|
* @name y
|
|
87
|
-
* @
|
|
85
|
+
* @memberof me.Bounds
|
|
88
86
|
*/
|
|
89
87
|
get y() {
|
|
90
88
|
return this.min.y;
|
|
@@ -102,7 +100,7 @@ class Bounds {
|
|
|
102
100
|
* @public
|
|
103
101
|
* @type {number}
|
|
104
102
|
* @name width
|
|
105
|
-
* @
|
|
103
|
+
* @memberof me.Bounds
|
|
106
104
|
*/
|
|
107
105
|
get width() {
|
|
108
106
|
return this.max.x - this.min.x;
|
|
@@ -117,7 +115,7 @@ class Bounds {
|
|
|
117
115
|
* @public
|
|
118
116
|
* @type {number}
|
|
119
117
|
* @name width
|
|
120
|
-
* @
|
|
118
|
+
* @memberof me.Bounds
|
|
121
119
|
*/
|
|
122
120
|
get height() {
|
|
123
121
|
return this.max.y - this.min.y;
|
|
@@ -132,7 +130,7 @@ class Bounds {
|
|
|
132
130
|
* @public
|
|
133
131
|
* @type {number}
|
|
134
132
|
* @name left
|
|
135
|
-
* @
|
|
133
|
+
* @memberof me.Bounds
|
|
136
134
|
*/
|
|
137
135
|
get left() {
|
|
138
136
|
return this.min.x;
|
|
@@ -143,7 +141,7 @@ class Bounds {
|
|
|
143
141
|
* @public
|
|
144
142
|
* @type {number}
|
|
145
143
|
* @name right
|
|
146
|
-
* @
|
|
144
|
+
* @memberof me.Bounds
|
|
147
145
|
*/
|
|
148
146
|
get right() {
|
|
149
147
|
return this.max.x;
|
|
@@ -154,7 +152,7 @@ class Bounds {
|
|
|
154
152
|
* @public
|
|
155
153
|
* @type {number}
|
|
156
154
|
* @name top
|
|
157
|
-
* @
|
|
155
|
+
* @memberof me.Bounds
|
|
158
156
|
*/
|
|
159
157
|
get top() {
|
|
160
158
|
return this.min.y;
|
|
@@ -165,7 +163,7 @@ class Bounds {
|
|
|
165
163
|
* @public
|
|
166
164
|
* @type {number}
|
|
167
165
|
* @name bottom
|
|
168
|
-
* @
|
|
166
|
+
* @memberof me.Bounds
|
|
169
167
|
*/
|
|
170
168
|
get bottom() {
|
|
171
169
|
return this.max.y;
|
|
@@ -176,7 +174,7 @@ class Bounds {
|
|
|
176
174
|
* @public
|
|
177
175
|
* @type {number}
|
|
178
176
|
* @name centerX
|
|
179
|
-
* @
|
|
177
|
+
* @memberof me.Bounds
|
|
180
178
|
*/
|
|
181
179
|
get centerX() {
|
|
182
180
|
return this.min.x + (this.width / 2);
|
|
@@ -187,7 +185,7 @@ class Bounds {
|
|
|
187
185
|
* @public
|
|
188
186
|
* @type {number}
|
|
189
187
|
* @name centerY
|
|
190
|
-
* @
|
|
188
|
+
* @memberof me.Bounds
|
|
191
189
|
*/
|
|
192
190
|
get centerY() {
|
|
193
191
|
return this.min.y + (this.height / 2);
|
|
@@ -198,7 +196,7 @@ class Bounds {
|
|
|
198
196
|
* @public
|
|
199
197
|
* @type {me.Vector2d}
|
|
200
198
|
* @name center
|
|
201
|
-
* @
|
|
199
|
+
* @memberof me.Bounds
|
|
202
200
|
*/
|
|
203
201
|
get center() {
|
|
204
202
|
return this._center.set(this.centerX, this.centerY);
|
|
@@ -207,7 +205,7 @@ class Bounds {
|
|
|
207
205
|
/**
|
|
208
206
|
* Updates bounds using the given vertices
|
|
209
207
|
* @name update
|
|
210
|
-
* @
|
|
208
|
+
* @memberof me.Bounds
|
|
211
209
|
* @function
|
|
212
210
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
213
211
|
*/
|
|
@@ -218,7 +216,7 @@ class Bounds {
|
|
|
218
216
|
/**
|
|
219
217
|
* add the given vertices to the bounds definition.
|
|
220
218
|
* @name add
|
|
221
|
-
* @
|
|
219
|
+
* @memberof me.Bounds
|
|
222
220
|
* @function
|
|
223
221
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
224
222
|
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
@@ -239,7 +237,7 @@ class Bounds {
|
|
|
239
237
|
/**
|
|
240
238
|
* add the given bounds to the bounds definition.
|
|
241
239
|
* @name addBounds
|
|
242
|
-
* @
|
|
240
|
+
* @memberof me.Bounds
|
|
243
241
|
* @function
|
|
244
242
|
* @param {me.Bounds} bounds
|
|
245
243
|
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
@@ -258,7 +256,7 @@ class Bounds {
|
|
|
258
256
|
/**
|
|
259
257
|
* add the given point to the bounds definition.
|
|
260
258
|
* @name addPoint
|
|
261
|
-
* @
|
|
259
|
+
* @memberof me.Bounds
|
|
262
260
|
* @function
|
|
263
261
|
* @param {me.Vector2d} v
|
|
264
262
|
* @param {me.Matrix2d} [m] an optional transform to apply to the given point
|
|
@@ -276,7 +274,7 @@ class Bounds {
|
|
|
276
274
|
/**
|
|
277
275
|
* add the given quad coordinates to this bound definition, multiplied by the given matrix
|
|
278
276
|
* @name addFrame
|
|
279
|
-
* @
|
|
277
|
+
* @memberof me.Bounds
|
|
280
278
|
* @function
|
|
281
279
|
* @param {number} x0 - left X coordinates of the quad
|
|
282
280
|
* @param {number} y0 - top Y coordinates of the quad
|
|
@@ -299,7 +297,7 @@ class Bounds {
|
|
|
299
297
|
/**
|
|
300
298
|
* Returns true if the bounds contains the given point.
|
|
301
299
|
* @name contains
|
|
302
|
-
* @
|
|
300
|
+
* @memberof me.Bounds
|
|
303
301
|
* @function
|
|
304
302
|
* @param {me.Vector2d} point
|
|
305
303
|
* @returns {boolean} True if the bounds contain the point, otherwise false
|
|
@@ -307,7 +305,7 @@ class Bounds {
|
|
|
307
305
|
/**
|
|
308
306
|
* Returns true if the bounds contains the given point.
|
|
309
307
|
* @name contains
|
|
310
|
-
* @
|
|
308
|
+
* @memberof me.Bounds
|
|
311
309
|
* @function
|
|
312
310
|
* @param {number} x
|
|
313
311
|
* @param {number} y
|
|
@@ -341,7 +339,7 @@ class Bounds {
|
|
|
341
339
|
/**
|
|
342
340
|
* Returns true if the two bounds intersect.
|
|
343
341
|
* @name overlaps
|
|
344
|
-
* @
|
|
342
|
+
* @memberof me.Bounds
|
|
345
343
|
* @function
|
|
346
344
|
* @param {me.Bounds|me.Rect} bounds
|
|
347
345
|
* @returns {boolean} True if the bounds overlap, otherwise false
|
|
@@ -354,7 +352,7 @@ class Bounds {
|
|
|
354
352
|
/**
|
|
355
353
|
* determines whether all coordinates of this bounds are finite numbers.
|
|
356
354
|
* @name isFinite
|
|
357
|
-
* @
|
|
355
|
+
* @memberof me.Bounds
|
|
358
356
|
* @function
|
|
359
357
|
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
360
358
|
*/
|
|
@@ -365,14 +363,14 @@ class Bounds {
|
|
|
365
363
|
/**
|
|
366
364
|
* Translates the bounds by the given vector.
|
|
367
365
|
* @name translate
|
|
368
|
-
* @
|
|
366
|
+
* @memberof me.Bounds
|
|
369
367
|
* @function
|
|
370
368
|
* @param {me.Vector2d} vector
|
|
371
369
|
*/
|
|
372
370
|
/**
|
|
373
371
|
* Translates the bounds by x on the x axis, and y on the y axis
|
|
374
372
|
* @name translate
|
|
375
|
-
* @
|
|
373
|
+
* @memberof me.Bounds
|
|
376
374
|
* @function
|
|
377
375
|
* @param {number} x
|
|
378
376
|
* @param {number} y
|
|
@@ -397,14 +395,14 @@ class Bounds {
|
|
|
397
395
|
/**
|
|
398
396
|
* Shifts the bounds to the given position vector.
|
|
399
397
|
* @name shift
|
|
400
|
-
* @
|
|
398
|
+
* @memberof me.Bounds
|
|
401
399
|
* @function
|
|
402
400
|
* @param {me.Vector2d} position
|
|
403
401
|
*/
|
|
404
402
|
/**
|
|
405
403
|
* Shifts the bounds to the given x, y position.
|
|
406
404
|
* @name shift
|
|
407
|
-
* @
|
|
405
|
+
* @memberof me.Bounds
|
|
408
406
|
* @function
|
|
409
407
|
* @param {number} x
|
|
410
408
|
* @param {number} y
|
|
@@ -434,7 +432,7 @@ class Bounds {
|
|
|
434
432
|
/**
|
|
435
433
|
* clone this bounds
|
|
436
434
|
* @name clone
|
|
437
|
-
* @
|
|
435
|
+
* @memberof me.Bounds
|
|
438
436
|
* @function
|
|
439
437
|
* @returns {me.Bounds}
|
|
440
438
|
*/
|
|
@@ -447,7 +445,7 @@ class Bounds {
|
|
|
447
445
|
/**
|
|
448
446
|
* Returns a polygon whose edges are the same as this bounds.
|
|
449
447
|
* @name toPolygon
|
|
450
|
-
* @
|
|
448
|
+
* @memberof me.Bounds
|
|
451
449
|
* @function
|
|
452
450
|
* @returns {me.Polygon} a new Polygon that represents this bounds.
|
|
453
451
|
*/
|
package/src/physics/collision.js
CHANGED
|
@@ -4,7 +4,7 @@ import { rayCast, globalResponse } from "./detector.js";
|
|
|
4
4
|
* Collision detection (and projection-based collision response) of 2D shapes.<br>
|
|
5
5
|
* Based on the Separating Axis Theorem and supports detecting collisions between simple Axis-Aligned Boxes, convex polygons and circles based shapes.
|
|
6
6
|
* @namespace collision
|
|
7
|
-
* @
|
|
7
|
+
* @memberof me
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var collision = {
|
|
@@ -12,7 +12,7 @@ var collision = {
|
|
|
12
12
|
/**
|
|
13
13
|
* The maximum number of children that a quadtree node can contain before it is split into sub-nodes.
|
|
14
14
|
* @name maxChildren
|
|
15
|
-
* @
|
|
15
|
+
* @memberof me.collision
|
|
16
16
|
* @public
|
|
17
17
|
* @type {number}
|
|
18
18
|
* @default 8
|
|
@@ -23,7 +23,7 @@ var collision = {
|
|
|
23
23
|
/**
|
|
24
24
|
* The maximum number of levels that the quadtree will create.
|
|
25
25
|
* @name maxDepth
|
|
26
|
-
* @
|
|
26
|
+
* @memberof me.collision
|
|
27
27
|
* @public
|
|
28
28
|
* @type {number}
|
|
29
29
|
* @default 4
|
|
@@ -46,7 +46,7 @@ var collision = {
|
|
|
46
46
|
* @readonly
|
|
47
47
|
* @enum {number}
|
|
48
48
|
* @name types
|
|
49
|
-
* @
|
|
49
|
+
* @memberof me.collision
|
|
50
50
|
* @see me.body.setCollisionMask
|
|
51
51
|
* @see me.body.collisionType
|
|
52
52
|
* @example
|
|
@@ -97,7 +97,7 @@ var collision = {
|
|
|
97
97
|
* a global instance of a response object used for collision detection <br>
|
|
98
98
|
* this object will be reused amongst collision detection call if not user-defined response is specified
|
|
99
99
|
* @name response
|
|
100
|
-
* @
|
|
100
|
+
* @memberof me.collision
|
|
101
101
|
* @public
|
|
102
102
|
* @type {me.collision.ResponseObject}
|
|
103
103
|
*/
|
|
@@ -106,7 +106,7 @@ var collision = {
|
|
|
106
106
|
/**
|
|
107
107
|
* Checks for object colliding with the given line
|
|
108
108
|
* @name rayCast
|
|
109
|
-
* @
|
|
109
|
+
* @memberof me.collision
|
|
110
110
|
* @public
|
|
111
111
|
* @function
|
|
112
112
|
* @param {me.Line} line line to be tested for collision
|
package/src/physics/detector.js
CHANGED
|
@@ -17,7 +17,7 @@ var dummyObj = {
|
|
|
17
17
|
* a function used to determine if two objects should collide (based on both respective objects collision mask and type).<br>
|
|
18
18
|
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
19
19
|
* @name shouldCollide
|
|
20
|
-
* @
|
|
20
|
+
* @memberof me.collision
|
|
21
21
|
* @ignore
|
|
22
22
|
* @function
|
|
23
23
|
* @param {me.Renderable} a a reference to the object A.
|
|
@@ -46,7 +46,7 @@ function shouldCollide(a, b) {
|
|
|
46
46
|
* @property {number} indexShapeA The index of the colliding shape for the object a body
|
|
47
47
|
* @property {number} indexShapeB The index of the colliding shape for the object b body
|
|
48
48
|
* @name ResponseObject
|
|
49
|
-
* @
|
|
49
|
+
* @memberof me.collision
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
52
|
class ResponseObject {
|
|
@@ -68,7 +68,7 @@ class ResponseObject {
|
|
|
68
68
|
* Response object for multiple intersection tests <br>
|
|
69
69
|
* (recommended as it will avoid allocating extra memory) <br>
|
|
70
70
|
* @name clear
|
|
71
|
-
* @
|
|
71
|
+
* @memberof me.collision.ResponseObject
|
|
72
72
|
* @public
|
|
73
73
|
* @function
|
|
74
74
|
* @returns {object} this object for chaining
|