melonjs 10.7.1 → 10.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/melonjs.js +1131 -652
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +1038 -198
- package/dist/melonjs.module.js +1234 -763
- package/package.json +7 -7
- package/src/camera/camera2d.js +1 -1
- package/src/entity/entity.js +6 -7
- package/src/geometries/ellipse.js +10 -11
- package/src/geometries/line.js +3 -3
- package/src/geometries/path2d.js +319 -0
- package/src/geometries/poly.js +11 -11
- package/src/geometries/rectangle.js +15 -15
- package/src/geometries/roundrect.js +67 -0
- package/src/index.js +5 -1
- package/src/input/pointerevent.js +1 -1
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXObject.js +9 -12
- package/src/level/tiled/TMXTileMap.js +23 -4
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/loader.js +4 -4
- package/src/loader/loadingscreen.js +1 -1
- package/src/math/color.js +1 -1
- package/src/math/matrix2.js +1 -1
- package/src/math/matrix3.js +1 -1
- package/src/math/observable_vector2.js +1 -1
- package/src/math/observable_vector3.js +1 -1
- package/src/math/vector2.js +1 -1
- package/src/math/vector3.js +1 -1
- package/src/particles/emitter.js +23 -14
- package/src/particles/particle.js +3 -2
- package/src/physics/body.js +67 -51
- package/src/physics/bounds.js +8 -9
- package/src/physics/world.js +1 -1
- package/src/renderable/collectable.js +9 -2
- package/src/renderable/colorlayer.js +1 -1
- package/src/renderable/container.js +1 -1
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/renderable.js +1 -1
- package/src/renderable/sprite.js +2 -3
- package/src/renderable/trigger.js +10 -4
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +10 -8
- package/src/system/pooling.js +156 -149
- package/src/text/bitmaptext.js +1 -1
- package/src/text/text.js +1 -1
- package/src/video/canvas/canvas_renderer.js +89 -34
- package/src/video/renderer.js +26 -14
- package/src/video/texture.js +1 -1
- package/src/video/webgl/glshader.js +29 -193
- package/src/video/webgl/utils/attributes.js +16 -0
- package/src/video/webgl/utils/precision.js +11 -0
- package/src/video/webgl/utils/program.js +58 -0
- package/src/video/webgl/utils/string.js +16 -0
- package/src/video/webgl/utils/uniforms.js +87 -0
- package/src/video/webgl/webgl_compositor.js +1 -14
- package/src/video/webgl/webgl_renderer.js +123 -181
package/dist/melonjs.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
2
|
+
* melonJS Game Engine - v10.8.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -317,10 +317,10 @@ var store$2 = sharedStore;
|
|
|
317
317
|
(shared$3.exports = function (key, value) {
|
|
318
318
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
319
319
|
})('versions', []).push({
|
|
320
|
-
version: '3.22.
|
|
320
|
+
version: '3.22.5',
|
|
321
321
|
mode: 'global',
|
|
322
322
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
323
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.22.
|
|
323
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.22.5/LICENSE',
|
|
324
324
|
source: 'https://github.com/zloirock/core-js'
|
|
325
325
|
});
|
|
326
326
|
|
|
@@ -430,19 +430,19 @@ var documentCreateElement = function (it) {
|
|
|
430
430
|
return EXISTS$1 ? document$1.createElement(it) : {};
|
|
431
431
|
};
|
|
432
432
|
|
|
433
|
-
var DESCRIPTORS$
|
|
433
|
+
var DESCRIPTORS$6 = descriptors;
|
|
434
434
|
var fails$3 = fails$8;
|
|
435
435
|
var createElement = documentCreateElement;
|
|
436
436
|
|
|
437
437
|
// Thanks to IE8 for its funny defineProperty
|
|
438
|
-
var ie8DomDefine = !DESCRIPTORS$
|
|
438
|
+
var ie8DomDefine = !DESCRIPTORS$6 && !fails$3(function () {
|
|
439
439
|
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
440
440
|
return Object.defineProperty(createElement('div'), 'a', {
|
|
441
441
|
get: function () { return 7; }
|
|
442
442
|
}).a != 7;
|
|
443
443
|
});
|
|
444
444
|
|
|
445
|
-
var DESCRIPTORS$
|
|
445
|
+
var DESCRIPTORS$5 = descriptors;
|
|
446
446
|
var call = functionCall;
|
|
447
447
|
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
448
448
|
var createPropertyDescriptor$1 = createPropertyDescriptor$2;
|
|
@@ -456,7 +456,7 @@ var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
|
|
|
456
456
|
|
|
457
457
|
// `Object.getOwnPropertyDescriptor` method
|
|
458
458
|
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
|
459
|
-
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$
|
|
459
|
+
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$5 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
|
|
460
460
|
O = toIndexedObject$2(O);
|
|
461
461
|
P = toPropertyKey$1(P);
|
|
462
462
|
if (IE8_DOM_DEFINE$1) try {
|
|
@@ -467,12 +467,12 @@ objectGetOwnPropertyDescriptor.f = DESCRIPTORS$4 ? $getOwnPropertyDescriptor$1 :
|
|
|
467
467
|
|
|
468
468
|
var objectDefineProperty = {};
|
|
469
469
|
|
|
470
|
-
var DESCRIPTORS$
|
|
470
|
+
var DESCRIPTORS$4 = descriptors;
|
|
471
471
|
var fails$2 = fails$8;
|
|
472
472
|
|
|
473
473
|
// V8 ~ Chrome 36-
|
|
474
474
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
|
475
|
-
var v8PrototypeDefineBug = DESCRIPTORS$
|
|
475
|
+
var v8PrototypeDefineBug = DESCRIPTORS$4 && fails$2(function () {
|
|
476
476
|
// eslint-disable-next-line es-x/no-object-defineproperty -- required for testing
|
|
477
477
|
return Object.defineProperty(function () { /* empty */ }, 'prototype', {
|
|
478
478
|
value: 42,
|
|
@@ -493,7 +493,7 @@ var anObject$2 = function (argument) {
|
|
|
493
493
|
};
|
|
494
494
|
|
|
495
495
|
var global$6 = global$m;
|
|
496
|
-
var DESCRIPTORS$
|
|
496
|
+
var DESCRIPTORS$3 = descriptors;
|
|
497
497
|
var IE8_DOM_DEFINE = ie8DomDefine;
|
|
498
498
|
var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
|
|
499
499
|
var anObject$1 = anObject$2;
|
|
@@ -510,7 +510,7 @@ var WRITABLE = 'writable';
|
|
|
510
510
|
|
|
511
511
|
// `Object.defineProperty` method
|
|
512
512
|
// https://tc39.es/ecma262/#sec-object.defineproperty
|
|
513
|
-
objectDefineProperty.f = DESCRIPTORS$
|
|
513
|
+
objectDefineProperty.f = DESCRIPTORS$3 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
|
|
514
514
|
anObject$1(O);
|
|
515
515
|
P = toPropertyKey(P);
|
|
516
516
|
anObject$1(Attributes);
|
|
@@ -537,11 +537,11 @@ objectDefineProperty.f = DESCRIPTORS$2 ? V8_PROTOTYPE_DEFINE_BUG ? function defi
|
|
|
537
537
|
return O;
|
|
538
538
|
};
|
|
539
539
|
|
|
540
|
-
var DESCRIPTORS$
|
|
540
|
+
var DESCRIPTORS$2 = descriptors;
|
|
541
541
|
var definePropertyModule$1 = objectDefineProperty;
|
|
542
542
|
var createPropertyDescriptor = createPropertyDescriptor$2;
|
|
543
543
|
|
|
544
|
-
var createNonEnumerableProperty$3 = DESCRIPTORS$
|
|
544
|
+
var createNonEnumerableProperty$3 = DESCRIPTORS$2 ? function (object, key, value) {
|
|
545
545
|
return definePropertyModule$1.f(object, key, createPropertyDescriptor(1, value));
|
|
546
546
|
} : function (object, key, value) {
|
|
547
547
|
object[key] = value;
|
|
@@ -550,17 +550,17 @@ var createNonEnumerableProperty$3 = DESCRIPTORS$1 ? function (object, key, value
|
|
|
550
550
|
|
|
551
551
|
var makeBuiltIn$2 = {exports: {}};
|
|
552
552
|
|
|
553
|
-
var DESCRIPTORS = descriptors;
|
|
553
|
+
var DESCRIPTORS$1 = descriptors;
|
|
554
554
|
var hasOwn$4 = hasOwnProperty_1;
|
|
555
555
|
|
|
556
556
|
var FunctionPrototype = Function.prototype;
|
|
557
557
|
// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe
|
|
558
|
-
var getDescriptor = DESCRIPTORS && Object.getOwnPropertyDescriptor;
|
|
558
|
+
var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
|
|
559
559
|
|
|
560
560
|
var EXISTS = hasOwn$4(FunctionPrototype, 'name');
|
|
561
561
|
// additional protection from minified / mangled / dropped function names
|
|
562
562
|
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
563
|
-
var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
563
|
+
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || (DESCRIPTORS$1 && getDescriptor(FunctionPrototype, 'name').configurable));
|
|
564
564
|
|
|
565
565
|
var functionName = {
|
|
566
566
|
EXISTS: EXISTS,
|
|
@@ -675,15 +675,17 @@ var internalState = {
|
|
|
675
675
|
var fails$1 = fails$8;
|
|
676
676
|
var isCallable$2 = isCallable$a;
|
|
677
677
|
var hasOwn$2 = hasOwnProperty_1;
|
|
678
|
-
var
|
|
678
|
+
var DESCRIPTORS = descriptors;
|
|
679
679
|
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
|
|
680
680
|
var inspectSource = inspectSource$2;
|
|
681
681
|
var InternalStateModule = internalState;
|
|
682
682
|
|
|
683
683
|
var enforceInternalState = InternalStateModule.enforce;
|
|
684
684
|
var getInternalState = InternalStateModule.get;
|
|
685
|
+
// eslint-disable-next-line es-x/no-object-defineproperty -- safe
|
|
686
|
+
var defineProperty = Object.defineProperty;
|
|
685
687
|
|
|
686
|
-
var CONFIGURABLE_LENGTH = !fails$1(function () {
|
|
688
|
+
var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails$1(function () {
|
|
687
689
|
return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8;
|
|
688
690
|
});
|
|
689
691
|
|
|
@@ -701,6 +703,11 @@ var makeBuiltIn$1 = makeBuiltIn$2.exports = function (value, name, options) {
|
|
|
701
703
|
if (CONFIGURABLE_LENGTH && options && hasOwn$2(options, 'arity') && value.length !== options.arity) {
|
|
702
704
|
defineProperty(value, 'length', { value: options.arity });
|
|
703
705
|
}
|
|
706
|
+
if (options && hasOwn$2(options, 'constructor') && options.constructor) {
|
|
707
|
+
if (DESCRIPTORS) try {
|
|
708
|
+
defineProperty(value, 'prototype', { writable: false });
|
|
709
|
+
} catch (error) { /* empty */ }
|
|
710
|
+
} else value.prototype = undefined;
|
|
704
711
|
var state = enforceInternalState(value);
|
|
705
712
|
if (!hasOwn$2(state, 'source')) {
|
|
706
713
|
state.source = TEMPLATE.join(typeof name == 'string' ? name : '');
|
|
@@ -822,17 +829,17 @@ var toIndexedObject = toIndexedObject$3;
|
|
|
822
829
|
var indexOf = arrayIncludes.indexOf;
|
|
823
830
|
var hiddenKeys$1 = hiddenKeys$3;
|
|
824
831
|
|
|
825
|
-
var push
|
|
832
|
+
var push = uncurryThis$1([].push);
|
|
826
833
|
|
|
827
834
|
var objectKeysInternal = function (object, names) {
|
|
828
835
|
var O = toIndexedObject(object);
|
|
829
836
|
var i = 0;
|
|
830
837
|
var result = [];
|
|
831
838
|
var key;
|
|
832
|
-
for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push
|
|
839
|
+
for (key in O) !hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push(result, key);
|
|
833
840
|
// Don't enum bug & hidden keys
|
|
834
841
|
while (names.length > i) if (hasOwn$1(O, key = names[i++])) {
|
|
835
|
-
~indexOf(result, key) || push
|
|
842
|
+
~indexOf(result, key) || push(result, key);
|
|
836
843
|
}
|
|
837
844
|
return result;
|
|
838
845
|
};
|
|
@@ -1587,10 +1594,8 @@ var fnUtils = /*#__PURE__*/Object.freeze({
|
|
|
1587
1594
|
throttle: throttle
|
|
1588
1595
|
});
|
|
1589
1596
|
|
|
1590
|
-
var objectClass = {};
|
|
1591
|
-
var instance_counter = 0;
|
|
1592
|
-
|
|
1593
1597
|
/**
|
|
1598
|
+
* @classdesc
|
|
1594
1599
|
* This object is used for object pooling - a technique that might speed up your game if used properly.<br>
|
|
1595
1600
|
* If some of your classes will be instantiated and removed a lot at a time, it is a
|
|
1596
1601
|
* good idea to add the class to this object pool. A separate pool for that class
|
|
@@ -1601,180 +1606,181 @@ var instance_counter = 0;
|
|
|
1601
1606
|
* which means, that on level loading the engine will try to instantiate every object
|
|
1602
1607
|
* found in the map, based on the user defined name in each Object Properties<br>
|
|
1603
1608
|
* <img src="images/object_properties.png"/><br>
|
|
1604
|
-
* @
|
|
1609
|
+
* @see {@link pool} a default global instance of ObjectPool
|
|
1605
1610
|
*/
|
|
1611
|
+
class ObjectPool {
|
|
1606
1612
|
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1613
|
+
constructor() {
|
|
1614
|
+
this.objectClass = {};
|
|
1615
|
+
this.instance_counter = 0;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* register an object to the pool. <br>
|
|
1620
|
+
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
1621
|
+
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
1622
|
+
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
1623
|
+
* @param {object} classObj corresponding Class to be instantiated
|
|
1624
|
+
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
1625
|
+
* @example
|
|
1626
|
+
* // implement CherryEntity
|
|
1627
|
+
* class CherryEntity extends Spritesheet {
|
|
1628
|
+
* onResetEvent() {
|
|
1629
|
+
* // reset object mutable properties
|
|
1630
|
+
* this.lifeBar = 100;
|
|
1631
|
+
* }
|
|
1632
|
+
* };
|
|
1633
|
+
* // add our users defined entities in the object pool and enable object recycling
|
|
1634
|
+
* me.pool.register("cherryentity", CherryEntity, true);
|
|
1635
|
+
*/
|
|
1636
|
+
register(className, classObj, recycling = false) {
|
|
1637
|
+
if (typeof (classObj) !== "undefined") {
|
|
1638
|
+
this.objectClass[className] = {
|
|
1639
|
+
"class" : classObj,
|
|
1640
|
+
"pool" : (recycling ? [] : undefined)
|
|
1641
|
+
};
|
|
1642
|
+
} else {
|
|
1643
|
+
throw new Error("Cannot register object '" + className + "', invalid class");
|
|
1644
|
+
}
|
|
1634
1645
|
}
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Pull a new instance of the requested object (if added into the object pool)
|
|
1649
|
+
* @param {string} name as used in {@link pool.register}
|
|
1650
|
+
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
1651
|
+
* @returns {object} the instance of the requested object
|
|
1652
|
+
* @example
|
|
1653
|
+
* me.pool.register("bullet", BulletEntity, true);
|
|
1654
|
+
* me.pool.register("enemy", EnemyEntity, true);
|
|
1655
|
+
* // ...
|
|
1656
|
+
* // when we need to manually create a new bullet:
|
|
1657
|
+
* var bullet = me.pool.pull("bullet", x, y, direction);
|
|
1658
|
+
* // ...
|
|
1659
|
+
* // params aren't a fixed number
|
|
1660
|
+
* // when we need new enemy we can add more params, that the object construct requires:
|
|
1661
|
+
* var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
|
|
1662
|
+
* // ...
|
|
1663
|
+
* // when we want to destroy existing object, the remove
|
|
1664
|
+
* // function will ensure the object can then be reallocated later
|
|
1665
|
+
* me.game.world.removeChild(enemy);
|
|
1666
|
+
* me.game.world.removeChild(bullet);
|
|
1667
|
+
*/
|
|
1668
|
+
pull(name) {
|
|
1669
|
+
var args = new Array(arguments.length);
|
|
1670
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
1671
|
+
args[i] = arguments[i];
|
|
1672
|
+
}
|
|
1673
|
+
var className = this.objectClass[name];
|
|
1674
|
+
if (className) {
|
|
1675
|
+
var proto = className["class"],
|
|
1676
|
+
poolArray = className.pool,
|
|
1677
|
+
obj;
|
|
1678
|
+
|
|
1679
|
+
if (poolArray && ((obj = poolArray.pop()))) {
|
|
1680
|
+
// pull an existing instance from the pool
|
|
1681
|
+
args.shift();
|
|
1682
|
+
// call the object onResetEvent function if defined
|
|
1683
|
+
if (typeof(obj.onResetEvent) === "function") {
|
|
1684
|
+
obj.onResetEvent.apply(obj, args);
|
|
1685
|
+
}
|
|
1686
|
+
this.instance_counter--;
|
|
1687
|
+
}
|
|
1688
|
+
else {
|
|
1689
|
+
// create a new instance
|
|
1690
|
+
args[0] = proto;
|
|
1691
|
+
obj = new (proto.bind.apply(proto, args))();
|
|
1692
|
+
if (poolArray) {
|
|
1693
|
+
obj.className = name;
|
|
1694
|
+
}
|
|
1684
1695
|
}
|
|
1696
|
+
return obj;
|
|
1685
1697
|
}
|
|
1686
|
-
|
|
1698
|
+
throw new Error("Cannot instantiate object of type '" + name + "'");
|
|
1687
1699
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
objectClass[className].pool = [];
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* purge the object pool from any inactive object <br>
|
|
1703
|
+
* Object pooling must be enabled for this function to work<br>
|
|
1704
|
+
* note: this will trigger the garbage collector
|
|
1705
|
+
*/
|
|
1706
|
+
purge() {
|
|
1707
|
+
for (var className in this.objectClass) {
|
|
1708
|
+
if (this.objectClass[className]) {
|
|
1709
|
+
this.objectClass[className].pool = [];
|
|
1710
|
+
}
|
|
1700
1711
|
}
|
|
1712
|
+
this.instance_counter = 0;
|
|
1701
1713
|
}
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
return false;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Push back an object instance into the object pool <br>
|
|
1717
|
+
* Object pooling for the object class must be enabled,
|
|
1718
|
+
* and object must have been instantiated using {@link pool#pull},
|
|
1719
|
+
* otherwise this function won't work
|
|
1720
|
+
* @throws will throw an error if the object cannot be recycled
|
|
1721
|
+
* @param {object} obj instance to be recycled
|
|
1722
|
+
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
1723
|
+
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
1724
|
+
*/
|
|
1725
|
+
push(obj, throwOnError = true) {
|
|
1726
|
+
if (!this.poolable(obj)) {
|
|
1727
|
+
if (throwOnError === true ) {
|
|
1728
|
+
throw new Error("me.pool: object " + obj + " cannot be recycled");
|
|
1729
|
+
} else {
|
|
1730
|
+
return false;
|
|
1731
|
+
}
|
|
1721
1732
|
}
|
|
1733
|
+
|
|
1734
|
+
// store back the object instance for later recycling
|
|
1735
|
+
this.objectClass[obj.className].pool.push(obj);
|
|
1736
|
+
this.instance_counter++;
|
|
1737
|
+
|
|
1738
|
+
return true;
|
|
1722
1739
|
}
|
|
1723
1740
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1741
|
+
/**
|
|
1742
|
+
* Check if an object with the provided name is registered
|
|
1743
|
+
* @param {string} name of the registered object class
|
|
1744
|
+
* @returns {boolean} true if the classname is registered
|
|
1745
|
+
*/
|
|
1746
|
+
exists(name) {
|
|
1747
|
+
return name in this.objectClass;
|
|
1748
|
+
};
|
|
1727
1749
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
* if (!me.pool.poolable(myCherryEntity)) {
|
|
1748
|
-
* // object was not properly registered
|
|
1749
|
-
* }
|
|
1750
|
-
*/
|
|
1751
|
-
function poolable(obj) {
|
|
1752
|
-
var className = obj.className;
|
|
1753
|
-
return (typeof className !== "undefined") &&
|
|
1754
|
-
(typeof obj.onResetEvent === "function") &&
|
|
1755
|
-
(className in objectClass) &&
|
|
1756
|
-
(objectClass[className].pool !== "undefined");
|
|
1750
|
+
/**
|
|
1751
|
+
* Check if an object is poolable
|
|
1752
|
+
* (was properly registered with the recycling feature enable)
|
|
1753
|
+
* @see register
|
|
1754
|
+
* @param {object} obj object to be checked
|
|
1755
|
+
* @returns {boolean} true if the object is poolable
|
|
1756
|
+
* @example
|
|
1757
|
+
* if (!me.pool.poolable(myCherryEntity)) {
|
|
1758
|
+
* // object was not properly registered
|
|
1759
|
+
* }
|
|
1760
|
+
*/
|
|
1761
|
+
poolable(obj) {
|
|
1762
|
+
var className = obj.className;
|
|
1763
|
+
return (typeof className !== "undefined") &&
|
|
1764
|
+
(typeof obj.onResetEvent === "function") &&
|
|
1765
|
+
(className in this.objectClass) &&
|
|
1766
|
+
(this.objectClass[className].pool !== "undefined");
|
|
1767
|
+
|
|
1768
|
+
}
|
|
1757
1769
|
|
|
1770
|
+
/**
|
|
1771
|
+
* returns the amount of object instance currently in the pool
|
|
1772
|
+
* @returns {number} amount of object instance
|
|
1773
|
+
*/
|
|
1774
|
+
getInstanceCount() {
|
|
1775
|
+
return this.instance_counter;
|
|
1776
|
+
}
|
|
1758
1777
|
}
|
|
1759
1778
|
/**
|
|
1760
|
-
*
|
|
1761
|
-
* @
|
|
1762
|
-
* @
|
|
1779
|
+
* a default global object pool instance
|
|
1780
|
+
* @public
|
|
1781
|
+
* @type {ObjectPool}
|
|
1763
1782
|
*/
|
|
1764
|
-
|
|
1765
|
-
return instance_counter;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
var pooling = /*#__PURE__*/Object.freeze({
|
|
1769
|
-
__proto__: null,
|
|
1770
|
-
register: register,
|
|
1771
|
-
pull: pull,
|
|
1772
|
-
purge: purge,
|
|
1773
|
-
push: push,
|
|
1774
|
-
exists: exists,
|
|
1775
|
-
poolable: poolable,
|
|
1776
|
-
getInstanceCount: getInstanceCount
|
|
1777
|
-
});
|
|
1783
|
+
var pool$1 = new ObjectPool();
|
|
1778
1784
|
|
|
1779
1785
|
/**
|
|
1780
1786
|
* @classdesc
|
|
@@ -2290,7 +2296,7 @@ class Vector2d {
|
|
|
2290
2296
|
* @returns {Vector2d} new me.Vector2d
|
|
2291
2297
|
*/
|
|
2292
2298
|
clone() {
|
|
2293
|
-
return pull("Vector2d", this.x, this.y);
|
|
2299
|
+
return pool$1.pull("Vector2d", this.x, this.y);
|
|
2294
2300
|
}
|
|
2295
2301
|
|
|
2296
2302
|
/**
|
|
@@ -2584,7 +2590,7 @@ class Color {
|
|
|
2584
2590
|
* @returns {Color} Reference to the newly cloned object
|
|
2585
2591
|
*/
|
|
2586
2592
|
clone() {
|
|
2587
|
-
return pull("Color").copy(this);
|
|
2593
|
+
return pool$1.pull("Color").copy(this);
|
|
2588
2594
|
}
|
|
2589
2595
|
|
|
2590
2596
|
/**
|
|
@@ -3254,12 +3260,12 @@ class Matrix3d {
|
|
|
3254
3260
|
*/
|
|
3255
3261
|
applyInverse(v) {
|
|
3256
3262
|
// invert the current matrix
|
|
3257
|
-
var im = pull("Matrix3d", this).invert();
|
|
3263
|
+
var im = pool$1.pull("Matrix3d", this).invert();
|
|
3258
3264
|
|
|
3259
3265
|
// apply the inverted matrix
|
|
3260
3266
|
im.apply(v);
|
|
3261
3267
|
|
|
3262
|
-
push(im);
|
|
3268
|
+
pool$1.push(im);
|
|
3263
3269
|
|
|
3264
3270
|
return v;
|
|
3265
3271
|
}
|
|
@@ -3566,7 +3572,7 @@ class Matrix3d {
|
|
|
3566
3572
|
* @returns {Matrix3d}
|
|
3567
3573
|
*/
|
|
3568
3574
|
clone() {
|
|
3569
|
-
return pull("Matrix3d", this);
|
|
3575
|
+
return pool$1.pull("Matrix3d", this);
|
|
3570
3576
|
}
|
|
3571
3577
|
|
|
3572
3578
|
/**
|
|
@@ -4072,7 +4078,7 @@ class Matrix2d {
|
|
|
4072
4078
|
* @returns {Matrix2d}
|
|
4073
4079
|
*/
|
|
4074
4080
|
clone() {
|
|
4075
|
-
return pull("Matrix2d", this);
|
|
4081
|
+
return pool$1.pull("Matrix2d", this);
|
|
4076
4082
|
}
|
|
4077
4083
|
|
|
4078
4084
|
/**
|
|
@@ -8657,7 +8663,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
8657
8663
|
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
8658
8664
|
*/
|
|
8659
8665
|
clone() {
|
|
8660
|
-
return pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
8666
|
+
return pool$1.pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
8661
8667
|
}
|
|
8662
8668
|
|
|
8663
8669
|
/**
|
|
@@ -8668,7 +8674,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
8668
8674
|
* @returns {Vector2d} new me.Vector2d
|
|
8669
8675
|
*/
|
|
8670
8676
|
toVector2d() {
|
|
8671
|
-
return pull("Vector2d", this._x, this._y);
|
|
8677
|
+
return pool$1.pull("Vector2d", this._x, this._y);
|
|
8672
8678
|
}
|
|
8673
8679
|
|
|
8674
8680
|
/**
|
|
@@ -9235,7 +9241,7 @@ class Vector3d {
|
|
|
9235
9241
|
* @returns {Vector3d} new me.Vector3d
|
|
9236
9242
|
*/
|
|
9237
9243
|
clone() {
|
|
9238
|
-
return pull("Vector3d", this.x, this.y, this.z);
|
|
9244
|
+
return pool$1.pull("Vector3d", this.x, this.y, this.z);
|
|
9239
9245
|
}
|
|
9240
9246
|
|
|
9241
9247
|
/**
|
|
@@ -9767,7 +9773,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
9767
9773
|
* @returns {ObservableVector3d} new me.ObservableVector3d
|
|
9768
9774
|
*/
|
|
9769
9775
|
clone() {
|
|
9770
|
-
return pull("ObservableVector3d",
|
|
9776
|
+
return pool$1.pull("ObservableVector3d",
|
|
9771
9777
|
this._x,
|
|
9772
9778
|
this._y,
|
|
9773
9779
|
this._z,
|
|
@@ -9783,7 +9789,7 @@ class ObservableVector3d extends Vector3d {
|
|
|
9783
9789
|
* @returns {Vector3d} new me.Vector3d
|
|
9784
9790
|
*/
|
|
9785
9791
|
toVector3d() {
|
|
9786
|
-
return pull("Vector3d", this._x, this._y, this._z);
|
|
9792
|
+
return pool$1.pull("Vector3d", this._x, this._y, this._z);
|
|
9787
9793
|
}
|
|
9788
9794
|
|
|
9789
9795
|
/**
|
|
@@ -10506,16 +10512,16 @@ class Polygon {
|
|
|
10506
10512
|
* @public
|
|
10507
10513
|
* @type {Vector2d}
|
|
10508
10514
|
* @name pos
|
|
10509
|
-
* @memberof Polygon
|
|
10515
|
+
* @memberof Polygon.prototype
|
|
10510
10516
|
*/
|
|
10511
|
-
this.pos =
|
|
10517
|
+
this.pos = pool$1.pull("Vector2d");
|
|
10512
10518
|
|
|
10513
10519
|
/**
|
|
10514
10520
|
* The bounding rectangle for this shape
|
|
10515
10521
|
* @ignore
|
|
10516
10522
|
* @type {Bounds}
|
|
10517
10523
|
* @name _bounds
|
|
10518
|
-
* @memberof Polygon
|
|
10524
|
+
* @memberof Polygon.prototype
|
|
10519
10525
|
*/
|
|
10520
10526
|
this._bounds;
|
|
10521
10527
|
|
|
@@ -10525,7 +10531,7 @@ class Polygon {
|
|
|
10525
10531
|
* @public
|
|
10526
10532
|
* @type {Vector2d[]}
|
|
10527
10533
|
* @name points
|
|
10528
|
-
* @memberof Polygon
|
|
10534
|
+
* @memberof Polygon.prototype
|
|
10529
10535
|
*/
|
|
10530
10536
|
this.points = [];
|
|
10531
10537
|
|
|
@@ -10598,13 +10604,13 @@ class Polygon {
|
|
|
10598
10604
|
if (typeof vertices[0] === "object") {
|
|
10599
10605
|
// array of {x,y} object
|
|
10600
10606
|
vertices.forEach((vertice) => {
|
|
10601
|
-
this.points.push(
|
|
10607
|
+
this.points.push(pool$1.pull("Vector2d", vertice.x, vertice.y));
|
|
10602
10608
|
});
|
|
10603
10609
|
|
|
10604
10610
|
} else {
|
|
10605
10611
|
// it's a flat array
|
|
10606
10612
|
for (var p = 0; p < vertices.length; p += 2) {
|
|
10607
|
-
this.points.push(
|
|
10613
|
+
this.points.push(pool$1.pull("Vector2d", vertices[p], vertices[p + 1]));
|
|
10608
10614
|
}
|
|
10609
10615
|
}
|
|
10610
10616
|
} else {
|
|
@@ -10739,12 +10745,12 @@ class Polygon {
|
|
|
10739
10745
|
// Calculate the edges/normals
|
|
10740
10746
|
for (i = 0; i < len; i++) {
|
|
10741
10747
|
if (edges[i] === undefined) {
|
|
10742
|
-
edges[i] =
|
|
10748
|
+
edges[i] = pool$1.pull("Vector2d");
|
|
10743
10749
|
}
|
|
10744
10750
|
edges[i].copy(points[(i + 1) % len]).sub(points[i]);
|
|
10745
10751
|
|
|
10746
10752
|
if (normals[i] === undefined) {
|
|
10747
|
-
normals[i] =
|
|
10753
|
+
normals[i] = pool$1.pull("Vector2d");
|
|
10748
10754
|
}
|
|
10749
10755
|
normals[i].copy(edges[i]).perp().normalize();
|
|
10750
10756
|
}
|
|
@@ -10860,14 +10866,14 @@ class Polygon {
|
|
|
10860
10866
|
/**
|
|
10861
10867
|
* Shifts the Polygon to the given position vector.
|
|
10862
10868
|
* @name shift
|
|
10863
|
-
* @memberof Polygon
|
|
10869
|
+
* @memberof Polygon.prototype
|
|
10864
10870
|
* @function
|
|
10865
10871
|
* @param {Vector2d} position
|
|
10866
10872
|
*/
|
|
10867
10873
|
/**
|
|
10868
10874
|
* Shifts the Polygon to the given x, y position.
|
|
10869
10875
|
* @name shift
|
|
10870
|
-
* @memberof Polygon
|
|
10876
|
+
* @memberof Polygon.prototype
|
|
10871
10877
|
* @function
|
|
10872
10878
|
* @param {number} x
|
|
10873
10879
|
* @param {number} y
|
|
@@ -10948,7 +10954,7 @@ class Polygon {
|
|
|
10948
10954
|
*/
|
|
10949
10955
|
getBounds() {
|
|
10950
10956
|
if (typeof this._bounds === "undefined") {
|
|
10951
|
-
this._bounds = pull("Bounds");
|
|
10957
|
+
this._bounds = pool$1.pull("Bounds");
|
|
10952
10958
|
}
|
|
10953
10959
|
return this._bounds;
|
|
10954
10960
|
}
|
|
@@ -11001,10 +11007,10 @@ class Rect extends Polygon {
|
|
|
11001
11007
|
constructor(x, y, w, h) {
|
|
11002
11008
|
// parent constructor
|
|
11003
11009
|
super(x, y, [
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11010
|
+
pool$1.pull("Vector2d", 0, 0), // 0, 0
|
|
11011
|
+
pool$1.pull("Vector2d", w, 0), // 1, 0
|
|
11012
|
+
pool$1.pull("Vector2d", w, h), // 1, 1
|
|
11013
|
+
pool$1.pull("Vector2d", 0, h) // 0, 1
|
|
11008
11014
|
]);
|
|
11009
11015
|
this.shapeType = "Rectangle";
|
|
11010
11016
|
}
|
|
@@ -11048,7 +11054,7 @@ class Rect extends Polygon {
|
|
|
11048
11054
|
* @public
|
|
11049
11055
|
* @type {number}
|
|
11050
11056
|
* @name left
|
|
11051
|
-
* @memberof Rect
|
|
11057
|
+
* @memberof Rect.prototype
|
|
11052
11058
|
*/
|
|
11053
11059
|
get left() {
|
|
11054
11060
|
return this.pos.x;
|
|
@@ -11059,7 +11065,7 @@ class Rect extends Polygon {
|
|
|
11059
11065
|
* @public
|
|
11060
11066
|
* @type {number}
|
|
11061
11067
|
* @name right
|
|
11062
|
-
* @memberof Rect
|
|
11068
|
+
* @memberof Rect.prototype
|
|
11063
11069
|
*/
|
|
11064
11070
|
get right() {
|
|
11065
11071
|
var w = this.width;
|
|
@@ -11071,7 +11077,7 @@ class Rect extends Polygon {
|
|
|
11071
11077
|
* @public
|
|
11072
11078
|
* @type {number}
|
|
11073
11079
|
* @name top
|
|
11074
|
-
* @memberof Rect
|
|
11080
|
+
* @memberof Rect.prototype
|
|
11075
11081
|
*/
|
|
11076
11082
|
get top() {
|
|
11077
11083
|
return this.pos.y;
|
|
@@ -11082,7 +11088,7 @@ class Rect extends Polygon {
|
|
|
11082
11088
|
* @public
|
|
11083
11089
|
* @type {number}
|
|
11084
11090
|
* @name bottom
|
|
11085
|
-
* @memberof Rect
|
|
11091
|
+
* @memberof Rect.prototype
|
|
11086
11092
|
*/
|
|
11087
11093
|
get bottom() {
|
|
11088
11094
|
var h = this.height;
|
|
@@ -11094,7 +11100,7 @@ class Rect extends Polygon {
|
|
|
11094
11100
|
* @public
|
|
11095
11101
|
* @type {number}
|
|
11096
11102
|
* @name width
|
|
11097
|
-
* @memberof Rect
|
|
11103
|
+
* @memberof Rect.prototype
|
|
11098
11104
|
*/
|
|
11099
11105
|
get width() {
|
|
11100
11106
|
return this.points[2].x;
|
|
@@ -11110,7 +11116,7 @@ class Rect extends Polygon {
|
|
|
11110
11116
|
* @public
|
|
11111
11117
|
* @type {number}
|
|
11112
11118
|
* @name height
|
|
11113
|
-
* @memberof Rect
|
|
11119
|
+
* @memberof Rect.prototype
|
|
11114
11120
|
*/
|
|
11115
11121
|
get height() {
|
|
11116
11122
|
return this.points[2].y;
|
|
@@ -11126,7 +11132,7 @@ class Rect extends Polygon {
|
|
|
11126
11132
|
* @public
|
|
11127
11133
|
* @type {number}
|
|
11128
11134
|
* @name centerX
|
|
11129
|
-
* @memberof Rect
|
|
11135
|
+
* @memberof Rect.prototype
|
|
11130
11136
|
*/
|
|
11131
11137
|
get centerX() {
|
|
11132
11138
|
if (isFinite(this.width)) {
|
|
@@ -11144,7 +11150,7 @@ class Rect extends Polygon {
|
|
|
11144
11150
|
* @public
|
|
11145
11151
|
* @type {number}
|
|
11146
11152
|
* @name centerY
|
|
11147
|
-
* @memberof Rect
|
|
11153
|
+
* @memberof Rect.prototype
|
|
11148
11154
|
*/
|
|
11149
11155
|
get centerY() {
|
|
11150
11156
|
if (isFinite(this.height)) {
|
|
@@ -11286,7 +11292,7 @@ class Rect extends Polygon {
|
|
|
11286
11292
|
/**
|
|
11287
11293
|
* Returns true if the rectangle contains the given point
|
|
11288
11294
|
* @name contains
|
|
11289
|
-
* @memberof Rect
|
|
11295
|
+
* @memberof Rect.prototype
|
|
11290
11296
|
* @function
|
|
11291
11297
|
* @param {Vector2d} point
|
|
11292
11298
|
* @returns {boolean} true if contains
|
|
@@ -11355,7 +11361,7 @@ class Rect extends Polygon {
|
|
|
11355
11361
|
* @returns {Polygon} a new Polygon that represents this rectangle.
|
|
11356
11362
|
*/
|
|
11357
11363
|
toPolygon() {
|
|
11358
|
-
return
|
|
11364
|
+
return pool$1.pull("Polygon",
|
|
11359
11365
|
this.pos.x, this.pos.y, this.points
|
|
11360
11366
|
);
|
|
11361
11367
|
}
|
|
@@ -11829,6 +11835,8 @@ class Bounds$1 {
|
|
|
11829
11835
|
* @param {Vector2d[]} [vertices] an array of me.Vector2d points
|
|
11830
11836
|
*/
|
|
11831
11837
|
constructor(vertices) {
|
|
11838
|
+
// @ignore
|
|
11839
|
+
this._center = new Vector2d();
|
|
11832
11840
|
this.onResetEvent(vertices);
|
|
11833
11841
|
}
|
|
11834
11842
|
|
|
@@ -11845,9 +11853,6 @@ class Bounds$1 {
|
|
|
11845
11853
|
if (typeof vertices !== "undefined") {
|
|
11846
11854
|
this.update(vertices);
|
|
11847
11855
|
}
|
|
11848
|
-
|
|
11849
|
-
// @ignore
|
|
11850
|
-
this._center = new Vector2d();
|
|
11851
11856
|
}
|
|
11852
11857
|
|
|
11853
11858
|
/**
|
|
@@ -12269,11 +12274,11 @@ class Bounds$1 {
|
|
|
12269
12274
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
12270
12275
|
*/
|
|
12271
12276
|
toPolygon () {
|
|
12272
|
-
return
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
+
return pool$1.pull("Polygon", this.x, this.y, [
|
|
12278
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
12279
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
12280
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
12281
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
12277
12282
|
]);
|
|
12278
12283
|
}
|
|
12279
12284
|
|
|
@@ -12969,11 +12974,11 @@ function dispatchEvent(normalizedEvents) {
|
|
|
12969
12974
|
if (typeof region.currentTransform !== "undefined") {
|
|
12970
12975
|
if (!region.currentTransform.isIdentity()) {
|
|
12971
12976
|
var invV = region.currentTransform.applyInverse(
|
|
12972
|
-
pull("Vector2d", gameX, gameY)
|
|
12977
|
+
pool$1.pull("Vector2d", gameX, gameY)
|
|
12973
12978
|
);
|
|
12974
12979
|
gameX = invV.x;
|
|
12975
12980
|
gameY = invV.y;
|
|
12976
|
-
push(invV);
|
|
12981
|
+
pool$1.push(invV);
|
|
12977
12982
|
}
|
|
12978
12983
|
}
|
|
12979
12984
|
eventInBounds = bounds.contains(gameX, gameY);
|
|
@@ -13202,7 +13207,7 @@ var throttlingInterval;
|
|
|
13202
13207
|
* };
|
|
13203
13208
|
*/
|
|
13204
13209
|
function globalToLocal(x, y, v) {
|
|
13205
|
-
v = v || pull("Vector2d");
|
|
13210
|
+
v = v || pool$1.pull("Vector2d");
|
|
13206
13211
|
var rect = device$1.getElementBounds(renderer.getScreenCanvas());
|
|
13207
13212
|
var pixelRatio = device$1.devicePixelRatio;
|
|
13208
13213
|
x -= rect.left + (globalThis.pageXOffset || 0);
|
|
@@ -14082,7 +14087,7 @@ class Renderable extends Rect {
|
|
|
14082
14087
|
* @name currentTransform
|
|
14083
14088
|
* @memberof Renderable#
|
|
14084
14089
|
*/
|
|
14085
|
-
this.currentTransform = pull("Matrix2d");
|
|
14090
|
+
this.currentTransform = pool$1.pull("Matrix2d");
|
|
14086
14091
|
}
|
|
14087
14092
|
this.currentTransform.identity();
|
|
14088
14093
|
|
|
@@ -14171,7 +14176,7 @@ class Renderable extends Rect {
|
|
|
14171
14176
|
* @name anchorPoint
|
|
14172
14177
|
* @memberof Renderable#
|
|
14173
14178
|
*/
|
|
14174
|
-
this.anchorPoint = pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
|
|
14179
|
+
this.anchorPoint = pool$1.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
|
|
14175
14180
|
}
|
|
14176
14181
|
|
|
14177
14182
|
/**
|
|
@@ -14256,7 +14261,7 @@ class Renderable extends Rect {
|
|
|
14256
14261
|
* // remove the tint
|
|
14257
14262
|
* this.tint.setColor(255, 255, 255);
|
|
14258
14263
|
*/
|
|
14259
|
-
this.tint = pull("Color", 255, 255, 255, 1.0);
|
|
14264
|
+
this.tint = pool$1.pull("Color", 255, 255, 255, 1.0);
|
|
14260
14265
|
|
|
14261
14266
|
/**
|
|
14262
14267
|
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
@@ -14290,7 +14295,7 @@ class Renderable extends Rect {
|
|
|
14290
14295
|
* @name pos
|
|
14291
14296
|
* @memberof Renderable#
|
|
14292
14297
|
*/
|
|
14293
|
-
this.pos = pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
|
|
14298
|
+
this.pos = pool$1.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
|
|
14294
14299
|
}
|
|
14295
14300
|
|
|
14296
14301
|
/**
|
|
@@ -14661,7 +14666,7 @@ class Renderable extends Rect {
|
|
|
14661
14666
|
*/
|
|
14662
14667
|
getAbsolutePosition() {
|
|
14663
14668
|
if (typeof this._absPos === "undefined") {
|
|
14664
|
-
this._absPos = pull("Vector2d");
|
|
14669
|
+
this._absPos = pool$1.pull("Vector2d");
|
|
14665
14670
|
}
|
|
14666
14671
|
// XXX Cache me or something
|
|
14667
14672
|
this._absPos.set(this.pos.x, this.pos.y);
|
|
@@ -14816,32 +14821,32 @@ class Renderable extends Rect {
|
|
|
14816
14821
|
*/
|
|
14817
14822
|
destroy() {
|
|
14818
14823
|
// allow recycling object properties
|
|
14819
|
-
push(this.currentTransform);
|
|
14824
|
+
pool$1.push(this.currentTransform);
|
|
14820
14825
|
this.currentTransform = undefined;
|
|
14821
14826
|
|
|
14822
|
-
push(this.anchorPoint);
|
|
14827
|
+
pool$1.push(this.anchorPoint);
|
|
14823
14828
|
this.anchorPoint = undefined;
|
|
14824
14829
|
|
|
14825
|
-
push(this.pos);
|
|
14830
|
+
pool$1.push(this.pos);
|
|
14826
14831
|
this.pos = undefined;
|
|
14827
14832
|
|
|
14828
14833
|
if (typeof this._absPos !== "undefined") {
|
|
14829
|
-
push(this._absPos);
|
|
14834
|
+
pool$1.push(this._absPos);
|
|
14830
14835
|
this._absPos = undefined;
|
|
14831
14836
|
}
|
|
14832
14837
|
|
|
14833
|
-
push(this._bounds);
|
|
14838
|
+
pool$1.push(this._bounds);
|
|
14834
14839
|
this._bounds = undefined;
|
|
14835
14840
|
|
|
14836
14841
|
this.onVisibilityChange = undefined;
|
|
14837
14842
|
|
|
14838
14843
|
if (typeof this.mask !== "undefined") {
|
|
14839
|
-
push(this.mask);
|
|
14844
|
+
pool$1.push(this.mask);
|
|
14840
14845
|
this.mask = undefined;
|
|
14841
14846
|
}
|
|
14842
14847
|
|
|
14843
14848
|
if (typeof this.tint !== "undefined") {
|
|
14844
|
-
push(this.tint);
|
|
14849
|
+
pool$1.push(this.tint);
|
|
14845
14850
|
this.tint = undefined;
|
|
14846
14851
|
}
|
|
14847
14852
|
|
|
@@ -14890,9 +14895,9 @@ class Ellipse {
|
|
|
14890
14895
|
* @public
|
|
14891
14896
|
* @type {Vector2d}
|
|
14892
14897
|
* @name pos
|
|
14893
|
-
* @memberof Ellipse
|
|
14898
|
+
* @memberof Ellipse.prototype
|
|
14894
14899
|
*/
|
|
14895
|
-
this.pos =
|
|
14900
|
+
this.pos = pool$1.pull("Vector2d");
|
|
14896
14901
|
|
|
14897
14902
|
/**
|
|
14898
14903
|
* The bounding rectangle for this shape
|
|
@@ -14905,7 +14910,7 @@ class Ellipse {
|
|
|
14905
14910
|
* @public
|
|
14906
14911
|
* @type {number}
|
|
14907
14912
|
* @name radius
|
|
14908
|
-
* @memberof Ellipse
|
|
14913
|
+
* @memberof Ellipse.prototype
|
|
14909
14914
|
*/
|
|
14910
14915
|
this.radius = NaN;
|
|
14911
14916
|
|
|
@@ -14914,27 +14919,27 @@ class Ellipse {
|
|
|
14914
14919
|
* @public
|
|
14915
14920
|
* @type {Vector2d}
|
|
14916
14921
|
* @name radiusV
|
|
14917
|
-
* @memberof Ellipse
|
|
14922
|
+
* @memberof Ellipse.prototype
|
|
14918
14923
|
*/
|
|
14919
|
-
this.radiusV =
|
|
14924
|
+
this.radiusV = pool$1.pull("Vector2d");
|
|
14920
14925
|
|
|
14921
14926
|
/**
|
|
14922
14927
|
* Radius squared, for pythagorean theorom
|
|
14923
14928
|
* @public
|
|
14924
14929
|
* @type {Vector2d}
|
|
14925
14930
|
* @name radiusSq
|
|
14926
|
-
* @memberof Ellipse
|
|
14931
|
+
* @memberof Ellipse.prototype
|
|
14927
14932
|
*/
|
|
14928
|
-
this.radiusSq =
|
|
14933
|
+
this.radiusSq = pool$1.pull("Vector2d");
|
|
14929
14934
|
|
|
14930
14935
|
/**
|
|
14931
14936
|
* x/y scaling ratio for ellipse
|
|
14932
14937
|
* @public
|
|
14933
14938
|
* @type {Vector2d}
|
|
14934
14939
|
* @name ratio
|
|
14935
|
-
* @memberof Ellipse
|
|
14940
|
+
* @memberof Ellipse.prototype
|
|
14936
14941
|
*/
|
|
14937
|
-
this.ratio =
|
|
14942
|
+
this.ratio = pool$1.pull("Vector2d");
|
|
14938
14943
|
|
|
14939
14944
|
// the shape type
|
|
14940
14945
|
this.shapeType = "Ellipse";
|
|
@@ -15124,7 +15129,7 @@ class Ellipse {
|
|
|
15124
15129
|
*/
|
|
15125
15130
|
getBounds() {
|
|
15126
15131
|
if (typeof this._bounds === "undefined") {
|
|
15127
|
-
this._bounds = pull("Bounds");
|
|
15132
|
+
this._bounds = pool$1.pull("Bounds");
|
|
15128
15133
|
}
|
|
15129
15134
|
return this._bounds;
|
|
15130
15135
|
}
|
|
@@ -16016,7 +16021,7 @@ class Body {
|
|
|
16016
16021
|
* @public
|
|
16017
16022
|
* @type {Bounds}
|
|
16018
16023
|
*/
|
|
16019
|
-
this.bounds =
|
|
16024
|
+
this.bounds = pool$1.pull("Bounds");
|
|
16020
16025
|
}
|
|
16021
16026
|
|
|
16022
16027
|
if (typeof this.shapes === "undefined") {
|
|
@@ -16050,55 +16055,54 @@ class Body {
|
|
|
16050
16055
|
*/
|
|
16051
16056
|
this.collisionType = collision.types.ENEMY_OBJECT;
|
|
16052
16057
|
|
|
16053
|
-
/**
|
|
16054
|
-
* body velocity
|
|
16055
|
-
* @public
|
|
16056
|
-
* @type {Vector2d}
|
|
16057
|
-
* @default <0,0>
|
|
16058
|
-
*/
|
|
16059
16058
|
if (typeof this.vel === "undefined") {
|
|
16060
|
-
|
|
16059
|
+
/**
|
|
16060
|
+
* body velocity
|
|
16061
|
+
* @public
|
|
16062
|
+
* @type {Vector2d}
|
|
16063
|
+
* @default <0,0>
|
|
16064
|
+
*/
|
|
16065
|
+
this.vel = pool$1.pull("Vector2d");
|
|
16061
16066
|
}
|
|
16062
16067
|
this.vel.set(0, 0);
|
|
16063
16068
|
|
|
16064
|
-
/**
|
|
16065
|
-
* body force or acceleration (automatically) applied to the body.
|
|
16066
|
-
* when defining a force, user should also define a max velocity
|
|
16067
|
-
* @public
|
|
16068
|
-
* @type {Vector2d}
|
|
16069
|
-
* @default <0,0>
|
|
16070
|
-
* @see Body.setMaxVelocity
|
|
16071
|
-
* @example
|
|
16072
|
-
* // define a default maximum acceleration, initial force and friction
|
|
16073
|
-
* this.body.force.set(0, 0);
|
|
16074
|
-
* this.body.friction.set(0.4, 0);
|
|
16075
|
-
* this.body.setMaxVelocity(3, 15);
|
|
16076
|
-
*
|
|
16077
|
-
* // apply a postive or negative force when pressing left of right key
|
|
16078
|
-
* update(dt) {
|
|
16079
|
-
* if (me.input.isKeyPressed("left")) {
|
|
16080
|
-
* this.body.force.x = -this.body.maxVel.x;
|
|
16081
|
-
* } else if (me.input.isKeyPressed("right")) {
|
|
16082
|
-
* this.body.force.x = this.body.maxVel.x;
|
|
16083
|
-
* } else {
|
|
16084
|
-
* this.body.force.x = 0;
|
|
16085
|
-
* }
|
|
16086
|
-
* }
|
|
16087
|
-
*/
|
|
16088
16069
|
if (typeof this.force === "undefined") {
|
|
16089
|
-
|
|
16070
|
+
/**
|
|
16071
|
+
* body force or acceleration (automatically) applied to the body.
|
|
16072
|
+
* when defining a force, user should also define a max velocity
|
|
16073
|
+
* @public
|
|
16074
|
+
* @type {Vector2d}
|
|
16075
|
+
* @default <0,0>
|
|
16076
|
+
* @see Body.setMaxVelocity
|
|
16077
|
+
* @example
|
|
16078
|
+
* // define a default maximum acceleration, initial force and friction
|
|
16079
|
+
* this.body.force.set(0, 0);
|
|
16080
|
+
* this.body.friction.set(0.4, 0);
|
|
16081
|
+
* this.body.setMaxVelocity(3, 15);
|
|
16082
|
+
*
|
|
16083
|
+
* // apply a postive or negative force when pressing left of right key
|
|
16084
|
+
* update(dt) {
|
|
16085
|
+
* if (me.input.isKeyPressed("left")) {
|
|
16086
|
+
* this.body.force.x = -this.body.maxVel.x;
|
|
16087
|
+
* } else if (me.input.isKeyPressed("right")) {
|
|
16088
|
+
* this.body.force.x = this.body.maxVel.x;
|
|
16089
|
+
* } else {
|
|
16090
|
+
* this.body.force.x = 0;
|
|
16091
|
+
* }
|
|
16092
|
+
* }
|
|
16093
|
+
*/
|
|
16094
|
+
this.force = pool$1.pull("Vector2d");
|
|
16090
16095
|
}
|
|
16091
16096
|
this.force.set(0, 0);
|
|
16092
16097
|
|
|
16093
|
-
|
|
16094
|
-
/**
|
|
16095
|
-
* body friction
|
|
16096
|
-
* @public
|
|
16097
|
-
* @type {Vector2d}
|
|
16098
|
-
* @default <0,0>
|
|
16099
|
-
*/
|
|
16100
16098
|
if (typeof this.friction === "undefined") {
|
|
16101
|
-
|
|
16099
|
+
/**
|
|
16100
|
+
* body friction
|
|
16101
|
+
* @public
|
|
16102
|
+
* @type {Vector2d}
|
|
16103
|
+
* @default <0,0>
|
|
16104
|
+
*/
|
|
16105
|
+
this.friction = pool$1.pull("Vector2d");
|
|
16102
16106
|
}
|
|
16103
16107
|
this.friction.set(0, 0);
|
|
16104
16108
|
|
|
@@ -16119,14 +16123,14 @@ class Body {
|
|
|
16119
16123
|
*/
|
|
16120
16124
|
this.mass = 1;
|
|
16121
16125
|
|
|
16122
|
-
/**
|
|
16123
|
-
* max velocity (to limit body velocity)
|
|
16124
|
-
* @public
|
|
16125
|
-
* @type {Vector2d}
|
|
16126
|
-
* @default <490,490>
|
|
16127
|
-
*/
|
|
16128
16126
|
if (typeof this.maxVel === "undefined") {
|
|
16129
|
-
|
|
16127
|
+
/**
|
|
16128
|
+
* max velocity (to limit body velocity)
|
|
16129
|
+
* @public
|
|
16130
|
+
* @type {Vector2d}
|
|
16131
|
+
* @default <490,490>
|
|
16132
|
+
*/
|
|
16133
|
+
this.maxVel = pool$1.pull("Vector2d");
|
|
16130
16134
|
}
|
|
16131
16135
|
// cap by default to half the default gravity force
|
|
16132
16136
|
this.maxVel.set(490, 490);
|
|
@@ -16276,7 +16280,7 @@ class Body {
|
|
|
16276
16280
|
polygon.setShape(0, 0, vertices);
|
|
16277
16281
|
} else {
|
|
16278
16282
|
// this will replace any other non polygon shape type if defined
|
|
16279
|
-
this.shapes[index] =
|
|
16283
|
+
this.shapes[index] = pool$1.pull("Polygon", 0, 0, vertices);
|
|
16280
16284
|
}
|
|
16281
16285
|
|
|
16282
16286
|
// update the body bounds to take in account the new vertices
|
|
@@ -16664,11 +16668,28 @@ class Body {
|
|
|
16664
16668
|
* @ignore
|
|
16665
16669
|
*/
|
|
16666
16670
|
destroy() {
|
|
16671
|
+
// push back instance into object pool
|
|
16672
|
+
pool$1.push(this.bounds);
|
|
16673
|
+
pool$1.push(this.vel);
|
|
16674
|
+
pool$1.push(this.force);
|
|
16675
|
+
pool$1.push(this.friction);
|
|
16676
|
+
pool$1.push(this.maxVel);
|
|
16677
|
+
this.shapes.forEach((shape) => {
|
|
16678
|
+
pool$1.push(shape);
|
|
16679
|
+
});
|
|
16680
|
+
|
|
16681
|
+
// set to undefined
|
|
16667
16682
|
this.onBodyUpdate = undefined;
|
|
16668
16683
|
this.ancestor = undefined;
|
|
16669
16684
|
this.bounds = undefined;
|
|
16670
|
-
this.
|
|
16685
|
+
this.vel = undefined;
|
|
16686
|
+
this.force = undefined;
|
|
16687
|
+
this.friction = undefined;
|
|
16688
|
+
this.maxVel = undefined;
|
|
16671
16689
|
this.shapes.length = 0;
|
|
16690
|
+
|
|
16691
|
+
// reset some variable to default
|
|
16692
|
+
this.setStatic(false);
|
|
16672
16693
|
}
|
|
16673
16694
|
}
|
|
16674
16695
|
|
|
@@ -16796,7 +16817,7 @@ class Container extends Renderable {
|
|
|
16796
16817
|
* // add a red background color to this container
|
|
16797
16818
|
* this.backgroundColor.setColor(255, 0, 0);
|
|
16798
16819
|
*/
|
|
16799
|
-
this.backgroundColor = pull("Color", 0, 0, 0, 0.0);
|
|
16820
|
+
this.backgroundColor = pool$1.pull("Color", 0, 0, 0, 0.0);
|
|
16800
16821
|
|
|
16801
16822
|
/**
|
|
16802
16823
|
* Used by the debug panel plugin
|
|
@@ -17354,7 +17375,7 @@ class Container extends Renderable {
|
|
|
17354
17375
|
|
|
17355
17376
|
if (!keepalive) {
|
|
17356
17377
|
// attempt at recycling the object
|
|
17357
|
-
if (push(child, false) === false ) {
|
|
17378
|
+
if (pool$1.push(child, false) === false ) {
|
|
17358
17379
|
// else just destroy it
|
|
17359
17380
|
if (typeof child.destroy === "function") {
|
|
17360
17381
|
child.destroy();
|
|
@@ -18115,7 +18136,7 @@ class World extends Container {
|
|
|
18115
18136
|
* @name bodies
|
|
18116
18137
|
* @memberof World
|
|
18117
18138
|
* @public
|
|
18118
|
-
* @type {Set}
|
|
18139
|
+
* @type {Set<Body>}
|
|
18119
18140
|
*/
|
|
18120
18141
|
this.bodies = new Set();
|
|
18121
18142
|
|
|
@@ -18523,7 +18544,7 @@ class Camera2d extends Renderable {
|
|
|
18523
18544
|
* @name bounds
|
|
18524
18545
|
* @memberof Camera2d
|
|
18525
18546
|
*/
|
|
18526
|
-
this.bounds = pull("Bounds");
|
|
18547
|
+
this.bounds = pool$1.pull("Bounds");
|
|
18527
18548
|
|
|
18528
18549
|
/**
|
|
18529
18550
|
* enable or disable damping
|
|
@@ -19011,8 +19032,8 @@ class Camera2d extends Renderable {
|
|
|
19011
19032
|
* });
|
|
19012
19033
|
*/
|
|
19013
19034
|
fadeOut(color, duration = 1000, onComplete) {
|
|
19014
|
-
this._fadeOut.color = pull("Color").copy(color);
|
|
19015
|
-
this._fadeOut.tween = pull("Tween", this._fadeOut.color)
|
|
19035
|
+
this._fadeOut.color = pool$1.pull("Color").copy(color);
|
|
19036
|
+
this._fadeOut.tween = pool$1.pull("Tween", this._fadeOut.color)
|
|
19016
19037
|
.to({ alpha: 0.0 }, duration)
|
|
19017
19038
|
.onComplete(onComplete || null);
|
|
19018
19039
|
this._fadeOut.tween.isPersistent = true;
|
|
@@ -19033,10 +19054,10 @@ class Camera2d extends Renderable {
|
|
|
19033
19054
|
* me.game.viewport.fadeIn("#FFFFFF", 75);
|
|
19034
19055
|
*/
|
|
19035
19056
|
fadeIn(color, duration = 1000, onComplete) {
|
|
19036
|
-
this._fadeIn.color = pull("Color").copy(color);
|
|
19057
|
+
this._fadeIn.color = pool$1.pull("Color").copy(color);
|
|
19037
19058
|
var _alpha = this._fadeIn.color.alpha;
|
|
19038
19059
|
this._fadeIn.color.alpha = 0.0;
|
|
19039
|
-
this._fadeIn.tween = pull("Tween", this._fadeIn.color)
|
|
19060
|
+
this._fadeIn.tween = pool$1.pull("Tween", this._fadeIn.color)
|
|
19040
19061
|
.to({ alpha: _alpha }, duration)
|
|
19041
19062
|
.onComplete(onComplete || null);
|
|
19042
19063
|
this._fadeIn.tween.isPersistent = true;
|
|
@@ -19090,7 +19111,7 @@ class Camera2d extends Renderable {
|
|
|
19090
19111
|
*/
|
|
19091
19112
|
localToWorld(x, y, v) {
|
|
19092
19113
|
// TODO memoization for one set of coords (multitouch)
|
|
19093
|
-
v = v || pull("Vector2d");
|
|
19114
|
+
v = v || pool$1.pull("Vector2d");
|
|
19094
19115
|
v.set(x, y).add(this.pos).sub(world.pos);
|
|
19095
19116
|
if (!this.currentTransform.isIdentity()) {
|
|
19096
19117
|
this.invCurrentTransform.apply(v);
|
|
@@ -19111,7 +19132,7 @@ class Camera2d extends Renderable {
|
|
|
19111
19132
|
*/
|
|
19112
19133
|
worldToLocal(x, y, v) {
|
|
19113
19134
|
// TODO memoization for one set of coords (multitouch)
|
|
19114
|
-
v = v || pull("Vector2d");
|
|
19135
|
+
v = v || pool$1.pull("Vector2d");
|
|
19115
19136
|
v.set(x, y);
|
|
19116
19137
|
if (!this.currentTransform.isIdentity()) {
|
|
19117
19138
|
this.currentTransform.apply(v);
|
|
@@ -19136,7 +19157,7 @@ class Camera2d extends Renderable {
|
|
|
19136
19157
|
// remove the tween if over
|
|
19137
19158
|
if (this._fadeIn.color.alpha === 1.0) {
|
|
19138
19159
|
this._fadeIn.tween = null;
|
|
19139
|
-
push(this._fadeIn.color);
|
|
19160
|
+
pool$1.push(this._fadeIn.color);
|
|
19140
19161
|
this._fadeIn.color = null;
|
|
19141
19162
|
}
|
|
19142
19163
|
}
|
|
@@ -19153,7 +19174,7 @@ class Camera2d extends Renderable {
|
|
|
19153
19174
|
// remove the tween if over
|
|
19154
19175
|
if (this._fadeOut.color.alpha === 0.0) {
|
|
19155
19176
|
this._fadeOut.tween = null;
|
|
19156
|
-
push(this._fadeOut.color);
|
|
19177
|
+
pool$1.push(this._fadeOut.color);
|
|
19157
19178
|
this._fadeOut.color = null;
|
|
19158
19179
|
}
|
|
19159
19180
|
}
|
|
@@ -19231,7 +19252,7 @@ class Stage {
|
|
|
19231
19252
|
* Cameras will be renderered based on this order defined in this list.
|
|
19232
19253
|
* Only the "default" camera will be resized when the window or canvas is resized.
|
|
19233
19254
|
* @public
|
|
19234
|
-
* @type {Map}
|
|
19255
|
+
* @type {Map<Camera2d>}
|
|
19235
19256
|
* @name cameras
|
|
19236
19257
|
* @memberof Stage
|
|
19237
19258
|
*/
|
|
@@ -19495,7 +19516,7 @@ class DefaultLoadingScreen extends Stage {
|
|
|
19495
19516
|
|
|
19496
19517
|
), 2);
|
|
19497
19518
|
|
|
19498
|
-
var logo1 = pull("Text",
|
|
19519
|
+
var logo1 = pool$1.pull("Text",
|
|
19499
19520
|
renderer.getWidth() / 2,
|
|
19500
19521
|
(renderer.getHeight() / 2) + 16, {
|
|
19501
19522
|
font: "century gothic",
|
|
@@ -19509,7 +19530,7 @@ class DefaultLoadingScreen extends Stage {
|
|
|
19509
19530
|
);
|
|
19510
19531
|
logo1.anchorPoint.set(0, 0);
|
|
19511
19532
|
|
|
19512
|
-
var logo2 = pull("Text",
|
|
19533
|
+
var logo2 = pool$1.pull("Text",
|
|
19513
19534
|
renderer.getWidth() / 2,
|
|
19514
19535
|
(renderer.getHeight() / 2) + 16, {
|
|
19515
19536
|
font: "century gothic",
|
|
@@ -20040,7 +20061,7 @@ var state = {
|
|
|
20040
20061
|
// if fading effect
|
|
20041
20062
|
if (_fade.duration && _stages[state].transition) {
|
|
20042
20063
|
/** @ignore */
|
|
20043
|
-
_onSwitchComplete =
|
|
20064
|
+
_onSwitchComplete = () => {
|
|
20044
20065
|
viewport.fadeOut(_fade.color, _fade.duration);
|
|
20045
20066
|
};
|
|
20046
20067
|
viewport.fadeIn(
|
|
@@ -21222,7 +21243,7 @@ class TextureAtlas {
|
|
|
21222
21243
|
var height = image.height;
|
|
21223
21244
|
|
|
21224
21245
|
// calculate the sprite count (line, col)
|
|
21225
|
-
var spritecount = pull("Vector2d",
|
|
21246
|
+
var spritecount = pool$1.pull("Vector2d",
|
|
21226
21247
|
~~((width - margin + spacing) / (data.framewidth + spacing)),
|
|
21227
21248
|
~~((height - margin + spacing) / (data.frameheight + spacing))
|
|
21228
21249
|
);
|
|
@@ -21265,7 +21286,7 @@ class TextureAtlas {
|
|
|
21265
21286
|
this.addUVs(atlas, name, width, height);
|
|
21266
21287
|
}
|
|
21267
21288
|
|
|
21268
|
-
push(spritecount);
|
|
21289
|
+
pool$1.push(spritecount);
|
|
21269
21290
|
|
|
21270
21291
|
return atlas;
|
|
21271
21292
|
}
|
|
@@ -21438,7 +21459,7 @@ class TextureAtlas {
|
|
|
21438
21459
|
*/
|
|
21439
21460
|
createSpriteFromName(name, settings, nineSlice = false) {
|
|
21440
21461
|
// instantiate a new sprite object
|
|
21441
|
-
return pull(
|
|
21462
|
+
return pool$1.pull(
|
|
21442
21463
|
nineSlice === true ? "me.NineSliceSprite" : "me.Sprite",
|
|
21443
21464
|
0, 0,
|
|
21444
21465
|
Object.assign({
|
|
@@ -21579,7 +21600,7 @@ class Sprite extends Renderable {
|
|
|
21579
21600
|
* @name offset
|
|
21580
21601
|
* @memberof Sprite#
|
|
21581
21602
|
*/
|
|
21582
|
-
this.offset = pull("Vector2d", 0, 0);
|
|
21603
|
+
this.offset = pool$1.pull("Vector2d", 0, 0);
|
|
21583
21604
|
|
|
21584
21605
|
/**
|
|
21585
21606
|
* The source texture object this sprite object is using
|
|
@@ -21604,7 +21625,7 @@ class Sprite extends Renderable {
|
|
|
21604
21625
|
// length of the current animation name
|
|
21605
21626
|
length : 0,
|
|
21606
21627
|
//current frame texture offset
|
|
21607
|
-
offset :
|
|
21628
|
+
offset : pool$1.pull("Vector2d"),
|
|
21608
21629
|
// current frame size
|
|
21609
21630
|
width : 0,
|
|
21610
21631
|
height : 0,
|
|
@@ -22096,7 +22117,7 @@ class Sprite extends Renderable {
|
|
|
22096
22117
|
* @ignore
|
|
22097
22118
|
*/
|
|
22098
22119
|
destroy() {
|
|
22099
|
-
push(this.offset);
|
|
22120
|
+
pool$1.push(this.offset);
|
|
22100
22121
|
this.offset = undefined;
|
|
22101
22122
|
super.destroy();
|
|
22102
22123
|
}
|
|
@@ -22336,6 +22357,70 @@ class Tile extends Bounds$1 {
|
|
|
22336
22357
|
}
|
|
22337
22358
|
}
|
|
22338
22359
|
|
|
22360
|
+
// https://developer.chrome.com/blog/canvas2d/#round-rect
|
|
22361
|
+
|
|
22362
|
+
/**
|
|
22363
|
+
* @classdesc
|
|
22364
|
+
* a rectangle object with rounded corners
|
|
22365
|
+
* @augments Rect
|
|
22366
|
+
*/
|
|
22367
|
+
class RoundRect extends Rect {
|
|
22368
|
+
/**
|
|
22369
|
+
* @param {number} x position of the rounded rectangle
|
|
22370
|
+
* @param {number} y position of the rounded rectangle
|
|
22371
|
+
* @param {number} width the rectangle width
|
|
22372
|
+
* @param {number} height the rectangle height
|
|
22373
|
+
* @param {number} [radius=20] the radius of the rounded corner
|
|
22374
|
+
*/
|
|
22375
|
+
constructor(x, y, width, height, radius = 20) {
|
|
22376
|
+
// parent constructor
|
|
22377
|
+
super(x, y, width, height);
|
|
22378
|
+
|
|
22379
|
+
// set the corner radius
|
|
22380
|
+
this.radius = radius;
|
|
22381
|
+
}
|
|
22382
|
+
|
|
22383
|
+
/** @ignore */
|
|
22384
|
+
onResetEvent(x, y, w, h, radius) {
|
|
22385
|
+
super.setShape(x, y, w, h);
|
|
22386
|
+
this.radius = radius;
|
|
22387
|
+
}
|
|
22388
|
+
|
|
22389
|
+
|
|
22390
|
+
/**
|
|
22391
|
+
* the radius of the rounded corner
|
|
22392
|
+
* @public
|
|
22393
|
+
* @type {number}
|
|
22394
|
+
* @default 20
|
|
22395
|
+
* @name radius
|
|
22396
|
+
* @memberof RoundRect.prototype
|
|
22397
|
+
*/
|
|
22398
|
+
get radius() {
|
|
22399
|
+
return this._radius;
|
|
22400
|
+
}
|
|
22401
|
+
set radius(value) {
|
|
22402
|
+
// verify the rectangle is at least as wide and tall as the rounded corners.
|
|
22403
|
+
if (this.width < 2 * value) {
|
|
22404
|
+
value = this.width / 2;
|
|
22405
|
+
}
|
|
22406
|
+
if (this.height < 2 * value) {
|
|
22407
|
+
value = this.height / 2;
|
|
22408
|
+
}
|
|
22409
|
+
this._radius = value;
|
|
22410
|
+
}
|
|
22411
|
+
|
|
22412
|
+
/**
|
|
22413
|
+
* clone this RoundRect
|
|
22414
|
+
* @name clone
|
|
22415
|
+
* @memberof RoundRect.prototype
|
|
22416
|
+
* @function
|
|
22417
|
+
* @returns {RoundRect} new RoundRect
|
|
22418
|
+
*/
|
|
22419
|
+
clone() {
|
|
22420
|
+
return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, this.radius);
|
|
22421
|
+
}
|
|
22422
|
+
}
|
|
22423
|
+
|
|
22339
22424
|
/**
|
|
22340
22425
|
* @classdesc
|
|
22341
22426
|
* a line segment Object
|
|
@@ -22411,11 +22496,11 @@ class Line extends Polygon {
|
|
|
22411
22496
|
|
|
22412
22497
|
// Calculate the edges/normals
|
|
22413
22498
|
if (edges[0] === undefined) {
|
|
22414
|
-
edges[0] =
|
|
22499
|
+
edges[0] = pool$1.pull("Vector2d");
|
|
22415
22500
|
}
|
|
22416
22501
|
edges[0].copy(points[1]).sub(points[0]);
|
|
22417
22502
|
if (normals[0] === undefined) {
|
|
22418
|
-
normals[0] =
|
|
22503
|
+
normals[0] = pool$1.pull("Vector2d");
|
|
22419
22504
|
}
|
|
22420
22505
|
normals[0].copy(edges[0]).perp().normalize();
|
|
22421
22506
|
|
|
@@ -22443,6 +22528,321 @@ class Line extends Polygon {
|
|
|
22443
22528
|
|
|
22444
22529
|
}
|
|
22445
22530
|
|
|
22531
|
+
/**
|
|
22532
|
+
* @classdesc
|
|
22533
|
+
* a simplified path2d implementation, supporting only one path
|
|
22534
|
+
*/
|
|
22535
|
+
class Path2D {
|
|
22536
|
+
constructor() {
|
|
22537
|
+
/**
|
|
22538
|
+
* the points defining the current path
|
|
22539
|
+
* @public
|
|
22540
|
+
* @type {Vector2d[]}
|
|
22541
|
+
* @name points
|
|
22542
|
+
* @memberof Path2D#
|
|
22543
|
+
*/
|
|
22544
|
+
this.points = [];
|
|
22545
|
+
|
|
22546
|
+
/**
|
|
22547
|
+
* space between interpolated points for quadratic and bezier curve approx. in pixels.
|
|
22548
|
+
* @public
|
|
22549
|
+
* @type {number}
|
|
22550
|
+
* @name arcResolution
|
|
22551
|
+
* @default 5
|
|
22552
|
+
* @memberof Path2D#
|
|
22553
|
+
*/
|
|
22554
|
+
this.arcResolution = 5;
|
|
22555
|
+
|
|
22556
|
+
/* @ignore */
|
|
22557
|
+
this.vertices = [];
|
|
22558
|
+
}
|
|
22559
|
+
|
|
22560
|
+
/**
|
|
22561
|
+
* begin a new path
|
|
22562
|
+
* @name beginPath
|
|
22563
|
+
* @memberof Path2D.prototype
|
|
22564
|
+
* @function
|
|
22565
|
+
*/
|
|
22566
|
+
beginPath() {
|
|
22567
|
+
// empty the cache and recycle all vectors
|
|
22568
|
+
this.points.forEach((point) => {
|
|
22569
|
+
pool$1.push(point);
|
|
22570
|
+
});
|
|
22571
|
+
this.points.length = 0;
|
|
22572
|
+
}
|
|
22573
|
+
|
|
22574
|
+
/**
|
|
22575
|
+
* causes the point of the pen to move back to the start of the current path.
|
|
22576
|
+
* It tries to draw a straight line from the current point to the start.
|
|
22577
|
+
* If the shape has already been closed or has only one point, this function does nothing.
|
|
22578
|
+
* @name closePath
|
|
22579
|
+
* @memberof Path2D.prototype
|
|
22580
|
+
* @function
|
|
22581
|
+
*/
|
|
22582
|
+
closePath() {
|
|
22583
|
+
var points = this.points;
|
|
22584
|
+
if (points.length > 1 && !points[points.length-1].equals(points[0])) {
|
|
22585
|
+
points.push(pool$1.pull("Vector2d", points[0].x, points[0].y));
|
|
22586
|
+
}
|
|
22587
|
+
}
|
|
22588
|
+
|
|
22589
|
+
/**
|
|
22590
|
+
* triangulate the shape defined by this path into an array of triangles
|
|
22591
|
+
* @name triangulatePath
|
|
22592
|
+
* @memberof Path2D.prototype
|
|
22593
|
+
* @function
|
|
22594
|
+
* @returns {Vector2d[]}
|
|
22595
|
+
*/
|
|
22596
|
+
triangulatePath() {
|
|
22597
|
+
var i = 0;
|
|
22598
|
+
var points = this.points;
|
|
22599
|
+
var vertices = this.vertices;
|
|
22600
|
+
var indices = earcut$1.exports(points.flatMap(p => [p.x, p.y]));
|
|
22601
|
+
|
|
22602
|
+
// calculate all vertices
|
|
22603
|
+
for (i = 0; i < indices.length; i++ ) {
|
|
22604
|
+
if (typeof vertices[i] === "undefined") {
|
|
22605
|
+
// increase cache buffer if necessary
|
|
22606
|
+
vertices[i] = pool$1.pull("Vector2d");
|
|
22607
|
+
}
|
|
22608
|
+
vertices[i].set(points[indices[i]].x, points[indices[i]].y);
|
|
22609
|
+
}
|
|
22610
|
+
|
|
22611
|
+
// recycle overhead from a previous triangulation
|
|
22612
|
+
while (vertices.length > indices.length) {
|
|
22613
|
+
pool$1.push(vertices[vertices.length-1]);
|
|
22614
|
+
vertices.length -= 1;
|
|
22615
|
+
}
|
|
22616
|
+
|
|
22617
|
+
return vertices;
|
|
22618
|
+
}
|
|
22619
|
+
|
|
22620
|
+
/**
|
|
22621
|
+
* moves the starting point of the current path to the (x, y) coordinates.
|
|
22622
|
+
* @name moveTo
|
|
22623
|
+
* @memberof Path2D.prototype
|
|
22624
|
+
* @function
|
|
22625
|
+
* @param {number} x the x-axis (horizontal) coordinate of the point.
|
|
22626
|
+
* @param {number} y the y-axis (vertical) coordinate of the point.
|
|
22627
|
+
*/
|
|
22628
|
+
moveTo(x, y) {
|
|
22629
|
+
this.points.push(pool$1.pull("Vector2d", x, y));
|
|
22630
|
+
}
|
|
22631
|
+
|
|
22632
|
+
/**
|
|
22633
|
+
* connects the last point in the current patch to the (x, y) coordinates with a straight line.
|
|
22634
|
+
* @name lineTo
|
|
22635
|
+
* @memberof Path2D.prototype
|
|
22636
|
+
* @function
|
|
22637
|
+
* @param {number} x the x-axis coordinate of the line's end point.
|
|
22638
|
+
* @param {number} y the y-axis coordinate of the line's end point.
|
|
22639
|
+
*/
|
|
22640
|
+
lineTo(x, y) {
|
|
22641
|
+
this.points.push(pool$1.pull("Vector2d", x, y));
|
|
22642
|
+
}
|
|
22643
|
+
|
|
22644
|
+
/**
|
|
22645
|
+
* adds an arc to the current path which is centered at (x, y) position with the given radius,
|
|
22646
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
|
|
22647
|
+
* @name arc
|
|
22648
|
+
* @memberof Path2D.prototype
|
|
22649
|
+
* @function
|
|
22650
|
+
* @param {number} x the horizontal coordinate of the arc's center.
|
|
22651
|
+
* @param {number} y the vertical coordinate of the arc's center.
|
|
22652
|
+
* @param {number} radius the arc's radius. Must be positive.
|
|
22653
|
+
* @param {number} startAngle the angle at which the arc starts in radians, measured from the positive x-axis.
|
|
22654
|
+
* @param {number} endAngle the angle at which the arc ends in radians, measured from the positive x-axis.
|
|
22655
|
+
* @param {boolean} [anticlockwise=false] an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
|
|
22656
|
+
*/
|
|
22657
|
+
arc(x, y, radius, startAngle, endAngle, anticlockwise = false) {
|
|
22658
|
+
var points = this.points;
|
|
22659
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22660
|
+
//bring angles all in [0, 2*PI] range
|
|
22661
|
+
if (startAngle === endAngle) return;
|
|
22662
|
+
var fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
22663
|
+
|
|
22664
|
+
startAngle = startAngle % (TAU);
|
|
22665
|
+
endAngle = endAngle % (TAU);
|
|
22666
|
+
|
|
22667
|
+
if (startAngle < 0) startAngle += TAU;
|
|
22668
|
+
if (endAngle < 0) endAngle += TAU;
|
|
22669
|
+
|
|
22670
|
+
if (startAngle >= endAngle) {
|
|
22671
|
+
endAngle+= TAU;
|
|
22672
|
+
}
|
|
22673
|
+
|
|
22674
|
+
var diff = endAngle - startAngle;
|
|
22675
|
+
var direction = 1;
|
|
22676
|
+
if (anticlockwise) {
|
|
22677
|
+
direction = -1;
|
|
22678
|
+
diff = TAU - diff;
|
|
22679
|
+
}
|
|
22680
|
+
|
|
22681
|
+
if (fullCircle) diff = TAU;
|
|
22682
|
+
|
|
22683
|
+
var length = diff * radius;
|
|
22684
|
+
var nr_of_interpolation_points = length / this.arcResolution;
|
|
22685
|
+
var dangle = diff / nr_of_interpolation_points;
|
|
22686
|
+
|
|
22687
|
+
var angle = startAngle;
|
|
22688
|
+
for (var j = 0; j < nr_of_interpolation_points; j++) {
|
|
22689
|
+
points.push(pool$1.pull("Vector2d", x + radius * Math.cos(angle), y + radius * Math.sin(angle)));
|
|
22690
|
+
angle += direction * dangle;
|
|
22691
|
+
}
|
|
22692
|
+
points.push(pool$1.pull("Vector2d", x + radius * Math.cos(endAngle), y + radius * Math.sin(endAngle)));
|
|
22693
|
+
}
|
|
22694
|
+
|
|
22695
|
+
/**
|
|
22696
|
+
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
22697
|
+
* @name arcTo
|
|
22698
|
+
* @memberof Path2D.prototype
|
|
22699
|
+
* @function
|
|
22700
|
+
* @param {number} x the x-axis coordinate of the first control point.
|
|
22701
|
+
* @param {number} y the y-axis coordinate of the first control point.
|
|
22702
|
+
* @param {number} x the x-axis coordinate of the second control point.
|
|
22703
|
+
* @param {number} y the y-axis coordinate of the second control point.
|
|
22704
|
+
* @param {number} radius the arc's radius. Must be positive.
|
|
22705
|
+
*/
|
|
22706
|
+
arcTo(x1, y1, x2, y2, radius) {
|
|
22707
|
+
var points = this.points;
|
|
22708
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22709
|
+
var x0 = points[points.length-1].x, y0 = points[points.length-1].y;
|
|
22710
|
+
|
|
22711
|
+
//a = -incoming vector, b = outgoing vector to x1, y1
|
|
22712
|
+
var a = [x0 - x1, y0 - y1];
|
|
22713
|
+
var b = [x2 - x1, y2 - y1];
|
|
22714
|
+
|
|
22715
|
+
//normalize
|
|
22716
|
+
var l_a = Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2));
|
|
22717
|
+
var l_b = Math.sqrt(Math.pow(b[0], 2) + Math.pow(b[1], 2));
|
|
22718
|
+
a[0] /= l_a; a[1] /= l_a; b[0] /= l_b; b[1] /= l_b;
|
|
22719
|
+
var angle = Math.atan2(a[1], a[0]) - Math.atan2(b[1], b[0]);
|
|
22720
|
+
|
|
22721
|
+
//work out tangent points using tan(θ) = opposite / adjacent; angle/2 because hypotenuse is the bisection of a,b
|
|
22722
|
+
var tan_angle_div2 = Math.tan(angle/2);
|
|
22723
|
+
var adj_l = (radius/tan_angle_div2);
|
|
22724
|
+
|
|
22725
|
+
var tangent_point1 = [x1 + a[0] * adj_l, y1 + a[1] * adj_l];
|
|
22726
|
+
var tangent_point2 = [x1 + b[0] * adj_l, y1 + b[1] * adj_l];
|
|
22727
|
+
|
|
22728
|
+
points.push(pool$1.pull("Vector2d", tangent_point1[0], tangent_point1[1]));
|
|
22729
|
+
|
|
22730
|
+
var bisec = [(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0];
|
|
22731
|
+
var bisec_l = Math.sqrt(Math.pow(bisec[0], 2) + Math.pow(bisec[1], 2));
|
|
22732
|
+
bisec[0] /= bisec_l; bisec[1] /= bisec_l;
|
|
22733
|
+
|
|
22734
|
+
var hyp_l = Math.sqrt(Math.pow(radius, 2) + Math.pow(adj_l, 2));
|
|
22735
|
+
var center = [x1 + hyp_l * bisec[0], y1 + hyp_l * bisec[1]];
|
|
22736
|
+
|
|
22737
|
+
var startAngle = Math.atan2(tangent_point1[1] - center[1], tangent_point1[0] - center[0]);
|
|
22738
|
+
var endAngle = Math.atan2(tangent_point2[1] - center[1], tangent_point2[0] - center[0]);
|
|
22739
|
+
|
|
22740
|
+
this.arc(center[0], center[1], radius, startAngle, endAngle);
|
|
22741
|
+
}
|
|
22742
|
+
|
|
22743
|
+
/**
|
|
22744
|
+
* adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
|
|
22745
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
|
|
22746
|
+
* @name ellipse
|
|
22747
|
+
* @memberof Path2D.prototype
|
|
22748
|
+
* @function
|
|
22749
|
+
* @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
|
|
22750
|
+
* @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
|
|
22751
|
+
* @param {number} radiusX the ellipse's major-axis radius. Must be non-negative.
|
|
22752
|
+
* @param {number} radiusY the ellipse's minor-axis radius. Must be non-negative.
|
|
22753
|
+
* @param {number} rotation the rotation of the ellipse, expressed in radians.
|
|
22754
|
+
* @param {number} startAngle the angle at which the ellipse starts, measured clockwise from the positive x-axis and expressed in radians.
|
|
22755
|
+
* @param {number} endAngle the angle at which the ellipse ends, measured clockwise from the positive x-axis and expressed in radians.
|
|
22756
|
+
* @param {boolean} [anticlockwise=false] an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
|
|
22757
|
+
*/
|
|
22758
|
+
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise = false) {
|
|
22759
|
+
var points = this.points;
|
|
22760
|
+
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
|
|
22761
|
+
if (startAngle === endAngle) return;
|
|
22762
|
+
var fullCircle = anticlockwise ? Math.abs(startAngle-endAngle) >= (TAU) : Math.abs(endAngle-startAngle) >= (TAU);
|
|
22763
|
+
|
|
22764
|
+
//bring angles all in [0, 2*PI] range
|
|
22765
|
+
startAngle = startAngle % (TAU);
|
|
22766
|
+
endAngle = endAngle % (TAU);
|
|
22767
|
+
if (startAngle < 0) startAngle += TAU;
|
|
22768
|
+
if (endAngle < 0) endAngle += TAU;
|
|
22769
|
+
|
|
22770
|
+
if (startAngle>=endAngle) {
|
|
22771
|
+
endAngle += TAU;
|
|
22772
|
+
}
|
|
22773
|
+
|
|
22774
|
+
var diff = endAngle - startAngle;
|
|
22775
|
+
|
|
22776
|
+
var direction = 1;
|
|
22777
|
+
if (anticlockwise) {
|
|
22778
|
+
direction = -1;
|
|
22779
|
+
diff = TAU - diff;
|
|
22780
|
+
}
|
|
22781
|
+
|
|
22782
|
+
if (fullCircle) diff = TAU;
|
|
22783
|
+
|
|
22784
|
+
var length = (diff * radiusX + diff * radiusY) / 2;
|
|
22785
|
+
var nr_of_interpolation_points = length / this.arcResolution;
|
|
22786
|
+
var dangle = diff / nr_of_interpolation_points;
|
|
22787
|
+
|
|
22788
|
+
var angle = startAngle;
|
|
22789
|
+
var cos_rotation = Math.cos(rotation);
|
|
22790
|
+
var sin_rotation = Math.sin(rotation);
|
|
22791
|
+
for (var j = 0; j < nr_of_interpolation_points; j++) {
|
|
22792
|
+
var _x1 = radiusX * Math.cos(angle);
|
|
22793
|
+
var _y1 = radiusY * Math.sin(angle);
|
|
22794
|
+
var _x2 = x + _x1 * cos_rotation - _y1 * sin_rotation;
|
|
22795
|
+
var _y2 = y + _x1 * sin_rotation + _y1 * cos_rotation;
|
|
22796
|
+
points.push(pool$1.pull("Vector2d", _x2, _y2));
|
|
22797
|
+
angle += direction * dangle;
|
|
22798
|
+
}
|
|
22799
|
+
//var x1 = radiusX * Math.cos(endAngle);
|
|
22800
|
+
//var y1 = radiusY * Math.sin(endAngle);
|
|
22801
|
+
//points.push(pool.pull("Vector2d", x + x1 * cos_rotation - y1 * sin_rotation, y + x1 * sin_rotation + y1 * cos_rotation));
|
|
22802
|
+
}
|
|
22803
|
+
|
|
22804
|
+
/**
|
|
22805
|
+
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|
|
22806
|
+
* @name rect
|
|
22807
|
+
* @memberof Path2D.prototype
|
|
22808
|
+
* @function
|
|
22809
|
+
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
22810
|
+
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
22811
|
+
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|
|
22812
|
+
* @param {number} height the rectangle's height. Positive values are down, and negative are up.
|
|
22813
|
+
*/
|
|
22814
|
+
rect(x, y, width, height) {
|
|
22815
|
+
this.moveTo(x, y);
|
|
22816
|
+
this.lineTo(x + width, y);
|
|
22817
|
+
this.lineTo(x + width, y + height);
|
|
22818
|
+
this.lineTo(x, y + height);
|
|
22819
|
+
this.lineTo(x, y);
|
|
22820
|
+
}
|
|
22821
|
+
|
|
22822
|
+
/**
|
|
22823
|
+
* adds an rounded rectangle to the current path.
|
|
22824
|
+
* @name roundRect
|
|
22825
|
+
* @memberof Path2D.prototype
|
|
22826
|
+
* @function
|
|
22827
|
+
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
22828
|
+
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
22829
|
+
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|
|
22830
|
+
* @param {number} height the rectangle's height. Positive values are down, and negative are up.
|
|
22831
|
+
* @param {number} radius the arc's radius to draw the borders. Must be positive.
|
|
22832
|
+
*/
|
|
22833
|
+
roundRect(x, y, width, height, radius) {
|
|
22834
|
+
this.moveTo(x + radius, y);
|
|
22835
|
+
this.lineTo(x + width - radius, y);
|
|
22836
|
+
this.arcTo(x + width, y, x + width, y + radius, radius);
|
|
22837
|
+
this.lineTo(x + width, y + height - radius);
|
|
22838
|
+
this.arcTo(x + width, y + height, x + width - radius, y + height, radius);
|
|
22839
|
+
this.lineTo(x + radius, y + height);
|
|
22840
|
+
this.arcTo(x, y + height, x, y + height - radius, radius);
|
|
22841
|
+
this.lineTo(x, y + radius);
|
|
22842
|
+
this.arcTo(x, y, x + radius, y, radius);
|
|
22843
|
+
}
|
|
22844
|
+
}
|
|
22845
|
+
|
|
22446
22846
|
/**
|
|
22447
22847
|
* @classdesc
|
|
22448
22848
|
* a base renderer object
|
|
@@ -22476,12 +22876,20 @@ class Renderer {
|
|
|
22476
22876
|
/**
|
|
22477
22877
|
* true if the current rendering context is valid
|
|
22478
22878
|
* @name isContextValid
|
|
22479
|
-
* @memberof Renderer
|
|
22879
|
+
* @memberof Renderer#
|
|
22480
22880
|
* @default true
|
|
22481
22881
|
* type {boolean}
|
|
22482
22882
|
*/
|
|
22483
22883
|
this.isContextValid = true;
|
|
22484
22884
|
|
|
22885
|
+
/**
|
|
22886
|
+
* The Path2D instance used by the renderer to draw primitives
|
|
22887
|
+
* @name path2D
|
|
22888
|
+
* @type {Path2D}
|
|
22889
|
+
* @memberof Renderer#
|
|
22890
|
+
*/
|
|
22891
|
+
this.path2D = new Path2D();
|
|
22892
|
+
|
|
22485
22893
|
/**
|
|
22486
22894
|
* @ignore
|
|
22487
22895
|
*/
|
|
@@ -22764,11 +23172,13 @@ class Renderer {
|
|
|
22764
23172
|
* @name stroke
|
|
22765
23173
|
* @memberof Renderer.prototype
|
|
22766
23174
|
* @function
|
|
22767
|
-
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
23175
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
22768
23176
|
* @param {boolean} [fill=false] fill the shape with the current color if true
|
|
22769
23177
|
*/
|
|
22770
23178
|
stroke(shape, fill) {
|
|
22771
|
-
if (shape instanceof
|
|
23179
|
+
if (shape instanceof RoundRect) {
|
|
23180
|
+
this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
|
|
23181
|
+
} else if (shape instanceof Rect || shape instanceof Bounds$1) {
|
|
22772
23182
|
this.strokeRect(shape.left, shape.top, shape.width, shape.height, fill);
|
|
22773
23183
|
} else if (shape instanceof Line || shape instanceof Polygon) {
|
|
22774
23184
|
this.strokePolygon(shape, fill);
|
|
@@ -22783,6 +23193,17 @@ class Renderer {
|
|
|
22783
23193
|
}
|
|
22784
23194
|
}
|
|
22785
23195
|
|
|
23196
|
+
/**
|
|
23197
|
+
* fill the given shape
|
|
23198
|
+
* @name fill
|
|
23199
|
+
* @memberof Renderer.prototype
|
|
23200
|
+
* @function
|
|
23201
|
+
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
23202
|
+
*/
|
|
23203
|
+
fill(shape) {
|
|
23204
|
+
this.stroke(shape, true);
|
|
23205
|
+
}
|
|
23206
|
+
|
|
22786
23207
|
/**
|
|
22787
23208
|
* tint the given image or canvas using the given color
|
|
22788
23209
|
* @name tint
|
|
@@ -22812,17 +23233,6 @@ class Renderer {
|
|
|
22812
23233
|
return canvas;
|
|
22813
23234
|
}
|
|
22814
23235
|
|
|
22815
|
-
/**
|
|
22816
|
-
* fill the given shape
|
|
22817
|
-
* @name fill
|
|
22818
|
-
* @memberof Renderer.prototype
|
|
22819
|
-
* @function
|
|
22820
|
-
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
22821
|
-
*/
|
|
22822
|
-
fill(shape) {
|
|
22823
|
-
this.stroke(shape, true);
|
|
22824
|
-
}
|
|
22825
|
-
|
|
22826
23236
|
/**
|
|
22827
23237
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
22828
23238
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
@@ -23060,7 +23470,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23060
23470
|
* @param {number} height The rectangle's height.
|
|
23061
23471
|
*/
|
|
23062
23472
|
clearRect(x, y, width, height) {
|
|
23063
|
-
this.
|
|
23473
|
+
this.getContext().clearRect(x, y, width, height);
|
|
23064
23474
|
}
|
|
23065
23475
|
|
|
23066
23476
|
/**
|
|
@@ -23079,7 +23489,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23079
23489
|
* var basic = renderer.createPattern(image, "no-repeat");
|
|
23080
23490
|
*/
|
|
23081
23491
|
createPattern(image, repeat) {
|
|
23082
|
-
return this.
|
|
23492
|
+
return this.getContext().createPattern(image, repeat);
|
|
23083
23493
|
}
|
|
23084
23494
|
|
|
23085
23495
|
/**
|
|
@@ -23105,10 +23515,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23105
23515
|
* renderer.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
|
|
23106
23516
|
*/
|
|
23107
23517
|
drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
|
|
23108
|
-
if (this.
|
|
23518
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23109
23519
|
// Fast path: don't draw fully transparent
|
|
23110
23520
|
return;
|
|
23111
23521
|
}
|
|
23522
|
+
var context = this.getContext();
|
|
23112
23523
|
|
|
23113
23524
|
if (typeof sw === "undefined") {
|
|
23114
23525
|
sw = dw = image.width;
|
|
@@ -23142,7 +23553,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23142
23553
|
// get a tinted version of this image from the texture cache
|
|
23143
23554
|
source = this.cache.tint(image, this.currentTint.toRGB());
|
|
23144
23555
|
}
|
|
23145
|
-
|
|
23556
|
+
context.drawImage(source, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
23146
23557
|
}
|
|
23147
23558
|
|
|
23148
23559
|
/**
|
|
@@ -23158,14 +23569,15 @@ class CanvasRenderer extends Renderer {
|
|
|
23158
23569
|
* @see CanvasRenderer#createPattern
|
|
23159
23570
|
*/
|
|
23160
23571
|
drawPattern(pattern, x, y, width, height) {
|
|
23161
|
-
if (this.
|
|
23572
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23162
23573
|
// Fast path: don't draw fully transparent
|
|
23163
23574
|
return;
|
|
23164
23575
|
}
|
|
23165
|
-
var
|
|
23166
|
-
|
|
23167
|
-
|
|
23168
|
-
|
|
23576
|
+
var context = this.getContext();
|
|
23577
|
+
var fillStyle = context.fillStyle;
|
|
23578
|
+
context.fillStyle = pattern;
|
|
23579
|
+
context.fillRect(x, y, width, height);
|
|
23580
|
+
context.fillStyle = fillStyle;
|
|
23169
23581
|
}
|
|
23170
23582
|
|
|
23171
23583
|
/**
|
|
@@ -23182,12 +23594,12 @@ class CanvasRenderer extends Renderer {
|
|
|
23182
23594
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23183
23595
|
*/
|
|
23184
23596
|
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
23185
|
-
|
|
23186
|
-
|
|
23187
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23597
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23188
23598
|
// Fast path: don't draw fully transparent
|
|
23189
23599
|
return;
|
|
23190
23600
|
}
|
|
23601
|
+
var context = this.getContext();
|
|
23602
|
+
|
|
23191
23603
|
context.translate(x, y);
|
|
23192
23604
|
context.beginPath();
|
|
23193
23605
|
context.arc(0, 0, radius, start, end, antiClockwise || false);
|
|
@@ -23223,12 +23635,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23223
23635
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23224
23636
|
*/
|
|
23225
23637
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23638
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23229
23639
|
// Fast path: don't draw fully transparent
|
|
23230
23640
|
return;
|
|
23231
23641
|
}
|
|
23642
|
+
var context = this.getContext();
|
|
23232
23643
|
|
|
23233
23644
|
var hw = w,
|
|
23234
23645
|
hh = h,
|
|
@@ -23279,9 +23690,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23279
23690
|
* @param {number} endY the end y coordinate
|
|
23280
23691
|
*/
|
|
23281
23692
|
strokeLine(startX, startY, endX, endY) {
|
|
23282
|
-
|
|
23283
|
-
|
|
23284
|
-
if (context < 1 / 255) {
|
|
23693
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23285
23694
|
// Fast path: don't draw fully transparent
|
|
23286
23695
|
return;
|
|
23287
23696
|
}
|
|
@@ -23315,12 +23724,11 @@ class CanvasRenderer extends Renderer {
|
|
|
23315
23724
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23316
23725
|
*/
|
|
23317
23726
|
strokePolygon(poly, fill = false) {
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
if (context.globalAlpha < 1 / 255) {
|
|
23727
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23321
23728
|
// Fast path: don't draw fully transparent
|
|
23322
23729
|
return;
|
|
23323
23730
|
}
|
|
23731
|
+
var context = this.getContext();
|
|
23324
23732
|
|
|
23325
23733
|
this.translate(poly.pos.x, poly.pos.y);
|
|
23326
23734
|
context.beginPath();
|
|
@@ -23359,15 +23767,13 @@ class CanvasRenderer extends Renderer {
|
|
|
23359
23767
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23360
23768
|
*/
|
|
23361
23769
|
strokeRect(x, y, width, height, fill = false) {
|
|
23362
|
-
if (
|
|
23363
|
-
|
|
23364
|
-
|
|
23365
|
-
if (this.backBufferContext2D.globalAlpha < 1 / 255) {
|
|
23366
|
-
// Fast path: don't draw fully transparent
|
|
23367
|
-
return;
|
|
23368
|
-
}
|
|
23369
|
-
this.backBufferContext2D.strokeRect(x, y, width, height);
|
|
23770
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23771
|
+
// Fast path: don't draw fully transparent
|
|
23772
|
+
return;
|
|
23370
23773
|
}
|
|
23774
|
+
var context = this.getContext();
|
|
23775
|
+
|
|
23776
|
+
context[fill === true ? "fillRect" : "strokeRect"](x, y, width, height);
|
|
23371
23777
|
}
|
|
23372
23778
|
|
|
23373
23779
|
/**
|
|
@@ -23381,11 +23787,59 @@ class CanvasRenderer extends Renderer {
|
|
|
23381
23787
|
* @param {number} height
|
|
23382
23788
|
*/
|
|
23383
23789
|
fillRect(x, y, width, height) {
|
|
23384
|
-
|
|
23790
|
+
this.strokeRect(x, y, width, height, true);
|
|
23791
|
+
}
|
|
23792
|
+
|
|
23793
|
+
/**
|
|
23794
|
+
* Stroke a rounded rectangle at the specified coordinates
|
|
23795
|
+
* @name strokeRoundRect
|
|
23796
|
+
* @memberof CanvasRenderer.prototype
|
|
23797
|
+
* @function
|
|
23798
|
+
* @param {number} x
|
|
23799
|
+
* @param {number} y
|
|
23800
|
+
* @param {number} width
|
|
23801
|
+
* @param {number} height
|
|
23802
|
+
* @param {number} radius
|
|
23803
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
23804
|
+
*/
|
|
23805
|
+
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
23806
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
23385
23807
|
// Fast path: don't draw fully transparent
|
|
23386
23808
|
return;
|
|
23387
23809
|
}
|
|
23388
|
-
this.
|
|
23810
|
+
var context = this.getContext();
|
|
23811
|
+
|
|
23812
|
+
context.beginPath();
|
|
23813
|
+
if (typeof context.roundRect === "function") {
|
|
23814
|
+
//https://developer.chrome.com/blog/canvas2d/#round-rect
|
|
23815
|
+
context.roundRect(x, y, width, height, radius);
|
|
23816
|
+
} else {
|
|
23817
|
+
context.moveTo(x + radius, y);
|
|
23818
|
+
context.lineTo(x + width - radius, y);
|
|
23819
|
+
context.arcTo(x + width, y, x + width, y + radius, radius);
|
|
23820
|
+
context.lineTo(x + width, y + height - radius);
|
|
23821
|
+
context.arcTo(x + width, y + height, x + width - radius, y + height, radius);
|
|
23822
|
+
context.lineTo(x + radius, y + height);
|
|
23823
|
+
context.arcTo(x, y + height, x, y + height - radius, radius);
|
|
23824
|
+
context.lineTo(x, y + radius);
|
|
23825
|
+
context.arcTo(x, y, x + radius, y, radius);
|
|
23826
|
+
}
|
|
23827
|
+
context[fill === true ? "fill" : "stroke"]();
|
|
23828
|
+
}
|
|
23829
|
+
|
|
23830
|
+
/**
|
|
23831
|
+
* Draw a rounded filled rectangle at the specified coordinates
|
|
23832
|
+
* @name fillRoundRect
|
|
23833
|
+
* @memberof CanvasRenderer.prototype
|
|
23834
|
+
* @function
|
|
23835
|
+
* @param {number} x
|
|
23836
|
+
* @param {number} y
|
|
23837
|
+
* @param {number} width
|
|
23838
|
+
* @param {number} height
|
|
23839
|
+
* @param {number} radius
|
|
23840
|
+
*/
|
|
23841
|
+
fillRoundRect(x, y, width, height, radius) {
|
|
23842
|
+
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
23389
23843
|
}
|
|
23390
23844
|
|
|
23391
23845
|
|
|
@@ -23427,7 +23881,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23427
23881
|
*/
|
|
23428
23882
|
restore() {
|
|
23429
23883
|
this.backBufferContext2D.restore();
|
|
23430
|
-
this.currentColor.glArray[3] = this.
|
|
23884
|
+
this.currentColor.glArray[3] = this.getGlobalAlpha();
|
|
23431
23885
|
this.currentScissor[0] = 0;
|
|
23432
23886
|
this.currentScissor[1] = 0;
|
|
23433
23887
|
this.currentScissor[2] = this.backBufferCanvas.width;
|
|
@@ -23475,7 +23929,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23475
23929
|
}
|
|
23476
23930
|
|
|
23477
23931
|
/**
|
|
23478
|
-
* Set the global alpha
|
|
23932
|
+
* Set the global alpha
|
|
23479
23933
|
* @name setGlobalAlpha
|
|
23480
23934
|
* @memberof CanvasRenderer.prototype
|
|
23481
23935
|
* @function
|
|
@@ -23485,6 +23939,17 @@ class CanvasRenderer extends Renderer {
|
|
|
23485
23939
|
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
23486
23940
|
}
|
|
23487
23941
|
|
|
23942
|
+
/**
|
|
23943
|
+
* Return the global alpha
|
|
23944
|
+
* @name getGlobalAlpha
|
|
23945
|
+
* @memberof CanvasRenderer.prototype
|
|
23946
|
+
* @function
|
|
23947
|
+
* @returns {number} global alpha value
|
|
23948
|
+
*/
|
|
23949
|
+
getGlobalAlpha() {
|
|
23950
|
+
return this.backBufferContext2D.globalAlpha;
|
|
23951
|
+
}
|
|
23952
|
+
|
|
23488
23953
|
/**
|
|
23489
23954
|
* Set the line width on the context
|
|
23490
23955
|
* @name setLineWidth
|
|
@@ -23594,7 +24059,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23594
24059
|
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
23595
24060
|
*/
|
|
23596
24061
|
setMask(mask) {
|
|
23597
|
-
var context = this.
|
|
24062
|
+
var context = this.getContext();
|
|
23598
24063
|
var _x = mask.pos.x, _y = mask.pos.y;
|
|
23599
24064
|
|
|
23600
24065
|
context.save();
|
|
@@ -23941,9 +24406,9 @@ class TMXLayer extends Renderable {
|
|
|
23941
24406
|
var tile = null;
|
|
23942
24407
|
|
|
23943
24408
|
if (this.contains(x, y)) {
|
|
23944
|
-
var coord = this.getRenderer().pixelToTileCoords(x, y, pull("Vector2d"));
|
|
24409
|
+
var coord = this.getRenderer().pixelToTileCoords(x, y, pool$1.pull("Vector2d"));
|
|
23945
24410
|
tile = this.cellAt(coord.x, coord.y);
|
|
23946
|
-
push(coord);
|
|
24411
|
+
pool$1.push(coord);
|
|
23947
24412
|
}
|
|
23948
24413
|
return tile;
|
|
23949
24414
|
}
|
|
@@ -24085,6 +24550,8 @@ class Bounds {
|
|
|
24085
24550
|
* @param {Vector2d[]} [vertices] an array of me.Vector2d points
|
|
24086
24551
|
*/
|
|
24087
24552
|
constructor(vertices) {
|
|
24553
|
+
// @ignore
|
|
24554
|
+
this._center = new Vector2d();
|
|
24088
24555
|
this.onResetEvent(vertices);
|
|
24089
24556
|
}
|
|
24090
24557
|
|
|
@@ -24101,9 +24568,6 @@ class Bounds {
|
|
|
24101
24568
|
if (typeof vertices !== "undefined") {
|
|
24102
24569
|
this.update(vertices);
|
|
24103
24570
|
}
|
|
24104
|
-
|
|
24105
|
-
// @ignore
|
|
24106
|
-
this._center = new Vector2d();
|
|
24107
24571
|
}
|
|
24108
24572
|
|
|
24109
24573
|
/**
|
|
@@ -24525,11 +24989,11 @@ class Bounds {
|
|
|
24525
24989
|
* @returns {Polygon} a new Polygon that represents this bounds.
|
|
24526
24990
|
*/
|
|
24527
24991
|
toPolygon () {
|
|
24528
|
-
return
|
|
24529
|
-
|
|
24530
|
-
|
|
24531
|
-
|
|
24532
|
-
|
|
24992
|
+
return pool$1.pull("Polygon", this.x, this.y, [
|
|
24993
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
24994
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
24995
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
24996
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
24533
24997
|
]);
|
|
24534
24998
|
}
|
|
24535
24999
|
|
|
@@ -24586,7 +25050,7 @@ class TMXRenderer {
|
|
|
24586
25050
|
* @returns {Bounds}
|
|
24587
25051
|
*/
|
|
24588
25052
|
getBounds(layer) {
|
|
24589
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25053
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
24590
25054
|
bounds.setMinMax(
|
|
24591
25055
|
0, 0,
|
|
24592
25056
|
this.cols * this.tilewidth,
|
|
@@ -24745,13 +25209,13 @@ class TMXOrthogonalRenderer extends TMXRenderer {
|
|
|
24745
25209
|
var start = this.pixelToTileCoords(
|
|
24746
25210
|
Math.max(rect.pos.x - (layer.maxTileSize.width - layer.tilewidth), 0),
|
|
24747
25211
|
Math.max(rect.pos.y - (layer.maxTileSize.height - layer.tileheight), 0),
|
|
24748
|
-
pull("Vector2d")
|
|
25212
|
+
pool$1.pull("Vector2d")
|
|
24749
25213
|
).floorSelf();
|
|
24750
25214
|
|
|
24751
25215
|
var end = this.pixelToTileCoords(
|
|
24752
25216
|
rect.pos.x + rect.width + this.tilewidth,
|
|
24753
25217
|
rect.pos.y + rect.height + this.tileheight,
|
|
24754
|
-
pull("Vector2d")
|
|
25218
|
+
pool$1.pull("Vector2d")
|
|
24755
25219
|
).ceilSelf();
|
|
24756
25220
|
|
|
24757
25221
|
//ensure we are in the valid tile range
|
|
@@ -24789,8 +25253,8 @@ class TMXOrthogonalRenderer extends TMXRenderer {
|
|
|
24789
25253
|
}
|
|
24790
25254
|
}
|
|
24791
25255
|
|
|
24792
|
-
push(start);
|
|
24793
|
-
push(end);
|
|
25256
|
+
pool$1.push(start);
|
|
25257
|
+
pool$1.push(end);
|
|
24794
25258
|
}
|
|
24795
25259
|
}
|
|
24796
25260
|
|
|
@@ -24836,7 +25300,7 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24836
25300
|
* @returns {Bounds}
|
|
24837
25301
|
*/
|
|
24838
25302
|
getBounds(layer) {
|
|
24839
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25303
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
24840
25304
|
bounds.setMinMax(
|
|
24841
25305
|
0, 0,
|
|
24842
25306
|
(this.cols + this.rows) * (this.tilewidth / 2),
|
|
@@ -24877,14 +25341,14 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24877
25341
|
adjustPosition(obj) {
|
|
24878
25342
|
var tileX = obj.x / this.hTilewidth;
|
|
24879
25343
|
var tileY = obj.y / this.tileheight;
|
|
24880
|
-
var isoPos = pull("Vector2d");
|
|
25344
|
+
var isoPos = pool$1.pull("Vector2d");
|
|
24881
25345
|
|
|
24882
25346
|
this.tileToPixelCoords(tileX, tileY, isoPos);
|
|
24883
25347
|
|
|
24884
25348
|
obj.x = isoPos.x;
|
|
24885
25349
|
obj.y = isoPos.y;
|
|
24886
25350
|
|
|
24887
|
-
push(isoPos);
|
|
25351
|
+
pool$1.push(isoPos);
|
|
24888
25352
|
}
|
|
24889
25353
|
|
|
24890
25354
|
/**
|
|
@@ -24914,18 +25378,18 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24914
25378
|
var rowItr = this.pixelToTileCoords(
|
|
24915
25379
|
rect.pos.x - tileset.tilewidth,
|
|
24916
25380
|
rect.pos.y - tileset.tileheight,
|
|
24917
|
-
pull("Vector2d")
|
|
25381
|
+
pool$1.pull("Vector2d")
|
|
24918
25382
|
).floorSelf();
|
|
24919
25383
|
var tileEnd = this.pixelToTileCoords(
|
|
24920
25384
|
rect.pos.x + rect.width + tileset.tilewidth,
|
|
24921
25385
|
rect.pos.y + rect.height + tileset.tileheight,
|
|
24922
|
-
pull("Vector2d")
|
|
25386
|
+
pool$1.pull("Vector2d")
|
|
24923
25387
|
).ceilSelf();
|
|
24924
25388
|
|
|
24925
|
-
var rectEnd = this.tileToPixelCoords(tileEnd.x, tileEnd.y, pull("Vector2d"));
|
|
25389
|
+
var rectEnd = this.tileToPixelCoords(tileEnd.x, tileEnd.y, pool$1.pull("Vector2d"));
|
|
24926
25390
|
|
|
24927
25391
|
// Determine the tile and pixel coordinates to start at
|
|
24928
|
-
var startPos = this.tileToPixelCoords(rowItr.x, rowItr.y, pull("Vector2d"));
|
|
25392
|
+
var startPos = this.tileToPixelCoords(rowItr.x, rowItr.y, pool$1.pull("Vector2d"));
|
|
24929
25393
|
startPos.x -= this.hTilewidth;
|
|
24930
25394
|
startPos.y += this.tileheight;
|
|
24931
25395
|
|
|
@@ -24992,11 +25456,11 @@ class TMXIsometricRenderer extends TMXRenderer {
|
|
|
24992
25456
|
}
|
|
24993
25457
|
}
|
|
24994
25458
|
|
|
24995
|
-
push(columnItr);
|
|
24996
|
-
push(rowItr);
|
|
24997
|
-
push(tileEnd);
|
|
24998
|
-
push(rectEnd);
|
|
24999
|
-
push(startPos);
|
|
25459
|
+
pool$1.push(columnItr);
|
|
25460
|
+
pool$1.push(rowItr);
|
|
25461
|
+
pool$1.push(tileEnd);
|
|
25462
|
+
pool$1.push(rectEnd);
|
|
25463
|
+
pool$1.push(startPos);
|
|
25000
25464
|
}
|
|
25001
25465
|
}
|
|
25002
25466
|
|
|
@@ -25081,7 +25545,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25081
25545
|
* @returns {Bounds}
|
|
25082
25546
|
*/
|
|
25083
25547
|
getBounds(layer) {
|
|
25084
|
-
var bounds = layer instanceof TMXLayer ? pull("Bounds") : this.bounds;
|
|
25548
|
+
var bounds = layer instanceof TMXLayer ? pool$1.pull("Bounds") : this.bounds;
|
|
25085
25549
|
|
|
25086
25550
|
// The map size is the same regardless of which indexes are shifted.
|
|
25087
25551
|
if (this.staggerX) {
|
|
@@ -25232,13 +25696,13 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25232
25696
|
}
|
|
25233
25697
|
|
|
25234
25698
|
// Start with the coordinates of a grid-aligned tile
|
|
25235
|
-
var referencePoint = pull("Vector2d",
|
|
25699
|
+
var referencePoint = pool$1.pull("Vector2d",
|
|
25236
25700
|
Math.floor(x / (this.columnwidth * 2)),
|
|
25237
25701
|
Math.floor((y / (this.rowheight * 2)))
|
|
25238
25702
|
);
|
|
25239
25703
|
|
|
25240
25704
|
// Relative x and y position on the base square of the grid-aligned tile
|
|
25241
|
-
var rel = pull("Vector2d",
|
|
25705
|
+
var rel = pool$1.pull("Vector2d",
|
|
25242
25706
|
x - referencePoint.x * (this.columnwidth * 2),
|
|
25243
25707
|
y - referencePoint.y * (this.rowheight * 2)
|
|
25244
25708
|
);
|
|
@@ -25297,8 +25761,8 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25297
25761
|
referencePoint.y + offsets[nearest].y
|
|
25298
25762
|
);
|
|
25299
25763
|
|
|
25300
|
-
push(referencePoint);
|
|
25301
|
-
push(rel);
|
|
25764
|
+
pool$1.push(referencePoint);
|
|
25765
|
+
pool$1.push(rel);
|
|
25302
25766
|
|
|
25303
25767
|
return ret;
|
|
25304
25768
|
}
|
|
@@ -25349,7 +25813,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25349
25813
|
*/
|
|
25350
25814
|
drawTile(renderer, x, y, tmxTile) {
|
|
25351
25815
|
var tileset = tmxTile.tileset;
|
|
25352
|
-
var point = this.tileToPixelCoords(x, y, pull("Vector2d"));
|
|
25816
|
+
var point = this.tileToPixelCoords(x, y, pool$1.pull("Vector2d"));
|
|
25353
25817
|
|
|
25354
25818
|
// draw the tile
|
|
25355
25819
|
tileset.drawTile(
|
|
@@ -25359,7 +25823,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25359
25823
|
tmxTile
|
|
25360
25824
|
);
|
|
25361
25825
|
|
|
25362
|
-
push(point);
|
|
25826
|
+
pool$1.push(point);
|
|
25363
25827
|
}
|
|
25364
25828
|
|
|
25365
25829
|
/**
|
|
@@ -25373,7 +25837,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25373
25837
|
var startTile = this.pixelToTileCoords(
|
|
25374
25838
|
rect.pos.x,
|
|
25375
25839
|
rect.pos.y,
|
|
25376
|
-
pull("Vector2d")
|
|
25840
|
+
pool$1.pull("Vector2d")
|
|
25377
25841
|
);
|
|
25378
25842
|
|
|
25379
25843
|
// Compensate for the layer position
|
|
@@ -25383,7 +25847,7 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25383
25847
|
var startPos = this.tileToPixelCoords(
|
|
25384
25848
|
startTile.x + layer.pos.x,
|
|
25385
25849
|
startTile.y + layer.pos.y,
|
|
25386
|
-
pull("Vector2d")
|
|
25850
|
+
pool$1.pull("Vector2d")
|
|
25387
25851
|
);
|
|
25388
25852
|
|
|
25389
25853
|
var rowTile = startTile.clone();
|
|
@@ -25446,8 +25910,8 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25446
25910
|
|
|
25447
25911
|
startPos.y += this.rowheight;
|
|
25448
25912
|
}
|
|
25449
|
-
push(rowTile);
|
|
25450
|
-
push(rowPos);
|
|
25913
|
+
pool$1.push(rowTile);
|
|
25914
|
+
pool$1.push(rowPos);
|
|
25451
25915
|
|
|
25452
25916
|
} else {
|
|
25453
25917
|
//ensure we are in the valid tile range
|
|
@@ -25483,12 +25947,12 @@ class TMXHexagonalRenderer extends TMXRenderer {
|
|
|
25483
25947
|
}
|
|
25484
25948
|
startPos.y += this.rowheight;
|
|
25485
25949
|
}
|
|
25486
|
-
push(rowTile);
|
|
25487
|
-
push(rowPos);
|
|
25950
|
+
pool$1.push(rowTile);
|
|
25951
|
+
pool$1.push(rowPos);
|
|
25488
25952
|
}
|
|
25489
25953
|
|
|
25490
|
-
push(startTile);
|
|
25491
|
-
push(startPos);
|
|
25954
|
+
pool$1.push(startTile);
|
|
25955
|
+
pool$1.push(startPos);
|
|
25492
25956
|
}
|
|
25493
25957
|
}
|
|
25494
25958
|
|
|
@@ -25527,7 +25991,7 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25527
25991
|
}
|
|
25528
25992
|
|
|
25529
25993
|
// Start with the coordinates of a grid-aligned tile
|
|
25530
|
-
var referencePoint = pull("Vector2d",
|
|
25994
|
+
var referencePoint = pool$1.pull("Vector2d",
|
|
25531
25995
|
Math.floor(alignedX / this.tilewidth),
|
|
25532
25996
|
Math.floor(alignedY / this.tileheight)
|
|
25533
25997
|
);
|
|
@@ -25546,7 +26010,7 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25546
26010
|
}
|
|
25547
26011
|
|
|
25548
26012
|
// Relative x and y position on the base square of the grid-aligned tile
|
|
25549
|
-
var rel = pull("Vector2d",
|
|
26013
|
+
var rel = pool$1.pull("Vector2d",
|
|
25550
26014
|
alignedX - referencePoint.x * this.tilewidth,
|
|
25551
26015
|
alignedY - referencePoint.y * this.tileheight
|
|
25552
26016
|
);
|
|
@@ -25579,8 +26043,8 @@ class TMXStaggeredRenderer extends TMXHexagonalRenderer {
|
|
|
25579
26043
|
|
|
25580
26044
|
ret.div(this.tilewidth / Math.sqrt(2)).rotate(degToRad(-45)).add(referencePoint);
|
|
25581
26045
|
|
|
25582
|
-
push(referencePoint);
|
|
25583
|
-
push(rel);
|
|
26046
|
+
pool$1.push(referencePoint);
|
|
26047
|
+
pool$1.push(rel);
|
|
25584
26048
|
|
|
25585
26049
|
return ret;
|
|
25586
26050
|
}
|
|
@@ -26208,7 +26672,7 @@ class TMXObject {
|
|
|
26208
26672
|
// add an ellipse shape
|
|
26209
26673
|
if (this.isEllipse === true) {
|
|
26210
26674
|
// ellipse coordinates are the center position, so set default to the corresonding radius
|
|
26211
|
-
shapes.push((
|
|
26675
|
+
shapes.push((pool$1.pull("Ellipse",
|
|
26212
26676
|
this.width / 2,
|
|
26213
26677
|
this.height / 2,
|
|
26214
26678
|
this.width,
|
|
@@ -26218,7 +26682,7 @@ class TMXObject {
|
|
|
26218
26682
|
|
|
26219
26683
|
// add a polygon
|
|
26220
26684
|
if (this.isPolygon === true) {
|
|
26221
|
-
var _polygon =
|
|
26685
|
+
var _polygon = pool$1.pull("Polygon", 0, 0, this.points);
|
|
26222
26686
|
// make sure it's a convex polygon
|
|
26223
26687
|
if (_polygon.isConvex() === false ) {
|
|
26224
26688
|
throw new Error("collision polygones in Tiled should be defined as Convex");
|
|
@@ -26234,22 +26698,22 @@ class TMXObject {
|
|
|
26234
26698
|
for (i = 0; i < segments; i++) {
|
|
26235
26699
|
// clone the value before, as [i + 1]
|
|
26236
26700
|
// is reused later by the next segment
|
|
26237
|
-
p1 =
|
|
26238
|
-
p2 =
|
|
26701
|
+
p1 = pool$1.pull("Vector2d", p[i].x, p[i].y);
|
|
26702
|
+
p2 = pool$1.pull("Vector2d", p[i + 1].x, p[i + 1].y);
|
|
26239
26703
|
if (this.rotation !== 0) {
|
|
26240
26704
|
p1 = p1.rotate(this.rotation);
|
|
26241
26705
|
p2 = p2.rotate(this.rotation);
|
|
26242
26706
|
}
|
|
26243
|
-
shapes.push(
|
|
26707
|
+
shapes.push(pool$1.pull("Line", 0, 0, [ p1, p2 ]));
|
|
26244
26708
|
}
|
|
26245
26709
|
}
|
|
26246
26710
|
|
|
26247
26711
|
// it's a rectangle, returns a polygon object anyway
|
|
26248
26712
|
else {
|
|
26249
|
-
shapes.push((
|
|
26713
|
+
shapes.push((pool$1.pull("Polygon",
|
|
26250
26714
|
0, 0, [
|
|
26251
|
-
|
|
26252
|
-
|
|
26715
|
+
pool$1.pull("Vector2d"), pool$1.pull("Vector2d", this.width, 0),
|
|
26716
|
+
pool$1.pull("Vector2d", this.width, this.height), pool$1.pull("Vector2d", 0, this.height)
|
|
26253
26717
|
]
|
|
26254
26718
|
)).rotate(this.rotation));
|
|
26255
26719
|
}
|
|
@@ -26443,16 +26907,16 @@ function readImageLayer(map, data, z) {
|
|
|
26443
26907
|
applyTMXProperties(data.properties, data);
|
|
26444
26908
|
|
|
26445
26909
|
// create the layer
|
|
26446
|
-
var imageLayer = pull("ImageLayer",
|
|
26910
|
+
var imageLayer = pool$1.pull("ImageLayer",
|
|
26447
26911
|
// x/y is deprecated since 0.15 and replace by offsetx/y
|
|
26448
26912
|
+data.offsetx || +data.x || 0,
|
|
26449
26913
|
+data.offsety || +data.y || 0,
|
|
26450
26914
|
Object.assign({
|
|
26451
26915
|
name: data.name,
|
|
26452
26916
|
image: data.image,
|
|
26453
|
-
ratio : pull("Vector2d", +data.parallaxx || 1.0, +data.parallaxy || 1.0),
|
|
26917
|
+
ratio : pool$1.pull("Vector2d", +data.parallaxx || 1.0, +data.parallaxy || 1.0),
|
|
26454
26918
|
// convert to melonJS color format (note: this should be done earlier when parsing data)
|
|
26455
|
-
tint : typeof (data.tintcolor) !== "undefined" ? (pull("Color")).parseHex(data.tintcolor, true) : undefined,
|
|
26919
|
+
tint : typeof (data.tintcolor) !== "undefined" ? (pool$1.pull("Color")).parseHex(data.tintcolor, true) : undefined,
|
|
26456
26920
|
z: z
|
|
26457
26921
|
}, data.properties)
|
|
26458
26922
|
);
|
|
@@ -26692,7 +27156,7 @@ class TMXTileMap {
|
|
|
26692
27156
|
if (this.background_image) {
|
|
26693
27157
|
// add a new image layer
|
|
26694
27158
|
this.layers.push(
|
|
26695
|
-
pull("ImageLayer",
|
|
27159
|
+
pool$1.pull("ImageLayer",
|
|
26696
27160
|
0, 0, {
|
|
26697
27161
|
name : "background_image",
|
|
26698
27162
|
image : this.background_image,
|
|
@@ -26852,6 +27316,8 @@ class TMXTileMap {
|
|
|
26852
27316
|
var settings = group.objects[o];
|
|
26853
27317
|
// reference to the instantiated object
|
|
26854
27318
|
var obj;
|
|
27319
|
+
// a reference to the default shape
|
|
27320
|
+
var shape;
|
|
26855
27321
|
|
|
26856
27322
|
// Tiled uses 0,0 by default
|
|
26857
27323
|
if (typeof (settings.anchorPoint) === "undefined") {
|
|
@@ -26859,7 +27325,7 @@ class TMXTileMap {
|
|
|
26859
27325
|
}
|
|
26860
27326
|
// convert to melonJS renderable argument name
|
|
26861
27327
|
if (typeof (settings.tintcolor) !== "undefined") {
|
|
26862
|
-
settings.tint = pull("Color");
|
|
27328
|
+
settings.tint = pool$1.pull("Color");
|
|
26863
27329
|
settings.tint.parseHex(settings.tintcolor, true);
|
|
26864
27330
|
}
|
|
26865
27331
|
|
|
@@ -26877,39 +27343,57 @@ class TMXTileMap {
|
|
|
26877
27343
|
settings.text.anchorPoint = settings.anchorPoint;
|
|
26878
27344
|
}
|
|
26879
27345
|
if (settings.text.bitmap === true) {
|
|
26880
|
-
obj = pull("BitmapText", settings.x, settings.y, settings.text);
|
|
27346
|
+
obj = pool$1.pull("BitmapText", settings.x, settings.y, settings.text);
|
|
26881
27347
|
} else {
|
|
26882
|
-
obj = pull("Text", settings.x, settings.y, settings.text);
|
|
27348
|
+
obj = pool$1.pull("Text", settings.x, settings.y, settings.text);
|
|
26883
27349
|
}
|
|
26884
27350
|
// set the obj z order
|
|
26885
27351
|
obj.pos.z = settings.z;
|
|
26886
27352
|
} else if (typeof settings.tile === "object") {
|
|
27353
|
+
// create a default shape if none is specified
|
|
27354
|
+
shape = settings.shapes;
|
|
27355
|
+
if (typeof shape === "undefined") {
|
|
27356
|
+
shape = pool$1.pull("Polygon", 0, 0, [
|
|
27357
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
27358
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
27359
|
+
pool$1.pull("Vector2d", this.width, this.height)
|
|
27360
|
+
]);
|
|
27361
|
+
}
|
|
26887
27362
|
// check if a me.Tile object is embedded
|
|
26888
27363
|
obj = settings.tile.getRenderable(settings);
|
|
26889
|
-
obj.body = new Body(obj,
|
|
27364
|
+
obj.body = new Body(obj, shape);
|
|
26890
27365
|
obj.body.setStatic(true);
|
|
26891
27366
|
// set the obj z order
|
|
26892
27367
|
obj.pos.setMuted(settings.x, settings.y, settings.z);
|
|
26893
27368
|
} else {
|
|
26894
27369
|
// pull the corresponding object from the object pool
|
|
26895
27370
|
if (typeof settings.name !== "undefined" && settings.name !== "") {
|
|
26896
|
-
obj = pull(
|
|
27371
|
+
obj = pool$1.pull(
|
|
26897
27372
|
settings.name,
|
|
26898
27373
|
settings.x, settings.y,
|
|
26899
27374
|
settings
|
|
26900
27375
|
);
|
|
26901
27376
|
} else {
|
|
26902
27377
|
// unnamed shape object
|
|
26903
|
-
obj = pull(
|
|
27378
|
+
obj = pool$1.pull(
|
|
26904
27379
|
"Renderable",
|
|
26905
27380
|
settings.x, settings.y,
|
|
26906
27381
|
settings.width, settings.height
|
|
26907
27382
|
);
|
|
27383
|
+
// create a default shape if none is specified
|
|
27384
|
+
shape = settings.shapes;
|
|
27385
|
+
if (typeof shape === "undefined") {
|
|
27386
|
+
shape = pool$1.pull("Polygon", 0, 0, [
|
|
27387
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
27388
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
27389
|
+
pool$1.pull("Vector2d", this.width, this.height)
|
|
27390
|
+
]);
|
|
27391
|
+
}
|
|
26908
27392
|
obj.anchorPoint.set(0, 0);
|
|
26909
27393
|
obj.name = settings.name;
|
|
26910
27394
|
obj.type = settings.type;
|
|
26911
27395
|
obj.id = settings.id;
|
|
26912
|
-
obj.body = new Body(obj,
|
|
27396
|
+
obj.body = new Body(obj, shape);
|
|
26913
27397
|
obj.body.setStatic(true);
|
|
26914
27398
|
obj.resize(obj.body.getBounds().width, obj.body.getBounds().height);
|
|
26915
27399
|
}
|
|
@@ -27309,7 +27793,7 @@ function checkLoadStatus(onload) {
|
|
|
27309
27793
|
}
|
|
27310
27794
|
}
|
|
27311
27795
|
else {
|
|
27312
|
-
timerId$1 = setTimeout(
|
|
27796
|
+
timerId$1 = setTimeout(() => {
|
|
27313
27797
|
checkLoadStatus(onload);
|
|
27314
27798
|
}, 100);
|
|
27315
27799
|
}
|
|
@@ -27346,7 +27830,7 @@ function preloadImage(img, onload, onerror) {
|
|
|
27346
27830
|
function preloadFontFace(data, onload, onerror) {
|
|
27347
27831
|
var font = new FontFace(data.name, data.src);
|
|
27348
27832
|
// loading promise
|
|
27349
|
-
font.load().then(
|
|
27833
|
+
font.load().then(() => {
|
|
27350
27834
|
// apply the font after the font has finished downloading
|
|
27351
27835
|
document.fonts.add(font);
|
|
27352
27836
|
document.body.style.fontFamily = data.name;
|
|
@@ -27535,12 +28019,12 @@ function preloadJavascript(data, onload, onerror) {
|
|
|
27535
28019
|
}
|
|
27536
28020
|
script.defer = true;
|
|
27537
28021
|
|
|
27538
|
-
script.onload =
|
|
28022
|
+
script.onload = () => {
|
|
27539
28023
|
// callback
|
|
27540
28024
|
onload();
|
|
27541
28025
|
};
|
|
27542
28026
|
|
|
27543
|
-
script.onerror =
|
|
28027
|
+
script.onerror = () => {
|
|
27544
28028
|
// callback
|
|
27545
28029
|
onerror(data.name);
|
|
27546
28030
|
};
|
|
@@ -28786,12 +29270,6 @@ function _checkCapabilities() {
|
|
|
28786
29270
|
// detect device type/platform
|
|
28787
29271
|
_detectDevice();
|
|
28788
29272
|
|
|
28789
|
-
// Mobile browser hacks
|
|
28790
|
-
if (device.isMobile) {
|
|
28791
|
-
// Prevent the webview from moving on a swipe
|
|
28792
|
-
device.enableSwipe(false);
|
|
28793
|
-
}
|
|
28794
|
-
|
|
28795
29273
|
// Touch/Gesture Event feature detection
|
|
28796
29274
|
device.TouchEvent = !!("ontouchstart" in globalThis);
|
|
28797
29275
|
device.PointerEvent = !!globalThis.PointerEvent;
|
|
@@ -28913,6 +29391,13 @@ function _checkCapabilities() {
|
|
|
28913
29391
|
);
|
|
28914
29392
|
}
|
|
28915
29393
|
}
|
|
29394
|
+
|
|
29395
|
+
// Mobile browser hacks
|
|
29396
|
+
if (device.isMobile) {
|
|
29397
|
+
// Prevent the webview from moving on a swipe
|
|
29398
|
+
device.enableSwipe(false);
|
|
29399
|
+
}
|
|
29400
|
+
|
|
28916
29401
|
}
|
|
28917
29402
|
|
|
28918
29403
|
// Initialize me.timer on Boot event
|
|
@@ -29349,13 +29834,14 @@ let device = {
|
|
|
29349
29834
|
* @param {boolean} [enable=true] enable or disable swipe.
|
|
29350
29835
|
*/
|
|
29351
29836
|
enableSwipe(enable) {
|
|
29837
|
+
var moveEvent = device.PointerEvent ? "pointermove" : (device.TouchEvent ? "touchmove" : "mousemove");
|
|
29352
29838
|
if (enable !== false) {
|
|
29353
29839
|
if (swipeEnabled === false) {
|
|
29354
|
-
globalThis.document.removeEventListener(
|
|
29840
|
+
globalThis.document.removeEventListener(moveEvent, _disableSwipeFn);
|
|
29355
29841
|
swipeEnabled = true;
|
|
29356
29842
|
}
|
|
29357
29843
|
} else if (swipeEnabled === true) {
|
|
29358
|
-
globalThis.document.addEventListener(
|
|
29844
|
+
globalThis.document.addEventListener(moveEvent, _disableSwipeFn, { passive: false });
|
|
29359
29845
|
swipeEnabled = false;
|
|
29360
29846
|
}
|
|
29361
29847
|
},
|
|
@@ -29839,6 +30325,29 @@ Object.defineProperty(device, "sound", {
|
|
|
29839
30325
|
|
|
29840
30326
|
var device$1 = device;
|
|
29841
30327
|
|
|
30328
|
+
/**
|
|
30329
|
+
* Hash map of GLSL data types to WebGL Uniform methods
|
|
30330
|
+
* @ignore
|
|
30331
|
+
*/
|
|
30332
|
+
const fnHash = {
|
|
30333
|
+
"bool" : "1i",
|
|
30334
|
+
"int" : "1i",
|
|
30335
|
+
"float" : "1f",
|
|
30336
|
+
"vec2" : "2fv",
|
|
30337
|
+
"vec3" : "3fv",
|
|
30338
|
+
"vec4" : "4fv",
|
|
30339
|
+
"bvec2" : "2iv",
|
|
30340
|
+
"bvec3" : "3iv",
|
|
30341
|
+
"bvec4" : "4iv",
|
|
30342
|
+
"ivec2" : "2iv",
|
|
30343
|
+
"ivec3" : "3iv",
|
|
30344
|
+
"ivec4" : "4iv",
|
|
30345
|
+
"mat2" : "Matrix2fv",
|
|
30346
|
+
"mat3" : "Matrix3fv",
|
|
30347
|
+
"mat4" : "Matrix4fv",
|
|
30348
|
+
"sampler2D" : "1i"
|
|
30349
|
+
};
|
|
30350
|
+
|
|
29842
30351
|
/**
|
|
29843
30352
|
* @ignore
|
|
29844
30353
|
*/
|
|
@@ -29902,6 +30411,7 @@ function extractUniforms(gl, shader) {
|
|
|
29902
30411
|
|
|
29903
30412
|
return uniforms;
|
|
29904
30413
|
}
|
|
30414
|
+
|
|
29905
30415
|
/**
|
|
29906
30416
|
* @ignore
|
|
29907
30417
|
*/
|
|
@@ -29918,6 +30428,7 @@ function extractAttributes(gl, shader) {
|
|
|
29918
30428
|
|
|
29919
30429
|
return attributes;
|
|
29920
30430
|
}
|
|
30431
|
+
|
|
29921
30432
|
/**
|
|
29922
30433
|
* @ignore
|
|
29923
30434
|
*/
|
|
@@ -29976,29 +30487,6 @@ function compileProgram(gl, vertex, fragment, attributes) {
|
|
|
29976
30487
|
return program;
|
|
29977
30488
|
}
|
|
29978
30489
|
|
|
29979
|
-
/**
|
|
29980
|
-
* Hash map of GLSL data types to WebGL Uniform methods
|
|
29981
|
-
* @ignore
|
|
29982
|
-
*/
|
|
29983
|
-
var fnHash = {
|
|
29984
|
-
"bool" : "1i",
|
|
29985
|
-
"int" : "1i",
|
|
29986
|
-
"float" : "1f",
|
|
29987
|
-
"vec2" : "2fv",
|
|
29988
|
-
"vec3" : "3fv",
|
|
29989
|
-
"vec4" : "4fv",
|
|
29990
|
-
"bvec2" : "2iv",
|
|
29991
|
-
"bvec3" : "3iv",
|
|
29992
|
-
"bvec4" : "4iv",
|
|
29993
|
-
"ivec2" : "2iv",
|
|
29994
|
-
"ivec3" : "3iv",
|
|
29995
|
-
"ivec4" : "4iv",
|
|
29996
|
-
"mat2" : "Matrix2fv",
|
|
29997
|
-
"mat3" : "Matrix3fv",
|
|
29998
|
-
"mat4" : "Matrix4fv",
|
|
29999
|
-
"sampler2D" : "1i"
|
|
30000
|
-
};
|
|
30001
|
-
|
|
30002
30490
|
/**
|
|
30003
30491
|
* set precision for the fiven shader source
|
|
30004
30492
|
* won't do anything if the precision is already specified
|
|
@@ -30010,6 +30498,7 @@ function setPrecision(src, precision) {
|
|
|
30010
30498
|
}
|
|
30011
30499
|
return src;
|
|
30012
30500
|
}
|
|
30501
|
+
|
|
30013
30502
|
/**
|
|
30014
30503
|
* clean the given source from space, comments, etc...
|
|
30015
30504
|
* @ignore
|
|
@@ -30026,6 +30515,7 @@ function minify(src) {
|
|
|
30026
30515
|
|
|
30027
30516
|
return src;
|
|
30028
30517
|
}
|
|
30518
|
+
|
|
30029
30519
|
/**
|
|
30030
30520
|
* @classdesc
|
|
30031
30521
|
* a base GL Shader object
|
|
@@ -30169,6 +30659,30 @@ class GLShader {
|
|
|
30169
30659
|
}
|
|
30170
30660
|
}
|
|
30171
30661
|
|
|
30662
|
+
/**
|
|
30663
|
+
* activate the given vertex attribute for this shader
|
|
30664
|
+
* @name setVertexAttributes
|
|
30665
|
+
* @memberof GLShader
|
|
30666
|
+
* @function
|
|
30667
|
+
* @param {WebGLRenderingContext} gl the current WebGL rendering context
|
|
30668
|
+
* @param {object[]} attributes an array of vertex attributes
|
|
30669
|
+
* @param {number} vertexByteSize the size of a single vertex in bytes
|
|
30670
|
+
*/
|
|
30671
|
+
setVertexAttributes(gl, attributes, vertexByteSize) {
|
|
30672
|
+
// set the vertex attributes
|
|
30673
|
+
for (var index = 0; index < attributes.length; ++index) {
|
|
30674
|
+
var element = attributes[index];
|
|
30675
|
+
var location = this.getAttribLocation(element.name);
|
|
30676
|
+
|
|
30677
|
+
if (location !== -1) {
|
|
30678
|
+
gl.enableVertexAttribArray(location);
|
|
30679
|
+
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexByteSize, element.offset);
|
|
30680
|
+
} else {
|
|
30681
|
+
gl.disableVertexAttribArray(index);
|
|
30682
|
+
}
|
|
30683
|
+
}
|
|
30684
|
+
}
|
|
30685
|
+
|
|
30172
30686
|
/**
|
|
30173
30687
|
* destroy this shader objects resources (program, attributes, uniforms)
|
|
30174
30688
|
* @name destroy
|
|
@@ -30703,20 +31217,7 @@ class WebGLCompositor {
|
|
|
30703
31217
|
this.activeShader = shader;
|
|
30704
31218
|
this.activeShader.bind();
|
|
30705
31219
|
this.activeShader.setUniform("uProjectionMatrix", this.renderer.projectionMatrix);
|
|
30706
|
-
|
|
30707
|
-
// set the vertex attributes
|
|
30708
|
-
for (var index = 0; index < this.attributes.length; ++index) {
|
|
30709
|
-
var gl = this.gl;
|
|
30710
|
-
var element = this.attributes[index];
|
|
30711
|
-
var location = this.activeShader.getAttribLocation(element.name);
|
|
30712
|
-
|
|
30713
|
-
if (location !== -1) {
|
|
30714
|
-
gl.enableVertexAttribArray(location);
|
|
30715
|
-
gl.vertexAttribPointer(location, element.size, element.type, element.normalized, this.vertexByteSize, element.offset);
|
|
30716
|
-
} else {
|
|
30717
|
-
gl.disableVertexAttribArray(index);
|
|
30718
|
-
}
|
|
30719
|
-
}
|
|
31220
|
+
this.activeShader.setVertexAttributes(this.gl, this.attributes, this.vertexByteSize);
|
|
30720
31221
|
}
|
|
30721
31222
|
}
|
|
30722
31223
|
|
|
@@ -30890,7 +31391,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30890
31391
|
/**
|
|
30891
31392
|
* The WebGL version used by this renderer (1 or 2)
|
|
30892
31393
|
* @name WebGLVersion
|
|
30893
|
-
* @memberof WebGLRenderer
|
|
31394
|
+
* @memberof WebGLRenderer#
|
|
30894
31395
|
* @type {number}
|
|
30895
31396
|
* @default 1
|
|
30896
31397
|
* @readonly
|
|
@@ -30900,7 +31401,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30900
31401
|
/**
|
|
30901
31402
|
* The vendor string of the underlying graphics driver.
|
|
30902
31403
|
* @name GPUVendor
|
|
30903
|
-
* @memberof WebGLRenderer
|
|
31404
|
+
* @memberof WebGLRenderer#
|
|
30904
31405
|
* @type {string}
|
|
30905
31406
|
* @default null
|
|
30906
31407
|
* @readonly
|
|
@@ -30910,7 +31411,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30910
31411
|
/**
|
|
30911
31412
|
* The renderer string of the underlying graphics driver.
|
|
30912
31413
|
* @name GPURenderer
|
|
30913
|
-
* @memberof WebGLRenderer
|
|
31414
|
+
* @memberof WebGLRenderer#
|
|
30914
31415
|
* @type {string}
|
|
30915
31416
|
* @default null
|
|
30916
31417
|
* @readonly
|
|
@@ -30920,7 +31421,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30920
31421
|
/**
|
|
30921
31422
|
* The WebGL context
|
|
30922
31423
|
* @name gl
|
|
30923
|
-
* @memberof WebGLRenderer
|
|
31424
|
+
* @memberof WebGLRenderer#
|
|
30924
31425
|
* type {WebGLRenderingContext}
|
|
30925
31426
|
*/
|
|
30926
31427
|
this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
|
|
@@ -30928,7 +31429,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30928
31429
|
/**
|
|
30929
31430
|
* Maximum number of texture unit supported under the current context
|
|
30930
31431
|
* @name maxTextures
|
|
30931
|
-
* @memberof WebGLRenderer
|
|
31432
|
+
* @memberof WebGLRenderer#
|
|
30932
31433
|
* @type {number}
|
|
30933
31434
|
* @readonly
|
|
30934
31435
|
*/
|
|
@@ -30954,16 +31455,6 @@ class WebGLRenderer extends Renderer {
|
|
|
30954
31455
|
*/
|
|
30955
31456
|
this._blendStack = [];
|
|
30956
31457
|
|
|
30957
|
-
/**
|
|
30958
|
-
* @ignore
|
|
30959
|
-
*/
|
|
30960
|
-
this._glPoints = [
|
|
30961
|
-
new Vector2d(),
|
|
30962
|
-
new Vector2d(),
|
|
30963
|
-
new Vector2d(),
|
|
30964
|
-
new Vector2d()
|
|
30965
|
-
];
|
|
30966
|
-
|
|
30967
31458
|
/**
|
|
30968
31459
|
* The current transformation matrix used for transformations on the overall scene
|
|
30969
31460
|
* @name currentTransform
|
|
@@ -30983,7 +31474,7 @@ class WebGLRenderer extends Renderer {
|
|
|
30983
31474
|
/**
|
|
30984
31475
|
* The list of active compositors
|
|
30985
31476
|
* @name compositors
|
|
30986
|
-
* @type {Map}
|
|
31477
|
+
* @type {Map<WebGLCompositor>}
|
|
30987
31478
|
* @memberof WebGLRenderer#
|
|
30988
31479
|
*/
|
|
30989
31480
|
this.compositors = new Map();
|
|
@@ -31197,10 +31688,10 @@ class WebGLRenderer extends Renderer {
|
|
|
31197
31688
|
if (color instanceof Color) {
|
|
31198
31689
|
glArray = color.toArray();
|
|
31199
31690
|
} else {
|
|
31200
|
-
var _color = pull("me.Color");
|
|
31691
|
+
var _color = pool$1.pull("me.Color");
|
|
31201
31692
|
// reuse temporary the renderer default color object
|
|
31202
31693
|
glArray = _color.parseCSS(color).toArray();
|
|
31203
|
-
push(_color);
|
|
31694
|
+
pool$1.push(_color);
|
|
31204
31695
|
}
|
|
31205
31696
|
// clear gl context with the specified color
|
|
31206
31697
|
this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
|
|
@@ -31492,8 +31983,8 @@ class WebGLRenderer extends Renderer {
|
|
|
31492
31983
|
this.setBlendMode(this._blendStack.pop());
|
|
31493
31984
|
|
|
31494
31985
|
// recycle objects
|
|
31495
|
-
push(color);
|
|
31496
|
-
push(matrix);
|
|
31986
|
+
pool$1.push(color);
|
|
31987
|
+
pool$1.push(matrix);
|
|
31497
31988
|
}
|
|
31498
31989
|
|
|
31499
31990
|
if (this._scissorStack.length !== 0) {
|
|
@@ -31570,6 +32061,17 @@ class WebGLRenderer extends Renderer {
|
|
|
31570
32061
|
this.currentColor.alpha = alpha;
|
|
31571
32062
|
}
|
|
31572
32063
|
|
|
32064
|
+
/**
|
|
32065
|
+
* Return the global alpha
|
|
32066
|
+
* @name getGlobalAlpha
|
|
32067
|
+
* @memberof WebGLRenderer.prototype
|
|
32068
|
+
* @function
|
|
32069
|
+
* @returns {number} global alpha value
|
|
32070
|
+
*/
|
|
32071
|
+
getGlobalAlpha() {
|
|
32072
|
+
return this.currentColor.alpha;
|
|
32073
|
+
}
|
|
32074
|
+
|
|
31573
32075
|
/**
|
|
31574
32076
|
* Set the current fill & stroke style color.
|
|
31575
32077
|
* By default, or upon reset, the value is set to #000000.
|
|
@@ -31608,34 +32110,18 @@ class WebGLRenderer extends Renderer {
|
|
|
31608
32110
|
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
31609
32111
|
* @param {boolean} [fill=false]
|
|
31610
32112
|
*/
|
|
31611
|
-
strokeArc(x, y, radius, start, end, antiClockwise = false, fill) {
|
|
31612
|
-
if (
|
|
31613
|
-
|
|
32113
|
+
strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
|
|
32114
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32115
|
+
// Fast path: don't draw fully transparent
|
|
32116
|
+
return;
|
|
32117
|
+
}
|
|
32118
|
+
this.path2D.beginPath();
|
|
32119
|
+
this.path2D.arc(x, y, radius, start, end, antiClockwise);
|
|
32120
|
+
if (fill === false) {
|
|
32121
|
+
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, this.path2D.points);
|
|
31614
32122
|
} else {
|
|
31615
|
-
|
|
31616
|
-
|
|
31617
|
-
var i, len = Math.floor(24 * Math.sqrt(radius * 2));
|
|
31618
|
-
var theta = (end - start) / (len * 2);
|
|
31619
|
-
var theta2 = theta * 2;
|
|
31620
|
-
var cos_theta = Math.cos(theta);
|
|
31621
|
-
var sin_theta = Math.sin(theta);
|
|
31622
|
-
|
|
31623
|
-
// Grow internal points buffer if necessary
|
|
31624
|
-
for (i = points.length; i < len + 1; i++) {
|
|
31625
|
-
points.push(new Vector2d());
|
|
31626
|
-
}
|
|
31627
|
-
|
|
31628
|
-
// calculate and draw all segments
|
|
31629
|
-
for (i = 0; i < len; i++) {
|
|
31630
|
-
var angle = ((theta) + start + (theta2 * i));
|
|
31631
|
-
var cos = Math.cos(angle);
|
|
31632
|
-
var sin = -Math.sin(angle);
|
|
31633
|
-
|
|
31634
|
-
points[i].x = x + (((cos_theta * cos) + (sin_theta * sin)) * radius);
|
|
31635
|
-
points[i].y = y + (((cos_theta * -sin) + (sin_theta * cos)) * radius);
|
|
31636
|
-
}
|
|
31637
|
-
// batch draw all lines
|
|
31638
|
-
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, points, len);
|
|
32123
|
+
this.path2D.closePath();
|
|
32124
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31639
32125
|
}
|
|
31640
32126
|
}
|
|
31641
32127
|
|
|
@@ -31651,35 +32137,8 @@ class WebGLRenderer extends Renderer {
|
|
|
31651
32137
|
* @param {number} end end angle in radians
|
|
31652
32138
|
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
31653
32139
|
*/
|
|
31654
|
-
fillArc(x, y, radius, start, end
|
|
31655
|
-
|
|
31656
|
-
var points = this._glPoints;
|
|
31657
|
-
var i, index = 0;
|
|
31658
|
-
var len = Math.floor(24 * Math.sqrt(radius * 2));
|
|
31659
|
-
var theta = (end - start) / (len * 2);
|
|
31660
|
-
var theta2 = theta * 2;
|
|
31661
|
-
var cos_theta = Math.cos(theta);
|
|
31662
|
-
var sin_theta = Math.sin(theta);
|
|
31663
|
-
|
|
31664
|
-
// Grow internal points buffer if necessary
|
|
31665
|
-
for (i = points.length; i < len * 2; i++) {
|
|
31666
|
-
points.push(new Vector2d());
|
|
31667
|
-
}
|
|
31668
|
-
|
|
31669
|
-
// calculate and draw all segments
|
|
31670
|
-
for (i = 0; i < len - 1; i++) {
|
|
31671
|
-
var angle = ((theta) + start + (theta2 * i));
|
|
31672
|
-
var cos = Math.cos(angle);
|
|
31673
|
-
var sin = -Math.sin(angle);
|
|
31674
|
-
|
|
31675
|
-
points[index++].set(x, y);
|
|
31676
|
-
points[index++].set(
|
|
31677
|
-
x - (((cos_theta * cos) + (sin_theta * sin)) * radius),
|
|
31678
|
-
y - (((cos_theta * -sin) + (sin_theta * cos)) * radius)
|
|
31679
|
-
);
|
|
31680
|
-
}
|
|
31681
|
-
// batch draw all triangles
|
|
31682
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLE_STRIP, points, index);
|
|
32140
|
+
fillArc(x, y, radius, start, end, antiClockwise = false) {
|
|
32141
|
+
this.strokeArc(x, y, radius, start, end, antiClockwise, true);
|
|
31683
32142
|
}
|
|
31684
32143
|
|
|
31685
32144
|
/**
|
|
@@ -31694,28 +32153,17 @@ class WebGLRenderer extends Renderer {
|
|
|
31694
32153
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31695
32154
|
*/
|
|
31696
32155
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
31697
|
-
if (
|
|
31698
|
-
|
|
32156
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32157
|
+
// Fast path: don't draw fully transparent
|
|
32158
|
+
return;
|
|
32159
|
+
}
|
|
32160
|
+
this.path2D.beginPath();
|
|
32161
|
+
this.path2D.ellipse(x, y, w, h, 0, 0, 360);
|
|
32162
|
+
this.path2D.closePath();
|
|
32163
|
+
if (fill === false) {
|
|
32164
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31699
32165
|
} else {
|
|
31700
|
-
|
|
31701
|
-
var len = Math.floor(24 * Math.sqrt(w)) ||
|
|
31702
|
-
Math.floor(12 * Math.sqrt(w + h));
|
|
31703
|
-
var segment = (TAU) / len;
|
|
31704
|
-
var points = this._glPoints,
|
|
31705
|
-
i;
|
|
31706
|
-
|
|
31707
|
-
// Grow internal points buffer if necessary
|
|
31708
|
-
for (i = points.length; i < len; i++) {
|
|
31709
|
-
points.push(new Vector2d());
|
|
31710
|
-
}
|
|
31711
|
-
|
|
31712
|
-
// calculate and draw all segments
|
|
31713
|
-
for (i = 0; i < len; i++) {
|
|
31714
|
-
points[i].x = x + (Math.sin(segment * -i) * w);
|
|
31715
|
-
points[i].y = y + (Math.cos(segment * -i) * h);
|
|
31716
|
-
}
|
|
31717
|
-
// batch draw all lines
|
|
31718
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, len);
|
|
32166
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31719
32167
|
}
|
|
31720
32168
|
}
|
|
31721
32169
|
|
|
@@ -31730,28 +32178,7 @@ class WebGLRenderer extends Renderer {
|
|
|
31730
32178
|
* @param {number} h vertical radius of the ellipse
|
|
31731
32179
|
*/
|
|
31732
32180
|
fillEllipse(x, y, w, h) {
|
|
31733
|
-
|
|
31734
|
-
var len = Math.floor(24 * Math.sqrt(w)) ||
|
|
31735
|
-
Math.floor(12 * Math.sqrt(w + h));
|
|
31736
|
-
var segment = (TAU) / len;
|
|
31737
|
-
var points = this._glPoints;
|
|
31738
|
-
var index = 0, i;
|
|
31739
|
-
|
|
31740
|
-
// Grow internal points buffer if necessary
|
|
31741
|
-
for (i = points.length; i < (len + 1) * 2; i++) {
|
|
31742
|
-
points.push(new Vector2d());
|
|
31743
|
-
}
|
|
31744
|
-
|
|
31745
|
-
// draw all vertices vertex coordinates
|
|
31746
|
-
for (i = 0; i < len + 1; i++) {
|
|
31747
|
-
points[index++].set(x, y);
|
|
31748
|
-
points[index++].set(
|
|
31749
|
-
x + (Math.sin(segment * i) * w),
|
|
31750
|
-
y + (Math.cos(segment * i) * h)
|
|
31751
|
-
);
|
|
31752
|
-
}
|
|
31753
|
-
// batch draw all triangles
|
|
31754
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLE_STRIP, points, index);
|
|
32181
|
+
this.strokeEllipse(x, y, w, h, false);
|
|
31755
32182
|
}
|
|
31756
32183
|
|
|
31757
32184
|
/**
|
|
@@ -31765,12 +32192,14 @@ class WebGLRenderer extends Renderer {
|
|
|
31765
32192
|
* @param {number} endY the end y coordinate
|
|
31766
32193
|
*/
|
|
31767
32194
|
strokeLine(startX, startY, endX, endY) {
|
|
31768
|
-
|
|
31769
|
-
|
|
31770
|
-
|
|
31771
|
-
|
|
31772
|
-
|
|
31773
|
-
this.
|
|
32195
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32196
|
+
// Fast path: don't draw fully transparent
|
|
32197
|
+
return;
|
|
32198
|
+
}
|
|
32199
|
+
this.path2D.beginPath();
|
|
32200
|
+
this.path2D.moveTo(startX, startY);
|
|
32201
|
+
this.path2D.lineTo(endX, endY);
|
|
32202
|
+
this.currentCompositor.drawVertices(this.gl.LINE_STRIP, this.path2D.points);
|
|
31774
32203
|
}
|
|
31775
32204
|
|
|
31776
32205
|
|
|
@@ -31797,25 +32226,27 @@ class WebGLRenderer extends Renderer {
|
|
|
31797
32226
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31798
32227
|
*/
|
|
31799
32228
|
strokePolygon(poly, fill = false) {
|
|
31800
|
-
if (
|
|
31801
|
-
|
|
32229
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32230
|
+
// Fast path: don't draw fully transparent
|
|
32231
|
+
return;
|
|
32232
|
+
}
|
|
32233
|
+
this.translate(poly.pos.x, poly.pos.y);
|
|
32234
|
+
this.path2D.beginPath();
|
|
32235
|
+
this.path2D.moveTo(poly.points[0].x, poly.points[0].y);
|
|
32236
|
+
var point;
|
|
32237
|
+
for (var i = 1; i < poly.points.length; i++) {
|
|
32238
|
+
point = poly.points[i];
|
|
32239
|
+
this.path2D.lineTo(point.x, point.y);
|
|
32240
|
+
}
|
|
32241
|
+
this.path2D.lineTo(poly.points[0].x, poly.points[0].y);
|
|
32242
|
+
this.path2D.closePath();
|
|
32243
|
+
if (fill === false) {
|
|
32244
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31802
32245
|
} else {
|
|
31803
|
-
|
|
31804
|
-
|
|
31805
|
-
i;
|
|
31806
|
-
|
|
31807
|
-
// Grow internal points buffer if necessary
|
|
31808
|
-
for (i = points.length; i < len; i++) {
|
|
31809
|
-
points.push(new Vector2d());
|
|
31810
|
-
}
|
|
31811
|
-
|
|
31812
|
-
// calculate and draw all segments
|
|
31813
|
-
for (i = 0; i < len; i++) {
|
|
31814
|
-
points[i].x = poly.pos.x + poly.points[i].x;
|
|
31815
|
-
points[i].y = poly.pos.y + poly.points[i].y;
|
|
31816
|
-
}
|
|
31817
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, len);
|
|
32246
|
+
// draw all triangles
|
|
32247
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31818
32248
|
}
|
|
32249
|
+
this.translate(-poly.pos.x, -poly.pos.y);
|
|
31819
32250
|
}
|
|
31820
32251
|
|
|
31821
32252
|
/**
|
|
@@ -31826,24 +32257,7 @@ class WebGLRenderer extends Renderer {
|
|
|
31826
32257
|
* @param {Polygon} poly the shape to draw
|
|
31827
32258
|
*/
|
|
31828
32259
|
fillPolygon(poly) {
|
|
31829
|
-
|
|
31830
|
-
var glPoints = this._glPoints;
|
|
31831
|
-
var indices = poly.getIndices();
|
|
31832
|
-
var x = poly.pos.x, y = poly.pos.y;
|
|
31833
|
-
var i;
|
|
31834
|
-
|
|
31835
|
-
// Grow internal points buffer if necessary
|
|
31836
|
-
for (i = glPoints.length; i < indices.length; i++) {
|
|
31837
|
-
glPoints.push(new Vector2d());
|
|
31838
|
-
}
|
|
31839
|
-
|
|
31840
|
-
// calculate all vertices
|
|
31841
|
-
for (i = 0; i < indices.length; i++ ) {
|
|
31842
|
-
glPoints[i].set(x + points[indices[i]].x, y + points[indices[i]].y);
|
|
31843
|
-
}
|
|
31844
|
-
|
|
31845
|
-
// draw all triangle
|
|
31846
|
-
this.currentCompositor.drawVertices(this.gl.TRIANGLES, glPoints, indices.length);
|
|
32260
|
+
this.strokePolygon(poly, true);
|
|
31847
32261
|
}
|
|
31848
32262
|
|
|
31849
32263
|
/**
|
|
@@ -31858,19 +32272,16 @@ class WebGLRenderer extends Renderer {
|
|
|
31858
32272
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31859
32273
|
*/
|
|
31860
32274
|
strokeRect(x, y, width, height, fill = false) {
|
|
31861
|
-
if (
|
|
31862
|
-
|
|
32275
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32276
|
+
// Fast path: don't draw fully transparent
|
|
32277
|
+
return;
|
|
32278
|
+
}
|
|
32279
|
+
this.path2D.beginPath();
|
|
32280
|
+
this.path2D.rect(x, y, width, height);
|
|
32281
|
+
if (fill === false) {
|
|
32282
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
31863
32283
|
} else {
|
|
31864
|
-
|
|
31865
|
-
points[0].x = x;
|
|
31866
|
-
points[0].y = y;
|
|
31867
|
-
points[1].x = x + width;
|
|
31868
|
-
points[1].y = y;
|
|
31869
|
-
points[2].x = x + width;
|
|
31870
|
-
points[2].y = y + height;
|
|
31871
|
-
points[3].x = x;
|
|
31872
|
-
points[3].y = y + height;
|
|
31873
|
-
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, points, 4);
|
|
32284
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
31874
32285
|
}
|
|
31875
32286
|
}
|
|
31876
32287
|
|
|
@@ -31885,16 +32296,49 @@ class WebGLRenderer extends Renderer {
|
|
|
31885
32296
|
* @param {number} height
|
|
31886
32297
|
*/
|
|
31887
32298
|
fillRect(x, y, width, height) {
|
|
31888
|
-
|
|
31889
|
-
|
|
31890
|
-
|
|
31891
|
-
|
|
31892
|
-
|
|
31893
|
-
|
|
31894
|
-
|
|
31895
|
-
|
|
31896
|
-
|
|
31897
|
-
|
|
32299
|
+
this.strokeRect(x, y, width, height, true);
|
|
32300
|
+
}
|
|
32301
|
+
|
|
32302
|
+
/**
|
|
32303
|
+
* Stroke a rounded rectangle at the specified coordinates
|
|
32304
|
+
* @name strokeRoundRect
|
|
32305
|
+
* @memberof WebGLRenderer.prototype
|
|
32306
|
+
* @function
|
|
32307
|
+
* @param {number} x
|
|
32308
|
+
* @param {number} y
|
|
32309
|
+
* @param {number} width
|
|
32310
|
+
* @param {number} height
|
|
32311
|
+
* @param {number} radius
|
|
32312
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
32313
|
+
*/
|
|
32314
|
+
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
32315
|
+
if (this.getGlobalAlpha() < 1 / 255) {
|
|
32316
|
+
// Fast path: don't draw fully transparent
|
|
32317
|
+
return;
|
|
32318
|
+
}
|
|
32319
|
+
this.path2D.beginPath();
|
|
32320
|
+
this.path2D.roundRect(x, y, width, height, radius);
|
|
32321
|
+
if (fill === false) {
|
|
32322
|
+
this.currentCompositor.drawVertices(this.gl.LINE_LOOP, this.path2D.points);
|
|
32323
|
+
} else {
|
|
32324
|
+
this.path2D.closePath();
|
|
32325
|
+
this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
|
|
32326
|
+
}
|
|
32327
|
+
}
|
|
32328
|
+
|
|
32329
|
+
/**
|
|
32330
|
+
* Draw a rounded filled rectangle at the specified coordinates
|
|
32331
|
+
* @name fillRoundRect
|
|
32332
|
+
* @memberof WebGLRenderer.prototype
|
|
32333
|
+
* @function
|
|
32334
|
+
* @param {number} x
|
|
32335
|
+
* @param {number} y
|
|
32336
|
+
* @param {number} width
|
|
32337
|
+
* @param {number} height
|
|
32338
|
+
* @param {number} radius
|
|
32339
|
+
*/
|
|
32340
|
+
fillRoundRect(x, y, width, height, radius) {
|
|
32341
|
+
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
31898
32342
|
}
|
|
31899
32343
|
|
|
31900
32344
|
/**
|
|
@@ -32979,10 +33423,10 @@ class BasePlugin {
|
|
|
32979
33423
|
* this can be overridden by the plugin
|
|
32980
33424
|
* @public
|
|
32981
33425
|
* @type {string}
|
|
32982
|
-
* @default "10.
|
|
33426
|
+
* @default "10.8.0"
|
|
32983
33427
|
* @name plugin.Base#version
|
|
32984
33428
|
*/
|
|
32985
|
-
this.version = "10.
|
|
33429
|
+
this.version = "10.8.0";
|
|
32986
33430
|
}
|
|
32987
33431
|
}
|
|
32988
33432
|
|
|
@@ -34246,10 +34690,10 @@ class Text extends Renderable {
|
|
|
34246
34690
|
this.fillStyle = settings.fillStyle;
|
|
34247
34691
|
} else {
|
|
34248
34692
|
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34249
|
-
this.fillStyle = pull("Color").parseCSS(settings.fillStyle);
|
|
34693
|
+
this.fillStyle = pool$1.pull("Color").parseCSS(settings.fillStyle);
|
|
34250
34694
|
}
|
|
34251
34695
|
} else {
|
|
34252
|
-
this.fillStyle = pull("Color", 0, 0, 0);
|
|
34696
|
+
this.fillStyle = pool$1.pull("Color", 0, 0, 0);
|
|
34253
34697
|
}
|
|
34254
34698
|
|
|
34255
34699
|
/**
|
|
@@ -34263,10 +34707,10 @@ class Text extends Renderable {
|
|
|
34263
34707
|
this.strokeStyle = settings.strokeStyle;
|
|
34264
34708
|
} else {
|
|
34265
34709
|
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34266
|
-
this.strokeStyle = pull("Color").parseCSS(settings.strokeStyle);
|
|
34710
|
+
this.strokeStyle = pool$1.pull("Color").parseCSS(settings.strokeStyle);
|
|
34267
34711
|
}
|
|
34268
34712
|
} else {
|
|
34269
|
-
this.strokeStyle = pull("Color", 0, 0, 0);
|
|
34713
|
+
this.strokeStyle = pool$1.pull("Color", 0, 0, 0);
|
|
34270
34714
|
}
|
|
34271
34715
|
|
|
34272
34716
|
/**
|
|
@@ -34608,8 +35052,8 @@ class Text extends Renderable {
|
|
|
34608
35052
|
* @ignore
|
|
34609
35053
|
*/
|
|
34610
35054
|
destroy() {
|
|
34611
|
-
push(this.fillStyle);
|
|
34612
|
-
push(this.strokeStyle);
|
|
35055
|
+
pool$1.push(this.fillStyle);
|
|
35056
|
+
pool$1.push(this.strokeStyle);
|
|
34613
35057
|
this.fillStyle = this.strokeStyle = undefined;
|
|
34614
35058
|
this.metrics = undefined;
|
|
34615
35059
|
this._text.length = 0;
|
|
@@ -34702,7 +35146,7 @@ class BitmapText extends Renderable {
|
|
|
34702
35146
|
* scaled font size
|
|
34703
35147
|
* @private
|
|
34704
35148
|
*/
|
|
34705
|
-
this.fontScale = pull("Vector2d", 1.0, 1.0);
|
|
35149
|
+
this.fontScale = pool$1.pull("Vector2d", 1.0, 1.0);
|
|
34706
35150
|
|
|
34707
35151
|
/**
|
|
34708
35152
|
* font image
|
|
@@ -34716,9 +35160,9 @@ class BitmapText extends Renderable {
|
|
|
34716
35160
|
* @private
|
|
34717
35161
|
*/
|
|
34718
35162
|
// use settings.font to retreive the data from the loader
|
|
34719
|
-
this.fontData = pull("BitmapTextData", loader.getBinary(settings.font));
|
|
35163
|
+
this.fontData = pool$1.pull("BitmapTextData", loader.getBinary(settings.font));
|
|
34720
35164
|
} else {
|
|
34721
|
-
this.fontData = pull("BitmapTextData",
|
|
35165
|
+
this.fontData = pool$1.pull("BitmapTextData",
|
|
34722
35166
|
// if starting/includes "info face" the whole data string was passed as parameter
|
|
34723
35167
|
(settings.fontData.includes("info face")) ? settings.fontData : loader.getBinary(settings.fontData)
|
|
34724
35168
|
);
|
|
@@ -34947,9 +35391,9 @@ class BitmapText extends Renderable {
|
|
|
34947
35391
|
* @ignore
|
|
34948
35392
|
*/
|
|
34949
35393
|
destroy() {
|
|
34950
|
-
push(this.fontScale);
|
|
35394
|
+
pool$1.push(this.fontScale);
|
|
34951
35395
|
this.fontScale = undefined;
|
|
34952
|
-
push(this.fontData);
|
|
35396
|
+
pool$1.push(this.fontData);
|
|
34953
35397
|
this.fontData = undefined;
|
|
34954
35398
|
this._text.length = 0;
|
|
34955
35399
|
this.metrics = undefined;
|
|
@@ -35227,7 +35671,7 @@ class ColorLayer extends Renderable {
|
|
|
35227
35671
|
* @name color
|
|
35228
35672
|
* @memberof ColorLayer#
|
|
35229
35673
|
*/
|
|
35230
|
-
this.color = pull("Color").parseCSS(color);
|
|
35674
|
+
this.color = pool$1.pull("Color").parseCSS(color);
|
|
35231
35675
|
|
|
35232
35676
|
this.onResetEvent(name, color, z);
|
|
35233
35677
|
|
|
@@ -35262,7 +35706,7 @@ class ColorLayer extends Renderable {
|
|
|
35262
35706
|
* @ignore
|
|
35263
35707
|
*/
|
|
35264
35708
|
destroy() {
|
|
35265
|
-
push(this.color);
|
|
35709
|
+
pool$1.push(this.color);
|
|
35266
35710
|
this.color = undefined;
|
|
35267
35711
|
super.destroy();
|
|
35268
35712
|
}
|
|
@@ -35314,7 +35758,7 @@ class ImageLayer extends Sprite {
|
|
|
35314
35758
|
* @default <1.0,1.0>
|
|
35315
35759
|
* @name ImageLayer#ratio
|
|
35316
35760
|
*/
|
|
35317
|
-
this.ratio = pull("Vector2d", 1.0, 1.0);
|
|
35761
|
+
this.ratio = pool$1.pull("Vector2d", 1.0, 1.0);
|
|
35318
35762
|
|
|
35319
35763
|
if (typeof(settings.ratio) !== "undefined") {
|
|
35320
35764
|
// little hack for backward compatiblity
|
|
@@ -35555,7 +35999,7 @@ class ImageLayer extends Sprite {
|
|
|
35555
35999
|
* @ignore
|
|
35556
36000
|
*/
|
|
35557
36001
|
destroy() {
|
|
35558
|
-
push(this.ratio);
|
|
36002
|
+
pool$1.push(this.ratio);
|
|
35559
36003
|
this.ratio = undefined;
|
|
35560
36004
|
off(ONCONTEXT_RESTORED, this.createPattern);
|
|
35561
36005
|
super.destroy();
|
|
@@ -36035,7 +36479,15 @@ class Collectable extends Sprite {
|
|
|
36035
36479
|
this.id = settings.id;
|
|
36036
36480
|
|
|
36037
36481
|
// add and configure the physic body
|
|
36038
|
-
|
|
36482
|
+
var shape = settings.shapes;
|
|
36483
|
+
if (typeof shape === "undefined") {
|
|
36484
|
+
shape = pool.pull("Polygon", 0, 0, [
|
|
36485
|
+
pool.pull("Vector2d", 0, 0),
|
|
36486
|
+
pool.pull("Vector2d", this.width, 0),
|
|
36487
|
+
pool.pull("Vector2d", this.width, this.height)
|
|
36488
|
+
]);
|
|
36489
|
+
}
|
|
36490
|
+
this.body = new Body(this, shape);
|
|
36039
36491
|
this.body.collisionType = collision.types.COLLECTABLE_OBJECT;
|
|
36040
36492
|
// by default only collides with PLAYER_OBJECT
|
|
36041
36493
|
this.body.setCollisionMask(collision.types.PLAYER_OBJECT);
|
|
@@ -36114,9 +36566,16 @@ class Trigger extends Renderable {
|
|
|
36114
36566
|
}
|
|
36115
36567
|
}.bind(this));
|
|
36116
36568
|
|
|
36117
|
-
|
|
36118
|
-
|
|
36119
|
-
|
|
36569
|
+
// add and configure the physic body
|
|
36570
|
+
var shape = settings.shapes;
|
|
36571
|
+
if (typeof shape === "undefined") {
|
|
36572
|
+
shape = pool.pull("Polygon", 0, 0, [
|
|
36573
|
+
pool.pull("Vector2d", 0, 0),
|
|
36574
|
+
pool.pull("Vector2d", this.width, 0),
|
|
36575
|
+
pool.pull("Vector2d", this.width, this.height)
|
|
36576
|
+
]);
|
|
36577
|
+
}
|
|
36578
|
+
this.body = new Body(this, shape);
|
|
36120
36579
|
this.body.collisionType = collision.types.ACTION_OBJECT;
|
|
36121
36580
|
// by default only collides with PLAYER_OBJECT
|
|
36122
36581
|
this.body.setCollisionMask(collision.types.PLAYER_OBJECT);
|
|
@@ -36735,14 +37194,17 @@ class ParticleEmitter extends Container {
|
|
|
36735
37194
|
* @param {number} y y position of the particle emitter
|
|
36736
37195
|
* @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
|
|
36737
37196
|
* @example
|
|
36738
|
-
* // Create a
|
|
36739
|
-
* var emitter = new ParticleEmitter(100, 100
|
|
36740
|
-
*
|
|
36741
|
-
*
|
|
36742
|
-
*
|
|
36743
|
-
*
|
|
36744
|
-
*
|
|
36745
|
-
*
|
|
37197
|
+
* // Create a particle emitter at position 100, 100
|
|
37198
|
+
* var emitter = new ParticleEmitter(100, 100, {
|
|
37199
|
+
* width: 16,
|
|
37200
|
+
* height : 16,
|
|
37201
|
+
* tint: "#f00",
|
|
37202
|
+
* totalParticles: 32,
|
|
37203
|
+
* angle: 0,
|
|
37204
|
+
* angleVariation: 6.283185307179586,
|
|
37205
|
+
* maxLife: 5,
|
|
37206
|
+
* speed: 3
|
|
37207
|
+
* });
|
|
36746
37208
|
*
|
|
36747
37209
|
* // Add the emitter to the game world
|
|
36748
37210
|
* me.game.world.addChild(emitter);
|
|
@@ -36765,6 +37227,15 @@ class ParticleEmitter extends Container {
|
|
|
36765
37227
|
settings.height | 1
|
|
36766
37228
|
);
|
|
36767
37229
|
|
|
37230
|
+
/**
|
|
37231
|
+
* the current (active) emitter settings
|
|
37232
|
+
* @public
|
|
37233
|
+
* @type {ParticleEmitterSettings}
|
|
37234
|
+
* @name settings
|
|
37235
|
+
* @memberof ParticleEmitter
|
|
37236
|
+
*/
|
|
37237
|
+
this.settings = {};
|
|
37238
|
+
|
|
36768
37239
|
// center the emitter around the given coordinates
|
|
36769
37240
|
this.centerOn(x, y);
|
|
36770
37241
|
|
|
@@ -36795,9 +37266,6 @@ class ParticleEmitter extends Container {
|
|
|
36795
37266
|
// count the updates
|
|
36796
37267
|
this._updateCount = 0;
|
|
36797
37268
|
|
|
36798
|
-
// the emitter settings
|
|
36799
|
-
this.settings = {};
|
|
36800
|
-
|
|
36801
37269
|
// internally store how much time was skipped when frames are skipped
|
|
36802
37270
|
this._dt = 0;
|
|
36803
37271
|
|
|
@@ -36809,7 +37277,7 @@ class ParticleEmitter extends Container {
|
|
|
36809
37277
|
|
|
36810
37278
|
/**
|
|
36811
37279
|
* Reset the emitter with particle emitter settings.
|
|
36812
|
-
* @param {
|
|
37280
|
+
* @param {ParticleEmitterSettings} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
|
|
36813
37281
|
*/
|
|
36814
37282
|
reset(settings = {}) {
|
|
36815
37283
|
Object.assign(this.settings, ParticleEmitterSettings, settings);
|
|
@@ -36843,9 +37311,9 @@ class ParticleEmitter extends Container {
|
|
|
36843
37311
|
// Add count particles in the game world
|
|
36844
37312
|
/** @ignore */
|
|
36845
37313
|
addParticles(count) {
|
|
36846
|
-
for (var i = 0; i <
|
|
37314
|
+
for (var i = 0; i < count; i++) {
|
|
36847
37315
|
// Add particle to the container
|
|
36848
|
-
this.addChild(pull("Particle", this), this.pos.z);
|
|
37316
|
+
this.addChild(pool$1.pull("Particle", this), this.pos.z);
|
|
36849
37317
|
}
|
|
36850
37318
|
this.isDirty = true;
|
|
36851
37319
|
}
|
|
@@ -36984,9 +37452,10 @@ class Particle extends Renderable {
|
|
|
36984
37452
|
emitter.settings.image.width,
|
|
36985
37453
|
emitter.settings.image.height
|
|
36986
37454
|
);
|
|
37455
|
+
this.currentTransform.identity();
|
|
36987
37456
|
} else {
|
|
36988
37457
|
// particle velocity
|
|
36989
|
-
this.vel =
|
|
37458
|
+
this.vel = pool$1.pull("Vector2d");
|
|
36990
37459
|
}
|
|
36991
37460
|
|
|
36992
37461
|
this.image = emitter.settings.image;
|
|
@@ -37220,11 +37689,11 @@ class Entity extends Renderable {
|
|
|
37220
37689
|
*/
|
|
37221
37690
|
// initialize the default body
|
|
37222
37691
|
if (typeof settings.shapes === "undefined") {
|
|
37223
|
-
settings.shapes =
|
|
37224
|
-
|
|
37225
|
-
|
|
37226
|
-
|
|
37227
|
-
|
|
37692
|
+
settings.shapes = pool$1.pull("Polygon", 0, 0, [
|
|
37693
|
+
pool$1.pull("Vector2d", 0, 0),
|
|
37694
|
+
pool$1.pull("Vector2d", this.width, 0),
|
|
37695
|
+
pool$1.pull("Vector2d", this.width, this.height),
|
|
37696
|
+
pool$1.pull("Vector2d", 0, this.height)
|
|
37228
37697
|
]);
|
|
37229
37698
|
}
|
|
37230
37699
|
this.body = new Body(this, settings.shapes, this.onBodyUpdate.bind(this));
|
|
@@ -37431,7 +37900,7 @@ device$1.turnOffPointerLock = function () {
|
|
|
37431
37900
|
/**
|
|
37432
37901
|
* @public
|
|
37433
37902
|
* @name Texture
|
|
37434
|
-
* @memberof Renderer
|
|
37903
|
+
* @memberof Renderer#
|
|
37435
37904
|
* @deprecated since 10.4.0
|
|
37436
37905
|
* @see TextureAtlas
|
|
37437
37906
|
*/
|
|
@@ -37494,7 +37963,7 @@ class DroptargetEntity extends DropTarget {
|
|
|
37494
37963
|
* @name version
|
|
37495
37964
|
* @type {string}
|
|
37496
37965
|
*/
|
|
37497
|
-
const version = "10.
|
|
37966
|
+
const version = "10.8.0";
|
|
37498
37967
|
|
|
37499
37968
|
|
|
37500
37969
|
/**
|
|
@@ -37529,58 +37998,60 @@ function boot() {
|
|
|
37529
37998
|
}
|
|
37530
37999
|
|
|
37531
38000
|
// register all built-ins objects into the object pool
|
|
37532
|
-
register("me.Entity", Entity);
|
|
37533
|
-
register("me.Collectable", Collectable);
|
|
37534
|
-
register("me.Trigger", Trigger);
|
|
37535
|
-
register("me.Tween", Tween, true);
|
|
37536
|
-
register("me.Color", Color, true);
|
|
37537
|
-
register("me.Particle", Particle, true);
|
|
37538
|
-
register("me.Sprite", Sprite);
|
|
37539
|
-
register("me.NineSliceSprite", NineSliceSprite);
|
|
37540
|
-
register("me.Renderable", Renderable);
|
|
37541
|
-
register("me.Text", Text, true);
|
|
37542
|
-
register("me.BitmapText", BitmapText);
|
|
37543
|
-
register("me.BitmapTextData", BitmapTextData, true);
|
|
37544
|
-
register("me.ImageLayer", ImageLayer);
|
|
37545
|
-
register("me.ColorLayer", ColorLayer, true);
|
|
37546
|
-
register("me.Vector2d", Vector2d, true);
|
|
37547
|
-
register("me.Vector3d", Vector3d, true);
|
|
37548
|
-
register("me.ObservableVector2d", ObservableVector2d, true);
|
|
37549
|
-
register("me.ObservableVector3d", ObservableVector3d, true);
|
|
37550
|
-
register("me.Matrix2d", Matrix2d, true);
|
|
37551
|
-
register("me.Matrix3d", Matrix3d, true);
|
|
37552
|
-
register("me.Rect", Rect, true);
|
|
37553
|
-
register("me.
|
|
37554
|
-
register("me.
|
|
37555
|
-
register("me.
|
|
37556
|
-
register("me.
|
|
38001
|
+
pool$1.register("me.Entity", Entity);
|
|
38002
|
+
pool$1.register("me.Collectable", Collectable);
|
|
38003
|
+
pool$1.register("me.Trigger", Trigger);
|
|
38004
|
+
pool$1.register("me.Tween", Tween, true);
|
|
38005
|
+
pool$1.register("me.Color", Color, true);
|
|
38006
|
+
pool$1.register("me.Particle", Particle, true);
|
|
38007
|
+
pool$1.register("me.Sprite", Sprite);
|
|
38008
|
+
pool$1.register("me.NineSliceSprite", NineSliceSprite);
|
|
38009
|
+
pool$1.register("me.Renderable", Renderable);
|
|
38010
|
+
pool$1.register("me.Text", Text, true);
|
|
38011
|
+
pool$1.register("me.BitmapText", BitmapText);
|
|
38012
|
+
pool$1.register("me.BitmapTextData", BitmapTextData, true);
|
|
38013
|
+
pool$1.register("me.ImageLayer", ImageLayer);
|
|
38014
|
+
pool$1.register("me.ColorLayer", ColorLayer, true);
|
|
38015
|
+
pool$1.register("me.Vector2d", Vector2d, true);
|
|
38016
|
+
pool$1.register("me.Vector3d", Vector3d, true);
|
|
38017
|
+
pool$1.register("me.ObservableVector2d", ObservableVector2d, true);
|
|
38018
|
+
pool$1.register("me.ObservableVector3d", ObservableVector3d, true);
|
|
38019
|
+
pool$1.register("me.Matrix2d", Matrix2d, true);
|
|
38020
|
+
pool$1.register("me.Matrix3d", Matrix3d, true);
|
|
38021
|
+
pool$1.register("me.Rect", Rect, true);
|
|
38022
|
+
pool$1.register("me.RoundRect", RoundRect, true);
|
|
38023
|
+
pool$1.register("me.Polygon", Polygon, true);
|
|
38024
|
+
pool$1.register("me.Line", Line, true);
|
|
38025
|
+
pool$1.register("me.Ellipse", Ellipse, true);
|
|
38026
|
+
pool$1.register("me.Bounds", Bounds$1, true);
|
|
37557
38027
|
|
|
37558
38028
|
// duplicate all entries if use with no namespace (e.g. es6)
|
|
37559
|
-
register("Entity", Entity);
|
|
37560
|
-
register("Collectable", Collectable);
|
|
37561
|
-
register("Trigger", Trigger);
|
|
37562
|
-
register("Tween", Tween, true);
|
|
37563
|
-
register("Color", Color, true);
|
|
37564
|
-
register("Particle", Particle, true);
|
|
37565
|
-
register("Sprite", Sprite);
|
|
37566
|
-
register("NineSliceSprite", NineSliceSprite);
|
|
37567
|
-
register("Renderable", Renderable);
|
|
37568
|
-
register("Text", Text, true);
|
|
37569
|
-
register("BitmapText", BitmapText);
|
|
37570
|
-
register("BitmapTextData", BitmapTextData, true);
|
|
37571
|
-
register("ImageLayer", ImageLayer);
|
|
37572
|
-
register("ColorLayer", ColorLayer, true);
|
|
37573
|
-
register("Vector2d", Vector2d, true);
|
|
37574
|
-
register("Vector3d", Vector3d, true);
|
|
37575
|
-
register("ObservableVector2d", ObservableVector2d, true);
|
|
37576
|
-
register("ObservableVector3d", ObservableVector3d, true);
|
|
37577
|
-
register("Matrix2d", Matrix2d, true);
|
|
37578
|
-
register("Matrix3d", Matrix3d, true);
|
|
37579
|
-
register("Rect", Rect, true);
|
|
37580
|
-
register("
|
|
37581
|
-
register("
|
|
37582
|
-
register("
|
|
37583
|
-
register("
|
|
38029
|
+
pool$1.register("Entity", Entity);
|
|
38030
|
+
pool$1.register("Collectable", Collectable);
|
|
38031
|
+
pool$1.register("Trigger", Trigger);
|
|
38032
|
+
pool$1.register("Tween", Tween, true);
|
|
38033
|
+
pool$1.register("Color", Color, true);
|
|
38034
|
+
pool$1.register("Particle", Particle, true);
|
|
38035
|
+
pool$1.register("Sprite", Sprite);
|
|
38036
|
+
pool$1.register("NineSliceSprite", NineSliceSprite);
|
|
38037
|
+
pool$1.register("Renderable", Renderable);
|
|
38038
|
+
pool$1.register("Text", Text, true);
|
|
38039
|
+
pool$1.register("BitmapText", BitmapText);
|
|
38040
|
+
pool$1.register("BitmapTextData", BitmapTextData, true);
|
|
38041
|
+
pool$1.register("ImageLayer", ImageLayer);
|
|
38042
|
+
pool$1.register("ColorLayer", ColorLayer, true);
|
|
38043
|
+
pool$1.register("Vector2d", Vector2d, true);
|
|
38044
|
+
pool$1.register("Vector3d", Vector3d, true);
|
|
38045
|
+
pool$1.register("ObservableVector2d", ObservableVector2d, true);
|
|
38046
|
+
pool$1.register("ObservableVector3d", ObservableVector3d, true);
|
|
38047
|
+
pool$1.register("Matrix2d", Matrix2d, true);
|
|
38048
|
+
pool$1.register("Matrix3d", Matrix3d, true);
|
|
38049
|
+
pool$1.register("Rect", Rect, true);
|
|
38050
|
+
pool$1.register("RoundRect", RoundRect, true);
|
|
38051
|
+
pool$1.register("Polygon", Polygon, true);
|
|
38052
|
+
pool$1.register("Line", Line, true);
|
|
38053
|
+
pool$1.register("Ellipse", Ellipse, true);
|
|
38054
|
+
pool$1.register("Bounds", Bounds$1, true);
|
|
37584
38055
|
|
|
37585
38056
|
// publish Boot notification
|
|
37586
38057
|
emit(BOOT);
|
|
@@ -37601,4 +38072,4 @@ device$1.onReady(function () {
|
|
|
37601
38072
|
}
|
|
37602
38073
|
});
|
|
37603
38074
|
|
|
37604
|
-
export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device$1 as device, event$1 as event, game, initialized, input, level, loader, plugin, plugins,
|
|
38075
|
+
export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device$1 as device, event$1 as event, game, initialized, input, level, loader, plugin, plugins, pool$1 as pool, save, skipAutoInit, state, timer$1 as timer, utils, version, video, warning };
|