melonjs 10.0.0 → 10.0.1
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 +64 -68
- package/dist/melonjs.min.js +2 -2
- package/dist/melonjs.module.d.ts +47 -7
- package/dist/melonjs.module.js +66 -70
- package/package.json +3 -3
- package/src/physics/collision.js +2 -57
- package/src/physics/detector.js +61 -13
package/dist/melonjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.0.
|
|
2
|
+
* melonJS Game Engine - v10.0.1
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -14680,11 +14680,61 @@
|
|
|
14680
14680
|
(a.body.collisionType & b.body.collisionMask) !== 0
|
|
14681
14681
|
);
|
|
14682
14682
|
}
|
|
14683
|
+
/**
|
|
14684
|
+
* @classdesc
|
|
14685
|
+
* An object representing the result of an intersection.
|
|
14686
|
+
* @property {me.Renderable} a The first object participating in the intersection
|
|
14687
|
+
* @property {me.Renderable} b The second object participating in the intersection
|
|
14688
|
+
* @property {Number} overlap Magnitude of the overlap on the shortest colliding axis
|
|
14689
|
+
* @property {me.Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
|
|
14690
|
+
* @property {me.Vector2d} overlapN The shortest colliding axis (unit-vector)
|
|
14691
|
+
* @property {Boolean} aInB Whether the first object is entirely inside the second
|
|
14692
|
+
* @property {Boolean} bInA Whether the second object is entirely inside the first
|
|
14693
|
+
* @property {Number} indexShapeA The index of the colliding shape for the object a body
|
|
14694
|
+
* @property {Number} indexShapeB The index of the colliding shape for the object b body
|
|
14695
|
+
* @name ResponseObject
|
|
14696
|
+
* @memberOf me.collision
|
|
14697
|
+
* @public
|
|
14698
|
+
* @see me.collision.check
|
|
14699
|
+
*/
|
|
14700
|
+
var ResponseObject = function ResponseObject() {
|
|
14701
|
+
this.a = null;
|
|
14702
|
+
this.b = null;
|
|
14703
|
+
this.overlapN = new Vector2d();
|
|
14704
|
+
this.overlapV = new Vector2d();
|
|
14705
|
+
this.aInB = true;
|
|
14706
|
+
this.bInA = true;
|
|
14707
|
+
this.indexShapeA = -1;
|
|
14708
|
+
this.indexShapeB = -1;
|
|
14709
|
+
this.overlap = Number.MAX_VALUE;
|
|
14710
|
+
return this;
|
|
14711
|
+
};
|
|
14712
|
+
|
|
14713
|
+
/**
|
|
14714
|
+
* Set some values of the response back to their defaults. <br>
|
|
14715
|
+
* Call this between tests if you are going to reuse a single <br>
|
|
14716
|
+
* Response object for multiple intersection tests <br>
|
|
14717
|
+
* (recommended as it will avoid allocating extra memory) <br>
|
|
14718
|
+
* @name clear
|
|
14719
|
+
* @memberOf me.collision.ResponseObject
|
|
14720
|
+
* @public
|
|
14721
|
+
* @function
|
|
14722
|
+
*/
|
|
14723
|
+
ResponseObject.prototype.clear = function clear () {
|
|
14724
|
+
this.aInB = true;
|
|
14725
|
+
this.bInA = true;
|
|
14726
|
+
this.overlap = Number.MAX_VALUE;
|
|
14727
|
+
this.indexShapeA = -1;
|
|
14728
|
+
this.indexShapeB = -1;
|
|
14729
|
+
return this;
|
|
14730
|
+
};
|
|
14731
|
+
|
|
14732
|
+
// @ignore
|
|
14733
|
+
var globalResponse = new ResponseObject();
|
|
14683
14734
|
|
|
14684
14735
|
/**
|
|
14685
14736
|
* find all the collisions for the specified object
|
|
14686
14737
|
* @name collisionCheck
|
|
14687
|
-
* @memberOf me.collision
|
|
14688
14738
|
* @ignore
|
|
14689
14739
|
* @function
|
|
14690
14740
|
* @param {me.Renderable} obj object to be tested for collision
|
|
@@ -14692,10 +14742,9 @@
|
|
|
14692
14742
|
* @return {Boolean} in case of collision, false otherwise
|
|
14693
14743
|
*/
|
|
14694
14744
|
function collisionCheck(objA, response) {
|
|
14695
|
-
if ( response === void 0 ) response =
|
|
14696
|
-
|
|
14697
|
-
var collision = 0;
|
|
14745
|
+
if ( response === void 0 ) response = globalResponse;
|
|
14698
14746
|
|
|
14747
|
+
var collisionCounter = 0;
|
|
14699
14748
|
// retreive a list of potential colliding objects from the game world
|
|
14700
14749
|
var candidates = world.broadphase.retrieve(objA);
|
|
14701
14750
|
|
|
@@ -14733,7 +14782,7 @@
|
|
|
14733
14782
|
response.clear()) === true
|
|
14734
14783
|
) {
|
|
14735
14784
|
// we touched something !
|
|
14736
|
-
|
|
14785
|
+
collisionCounter++;
|
|
14737
14786
|
|
|
14738
14787
|
// set the shape index
|
|
14739
14788
|
response.indexShapeA = indexA;
|
|
@@ -14754,12 +14803,11 @@
|
|
|
14754
14803
|
}
|
|
14755
14804
|
}
|
|
14756
14805
|
// we could return the amount of objects we collided with ?
|
|
14757
|
-
return
|
|
14806
|
+
return collisionCounter > 0;
|
|
14758
14807
|
}
|
|
14759
14808
|
/**
|
|
14760
14809
|
* Checks for object colliding with the given line
|
|
14761
14810
|
* @name rayCast
|
|
14762
|
-
* @memberOf me.collision
|
|
14763
14811
|
* @ignore
|
|
14764
14812
|
* @function
|
|
14765
14813
|
* @param {me.Line} line line to be tested for collision
|
|
@@ -14786,7 +14834,7 @@
|
|
|
14786
14834
|
function rayCast(line, result) {
|
|
14787
14835
|
if ( result === void 0 ) result = [];
|
|
14788
14836
|
|
|
14789
|
-
var
|
|
14837
|
+
var collisionCounter = 0;
|
|
14790
14838
|
|
|
14791
14839
|
// retrieve a list of potential colliding objects from the game world
|
|
14792
14840
|
var candidates = world.broadphase.retrieve(line);
|
|
@@ -14819,8 +14867,8 @@
|
|
|
14819
14867
|
shapeB
|
|
14820
14868
|
)) {
|
|
14821
14869
|
// we touched something !
|
|
14822
|
-
result[
|
|
14823
|
-
|
|
14870
|
+
result[collisionCounter] = objB;
|
|
14871
|
+
collisionCounter++;
|
|
14824
14872
|
}
|
|
14825
14873
|
indexB++;
|
|
14826
14874
|
} while (indexB < bLen);
|
|
@@ -14828,7 +14876,7 @@
|
|
|
14828
14876
|
}
|
|
14829
14877
|
|
|
14830
14878
|
// cap result in case it was not empty
|
|
14831
|
-
result.length =
|
|
14879
|
+
result.length = collisionCounter;
|
|
14832
14880
|
|
|
14833
14881
|
// return the list of colliding objects
|
|
14834
14882
|
return result;
|
|
@@ -14841,56 +14889,6 @@
|
|
|
14841
14889
|
* @memberOf me
|
|
14842
14890
|
*/
|
|
14843
14891
|
|
|
14844
|
-
/**
|
|
14845
|
-
* @classdesc
|
|
14846
|
-
* An object representing the result of an intersection.
|
|
14847
|
-
* @property {me.Renderable} a The first object participating in the intersection
|
|
14848
|
-
* @property {me.Renderable} b The second object participating in the intersection
|
|
14849
|
-
* @property {Number} overlap Magnitude of the overlap on the shortest colliding axis
|
|
14850
|
-
* @property {me.Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
|
|
14851
|
-
* @property {me.Vector2d} overlapN The shortest colliding axis (unit-vector)
|
|
14852
|
-
* @property {Boolean} aInB Whether the first object is entirely inside the second
|
|
14853
|
-
* @property {Boolean} bInA Whether the second object is entirely inside the first
|
|
14854
|
-
* @property {Number} indexShapeA The index of the colliding shape for the object a body
|
|
14855
|
-
* @property {Number} indexShapeB The index of the colliding shape for the object b body
|
|
14856
|
-
* @name ResponseObject
|
|
14857
|
-
* @memberOf me.collision
|
|
14858
|
-
* @public
|
|
14859
|
-
* @see me.collision.check
|
|
14860
|
-
*/
|
|
14861
|
-
var ResponseObject = function ResponseObject() {
|
|
14862
|
-
this.a = null;
|
|
14863
|
-
this.b = null;
|
|
14864
|
-
this.overlapN = new Vector2d();
|
|
14865
|
-
this.overlapV = new Vector2d();
|
|
14866
|
-
this.aInB = true;
|
|
14867
|
-
this.bInA = true;
|
|
14868
|
-
this.indexShapeA = -1;
|
|
14869
|
-
this.indexShapeB = -1;
|
|
14870
|
-
this.overlap = Number.MAX_VALUE;
|
|
14871
|
-
return this;
|
|
14872
|
-
};
|
|
14873
|
-
|
|
14874
|
-
/**
|
|
14875
|
-
* Set some values of the response back to their defaults. <br>
|
|
14876
|
-
* Call this between tests if you are going to reuse a single <br>
|
|
14877
|
-
* Response object for multiple intersection tests <br>
|
|
14878
|
-
* (recommended as it will avoid allocating extra memory) <br>
|
|
14879
|
-
* @name clear
|
|
14880
|
-
* @memberOf me.collision.ResponseObject
|
|
14881
|
-
* @public
|
|
14882
|
-
* @function
|
|
14883
|
-
*/
|
|
14884
|
-
ResponseObject.prototype.clear = function clear () {
|
|
14885
|
-
this.aInB = true;
|
|
14886
|
-
this.bInA = true;
|
|
14887
|
-
this.overlap = Number.MAX_VALUE;
|
|
14888
|
-
this.indexShapeA = -1;
|
|
14889
|
-
this.indexShapeB = -1;
|
|
14890
|
-
return this;
|
|
14891
|
-
};
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
14892
|
var collision = {
|
|
14895
14893
|
|
|
14896
14894
|
/**
|
|
@@ -14986,8 +14984,7 @@
|
|
|
14986
14984
|
* @public
|
|
14987
14985
|
* @type {me.collision.ResponseObject}
|
|
14988
14986
|
*/
|
|
14989
|
-
response :
|
|
14990
|
-
|
|
14987
|
+
response : globalResponse,
|
|
14991
14988
|
|
|
14992
14989
|
/**
|
|
14993
14990
|
* Checks for object colliding with the given line
|
|
@@ -15017,7 +15014,6 @@
|
|
|
15017
15014
|
* }
|
|
15018
15015
|
*/
|
|
15019
15016
|
rayCast: function rayCast$1(line, resultArray) { return rayCast(line, resultArray); }
|
|
15020
|
-
|
|
15021
15017
|
};
|
|
15022
15018
|
|
|
15023
15019
|
/**
|
|
@@ -31685,10 +31681,10 @@
|
|
|
31685
31681
|
* this can be overridden by the plugin
|
|
31686
31682
|
* @public
|
|
31687
31683
|
* @type String
|
|
31688
|
-
* @default "10.0.
|
|
31684
|
+
* @default "10.0.1"
|
|
31689
31685
|
* @name me.plugin.Base#version
|
|
31690
31686
|
*/
|
|
31691
|
-
this.version = "10.0.
|
|
31687
|
+
this.version = "10.0.1";
|
|
31692
31688
|
};
|
|
31693
31689
|
|
|
31694
31690
|
/**
|
|
@@ -35949,7 +35945,7 @@
|
|
|
35949
35945
|
* @name version
|
|
35950
35946
|
* @type {string}
|
|
35951
35947
|
*/
|
|
35952
|
-
var version = "10.0.
|
|
35948
|
+
var version = "10.0.1";
|
|
35953
35949
|
|
|
35954
35950
|
|
|
35955
35951
|
/**
|