melonjs 10.0.2 → 10.2.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/README.md +7 -13
- package/dist/melonjs.js +1213 -828
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +581 -454
- package/dist/melonjs.module.js +1182 -823
- package/package.json +6 -6
- package/src/camera/camera2d.js +3 -3
- package/src/game.js +1 -1
- package/src/index.js +4 -0
- package/src/input/pointer.js +22 -21
- package/src/input/pointerevent.js +10 -12
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/loader/loader.js +2 -2
- package/src/loader/loadingscreen.js +40 -72
- package/src/math/color.js +22 -4
- package/src/physics/body.js +1 -7
- package/src/physics/bounds.js +2 -2
- package/src/physics/detector.js +0 -1
- package/src/physics/world.js +2 -1
- package/src/renderable/container.js +1 -0
- package/src/renderable/imagelayer.js +2 -0
- package/src/renderable/nineslicesprite.js +211 -0
- package/src/renderable/renderable.js +3 -3
- package/src/renderable/sprite.js +2 -2
- package/src/state/stage.js +2 -2
- package/src/state/state.js +2 -2
- package/src/system/device.js +15 -1
- package/src/text/text.js +82 -21
- package/src/video/renderer.js +5 -3
- package/src/video/texture.js +17 -7
- package/src/video/texture_cache.js +11 -0
- package/src/video/video.js +3 -3
- package/src/video/webgl/buffer/vertex.js +130 -0
- package/src/video/webgl/shaders/quad.vert +1 -1
- package/src/video/webgl/webgl_compositor.js +104 -167
- package/src/video/webgl/webgl_renderer.js +25 -20
package/dist/melonjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
2
|
+
* melonJS Game Engine - v10.2.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
|
|
@@ -1532,7 +1532,7 @@
|
|
|
1532
1532
|
};
|
|
1533
1533
|
|
|
1534
1534
|
/**
|
|
1535
|
-
* Color Red Component
|
|
1535
|
+
* Color Red Component [0 .. 255]
|
|
1536
1536
|
* @type Number
|
|
1537
1537
|
* @name r
|
|
1538
1538
|
* @readonly
|
|
@@ -1554,7 +1554,7 @@
|
|
|
1554
1554
|
|
|
1555
1555
|
|
|
1556
1556
|
/**
|
|
1557
|
-
* Color Green Component
|
|
1557
|
+
* Color Green Component [0 .. 255]
|
|
1558
1558
|
* @type Number
|
|
1559
1559
|
* @name g
|
|
1560
1560
|
* @readonly
|
|
@@ -1576,7 +1576,7 @@
|
|
|
1576
1576
|
|
|
1577
1577
|
|
|
1578
1578
|
/**
|
|
1579
|
-
* Color Blue Component
|
|
1579
|
+
* Color Blue Component [0 .. 255]
|
|
1580
1580
|
* @type Number
|
|
1581
1581
|
* @name b
|
|
1582
1582
|
* @readonly
|
|
@@ -1596,7 +1596,7 @@
|
|
|
1596
1596
|
};
|
|
1597
1597
|
|
|
1598
1598
|
/**
|
|
1599
|
-
* Color Alpha Component
|
|
1599
|
+
* Color Alpha Component [0.0 .. 1.0]
|
|
1600
1600
|
* @type Number
|
|
1601
1601
|
* @name alpha
|
|
1602
1602
|
* @readonly
|
|
@@ -1887,6 +1887,25 @@
|
|
|
1887
1887
|
);
|
|
1888
1888
|
};
|
|
1889
1889
|
|
|
1890
|
+
/**
|
|
1891
|
+
* Pack this color into a Uint32 ARGB representation
|
|
1892
|
+
* @name toUint32
|
|
1893
|
+
* @memberOf me.Color
|
|
1894
|
+
* @function
|
|
1895
|
+
* @param {Number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
1896
|
+
* @return {Uint32}
|
|
1897
|
+
*/
|
|
1898
|
+
Color.prototype.toUint32 = function toUint32 (alpha) {
|
|
1899
|
+
if ( alpha === void 0 ) alpha = this.alpha;
|
|
1900
|
+
|
|
1901
|
+
var ur = this.r & 0xff;
|
|
1902
|
+
var ug = this.g & 0xff;
|
|
1903
|
+
var ub = this.b & 0xff;
|
|
1904
|
+
var ua = (alpha * 255) & 0xff;
|
|
1905
|
+
|
|
1906
|
+
return (ua << 24) + (ur << 16) + (ug << 8) + ub;
|
|
1907
|
+
};
|
|
1908
|
+
|
|
1890
1909
|
/**
|
|
1891
1910
|
* return an array representation of this object
|
|
1892
1911
|
* @name toArray
|
|
@@ -1898,6 +1917,7 @@
|
|
|
1898
1917
|
return this.glArray;
|
|
1899
1918
|
};
|
|
1900
1919
|
|
|
1920
|
+
|
|
1901
1921
|
/**
|
|
1902
1922
|
* Get the color in "#RRGGBB" format
|
|
1903
1923
|
* @name toHex
|
|
@@ -10918,20 +10938,485 @@
|
|
|
10918
10938
|
}
|
|
10919
10939
|
|
|
10920
10940
|
/**
|
|
10921
|
-
*
|
|
10941
|
+
* @classdesc
|
|
10942
|
+
* a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
|
|
10943
|
+
* @class Bounds
|
|
10944
|
+
* @memberOf me
|
|
10945
|
+
* @constructor
|
|
10946
|
+
* @memberOf me
|
|
10947
|
+
* @param {me.Vector2d[]} [vertices] an array of me.Vector2d points
|
|
10948
|
+
* @return {me.Bounds} A new bounds object
|
|
10949
|
+
*/
|
|
10950
|
+
|
|
10951
|
+
var Bounds$1 = function Bounds(vertices) {
|
|
10952
|
+
this.onResetEvent(vertices);
|
|
10953
|
+
};
|
|
10954
|
+
|
|
10955
|
+
var prototypeAccessors$1 = { x: { configurable: true },y: { configurable: true },width: { configurable: true },height: { configurable: true },left: { configurable: true },right: { configurable: true },top: { configurable: true },bottom: { configurable: true },centerX: { configurable: true },centerY: { configurable: true },center: { configurable: true } };
|
|
10956
|
+
|
|
10957
|
+
Bounds$1.prototype.onResetEvent = function onResetEvent (vertices) {
|
|
10958
|
+
if (typeof this.min === "undefined") {
|
|
10959
|
+
this.min = { x: Infinity, y: Infinity };
|
|
10960
|
+
this.max = { x: -Infinity, y: -Infinity };
|
|
10961
|
+
} else {
|
|
10962
|
+
this.clear();
|
|
10963
|
+
}
|
|
10964
|
+
if (typeof vertices !== "undefined") {
|
|
10965
|
+
this.update(vertices);
|
|
10966
|
+
}
|
|
10967
|
+
|
|
10968
|
+
// @ignore
|
|
10969
|
+
this._center = new Vector2d();
|
|
10970
|
+
};
|
|
10971
|
+
|
|
10972
|
+
/**
|
|
10973
|
+
* reset the bound
|
|
10974
|
+
* @name clear
|
|
10975
|
+
* @memberOf me.Bounds
|
|
10976
|
+
* @function
|
|
10977
|
+
*/
|
|
10978
|
+
Bounds$1.prototype.clear = function clear () {
|
|
10979
|
+
this.setMinMax(Infinity, Infinity, -Infinity, -Infinity);
|
|
10980
|
+
|
|
10981
|
+
};
|
|
10982
|
+
|
|
10983
|
+
/**
|
|
10984
|
+
* sets the bounds to the given min and max value
|
|
10985
|
+
* @name setMinMax
|
|
10986
|
+
* @memberOf me.Bounds
|
|
10987
|
+
* @function
|
|
10988
|
+
* @param {Number} minX
|
|
10989
|
+
* @param {Number} minY
|
|
10990
|
+
* @param {Number} maxX
|
|
10991
|
+
* @param {Number} maxY
|
|
10992
|
+
*/
|
|
10993
|
+
Bounds$1.prototype.setMinMax = function setMinMax (minX, minY, maxX, maxY) {
|
|
10994
|
+
this.min.x = minX;
|
|
10995
|
+
this.min.y = minY;
|
|
10996
|
+
|
|
10997
|
+
this.max.x = maxX;
|
|
10998
|
+
this.max.y = maxY;
|
|
10999
|
+
};
|
|
11000
|
+
|
|
11001
|
+
/**
|
|
11002
|
+
* x position of the bound
|
|
11003
|
+
* @public
|
|
11004
|
+
* @type {Number}
|
|
11005
|
+
* @name x
|
|
11006
|
+
* @memberOf me.Bounds
|
|
11007
|
+
*/
|
|
11008
|
+
prototypeAccessors$1.x.get = function () {
|
|
11009
|
+
return this.min.x;
|
|
11010
|
+
};
|
|
11011
|
+
|
|
11012
|
+
prototypeAccessors$1.x.set = function (value) {
|
|
11013
|
+
var deltaX = this.max.x - this.min.x;
|
|
11014
|
+
this.min.x = value;
|
|
11015
|
+
this.max.x = value + deltaX;
|
|
11016
|
+
};
|
|
11017
|
+
|
|
11018
|
+
/**
|
|
11019
|
+
* y position of the bounds
|
|
11020
|
+
* @public
|
|
11021
|
+
* @type {Number}
|
|
11022
|
+
* @name y
|
|
11023
|
+
* @memberOf me.Bounds
|
|
11024
|
+
*/
|
|
11025
|
+
prototypeAccessors$1.y.get = function () {
|
|
11026
|
+
return this.min.y;
|
|
11027
|
+
};
|
|
11028
|
+
|
|
11029
|
+
prototypeAccessors$1.y.set = function (value) {
|
|
11030
|
+
var deltaY = this.max.y - this.min.y;
|
|
11031
|
+
|
|
11032
|
+
this.min.y = value;
|
|
11033
|
+
this.max.y = value + deltaY;
|
|
11034
|
+
};
|
|
11035
|
+
|
|
11036
|
+
/**
|
|
11037
|
+
* width of the bounds
|
|
11038
|
+
* @public
|
|
11039
|
+
* @type {Number}
|
|
11040
|
+
* @name width
|
|
11041
|
+
* @memberOf me.Bounds
|
|
11042
|
+
*/
|
|
11043
|
+
prototypeAccessors$1.width.get = function () {
|
|
11044
|
+
return this.max.x - this.min.x;
|
|
11045
|
+
};
|
|
11046
|
+
|
|
11047
|
+
prototypeAccessors$1.width.set = function (value) {
|
|
11048
|
+
this.max.x = this.min.x + value;
|
|
11049
|
+
};
|
|
11050
|
+
|
|
11051
|
+
/**
|
|
11052
|
+
* width of the bounds
|
|
11053
|
+
* @public
|
|
11054
|
+
* @type {Number}
|
|
11055
|
+
* @name width
|
|
11056
|
+
* @memberOf me.Bounds
|
|
11057
|
+
*/
|
|
11058
|
+
prototypeAccessors$1.height.get = function () {
|
|
11059
|
+
return this.max.y - this.min.y;
|
|
11060
|
+
};
|
|
11061
|
+
|
|
11062
|
+
prototypeAccessors$1.height.set = function (value) {
|
|
11063
|
+
this.max.y = this.min.y + value;
|
|
11064
|
+
};
|
|
11065
|
+
|
|
11066
|
+
/**
|
|
11067
|
+
* left coordinate of the bound
|
|
11068
|
+
* @public
|
|
11069
|
+
* @type {Number}
|
|
11070
|
+
* @name left
|
|
11071
|
+
* @memberOf me.Bounds
|
|
11072
|
+
*/
|
|
11073
|
+
prototypeAccessors$1.left.get = function () {
|
|
11074
|
+
return this.min.x;
|
|
11075
|
+
};
|
|
11076
|
+
|
|
11077
|
+
/**
|
|
11078
|
+
* right coordinate of the bound
|
|
11079
|
+
* @public
|
|
11080
|
+
* @type {Number}
|
|
11081
|
+
* @name right
|
|
11082
|
+
* @memberOf me.Bounds
|
|
11083
|
+
*/
|
|
11084
|
+
prototypeAccessors$1.right.get = function () {
|
|
11085
|
+
return this.max.x;
|
|
11086
|
+
};
|
|
11087
|
+
|
|
11088
|
+
/**
|
|
11089
|
+
* top coordinate of the bound
|
|
11090
|
+
* @public
|
|
11091
|
+
* @type {Number}
|
|
11092
|
+
* @name top
|
|
11093
|
+
* @memberOf me.Bounds
|
|
11094
|
+
*/
|
|
11095
|
+
prototypeAccessors$1.top.get = function () {
|
|
11096
|
+
return this.min.y;
|
|
11097
|
+
};
|
|
11098
|
+
|
|
11099
|
+
/**
|
|
11100
|
+
* bottom coordinate of the bound
|
|
11101
|
+
* @public
|
|
11102
|
+
* @type {Number}
|
|
11103
|
+
* @name bottom
|
|
11104
|
+
* @memberOf me.Bounds
|
|
11105
|
+
*/
|
|
11106
|
+
prototypeAccessors$1.bottom.get = function () {
|
|
11107
|
+
return this.max.y;
|
|
11108
|
+
};
|
|
11109
|
+
|
|
11110
|
+
/**
|
|
11111
|
+
* center position of the bound on the x axis
|
|
11112
|
+
* @public
|
|
11113
|
+
* @type {Number}
|
|
11114
|
+
* @name centerX
|
|
11115
|
+
* @memberOf me.Bounds
|
|
11116
|
+
*/
|
|
11117
|
+
prototypeAccessors$1.centerX.get = function () {
|
|
11118
|
+
return this.min.x + (this.width / 2);
|
|
11119
|
+
};
|
|
11120
|
+
|
|
11121
|
+
/**
|
|
11122
|
+
* center position of the bound on the y axis
|
|
11123
|
+
* @public
|
|
11124
|
+
* @type {Number}
|
|
11125
|
+
* @name centerY
|
|
11126
|
+
* @memberOf me.Bounds
|
|
11127
|
+
*/
|
|
11128
|
+
prototypeAccessors$1.centerY.get = function () {
|
|
11129
|
+
return this.min.y + (this.height / 2);
|
|
11130
|
+
};
|
|
11131
|
+
|
|
11132
|
+
/**
|
|
11133
|
+
* return the center position of the bound
|
|
11134
|
+
* @public
|
|
11135
|
+
* @type {me.Vector2d}
|
|
11136
|
+
* @name center
|
|
11137
|
+
* @memberOf me.Bounds
|
|
11138
|
+
*/
|
|
11139
|
+
prototypeAccessors$1.center.get = function () {
|
|
11140
|
+
return this._center.set(this.centerX, this.centerY);
|
|
11141
|
+
};
|
|
11142
|
+
|
|
11143
|
+
/**
|
|
11144
|
+
* Updates bounds using the given vertices
|
|
11145
|
+
* @name update
|
|
11146
|
+
* @memberOf me.Bounds
|
|
11147
|
+
* @function
|
|
11148
|
+
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
11149
|
+
*/
|
|
11150
|
+
Bounds$1.prototype.update = function update (vertices) {
|
|
11151
|
+
this.add(vertices, true);
|
|
11152
|
+
};
|
|
11153
|
+
|
|
11154
|
+
/**
|
|
11155
|
+
* add the given vertices to the bounds definition.
|
|
11156
|
+
* @name add
|
|
11157
|
+
* @memberOf me.Bounds
|
|
11158
|
+
* @function
|
|
11159
|
+
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
11160
|
+
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
11161
|
+
*/
|
|
11162
|
+
Bounds$1.prototype.add = function add (vertices, clear) {
|
|
11163
|
+
if ( clear === void 0 ) clear = false;
|
|
11164
|
+
|
|
11165
|
+
if (clear === true) {
|
|
11166
|
+
this.clear();
|
|
11167
|
+
}
|
|
11168
|
+
for (var i = 0; i < vertices.length; i++) {
|
|
11169
|
+
var vertex = vertices[i];
|
|
11170
|
+
if (vertex.x > this.max.x) { this.max.x = vertex.x; }
|
|
11171
|
+
if (vertex.x < this.min.x) { this.min.x = vertex.x; }
|
|
11172
|
+
if (vertex.y > this.max.y) { this.max.y = vertex.y; }
|
|
11173
|
+
if (vertex.y < this.min.y) { this.min.y = vertex.y; }
|
|
11174
|
+
}
|
|
11175
|
+
};
|
|
11176
|
+
|
|
11177
|
+
/**
|
|
11178
|
+
* add the given bounds to the bounds definition.
|
|
11179
|
+
* @name addBounds
|
|
11180
|
+
* @memberOf me.Bounds
|
|
11181
|
+
* @function
|
|
11182
|
+
* @param {me.Bounds} bounds
|
|
11183
|
+
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
11184
|
+
*/
|
|
11185
|
+
Bounds$1.prototype.addBounds = function addBounds (bounds, clear) {
|
|
11186
|
+
if ( clear === void 0 ) clear = false;
|
|
11187
|
+
|
|
11188
|
+
if (clear === true) {
|
|
11189
|
+
this.clear();
|
|
11190
|
+
}
|
|
11191
|
+
|
|
11192
|
+
if (bounds.max.x > this.max.x) { this.max.x = bounds.max.x; }
|
|
11193
|
+
if (bounds.min.x < this.min.x) { this.min.x = bounds.min.x; }
|
|
11194
|
+
if (bounds.max.y > this.max.y) { this.max.y = bounds.max.y; }
|
|
11195
|
+
if (bounds.min.y < this.min.y) { this.min.y = bounds.min.y; }
|
|
11196
|
+
};
|
|
11197
|
+
|
|
11198
|
+
/**
|
|
11199
|
+
* add the given point to the bounds definition.
|
|
11200
|
+
* @name addPoint
|
|
11201
|
+
* @memberOf me.Bounds
|
|
11202
|
+
* @function
|
|
11203
|
+
* @param {me.Vector2d} vector
|
|
11204
|
+
* @param {me.Matrix2d} [matrix] an optional transform to apply to the given point
|
|
11205
|
+
*/
|
|
11206
|
+
Bounds$1.prototype.addPoint = function addPoint (v, m) {
|
|
11207
|
+
if (typeof m !== "undefined") {
|
|
11208
|
+
v = m.apply(v);
|
|
11209
|
+
}
|
|
11210
|
+
this.min.x = Math.min(this.min.x, v.x);
|
|
11211
|
+
this.max.x = Math.max(this.max.x, v.x);
|
|
11212
|
+
this.min.y = Math.min(this.min.y, v.y);
|
|
11213
|
+
this.max.y = Math.max(this.max.y, v.y);
|
|
11214
|
+
};
|
|
11215
|
+
|
|
11216
|
+
/**
|
|
11217
|
+
* add the given quad coordinates to this bound definition, multiplied by the given matrix
|
|
11218
|
+
* @name addFrame
|
|
11219
|
+
* @memberOf me.Bounds
|
|
11220
|
+
* @function
|
|
11221
|
+
* @param {Number} x0 - left X coordinates of the quad
|
|
11222
|
+
* @param {Number} y0 - top Y coordinates of the quad
|
|
11223
|
+
* @param {Number} x1 - right X coordinates of the quad
|
|
11224
|
+
* @param {Number} y1 - bottom y coordinates of the quad
|
|
11225
|
+
* @param {me.Matrix2d} [matrix] an optional transform to apply to the given frame coordinates
|
|
11226
|
+
*/
|
|
11227
|
+
Bounds$1.prototype.addFrame = function addFrame (x0, y0, x1, y1, m) {
|
|
11228
|
+
var v = me.pool.pull("Vector2d");
|
|
11229
|
+
|
|
11230
|
+
// transform all points and add to the bound definition
|
|
11231
|
+
this.addPoint(v.set(x0, y0), m);
|
|
11232
|
+
this.addPoint(v.set(x1, y0), m);
|
|
11233
|
+
this.addPoint(v.set(x0, y1), m);
|
|
11234
|
+
this.addPoint(v.set(x1, y1), m);
|
|
11235
|
+
|
|
11236
|
+
me.pool.push(v);
|
|
11237
|
+
};
|
|
11238
|
+
|
|
11239
|
+
/**
|
|
11240
|
+
* Returns true if the bounds contains the given point.
|
|
11241
|
+
* @name contains
|
|
11242
|
+
* @memberOf me.Bounds
|
|
11243
|
+
* @function
|
|
11244
|
+
* @param {me.Vector2d} point
|
|
11245
|
+
* @return {boolean} True if the bounds contain the point, otherwise false
|
|
11246
|
+
*/
|
|
11247
|
+
/**
|
|
11248
|
+
* Returns true if the bounds contains the given point.
|
|
11249
|
+
* @name contains
|
|
11250
|
+
* @memberOf me.Bounds
|
|
11251
|
+
* @function
|
|
11252
|
+
* @param {Number} x
|
|
11253
|
+
* @param {Number} y
|
|
11254
|
+
* @return {boolean} True if the bounds contain the point, otherwise false
|
|
11255
|
+
*/
|
|
11256
|
+
Bounds$1.prototype.contains = function contains () {
|
|
11257
|
+
var arg0 = arguments[0];
|
|
11258
|
+
var _x1, _x2, _y1, _y2;
|
|
11259
|
+
if (arguments.length === 2) {
|
|
11260
|
+
// x, y
|
|
11261
|
+
_x1 = _x2 = arg0;
|
|
11262
|
+
_y1 = _y2 = arguments[1];
|
|
11263
|
+
} else {
|
|
11264
|
+
if (arg0 instanceof Bounds$1) {
|
|
11265
|
+
// bounds
|
|
11266
|
+
_x1 = arg0.min.x;
|
|
11267
|
+
_x2 = arg0.max.x;
|
|
11268
|
+
_y1 = arg0.min.y;
|
|
11269
|
+
_y2 = arg0.max.y;
|
|
11270
|
+
} else {
|
|
11271
|
+
// vector
|
|
11272
|
+
_x1 = _x2 = arg0.x;
|
|
11273
|
+
_y1 = _y2 = arg0.y;
|
|
11274
|
+
}
|
|
11275
|
+
}
|
|
11276
|
+
|
|
11277
|
+
return _x1 >= this.min.x && _x2 <= this.max.x
|
|
11278
|
+
&& _y1 >= this.min.y && _y2 <= this.max.y;
|
|
11279
|
+
};
|
|
11280
|
+
|
|
11281
|
+
/**
|
|
11282
|
+
* Returns true if the two bounds intersect.
|
|
11283
|
+
* @name overlaps
|
|
11284
|
+
* @memberOf me.Bounds
|
|
11285
|
+
* @function
|
|
11286
|
+
* @param {me.Bounds|me.Rect} bounds
|
|
11287
|
+
* @return {boolean} True if the bounds overlap, otherwise false
|
|
11288
|
+
*/
|
|
11289
|
+
Bounds$1.prototype.overlaps = function overlaps (bounds) {
|
|
11290
|
+
return !(this.right < bounds.left || this.left > bounds.right ||
|
|
11291
|
+
this.bottom < bounds.top || this.top > bounds.bottom);
|
|
11292
|
+
};
|
|
11293
|
+
|
|
11294
|
+
/**
|
|
11295
|
+
* determines whether all coordinates of this bounds are finite numbers.
|
|
11296
|
+
* @name isFinite
|
|
11297
|
+
* @memberOf me.Bounds
|
|
11298
|
+
* @function
|
|
11299
|
+
* @return {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
11300
|
+
*/
|
|
11301
|
+
Bounds$1.prototype.isFinite = function isFinite$1 () {
|
|
11302
|
+
return (isFinite(this.min.x) && isFinite(this.max.x) && isFinite(this.min.y) && isFinite(this.max.y));
|
|
11303
|
+
};
|
|
11304
|
+
|
|
11305
|
+
/**
|
|
11306
|
+
* Translates the bounds by the given vector.
|
|
11307
|
+
* @name translate
|
|
11308
|
+
* @memberOf me.Bounds
|
|
11309
|
+
* @function
|
|
11310
|
+
* @param {me.Vector2d} vector
|
|
11311
|
+
*/
|
|
11312
|
+
/**
|
|
11313
|
+
* Translates the bounds by x on the x axis, and y on the y axis
|
|
11314
|
+
* @name translate
|
|
11315
|
+
* @memberOf me.Bounds
|
|
11316
|
+
* @function
|
|
11317
|
+
* @param {Number} x
|
|
11318
|
+
* @param {Number} y
|
|
11319
|
+
*/
|
|
11320
|
+
Bounds$1.prototype.translate = function translate () {
|
|
11321
|
+
var _x, _y;
|
|
11322
|
+
if (arguments.length === 2) {
|
|
11323
|
+
// x, y
|
|
11324
|
+
_x = arguments[0];
|
|
11325
|
+
_y = arguments[1];
|
|
11326
|
+
} else {
|
|
11327
|
+
// vector
|
|
11328
|
+
_x = arguments[0].x;
|
|
11329
|
+
_y = arguments[0].y;
|
|
11330
|
+
}
|
|
11331
|
+
this.min.x += _x;
|
|
11332
|
+
this.max.x += _x;
|
|
11333
|
+
this.min.y += _y;
|
|
11334
|
+
this.max.y += _y;
|
|
11335
|
+
};
|
|
11336
|
+
|
|
11337
|
+
/**
|
|
11338
|
+
* Shifts the bounds to the given position vector.
|
|
11339
|
+
* @name shift
|
|
11340
|
+
* @memberOf me.Bounds
|
|
11341
|
+
* @function
|
|
11342
|
+
* @param {me.Vector2d} position
|
|
11343
|
+
*/
|
|
11344
|
+
/**
|
|
11345
|
+
* Shifts the bounds to the given x, y position.
|
|
11346
|
+
* @name shift
|
|
11347
|
+
* @memberOf me.Bounds
|
|
11348
|
+
* @function
|
|
11349
|
+
* @param {Number} x
|
|
11350
|
+
* @param {Number} y
|
|
11351
|
+
*/
|
|
11352
|
+
Bounds$1.prototype.shift = function shift () {
|
|
11353
|
+
var _x, _y;
|
|
11354
|
+
|
|
11355
|
+
if (arguments.length === 2) {
|
|
11356
|
+
// x, y
|
|
11357
|
+
_x = arguments[0];
|
|
11358
|
+
_y = arguments[1];
|
|
11359
|
+
} else {
|
|
11360
|
+
// vector
|
|
11361
|
+
_x = arguments[0].x;
|
|
11362
|
+
_y = arguments[0].y;
|
|
11363
|
+
}
|
|
11364
|
+
|
|
11365
|
+
var deltaX = this.max.x - this.min.x,
|
|
11366
|
+
deltaY = this.max.y - this.min.y;
|
|
11367
|
+
|
|
11368
|
+
this.min.x = _x;
|
|
11369
|
+
this.max.x = _x + deltaX;
|
|
11370
|
+
this.min.y = _y;
|
|
11371
|
+
this.max.y = _y + deltaY;
|
|
11372
|
+
};
|
|
11373
|
+
|
|
11374
|
+
/**
|
|
11375
|
+
* clone this bounds
|
|
11376
|
+
* @name clone
|
|
11377
|
+
* @memberOf me.Bounds
|
|
11378
|
+
* @function
|
|
11379
|
+
* @return {me.Bounds}
|
|
11380
|
+
*/
|
|
11381
|
+
Bounds$1.prototype.clone = function clone () {
|
|
11382
|
+
var bounds = new Bounds$1();
|
|
11383
|
+
bounds.addBounds(this);
|
|
11384
|
+
return bounds;
|
|
11385
|
+
};
|
|
11386
|
+
|
|
11387
|
+
/**
|
|
11388
|
+
* Returns a polygon whose edges are the same as this bounds.
|
|
11389
|
+
* @name toPolygon
|
|
11390
|
+
* @memberOf me.Bounds
|
|
11391
|
+
* @function
|
|
11392
|
+
* @return {me.Polygon} a new Polygon that represents this bounds.
|
|
11393
|
+
*/
|
|
11394
|
+
Bounds$1.prototype.toPolygon = function toPolygon () {
|
|
11395
|
+
return new Polygon(this.x, this.y, [
|
|
11396
|
+
new Vector2d(0, 0),
|
|
11397
|
+
new Vector2d(this.width, 0),
|
|
11398
|
+
new Vector2d(this.width, this.height),
|
|
11399
|
+
new Vector2d(0, this.height)
|
|
11400
|
+
]);
|
|
11401
|
+
};
|
|
11402
|
+
|
|
11403
|
+
Object.defineProperties( Bounds$1.prototype, prototypeAccessors$1 );
|
|
11404
|
+
|
|
11405
|
+
/**
|
|
11406
|
+
* a temporary vector object
|
|
10922
11407
|
* @ignore
|
|
10923
11408
|
*/
|
|
10924
|
-
var
|
|
11409
|
+
var tmpVec = new Vector2d();
|
|
10925
11410
|
|
|
10926
11411
|
/**
|
|
10927
11412
|
* @classdesc
|
|
10928
11413
|
* a pointer object, representing a single finger on a touch enabled device.
|
|
10929
11414
|
* @class
|
|
10930
|
-
* @extends me.
|
|
11415
|
+
* @extends me.Bounds
|
|
10931
11416
|
* @memberOf me
|
|
10932
11417
|
* @constructor
|
|
10933
11418
|
*/
|
|
10934
|
-
var Pointer = /*@__PURE__*/(function (
|
|
11419
|
+
var Pointer = /*@__PURE__*/(function (Bounds) {
|
|
10935
11420
|
function Pointer(x, y, w, h) {
|
|
10936
11421
|
if ( x === void 0 ) x = 0;
|
|
10937
11422
|
if ( y === void 0 ) y = 0;
|
|
@@ -10940,7 +11425,10 @@
|
|
|
10940
11425
|
|
|
10941
11426
|
|
|
10942
11427
|
// parent constructor
|
|
10943
|
-
|
|
11428
|
+
Bounds.call(this);
|
|
11429
|
+
|
|
11430
|
+
// initial coordinates/size
|
|
11431
|
+
this.setMinMax(x, y, x + w, y + h);
|
|
10944
11432
|
|
|
10945
11433
|
/**
|
|
10946
11434
|
* constant for left button
|
|
@@ -11180,8 +11668,8 @@
|
|
|
11180
11668
|
this.bind = [ 0, 0, 0 ];
|
|
11181
11669
|
}
|
|
11182
11670
|
|
|
11183
|
-
if (
|
|
11184
|
-
Pointer.prototype = Object.create(
|
|
11671
|
+
if ( Bounds ) Pointer.__proto__ = Bounds;
|
|
11672
|
+
Pointer.prototype = Object.create( Bounds && Bounds.prototype );
|
|
11185
11673
|
Pointer.prototype.constructor = Pointer;
|
|
11186
11674
|
|
|
11187
11675
|
/**
|
|
@@ -11203,9 +11691,6 @@
|
|
|
11203
11691
|
if ( clientY === void 0 ) clientY = 0;
|
|
11204
11692
|
if ( pointerId === void 0 ) pointerId = 1;
|
|
11205
11693
|
|
|
11206
|
-
var width = 1;
|
|
11207
|
-
var height = 1;
|
|
11208
|
-
|
|
11209
11694
|
// the original event object
|
|
11210
11695
|
this.event = event;
|
|
11211
11696
|
|
|
@@ -11215,7 +11700,9 @@
|
|
|
11215
11700
|
this.clientY = clientY;
|
|
11216
11701
|
|
|
11217
11702
|
// translate to local coordinates
|
|
11218
|
-
globalToLocal(this.pageX, this.pageY,
|
|
11703
|
+
globalToLocal(this.pageX, this.pageY, tmpVec);
|
|
11704
|
+
this.gameScreenX = this.x = tmpVec.x;
|
|
11705
|
+
this.gameScreenY = this.y = tmpVec.y;
|
|
11219
11706
|
|
|
11220
11707
|
// true if not originally a pointer event
|
|
11221
11708
|
this.isNormalized = !device$1.PointerEvent || (device$1.PointerEvent && !(event instanceof window.PointerEvent));
|
|
@@ -11241,34 +11728,33 @@
|
|
|
11241
11728
|
|
|
11242
11729
|
this.type = event.type;
|
|
11243
11730
|
|
|
11244
|
-
|
|
11245
|
-
this.gameScreenY = this.pos.y;
|
|
11731
|
+
|
|
11246
11732
|
|
|
11247
11733
|
// get the current screen to game world offset
|
|
11248
11734
|
if (typeof viewport !== "undefined") {
|
|
11249
|
-
viewport.localToWorld(this.gameScreenX, this.gameScreenY,
|
|
11735
|
+
viewport.localToWorld(this.gameScreenX, this.gameScreenY, tmpVec);
|
|
11250
11736
|
}
|
|
11251
11737
|
|
|
11252
11738
|
/* Initialize the two coordinate space properties. */
|
|
11253
|
-
this.gameWorldX =
|
|
11254
|
-
this.gameWorldY =
|
|
11739
|
+
this.gameWorldX = tmpVec.x;
|
|
11740
|
+
this.gameWorldY = tmpVec.y;
|
|
11255
11741
|
|
|
11256
11742
|
// get the pointer size
|
|
11257
11743
|
if (this.isNormalized === false) {
|
|
11258
11744
|
// native PointerEvent
|
|
11259
|
-
width = event.width || 1;
|
|
11260
|
-
height = event.height || 1;
|
|
11745
|
+
this.width = event.width || 1;
|
|
11746
|
+
this.height = event.height || 1;
|
|
11261
11747
|
} else if (typeof(event.radiusX) === "number") {
|
|
11262
11748
|
// TouchEvent
|
|
11263
|
-
width = (event.radiusX * 2) || 1;
|
|
11264
|
-
height = (event.radiusY * 2) || 1;
|
|
11749
|
+
this.width = (event.radiusX * 2) || 1;
|
|
11750
|
+
this.height = (event.radiusY * 2) || 1;
|
|
11751
|
+
} else {
|
|
11752
|
+
this.width = this.height = 1;
|
|
11265
11753
|
}
|
|
11266
|
-
// resize the pointer object accordingly
|
|
11267
|
-
this.resize(width, height);
|
|
11268
11754
|
};
|
|
11269
11755
|
|
|
11270
11756
|
return Pointer;
|
|
11271
|
-
}(
|
|
11757
|
+
}(Bounds$1));
|
|
11272
11758
|
|
|
11273
11759
|
/**
|
|
11274
11760
|
* A pool of `Pointer` objects to cache pointer/touch event coordinates.
|
|
@@ -11376,8 +11862,6 @@
|
|
|
11376
11862
|
// the current pointer area
|
|
11377
11863
|
currentPointer = new Rect(0, 0, 1, 1);
|
|
11378
11864
|
|
|
11379
|
-
pointer = new Pointer(0, 0, 1, 1);
|
|
11380
|
-
|
|
11381
11865
|
// instantiate a pool of pointer catched
|
|
11382
11866
|
for (var v = 0; v < device$1.maxTouchPoints; v++) {
|
|
11383
11867
|
T_POINTERS.push(new Pointer());
|
|
@@ -11667,15 +12151,15 @@
|
|
|
11667
12151
|
* @ignore
|
|
11668
12152
|
*/
|
|
11669
12153
|
function normalizeEvent(originalEvent) {
|
|
11670
|
-
var
|
|
12154
|
+
var _pointer;
|
|
11671
12155
|
|
|
11672
12156
|
// PointerEvent or standard Mouse event
|
|
11673
12157
|
if (device$1.TouchEvent && originalEvent.changedTouches) {
|
|
11674
12158
|
// iOS/Android Touch event
|
|
11675
12159
|
for (var i = 0, l = originalEvent.changedTouches.length; i < l; i++) {
|
|
11676
12160
|
var touchEvent = originalEvent.changedTouches[i];
|
|
11677
|
-
|
|
11678
|
-
|
|
12161
|
+
_pointer = T_POINTERS.pop();
|
|
12162
|
+
_pointer.setEvent(
|
|
11679
12163
|
originalEvent,
|
|
11680
12164
|
touchEvent.pageX,
|
|
11681
12165
|
touchEvent.pageY,
|
|
@@ -11683,12 +12167,12 @@
|
|
|
11683
12167
|
touchEvent.clientY,
|
|
11684
12168
|
touchEvent.identifier
|
|
11685
12169
|
);
|
|
11686
|
-
normalizedEvents.push(
|
|
12170
|
+
normalizedEvents.push(_pointer);
|
|
11687
12171
|
}
|
|
11688
12172
|
} else {
|
|
11689
12173
|
// Mouse or PointerEvent
|
|
11690
|
-
|
|
11691
|
-
|
|
12174
|
+
_pointer = T_POINTERS.pop();
|
|
12175
|
+
_pointer.setEvent(
|
|
11692
12176
|
originalEvent,
|
|
11693
12177
|
originalEvent.pageX,
|
|
11694
12178
|
originalEvent.pageY,
|
|
@@ -11696,7 +12180,7 @@
|
|
|
11696
12180
|
originalEvent.clientY,
|
|
11697
12181
|
originalEvent.pointerId
|
|
11698
12182
|
);
|
|
11699
|
-
normalizedEvents.push(
|
|
12183
|
+
normalizedEvents.push(_pointer);
|
|
11700
12184
|
}
|
|
11701
12185
|
|
|
11702
12186
|
// if event.isPrimary is defined and false, return
|
|
@@ -11768,7 +12252,7 @@
|
|
|
11768
12252
|
* @name pointer
|
|
11769
12253
|
* @memberOf me.input
|
|
11770
12254
|
*/
|
|
11771
|
-
var pointer;
|
|
12255
|
+
var pointer = new Pointer(0, 0, 1, 1);
|
|
11772
12256
|
|
|
11773
12257
|
/**
|
|
11774
12258
|
* time interval for event throttling in milliseconds<br>
|
|
@@ -11790,8 +12274,8 @@
|
|
|
11790
12274
|
* @function
|
|
11791
12275
|
* @param {Number} x the global x coordinate to be translated.
|
|
11792
12276
|
* @param {Number} y the global y coordinate to be translated.
|
|
11793
|
-
* @param {
|
|
11794
|
-
* @return {me.Vector2d} A vector object with the corresponding translated coordinates
|
|
12277
|
+
* @param {me.Vector2d} [v] an optional vector object where to set the translated coordinates
|
|
12278
|
+
* @return {me.Vector2d} A vector object with the corresponding translated coordinates
|
|
11795
12279
|
* @example
|
|
11796
12280
|
* onMouseEvent : function (pointer) {
|
|
11797
12281
|
* // convert the given into local (viewport) relative coordinates
|
|
@@ -12528,7 +13012,7 @@
|
|
|
12528
13012
|
__proto__: null,
|
|
12529
13013
|
preventDefault: preventDefault,
|
|
12530
13014
|
get pointerEventTarget () { return pointerEventTarget; },
|
|
12531
|
-
|
|
13015
|
+
pointer: pointer,
|
|
12532
13016
|
get throttlingInterval () { return throttlingInterval; },
|
|
12533
13017
|
globalToLocal: globalToLocal,
|
|
12534
13018
|
setTouchAction: setTouchAction,
|
|
@@ -12593,7 +13077,6 @@
|
|
|
12593
13077
|
* @public
|
|
12594
13078
|
* @type {me.Body}
|
|
12595
13079
|
* @see me.Body
|
|
12596
|
-
* @see me.collision#check
|
|
12597
13080
|
* @name body
|
|
12598
13081
|
* @memberOf me.Renderable#
|
|
12599
13082
|
* @example
|
|
@@ -12972,6 +13455,7 @@
|
|
|
12972
13455
|
if (isNaN(this.alpha)) {
|
|
12973
13456
|
this.alpha = 1.0;
|
|
12974
13457
|
}
|
|
13458
|
+
this.isDirty = true;
|
|
12975
13459
|
}
|
|
12976
13460
|
};
|
|
12977
13461
|
|
|
@@ -13293,8 +13777,8 @@
|
|
|
13293
13777
|
// offset by the anchor point
|
|
13294
13778
|
renderer.translate(-ax, -ay);
|
|
13295
13779
|
|
|
13296
|
-
// apply the
|
|
13297
|
-
renderer.setTint(this.tint);
|
|
13780
|
+
// apply the current tint and opacity
|
|
13781
|
+
renderer.setTint(this.tint, this.getOpacity());
|
|
13298
13782
|
};
|
|
13299
13783
|
|
|
13300
13784
|
/**
|
|
@@ -13705,471 +14189,6 @@
|
|
|
13705
14189
|
);
|
|
13706
14190
|
};
|
|
13707
14191
|
|
|
13708
|
-
/**
|
|
13709
|
-
* @classdesc
|
|
13710
|
-
* a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
|
|
13711
|
-
* @class Bounds
|
|
13712
|
-
* @memberOf me
|
|
13713
|
-
* @constructor
|
|
13714
|
-
* @memberOf me
|
|
13715
|
-
* @param {me.Vector2d[]} [vertices] an array of me.Vector2d points
|
|
13716
|
-
* @return {me.Bounds} A new bounds object
|
|
13717
|
-
*/
|
|
13718
|
-
|
|
13719
|
-
var Bounds$1 = function Bounds(vertices) {
|
|
13720
|
-
this.onResetEvent(vertices);
|
|
13721
|
-
};
|
|
13722
|
-
|
|
13723
|
-
var prototypeAccessors$1 = { x: { configurable: true },y: { configurable: true },width: { configurable: true },height: { configurable: true },left: { configurable: true },right: { configurable: true },top: { configurable: true },bottom: { configurable: true },centerX: { configurable: true },centerY: { configurable: true },center: { configurable: true } };
|
|
13724
|
-
|
|
13725
|
-
Bounds$1.prototype.onResetEvent = function onResetEvent (vertices) {
|
|
13726
|
-
if (typeof this.min === "undefined") {
|
|
13727
|
-
this.min = { x: Infinity, y: Infinity };
|
|
13728
|
-
this.max = { x: -Infinity, y: -Infinity };
|
|
13729
|
-
} else {
|
|
13730
|
-
this.clear();
|
|
13731
|
-
}
|
|
13732
|
-
if (typeof vertices !== "undefined") {
|
|
13733
|
-
this.update(vertices);
|
|
13734
|
-
}
|
|
13735
|
-
|
|
13736
|
-
// @ignore
|
|
13737
|
-
this._center = new Vector2d();
|
|
13738
|
-
};
|
|
13739
|
-
|
|
13740
|
-
/**
|
|
13741
|
-
* reset the bound
|
|
13742
|
-
* @name clear
|
|
13743
|
-
* @memberOf me.Bounds
|
|
13744
|
-
* @function
|
|
13745
|
-
*/
|
|
13746
|
-
Bounds$1.prototype.clear = function clear () {
|
|
13747
|
-
this.setMinMax(Infinity, Infinity, -Infinity, -Infinity);
|
|
13748
|
-
|
|
13749
|
-
};
|
|
13750
|
-
|
|
13751
|
-
/**
|
|
13752
|
-
* sets the bounds to the given min and max value
|
|
13753
|
-
* @name setMinMax
|
|
13754
|
-
* @memberOf me.Bounds
|
|
13755
|
-
* @function
|
|
13756
|
-
* @param {Number} minX
|
|
13757
|
-
* @param {Number} minY
|
|
13758
|
-
* @param {Number} maxX
|
|
13759
|
-
* @param {Number} maxY
|
|
13760
|
-
*/
|
|
13761
|
-
Bounds$1.prototype.setMinMax = function setMinMax (minX, minY, maxX, maxY) {
|
|
13762
|
-
this.min.x = minX;
|
|
13763
|
-
this.min.y = minY;
|
|
13764
|
-
|
|
13765
|
-
this.max.x = maxX;
|
|
13766
|
-
this.max.y = maxY;
|
|
13767
|
-
};
|
|
13768
|
-
|
|
13769
|
-
/**
|
|
13770
|
-
* x position of the bound
|
|
13771
|
-
* @public
|
|
13772
|
-
* @type {Number}
|
|
13773
|
-
* @name x
|
|
13774
|
-
* @memberOf me.Bounds
|
|
13775
|
-
*/
|
|
13776
|
-
prototypeAccessors$1.x.get = function () {
|
|
13777
|
-
return this.min.x;
|
|
13778
|
-
};
|
|
13779
|
-
|
|
13780
|
-
prototypeAccessors$1.x.set = function (value) {
|
|
13781
|
-
var deltaX = this.max.x - this.min.x;
|
|
13782
|
-
this.min.x = value;
|
|
13783
|
-
this.max.x = value + deltaX;
|
|
13784
|
-
};
|
|
13785
|
-
|
|
13786
|
-
/**
|
|
13787
|
-
* y position of the bounds
|
|
13788
|
-
* @public
|
|
13789
|
-
* @type {Number}
|
|
13790
|
-
* @name y
|
|
13791
|
-
* @memberOf me.Bounds
|
|
13792
|
-
*/
|
|
13793
|
-
prototypeAccessors$1.y.get = function () {
|
|
13794
|
-
return this.min.y;
|
|
13795
|
-
};
|
|
13796
|
-
|
|
13797
|
-
prototypeAccessors$1.y.set = function (value) {
|
|
13798
|
-
var deltaY = this.max.y - this.min.y;
|
|
13799
|
-
|
|
13800
|
-
this.min.y = value;
|
|
13801
|
-
this.max.y = value + deltaY;
|
|
13802
|
-
};
|
|
13803
|
-
|
|
13804
|
-
/**
|
|
13805
|
-
* width of the bounds
|
|
13806
|
-
* @public
|
|
13807
|
-
* @type {Number}
|
|
13808
|
-
* @name width
|
|
13809
|
-
* @memberOf me.Bounds
|
|
13810
|
-
*/
|
|
13811
|
-
prototypeAccessors$1.width.get = function () {
|
|
13812
|
-
return this.max.x - this.min.x;
|
|
13813
|
-
};
|
|
13814
|
-
|
|
13815
|
-
prototypeAccessors$1.width.set = function (value) {
|
|
13816
|
-
this.max.x = this.min.x + value;
|
|
13817
|
-
};
|
|
13818
|
-
|
|
13819
|
-
/**
|
|
13820
|
-
* width of the bounds
|
|
13821
|
-
* @public
|
|
13822
|
-
* @type {Number}
|
|
13823
|
-
* @name width
|
|
13824
|
-
* @memberOf me.Bounds
|
|
13825
|
-
*/
|
|
13826
|
-
prototypeAccessors$1.height.get = function () {
|
|
13827
|
-
return this.max.y - this.min.y;
|
|
13828
|
-
};
|
|
13829
|
-
|
|
13830
|
-
prototypeAccessors$1.height.set = function (value) {
|
|
13831
|
-
this.max.y = this.min.y + value;
|
|
13832
|
-
};
|
|
13833
|
-
|
|
13834
|
-
/**
|
|
13835
|
-
* left coordinate of the bound
|
|
13836
|
-
* @public
|
|
13837
|
-
* @type {Number}
|
|
13838
|
-
* @name left
|
|
13839
|
-
* @memberOf me.Bounds
|
|
13840
|
-
*/
|
|
13841
|
-
prototypeAccessors$1.left.get = function () {
|
|
13842
|
-
return this.min.x;
|
|
13843
|
-
};
|
|
13844
|
-
|
|
13845
|
-
/**
|
|
13846
|
-
* right coordinate of the bound
|
|
13847
|
-
* @public
|
|
13848
|
-
* @type {Number}
|
|
13849
|
-
* @name right
|
|
13850
|
-
* @memberOf me.Bounds
|
|
13851
|
-
*/
|
|
13852
|
-
prototypeAccessors$1.right.get = function () {
|
|
13853
|
-
return this.max.x;
|
|
13854
|
-
};
|
|
13855
|
-
|
|
13856
|
-
/**
|
|
13857
|
-
* top coordinate of the bound
|
|
13858
|
-
* @public
|
|
13859
|
-
* @type {Number}
|
|
13860
|
-
* @name top
|
|
13861
|
-
* @memberOf me.Bounds
|
|
13862
|
-
*/
|
|
13863
|
-
prototypeAccessors$1.top.get = function () {
|
|
13864
|
-
return this.min.y;
|
|
13865
|
-
};
|
|
13866
|
-
|
|
13867
|
-
/**
|
|
13868
|
-
* bottom coordinate of the bound
|
|
13869
|
-
* @public
|
|
13870
|
-
* @type {Number}
|
|
13871
|
-
* @name bottom
|
|
13872
|
-
* @memberOf me.Bounds
|
|
13873
|
-
*/
|
|
13874
|
-
prototypeAccessors$1.bottom.get = function () {
|
|
13875
|
-
return this.max.y;
|
|
13876
|
-
};
|
|
13877
|
-
|
|
13878
|
-
/**
|
|
13879
|
-
* center position of the bound on the x axis
|
|
13880
|
-
* @public
|
|
13881
|
-
* @type {Number}
|
|
13882
|
-
* @name centerX
|
|
13883
|
-
* @memberOf me.Bounds
|
|
13884
|
-
*/
|
|
13885
|
-
prototypeAccessors$1.centerX.get = function () {
|
|
13886
|
-
return this.min.x + (this.width / 2);
|
|
13887
|
-
};
|
|
13888
|
-
|
|
13889
|
-
/**
|
|
13890
|
-
* center position of the bound on the y axis
|
|
13891
|
-
* @public
|
|
13892
|
-
* @type {Number}
|
|
13893
|
-
* @name centerY
|
|
13894
|
-
* @memberOf me.Bounds
|
|
13895
|
-
*/
|
|
13896
|
-
prototypeAccessors$1.centerY.get = function () {
|
|
13897
|
-
return this.min.y + (this.height / 2);
|
|
13898
|
-
};
|
|
13899
|
-
|
|
13900
|
-
/**
|
|
13901
|
-
* return the center position of the bound
|
|
13902
|
-
* @public
|
|
13903
|
-
* @type {me.Vector2d}
|
|
13904
|
-
* @name center
|
|
13905
|
-
* @memberOf me.Bounds
|
|
13906
|
-
*/
|
|
13907
|
-
prototypeAccessors$1.center.get = function () {
|
|
13908
|
-
return this._center.set(this.centerX, this.centerY);
|
|
13909
|
-
};
|
|
13910
|
-
|
|
13911
|
-
/**
|
|
13912
|
-
* Updates bounds using the given vertices
|
|
13913
|
-
* @name update
|
|
13914
|
-
* @memberOf me.Bounds
|
|
13915
|
-
* @function
|
|
13916
|
-
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
13917
|
-
*/
|
|
13918
|
-
Bounds$1.prototype.update = function update (vertices) {
|
|
13919
|
-
this.add(vertices, true);
|
|
13920
|
-
};
|
|
13921
|
-
|
|
13922
|
-
/**
|
|
13923
|
-
* add the given vertices to the bounds definition.
|
|
13924
|
-
* @name add
|
|
13925
|
-
* @memberOf me.Bounds
|
|
13926
|
-
* @function
|
|
13927
|
-
* @param {me.Vector2d[]} vertices an array of me.Vector2d points
|
|
13928
|
-
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
13929
|
-
*/
|
|
13930
|
-
Bounds$1.prototype.add = function add (vertices, clear) {
|
|
13931
|
-
if ( clear === void 0 ) clear = false;
|
|
13932
|
-
|
|
13933
|
-
if (clear === true) {
|
|
13934
|
-
this.clear();
|
|
13935
|
-
}
|
|
13936
|
-
for (var i = 0; i < vertices.length; i++) {
|
|
13937
|
-
var vertex = vertices[i];
|
|
13938
|
-
if (vertex.x > this.max.x) { this.max.x = vertex.x; }
|
|
13939
|
-
if (vertex.x < this.min.x) { this.min.x = vertex.x; }
|
|
13940
|
-
if (vertex.y > this.max.y) { this.max.y = vertex.y; }
|
|
13941
|
-
if (vertex.y < this.min.y) { this.min.y = vertex.y; }
|
|
13942
|
-
}
|
|
13943
|
-
};
|
|
13944
|
-
|
|
13945
|
-
/**
|
|
13946
|
-
* add the given bounds to the bounds definition.
|
|
13947
|
-
* @name addBounds
|
|
13948
|
-
* @memberOf me.Bounds
|
|
13949
|
-
* @function
|
|
13950
|
-
* @param {me.Bounds} bounds
|
|
13951
|
-
* @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
|
|
13952
|
-
*/
|
|
13953
|
-
Bounds$1.prototype.addBounds = function addBounds (bounds, clear) {
|
|
13954
|
-
if ( clear === void 0 ) clear = false;
|
|
13955
|
-
|
|
13956
|
-
if (clear === true) {
|
|
13957
|
-
this.clear();
|
|
13958
|
-
}
|
|
13959
|
-
|
|
13960
|
-
if (bounds.max.x > this.max.x) { this.max.x = bounds.max.x; }
|
|
13961
|
-
if (bounds.min.x < this.min.x) { this.min.x = bounds.min.x; }
|
|
13962
|
-
if (bounds.max.y > this.max.y) { this.max.y = bounds.max.y; }
|
|
13963
|
-
if (bounds.min.y < this.min.y) { this.min.y = bounds.min.y; }
|
|
13964
|
-
};
|
|
13965
|
-
|
|
13966
|
-
/**
|
|
13967
|
-
* add the given point to the bounds definition.
|
|
13968
|
-
* @name addPoint
|
|
13969
|
-
* @memberOf me.Bounds
|
|
13970
|
-
* @function
|
|
13971
|
-
* @param {me.Vector2d} vector
|
|
13972
|
-
* @param {me.Matrix2d} [matrix] an optional transform to apply to the given point
|
|
13973
|
-
*/
|
|
13974
|
-
Bounds$1.prototype.addPoint = function addPoint (v, m) {
|
|
13975
|
-
if (typeof m !== "undefined") {
|
|
13976
|
-
v = m.apply(v);
|
|
13977
|
-
}
|
|
13978
|
-
this.min.x = Math.min(this.min.x, v.x);
|
|
13979
|
-
this.max.x = Math.max(this.max.x, v.x);
|
|
13980
|
-
this.min.y = Math.min(this.min.y, v.y);
|
|
13981
|
-
this.max.y = Math.max(this.max.y, v.y);
|
|
13982
|
-
};
|
|
13983
|
-
|
|
13984
|
-
/**
|
|
13985
|
-
* add the given quad coordinates to this bound definition, multiplied by the given matrix
|
|
13986
|
-
* @name addFrame
|
|
13987
|
-
* @memberOf me.Bounds
|
|
13988
|
-
* @function
|
|
13989
|
-
* @param {Number} x0 - left X coordinates of the quad
|
|
13990
|
-
* @param {Number} y0 - top Y coordinates of the quad
|
|
13991
|
-
* @param {Number} x1 - right X coordinates of the quad
|
|
13992
|
-
* @param {Number} y1 - bottom y coordinates of the quad
|
|
13993
|
-
* @param {me.Matrix2d} [matrix] an optional transform to apply to the given frame coordinates
|
|
13994
|
-
*/
|
|
13995
|
-
Bounds$1.prototype.addFrame = function addFrame (x0, y0, x1, y1, m) {
|
|
13996
|
-
var v = me.pool.pull("Vector2d");
|
|
13997
|
-
|
|
13998
|
-
// transform all points and add to the bound definition
|
|
13999
|
-
this.addPoint(v.set(x0, y0), m);
|
|
14000
|
-
this.addPoint(v.set(x1, y0), m);
|
|
14001
|
-
this.addPoint(v.set(x0, y1), m);
|
|
14002
|
-
this.addPoint(v.set(x1, y1), m);
|
|
14003
|
-
|
|
14004
|
-
me.pool.push(v);
|
|
14005
|
-
};
|
|
14006
|
-
|
|
14007
|
-
/**
|
|
14008
|
-
* Returns true if the bounds contains the given point.
|
|
14009
|
-
* @name contains
|
|
14010
|
-
* @memberOf me.Bounds
|
|
14011
|
-
* @function
|
|
14012
|
-
* @param {me.Vector2d} point
|
|
14013
|
-
* @return {boolean} True if the bounds contain the point, otherwise false
|
|
14014
|
-
*/
|
|
14015
|
-
/**
|
|
14016
|
-
* Returns true if the bounds contains the given point.
|
|
14017
|
-
* @name contains
|
|
14018
|
-
* @memberOf me.Bounds
|
|
14019
|
-
* @function
|
|
14020
|
-
* @param {Number} x
|
|
14021
|
-
* @param {Number} y
|
|
14022
|
-
* @return {boolean} True if the bounds contain the point, otherwise false
|
|
14023
|
-
*/
|
|
14024
|
-
Bounds$1.prototype.contains = function contains () {
|
|
14025
|
-
var arg0 = arguments[0];
|
|
14026
|
-
var _x1, _x2, _y1, _y2;
|
|
14027
|
-
if (arguments.length === 2) {
|
|
14028
|
-
// x, y
|
|
14029
|
-
_x1 = _x2 = arg0;
|
|
14030
|
-
_y1 = _y2 = arguments[1];
|
|
14031
|
-
} else {
|
|
14032
|
-
if (arg0 instanceof Bounds$1) {
|
|
14033
|
-
// bounds
|
|
14034
|
-
_x1 = arg0.min.x;
|
|
14035
|
-
_x2 = arg0.max.x;
|
|
14036
|
-
_y1 = arg0.min.y;
|
|
14037
|
-
_y2 = arg0.max.y;
|
|
14038
|
-
} else {
|
|
14039
|
-
// vector
|
|
14040
|
-
_x1 = _x2 = arg0.x;
|
|
14041
|
-
_y1 = _y2 = arg0.y;
|
|
14042
|
-
}
|
|
14043
|
-
}
|
|
14044
|
-
|
|
14045
|
-
return _x1 >= this.min.x && _x2 <= this.max.x
|
|
14046
|
-
&& _y1 >= this.min.y && _y2 <= this.max.y;
|
|
14047
|
-
};
|
|
14048
|
-
|
|
14049
|
-
/**
|
|
14050
|
-
* Returns true if the two bounds intersect.
|
|
14051
|
-
* @name overlaps
|
|
14052
|
-
* @memberOf me.Bounds
|
|
14053
|
-
* @function
|
|
14054
|
-
* @param {me.Bounds|me.Rect} bounds
|
|
14055
|
-
* @return {boolean} True if the bounds overlap, otherwise false
|
|
14056
|
-
*/
|
|
14057
|
-
Bounds$1.prototype.overlaps = function overlaps (bounds) {
|
|
14058
|
-
return (this.left <= bounds.right && this.right >= bounds.left
|
|
14059
|
-
&& this.bottom >= bounds.top && this.top <= bounds.bottom);
|
|
14060
|
-
};
|
|
14061
|
-
|
|
14062
|
-
/**
|
|
14063
|
-
* determines whether all coordinates of this bounds are finite numbers.
|
|
14064
|
-
* @name isFinite
|
|
14065
|
-
* @memberOf me.Bounds
|
|
14066
|
-
* @function
|
|
14067
|
-
* @return {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
|
|
14068
|
-
*/
|
|
14069
|
-
Bounds$1.prototype.isFinite = function isFinite$1 () {
|
|
14070
|
-
return (isFinite(this.min.x) && isFinite(this.max.x) && isFinite(this.min.y) && isFinite(this.max.y));
|
|
14071
|
-
};
|
|
14072
|
-
|
|
14073
|
-
/**
|
|
14074
|
-
* Translates the bounds by the given vector.
|
|
14075
|
-
* @name translate
|
|
14076
|
-
* @memberOf me.Bounds
|
|
14077
|
-
* @function
|
|
14078
|
-
* @param {me.Vector2d} vector
|
|
14079
|
-
*/
|
|
14080
|
-
/**
|
|
14081
|
-
* Translates the bounds by x on the x axis, and y on the y axis
|
|
14082
|
-
* @name translate
|
|
14083
|
-
* @memberOf me.Bounds
|
|
14084
|
-
* @function
|
|
14085
|
-
* @param {Number} x
|
|
14086
|
-
* @param {Number} y
|
|
14087
|
-
*/
|
|
14088
|
-
Bounds$1.prototype.translate = function translate () {
|
|
14089
|
-
var _x, _y;
|
|
14090
|
-
if (arguments.length === 2) {
|
|
14091
|
-
// x, y
|
|
14092
|
-
_x = arguments[0];
|
|
14093
|
-
_y = arguments[1];
|
|
14094
|
-
} else {
|
|
14095
|
-
// vector
|
|
14096
|
-
_x = arguments[0].x;
|
|
14097
|
-
_y = arguments[0].y;
|
|
14098
|
-
}
|
|
14099
|
-
this.min.x += _x;
|
|
14100
|
-
this.max.x += _x;
|
|
14101
|
-
this.min.y += _y;
|
|
14102
|
-
this.max.y += _y;
|
|
14103
|
-
};
|
|
14104
|
-
|
|
14105
|
-
/**
|
|
14106
|
-
* Shifts the bounds to the given position vector.
|
|
14107
|
-
* @name shift
|
|
14108
|
-
* @memberOf me.Bounds
|
|
14109
|
-
* @function
|
|
14110
|
-
* @param {me.Vector2d} position
|
|
14111
|
-
*/
|
|
14112
|
-
/**
|
|
14113
|
-
* Shifts the bounds to the given x, y position.
|
|
14114
|
-
* @name shift
|
|
14115
|
-
* @memberOf me.Bounds
|
|
14116
|
-
* @function
|
|
14117
|
-
* @param {Number} x
|
|
14118
|
-
* @param {Number} y
|
|
14119
|
-
*/
|
|
14120
|
-
Bounds$1.prototype.shift = function shift () {
|
|
14121
|
-
var _x, _y;
|
|
14122
|
-
|
|
14123
|
-
if (arguments.length === 2) {
|
|
14124
|
-
// x, y
|
|
14125
|
-
_x = arguments[0];
|
|
14126
|
-
_y = arguments[1];
|
|
14127
|
-
} else {
|
|
14128
|
-
// vector
|
|
14129
|
-
_x = arguments[0].x;
|
|
14130
|
-
_y = arguments[0].y;
|
|
14131
|
-
}
|
|
14132
|
-
|
|
14133
|
-
var deltaX = this.max.x - this.min.x,
|
|
14134
|
-
deltaY = this.max.y - this.min.y;
|
|
14135
|
-
|
|
14136
|
-
this.min.x = _x;
|
|
14137
|
-
this.max.x = _x + deltaX;
|
|
14138
|
-
this.min.y = _y;
|
|
14139
|
-
this.max.y = _y + deltaY;
|
|
14140
|
-
};
|
|
14141
|
-
|
|
14142
|
-
/**
|
|
14143
|
-
* clone this bounds
|
|
14144
|
-
* @name clone
|
|
14145
|
-
* @memberOf me.Bounds
|
|
14146
|
-
* @function
|
|
14147
|
-
* @return {me.Bounds}
|
|
14148
|
-
*/
|
|
14149
|
-
Bounds$1.prototype.clone = function clone () {
|
|
14150
|
-
var bounds = new Bounds$1();
|
|
14151
|
-
bounds.addBounds(this);
|
|
14152
|
-
return bounds;
|
|
14153
|
-
};
|
|
14154
|
-
|
|
14155
|
-
/**
|
|
14156
|
-
* Returns a polygon whose edges are the same as this bounds.
|
|
14157
|
-
* @name toPolygon
|
|
14158
|
-
* @memberOf me.Bounds
|
|
14159
|
-
* @function
|
|
14160
|
-
* @return {me.Polygon} a new Polygon that represents this bounds.
|
|
14161
|
-
*/
|
|
14162
|
-
Bounds$1.prototype.toPolygon = function toPolygon () {
|
|
14163
|
-
return new Polygon(this.x, this.y, [
|
|
14164
|
-
new Vector2d(0, 0),
|
|
14165
|
-
new Vector2d(this.width, 0),
|
|
14166
|
-
new Vector2d(this.width, this.height),
|
|
14167
|
-
new Vector2d(0, this.height)
|
|
14168
|
-
]);
|
|
14169
|
-
};
|
|
14170
|
-
|
|
14171
|
-
Object.defineProperties( Bounds$1.prototype, prototypeAccessors$1 );
|
|
14172
|
-
|
|
14173
14192
|
/*
|
|
14174
14193
|
* Separating Axis Theorem implementation, based on the SAT.js library by Jim Riecken <jimr@jimr.ca>
|
|
14175
14194
|
* Available under the MIT License - https://github.com/jriecken/sat-js
|
|
@@ -14696,7 +14715,6 @@
|
|
|
14696
14715
|
* @name ResponseObject
|
|
14697
14716
|
* @memberOf me.collision
|
|
14698
14717
|
* @public
|
|
14699
|
-
* @see me.collision.check
|
|
14700
14718
|
*/
|
|
14701
14719
|
var ResponseObject = function ResponseObject() {
|
|
14702
14720
|
this.a = null;
|
|
@@ -15018,13 +15036,7 @@
|
|
|
15018
15036
|
};
|
|
15019
15037
|
|
|
15020
15038
|
/**
|
|
15021
|
-
* a Generic Body Object with some physic properties and behavior functionality
|
|
15022
|
-
The body object is attached as a member of a Renderable. The Body object can handle movements of the parent with
|
|
15023
|
-
the body.update call. It is important to know that when body.update is called there are several things that happen related to
|
|
15024
|
-
the movement and positioning of the parent renderable object. 1) The force/gravity/friction parameters are used
|
|
15025
|
-
to calculate a new velocity and 2) the parent position is updated by adding this to the parent.pos (position me.Vector2d)
|
|
15026
|
-
value. Thus Affecting the movement of the parent. Look at the source code for /src/physics/body.js:update (me.Body.update) for
|
|
15027
|
-
a better understanding.
|
|
15039
|
+
* a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
|
|
15028
15040
|
* @class Body
|
|
15029
15041
|
* @memberOf me
|
|
15030
15042
|
* @constructor
|
|
@@ -15827,6 +15839,7 @@
|
|
|
15827
15839
|
var globalFloatingCounter = 0;
|
|
15828
15840
|
|
|
15829
15841
|
/**
|
|
15842
|
+
* @classdesc
|
|
15830
15843
|
* me.Container represents a collection of child objects
|
|
15831
15844
|
* @class Container
|
|
15832
15845
|
* @extends me.Renderable
|
|
@@ -17172,8 +17185,9 @@
|
|
|
17172
17185
|
};
|
|
17173
17186
|
|
|
17174
17187
|
/**
|
|
17188
|
+
* @classdesc
|
|
17175
17189
|
* an object representing the physic world, and responsible for managing and updating all childs and physics
|
|
17176
|
-
* @class
|
|
17190
|
+
* @class World
|
|
17177
17191
|
* @extends me.Container
|
|
17178
17192
|
* @memberOf me
|
|
17179
17193
|
* @constructor
|
|
@@ -17483,7 +17497,7 @@
|
|
|
17483
17497
|
* Update the renderer framerate using the system config variables.
|
|
17484
17498
|
* @function me.game.updateFrameRate
|
|
17485
17499
|
* @see me.timer.maxfps
|
|
17486
|
-
* @see me.
|
|
17500
|
+
* @see me.World.fps
|
|
17487
17501
|
*/
|
|
17488
17502
|
function updateFrameRate() {
|
|
17489
17503
|
// reset the frame counter
|
|
@@ -17817,9 +17831,12 @@
|
|
|
17817
17831
|
* @param {Number} [y=0]
|
|
17818
17832
|
*/
|
|
17819
17833
|
Camera2d.prototype.reset = function reset (x, y) {
|
|
17834
|
+
if ( x === void 0 ) x = 0;
|
|
17835
|
+
if ( y === void 0 ) y = 0;
|
|
17836
|
+
|
|
17820
17837
|
// reset the initial camera position to 0,0
|
|
17821
|
-
this.pos.x = x
|
|
17822
|
-
this.pos.y = y
|
|
17838
|
+
this.pos.x = x;
|
|
17839
|
+
this.pos.y = y;
|
|
17823
17840
|
|
|
17824
17841
|
// reset the target
|
|
17825
17842
|
this.unfollow();
|
|
@@ -18389,7 +18406,7 @@
|
|
|
18389
18406
|
* @memberOf me
|
|
18390
18407
|
* @constructor
|
|
18391
18408
|
* @param {Object} [options] The stage` parameters
|
|
18392
|
-
* @param {
|
|
18409
|
+
* @param {me.Camera2d[]} [options.cameras=[new me.Camera2d()]] a list of cameras (experimental)
|
|
18393
18410
|
* @param {Function} [options.onResetEvent] called by the state manager when reseting the object
|
|
18394
18411
|
* @param {Function} [options.onDestroyEvent] called by the state manager before switching to another state
|
|
18395
18412
|
* @see me.state
|
|
@@ -18423,7 +18440,7 @@
|
|
|
18423
18440
|
Stage.prototype.reset = function reset$1 () {
|
|
18424
18441
|
var this$1$1 = this;
|
|
18425
18442
|
|
|
18426
|
-
|
|
18443
|
+
|
|
18427
18444
|
// add all defined cameras
|
|
18428
18445
|
this.settings.cameras.forEach(function (camera) {
|
|
18429
18446
|
this$1$1.cameras.set(camera.name, camera);
|
|
@@ -18710,84 +18727,23 @@
|
|
|
18710
18727
|
|
|
18711
18728
|
return IconLogo;
|
|
18712
18729
|
}(Renderable));
|
|
18713
|
-
// the melonJS Text Logo
|
|
18714
|
-
var TextLogo = /*@__PURE__*/(function (Renderable) {
|
|
18715
|
-
function TextLogo(w, h) {
|
|
18716
|
-
Renderable.call(this, 0, 0, w, h);
|
|
18717
|
-
|
|
18718
|
-
this.textWidth = 0;
|
|
18719
|
-
|
|
18720
|
-
// offscreen cache canvas
|
|
18721
|
-
this.fontCanvas = createCanvas(256, 64, true);
|
|
18722
|
-
this.drawFont(renderer.getContext2d(this.fontCanvas));
|
|
18723
|
-
|
|
18724
|
-
this.anchorPoint.set(0, 0.5);
|
|
18725
|
-
}
|
|
18726
|
-
|
|
18727
|
-
if ( Renderable ) TextLogo.__proto__ = Renderable;
|
|
18728
|
-
TextLogo.prototype = Object.create( Renderable && Renderable.prototype );
|
|
18729
|
-
TextLogo.prototype.constructor = TextLogo;
|
|
18730
|
-
|
|
18731
|
-
TextLogo.prototype.drawFont = function drawFont (context) {
|
|
18732
|
-
var logo1 = pool.pull("Text", 0, 0, {
|
|
18733
|
-
font: "century gothic",
|
|
18734
|
-
size: 32,
|
|
18735
|
-
fillStyle: "white",
|
|
18736
|
-
textAlign: "middle",
|
|
18737
|
-
textBaseline : "top",
|
|
18738
|
-
text: "melon"
|
|
18739
|
-
});
|
|
18740
|
-
var logo2 = pool.pull("Text", 0, 0, {
|
|
18741
|
-
font: "century gothic",
|
|
18742
|
-
size: 32,
|
|
18743
|
-
fillStyle: "#55aa00",
|
|
18744
|
-
textAlign: "middle",
|
|
18745
|
-
textBaseline : "top",
|
|
18746
|
-
bold: true,
|
|
18747
|
-
text: "JS"
|
|
18748
|
-
});
|
|
18749
|
-
|
|
18750
|
-
|
|
18751
|
-
// compute both logo respective size
|
|
18752
|
-
var logo1_width = logo1.measureText(context).width;
|
|
18753
|
-
var logo2_width = logo2.measureText(context).width;
|
|
18754
|
-
|
|
18755
|
-
this.textWidth = logo1_width + logo2_width;
|
|
18756
|
-
|
|
18757
|
-
// calculate the final rendering position
|
|
18758
|
-
this.pos.x = Math.round(this.width - this.textWidth / 2);
|
|
18759
|
-
this.pos.y = Math.round(this.height + 16);
|
|
18760
|
-
|
|
18761
|
-
// use the private _drawFont method to directly draw on the canvas context
|
|
18762
|
-
logo1._drawFont(context, ["melon"], 0, 0);
|
|
18763
|
-
logo2._drawFont(context, ["JS"], logo1_width, 0);
|
|
18764
|
-
|
|
18765
|
-
// put them back into the object pool
|
|
18766
|
-
pool.push(logo1);
|
|
18767
|
-
pool.push(logo2);
|
|
18768
|
-
};
|
|
18769
18730
|
|
|
18770
|
-
/**
|
|
18771
|
-
* @ignore
|
|
18772
|
-
*/
|
|
18773
|
-
TextLogo.prototype.draw = function draw (renderer) {
|
|
18774
|
-
renderer.drawImage(this.fontCanvas, Math.round((renderer.getWidth() - this.textWidth) / 2), this.pos.y);
|
|
18775
|
-
};
|
|
18776
|
-
|
|
18777
|
-
return TextLogo;
|
|
18778
|
-
}(Renderable));
|
|
18779
18731
|
/**
|
|
18780
18732
|
* a default loading screen
|
|
18781
18733
|
* @memberOf me
|
|
18782
18734
|
* @ignore
|
|
18783
18735
|
* @constructor
|
|
18784
18736
|
*/
|
|
18785
|
-
var
|
|
18786
|
-
|
|
18787
|
-
|
|
18788
|
-
|
|
18789
|
-
|
|
18790
|
-
|
|
18737
|
+
var DefaultLoadingScreen = /*@__PURE__*/(function (Stage) {
|
|
18738
|
+
function DefaultLoadingScreen () {
|
|
18739
|
+
Stage.apply(this, arguments);
|
|
18740
|
+
}
|
|
18741
|
+
|
|
18742
|
+
if ( Stage ) DefaultLoadingScreen.__proto__ = Stage;
|
|
18743
|
+
DefaultLoadingScreen.prototype = Object.create( Stage && Stage.prototype );
|
|
18744
|
+
DefaultLoadingScreen.prototype.constructor = DefaultLoadingScreen;
|
|
18745
|
+
|
|
18746
|
+
DefaultLoadingScreen.prototype.onResetEvent = function onResetEvent () {
|
|
18791
18747
|
var barHeight = 8;
|
|
18792
18748
|
|
|
18793
18749
|
// clear the background
|
|
@@ -18808,13 +18764,47 @@
|
|
|
18808
18764
|
|
|
18809
18765
|
), 2);
|
|
18810
18766
|
|
|
18767
|
+
var logo1 = pool.pull("Text",
|
|
18768
|
+
renderer.getWidth() / 2,
|
|
18769
|
+
(renderer.getHeight() / 2) + 16, {
|
|
18770
|
+
font: "century gothic",
|
|
18771
|
+
size: 32,
|
|
18772
|
+
fillStyle: "white",
|
|
18773
|
+
textAlign: "left",
|
|
18774
|
+
textBaseline : "top",
|
|
18775
|
+
text: "melon",
|
|
18776
|
+
offScreenCanvas: true
|
|
18777
|
+
}
|
|
18778
|
+
);
|
|
18779
|
+
logo1.anchorPoint.set(0, 0);
|
|
18780
|
+
|
|
18781
|
+
var logo2 = pool.pull("Text",
|
|
18782
|
+
renderer.getWidth() / 2,
|
|
18783
|
+
(renderer.getHeight() / 2) + 16, {
|
|
18784
|
+
font: "century gothic",
|
|
18785
|
+
size: 32,
|
|
18786
|
+
fillStyle: "#55aa00",
|
|
18787
|
+
textAlign: "left",
|
|
18788
|
+
textBaseline : "top",
|
|
18789
|
+
bold: true,
|
|
18790
|
+
text: "JS",
|
|
18791
|
+
offScreenCanvas: true
|
|
18792
|
+
}
|
|
18793
|
+
);
|
|
18794
|
+
logo2.anchorPoint.set(0, 0);
|
|
18795
|
+
|
|
18796
|
+
// adjust position of both text
|
|
18797
|
+
var text_width = logo1.getBounds().width + logo2.getBounds().width;
|
|
18798
|
+
logo1.pos.x = renderer.getWidth() / 2 - text_width / 2;
|
|
18799
|
+
logo2.pos.x = logo1.pos.x + logo1.getBounds().width;
|
|
18800
|
+
|
|
18811
18801
|
// melonJS text
|
|
18812
|
-
world.addChild(
|
|
18813
|
-
|
|
18814
|
-
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
});
|
|
18802
|
+
world.addChild(logo1, 2);
|
|
18803
|
+
world.addChild(logo2, 2);
|
|
18804
|
+
};
|
|
18805
|
+
|
|
18806
|
+
return DefaultLoadingScreen;
|
|
18807
|
+
}(Stage));
|
|
18818
18808
|
|
|
18819
18809
|
// current state
|
|
18820
18810
|
var _state = -1;
|
|
@@ -18946,7 +18936,7 @@
|
|
|
18946
18936
|
// initialize me.state on system boot
|
|
18947
18937
|
on(BOOT, function () {
|
|
18948
18938
|
// set the built-in loading stage
|
|
18949
|
-
state.set(state.LOADING,
|
|
18939
|
+
state.set(state.LOADING, new DefaultLoadingScreen());
|
|
18950
18940
|
// set and enable the default stage
|
|
18951
18941
|
state.set(state.DEFAULT, new Stage());
|
|
18952
18942
|
// enable by default as soon as the display is initialized
|
|
@@ -19764,6 +19754,17 @@
|
|
|
19764
19754
|
return this.cache.get(image);
|
|
19765
19755
|
};
|
|
19766
19756
|
|
|
19757
|
+
/**
|
|
19758
|
+
* @ignore
|
|
19759
|
+
*/
|
|
19760
|
+
TextureCache.prototype.remove = function remove (image) {
|
|
19761
|
+
if (!this.cache.has(image)) {
|
|
19762
|
+
if (this.cache.remove(image) === true) {
|
|
19763
|
+
this.length--;
|
|
19764
|
+
}
|
|
19765
|
+
}
|
|
19766
|
+
};
|
|
19767
|
+
|
|
19767
19768
|
/**
|
|
19768
19769
|
* @ignore
|
|
19769
19770
|
*/
|
|
@@ -20091,10 +20092,10 @@
|
|
|
20091
20092
|
var sh = atlas[frame].height;
|
|
20092
20093
|
|
|
20093
20094
|
atlas[frame].uvs = new Float32Array([
|
|
20094
|
-
s.x / w, //
|
|
20095
|
-
s.y / h, //
|
|
20096
|
-
(s.x + sw) / w, //
|
|
20097
|
-
(s.y + sh) / h//
|
|
20095
|
+
s.x / w, // u0 (left)
|
|
20096
|
+
s.y / h, // v0 (top)
|
|
20097
|
+
(s.x + sw) / w, // u1 (right)
|
|
20098
|
+
(s.y + sh) / h// v1 (bottom)
|
|
20098
20099
|
]);
|
|
20099
20100
|
// Cache source coordinates
|
|
20100
20101
|
// TODO: Remove this when the Batcher only accepts a region name
|
|
@@ -20230,7 +20231,8 @@
|
|
|
20230
20231
|
* @function
|
|
20231
20232
|
* @param {String} name name of the sprite
|
|
20232
20233
|
* @param {Object} [settings] Additional settings passed to the {@link me.Sprite} contructor
|
|
20233
|
-
* @
|
|
20234
|
+
* @param {Boolean} [nineSlice=false] if true returns a 9-slice sprite
|
|
20235
|
+
* @return {me.Sprite|me.NineSliceSprite}
|
|
20234
20236
|
* @example
|
|
20235
20237
|
* // create a new texture object under the `game` namespace
|
|
20236
20238
|
* game.texture = new me.video.renderer.Texture(
|
|
@@ -20243,11 +20245,22 @@
|
|
|
20243
20245
|
* var sprite = game.texture.createSpriteFromName("coin.png");
|
|
20244
20246
|
* // set the renderable position to bottom center
|
|
20245
20247
|
* sprite.anchorPoint.set(0.5, 1.0);
|
|
20248
|
+
* ...
|
|
20249
|
+
* ...
|
|
20250
|
+
* // create a 9-slice sprite
|
|
20251
|
+
* var dialogPanel = game.texture.createSpriteFromName(
|
|
20252
|
+
* "rpg_dialo.png",
|
|
20253
|
+
* // width & height are mandatory for 9-slice sprites
|
|
20254
|
+
* { width: this.width, height: this.height },
|
|
20255
|
+
* true
|
|
20256
|
+
* );
|
|
20246
20257
|
*/
|
|
20247
|
-
Texture.prototype.createSpriteFromName = function createSpriteFromName (name, settings) {
|
|
20258
|
+
Texture.prototype.createSpriteFromName = function createSpriteFromName (name, settings, nineSlice) {
|
|
20259
|
+
if ( nineSlice === void 0 ) nineSlice = false;
|
|
20260
|
+
|
|
20248
20261
|
// instantiate a new sprite object
|
|
20249
20262
|
return pool.pull(
|
|
20250
|
-
"me.Sprite",
|
|
20263
|
+
nineSlice === true ? "me.NineSliceSprite" : "me.Sprite",
|
|
20251
20264
|
0, 0,
|
|
20252
20265
|
Object.assign({
|
|
20253
20266
|
image: this,
|
|
@@ -20335,7 +20348,7 @@
|
|
|
20335
20348
|
* @param {String} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
|
|
20336
20349
|
* @param {Number} [settings.framewidth] Width of a single frame within the spritesheet
|
|
20337
20350
|
* @param {Number} [settings.frameheight] Height of a single frame within the spritesheet
|
|
20338
|
-
* @param {String|Color} [settings.tint] a tint to be applied to this sprite
|
|
20351
|
+
* @param {String|me.Color} [settings.tint] a tint to be applied to this sprite
|
|
20339
20352
|
* @param {Number} [settings.flipX] flip the sprite on the horizontal axis
|
|
20340
20353
|
* @param {Number} [settings.flipY] flip the sprite on the vertical axis
|
|
20341
20354
|
* @param {me.Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
|
|
@@ -20492,7 +20505,7 @@
|
|
|
20492
20505
|
// set the default rotation angle is defined in the settings
|
|
20493
20506
|
// * WARNING: rotating sprites decreases performance with Canvas Renderer
|
|
20494
20507
|
if (typeof (settings.rotation) !== "undefined") {
|
|
20495
|
-
this.
|
|
20508
|
+
this.rotate(settings.rotation);
|
|
20496
20509
|
}
|
|
20497
20510
|
|
|
20498
20511
|
// update anchorPoint
|
|
@@ -21413,7 +21426,7 @@
|
|
|
21413
21426
|
* @function
|
|
21414
21427
|
* @param {HTMLCanvasElement} canvas
|
|
21415
21428
|
* @param {Boolean} [transparent=true] use false to disable transparency
|
|
21416
|
-
* @return {
|
|
21429
|
+
* @return {CanvasRenderingContext2D}
|
|
21417
21430
|
*/
|
|
21418
21431
|
Renderer.prototype.getContext2d = function getContext2d (c, transparent) {
|
|
21419
21432
|
if (typeof c === "undefined" || c === null) {
|
|
@@ -21655,11 +21668,15 @@
|
|
|
21655
21668
|
* @name setTint
|
|
21656
21669
|
* @memberOf me.Renderer.prototype
|
|
21657
21670
|
* @function
|
|
21658
|
-
* @param {me.Color}
|
|
21671
|
+
* @param {me.Color} tint the tint color
|
|
21672
|
+
* @param {Number} [alpha] an alpha value to be applied to the tint
|
|
21659
21673
|
*/
|
|
21660
|
-
Renderer.prototype.setTint = function setTint (tint) {
|
|
21674
|
+
Renderer.prototype.setTint = function setTint (tint, alpha) {
|
|
21675
|
+
if ( alpha === void 0 ) alpha = tint.alpha;
|
|
21676
|
+
|
|
21661
21677
|
// global tint color
|
|
21662
21678
|
this.currentTint.copy(tint);
|
|
21679
|
+
this.currentTint.alpha *= alpha;
|
|
21663
21680
|
};
|
|
21664
21681
|
|
|
21665
21682
|
/**
|
|
@@ -22726,7 +22743,7 @@
|
|
|
22726
22743
|
* // get the TMX Map Layer called "Front layer"
|
|
22727
22744
|
* var layer = me.game.world.getChildByName("Front Layer")[0];
|
|
22728
22745
|
* // get the tile object corresponding to the latest pointer position
|
|
22729
|
-
* var tile = layer.getTile(me.input.pointer.
|
|
22746
|
+
* var tile = layer.getTile(me.input.pointer.x, me.input.pointer.y);
|
|
22730
22747
|
*/
|
|
22731
22748
|
TMXLayer.prototype.getTile = function getTile (x, y) {
|
|
22732
22749
|
var tile = null;
|
|
@@ -23219,8 +23236,8 @@
|
|
|
23219
23236
|
* @return {boolean} True if the bounds overlap, otherwise false
|
|
23220
23237
|
*/
|
|
23221
23238
|
Bounds.prototype.overlaps = function overlaps (bounds) {
|
|
23222
|
-
return (this.
|
|
23223
|
-
|
|
23239
|
+
return !(this.right < bounds.left || this.left > bounds.right ||
|
|
23240
|
+
this.bottom < bounds.top || this.top > bounds.bottom);
|
|
23224
23241
|
};
|
|
23225
23242
|
|
|
23226
23243
|
/**
|
|
@@ -26554,6 +26571,8 @@
|
|
|
26554
26571
|
* me.loader.preload(game.resources, this.loaded.bind(this));
|
|
26555
26572
|
*/
|
|
26556
26573
|
preload: function preload(res, onload, switchToLoadState) {
|
|
26574
|
+
if ( switchToLoadState === void 0 ) switchToLoadState = true;
|
|
26575
|
+
|
|
26557
26576
|
// parse the resources
|
|
26558
26577
|
for (var i = 0; i < res.length; i++) {
|
|
26559
26578
|
resourceCount += this.load(
|
|
@@ -26567,7 +26586,7 @@
|
|
|
26567
26586
|
this.onload = onload;
|
|
26568
26587
|
}
|
|
26569
26588
|
|
|
26570
|
-
if (switchToLoadState
|
|
26589
|
+
if (switchToLoadState === true) {
|
|
26571
26590
|
// swith to the loading screen
|
|
26572
26591
|
state.change(state.LOADING);
|
|
26573
26592
|
}
|
|
@@ -27627,6 +27646,10 @@
|
|
|
27627
27646
|
device.hasDeviceOrientation = !!window.DeviceOrientationEvent;
|
|
27628
27647
|
device.hasAccelerometer = !!window.DeviceMotionEvent;
|
|
27629
27648
|
|
|
27649
|
+
// support the ScreenOrientation API
|
|
27650
|
+
device.ScreenOrientation = (typeof screen !== "undefined") &&
|
|
27651
|
+
(typeof screen.orientation !== "undefined");
|
|
27652
|
+
|
|
27630
27653
|
// fullscreen api detection & polyfill when possible
|
|
27631
27654
|
device.hasFullscreenSupport = prefixed("fullscreenEnabled", document) ||
|
|
27632
27655
|
document.mozFullScreenEnabled;
|
|
@@ -27769,6 +27792,16 @@
|
|
|
27769
27792
|
*/
|
|
27770
27793
|
hasDeviceOrientation : false,
|
|
27771
27794
|
|
|
27795
|
+
/**
|
|
27796
|
+
* Supports the ScreenOrientation API
|
|
27797
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/onchange
|
|
27798
|
+
* @type Boolean
|
|
27799
|
+
* @readonly
|
|
27800
|
+
* @name ScreenOrientation
|
|
27801
|
+
* @memberOf me.device
|
|
27802
|
+
*/
|
|
27803
|
+
ScreenOrientation : false,
|
|
27804
|
+
|
|
27772
27805
|
/**
|
|
27773
27806
|
* Browser full screen support
|
|
27774
27807
|
* @type Boolean
|
|
@@ -28201,7 +28234,7 @@
|
|
|
28201
28234
|
var screen = window.screen;
|
|
28202
28235
|
|
|
28203
28236
|
// first try using "standard" values
|
|
28204
|
-
if (
|
|
28237
|
+
if (this.ScreenOrientation === true) {
|
|
28205
28238
|
var orientation = prefixed("orientation", screen);
|
|
28206
28239
|
if (typeof orientation !== "undefined" && typeof orientation.type === "string") {
|
|
28207
28240
|
// Screen Orientation API specification
|
|
@@ -29033,14 +29066,149 @@
|
|
|
29033
29066
|
this.fragment = null;
|
|
29034
29067
|
};
|
|
29035
29068
|
|
|
29069
|
+
/**
|
|
29070
|
+
* @classdesc
|
|
29071
|
+
* a Vertex Buffer object
|
|
29072
|
+
* @class VertexArrayBuffer
|
|
29073
|
+
* @private
|
|
29074
|
+
*/
|
|
29075
|
+
|
|
29076
|
+
var VertexArrayBuffer = function VertexArrayBuffer(vertex_size, vertex_per_quad) {
|
|
29077
|
+
// the size of one vertex
|
|
29078
|
+
this.vertexSize = vertex_size;
|
|
29079
|
+
// size of a quad in vertex
|
|
29080
|
+
this.quadSize = vertex_per_quad;
|
|
29081
|
+
// the maximum number of vertices the vertex array buffer can hold
|
|
29082
|
+
this.maxVertex = 256;
|
|
29083
|
+
// the current number of vertices added to the vertex array buffer
|
|
29084
|
+
this.vertexCount = 0;
|
|
29085
|
+
|
|
29086
|
+
// the actual vertex data buffer
|
|
29087
|
+
this.buffer = new ArrayBuffer(this.maxVertex * this.vertexSize * this.quadSize);
|
|
29088
|
+
// Float32 and Uint32 view of the vertex data array buffer
|
|
29089
|
+
this.bufferF32 = new Float32Array(this.buffer);
|
|
29090
|
+
this.bufferU32 = new Uint32Array(this.buffer);
|
|
29091
|
+
|
|
29092
|
+
|
|
29093
|
+
return this;
|
|
29094
|
+
};
|
|
29095
|
+
|
|
29096
|
+
/**
|
|
29097
|
+
* clear the vertex array buffer
|
|
29098
|
+
*/
|
|
29099
|
+
VertexArrayBuffer.prototype.clear = function clear () {
|
|
29100
|
+
this.vertexCount = 0;
|
|
29101
|
+
};
|
|
29102
|
+
|
|
29103
|
+
|
|
29104
|
+
/**
|
|
29105
|
+
* return true if full
|
|
29106
|
+
*/
|
|
29107
|
+
VertexArrayBuffer.prototype.isFull = function isFull (vertex) {
|
|
29108
|
+
if ( vertex === void 0 ) vertex = 0;
|
|
29109
|
+
|
|
29110
|
+
return (this.vertexCount + vertex >= this.maxVertex);
|
|
29111
|
+
};
|
|
29112
|
+
|
|
29113
|
+
/**
|
|
29114
|
+
* resize the vertex buffer, retaining its original contents
|
|
29115
|
+
*/
|
|
29116
|
+
VertexArrayBuffer.prototype.resize = function resize () {
|
|
29117
|
+
// double the vertex size
|
|
29118
|
+
this.maxVertex <<= 1;
|
|
29119
|
+
// save a reference to the previous data
|
|
29120
|
+
var data = this.bufferF32;
|
|
29121
|
+
|
|
29122
|
+
// recreate ArrayBuffer and views
|
|
29123
|
+
this.buffer = new ArrayBuffer(this.maxVertex * this.vertexSize * this.quadSize);
|
|
29124
|
+
this.bufferF32 = new Float32Array(this.buffer);
|
|
29125
|
+
this.bufferU32 = new Uint32Array(this.buffer);
|
|
29126
|
+
|
|
29127
|
+
// copy previous data
|
|
29128
|
+
this.bufferF32.set(data);
|
|
29129
|
+
|
|
29130
|
+
return this;
|
|
29131
|
+
};
|
|
29132
|
+
|
|
29133
|
+
/**
|
|
29134
|
+
* push a new vertex to the buffer
|
|
29135
|
+
*/
|
|
29136
|
+
VertexArrayBuffer.prototype.push = function push (x, y, u, v, tint) {
|
|
29137
|
+
var offset = this.vertexCount * this.vertexSize;
|
|
29138
|
+
|
|
29139
|
+
if (this.vertexCount >= this.maxVertex) {
|
|
29140
|
+
this.resize();
|
|
29141
|
+
}
|
|
29142
|
+
|
|
29143
|
+
this.bufferF32[offset + 0] = x;
|
|
29144
|
+
this.bufferF32[offset + 1] = y;
|
|
29145
|
+
|
|
29146
|
+
if (typeof u !== "undefined") {
|
|
29147
|
+
this.bufferF32[offset + 2] = u;
|
|
29148
|
+
this.bufferF32[offset + 3] = v;
|
|
29149
|
+
}
|
|
29150
|
+
|
|
29151
|
+
if (typeof tint !== "undefined") {
|
|
29152
|
+
this.bufferU32[offset + 4] = tint;
|
|
29153
|
+
}
|
|
29154
|
+
|
|
29155
|
+
this.vertexCount++;
|
|
29156
|
+
|
|
29157
|
+
return this;
|
|
29158
|
+
};
|
|
29159
|
+
|
|
29160
|
+
/**
|
|
29161
|
+
* return a reference to the data in Float32 format
|
|
29162
|
+
*/
|
|
29163
|
+
VertexArrayBuffer.prototype.toFloat32 = function toFloat32 (begin, end) {
|
|
29164
|
+
if (typeof end !== "undefined") {
|
|
29165
|
+
return this.bufferF32.subarray(begin, end);
|
|
29166
|
+
} else {
|
|
29167
|
+
return this.bufferF32;
|
|
29168
|
+
}
|
|
29169
|
+
};
|
|
29170
|
+
|
|
29171
|
+
/**
|
|
29172
|
+
* return a reference to the data in Uint32 format
|
|
29173
|
+
*/
|
|
29174
|
+
VertexArrayBuffer.prototype.toUint32 = function toUint32 (begin, end) {
|
|
29175
|
+
if (typeof end !== "undefined") {
|
|
29176
|
+
return this.bufferU32.subarray(begin, end);
|
|
29177
|
+
} else {
|
|
29178
|
+
return this.bufferU32;
|
|
29179
|
+
}
|
|
29180
|
+
};
|
|
29181
|
+
|
|
29182
|
+
/**
|
|
29183
|
+
* return the size of the vertex in vertex
|
|
29184
|
+
*/
|
|
29185
|
+
VertexArrayBuffer.prototype.length = function length () {
|
|
29186
|
+
return this.vertexCount;
|
|
29187
|
+
};
|
|
29188
|
+
|
|
29189
|
+
/**
|
|
29190
|
+
* return true if empty
|
|
29191
|
+
*/
|
|
29192
|
+
VertexArrayBuffer.prototype.isEmpty = function isEmpty () {
|
|
29193
|
+
return this.vertexCount === 0;
|
|
29194
|
+
};
|
|
29195
|
+
|
|
29036
29196
|
var primitiveVertex = "// Current vertex point\nattribute vec2 aVertex;\n\n// Projection matrix\nuniform mat4 uProjectionMatrix;\n\n// Vertex color\nuniform vec4 uColor;\n\n// Fragment color\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(uColor.rgb * uColor.a, uColor.a);\n}\n";
|
|
29037
29197
|
|
|
29038
29198
|
var primitiveFragment = "varying vec4 vColor;\n\nvoid main(void) {\n gl_FragColor = vColor;\n}\n";
|
|
29039
29199
|
|
|
29040
|
-
var quadVertex = "attribute vec2 aVertex;\nattribute vec2 aRegion;\nattribute vec4 aColor;\n\nuniform mat4 uProjectionMatrix;\n\nvarying vec2 vRegion;\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(aColor.
|
|
29200
|
+
var quadVertex = "attribute vec2 aVertex;\nattribute vec2 aRegion;\nattribute vec4 aColor;\n\nuniform mat4 uProjectionMatrix;\n\nvarying vec2 vRegion;\nvarying vec4 vColor;\n\nvoid main(void) {\n // Transform the vertex position by the projection matrix\n gl_Position = uProjectionMatrix * vec4(aVertex, 0.0, 1.0);\n // Pass the remaining attributes to the fragment shader\n vColor = vec4(aColor.bgr * aColor.a, aColor.a);\n vRegion = aRegion;\n}\n";
|
|
29041
29201
|
|
|
29042
29202
|
var quadFragment = "uniform sampler2D uSampler;\nvarying vec4 vColor;\nvarying vec2 vRegion;\n\nvoid main(void) {\n gl_FragColor = texture2D(uSampler, vRegion) * vColor;\n}\n";
|
|
29043
29203
|
|
|
29204
|
+
// a pool of resuable vectors
|
|
29205
|
+
var V_ARRAY = [
|
|
29206
|
+
new Vector2d(),
|
|
29207
|
+
new Vector2d(),
|
|
29208
|
+
new Vector2d(),
|
|
29209
|
+
new Vector2d()
|
|
29210
|
+
];
|
|
29211
|
+
|
|
29044
29212
|
// Handy constants
|
|
29045
29213
|
var VERTEX_SIZE = 2;
|
|
29046
29214
|
var REGION_SIZE = 2;
|
|
@@ -29049,15 +29217,31 @@
|
|
|
29049
29217
|
var ELEMENT_SIZE = VERTEX_SIZE + REGION_SIZE + COLOR_SIZE;
|
|
29050
29218
|
var ELEMENT_OFFSET = ELEMENT_SIZE * Float32Array.BYTES_PER_ELEMENT;
|
|
29051
29219
|
|
|
29052
|
-
var VERTEX_ELEMENT = 0;
|
|
29053
|
-
var REGION_ELEMENT = VERTEX_ELEMENT + VERTEX_SIZE;
|
|
29054
|
-
var COLOR_ELEMENT = REGION_ELEMENT + REGION_SIZE;
|
|
29055
|
-
|
|
29056
29220
|
var ELEMENTS_PER_QUAD = 4;
|
|
29057
29221
|
var INDICES_PER_QUAD = 6;
|
|
29058
29222
|
|
|
29059
29223
|
var MAX_LENGTH = 16000;
|
|
29060
29224
|
|
|
29225
|
+
/**
|
|
29226
|
+
* Create a full index buffer for the element array
|
|
29227
|
+
* @ignore
|
|
29228
|
+
*/
|
|
29229
|
+
function createIB() {
|
|
29230
|
+
var indices = [
|
|
29231
|
+
0, 1, 2,
|
|
29232
|
+
2, 1, 3
|
|
29233
|
+
];
|
|
29234
|
+
|
|
29235
|
+
// ~384KB index buffer
|
|
29236
|
+
var data = new Array(MAX_LENGTH * INDICES_PER_QUAD);
|
|
29237
|
+
for (var i = 0; i < data.length; i++) {
|
|
29238
|
+
data[i] = indices[i % INDICES_PER_QUAD] +
|
|
29239
|
+
~~(i / INDICES_PER_QUAD) * ELEMENTS_PER_QUAD;
|
|
29240
|
+
}
|
|
29241
|
+
|
|
29242
|
+
return new Uint16Array(data);
|
|
29243
|
+
}
|
|
29244
|
+
|
|
29061
29245
|
/**
|
|
29062
29246
|
* @classdesc
|
|
29063
29247
|
* A WebGL Compositor object. This class handles all of the WebGL state<br>
|
|
@@ -29088,20 +29272,12 @@
|
|
|
29088
29272
|
* @type Number
|
|
29089
29273
|
* @readonly
|
|
29090
29274
|
*/
|
|
29091
|
-
this.length = 0;
|
|
29275
|
+
//this.length = 0;
|
|
29092
29276
|
|
|
29093
29277
|
// list of active texture units
|
|
29094
29278
|
this.currentTextureUnit = -1;
|
|
29095
29279
|
this.boundTextures = [];
|
|
29096
29280
|
|
|
29097
|
-
// Vector pool
|
|
29098
|
-
this.v = [
|
|
29099
|
-
new Vector2d(),
|
|
29100
|
-
new Vector2d(),
|
|
29101
|
-
new Vector2d(),
|
|
29102
|
-
new Vector2d()
|
|
29103
|
-
];
|
|
29104
|
-
|
|
29105
29281
|
// the associated renderer
|
|
29106
29282
|
this.renderer = renderer;
|
|
29107
29283
|
|
|
@@ -29111,9 +29287,6 @@
|
|
|
29111
29287
|
// Global fill color
|
|
29112
29288
|
this.color = renderer.currentColor;
|
|
29113
29289
|
|
|
29114
|
-
// Global tint color
|
|
29115
|
-
this.tint = renderer.currentTint;
|
|
29116
|
-
|
|
29117
29290
|
// Global transformation matrix
|
|
29118
29291
|
this.viewMatrix = renderer.currentTransform;
|
|
29119
29292
|
|
|
@@ -29149,9 +29322,9 @@
|
|
|
29149
29322
|
/// define all vertex attributes
|
|
29150
29323
|
this.addAttribute("aVertex", 2, gl.FLOAT, false, 0 * Float32Array.BYTES_PER_ELEMENT); // 0
|
|
29151
29324
|
this.addAttribute("aRegion", 2, gl.FLOAT, false, 2 * Float32Array.BYTES_PER_ELEMENT); // 1
|
|
29152
|
-
this.addAttribute("aColor", 4, gl.
|
|
29325
|
+
this.addAttribute("aColor", 4, gl.UNSIGNED_BYTE, true, 4 * Float32Array.BYTES_PER_ELEMENT); // 2
|
|
29153
29326
|
|
|
29154
|
-
//
|
|
29327
|
+
// vertex buffer
|
|
29155
29328
|
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
|
|
29156
29329
|
gl.bufferData(
|
|
29157
29330
|
gl.ARRAY_BUFFER,
|
|
@@ -29159,17 +29332,11 @@
|
|
|
29159
29332
|
gl.STREAM_DRAW
|
|
29160
29333
|
);
|
|
29161
29334
|
|
|
29162
|
-
this.
|
|
29163
|
-
this.sbIndex = 0;
|
|
29164
|
-
|
|
29165
|
-
// Quad stream buffer
|
|
29166
|
-
this.stream = new Float32Array(
|
|
29167
|
-
this.sbSize * ELEMENT_SIZE * ELEMENTS_PER_QUAD
|
|
29168
|
-
);
|
|
29335
|
+
this.vertexBuffer = new VertexArrayBuffer(ELEMENT_SIZE, ELEMENTS_PER_QUAD);
|
|
29169
29336
|
|
|
29170
|
-
//
|
|
29337
|
+
// Cache index buffer (TODO Remove use for cache by replacing drawElements by drawArrays)
|
|
29171
29338
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gl.createBuffer());
|
|
29172
|
-
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,
|
|
29339
|
+
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, createIB(), gl.STATIC_DRAW);
|
|
29173
29340
|
|
|
29174
29341
|
// register to the CANVAS resize channel
|
|
29175
29342
|
on(CANVAS_ONRESIZE, function (width, height) {
|
|
@@ -29185,9 +29352,6 @@
|
|
|
29185
29352
|
* @ignore
|
|
29186
29353
|
*/
|
|
29187
29354
|
WebGLCompositor.prototype.reset = function reset () {
|
|
29188
|
-
this.sbIndex = 0;
|
|
29189
|
-
this.length = 0;
|
|
29190
|
-
|
|
29191
29355
|
// WebGL context
|
|
29192
29356
|
this.gl = this.renderer.gl;
|
|
29193
29357
|
|
|
@@ -29225,7 +29389,7 @@
|
|
|
29225
29389
|
* @param {String} name name of the attribute in the vertex shader
|
|
29226
29390
|
* @param {Number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
29227
29391
|
* @param {GLenum} type data type of each component in the array
|
|
29228
|
-
* @param {Boolean} normalized whether integer data values should be normalized into a certain
|
|
29392
|
+
* @param {Boolean} normalized whether integer data values should be normalized into a certain range when being cast to a float
|
|
29229
29393
|
* @param {Number} offset offset in bytes of the first component in the vertex attribute array
|
|
29230
29394
|
*/
|
|
29231
29395
|
WebGLCompositor.prototype.addAttribute = function addAttribute (name, size, type, normalized, offset) {
|
|
@@ -29277,10 +29441,10 @@
|
|
|
29277
29441
|
var gl = this.gl;
|
|
29278
29442
|
var isPOT = isPowerOfTwo(w || image.width) && isPowerOfTwo(h || image.height);
|
|
29279
29443
|
var texture = gl.createTexture();
|
|
29280
|
-
var rs = (repeat.search(/^repeat(-x)?$/) === 0) && (isPOT || this.renderer.WebGLVersion
|
|
29281
|
-
var rt = (repeat.search(/^repeat(-y)?$/) === 0) && (isPOT || this.renderer.WebGLVersion
|
|
29444
|
+
var rs = (repeat.search(/^repeat(-x)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
29445
|
+
var rt = (repeat.search(/^repeat(-y)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
29282
29446
|
|
|
29283
|
-
this.
|
|
29447
|
+
this.bindTexture2D(texture, unit);
|
|
29284
29448
|
|
|
29285
29449
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, rs);
|
|
29286
29450
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, rt);
|
|
@@ -29304,13 +29468,13 @@
|
|
|
29304
29468
|
|
|
29305
29469
|
/**
|
|
29306
29470
|
* assign the given WebGL texture to the current batch
|
|
29307
|
-
* @name
|
|
29471
|
+
* @name bindTexture2D
|
|
29308
29472
|
* @memberOf me.WebGLCompositor
|
|
29309
29473
|
* @function
|
|
29310
29474
|
* @param {WebGLTexture} a WebGL texture
|
|
29311
29475
|
* @param {Number} unit Texture unit to which the given texture is bound
|
|
29312
29476
|
*/
|
|
29313
|
-
WebGLCompositor.prototype.
|
|
29477
|
+
WebGLCompositor.prototype.bindTexture2D = function bindTexture2D (texture, unit) {
|
|
29314
29478
|
var gl = this.gl;
|
|
29315
29479
|
|
|
29316
29480
|
if (texture !== this.boundTextures[unit]) {
|
|
@@ -29330,6 +29494,17 @@
|
|
|
29330
29494
|
}
|
|
29331
29495
|
};
|
|
29332
29496
|
|
|
29497
|
+
/**
|
|
29498
|
+
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
29499
|
+
* @name unbindTexture2D
|
|
29500
|
+
* @memberOf me.WebGLCompositor
|
|
29501
|
+
* @function
|
|
29502
|
+
* @param {WebGLTexture} a WebGL texture
|
|
29503
|
+
*/
|
|
29504
|
+
WebGLCompositor.prototype.unbindTexture2D = function unbindTexture2D (texture) {
|
|
29505
|
+
var unit = this.renderer.cache.getUnit(texture);
|
|
29506
|
+
this.boundTextures[unit] = null;
|
|
29507
|
+
};
|
|
29333
29508
|
|
|
29334
29509
|
/**
|
|
29335
29510
|
* @ignore
|
|
@@ -29350,43 +29525,12 @@
|
|
|
29350
29525
|
texture.premultipliedAlpha
|
|
29351
29526
|
);
|
|
29352
29527
|
} else {
|
|
29353
|
-
this.
|
|
29528
|
+
this.bindTexture2D(texture2D, unit);
|
|
29354
29529
|
}
|
|
29355
29530
|
|
|
29356
29531
|
return this.currentTextureUnit;
|
|
29357
29532
|
};
|
|
29358
29533
|
|
|
29359
|
-
/**
|
|
29360
|
-
* Create a full index buffer for the element array
|
|
29361
|
-
* @ignore
|
|
29362
|
-
*/
|
|
29363
|
-
WebGLCompositor.prototype.createIB = function createIB () {
|
|
29364
|
-
var indices = [
|
|
29365
|
-
0, 1, 2,
|
|
29366
|
-
2, 1, 3
|
|
29367
|
-
];
|
|
29368
|
-
|
|
29369
|
-
// ~384KB index buffer
|
|
29370
|
-
var data = new Array(MAX_LENGTH * INDICES_PER_QUAD);
|
|
29371
|
-
for (var i = 0; i < data.length; i++) {
|
|
29372
|
-
data[i] = indices[i % INDICES_PER_QUAD] +
|
|
29373
|
-
~~(i / INDICES_PER_QUAD) * ELEMENTS_PER_QUAD;
|
|
29374
|
-
}
|
|
29375
|
-
|
|
29376
|
-
return new Uint16Array(data);
|
|
29377
|
-
};
|
|
29378
|
-
|
|
29379
|
-
/**
|
|
29380
|
-
* Resize the stream buffer, retaining its original contents
|
|
29381
|
-
* @ignore
|
|
29382
|
-
*/
|
|
29383
|
-
WebGLCompositor.prototype.resizeSB = function resizeSB () {
|
|
29384
|
-
this.sbSize <<= 1;
|
|
29385
|
-
var stream = new Float32Array(this.sbSize * ELEMENT_SIZE * ELEMENTS_PER_QUAD);
|
|
29386
|
-
stream.set(this.stream);
|
|
29387
|
-
this.stream = stream;
|
|
29388
|
-
};
|
|
29389
|
-
|
|
29390
29534
|
/**
|
|
29391
29535
|
* Select the shader to use for compositing
|
|
29392
29536
|
* @name useShader
|
|
@@ -29424,33 +29568,29 @@
|
|
|
29424
29568
|
* @memberOf me.WebGLCompositor
|
|
29425
29569
|
* @function
|
|
29426
29570
|
* @param {me.Renderer.Texture} texture Source texture
|
|
29427
|
-
* @param {String} key Source texture region name
|
|
29428
29571
|
* @param {Number} x Destination x-coordinate
|
|
29429
29572
|
* @param {Number} y Destination y-coordinate
|
|
29430
29573
|
* @param {Number} w Destination width
|
|
29431
29574
|
* @param {Number} h Destination height
|
|
29575
|
+
* @param {number} u0 Texture UV (u0) value.
|
|
29576
|
+
* @param {number} v0 Texture UV (v0) value.
|
|
29577
|
+
* @param {number} u1 Texture UV (u1) value.
|
|
29578
|
+
* @param {number} v1 Texture UV (v1) value.
|
|
29579
|
+
* @param {number} tint tint color to be applied to the texture in UINT32 format
|
|
29432
29580
|
*/
|
|
29433
|
-
WebGLCompositor.prototype.addQuad = function addQuad (texture,
|
|
29434
|
-
//var gl = this.gl;
|
|
29435
|
-
var color = this.color.toArray();
|
|
29436
|
-
var tint = this.tint.toArray();
|
|
29581
|
+
WebGLCompositor.prototype.addQuad = function addQuad (texture, x, y, w, h, u0, v0, u1, v1, tint) {
|
|
29437
29582
|
|
|
29438
|
-
if (color
|
|
29583
|
+
if (this.color.alpha < 1 / 255) {
|
|
29439
29584
|
// Fast path: don't send fully transparent quads
|
|
29440
29585
|
return;
|
|
29441
|
-
} else {
|
|
29442
|
-
// use the global alpha
|
|
29443
|
-
tint[3] = color[3];
|
|
29444
29586
|
}
|
|
29445
29587
|
|
|
29446
|
-
|
|
29588
|
+
this.useShader(this.quadShader);
|
|
29589
|
+
|
|
29590
|
+
if (this.vertexBuffer.isFull(4)) {
|
|
29591
|
+
// is the vertex buffer full if we add 4 more vertices
|
|
29447
29592
|
this.flush();
|
|
29448
29593
|
}
|
|
29449
|
-
if (this.length >= this.sbSize) {
|
|
29450
|
-
this.resizeSB();
|
|
29451
|
-
}
|
|
29452
|
-
|
|
29453
|
-
this.useShader(this.quadShader);
|
|
29454
29594
|
|
|
29455
29595
|
// upload and activate the texture if necessary
|
|
29456
29596
|
var unit = this.uploadTexture(texture);
|
|
@@ -29459,56 +29599,22 @@
|
|
|
29459
29599
|
|
|
29460
29600
|
// Transform vertices
|
|
29461
29601
|
var m = this.viewMatrix,
|
|
29462
|
-
|
|
29463
|
-
|
|
29464
|
-
|
|
29465
|
-
|
|
29602
|
+
vec0 = V_ARRAY[0].set(x, y),
|
|
29603
|
+
vec1 = V_ARRAY[1].set(x + w, y),
|
|
29604
|
+
vec2 = V_ARRAY[2].set(x, y + h),
|
|
29605
|
+
vec3 = V_ARRAY[3].set(x + w, y + h);
|
|
29466
29606
|
|
|
29467
29607
|
if (!m.isIdentity()) {
|
|
29468
|
-
m.apply(
|
|
29469
|
-
m.apply(
|
|
29470
|
-
m.apply(
|
|
29471
|
-
m.apply(
|
|
29472
|
-
}
|
|
29473
|
-
|
|
29474
|
-
|
|
29475
|
-
|
|
29476
|
-
|
|
29477
|
-
|
|
29478
|
-
idx3 = idx2 + ELEMENT_SIZE;
|
|
29479
|
-
|
|
29480
|
-
// Fill vertex buffer
|
|
29481
|
-
// FIXME: Pack each vertex vector into single float
|
|
29482
|
-
this.stream[idx0 + VERTEX_ELEMENT + 0] = v0.x;
|
|
29483
|
-
this.stream[idx0 + VERTEX_ELEMENT + 1] = v0.y;
|
|
29484
|
-
this.stream[idx1 + VERTEX_ELEMENT + 0] = v1.x;
|
|
29485
|
-
this.stream[idx1 + VERTEX_ELEMENT + 1] = v1.y;
|
|
29486
|
-
this.stream[idx2 + VERTEX_ELEMENT + 0] = v2.x;
|
|
29487
|
-
this.stream[idx2 + VERTEX_ELEMENT + 1] = v2.y;
|
|
29488
|
-
this.stream[idx3 + VERTEX_ELEMENT + 0] = v3.x;
|
|
29489
|
-
this.stream[idx3 + VERTEX_ELEMENT + 1] = v3.y;
|
|
29490
|
-
|
|
29491
|
-
// Fill texture coordinates buffer
|
|
29492
|
-
var uvs = texture.getUVs(key);
|
|
29493
|
-
// FIXME: Pack each texture coordinate into single floats
|
|
29494
|
-
this.stream[idx0 + REGION_ELEMENT + 0] = uvs[0];
|
|
29495
|
-
this.stream[idx0 + REGION_ELEMENT + 1] = uvs[1];
|
|
29496
|
-
this.stream[idx1 + REGION_ELEMENT + 0] = uvs[2];
|
|
29497
|
-
this.stream[idx1 + REGION_ELEMENT + 1] = uvs[1];
|
|
29498
|
-
this.stream[idx2 + REGION_ELEMENT + 0] = uvs[0];
|
|
29499
|
-
this.stream[idx2 + REGION_ELEMENT + 1] = uvs[3];
|
|
29500
|
-
this.stream[idx3 + REGION_ELEMENT + 0] = uvs[2];
|
|
29501
|
-
this.stream[idx3 + REGION_ELEMENT + 1] = uvs[3];
|
|
29502
|
-
|
|
29503
|
-
// Fill color buffer
|
|
29504
|
-
// FIXME: Pack color vector into single float
|
|
29505
|
-
this.stream.set(tint, idx0 + COLOR_ELEMENT);
|
|
29506
|
-
this.stream.set(tint, idx1 + COLOR_ELEMENT);
|
|
29507
|
-
this.stream.set(tint, idx2 + COLOR_ELEMENT);
|
|
29508
|
-
this.stream.set(tint, idx3 + COLOR_ELEMENT);
|
|
29509
|
-
|
|
29510
|
-
this.sbIndex += ELEMENT_SIZE * ELEMENTS_PER_QUAD;
|
|
29511
|
-
this.length++;
|
|
29608
|
+
m.apply(vec0);
|
|
29609
|
+
m.apply(vec1);
|
|
29610
|
+
m.apply(vec2);
|
|
29611
|
+
m.apply(vec3);
|
|
29612
|
+
}
|
|
29613
|
+
|
|
29614
|
+
this.vertexBuffer.push(vec0.x, vec0.y, u0, v0, tint);
|
|
29615
|
+
this.vertexBuffer.push(vec1.x, vec1.y, u1, v0, tint);
|
|
29616
|
+
this.vertexBuffer.push(vec2.x, vec2.y, u0, v1, tint);
|
|
29617
|
+
this.vertexBuffer.push(vec3.x, vec3.y, u1, v1, tint);
|
|
29512
29618
|
};
|
|
29513
29619
|
|
|
29514
29620
|
/**
|
|
@@ -29517,28 +29623,34 @@
|
|
|
29517
29623
|
* @memberOf me.WebGLCompositor
|
|
29518
29624
|
* @function
|
|
29519
29625
|
*/
|
|
29520
|
-
WebGLCompositor.prototype.flush = function flush () {
|
|
29521
|
-
|
|
29626
|
+
WebGLCompositor.prototype.flush = function flush (mode) {
|
|
29627
|
+
if ( mode === void 0 ) mode = this.mode;
|
|
29628
|
+
|
|
29629
|
+
var vertex = this.vertexBuffer;
|
|
29630
|
+
var vertexCount = vertex.vertexCount;
|
|
29631
|
+
|
|
29632
|
+
if (vertexCount > 0) {
|
|
29522
29633
|
var gl = this.gl;
|
|
29634
|
+
var vertexSize = vertex.vertexSize;
|
|
29523
29635
|
|
|
29524
29636
|
// Copy data into stream buffer
|
|
29525
|
-
|
|
29526
|
-
|
|
29527
|
-
|
|
29528
|
-
|
|
29529
|
-
|
|
29530
|
-
);
|
|
29637
|
+
if (this.renderer.WebGLVersion > 1) {
|
|
29638
|
+
gl.bufferData(gl.ARRAY_BUFFER, vertex.toFloat32(), gl.STREAM_DRAW, 0, vertexCount * vertexSize);
|
|
29639
|
+
} else {
|
|
29640
|
+
gl.bufferData(gl.ARRAY_BUFFER, vertex.toFloat32(0, vertexCount * vertexSize), gl.STREAM_DRAW);
|
|
29641
|
+
}
|
|
29531
29642
|
|
|
29532
29643
|
// Draw the stream buffer
|
|
29533
|
-
|
|
29534
|
-
|
|
29535
|
-
|
|
29536
|
-
gl.
|
|
29537
|
-
|
|
29538
|
-
|
|
29644
|
+
// TODO : finalize the WebGLCompositor implementation (splitting this one into two)
|
|
29645
|
+
// so that different compositor with different attributes/uniforms & drawing method can be used
|
|
29646
|
+
if (this.activeShader === this.primitiveShader) {
|
|
29647
|
+
gl.drawArrays(mode, 0, vertexCount);
|
|
29648
|
+
} else {
|
|
29649
|
+
gl.drawElements(mode, vertexCount / vertex.quadSize * INDICES_PER_QUAD, gl.UNSIGNED_SHORT, 0);
|
|
29650
|
+
}
|
|
29539
29651
|
|
|
29540
|
-
|
|
29541
|
-
|
|
29652
|
+
// clear the vertex buffer
|
|
29653
|
+
vertex.clear();
|
|
29542
29654
|
}
|
|
29543
29655
|
};
|
|
29544
29656
|
|
|
@@ -29547,43 +29659,31 @@
|
|
|
29547
29659
|
* @name drawVertices
|
|
29548
29660
|
* @memberOf me.WebGLCompositor
|
|
29549
29661
|
* @function
|
|
29550
|
-
* @param {GLENUM}
|
|
29551
|
-
* @param {me.Vector2d[]}
|
|
29662
|
+
* @param {GLENUM} mode primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
29663
|
+
* @param {me.Vector2d[]} verts vertices
|
|
29552
29664
|
* @param {Number} [vertexCount=verts.length] amount of points defined in the points array
|
|
29553
29665
|
*/
|
|
29554
29666
|
WebGLCompositor.prototype.drawVertices = function drawVertices (mode, verts, vertexCount) {
|
|
29555
|
-
|
|
29556
|
-
|
|
29557
|
-
vertexCount = vertexCount || verts.length;
|
|
29667
|
+
if ( vertexCount === void 0 ) vertexCount = verts.length;
|
|
29558
29668
|
|
|
29559
29669
|
// use the primitive shader
|
|
29560
29670
|
this.useShader(this.primitiveShader);
|
|
29561
|
-
|
|
29562
29671
|
// Set the line color
|
|
29563
29672
|
this.primitiveShader.setUniform("uColor", this.color);
|
|
29564
29673
|
|
|
29565
|
-
// Put vertex data into the stream buffer
|
|
29566
|
-
var offset = 0;
|
|
29567
29674
|
var m = this.viewMatrix;
|
|
29675
|
+
var vertex = this.vertexBuffer;
|
|
29568
29676
|
var m_isIdentity = m.isIdentity();
|
|
29677
|
+
|
|
29569
29678
|
for (var i = 0; i < vertexCount; i++) {
|
|
29570
29679
|
if (!m_isIdentity) {
|
|
29571
29680
|
m.apply(verts[i]);
|
|
29572
29681
|
}
|
|
29573
|
-
|
|
29574
|
-
this.stream[offset + 1] = verts[i].y;
|
|
29575
|
-
offset += ELEMENT_SIZE;
|
|
29682
|
+
vertex.push(verts[i].x, verts[i].y);
|
|
29576
29683
|
}
|
|
29577
29684
|
|
|
29578
|
-
//
|
|
29579
|
-
|
|
29580
|
-
gl.ARRAY_BUFFER,
|
|
29581
|
-
this.stream.subarray(0, vertexCount * ELEMENT_SIZE),
|
|
29582
|
-
gl.STREAM_DRAW
|
|
29583
|
-
);
|
|
29584
|
-
|
|
29585
|
-
// Draw the stream buffer
|
|
29586
|
-
gl.drawArrays(mode, 0, vertexCount);
|
|
29685
|
+
// flush
|
|
29686
|
+
this.flush(mode);
|
|
29587
29687
|
};
|
|
29588
29688
|
|
|
29589
29689
|
/**
|
|
@@ -29640,14 +29740,6 @@
|
|
|
29640
29740
|
// parent contructor
|
|
29641
29741
|
Renderer.call(this, options);
|
|
29642
29742
|
|
|
29643
|
-
/**
|
|
29644
|
-
* The WebGL context
|
|
29645
|
-
* @name gl
|
|
29646
|
-
* @memberOf me.WebGLRenderer
|
|
29647
|
-
* type {WebGLRenderingContext}
|
|
29648
|
-
*/
|
|
29649
|
-
this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
|
|
29650
|
-
|
|
29651
29743
|
/**
|
|
29652
29744
|
* The WebGL version used by this renderer (1 or 2)
|
|
29653
29745
|
* @name WebGLVersion
|
|
@@ -29656,7 +29748,7 @@
|
|
|
29656
29748
|
* @default 1
|
|
29657
29749
|
* @readonly
|
|
29658
29750
|
*/
|
|
29659
|
-
this.
|
|
29751
|
+
this.WebGLVersion = 1;
|
|
29660
29752
|
|
|
29661
29753
|
/**
|
|
29662
29754
|
* The vendor string of the underlying graphics driver.
|
|
@@ -29678,6 +29770,14 @@
|
|
|
29678
29770
|
*/
|
|
29679
29771
|
this.GPURenderer = null;
|
|
29680
29772
|
|
|
29773
|
+
/**
|
|
29774
|
+
* The WebGL context
|
|
29775
|
+
* @name gl
|
|
29776
|
+
* @memberOf me.WebGLRenderer
|
|
29777
|
+
* type {WebGLRenderingContext}
|
|
29778
|
+
*/
|
|
29779
|
+
this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
|
|
29780
|
+
|
|
29681
29781
|
/**
|
|
29682
29782
|
* Maximum number of texture unit supported under the current context
|
|
29683
29783
|
* @name maxTextures
|
|
@@ -29958,14 +30058,18 @@
|
|
|
29958
30058
|
this.currentCompositor.uploadTexture(this.fontTexture, 0, 0, 0, true);
|
|
29959
30059
|
|
|
29960
30060
|
// Add the new quad
|
|
29961
|
-
var
|
|
30061
|
+
var uvs = this.fontTexture.getUVs(bounds.left + "," + bounds.top + "," + bounds.width + "," + bounds.height);
|
|
29962
30062
|
this.currentCompositor.addQuad(
|
|
29963
30063
|
this.fontTexture,
|
|
29964
|
-
key,
|
|
29965
30064
|
bounds.left,
|
|
29966
30065
|
bounds.top,
|
|
29967
30066
|
bounds.width,
|
|
29968
|
-
bounds.height
|
|
30067
|
+
bounds.height,
|
|
30068
|
+
uvs[0],
|
|
30069
|
+
uvs[1],
|
|
30070
|
+
uvs[2],
|
|
30071
|
+
uvs[3],
|
|
30072
|
+
this.currentTint.toUint32()
|
|
29969
30073
|
);
|
|
29970
30074
|
|
|
29971
30075
|
// Clear font context2D
|
|
@@ -30025,8 +30129,9 @@
|
|
|
30025
30129
|
dy |= 0;
|
|
30026
30130
|
}
|
|
30027
30131
|
|
|
30028
|
-
var
|
|
30029
|
-
|
|
30132
|
+
var texture = this.cache.get(image);
|
|
30133
|
+
var uvs = texture.getUVs(sx + "," + sy + "," + sw + "," + sh);
|
|
30134
|
+
this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
30030
30135
|
};
|
|
30031
30136
|
|
|
30032
30137
|
/**
|
|
@@ -30042,8 +30147,8 @@
|
|
|
30042
30147
|
* @see me.WebGLRenderer#createPattern
|
|
30043
30148
|
*/
|
|
30044
30149
|
WebGLRenderer.prototype.drawPattern = function drawPattern (pattern, x, y, width, height) {
|
|
30045
|
-
var
|
|
30046
|
-
this.currentCompositor.addQuad(pattern,
|
|
30150
|
+
var uvs = pattern.getUVs("0,0," + width + "," + height);
|
|
30151
|
+
this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
30047
30152
|
};
|
|
30048
30153
|
|
|
30049
30154
|
|
|
@@ -30257,7 +30362,7 @@
|
|
|
30257
30362
|
* @param {Number} alpha 0.0 to 1.0 values accepted.
|
|
30258
30363
|
*/
|
|
30259
30364
|
WebGLRenderer.prototype.setGlobalAlpha = function setGlobalAlpha (a) {
|
|
30260
|
-
this.currentColor.
|
|
30365
|
+
this.currentColor.alpha = a;
|
|
30261
30366
|
};
|
|
30262
30367
|
|
|
30263
30368
|
/**
|
|
@@ -30269,9 +30374,9 @@
|
|
|
30269
30374
|
* @param {me.Color|String} color css color string.
|
|
30270
30375
|
*/
|
|
30271
30376
|
WebGLRenderer.prototype.setColor = function setColor (color) {
|
|
30272
|
-
var alpha = this.currentColor.
|
|
30377
|
+
var alpha = this.currentColor.alpha;
|
|
30273
30378
|
this.currentColor.copy(color);
|
|
30274
|
-
this.currentColor.
|
|
30379
|
+
this.currentColor.alpha *= alpha;
|
|
30275
30380
|
};
|
|
30276
30381
|
|
|
30277
30382
|
/**
|
|
@@ -30534,7 +30639,7 @@
|
|
|
30534
30639
|
}
|
|
30535
30640
|
|
|
30536
30641
|
// calculate all vertices
|
|
30537
|
-
for (i = 0; i < indices.length; i
|
|
30642
|
+
for (i = 0; i < indices.length; i++ ) {
|
|
30538
30643
|
glPoints[i].set(x + points[indices[i]].x, y + points[indices[i]].y);
|
|
30539
30644
|
}
|
|
30540
30645
|
|
|
@@ -31037,9 +31142,9 @@
|
|
|
31037
31142
|
},
|
|
31038
31143
|
false
|
|
31039
31144
|
);
|
|
31040
|
-
|
|
31041
|
-
|
|
31042
|
-
window.screen.
|
|
31145
|
+
|
|
31146
|
+
if (device$1.ScreenOrientation === true) {
|
|
31147
|
+
window.screen.orientation.onchange = function (e) {
|
|
31043
31148
|
emit(WINDOW_ONORIENTATION_CHANGE, e);
|
|
31044
31149
|
};
|
|
31045
31150
|
}
|
|
@@ -31682,10 +31787,10 @@
|
|
|
31682
31787
|
* this can be overridden by the plugin
|
|
31683
31788
|
* @public
|
|
31684
31789
|
* @type String
|
|
31685
|
-
* @default "10.
|
|
31790
|
+
* @default "10.2.1"
|
|
31686
31791
|
* @name me.plugin.Base#version
|
|
31687
31792
|
*/
|
|
31688
|
-
this.version = "10.
|
|
31793
|
+
this.version = "10.2.1";
|
|
31689
31794
|
};
|
|
31690
31795
|
|
|
31691
31796
|
/**
|
|
@@ -32719,6 +32824,8 @@
|
|
|
32719
32824
|
* @ignore
|
|
32720
32825
|
*/
|
|
32721
32826
|
var setContextStyle = function(context, font, stroke) {
|
|
32827
|
+
if ( stroke === void 0 ) stroke = false;
|
|
32828
|
+
|
|
32722
32829
|
context.font = font.font;
|
|
32723
32830
|
context.fillStyle = font.fillStyle.toRGBA();
|
|
32724
32831
|
if (stroke === true) {
|
|
@@ -32748,7 +32855,8 @@
|
|
|
32748
32855
|
* @param {String} [settings.textBaseline="top"] the text baseline
|
|
32749
32856
|
* @param {Number} [settings.lineHeight=1.0] line spacing height
|
|
32750
32857
|
* @param {me.Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
32751
|
-
* @param {
|
|
32858
|
+
* @param {Boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
32859
|
+
* @param {(String|String[])} [settings.text=""] a string, or an array of strings
|
|
32752
32860
|
* @example
|
|
32753
32861
|
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
32754
32862
|
*/
|
|
@@ -32841,6 +32949,17 @@
|
|
|
32841
32949
|
*/
|
|
32842
32950
|
this.lineHeight = settings.lineHeight || 1.0;
|
|
32843
32951
|
|
|
32952
|
+
/**
|
|
32953
|
+
* whether to draw the font to a indidividual offscreen canvas texture first <br>
|
|
32954
|
+
* Note: this will improve performances when using WebGL, but will impact
|
|
32955
|
+
* memory consumption as every text element will have its own canvas texture
|
|
32956
|
+
* @public
|
|
32957
|
+
* @type Boolean
|
|
32958
|
+
* @default false
|
|
32959
|
+
* @name me.Text#offScreenCanvas
|
|
32960
|
+
*/
|
|
32961
|
+
this.offScreenCanvas = false;
|
|
32962
|
+
|
|
32844
32963
|
/**
|
|
32845
32964
|
* the text to be displayed
|
|
32846
32965
|
* @private
|
|
@@ -32883,8 +33002,31 @@
|
|
|
32883
33002
|
this.italic();
|
|
32884
33003
|
}
|
|
32885
33004
|
|
|
33005
|
+
if (settings.offScreenCanvas === true) {
|
|
33006
|
+
this.offScreenCanvas = true;
|
|
33007
|
+
this.canvas = createCanvas(2, 2, true);
|
|
33008
|
+
this.context = this.canvas.getContext("2d");
|
|
33009
|
+
}
|
|
33010
|
+
|
|
32886
33011
|
// set the text
|
|
32887
33012
|
this.setText(settings.text);
|
|
33013
|
+
|
|
33014
|
+
// force update bounds on object creation
|
|
33015
|
+
this.update(0);
|
|
33016
|
+
};
|
|
33017
|
+
|
|
33018
|
+
/** @ignore */
|
|
33019
|
+
Text.prototype.onDeactivateEvent = function onDeactivateEvent () {
|
|
33020
|
+
// free the canvas and potential corresponding texture when deactivated
|
|
33021
|
+
if (this.offScreenCanvas === true) {
|
|
33022
|
+
if (renderer instanceof WebGLRenderer) {
|
|
33023
|
+
renderer.currentCompositor.unbindTexture2D(renderer.cache.get(this.canvas));
|
|
33024
|
+
renderer.cache.remove(this.canvas);
|
|
33025
|
+
}
|
|
33026
|
+
this.canvas.width = this.canvas.height = 0;
|
|
33027
|
+
this.context = undefined;
|
|
33028
|
+
this.canvas = undefined;
|
|
33029
|
+
}
|
|
32888
33030
|
};
|
|
32889
33031
|
|
|
32890
33032
|
/**
|
|
@@ -32966,9 +33108,7 @@
|
|
|
32966
33108
|
* @return this object for chaining
|
|
32967
33109
|
*/
|
|
32968
33110
|
Text.prototype.setText = function setText (value) {
|
|
32969
|
-
if (
|
|
32970
|
-
value = "";
|
|
32971
|
-
}
|
|
33111
|
+
if ( value === void 0 ) value = "";
|
|
32972
33112
|
|
|
32973
33113
|
if (this._text.toString() !== value.toString()) {
|
|
32974
33114
|
if (!Array.isArray(value)) {
|
|
@@ -32987,28 +33127,25 @@
|
|
|
32987
33127
|
* @name measureText
|
|
32988
33128
|
* @memberOf me.Text.prototype
|
|
32989
33129
|
* @function
|
|
32990
|
-
* @param {me.CanvasRenderer|me.WebGLRenderer} [renderer] reference
|
|
33130
|
+
* @param {me.CanvasRenderer|me.WebGLRenderer} [renderer] reference to the active renderer
|
|
32991
33131
|
* @param {String} [text] the text to be measured
|
|
32992
33132
|
* @param {me.Rect|me.Bounds} [ret] a object in which to store the text metrics
|
|
32993
33133
|
* @returns {TextMetrics} a TextMetrics object with two properties: `width` and `height`, defining the output dimensions
|
|
32994
33134
|
*/
|
|
32995
33135
|
Text.prototype.measureText = function measureText (_renderer, text, ret) {
|
|
32996
33136
|
var context;
|
|
33137
|
+
var textMetrics = ret || this.getBounds();
|
|
33138
|
+
var lineHeight = this.fontSize * this.lineHeight;
|
|
33139
|
+
var strings = typeof text !== "undefined" ? ("" + (text)).split("\n") : this._text;
|
|
32997
33140
|
|
|
32998
|
-
if (
|
|
32999
|
-
context =
|
|
33141
|
+
if (this.offScreenCanvas === true) {
|
|
33142
|
+
context = this.context;
|
|
33000
33143
|
} else if (_renderer instanceof Renderer) {
|
|
33001
33144
|
context = _renderer.getFontContext();
|
|
33002
33145
|
} else {
|
|
33003
|
-
|
|
33004
|
-
context = _renderer;
|
|
33146
|
+
context = renderer.getFontContext();
|
|
33005
33147
|
}
|
|
33006
33148
|
|
|
33007
|
-
var textMetrics = ret || this.getBounds();
|
|
33008
|
-
var lineHeight = this.fontSize * this.lineHeight;
|
|
33009
|
-
|
|
33010
|
-
var strings = typeof text !== "undefined" ? ("" + (text)).split("\n") : this._text;
|
|
33011
|
-
|
|
33012
33149
|
// save the previous context
|
|
33013
33150
|
context.save();
|
|
33014
33151
|
|
|
@@ -33044,7 +33181,33 @@
|
|
|
33044
33181
|
*/
|
|
33045
33182
|
Text.prototype.update = function update (/* dt */) {
|
|
33046
33183
|
if (this.isDirty === true) {
|
|
33047
|
-
this.measureText();
|
|
33184
|
+
var bounds = this.measureText(renderer);
|
|
33185
|
+
if (this.offScreenCanvas === true) {
|
|
33186
|
+
var width = Math.round(bounds.width),
|
|
33187
|
+
height = Math.round(bounds.height);
|
|
33188
|
+
|
|
33189
|
+
if (renderer instanceof WebGLRenderer) {
|
|
33190
|
+
// invalidate the previous corresponding texture so that it can reuploaded once changed
|
|
33191
|
+
renderer.currentCompositor.unbindTexture2D(renderer.cache.get(this.canvas));
|
|
33192
|
+
|
|
33193
|
+
if (renderer.WebGLVersion === 1) {
|
|
33194
|
+
// round size to next Pow2
|
|
33195
|
+
width = nextPowerOfTwo(bounds.width);
|
|
33196
|
+
height = nextPowerOfTwo(bounds.height);
|
|
33197
|
+
}
|
|
33198
|
+
}
|
|
33199
|
+
|
|
33200
|
+
// resize the cache canvas if necessary
|
|
33201
|
+
if (this.canvas.width < width || this.canvas.height < height) {
|
|
33202
|
+
this.canvas.width = width;
|
|
33203
|
+
this.canvas.height = height;
|
|
33204
|
+
// resizing the canvas will automatically clear its content
|
|
33205
|
+
} else {
|
|
33206
|
+
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
|
33207
|
+
}
|
|
33208
|
+
this._drawFont(this.context, this._text, this.pos.x - bounds.x, this.pos.y - bounds.y, false);
|
|
33209
|
+
|
|
33210
|
+
}
|
|
33048
33211
|
}
|
|
33049
33212
|
return this.isDirty;
|
|
33050
33213
|
};
|
|
@@ -33094,7 +33257,12 @@
|
|
|
33094
33257
|
}
|
|
33095
33258
|
|
|
33096
33259
|
// draw the text
|
|
33097
|
-
|
|
33260
|
+
if (this.offScreenCanvas === true) {
|
|
33261
|
+
renderer.drawImage(this.canvas, this.getBounds().x, this.getBounds().y);
|
|
33262
|
+
} else {
|
|
33263
|
+
renderer.drawFont(this._drawFont(renderer.getFontContext(), this._text, x, y, stroke));
|
|
33264
|
+
}
|
|
33265
|
+
|
|
33098
33266
|
|
|
33099
33267
|
// for backward compatibilty
|
|
33100
33268
|
if (typeof this.ancestor === "undefined") {
|
|
@@ -33127,6 +33295,8 @@
|
|
|
33127
33295
|
* @ignore
|
|
33128
33296
|
*/
|
|
33129
33297
|
Text.prototype._drawFont = function _drawFont (context, text, x, y, stroke) {
|
|
33298
|
+
if ( stroke === void 0 ) stroke = false;
|
|
33299
|
+
|
|
33130
33300
|
setContextStyle(context, this, stroke);
|
|
33131
33301
|
|
|
33132
33302
|
var lineHeight = this.fontSize * this.lineHeight;
|
|
@@ -34044,6 +34214,8 @@
|
|
|
34044
34214
|
else {
|
|
34045
34215
|
this.pos.y = y;
|
|
34046
34216
|
}
|
|
34217
|
+
|
|
34218
|
+
this.isDirty = true;
|
|
34047
34219
|
};
|
|
34048
34220
|
|
|
34049
34221
|
/*
|
|
@@ -34114,6 +34286,216 @@
|
|
|
34114
34286
|
return ImageLayer;
|
|
34115
34287
|
}(Sprite));
|
|
34116
34288
|
|
|
34289
|
+
/**
|
|
34290
|
+
* @classdesc
|
|
34291
|
+
* A NineSliceSprite is similar to a Sprite, but it uses 9-slice scaling to strech its inner area to fit the size of the Renderable,
|
|
34292
|
+
* by proportionally scaling a sprite by splitting it in a grid of nine parts (with only parts 1, 3, 7, 9 not being scaled). <br>
|
|
34293
|
+
* <img src="images/9-slice-scaling.png"/><br>
|
|
34294
|
+
* @see https://en.wikipedia.org/wiki/9-slice_scaling
|
|
34295
|
+
* @class NineSliceSprite
|
|
34296
|
+
* @extends me.Sprite
|
|
34297
|
+
* @memberOf me
|
|
34298
|
+
* @constructor
|
|
34299
|
+
* @param {Number} x the x coordinates of the sprite object
|
|
34300
|
+
* @param {Number} y the y coordinates of the sprite object
|
|
34301
|
+
* @param {Object} settings Configuration parameters for the Sprite object
|
|
34302
|
+
* @param {Number} settings.width the width of the Renderable over which the sprite needs to be stretched
|
|
34303
|
+
* @param {Number} settings.height the height of the Renderable over which the sprite needs to be stretched
|
|
34304
|
+
* @param {me.Renderer.Texture|HTMLImageElement|HTMLCanvasElement|String} settings.image reference to a texture, spritesheet image or to a texture atlas
|
|
34305
|
+
* @param {String} [settings.name=""] name of this object
|
|
34306
|
+
* @param {String} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
|
|
34307
|
+
* @param {Number} [settings.framewidth] Width of a single frame within the spritesheet
|
|
34308
|
+
* @param {Number} [settings.frameheight] Height of a single frame within the spritesheet
|
|
34309
|
+
* @param {String|me.Color} [settings.tint] a tint to be applied to this sprite
|
|
34310
|
+
* @param {Number} [settings.flipX] flip the sprite on the horizontal axis
|
|
34311
|
+
* @param {Number} [settings.flipY] flip the sprite on the vertical axis
|
|
34312
|
+
* @param {me.Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
|
|
34313
|
+
* @example
|
|
34314
|
+
* this.panelSprite = new me.NineSliceSprite(0, 0, {
|
|
34315
|
+
* image : game.texture,
|
|
34316
|
+
* region : "grey_panel",
|
|
34317
|
+
* width : this.width,
|
|
34318
|
+
* height : this.height
|
|
34319
|
+
* });
|
|
34320
|
+
*/
|
|
34321
|
+
|
|
34322
|
+
var NineSliceSprite = /*@__PURE__*/(function (Sprite) {
|
|
34323
|
+
function NineSliceSprite(x, y, settings) {
|
|
34324
|
+
// call the super constructor
|
|
34325
|
+
Sprite.call(this, x, y, settings);
|
|
34326
|
+
|
|
34327
|
+
// ensure mandatory properties are defined
|
|
34328
|
+
if ((typeof settings.width !== "number") || (typeof settings.height !== "number")) {
|
|
34329
|
+
throw new Error("height and width properties are mandatory");
|
|
34330
|
+
}
|
|
34331
|
+
|
|
34332
|
+
// override the renderable sprite with the given one
|
|
34333
|
+
// resize based on the active frame
|
|
34334
|
+
this.width = settings.width;
|
|
34335
|
+
this.height = settings.height;
|
|
34336
|
+
}
|
|
34337
|
+
|
|
34338
|
+
if ( Sprite ) NineSliceSprite.__proto__ = Sprite;
|
|
34339
|
+
NineSliceSprite.prototype = Object.create( Sprite && Sprite.prototype );
|
|
34340
|
+
NineSliceSprite.prototype.constructor = NineSliceSprite;
|
|
34341
|
+
|
|
34342
|
+
/**
|
|
34343
|
+
* @ignore
|
|
34344
|
+
*/
|
|
34345
|
+
NineSliceSprite.prototype.draw = function draw (renderer) {
|
|
34346
|
+
// the frame to draw
|
|
34347
|
+
var frame = this.current;
|
|
34348
|
+
|
|
34349
|
+
// cache the current position and size
|
|
34350
|
+
var dx = this.pos.x,
|
|
34351
|
+
dy = this.pos.y;
|
|
34352
|
+
|
|
34353
|
+
var w = frame.width,
|
|
34354
|
+
h = frame.height;
|
|
34355
|
+
|
|
34356
|
+
// frame offset in the texture/atlas
|
|
34357
|
+
var frame_offset = frame.offset;
|
|
34358
|
+
var g_offset = this.offset;
|
|
34359
|
+
|
|
34360
|
+
|
|
34361
|
+
// remove image's TexturePacker/ShoeBox rotation
|
|
34362
|
+
if (frame.angle !== 0) {
|
|
34363
|
+
renderer.translate(-dx, -dy);
|
|
34364
|
+
renderer.rotate(frame.angle);
|
|
34365
|
+
dx -= h;
|
|
34366
|
+
w = frame.height;
|
|
34367
|
+
h = frame.width;
|
|
34368
|
+
}
|
|
34369
|
+
|
|
34370
|
+
var sx = g_offset.x + frame_offset.x,
|
|
34371
|
+
sy = g_offset.y + frame_offset.y;
|
|
34372
|
+
|
|
34373
|
+
// should this be configurable ?
|
|
34374
|
+
var corner_width = frame.width / 4,
|
|
34375
|
+
corner_height = frame.height / 4;
|
|
34376
|
+
|
|
34377
|
+
// OPTIMIZE ME !
|
|
34378
|
+
|
|
34379
|
+
// DRAW CORNERS
|
|
34380
|
+
|
|
34381
|
+
// Top Left
|
|
34382
|
+
renderer.drawImage(
|
|
34383
|
+
this.image,
|
|
34384
|
+
sx, // sx
|
|
34385
|
+
sy, // sy
|
|
34386
|
+
corner_width, corner_height, // sw,sh
|
|
34387
|
+
dx, dy, // dx,dy
|
|
34388
|
+
corner_width, corner_height // dw,dh
|
|
34389
|
+
);
|
|
34390
|
+
|
|
34391
|
+
// Top Right
|
|
34392
|
+
renderer.drawImage(
|
|
34393
|
+
this.image,
|
|
34394
|
+
sx + w - corner_width, // sx
|
|
34395
|
+
sy, // sy
|
|
34396
|
+
corner_width, corner_height, // sw,sh
|
|
34397
|
+
dx + this.width - corner_width, // dx
|
|
34398
|
+
dy, // dy
|
|
34399
|
+
corner_width, corner_height // dw,dh
|
|
34400
|
+
);
|
|
34401
|
+
// Bottom Left
|
|
34402
|
+
renderer.drawImage(
|
|
34403
|
+
this.image,
|
|
34404
|
+
sx, // sx
|
|
34405
|
+
sy + h - corner_height, // sy
|
|
34406
|
+
corner_width, corner_height, // sw,sh
|
|
34407
|
+
dx, // dx
|
|
34408
|
+
dy + this.height - corner_height, // dy
|
|
34409
|
+
corner_width, corner_height // dw,dh
|
|
34410
|
+
);
|
|
34411
|
+
// Bottom Right
|
|
34412
|
+
renderer.drawImage(
|
|
34413
|
+
this.image,
|
|
34414
|
+
sx + w - corner_width, // sx
|
|
34415
|
+
sy + h - corner_height, // sy
|
|
34416
|
+
corner_width, corner_height, // sw,sh
|
|
34417
|
+
dx + this.width - corner_width, //dx
|
|
34418
|
+
dy + this.height - corner_height, // dy
|
|
34419
|
+
corner_width, corner_height // dw,dh
|
|
34420
|
+
);
|
|
34421
|
+
|
|
34422
|
+
|
|
34423
|
+
// DRAW SIDES and CENTER
|
|
34424
|
+
var image_center_width = w - (corner_width << 1);
|
|
34425
|
+
var image_center_height = h - (corner_height << 1);
|
|
34426
|
+
|
|
34427
|
+
var target_center_width = this.width - (corner_width << 1);
|
|
34428
|
+
var target_center_height = this.height - (corner_height << 1);
|
|
34429
|
+
|
|
34430
|
+
//Top center
|
|
34431
|
+
renderer.drawImage(
|
|
34432
|
+
this.image,
|
|
34433
|
+
sx + corner_width, // sx
|
|
34434
|
+
sy, // sy
|
|
34435
|
+
image_center_width, // sw
|
|
34436
|
+
corner_height, // sh
|
|
34437
|
+
dx + corner_width, // dx
|
|
34438
|
+
dy, // dy
|
|
34439
|
+
target_center_width, // dw
|
|
34440
|
+
corner_height // dh
|
|
34441
|
+
);
|
|
34442
|
+
|
|
34443
|
+
//Bottom center
|
|
34444
|
+
renderer.drawImage(
|
|
34445
|
+
this.image,
|
|
34446
|
+
sx + corner_width, // sx
|
|
34447
|
+
sy + h - corner_height, // sy
|
|
34448
|
+
image_center_width, // sw
|
|
34449
|
+
corner_height, // sh
|
|
34450
|
+
dx + corner_width, // dx
|
|
34451
|
+
dy + this.height - corner_height, // dx
|
|
34452
|
+
target_center_width, // dw
|
|
34453
|
+
corner_height // dh
|
|
34454
|
+
);
|
|
34455
|
+
|
|
34456
|
+
// Middle Left
|
|
34457
|
+
renderer.drawImage(
|
|
34458
|
+
this.image,
|
|
34459
|
+
sx, // sx
|
|
34460
|
+
sy + corner_height, // sy
|
|
34461
|
+
corner_width, // sw
|
|
34462
|
+
image_center_height, // sh
|
|
34463
|
+
dx, // dx
|
|
34464
|
+
dy + corner_height, // dy
|
|
34465
|
+
corner_width, // dw
|
|
34466
|
+
target_center_height // dh
|
|
34467
|
+
);
|
|
34468
|
+
|
|
34469
|
+
// Middle Right
|
|
34470
|
+
renderer.drawImage(
|
|
34471
|
+
this.image,
|
|
34472
|
+
sx + w - corner_width, // sx
|
|
34473
|
+
sy + corner_height, // sy
|
|
34474
|
+
corner_width, // sw
|
|
34475
|
+
image_center_height, // sh
|
|
34476
|
+
dx + this.width - corner_width, // dx
|
|
34477
|
+
dy + corner_height, // dy
|
|
34478
|
+
corner_width, // dw
|
|
34479
|
+
target_center_height // dh
|
|
34480
|
+
);
|
|
34481
|
+
|
|
34482
|
+
// Middle Center
|
|
34483
|
+
renderer.drawImage(
|
|
34484
|
+
this.image,
|
|
34485
|
+
sx + corner_width, // sx
|
|
34486
|
+
sy + corner_height, // sy
|
|
34487
|
+
image_center_width, // sw
|
|
34488
|
+
image_center_height, // sh
|
|
34489
|
+
dx + corner_width, // dx
|
|
34490
|
+
dy + corner_height, // dy
|
|
34491
|
+
target_center_width, // dw
|
|
34492
|
+
target_center_height // dh
|
|
34493
|
+
);
|
|
34494
|
+
};
|
|
34495
|
+
|
|
34496
|
+
return NineSliceSprite;
|
|
34497
|
+
}(Sprite));
|
|
34498
|
+
|
|
34117
34499
|
/**
|
|
34118
34500
|
* @classdesc
|
|
34119
34501
|
* GUI Object<br>
|
|
@@ -35952,7 +36334,7 @@
|
|
|
35952
36334
|
* @name version
|
|
35953
36335
|
* @type {string}
|
|
35954
36336
|
*/
|
|
35955
|
-
var version = "10.
|
|
36337
|
+
var version = "10.2.1";
|
|
35956
36338
|
|
|
35957
36339
|
|
|
35958
36340
|
/**
|
|
@@ -35997,6 +36379,7 @@
|
|
|
35997
36379
|
pool.register("me.Color", Color, true);
|
|
35998
36380
|
pool.register("me.Particle", Particle, true);
|
|
35999
36381
|
pool.register("me.Sprite", Sprite);
|
|
36382
|
+
pool.register("me.NineSliceSprite", NineSliceSprite);
|
|
36000
36383
|
pool.register("me.Renderable", Renderable);
|
|
36001
36384
|
pool.register("me.Text", Text, true);
|
|
36002
36385
|
pool.register("me.BitmapText", BitmapText);
|
|
@@ -36023,6 +36406,7 @@
|
|
|
36023
36406
|
pool.register("Color", Color, true);
|
|
36024
36407
|
pool.register("Particle", Particle, true);
|
|
36025
36408
|
pool.register("Sprite", Sprite);
|
|
36409
|
+
pool.register("NineSliceSprite", NineSliceSprite);
|
|
36026
36410
|
pool.register("Renderable", Renderable);
|
|
36027
36411
|
pool.register("Text", Text, true);
|
|
36028
36412
|
pool.register("BitmapText", BitmapText);
|
|
@@ -36081,6 +36465,7 @@
|
|
|
36081
36465
|
exports.Math = math;
|
|
36082
36466
|
exports.Matrix2d = Matrix2d;
|
|
36083
36467
|
exports.Matrix3d = Matrix3d;
|
|
36468
|
+
exports.NineSliceSprite = NineSliceSprite;
|
|
36084
36469
|
exports.ObservableVector2d = ObservableVector2d;
|
|
36085
36470
|
exports.ObservableVector3d = ObservableVector3d;
|
|
36086
36471
|
exports.Particle = Particle;
|