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
|
@@ -5,9 +5,8 @@ import pool from "./../system/pooling.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* an ellipse Object
|
|
7
7
|
* @class Ellipse
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @constructor
|
|
8
|
+
* @augments me.Object
|
|
9
|
+
* @memberof me
|
|
11
10
|
* @param {number} x the center x coordinate of the ellipse
|
|
12
11
|
* @param {number} y the center y coordinate of the ellipse
|
|
13
12
|
* @param {number} w width (diameter) of the ellipse
|
|
@@ -22,7 +21,7 @@ class Ellipse {
|
|
|
22
21
|
* @public
|
|
23
22
|
* @type {me.Vector2d}
|
|
24
23
|
* @name pos
|
|
25
|
-
* @
|
|
24
|
+
* @memberof me.Ellipse#
|
|
26
25
|
*/
|
|
27
26
|
this.pos = new Vector2d();
|
|
28
27
|
|
|
@@ -31,7 +30,7 @@ class Ellipse {
|
|
|
31
30
|
* @private
|
|
32
31
|
* @type {me.Bounds}
|
|
33
32
|
* @name _bounds
|
|
34
|
-
* @
|
|
33
|
+
* @memberof me.Ellipse#
|
|
35
34
|
*/
|
|
36
35
|
this._bounds = undefined;
|
|
37
36
|
|
|
@@ -40,7 +39,7 @@ class Ellipse {
|
|
|
40
39
|
* @public
|
|
41
40
|
* @type {number}
|
|
42
41
|
* @name radius
|
|
43
|
-
* @
|
|
42
|
+
* @memberof me.Ellipse
|
|
44
43
|
*/
|
|
45
44
|
this.radius = NaN;
|
|
46
45
|
|
|
@@ -49,7 +48,7 @@ class Ellipse {
|
|
|
49
48
|
* @public
|
|
50
49
|
* @type {me.Vector2d}
|
|
51
50
|
* @name radiusV
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.Ellipse#
|
|
53
52
|
*/
|
|
54
53
|
this.radiusV = new Vector2d();
|
|
55
54
|
|
|
@@ -58,7 +57,7 @@ class Ellipse {
|
|
|
58
57
|
* @public
|
|
59
58
|
* @type {me.Vector2d}
|
|
60
59
|
* @name radiusSq
|
|
61
|
-
* @
|
|
60
|
+
* @memberof me.Ellipse#
|
|
62
61
|
*/
|
|
63
62
|
this.radiusSq = new Vector2d();
|
|
64
63
|
|
|
@@ -67,7 +66,7 @@ class Ellipse {
|
|
|
67
66
|
* @public
|
|
68
67
|
* @type {me.Vector2d}
|
|
69
68
|
* @name ratio
|
|
70
|
-
* @
|
|
69
|
+
* @memberof me.Ellipse#
|
|
71
70
|
*/
|
|
72
71
|
this.ratio = new Vector2d();
|
|
73
72
|
|
|
@@ -84,7 +83,7 @@ class Ellipse {
|
|
|
84
83
|
/**
|
|
85
84
|
* set new value to the Ellipse shape
|
|
86
85
|
* @name setShape
|
|
87
|
-
* @
|
|
86
|
+
* @memberof me.Ellipse.prototype
|
|
88
87
|
* @function
|
|
89
88
|
* @param {number} x the center x coordinate of the ellipse
|
|
90
89
|
* @param {number} y the center y coordinate of the ellipse
|
|
@@ -114,7 +113,7 @@ class Ellipse {
|
|
|
114
113
|
/**
|
|
115
114
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
116
115
|
* @name rotate
|
|
117
|
-
* @
|
|
116
|
+
* @memberof me.Ellipse.prototype
|
|
118
117
|
* @function
|
|
119
118
|
* @param {number} angle The angle to rotate (in radians)
|
|
120
119
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
|
|
@@ -131,7 +130,7 @@ class Ellipse {
|
|
|
131
130
|
/**
|
|
132
131
|
* Scale this Ellipse by the specified scalar.
|
|
133
132
|
* @name scale
|
|
134
|
-
* @
|
|
133
|
+
* @memberof me.Ellipse.prototype
|
|
135
134
|
* @function
|
|
136
135
|
* @param {number} x
|
|
137
136
|
* @param {number} [y=x]
|
|
@@ -150,7 +149,7 @@ class Ellipse {
|
|
|
150
149
|
/**
|
|
151
150
|
* Scale this Ellipse by the specified vector.
|
|
152
151
|
* @name scale
|
|
153
|
-
* @
|
|
152
|
+
* @memberof me.Ellipse.prototype
|
|
154
153
|
* @function
|
|
155
154
|
* @param {me.Vector2d} v
|
|
156
155
|
* @returns {me.Ellipse} Reference to this object for method chaining
|
|
@@ -162,7 +161,7 @@ class Ellipse {
|
|
|
162
161
|
/**
|
|
163
162
|
* apply the given transformation matrix to this ellipse
|
|
164
163
|
* @name transform
|
|
165
|
-
* @
|
|
164
|
+
* @memberof me.Ellipse.prototype
|
|
166
165
|
* @function
|
|
167
166
|
* @param {me.Matrix2d} matrix the transformation matrix
|
|
168
167
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
@@ -175,7 +174,7 @@ class Ellipse {
|
|
|
175
174
|
/**
|
|
176
175
|
* translate the circle/ellipse by the specified offset
|
|
177
176
|
* @name translate
|
|
178
|
-
* @
|
|
177
|
+
* @memberof me.Ellipse.prototype
|
|
179
178
|
* @function
|
|
180
179
|
* @param {number} x x offset
|
|
181
180
|
* @param {number} y y offset
|
|
@@ -184,7 +183,7 @@ class Ellipse {
|
|
|
184
183
|
/**
|
|
185
184
|
* translate the circle/ellipse by the specified vector
|
|
186
185
|
* @name translate
|
|
187
|
-
* @
|
|
186
|
+
* @memberof me.Ellipse.prototype
|
|
188
187
|
* @function
|
|
189
188
|
* @param {me.Vector2d} v vector offset
|
|
190
189
|
* @returns {me.Ellipse} this ellipse
|
|
@@ -212,7 +211,7 @@ class Ellipse {
|
|
|
212
211
|
/**
|
|
213
212
|
* check if this circle/ellipse contains the specified point
|
|
214
213
|
* @name contains
|
|
215
|
-
* @
|
|
214
|
+
* @memberof me.Ellipse.prototype
|
|
216
215
|
* @function
|
|
217
216
|
* @param {me.Vector2d} point
|
|
218
217
|
* @returns {boolean} true if contains
|
|
@@ -221,7 +220,7 @@ class Ellipse {
|
|
|
221
220
|
/**
|
|
222
221
|
* check if this circle/ellipse contains the specified point
|
|
223
222
|
* @name contains
|
|
224
|
-
* @
|
|
223
|
+
* @memberof me.Ellipse.prototype
|
|
225
224
|
* @function
|
|
226
225
|
* @param {number} x x coordinate
|
|
227
226
|
* @param {number} y y coordinate
|
|
@@ -253,7 +252,7 @@ class Ellipse {
|
|
|
253
252
|
/**
|
|
254
253
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
255
254
|
* @name getBounds
|
|
256
|
-
* @
|
|
255
|
+
* @memberof me.Ellipse.prototype
|
|
257
256
|
* @function
|
|
258
257
|
* @returns {me.Bounds} this shape bounding box Rectangle object
|
|
259
258
|
*/
|
|
@@ -267,7 +266,7 @@ class Ellipse {
|
|
|
267
266
|
/**
|
|
268
267
|
* clone this Ellipse
|
|
269
268
|
* @name clone
|
|
270
|
-
* @
|
|
269
|
+
* @memberof me.Ellipse.prototype
|
|
271
270
|
* @function
|
|
272
271
|
* @returns {me.Ellipse} new Ellipse
|
|
273
272
|
*/
|
|
@@ -5,9 +5,8 @@ import Polygon from "./poly.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a line segment Object
|
|
7
7
|
* @class Line
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @constructor
|
|
8
|
+
* @augments me.Polygon
|
|
9
|
+
* @memberof me
|
|
11
10
|
* @param {number} x origin point of the Line
|
|
12
11
|
* @param {number} y origin point of the Line
|
|
13
12
|
* @param {me.Vector2d[]} points array of vectors defining the Line
|
|
@@ -18,7 +17,7 @@ class Line extends Polygon {
|
|
|
18
17
|
/**
|
|
19
18
|
* Returns true if the Line contains the given point
|
|
20
19
|
* @name contains
|
|
21
|
-
* @
|
|
20
|
+
* @memberof me.Line.prototype
|
|
22
21
|
* @function
|
|
23
22
|
* @param {me.Vector2d} point
|
|
24
23
|
* @returns {boolean} true if contains
|
|
@@ -27,7 +26,7 @@ class Line extends Polygon {
|
|
|
27
26
|
/**
|
|
28
27
|
* Returns true if the Line contains the given point
|
|
29
28
|
* @name contains
|
|
30
|
-
* @
|
|
29
|
+
* @memberof me.Line.prototype
|
|
31
30
|
* @function
|
|
32
31
|
* @param {number} x x coordinate
|
|
33
32
|
* @param {number} y y coordinate
|
|
@@ -61,7 +60,7 @@ class Line extends Polygon {
|
|
|
61
60
|
* Computes the calculated collision edges and normals.
|
|
62
61
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
63
62
|
* @name recalc
|
|
64
|
-
* @
|
|
63
|
+
* @memberof me.Line.prototype
|
|
65
64
|
* @function
|
|
66
65
|
* @returns {me.Line} this instance for objecf chaining
|
|
67
66
|
*/
|
|
@@ -97,7 +96,7 @@ class Line extends Polygon {
|
|
|
97
96
|
/**
|
|
98
97
|
* clone this line segment
|
|
99
98
|
* @name clone
|
|
100
|
-
* @
|
|
99
|
+
* @memberof me.Line.prototype
|
|
101
100
|
* @function
|
|
102
101
|
* @returns {me.Line} new Line
|
|
103
102
|
*/
|
|
@@ -11,8 +11,7 @@ import pool from "./../system/pooling.js";
|
|
|
11
11
|
* <center><img src="images/convex_polygon.png"/></center><br>
|
|
12
12
|
* A polygon's `winding` is clockwise iff its vertices (points) are declared turning to the right. The image above shows COUNTERCLOCKWISE winding.
|
|
13
13
|
* @class Polygon
|
|
14
|
-
* @
|
|
15
|
-
* @constructor
|
|
14
|
+
* @memberof me
|
|
16
15
|
* @param {number} x origin point of the Polygon
|
|
17
16
|
* @param {number} y origin point of the Polygon
|
|
18
17
|
* @param {me.Vector2d[]} points array of vector defining the Polygon
|
|
@@ -35,7 +34,7 @@ class Polygon {
|
|
|
35
34
|
* @ignore
|
|
36
35
|
* @type {me.Bounds}
|
|
37
36
|
* @name _bounds
|
|
38
|
-
* @
|
|
37
|
+
* @memberof me.Polygon#
|
|
39
38
|
*/
|
|
40
39
|
this._bounds;
|
|
41
40
|
|
|
@@ -45,7 +44,7 @@ class Polygon {
|
|
|
45
44
|
* @public
|
|
46
45
|
* @type {me.Vector2d[]}
|
|
47
46
|
* @name points
|
|
48
|
-
* @
|
|
47
|
+
* @memberof me.Polygon#
|
|
49
48
|
*/
|
|
50
49
|
this.points = [];
|
|
51
50
|
|
|
@@ -84,7 +83,7 @@ class Polygon {
|
|
|
84
83
|
/**
|
|
85
84
|
* set new value to the Polygon
|
|
86
85
|
* @name setShape
|
|
87
|
-
* @
|
|
86
|
+
* @memberof me.Polygon.prototype
|
|
88
87
|
* @function
|
|
89
88
|
* @param {number} x position of the Polygon
|
|
90
89
|
* @param {number} y position of the Polygon
|
|
@@ -100,7 +99,7 @@ class Polygon {
|
|
|
100
99
|
/**
|
|
101
100
|
* set the vertices defining this Polygon
|
|
102
101
|
* @name setVertices
|
|
103
|
-
* @
|
|
102
|
+
* @memberof me.Polygon.prototype
|
|
104
103
|
* @function
|
|
105
104
|
* @param {me.Vector2d[]} vertices array of vector or vertice defining the Polygon
|
|
106
105
|
* @returns {me.Polygon} this instance for objecf chaining
|
|
@@ -140,7 +139,7 @@ class Polygon {
|
|
|
140
139
|
/**
|
|
141
140
|
* apply the given transformation matrix to this Polygon
|
|
142
141
|
* @name transform
|
|
143
|
-
* @
|
|
142
|
+
* @memberof me.Polygon.prototype
|
|
144
143
|
* @function
|
|
145
144
|
* @param {me.Matrix2d} m the transformation matrix
|
|
146
145
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
@@ -159,7 +158,7 @@ class Polygon {
|
|
|
159
158
|
/**
|
|
160
159
|
* apply an isometric projection to this shape
|
|
161
160
|
* @name toIso
|
|
162
|
-
* @
|
|
161
|
+
* @memberof me.Polygon.prototype
|
|
163
162
|
* @function
|
|
164
163
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
165
164
|
*/
|
|
@@ -170,7 +169,7 @@ class Polygon {
|
|
|
170
169
|
/**
|
|
171
170
|
* apply a 2d projection to this shape
|
|
172
171
|
* @name to2d
|
|
173
|
-
* @
|
|
172
|
+
* @memberof me.Polygon.prototype
|
|
174
173
|
* @function
|
|
175
174
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
176
175
|
*/
|
|
@@ -181,7 +180,7 @@ class Polygon {
|
|
|
181
180
|
/**
|
|
182
181
|
* Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
|
|
183
182
|
* @name rotate
|
|
184
|
-
* @
|
|
183
|
+
* @memberof me.Polygon.prototype
|
|
185
184
|
* @function
|
|
186
185
|
* @param {number} angle The angle to rotate (in radians)
|
|
187
186
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
|
|
@@ -203,7 +202,7 @@ class Polygon {
|
|
|
203
202
|
/**
|
|
204
203
|
* Scale this Polygon by the given scalar.
|
|
205
204
|
* @name scale
|
|
206
|
-
* @
|
|
205
|
+
* @memberof me.Polygon.prototype
|
|
207
206
|
* @function
|
|
208
207
|
* @param {number} x
|
|
209
208
|
* @param {number} [y=x]
|
|
@@ -225,7 +224,7 @@ class Polygon {
|
|
|
225
224
|
/**
|
|
226
225
|
* Scale this Polygon by the given vector
|
|
227
226
|
* @name scaleV
|
|
228
|
-
* @
|
|
227
|
+
* @memberof me.Polygon.prototype
|
|
229
228
|
* @function
|
|
230
229
|
* @param {me.Vector2d} v
|
|
231
230
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
@@ -238,7 +237,7 @@ class Polygon {
|
|
|
238
237
|
* Computes the calculated collision polygon.
|
|
239
238
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
240
239
|
* @name recalc
|
|
241
|
-
* @
|
|
240
|
+
* @memberof me.Polygon.prototype
|
|
242
241
|
* @function
|
|
243
242
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
244
243
|
*/
|
|
@@ -278,10 +277,11 @@ class Polygon {
|
|
|
278
277
|
return this;
|
|
279
278
|
}
|
|
280
279
|
|
|
280
|
+
|
|
281
281
|
/**
|
|
282
282
|
* returns a list of indices for all triangles defined in this polygon
|
|
283
283
|
* @name getIndices
|
|
284
|
-
* @
|
|
284
|
+
* @memberof me.Polygon.prototype
|
|
285
285
|
* @function
|
|
286
286
|
* @returns {Array} an array of vertex indices for all triangles forming this polygon.
|
|
287
287
|
*/
|
|
@@ -292,10 +292,57 @@ class Polygon {
|
|
|
292
292
|
return this.indices;
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
|
|
297
|
+
* @name isConvex
|
|
298
|
+
* @memberof me.Polygon.prototype
|
|
299
|
+
* @function
|
|
300
|
+
* @returns {boolean} true if the vertices are convex, false if not, null if not computable
|
|
301
|
+
*/
|
|
302
|
+
isConvex() {
|
|
303
|
+
// http://paulbourke.net/geometry/polygonmesh/
|
|
304
|
+
// Copyright (c) Paul Bourke (use permitted)
|
|
305
|
+
|
|
306
|
+
var flag = 0,
|
|
307
|
+
vertices = this.points,
|
|
308
|
+
n = vertices.length,
|
|
309
|
+
i,
|
|
310
|
+
j,
|
|
311
|
+
k,
|
|
312
|
+
z;
|
|
313
|
+
|
|
314
|
+
if (n < 3) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
for (i = 0; i < n; i++) {
|
|
319
|
+
j = (i + 1) % n;
|
|
320
|
+
k = (i + 2) % n;
|
|
321
|
+
z = (vertices[j].x - vertices[i].x) * (vertices[k].y - vertices[j].y);
|
|
322
|
+
z -= (vertices[j].y - vertices[i].y) * (vertices[k].x - vertices[j].x);
|
|
323
|
+
|
|
324
|
+
if (z < 0) {
|
|
325
|
+
flag |= 1;
|
|
326
|
+
} else if (z > 0) {
|
|
327
|
+
flag |= 2;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (flag === 3) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (flag !== 0) {
|
|
336
|
+
return true;
|
|
337
|
+
} else {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
295
342
|
/**
|
|
296
343
|
* translate the Polygon by the specified offset
|
|
297
344
|
* @name translate
|
|
298
|
-
* @
|
|
345
|
+
* @memberof me.Polygon.prototype
|
|
299
346
|
* @function
|
|
300
347
|
* @param {number} x x offset
|
|
301
348
|
* @param {number} y y offset
|
|
@@ -304,7 +351,7 @@ class Polygon {
|
|
|
304
351
|
/**
|
|
305
352
|
* translate the Polygon by the specified vector
|
|
306
353
|
* @name translate
|
|
307
|
-
* @
|
|
354
|
+
* @memberof me.Polygon.prototype
|
|
308
355
|
* @function
|
|
309
356
|
* @param {me.Vector2d} v vector offset
|
|
310
357
|
* @returns {me.Polygon} Reference to this object for method chaining
|
|
@@ -332,14 +379,14 @@ class Polygon {
|
|
|
332
379
|
/**
|
|
333
380
|
* Shifts the Polygon to the given position vector.
|
|
334
381
|
* @name shift
|
|
335
|
-
* @
|
|
382
|
+
* @memberof me.Polygon
|
|
336
383
|
* @function
|
|
337
384
|
* @param {me.Vector2d} position
|
|
338
385
|
*/
|
|
339
386
|
/**
|
|
340
387
|
* Shifts the Polygon to the given x, y position.
|
|
341
388
|
* @name shift
|
|
342
|
-
* @
|
|
389
|
+
* @memberof me.Polygon
|
|
343
390
|
* @function
|
|
344
391
|
* @param {number} x
|
|
345
392
|
* @param {number} y
|
|
@@ -365,7 +412,7 @@ class Polygon {
|
|
|
365
412
|
* (Note: it is highly recommended to first do a hit test on the corresponding <br>
|
|
366
413
|
* bounding rect, as the function can be highly consuming with complex shapes)
|
|
367
414
|
* @name contains
|
|
368
|
-
* @
|
|
415
|
+
* @memberof me.Polygon.prototype
|
|
369
416
|
* @function
|
|
370
417
|
* @param {me.Vector2d} point
|
|
371
418
|
* @returns {boolean} true if contains
|
|
@@ -376,7 +423,7 @@ class Polygon {
|
|
|
376
423
|
* (Note: it is highly recommended to first do a hit test on the corresponding <br>
|
|
377
424
|
* bounding rect, as the function can be highly consuming with complex shapes)
|
|
378
425
|
* @name contains
|
|
379
|
-
* @
|
|
426
|
+
* @memberof me.Polygon.prototype
|
|
380
427
|
* @function
|
|
381
428
|
* @param {number} x x coordinate
|
|
382
429
|
* @param {number} y y coordinate
|
|
@@ -414,7 +461,7 @@ class Polygon {
|
|
|
414
461
|
/**
|
|
415
462
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
416
463
|
* @name getBounds
|
|
417
|
-
* @
|
|
464
|
+
* @memberof me.Polygon.prototype
|
|
418
465
|
* @function
|
|
419
466
|
* @returns {me.Bounds} this shape bounding box Rectangle object
|
|
420
467
|
*/
|
|
@@ -429,7 +476,7 @@ class Polygon {
|
|
|
429
476
|
* update the bounding box for this shape.
|
|
430
477
|
* @ignore
|
|
431
478
|
* @name updateBounds
|
|
432
|
-
* @
|
|
479
|
+
* @memberof me.Polygon.prototype
|
|
433
480
|
* @function
|
|
434
481
|
* @returns {me.Bounds} this shape bounding box Rectangle object
|
|
435
482
|
*/
|
|
@@ -445,7 +492,7 @@ class Polygon {
|
|
|
445
492
|
/**
|
|
446
493
|
* clone this Polygon
|
|
447
494
|
* @name clone
|
|
448
|
-
* @
|
|
495
|
+
* @memberof me.Polygon.prototype
|
|
449
496
|
* @function
|
|
450
497
|
* @returns {me.Polygon} new Polygon
|
|
451
498
|
*/
|
|
@@ -5,9 +5,8 @@ import Polygon from "./poly.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a rectangle Object
|
|
7
7
|
* @class Rect
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @constructor
|
|
8
|
+
* @augments me.Polygon
|
|
9
|
+
* @memberof me
|
|
11
10
|
* @param {number} x position of the Rectangle
|
|
12
11
|
* @param {number} y position of the Rectangle
|
|
13
12
|
* @param {number} w width of the rectangle
|
|
@@ -35,7 +34,7 @@ class Rect extends Polygon {
|
|
|
35
34
|
/**
|
|
36
35
|
* set new value to the rectangle shape
|
|
37
36
|
* @name setShape
|
|
38
|
-
* @
|
|
37
|
+
* @memberof me.Rect.prototype
|
|
39
38
|
* @function
|
|
40
39
|
* @param {number} x position of the Rectangle
|
|
41
40
|
* @param {number} y position of the Rectangle
|
|
@@ -66,7 +65,7 @@ class Rect extends Polygon {
|
|
|
66
65
|
* @public
|
|
67
66
|
* @type {number}
|
|
68
67
|
* @name left
|
|
69
|
-
* @
|
|
68
|
+
* @memberof me.Rect
|
|
70
69
|
*/
|
|
71
70
|
get left() {
|
|
72
71
|
return this.pos.x;
|
|
@@ -77,7 +76,7 @@ class Rect extends Polygon {
|
|
|
77
76
|
* @public
|
|
78
77
|
* @type {number}
|
|
79
78
|
* @name right
|
|
80
|
-
* @
|
|
79
|
+
* @memberof me.Rect
|
|
81
80
|
*/
|
|
82
81
|
get right() {
|
|
83
82
|
var w = this.width;
|
|
@@ -89,7 +88,7 @@ class Rect extends Polygon {
|
|
|
89
88
|
* @public
|
|
90
89
|
* @type {number}
|
|
91
90
|
* @name top
|
|
92
|
-
* @
|
|
91
|
+
* @memberof me.Rect
|
|
93
92
|
*/
|
|
94
93
|
get top() {
|
|
95
94
|
return this.pos.y;
|
|
@@ -100,7 +99,7 @@ class Rect extends Polygon {
|
|
|
100
99
|
* @public
|
|
101
100
|
* @type {number}
|
|
102
101
|
* @name bottom
|
|
103
|
-
* @
|
|
102
|
+
* @memberof me.Rect
|
|
104
103
|
*/
|
|
105
104
|
get bottom() {
|
|
106
105
|
var h = this.height;
|
|
@@ -112,7 +111,7 @@ class Rect extends Polygon {
|
|
|
112
111
|
* @public
|
|
113
112
|
* @type {number}
|
|
114
113
|
* @name width
|
|
115
|
-
* @
|
|
114
|
+
* @memberof me.Rect
|
|
116
115
|
*/
|
|
117
116
|
get width() {
|
|
118
117
|
return this.points[2].x;
|
|
@@ -128,7 +127,7 @@ class Rect extends Polygon {
|
|
|
128
127
|
* @public
|
|
129
128
|
* @type {number}
|
|
130
129
|
* @name height
|
|
131
|
-
* @
|
|
130
|
+
* @memberof me.Rect
|
|
132
131
|
*/
|
|
133
132
|
get height() {
|
|
134
133
|
return this.points[2].y;
|
|
@@ -144,7 +143,7 @@ class Rect extends Polygon {
|
|
|
144
143
|
* @public
|
|
145
144
|
* @type {number}
|
|
146
145
|
* @name centerX
|
|
147
|
-
* @
|
|
146
|
+
* @memberof me.Rect
|
|
148
147
|
*/
|
|
149
148
|
get centerX() {
|
|
150
149
|
if (isFinite(this.width)) {
|
|
@@ -162,7 +161,7 @@ class Rect extends Polygon {
|
|
|
162
161
|
* @public
|
|
163
162
|
* @type {number}
|
|
164
163
|
* @name centerY
|
|
165
|
-
* @
|
|
164
|
+
* @memberof me.Rect
|
|
166
165
|
*/
|
|
167
166
|
get centerY() {
|
|
168
167
|
if (isFinite(this.height)) {
|
|
@@ -178,7 +177,7 @@ class Rect extends Polygon {
|
|
|
178
177
|
/**
|
|
179
178
|
* resize the rectangle
|
|
180
179
|
* @name resize
|
|
181
|
-
* @
|
|
180
|
+
* @memberof me.Rect.prototype
|
|
182
181
|
* @function
|
|
183
182
|
* @param {number} w new width of the rectangle
|
|
184
183
|
* @param {number} h new height of the rectangle
|
|
@@ -193,7 +192,7 @@ class Rect extends Polygon {
|
|
|
193
192
|
/**
|
|
194
193
|
* scale the rectangle
|
|
195
194
|
* @name scale
|
|
196
|
-
* @
|
|
195
|
+
* @memberof me.Rect.prototype
|
|
197
196
|
* @function
|
|
198
197
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
199
198
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
@@ -208,7 +207,7 @@ class Rect extends Polygon {
|
|
|
208
207
|
/**
|
|
209
208
|
* clone this rectangle
|
|
210
209
|
* @name clone
|
|
211
|
-
* @
|
|
210
|
+
* @memberof me.Rect.prototype
|
|
212
211
|
* @function
|
|
213
212
|
* @returns {me.Rect} new rectangle
|
|
214
213
|
*/
|
|
@@ -219,7 +218,7 @@ class Rect extends Polygon {
|
|
|
219
218
|
/**
|
|
220
219
|
* copy the position and size of the given rectangle into this one
|
|
221
220
|
* @name copy
|
|
222
|
-
* @
|
|
221
|
+
* @memberof me.Rect.prototype
|
|
223
222
|
* @function
|
|
224
223
|
* @param {me.Rect} rect Source rectangle
|
|
225
224
|
* @returns {me.Rect} new rectangle
|
|
@@ -231,7 +230,7 @@ class Rect extends Polygon {
|
|
|
231
230
|
/**
|
|
232
231
|
* merge this rectangle with another one
|
|
233
232
|
* @name union
|
|
234
|
-
* @
|
|
233
|
+
* @memberof me.Rect.prototype
|
|
235
234
|
* @function
|
|
236
235
|
* @param {me.Rect} rect other rectangle to union with
|
|
237
236
|
* @returns {me.Rect} the union(ed) rectangle
|
|
@@ -253,7 +252,7 @@ class Rect extends Polygon {
|
|
|
253
252
|
/**
|
|
254
253
|
* check if this rectangle is intersecting with the specified one
|
|
255
254
|
* @name overlaps
|
|
256
|
-
* @
|
|
255
|
+
* @memberof me.Rect.prototype
|
|
257
256
|
* @function
|
|
258
257
|
* @param {me.Rect} rect
|
|
259
258
|
* @returns {boolean} true if overlaps
|
|
@@ -270,7 +269,7 @@ class Rect extends Polygon {
|
|
|
270
269
|
/**
|
|
271
270
|
* Returns true if the rectangle contains the given rectangle
|
|
272
271
|
* @name contains
|
|
273
|
-
* @
|
|
272
|
+
* @memberof me.Rect.prototype
|
|
274
273
|
* @function
|
|
275
274
|
* @param {me.Rect} rect
|
|
276
275
|
* @returns {boolean} true if contains
|
|
@@ -279,7 +278,7 @@ class Rect extends Polygon {
|
|
|
279
278
|
/**
|
|
280
279
|
* Returns true if the rectangle contains the given point
|
|
281
280
|
* @name contains
|
|
282
|
-
* @
|
|
281
|
+
* @memberof me.Rect.prototype
|
|
283
282
|
* @function
|
|
284
283
|
* @param {number} x x coordinate
|
|
285
284
|
* @param {number} y y coordinate
|
|
@@ -289,7 +288,7 @@ class Rect extends Polygon {
|
|
|
289
288
|
/**
|
|
290
289
|
* Returns true if the rectangle contains the given point
|
|
291
290
|
* @name contains
|
|
292
|
-
* @
|
|
291
|
+
* @memberof me.Rect
|
|
293
292
|
* @function
|
|
294
293
|
* @param {me.Vector2d} point
|
|
295
294
|
* @returns {boolean} true if contains
|
|
@@ -325,7 +324,7 @@ class Rect extends Polygon {
|
|
|
325
324
|
/**
|
|
326
325
|
* check if this rectangle is identical to the specified one
|
|
327
326
|
* @name equals
|
|
328
|
-
* @
|
|
327
|
+
* @memberof me.Rect.prototype
|
|
329
328
|
* @function
|
|
330
329
|
* @param {me.Rect} rect
|
|
331
330
|
* @returns {boolean} true if equals
|
|
@@ -342,7 +341,7 @@ class Rect extends Polygon {
|
|
|
342
341
|
/**
|
|
343
342
|
* determines whether all coordinates of this rectangle are finite numbers.
|
|
344
343
|
* @name isFinite
|
|
345
|
-
* @
|
|
344
|
+
* @memberof me.Rect.prototype
|
|
346
345
|
* @function
|
|
347
346
|
* @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
348
347
|
*/
|
|
@@ -353,7 +352,7 @@ class Rect extends Polygon {
|
|
|
353
352
|
/**
|
|
354
353
|
* Returns a polygon whose edges are the same as this box.
|
|
355
354
|
* @name toPolygon
|
|
356
|
-
* @
|
|
355
|
+
* @memberof me.Rect.prototype
|
|
357
356
|
* @function
|
|
358
357
|
* @returns {me.Polygon} a new Polygon that represents this rectangle.
|
|
359
358
|
*/
|
package/src/index.js
CHANGED
|
@@ -28,10 +28,10 @@ import ObservableVector2d from "./math/observable_vector2.js";
|
|
|
28
28
|
import ObservableVector3d from "./math/observable_vector3.js";
|
|
29
29
|
import Matrix2d from "./math/matrix2.js";
|
|
30
30
|
import Matrix3d from "./math/matrix3.js";
|
|
31
|
-
import Polygon from "./
|
|
32
|
-
import Line from "./
|
|
33
|
-
import Ellipse from "./
|
|
34
|
-
import Rect from "./
|
|
31
|
+
import Polygon from "./geometries/poly.js";
|
|
32
|
+
import Line from "./geometries/line.js";
|
|
33
|
+
import Ellipse from "./geometries/ellipse.js";
|
|
34
|
+
import Rect from "./geometries/rectangle.js";
|
|
35
35
|
import QuadTree from "./physics/quadtree.js";
|
|
36
36
|
import Body from "./physics/body.js";
|
|
37
37
|
import Bounds from "./physics/bounds.js";
|
|
@@ -173,8 +173,7 @@ export {
|
|
|
173
173
|
DroptargetEntity
|
|
174
174
|
};
|
|
175
175
|
|
|
176
|
-
// Backward compatibility for deprecated method or properties
|
|
177
|
-
// automatically applied when generating the UMD module through rollup
|
|
176
|
+
// Backward compatibility for deprecated method or properties
|
|
178
177
|
export {
|
|
179
178
|
deprecated
|
|
180
179
|
};
|
|
@@ -185,7 +184,7 @@ export {
|
|
|
185
184
|
* @type {boolean}
|
|
186
185
|
* @default false
|
|
187
186
|
* @readonly
|
|
188
|
-
* @
|
|
187
|
+
* @memberof me
|
|
189
188
|
*/
|
|
190
189
|
export var initialized = false;
|
|
191
190
|
|
|
@@ -194,7 +193,7 @@ export var initialized = false;
|
|
|
194
193
|
* @type {boolean}
|
|
195
194
|
* @default false
|
|
196
195
|
* @see me.boot
|
|
197
|
-
* @
|
|
196
|
+
* @memberof me
|
|
198
197
|
*/
|
|
199
198
|
export var skipAutoInit = false;
|
|
200
199
|
|
|
@@ -203,7 +202,7 @@ export var skipAutoInit = false;
|
|
|
203
202
|
* this is automatically called unless me.skipAutoInit is set to true,
|
|
204
203
|
* to allow asynchronous loaders to work.
|
|
205
204
|
* @name boot
|
|
206
|
-
* @
|
|
205
|
+
* @memberof me
|
|
207
206
|
* @see me.skipAutoInit
|
|
208
207
|
* @public
|
|
209
208
|
* @function
|